Skip to contentSkip to conversation

SDM845 System Cache Driver

PATCH Superseded Rishabh Bhatnagar 4 participants 11 messages May 16, 2018 – May 23, 2018

Subsystems (3)

v7 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v7 cover SDM845 System Cache Driver

This series implements system cache or LLCC(Last Level Cache Controller) driver for SDM845 SOC. The purpose of the driver is to partition the system cache and program the settings such as priortiy, lines to probe while doing a look up in the system cache, low power related settings etc. The partitions are called cache slices. Each cache slice is associated with size and SCID(System Cache ID). The driver also provides API for clients to query the cache slice details,activate and deactivate them.

The driver can be broadly classified into:
* SOC specific driver: llcc-sdm845.c: Cache partitioning and cache slice properties for usecases on sdm845 that need to use system cache.

* API : llcc-slice.c: Exports APIs to clients to query cache slice details, activate and deactivate cache slices.

Changes since v6:
* Remove the max-slices property from DT.
* Make client's slice_ids as macros.
* Unlock mutex while returning from function in case of error.

Changes since v5:
* Remove client information from DT.
* Make the llcc driver data as global.
* Check return value of llcc_update_act_ctrl function
* Change error returned from -EFAULT to -EINVAL

Changes since v4:
* Remove null pointer checks as per comments.
* Remove extra blank lines.

Changes since v3:
* Use the regmap_read_poll_timeout function
* Check for regmap read/write errors.
* Remove memory barrier after regmap write
* Derive memory bank offsets using stride macro variable
* Remove debug statements from code
* Remove the qcom_llcc_remove function
* Use if IS_ENABLED in place of ifdef for built-in module
* Change EXPORT_SYMBOL to EXPORT_SYMBOL_GPL
* Remove unnecessary free functions
* Change the variable names as per review comments

Changes since v2:
* Corrected the Makefile to fix compilation.

Changes since v1:
* Added Makefile and Kconfig.

Changes since v0:
* Removed the syscon and simple-mfd approach
* Updated the device tree nodes to mention LLCC as a single HW block
* Moved llcc bank offsets from device tree and handled the offset in the driver.

ckadabi at codeaurora.org (2):
dt-bindings: Documentation for qcom, llcc
drivers: soc: Add LLCC driver

 .../devicetree/bindings/arm/msm/qcom,llcc.txt      |  26 ++
 drivers/soc/qcom/Kconfig                           |  17 ++
 drivers/soc/qcom/Makefile                          |   2 +
 drivers/soc/qcom/llcc-sdm845.c                     | 106 +++++++
 drivers/soc/qcom/llcc-slice.c                      | 337 +++++++++++++++++++++
 include/linux/soc/qcom/llcc-qcom.h                 | 180 +++++++++++
 6 files changed, 668 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
 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
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#1 lore raw

PATCH v7 1/2 dt-bindings: Documentation for qcom, llcc

Documentation for last level cache controller device tree bindings, client bindings usage examples.

---
 .../devicetree/bindings/arm/msm/qcom,llcc.txt      | 26 ++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt new file +26 -0
new file mode 100644
index 0000000..0ebbf0a
@@ -0,0 +1,26 @@
+== Introduction==
+
+LLCC (Last Level Cache Controller) provides last level of cache memory in SOC,
+that can be shared by multiple clients. Clients here are different cores in the
+SOC, the idea is to minimize the local caches at the clients and migrate to
+common pool of memory. Cache memory is divided into partitions called slices
+which are assigned to clients. Clients can query the slice details, activate
+and deactivate them.
+
+Properties:
+- compatible:
+	Usage: required
+	Value type: <string>
+	Definition: must be "qcom,sdm845-llcc"
+
+- reg:
+	Usage: required
+	Value Type: <prop-encoded-array>
+	Definition: Start address and the the size of the register region.
+
+Example:
+
+	qcom,llcc at 1100000 {
+		compatible = "qcom,sdm845-llcc";
+		reg = <0x1100000 0x250000>;
+	};
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
maintainer Reviewed-by on v7 1/2
#2 lore raw

Re: [PATCH v7 1/2] dt-bindings: Documentation for qcom, llcc

Quoted 9 lines · Rishabh Bhatnagar

Documentation for last level cache controller device tree bindings, client bindings usage examples.

---
 .../devicetree/bindings/arm/msm/qcom,llcc.txt      | 26 ++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt

Other than the node name discussed in v6,

#3 lore raw

PATCH v7 2/2 drivers: soc: Add LLCC driver

In reply to 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.

---
 drivers/soc/qcom/Kconfig           |  17 ++
 drivers/soc/qcom/Makefile          |   2 +
 drivers/soc/qcom/llcc-sdm845.c     | 106 ++++++++++++
 drivers/soc/qcom/llcc-slice.c      | 337 +++++++++++++++++++++++++++++++++++++
 include/linux/soc/qcom/llcc-qcom.h | 180 ++++++++++++++++++++
 5 files changed, 642 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
drivers/soc/qcom/Kconfig +17 -0
index e050eb8..0b550f9 100644
@@ -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 clients 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
drivers/soc/qcom/Makefile +2 -0
index dcebf28..e16d6a2 100644
@@ -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
drivers/soc/qcom/llcc-sdm845.c new file +106 -0

106 lines not on this page · raw message

drivers/soc/qcom/llcc-slice.c new file +337 -0

337 lines not on this page · raw message

include/linux/soc/qcom/llcc-qcom.h new file +180 -0

180 lines not on this page · raw message

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
Reviewed-by on v7 2/2
#4 lore raw

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

Quoted 8 lines · 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.

Quoted 7 lines
---
  drivers/soc/qcom/Kconfig           |  17 ++
  drivers/soc/qcom/Makefile          |   2 +
  drivers/soc/qcom/llcc-sdm845.c     | 106 ++++++++++++
  drivers/soc/qcom/llcc-slice.c      | 337

+++++++++++++++++++++++++++++++++++++

Quoted 5 lines
  include/linux/soc/qcom/llcc-qcom.h | 180 ++++++++++++++++++++
  5 files changed, 642 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

Thanks Rishabh.

#5 lore raw

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

In reply to Rishabh Bhatnagar

drivers/soc/qcom/llcc-sdm845.c line 81

Quoted 12 lines · 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.

drivers/soc/qcom/llcc-sdm845.c new file +3 -0
+static const struct of_device_id sdm845_qcom_llcc_of_match[] = {
+       { .compatible = "qcom,sdm845-llcc", },
 
+       { },

Slightly better w/o comma

drivers/soc/qcom/llcc-sdm845.c line 87

Quoted 7 lines
drivers/soc/qcom/llcc-sdm845.c new file +5 -0
+};
 
+static struct platform_driver sdm845_qcom_llcc_driver = {
+       .driver = {
+               .name = "sdm845-llcc",
 
+               .owner = THIS_MODULE,

No need. See below.

Quoted 7 lines
drivers/soc/qcom/llcc-sdm845.c new file +6 -0
+               .of_match_table = sdm845_qcom_llcc_of_match,
+       },
+       .probe = sdm845_qcom_llcc_probe,
+};
 
+
+static int __init sdm845_init_qcom_llcc_init(void)

drivers/soc/qcom/llcc-sdm845.c line 103

Quoted 10 lines
drivers/soc/qcom/llcc-sdm845.c new file +10 -0
+{
+       return platform_driver_register(&sdm845_qcom_llcc_driver);
+}
+module_init(sdm845_init_qcom_llcc_init);
+
+static void __exit sdm845_exit_qcom_llcc_exit(void)
+{
+       platform_driver_unregister(&sdm845_qcom_llcc_driver);
+}
+module_exit(sdm845_exit_qcom_llcc_exit);

Why not to use module_platform_driver() macro?

drivers/soc/qcom/llcc-slice.c line 22

Quoted 5 lines
drivers/soc/qcom/llcc-slice.c new file +5 -0
+#define ACTIVATE                      0x1
+#define DEACTIVATE                    0x2
+#define ACT_CTRL_OPCODE_ACTIVATE      0x1
+#define ACT_CTRL_OPCODE_DEACTIVATE    0x2
+#define ACT_CTRL_ACT_TRIG             0x1

Are these bits? Perhaps BIT() ?

drivers/soc/qcom/llcc-slice.c line 27

Quoted 5 lines
drivers/soc/qcom/llcc-slice.c new file +5 -0
+#define ACT_CTRL_OPCODE_SHIFT         0x1
+#define ATTR1_PROBE_TARGET_WAYS_SHIFT 0x2
+#define ATTR1_FIXED_SIZE_SHIFT        0x3
+#define ATTR1_PRIORITY_SHIFT          0x4
+#define ATTR1_MAX_CAP_SHIFT           0x10

Better to use fixed size pattern, i.e. 0x01, 0x02, 0x03, 0x04, 0x10.

drivers/soc/qcom/llcc-slice.c line 29

Quoted 2 lines
drivers/soc/qcom/llcc-slice.c new file +2 -0
+#define ATTR0_RES_WAYS_MASK           0x00000fff
+#define ATTR0_BONUS_WAYS_MASK         0x0fff0000

GENMASK()

Quoted 1 line

+#define LLCC_LB_CNT_MASK 0xf0000000

Ditto.

