SDM845 System Cache Driver
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.
System cache has other blocks for memory error detection and AMON (Activity Monitor) for lock up detection.
Since the hardware block has multiple functional units the driver is implemented to use syscon/regmap interface. The driver can be broadly classified into:
- Core driver: llcc-core.c: This driver initializes the syscon, does common settings required to enable interrupts and error handling features.
- 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.
Channagoud Kadabi (2):
dt-bindings: Documentation for qcom,llcc
drivers: soc: Add LLCC driver
.../devicetree/bindings/arm/msm/qcom,llcc.txt | 93 +++++ drivers/soc/qcom/Kconfig | 16 + drivers/soc/qcom/Makefile | 2 + drivers/soc/qcom/llcc-core.c | 120 ++++++ drivers/soc/qcom/llcc-sdm845.c | 102 +++++ drivers/soc/qcom/llcc-slice.c | 456 +++++++++++++++++++++ include/linux/soc/qcom/llcc-qcom.h | 152 +++++++ 7 files changed, 941 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt create mode 100644 drivers/soc/qcom/llcc-core.c 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
PATCH 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 | 93 ++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt new file +93 -0
@@ -0,0 +1,93 @@ +* LLCC (Last Level Cache Controller) + +Properties: +- compatible: + Usage: required + Value type: <string> + Definition: must be "qcom,llcc-core" + +- reg: + Usage: required + Value Type: <prop-encoded-array> + Definition: must be addresses and sizes of the LLCC registers + +- llcc-bank-off: + Usage: required + Value Type: <u32 array> + Definition: Offsets of llcc banks from llcc base address starting from + LLCC bank0. + +- llcc-broadcast-off: + Usage: required + Value Type: <u32> + Definition: Offset of broadcast register from LLCC bank0 address. + +- #cache-cells: + Usage: required + Value Type: <u32> + Definition: Number of cache cells, must be 1 + +- max-slices: + usage: required + Value Type: <u32> + Definition: Number of cache slices supported by hardware + +- status: + Usage: optional + Value type: <string> + Definition: Property to enable or disable the driver + +== llcc amon device == + +Properties: +-qcom,fg-cnt : The value of fine grained counter of activity monitor + block. + +compatible devices: + qcom,sdm845-llcc + +Example: + + qcom,system-cache@1300000 { + compatible = "qcom,llcc-core", "syscon", "simple-mfd"; + reg = <0x1300000 0x50000>; + reg-names = "llcc_base"; + + llcc: qcom,sdm845-llcc { + compatible = "qcom,sdm845-llcc"; + #cache-cells = <1>; + max-slices = <32>; + }; + + qcom,llcc-ecc { + compatible = "qcom,llcc-ecc"; + }; + + qcom,llcc-amon { + compatible = "qcom,llcc-amon"; + qcom,fg-cnt = <0x7>; + }; + + }; + +== Client == + +Properties: +- cache-slice-names: + Usage: required + Value type: <stringlist> + Definition: A set of names that identify the usecase names of a client that uses + cache slice. These strings are used to look up the cache slice + entries by name. + +- cache-slices: + Usage: required + Value type: <prop-encoded-array> + Definition: The tuple has phandle to llcc device as the first argument and the + second argument is the usecase id of the client. +For example: + + video-decoder-encoder { + cache-slice-names = "vidsc0", "vidsc1"; + cache-slices = <&llcc 2>, <&llcc 3>; + };
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 2/2 drivers: soc: Add LLCC driver
In reply to Channagoud KadabiLLCC (Last Level Cache Controller) provides additional cache memory in the system. LLCC is partitioned into muliple 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 for their usecase and activate or deactivate the slice as needed. LLCC driver provides API interfaces for the clients to perform these operations.
--- drivers/soc/qcom/Kconfig | 16 ++ drivers/soc/qcom/Makefile | 2 + drivers/soc/qcom/llcc-core.c | 120 ++++++++++ drivers/soc/qcom/llcc-sdm845.c | 102 +++++++++ drivers/soc/qcom/llcc-slice.c | 456 +++++++++++++++++++++++++++++++++++++ include/linux/soc/qcom/llcc-qcom.h | 152 +++++++++++++ 6 files changed, 848 insertions(+) create mode 100644 drivers/soc/qcom/llcc-core.c 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 +16 -0
@@ -89,6 +89,22 @@ config QCOM_SMSM Say yes here to support the Qualcomm Shared Memory State Machine. The state machine is represented by bits in shared memory. +config QCOM_LLCC + tristate "Qualcomm Technologies, Inc. LLCC driver" + depends on ARCH_QCOM + help + Qualcomm Technologies, Inc. platform specific LLCC driver for Last + Level Cache. 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 is provides + data required to configure LLCC so that clients can start using the + LLCC slices. + config QCOM_WCNSS_CTRL tristate "Qualcomm WCNSS control driver" depends on ARCH_QCOM
drivers/soc/qcom/Makefile +2 -0
@@ -1,5 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_QCOM_GLINK_SSR) += glink_ssr.o +obj-$(CONFIG_QCOM_LLCC) += llcc-core.o llcc-slice.o +obj-$(CONFIG_QCOM_SDM845_LLCC) += llcc-sdm845.o obj-$(CONFIG_QCOM_GSBI) += qcom_gsbi.o obj-$(CONFIG_QCOM_MDT_LOADER) += mdt_loader.o obj-$(CONFIG_QCOM_PM) += spm.o
drivers/soc/qcom/llcc-core.c new file +120 -0
120 lines not on this page · raw message
drivers/soc/qcom/llcc-sdm845.c new file +102 -0
102 lines not on this page · raw message
drivers/soc/qcom/llcc-slice.c new file +456 -0
456 lines not on this page · raw message
include/linux/soc/qcom/llcc-qcom.h new file +152 -0
152 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
Re: [PATCH 2/2] drivers: soc: Add LLCC driver
Quoted 8 lines · Channagoud Kadabi
LLCC (Last Level Cache Controller) provides additional cache memory in the system. LLCC is partitioned into muliple 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 for their usecase and activate or deactivate the slice as needed. LLCC driver provides API interfaces for the clients to perform these operations.
Steve/linux-arm-msm folks, please provide review comments to system cache driver patch series.
---Trilok Soni--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
kbuild test robot
build botRe: [PATCH 2/2] drivers: soc: Add LLCC driver
In reply to Channagoud KadabiThank you for the patch! Yet something to improve:
Hi Channagoud,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v4.15 next-20180126]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Channagoud-Kadabi/SDM845-System-Cache-Driver/20180119-223446
config: arm64-allmodconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm64
All errors (new ones prefixed by >>):
>> drivers/soc/qcom/llcc-slice.c:138:25: error: redefinition of 'llcc_slice_getd'
struct llcc_slice_desc *llcc_slice_getd(struct device *dev, const char *name)
^~~~~~~~~~~~~~~
In file included from drivers/soc/qcom/llcc-slice.c:28:0:
include/linux/soc/qcom/llcc-qcom.h:111:39: note: previous definition of 'llcc_slice_getd' was here
static inline struct llcc_slice_desc *llcc_slice_getd(struct device *dev,
^~~~~~~~~~~~~~~
>> drivers/soc/qcom/llcc-slice.c:171:6: error: redefinition of 'llcc_slice_putd'
void llcc_slice_putd(struct llcc_slice_desc *desc)
^~~~~~~~~~~~~~~
In file included from drivers/soc/qcom/llcc-slice.c:28:0:
include/linux/soc/qcom/llcc-qcom.h:117:20: note: previous definition of 'llcc_slice_putd' was here
static inline void llcc_slice_putd(struct llcc_slice_desc *desc)
^~~~~~~~~~~~~~~
>> drivers/soc/qcom/llcc-slice.c:214:5: error: redefinition of 'llcc_slice_activate'
int llcc_slice_activate(struct llcc_slice_desc *desc)
^~~~~~~~~~~~~~~~~~~
In file included from drivers/soc/qcom/llcc-slice.c:28:0:
include/linux/soc/qcom/llcc-qcom.h:131:19: note: previous definition of 'llcc_slice_activate' was here
static inline int llcc_slice_activate(struct llcc_slice_desc *desc)
^~~~~~~~~~~~~~~~~~~
>> drivers/soc/qcom/llcc-slice.c:257:5: error: redefinition of 'llcc_slice_deactivate'
int llcc_slice_deactivate(struct llcc_slice_desc *desc)
^~~~~~~~~~~~~~~~~~~~~
In file included from drivers/soc/qcom/llcc-slice.c:28:0:
include/linux/soc/qcom/llcc-qcom.h:136:19: note: previous definition of 'llcc_slice_deactivate' was here
static inline int llcc_slice_deactivate(struct llcc_slice_desc *desc)
^~~~~~~~~~~~~~~~~~~~~
>> drivers/soc/qcom/llcc-slice.c:299:5: error: redefinition of 'llcc_get_slice_id'
int llcc_get_slice_id(struct llcc_slice_desc *desc)
^~~~~~~~~~~~~~~~~
In file included from drivers/soc/qcom/llcc-slice.c:28:0:
include/linux/soc/qcom/llcc-qcom.h:122:19: note: previous definition of 'llcc_get_slice_id' was here
static inline int llcc_get_slice_id(struct llcc_slice_desc *desc)
^~~~~~~~~~~~~~~~~
>> drivers/soc/qcom/llcc-slice.c:315:8: error: redefinition of 'llcc_get_slice_size'
size_t llcc_get_slice_size(struct llcc_slice_desc *desc)
^~~~~~~~~~~~~~~~~~~
In file included from drivers/soc/qcom/llcc-slice.c:28:0:
include/linux/soc/qcom/llcc-qcom.h:127:22: note: previous definition of 'llcc_get_slice_size' was here
static inline size_t llcc_get_slice_size(struct llcc_slice_desc *desc)
^~~~~~~~~~~~~~~~~~~
>> drivers/soc/qcom/llcc-slice.c:384:5: error: redefinition of 'qcom_llcc_probe'
int qcom_llcc_probe(struct platform_device *pdev,
^~~~~~~~~~~~~~~
In file included from drivers/soc/qcom/llcc-slice.c:28:0:
include/linux/soc/qcom/llcc-qcom.h:140:19: note: previous definition of 'qcom_llcc_probe' was here
static inline int qcom_llcc_probe(struct platform_device *pdev,
^~~~~~~~~~~~~~~
>> drivers/soc/qcom/llcc-slice.c:443:5: error: redefinition of 'qcom_llcc_remove' int qcom_llcc_remove(struct platform_device *pdev)
^~~~~~~~~~~~~~~~
In file included from drivers/soc/qcom/llcc-slice.c:28:0:
include/linux/soc/qcom/llcc-qcom.h:146:19: note: previous definition of 'qcom_llcc_remove' was here
static inline int qcom_llcc_remove(struct platform_device *pdev)
^~~~~~~~~~~~~~~~
vim +/llcc_slice_getd +138 drivers/soc/qcom/llcc-slice.c
129
130 /**
131 * llcc_slice_getd - get llcc slice descriptor
132 * @dev: Device pointer of the client
133 * @name: Name of the use case
134 *
135 * A pointer to llcc slice descriptor will be returned on success and
136 * and error pointer is returned on failure
137 */
> 138 struct llcc_slice_desc *llcc_slice_getd(struct device *dev, const char *name)
139 {
140 struct device_node *np = dev->of_node;
141 int index = 0;
142 const char *slice_name;
143 struct property *prop;
144
145 if (!np) {
146 dev_err(dev, "%s() currently only supports DT\n", __func__);
147 return ERR_PTR(-ENOENT);
148 }
149
150 if (!of_get_property(np, "cache-slice-names", NULL)) {
151 dev_err(dev,
152 "%s() requires a \"cache-slice-names\" property\n",
153 __func__);
154 return ERR_PTR(-ENOENT);
155 }
156
157 of_property_for_each_string(np, "cache-slice-names", prop, slice_name) {
158 if (!strcmp(name, slice_name))
159 break;
160 index++;
161 }
162
163 return llcc_slice_get_entry(dev, index);
164 }
165 EXPORT_SYMBOL(llcc_slice_getd);
166
167 /**
168 * llcc_slice_putd - llcc slice descritpor
169 * @desc: Pointer to llcc slice descriptor
170 */
> 171 void llcc_slice_putd(struct llcc_slice_desc *desc)
172 {
173 kfree(desc);
174 }
175 EXPORT_SYMBOL(llcc_slice_putd);
176
177 static int llcc_update_act_ctrl(struct llcc_drv_data *drv, u32 sid,
178 u32 act_ctrl_reg_val, u32 status)
179 {
180 u32 act_ctrl_reg;
181 u32 status_reg;
182 u32 slice_status;
183 unsigned long timeout;
184
185 act_ctrl_reg = drv->b_off + LLCC_TRP_ACT_CTRLn(sid);
186 status_reg = drv->b_off + LLCC_TRP_STATUSn(sid);
187
188 regmap_write(drv->llcc_map, act_ctrl_reg, act_ctrl_reg_val);
189
190 /* Make sure the activate trigger is applied before clearing it */
191 mb();
192
193 /* Clear the ACTIVE trigger */
194 act_ctrl_reg_val &= ~ACT_CTRL_ACT_TRIG;
195 regmap_write(drv->llcc_map, act_ctrl_reg, act_ctrl_reg_val);
196
197 timeout = jiffies + usecs_to_jiffies(LLCC_STATUS_READ_DELAY);
198 while (time_before(jiffies, timeout)) {
199 regmap_read(drv->llcc_map, status_reg, &slice_status);
200 if (!(slice_status & status))
201 return 0;
202 }
203
204 return -ETIMEDOUT;
205 }
206
207 /**
208 * llcc_slice_activate - Activate the llcc slice
209 * @desc: Pointer to llcc slice descriptor
210 *
211 * A value zero will be returned on success and a negative errno will
212 * be returned in error cases
213 */
> 214 int llcc_slice_activate(struct llcc_slice_desc *desc)
215 {
216 int rc = -EINVAL;
217 u32 act_ctrl_val;
218 struct llcc_drv_data *drv;
219
220 if (desc == NULL) {
221 pr_err("Input descriptor supplied is invalid\n");
222 return rc;
223 }
224
225 drv = dev_get_drvdata(desc->dev);
226 if (!drv) {
227 pr_err("Invalid device pointer in the desc\n");
228 return rc;
229 }
230
231 mutex_lock(&drv->slice_mutex);
232 if (test_bit(desc->llcc_slice_id, drv->llcc_slice_map)) {
233 mutex_unlock(&drv->slice_mutex);
234 return 0;
235 }
236
237 act_ctrl_val = ACT_CTRL_OPCODE_ACTIVATE << ACT_CTRL_OPCODE_SHIFT;
238 act_ctrl_val |= ACT_CTRL_ACT_TRIG;
239
240 rc = llcc_update_act_ctrl(drv, desc->llcc_slice_id, act_ctrl_val,
241 DEACTIVATE);
242
243 __set_bit(desc->llcc_slice_id, drv->llcc_slice_map);
244 mutex_unlock(&drv->slice_mutex);
245
246 return rc;
247 }
248 EXPORT_SYMBOL(llcc_slice_activate);
249
250 /**
251 * llcc_slice_deactivate - Deactivate the llcc slice
252 * @desc: Pointer to llcc slice descriptor
253 *
254 * A value zero will be returned on success and a negative errno will
255 * be returned in error cases
256 */
> 257 int llcc_slice_deactivate(struct llcc_slice_desc *desc)
258 {
259 u32 act_ctrl_val;
260 int rc = -EINVAL;
261 struct llcc_drv_data *drv;
262
263 if (desc == NULL) {
264 pr_err("Input descriptor supplied is invalid\n");
265 return rc;
266 }
267
268 drv = dev_get_drvdata(desc->dev);
269 if (!drv) {
270 pr_err("Invalid device pointer in the desc\n");
271 return rc;
272 }
273
274 mutex_lock(&drv->slice_mutex);
275 if (!test_bit(desc->llcc_slice_id, drv->llcc_slice_map)) {
276 mutex_unlock(&drv->slice_mutex);
277 return 0;
278 }
279 act_ctrl_val = ACT_CTRL_OPCODE_DEACTIVATE << ACT_CTRL_OPCODE_SHIFT;
280 act_ctrl_val |= ACT_CTRL_ACT_TRIG;
281
282 rc = llcc_update_act_ctrl(drv, desc->llcc_slice_id, act_ctrl_val,
283 ACTIVATE);
284
285 __clear_bit(desc->llcc_slice_id, drv->llcc_slice_map);
286 mutex_unlock(&drv->slice_mutex);
287
288 return rc;
289 }
290 EXPORT_SYMBOL(llcc_slice_deactivate);
291
292 /**
293 * llcc_get_slice_id - return the slice id
294 * @desc: Pointer to llcc slice descriptor
295 *
296 * A positive value will be returned on success and a negative errno will
297 * be returned on error
298 */
> 299 int llcc_get_slice_id(struct llcc_slice_desc *desc)
300 {
301 if (!desc)
302 return -EINVAL;
303
304 return desc->llcc_slice_id;
305 }
306 EXPORT_SYMBOL(llcc_get_slice_id);
307
308 /**
309 * llcc_get_slice_size - return the slice id
310 * @desc: Pointer to llcc slice descriptor
311 *
312 * A positive value will be returned on success and zero will returned on
313 * error
314 */
> 315 size_t llcc_get_slice_size(struct llcc_slice_desc *desc) 316 {
317 if (!desc)
318 return 0;
319
320 return desc->llcc_slice_size;
321 }
322 EXPORT_SYMBOL(llcc_get_slice_size);
323
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation