[PATCH] driver core: platform: Fix the usage of platform device name(pdev->name)

2019-04-22 Thread Venkata Narendra Kumar Gutta
Platform core is using pdev->name as the platform device name to do
the binding of the devices with the drivers. But, when the platform
driver overrides the platform device name with dev_set_name(),
the pdev->name is pointing to a location which is freed and becomes
an invalid parameter to do the binding match.

use-after-free instance:

[   33.325013] BUG: KASAN: use-after-free in strcmp+0x8c/0xb0
[   33.330646] Read of size 1 at addr ffc10beae600 by task modprobe
[   33.339068] CPU: 5 PID: 518 Comm: modprobe Tainted:
G S  W  O  4.19.30+ #3
[   33.346835] Hardware name: MTP (DT)
[   33.350419] Call trace:
[   33.352941]  dump_backtrace+0x0/0x3b8
[   33.356713]  show_stack+0x24/0x30
[   33.360119]  dump_stack+0x160/0x1d8
[   33.363709]  print_address_description+0x84/0x2e0
[   33.368549]  kasan_report+0x26c/0x2d0
[   33.372322]  __asan_report_load1_noabort+0x2c/0x38
[   33.377248]  strcmp+0x8c/0xb0
[   33.380306]  platform_match+0x70/0x1f8
[   33.384168]  __driver_attach+0x78/0x3a0
[   33.388111]  bus_for_each_dev+0x13c/0x1b8
[   33.392237]  driver_attach+0x4c/0x58
[   33.395910]  bus_add_driver+0x350/0x560
[   33.399854]  driver_register+0x23c/0x328
[   33.403886]  __platform_driver_register+0xd0/0xe0

So, use dev_name(>dev), which fetches the platform device name from
the kobject(dev->kobj->name) of the device instead of the pdev->name.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/base/platform.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index dab0a5a..0e23aa2 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -888,7 +888,7 @@ static ssize_t modalias_show(struct device *dev, struct 
device_attribute *a,
if (len != -ENODEV)
return len;
 
-   len = snprintf(buf, PAGE_SIZE, "platform:%s\n", pdev->name);
+   len = snprintf(buf, PAGE_SIZE, "platform:%s\n", dev_name(>dev));
 
return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
 }
@@ -964,7 +964,7 @@ static int platform_uevent(struct device *dev, struct 
kobj_uevent_env *env)
return rc;
 
add_uevent_var(env, "MODALIAS=%s%s", PLATFORM_MODULE_PREFIX,
-   pdev->name);
+   dev_name(>dev));
return 0;
 }
 
@@ -973,7 +973,7 @@ static const struct platform_device_id *platform_match_id(
struct platform_device *pdev)
 {
while (id->name[0]) {
-   if (strcmp(pdev->name, id->name) == 0) {
+   if (strcmp(dev_name(>dev), id->name) == 0) {
pdev->id_entry = id;
return id;
}
@@ -1017,7 +1017,7 @@ static int platform_match(struct device *dev, struct 
device_driver *drv)
return platform_match_id(pdrv->id_table, pdev) != NULL;
 
/* fall-back to driver name match */
-   return (strcmp(pdev->name, drv->name) == 0);
+   return (strcmp(dev_name(>dev), drv->name) == 0);
 }
 
 #ifdef CONFIG_PM_SLEEP
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v6 4/4] dt-bindings: msm: Update documentation of qcom,llcc

2018-09-12 Thread Venkata Narendra Kumar Gutta
Add reg-names and interrupts for LLCC documentation and the usage
examples. llcc broadcast base is added in addition to llcc base,
which is used for llcc broadcast writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
Reviewed-by: Rob Herring 
---
 .../devicetree/bindings/arm/msm/qcom,llcc.txt | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt 
b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
index 5e85749..eaee06b 100644
--- a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
@@ -16,11 +16,26 @@ Properties:
 - reg:
Usage: required
Value Type: 
-   Definition: Start address and the the size of the register region.
+   Definition: The first element specifies the llcc base start address and
+   the size of the register region. The second element 
specifies
+   the llcc broadcast base address and size of the register 
region.
+
+- reg-names:
+Usage: required
+Value Type: 
+Definition: Register region names. Must be "llcc_base", 
"llcc_broadcast_base".
+
+- interrupts:
+   Usage: required
+   Definition: The interrupt is associated with the llcc edac device.
+   It's used for llcc cache single and double bit error 
detection
+   and reporting.
 
 Example:
 
cache-controller@110 {
compatible = "qcom,sdm845-llcc";
-   reg = <0x110 0x25>;
+   reg = <0x110 0x20>, <0x130 0x5> ;
+   reg-names = "llcc_base", "llcc_broadcast_base";
+   interrupts = ;
};
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v6 2/4] drivers: soc: Add support to register LLCC EDAC driver

2018-09-12 Thread Venkata Narendra Kumar Gutta
Cache error reporting controller detects and reports single and
double bit errors on Last Level Cache Controller (LLCC) cache.
Add required support to register LLCC EDAC driver as platform driver,
from LLCC driver.

Signed-off-by: Venkata Narendra Kumar Gutta 
Reviewed-by: Evan Green 
---
 drivers/soc/qcom/llcc-slice.c  | 18 --
 include/linux/soc/qcom/llcc-qcom.h |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index a63640d..09c8bb0 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -224,7 +224,7 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
u32 attr0_val;
u32 max_cap_cacheline;
u32 sz;
-   int ret;
+   int ret = 0;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
 