Quoted 1 line

+#define MAX_CAP_TO_BYTES(n) (n * 1024)

(n * SZ_1K) ?

Quoted 1 line

+#define LLCC_TRP_ACT_CTRLn(n) (n * 0x1000)

SZ_4K ?

Quoted 1 line

+#define LLCC_TRP_STATUSn(n) (4 + n * 0x1000)

Ditto.

Quoted 8 lines
drivers/soc/qcom/llcc-slice.c new file +8 -0
+struct llcc_slice_desc *llcc_slice_getd(u32 uid)
+{
+       const struct llcc_slice_config *cfg;
+       struct llcc_slice_desc *desc;
+       u32 sz, count = 0;
+
+       cfg = drv_data->cfg;
+       sz = drv_data->cfg_size;

drivers/soc/qcom/llcc-slice.c line 79

Quoted 10 lines
drivers/soc/qcom/llcc-slice.c new file +9 -0
+
 
+       while (cfg && count < sz) {
+               if (cfg->usecase_id == uid)
+                       break;
+               cfg++;
+               count++;
+       }
+       if (cfg == NULL || count == sz)
+               return ERR_PTR(-ENODEV);

if (!cfg)

          return ERR_PTR(-ENODEV);

while (cfg->... != uid) {
cfg++;
count++;
}

if (count == sz)
return ...

Though I would rather put it to for () loop.

drivers/soc/qcom/llcc-slice.c line 108

Quoted 8 lines
drivers/soc/qcom/llcc-slice.c new file +7 -0
+static int llcc_update_act_ctrl(u32 sid,
+                               u32 act_ctrl_reg_val, u32 status)
+{
+       u32 act_ctrl_reg;
+       u32 status_reg;
+       u32 slice_status;
 
+       int ret = 0;

Useless assignment. Check entire patch series for a such.

drivers/soc/qcom/llcc-slice.c line 126

Quoted 2 lines
drivers/soc/qcom/llcc-slice.c new file +2 -0
+       ret = regmap_read_poll_timeout(drv_data->regmap, status_reg,
+       slice_status, !(slice_status & status), 0, LLCC_STATUS_READ_DELAY);

Wrong indentation.

drivers/soc/qcom/llcc-slice.c line 151

Quoted 5 lines
drivers/soc/qcom/llcc-slice.c new file +4 -0
+       return ret;
+}
 
+       ret = llcc_update_act_ctrl(desc->slice_id, act_ctrl_val,
+                                 DEACTIVATE);

Perhaps one line (~83 characters here is OK) ?

Review

Quoted 2 lines
(quoted diff) +2 -0
+       ret = llcc_update_act_ctrl(desc->slice_id, act_ctrl_val,
+                                 ACTIVATE);

Ditto.

drivers/soc/qcom/llcc-slice.c line 238

Quoted 4 lines
drivers/soc/qcom/llcc-slice.c new file +4 -0
+               attr1_cfg = bcast_off +
+                               LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);
+               attr0_cfg = bcast_off +
+                               LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);

Ditto.

drivers/soc/qcom/llcc-slice.c line 245

Quoted 5 lines
drivers/soc/qcom/llcc-slice.c new file +5 -0
+               attr1_val |= llcc_table[i].probe_target_ways <<
+                               ATTR1_PROBE_TARGET_WAYS_SHIFT;
+               attr1_val |= llcc_table[i].fixed_size <<
+                               ATTR1_FIXED_SIZE_SHIFT;
+               attr1_val |= llcc_table[i].priority << ATTR1_PRIORITY_SHIFT;

foo |=
bar << SHIFT;

would look slightly better.

drivers/soc/qcom/llcc-slice.c line 316

