Add the QAD, ctitrigger and bootconfig support for dcc driver.
The QAD is used for access control of the DCC configurations
and can be set or unset by writing to DCC_QAD_OUTPUT register.
The Cti-trigger is used for the cross trigger interface, on
enabling it the software trigger can be initiated for dcc by
setting the cti-trigout.
Bootconfig support for DCC is for configuring register values
to dcc at boot time, this is needed for debugging crashes that
happen at boot time.
Add the debugfs files QAD and CTI-trigger for each list folder.
Also add hwtrigger debugfs file which needs to be disabled on
enabling the cti-trigger.
Signed-off-by: Souradeep Chowdhury <quic_schowdhu@xxxxxxxxxxx>
---
Documentation/ABI/testing/debugfs-driver-dcc | 24 +++
drivers/soc/qcom/dcc.c | 284 ++++++++++++++++++++++++++-
2 files changed, 304 insertions(+), 4 deletions(-)
diff --git a/Documentation/ABI/testing/debugfs-driver-dcc b/Documentation/ABI/testing/debugfs-driver-dcc
index 27ed591..f817a9f 100644
--- a/Documentation/ABI/testing/debugfs-driver-dcc
+++ b/Documentation/ABI/testing/debugfs-driver-dcc
@@ -125,3 +125,27 @@ Description:
on manual or crash induced triggers. Lists must
be configured and enabled sequentially, e.g. list
2 can only be enabled when list 1 have so.
+
+What: /sys/kernel/debug/dcc/.../[list-number]/ctitrigger
+Date: January 2023
+Contact: Souradeep Chowdhury <quic_schowdhu@xxxxxxxxxxx>
+Description:
+ This debugfs interface is used for enabling the
+ ctitrigger. Ctitrigger can be enabled by writing
+ a '1' to the file.
+
+What: /sys/kernel/debug/dcc/.../[list-number]/QAD
+Date: January 2023
+Contact: Souradeep Chowdhury <quic_schowdhu@xxxxxxxxxxx>
+Description:
+ This debugfs interface is used for enabling the
+ ctitrigger. Ctitrigger can be enabled by writing
+ a '1' to the file.
+
+What: /sys/kernel/debug/dcc/.../[list-number]/hwtrigger
+Date: January 2023
+Contact: Souradeep Chowdhury <quic_schowdhu@xxxxxxxxxxx>
+Description:
+ This debugfs interface is used for enabling the
+ hwtrigger support. Hwtrigger can be enabled by
+ writing a '1' to the file.
diff --git a/drivers/soc/qcom/dcc.c b/drivers/soc/qcom/dcc.c
index 5b50d63..ea44dbf 100644
--- a/drivers/soc/qcom/dcc.c
+++ b/drivers/soc/qcom/dcc.c
@@ -6,6 +6,7 @@
#include <linux/bitfield.h>
#include <linux/bitops.h>
+#include <linux/bootconfig.h>
#include <linux/debugfs.h>
#include <linux/delay.h>
#include <linux/fs.h>
@@ -36,6 +37,8 @@
#define DCC_LL_INT_STATUS 0x1c
#define DCC_LL_SW_TRIGGER 0x2c
#define DCC_LL_BUS_ACCESS_STATUS 0x30
+#define DCC_CTI_TRIG 0x34
+#define DCC_QAD_OUTPUT 0x38
/* Default value used if a bit 6 in the HW_INFO register is set. */
#define DCC_FIX_LOOP_OFFSET 16
@@ -114,6 +117,9 @@ struct dcc_config_entry {
* @nr_link_list: Total number of linkedlists supported by the DCC configuration
* @loop_shift: Loop offset bits range for the addresses
* @enable_bitmap: Bitmap to capture the enabled status of each linked list of addresses
+ * @cti_bitmap: Bitmap to capture the cti-trigger status of each linked list of addresses
+ * @qad_bitmap: Bitmap to capture the qad status of each linked list of addresses
+ * @hwtrig_bitmap: Bitmap to capture the hwtrig status of each linked list of addresses
*/
struct dcc_drvdata {
void __iomem *base;
@@ -131,6 +137,9 @@ struct dcc_drvdata {
size_t nr_link_list;
u8 loop_shift;
unsigned long *enable_bitmap;
+ unsigned long *cti_bitmap;
+ unsigned long *qad_bitmap;
+ unsigned long *hwtrig_bitmap;
};
struct dcc_cfg_attr {
@@ -148,6 +157,18 @@ struct dcc_cfg_loop_attr {
bool loop_start;
};
+static char *replace_char(char *str, char find, char replace)
+{
+ char *current_pos = strchr(str, find);
+
+ while (current_pos) {
+ *current_pos = replace;
+ current_pos = strchr(current_pos, find);
+ }
+
+ return str;
+}
+
static inline u32 dcc_list_offset(int version)
{
return version == 1 ? 0x1c : version == 2 ? 0x2c : 0x34;
@@ -201,6 +222,10 @@ static int dcc_sw_trigger(struct dcc_drvdata *drvdata)
continue;
ll_cfg = dcc_list_readl(drvdata, i, DCC_LL_CFG);
tmp_ll_cfg = ll_cfg & ~DCC_TRIGGER_MASK;
+ if (drvdata->mem_map_ver != 3)
+ tmp_ll_cfg = ll_cfg & ~DCC_TRIGGER_MASK;
+ else
+ tmp_ll_cfg = ll_cfg & ~BIT(8);
dcc_list_writel(drvdata, tmp_ll_cfg, i, DCC_LL_CFG);
dcc_list_writel(drvdata, 1, i, DCC_LL_SW_TRIGGER);
dcc_list_writel(drvdata, ll_cfg, i, DCC_LL_CFG);
@@ -577,6 +602,25 @@ static int dcc_enable(struct dcc_drvdata *drvdata, unsigned int curr_list)
/* 5. Configure trigger */
dcc_list_writel(drvdata, DCC_TRIGGER_MASK,
curr_list, DCC_LL_CFG);
+ if (drvdata->mem_map_ver == 3) {
+ dcc_list_writel(drvdata, test_bit(curr_list, drvdata->qad_bitmap), curr_list,
+ DCC_QAD_OUTPUT);
+ dcc_list_writel(drvdata, test_bit(curr_list, drvdata->cti_bitmap), curr_list,
+ DCC_CTI_TRIG);
+ if (test_bit(curr_list, drvdata->hwtrig_bitmap))
+ dcc_list_writel(drvdata, BIT(8), curr_list, DCC_LL_CFG);
+ else
+ dcc_list_writel(drvdata, (unsigned int)~BIT(8), curr_list, DCC_LL_CFG);
+ } else {
+ if (test_bit(curr_list, drvdata->hwtrig_bitmap))
+ dcc_list_writel(drvdata, DCC_TRIGGER_MASK |
+ test_bit(curr_list, drvdata->cti_bitmap) << 8,
+ curr_list, DCC_LL_CFG);
+ else
+ dcc_list_writel(drvdata, ~DCC_TRIGGER_MASK &
+ test_bit(curr_list, drvdata->cti_bitmap) << 8,
+ curr_list, DCC_LL_CFG);
+ }
out_unlock:
mutex_unlock(&drvdata->mutex);
@@ -1103,6 +1147,168 @@ static const struct file_operations config_fops = {
.release = single_release,
};
+static ssize_t ctitrigger_read(struct file *filp, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ char *buf;
+ int curr_list;
+ struct dcc_drvdata *drvdata = filp->private_data;
+
+ curr_list = dcc_filp_curr_list(filp);
+
+ mutex_lock(&drvdata->mutex);
+
+ if (test_bit(curr_list, drvdata->cti_bitmap))
+ buf = "Y\n";
+ else
+ buf = "N\n";
+
+ mutex_unlock(&drvdata->mutex);
+
+ return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
+}
+
+static ssize_t ctitrigger_write(struct file *filp, const char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ int ret = 0, curr_list;
+ bool val;
+ struct dcc_drvdata *drvdata = filp->private_data;
+
+ curr_list = dcc_filp_curr_list(filp);
+
+ if (test_bit(curr_list, drvdata->enable_bitmap))
+ return -EBUSY;
+
+ ret = kstrtobool_from_user(userbuf, count, &val);
+ if (ret < 0)
+ return 0;
+
+ if (val)
+ set_bit(curr_list, drvdata->cti_bitmap);
+ else
+ clear_bit(curr_list, drvdata->cti_bitmap);
+
+ return count;
+}
+
+static const struct file_operations ctitrigger_fops = {
+ .read = ctitrigger_read,
+ .write = ctitrigger_write,
+ .open = simple_open,
+ .llseek = generic_file_llseek,
+};
+
+static ssize_t qad_read(struct file *filp, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ char *buf;
+ int curr_list;
+
+ struct dcc_drvdata *drvdata = filp->private_data;
+
+ curr_list = dcc_filp_curr_list(filp);
+
+ mutex_lock(&drvdata->mutex);
+
+ if (test_bit(curr_list, drvdata->qad_bitmap))
+ buf = "Y\n";
+ else
+ buf = "N\n";
+
+ mutex_unlock(&drvdata->mutex);
+
+ return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
+}
+
+static ssize_t qad_write(struct file *filp, const char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ int ret = 0, curr_list;