@@ -282,6 +282,7 @@ int qcom_llcc_probe(struct platform_device *pdev,
struct resource *llcc_banks_res, *llcc_bcast_res;
void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
+   struct platform_device *llcc_edac;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
@@ -341,6 +342,19 @@ int qcom_llcc_probe(struct platform_device *pdev,
mutex_init(_data->lock);
platform_set_drvdata(pdev, drv_data);
 
-   return qcom_llcc_cfg_program(pdev);
+   ret = qcom_llcc_cfg_program(pdev);
+   if (ret)
+   return ret;
+
+   drv_data->ecc_irq = platform_get_irq(pdev, 0);
+   if (drv_data->ecc_irq >= 0) {
+   llcc_edac = platform_device_register_data(>dev,
+   "qcom_llcc_edac", -1, drv_data,
+   sizeof(*drv_data));
+   if (IS_ERR(llcc_edac))
+   dev_err(dev, "Failed to register llcc edac driver\n");
+   }
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(qcom_llcc_probe);
diff --git a/include/linux/soc/qcom/llcc-qcom.h 
b/include/linux/soc/qcom/llcc-qcom.h
index c681e79..2e4b34d 100644
--- a/include/linux/soc/qcom/llcc-qcom.h
+++ b/include/linux/soc/qcom/llcc-qcom.h
@@ -78,6 +78,7 @@ struct llcc_slice_config {
  * @num_banks: Number of llcc banks
  * @bitmap: Bit map to track the active slice ids
  * @offsets: Pointer to the bank offsets array
+ * @ecc_irq: interrupt for llcc cache error detection and reporting
  */
 struct llcc_drv_data {
struct regmap *regmap;
@@ -89,6 +90,7 @@ struct llcc_drv_data {
u32 num_banks;
unsigned long *bitmap;
u32 *offsets;
+   int ecc_irq;
 };
 
 #if IS_ENABLED(CONFIG_QCOM_LLCC)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v6 4/4] dt-bindings: msm: Update documentation of qcom,llcc

2018-09-12 Thread Venkata Narendra Kumar Gutta
Add reg-names and interrupts for LLCC documentation and the usage
examples. llcc broadcast base is added in addition to llcc base,
which is used for llcc broadcast writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
Reviewed-by: Rob Herring 
---
 .../devicetree/bindings/arm/msm/qcom,llcc.txt | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt 
b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
index 5e85749..eaee06b 100644
--- a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
@@ -16,11 +16,26 @@ Properties:
 - reg:
Usage: required
Value Type: 
-   Definition: Start address and the the size of the register region.
+   Definition: The first element specifies the llcc base start address and
+   the size of the register region. The second element 
specifies
+   the llcc broadcast base address and size of the register 
region.
+
+- reg-names:
+Usage: required
+Value Type: 
+Definition: Register region names. Must be "llcc_base", 
"llcc_broadcast_base".
+
+- interrupts:
+   Usage: required
+   Definition: The interrupt is associated with the llcc edac device.
+   It's used for llcc cache single and double bit error 
detection
+   and reporting.
 
 Example:
 
cache-controller@110 {
compatible = "qcom,sdm845-llcc";
-   reg = <0x110 0x25>;
+   reg = <0x110 0x20>, <0x130 0x5> ;
+   reg-names = "llcc_base", "llcc_broadcast_base";
+   interrupts = ;
};
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v6 2/4] drivers: soc: Add support to register LLCC EDAC driver

2018-09-12 Thread Venkata Narendra Kumar Gutta
Cache error reporting controller detects and reports single and
double bit errors on Last Level Cache Controller (LLCC) cache.
Add required support to register LLCC EDAC driver as platform driver,
from LLCC driver.

Signed-off-by: Venkata Narendra Kumar Gutta 
Reviewed-by: Evan Green 
---
 drivers/soc/qcom/llcc-slice.c  | 18 --
 include/linux/soc/qcom/llcc-qcom.h |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index a63640d..09c8bb0 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -224,7 +224,7 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
u32 attr0_val;
u32 max_cap_cacheline;
u32 sz;
-   int ret;
+   int ret = 0;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
 
@@ -282,6 +282,7 @@ int qcom_llcc_probe(struct platform_device *pdev,
struct resource *llcc_banks_res, *llcc_bcast_res;
void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
+   struct platform_device *llcc_edac;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
@@ -341,6 +342,19 @@ int qcom_llcc_probe(struct platform_device *pdev,
mutex_init(_data->lock);
platform_set_drvdata(pdev, drv_data);
 
-   return qcom_llcc_cfg_program(pdev);
+   ret = qcom_llcc_cfg_program(pdev);
+   if (ret)
+   return ret;
+
+   drv_data->ecc_irq = platform_get_irq(pdev, 0);
+   if (drv_data->ecc_irq >= 0) {
+   llcc_edac = platform_device_register_data(>dev,
+   "qcom_llcc_edac", -1, drv_data,
+   sizeof(*drv_data));
+   if (IS_ERR(llcc_edac))
+   dev_err(dev, "Failed to register llcc edac driver\n");
+   }
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(qcom_llcc_probe);
diff --git a/include/linux/soc/qcom/llcc-qcom.h 
b/include/linux/soc/qcom/llcc-qcom.h
index c681e79..2e4b34d 100644
--- a/include/linux/soc/qcom/llcc-qcom.h
+++ b/include/linux/soc/qcom/llcc-qcom.h
@@ -78,6 +78,7 @@ struct llcc_slice_config {
  * @num_banks: Number of llcc banks
  * @bitmap: Bit map to track the active slice ids
  * @offsets: Pointer to the bank offsets array
+ * @ecc_irq: interrupt for llcc cache error detection and reporting
  */
 struct llcc_drv_data {
struct regmap *regmap;
@@ -89,6 +90,7 @@ struct llcc_drv_data {
u32 num_banks;
unsigned long *bitmap;
u32 *offsets;
+   int ecc_irq;
 };
 
 #if IS_ENABLED(CONFIG_QCOM_LLCC)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v6 3/4] drivers: edac: Add EDAC driver support for QCOM SoCs

2018-09-12 Thread Venkata Narendra Kumar Gutta
From: Channagoud Kadabi 

Add error reporting driver for Single Bit Errors (SBEs) and Double Bit
Errors (DBEs). As of now, this driver supports error reporting for
Last Level Cache Controller (LLCC) of Tag RAM and Data RAM. Interrupts
are triggered when the errors happen in the cache, the driver handles
those interrupts and dumps the syndrome registers.

Signed-off-by: Channagoud Kadabi 
Signed-off-by: Venkata Narendra Kumar Gutta 
Co-developed-by: Venkata Narendra Kumar Gutta 
Acked-by: Borislav Petkov 
---
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  14 ++
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 414 +
 include/linux/soc/qcom/llcc-qcom.h |  24 +++
 5 files changed, 461 insertions(+)
 create mode 100644 drivers/edac/qcom_edac.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a23427..b413008 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5227,6 +5227,14 @@ L:   linux-e...@vger.kernel.org
 S: Maintained
 F: drivers/edac/ti_edac.c
 
+EDAC-QCOM
+M: Channagoud Kadabi 
+M: Venkata Narendra Kumar Gutta 
+L: linux-arm-...@vger.kernel.org
+L: linux-e...@vger.kernel.org
+S: Maintained
+F: drivers/edac/qcom_edac.c
+
 EDIROL UA-101/UA-1000 DRIVER
 M: Clemens Ladisch 
 L: alsa-de...@alsa-project.org (moderated for non-subscribers)
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 57304b2..df9467e 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -460,4 +460,18 @@ config EDAC_TI
  Support for error detection and correction on the
   TI SoCs.
 
+config EDAC_QCOM
+   tristate "QCOM EDAC Controller"
+   depends on ARCH_QCOM && QCOM_LLCC
+   help
+ Support for error detection and correction on the
+ Qualcomm Technologies, Inc. SoCs.
+
+ This driver reports Single Bit Errors (SBEs) and Double Bit Errors 
(DBEs).
+ As of now, it supports error reporting for Last Level Cache 
Controller (LLCC)
+ of Tag RAM and Data RAM.
+
+ For debugging issues having to do with stability and overall system
+ health, you should probably say 'Y' here.
+
 endif # EDAC
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index 02b43a7..716096d 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -77,3 +77,4 @@ obj-$(CONFIG_EDAC_ALTERA) += altera_edac.o
 obj-$(CONFIG_EDAC_SYNOPSYS)+= synopsys_edac.o
 obj-$(CONFIG_EDAC_XGENE)   += xgene_edac.o
 obj-$(CONFIG_EDAC_TI)  += ti_edac.o
+obj-$(CONFIG_EDAC_QCOM)+= qcom_edac.o
diff --git a/drivers/edac/qcom_edac.c b/drivers/edac/qcom_edac.c
new file mode 100644
index 000..82bd775
--- /dev/null
+++ b/drivers/edac/qcom_edac.c
@@ -0,0 +1,414 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "edac_mc.h"
+#include "edac_device.h"
+
+#define EDAC_LLCC   "qcom_llcc"
+
+#define LLCC_ERP_PANIC_ON_UE1
+
+#define TRP_SYN_REG_CNT 6
+#define DRP_SYN_REG_CNT 8
+
+#define LLCC_COMMON_STATUS0 0x0003000c
+#define LLCC_LB_CNT_MASKGENMASK(31, 28)
+#define LLCC_LB_CNT_SHIFT   28
+
+/* Single & double bit syndrome register offsets */
+#define TRP_ECC_SB_ERR_SYN0 0x0002304c
+#define TRP_ECC_DB_ERR_SYN0 0x00020370
+#define DRP_ECC_SB_ERR_SYN0 0x0004204c
+#define DRP_ECC_DB_ERR_SYN0 0x00042070
+
+/* Error register offsets */
+#define TRP_ECC_ERROR_STATUS1   0x00020348
+#define TRP_ECC_ERROR_STATUS0   0x00020344
+#define DRP_ECC_ERROR_STATUS1   0x00042048
+#define DRP_ECC_ERROR_STATUS0   0x00042044
+
+/* TRP, DRP interrupt register offsets */
+#define DRP_INTERRUPT_STATUS0x00041000
+#define TRP_INTERRUPT_0_STATUS  0x00020480
+#define DRP_INTERRUPT_CLEAR 0x00041008
+#define DRP_ECC_ERROR_CNTR_CLEAR0x00040004
+#define TRP_INTERRUPT_0_CLEAR   0x00020484
+#define TRP_ECC_ERROR_CNTR_CLEAR0x00020440
+
+/* Mask and shift macros */
+#define ECC_DB_ERR_COUNT_MASK   GENMASK(4, 0)
+#define ECC_DB_ERR_WAYS_MASKGENMASK(31, 16)
+#define ECC_DB_ERR_WAYS_SHIFT   BIT(4)
+
+#define ECC_SB_ERR_COUNT_MASK   GENMASK(23, 16)
+#define ECC_SB_ERR_COUNT_SHIFT  BIT(4)
+#define ECC_SB_ERR_WAYS_MASKGENMASK(15, 0)
+
+#define SB_ECC_ERRORBIT(0)
+#define DB_ECC_ERRORBIT(1)
+
+#define DRP_TRP_INT_CLEAR   GENMASK(1, 0)
+#define DRP_TRP_CNT_CLEAR   GENMASK(1, 0)
+
+/* Config registers offsets*/
+#define DRP_ECC_ERROR_CFG   0x0004000

[PATCH v6 3/4] drivers: edac: Add EDAC driver support for QCOM SoCs

2018-09-12 Thread Venkata Narendra Kumar Gutta
From: Channagoud Kadabi 

Add error reporting driver for Single Bit Errors (SBEs) and Double Bit
Errors (DBEs). As of now, this driver supports error reporting for
Last Level Cache Controller (LLCC) of Tag RAM and Data RAM. Interrupts
are triggered when the errors happen in the cache, the driver handles
those interrupts and dumps the syndrome registers.

Signed-off-by: Channagoud Kadabi 
Signed-off-by: Venkata Narendra Kumar Gutta 
Co-developed-by: Venkata Narendra Kumar Gutta 
Acked-by: Borislav Petkov 
---
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  14 ++
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 414 +
 include/linux/soc/qcom/llcc-qcom.h |  24 +++
 5 files changed, 461 insertions(+)
 create mode 100644 drivers/edac/qcom_edac.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a23427..b413008 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5227,6 +5227,14 @@ L:   linux-e...@vger.kernel.org
 S: Maintained
 F: drivers/edac/ti_edac.c
 
+EDAC-QCOM
+M: Channagoud Kadabi 
+M: Venkata Narendra Kumar Gutta 
+L: linux-arm-...@vger.kernel.org
+L: linux-e...@vger.kernel.org
+S: Maintained
+F: drivers/edac/qcom_edac.c
+
 EDIROL UA-101/UA-1000 DRIVER
 M: Clemens Ladisch 
 L: alsa-de...@alsa-project.org (moderated for non-subscribers)
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 57304b2..df9467e 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -460,4 +460,18 @@ config EDAC_TI
  Support for error detection and correction on the
   TI SoCs.
 
+config EDAC_QCOM
+   tristate "QCOM EDAC Controller"
+   depends on ARCH_QCOM && QCOM_LLCC
+   help
+ Support for error detection and correction on the
+ Qualcomm Technologies, Inc. SoCs.
+
+ This driver reports Single Bit Errors (SBEs) and Double Bit Errors 
(DBEs).
+ As of now, it supports error reporting for Last Level Cache 
Controller (LLCC)
+ of Tag RAM and Data RAM.
+
+ For debugging issues having to do with stability and overall system
+ health, you should probably say 'Y' here.
+
 endif # EDAC
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index 02b43a7..716096d 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -77,3 +77,4 @@ obj-$(CONFIG_EDAC_ALTERA) += altera_edac.o
 obj-$(CONFIG_EDAC_SYNOPSYS)+= synopsys_edac.o
 obj-$(CONFIG_EDAC_XGENE)   += xgene_edac.o
 obj-$(CONFIG_EDAC_TI)  += ti_edac.o
+obj-$(CONFIG_EDAC_QCOM)+= qcom_edac.o
diff --git a/drivers/edac/qcom_edac.c b/drivers/edac/qcom_edac.c
new file mode 100644
index 000..82bd775
--- /dev/null
+++ b/drivers/edac/qcom_edac.c
@@ -0,0 +1,414 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "edac_mc.h"
+#include "edac_device.h"
+
+#define EDAC_LLCC   "qcom_llcc"
+
+#define LLCC_ERP_PANIC_ON_UE1
+
+#define TRP_SYN_REG_CNT 6
+#define DRP_SYN_REG_CNT 8
+
+#define LLCC_COMMON_STATUS0 0x0003000c
+#define LLCC_LB_CNT_MASKGENMASK(31, 28)
+#define LLCC_LB_CNT_SHIFT   28
+
+/* Single & double bit syndrome register offsets */
+#define TRP_ECC_SB_ERR_SYN0 0x0002304c
+#define TRP_ECC_DB_ERR_SYN0 0x00020370
+#define DRP_ECC_SB_ERR_SYN0 0x0004204c
+#define DRP_ECC_DB_ERR_SYN0 0x00042070
+
+/* Error register offsets */
+#define TRP_ECC_ERROR_STATUS1   0x00020348
+#define TRP_ECC_ERROR_STATUS0   0x00020344
+#define DRP_ECC_ERROR_STATUS1   0x00042048
+#define DRP_ECC_ERROR_STATUS0   0x00042044
+
+/* TRP, DRP interrupt register offsets */
+#define DRP_INTERRUPT_STATUS0x00041000
+#define TRP_INTERRUPT_0_STATUS  0x00020480
+#define DRP_INTERRUPT_CLEAR 0x00041008
+#define DRP_ECC_ERROR_CNTR_CLEAR0x00040004
+#define TRP_INTERRUPT_0_CLEAR   0x00020484
+#define TRP_ECC_ERROR_CNTR_CLEAR0x00020440
+
+/* Mask and shift macros */
+#define ECC_DB_ERR_COUNT_MASK   GENMASK(4, 0)
+#define ECC_DB_ERR_WAYS_MASKGENMASK(31, 16)
+#define ECC_DB_ERR_WAYS_SHIFT   BIT(4)
+
+#define ECC_SB_ERR_COUNT_MASK   GENMASK(23, 16)
+#define ECC_SB_ERR_COUNT_SHIFT  BIT(4)
+#define ECC_SB_ERR_WAYS_MASKGENMASK(15, 0)
+
+#define SB_ECC_ERRORBIT(0)
+#define DB_ECC_ERRORBIT(1)
+
+#define DRP_TRP_INT_CLEAR   GENMASK(1, 0)
+#define DRP_TRP_CNT_CLEAR   GENMASK(1, 0)
+
+/* Config registers offsets*/
+#define DRP_ECC_ERROR_CFG   0x0004000

[PATCH v6 0/4] Add EDAC driver for QCOM SoCs

2018-09-12 Thread Venkata Narendra Kumar Gutta
This series implements EDAC driver for QCOM SoCs. As of now, this driver
supports EDAC for Last Level Cache Controller (LLCC). LLCC EDAC driver is
to detect and report single and double bit errors on Last Level Cache
Controller (LLCC) cache. Interrupts are triggered when the errors happen
in the cache, the driver handles those interrupts and dumps the syndrome
registers.

The driver functionality is implemented in:
qcom_edac.c : This platform driver registers to edac framework and
handles the single and double bit errors in cache by registering
interrupt handlers.

llcc-slice.c: It invokes the llcc edac driver and passes platform
data to it.

This patchset depends on the LLCC driver, which is part of 4.19 release.
Link: https://patchwork.kernel.org/patch/10422531/
Link: 
http://lists-archives.com/linux-kernel/29157082-dt-bindings-documentation-for-qcom-llcc.html

Patch wise description given below:

Patch 1 adds the broadcast base regmap for broadcast writes in llcc.

Patch 2 adds the required changes to register edac driver from llcc driver.

Patch 3 adds the EDAC driver support for QCOM SoCS.

Patch 4 updates the dt bindings of llcc.

Changes since v5:
  * Updated vendor naming convention in MAINTAINERS and Kconfig

Changes since v4:
  * Removed of_device_id struct entry from edac driver
  * Modified reg-names in the documentation

Changes since v3:
  * Updated the Kconfig and addressed minor comments in the driver

Changes since v2:
  * Modified the edac driver and Kconfig
-  removed unnecessary header files, typecasting and redundant comments.
-  Changed the initialization of reg_data datastructure to static,
   Also updated the llcc_edac_reg_data member names and datatypes.
-  Removed "EDAC_QCOM_LLCC_PANIC_ON_UE" Kconfig variable

Changes since v1:
  * Modified the edac driver
- Removed duplicate functions that are used to dump the syndrome registers,
  replaced that with a common function and a reg_data datastructure.
- Removed structure containing function pointers.
- Addressed comments on error handling to clear the interrupt status.
  * Updated Kconfig

Changes since v0:
  * Added EDAC_QCOM config and updated the driver
  * Addressed comments related to indentation and other minor ones

Channagoud Kadabi (1):
  drivers: edac: Add EDAC driver support for QCOM SoCs

Venkata Narendra Kumar Gutta (3):
  drivers: soc: Add broadcast base for Last Level Cache Controller
(LLCC)
  drivers: soc: Add support to register LLCC EDAC driver
  dt-bindings: msm: Update documentation of qcom,llcc

 .../devicetree/bindings/arm/msm/qcom,llcc.txt  |  19 +-
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  14 +
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 414 +
 drivers/soc/qcom/llcc-slice.c  |  73 ++--
 include/linux/soc/qcom/llcc-qcom.h |  30 +-
 7 files changed, 531 insertions(+), 28 deletions(-)
 create mode 100644 drivers/edac/qcom_edac.c

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v6 0/4] Add EDAC driver for QCOM SoCs

2018-09-12 Thread Venkata Narendra Kumar Gutta
This series implements EDAC driver for QCOM SoCs. As of now, this driver
supports EDAC for Last Level Cache Controller (LLCC). LLCC EDAC driver is
to detect and report single and double bit errors on Last Level Cache
Controller (LLCC) cache. Interrupts are triggered when the errors happen
in the cache, the driver handles those interrupts and dumps the syndrome
registers.

The driver functionality is implemented in:
qcom_edac.c : This platform driver registers to edac framework and
handles the single and double bit errors in cache by registering
interrupt handlers.

llcc-slice.c: It invokes the llcc edac driver and passes platform
data to it.

This patchset depends on the LLCC driver, which is part of 4.19 release.
Link: https://patchwork.kernel.org/patch/10422531/
Link: 
http://lists-archives.com/linux-kernel/29157082-dt-bindings-documentation-for-qcom-llcc.html

Patch wise description given below:

Patch 1 adds the broadcast base regmap for broadcast writes in llcc.

Patch 2 adds the required changes to register edac driver from llcc driver.

Patch 3 adds the EDAC driver support for QCOM SoCS.

Patch 4 updates the dt bindings of llcc.

Changes since v5:
  * Updated vendor naming convention in MAINTAINERS and Kconfig

Changes since v4:
  * Removed of_device_id struct entry from edac driver
  * Modified reg-names in the documentation

Changes since v3:
  * Updated the Kconfig and addressed minor comments in the driver

Changes since v2:
  * Modified the edac driver and Kconfig
-  removed unnecessary header files, typecasting and redundant comments.
-  Changed the initialization of reg_data datastructure to static,
   Also updated the llcc_edac_reg_data member names and datatypes.
-  Removed "EDAC_QCOM_LLCC_PANIC_ON_UE" Kconfig variable

Changes since v1:
  * Modified the edac driver
- Removed duplicate functions that are used to dump the syndrome registers,
  replaced that with a common function and a reg_data datastructure.
- Removed structure containing function pointers.
- Addressed comments on error handling to clear the interrupt status.
  * Updated Kconfig

Changes since v0:
  * Added EDAC_QCOM config and updated the driver
  * Addressed comments related to indentation and other minor ones

Channagoud Kadabi (1):
  drivers: edac: Add EDAC driver support for QCOM SoCs

Venkata Narendra Kumar Gutta (3):
  drivers: soc: Add broadcast base for Last Level Cache Controller
(LLCC)
  drivers: soc: Add support to register LLCC EDAC driver
  dt-bindings: msm: Update documentation of qcom,llcc

 .../devicetree/bindings/arm/msm/qcom,llcc.txt  |  19 +-
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  14 +
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 414 +
 drivers/soc/qcom/llcc-slice.c  |  73 ++--
 include/linux/soc/qcom/llcc-qcom.h |  30 +-
 7 files changed, 531 insertions(+), 28 deletions(-)
 create mode 100644 drivers/edac/qcom_edac.c

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v6 1/4] drivers: soc: Add broadcast base for Last Level Cache Controller (LLCC)

2018-09-12 Thread Venkata Narendra Kumar Gutta
Currently, broadcast base is set to end of the LLCC banks, which may
not be correct always. As the number of banks may vary for each chipset
and the broadcast base could be at a different address as well. This info
depends on the chipset, so get the broadcast base info from the device
tree (DT). Add broadcast base in LLCC driver and use this for broadcast
writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
Reviewed-by: Evan Green 
---
 drivers/soc/qcom/llcc-slice.c  | 55 +++---
 include/linux/soc/qcom/llcc-qcom.h |  4 +--
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index fcaad1a..a63640d 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -105,22 +105,24 @@ static int llcc_update_act_ctrl(u32 sid,
u32 slice_status;
int ret;
 
-   act_ctrl_reg = drv_data->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
-   status_reg = drv_data->bcast_off + LLCC_TRP_STATUSn(sid);
+   act_ctrl_reg = LLCC_TRP_ACT_CTRLn(sid);
+   status_reg = LLCC_TRP_STATUSn(sid);
 
/* Set the ACTIVE trigger */
act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
-   ret = regmap_write(drv_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_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_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_regmap, act_ctrl_reg,
+   act_ctrl_reg_val);
if (ret)
return ret;
 
-   ret = regmap_read_poll_timeout(drv_data->regmap, status_reg,
+   ret = regmap_read_poll_timeout(drv_data->bcast_regmap, status_reg,
  slice_status, !(slice_status & status),
  0, LLCC_STATUS_READ_DELAY);
return ret;
@@ -225,16 +227,13 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
int ret;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
-   u32 bcast_off = drv_data->bcast_off;
 
sz = drv_data->cfg_size;
llcc_table = drv_data->cfg;
 
for (i = 0; i < sz; i++) {
-   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);
+   attr1_cfg = LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);
+   attr0_cfg = LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);
 
attr1_val = llcc_table[i].cache_mode;
attr1_val |= llcc_table[i].probe_target_ways <<
@@ -259,10 +258,12 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
attr0_val = llcc_table[i].res_ways & ATTR0_RES_WAYS_MASK;
attr0_val |= llcc_table[i].bonus_ways << ATTR0_BONUS_WAYS_SHIFT;
 
-   ret = regmap_write(drv_data->regmap, attr1_cfg, attr1_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr1_cfg,
+   attr1_val);
if (ret)
return ret;
-   ret = regmap_write(drv_data->regmap, attr0_cfg, attr0_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr0_cfg,
+   attr0_val);
if (ret)
return ret;
if (llcc_table[i].activate_on_init) {
@@ -278,24 +279,36 @@ int qcom_llcc_probe(struct platform_device *pdev,
 {
u32 num_banks;
struct device *dev = >dev;
-   struct resource *res;
-   void __iomem *base;
+   struct resource *llcc_banks_res, *llcc_bcast_res;
+   void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
return -ENOMEM;
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_ioremap_resource(>dev, res);
-   if (IS_ERR(base))
-   return PTR_ERR(base);
+   llcc_banks_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+   "llcc_base");
+   llcc_banks_base = devm_ioremap_resource(>dev, llcc_banks_res);
+   if (IS_ERR(llcc_banks_base))
+   return PTR_ERR(llcc_banks_base);
 
-   drv_data->regmap = devm_regmap_init_mmio(dev, base,
-   _regmap_config);
+   drv_data->regmap = devm_regmap_init_mmio(dev, llcc_banks_base,
+  

[PATCH v6 1/4] drivers: soc: Add broadcast base for Last Level Cache Controller (LLCC)

2018-09-12 Thread Venkata Narendra Kumar Gutta
Currently, broadcast base is set to end of the LLCC banks, which may
not be correct always. As the number of banks may vary for each chipset
and the broadcast base could be at a different address as well. This info
depends on the chipset, so get the broadcast base info from the device
tree (DT). Add broadcast base in LLCC driver and use this for broadcast
writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
Reviewed-by: Evan Green 
---
 drivers/soc/qcom/llcc-slice.c  | 55 +++---
 include/linux/soc/qcom/llcc-qcom.h |  4 +--
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index fcaad1a..a63640d 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -105,22 +105,24 @@ static int llcc_update_act_ctrl(u32 sid,
u32 slice_status;
int ret;
 
-   act_ctrl_reg = drv_data->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
-   status_reg = drv_data->bcast_off + LLCC_TRP_STATUSn(sid);
+   act_ctrl_reg = LLCC_TRP_ACT_CTRLn(sid);
+   status_reg = LLCC_TRP_STATUSn(sid);
 
/* Set the ACTIVE trigger */
act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
-   ret = regmap_write(drv_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_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_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_regmap, act_ctrl_reg,
+   act_ctrl_reg_val);
if (ret)
return ret;
 
-   ret = regmap_read_poll_timeout(drv_data->regmap, status_reg,
+   ret = regmap_read_poll_timeout(drv_data->bcast_regmap, status_reg,
  slice_status, !(slice_status & status),
  0, LLCC_STATUS_READ_DELAY);
return ret;
@@ -225,16 +227,13 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
int ret;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
-   u32 bcast_off = drv_data->bcast_off;
 
sz = drv_data->cfg_size;
llcc_table = drv_data->cfg;
 
for (i = 0; i < sz; i++) {
-   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);
+   attr1_cfg = LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);
+   attr0_cfg = LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);
 
attr1_val = llcc_table[i].cache_mode;
attr1_val |= llcc_table[i].probe_target_ways <<
@@ -259,10 +258,12 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
attr0_val = llcc_table[i].res_ways & ATTR0_RES_WAYS_MASK;
attr0_val |= llcc_table[i].bonus_ways << ATTR0_BONUS_WAYS_SHIFT;
 
-   ret = regmap_write(drv_data->regmap, attr1_cfg, attr1_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr1_cfg,
+   attr1_val);
if (ret)
return ret;
-   ret = regmap_write(drv_data->regmap, attr0_cfg, attr0_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr0_cfg,
+   attr0_val);
if (ret)
return ret;
if (llcc_table[i].activate_on_init) {
@@ -278,24 +279,36 @@ int qcom_llcc_probe(struct platform_device *pdev,
 {
u32 num_banks;
struct device *dev = >dev;
-   struct resource *res;
-   void __iomem *base;
+   struct resource *llcc_banks_res, *llcc_bcast_res;
+   void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
return -ENOMEM;
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_ioremap_resource(>dev, res);
-   if (IS_ERR(base))
-   return PTR_ERR(base);
+   llcc_banks_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+   "llcc_base");
+   llcc_banks_base = devm_ioremap_resource(>dev, llcc_banks_res);
+   if (IS_ERR(llcc_banks_base))
+   return PTR_ERR(llcc_banks_base);
 
-   drv_data->regmap = devm_regmap_init_mmio(dev, base,
-   _regmap_config);
+   drv_data->regmap = devm_regmap_init_mmio(dev, llcc_banks_base,
+  

[PATCH v5 0/4] Add EDAC driver for QCOM SoCs

2018-09-10 Thread Venkata Narendra Kumar Gutta
This series implements EDAC driver for QCOM SoCs. As of now, this driver
supports EDAC for Last Level Cache Controller (LLCC). LLCC EDAC driver is
to detect and report single and double bit errors on Last Level Cache
Controller (LLCC) cache. Interrupts are triggered when the errors happen
in the cache, the driver handles those interrupts and dumps the syndrome
registers.

The driver functionality is implemented in:
qcom_edac.c : This platform driver registers to edac framework and
handles the single and double bit errors in cache by registering
interrupt handlers.

llcc-slice.c: It invokes the llcc edac driver and passes platform
data to it.

This patchset depends on the LLCC driver, which is part of 4.19 release.
Link: https://patchwork.kernel.org/patch/10422531/
Link: 
http://lists-archives.com/linux-kernel/29157082-dt-bindings-documentation-for-qcom-llcc.html

Patch wise description given below:

Patch 1 adds the broadcast base regmap for broadcast writes in llcc.

Patch 2 adds the required changes to register edac driver from llcc driver.

Patch 3 adds the EDAC driver support for QCOM SoCS.

Patch 4 updates the dt bindings of llcc.

Changes since v4:
  * Removed of_device_id struct entry from edac driver
  * Modified reg-names in the documentation

Changes since v3:
  * Updated the Kconfig and addressed minor comments in the driver

Changes since v2:
  * Modified the edac driver and Kconfig
-  removed unnecessary header files, typecasting and redundant comments.
-  Changed the initialization of reg_data datastructure to static,
   Also updated the llcc_edac_reg_data member names and datatypes.
-  Removed "EDAC_QCOM_LLCC_PANIC_ON_UE" Kconfig variable

Changes since v1:
  * Modified the edac driver
- Removed duplicate functions that are used to dump the syndrome registers,
  replaced that with a common function and a reg_data datastructure.
- Removed structure containing function pointers.
- Addressed comments on error handling to clear the interrupt status.
  * Updated Kconfig

Changes since v0:
  * Added EDAC_QCOM config and updated the driver
  * Addressed comments related to indentation and other minor ones

Channagoud Kadabi (1):
  drivers: edac: Add EDAC driver support for QCOM SoCs

Venkata Narendra Kumar Gutta (3):
  drivers: soc: Add broadcast base for Last Level Cache Controller
(LLCC)
  drivers: soc: Add support to register LLCC EDAC driver
  dt-bindings: msm: Update documentation of qcom,llcc

 .../devicetree/bindings/arm/msm/qcom,llcc.txt  |  19 +-
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  14 +
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 414 +
 drivers/soc/qcom/llcc-slice.c  |  73 ++--
 include/linux/soc/qcom/llcc-qcom.h |  30 +-
 7 files changed, 531 insertions(+), 28 deletions(-)
 create mode 100644 drivers/edac/qcom_edac.c

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v5 3/4] drivers: edac: Add EDAC driver support for QCOM SoCs

2018-09-10 Thread Venkata Narendra Kumar Gutta
From: Channagoud Kadabi 

Add error reporting driver for Single Bit Errors (SBEs) and Double Bit
Errors (DBEs). As of now, this driver supports error reporting for
Last Level Cache Controller (LLCC) of Tag RAM and Data RAM. Interrupts
are triggered when the errors happen in the cache, the driver handles
those interrupts and dumps the syndrome registers.

Signed-off-by: Channagoud Kadabi 
Signed-off-by: Venkata Narendra Kumar Gutta 
Co-developed-by: Venkata Narendra Kumar Gutta 
Acked-by: Borislav Petkov 
---
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  14 ++
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 414 +
 include/linux/soc/qcom/llcc-qcom.h |  24 +++
 5 files changed, 461 insertions(+)
 create mode 100644 drivers/edac/qcom_edac.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a23427..0bff713 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5227,6 +5227,14 @@ L:   linux-e...@vger.kernel.org
 S: Maintained
 F: drivers/edac/ti_edac.c
 
+EDAC-QUALCOMM
+M: Channagoud Kadabi 
+M: Venkata Narendra Kumar Gutta 
+L: linux-arm-...@vger.kernel.org
+L: linux-e...@vger.kernel.org
+S: Maintained
+F: drivers/edac/qcom_edac.c
+
 EDIROL UA-101/UA-1000 DRIVER
 M: Clemens Ladisch 
 L: alsa-de...@alsa-project.org (moderated for non-subscribers)
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 57304b2..c4e3472 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -460,4 +460,18 @@ config EDAC_TI
  Support for error detection and correction on the
   TI SoCs.
 
+config EDAC_QCOM
+   tristate "QCOM EDAC Controller"
+   depends on ARCH_QCOM && QCOM_LLCC
+   help
+ Support for error detection and correction on the
+ QCOM SoCs.
+
+ This driver reports Single Bit Errors (SBEs) and Double Bit Errors 
(DBEs).
+ As of now, it supports error reporting for Last Level Cache 
Controller (LLCC)
+ of Tag RAM and Data RAM.
+
+ For debugging issues having to do with stability and overall system
+ health, you should probably say 'Y' here.
+
 endif # EDAC
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index 02b43a7..716096d 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -77,3 +77,4 @@ obj-$(CONFIG_EDAC_ALTERA) += altera_edac.o
 obj-$(CONFIG_EDAC_SYNOPSYS)+= synopsys_edac.o
 obj-$(CONFIG_EDAC_XGENE)   += xgene_edac.o
 obj-$(CONFIG_EDAC_TI)  += ti_edac.o
+obj-$(CONFIG_EDAC_QCOM)+= qcom_edac.o
diff --git a/drivers/edac/qcom_edac.c b/drivers/edac/qcom_edac.c
new file mode 100644
index 000..82bd775
--- /dev/null
+++ b/drivers/edac/qcom_edac.c
@@ -0,0 +1,414 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "edac_mc.h"
+#include "edac_device.h"
+
+#define EDAC_LLCC   "qcom_llcc"
+
+#define LLCC_ERP_PANIC_ON_UE1
+
+#define TRP_SYN_REG_CNT 6
+#define DRP_SYN_REG_CNT 8
+
+#define LLCC_COMMON_STATUS0 0x0003000c
+#define LLCC_LB_CNT_MASKGENMASK(31, 28)
+#define LLCC_LB_CNT_SHIFT   28
+
+/* Single & double bit syndrome register offsets */
+#define TRP_ECC_SB_ERR_SYN0 0x0002304c
+#define TRP_ECC_DB_ERR_SYN0 0x00020370
+#define DRP_ECC_SB_ERR_SYN0 0x0004204c
+#define DRP_ECC_DB_ERR_SYN0 0x00042070
+
+/* Error register offsets */
+#define TRP_ECC_ERROR_STATUS1   0x00020348
+#define TRP_ECC_ERROR_STATUS0   0x00020344
+#define DRP_ECC_ERROR_STATUS1   0x00042048
+#define DRP_ECC_ERROR_STATUS0   0x00042044
+
+/* TRP, DRP interrupt register offsets */
+#define DRP_INTERRUPT_STATUS0x00041000
+#define TRP_INTERRUPT_0_STATUS  0x00020480
+#define DRP_INTERRUPT_CLEAR 0x00041008
+#define DRP_ECC_ERROR_CNTR_CLEAR0x00040004
+#define TRP_INTERRUPT_0_CLEAR   0x00020484
+#define TRP_ECC_ERROR_CNTR_CLEAR0x00020440
+
+/* Mask and shift macros */
+#define ECC_DB_ERR_COUNT_MASK   GENMASK(4, 0)
+#define ECC_DB_ERR_WAYS_MASKGENMASK(31, 16)
+#define ECC_DB_ERR_WAYS_SHIFT   BIT(4)
+
+#define ECC_SB_ERR_COUNT_MASK   GENMASK(23, 16)
+#define ECC_SB_ERR_COUNT_SHIFT  BIT(4)
+#define ECC_SB_ERR_WAYS_MASKGENMASK(15, 0)
+
+#define SB_ECC_ERRORBIT(0)
+#define DB_ECC_ERRORBIT(1)
+
+#define DRP_TRP_INT_CLEAR   GENMASK(1, 0)
+#define DRP_TRP_CNT_CLEAR   GENMASK(1, 0)
+
+/* Config registers offsets*/
+#define DRP_ECC_ERROR_CFG   0x0004
+
+/* Tag 

[PATCH v5 4/4] dt-bindings: msm: Update documentation of qcom,llcc

2018-09-10 Thread Venkata Narendra Kumar Gutta
Add reg-names and interrupts for LLCC documentation and the usage
examples. llcc broadcast base is added in addition to llcc base,
which is used for llcc broadcast writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
Reviewed-by: Rob Herring 
---
 .../devicetree/bindings/arm/msm/qcom,llcc.txt | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt 
b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
index 5e85749..eaee06b 100644
--- a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
@@ -16,11 +16,26 @@ Properties:
 - reg:
Usage: required
Value Type: 
-   Definition: Start address and the the size of the register region.
+   Definition: The first element specifies the llcc base start address and
+   the size of the register region. The second element 
specifies
+   the llcc broadcast base address and size of the register 
region.
+
+- reg-names:
+Usage: required
+Value Type: 
+Definition: Register region names. Must be "llcc_base", 
"llcc_broadcast_base".
+
+- interrupts:
+   Usage: required
+   Definition: The interrupt is associated with the llcc edac device.
+   It's used for llcc cache single and double bit error 
detection
+   and reporting.
 
 Example:
 
cache-controller@110 {
compatible = "qcom,sdm845-llcc";
-   reg = <0x110 0x25>;
+   reg = <0x110 0x20>, <0x130 0x5> ;
+   reg-names = "llcc_base", "llcc_broadcast_base";
+   interrupts = ;
};
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v5 2/4] drivers: soc: Add support to register LLCC EDAC driver

2018-09-10 Thread Venkata Narendra Kumar Gutta
Cache error reporting controller detects and reports single and
double bit errors on Last Level Cache Controller (LLCC) cache.
Add required support to register LLCC EDAC driver as platform driver,
from LLCC driver.

Signed-off-by: Venkata Narendra Kumar Gutta 
Reviewed-by: Evan Green 
---
 drivers/soc/qcom/llcc-slice.c  | 18 --
 include/linux/soc/qcom/llcc-qcom.h |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index a63640d..09c8bb0 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -224,7 +224,7 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
u32 attr0_val;
u32 max_cap_cacheline;
u32 sz;
-   int ret;
+   int ret = 0;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
 
@@ -282,6 +282,7 @@ int qcom_llcc_probe(struct platform_device *pdev,
struct resource *llcc_banks_res, *llcc_bcast_res;
void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
+   struct platform_device *llcc_edac;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
@@ -341,6 +342,19 @@ int qcom_llcc_probe(struct platform_device *pdev,
mutex_init(_data->lock);
platform_set_drvdata(pdev, drv_data);
 
-   return qcom_llcc_cfg_program(pdev);
+   ret = qcom_llcc_cfg_program(pdev);
+   if (ret)
+   return ret;
+
+   drv_data->ecc_irq = platform_get_irq(pdev, 0);
+   if (drv_data->ecc_irq >= 0) {
+   llcc_edac = platform_device_register_data(>dev,
+   "qcom_llcc_edac", -1, drv_data,
+   sizeof(*drv_data));
+   if (IS_ERR(llcc_edac))
+   dev_err(dev, "Failed to register llcc edac driver\n");
+   }
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(qcom_llcc_probe);
diff --git a/include/linux/soc/qcom/llcc-qcom.h 
b/include/linux/soc/qcom/llcc-qcom.h
index c681e79..2e4b34d 100644
--- a/include/linux/soc/qcom/llcc-qcom.h
+++ b/include/linux/soc/qcom/llcc-qcom.h
@@ -78,6 +78,7 @@ struct llcc_slice_config {
  * @num_banks: Number of llcc banks
  * @bitmap: Bit map to track the active slice ids
  * @offsets: Pointer to the bank offsets array
+ * @ecc_irq: interrupt for llcc cache error detection and reporting
  */
 struct llcc_drv_data {
struct regmap *regmap;
@@ -89,6 +90,7 @@ struct llcc_drv_data {
u32 num_banks;
unsigned long *bitmap;
u32 *offsets;
+   int ecc_irq;
 };
 
 #if IS_ENABLED(CONFIG_QCOM_LLCC)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v5 1/4] drivers: soc: Add broadcast base for Last Level Cache Controller (LLCC)

2018-09-10 Thread Venkata Narendra Kumar Gutta
Currently, broadcast base is set to end of the LLCC banks, which may
not be correct always. As the number of banks may vary for each chipset
and the broadcast base could be at a different address as well. This info
depends on the chipset, so get the broadcast base info from the device
tree (DT). Add broadcast base in LLCC driver and use this for broadcast
writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
Reviewed-by: Evan Green 
---
 drivers/soc/qcom/llcc-slice.c  | 55 +++---
 include/linux/soc/qcom/llcc-qcom.h |  4 +--
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index fcaad1a..a63640d 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -105,22 +105,24 @@ static int llcc_update_act_ctrl(u32 sid,
u32 slice_status;
int ret;
 
-   act_ctrl_reg = drv_data->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
-   status_reg = drv_data->bcast_off + LLCC_TRP_STATUSn(sid);
+   act_ctrl_reg = LLCC_TRP_ACT_CTRLn(sid);
+   status_reg = LLCC_TRP_STATUSn(sid);
 
/* Set the ACTIVE trigger */
act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
-   ret = regmap_write(drv_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_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_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_regmap, act_ctrl_reg,
+   act_ctrl_reg_val);
if (ret)
return ret;
 
-   ret = regmap_read_poll_timeout(drv_data->regmap, status_reg,
+   ret = regmap_read_poll_timeout(drv_data->bcast_regmap, status_reg,
  slice_status, !(slice_status & status),
  0, LLCC_STATUS_READ_DELAY);
return ret;
@@ -225,16 +227,13 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
int ret;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
-   u32 bcast_off = drv_data->bcast_off;
 
sz = drv_data->cfg_size;
llcc_table = drv_data->cfg;
 
for (i = 0; i < sz; i++) {
-   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);
+   attr1_cfg = LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);
+   attr0_cfg = LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);
 
attr1_val = llcc_table[i].cache_mode;
attr1_val |= llcc_table[i].probe_target_ways <<
@@ -259,10 +258,12 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
attr0_val = llcc_table[i].res_ways & ATTR0_RES_WAYS_MASK;
attr0_val |= llcc_table[i].bonus_ways << ATTR0_BONUS_WAYS_SHIFT;
 
-   ret = regmap_write(drv_data->regmap, attr1_cfg, attr1_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr1_cfg,
+   attr1_val);
if (ret)
return ret;
-   ret = regmap_write(drv_data->regmap, attr0_cfg, attr0_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr0_cfg,
+   attr0_val);
if (ret)
return ret;
if (llcc_table[i].activate_on_init) {
@@ -278,24 +279,36 @@ int qcom_llcc_probe(struct platform_device *pdev,
 {
u32 num_banks;
struct device *dev = >dev;
-   struct resource *res;
-   void __iomem *base;
+   struct resource *llcc_banks_res, *llcc_bcast_res;
+   void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
return -ENOMEM;
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_ioremap_resource(>dev, res);
-   if (IS_ERR(base))
-   return PTR_ERR(base);
+   llcc_banks_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+   "llcc_base");
+   llcc_banks_base = devm_ioremap_resource(>dev, llcc_banks_res);
+   if (IS_ERR(llcc_banks_base))
+   return PTR_ERR(llcc_banks_base);
 
-   drv_data->regmap = devm_regmap_init_mmio(dev, base,
-   _regmap_config);
+   drv_data->regmap = devm_regmap_init_mmio(dev, llcc_banks_base,
+  

[PATCH v5 0/4] Add EDAC driver for QCOM SoCs

2018-09-10 Thread Venkata Narendra Kumar Gutta
This series implements EDAC driver for QCOM SoCs. As of now, this driver
supports EDAC for Last Level Cache Controller (LLCC). LLCC EDAC driver is
to detect and report single and double bit errors on Last Level Cache
Controller (LLCC) cache. Interrupts are triggered when the errors happen
in the cache, the driver handles those interrupts and dumps the syndrome
registers.

The driver functionality is implemented in:
qcom_edac.c : This platform driver registers to edac framework and
handles the single and double bit errors in cache by registering
interrupt handlers.

llcc-slice.c: It invokes the llcc edac driver and passes platform
data to it.

This patchset depends on the LLCC driver, which is part of 4.19 release.
Link: https://patchwork.kernel.org/patch/10422531/
Link: 
http://lists-archives.com/linux-kernel/29157082-dt-bindings-documentation-for-qcom-llcc.html

Patch wise description given below:

Patch 1 adds the broadcast base regmap for broadcast writes in llcc.

Patch 2 adds the required changes to register edac driver from llcc driver.

Patch 3 adds the EDAC driver support for QCOM SoCS.

Patch 4 updates the dt bindings of llcc.

Changes since v4:
  * Removed of_device_id struct entry from edac driver
  * Modified reg-names in the documentation

Changes since v3:
  * Updated the Kconfig and addressed minor comments in the driver

Changes since v2:
  * Modified the edac driver and Kconfig
-  removed unnecessary header files, typecasting and redundant comments.
-  Changed the initialization of reg_data datastructure to static,
   Also updated the llcc_edac_reg_data member names and datatypes.
-  Removed "EDAC_QCOM_LLCC_PANIC_ON_UE" Kconfig variable

Changes since v1:
  * Modified the edac driver
- Removed duplicate functions that are used to dump the syndrome registers,
  replaced that with a common function and a reg_data datastructure.
- Removed structure containing function pointers.
- Addressed comments on error handling to clear the interrupt status.
  * Updated Kconfig

Changes since v0:
  * Added EDAC_QCOM config and updated the driver
  * Addressed comments related to indentation and other minor ones

Channagoud Kadabi (1):
  drivers: edac: Add EDAC driver support for QCOM SoCs

Venkata Narendra Kumar Gutta (3):
  drivers: soc: Add broadcast base for Last Level Cache Controller
(LLCC)
  drivers: soc: Add support to register LLCC EDAC driver
  dt-bindings: msm: Update documentation of qcom,llcc

 .../devicetree/bindings/arm/msm/qcom,llcc.txt  |  19 +-
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  14 +
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 414 +
 drivers/soc/qcom/llcc-slice.c  |  73 ++--
 include/linux/soc/qcom/llcc-qcom.h |  30 +-
 7 files changed, 531 insertions(+), 28 deletions(-)
 create mode 100644 drivers/edac/qcom_edac.c

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v5 3/4] drivers: edac: Add EDAC driver support for QCOM SoCs

2018-09-10 Thread Venkata Narendra Kumar Gutta
From: Channagoud Kadabi 

Add error reporting driver for Single Bit Errors (SBEs) and Double Bit
Errors (DBEs). As of now, this driver supports error reporting for
Last Level Cache Controller (LLCC) of Tag RAM and Data RAM. Interrupts
are triggered when the errors happen in the cache, the driver handles
those interrupts and dumps the syndrome registers.

Signed-off-by: Channagoud Kadabi 
Signed-off-by: Venkata Narendra Kumar Gutta 
Co-developed-by: Venkata Narendra Kumar Gutta 
Acked-by: Borislav Petkov 
---
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  14 ++
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 414 +
 include/linux/soc/qcom/llcc-qcom.h |  24 +++
 5 files changed, 461 insertions(+)
 create mode 100644 drivers/edac/qcom_edac.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a23427..0bff713 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5227,6 +5227,14 @@ L:   linux-e...@vger.kernel.org
 S: Maintained
 F: drivers/edac/ti_edac.c
 
+EDAC-QUALCOMM
+M: Channagoud Kadabi 
+M: Venkata Narendra Kumar Gutta 
+L: linux-arm-...@vger.kernel.org
+L: linux-e...@vger.kernel.org
+S: Maintained
+F: drivers/edac/qcom_edac.c
+
 EDIROL UA-101/UA-1000 DRIVER
 M: Clemens Ladisch 
 L: alsa-de...@alsa-project.org (moderated for non-subscribers)
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 57304b2..c4e3472 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -460,4 +460,18 @@ config EDAC_TI
  Support for error detection and correction on the
   TI SoCs.
 
+config EDAC_QCOM
+   tristate "QCOM EDAC Controller"
+   depends on ARCH_QCOM && QCOM_LLCC
+   help
+ Support for error detection and correction on the
+ QCOM SoCs.
+
+ This driver reports Single Bit Errors (SBEs) and Double Bit Errors 
(DBEs).
+ As of now, it supports error reporting for Last Level Cache 
Controller (LLCC)
+ of Tag RAM and Data RAM.
+
+ For debugging issues having to do with stability and overall system
+ health, you should probably say 'Y' here.
+
 endif # EDAC
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index 02b43a7..716096d 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -77,3 +77,4 @@ obj-$(CONFIG_EDAC_ALTERA) += altera_edac.o
 obj-$(CONFIG_EDAC_SYNOPSYS)+= synopsys_edac.o
 obj-$(CONFIG_EDAC_XGENE)   += xgene_edac.o
 obj-$(CONFIG_EDAC_TI)  += ti_edac.o
+obj-$(CONFIG_EDAC_QCOM)+= qcom_edac.o
diff --git a/drivers/edac/qcom_edac.c b/drivers/edac/qcom_edac.c
new file mode 100644
index 000..82bd775
--- /dev/null
+++ b/drivers/edac/qcom_edac.c
@@ -0,0 +1,414 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "edac_mc.h"
+#include "edac_device.h"
+
+#define EDAC_LLCC   "qcom_llcc"
+
+#define LLCC_ERP_PANIC_ON_UE1
+
+#define TRP_SYN_REG_CNT 6
+#define DRP_SYN_REG_CNT 8
+
+#define LLCC_COMMON_STATUS0 0x0003000c
+#define LLCC_LB_CNT_MASKGENMASK(31, 28)
+#define LLCC_LB_CNT_SHIFT   28
+
+/* Single & double bit syndrome register offsets */
+#define TRP_ECC_SB_ERR_SYN0 0x0002304c
+#define TRP_ECC_DB_ERR_SYN0 0x00020370
+#define DRP_ECC_SB_ERR_SYN0 0x0004204c
+#define DRP_ECC_DB_ERR_SYN0 0x00042070
+
+/* Error register offsets */
+#define TRP_ECC_ERROR_STATUS1   0x00020348
+#define TRP_ECC_ERROR_STATUS0   0x00020344
+#define DRP_ECC_ERROR_STATUS1   0x00042048
+#define DRP_ECC_ERROR_STATUS0   0x00042044
+
+/* TRP, DRP interrupt register offsets */
+#define DRP_INTERRUPT_STATUS0x00041000
+#define TRP_INTERRUPT_0_STATUS  0x00020480
+#define DRP_INTERRUPT_CLEAR 0x00041008
+#define DRP_ECC_ERROR_CNTR_CLEAR0x00040004
+#define TRP_INTERRUPT_0_CLEAR   0x00020484
+#define TRP_ECC_ERROR_CNTR_CLEAR0x00020440
+
+/* Mask and shift macros */
+#define ECC_DB_ERR_COUNT_MASK   GENMASK(4, 0)
+#define ECC_DB_ERR_WAYS_MASKGENMASK(31, 16)
+#define ECC_DB_ERR_WAYS_SHIFT   BIT(4)
+
+#define ECC_SB_ERR_COUNT_MASK   GENMASK(23, 16)
+#define ECC_SB_ERR_COUNT_SHIFT  BIT(4)
+#define ECC_SB_ERR_WAYS_MASKGENMASK(15, 0)
+
+#define SB_ECC_ERRORBIT(0)
+#define DB_ECC_ERRORBIT(1)
+
+#define DRP_TRP_INT_CLEAR   GENMASK(1, 0)
+#define DRP_TRP_CNT_CLEAR   GENMASK(1, 0)
+
+/* Config registers offsets*/
+#define DRP_ECC_ERROR_CFG   0x0004
+
+/* Tag 

[PATCH v5 4/4] dt-bindings: msm: Update documentation of qcom,llcc

2018-09-10 Thread Venkata Narendra Kumar Gutta
Add reg-names and interrupts for LLCC documentation and the usage
examples. llcc broadcast base is added in addition to llcc base,
which is used for llcc broadcast writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
Reviewed-by: Rob Herring 
---
 .../devicetree/bindings/arm/msm/qcom,llcc.txt | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt 
b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
index 5e85749..eaee06b 100644
--- a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
@@ -16,11 +16,26 @@ Properties:
 - reg:
Usage: required
Value Type: 
-   Definition: Start address and the the size of the register region.
+   Definition: The first element specifies the llcc base start address and
+   the size of the register region. The second element 
specifies
+   the llcc broadcast base address and size of the register 
region.
+
+- reg-names:
+Usage: required
+Value Type: 
+Definition: Register region names. Must be "llcc_base", 
"llcc_broadcast_base".
+
+- interrupts:
+   Usage: required
+   Definition: The interrupt is associated with the llcc edac device.
+   It's used for llcc cache single and double bit error 
detection
+   and reporting.
 
 Example:
 
cache-controller@110 {
compatible = "qcom,sdm845-llcc";
-   reg = <0x110 0x25>;
+   reg = <0x110 0x20>, <0x130 0x5> ;
+   reg-names = "llcc_base", "llcc_broadcast_base";
+   interrupts = ;
};
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v5 2/4] drivers: soc: Add support to register LLCC EDAC driver

2018-09-10 Thread Venkata Narendra Kumar Gutta
Cache error reporting controller detects and reports single and
double bit errors on Last Level Cache Controller (LLCC) cache.
Add required support to register LLCC EDAC driver as platform driver,
from LLCC driver.

Signed-off-by: Venkata Narendra Kumar Gutta 
Reviewed-by: Evan Green 
---
 drivers/soc/qcom/llcc-slice.c  | 18 --
 include/linux/soc/qcom/llcc-qcom.h |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index a63640d..09c8bb0 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -224,7 +224,7 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
u32 attr0_val;
u32 max_cap_cacheline;
u32 sz;
-   int ret;
+   int ret = 0;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
 
@@ -282,6 +282,7 @@ int qcom_llcc_probe(struct platform_device *pdev,
struct resource *llcc_banks_res, *llcc_bcast_res;
void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
+   struct platform_device *llcc_edac;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
@@ -341,6 +342,19 @@ int qcom_llcc_probe(struct platform_device *pdev,
mutex_init(_data->lock);
platform_set_drvdata(pdev, drv_data);
 
-   return qcom_llcc_cfg_program(pdev);
+   ret = qcom_llcc_cfg_program(pdev);
+   if (ret)
+   return ret;
+
+   drv_data->ecc_irq = platform_get_irq(pdev, 0);
+   if (drv_data->ecc_irq >= 0) {
+   llcc_edac = platform_device_register_data(>dev,
+   "qcom_llcc_edac", -1, drv_data,
+   sizeof(*drv_data));
+   if (IS_ERR(llcc_edac))
+   dev_err(dev, "Failed to register llcc edac driver\n");
+   }
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(qcom_llcc_probe);
diff --git a/include/linux/soc/qcom/llcc-qcom.h 
b/include/linux/soc/qcom/llcc-qcom.h
index c681e79..2e4b34d 100644
--- a/include/linux/soc/qcom/llcc-qcom.h
+++ b/include/linux/soc/qcom/llcc-qcom.h
@@ -78,6 +78,7 @@ struct llcc_slice_config {
  * @num_banks: Number of llcc banks
  * @bitmap: Bit map to track the active slice ids
  * @offsets: Pointer to the bank offsets array
+ * @ecc_irq: interrupt for llcc cache error detection and reporting
  */
 struct llcc_drv_data {
struct regmap *regmap;
@@ -89,6 +90,7 @@ struct llcc_drv_data {
u32 num_banks;
unsigned long *bitmap;
u32 *offsets;
+   int ecc_irq;
 };
 
 #if IS_ENABLED(CONFIG_QCOM_LLCC)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v5 1/4] drivers: soc: Add broadcast base for Last Level Cache Controller (LLCC)

2018-09-10 Thread Venkata Narendra Kumar Gutta
Currently, broadcast base is set to end of the LLCC banks, which may
not be correct always. As the number of banks may vary for each chipset
and the broadcast base could be at a different address as well. This info
depends on the chipset, so get the broadcast base info from the device
tree (DT). Add broadcast base in LLCC driver and use this for broadcast
writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
Reviewed-by: Evan Green 
---
 drivers/soc/qcom/llcc-slice.c  | 55 +++---
 include/linux/soc/qcom/llcc-qcom.h |  4 +--
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index fcaad1a..a63640d 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -105,22 +105,24 @@ static int llcc_update_act_ctrl(u32 sid,
u32 slice_status;
int ret;
 
-   act_ctrl_reg = drv_data->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
-   status_reg = drv_data->bcast_off + LLCC_TRP_STATUSn(sid);
+   act_ctrl_reg = LLCC_TRP_ACT_CTRLn(sid);
+   status_reg = LLCC_TRP_STATUSn(sid);
 
/* Set the ACTIVE trigger */
act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
-   ret = regmap_write(drv_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_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_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_regmap, act_ctrl_reg,
+   act_ctrl_reg_val);
if (ret)
return ret;
 
-   ret = regmap_read_poll_timeout(drv_data->regmap, status_reg,
+   ret = regmap_read_poll_timeout(drv_data->bcast_regmap, status_reg,
  slice_status, !(slice_status & status),
  0, LLCC_STATUS_READ_DELAY);
return ret;
@@ -225,16 +227,13 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
int ret;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
-   u32 bcast_off = drv_data->bcast_off;
 
sz = drv_data->cfg_size;
llcc_table = drv_data->cfg;
 
for (i = 0; i < sz; i++) {
-   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);
+   attr1_cfg = LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);
+   attr0_cfg = LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);
 
attr1_val = llcc_table[i].cache_mode;
attr1_val |= llcc_table[i].probe_target_ways <<
@@ -259,10 +258,12 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
attr0_val = llcc_table[i].res_ways & ATTR0_RES_WAYS_MASK;
attr0_val |= llcc_table[i].bonus_ways << ATTR0_BONUS_WAYS_SHIFT;
 
-   ret = regmap_write(drv_data->regmap, attr1_cfg, attr1_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr1_cfg,
+   attr1_val);
if (ret)
return ret;
-   ret = regmap_write(drv_data->regmap, attr0_cfg, attr0_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr0_cfg,
+   attr0_val);
if (ret)
return ret;
if (llcc_table[i].activate_on_init) {
@@ -278,24 +279,36 @@ int qcom_llcc_probe(struct platform_device *pdev,
 {
u32 num_banks;
struct device *dev = >dev;
-   struct resource *res;
-   void __iomem *base;
+   struct resource *llcc_banks_res, *llcc_bcast_res;
+   void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
return -ENOMEM;
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_ioremap_resource(>dev, res);
-   if (IS_ERR(base))
-   return PTR_ERR(base);
+   llcc_banks_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+   "llcc_base");
+   llcc_banks_base = devm_ioremap_resource(>dev, llcc_banks_res);
+   if (IS_ERR(llcc_banks_base))
+   return PTR_ERR(llcc_banks_base);
 
-   drv_data->regmap = devm_regmap_init_mmio(dev, base,
-   _regmap_config);
+   drv_data->regmap = devm_regmap_init_mmio(dev, llcc_banks_base,
+  

[PATCH v4 3/4] drivers: edac: Add EDAC driver support for QCOM SoCs

2018-09-04 Thread Venkata Narendra Kumar Gutta
From: Channagoud Kadabi 

Add error reporting driver for Single Bit Errors (SBEs) and Double Bit
Errors (DBEs). As of now, this driver supports error reporting for
Last Level Cache Controller (LLCC) of Tag RAM and Data RAM. Interrupts
are triggered when the errors happen in the cache, the driver handles
those interrupts and dumps the syndrome registers.

Signed-off-by: Channagoud Kadabi 
Signed-off-by: Venkata Narendra Kumar Gutta 
Co-developed-by: Venkata Narendra Kumar Gutta 
---
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  14 ++
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 420 +
 include/linux/soc/qcom/llcc-qcom.h |  24 +++
 5 files changed, 467 insertions(+)
 create mode 100644 drivers/edac/qcom_edac.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a23427..0bff713 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5227,6 +5227,14 @@ L:   linux-e...@vger.kernel.org
 S: Maintained
 F: drivers/edac/ti_edac.c
 
+EDAC-QUALCOMM
+M: Channagoud Kadabi 
+M: Venkata Narendra Kumar Gutta 
+L: linux-arm-...@vger.kernel.org
+L: linux-e...@vger.kernel.org
+S: Maintained
+F: drivers/edac/qcom_edac.c
+
 EDIROL UA-101/UA-1000 DRIVER
 M: Clemens Ladisch 
 L: alsa-de...@alsa-project.org (moderated for non-subscribers)
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 57304b2..c4e3472 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -460,4 +460,18 @@ config EDAC_TI
  Support for error detection and correction on the
   TI SoCs.
 
+config EDAC_QCOM
+   tristate "QCOM EDAC Controller"
+   depends on ARCH_QCOM && QCOM_LLCC
+   help
+ Support for error detection and correction on the
+ QCOM SoCs.
+
+ This driver reports Single Bit Errors (SBEs) and Double Bit Errors 
(DBEs).
+ As of now, it supports error reporting for Last Level Cache 
Controller (LLCC)
+ of Tag RAM and Data RAM.
+
+ For debugging issues having to do with stability and overall system
+ health, you should probably say 'Y' here.
+
 endif # EDAC
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index 02b43a7..716096d 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -77,3 +77,4 @@ obj-$(CONFIG_EDAC_ALTERA) += altera_edac.o
 obj-$(CONFIG_EDAC_SYNOPSYS)+= synopsys_edac.o
 obj-$(CONFIG_EDAC_XGENE)   += xgene_edac.o
 obj-$(CONFIG_EDAC_TI)  += ti_edac.o
+obj-$(CONFIG_EDAC_QCOM)+= qcom_edac.o
diff --git a/drivers/edac/qcom_edac.c b/drivers/edac/qcom_edac.c
new file mode 100644
index 000..1773216
--- /dev/null
+++ b/drivers/edac/qcom_edac.c
@@ -0,0 +1,420 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "edac_mc.h"
+#include "edac_device.h"
+
+#define EDAC_LLCC   "qcom_llcc"
+
+#define LLCC_ERP_PANIC_ON_UE1
+
+#define TRP_SYN_REG_CNT 6
+#define DRP_SYN_REG_CNT 8
+
+#define LLCC_COMMON_STATUS0 0x0003000c
+#define LLCC_LB_CNT_MASKGENMASK(31, 28)
+#define LLCC_LB_CNT_SHIFT   28
+
+/* Single & double bit syndrome register offsets */
+#define TRP_ECC_SB_ERR_SYN0 0x0002304c
+#define TRP_ECC_DB_ERR_SYN0 0x00020370
+#define DRP_ECC_SB_ERR_SYN0 0x0004204c
+#define DRP_ECC_DB_ERR_SYN0 0x00042070
+
+/* Error register offsets */
+#define TRP_ECC_ERROR_STATUS1   0x00020348
+#define TRP_ECC_ERROR_STATUS0   0x00020344
+#define DRP_ECC_ERROR_STATUS1   0x00042048
+#define DRP_ECC_ERROR_STATUS0   0x00042044
+
+/* TRP, DRP interrupt register offsets */
+#define DRP_INTERRUPT_STATUS0x00041000
+#define TRP_INTERRUPT_0_STATUS  0x00020480
+#define DRP_INTERRUPT_CLEAR 0x00041008
+#define DRP_ECC_ERROR_CNTR_CLEAR0x00040004
+#define TRP_INTERRUPT_0_CLEAR   0x00020484
+#define TRP_ECC_ERROR_CNTR_CLEAR0x00020440
+
+/* Mask and shift macros */
+#define ECC_DB_ERR_COUNT_MASK   GENMASK(4, 0)
+#define ECC_DB_ERR_WAYS_MASKGENMASK(31, 16)
+#define ECC_DB_ERR_WAYS_SHIFT   BIT(4)
+
+#define ECC_SB_ERR_COUNT_MASK   GENMASK(23, 16)
+#define ECC_SB_ERR_COUNT_SHIFT  BIT(4)
+#define ECC_SB_ERR_WAYS_MASKGENMASK(15, 0)
+
+#define SB_ECC_ERRORBIT(0)
+#define DB_ECC_ERRORBIT(1)
+
+#define DRP_TRP_INT_CLEAR   GENMASK(1, 0)
+#define DRP_TRP_CNT_CLEAR   GENMASK(1, 0)
+
+/* Config registers offsets*/
+#define DRP_ECC_ERROR_CFG   0x0004
+
+/* Tag RAM, Data RAM interrupt

[PATCH v4 0/4] Add EDAC driver for QCOM SoCs

2018-09-04 Thread Venkata Narendra Kumar Gutta
This series implements EDAC driver for QCOM SoCs. As of now, this driver
supports EDAC for Last Level Cache Controller (LLCC). LLCC EDAC driver is
to detect and report single and double bit errors on Last Level Cache
Controller (LLCC) cache. Interrupts are triggered when the errors happen
in the cache, the driver handles those interrupts and dumps the syndrome
registers.

The driver functionality is implemented in:
qcom_edac.c : This platform driver registers to edac framework and
handles the single and double bit errors in cache by registering
interrupt handlers.

llcc-slice.c: It invokes the llcc edac driver and passes platform
data to it.

This patchset depends on the LLCC driver, which is part of 4.19 release.
Link: https://patchwork.kernel.org/patch/10422531/
Link: 
http://lists-archives.com/linux-kernel/29157082-dt-bindings-documentation-for-qcom-llcc.html

Patch wise description given below:

Patch 1 adds the broadcast base regmap for broadcast writes in llcc.

Patch 2 adds the required changes to register edac driver from llcc driver.

Patch 3 adds the EDAC driver support for QCOM SoCS.

Patch 4 updates the dt bindings of llcc.

Changes since v3:
  * Updated the Kconfig and addressed minor comments in the driver

Changes since v2:
  * Modified the edac driver and Kconfig
-  removed unnecessary header files, typecasting and redundant comments.
-  Changed the initialization of reg_data datastructure to static,
   Also updated the llcc_edac_reg_data member names and datatypes.
-  Removed "EDAC_QCOM_LLCC_PANIC_ON_UE" Kconfig variable

Changes since v1:
  * Modified the edac driver
- Removed duplicate functions that are used to dump the syndrome registers,
  replaced that with a common function and a reg_data datastructure.
- Removed structure containing function pointers.
- Addressed comments on error handling to clear the interrupt status.
  * updated Kconfig

Changes since v0:
  * Added EDAC_QCOM config and updated the driver
  * Addressed comments related to indentation and other minor ones

Channagoud Kadabi (1):
  drivers: edac: Add EDAC driver support for QCOM SoCs

Venkata Narendra Kumar Gutta (3):
  drivers: soc: Add broadcast base for Last Level Cache Controller
(LLCC)
  drivers: soc: Add support to register LLCC EDAC driver
  dt-bindings: msm: Update documentation of qcom,llcc

 .../devicetree/bindings/arm/msm/qcom,llcc.txt  |  19 +-
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  14 +
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 420 +
 drivers/soc/qcom/llcc-slice.c  |  73 ++--
 include/linux/soc/qcom/llcc-qcom.h |  30 +-
 7 files changed, 537 insertions(+), 28 deletions(-)
 create mode 100644 drivers/edac/qcom_edac.c

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v4 3/4] drivers: edac: Add EDAC driver support for QCOM SoCs

2018-09-04 Thread Venkata Narendra Kumar Gutta
From: Channagoud Kadabi 

Add error reporting driver for Single Bit Errors (SBEs) and Double Bit
Errors (DBEs). As of now, this driver supports error reporting for
Last Level Cache Controller (LLCC) of Tag RAM and Data RAM. Interrupts
are triggered when the errors happen in the cache, the driver handles
those interrupts and dumps the syndrome registers.

Signed-off-by: Channagoud Kadabi 
Signed-off-by: Venkata Narendra Kumar Gutta 
Co-developed-by: Venkata Narendra Kumar Gutta 
---
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  14 ++
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 420 +
 include/linux/soc/qcom/llcc-qcom.h |  24 +++
 5 files changed, 467 insertions(+)
 create mode 100644 drivers/edac/qcom_edac.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a23427..0bff713 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5227,6 +5227,14 @@ L:   linux-e...@vger.kernel.org
 S: Maintained
 F: drivers/edac/ti_edac.c
 
+EDAC-QUALCOMM
+M: Channagoud Kadabi 
+M: Venkata Narendra Kumar Gutta 
+L: linux-arm-...@vger.kernel.org
+L: linux-e...@vger.kernel.org
+S: Maintained
+F: drivers/edac/qcom_edac.c
+
 EDIROL UA-101/UA-1000 DRIVER
 M: Clemens Ladisch 
 L: alsa-de...@alsa-project.org (moderated for non-subscribers)
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 57304b2..c4e3472 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -460,4 +460,18 @@ config EDAC_TI
  Support for error detection and correction on the
   TI SoCs.
 
+config EDAC_QCOM
+   tristate "QCOM EDAC Controller"
+   depends on ARCH_QCOM && QCOM_LLCC
+   help
+ Support for error detection and correction on the
+ QCOM SoCs.
+
+ This driver reports Single Bit Errors (SBEs) and Double Bit Errors 
(DBEs).
+ As of now, it supports error reporting for Last Level Cache 
Controller (LLCC)
+ of Tag RAM and Data RAM.
+
+ For debugging issues having to do with stability and overall system
+ health, you should probably say 'Y' here.
+
 endif # EDAC
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index 02b43a7..716096d 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -77,3 +77,4 @@ obj-$(CONFIG_EDAC_ALTERA) += altera_edac.o
 obj-$(CONFIG_EDAC_SYNOPSYS)+= synopsys_edac.o
 obj-$(CONFIG_EDAC_XGENE)   += xgene_edac.o
 obj-$(CONFIG_EDAC_TI)  += ti_edac.o
+obj-$(CONFIG_EDAC_QCOM)+= qcom_edac.o
diff --git a/drivers/edac/qcom_edac.c b/drivers/edac/qcom_edac.c
new file mode 100644
index 000..1773216
--- /dev/null
+++ b/drivers/edac/qcom_edac.c
@@ -0,0 +1,420 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "edac_mc.h"
+#include "edac_device.h"
+
+#define EDAC_LLCC   "qcom_llcc"
+
+#define LLCC_ERP_PANIC_ON_UE1
+
+#define TRP_SYN_REG_CNT 6
+#define DRP_SYN_REG_CNT 8
+
+#define LLCC_COMMON_STATUS0 0x0003000c
+#define LLCC_LB_CNT_MASKGENMASK(31, 28)
+#define LLCC_LB_CNT_SHIFT   28
+
+/* Single & double bit syndrome register offsets */
+#define TRP_ECC_SB_ERR_SYN0 0x0002304c
+#define TRP_ECC_DB_ERR_SYN0 0x00020370
+#define DRP_ECC_SB_ERR_SYN0 0x0004204c
+#define DRP_ECC_DB_ERR_SYN0 0x00042070
+
+/* Error register offsets */
+#define TRP_ECC_ERROR_STATUS1   0x00020348
+#define TRP_ECC_ERROR_STATUS0   0x00020344
+#define DRP_ECC_ERROR_STATUS1   0x00042048
+#define DRP_ECC_ERROR_STATUS0   0x00042044
+
+/* TRP, DRP interrupt register offsets */
+#define DRP_INTERRUPT_STATUS0x00041000
+#define TRP_INTERRUPT_0_STATUS  0x00020480
+#define DRP_INTERRUPT_CLEAR 0x00041008
+#define DRP_ECC_ERROR_CNTR_CLEAR0x00040004
+#define TRP_INTERRUPT_0_CLEAR   0x00020484
+#define TRP_ECC_ERROR_CNTR_CLEAR0x00020440
+
+/* Mask and shift macros */
+#define ECC_DB_ERR_COUNT_MASK   GENMASK(4, 0)
+#define ECC_DB_ERR_WAYS_MASKGENMASK(31, 16)
+#define ECC_DB_ERR_WAYS_SHIFT   BIT(4)
+
+#define ECC_SB_ERR_COUNT_MASK   GENMASK(23, 16)
+#define ECC_SB_ERR_COUNT_SHIFT  BIT(4)
+#define ECC_SB_ERR_WAYS_MASKGENMASK(15, 0)
+
+#define SB_ECC_ERRORBIT(0)
+#define DB_ECC_ERRORBIT(1)
+
+#define DRP_TRP_INT_CLEAR   GENMASK(1, 0)
+#define DRP_TRP_CNT_CLEAR   GENMASK(1, 0)
+
+/* Config registers offsets*/
+#define DRP_ECC_ERROR_CFG   0x0004
+
+/* Tag RAM, Data RAM interrupt

[PATCH v4 0/4] Add EDAC driver for QCOM SoCs

2018-09-04 Thread Venkata Narendra Kumar Gutta
This series implements EDAC driver for QCOM SoCs. As of now, this driver
supports EDAC for Last Level Cache Controller (LLCC). LLCC EDAC driver is
to detect and report single and double bit errors on Last Level Cache
Controller (LLCC) cache. Interrupts are triggered when the errors happen
in the cache, the driver handles those interrupts and dumps the syndrome
registers.

The driver functionality is implemented in:
qcom_edac.c : This platform driver registers to edac framework and
handles the single and double bit errors in cache by registering
interrupt handlers.

llcc-slice.c: It invokes the llcc edac driver and passes platform
data to it.

This patchset depends on the LLCC driver, which is part of 4.19 release.
Link: https://patchwork.kernel.org/patch/10422531/
Link: 
http://lists-archives.com/linux-kernel/29157082-dt-bindings-documentation-for-qcom-llcc.html

Patch wise description given below:

Patch 1 adds the broadcast base regmap for broadcast writes in llcc.

Patch 2 adds the required changes to register edac driver from llcc driver.

Patch 3 adds the EDAC driver support for QCOM SoCS.

Patch 4 updates the dt bindings of llcc.

Changes since v3:
  * Updated the Kconfig and addressed minor comments in the driver

Changes since v2:
  * Modified the edac driver and Kconfig
-  removed unnecessary header files, typecasting and redundant comments.
-  Changed the initialization of reg_data datastructure to static,
   Also updated the llcc_edac_reg_data member names and datatypes.
-  Removed "EDAC_QCOM_LLCC_PANIC_ON_UE" Kconfig variable

Changes since v1:
  * Modified the edac driver
- Removed duplicate functions that are used to dump the syndrome registers,
  replaced that with a common function and a reg_data datastructure.
- Removed structure containing function pointers.
- Addressed comments on error handling to clear the interrupt status.
  * updated Kconfig

Changes since v0:
  * Added EDAC_QCOM config and updated the driver
  * Addressed comments related to indentation and other minor ones

Channagoud Kadabi (1):
  drivers: edac: Add EDAC driver support for QCOM SoCs

Venkata Narendra Kumar Gutta (3):
  drivers: soc: Add broadcast base for Last Level Cache Controller
(LLCC)
  drivers: soc: Add support to register LLCC EDAC driver
  dt-bindings: msm: Update documentation of qcom,llcc

 .../devicetree/bindings/arm/msm/qcom,llcc.txt  |  19 +-
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  14 +
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 420 +
 drivers/soc/qcom/llcc-slice.c  |  73 ++--
 include/linux/soc/qcom/llcc-qcom.h |  30 +-
 7 files changed, 537 insertions(+), 28 deletions(-)
 create mode 100644 drivers/edac/qcom_edac.c

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v4 1/4] drivers: soc: Add broadcast base for Last Level Cache Controller (LLCC)

2018-09-04 Thread Venkata Narendra Kumar Gutta
Currently, broadcast base is set to end of the LLCC banks, which may
not be correct always. As the number of banks may vary for each chipset
and the broadcast base could be at a different address as well. This info
depends on the chipset, so get the broadcast base info from the device
tree (DT). Add broadcast base in LLCC driver and use this for broadcast
writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
Reviewed-by: Evan Green 
---
 drivers/soc/qcom/llcc-slice.c  | 55 +++---
 include/linux/soc/qcom/llcc-qcom.h |  4 +--
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index fcaad1a..a63640d 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -105,22 +105,24 @@ static int llcc_update_act_ctrl(u32 sid,
u32 slice_status;
int ret;
 
-   act_ctrl_reg = drv_data->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
-   status_reg = drv_data->bcast_off + LLCC_TRP_STATUSn(sid);
+   act_ctrl_reg = LLCC_TRP_ACT_CTRLn(sid);
+   status_reg = LLCC_TRP_STATUSn(sid);
 
/* Set the ACTIVE trigger */
act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
-   ret = regmap_write(drv_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_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_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_regmap, act_ctrl_reg,
+   act_ctrl_reg_val);
if (ret)
return ret;
 
-   ret = regmap_read_poll_timeout(drv_data->regmap, status_reg,
+   ret = regmap_read_poll_timeout(drv_data->bcast_regmap, status_reg,
  slice_status, !(slice_status & status),
  0, LLCC_STATUS_READ_DELAY);
return ret;
@@ -225,16 +227,13 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
int ret;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
-   u32 bcast_off = drv_data->bcast_off;
 
sz = drv_data->cfg_size;
llcc_table = drv_data->cfg;
 
for (i = 0; i < sz; i++) {
-   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);
+   attr1_cfg = LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);
+   attr0_cfg = LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);
 
attr1_val = llcc_table[i].cache_mode;
attr1_val |= llcc_table[i].probe_target_ways <<
@@ -259,10 +258,12 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
attr0_val = llcc_table[i].res_ways & ATTR0_RES_WAYS_MASK;
attr0_val |= llcc_table[i].bonus_ways << ATTR0_BONUS_WAYS_SHIFT;
 
-   ret = regmap_write(drv_data->regmap, attr1_cfg, attr1_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr1_cfg,
+   attr1_val);
if (ret)
return ret;
-   ret = regmap_write(drv_data->regmap, attr0_cfg, attr0_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr0_cfg,
+   attr0_val);
if (ret)
return ret;
if (llcc_table[i].activate_on_init) {
@@ -278,24 +279,36 @@ int qcom_llcc_probe(struct platform_device *pdev,
 {
u32 num_banks;
struct device *dev = >dev;
-   struct resource *res;
-   void __iomem *base;
+   struct resource *llcc_banks_res, *llcc_bcast_res;
+   void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
return -ENOMEM;
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_ioremap_resource(>dev, res);
-   if (IS_ERR(base))
-   return PTR_ERR(base);
+   llcc_banks_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+   "llcc_base");
+   llcc_banks_base = devm_ioremap_resource(>dev, llcc_banks_res);
+   if (IS_ERR(llcc_banks_base))
+   return PTR_ERR(llcc_banks_base);
 
-   drv_data->regmap = devm_regmap_init_mmio(dev, base,
-   _regmap_config);
+   drv_data->regmap = devm_regmap_init_mmio(dev, llcc_banks_base,
+  

[PATCH v4 4/4] dt-bindings: msm: Update documentation of qcom,llcc

2018-09-04 Thread Venkata Narendra Kumar Gutta
Add reg-names and interrupts for LLCC documentation and the usage
examples. llcc broadcast base is added in addition to llcc base,
which is used for llcc broadcast writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
Reviewed-by: Rob Herring 
---
 .../devicetree/bindings/arm/msm/qcom,llcc.txt | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt 
b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
index 5e85749..2e007dc 100644
--- a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
@@ -16,11 +16,26 @@ Properties:
 - reg:
Usage: required
Value Type: 
-   Definition: Start address and the the size of the register region.
+   Definition: The first element specifies the llcc base start address and
+   the size of the register region. The second element 
specifies
+   the llcc broadcast base address and size of the register 
region.
+
+- reg-names:
+Usage: required
+Value Type: 
+Definition: Register region names. Must be "llcc_base", 
"llcc_bcast_base".
+
+- interrupts:
+   Usage: required
+   Definition: The interrupt is associated with the llcc edac device.
+   It's used for llcc cache single and double bit error 
detection
+   and reporting.
 
 Example:
 
cache-controller@110 {
compatible = "qcom,sdm845-llcc";
-   reg = <0x110 0x25>;
+   reg = <0x110 0x20>, <0x130 0x5> ;
+   reg-names = "llcc_base", "llcc_bcast_base";
+   interrupts = ;
};
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v4 2/4] drivers: soc: Add support to register LLCC EDAC driver

2018-09-04 Thread Venkata Narendra Kumar Gutta
Cache error reporting controller detects and reports single and
double bit errors on Last Level Cache Controller (LLCC) cache.
Add required support to register LLCC EDAC driver as platform driver,
from LLCC driver.

Signed-off-by: Venkata Narendra Kumar Gutta 
Reviewed-by: Evan Green 
---
 drivers/soc/qcom/llcc-slice.c  | 18 --
 include/linux/soc/qcom/llcc-qcom.h |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index a63640d..09c8bb0 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -224,7 +224,7 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
u32 attr0_val;
u32 max_cap_cacheline;
u32 sz;
-   int ret;
+   int ret = 0;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
 
@@ -282,6 +282,7 @@ int qcom_llcc_probe(struct platform_device *pdev,
struct resource *llcc_banks_res, *llcc_bcast_res;
void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
+   struct platform_device *llcc_edac;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
@@ -341,6 +342,19 @@ int qcom_llcc_probe(struct platform_device *pdev,
mutex_init(_data->lock);
platform_set_drvdata(pdev, drv_data);
 
-   return qcom_llcc_cfg_program(pdev);
+   ret = qcom_llcc_cfg_program(pdev);
+   if (ret)
+   return ret;
+
+   drv_data->ecc_irq = platform_get_irq(pdev, 0);
+   if (drv_data->ecc_irq >= 0) {
+   llcc_edac = platform_device_register_data(>dev,
+   "qcom_llcc_edac", -1, drv_data,
+   sizeof(*drv_data));
+   if (IS_ERR(llcc_edac))
+   dev_err(dev, "Failed to register llcc edac driver\n");
+   }
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(qcom_llcc_probe);
diff --git a/include/linux/soc/qcom/llcc-qcom.h 
b/include/linux/soc/qcom/llcc-qcom.h
index c681e79..2e4b34d 100644
--- a/include/linux/soc/qcom/llcc-qcom.h
+++ b/include/linux/soc/qcom/llcc-qcom.h
@@ -78,6 +78,7 @@ struct llcc_slice_config {
  * @num_banks: Number of llcc banks
  * @bitmap: Bit map to track the active slice ids
  * @offsets: Pointer to the bank offsets array
+ * @ecc_irq: interrupt for llcc cache error detection and reporting
  */
 struct llcc_drv_data {
struct regmap *regmap;
@@ -89,6 +90,7 @@ struct llcc_drv_data {
u32 num_banks;
unsigned long *bitmap;
u32 *offsets;
+   int ecc_irq;
 };
 
 #if IS_ENABLED(CONFIG_QCOM_LLCC)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v4 1/4] drivers: soc: Add broadcast base for Last Level Cache Controller (LLCC)

2018-09-04 Thread Venkata Narendra Kumar Gutta
Currently, broadcast base is set to end of the LLCC banks, which may
not be correct always. As the number of banks may vary for each chipset
and the broadcast base could be at a different address as well. This info
depends on the chipset, so get the broadcast base info from the device
tree (DT). Add broadcast base in LLCC driver and use this for broadcast
writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
Reviewed-by: Evan Green 
---
 drivers/soc/qcom/llcc-slice.c  | 55 +++---
 include/linux/soc/qcom/llcc-qcom.h |  4 +--
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index fcaad1a..a63640d 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -105,22 +105,24 @@ static int llcc_update_act_ctrl(u32 sid,
u32 slice_status;
int ret;
 
-   act_ctrl_reg = drv_data->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
-   status_reg = drv_data->bcast_off + LLCC_TRP_STATUSn(sid);
+   act_ctrl_reg = LLCC_TRP_ACT_CTRLn(sid);
+   status_reg = LLCC_TRP_STATUSn(sid);
 
/* Set the ACTIVE trigger */
act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
-   ret = regmap_write(drv_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_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_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_regmap, act_ctrl_reg,
+   act_ctrl_reg_val);
if (ret)
return ret;
 
-   ret = regmap_read_poll_timeout(drv_data->regmap, status_reg,
+   ret = regmap_read_poll_timeout(drv_data->bcast_regmap, status_reg,
  slice_status, !(slice_status & status),
  0, LLCC_STATUS_READ_DELAY);
return ret;
@@ -225,16 +227,13 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
int ret;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
-   u32 bcast_off = drv_data->bcast_off;
 
sz = drv_data->cfg_size;
llcc_table = drv_data->cfg;
 
for (i = 0; i < sz; i++) {
-   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);
+   attr1_cfg = LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);
+   attr0_cfg = LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);
 
attr1_val = llcc_table[i].cache_mode;
attr1_val |= llcc_table[i].probe_target_ways <<
@@ -259,10 +258,12 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
attr0_val = llcc_table[i].res_ways & ATTR0_RES_WAYS_MASK;
attr0_val |= llcc_table[i].bonus_ways << ATTR0_BONUS_WAYS_SHIFT;
 
-   ret = regmap_write(drv_data->regmap, attr1_cfg, attr1_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr1_cfg,
+   attr1_val);
if (ret)
return ret;
-   ret = regmap_write(drv_data->regmap, attr0_cfg, attr0_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr0_cfg,
+   attr0_val);
if (ret)
return ret;
if (llcc_table[i].activate_on_init) {
@@ -278,24 +279,36 @@ int qcom_llcc_probe(struct platform_device *pdev,
 {
u32 num_banks;
struct device *dev = >dev;
-   struct resource *res;
-   void __iomem *base;
+   struct resource *llcc_banks_res, *llcc_bcast_res;
+   void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
return -ENOMEM;
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_ioremap_resource(>dev, res);
-   if (IS_ERR(base))
-   return PTR_ERR(base);
+   llcc_banks_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+   "llcc_base");
+   llcc_banks_base = devm_ioremap_resource(>dev, llcc_banks_res);
+   if (IS_ERR(llcc_banks_base))
+   return PTR_ERR(llcc_banks_base);
 
-   drv_data->regmap = devm_regmap_init_mmio(dev, base,
-   _regmap_config);
+   drv_data->regmap = devm_regmap_init_mmio(dev, llcc_banks_base,
+  

[PATCH v4 4/4] dt-bindings: msm: Update documentation of qcom,llcc

2018-09-04 Thread Venkata Narendra Kumar Gutta
Add reg-names and interrupts for LLCC documentation and the usage
examples. llcc broadcast base is added in addition to llcc base,
which is used for llcc broadcast writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
Reviewed-by: Rob Herring 
---
 .../devicetree/bindings/arm/msm/qcom,llcc.txt | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt 
b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
index 5e85749..2e007dc 100644
--- a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
@@ -16,11 +16,26 @@ Properties:
 - reg:
Usage: required
Value Type: 
-   Definition: Start address and the the size of the register region.
+   Definition: The first element specifies the llcc base start address and
+   the size of the register region. The second element 
specifies
+   the llcc broadcast base address and size of the register 
region.
+
+- reg-names:
+Usage: required
+Value Type: 
+Definition: Register region names. Must be "llcc_base", 
"llcc_bcast_base".
+
+- interrupts:
+   Usage: required
+   Definition: The interrupt is associated with the llcc edac device.
+   It's used for llcc cache single and double bit error 
detection
+   and reporting.
 
 Example:
 
cache-controller@110 {
compatible = "qcom,sdm845-llcc";
-   reg = <0x110 0x25>;
+   reg = <0x110 0x20>, <0x130 0x5> ;
+   reg-names = "llcc_base", "llcc_bcast_base";
+   interrupts = ;
};
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v4 2/4] drivers: soc: Add support to register LLCC EDAC driver

2018-09-04 Thread Venkata Narendra Kumar Gutta
Cache error reporting controller detects and reports single and
double bit errors on Last Level Cache Controller (LLCC) cache.
Add required support to register LLCC EDAC driver as platform driver,
from LLCC driver.

Signed-off-by: Venkata Narendra Kumar Gutta 
Reviewed-by: Evan Green 
---
 drivers/soc/qcom/llcc-slice.c  | 18 --
 include/linux/soc/qcom/llcc-qcom.h |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index a63640d..09c8bb0 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -224,7 +224,7 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
u32 attr0_val;
u32 max_cap_cacheline;
u32 sz;
-   int ret;
+   int ret = 0;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
 
@@ -282,6 +282,7 @@ int qcom_llcc_probe(struct platform_device *pdev,
struct resource *llcc_banks_res, *llcc_bcast_res;
void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
+   struct platform_device *llcc_edac;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
@@ -341,6 +342,19 @@ int qcom_llcc_probe(struct platform_device *pdev,
mutex_init(_data->lock);
platform_set_drvdata(pdev, drv_data);
 
-   return qcom_llcc_cfg_program(pdev);
+   ret = qcom_llcc_cfg_program(pdev);
+   if (ret)
+   return ret;
+
+   drv_data->ecc_irq = platform_get_irq(pdev, 0);
+   if (drv_data->ecc_irq >= 0) {
+   llcc_edac = platform_device_register_data(>dev,
+   "qcom_llcc_edac", -1, drv_data,
+   sizeof(*drv_data));
+   if (IS_ERR(llcc_edac))
+   dev_err(dev, "Failed to register llcc edac driver\n");
+   }
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(qcom_llcc_probe);
diff --git a/include/linux/soc/qcom/llcc-qcom.h 
b/include/linux/soc/qcom/llcc-qcom.h
index c681e79..2e4b34d 100644
--- a/include/linux/soc/qcom/llcc-qcom.h
+++ b/include/linux/soc/qcom/llcc-qcom.h
@@ -78,6 +78,7 @@ struct llcc_slice_config {
  * @num_banks: Number of llcc banks
  * @bitmap: Bit map to track the active slice ids
  * @offsets: Pointer to the bank offsets array
+ * @ecc_irq: interrupt for llcc cache error detection and reporting
  */
 struct llcc_drv_data {
struct regmap *regmap;
@@ -89,6 +90,7 @@ struct llcc_drv_data {
u32 num_banks;
unsigned long *bitmap;
u32 *offsets;
+   int ecc_irq;
 };
 
 #if IS_ENABLED(CONFIG_QCOM_LLCC)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v3 3/4] drivers: edac: Add EDAC driver support for QCOM SoCs

2018-08-28 Thread Venkata Narendra Kumar Gutta
From: Channagoud Kadabi 

Add error reporting driver for Single Bit Errors (SBEs) and Double Bit
Errors (DBEs). As of now, this driver supports error reporting for
Last Level Cache Controller (LLCC) of Tag RAM and Data RAM. Interrupts
are triggered when the errors happen in the cache, the driver handles
those interrupts and dumps the syndrome registers.

Signed-off-by: Channagoud Kadabi 
Signed-off-by: Venkata Narendra Kumar Gutta 
Co-developed-by: Venkata Narendra Kumar Gutta 
---
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  22 ++
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 421 +
 include/linux/soc/qcom/llcc-qcom.h |  24 +++
 5 files changed, 476 insertions(+)
 create mode 100644 drivers/edac/qcom_edac.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a23427..0bff713 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5227,6 +5227,14 @@ L:   linux-e...@vger.kernel.org
 S: Maintained
 F: drivers/edac/ti_edac.c
 
+EDAC-QUALCOMM
+M: Channagoud Kadabi 
+M: Venkata Narendra Kumar Gutta 
+L: linux-arm-...@vger.kernel.org
+L: linux-e...@vger.kernel.org
+S: Maintained
+F: drivers/edac/qcom_edac.c
+
 EDIROL UA-101/UA-1000 DRIVER
 M: Clemens Ladisch 
 L: alsa-de...@alsa-project.org (moderated for non-subscribers)
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 57304b2..df58957 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -460,4 +460,26 @@ config EDAC_TI
  Support for error detection and correction on the
   TI SoCs.
 
+config EDAC_QCOM
+   tristate "QCOM EDAC Controller"
+   depends on EDAC
+   help
+ Support for error detection and correction on the
+ QCOM SoCs.
+
+ This driver reports Single Bit Errors (SBEs) and Double Bit Errors 
(DBEs).
+ As of now, it supports error reporting for Last Level Cache 
Controller (LLCC)
+ of Tag RAM and Data RAM.
+
+config EDAC_QCOM_LLCC
+   tristate "QCOM EDAC Controller for LLCC Cache"
+   depends on EDAC_QCOM && QCOM_LLCC
+   help
+ Support for error detection and correction on the
+ QCOM LLCC cache. Report errors caught by LLCC ECC
+ mechanism.
+
+ For debugging issues having to do with stability and overall system
+ health, you should probably say 'Y' here.
+
 endif # EDAC
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index 02b43a7..716096d 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -77,3 +77,4 @@ obj-$(CONFIG_EDAC_ALTERA) += altera_edac.o
 obj-$(CONFIG_EDAC_SYNOPSYS)+= synopsys_edac.o
 obj-$(CONFIG_EDAC_XGENE)   += xgene_edac.o
 obj-$(CONFIG_EDAC_TI)  += ti_edac.o
+obj-$(CONFIG_EDAC_QCOM)+= qcom_edac.o
diff --git a/drivers/edac/qcom_edac.c b/drivers/edac/qcom_edac.c
new file mode 100644
index 000..871ed07
--- /dev/null
+++ b/drivers/edac/qcom_edac.c
@@ -0,0 +1,421 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "edac_mc.h"
+#include "edac_device.h"
+
+#define EDAC_LLCC   "qcom_llcc"
+
+#define LLCC_ERP_PANIC_ON_UE1
+
+#define TRP_SYN_REG_CNT 6
+#define DRP_SYN_REG_CNT 8
+
+#define LLCC_COMMON_STATUS0 0x0003000c
+#define LLCC_LB_CNT_MASKGENMASK(31, 28)
+#define LLCC_LB_CNT_SHIFT   28
+
+/* Single & double bit syndrome register offsets */
+#define TRP_ECC_SB_ERR_SYN0 0x0002304c
+#define TRP_ECC_DB_ERR_SYN0 0x00020370
+#define DRP_ECC_SB_ERR_SYN0 0x0004204c
+#define DRP_ECC_DB_ERR_SYN0 0x00042070
+
+/* Error register offsets */
+#define TRP_ECC_ERROR_STATUS1   0x00020348
+#define TRP_ECC_ERROR_STATUS0   0x00020344
+#define DRP_ECC_ERROR_STATUS1   0x00042048
+#define DRP_ECC_ERROR_STATUS0   0x00042044
+
+/* TRP, DRP interrupt register offsets */
+#define DRP_INTERRUPT_STATUS0x00041000
+#define TRP_INTERRUPT_0_STATUS  0x00020480
+#define DRP_INTERRUPT_CLEAR 0x00041008
+#define DRP_ECC_ERROR_CNTR_CLEAR0x00040004
+#define TRP_INTERRUPT_0_CLEAR   0x00020484
+#define TRP_ECC_ERROR_CNTR_CLEAR0x00020440
+
+/* Mask and shift macros */
+#define ECC_DB_ERR_COUNT_MASK   GENMASK(4, 0)
+#define ECC_DB_ERR_WAYS_MASKGENMASK(31, 16)
+#define ECC_DB_ERR_WAYS_SHIFT   BIT(4)
+
+#define ECC_SB_ERR_COUNT_MASK   GENMASK(23, 16)
+#define ECC_SB_ERR_COUNT_SHIFT  BIT(4)
+#define ECC_SB_ERR_WAYS_MASKGENMASK(15, 0)
+
+#define SB_ECC_ERRORBIT(0)
+#define DB_EC

[PATCH v3 3/4] drivers: edac: Add EDAC driver support for QCOM SoCs

2018-08-28 Thread Venkata Narendra Kumar Gutta
From: Channagoud Kadabi 

Add error reporting driver for Single Bit Errors (SBEs) and Double Bit
Errors (DBEs). As of now, this driver supports error reporting for
Last Level Cache Controller (LLCC) of Tag RAM and Data RAM. Interrupts
are triggered when the errors happen in the cache, the driver handles
those interrupts and dumps the syndrome registers.

Signed-off-by: Channagoud Kadabi 
Signed-off-by: Venkata Narendra Kumar Gutta 
Co-developed-by: Venkata Narendra Kumar Gutta 
---
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  22 ++
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 421 +
 include/linux/soc/qcom/llcc-qcom.h |  24 +++
 5 files changed, 476 insertions(+)
 create mode 100644 drivers/edac/qcom_edac.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a23427..0bff713 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5227,6 +5227,14 @@ L:   linux-e...@vger.kernel.org
 S: Maintained
 F: drivers/edac/ti_edac.c
 
+EDAC-QUALCOMM
+M: Channagoud Kadabi 
+M: Venkata Narendra Kumar Gutta 
+L: linux-arm-...@vger.kernel.org
+L: linux-e...@vger.kernel.org
+S: Maintained
+F: drivers/edac/qcom_edac.c
+
 EDIROL UA-101/UA-1000 DRIVER
 M: Clemens Ladisch 
 L: alsa-de...@alsa-project.org (moderated for non-subscribers)
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 57304b2..df58957 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -460,4 +460,26 @@ config EDAC_TI
  Support for error detection and correction on the
   TI SoCs.
 
+config EDAC_QCOM
+   tristate "QCOM EDAC Controller"
+   depends on EDAC
+   help
+ Support for error detection and correction on the
+ QCOM SoCs.
+
+ This driver reports Single Bit Errors (SBEs) and Double Bit Errors 
(DBEs).
+ As of now, it supports error reporting for Last Level Cache 
Controller (LLCC)
+ of Tag RAM and Data RAM.
+
+config EDAC_QCOM_LLCC
+   tristate "QCOM EDAC Controller for LLCC Cache"
+   depends on EDAC_QCOM && QCOM_LLCC
+   help
+ Support for error detection and correction on the
+ QCOM LLCC cache. Report errors caught by LLCC ECC
+ mechanism.
+
+ For debugging issues having to do with stability and overall system
+ health, you should probably say 'Y' here.
+
 endif # EDAC
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index 02b43a7..716096d 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -77,3 +77,4 @@ obj-$(CONFIG_EDAC_ALTERA) += altera_edac.o
 obj-$(CONFIG_EDAC_SYNOPSYS)+= synopsys_edac.o
 obj-$(CONFIG_EDAC_XGENE)   += xgene_edac.o
 obj-$(CONFIG_EDAC_TI)  += ti_edac.o
+obj-$(CONFIG_EDAC_QCOM)+= qcom_edac.o
diff --git a/drivers/edac/qcom_edac.c b/drivers/edac/qcom_edac.c
new file mode 100644
index 000..871ed07
--- /dev/null
+++ b/drivers/edac/qcom_edac.c
@@ -0,0 +1,421 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "edac_mc.h"
+#include "edac_device.h"
+
+#define EDAC_LLCC   "qcom_llcc"
+
+#define LLCC_ERP_PANIC_ON_UE1
+
+#define TRP_SYN_REG_CNT 6
+#define DRP_SYN_REG_CNT 8
+
+#define LLCC_COMMON_STATUS0 0x0003000c
+#define LLCC_LB_CNT_MASKGENMASK(31, 28)
+#define LLCC_LB_CNT_SHIFT   28
+
+/* Single & double bit syndrome register offsets */
+#define TRP_ECC_SB_ERR_SYN0 0x0002304c
+#define TRP_ECC_DB_ERR_SYN0 0x00020370
+#define DRP_ECC_SB_ERR_SYN0 0x0004204c
+#define DRP_ECC_DB_ERR_SYN0 0x00042070
+
+/* Error register offsets */
+#define TRP_ECC_ERROR_STATUS1   0x00020348
+#define TRP_ECC_ERROR_STATUS0   0x00020344
+#define DRP_ECC_ERROR_STATUS1   0x00042048
+#define DRP_ECC_ERROR_STATUS0   0x00042044
+
+/* TRP, DRP interrupt register offsets */
+#define DRP_INTERRUPT_STATUS0x00041000
+#define TRP_INTERRUPT_0_STATUS  0x00020480
+#define DRP_INTERRUPT_CLEAR 0x00041008
+#define DRP_ECC_ERROR_CNTR_CLEAR0x00040004
+#define TRP_INTERRUPT_0_CLEAR   0x00020484
+#define TRP_ECC_ERROR_CNTR_CLEAR0x00020440
+
+/* Mask and shift macros */
+#define ECC_DB_ERR_COUNT_MASK   GENMASK(4, 0)
+#define ECC_DB_ERR_WAYS_MASKGENMASK(31, 16)
+#define ECC_DB_ERR_WAYS_SHIFT   BIT(4)
+
+#define ECC_SB_ERR_COUNT_MASK   GENMASK(23, 16)
+#define ECC_SB_ERR_COUNT_SHIFT  BIT(4)
+#define ECC_SB_ERR_WAYS_MASKGENMASK(15, 0)
+
+#define SB_ECC_ERRORBIT(0)
+#define DB_EC

[PATCH v3 4/4] dt-bindings: msm: Update documentation of qcom,llcc

2018-08-28 Thread Venkata Narendra Kumar Gutta
Add reg-names and interrupts for LLCC documentation and the usage
examples. llcc broadcast base is added in addition to llcc base,
which is used for llcc broadcast writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 .../devicetree/bindings/arm/msm/qcom,llcc.txt | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt 
b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
index 5e85749..2e007dc 100644
--- a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
@@ -16,11 +16,26 @@ Properties:
 - reg:
Usage: required
Value Type: 
-   Definition: Start address and the the size of the register region.
+   Definition: The first element specifies the llcc base start address and
+   the size of the register region. The second element 
specifies
+   the llcc broadcast base address and size of the register 
region.
+
+- reg-names:
+Usage: required
+Value Type: 
+Definition: Register region names. Must be "llcc_base", 
"llcc_bcast_base".
+
+- interrupts:
+   Usage: required
+   Definition: The interrupt is associated with the llcc edac device.
+   It's used for llcc cache single and double bit error 
detection
+   and reporting.
 
 Example:
 
cache-controller@110 {
compatible = "qcom,sdm845-llcc";
-   reg = <0x110 0x25>;
+   reg = <0x110 0x20>, <0x130 0x5> ;
+   reg-names = "llcc_base", "llcc_bcast_base";
+   interrupts = ;
};
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v3 2/4] drivers: soc: Add support to register LLCC EDAC driver

2018-08-28 Thread Venkata Narendra Kumar Gutta
Cache error reporting controller detects and reports single and
double bit errors on Last Level Cache Controller (LLCC) cache.
Add required support to register LLCC EDAC driver as platform driver,
from LLCC driver.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/soc/qcom/llcc-slice.c  | 18 --
 include/linux/soc/qcom/llcc-qcom.h |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index a63640d..09c8bb0 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -224,7 +224,7 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
u32 attr0_val;
u32 max_cap_cacheline;
u32 sz;
-   int ret;
+   int ret = 0;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
 
@@ -282,6 +282,7 @@ int qcom_llcc_probe(struct platform_device *pdev,
struct resource *llcc_banks_res, *llcc_bcast_res;
void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
+   struct platform_device *llcc_edac;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
@@ -341,6 +342,19 @@ int qcom_llcc_probe(struct platform_device *pdev,
mutex_init(_data->lock);
platform_set_drvdata(pdev, drv_data);
 
-   return qcom_llcc_cfg_program(pdev);
+   ret = qcom_llcc_cfg_program(pdev);
+   if (ret)
+   return ret;
+
+   drv_data->ecc_irq = platform_get_irq(pdev, 0);
+   if (drv_data->ecc_irq >= 0) {
+   llcc_edac = platform_device_register_data(>dev,
+   "qcom_llcc_edac", -1, drv_data,
+   sizeof(*drv_data));
+   if (IS_ERR(llcc_edac))
+   dev_err(dev, "Failed to register llcc edac driver\n");
+   }
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(qcom_llcc_probe);
diff --git a/include/linux/soc/qcom/llcc-qcom.h 
b/include/linux/soc/qcom/llcc-qcom.h
index c681e79..2e4b34d 100644
--- a/include/linux/soc/qcom/llcc-qcom.h
+++ b/include/linux/soc/qcom/llcc-qcom.h
@@ -78,6 +78,7 @@ struct llcc_slice_config {
  * @num_banks: Number of llcc banks
  * @bitmap: Bit map to track the active slice ids
  * @offsets: Pointer to the bank offsets array
+ * @ecc_irq: interrupt for llcc cache error detection and reporting
  */
 struct llcc_drv_data {
struct regmap *regmap;
@@ -89,6 +90,7 @@ struct llcc_drv_data {
u32 num_banks;
unsigned long *bitmap;
u32 *offsets;
+   int ecc_irq;
 };
 
 #if IS_ENABLED(CONFIG_QCOM_LLCC)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v3 1/4] drivers: soc: Add broadcast base for Last Level Cache Controller (LLCC)

2018-08-28 Thread Venkata Narendra Kumar Gutta
Currently, broadcast base is set to end of the LLCC banks, which may
not be correct always. As the number of banks may vary for each chipset
and the broadcast base could be at a different address as well. This info
depends on the chipset, so get the broadcast base info from the device
tree (DT). Add broadcast base in LLCC driver and use this for broadcast
writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/soc/qcom/llcc-slice.c  | 55 +++---
 include/linux/soc/qcom/llcc-qcom.h |  4 +--
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index fcaad1a..a63640d 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -105,22 +105,24 @@ static int llcc_update_act_ctrl(u32 sid,
u32 slice_status;
int ret;
 
-   act_ctrl_reg = drv_data->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
-   status_reg = drv_data->bcast_off + LLCC_TRP_STATUSn(sid);
+   act_ctrl_reg = LLCC_TRP_ACT_CTRLn(sid);
+   status_reg = LLCC_TRP_STATUSn(sid);
 
/* Set the ACTIVE trigger */
act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
-   ret = regmap_write(drv_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_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_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_regmap, act_ctrl_reg,
+   act_ctrl_reg_val);
if (ret)
return ret;
 
-   ret = regmap_read_poll_timeout(drv_data->regmap, status_reg,
+   ret = regmap_read_poll_timeout(drv_data->bcast_regmap, status_reg,
  slice_status, !(slice_status & status),
  0, LLCC_STATUS_READ_DELAY);
return ret;
@@ -225,16 +227,13 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
int ret;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
-   u32 bcast_off = drv_data->bcast_off;
 
sz = drv_data->cfg_size;
llcc_table = drv_data->cfg;
 
for (i = 0; i < sz; i++) {
-   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);
+   attr1_cfg = LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);
+   attr0_cfg = LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);
 
attr1_val = llcc_table[i].cache_mode;
attr1_val |= llcc_table[i].probe_target_ways <<
@@ -259,10 +258,12 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
attr0_val = llcc_table[i].res_ways & ATTR0_RES_WAYS_MASK;
attr0_val |= llcc_table[i].bonus_ways << ATTR0_BONUS_WAYS_SHIFT;
 
-   ret = regmap_write(drv_data->regmap, attr1_cfg, attr1_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr1_cfg,
+   attr1_val);
if (ret)
return ret;
-   ret = regmap_write(drv_data->regmap, attr0_cfg, attr0_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr0_cfg,
+   attr0_val);
if (ret)
return ret;
if (llcc_table[i].activate_on_init) {
@@ -278,24 +279,36 @@ int qcom_llcc_probe(struct platform_device *pdev,
 {
u32 num_banks;
struct device *dev = >dev;
-   struct resource *res;
-   void __iomem *base;
+   struct resource *llcc_banks_res, *llcc_bcast_res;
+   void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
return -ENOMEM;
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_ioremap_resource(>dev, res);
-   if (IS_ERR(base))
-   return PTR_ERR(base);
+   llcc_banks_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+   "llcc_base");
+   llcc_banks_base = devm_ioremap_resource(>dev, llcc_banks_res);
+   if (IS_ERR(llcc_banks_base))
+   return PTR_ERR(llcc_banks_base);
 
-   drv_data->regmap = devm_regmap_init_mmio(dev, base,
-   _regmap_config);
+   drv_data->regmap = devm_regmap_init_mmio(dev, llcc_banks_base,
+

[PATCH v3 4/4] dt-bindings: msm: Update documentation of qcom,llcc

2018-08-28 Thread Venkata Narendra Kumar Gutta
Add reg-names and interrupts for LLCC documentation and the usage
examples. llcc broadcast base is added in addition to llcc base,
which is used for llcc broadcast writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 .../devicetree/bindings/arm/msm/qcom,llcc.txt | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt 
b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
index 5e85749..2e007dc 100644
--- a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
@@ -16,11 +16,26 @@ Properties:
 - reg:
Usage: required
Value Type: 
-   Definition: Start address and the the size of the register region.
+   Definition: The first element specifies the llcc base start address and
+   the size of the register region. The second element 
specifies
+   the llcc broadcast base address and size of the register 
region.
+
+- reg-names:
+Usage: required
+Value Type: 
+Definition: Register region names. Must be "llcc_base", 
"llcc_bcast_base".
+
+- interrupts:
+   Usage: required
+   Definition: The interrupt is associated with the llcc edac device.
+   It's used for llcc cache single and double bit error 
detection
+   and reporting.
 
 Example:
 
cache-controller@110 {
compatible = "qcom,sdm845-llcc";
-   reg = <0x110 0x25>;
+   reg = <0x110 0x20>, <0x130 0x5> ;
+   reg-names = "llcc_base", "llcc_bcast_base";
+   interrupts = ;
};
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v3 2/4] drivers: soc: Add support to register LLCC EDAC driver

2018-08-28 Thread Venkata Narendra Kumar Gutta
Cache error reporting controller detects and reports single and
double bit errors on Last Level Cache Controller (LLCC) cache.
Add required support to register LLCC EDAC driver as platform driver,
from LLCC driver.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/soc/qcom/llcc-slice.c  | 18 --
 include/linux/soc/qcom/llcc-qcom.h |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index a63640d..09c8bb0 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -224,7 +224,7 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
u32 attr0_val;
u32 max_cap_cacheline;
u32 sz;
-   int ret;
+   int ret = 0;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
 
@@ -282,6 +282,7 @@ int qcom_llcc_probe(struct platform_device *pdev,
struct resource *llcc_banks_res, *llcc_bcast_res;
void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
+   struct platform_device *llcc_edac;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
@@ -341,6 +342,19 @@ int qcom_llcc_probe(struct platform_device *pdev,
mutex_init(_data->lock);
platform_set_drvdata(pdev, drv_data);
 
-   return qcom_llcc_cfg_program(pdev);
+   ret = qcom_llcc_cfg_program(pdev);
+   if (ret)
+   return ret;
+
+   drv_data->ecc_irq = platform_get_irq(pdev, 0);
+   if (drv_data->ecc_irq >= 0) {
+   llcc_edac = platform_device_register_data(>dev,
+   "qcom_llcc_edac", -1, drv_data,
+   sizeof(*drv_data));
+   if (IS_ERR(llcc_edac))
+   dev_err(dev, "Failed to register llcc edac driver\n");
+   }
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(qcom_llcc_probe);
diff --git a/include/linux/soc/qcom/llcc-qcom.h 
b/include/linux/soc/qcom/llcc-qcom.h
index c681e79..2e4b34d 100644
--- a/include/linux/soc/qcom/llcc-qcom.h
+++ b/include/linux/soc/qcom/llcc-qcom.h
@@ -78,6 +78,7 @@ struct llcc_slice_config {
  * @num_banks: Number of llcc banks
  * @bitmap: Bit map to track the active slice ids
  * @offsets: Pointer to the bank offsets array
+ * @ecc_irq: interrupt for llcc cache error detection and reporting
  */
 struct llcc_drv_data {
struct regmap *regmap;
@@ -89,6 +90,7 @@ struct llcc_drv_data {
u32 num_banks;
unsigned long *bitmap;
u32 *offsets;
+   int ecc_irq;
 };
 
 #if IS_ENABLED(CONFIG_QCOM_LLCC)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v3 1/4] drivers: soc: Add broadcast base for Last Level Cache Controller (LLCC)

2018-08-28 Thread Venkata Narendra Kumar Gutta
Currently, broadcast base is set to end of the LLCC banks, which may
not be correct always. As the number of banks may vary for each chipset
and the broadcast base could be at a different address as well. This info
depends on the chipset, so get the broadcast base info from the device
tree (DT). Add broadcast base in LLCC driver and use this for broadcast
writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/soc/qcom/llcc-slice.c  | 55 +++---
 include/linux/soc/qcom/llcc-qcom.h |  4 +--
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index fcaad1a..a63640d 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -105,22 +105,24 @@ static int llcc_update_act_ctrl(u32 sid,
u32 slice_status;
int ret;
 
-   act_ctrl_reg = drv_data->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
-   status_reg = drv_data->bcast_off + LLCC_TRP_STATUSn(sid);
+   act_ctrl_reg = LLCC_TRP_ACT_CTRLn(sid);
+   status_reg = LLCC_TRP_STATUSn(sid);
 
/* Set the ACTIVE trigger */
act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
-   ret = regmap_write(drv_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_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_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_regmap, act_ctrl_reg,
+   act_ctrl_reg_val);
if (ret)
return ret;
 
-   ret = regmap_read_poll_timeout(drv_data->regmap, status_reg,
+   ret = regmap_read_poll_timeout(drv_data->bcast_regmap, status_reg,
  slice_status, !(slice_status & status),
  0, LLCC_STATUS_READ_DELAY);
return ret;
@@ -225,16 +227,13 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
int ret;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
-   u32 bcast_off = drv_data->bcast_off;
 
sz = drv_data->cfg_size;
llcc_table = drv_data->cfg;
 
for (i = 0; i < sz; i++) {
-   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);
+   attr1_cfg = LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);
+   attr0_cfg = LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);
 
attr1_val = llcc_table[i].cache_mode;
attr1_val |= llcc_table[i].probe_target_ways <<
@@ -259,10 +258,12 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
attr0_val = llcc_table[i].res_ways & ATTR0_RES_WAYS_MASK;
attr0_val |= llcc_table[i].bonus_ways << ATTR0_BONUS_WAYS_SHIFT;
 
-   ret = regmap_write(drv_data->regmap, attr1_cfg, attr1_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr1_cfg,
+   attr1_val);
if (ret)
return ret;
-   ret = regmap_write(drv_data->regmap, attr0_cfg, attr0_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr0_cfg,
+   attr0_val);
if (ret)
return ret;
if (llcc_table[i].activate_on_init) {
@@ -278,24 +279,36 @@ int qcom_llcc_probe(struct platform_device *pdev,
 {
u32 num_banks;
struct device *dev = >dev;
-   struct resource *res;
-   void __iomem *base;
+   struct resource *llcc_banks_res, *llcc_bcast_res;
+   void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
return -ENOMEM;
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_ioremap_resource(>dev, res);
-   if (IS_ERR(base))
-   return PTR_ERR(base);
+   llcc_banks_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+   "llcc_base");
+   llcc_banks_base = devm_ioremap_resource(>dev, llcc_banks_res);
+   if (IS_ERR(llcc_banks_base))
+   return PTR_ERR(llcc_banks_base);
 
-   drv_data->regmap = devm_regmap_init_mmio(dev, base,
-   _regmap_config);
+   drv_data->regmap = devm_regmap_init_mmio(dev, llcc_banks_base,
+

[PATCH v3 0/4] Add EDAC driver for QCOM SoCs

2018-08-28 Thread Venkata Narendra Kumar Gutta
This series implements EDAC driver for QCOM SoCs. As of now, this driver
supports EDAC for Last Level Cache Controller (LLCC). LLCC EDAC driver is
to detect and report single and double bit errors on Last Level Cache
Controller (LLCC) cache. Interrupts are triggered when the errors happen
in the cache, the driver handles those interrupts and dumps the syndrome
registers.

The driver functionality is implemented in:
qcom_edac.c : This platform driver registers to edac framework and
handles the single and double bit errors in cache by registering
interrupt handlers.

llcc-slice.c: It invokes the llcc edac driver and passes platform
data to it.

This patchset depends on the LLCC driver, which is part of 4.19 release.
Link: https://patchwork.kernel.org/patch/10422531/
Link: 
http://lists-archives.com/linux-kernel/29157082-dt-bindings-documentation-for-qcom-llcc.html

Patch wise description given below:

Patch 1 adds the broadcast base regmap for broadcast writes in llcc.

Patch 2 adds the required changes to register edac driver from llcc driver.

Patch 3 adds the EDAC driver support for QCOM SoCS.

Patch 4 updates the dt bindings of llcc.

Changes since v2:
  * Modified the edac driver and Kconfig
-  removed unnecessary header files, typecasting and redundant comments.
-  Changed the initialization of reg_data datastructure to static, 
   Also updated the llcc_edac_reg_data member names and datatypes.
-  Removed "EDAC_QCOM_LLCC_PANIC_ON_UE" Kconfig variable

Changes since v1:
  * Modified the edac driver
- Removed duplicate functions that are used to dump the syndrome registers,
  replaced that with a common function and a reg_data datastructure.
- Removed structure containing function pointers.
- Addressed comments on error handling to clear the interrupt status.
  * updated Kconfig

Changes since v0:
  * Added EDAC_QCOM config and updated the driver
  * Addressed comments related to indentation and other minor ones

Channagoud Kadabi (1):
  drivers: edac: Add EDAC driver support for QCOM SoCs

Venkata Narendra Kumar Gutta (3):
  drivers: soc: Add broadcast base for Last Level Cache Controller
(LLCC)
  drivers: soc: Add support to register LLCC EDAC driver
  dt-bindings: msm: Update documentation of qcom,llcc

 .../devicetree/bindings/arm/msm/qcom,llcc.txt  |  19 +-
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  22 ++
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 421 +
 drivers/soc/qcom/llcc-slice.c  |  73 ++--
 include/linux/soc/qcom/llcc-qcom.h |  30 +-
 7 files changed, 546 insertions(+), 28 deletions(-)
 create mode 100644 drivers/edac/qcom_edac.c

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v3 0/4] Add EDAC driver for QCOM SoCs

2018-08-28 Thread Venkata Narendra Kumar Gutta
This series implements EDAC driver for QCOM SoCs. As of now, this driver
supports EDAC for Last Level Cache Controller (LLCC). LLCC EDAC driver is
to detect and report single and double bit errors on Last Level Cache
Controller (LLCC) cache. Interrupts are triggered when the errors happen
in the cache, the driver handles those interrupts and dumps the syndrome
registers.

The driver functionality is implemented in:
qcom_edac.c : This platform driver registers to edac framework and
handles the single and double bit errors in cache by registering
interrupt handlers.

llcc-slice.c: It invokes the llcc edac driver and passes platform
data to it.

This patchset depends on the LLCC driver, which is part of 4.19 release.
Link: https://patchwork.kernel.org/patch/10422531/
Link: 
http://lists-archives.com/linux-kernel/29157082-dt-bindings-documentation-for-qcom-llcc.html

Patch wise description given below:

Patch 1 adds the broadcast base regmap for broadcast writes in llcc.

Patch 2 adds the required changes to register edac driver from llcc driver.

Patch 3 adds the EDAC driver support for QCOM SoCS.

Patch 4 updates the dt bindings of llcc.

Changes since v2:
  * Modified the edac driver and Kconfig
-  removed unnecessary header files, typecasting and redundant comments.
-  Changed the initialization of reg_data datastructure to static, 
   Also updated the llcc_edac_reg_data member names and datatypes.
-  Removed "EDAC_QCOM_LLCC_PANIC_ON_UE" Kconfig variable

Changes since v1:
  * Modified the edac driver
- Removed duplicate functions that are used to dump the syndrome registers,
  replaced that with a common function and a reg_data datastructure.
- Removed structure containing function pointers.
- Addressed comments on error handling to clear the interrupt status.
  * updated Kconfig

Changes since v0:
  * Added EDAC_QCOM config and updated the driver
  * Addressed comments related to indentation and other minor ones

Channagoud Kadabi (1):
  drivers: edac: Add EDAC driver support for QCOM SoCs

Venkata Narendra Kumar Gutta (3):
  drivers: soc: Add broadcast base for Last Level Cache Controller
(LLCC)
  drivers: soc: Add support to register LLCC EDAC driver
  dt-bindings: msm: Update documentation of qcom,llcc

 .../devicetree/bindings/arm/msm/qcom,llcc.txt  |  19 +-
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  22 ++
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 421 +
 drivers/soc/qcom/llcc-slice.c  |  73 ++--
 include/linux/soc/qcom/llcc-qcom.h |  30 +-
 7 files changed, 546 insertions(+), 28 deletions(-)
 create mode 100644 drivers/edac/qcom_edac.c

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v2 4/4] dt-bindigs: msm: Update documentation of qcom,llcc

2018-08-17 Thread Venkata Narendra Kumar Gutta
Add reg-names and interrupts for LLCC documentation and the usage
examples. llcc broadcast base is added in addition to llcc base,
which is used for llcc broadcast writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt 
b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
index 5e85749..b4b1c86 100644
--- a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
@@ -18,9 +18,22 @@ Properties:
Value Type: 
Definition: Start address and the the size of the register region.
 
+- reg-names:
+Usage: required
+Value Type: 
+Definition: Register region names. Must be "llcc_base", 
"llcc_bcast_base".
+
+- interrupts:
+   Usage: required
+   Definition: The interrupt is associated with the llcc edac device.
+   It's used for llcc cache single and double bit error 
detection
+   and reporting.
+
 Example:
 
cache-controller@110 {
compatible = "qcom,sdm845-llcc";
-   reg = <0x110 0x25>;
+   reg = <0x110 0x20>, <0x130 0x5> ;
+   reg-names = "llcc_base", "llcc_bcast_base";
+   interrupts = ;
};
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v2 2/4] drivers: soc: Add support to register LLCC EDAC driver

2018-08-17 Thread Venkata Narendra Kumar Gutta
Cache error reporting controller is to detect and report single
and double bit errors on Last Level Cache Controller (LLCC) cache.
Add required support to register LLCC EDAC driver as platform driver,
from LLCC driver.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/soc/qcom/llcc-slice.c  | 18 --
 include/linux/soc/qcom/llcc-qcom.h |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index a63640d..09c8bb0 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -224,7 +224,7 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
u32 attr0_val;
u32 max_cap_cacheline;
u32 sz;
-   int ret;
+   int ret = 0;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
 
@@ -282,6 +282,7 @@ int qcom_llcc_probe(struct platform_device *pdev,
struct resource *llcc_banks_res, *llcc_bcast_res;
void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
+   struct platform_device *llcc_edac;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
@@ -341,6 +342,19 @@ int qcom_llcc_probe(struct platform_device *pdev,
mutex_init(_data->lock);
platform_set_drvdata(pdev, drv_data);
 
-   return qcom_llcc_cfg_program(pdev);
+   ret = qcom_llcc_cfg_program(pdev);
+   if (ret)
+   return ret;
+
+   drv_data->ecc_irq = platform_get_irq(pdev, 0);
+   if (drv_data->ecc_irq >= 0) {
+   llcc_edac = platform_device_register_data(>dev,
+   "qcom_llcc_edac", -1, drv_data,
+   sizeof(*drv_data));
+   if (IS_ERR(llcc_edac))
+   dev_err(dev, "Failed to register llcc edac driver\n");
+   }
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(qcom_llcc_probe);
diff --git a/include/linux/soc/qcom/llcc-qcom.h 
b/include/linux/soc/qcom/llcc-qcom.h
index c681e79..2e4b34d 100644
--- a/include/linux/soc/qcom/llcc-qcom.h
+++ b/include/linux/soc/qcom/llcc-qcom.h
@@ -78,6 +78,7 @@ struct llcc_slice_config {
  * @num_banks: Number of llcc banks
  * @bitmap: Bit map to track the active slice ids
  * @offsets: Pointer to the bank offsets array
+ * @ecc_irq: interrupt for llcc cache error detection and reporting
  */
 struct llcc_drv_data {
struct regmap *regmap;
@@ -89,6 +90,7 @@ struct llcc_drv_data {
u32 num_banks;
unsigned long *bitmap;
u32 *offsets;
+   int ecc_irq;
 };
 
 #if IS_ENABLED(CONFIG_QCOM_LLCC)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v2 4/4] dt-bindigs: msm: Update documentation of qcom,llcc

2018-08-17 Thread Venkata Narendra Kumar Gutta
Add reg-names and interrupts for LLCC documentation and the usage
examples. llcc broadcast base is added in addition to llcc base,
which is used for llcc broadcast writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt 
b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
index 5e85749..b4b1c86 100644
--- a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
@@ -18,9 +18,22 @@ Properties:
Value Type: 
Definition: Start address and the the size of the register region.
 
+- reg-names:
+Usage: required
+Value Type: 
+Definition: Register region names. Must be "llcc_base", 
"llcc_bcast_base".
+
+- interrupts:
+   Usage: required
+   Definition: The interrupt is associated with the llcc edac device.
+   It's used for llcc cache single and double bit error 
detection
+   and reporting.
+
 Example:
 
cache-controller@110 {
compatible = "qcom,sdm845-llcc";
-   reg = <0x110 0x25>;
+   reg = <0x110 0x20>, <0x130 0x5> ;
+   reg-names = "llcc_base", "llcc_bcast_base";
+   interrupts = ;
};
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v2 2/4] drivers: soc: Add support to register LLCC EDAC driver

2018-08-17 Thread Venkata Narendra Kumar Gutta
Cache error reporting controller is to detect and report single
and double bit errors on Last Level Cache Controller (LLCC) cache.
Add required support to register LLCC EDAC driver as platform driver,
from LLCC driver.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/soc/qcom/llcc-slice.c  | 18 --
 include/linux/soc/qcom/llcc-qcom.h |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index a63640d..09c8bb0 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -224,7 +224,7 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
u32 attr0_val;
u32 max_cap_cacheline;
u32 sz;
-   int ret;
+   int ret = 0;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
 
@@ -282,6 +282,7 @@ int qcom_llcc_probe(struct platform_device *pdev,
struct resource *llcc_banks_res, *llcc_bcast_res;
void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
+   struct platform_device *llcc_edac;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
@@ -341,6 +342,19 @@ int qcom_llcc_probe(struct platform_device *pdev,
mutex_init(_data->lock);
platform_set_drvdata(pdev, drv_data);
 
-   return qcom_llcc_cfg_program(pdev);
+   ret = qcom_llcc_cfg_program(pdev);
+   if (ret)
+   return ret;
+
+   drv_data->ecc_irq = platform_get_irq(pdev, 0);
+   if (drv_data->ecc_irq >= 0) {
+   llcc_edac = platform_device_register_data(>dev,
+   "qcom_llcc_edac", -1, drv_data,
+   sizeof(*drv_data));
+   if (IS_ERR(llcc_edac))
+   dev_err(dev, "Failed to register llcc edac driver\n");
+   }
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(qcom_llcc_probe);
diff --git a/include/linux/soc/qcom/llcc-qcom.h 
b/include/linux/soc/qcom/llcc-qcom.h
index c681e79..2e4b34d 100644
--- a/include/linux/soc/qcom/llcc-qcom.h
+++ b/include/linux/soc/qcom/llcc-qcom.h
@@ -78,6 +78,7 @@ struct llcc_slice_config {
  * @num_banks: Number of llcc banks
  * @bitmap: Bit map to track the active slice ids
  * @offsets: Pointer to the bank offsets array
+ * @ecc_irq: interrupt for llcc cache error detection and reporting
  */
 struct llcc_drv_data {
struct regmap *regmap;
@@ -89,6 +90,7 @@ struct llcc_drv_data {
u32 num_banks;
unsigned long *bitmap;
u32 *offsets;
+   int ecc_irq;
 };
 
 #if IS_ENABLED(CONFIG_QCOM_LLCC)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v2 3/4] drivers: edac: Add EDAC driver support for QCOM SoCs

2018-08-17 Thread Venkata Narendra Kumar Gutta
From: Channagoud Kadabi 

Add error reporting driver for Single Bit Errors (SBEs) and Double Bit
Errors (DBEs). As of now, this driver supports erp for Last Level Cache
Controller (LLCC). This driver takes care of dumping registers and adding
config options to enable and disable panic when the errors happen in cache.

Signed-off-by: Channagoud Kadabi 
Signed-off-by: Venkata Narendra Kumar Gutta 
Co-developed-by: Venkata Narendra Kumar Gutta 
---
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  28 +++
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 446 +
 include/linux/soc/qcom/llcc-qcom.h |  25 +++
 5 files changed, 508 insertions(+)
 create mode 100644 drivers/edac/qcom_edac.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a23427..0bff713 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5227,6 +5227,14 @@ L:   linux-e...@vger.kernel.org
 S: Maintained
 F: drivers/edac/ti_edac.c
 
+EDAC-QUALCOMM
+M: Channagoud Kadabi 
+M: Venkata Narendra Kumar Gutta 
+L: linux-arm-...@vger.kernel.org
+L: linux-e...@vger.kernel.org
+S: Maintained
+F: drivers/edac/qcom_edac.c
+
 EDIROL UA-101/UA-1000 DRIVER
 M: Clemens Ladisch 
 L: alsa-de...@alsa-project.org (moderated for non-subscribers)
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 57304b2..da8f150 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -460,4 +460,32 @@ config EDAC_TI
  Support for error detection and correction on the
   TI SoCs.
 
+config EDAC_QCOM
+   tristate "QCOM EDAC Controller"
+   depends on EDAC
+   help
+ Support for error detection and correction on the
+ QCOM SoCs.
+
+config EDAC_QCOM_LLCC
+   tristate "QCOM EDAC Controller for LLCC Cache"
+   depends on EDAC_QCOM && QCOM_LLCC
+   help
+ Support for error detection and correction on the
+ QCOM LLCC cache. Report errors caught by LLCC ECC
+ mechanism.
+
+ For debugging issues having to do with stability and overall system
+  health, you should probably say 'Y' here.
+
+config EDAC_QCOM_LLCC_PANIC_ON_UE
+   bool "Panic on uncorrectable errors - qcom llcc"
+   depends on EDAC_QCOM_LLCC
+   help
+ Forcibly cause a kernel panic if an uncorrectable error (UE) is
+ detected. This can reduce debugging times on hardware which may be
+ operating at voltages or frequencies outside normal specification.
+
+ For production builds, you should probably say 'N' here.
+
 endif # EDAC
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index 02b43a7..716096d 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -77,3 +77,4 @@ obj-$(CONFIG_EDAC_ALTERA) += altera_edac.o
 obj-$(CONFIG_EDAC_SYNOPSYS)+= synopsys_edac.o
 obj-$(CONFIG_EDAC_XGENE)   += xgene_edac.o
 obj-$(CONFIG_EDAC_TI)  += ti_edac.o
+obj-$(CONFIG_EDAC_QCOM)+= qcom_edac.o
diff --git a/drivers/edac/qcom_edac.c b/drivers/edac/qcom_edac.c
new file mode 100644
index 000..9a8c670
--- /dev/null
+++ b/drivers/edac/qcom_edac.c
@@ -0,0 +1,446 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "edac_mc.h"
+#include "edac_device.h"
+
+#ifdef CONFIG_EDAC_QCOM_LLCC_PANIC_ON_UE
+#define LLCC_ERP_PANIC_ON_UE1
+#else
+#define LLCC_ERP_PANIC_ON_UE0
+#endif
+
+#define EDAC_LLCC   "qcom_llcc"
+
+#define TRP_SYN_REG_CNT 6
+
+#define DRP_SYN_REG_CNT 8
+
+#define LLCC_COMMON_STATUS0 0x0003000C
+#define LLCC_LB_CNT_MASKGENMASK(31, 28)
+#define LLCC_LB_CNT_SHIFT   28
+
+/* single & Double Bit syndrome register offsets */
+#define TRP_ECC_SB_ERR_SYN0 0x0002304C
+#define TRP_ECC_DB_ERR_SYN0 0x00020370
+#define DRP_ECC_SB_ERR_SYN0 0x0004204C
+#define DRP_ECC_DB_ERR_SYN0 0x00042070
+
+/* Error register offsets */
+#define TRP_ECC_ERROR_STATUS1   0x00020348
+#define TRP_ECC_ERROR_STATUS0   0x00020344
+#define DRP_ECC_ERROR_STATUS1   0x00042048
+#define DRP_ECC_ERROR_STATUS0   0x00042044
+
+/* TRP, DRP interrupt register offsets */
+#define DRP_INTERRUPT_STATUS0x00041000
+#define TRP_INTERRUPT_0_STATUS  0x00020480
+#define DRP_INTERRUPT_CLEAR 0x00041008
+#define DRP_ECC_ERROR_CNTR_CLEAR0x00040004
+#define TRP_INTERRUPT_0_CLEAR   0x00020484
+#define TRP_ECC_ERROR_CNTR_CLEAR0x00020440
+
+/* Mask and shift macros */
+#define ECC_DB_ERR_COUNT_MASK   GENMASK(4, 0)
+#define ECC_DB

[PATCH v2 0/4] Add EDAC driver for QCOM SoCs

2018-08-17 Thread Venkata Narendra Kumar Gutta
This series implements EDAC driver for QCOM SoCs. As of now, this driver
supports EDAC for Last Level Cache Controller (LLCC). LLCC EDAC driver is
to detect and report single and double bit errors on Last Level Cache
Controller (LLCC) cache. This driver also takes care of dumping registers
and also adding config options to enable and disable panic when these
errors happen in LLCC.

The driver functionality is implemented in:
qcom_edac.c : This platform driver registers to edac framework and
handles the single and double bit errors in cache by registering
interrupt handlers.

llcc-slice.c: It invokes the llcc edac driver and passes platform
data to it.

This patchset depends on the LLCC driver, which is part of 4.19 release.
Link: https://patchwork.kernel.org/patch/10422531/
Link: 
http://lists-archives.com/linux-kernel/29157082-dt-bindings-documentation-for-qcom-llcc.html

Patch wise description given below:

Patch 1 adds the broadcast base regmap for broadcast writes in llcc.

Patch 2 adds the required changes to register edac driver from llcc driver.

Patch 3 adds the EDAC driver support for QCOM SoCS.

Patch 4 updates the dt bindings of llcc.

Changes since v1:
  * Modified the edac driver
- Removed duplicate functions that are used to dump the syndrome registers,
  replaced that with a common function and a reg_data datastructure.
- Removed structure containing function pointers.
- Addressed comments on error handling to clear the interrupt status.
  * updated Kconfig

Changes since v0:
  * Added EDAC_QCOM config and updated the driver
  * Addressed comments related to indentation and other minor ones

Channagoud Kadabi (1):
  drivers: edac: Add EDAC driver support for QCOM SoCs

Venkata Narendra Kumar Gutta (3):
  drivers: soc: Add broadcast base for Last Level Cache Controller
(LLCC)
  drivers: soc: Add support to register LLCC EDAC driver
  dt-bindigs: msm: Update documentation of qcom,llcc

 .../devicetree/bindings/arm/msm/qcom,llcc.txt  |  15 +-
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  28 ++
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 446 +
 drivers/soc/qcom/llcc-slice.c  |  73 ++--
 include/linux/soc/qcom/llcc-qcom.h |  31 +-
 7 files changed, 575 insertions(+), 27 deletions(-)
 create mode 100644 drivers/edac/qcom_edac.c

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v2 1/4] drivers: soc: Add broadcast base for Last Level Cache Controller (LLCC)

2018-08-17 Thread Venkata Narendra Kumar Gutta
Currently, boradcast base is set to end of the LLCC banks, which may
not be correct always. As the number of banks may vary for each chipset
and the broadcast base could be at a different address as well. This info
depends on the chipset, so get the broadcast base info from the device
tree (DT). Add broadcast base in LLCC driver and use this for broadcast
writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/soc/qcom/llcc-slice.c  | 55 +++---
 include/linux/soc/qcom/llcc-qcom.h |  4 +--
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index fcaad1a..a63640d 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -105,22 +105,24 @@ static int llcc_update_act_ctrl(u32 sid,
u32 slice_status;
int ret;
 
-   act_ctrl_reg = drv_data->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
-   status_reg = drv_data->bcast_off + LLCC_TRP_STATUSn(sid);
+   act_ctrl_reg = LLCC_TRP_ACT_CTRLn(sid);
+   status_reg = LLCC_TRP_STATUSn(sid);
 
/* Set the ACTIVE trigger */
act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
-   ret = regmap_write(drv_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_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_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_regmap, act_ctrl_reg,
+   act_ctrl_reg_val);
if (ret)
return ret;
 
-   ret = regmap_read_poll_timeout(drv_data->regmap, status_reg,
+   ret = regmap_read_poll_timeout(drv_data->bcast_regmap, status_reg,
  slice_status, !(slice_status & status),
  0, LLCC_STATUS_READ_DELAY);
return ret;
@@ -225,16 +227,13 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
int ret;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
-   u32 bcast_off = drv_data->bcast_off;
 
sz = drv_data->cfg_size;
llcc_table = drv_data->cfg;
 
for (i = 0; i < sz; i++) {
-   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);
+   attr1_cfg = LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);
+   attr0_cfg = LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);
 
attr1_val = llcc_table[i].cache_mode;
attr1_val |= llcc_table[i].probe_target_ways <<
@@ -259,10 +258,12 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
attr0_val = llcc_table[i].res_ways & ATTR0_RES_WAYS_MASK;
attr0_val |= llcc_table[i].bonus_ways << ATTR0_BONUS_WAYS_SHIFT;
 
-   ret = regmap_write(drv_data->regmap, attr1_cfg, attr1_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr1_cfg,
+   attr1_val);
if (ret)
return ret;
-   ret = regmap_write(drv_data->regmap, attr0_cfg, attr0_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr0_cfg,
+   attr0_val);
if (ret)
return ret;
if (llcc_table[i].activate_on_init) {
@@ -278,24 +279,36 @@ int qcom_llcc_probe(struct platform_device *pdev,
 {
u32 num_banks;
struct device *dev = >dev;
-   struct resource *res;
-   void __iomem *base;
+   struct resource *llcc_banks_res, *llcc_bcast_res;
+   void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
return -ENOMEM;
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_ioremap_resource(>dev, res);
-   if (IS_ERR(base))
-   return PTR_ERR(base);
+   llcc_banks_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+   "llcc_base");
+   llcc_banks_base = devm_ioremap_resource(>dev, llcc_banks_res);
+   if (IS_ERR(llcc_banks_base))
+   return PTR_ERR(llcc_banks_base);
 
-   drv_data->regmap = devm_regmap_init_mmio(dev, base,
-   _regmap_config);
+   drv_data->regmap = devm_regmap_init_mmio(dev, llcc_banks_base,
+

[PATCH v2 0/4] Add EDAC driver for QCOM SoCs

2018-08-17 Thread Venkata Narendra Kumar Gutta
This series implements EDAC driver for QCOM SoCs. As of now, this driver
supports EDAC for Last Level Cache Controller (LLCC). LLCC EDAC driver is
to detect and report single and double bit errors on Last Level Cache
Controller (LLCC) cache. This driver also takes care of dumping registers
and also adding config options to enable and disable panic when these
errors happen in LLCC.

The driver functionality is implemented in:
qcom_edac.c : This platform driver registers to edac framework and
handles the single and double bit errors in cache by registering
interrupt handlers.

llcc-slice.c: It invokes the llcc edac driver and passes platform
data to it.

This patchset depends on the LLCC driver, which is part of 4.19 release.
Link: https://patchwork.kernel.org/patch/10422531/
Link: 
http://lists-archives.com/linux-kernel/29157082-dt-bindings-documentation-for-qcom-llcc.html

Patch wise description given below:

Patch 1 adds the broadcast base regmap for broadcast writes in llcc.

Patch 2 adds the required changes to register edac driver from llcc driver.

Patch 3 adds the EDAC driver support for QCOM SoCS.

Patch 4 updates the dt bindings of llcc.

Changes since v1:
  * Modified the edac driver
- Removed duplicate functions that are used to dump the syndrome registers,
  replaced that with a common function and a reg_data datastructure.
- Removed structure containing function pointers.
- Addressed comments on error handling to clear the interrupt status.
  * updated Kconfig

Changes since v0:
  * Added EDAC_QCOM config and updated the driver
  * Addressed comments related to indentation and other minor ones

Channagoud Kadabi (1):
  drivers: edac: Add EDAC driver support for QCOM SoCs

Venkata Narendra Kumar Gutta (3):
  drivers: soc: Add broadcast base for Last Level Cache Controller
(LLCC)
  drivers: soc: Add support to register LLCC EDAC driver
  dt-bindigs: msm: Update documentation of qcom,llcc

 .../devicetree/bindings/arm/msm/qcom,llcc.txt  |  15 +-
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  28 ++
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 446 +
 drivers/soc/qcom/llcc-slice.c  |  73 ++--
 include/linux/soc/qcom/llcc-qcom.h |  31 +-
 7 files changed, 575 insertions(+), 27 deletions(-)
 create mode 100644 drivers/edac/qcom_edac.c

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v2 1/4] drivers: soc: Add broadcast base for Last Level Cache Controller (LLCC)

2018-08-17 Thread Venkata Narendra Kumar Gutta
Currently, boradcast base is set to end of the LLCC banks, which may
not be correct always. As the number of banks may vary for each chipset
and the broadcast base could be at a different address as well. This info
depends on the chipset, so get the broadcast base info from the device
tree (DT). Add broadcast base in LLCC driver and use this for broadcast
writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/soc/qcom/llcc-slice.c  | 55 +++---
 include/linux/soc/qcom/llcc-qcom.h |  4 +--
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index fcaad1a..a63640d 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -105,22 +105,24 @@ static int llcc_update_act_ctrl(u32 sid,
u32 slice_status;
int ret;
 
-   act_ctrl_reg = drv_data->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
-   status_reg = drv_data->bcast_off + LLCC_TRP_STATUSn(sid);
+   act_ctrl_reg = LLCC_TRP_ACT_CTRLn(sid);
+   status_reg = LLCC_TRP_STATUSn(sid);
 
/* Set the ACTIVE trigger */
act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
-   ret = regmap_write(drv_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_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_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_regmap, act_ctrl_reg,
+   act_ctrl_reg_val);
if (ret)
return ret;
 
-   ret = regmap_read_poll_timeout(drv_data->regmap, status_reg,
+   ret = regmap_read_poll_timeout(drv_data->bcast_regmap, status_reg,
  slice_status, !(slice_status & status),
  0, LLCC_STATUS_READ_DELAY);
return ret;
@@ -225,16 +227,13 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
int ret;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
-   u32 bcast_off = drv_data->bcast_off;
 
sz = drv_data->cfg_size;
llcc_table = drv_data->cfg;
 
for (i = 0; i < sz; i++) {
-   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);
+   attr1_cfg = LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);
+   attr0_cfg = LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);
 
attr1_val = llcc_table[i].cache_mode;
attr1_val |= llcc_table[i].probe_target_ways <<
@@ -259,10 +258,12 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
attr0_val = llcc_table[i].res_ways & ATTR0_RES_WAYS_MASK;
attr0_val |= llcc_table[i].bonus_ways << ATTR0_BONUS_WAYS_SHIFT;
 
-   ret = regmap_write(drv_data->regmap, attr1_cfg, attr1_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr1_cfg,
+   attr1_val);
if (ret)
return ret;
-   ret = regmap_write(drv_data->regmap, attr0_cfg, attr0_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr0_cfg,
+   attr0_val);
if (ret)
return ret;
if (llcc_table[i].activate_on_init) {
@@ -278,24 +279,36 @@ int qcom_llcc_probe(struct platform_device *pdev,
 {
u32 num_banks;
struct device *dev = >dev;
-   struct resource *res;
-   void __iomem *base;
+   struct resource *llcc_banks_res, *llcc_bcast_res;
+   void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
return -ENOMEM;
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_ioremap_resource(>dev, res);
-   if (IS_ERR(base))
-   return PTR_ERR(base);
+   llcc_banks_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+   "llcc_base");
+   llcc_banks_base = devm_ioremap_resource(>dev, llcc_banks_res);
+   if (IS_ERR(llcc_banks_base))
+   return PTR_ERR(llcc_banks_base);
 
-   drv_data->regmap = devm_regmap_init_mmio(dev, base,
-   _regmap_config);
+   drv_data->regmap = devm_regmap_init_mmio(dev, llcc_banks_base,
+

[PATCH v2 3/4] drivers: edac: Add EDAC driver support for QCOM SoCs

2018-08-17 Thread Venkata Narendra Kumar Gutta
From: Channagoud Kadabi 

Add error reporting driver for Single Bit Errors (SBEs) and Double Bit
Errors (DBEs). As of now, this driver supports erp for Last Level Cache
Controller (LLCC). This driver takes care of dumping registers and adding
config options to enable and disable panic when the errors happen in cache.

Signed-off-by: Channagoud Kadabi 
Signed-off-by: Venkata Narendra Kumar Gutta 
Co-developed-by: Venkata Narendra Kumar Gutta 
---
 MAINTAINERS|   8 +
 drivers/edac/Kconfig   |  28 +++
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 446 +
 include/linux/soc/qcom/llcc-qcom.h |  25 +++
 5 files changed, 508 insertions(+)
 create mode 100644 drivers/edac/qcom_edac.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a23427..0bff713 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5227,6 +5227,14 @@ L:   linux-e...@vger.kernel.org
 S: Maintained
 F: drivers/edac/ti_edac.c
 
+EDAC-QUALCOMM
+M: Channagoud Kadabi 
+M: Venkata Narendra Kumar Gutta 
+L: linux-arm-...@vger.kernel.org
+L: linux-e...@vger.kernel.org
+S: Maintained
+F: drivers/edac/qcom_edac.c
+
 EDIROL UA-101/UA-1000 DRIVER
 M: Clemens Ladisch 
 L: alsa-de...@alsa-project.org (moderated for non-subscribers)
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 57304b2..da8f150 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -460,4 +460,32 @@ config EDAC_TI
  Support for error detection and correction on the
   TI SoCs.
 
+config EDAC_QCOM
+   tristate "QCOM EDAC Controller"
+   depends on EDAC
+   help
+ Support for error detection and correction on the
+ QCOM SoCs.
+
+config EDAC_QCOM_LLCC
+   tristate "QCOM EDAC Controller for LLCC Cache"
+   depends on EDAC_QCOM && QCOM_LLCC
+   help
+ Support for error detection and correction on the
+ QCOM LLCC cache. Report errors caught by LLCC ECC
+ mechanism.
+
+ For debugging issues having to do with stability and overall system
+  health, you should probably say 'Y' here.
+
+config EDAC_QCOM_LLCC_PANIC_ON_UE
+   bool "Panic on uncorrectable errors - qcom llcc"
+   depends on EDAC_QCOM_LLCC
+   help
+ Forcibly cause a kernel panic if an uncorrectable error (UE) is
+ detected. This can reduce debugging times on hardware which may be
+ operating at voltages or frequencies outside normal specification.
+
+ For production builds, you should probably say 'N' here.
+
 endif # EDAC
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index 02b43a7..716096d 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -77,3 +77,4 @@ obj-$(CONFIG_EDAC_ALTERA) += altera_edac.o
 obj-$(CONFIG_EDAC_SYNOPSYS)+= synopsys_edac.o
 obj-$(CONFIG_EDAC_XGENE)   += xgene_edac.o
 obj-$(CONFIG_EDAC_TI)  += ti_edac.o
+obj-$(CONFIG_EDAC_QCOM)+= qcom_edac.o
diff --git a/drivers/edac/qcom_edac.c b/drivers/edac/qcom_edac.c
new file mode 100644
index 000..9a8c670
--- /dev/null
+++ b/drivers/edac/qcom_edac.c
@@ -0,0 +1,446 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "edac_mc.h"
+#include "edac_device.h"
+
+#ifdef CONFIG_EDAC_QCOM_LLCC_PANIC_ON_UE
+#define LLCC_ERP_PANIC_ON_UE1
+#else
+#define LLCC_ERP_PANIC_ON_UE0
+#endif
+
+#define EDAC_LLCC   "qcom_llcc"
+
+#define TRP_SYN_REG_CNT 6
+
+#define DRP_SYN_REG_CNT 8
+
+#define LLCC_COMMON_STATUS0 0x0003000C
+#define LLCC_LB_CNT_MASKGENMASK(31, 28)
+#define LLCC_LB_CNT_SHIFT   28
+
+/* single & Double Bit syndrome register offsets */
+#define TRP_ECC_SB_ERR_SYN0 0x0002304C
+#define TRP_ECC_DB_ERR_SYN0 0x00020370
+#define DRP_ECC_SB_ERR_SYN0 0x0004204C
+#define DRP_ECC_DB_ERR_SYN0 0x00042070
+
+/* Error register offsets */
+#define TRP_ECC_ERROR_STATUS1   0x00020348
+#define TRP_ECC_ERROR_STATUS0   0x00020344
+#define DRP_ECC_ERROR_STATUS1   0x00042048
+#define DRP_ECC_ERROR_STATUS0   0x00042044
+
+/* TRP, DRP interrupt register offsets */
+#define DRP_INTERRUPT_STATUS0x00041000
+#define TRP_INTERRUPT_0_STATUS  0x00020480
+#define DRP_INTERRUPT_CLEAR 0x00041008
+#define DRP_ECC_ERROR_CNTR_CLEAR0x00040004
+#define TRP_INTERRUPT_0_CLEAR   0x00020484
+#define TRP_ECC_ERROR_CNTR_CLEAR0x00020440
+
+/* Mask and shift macros */
+#define ECC_DB_ERR_COUNT_MASK   GENMASK(4, 0)
+#define ECC_DB

[PATCH v1 0/4] Add EDAC driver for QCOM SoCs

2018-08-01 Thread Venkata Narendra Kumar Gutta
This series implements EDAC driver for QCOM SoCs. As of now, this driver
supports EDAC for Last Level Cache Controller (LLCC). LLCC EDAC driver is
to detect and report single and double bit errors on Last Level Cache
Controller (LLCC) cache. This driver also takes care of dumping registers
and also adding config options to enable and disable panic when these
errors happen in LLCC.

The driver functionality is implemented in:
qcom_edac.c : This platform driver registers to edac framework and
handles the single and double bit errors in cache by registering
interrupt handlers.

llcc-slice.c: It invokes the llcc edac driver and passes platform
data to it.

This patchset depends on the LLCC driver, which is yet to be merged.
Link: https://patchwork.kernel.org/patch/10422531/
Link: 
http://lists-archives.com/linux-kernel/29157082-dt-bindings-documentation-for-qcom-llcc.html

Changes since v0:
  * Added EDAC_QCOM config and updated the driver
  * Addressed comments related to indentation and other minor ones

Channagoud Kadabi (1):
  drivers: edac: Add EDAC driver support for QCOM SoCs

Venkata Narendra Kumar Gutta (3):
  drivers: soc: Add broadcast base for Last Level Cache Controller
(LLCC)
  drivers: soc: Add support to register LLCC EDAC driver
  dt-bindigs: Update documentation of qcom,llcc

 .../devicetree/bindings/arm/msm/qcom,llcc.txt  |  15 +-
 MAINTAINERS|   7 +
 drivers/edac/Kconfig   |  28 ++
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 507 +
 drivers/soc/qcom/llcc-slice.c  |  73 ++-
 include/linux/soc/qcom/llcc-qcom.h |   6 +-
 7 files changed, 610 insertions(+), 27 deletions(-)
 create mode 100644 drivers/edac/qcom_edac.c

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v1 0/4] Add EDAC driver for QCOM SoCs

2018-08-01 Thread Venkata Narendra Kumar Gutta
This series implements EDAC driver for QCOM SoCs. As of now, this driver
supports EDAC for Last Level Cache Controller (LLCC). LLCC EDAC driver is
to detect and report single and double bit errors on Last Level Cache
Controller (LLCC) cache. This driver also takes care of dumping registers
and also adding config options to enable and disable panic when these
errors happen in LLCC.

The driver functionality is implemented in:
qcom_edac.c : This platform driver registers to edac framework and
handles the single and double bit errors in cache by registering
interrupt handlers.

llcc-slice.c: It invokes the llcc edac driver and passes platform
data to it.

This patchset depends on the LLCC driver, which is yet to be merged.
Link: https://patchwork.kernel.org/patch/10422531/
Link: 
http://lists-archives.com/linux-kernel/29157082-dt-bindings-documentation-for-qcom-llcc.html

Changes since v0:
  * Added EDAC_QCOM config and updated the driver
  * Addressed comments related to indentation and other minor ones

Channagoud Kadabi (1):
  drivers: edac: Add EDAC driver support for QCOM SoCs

Venkata Narendra Kumar Gutta (3):
  drivers: soc: Add broadcast base for Last Level Cache Controller
(LLCC)
  drivers: soc: Add support to register LLCC EDAC driver
  dt-bindigs: Update documentation of qcom,llcc

 .../devicetree/bindings/arm/msm/qcom,llcc.txt  |  15 +-
 MAINTAINERS|   7 +
 drivers/edac/Kconfig   |  28 ++
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_edac.c   | 507 +
 drivers/soc/qcom/llcc-slice.c  |  73 ++-
 include/linux/soc/qcom/llcc-qcom.h |   6 +-
 7 files changed, 610 insertions(+), 27 deletions(-)
 create mode 100644 drivers/edac/qcom_edac.c

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v1 4/4] dt-bindigs: Update documentation of qcom,llcc

2018-08-01 Thread Venkata Narendra Kumar Gutta
Add reg-names and interrupts for LLCC documentation and the usage
examples. llcc broadcast base is added in addition to llcc base,
which is used for llcc broadcast writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt 
b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
index 5e85749..b4b1c86 100644
--- a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
@@ -18,9 +18,22 @@ Properties:
Value Type: 
Definition: Start address and the the size of the register region.
 
+- reg-names:
+Usage: required
+Value Type: 
+Definition: Register region names. Must be "llcc_base", 
"llcc_bcast_base".
+
+- interrupts:
+   Usage: required
+   Definition: The interrupt is associated with the llcc edac device.
+   It's used for llcc cache single and double bit error 
detection
+   and reporting.
+
 Example:
 
cache-controller@110 {
compatible = "qcom,sdm845-llcc";
-   reg = <0x110 0x25>;
+   reg = <0x110 0x20>, <0x130 0x5> ;
+   reg-names = "llcc_base", "llcc_bcast_base";
+   interrupts = ;
};
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v1 4/4] dt-bindigs: Update documentation of qcom,llcc

2018-08-01 Thread Venkata Narendra Kumar Gutta
Add reg-names and interrupts for LLCC documentation and the usage
examples. llcc broadcast base is added in addition to llcc base,
which is used for llcc broadcast writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt 
b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
index 5e85749..b4b1c86 100644
--- a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
@@ -18,9 +18,22 @@ Properties:
Value Type: 
Definition: Start address and the the size of the register region.
 
+- reg-names:
+Usage: required
+Value Type: 
+Definition: Register region names. Must be "llcc_base", 
"llcc_bcast_base".
+
+- interrupts:
+   Usage: required
+   Definition: The interrupt is associated with the llcc edac device.
+   It's used for llcc cache single and double bit error 
detection
+   and reporting.
+
 Example:
 
cache-controller@110 {
compatible = "qcom,sdm845-llcc";
-   reg = <0x110 0x25>;
+   reg = <0x110 0x20>, <0x130 0x5> ;
+   reg-names = "llcc_base", "llcc_bcast_base";
+   interrupts = ;
};
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v1 2/4] drivers: soc: Add support to register LLCC EDAC driver

2018-08-01 Thread Venkata Narendra Kumar Gutta
Cache error reporting controller is to detect and report single
and double bit errors on Last Level Cache Controller (LLCC) cache.
Add required support to register LLCC EDAC driver as platform driver,
from LLCC driver.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/soc/qcom/llcc-slice.c  | 18 --
 include/linux/soc/qcom/llcc-qcom.h |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index a63640d..09c8bb0 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -224,7 +224,7 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
u32 attr0_val;
u32 max_cap_cacheline;
u32 sz;
-   int ret;
+   int ret = 0;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
 
@@ -282,6 +282,7 @@ int qcom_llcc_probe(struct platform_device *pdev,
struct resource *llcc_banks_res, *llcc_bcast_res;
void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
+   struct platform_device *llcc_edac;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
@@ -341,6 +342,19 @@ int qcom_llcc_probe(struct platform_device *pdev,
mutex_init(_data->lock);
platform_set_drvdata(pdev, drv_data);
 
-   return qcom_llcc_cfg_program(pdev);
+   ret = qcom_llcc_cfg_program(pdev);
+   if (ret)
+   return ret;
+
+   drv_data->ecc_irq = platform_get_irq(pdev, 0);
+   if (drv_data->ecc_irq >= 0) {
+   llcc_edac = platform_device_register_data(>dev,
+   "qcom_llcc_edac", -1, drv_data,
+   sizeof(*drv_data));
+   if (IS_ERR(llcc_edac))
+   dev_err(dev, "Failed to register llcc edac driver\n");
+   }
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(qcom_llcc_probe);
diff --git a/include/linux/soc/qcom/llcc-qcom.h 
b/include/linux/soc/qcom/llcc-qcom.h
index c681e79..1a3bc25 100644
--- a/include/linux/soc/qcom/llcc-qcom.h
+++ b/include/linux/soc/qcom/llcc-qcom.h
@@ -78,6 +78,7 @@ struct llcc_slice_config {
  * @num_banks: Number of llcc banks
  * @bitmap: Bit map to track the active slice ids
  * @offsets: Pointer to the bank offsets array
+ * @ecc_irq: interrupt for llcc cache error detection and reporting
  */
 struct llcc_drv_data {
struct regmap *regmap;
@@ -89,6 +90,7 @@ struct llcc_drv_data {
u32 num_banks;
unsigned long *bitmap;
u32 *offsets;
+   u32 ecc_irq;
 };
 
 #if IS_ENABLED(CONFIG_QCOM_LLCC)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v1 3/4] drivers: edac: Add EDAC driver support for QCOM SoCs

2018-08-01 Thread Venkata Narendra Kumar Gutta
From: Channagoud Kadabi 

Add error reporting driver for SBEs and DBEs. As of now, this driver
supports erp for Last Level Cache Controller (LLCC). This driver takes
care of dumping registers and adding config options to enable and
disable panic when the errors happen in cache.

Co-developed-by: Venkata Narendra Kumar Gutta 
Signed-off-by: Venkata Narendra Kumar Gutta 
Signed-off-by: Channagoud Kadabi 
---
 MAINTAINERS  |   7 +
 drivers/edac/Kconfig |  28 +++
 drivers/edac/Makefile|   1 +
 drivers/edac/qcom_edac.c | 507 +++
 4 files changed, 543 insertions(+)
 create mode 100644 drivers/edac/qcom_edac.c

diff --git a/MAINTAINERS b/MAINTAINERS
index f6a9b08..68b3484 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5227,6 +5227,13 @@ L:   linux-e...@vger.kernel.org
 S: Maintained
 F: drivers/edac/ti_edac.c
 
+EDAC-QUALCOMM
+M: Channagoud Kadabi
+M: Venkata Narendra Kumar Gutta
+L: linux-arm-...@vger.kernel.org
+S: Maintained
+F: drivers/edac/qcom_edac.c
+
 EDIROL UA-101/UA-1000 DRIVER
 M: Clemens Ladisch 
 L: alsa-de...@alsa-project.org (moderated for non-subscribers)
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 57304b2..c654b0e 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -460,4 +460,32 @@ config EDAC_TI
  Support for error detection and correction on the
   TI SoCs.
 
+config EDAC_QCOM
+   depends on EDAC=y
+   tristate "QCOM EDAC Controller"
+   help
+   Support for error detection and correction on the
+   QCOM SoCs.
+
+config EDAC_QCOM_LLCC
+   depends on EDAC_QCOM=y && QCOM_LLCC
+   tristate "QCOM EDAC Controller for LLCC Cache"
+   help
+   Support for error detection and correction on the
+   QCOM LLCC cache. Report errors caught by LLCC ECC
+   mechanism.
+
+   For debugging issues having to do with stability and overall 
system
+   health, you should probably say 'Y' here.
+
+config EDAC_QCOM_LLCC_PANIC_ON_UE
+   depends on EDAC_QCOM_LLCC
+   bool "Panic on uncorrectable errors - qcom llcc"
+   help
+   Forcibly cause a kernel panic if an uncorrectable error (UE) is
+   detected. This can reduce debugging times on hardware which may 
be
+   operating at voltages or frequencies outside normal 
specification.
+
+   For production builds, you should probably say 'N' here.
+
 endif # EDAC
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index 02b43a7..716096d 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -77,3 +77,4 @@ obj-$(CONFIG_EDAC_ALTERA) += altera_edac.o
 obj-$(CONFIG_EDAC_SYNOPSYS)+= synopsys_edac.o
 obj-$(CONFIG_EDAC_XGENE)   += xgene_edac.o
 obj-$(CONFIG_EDAC_TI)  += ti_edac.o
+obj-$(CONFIG_EDAC_QCOM)+= qcom_edac.o
diff --git a/drivers/edac/qcom_edac.c b/drivers/edac/qcom_edac.c
new file mode 100644
index 000..cf3e2b0
--- /dev/null
+++ b/drivers/edac/qcom_edac.c
@@ -0,0 +1,507 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "edac_mc.h"
+#include "edac_device.h"
+
+#ifdef CONFIG_EDAC_QCOM_LLCC_PANIC_ON_UE
+#define LLCC_ERP_PANIC_ON_UE1
+#else
+#define LLCC_ERP_PANIC_ON_UE0
+#endif
+
+#define EDAC_LLCC   "qcom_llcc"
+
+#define TRP_SYN_REG_CNT 6
+
+#define DRP_SYN_REG_CNT 8
+
+#define LLCC_COMMON_STATUS0 0x0003000C
+#define LLCC_LB_CNT_MASKGENMASK(31, 28)
+#define LLCC_LB_CNT_SHIFT   28
+
+/* single & Double Bit syndrome register offsets */
+#define TRP_ECC_SB_ERR_SYN0 0x0002304C
+#define TRP_ECC_DB_ERR_SYN0 0x00020370
+#define DRP_ECC_SB_ERR_SYN0 0x0004204C
+#define DRP_ECC_DB_ERR_SYN0 0x00042070
+
+/* Error register offsets */
+#define TRP_ECC_ERROR_STATUS1   0x00020348
+#define TRP_ECC_ERROR_STATUS0   0x00020344
+#define DRP_ECC_ERROR_STATUS1   0x00042048
+#define DRP_ECC_ERROR_STATUS0   0x00042044
+
+/* TRP, DRP interrupt register offsets */
+#define DRP_INTERRUPT_STATUS0x00041000
+#define TRP_INTERRUPT_0_STATUS  0x00020480
+#define DRP_INTERRUPT_CLEAR 0x00041008
+#define DRP_ECC_ERROR_CNTR_CLEAR0x00040004
+#define TRP_INTERRUPT_0_CLEAR   0x00020484
+#define TRP_ECC_ERROR_CNTR_CLEAR0x00020440
+
+/* Mask and shift macros */
+#define ECC_DB_ERR_COUNT_MASK   GENMASK(4, 0)
+#define ECC_DB_ERR_WAYS_MASKGENMASK(31, 16)
+#define ECC_DB_ERR_WAYS_SHIFT   BI

[PATCH v1 3/4] drivers: edac: Add EDAC driver support for QCOM SoCs

2018-08-01 Thread Venkata Narendra Kumar Gutta
From: Channagoud Kadabi 

Add error reporting driver for SBEs and DBEs. As of now, this driver
supports erp for Last Level Cache Controller (LLCC). This driver takes
care of dumping registers and adding config options to enable and
disable panic when the errors happen in cache.

Co-developed-by: Venkata Narendra Kumar Gutta 
Signed-off-by: Venkata Narendra Kumar Gutta 
Signed-off-by: Channagoud Kadabi 
---
 MAINTAINERS  |   7 +
 drivers/edac/Kconfig |  28 +++
 drivers/edac/Makefile|   1 +
 drivers/edac/qcom_edac.c | 507 +++
 4 files changed, 543 insertions(+)
 create mode 100644 drivers/edac/qcom_edac.c

diff --git a/MAINTAINERS b/MAINTAINERS
index f6a9b08..68b3484 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5227,6 +5227,13 @@ L:   linux-e...@vger.kernel.org
 S: Maintained
 F: drivers/edac/ti_edac.c
 
+EDAC-QUALCOMM
+M: Channagoud Kadabi
+M: Venkata Narendra Kumar Gutta
+L: linux-arm-...@vger.kernel.org
+S: Maintained
+F: drivers/edac/qcom_edac.c
+
 EDIROL UA-101/UA-1000 DRIVER
 M: Clemens Ladisch 
 L: alsa-de...@alsa-project.org (moderated for non-subscribers)
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 57304b2..c654b0e 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -460,4 +460,32 @@ config EDAC_TI
  Support for error detection and correction on the
   TI SoCs.
 
+config EDAC_QCOM
+   depends on EDAC=y
+   tristate "QCOM EDAC Controller"
+   help
+   Support for error detection and correction on the
+   QCOM SoCs.
+
+config EDAC_QCOM_LLCC
+   depends on EDAC_QCOM=y && QCOM_LLCC
+   tristate "QCOM EDAC Controller for LLCC Cache"
+   help
+   Support for error detection and correction on the
+   QCOM LLCC cache. Report errors caught by LLCC ECC
+   mechanism.
+
+   For debugging issues having to do with stability and overall 
system
+   health, you should probably say 'Y' here.
+
+config EDAC_QCOM_LLCC_PANIC_ON_UE
+   depends on EDAC_QCOM_LLCC
+   bool "Panic on uncorrectable errors - qcom llcc"
+   help
+   Forcibly cause a kernel panic if an uncorrectable error (UE) is
+   detected. This can reduce debugging times on hardware which may 
be
+   operating at voltages or frequencies outside normal 
specification.
+
+   For production builds, you should probably say 'N' here.
+
 endif # EDAC
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index 02b43a7..716096d 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -77,3 +77,4 @@ obj-$(CONFIG_EDAC_ALTERA) += altera_edac.o
 obj-$(CONFIG_EDAC_SYNOPSYS)+= synopsys_edac.o
 obj-$(CONFIG_EDAC_XGENE)   += xgene_edac.o
 obj-$(CONFIG_EDAC_TI)  += ti_edac.o
+obj-$(CONFIG_EDAC_QCOM)+= qcom_edac.o
diff --git a/drivers/edac/qcom_edac.c b/drivers/edac/qcom_edac.c
new file mode 100644
index 000..cf3e2b0
--- /dev/null
+++ b/drivers/edac/qcom_edac.c
@@ -0,0 +1,507 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "edac_mc.h"
+#include "edac_device.h"
+
+#ifdef CONFIG_EDAC_QCOM_LLCC_PANIC_ON_UE
+#define LLCC_ERP_PANIC_ON_UE1
+#else
+#define LLCC_ERP_PANIC_ON_UE0
+#endif
+
+#define EDAC_LLCC   "qcom_llcc"
+
+#define TRP_SYN_REG_CNT 6
+
+#define DRP_SYN_REG_CNT 8
+
+#define LLCC_COMMON_STATUS0 0x0003000C
+#define LLCC_LB_CNT_MASKGENMASK(31, 28)
+#define LLCC_LB_CNT_SHIFT   28
+
+/* single & Double Bit syndrome register offsets */
+#define TRP_ECC_SB_ERR_SYN0 0x0002304C
+#define TRP_ECC_DB_ERR_SYN0 0x00020370
+#define DRP_ECC_SB_ERR_SYN0 0x0004204C
+#define DRP_ECC_DB_ERR_SYN0 0x00042070
+
+/* Error register offsets */
+#define TRP_ECC_ERROR_STATUS1   0x00020348
+#define TRP_ECC_ERROR_STATUS0   0x00020344
+#define DRP_ECC_ERROR_STATUS1   0x00042048
+#define DRP_ECC_ERROR_STATUS0   0x00042044
+
+/* TRP, DRP interrupt register offsets */
+#define DRP_INTERRUPT_STATUS0x00041000
+#define TRP_INTERRUPT_0_STATUS  0x00020480
+#define DRP_INTERRUPT_CLEAR 0x00041008
+#define DRP_ECC_ERROR_CNTR_CLEAR0x00040004
+#define TRP_INTERRUPT_0_CLEAR   0x00020484
+#define TRP_ECC_ERROR_CNTR_CLEAR0x00020440
+
+/* Mask and shift macros */
+#define ECC_DB_ERR_COUNT_MASK   GENMASK(4, 0)
+#define ECC_DB_ERR_WAYS_MASKGENMASK(31, 16)
+#define ECC_DB_ERR_WAYS_SHIFT   BI

[PATCH v1 2/4] drivers: soc: Add support to register LLCC EDAC driver

2018-08-01 Thread Venkata Narendra Kumar Gutta
Cache error reporting controller is to detect and report single
and double bit errors on Last Level Cache Controller (LLCC) cache.
Add required support to register LLCC EDAC driver as platform driver,
from LLCC driver.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/soc/qcom/llcc-slice.c  | 18 --
 include/linux/soc/qcom/llcc-qcom.h |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index a63640d..09c8bb0 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -224,7 +224,7 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
u32 attr0_val;
u32 max_cap_cacheline;
u32 sz;
-   int ret;
+   int ret = 0;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
 
@@ -282,6 +282,7 @@ int qcom_llcc_probe(struct platform_device *pdev,
struct resource *llcc_banks_res, *llcc_bcast_res;
void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
+   struct platform_device *llcc_edac;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
@@ -341,6 +342,19 @@ int qcom_llcc_probe(struct platform_device *pdev,
mutex_init(_data->lock);
platform_set_drvdata(pdev, drv_data);
 
-   return qcom_llcc_cfg_program(pdev);
+   ret = qcom_llcc_cfg_program(pdev);
+   if (ret)
+   return ret;
+
+   drv_data->ecc_irq = platform_get_irq(pdev, 0);
+   if (drv_data->ecc_irq >= 0) {
+   llcc_edac = platform_device_register_data(>dev,
+   "qcom_llcc_edac", -1, drv_data,
+   sizeof(*drv_data));
+   if (IS_ERR(llcc_edac))
+   dev_err(dev, "Failed to register llcc edac driver\n");
+   }
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(qcom_llcc_probe);
diff --git a/include/linux/soc/qcom/llcc-qcom.h 
b/include/linux/soc/qcom/llcc-qcom.h
index c681e79..1a3bc25 100644
--- a/include/linux/soc/qcom/llcc-qcom.h
+++ b/include/linux/soc/qcom/llcc-qcom.h
@@ -78,6 +78,7 @@ struct llcc_slice_config {
  * @num_banks: Number of llcc banks
  * @bitmap: Bit map to track the active slice ids
  * @offsets: Pointer to the bank offsets array
+ * @ecc_irq: interrupt for llcc cache error detection and reporting
  */
 struct llcc_drv_data {
struct regmap *regmap;
@@ -89,6 +90,7 @@ struct llcc_drv_data {
u32 num_banks;
unsigned long *bitmap;
u32 *offsets;
+   u32 ecc_irq;
 };
 
 #if IS_ENABLED(CONFIG_QCOM_LLCC)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v1 1/4] drivers: soc: Add broadcast base for Last Level Cache Controller (LLCC)

2018-08-01 Thread Venkata Narendra Kumar Gutta
Currently, boradcast base is set to end of the LLCC banks, which may
not be correct always. As the number of banks may vary for each chipset
and the broadcast base could be at a different address as well. This info
depends on the chipset, so get the broadcast base info from the device
tree (DT). Add broadcast base in LLCC driver and use this for broadcast
writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/soc/qcom/llcc-slice.c  | 55 +++---
 include/linux/soc/qcom/llcc-qcom.h |  4 +--
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index fcaad1a..a63640d 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -105,22 +105,24 @@ static int llcc_update_act_ctrl(u32 sid,
u32 slice_status;
int ret;
 
-   act_ctrl_reg = drv_data->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
-   status_reg = drv_data->bcast_off + LLCC_TRP_STATUSn(sid);
+   act_ctrl_reg = LLCC_TRP_ACT_CTRLn(sid);
+   status_reg = LLCC_TRP_STATUSn(sid);
 
/* Set the ACTIVE trigger */
act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
-   ret = regmap_write(drv_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_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_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_regmap, act_ctrl_reg,
+   act_ctrl_reg_val);
if (ret)
return ret;
 
-   ret = regmap_read_poll_timeout(drv_data->regmap, status_reg,
+   ret = regmap_read_poll_timeout(drv_data->bcast_regmap, status_reg,
  slice_status, !(slice_status & status),
  0, LLCC_STATUS_READ_DELAY);
return ret;
@@ -225,16 +227,13 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
int ret;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
-   u32 bcast_off = drv_data->bcast_off;
 
sz = drv_data->cfg_size;
llcc_table = drv_data->cfg;
 
for (i = 0; i < sz; i++) {
-   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);
+   attr1_cfg = LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);
+   attr0_cfg = LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);
 
attr1_val = llcc_table[i].cache_mode;
attr1_val |= llcc_table[i].probe_target_ways <<
@@ -259,10 +258,12 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
attr0_val = llcc_table[i].res_ways & ATTR0_RES_WAYS_MASK;
attr0_val |= llcc_table[i].bonus_ways << ATTR0_BONUS_WAYS_SHIFT;
 
-   ret = regmap_write(drv_data->regmap, attr1_cfg, attr1_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr1_cfg,
+   attr1_val);
if (ret)
return ret;
-   ret = regmap_write(drv_data->regmap, attr0_cfg, attr0_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr0_cfg,
+   attr0_val);
if (ret)
return ret;
if (llcc_table[i].activate_on_init) {
@@ -278,24 +279,36 @@ int qcom_llcc_probe(struct platform_device *pdev,
 {
u32 num_banks;
struct device *dev = >dev;
-   struct resource *res;
-   void __iomem *base;
+   struct resource *llcc_banks_res, *llcc_bcast_res;
+   void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
return -ENOMEM;
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_ioremap_resource(>dev, res);
-   if (IS_ERR(base))
-   return PTR_ERR(base);
+   llcc_banks_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+   "llcc_base");
+   llcc_banks_base = devm_ioremap_resource(>dev, llcc_banks_res);
+   if (IS_ERR(llcc_banks_base))
+   return PTR_ERR(llcc_banks_base);
 
-   drv_data->regmap = devm_regmap_init_mmio(dev, base,
-   _regmap_config);
+   drv_data->regmap = devm_regmap_init_mmio(dev, llcc_banks_base,
+

[PATCH v1 1/4] drivers: soc: Add broadcast base for Last Level Cache Controller (LLCC)

2018-08-01 Thread Venkata Narendra Kumar Gutta
Currently, boradcast base is set to end of the LLCC banks, which may
not be correct always. As the number of banks may vary for each chipset
and the broadcast base could be at a different address as well. This info
depends on the chipset, so get the broadcast base info from the device
tree (DT). Add broadcast base in LLCC driver and use this for broadcast
writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/soc/qcom/llcc-slice.c  | 55 +++---
 include/linux/soc/qcom/llcc-qcom.h |  4 +--
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index fcaad1a..a63640d 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -105,22 +105,24 @@ static int llcc_update_act_ctrl(u32 sid,
u32 slice_status;
int ret;
 
-   act_ctrl_reg = drv_data->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
-   status_reg = drv_data->bcast_off + LLCC_TRP_STATUSn(sid);
+   act_ctrl_reg = LLCC_TRP_ACT_CTRLn(sid);
+   status_reg = LLCC_TRP_STATUSn(sid);
 
/* Set the ACTIVE trigger */
act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
-   ret = regmap_write(drv_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_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_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_regmap, act_ctrl_reg,
+   act_ctrl_reg_val);
if (ret)
return ret;
 
-   ret = regmap_read_poll_timeout(drv_data->regmap, status_reg,
+   ret = regmap_read_poll_timeout(drv_data->bcast_regmap, status_reg,
  slice_status, !(slice_status & status),
  0, LLCC_STATUS_READ_DELAY);
return ret;
@@ -225,16 +227,13 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
int ret;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
-   u32 bcast_off = drv_data->bcast_off;
 
sz = drv_data->cfg_size;
llcc_table = drv_data->cfg;
 
for (i = 0; i < sz; i++) {
-   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);
+   attr1_cfg = LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);
+   attr0_cfg = LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);
 
attr1_val = llcc_table[i].cache_mode;
attr1_val |= llcc_table[i].probe_target_ways <<
@@ -259,10 +258,12 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
attr0_val = llcc_table[i].res_ways & ATTR0_RES_WAYS_MASK;
attr0_val |= llcc_table[i].bonus_ways << ATTR0_BONUS_WAYS_SHIFT;
 
-   ret = regmap_write(drv_data->regmap, attr1_cfg, attr1_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr1_cfg,
+   attr1_val);
if (ret)
return ret;
-   ret = regmap_write(drv_data->regmap, attr0_cfg, attr0_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr0_cfg,
+   attr0_val);
if (ret)
return ret;
if (llcc_table[i].activate_on_init) {
@@ -278,24 +279,36 @@ int qcom_llcc_probe(struct platform_device *pdev,
 {
u32 num_banks;
struct device *dev = >dev;
-   struct resource *res;
-   void __iomem *base;
+   struct resource *llcc_banks_res, *llcc_bcast_res;
+   void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
return -ENOMEM;
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_ioremap_resource(>dev, res);
-   if (IS_ERR(base))
-   return PTR_ERR(base);
+   llcc_banks_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+   "llcc_base");
+   llcc_banks_base = devm_ioremap_resource(>dev, llcc_banks_res);
+   if (IS_ERR(llcc_banks_base))
+   return PTR_ERR(llcc_banks_base);
 
-   drv_data->regmap = devm_regmap_init_mmio(dev, base,
-   _regmap_config);
+   drv_data->regmap = devm_regmap_init_mmio(dev, llcc_banks_base,
+

[PATCH v0 2/4] drivers: soc: Support to add cache erp driver for Last Level Cache Controller (LLCC)

2018-07-25 Thread Venkata Narendra Kumar Gutta
Cache error reporting controller is to detect and report single
and double bit errors on Last Level Cache Controller (LLCC) cache.
Add required support to register cache erp driver as platform driver,
from LLCC driver.

Signed-off-by: Channagoud Kadabi 
Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/soc/qcom/llcc-slice.c  | 18 --
 include/linux/soc/qcom/llcc-qcom.h |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index a63640d..9860ef9 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -224,7 +224,7 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
u32 attr0_val;
u32 max_cap_cacheline;
u32 sz;
-   int ret;
+   int ret = 0;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
 
@@ -282,6 +282,7 @@ int qcom_llcc_probe(struct platform_device *pdev,
struct resource *llcc_banks_res, *llcc_bcast_res;
void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
+   struct platform_device *llcc_edac;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
@@ -341,6 +342,19 @@ int qcom_llcc_probe(struct platform_device *pdev,
mutex_init(_data->lock);
platform_set_drvdata(pdev, drv_data);
 
-   return qcom_llcc_cfg_program(pdev);
+   ret = qcom_llcc_cfg_program(pdev);
+   if (ret)
+   return ret;
+
+   drv_data->ecc_irq = platform_get_irq(pdev, 0);
+   if (drv_data->ecc_irq >= 0) {
+   llcc_edac = platform_device_register_data(>dev,
+   "qcom_llcc_erp", -1, drv_data,
+   sizeof(*drv_data));
+   if (IS_ERR(llcc_edac))
+   dev_err(dev, "Failed to register llcc edac driver\n");
+   }
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(qcom_llcc_probe);
diff --git a/include/linux/soc/qcom/llcc-qcom.h 
b/include/linux/soc/qcom/llcc-qcom.h
index c681e79..1a3bc25 100644
--- a/include/linux/soc/qcom/llcc-qcom.h
+++ b/include/linux/soc/qcom/llcc-qcom.h
@@ -78,6 +78,7 @@ struct llcc_slice_config {
  * @num_banks: Number of llcc banks
  * @bitmap: Bit map to track the active slice ids
  * @offsets: Pointer to the bank offsets array
+ * @ecc_irq: interrupt for llcc cache error detection and reporting
  */
 struct llcc_drv_data {
struct regmap *regmap;
@@ -89,6 +90,7 @@ struct llcc_drv_data {
u32 num_banks;
unsigned long *bitmap;
u32 *offsets;
+   u32 ecc_irq;
 };
 
 #if IS_ENABLED(CONFIG_QCOM_LLCC)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v0 2/4] drivers: soc: Support to add cache erp driver for Last Level Cache Controller (LLCC)

2018-07-25 Thread Venkata Narendra Kumar Gutta
Cache error reporting controller is to detect and report single
and double bit errors on Last Level Cache Controller (LLCC) cache.
Add required support to register cache erp driver as platform driver,
from LLCC driver.

Signed-off-by: Channagoud Kadabi 
Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/soc/qcom/llcc-slice.c  | 18 --
 include/linux/soc/qcom/llcc-qcom.h |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index a63640d..9860ef9 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -224,7 +224,7 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
u32 attr0_val;
u32 max_cap_cacheline;
u32 sz;
-   int ret;
+   int ret = 0;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
 
@@ -282,6 +282,7 @@ int qcom_llcc_probe(struct platform_device *pdev,
struct resource *llcc_banks_res, *llcc_bcast_res;
void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
+   struct platform_device *llcc_edac;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
@@ -341,6 +342,19 @@ int qcom_llcc_probe(struct platform_device *pdev,
mutex_init(_data->lock);
platform_set_drvdata(pdev, drv_data);
 
-   return qcom_llcc_cfg_program(pdev);
+   ret = qcom_llcc_cfg_program(pdev);
+   if (ret)
+   return ret;
+
+   drv_data->ecc_irq = platform_get_irq(pdev, 0);
+   if (drv_data->ecc_irq >= 0) {
+   llcc_edac = platform_device_register_data(>dev,
+   "qcom_llcc_erp", -1, drv_data,
+   sizeof(*drv_data));
+   if (IS_ERR(llcc_edac))
+   dev_err(dev, "Failed to register llcc edac driver\n");
+   }
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(qcom_llcc_probe);
diff --git a/include/linux/soc/qcom/llcc-qcom.h 
b/include/linux/soc/qcom/llcc-qcom.h
index c681e79..1a3bc25 100644
--- a/include/linux/soc/qcom/llcc-qcom.h
+++ b/include/linux/soc/qcom/llcc-qcom.h
@@ -78,6 +78,7 @@ struct llcc_slice_config {
  * @num_banks: Number of llcc banks
  * @bitmap: Bit map to track the active slice ids
  * @offsets: Pointer to the bank offsets array
+ * @ecc_irq: interrupt for llcc cache error detection and reporting
  */
 struct llcc_drv_data {
struct regmap *regmap;
@@ -89,6 +90,7 @@ struct llcc_drv_data {
u32 num_banks;
unsigned long *bitmap;
u32 *offsets;
+   u32 ecc_irq;
 };
 
 #if IS_ENABLED(CONFIG_QCOM_LLCC)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v0 4/4] dt-bindigs: Update documentation of qcom,llcc

2018-07-25 Thread Venkata Narendra Kumar Gutta
Add reg-names and interrupts for LLCC documentation and the usage
examples. llcc broadcast base is added in addition to llcc base,
which is used for llcc broadcast writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt 
b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
index 5e85749..b4b1c86 100644
--- a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
@@ -18,9 +18,22 @@ Properties:
Value Type: 
Definition: Start address and the the size of the register region.
 
+- reg-names:
+Usage: required
+Value Type: 
+Definition: Register region names. Must be "llcc_base", 
"llcc_bcast_base".
+
+- interrupts:
+   Usage: required
+   Definition: The interrupt is associated with the llcc edac device.
+   It's used for llcc cache single and double bit error 
detection
+   and reporting.
+
 Example:
 
cache-controller@110 {
compatible = "qcom,sdm845-llcc";
-   reg = <0x110 0x25>;
+   reg = <0x110 0x20>, <0x130 0x5> ;
+   reg-names = "llcc_base", "llcc_bcast_base";
+   interrupts = ;
};
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v0 3/4] drivers: edac: Add cache erp driver for Last Level Cache Controller (LLCC)

2018-07-25 Thread Venkata Narendra Kumar Gutta
Add cache error reporting driver for single and double bit errors on
Last Level Cache Controller (LLCC) cache. This driver takes care of
dumping registers and add config options to enable and disable panic
when these errors happen.

Signed-off-by: Channagoud Kadabi 
Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/edac/Kconfig  |  21 ++
 drivers/edac/Makefile |   1 +
 drivers/edac/qcom_llcc_edac.c | 520 ++
 3 files changed, 542 insertions(+)
 create mode 100644 drivers/edac/qcom_llcc_edac.c

diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 57304b2..68518ad 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -460,4 +460,25 @@ config EDAC_TI
  Support for error detection and correction on the
   TI SoCs.
 
+config EDAC_QCOM_LLCC
+depends on QCOM_LLCC
+tristate "QCOM EDAC Controller for LLCC Cache"
+help
+  Support for error detection and correction on the
+  QCOM LLCC cache. Report errors caught by LLCC ECC
+  mechanism.
+
+  For debugging issues having to do with stability and overall system
+  health, you should probably say 'Y' here.
+
+config EDAC_QCOM_LLCC_PANIC_ON_UE
+depends on EDAC_QCOM_LLCC
+bool "Panic on uncorrectable errors - qcom llcc"
+help
+  Forcibly cause a kernel panic if an uncorrectable error (UE) is
+  detected. This can reduce debugging times on hardware which may be
+  operating at voltages or frequencies outside normal specification.
+
+  For production builds, you should probably say 'N' here.
+
 endif # EDAC
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index 02b43a7..28aff28 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -77,3 +77,4 @@ obj-$(CONFIG_EDAC_ALTERA) += altera_edac.o
 obj-$(CONFIG_EDAC_SYNOPSYS)+= synopsys_edac.o
 obj-$(CONFIG_EDAC_XGENE)   += xgene_edac.o
 obj-$(CONFIG_EDAC_TI)  += ti_edac.o
+obj-$(CONFIG_EDAC_QCOM_LLCC)   += qcom_llcc_edac.o
diff --git a/drivers/edac/qcom_llcc_edac.c b/drivers/edac/qcom_llcc_edac.c
new file mode 100644
index 000..7a678b5
--- /dev/null
+++ b/drivers/edac/qcom_llcc_edac.c
@@ -0,0 +1,520 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "edac_mc.h"
+#include "edac_device.h"
+
+#ifdef CONFIG_EDAC_QCOM_LLCC_PANIC_ON_UE
+#define LLCC_ERP_PANIC_ON_UE 1
+#else
+#define LLCC_ERP_PANIC_ON_UE 0
+#endif
+
+#define EDAC_LLCC  "qcom_llcc"
+
+#define TRP_SYN_REG_CNT6
+
+#define DRP_SYN_REG_CNT8
+
+#define LLCC_COMMON_STATUS00x0003000C
+#define LLCC_LB_CNT_MASK   GENMASK(31, 28)
+#define LLCC_LB_CNT_SHIFT  28
+
+/* single & Double Bit syndrome register offsets */
+#define TRP_ECC_SB_ERR_SYN00x0002304C
+#define TRP_ECC_DB_ERR_SYN00x00020370
+#define DRP_ECC_SB_ERR_SYN00x0004204C
+#define DRP_ECC_DB_ERR_SYN00x00042070
+
+/* Error register offsets */
+#define TRP_ECC_ERROR_STATUS1  0x00020348
+#define TRP_ECC_ERROR_STATUS0  0x00020344
+#define DRP_ECC_ERROR_STATUS1  0x00042048
+#define DRP_ECC_ERROR_STATUS0  0x00042044
+
+/* TRP, DRP interrupt register offsets */
+#define DRP_INTERRUPT_STATUS   0x00041000
+#define TRP_INTERRUPT_0_STATUS 0x00020480
+#define DRP_INTERRUPT_CLEAR0x00041008
+#define DRP_ECC_ERROR_CNTR_CLEAR   0x00040004
+#define TRP_INTERRUPT_0_CLEAR  0x00020484
+#define TRP_ECC_ERROR_CNTR_CLEAR   0x00020440
+
+/* Mask and shift macros */
+#define ECC_DB_ERR_COUNT_MASK  GENMASK(4, 0)
+#define ECC_DB_ERR_WAYS_MASK   GENMASK(31, 16)
+#define ECC_DB_ERR_WAYS_SHIFT  BIT(4)
+
+#define ECC_SB_ERR_COUNT_MASK  GENMASK(23, 16)
+#define ECC_SB_ERR_COUNT_SHIFT BIT(4)
+#define ECC_SB_ERR_WAYS_MASK   GENMASK(15, 0)
+
+#define SB_ECC_ERROR   BIT(0)
+#define DB_ECC_ERROR   BIT(1)
+
+#define DRP_TRP_INT_CLEAR  GENMASK(1, 0)
+#define DRP_TRP_CNT_CLEAR  GENMASK(1, 0)
+
+/* Config registers offsets*/
+#define DRP_ECC_ERROR_CFG   0x0004
+
+/* TRP, DRP interrupt register offsets */
+#define CMN_INTERRUPT_0_ENABLE  0x0003001C
+#define CMN_INTERRUPT_2_ENABLE  0x0003003C
+#define TRP_INTERRUPT_0_ENABLE  0x00020488
+#define DRP_INTERRUPT_ENABLE0x0004100C
+
+#define SB_ERROR_THRESHOLD  0x1
+#define SB_ERROR_THRESHOLD_SHIFT24
+#define SB_DB_TRP_INTERRUPT_ENABLE  0x3
+#define TRP0_INTERRUPT_ENABLE   0x1
+#define DRP0_INTERRUPT_ENABLE   BIT(6)
+#define SB_DB_DRP_INTERRUPT_ENABLE  0x3
+
+
+enum {
+   LLCC_DRAM_CE = 0,
+   LLCC_DRAM_UE,
+   LLCC_TR

[PATCH v0 4/4] dt-bindigs: Update documentation of qcom,llcc

2018-07-25 Thread Venkata Narendra Kumar Gutta
Add reg-names and interrupts for LLCC documentation and the usage
examples. llcc broadcast base is added in addition to llcc base,
which is used for llcc broadcast writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt 
b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
index 5e85749..b4b1c86 100644
--- a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
@@ -18,9 +18,22 @@ Properties:
Value Type: 
Definition: Start address and the the size of the register region.
 
+- reg-names:
+Usage: required
+Value Type: 
+Definition: Register region names. Must be "llcc_base", 
"llcc_bcast_base".
+
+- interrupts:
+   Usage: required
+   Definition: The interrupt is associated with the llcc edac device.
+   It's used for llcc cache single and double bit error 
detection
+   and reporting.
+
 Example:
 
cache-controller@110 {
compatible = "qcom,sdm845-llcc";
-   reg = <0x110 0x25>;
+   reg = <0x110 0x20>, <0x130 0x5> ;
+   reg-names = "llcc_base", "llcc_bcast_base";
+   interrupts = ;
};
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v0 3/4] drivers: edac: Add cache erp driver for Last Level Cache Controller (LLCC)

2018-07-25 Thread Venkata Narendra Kumar Gutta
Add cache error reporting driver for single and double bit errors on
Last Level Cache Controller (LLCC) cache. This driver takes care of
dumping registers and add config options to enable and disable panic
when these errors happen.

Signed-off-by: Channagoud Kadabi 
Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/edac/Kconfig  |  21 ++
 drivers/edac/Makefile |   1 +
 drivers/edac/qcom_llcc_edac.c | 520 ++
 3 files changed, 542 insertions(+)
 create mode 100644 drivers/edac/qcom_llcc_edac.c

diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 57304b2..68518ad 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -460,4 +460,25 @@ config EDAC_TI
  Support for error detection and correction on the
   TI SoCs.
 
+config EDAC_QCOM_LLCC
+depends on QCOM_LLCC
+tristate "QCOM EDAC Controller for LLCC Cache"
+help
+  Support for error detection and correction on the
+  QCOM LLCC cache. Report errors caught by LLCC ECC
+  mechanism.
+
+  For debugging issues having to do with stability and overall system
+  health, you should probably say 'Y' here.
+
+config EDAC_QCOM_LLCC_PANIC_ON_UE
+depends on EDAC_QCOM_LLCC
+bool "Panic on uncorrectable errors - qcom llcc"
+help
+  Forcibly cause a kernel panic if an uncorrectable error (UE) is
+  detected. This can reduce debugging times on hardware which may be
+  operating at voltages or frequencies outside normal specification.
+
+  For production builds, you should probably say 'N' here.
+
 endif # EDAC
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index 02b43a7..28aff28 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -77,3 +77,4 @@ obj-$(CONFIG_EDAC_ALTERA) += altera_edac.o
 obj-$(CONFIG_EDAC_SYNOPSYS)+= synopsys_edac.o
 obj-$(CONFIG_EDAC_XGENE)   += xgene_edac.o
 obj-$(CONFIG_EDAC_TI)  += ti_edac.o
+obj-$(CONFIG_EDAC_QCOM_LLCC)   += qcom_llcc_edac.o
diff --git a/drivers/edac/qcom_llcc_edac.c b/drivers/edac/qcom_llcc_edac.c
new file mode 100644
index 000..7a678b5
--- /dev/null
+++ b/drivers/edac/qcom_llcc_edac.c
@@ -0,0 +1,520 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "edac_mc.h"
+#include "edac_device.h"
+
+#ifdef CONFIG_EDAC_QCOM_LLCC_PANIC_ON_UE
+#define LLCC_ERP_PANIC_ON_UE 1
+#else
+#define LLCC_ERP_PANIC_ON_UE 0
+#endif
+
+#define EDAC_LLCC  "qcom_llcc"
+
+#define TRP_SYN_REG_CNT6
+
+#define DRP_SYN_REG_CNT8
+
+#define LLCC_COMMON_STATUS00x0003000C
+#define LLCC_LB_CNT_MASK   GENMASK(31, 28)
+#define LLCC_LB_CNT_SHIFT  28
+
+/* single & Double Bit syndrome register offsets */
+#define TRP_ECC_SB_ERR_SYN00x0002304C
+#define TRP_ECC_DB_ERR_SYN00x00020370
+#define DRP_ECC_SB_ERR_SYN00x0004204C
+#define DRP_ECC_DB_ERR_SYN00x00042070
+
+/* Error register offsets */
+#define TRP_ECC_ERROR_STATUS1  0x00020348
+#define TRP_ECC_ERROR_STATUS0  0x00020344
+#define DRP_ECC_ERROR_STATUS1  0x00042048
+#define DRP_ECC_ERROR_STATUS0  0x00042044
+
+/* TRP, DRP interrupt register offsets */
+#define DRP_INTERRUPT_STATUS   0x00041000
+#define TRP_INTERRUPT_0_STATUS 0x00020480
+#define DRP_INTERRUPT_CLEAR0x00041008
+#define DRP_ECC_ERROR_CNTR_CLEAR   0x00040004
+#define TRP_INTERRUPT_0_CLEAR  0x00020484
+#define TRP_ECC_ERROR_CNTR_CLEAR   0x00020440
+
+/* Mask and shift macros */
+#define ECC_DB_ERR_COUNT_MASK  GENMASK(4, 0)
+#define ECC_DB_ERR_WAYS_MASK   GENMASK(31, 16)
+#define ECC_DB_ERR_WAYS_SHIFT  BIT(4)
+
+#define ECC_SB_ERR_COUNT_MASK  GENMASK(23, 16)
+#define ECC_SB_ERR_COUNT_SHIFT BIT(4)
+#define ECC_SB_ERR_WAYS_MASK   GENMASK(15, 0)
+
+#define SB_ECC_ERROR   BIT(0)
+#define DB_ECC_ERROR   BIT(1)
+
+#define DRP_TRP_INT_CLEAR  GENMASK(1, 0)
+#define DRP_TRP_CNT_CLEAR  GENMASK(1, 0)
+
+/* Config registers offsets*/
+#define DRP_ECC_ERROR_CFG   0x0004
+
+/* TRP, DRP interrupt register offsets */
+#define CMN_INTERRUPT_0_ENABLE  0x0003001C
+#define CMN_INTERRUPT_2_ENABLE  0x0003003C
+#define TRP_INTERRUPT_0_ENABLE  0x00020488
+#define DRP_INTERRUPT_ENABLE0x0004100C
+
+#define SB_ERROR_THRESHOLD  0x1
+#define SB_ERROR_THRESHOLD_SHIFT24
+#define SB_DB_TRP_INTERRUPT_ENABLE  0x3
+#define TRP0_INTERRUPT_ENABLE   0x1
+#define DRP0_INTERRUPT_ENABLE   BIT(6)
+#define SB_DB_DRP_INTERRUPT_ENABLE  0x3
+
+
+enum {
+   LLCC_DRAM_CE = 0,
+   LLCC_DRAM_UE,
+   LLCC_TR

[PATCH v0 1/4] drivers: soc: Add broadcast base for Last Level Cache Controller (LLCC)

2018-07-25 Thread Venkata Narendra Kumar Gutta
Currently, boradcast base is set to end of the LLCC banks, which may
not be correct always. As the number of banks may vary for each chipset
and the broadcast base could be at a different address as well. This info
depends on the chipset, so get the broadcast base info from the device
tree (DT). Add broadcast base in LLCC driver and use this for broadcast
writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/soc/qcom/llcc-slice.c  | 55 +++---
 include/linux/soc/qcom/llcc-qcom.h |  4 +--
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index fcaad1a..a63640d 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -105,22 +105,24 @@ static int llcc_update_act_ctrl(u32 sid,
u32 slice_status;
int ret;
 
-   act_ctrl_reg = drv_data->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
-   status_reg = drv_data->bcast_off + LLCC_TRP_STATUSn(sid);
+   act_ctrl_reg = LLCC_TRP_ACT_CTRLn(sid);
+   status_reg = LLCC_TRP_STATUSn(sid);
 
/* Set the ACTIVE trigger */
act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
-   ret = regmap_write(drv_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_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_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_regmap, act_ctrl_reg,
+   act_ctrl_reg_val);
if (ret)
return ret;
 
-   ret = regmap_read_poll_timeout(drv_data->regmap, status_reg,
+   ret = regmap_read_poll_timeout(drv_data->bcast_regmap, status_reg,
  slice_status, !(slice_status & status),
  0, LLCC_STATUS_READ_DELAY);
return ret;
@@ -225,16 +227,13 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
int ret;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
-   u32 bcast_off = drv_data->bcast_off;
 
sz = drv_data->cfg_size;
llcc_table = drv_data->cfg;
 
for (i = 0; i < sz; i++) {
-   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);
+   attr1_cfg = LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);
+   attr0_cfg = LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);
 
attr1_val = llcc_table[i].cache_mode;
attr1_val |= llcc_table[i].probe_target_ways <<
@@ -259,10 +258,12 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
attr0_val = llcc_table[i].res_ways & ATTR0_RES_WAYS_MASK;
attr0_val |= llcc_table[i].bonus_ways << ATTR0_BONUS_WAYS_SHIFT;
 
-   ret = regmap_write(drv_data->regmap, attr1_cfg, attr1_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr1_cfg,
+   attr1_val);
if (ret)
return ret;
-   ret = regmap_write(drv_data->regmap, attr0_cfg, attr0_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr0_cfg,
+   attr0_val);
if (ret)
return ret;
if (llcc_table[i].activate_on_init) {
@@ -278,24 +279,36 @@ int qcom_llcc_probe(struct platform_device *pdev,
 {
u32 num_banks;
struct device *dev = >dev;
-   struct resource *res;
-   void __iomem *base;
+   struct resource *llcc_banks_res, *llcc_bcast_res;
+   void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
return -ENOMEM;
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_ioremap_resource(>dev, res);
-   if (IS_ERR(base))
-   return PTR_ERR(base);
+   llcc_banks_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+   "llcc_base");
+   llcc_banks_base = devm_ioremap_resource(>dev, llcc_banks_res);
+   if (IS_ERR(llcc_banks_base))
+   return PTR_ERR(llcc_banks_base);
 
-   drv_data->regmap = devm_regmap_init_mmio(dev, base,
-   _regmap_config);
+   drv_data->regmap = devm_regmap_init_mmio(dev, llcc_banks_base,
+

[PATCH v0 1/4] drivers: soc: Add broadcast base for Last Level Cache Controller (LLCC)

2018-07-25 Thread Venkata Narendra Kumar Gutta
Currently, boradcast base is set to end of the LLCC banks, which may
not be correct always. As the number of banks may vary for each chipset
and the broadcast base could be at a different address as well. This info
depends on the chipset, so get the broadcast base info from the device
tree (DT). Add broadcast base in LLCC driver and use this for broadcast
writes.

Signed-off-by: Venkata Narendra Kumar Gutta 
---
 drivers/soc/qcom/llcc-slice.c  | 55 +++---
 include/linux/soc/qcom/llcc-qcom.h |  4 +--
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c
index fcaad1a..a63640d 100644
--- a/drivers/soc/qcom/llcc-slice.c
+++ b/drivers/soc/qcom/llcc-slice.c
@@ -105,22 +105,24 @@ static int llcc_update_act_ctrl(u32 sid,
u32 slice_status;
int ret;
 
-   act_ctrl_reg = drv_data->bcast_off + LLCC_TRP_ACT_CTRLn(sid);
-   status_reg = drv_data->bcast_off + LLCC_TRP_STATUSn(sid);
+   act_ctrl_reg = LLCC_TRP_ACT_CTRLn(sid);
+   status_reg = LLCC_TRP_STATUSn(sid);
 
/* Set the ACTIVE trigger */
act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG;
-   ret = regmap_write(drv_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_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_data->regmap, act_ctrl_reg, act_ctrl_reg_val);
+   ret = regmap_write(drv_data->bcast_regmap, act_ctrl_reg,
+   act_ctrl_reg_val);
if (ret)
return ret;
 
-   ret = regmap_read_poll_timeout(drv_data->regmap, status_reg,
+   ret = regmap_read_poll_timeout(drv_data->bcast_regmap, status_reg,
  slice_status, !(slice_status & status),
  0, LLCC_STATUS_READ_DELAY);
return ret;
@@ -225,16 +227,13 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
int ret;
const struct llcc_slice_config *llcc_table;
struct llcc_slice_desc desc;
-   u32 bcast_off = drv_data->bcast_off;
 
sz = drv_data->cfg_size;
llcc_table = drv_data->cfg;
 
for (i = 0; i < sz; i++) {
-   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);
+   attr1_cfg = LLCC_TRP_ATTR1_CFGn(llcc_table[i].slice_id);
+   attr0_cfg = LLCC_TRP_ATTR0_CFGn(llcc_table[i].slice_id);
 
attr1_val = llcc_table[i].cache_mode;
attr1_val |= llcc_table[i].probe_target_ways <<
@@ -259,10 +258,12 @@ static int qcom_llcc_cfg_program(struct platform_device 
*pdev)
attr0_val = llcc_table[i].res_ways & ATTR0_RES_WAYS_MASK;
attr0_val |= llcc_table[i].bonus_ways << ATTR0_BONUS_WAYS_SHIFT;
 
-   ret = regmap_write(drv_data->regmap, attr1_cfg, attr1_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr1_cfg,
+   attr1_val);
if (ret)
return ret;
-   ret = regmap_write(drv_data->regmap, attr0_cfg, attr0_val);
+   ret = regmap_write(drv_data->bcast_regmap, attr0_cfg,
+   attr0_val);
if (ret)
return ret;
if (llcc_table[i].activate_on_init) {
@@ -278,24 +279,36 @@ int qcom_llcc_probe(struct platform_device *pdev,
 {
u32 num_banks;
struct device *dev = >dev;
-   struct resource *res;
-   void __iomem *base;
+   struct resource *llcc_banks_res, *llcc_bcast_res;
+   void __iomem *llcc_banks_base, *llcc_bcast_base;
int ret, i;
 
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
return -ENOMEM;
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_ioremap_resource(>dev, res);
-   if (IS_ERR(base))
-   return PTR_ERR(base);
+   llcc_banks_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+   "llcc_base");
+   llcc_banks_base = devm_ioremap_resource(>dev, llcc_banks_res);
+   if (IS_ERR(llcc_banks_base))
+   return PTR_ERR(llcc_banks_base);
 
-   drv_data->regmap = devm_regmap_init_mmio(dev, base,
-   _regmap_config);
+   drv_data->regmap = devm_regmap_init_mmio(dev, llcc_banks_base,
+

[PATCH v0 0/4] Add cache erp driver for Last Level Cache Controller (LLCC)

2018-07-25 Thread Venkata Narendra Kumar Gutta
This series implements cache erp driver for Last Level Cache Controller 
(LLCC). Cache erp driver is to detect and report single and double bit
errors on Last Level Cache Controller (LLCC) cache. This driver also takes
care of dumping registers and have config options to enable and disable
panic when these errors happen in LLCC.

The driver functionality is implemented in:
qcom_llcc_edac.c : This platform driver registers to edac framework and
handles the single and double bit errors in llcc cache by registering
interrupt handlers. 

llcc-slice.c: It invokes the llcc cache erp driver and passes platform
data to it. 

This patchset depends on the LLCC driver, which is yet to be merged.
Link: https://patchwork.kernel.org/patch/10422531/
Link: Link: 
http://lists-archives.com/linux-kernel/29157082-dt-bindings-documentation-for-qcom-llcc.html

Venkata Narendra Kumar Gutta (4):
  drivers: soc: Add broadcast base for Last Level Cache Controller
(LLCC)
  drivers: soc: Support to add cache erp driver for Last Level Cache
Controller (LLCC)
  drivers: edac: Add cache erp driver for Last Level Cache Controller
(LLCC)
  dt-bindigs: Update documentation of qcom,llcc

 .../devicetree/bindings/arm/msm/qcom,llcc.txt  |  41 ++
 drivers/edac/Kconfig   |  21 +
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_llcc_edac.c  | 523 +
 drivers/soc/qcom/llcc-slice.c  |  74 ++-
 include/linux/soc/qcom/llcc-qcom.h |   6 +-
 6 files changed, 640 insertions(+), 26 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
 create mode 100644 drivers/edac/qcom_llcc_edac.c

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v0 0/4] Add cache erp driver for Last Level Cache Controller (LLCC)

2018-07-25 Thread Venkata Narendra Kumar Gutta
This series implements cache erp driver for Last Level Cache Controller 
(LLCC). Cache erp driver is to detect and report single and double bit
errors on Last Level Cache Controller (LLCC) cache. This driver also takes
care of dumping registers and have config options to enable and disable
panic when these errors happen in LLCC.

The driver functionality is implemented in:
qcom_llcc_edac.c : This platform driver registers to edac framework and
handles the single and double bit errors in llcc cache by registering
interrupt handlers. 

llcc-slice.c: It invokes the llcc cache erp driver and passes platform
data to it. 

This patchset depends on the LLCC driver, which is yet to be merged.
Link: https://patchwork.kernel.org/patch/10422531/
Link: Link: 
http://lists-archives.com/linux-kernel/29157082-dt-bindings-documentation-for-qcom-llcc.html

Venkata Narendra Kumar Gutta (4):
  drivers: soc: Add broadcast base for Last Level Cache Controller
(LLCC)
  drivers: soc: Support to add cache erp driver for Last Level Cache
Controller (LLCC)
  drivers: edac: Add cache erp driver for Last Level Cache Controller
(LLCC)
  dt-bindigs: Update documentation of qcom,llcc

 .../devicetree/bindings/arm/msm/qcom,llcc.txt  |  41 ++
 drivers/edac/Kconfig   |  21 +
 drivers/edac/Makefile  |   1 +
 drivers/edac/qcom_llcc_edac.c  | 523 +
 drivers/soc/qcom/llcc-slice.c  |  74 ++-
 include/linux/soc/qcom/llcc-qcom.h |   6 +-
 6 files changed, 640 insertions(+), 26 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
 create mode 100644 drivers/edac/qcom_llcc_edac.c

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH] ARM64: smp: Fix cpu_up() racing with sys_reboot

2018-07-19 Thread Venkata Narendra Kumar Gutta
Nothing stops a process from hotplugging in a CPU concurrently
with a sys_reboot() call. In such a situation we could have
ipi_cpu_stop() mark a cpu as 'offline' and _cpu_up() ignore the
fact that the CPU is not really offline and call the
CPU_UP_PREPARE notifier. When this happens stop_machine code will
complain that the cpu thread already exists and BUG_ON().

CPU0  CPU1

 sys_reboot()
 kernel_restart()
 machine_restart()
 machine_shutdown()
 smp_send_stop()
 ...   ipi_cpu_stop()
   set_cpu_online(1, false)
   local_irq_disable()
   while(1)

 cpu_up()
 _cpu_up()
 if (!cpu_online(1))
 __cpu_notify(CPU_UP_PREPARE...)

 cpu_stop_cpu_callback()
 BUG_ON(stopper->thread)

This is easily reproducible by hotplugging in and out in a tight
loop while also rebooting.

Since the CPU is not really offline and hasn't gone through the
proper steps to be marked as such, let's mark the CPU as inactive.
This is just as easily testable as online and avoids any possibility
of _cpu_up() trying to bring the CPU back online when it never was
offline to begin with. Based on the similar patchset by for arm
targets 040c163( "ARM: smp: Fix cpu_up() racing with sys_reboot)"

Signed-off-by: Abhimanyu Kapur 
Signed-off-by: Venkata Narendra Kumar Gutta 
---
 arch/arm64/kernel/smp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 2faa986..adee4d3 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -790,7 +790,7 @@ void arch_irq_work_raise(void)
  */
 static void ipi_cpu_stop(unsigned int cpu)
 {
-   set_cpu_online(cpu, false);
+   set_cpu_active(cpu, false);
 
local_daif_mask();
sdei_mask_local_cpu();
@@ -925,10 +925,10 @@ void smp_send_stop(void)
 
/* Wait up to one second for other CPUs to stop */
timeout = USEC_PER_SEC;
-   while (num_online_cpus() > 1 && timeout--)
+   while (num_active_cpus() > 1 && timeout--)
udelay(1);
 
-   if (num_online_cpus() > 1)
+   if (num_active_cpus() > 1)
pr_warning("SMP: failed to stop secondary CPUs %*pbl\n",
   cpumask_pr_args(cpu_online_mask));
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH] ARM64: smp: Fix cpu_up() racing with sys_reboot

2018-07-19 Thread Venkata Narendra Kumar Gutta
Nothing stops a process from hotplugging in a CPU concurrently
with a sys_reboot() call. In such a situation we could have
ipi_cpu_stop() mark a cpu as 'offline' and _cpu_up() ignore the
fact that the CPU is not really offline and call the
CPU_UP_PREPARE notifier. When this happens stop_machine code will
complain that the cpu thread already exists and BUG_ON().

CPU0  CPU1

 sys_reboot()
 kernel_restart()
 machine_restart()
 machine_shutdown()
 smp_send_stop()
 ...   ipi_cpu_stop()
   set_cpu_online(1, false)
   local_irq_disable()
   while(1)

 cpu_up()
 _cpu_up()
 if (!cpu_online(1))
 __cpu_notify(CPU_UP_PREPARE...)

 cpu_stop_cpu_callback()
 BUG_ON(stopper->thread)

This is easily reproducible by hotplugging in and out in a tight
loop while also rebooting.

Since the CPU is not really offline and hasn't gone through the
proper steps to be marked as such, let's mark the CPU as inactive.
This is just as easily testable as online and avoids any possibility
of _cpu_up() trying to bring the CPU back online when it never was
offline to begin with. Based on the similar patchset by for arm
targets 040c163( "ARM: smp: Fix cpu_up() racing with sys_reboot)"

Signed-off-by: Abhimanyu Kapur 
Signed-off-by: Venkata Narendra Kumar Gutta 
---
 arch/arm64/kernel/smp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 2faa986..adee4d3 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -790,7 +790,7 @@ void arch_irq_work_raise(void)
  */
 static void ipi_cpu_stop(unsigned int cpu)
 {
-   set_cpu_online(cpu, false);
+   set_cpu_active(cpu, false);
 
local_daif_mask();
sdei_mask_local_cpu();
@@ -925,10 +925,10 @@ void smp_send_stop(void)
 
/* Wait up to one second for other CPUs to stop */
timeout = USEC_PER_SEC;
-   while (num_online_cpus() > 1 && timeout--)
+   while (num_active_cpus() > 1 && timeout--)
udelay(1);
 
-   if (num_online_cpus() > 1)
+   if (num_active_cpus() > 1)
pr_warning("SMP: failed to stop secondary CPUs %*pbl\n",
   cpumask_pr_args(cpu_online_mask));
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH] ARM64: smp: BUG() if smp_send_reschedule() is called for an offline cpu

2018-07-19 Thread Venkata Narendra Kumar Gutta
Based on the 'commit <8b775be35e41b9f> ("ARM: smp:
BUG() if smp_send_reschedule() is called for an offline cpu")'

Sending an IPI_RESCHEDULE to an offline CPU is incorrect and potentially
bad for both power and stability. On some sub-architectures such as MSM,
if a power-collapsed CPU is unexpectedly woken up by an IPI, it will be
begin executing without the preparations that would normally happen as
part of CPU_UP_PREPARE. If clocks, voltage regulators, or other hardware
configuration are not performed, the booting CPU may cause general
instability or (at best) poor power performance since the CPU would be
powered up but not utilized.

One common cause for such issues is misuse of add_timer_on() or APIs
such as queue_work_on() which call it. If proper precautions are not
taken to block hotplug while these APIs are called then a race may
result in IPIs being sent to CPUs that are already offline.

This same argument could be applied to other IPIs (with the exception
of IPI_WAKEUP), but the others are already restricted to only online
CPUs by existing mechanisms, so an explicit assertion is not useful.

Signed-off-by: Matt Wagantall 
Signed-off-by: Trilok Soni 
Signed-off-by: Venkata Narendra Kumar Gutta 
---
 arch/arm64/kernel/smp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 2faa986..5e39030 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -898,6 +898,7 @@ void handle_IPI(int ipinr, struct pt_regs *regs)
 
 void smp_send_reschedule(int cpu)
 {
+   BUG_ON(cpu_is_offline(cpu));
smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE);
 }
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH] ARM64: smp: BUG() if smp_send_reschedule() is called for an offline cpu

2018-07-19 Thread Venkata Narendra Kumar Gutta
Based on the 'commit <8b775be35e41b9f> ("ARM: smp:
BUG() if smp_send_reschedule() is called for an offline cpu")'

Sending an IPI_RESCHEDULE to an offline CPU is incorrect and potentially
bad for both power and stability. On some sub-architectures such as MSM,
if a power-collapsed CPU is unexpectedly woken up by an IPI, it will be
begin executing without the preparations that would normally happen as
part of CPU_UP_PREPARE. If clocks, voltage regulators, or other hardware
configuration are not performed, the booting CPU may cause general
instability or (at best) poor power performance since the CPU would be
powered up but not utilized.

One common cause for such issues is misuse of add_timer_on() or APIs
such as queue_work_on() which call it. If proper precautions are not
taken to block hotplug while these APIs are called then a race may
result in IPIs being sent to CPUs that are already offline.

This same argument could be applied to other IPIs (with the exception
of IPI_WAKEUP), but the others are already restricted to only online
CPUs by existing mechanisms, so an explicit assertion is not useful.

Signed-off-by: Matt Wagantall 
Signed-off-by: Trilok Soni 
Signed-off-by: Venkata Narendra Kumar Gutta 
---
 arch/arm64/kernel/smp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 2faa986..5e39030 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -898,6 +898,7 @@ void handle_IPI(int ipinr, struct pt_regs *regs)
 
 void smp_send_reschedule(int cpu)
 {
+   BUG_ON(cpu_is_offline(cpu));
smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE);
 }
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project