[PATCH V1] soc: qcom: smp2p: Introduce tracepoint support

2024-04-29 Thread Sudeepgoud Patil
Introduce tracepoint support for smp2p providing useful logging
for communication between clients.

Signed-off-by: Sudeepgoud Patil 
Signed-off-by: Deepak Kumar Singh 
---
 drivers/soc/qcom/Makefile  |  1 +
 drivers/soc/qcom/smp2p.c   | 10 
 drivers/soc/qcom/trace-smp2p.h | 99 ++
 3 files changed, 110 insertions(+)
 create mode 100644 drivers/soc/qcom/trace-smp2p.h

diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index ca0bece0dfff..30c1bf645501 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -23,6 +23,7 @@ qcom_rpmh-y   += rpmh.o
 obj-$(CONFIG_QCOM_SMD_RPM) += rpm-proc.o smd-rpm.o
 obj-$(CONFIG_QCOM_SMEM) += smem.o
 obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o
+CFLAGS_smp2p.o := -I$(src)
 obj-$(CONFIG_QCOM_SMP2P)   += smp2p.o
 obj-$(CONFIG_QCOM_SMSM)+= smsm.o
 obj-$(CONFIG_QCOM_SOCINFO) += socinfo.o
diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
index a21241cbeec7..dde8513641ae 100644
--- a/drivers/soc/qcom/smp2p.c
+++ b/drivers/soc/qcom/smp2p.c
@@ -20,6 +20,9 @@
 #include 
 #include 
 
+#define CREATE_TRACE_POINTS
+#include "trace-smp2p.h"
+
 /*
  * The Shared Memory Point to Point (SMP2P) protocol facilitates communication
  * of a single 32-bit value between two processors.  Each value has a single
@@ -191,6 +194,7 @@ static void qcom_smp2p_do_ssr_ack(struct qcom_smp2p *smp2p)
struct smp2p_smem_item *out = smp2p->out;
u32 val;
 
+   trace_smp2p_ssr_ack(smp2p->remote_pid);
smp2p->ssr_ack = !smp2p->ssr_ack;
 
val = out->flags & ~BIT(SMP2P_FLAGS_RESTART_ACK_BIT);
@@ -213,6 +217,7 @@ static void qcom_smp2p_negotiate(struct qcom_smp2p *smp2p)
smp2p->ssr_ack_enabled = true;
 
smp2p->negotiation_done = true;
+   trace_smp2p_negotiate(smp2p->remote_pid, 
smp2p->ssr_ack_enabled);
}
 }
 
@@ -251,6 +256,8 @@ static void qcom_smp2p_notify_in(struct qcom_smp2p *smp2p)
status = val ^ entry->last_value;
entry->last_value = val;
 
+   trace_smp2p_notify_in(smp2p->remote_pid, entry->name, status, 
val);
+
/* No changes of this entry? */
if (!status)
continue;
@@ -406,6 +413,9 @@ static int smp2p_update_bits(void *data, u32 mask, u32 
value)
writel(val, entry->value);
spin_unlock_irqrestore(&entry->lock, flags);
 
+   trace_smp2p_update_bits(entry->smp2p->remote_pid,
+   entry->name, orig, val);
+
if (val != orig)
qcom_smp2p_kick(entry->smp2p);
 