Quoted 8 lines
drivers/soc/qcom/llcc-slice.c new file +7 -0
+int qcom_llcc_probe(struct platform_device *pdev,
+                     const struct llcc_slice_config *llcc_cfg, u32 sz)
+{
 
+       drv_data->offsets = devm_kzalloc(dev, num_banks * sizeof(u32),
+                                                       GFP_KERNEL);
+       if (!drv_data->offsets)
+               return -ENOMEM;

devm_kcalloc() ?

drivers/soc/qcom/llcc-slice.c line 319

Quoted 3 lines
drivers/soc/qcom/llcc-slice.c new file +3 -0
+
+       for (i = 0; i < num_banks; i++)
+               drv_data->offsets[i] = (i * BANK_OFFSET_STRIDE);

Pointless parens.

drivers/soc/qcom/llcc-slice.c line 327

Quoted 5 lines
drivers/soc/qcom/llcc-slice.c new file +5 -0
+       drv_data->bitmap = devm_kcalloc(dev,
+       BITS_TO_LONGS(drv_data->max_slices), sizeof(unsigned long),
+                                               GFP_KERNEL);
+       if (!drv_data->bitmap)
+               return -ENOMEM;

Perhaps at some point someone will add
bitmap_alloc()
devm_bitmap_alloc()

Quoted 1 line

+ bitmap_zero(drv_data->bitmap, drv_data->max_slices);

Pointless

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw

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

Quoted 11 lines · Andy Shevchenko
Quoted 8 lines · 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.

Quoted 6 lines

drivers/soc/qcom/llcc-sdm845.c line 81

Quoted 4 lines
drivers/soc/qcom/llcc-sdm845.c new file +3 -0
+static const struct of_device_id sdm845_qcom_llcc_of_match[] = {
+       { .compatible = "qcom,sdm845-llcc", },
 
+       { },

Slightly better w/o comma

Changed

Quoted 16 lines

drivers/soc/qcom/llcc-sdm845.c line 87

Quoted 8 lines
drivers/soc/qcom/llcc-sdm845.c new file +5 -0
+};
 
+static struct platform_driver sdm845_qcom_llcc_driver = {
+       .driver = {
+               .name = "sdm845-llcc",
 
+               .owner = THIS_MODULE,

No need. See below.

Quoted 4 lines
drivers/soc/qcom/llcc-sdm845.c new file +4 -0
+               .of_match_table = sdm845_qcom_llcc_of_match,
+       },
+       .probe = sdm845_qcom_llcc_probe,
+};
Quoted 14 lines

drivers/soc/qcom/llcc-sdm845.c line 103

Quoted 12 lines
drivers/soc/qcom/llcc-sdm845.c new file +12 -0
+
+static int __init sdm845_init_qcom_llcc_init(void)
+{
+       return platform_driver_register(&sdm845_qcom_llcc_driver);
+}
+module_init(sdm845_init_qcom_llcc_init);
+
+static void __exit sdm845_exit_qcom_llcc_exit(void)
+{
+       platform_driver_unregister(&sdm845_qcom_llcc_driver);
+}
+module_exit(sdm845_exit_qcom_llcc_exit);

Why not to use module_platform_driver() macro?

Done

Quoted 9 lines

drivers/soc/qcom/llcc-slice.c line 22

Quoted 6 lines
drivers/soc/qcom/llcc-slice.c new file +5 -0
+#define ACTIVATE                      0x1
+#define DEACTIVATE                    0x2
+#define ACT_CTRL_OPCODE_ACTIVATE      0x1
+#define ACT_CTRL_OPCODE_DEACTIVATE    0x2
+#define ACT_CTRL_ACT_TRIG             0x1

Are these bits? Perhaps BIT() ?

isn't it just better to use fixed size as u suggest in the next comment?

Quoted 8 lines

drivers/soc/qcom/llcc-slice.c line 27

Quoted 5 lines
drivers/soc/qcom/llcc-slice.c new file +5 -0
+#define ACT_CTRL_OPCODE_SHIFT         0x1
+#define ATTR1_PROBE_TARGET_WAYS_SHIFT 0x2
+#define ATTR1_FIXED_SIZE_SHIFT        0x3
+#define ATTR1_PRIORITY_SHIFT          0x4
+#define ATTR1_MAX_CAP_SHIFT           0x10

Better to use fixed size pattern, i.e. 0x01, 0x02, 0x03, 0x04, 0x10.

Quoted 4 lines

drivers/soc/qcom/llcc-slice.c line 29

Quoted 2 lines
drivers/soc/qcom/llcc-slice.c new file +2 -0
+#define ATTR0_RES_WAYS_MASK           0x00000fff
+#define ATTR0_BONUS_WAYS_MASK         0x0fff0000

GENMASK()

Done

Quoted 8 lines
Quoted 2 lines

+#define LLCC_LB_CNT_MASK 0xf0000000

Ditto.

Quoted 1 line

+#define MAX_CAP_TO_BYTES(n) (n * 1024)

(n * SZ_1K) ?

Done

Quoted 36 lines
Quoted 2 lines

+#define LLCC_TRP_ACT_CTRLn(n) (n * 0x1000)

SZ_4K ?

Quoted 1 line

+#define LLCC_TRP_STATUSn(n) (4 + n * 0x1000)

Ditto.

Quoted 8 lines
drivers/soc/qcom/llcc-slice.c new file +8 -0
+struct llcc_slice_desc *llcc_slice_getd(u32 uid)
+{
+       const struct llcc_slice_config *cfg;
+       struct llcc_slice_desc *desc;
+       u32 sz, count = 0;
+
+       cfg = drv_data->cfg;
+       sz = drv_data->cfg_size;

drivers/soc/qcom/llcc-slice.c line 79

Quoted 10 lines
drivers/soc/qcom/llcc-slice.c new file +9 -0
+
 
+       while (cfg && count < sz) {
+               if (cfg->usecase_id == uid)
+                       break;
+               cfg++;
+               count++;
+       }
+       if (cfg == NULL || count == sz)
+               return ERR_PTR(-ENODEV);

if (!cfg)

          return ERR_PTR(-ENODEV);

while (cfg->... != uid) {
cfg++;
count++;
}

Quoted 5 lines

if (count == sz)
return ...

Though I would rather put it to for () loop.

In each while loop iteration the cfg pointer needs to be checked for NULL. What if the usecase id never matches the uid passed by client and we keep iterating. At some point it will crash.

Quoted 10 lines

drivers/soc/qcom/llcc-slice.c line 108

Quoted 8 lines
drivers/soc/qcom/llcc-slice.c new file +7 -0
+static int llcc_update_act_ctrl(u32 sid,
+                               u32 act_ctrl_reg_val, u32 status)
+{
+       u32 act_ctrl_reg;
+       u32 status_reg;
+       u32 slice_status;
 
+       int ret = 0;

Useless assignment. Check entire patch series for a such.

Checked and removed these.

Quoted 6 lines
Quoted 4 lines
(quoted diff) +2 -0
+       ret = regmap_read_poll_timeout(drv_data->regmap, status_reg,
+       slice_status, !(slice_status & status), 0, 

LLCC_STATUS_READ_DELAY);

Wrong indentation.

Corrected

Quoted 8 lines

drivers/soc/qcom/llcc-slice.c line 151

Quoted 6 lines
drivers/soc/qcom/llcc-slice.c new file +4 -0
+       return ret;
+}
 
+       ret = llcc_update_act_ctrl(desc->slice_id, act_ctrl_val,
+                                 DEACTIVATE);

Perhaps one line (~83 characters here is OK) ?

The checkpatch script complains about such lines.

Quoted 32 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+       ret = llcc_update_act_ctrl(desc->slice_id, act_ctrl_val,
+                                 ACTIVATE);

Ditto.

Quoted 6 lines
drivers/soc/qcom/llcc-slice.c new file +2 -0
+               attr1_cfg = bcast_off +
+                               

LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);

drivers/soc/qcom/llcc-slice.c new file +2 -0
+               attr0_cfg = bcast_off +
+                               

LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);

