Re: [PATCH v4 2/2] drivers: soc: Add LLCC driver

2018-04-16 Thread rishabhb

On 2018-04-16 10:14, Evan Green wrote:

On Fri, Apr 13, 2018 at 4:08 PM  wrote:


On 2018-04-12 15:02, Evan Green wrote:
> Hi Rishabh,
>
> On Tue, Apr 10, 2018 at 1:09 PM Rishabh Bhatnagar
> 
> wrote:
>
>> LLCC (Last Level Cache Controller) provides additional cache memory
>> in the system. LLCC is partitioned into multiple slices and each
>> slice gets its own priority, size, ID and other config parameters.
>> LLCC driver programs these parameters for each slice. Clients that
>> are assigned to use LLCC need to get information such size & ID of the
>> slice they get and activate or deactivate the slice as needed. LLCC
>> driver
>> provides API for the clients to perform these operations.
>
>> Signed-off-by: Channagoud Kadabi 
>> Signed-off-by: Rishabh Bhatnagar 
>> ---
>>   drivers/soc/qcom/Kconfig   |  17 ++
>>   drivers/soc/qcom/Makefile  |   2 +
>>   drivers/soc/qcom/llcc-sdm845.c | 110 ++
>>   drivers/soc/qcom/llcc-slice.c  | 404
> +
>>   include/linux/soc/qcom/llcc-qcom.h | 168 +++
>>   5 files changed, 701 insertions(+)
>>   create mode 100644 drivers/soc/qcom/llcc-sdm845.c
>>   create mode 100644 drivers/soc/qcom/llcc-slice.c
>>   create mode 100644 include/linux/soc/qcom/llcc-qcom.h
>
> [...]
>> diff --git a/drivers/soc/qcom/llcc-sdm845.c
> b/drivers/soc/qcom/llcc-sdm845.c
>> new file mode 100644
>> index 000..619b226
>> --- /dev/null
>> +++ b/drivers/soc/qcom/llcc-sdm845.c
>> @@ -0,0 +1,110 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * Copyright (c) 2017-2018, The Linux Foundation. All rights
>> reserved.
>> + *
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +/*
>> + * SCT(System Cache Table) entry contains of the following parameters
>
> contains the following members:
>
>> + * name: Name of the client's use case for which the llcc slice is
>> used
>> + * uid: Unique id for the client's use case
>
> s/uid/usecase_id/
>
>> + * slice_id: llcc slice id for each client
>> + * max_cap: The maximum capacity of the cache slice provided in KB
>> + * priority: Priority of the client used to select victim line for
> replacement
>> + * fixed_size: Determine if the slice has a fixed capacity
>
> "Boolean indicating if the slice has a fixed capacity" might be better
>
>> diff --git a/drivers/soc/qcom/llcc-slice.c
>> b/drivers/soc/qcom/llcc-slice.c
>> new file mode 100644
>> index 000..67a81b0
>> --- /dev/null
>> +++ b/drivers/soc/qcom/llcc-slice.c
> ...
>> +static int llcc_update_act_ctrl(struct llcc_drv_data *drv, u32 sid,
>> +   u32 act_ctrl_reg_val, u32 status)
>> +{
>> +   u32 act_ctrl_reg;
>> +   u32 status_reg;
>> +   u32 slice_status;
>> +   int ret = 0;
>> +
>> +   act_ctrl_reg = drv->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
>> +   status_reg = drv->bcast_off + LLCC_TRP_STATUSn(sid);
>> +
>> +   /*Set the ACTIVE trigger*/
>
> Add spaces around /* */
>
>> +   act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
>> +   ret = regmap_write(drv->regmap, act_ctrl_reg,
>> act_ctrl_reg_val);
>> +   if (ret)
>> +   return ret;
>> +
>> +   /* Clear the ACTIVE trigger */
>> +   act_ctrl_reg_val &= ~ACT_CTRL_ACT_TRIG;
>> +   ret = regmap_write(drv->regmap, act_ctrl_reg,
>> act_ctrl_reg_val);
>> +   if (ret)
>> +   return ret;
>> +
>> +   ret = regmap_read_poll_timeout(drv->regmap, status_reg,
> slice_status,
>> +   !(slice_status & status), 0,
> LLCC_STATUS_READ_DELAY);
>> +   return ret;
>> +}
>> +
>> +/**
>> + * llcc_slice_activate - Activate the llcc slice
>> + * @desc: Pointer to llcc slice descriptor
>> + *
>> + * A value zero will be returned on success and a negative errno will
>
> a value of zero
>
>> + * be returned in error cases
>> + */
>> +int llcc_slice_activate(struct llcc_slice_desc *desc)
>> +{
>> +   int ret;
>> +   u32 act_ctrl_val;
>> +   struct llcc_drv_data *drv;
>> +
>> +   if (desc == NULL)
>> +   return -EINVAL;
>
> I think we can remove this check, right?
>
>> +
>> +   drv = dev_get_drvdata(desc->dev);
>> +   if (!drv)
>> +   return -EINVAL;
>> +
>> +   mutex_lock(>lock);
>> +   if (test_bit(desc->slice_id, drv->bitmap)) {
>> +   mutex_unlock(>lock);
>> +   return 0;
>> +   }
>> +
>> +   act_ctrl_val = ACT_CTRL_OPCODE_ACTIVATE <<
>> ACT_CTRL_OPCODE_SHIFT;
>> +
>> +   ret = llcc_update_act_ctrl(drv, desc->slice_id, act_ctrl_val,
>> + DEACTIVATE);
>> +
>> +   __set_bit(desc->slice_id, drv->bitmap);
>> +   mutex_unlock(>lock);
>> +
>> +   return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(llcc_slice_activate);
>> +
>> +/**
>> + * llcc_slice_deactivate - Deactivate the llcc slice
>> + * @desc: Pointer to llcc 

Re: [PATCH v4 2/2] drivers: soc: Add LLCC driver

2018-04-16 Thread rishabhb

On 2018-04-16 10:14, Evan Green wrote:

On Fri, Apr 13, 2018 at 4:08 PM  wrote:


On 2018-04-12 15:02, Evan Green wrote:
> Hi Rishabh,
>
> On Tue, Apr 10, 2018 at 1:09 PM Rishabh Bhatnagar
> 
> wrote:
>
>> LLCC (Last Level Cache Controller) provides additional cache memory
>> in the system. LLCC is partitioned into multiple slices and each
>> slice gets its own priority, size, ID and other config parameters.
>> LLCC driver programs these parameters for each slice. Clients that
>> are assigned to use LLCC need to get information such size & ID of the
>> slice they get and activate or deactivate the slice as needed. LLCC
>> driver
>> provides API for the clients to perform these operations.
>
>> Signed-off-by: Channagoud Kadabi 
>> Signed-off-by: Rishabh Bhatnagar 
>> ---
>>   drivers/soc/qcom/Kconfig   |  17 ++
>>   drivers/soc/qcom/Makefile  |   2 +
>>   drivers/soc/qcom/llcc-sdm845.c | 110 ++
>>   drivers/soc/qcom/llcc-slice.c  | 404
> +
>>   include/linux/soc/qcom/llcc-qcom.h | 168 +++
>>   5 files changed, 701 insertions(+)
>>   create mode 100644 drivers/soc/qcom/llcc-sdm845.c
>>   create mode 100644 drivers/soc/qcom/llcc-slice.c
>>   create mode 100644 include/linux/soc/qcom/llcc-qcom.h
>
> [...]
>> diff --git a/drivers/soc/qcom/llcc-sdm845.c
> b/drivers/soc/qcom/llcc-sdm845.c
>> new file mode 100644
>> index 000..619b226
>> --- /dev/null
>> +++ b/drivers/soc/qcom/llcc-sdm845.c
>> @@ -0,0 +1,110 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * Copyright (c) 2017-2018, The Linux Foundation. All rights
>> reserved.
>> + *
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +/*
>> + * SCT(System Cache Table) entry contains of the following parameters
>
> contains the following members:
>
>> + * name: Name of the client's use case for which the llcc slice is
>> used
>> + * uid: Unique id for the client's use case
>
> s/uid/usecase_id/
>
>> + * slice_id: llcc slice id for each client
>> + * max_cap: The maximum capacity of the cache slice provided in KB
>> + * priority: Priority of the client used to select victim line for
> replacement
>> + * fixed_size: Determine if the slice has a fixed capacity
>
> "Boolean indicating if the slice has a fixed capacity" might be better
>
>> diff --git a/drivers/soc/qcom/llcc-slice.c
>> b/drivers/soc/qcom/llcc-slice.c
>> new file mode 100644
>> index 000..67a81b0
>> --- /dev/null
>> +++ b/drivers/soc/qcom/llcc-slice.c
> ...
>> +static int llcc_update_act_ctrl(struct llcc_drv_data *drv, u32 sid,
>> +   u32 act_ctrl_reg_val, u32 status)
>> +{
>> +   u32 act_ctrl_reg;
>> +   u32 status_reg;
>> +   u32 slice_status;
>> +   int ret = 0;
>> +
>> +   act_ctrl_reg = drv->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
>> +   status_reg = drv->bcast_off + LLCC_TRP_STATUSn(sid);
>> +
>> +   /*Set the ACTIVE trigger*/
>
> Add spaces around /* */
>
>> +   act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
>> +   ret = regmap_write(drv->regmap, act_ctrl_reg,
>> act_ctrl_reg_val);
>> +   if (ret)
>> +   return ret;
>> +
>> +   /* Clear the ACTIVE trigger */
>> +   act_ctrl_reg_val &= ~ACT_CTRL_ACT_TRIG;
>> +   ret = regmap_write(drv->regmap, act_ctrl_reg,
>> act_ctrl_reg_val);
>> +   if (ret)
>> +   return ret;
>> +
>> +   ret = regmap_read_poll_timeout(drv->regmap, status_reg,
> slice_status,
>> +   !(slice_status & status), 0,
> LLCC_STATUS_READ_DELAY);
>> +   return ret;
>> +}
>> +
>> +/**
>> + * llcc_slice_activate - Activate the llcc slice
>> + * @desc: Pointer to llcc slice descriptor
>> + *
>> + * A value zero will be returned on success and a negative errno will
>
> a value of zero
>
>> + * be returned in error cases
>> + */
>> +int llcc_slice_activate(struct llcc_slice_desc *desc)
>> +{
>> +   int ret;
>> +   u32 act_ctrl_val;
>> +   struct llcc_drv_data *drv;
>> +
>> +   if (desc == NULL)
>> +   return -EINVAL;
>
> I think we can remove this check, right?
>
>> +
>> +   drv = dev_get_drvdata(desc->dev);
>> +   if (!drv)
>> +   return -EINVAL;
>> +
>> +   mutex_lock(>lock);
>> +   if (test_bit(desc->slice_id, drv->bitmap)) {
>> +   mutex_unlock(>lock);
>> +   return 0;
>> +   }
>> +
>> +   act_ctrl_val = ACT_CTRL_OPCODE_ACTIVATE <<
>> ACT_CTRL_OPCODE_SHIFT;
>> +
>> +   ret = llcc_update_act_ctrl(drv, desc->slice_id, act_ctrl_val,
>> + DEACTIVATE);
>> +
>> +   __set_bit(desc->slice_id, drv->bitmap);
>> +   mutex_unlock(>lock);
>> +
>> +   return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(llcc_slice_activate);
>> +
>> +/**
>> + * llcc_slice_deactivate - Deactivate the llcc slice
>> + * @desc: Pointer to llcc slice descriptor
>> + *
>> + * A value zero will be returned on success and a negative errno will
>> + 

Re: [PATCH v4 2/2] drivers: soc: Add LLCC driver

2018-04-16 Thread saiprakash . ranjan

Hi Rishabh,


+MODULE_DESCRIPTION("QTI sdm845 LLCC driver");


I think it should be QCOM or Qualcomm and not QTI


+
+   desc = devm_kzalloc(dev, sizeof(struct llcc_slice_desc), GFP_KERNEL);


Can use *desc instead

+struct llcc_slice_desc *llcc_slice_getd(struct device *dev, const char 
*name)

+{
+   struct device_node *np = dev->of_node;
+   int index = 0;
+   const char *slice_name;
+   struct property *prop;
+
+   if (!np)
+   return ERR_PTR(-ENOENT);


Is this check required?


diff --git a/include/linux/soc/qcom/llcc-qcom.h
b/include/linux/soc/qcom/llcc-qcom.h
new file mode 100644
index 000..3e97569
--- /dev/null
+++ b/include/linux/soc/qcom/llcc-qcom.h
@@ -0,0 +1,168 @@
+// SPDX-License-Identifier: GPL-2.0


Should be within /* */ for headers as per kernel licensing rules.

Regards,
Sai Prakash


Re: [PATCH v4 2/2] drivers: soc: Add LLCC driver

2018-04-16 Thread saiprakash . ranjan

Hi Rishabh,


+MODULE_DESCRIPTION("QTI sdm845 LLCC driver");


I think it should be QCOM or Qualcomm and not QTI


+
+   desc = devm_kzalloc(dev, sizeof(struct llcc_slice_desc), GFP_KERNEL);


Can use *desc instead

+struct llcc_slice_desc *llcc_slice_getd(struct device *dev, const char 
*name)

+{
+   struct device_node *np = dev->of_node;
+   int index = 0;
+   const char *slice_name;
+   struct property *prop;
+
+   if (!np)
+   return ERR_PTR(-ENOENT);


Is this check required?


diff --git a/include/linux/soc/qcom/llcc-qcom.h
b/include/linux/soc/qcom/llcc-qcom.h
new file mode 100644
index 000..3e97569
--- /dev/null
+++ b/include/linux/soc/qcom/llcc-qcom.h
@@ -0,0 +1,168 @@
+// SPDX-License-Identifier: GPL-2.0


Should be within /* */ for headers as per kernel licensing rules.

Regards,
Sai Prakash


Re: [PATCH v4 2/2] drivers: soc: Add LLCC driver

2018-04-16 Thread Evan Green
On Fri, Apr 13, 2018 at 4:08 PM  wrote:

> On 2018-04-12 15:02, Evan Green wrote:
> > Hi Rishabh,
> >
> > On Tue, Apr 10, 2018 at 1:09 PM Rishabh Bhatnagar
> > 
> > wrote:
> >
> >> LLCC (Last Level Cache Controller) provides additional cache memory
> >> in the system. LLCC is partitioned into multiple slices and each
> >> slice gets its own priority, size, ID and other config parameters.
> >> LLCC driver programs these parameters for each slice. Clients that
> >> are assigned to use LLCC need to get information such size & ID of the
> >> slice they get and activate or deactivate the slice as needed. LLCC
> >> driver
> >> provides API for the clients to perform these operations.
> >
> >> Signed-off-by: Channagoud Kadabi 
> >> Signed-off-by: Rishabh Bhatnagar 
> >> ---
> >>   drivers/soc/qcom/Kconfig   |  17 ++
> >>   drivers/soc/qcom/Makefile  |   2 +
> >>   drivers/soc/qcom/llcc-sdm845.c | 110 ++
> >>   drivers/soc/qcom/llcc-slice.c  | 404
> > +
> >>   include/linux/soc/qcom/llcc-qcom.h | 168 +++
> >>   5 files changed, 701 insertions(+)
> >>   create mode 100644 drivers/soc/qcom/llcc-sdm845.c
> >>   create mode 100644 drivers/soc/qcom/llcc-slice.c
> >>   create mode 100644 include/linux/soc/qcom/llcc-qcom.h
> >
> > [...]
> >> diff --git a/drivers/soc/qcom/llcc-sdm845.c
> > b/drivers/soc/qcom/llcc-sdm845.c
> >> new file mode 100644
> >> index 000..619b226
> >> --- /dev/null
> >> +++ b/drivers/soc/qcom/llcc-sdm845.c
> >> @@ -0,0 +1,110 @@
> >> +// SPDX-License-Identifier: GPL-2.0
> >> +/*
> >> + * Copyright (c) 2017-2018, The Linux Foundation. All rights
> >> reserved.
> >> + *
> >> + */
> >> +
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +
> >> +/*
> >> + * SCT(System Cache Table) entry contains of the following parameters
> >
> > contains the following members:
> >
> >> + * name: Name of the client's use case for which the llcc slice is
> >> used
> >> + * uid: Unique id for the client's use case
> >
> > s/uid/usecase_id/
> >
> >> + * slice_id: llcc slice id for each client
> >> + * max_cap: The maximum capacity of the cache slice provided in KB
> >> + * priority: Priority of the client used to select victim line for
> > replacement
> >> + * fixed_size: Determine if the slice has a fixed capacity
> >
> > "Boolean indicating if the slice has a fixed capacity" might be better
> >
> >> diff --git a/drivers/soc/qcom/llcc-slice.c
> >> b/drivers/soc/qcom/llcc-slice.c
> >> new file mode 100644
> >> index 000..67a81b0
> >> --- /dev/null
> >> +++ b/drivers/soc/qcom/llcc-slice.c
> > ...
> >> +static int llcc_update_act_ctrl(struct llcc_drv_data *drv, u32 sid,
> >> +   u32 act_ctrl_reg_val, u32 status)
> >> +{
> >> +   u32 act_ctrl_reg;
> >> +   u32 status_reg;
> >> +   u32 slice_status;
> >> +   int ret = 0;
> >> +
> >> +   act_ctrl_reg = drv->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
> >> +   status_reg = drv->bcast_off + LLCC_TRP_STATUSn(sid);
> >> +
> >> +   /*Set the ACTIVE trigger*/
> >
> > Add spaces around /* */
> >
> >> +   act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
> >> +   ret = regmap_write(drv->regmap, act_ctrl_reg,
> >> act_ctrl_reg_val);
> >> +   if (ret)
> >> +   return ret;
> >> +
> >> +   /* Clear the ACTIVE trigger */
> >> +   act_ctrl_reg_val &= ~ACT_CTRL_ACT_TRIG;
> >> +   ret = regmap_write(drv->regmap, act_ctrl_reg,
> >> act_ctrl_reg_val);
> >> +   if (ret)
> >> +   return ret;
> >> +
> >> +   ret = regmap_read_poll_timeout(drv->regmap, status_reg,
> > slice_status,
> >> +   !(slice_status & status), 0,
> > LLCC_STATUS_READ_DELAY);
> >> +   return ret;
> >> +}
> >> +
> >> +/**
> >> + * llcc_slice_activate - Activate the llcc slice
> >> + * @desc: Pointer to llcc slice descriptor
> >> + *
> >> + * A value zero will be returned on success and a negative errno will
> >
> > a value of zero
> >
> >> + * be returned in error cases
> >> + */
> >> +int llcc_slice_activate(struct llcc_slice_desc *desc)
> >> +{
> >> +   int ret;
> >> +   u32 act_ctrl_val;
> >> +   struct llcc_drv_data *drv;
> >> +
> >> +   if (desc == NULL)
> >> +   return -EINVAL;
> >
> > I think we can remove this check, right?
> >
> >> +
> >> +   drv = dev_get_drvdata(desc->dev);
> >> +   if (!drv)
> >> +   return -EINVAL;
> >> +
> >> +   mutex_lock(>lock);
> >> +   if (test_bit(desc->slice_id, drv->bitmap)) {
> >> +   mutex_unlock(>lock);
> >> +   return 0;
> >> +   }
> >> +
> >> +   act_ctrl_val = ACT_CTRL_OPCODE_ACTIVATE <<
> >> ACT_CTRL_OPCODE_SHIFT;
> >> +
> >> +   ret = llcc_update_act_ctrl(drv, desc->slice_id, act_ctrl_val,
> >> + DEACTIVATE);
> >> +
> >> +  

Re: [PATCH v4 2/2] drivers: soc: Add LLCC driver

2018-04-16 Thread Evan Green
On Fri, Apr 13, 2018 at 4:08 PM  wrote:

> On 2018-04-12 15:02, Evan Green wrote:
> > Hi Rishabh,
> >
> > On Tue, Apr 10, 2018 at 1:09 PM Rishabh Bhatnagar
> > 
> > wrote:
> >
> >> LLCC (Last Level Cache Controller) provides additional cache memory
> >> in the system. LLCC is partitioned into multiple slices and each
> >> slice gets its own priority, size, ID and other config parameters.
> >> LLCC driver programs these parameters for each slice. Clients that
> >> are assigned to use LLCC need to get information such size & ID of the
> >> slice they get and activate or deactivate the slice as needed. LLCC
> >> driver
> >> provides API for the clients to perform these operations.
> >
> >> Signed-off-by: Channagoud Kadabi 
> >> Signed-off-by: Rishabh Bhatnagar 
> >> ---
> >>   drivers/soc/qcom/Kconfig   |  17 ++
> >>   drivers/soc/qcom/Makefile  |   2 +
> >>   drivers/soc/qcom/llcc-sdm845.c | 110 ++
> >>   drivers/soc/qcom/llcc-slice.c  | 404
> > +
> >>   include/linux/soc/qcom/llcc-qcom.h | 168 +++
> >>   5 files changed, 701 insertions(+)
> >>   create mode 100644 drivers/soc/qcom/llcc-sdm845.c
> >>   create mode 100644 drivers/soc/qcom/llcc-slice.c
> >>   create mode 100644 include/linux/soc/qcom/llcc-qcom.h
> >
> > [...]
> >> diff --git a/drivers/soc/qcom/llcc-sdm845.c
> > b/drivers/soc/qcom/llcc-sdm845.c
> >> new file mode 100644
> >> index 000..619b226
> >> --- /dev/null
> >> +++ b/drivers/soc/qcom/llcc-sdm845.c
> >> @@ -0,0 +1,110 @@
> >> +// SPDX-License-Identifier: GPL-2.0
> >> +/*
> >> + * Copyright (c) 2017-2018, The Linux Foundation. All rights
> >> reserved.
> >> + *
> >> + */
> >> +
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +
> >> +/*
> >> + * SCT(System Cache Table) entry contains of the following parameters
> >
> > contains the following members:
> >
> >> + * name: Name of the client's use case for which the llcc slice is
> >> used
> >> + * uid: Unique id for the client's use case
> >
> > s/uid/usecase_id/
> >
> >> + * slice_id: llcc slice id for each client
> >> + * max_cap: The maximum capacity of the cache slice provided in KB
> >> + * priority: Priority of the client used to select victim line for
> > replacement
> >> + * fixed_size: Determine if the slice has a fixed capacity
> >
> > "Boolean indicating if the slice has a fixed capacity" might be better
> >
> >> diff --git a/drivers/soc/qcom/llcc-slice.c
> >> b/drivers/soc/qcom/llcc-slice.c
> >> new file mode 100644
> >> index 000..67a81b0
> >> --- /dev/null
> >> +++ b/drivers/soc/qcom/llcc-slice.c
> > ...
> >> +static int llcc_update_act_ctrl(struct llcc_drv_data *drv, u32 sid,
> >> +   u32 act_ctrl_reg_val, u32 status)
> >> +{
> >> +   u32 act_ctrl_reg;
> >> +   u32 status_reg;
> >> +   u32 slice_status;
> >> +   int ret = 0;
> >> +
> >> +   act_ctrl_reg = drv->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
> >> +   status_reg = drv->bcast_off + LLCC_TRP_STATUSn(sid);
> >> +
> >> +   /*Set the ACTIVE trigger*/
> >
> > Add spaces around /* */
> >
> >> +   act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
> >> +   ret = regmap_write(drv->regmap, act_ctrl_reg,
> >> act_ctrl_reg_val);
> >> +   if (ret)
> >> +   return ret;
> >> +
> >> +   /* Clear the ACTIVE trigger */
> >> +   act_ctrl_reg_val &= ~ACT_CTRL_ACT_TRIG;
> >> +   ret = regmap_write(drv->regmap, act_ctrl_reg,
> >> act_ctrl_reg_val);
> >> +   if (ret)
> >> +   return ret;
> >> +
> >> +   ret = regmap_read_poll_timeout(drv->regmap, status_reg,
> > slice_status,
> >> +   !(slice_status & status), 0,
> > LLCC_STATUS_READ_DELAY);
> >> +   return ret;
> >> +}
> >> +
> >> +/**
> >> + * llcc_slice_activate - Activate the llcc slice
> >> + * @desc: Pointer to llcc slice descriptor
> >> + *
> >> + * A value zero will be returned on success and a negative errno will
> >
> > a value of zero
> >
> >> + * be returned in error cases
> >> + */
> >> +int llcc_slice_activate(struct llcc_slice_desc *desc)
> >> +{
> >> +   int ret;
> >> +   u32 act_ctrl_val;
> >> +   struct llcc_drv_data *drv;
> >> +
> >> +   if (desc == NULL)
> >> +   return -EINVAL;
> >
> > I think we can remove this check, right?
> >
> >> +
> >> +   drv = dev_get_drvdata(desc->dev);
> >> +   if (!drv)
> >> +   return -EINVAL;
> >> +
> >> +   mutex_lock(>lock);
> >> +   if (test_bit(desc->slice_id, drv->bitmap)) {
> >> +   mutex_unlock(>lock);
> >> +   return 0;
> >> +   }
> >> +
> >> +   act_ctrl_val = ACT_CTRL_OPCODE_ACTIVATE <<
> >> ACT_CTRL_OPCODE_SHIFT;
> >> +
> >> +   ret = llcc_update_act_ctrl(drv, desc->slice_id, act_ctrl_val,
> >> + DEACTIVATE);
> >> +
> >> +   __set_bit(desc->slice_id, drv->bitmap);
> >> +   mutex_unlock(>lock);
> >> +
> >> +   

Re: [PATCH v4 2/2] drivers: soc: Add LLCC driver

2018-04-13 Thread rishabhb

On 2018-04-12 15:02, Evan Green wrote:

Hi Rishabh,

On Tue, Apr 10, 2018 at 1:09 PM Rishabh Bhatnagar 


wrote:


LLCC (Last Level Cache Controller) provides additional cache memory
in the system. LLCC is partitioned into multiple slices and each
slice gets its own priority, size, ID and other config parameters.
LLCC driver programs these parameters for each slice. Clients that
are assigned to use LLCC need to get information such size & ID of the
slice they get and activate or deactivate the slice as needed. LLCC 
driver

provides API for the clients to perform these operations.



Signed-off-by: Channagoud Kadabi 
Signed-off-by: Rishabh Bhatnagar 
---
  drivers/soc/qcom/Kconfig   |  17 ++
  drivers/soc/qcom/Makefile  |   2 +
  drivers/soc/qcom/llcc-sdm845.c | 110 ++
  drivers/soc/qcom/llcc-slice.c  | 404

+

  include/linux/soc/qcom/llcc-qcom.h | 168 +++
  5 files changed, 701 insertions(+)
  create mode 100644 drivers/soc/qcom/llcc-sdm845.c
  create mode 100644 drivers/soc/qcom/llcc-slice.c
  create mode 100644 include/linux/soc/qcom/llcc-qcom.h


[...]

diff --git a/drivers/soc/qcom/llcc-sdm845.c

b/drivers/soc/qcom/llcc-sdm845.c

new file mode 100644
index 000..619b226
--- /dev/null
+++ b/drivers/soc/qcom/llcc-sdm845.c
@@ -0,0 +1,110 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2017-2018, The Linux Foundation. All rights 
reserved.

+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * SCT(System Cache Table) entry contains of the following parameters


contains the following members:

+ * name: Name of the client's use case for which the llcc slice is 
used

+ * uid: Unique id for the client's use case


s/uid/usecase_id/


+ * slice_id: llcc slice id for each client
+ * max_cap: The maximum capacity of the cache slice provided in KB
+ * priority: Priority of the client used to select victim line for

replacement

+ * fixed_size: Determine if the slice has a fixed capacity


"Boolean indicating if the slice has a fixed capacity" might be better

diff --git a/drivers/soc/qcom/llcc-slice.c 
b/drivers/soc/qcom/llcc-slice.c

new file mode 100644
index 000..67a81b0
--- /dev/null
+++ b/drivers/soc/qcom/llcc-slice.c

...

+static int llcc_update_act_ctrl(struct llcc_drv_data *drv, u32 sid,
+   u32 act_ctrl_reg_val, u32 status)
+{
+   u32 act_ctrl_reg;
+   u32 status_reg;
+   u32 slice_status;
+   int ret = 0;
+
+   act_ctrl_reg = drv->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
+   status_reg = drv->bcast_off + LLCC_TRP_STATUSn(sid);
+
+   /*Set the ACTIVE trigger*/


Add spaces around /* */


+   act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
+   ret = regmap_write(drv->regmap, act_ctrl_reg, 
act_ctrl_reg_val);

+   if (ret)
+   return ret;
+
+   /* Clear the ACTIVE trigger */
+   act_ctrl_reg_val &= ~ACT_CTRL_ACT_TRIG;
+   ret = regmap_write(drv->regmap, act_ctrl_reg, 
act_ctrl_reg_val);

+   if (ret)
+   return ret;
+
+   ret = regmap_read_poll_timeout(drv->regmap, status_reg,

slice_status,

+   !(slice_status & status), 0,

LLCC_STATUS_READ_DELAY);

+   return ret;
+}
+
+/**
+ * llcc_slice_activate - Activate the llcc slice
+ * @desc: Pointer to llcc slice descriptor
+ *
+ * A value zero will be returned on success and a negative errno will


a value of zero


+ * be returned in error cases
+ */
+int llcc_slice_activate(struct llcc_slice_desc *desc)
+{
+   int ret;
+   u32 act_ctrl_val;
+   struct llcc_drv_data *drv;
+
+   if (desc == NULL)
+   return -EINVAL;


I think we can remove this check, right?


+
+   drv = dev_get_drvdata(desc->dev);
+   if (!drv)
+   return -EINVAL;
+
+   mutex_lock(>lock);
+   if (test_bit(desc->slice_id, drv->bitmap)) {
+   mutex_unlock(>lock);
+   return 0;
+   }
+
+   act_ctrl_val = ACT_CTRL_OPCODE_ACTIVATE << 
ACT_CTRL_OPCODE_SHIFT;

+
+   ret = llcc_update_act_ctrl(drv, desc->slice_id, act_ctrl_val,
+ DEACTIVATE);
+
+   __set_bit(desc->slice_id, drv->bitmap);
+   mutex_unlock(>lock);
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(llcc_slice_activate);
+
+/**
+ * llcc_slice_deactivate - Deactivate the llcc slice
+ * @desc: Pointer to llcc slice descriptor
+ *
+ * A value zero will be returned on success and a negative errno will
+ * be returned in error cases
+ */
+int llcc_slice_deactivate(struct llcc_slice_desc *desc)
+{
+   u32 act_ctrl_val;
+   int ret;
+   struct llcc_drv_data *drv;
+
+   if (desc == NULL)
+   return -EINVAL;
+
+   drv = dev_get_drvdata(desc->dev);
+   if (!drv)
+   return -EINVAL;
+
+   mutex_lock(>lock);
+   if (!test_bit(desc->slice_id, 

Re: [PATCH v4 2/2] drivers: soc: Add LLCC driver

2018-04-13 Thread rishabhb

On 2018-04-12 15:02, Evan Green wrote:

Hi Rishabh,

On Tue, Apr 10, 2018 at 1:09 PM Rishabh Bhatnagar 


wrote:


LLCC (Last Level Cache Controller) provides additional cache memory
in the system. LLCC is partitioned into multiple slices and each
slice gets its own priority, size, ID and other config parameters.
LLCC driver programs these parameters for each slice. Clients that
are assigned to use LLCC need to get information such size & ID of the
slice they get and activate or deactivate the slice as needed. LLCC 
driver

provides API for the clients to perform these operations.



Signed-off-by: Channagoud Kadabi 
Signed-off-by: Rishabh Bhatnagar 
---
  drivers/soc/qcom/Kconfig   |  17 ++
  drivers/soc/qcom/Makefile  |   2 +
  drivers/soc/qcom/llcc-sdm845.c | 110 ++
  drivers/soc/qcom/llcc-slice.c  | 404

+

  include/linux/soc/qcom/llcc-qcom.h | 168 +++
  5 files changed, 701 insertions(+)
  create mode 100644 drivers/soc/qcom/llcc-sdm845.c
  create mode 100644 drivers/soc/qcom/llcc-slice.c
  create mode 100644 include/linux/soc/qcom/llcc-qcom.h


[...]

diff --git a/drivers/soc/qcom/llcc-sdm845.c

b/drivers/soc/qcom/llcc-sdm845.c

new file mode 100644
index 000..619b226
--- /dev/null
+++ b/drivers/soc/qcom/llcc-sdm845.c
@@ -0,0 +1,110 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2017-2018, The Linux Foundation. All rights 
reserved.

+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * SCT(System Cache Table) entry contains of the following parameters


contains the following members:

+ * name: Name of the client's use case for which the llcc slice is 
used

+ * uid: Unique id for the client's use case


s/uid/usecase_id/


+ * slice_id: llcc slice id for each client
+ * max_cap: The maximum capacity of the cache slice provided in KB
+ * priority: Priority of the client used to select victim line for

replacement

+ * fixed_size: Determine if the slice has a fixed capacity


"Boolean indicating if the slice has a fixed capacity" might be better

diff --git a/drivers/soc/qcom/llcc-slice.c 
b/drivers/soc/qcom/llcc-slice.c

new file mode 100644
index 000..67a81b0
--- /dev/null
+++ b/drivers/soc/qcom/llcc-slice.c

...

+static int llcc_update_act_ctrl(struct llcc_drv_data *drv, u32 sid,
+   u32 act_ctrl_reg_val, u32 status)
+{
+   u32 act_ctrl_reg;
+   u32 status_reg;
+   u32 slice_status;
+   int ret = 0;
+
+   act_ctrl_reg = drv->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
+   status_reg = drv->bcast_off + LLCC_TRP_STATUSn(sid);
+
+   /*Set the ACTIVE trigger*/


Add spaces around /* */


+   act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
+   ret = regmap_write(drv->regmap, act_ctrl_reg, 
act_ctrl_reg_val);

+   if (ret)
+   return ret;
+
+   /* Clear the ACTIVE trigger */
+   act_ctrl_reg_val &= ~ACT_CTRL_ACT_TRIG;
+   ret = regmap_write(drv->regmap, act_ctrl_reg, 
act_ctrl_reg_val);

+   if (ret)
+   return ret;
+
+   ret = regmap_read_poll_timeout(drv->regmap, status_reg,

slice_status,

+   !(slice_status & status), 0,

LLCC_STATUS_READ_DELAY);

+   return ret;
+}
+
+/**
+ * llcc_slice_activate - Activate the llcc slice
+ * @desc: Pointer to llcc slice descriptor
+ *
+ * A value zero will be returned on success and a negative errno will


a value of zero


+ * be returned in error cases
+ */
+int llcc_slice_activate(struct llcc_slice_desc *desc)
+{
+   int ret;
+   u32 act_ctrl_val;
+   struct llcc_drv_data *drv;
+
+   if (desc == NULL)
+   return -EINVAL;


I think we can remove this check, right?


+
+   drv = dev_get_drvdata(desc->dev);
+   if (!drv)
+   return -EINVAL;
+
+   mutex_lock(>lock);
+   if (test_bit(desc->slice_id, drv->bitmap)) {
+   mutex_unlock(>lock);
+   return 0;
+   }
+
+   act_ctrl_val = ACT_CTRL_OPCODE_ACTIVATE << 
ACT_CTRL_OPCODE_SHIFT;

+
+   ret = llcc_update_act_ctrl(drv, desc->slice_id, act_ctrl_val,
+ DEACTIVATE);
+
+   __set_bit(desc->slice_id, drv->bitmap);
+   mutex_unlock(>lock);
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(llcc_slice_activate);
+
+/**
+ * llcc_slice_deactivate - Deactivate the llcc slice
+ * @desc: Pointer to llcc slice descriptor
+ *
+ * A value zero will be returned on success and a negative errno will
+ * be returned in error cases
+ */
+int llcc_slice_deactivate(struct llcc_slice_desc *desc)
+{
+   u32 act_ctrl_val;
+   int ret;
+   struct llcc_drv_data *drv;
+
+   if (desc == NULL)
+   return -EINVAL;
+
+   drv = dev_get_drvdata(desc->dev);
+   if (!drv)
+   return -EINVAL;
+
+   mutex_lock(>lock);
+   if (!test_bit(desc->slice_id, drv->bitmap)) {
+   mutex_unlock(>lock);
+   return 0;
+   

Re: [PATCH v4 2/2] drivers: soc: Add LLCC driver

2018-04-12 Thread Evan Green
Hi Rishabh,

On Tue, Apr 10, 2018 at 1:09 PM Rishabh Bhatnagar 
wrote:

> LLCC (Last Level Cache Controller) provides additional cache memory
> in the system. LLCC is partitioned into multiple slices and each
> slice gets its own priority, size, ID and other config parameters.
> LLCC driver programs these parameters for each slice. Clients that
> are assigned to use LLCC need to get information such size & ID of the
> slice they get and activate or deactivate the slice as needed. LLCC driver
> provides API for the clients to perform these operations.

> Signed-off-by: Channagoud Kadabi 
> Signed-off-by: Rishabh Bhatnagar 
> ---
>   drivers/soc/qcom/Kconfig   |  17 ++
>   drivers/soc/qcom/Makefile  |   2 +
>   drivers/soc/qcom/llcc-sdm845.c | 110 ++
>   drivers/soc/qcom/llcc-slice.c  | 404
+
>   include/linux/soc/qcom/llcc-qcom.h | 168 +++
>   5 files changed, 701 insertions(+)
>   create mode 100644 drivers/soc/qcom/llcc-sdm845.c
>   create mode 100644 drivers/soc/qcom/llcc-slice.c
>   create mode 100644 include/linux/soc/qcom/llcc-qcom.h

[...]
> diff --git a/drivers/soc/qcom/llcc-sdm845.c
b/drivers/soc/qcom/llcc-sdm845.c
> new file mode 100644
> index 000..619b226
> --- /dev/null
> +++ b/drivers/soc/qcom/llcc-sdm845.c
> @@ -0,0 +1,110 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
> + *
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/*
> + * SCT(System Cache Table) entry contains of the following parameters

contains the following members:

> + * name: Name of the client's use case for which the llcc slice is used
> + * uid: Unique id for the client's use case

s/uid/usecase_id/

> + * slice_id: llcc slice id for each client
> + * max_cap: The maximum capacity of the cache slice provided in KB
> + * priority: Priority of the client used to select victim line for
replacement
> + * fixed_size: Determine if the slice has a fixed capacity

"Boolean indicating if the slice has a fixed capacity" might be better

> diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
> new file mode 100644
> index 000..67a81b0
> --- /dev/null
> +++ b/drivers/soc/qcom/llcc-slice.c
...
> +static int llcc_update_act_ctrl(struct llcc_drv_data *drv, u32 sid,
> +   u32 act_ctrl_reg_val, u32 status)
> +{
> +   u32 act_ctrl_reg;
> +   u32 status_reg;
> +   u32 slice_status;
> +   int ret = 0;
> +
> +   act_ctrl_reg = drv->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
> +   status_reg = drv->bcast_off + LLCC_TRP_STATUSn(sid);
> +
> +   /*Set the ACTIVE trigger*/

Add spaces around /* */

> +   act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
> +   ret = regmap_write(drv->regmap, act_ctrl_reg, act_ctrl_reg_val);
> +   if (ret)
> +   return ret;
> +
> +   /* Clear the ACTIVE trigger */
> +   act_ctrl_reg_val &= ~ACT_CTRL_ACT_TRIG;
> +   ret = regmap_write(drv->regmap, act_ctrl_reg, act_ctrl_reg_val);
> +   if (ret)
> +   return ret;
> +
> +   ret = regmap_read_poll_timeout(drv->regmap, status_reg,
slice_status,
> +   !(slice_status & status), 0,
LLCC_STATUS_READ_DELAY);
> +   return ret;
> +}
> +
> +/**
> + * llcc_slice_activate - Activate the llcc slice
> + * @desc: Pointer to llcc slice descriptor
> + *
> + * A value zero will be returned on success and a negative errno will

a value of zero

> + * be returned in error cases
> + */
> +int llcc_slice_activate(struct llcc_slice_desc *desc)
> +{
> +   int ret;
> +   u32 act_ctrl_val;
> +   struct llcc_drv_data *drv;
> +
> +   if (desc == NULL)
> +   return -EINVAL;

I think we can remove this check, right?

> +
> +   drv = dev_get_drvdata(desc->dev);
> +   if (!drv)
> +   return -EINVAL;
> +
> +   mutex_lock(>lock);
> +   if (test_bit(desc->slice_id, drv->bitmap)) {
> +   mutex_unlock(>lock);
> +   return 0;
> +   }
> +
> +   act_ctrl_val = ACT_CTRL_OPCODE_ACTIVATE << ACT_CTRL_OPCODE_SHIFT;
> +
> +   ret = llcc_update_act_ctrl(drv, desc->slice_id, act_ctrl_val,
> + DEACTIVATE);
> +
> +   __set_bit(desc->slice_id, drv->bitmap);
> +   mutex_unlock(>lock);
> +
> +   return ret;
> +}
> +EXPORT_SYMBOL_GPL(llcc_slice_activate);
> +
> +/**
> + * llcc_slice_deactivate - Deactivate the llcc slice
> + * @desc: Pointer to llcc slice descriptor
> + *
> + * A value zero will be returned on success and a negative errno will
> + * be returned in error cases
> + */
> +int llcc_slice_deactivate(struct llcc_slice_desc *desc)
> +{
> +   u32 act_ctrl_val;
> +   int ret;
> +   struct llcc_drv_data *drv;
> +
> +   if (desc == NULL)
> +   return 

Re: [PATCH v4 2/2] drivers: soc: Add LLCC driver

2018-04-12 Thread Evan Green
Hi Rishabh,

On Tue, Apr 10, 2018 at 1:09 PM Rishabh Bhatnagar 
wrote:

> LLCC (Last Level Cache Controller) provides additional cache memory
> in the system. LLCC is partitioned into multiple slices and each
> slice gets its own priority, size, ID and other config parameters.
> LLCC driver programs these parameters for each slice. Clients that
> are assigned to use LLCC need to get information such size & ID of the
> slice they get and activate or deactivate the slice as needed. LLCC driver
> provides API for the clients to perform these operations.

> Signed-off-by: Channagoud Kadabi 
> Signed-off-by: Rishabh Bhatnagar 
> ---
>   drivers/soc/qcom/Kconfig   |  17 ++
>   drivers/soc/qcom/Makefile  |   2 +
>   drivers/soc/qcom/llcc-sdm845.c | 110 ++
>   drivers/soc/qcom/llcc-slice.c  | 404
+
>   include/linux/soc/qcom/llcc-qcom.h | 168 +++
>   5 files changed, 701 insertions(+)
>   create mode 100644 drivers/soc/qcom/llcc-sdm845.c
>   create mode 100644 drivers/soc/qcom/llcc-slice.c
>   create mode 100644 include/linux/soc/qcom/llcc-qcom.h

[...]
> diff --git a/drivers/soc/qcom/llcc-sdm845.c
b/drivers/soc/qcom/llcc-sdm845.c
> new file mode 100644
> index 000..619b226
> --- /dev/null
> +++ b/drivers/soc/qcom/llcc-sdm845.c
> @@ -0,0 +1,110 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
> + *
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/*
> + * SCT(System Cache Table) entry contains of the following parameters

contains the following members:

> + * name: Name of the client's use case for which the llcc slice is used
> + * uid: Unique id for the client's use case

s/uid/usecase_id/

> + * slice_id: llcc slice id for each client
> + * max_cap: The maximum capacity of the cache slice provided in KB
> + * priority: Priority of the client used to select victim line for
replacement
> + * fixed_size: Determine if the slice has a fixed capacity

"Boolean indicating if the slice has a fixed capacity" might be better

> diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
> new file mode 100644
> index 000..67a81b0
> --- /dev/null
> +++ b/drivers/soc/qcom/llcc-slice.c
...
> +static int llcc_update_act_ctrl(struct llcc_drv_data *drv, u32 sid,
> +   u32 act_ctrl_reg_val, u32 status)
> +{
> +   u32 act_ctrl_reg;
> +   u32 status_reg;
> +   u32 slice_status;
> +   int ret = 0;
> +
> +   act_ctrl_reg = drv->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
> +   status_reg = drv->bcast_off + LLCC_TRP_STATUSn(sid);
> +
> +   /*Set the ACTIVE trigger*/

Add spaces around /* */

> +   act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
> +   ret = regmap_write(drv->regmap, act_ctrl_reg, act_ctrl_reg_val);
> +   if (ret)
> +   return ret;
> +
> +   /* Clear the ACTIVE trigger */
> +   act_ctrl_reg_val &= ~ACT_CTRL_ACT_TRIG;
> +   ret = regmap_write(drv->regmap, act_ctrl_reg, act_ctrl_reg_val);
> +   if (ret)
> +   return ret;
> +
> +   ret = regmap_read_poll_timeout(drv->regmap, status_reg,
slice_status,
> +   !(slice_status & status), 0,
LLCC_STATUS_READ_DELAY);
> +   return ret;
> +}
> +
> +/**
> + * llcc_slice_activate - Activate the llcc slice
> + * @desc: Pointer to llcc slice descriptor
> + *
> + * A value zero will be returned on success and a negative errno will

a value of zero

> + * be returned in error cases
> + */
> +int llcc_slice_activate(struct llcc_slice_desc *desc)
> +{
> +   int ret;
> +   u32 act_ctrl_val;
> +   struct llcc_drv_data *drv;
> +
> +   if (desc == NULL)
> +   return -EINVAL;

I think we can remove this check, right?

> +
> +   drv = dev_get_drvdata(desc->dev);
> +   if (!drv)
> +   return -EINVAL;
> +
> +   mutex_lock(>lock);
> +   if (test_bit(desc->slice_id, drv->bitmap)) {
> +   mutex_unlock(>lock);
> +   return 0;
> +   }
> +
> +   act_ctrl_val = ACT_CTRL_OPCODE_ACTIVATE << ACT_CTRL_OPCODE_SHIFT;
> +
> +   ret = llcc_update_act_ctrl(drv, desc->slice_id, act_ctrl_val,
> + DEACTIVATE);
> +
> +   __set_bit(desc->slice_id, drv->bitmap);
> +   mutex_unlock(>lock);
> +
> +   return ret;
> +}
> +EXPORT_SYMBOL_GPL(llcc_slice_activate);
> +
> +/**
> + * llcc_slice_deactivate - Deactivate the llcc slice
> + * @desc: Pointer to llcc slice descriptor
> + *
> + * A value zero will be returned on success and a negative errno will
> + * be returned in error cases
> + */
> +int llcc_slice_deactivate(struct llcc_slice_desc *desc)
> +{
> +   u32 act_ctrl_val;
> +   int ret;
> +   struct llcc_drv_data *drv;
> +
> +   if (desc == NULL)
> +   return -EINVAL;
> +
> +   drv = dev_get_drvdata(desc->dev);
> +   if 

Re: [PATCH v4 2/2] drivers: soc: Add LLCC driver

2018-04-10 Thread Jordan Crouse
On Tue, Apr 10, 2018 at 01:08:13PM -0700, Rishabh Bhatnagar wrote:
> LLCC (Last Level Cache Controller) provides additional cache memory
> in the system. LLCC is partitioned into multiple slices and each
> slice gets its own priority, size, ID and other config parameters.
> LLCC driver programs these parameters for each slice. Clients that
> are assigned to use LLCC need to get information such size & ID of the
> slice they get and activate or deactivate the slice as needed. LLCC driver
> provides API for the clients to perform these operations.
> 
> Signed-off-by: Channagoud Kadabi 
> Signed-off-by: Rishabh Bhatnagar 
> ---
>  drivers/soc/qcom/Kconfig   |  17 ++
>  drivers/soc/qcom/Makefile  |   2 +
>  drivers/soc/qcom/llcc-sdm845.c | 110 ++
>  drivers/soc/qcom/llcc-slice.c  | 404 
> +
>  include/linux/soc/qcom/llcc-qcom.h | 168 +++
>  5 files changed, 701 insertions(+)
>  create mode 100644 drivers/soc/qcom/llcc-sdm845.c
>  create mode 100644 drivers/soc/qcom/llcc-slice.c
>  create mode 100644 include/linux/soc/qcom/llcc-qcom.h



> diff --git a/drivers/soc/qcom/llcc-sdm845.c b/drivers/soc/qcom/llcc-sdm845.c
> new file mode 100644
> index 000..619b226
> --- /dev/null
> +++ b/drivers/soc/qcom/llcc-sdm845.c
> @@ -0,0 +1,110 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
> + *
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/*
> + * SCT(System Cache Table) entry contains of the following parameters
> + * name: Name of the client's use case for which the llcc slice is used
> + * uid: Unique id for the client's use case
> + * slice_id: llcc slice id for each client
> + * max_cap: The maximum capacity of the cache slice provided in KB
> + * priority: Priority of the client used to select victim line for 
> replacement
> + * fixed_size: Determine if the slice has a fixed capacity
> + * bonus_ways: Bonus ways are additional ways to be used for any slice,
> + *   if client ends up using more than reserved cache ways. Bonus
> + *   ways are allocated only if they are not reserved for some
> + *   other client.
> + * res_ways: Reserved ways for the cache slice, the reserved ways cannot
> + *   be used by any other client than the one its assigned to.
> + * cache_mode: Each slice operates as a cache, this controls the mode of the
> + * slice: normal or TCM(Tightly Coupled Memory)
> + * probe_target_ways: Determines what ways to probe for access hit. When
> + *configured to 1 only bonus and reserved ways are 
> probed.
> + *When configured to 0 all ways in llcc are probed.
> + * dis_cap_alloc: Disable capacity based allocation for a client
> + * retain_on_pc: If this bit is set and client has maintained active vote
> + *   then the ways assigned to this client are not flushed on 
> power
> + *   collapse.
> + * activate_on_init: Activate the slice immediately after the SCT is 
> programmed
> + */
> +#define SCT_ENTRY(n, uid, sid, mc, p, fs, bway, rway, cmod, ptw, dca, rp, a) 
> \
> + {   \
> + .name = n,  \
> + .usecase_id = uid,  \
> + .slice_id = sid,\
> + .max_cap = mc,  \
> + .priority = p,  \
> + .fixed_size = fs,   \
> + .bonus_ways = bway, \
> + .res_ways = rway,   \
> + .cache_mode = cmod, \
> + .probe_target_ways = ptw,   \
> + .dis_cap_alloc = dca,   \
> + .retain_on_pc = rp, \
> + .activate_on_init = a,  \
> + }
> +
> +

Extra blank line.

> +static struct llcc_slice_config sdm845_data[] =  {
> + SCT_ENTRY("cpuss",   1,  1,  2816, 1, 0, 0xffc, 0x2,   0, 0, 1, 1, 1),
> + SCT_ENTRY("vidsc0",  2,  2,  512,  2, 1, 0x0,   0x0f0, 0, 0, 1, 1, 0),
> + SCT_ENTRY("vidsc1",  3,  3,  512,  2, 1, 0x0,   0x0f0, 0, 0, 1, 1, 0),
> + SCT_ENTRY("rotator", 4,  4,  563,  2, 1, 0x0,   0x00e, 2, 0, 1, 1, 0),
> + SCT_ENTRY("voice",   5,  5,  2816, 1, 0, 0xffc, 0x2,   0, 0, 1, 1, 0),
> + SCT_ENTRY("audio",   6,  6,  2816, 1, 0, 0xffc, 0x2,   0, 0, 1, 1, 0),
> + SCT_ENTRY("mdmhpgr", 7,  7,  1024, 2, 0, 0xfc,  0xf00, 0, 0, 1, 1, 0),
> + SCT_ENTRY("modem",   8,  8,  2816, 1, 0, 0xffc, 0x2,   0, 0, 1, 1, 0),
> + SCT_ENTRY("compute", 10, 10, 2816, 1, 0, 0xffc, 0x2,   0, 0, 1, 1, 0),
> + SCT_ENTRY("gpuhtw",  11, 11, 512,  1, 1, 0xc,   0x0,   0, 0, 1, 1, 0),
> + SCT_ENTRY("gpu", 12, 12, 2304, 1, 0, 0xff0, 0x2,   0, 0, 1, 1, 0),
> + SCT_ENTRY("mmuhwt",  13, 13, 256,  2, 0, 0x0,   0x1,   

Re: [PATCH v4 2/2] drivers: soc: Add LLCC driver

2018-04-10 Thread Jordan Crouse
On Tue, Apr 10, 2018 at 01:08:13PM -0700, Rishabh Bhatnagar wrote:
> LLCC (Last Level Cache Controller) provides additional cache memory
> in the system. LLCC is partitioned into multiple slices and each
> slice gets its own priority, size, ID and other config parameters.
> LLCC driver programs these parameters for each slice. Clients that
> are assigned to use LLCC need to get information such size & ID of the
> slice they get and activate or deactivate the slice as needed. LLCC driver
> provides API for the clients to perform these operations.
> 
> Signed-off-by: Channagoud Kadabi 
> Signed-off-by: Rishabh Bhatnagar 
> ---
>  drivers/soc/qcom/Kconfig   |  17 ++
>  drivers/soc/qcom/Makefile  |   2 +
>  drivers/soc/qcom/llcc-sdm845.c | 110 ++
>  drivers/soc/qcom/llcc-slice.c  | 404 
> +
>  include/linux/soc/qcom/llcc-qcom.h | 168 +++
>  5 files changed, 701 insertions(+)
>  create mode 100644 drivers/soc/qcom/llcc-sdm845.c
>  create mode 100644 drivers/soc/qcom/llcc-slice.c
>  create mode 100644 include/linux/soc/qcom/llcc-qcom.h



> diff --git a/drivers/soc/qcom/llcc-sdm845.c b/drivers/soc/qcom/llcc-sdm845.c
> new file mode 100644
> index 000..619b226
> --- /dev/null
> +++ b/drivers/soc/qcom/llcc-sdm845.c
> @@ -0,0 +1,110 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
> + *
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/*
> + * SCT(System Cache Table) entry contains of the following parameters
> + * name: Name of the client's use case for which the llcc slice is used
> + * uid: Unique id for the client's use case
> + * slice_id: llcc slice id for each client
> + * max_cap: The maximum capacity of the cache slice provided in KB
> + * priority: Priority of the client used to select victim line for 
> replacement
> + * fixed_size: Determine if the slice has a fixed capacity
> + * bonus_ways: Bonus ways are additional ways to be used for any slice,
> + *   if client ends up using more than reserved cache ways. Bonus
> + *   ways are allocated only if they are not reserved for some
> + *   other client.
> + * res_ways: Reserved ways for the cache slice, the reserved ways cannot
> + *   be used by any other client than the one its assigned to.
> + * cache_mode: Each slice operates as a cache, this controls the mode of the
> + * slice: normal or TCM(Tightly Coupled Memory)
> + * probe_target_ways: Determines what ways to probe for access hit. When
> + *configured to 1 only bonus and reserved ways are 
> probed.
> + *When configured to 0 all ways in llcc are probed.
> + * dis_cap_alloc: Disable capacity based allocation for a client
> + * retain_on_pc: If this bit is set and client has maintained active vote
> + *   then the ways assigned to this client are not flushed on 
> power
> + *   collapse.
> + * activate_on_init: Activate the slice immediately after the SCT is 
> programmed
> + */
> +#define SCT_ENTRY(n, uid, sid, mc, p, fs, bway, rway, cmod, ptw, dca, rp, a) 
> \
> + {   \
> + .name = n,  \
> + .usecase_id = uid,  \
> + .slice_id = sid,\
> + .max_cap = mc,  \
> + .priority = p,  \
> + .fixed_size = fs,   \
> + .bonus_ways = bway, \
> + .res_ways = rway,   \
> + .cache_mode = cmod, \
> + .probe_target_ways = ptw,   \
> + .dis_cap_alloc = dca,   \
> + .retain_on_pc = rp, \
> + .activate_on_init = a,  \
> + }
> +
> +

Extra blank line.

> +static struct llcc_slice_config sdm845_data[] =  {
> + SCT_ENTRY("cpuss",   1,  1,  2816, 1, 0, 0xffc, 0x2,   0, 0, 1, 1, 1),
> + SCT_ENTRY("vidsc0",  2,  2,  512,  2, 1, 0x0,   0x0f0, 0, 0, 1, 1, 0),
> + SCT_ENTRY("vidsc1",  3,  3,  512,  2, 1, 0x0,   0x0f0, 0, 0, 1, 1, 0),
> + SCT_ENTRY("rotator", 4,  4,  563,  2, 1, 0x0,   0x00e, 2, 0, 1, 1, 0),
> + SCT_ENTRY("voice",   5,  5,  2816, 1, 0, 0xffc, 0x2,   0, 0, 1, 1, 0),
> + SCT_ENTRY("audio",   6,  6,  2816, 1, 0, 0xffc, 0x2,   0, 0, 1, 1, 0),
> + SCT_ENTRY("mdmhpgr", 7,  7,  1024, 2, 0, 0xfc,  0xf00, 0, 0, 1, 1, 0),
> + SCT_ENTRY("modem",   8,  8,  2816, 1, 0, 0xffc, 0x2,   0, 0, 1, 1, 0),
> + SCT_ENTRY("compute", 10, 10, 2816, 1, 0, 0xffc, 0x2,   0, 0, 1, 1, 0),
> + SCT_ENTRY("gpuhtw",  11, 11, 512,  1, 1, 0xc,   0x0,   0, 0, 1, 1, 0),
> + SCT_ENTRY("gpu", 12, 12, 2304, 1, 0, 0xff0, 0x2,   0, 0, 1, 1, 0),
> + SCT_ENTRY("mmuhwt",  13, 13, 256,  2, 0, 0x0,   0x1,   0, 0, 1, 0, 1),
> + SCT_ENTRY("cmptdma", 15, 

[PATCH v4 2/2] drivers: soc: Add LLCC driver

2018-04-10 Thread Rishabh Bhatnagar
LLCC (Last Level Cache Controller) provides additional cache memory
in the system. LLCC is partitioned into multiple slices and each
slice gets its own priority, size, ID and other config parameters.
LLCC driver programs these parameters for each slice. Clients that
are assigned to use LLCC need to get information such size & ID of the
slice they get and activate or deactivate the slice as needed. LLCC driver
provides API for the clients to perform these operations.

Signed-off-by: Channagoud Kadabi 
Signed-off-by: Rishabh Bhatnagar 
---
 drivers/soc/qcom/Kconfig   |  17 ++
 drivers/soc/qcom/Makefile  |   2 +
 drivers/soc/qcom/llcc-sdm845.c | 110 ++
 drivers/soc/qcom/llcc-slice.c  | 404 +
 include/linux/soc/qcom/llcc-qcom.h | 168 +++
 5 files changed, 701 insertions(+)
 create mode 100644 drivers/soc/qcom/llcc-sdm845.c
 create mode 100644 drivers/soc/qcom/llcc-slice.c
 create mode 100644 include/linux/soc/qcom/llcc-qcom.h

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index e050eb8..2b09321 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -21,6 +21,23 @@ config QCOM_GSBI
   functions for connecting the underlying serial UART, SPI, and I2C
   devices to the output pins.

+config QCOM_LLCC
+   tristate "Qualcomm Technologies, Inc. LLCC driver"
+   depends on ARCH_QCOM
+   help
+ Qualcomm Technologies, Inc. platform specific
+ Last Level Cache Controller(LLCC) driver. This provides interfaces
+ to client's that use the LLCC. Say yes here to enable LLCC slice
+ driver.
+
+config QCOM_SDM845_LLCC
+   tristate "Qualcomm Technologies, Inc. SDM845 LLCC driver"
+   depends on QCOM_LLCC
+   help
+ Say yes here to enable the LLCC driver for SDM845. This provides
+ data required to configure LLCC so that clients can start using the
+ LLCC slices.
+
 config QCOM_MDT_LOADER
tristate
select QCOM_SCM
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index dcebf28..e16d6a2 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -12,3 +12,5 @@ obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o
 obj-$(CONFIG_QCOM_SMP2P)   += smp2p.o
 obj-$(CONFIG_QCOM_SMSM)+= smsm.o
 obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o
+obj-$(CONFIG_QCOM_LLCC) += llcc-slice.o
+obj-$(CONFIG_QCOM_SDM845_LLCC) += llcc-sdm845.o
diff --git a/drivers/soc/qcom/llcc-sdm845.c b/drivers/soc/qcom/llcc-sdm845.c
new file mode 100644
index 000..619b226
--- /dev/null
+++ b/drivers/soc/qcom/llcc-sdm845.c
@@ -0,0 +1,110 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * SCT(System Cache Table) entry contains of the following parameters
+ * name: Name of the client's use case for which the llcc slice is used
+ * uid: Unique id for the client's use case
+ * slice_id: llcc slice id for each client
+ * max_cap: The maximum capacity of the cache slice provided in KB
+ * priority: Priority of the client used to select victim line for replacement
+ * fixed_size: Determine if the slice has a fixed capacity
+ * bonus_ways: Bonus ways are additional ways to be used for any slice,
+ * if client ends up using more than reserved cache ways. Bonus
+ * ways are allocated only if they are not reserved for some
+ * other client.
+ * res_ways: Reserved ways for the cache slice, the reserved ways cannot
+ * be used by any other client than the one its assigned to.
+ * cache_mode: Each slice operates as a cache, this controls the mode of the
+ * slice: normal or TCM(Tightly Coupled Memory)
+ * probe_target_ways: Determines what ways to probe for access hit. When
+ *configured to 1 only bonus and reserved ways are probed.
+ *When configured to 0 all ways in llcc are probed.
+ * dis_cap_alloc: Disable capacity based allocation for a client
+ * retain_on_pc: If this bit is set and client has maintained active vote
+ *   then the ways assigned to this client are not flushed on power
+ *   collapse.
+ * activate_on_init: Activate the slice immediately after the SCT is programmed
+ */
+#define SCT_ENTRY(n, uid, sid, mc, p, fs, bway, rway, cmod, ptw, dca, rp, a) \
+   {   \
+   .name = n,  \
+   .usecase_id = uid,  \
+   .slice_id = sid,\
+   .max_cap = mc,  \
+   .priority = p,  \
+   .fixed_size = fs,   \
+   .bonus_ways = bway, \
+   .res_ways = rway,   \
+  

[PATCH v4 2/2] drivers: soc: Add LLCC driver

2018-04-10 Thread Rishabh Bhatnagar
LLCC (Last Level Cache Controller) provides additional cache memory
in the system. LLCC is partitioned into multiple slices and each
slice gets its own priority, size, ID and other config parameters.
LLCC driver programs these parameters for each slice. Clients that
are assigned to use LLCC need to get information such size & ID of the
slice they get and activate or deactivate the slice as needed. LLCC driver
provides API for the clients to perform these operations.

Signed-off-by: Channagoud Kadabi 
Signed-off-by: Rishabh Bhatnagar 
---
 drivers/soc/qcom/Kconfig   |  17 ++
 drivers/soc/qcom/Makefile  |   2 +
 drivers/soc/qcom/llcc-sdm845.c | 110 ++
 drivers/soc/qcom/llcc-slice.c  | 404 +
 include/linux/soc/qcom/llcc-qcom.h | 168 +++
 5 files changed, 701 insertions(+)
 create mode 100644 drivers/soc/qcom/llcc-sdm845.c
 create mode 100644 drivers/soc/qcom/llcc-slice.c
 create mode 100644 include/linux/soc/qcom/llcc-qcom.h

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index e050eb8..2b09321 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -21,6 +21,23 @@ config QCOM_GSBI
   functions for connecting the underlying serial UART, SPI, and I2C
   devices to the output pins.

+config QCOM_LLCC
+   tristate "Qualcomm Technologies, Inc. LLCC driver"
+   depends on ARCH_QCOM
+   help
+ Qualcomm Technologies, Inc. platform specific
+ Last Level Cache Controller(LLCC) driver. This provides interfaces
+ to client's that use the LLCC. Say yes here to enable LLCC slice
+ driver.
+
+config QCOM_SDM845_LLCC
+   tristate "Qualcomm Technologies, Inc. SDM845 LLCC driver"
+   depends on QCOM_LLCC
+   help
+ Say yes here to enable the LLCC driver for SDM845. This provides
+ data required to configure LLCC so that clients can start using the
+ LLCC slices.
+
 config QCOM_MDT_LOADER
tristate
select QCOM_SCM
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index dcebf28..e16d6a2 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -12,3 +12,5 @@ obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o
 obj-$(CONFIG_QCOM_SMP2P)   += smp2p.o
 obj-$(CONFIG_QCOM_SMSM)+= smsm.o
 obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o
+obj-$(CONFIG_QCOM_LLCC) += llcc-slice.o
+obj-$(CONFIG_QCOM_SDM845_LLCC) += llcc-sdm845.o
diff --git a/drivers/soc/qcom/llcc-sdm845.c b/drivers/soc/qcom/llcc-sdm845.c
new file mode 100644
index 000..619b226
--- /dev/null
+++ b/drivers/soc/qcom/llcc-sdm845.c
@@ -0,0 +1,110 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * SCT(System Cache Table) entry contains of the following parameters
+ * name: Name of the client's use case for which the llcc slice is used
+ * uid: Unique id for the client's use case
+ * slice_id: llcc slice id for each client
+ * max_cap: The maximum capacity of the cache slice provided in KB
+ * priority: Priority of the client used to select victim line for replacement
+ * fixed_size: Determine if the slice has a fixed capacity
+ * bonus_ways: Bonus ways are additional ways to be used for any slice,
+ * if client ends up using more than reserved cache ways. Bonus
+ * ways are allocated only if they are not reserved for some
+ * other client.
+ * res_ways: Reserved ways for the cache slice, the reserved ways cannot
+ * be used by any other client than the one its assigned to.
+ * cache_mode: Each slice operates as a cache, this controls the mode of the
+ * slice: normal or TCM(Tightly Coupled Memory)
+ * probe_target_ways: Determines what ways to probe for access hit. When
+ *configured to 1 only bonus and reserved ways are probed.
+ *When configured to 0 all ways in llcc are probed.
+ * dis_cap_alloc: Disable capacity based allocation for a client
+ * retain_on_pc: If this bit is set and client has maintained active vote
+ *   then the ways assigned to this client are not flushed on power
+ *   collapse.
+ * activate_on_init: Activate the slice immediately after the SCT is programmed
+ */
+#define SCT_ENTRY(n, uid, sid, mc, p, fs, bway, rway, cmod, ptw, dca, rp, a) \
+   {   \
+   .name = n,  \
+   .usecase_id = uid,  \
+   .slice_id = sid,\
+   .max_cap = mc,  \
+   .priority = p,  \
+   .fixed_size = fs,   \
+   .bonus_ways = bway, \
+   .res_ways = rway,   \
+   .cache_mode = cmod, \
+