diff --git a/drivers/soc/qcom/trace-smp2p.h b/drivers/soc/qcom/trace-smp2p.h
new file mode 100644
index ..c61afab23f0c
--- /dev/null
+++ b/drivers/soc/qcom/trace-smp2p.h
@@ -0,0 +1,99 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM qcom_smp2p
+
+#if !defined(__QCOM_SMP2P_TRACE_H__) || defined(TRACE_HEADER_MULTI_READ)
+#define __QCOM_SMP2P_TRACE_H__
+
+#include 
+
+TRACE_EVENT(smp2p_ssr_ack,
+   TP_PROTO(unsigned int remote_pid),
+   TP_ARGS(remote_pid),
+   TP_STRUCT__entry(
+   __field(u32, remote_pid)
+   ),
+   TP_fast_assign(
+   __entry->remote_pid = remote_pid;
+   ),
+   TP_printk("%d: SSR detected, doing SSR Handshake",
+   __entry->remote_pid
+   )
+);
+
+TRACE_EVENT(smp2p_negotiate,
+   TP_PROTO(unsigned int remote_pid, bool ssr_ack_enabled),
+   TP_ARGS(remote_pid, ssr_ack_enabled),
+   TP_STRUCT__entry(
+   __field(u32, remote_pid)
+   __field(bool, ssr_ack_enabled)
+   ),
+   TP_fast_assign(
+   __entry->remote_pid = remote_pid;
+   __entry->ssr_ack_enabled = ssr_ack_enabled;
+   ),
+   TP_printk("%d: state=open ssr_ack=%d",
+   __entry->remote_pid,
+   __entry->ssr_ack_enabled
+   )
+);
+
+TRACE_EVENT(smp2p_notify_in,
+   TP_PROTO(unsigned int remote_pid, const char *name, unsigned long 
status, u32 val),
+   TP_ARGS(remote_pid, name, status, val),
+   TP_STRUCT__entry(
+   __field(u32, remote_pid)
+   __string(name, name)
+   __field(unsigned long, status)
+   __field(u32, val)
+   ),
+   TP_fast_assign(
+   __entry->remote_pid = remote_pid;
+   __assign_str(name, name);
+   __entry->status = status;
+   __entry->val = val;
+   ),
+   TP_printk("%d: %s: status:0x%0lx val:0x%0x",
+   __entry->remote_pid,
+   __get_str(name),
+   __entry->status,
+   

[PATCH V2 0/2] Add tracepoint support and remote name mapping to smp2p

2024-06-11 Thread Sudeepgoud Patil
This commit introduces tracepoint support to smp2p module, enabling logging of 
communication
events between local and remote processors. The tracepoints capture essential 
details
such as remote processor ID, subsystem names, negotiation specifics, supported 
features,
bit changes, and subsystem restart (SSR) activity.
These tracepoints enhance debugging capabilities for inter-subsystem issues.

Addressing feedback from v1 to map remote PID (Process ID) along with the 
remote name
in tracepoints added new patch in V2 1/2, adding support to include the remote 
name
in the smp2p irq devname which fetches remote name from respective smp2p dtsi 
node,
which also makes the wakeup source distinguishable in irq wakeup prints.

Changes in v2:
- Added support to include the remote name in the smp2p IRQ devname, allowing 
for remote PID-name mapping
- Mapped the remote PID (Process ID) along with the remote name in tracepoints, 
as suggested by Chris
- Modified to capture all `out->features` instead of just the `ssr_ack`, 
following Chris's recommendation
- Expanded the commit description to provide additional context
- Link to v1: 
https://lore.kernel.org/all/20240429075528.1723133-1-quic_sudee...@quicinc.com

Sudeepgoud Patil (2):
  soc: qcom: smp2p: Add remote name into smp2p irq devname
  soc: qcom: smp2p: Introduce tracepoint support

 drivers/soc/qcom/Makefile  |   1 +
 drivers/soc/qcom/smp2p.c   |  26 +++-
 drivers/soc/qcom/trace-smp2p.h | 116 +
 3 files changed, 142 insertions(+), 1 deletion(-)
 create mode 100644 drivers/soc/qcom/trace-smp2p.h

-- 




[PATCH V2 1/2] soc: qcom: smp2p: Add remote name into smp2p irq devname

2024-06-11 Thread Sudeepgoud Patil
Add smp2p irq devname which fetches remote name from respective
smp2p dtsi node, which makes the wakeup source distinguishable
in irq wakeup prints.

Signed-off-by: Sudeepgoud Patil 
---
 drivers/soc/qcom/smp2p.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
index a21241cbeec7..a77fee048b38 100644
--- a/drivers/soc/qcom/smp2p.c
+++ b/drivers/soc/qcom/smp2p.c
@@ -122,6 +122,7 @@ struct smp2p_entry {
  * @ssr_ack_enabled: SMP2P_FEATURE_SSR_ACK feature is supported and was enabled
  * @ssr_ack: current cached state of the local ack bit
  * @negotiation_done: whether negotiating finished
+ * @irq_devname: poniter to the smp2p irq devname
  * @local_pid: processor id of the inbound edge
  * @remote_pid:processor id of the outbound edge
  * @ipc_regmap:regmap for the outbound ipc
@@ -146,6 +147,7 @@ struct qcom_smp2p {
bool ssr_ack;
bool negotiation_done;
 
+   char *irq_devname;
unsigned local_pid;
unsigned remote_pid;
 
@@ -614,10 +616,16 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
/* Kick the outgoing edge after allocating entries */
qcom_smp2p_kick(smp2p);
 
+   smp2p->irq_devname = kasprintf(GFP_KERNEL, "%s", 
pdev->dev.of_node->name);
+   if (!smp2p->irq_devname) {
+   ret = -ENOMEM;
+   goto unwind_interfaces;
+   }
+
ret = devm_request_threaded_irq(&pdev->dev, irq,
NULL, qcom_smp2p_intr,
IRQF_ONESHOT,
-   "smp2p", (void *)smp2p);
+   smp2p->irq_devname, (void *)smp2p);
if (ret) {
dev_err(&pdev->dev, "failed to request interrupt\n");
goto unwind_interfaces;
@@ -650,6 +658,8 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
list_for_each_entry(entry, &smp2p->outbound, node)
qcom_smem_state_unregister(entry->state);
 
+   kfree(smp2p->irq_devname);
+
smp2p->out->valid_entries = 0;
 
 release_mbox:
@@ -677,6 +687,8 @@ static void qcom_smp2p_remove(struct platform_device *pdev)
 
mbox_free_channel(smp2p->mbox_chan);
 
+   kfree(smp2p->irq_devname);
+
smp2p->out->valid_entries = 0;
 }
 
-- 




[PATCH V2 2/2] soc: qcom: smp2p: Introduce tracepoint support

2024-06-11 Thread Sudeepgoud Patil
This commit introduces tracepoint support for smp2p,
enabling logging of communication between local and remote processors.
The tracepoints include information about the remote processor ID,
remote subsystem name, negotiation details, supported features,
bit change notifications, and ssr activity.
These tracepoints are valuable for debugging issues between subsystems.

Signed-off-by: Sudeepgoud Patil 
---
 drivers/soc/qcom/Makefile  |   1 +
 drivers/soc/qcom/smp2p.c   |  12 
 drivers/soc/qcom/trace-smp2p.h | 116 +
 3 files changed, 129 insertions(+)
 create mode 100644 drivers/soc/qcom/trace-smp2p.h

diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index ca0bece0dfff..30c1bf645501 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -23,6 +23,7 @@ qcom_rpmh-y   += rpmh.o
 obj-$(CONFIG_QCOM_SMD_RPM) += rpm-proc.o smd-rpm.o
 obj-$(CONFIG_QCOM_SMEM) += smem.o
 obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o
+CFLAGS_smp2p.o := -I$(src)
 obj-$(CONFIG_QCOM_SMP2P)   += smp2p.o
 obj-$(CONFIG_QCOM_SMSM)+= smsm.o
 obj-$(CONFIG_QCOM_SOCINFO) += socinfo.o
diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
index a77fee048b38..6eab8ff55691 100644
--- a/drivers/soc/qcom/smp2p.c
+++ b/drivers/soc/qcom/smp2p.c
@@ -20,6 +20,9 @@
 #include 
 #include 
 
+#define CREATE_TRACE_POINTS
+#include "trace-smp2p.h"
+
 /*
  * The Shared Memory Point to Point (SMP2P) protocol facilitates communication
  * of a single 32-bit value between two processors.  Each value has a single
@@ -193,6 +196,7 @@ static void qcom_smp2p_do_ssr_ack(struct qcom_smp2p *smp2p)
struct smp2p_smem_item *out = smp2p->out;
u32 val;
 
+   trace_smp2p_ssr_ack(smp2p->remote_pid, smp2p->irq_devname);
smp2p->ssr_ack = !smp2p->ssr_ack;
 
val = out->flags & ~BIT(SMP2P_FLAGS_RESTART_ACK_BIT);
@@ -215,6 +219,8 @@ static void qcom_smp2p_negotiate(struct qcom_smp2p *smp2p)
smp2p->ssr_ack_enabled = true;
 
smp2p->negotiation_done = true;
+   trace_smp2p_negotiate(smp2p->remote_pid, smp2p->irq_devname,
+   out->features);
}
 }
 
@@ -253,6 +259,9 @@ static void qcom_smp2p_notify_in(struct qcom_smp2p *smp2p)
status = val ^ entry->last_value;
entry->last_value = val;
 
+   trace_smp2p_notify_in(smp2p->remote_pid, smp2p->irq_devname,
+   entry->name, status, val);
+
/* No changes of this entry? */
if (!status)
continue;
@@ -408,6 +417,9 @@ static int smp2p_update_bits(void *data, u32 mask, u32 
value)
writel(val, entry->value);
spin_unlock_irqrestore(&entry->lock, flags);
 
+   trace_smp2p_update_bits(entry->smp2p->remote_pid, 
entry->smp2p->irq_devname,
+   entry->name, orig, val);
+
if (val != orig)
qcom_smp2p_kick(entry->smp2p);
 
diff --git a/drivers/soc/qcom/trace-smp2p.h b/drivers/soc/qcom/trace-smp2p.h
new file mode 100644
index ..833782460b57
--- /dev/null
+++ b/drivers/soc/qcom/trace-smp2p.h
@@ -0,0 +1,116 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM qcom_smp2p
+
+#if !defined(__QCOM_SMP2P_TRACE_H__) || defined(TRACE_HEADER_MULTI_READ)
+#define __QCOM_SMP2P_TRACE_H__
+
+#include 
+
+#define SMP2P_FEATURE_SSR_ACK 0x1
+
+TRACE_EVENT(smp2p_ssr_ack,
+   TP_PROTO(unsigned int remote_pid, char *irq_devname),
+   TP_ARGS(remote_pid, irq_devname),
+   TP_STRUCT__entry(
+   __field(u32, remote_pid)
+   __string(irq_devname, irq_devname)
+   ),
+   TP_fast_assign(
+   __entry->remote_pid = remote_pid;
+   __assign_str(irq_devname, irq_devname);
+   ),
+   TP_printk("%d: %s: SSR detected, doing SSR Handshake",
+   __entry->remote_pid,
+   __get_str(irq_devname)
+   )
+);
+
+TRACE_EVENT(smp2p_negotiate,
+   TP_PROTO(unsigned int remote_pid, char *irq_devname, unsigned int 
features),
+   TP_ARGS(remote_pid, irq_devname, features),
+   TP_STRUCT__entry(
+   __field(u32, remote_pid)
+   __string(irq_devname, irq_devname)
+   __field(u32, out_features)
+   ),
+   TP_fast_assign(
+   __entry->remote_pid = remote_pid;
+   __assign_str(irq_devname, irq_devname);
+   __entry->out_features = features;
+   ),
+   TP_printk("%d: %s: state=open out_features=%s",
+   __entry->remote_pid,
+   __get_str(irq_devname),
+   __print_flags(__entry->out_featu

[PATCH V3 0/2] Use of devname for interrupt descriptions and tracepoint support for smp2p

2024-06-27 Thread Sudeepgoud Patil
This commit enhances the smp2p driver by adding support for using the device
name in interrupt descriptions and introducing tracepoint functionality.
These improvements facilitate more effective debugging of smp2p-related issues.

The devname patch, along with the callback to print the irq chip name as the
device name and the removal of the ‘smp2p’ string from the irq request,
results in a unique interrupt description.

Tracepoint functionality captures essential details such as subsystem name,
negotiation specifics, supported features, bit changes, and subsystem restart
activity. These enhancements significantly improve debugging capabilities
for inter-subsystem issues.

Changes in v3:
- Updated patch to use devname for interrupt descriptions with a different 
approach.
- Modified tracepoint patch by removing remote_pid field from all tracepoints.
- Using SMP2P_FEATURE_SSR_ACK definition from smp2p.c instead of redefiniton. 
- Link to v2: 
https://lore.kernel.org/all/20240611123351.3813190-1-quic_sudee...@quicinc.com

Changes in v2:
- Added support to include the remote name in the smp2p IRQ devname, allowing 
for remote PID-name mapping
- Mapped the remote PID (Process ID) along with the remote name in tracepoints, 
as suggested by Chris
- Modified to capture all `out->features` instead of just the `ssr_ack`, 
following Chris's recommendation
- Expanded the commit description to provide additional context
- Link to v1: 
https://lore.kernel.org/all/20240429075528.1723133-1-quic_sudee...@quicinc.com

Chris Lew (1):
  soc: qcom: smp2p: Use devname for interrupt descriptions

Sudeepgoud Patil (1):
  soc: qcom: smp2p: Introduce tracepoint support

 drivers/soc/qcom/Makefile  |  1 +
 drivers/soc/qcom/smp2p.c   | 20 ++-
 drivers/soc/qcom/trace-smp2p.h | 98 ++
 3 files changed, 118 insertions(+), 1 deletion(-)
 create mode 100644 drivers/soc/qcom/trace-smp2p.h

-- 




[PATCH V3 1/2] soc: qcom: smp2p: Use devname for interrupt descriptions

2024-06-27 Thread Sudeepgoud Patil
From: Chris Lew 

When using /proc/interrupts to collect statistics on smp2p interrupt
counts, it is hard to distinguish the different instances of smp2p from
each other. For example to debug a processor boot issue, the ready and
handover interrupts are checked for sanity to ensure the firmware
reached a specific initialization stage.

Remove "smp2p" string from the irq request so that the irq will default
to the device name. Add an .irq_print_chip() callback to print the irq
chip name as the device name. These two changes allow for a unique name
to be used in /proc/interrupts as shown below.

/ # cat /proc/interrupts | grep smp2p
 18:  ...  ipcc 196610 Edge  smp2p-adsp
 20:  ...  ipcc 131074 Edge  smp2p-modem
170:  ...  smp2p-modem   1 Edge  q6v5 ready
178:  ...  smp2p-adsp   1 Edge  q6v5 ready

Signed-off-by: Chris Lew 
---
 drivers/soc/qcom/smp2p.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
index a21241cbeec7..696c2a8387d0 100644
--- a/drivers/soc/qcom/smp2p.c
+++ b/drivers/soc/qcom/smp2p.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -353,11 +354,19 @@ static int smp2p_set_irq_type(struct irq_data *irqd, 
unsigned int type)
return 0;
 }
 
+static void smp2p_irq_print_chip(struct irq_data *irqd, struct seq_file *p)
+{
+   struct smp2p_entry *entry = irq_data_get_irq_chip_data(irqd);
+
+   seq_printf(p, " %8s", dev_name(entry->smp2p->dev));
+}
+
 static struct irq_chip smp2p_irq_chip = {
.name   = "smp2p",
.irq_mask   = smp2p_mask_irq,
.irq_unmask = smp2p_unmask_irq,
.irq_set_type   = smp2p_set_irq_type,
+   .irq_print_chip = smp2p_irq_print_chip,
 };
 
 static int smp2p_irq_map(struct irq_domain *d,
@@ -617,7 +626,7 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
ret = devm_request_threaded_irq(&pdev->dev, irq,
NULL, qcom_smp2p_intr,
IRQF_ONESHOT,
-   "smp2p", (void *)smp2p);
+   NULL, (void *)smp2p);
if (ret) {
dev_err(&pdev->dev, "failed to request interrupt\n");
goto unwind_interfaces;
-- 




[PATCH V3 2/2] soc: qcom: smp2p: Introduce tracepoint support

2024-06-27 Thread Sudeepgoud Patil
This commit introduces tracepoint support for smp2p, enabling
logging of communication between local and remote processors.
These tracepoints include information about the remote subsystem
name, negotiation details, supported features, bit change
notifications, and ssr activity. These logs are useful for
debugging issues between subsystems.

Signed-off-by: Sudeepgoud Patil 
---
 drivers/soc/qcom/Makefile  |  1 +
 drivers/soc/qcom/smp2p.c   |  9 
 drivers/soc/qcom/trace-smp2p.h | 98 ++
 3 files changed, 108 insertions(+)
 create mode 100644 drivers/soc/qcom/trace-smp2p.h

diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index ca0bece0dfff..30c1bf645501 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -23,6 +23,7 @@ qcom_rpmh-y   += rpmh.o
 obj-$(CONFIG_QCOM_SMD_RPM) += rpm-proc.o smd-rpm.o
 obj-$(CONFIG_QCOM_SMEM) += smem.o
 obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o
+CFLAGS_smp2p.o := -I$(src)
 obj-$(CONFIG_QCOM_SMP2P)   += smp2p.o
 obj-$(CONFIG_QCOM_SMSM)+= smsm.o
 obj-$(CONFIG_QCOM_SOCINFO) += socinfo.o
diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
index 696c2a8387d0..4aa61b0f11ad 100644
--- a/drivers/soc/qcom/smp2p.c
+++ b/drivers/soc/qcom/smp2p.c
@@ -161,6 +161,9 @@ struct qcom_smp2p {
struct list_head outbound;
 };
 
+#define CREATE_TRACE_POINTS
+#include "trace-smp2p.h"
+
 static void qcom_smp2p_kick(struct qcom_smp2p *smp2p)
 {
/* Make sure any updated data is written before the kick */
@@ -192,6 +195,7 @@ static void qcom_smp2p_do_ssr_ack(struct qcom_smp2p *smp2p)
struct smp2p_smem_item *out = smp2p->out;
u32 val;
 
+   trace_smp2p_ssr_ack(smp2p->dev);
smp2p->ssr_ack = !smp2p->ssr_ack;
 
val = out->flags & ~BIT(SMP2P_FLAGS_RESTART_ACK_BIT);
@@ -214,6 +218,7 @@ static void qcom_smp2p_negotiate(struct qcom_smp2p *smp2p)
smp2p->ssr_ack_enabled = true;
 
smp2p->negotiation_done = true;
+   trace_smp2p_negotiate(smp2p->dev, out->features);
}
 }
 
@@ -252,6 +257,8 @@ static void qcom_smp2p_notify_in(struct qcom_smp2p *smp2p)
status = val ^ entry->last_value;
entry->last_value = val;
 
+   trace_smp2p_notify_in(entry, status, val);
+
/* No changes of this entry? */
if (!status)
continue;
@@ -415,6 +422,8 @@ static int smp2p_update_bits(void *data, u32 mask, u32 
value)
writel(val, entry->value);
spin_unlock_irqrestore(&entry->lock, flags);
 
+   trace_smp2p_update_bits(entry, orig, val);
+
if (val != orig)
qcom_smp2p_kick(entry->smp2p);
 
diff --git a/drivers/soc/qcom/trace-smp2p.h b/drivers/soc/qcom/trace-smp2p.h
new file mode 100644
index ..fa985a0d7615
--- /dev/null
+++ b/drivers/soc/qcom/trace-smp2p.h
@@ -0,0 +1,98 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM qcom_smp2p
+
+#if !defined(__QCOM_SMP2P_TRACE_H__) || defined(TRACE_HEADER_MULTI_READ)
+#define __QCOM_SMP2P_TRACE_H__
+
+#include 
+#include 
+
+TRACE_EVENT(smp2p_ssr_ack,
+   TP_PROTO(const struct device *dev),
+   TP_ARGS(dev),
+   TP_STRUCT__entry(
+   __string(dev_name, dev_name(dev))
+   ),
+   TP_fast_assign(
+   __assign_str(dev_name, dev_name(dev));
+   ),
+   TP_printk("%s: SSR detected", __get_str(dev_name))
+);
+
+TRACE_EVENT(smp2p_negotiate,
+   TP_PROTO(const struct device *dev, unsigned int features),
+   TP_ARGS(dev, features),
+   TP_STRUCT__entry(
+   __string(dev_name, dev_name(dev))
+   __field(u32, out_features)
+   ),
+   TP_fast_assign(
+   __assign_str(dev_name, dev_name(dev));
+   __entry->out_features = features;
+   ),
+   TP_printk("%s: state=open out_features=%s", __get_str(dev_name),
+   __print_flags(__entry->out_features, "|",
+   {SMP2P_FEATURE_SSR_ACK, "SMP2P_FEATURE_SSR_ACK"})
+   )
+);
+
+TRACE_EVENT(smp2p_notify_in,
+   TP_PROTO(struct smp2p_entry *smp2p_entry, unsigned long status, u32 
val),
+   TP_ARGS(smp2p_entry, status, val),
+   TP_STRUCT__entry(
+   __string(dev_name, dev_name(smp2p_entry->smp2p->dev))
+   __string(client_name, smp2p_entry->name)
+   __field(unsigned long, status)
+   __field(u32, val)
+   ),
+   TP_fast_assign(
+   __assign_str(dev_name, dev_name(smp2p_entry->smp2p->dev));
+   __assign_str(client_name, smp2p_entry->name);
+   __entry->status = status;
+  

[PATCH v4 1/2] soc: qcom: smp2p: Use devname for interrupt descriptions

2024-07-16 Thread Sudeepgoud Patil
From: Chris Lew 

When using /proc/interrupts to collect statistics on smp2p interrupt
counts, it is hard to distinguish the different instances of smp2p from
each other. For example to debug a processor boot issue, the ready and
handover interrupts are checked for sanity to ensure the firmware
reached a specific initialization stage.

Remove "smp2p" string from the irq request so that the irq will default
to the device name. Add an .irq_print_chip() callback to print the irq
chip name as the device name. These two changes allow for a unique name
to be used in /proc/interrupts as shown below.

/ # cat /proc/interrupts | grep smp2p
 18:  ...  ipcc 196610 Edge  smp2p-adsp
 20:  ...  ipcc 131074 Edge  smp2p-modem
170:  ...  smp2p-modem   1 Edge  q6v5 ready
178:  ...  smp2p-adsp   1 Edge  q6v5 ready

Signed-off-by: Chris Lew 
Signed-off-by: Sudeepgoud Patil 
---
 drivers/soc/qcom/smp2p.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
index a21241cbeec7..696c2a8387d0 100644
--- a/drivers/soc/qcom/smp2p.c
+++ b/drivers/soc/qcom/smp2p.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -353,11 +354,19 @@ static int smp2p_set_irq_type(struct irq_data *irqd, 
unsigned int type)
return 0;
 }
 
+static void smp2p_irq_print_chip(struct irq_data *irqd, struct seq_file *p)
+{
+   struct smp2p_entry *entry = irq_data_get_irq_chip_data(irqd);
+
+   seq_printf(p, " %8s", dev_name(entry->smp2p->dev));
+}
+
 static struct irq_chip smp2p_irq_chip = {
.name   = "smp2p",
.irq_mask   = smp2p_mask_irq,
.irq_unmask = smp2p_unmask_irq,
.irq_set_type   = smp2p_set_irq_type,
+   .irq_print_chip = smp2p_irq_print_chip,
 };
 
 static int smp2p_irq_map(struct irq_domain *d,
@@ -617,7 +626,7 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
ret = devm_request_threaded_irq(&pdev->dev, irq,
NULL, qcom_smp2p_intr,
IRQF_ONESHOT,
-   "smp2p", (void *)smp2p);
+   NULL, (void *)smp2p);
if (ret) {
dev_err(&pdev->dev, "failed to request interrupt\n");
goto unwind_interfaces;
-- 



[PATCH v4 0/2] Use of devname for interrupt descriptions and tracepoint support for smp2p

2024-07-16 Thread Sudeepgoud Patil
This commit enhances the smp2p driver by adding support for using the device
name in interrupt descriptions and introducing tracepoint functionality.
These improvements facilitate more effective debugging of smp2p-related issues.

The devname patch, along with the callback to print the irq chip name as the
device name and the removal of the ‘smp2p’ string from the irq request,
results in a unique interrupt description.

Tracepoint functionality captures essential details such as subsystem name,
negotiation specifics, supported features, bit changes, and subsystem restart
activity. These enhancements significantly improve debugging capabilities
for inter-subsystem issues.

Changes in v4:
- Add sign-off for "Use devname for interrupt descriptions" patch
- Update commit message in imperative mood for tracepoint patch
- Remove second argument of __assign_str() as per the commit 2c92ca8 
("tracing/treewide: Remove second parameter of __assign_str()") 
- Link to v3: 
https://lore.kernel.org/all/20240627104831.4176799-1-quic_sudee...@quicinc.com 

Changes in v3:
- Update patch to use devname for interrupt descriptions with a different 
approach
- Modify tracepoint patch by removing remote_pid field from all tracepoints
- Use SMP2P_FEATURE_SSR_ACK definition from smp2p.c instead of redefiniton
- Link to v2: 
https://lore.kernel.org/all/20240611123351.3813190-1-quic_sudee...@quicinc.com

Changes in v2:
- Add support to include the remote name in the smp2p IRQ devname, allowing for 
remote PID-name mapping
- Map the remote PID (Process ID) along with the remote name in tracepoints, as 
suggested by Chris
- Modify to capture all `out->features` instead of just the `ssr_ack`, 
following Chris's recommendation
- Expand the commit description to provide additional context
- Link to v1: 
https://lore.kernel.org/all/20240429075528.1723133-1-quic_sudee...@quicinc.com

Chris Lew (1):
  soc: qcom: smp2p: Use devname for interrupt descriptions

Sudeepgoud Patil (1):
  soc: qcom: smp2p: Introduce tracepoint support

 drivers/soc/qcom/Makefile  |  1 +
 drivers/soc/qcom/smp2p.c   | 20 ++-
 drivers/soc/qcom/trace-smp2p.h | 98 ++
 3 files changed, 118 insertions(+), 1 deletion(-)
 create mode 100644 drivers/soc/qcom/trace-smp2p.h


base-commit: d67978318827d06f1c0fa4c31343a279e9df6fde
-- 



[PATCH v4 2/2] soc: qcom: smp2p: Introduce tracepoint support

2024-07-16 Thread Sudeepgoud Patil
Introduce tracepoint support for smp2p to enable
communication logging between local and remote processors.
Include tracepoints with information about the remote subsystem
name, negotiation details, supported features, bit change
notifications, and ssr activity. These logs are useful for
debugging issues between subsystems.

Signed-off-by: Sudeepgoud Patil 
---
 drivers/soc/qcom/Makefile  |  1 +
 drivers/soc/qcom/smp2p.c   |  9 
 drivers/soc/qcom/trace-smp2p.h | 98 ++
 3 files changed, 108 insertions(+)
 create mode 100644 drivers/soc/qcom/trace-smp2p.h

diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index ca0bece0dfff..30c1bf645501 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -23,6 +23,7 @@ qcom_rpmh-y   += rpmh.o
 obj-$(CONFIG_QCOM_SMD_RPM) += rpm-proc.o smd-rpm.o
 obj-$(CONFIG_QCOM_SMEM) += smem.o
 obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o
+CFLAGS_smp2p.o := -I$(src)
 obj-$(CONFIG_QCOM_SMP2P)   += smp2p.o
 obj-$(CONFIG_QCOM_SMSM)+= smsm.o
 obj-$(CONFIG_QCOM_SOCINFO) += socinfo.o
diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
index 696c2a8387d0..4aa61b0f11ad 100644
--- a/drivers/soc/qcom/smp2p.c
+++ b/drivers/soc/qcom/smp2p.c
@@ -161,6 +161,9 @@ struct qcom_smp2p {
struct list_head outbound;
 };
 
+#define CREATE_TRACE_POINTS
+#include "trace-smp2p.h"
+
 static void qcom_smp2p_kick(struct qcom_smp2p *smp2p)
 {
/* Make sure any updated data is written before the kick */
@@ -192,6 +195,7 @@ static void qcom_smp2p_do_ssr_ack(struct qcom_smp2p *smp2p)
struct smp2p_smem_item *out = smp2p->out;
u32 val;
 
+   trace_smp2p_ssr_ack(smp2p->dev);
smp2p->ssr_ack = !smp2p->ssr_ack;
 
val = out->flags & ~BIT(SMP2P_FLAGS_RESTART_ACK_BIT);
@@ -214,6 +218,7 @@ static void qcom_smp2p_negotiate(struct qcom_smp2p *smp2p)
smp2p->ssr_ack_enabled = true;
 
smp2p->negotiation_done = true;
+   trace_smp2p_negotiate(smp2p->dev, out->features);
}
 }
 
@@ -252,6 +257,8 @@ static void qcom_smp2p_notify_in(struct qcom_smp2p *smp2p)
status = val ^ entry->last_value;
entry->last_value = val;
 
+   trace_smp2p_notify_in(entry, status, val);
+
/* No changes of this entry? */
if (!status)
continue;
@@ -415,6 +422,8 @@ static int smp2p_update_bits(void *data, u32 mask, u32 
value)
writel(val, entry->value);
spin_unlock_irqrestore(&entry->lock, flags);
 
+   trace_smp2p_update_bits(entry, orig, val);
+
if (val != orig)
qcom_smp2p_kick(entry->smp2p);
 
diff --git a/drivers/soc/qcom/trace-smp2p.h b/drivers/soc/qcom/trace-smp2p.h
new file mode 100644
index ..9a6392043f10
--- /dev/null
+++ b/drivers/soc/qcom/trace-smp2p.h
@@ -0,0 +1,98 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM qcom_smp2p
+
+#if !defined(__QCOM_SMP2P_TRACE_H__) || defined(TRACE_HEADER_MULTI_READ)
+#define __QCOM_SMP2P_TRACE_H__
+
+#include 
+#include 
+
+TRACE_EVENT(smp2p_ssr_ack,
+   TP_PROTO(const struct device *dev),
+   TP_ARGS(dev),
+   TP_STRUCT__entry(
+   __string(dev_name, dev_name(dev))
+   ),
+   TP_fast_assign(
+   __assign_str(dev_name);
+   ),
+   TP_printk("%s: SSR detected", __get_str(dev_name))
+);
+
+TRACE_EVENT(smp2p_negotiate,
+   TP_PROTO(const struct device *dev, unsigned int features),
+   TP_ARGS(dev, features),
+   TP_STRUCT__entry(
+   __string(dev_name, dev_name(dev))
+   __field(u32, out_features)
+   ),
+   TP_fast_assign(
+   __assign_str(dev_name);
+   __entry->out_features = features;
+   ),
+   TP_printk("%s: state=open out_features=%s", __get_str(dev_name),
+   __print_flags(__entry->out_features, "|",
+   {SMP2P_FEATURE_SSR_ACK, "SMP2P_FEATURE_SSR_ACK"})
+   )
+);
+
+TRACE_EVENT(smp2p_notify_in,
+   TP_PROTO(struct smp2p_entry *smp2p_entry, unsigned long status, u32 
val),
+   TP_ARGS(smp2p_entry, status, val),
+   TP_STRUCT__entry(
+   __string(dev_name, dev_name(smp2p_entry->smp2p->dev))
+   __string(client_name, smp2p_entry->name)
+   __field(unsigned long, status)
+   __field(u32, val)
+   ),
+   TP_fast_assign(
+   __assign_str(dev_name);
+   __assign_str(client_name);
+   __entry->status = status;
+   __entry->val = val;
+   ),
+   TP_printk("%s: %s: status:0x%0lx val:0x%0x",
+