Ditto.

Quoted 6 lines
drivers/soc/qcom/llcc-slice.c new file +5 -0
+               attr1_val |= llcc_table[i].probe_target_ways <<
+                               ATTR1_PROBE_TARGET_WAYS_SHIFT;
+               attr1_val |= llcc_table[i].fixed_size <<
+                               ATTR1_FIXED_SIZE_SHIFT;
+               attr1_val |= llcc_table[i].priority << 

ATTR1_PRIORITY_SHIFT;

foo |=
bar << SHIFT;

would look slightly better.

Quoted 4 lines
(quoted diff) +2 -0
+int qcom_llcc_probe(struct platform_device *pdev,
+                     const struct llcc_slice_config *llcc_cfg, u32 

sz)
+{

Quoted 6 lines

drivers/soc/qcom/llcc-slice.c line 316

Quoted 4 lines
drivers/soc/qcom/llcc-slice.c new file +4 -0
+       drv_data->offsets = devm_kzalloc(dev, num_banks * sizeof(u32),
+                                                       GFP_KERNEL);
+       if (!drv_data->offsets)
+               return -ENOMEM;

devm_kcalloc() ?

changed

Quoted 5 lines

drivers/soc/qcom/llcc-slice.c line 319

Quoted 3 lines
drivers/soc/qcom/llcc-slice.c new file +3 -0
+
+       for (i = 0; i < num_banks; i++)
+               drv_data->offsets[i] = (i * BANK_OFFSET_STRIDE);

Pointless parens.

Removed

Quoted 7 lines

drivers/soc/qcom/llcc-slice.c line 327

Quoted 6 lines
drivers/soc/qcom/llcc-slice.c new file +5 -0
+       drv_data->bitmap = devm_kcalloc(dev,
+       BITS_TO_LONGS(drv_data->max_slices), sizeof(unsigned long),
+                                               GFP_KERNEL);
+       if (!drv_data->bitmap)
+               return -ENOMEM;
Quoted 7 lines

Perhaps at some point someone will add
bitmap_alloc()
devm_bitmap_alloc()

Quoted 1 line

+ bitmap_zero(drv_data->bitmap, drv_data->max_slices);

Pointless

Removed

#7 lore raw

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

Quoted 13 lines · On Tue, May 22, 2018 at 9:33 PM, <[email protected]> wrote:
Quoted 12 lines · Andy Shevchenko

drivers/soc/qcom/llcc-slice.c line 22

Quoted 5 lines · Rishabh Bhatnagar
drivers/soc/qcom/llcc-slice.c new file +5 -0
+#define ACTIVATE                      0x1
+#define DEACTIVATE                    0x2
+#define ACT_CTRL_OPCODE_ACTIVATE      0x1
+#define ACT_CTRL_OPCODE_DEACTIVATE    0x2
+#define ACT_CTRL_ACT_TRIG             0x1

Are these bits? Perhaps BIT() ?

Quoted 1 line

isn't it just better to use fixed size as u suggest in the next comment?

If the are bits, use BIT() macro.

Quoted 29 lines
Quoted 29 lines
Quoted 9 lines
drivers/soc/qcom/llcc-slice.c new file +9 -0
+struct llcc_slice_desc *llcc_slice_getd(u32 uid)
+{
+       const struct llcc_slice_config *cfg;
+       struct llcc_slice_desc *desc;
+       u32 sz, count = 0;
+
+       cfg = drv_data->cfg;
+       sz = drv_data->cfg_size;
+

drivers/soc/qcom/llcc-slice.c line 79

Quoted 10 lines
drivers/soc/qcom/llcc-slice.c new file +8 -0
 
 
+       while (cfg && count < sz) {
+               if (cfg->usecase_id == uid)
+                       break;
+               cfg++;
+               count++;
+       }
+       if (cfg == NULL || count == sz)
+               return ERR_PTR(-ENODEV);

if (!cfg)

          return ERR_PTR(-ENODEV);

while (cfg->... != uid) {
cfg++;
count++;
}

Quoted 8 lines
Quoted 5 lines

if (count == sz)
return ...

Though I would rather put it to for () loop.

In each while loop iteration the cfg pointer needs to be checked for NULL. What if the usecase id never matches the uid passed by client and we keep iterating. At some point it will crash.

do {
if (!cfg || count == sz)
return ...(-ENODEV);
...
} while (...);

Though, as I said for-loop will look slightly better I think.

Quoted 7 lines
Quoted 5 lines

drivers/soc/qcom/llcc-slice.c line 151

Quoted 2 lines
drivers/soc/qcom/llcc-slice.c new file +2 -0
+       ret = llcc_update_act_ctrl(desc->slice_id, act_ctrl_val,
+                                 DEACTIVATE);

Perhaps one line (~83 characters here is OK) ?

The checkpatch script complains about such lines.

So what if it just 3 characters out?

Quoted 21 lines
Quoted 20 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+       ret = llcc_update_act_ctrl(desc->slice_id, act_ctrl_val,
+                                 ACTIVATE);

Ditto.

Quoted 6 lines
drivers/soc/qcom/llcc-slice.c new file +2 -0
+               attr1_cfg = bcast_off +
+

LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);

drivers/soc/qcom/llcc-slice.c new file +2 -0
+               attr0_cfg = bcast_off +
+

LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);

Ditto.

Quoted 6 lines
drivers/soc/qcom/llcc-slice.c new file +5 -0
+               attr1_val |= llcc_table[i].probe_target_ways <<
+                               ATTR1_PROBE_TARGET_WAYS_SHIFT;
+               attr1_val |= llcc_table[i].fixed_size <<
+                               ATTR1_FIXED_SIZE_SHIFT;
+               attr1_val |= llcc_table[i].priority <<

ATTR1_PRIORITY_SHIFT;

Quoted 4 lines
Quoted 4 lines

foo |=
bar << SHIFT;

would look slightly better.

Did you consider this option ?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#8 lore raw

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

Quoted 57 lines · Andy Shevchenko
Quoted 13 lines · On Tue, May 22, 2018 at 9:33 PM, <[email protected]> wrote:
Quoted 12 lines · Andy Shevchenko

drivers/soc/qcom/llcc-slice.c line 22

Quoted 5 lines · Rishabh Bhatnagar
drivers/soc/qcom/llcc-slice.c new file +5 -0
+#define ACTIVATE                      0x1
+#define DEACTIVATE                    0x2
+#define ACT_CTRL_OPCODE_ACTIVATE      0x1
+#define ACT_CTRL_OPCODE_DEACTIVATE    0x2
+#define ACT_CTRL_ACT_TRIG             0x1

Are these bits? Perhaps BIT() ?

Quoted 2 lines

isn't it just better to use fixed size as u suggest in the next comment?

If the are bits, use BIT() macro.

Quoted 29 lines
Quoted 29 lines
Quoted 9 lines
drivers/soc/qcom/llcc-slice.c new file +9 -0
+struct llcc_slice_desc *llcc_slice_getd(u32 uid)
+{
+       const struct llcc_slice_config *cfg;
+       struct llcc_slice_desc *desc;
+       u32 sz, count = 0;
+
+       cfg = drv_data->cfg;
+       sz = drv_data->cfg_size;
+

drivers/soc/qcom/llcc-slice.c line 79

Quoted 10 lines
drivers/soc/qcom/llcc-slice.c new file +8 -0
 
 
+       while (cfg && count < sz) {
+               if (cfg->usecase_id == uid)
+                       break;
+               cfg++;
+               count++;
+       }
+       if (cfg == NULL || count == sz)
+               return ERR_PTR(-ENODEV);

if (!cfg)

          return ERR_PTR(-ENODEV);

while (cfg->... != uid) {
cfg++;
count++;
}

Quoted 8 lines
Quoted 5 lines

if (count == sz)
return ...

Though I would rather put it to for () loop.

In each while loop iteration the cfg pointer needs to be checked for NULL. What if the usecase id never matches the uid passed by client and we keep iterating. At some point it will crash.

Quoted 7 lines

do {
if (!cfg || count == sz)
return ...(-ENODEV);
...
} while (...);

Though, as I said for-loop will look slightly better I think.

Is this fine?

for (count = 0; count < sz; count++) {
    if (!cfg)
	return ERR_PTR(-ENODEV);
    if (cfg->usecase_id == uid)
	break;
    cfg++;
}
if (count == sz)
    return ERR_PTR(-ENODEV);
Quoted 11 lines
Quoted 8 lines
Quoted 6 lines

drivers/soc/qcom/llcc-slice.c line 151

Quoted 3 lines
drivers/soc/qcom/llcc-slice.c new file +2 -0
+       ret = llcc_update_act_ctrl(desc->slice_id, act_ctrl_val,
+                                 DEACTIVATE);

Perhaps one line (~83 characters here is OK) ?

The checkpatch script complains about such lines.

So what if it just 3 characters out?

Other reviewers sometimes are not okay if the checkpatch complains. Because I have gotten many reviews previously concerning about line length. Not sure how to proceed here.

Quoted 21 lines
Quoted 20 lines
Quoted 20 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+       ret = llcc_update_act_ctrl(desc->slice_id, act_ctrl_val,
+                                 ACTIVATE);

Ditto.

Quoted 6 lines
drivers/soc/qcom/llcc-slice.c new file +2 -0
+               attr1_cfg = bcast_off +
+

LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);

drivers/soc/qcom/llcc-slice.c new file +2 -0
+               attr0_cfg = bcast_off +
+

LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);

Ditto.

Quoted 6 lines
drivers/soc/qcom/llcc-slice.c new file +5 -0
+               attr1_val |= llcc_table[i].probe_target_ways <<
+                               ATTR1_PROBE_TARGET_WAYS_SHIFT;
+               attr1_val |= llcc_table[i].fixed_size <<
+                               ATTR1_FIXED_SIZE_SHIFT;
+               attr1_val |= llcc_table[i].priority <<

ATTR1_PRIORITY_SHIFT;

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

foo |=
bar << SHIFT;

would look slightly better.

Did you consider this option ?

Yes, forgot to mention.

#9 lore raw

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

Quoted 58 lines · On Tue, May 22, 2018 at 11:40 PM, <[email protected]> wrote:
Quoted 41 lines · Andy Shevchenko
Quoted 31 lines · On Tue, May 22, 2018 at 9:33 PM, <[email protected]> wrote:
Quoted 29 lines · Andy Shevchenko
Quoted 10 lines
drivers/soc/qcom/llcc-slice.c new file +9 -0
+struct llcc_slice_desc *llcc_slice_getd(u32 uid)
+{
+       const struct llcc_slice_config *cfg;
+       struct llcc_slice_desc *desc;
+       u32 sz, count = 0;
+
+       cfg = drv_data->cfg;
+       sz = drv_data->cfg_size;
+
 

drivers/soc/qcom/llcc-slice.c line 79

Quoted 10 lines
drivers/soc/qcom/llcc-slice.c new file +8 -0
 
 
+       while (cfg && count < sz) {
+               if (cfg->usecase_id == uid)
+                       break;
+               cfg++;
+               count++;
+       }
+       if (cfg == NULL || count == sz)
+               return ERR_PTR(-ENODEV);

if (!cfg)

          return ERR_PTR(-ENODEV);

while (cfg->... != uid) {
cfg++;
count++;
}

Quoted 8 lines
Quoted 5 lines

if (count == sz)
return ...

Though I would rather put it to for () loop.

In each while loop iteration the cfg pointer needs to be checked for NULL. What if the usecase id never matches the uid passed by client and we keep iterating. At some point it will crash.

Quoted 7 lines

do {
if (!cfg || count == sz)
return ...(-ENODEV);
...
} while (...);

Though, as I said for-loop will look slightly better I think.

Is this fine?

for (count = 0; count < sz; count++) {
   if (!cfg)
        return ERR_PTR(-ENODEV);
   if (cfg->usecase_id == uid)
        break;
   cfg++;
}
Quoted 2 lines

if (count == sz)
return ERR_PTR(-ENODEV);

for (count = 0; cfg && count < sz; count++, cfg++)
if (_id == uid)
break;

if (!cfg || count == sz)

    return ERR_PTR(-ENODEV);

Simpler ?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#10 lore raw

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

In reply to Andy Shevchenko
Quoted 69 lines · Andy Shevchenko
Quoted 13 lines · On Tue, May 22, 2018 at 9:33 PM, <[email protected]> wrote:
Quoted 12 lines · Andy Shevchenko

drivers/soc/qcom/llcc-slice.c line 22

Quoted 5 lines · Rishabh Bhatnagar
drivers/soc/qcom/llcc-slice.c new file +5 -0
+#define ACTIVATE                      0x1
+#define DEACTIVATE                    0x2
+#define ACT_CTRL_OPCODE_ACTIVATE      0x1
+#define ACT_CTRL_OPCODE_DEACTIVATE    0x2
+#define ACT_CTRL_ACT_TRIG             0x1

Are these bits? Perhaps BIT() ?

Quoted 2 lines

isn't it just better to use fixed size as u suggest in the next comment?

If the are bits, use BIT() macro.

Quoted 29 lines
Quoted 29 lines
Quoted 9 lines
drivers/soc/qcom/llcc-slice.c new file +9 -0
+struct llcc_slice_desc *llcc_slice_getd(u32 uid)
+{
+       const struct llcc_slice_config *cfg;
+       struct llcc_slice_desc *desc;
+       u32 sz, count = 0;
+
+       cfg = drv_data->cfg;
+       sz = drv_data->cfg_size;
+

drivers/soc/qcom/llcc-slice.c line 79

Quoted 10 lines
drivers/soc/qcom/llcc-slice.c new file +8 -0
 
 
+       while (cfg && count < sz) {
+               if (cfg->usecase_id == uid)
+                       break;
+               cfg++;
+               count++;
+       }
+       if (cfg == NULL || count == sz)
+               return ERR_PTR(-ENODEV);

if (!cfg)

          return ERR_PTR(-ENODEV);

while (cfg->... != uid) {
cfg++;
count++;
}

Quoted 8 lines
Quoted 5 lines

if (count == sz)
return ...

Though I would rather put it to for () loop.

In each while loop iteration the cfg pointer needs to be checked for NULL. What if the usecase id never matches the uid passed by client and we keep iterating. At some point it will crash.

do {
if (!cfg || count == sz)
return ...(-ENODEV);
...
} while (...);

Though, as I said for-loop will look slightly better I think.

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
drivers/soc/qcom/llcc-slice.c new file +2 -0
+       ret = llcc_update_act_ctrl(desc->slice_id, act_ctrl_val,
+                                 DEACTIVATE);
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Perhaps one line (~83 characters here is OK) ?

The checkpatch script complains about such lines.

So what if it just 3 characters out?

Many upstream reviewers have objection to lines crossing over 80 characters
I have gotten reviews to reduce the line length even if its like 81~82 characters. Can we keep this as it is? I have addressed all other comments and will send out the next patch by today.

Quoted 27 lines
Quoted 21 lines
Quoted 20 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+       ret = llcc_update_act_ctrl(desc->slice_id, act_ctrl_val,
+                                 ACTIVATE);

Ditto.

Quoted 6 lines
drivers/soc/qcom/llcc-slice.c new file +2 -0
+               attr1_cfg = bcast_off +
+

LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);

drivers/soc/qcom/llcc-slice.c new file +2 -0
+               attr0_cfg = bcast_off +
+

LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);

Ditto.

Quoted 6 lines
drivers/soc/qcom/llcc-slice.c new file +5 -0
+               attr1_val |= llcc_table[i].probe_target_ways <<
+                               ATTR1_PROBE_TARGET_WAYS_SHIFT;
+               attr1_val |= llcc_table[i].fixed_size <<
+                               ATTR1_FIXED_SIZE_SHIFT;
+               attr1_val |= llcc_table[i].priority <<

ATTR1_PRIORITY_SHIFT;

Quoted 4 lines
Quoted 4 lines

foo |=
bar << SHIFT;

would look slightly better.

Did you consider this option ?