mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 0/2] soc: qcom: smp2p: Add support for remoteproc early attach
@ 2026-01-27 10:38 Deepak Kumar Singh
  2026-01-27 10:38 ` [PATCH v3 1/2] soc: qcom: smp2p: Add irqchip state support Deepak Kumar Singh
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Deepak Kumar Singh @ 2026-01-27 10:38 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio
  Cc: linux-arm-msm, linux-kernel, Deepak Kumar Singh,
	linux-remoteproc, Chris Lew

Some remoteproc will boot during earlier boot stages, add callback
.irq_get_irqchip_state for remoteproc to check the states in smp2p
and mark the state "attached", also add smp2p v2 support.

Signed-off-by: Deepak Kumar Singh <deepak.singh@oss.qualcomm.com>
---
Changes in v3:
- Update commit message.
- Clean up macros for smp2p version.
- Update description for smp2p version 2.
- Update version negotiation to accomodate version 2.
- Address other minor comments from v2.
- Link to v2: https://lore.kernel.org/all/20251103152929.2434911-1-deepak.singh@oss.qualcomm.com

Changes in v2:
- Update condition to check version 2 in qcom_smp2p_start_in().
- Add more comment to describe above condition.
- Add description for version v1 and v2 of smp2p.
- Check validity of in_version.
- Link to v1: https://lore.kernel.org/all/20250923-smp2p-v1-0-2c045af73dac@oss.qualcomm.com

---
Chris Lew (2):
      soc: qcom: smp2p: Add irqchip state support
      soc: qcom: smp2p: Add support for smp2p v2

 drivers/soc/qcom/smp2p.c | 103 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 99 insertions(+), 4 deletions(-)
---
base-commit: fcb70a56f4d81450114034b2c61f48ce7444a0e2
change-id: 20251127-smp2pv2-bb88f617b5b0

Best regards,
-- 
Deepak Kumar Singh <deepak.singh@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 1/2] soc: qcom: smp2p: Add irqchip state support
  2026-01-27 10:38 [PATCH v3 0/2] soc: qcom: smp2p: Add support for remoteproc early attach Deepak Kumar Singh
@ 2026-01-27 10:38 ` Deepak Kumar Singh
  2026-01-27 12:55   ` Konrad Dybcio
  2026-01-27 10:38 ` [PATCH v3 2/2] soc: qcom: smp2p: Add support for smp2p v2 Deepak Kumar Singh
  2026-03-16  2:02 ` [PATCH v3 0/2] soc: qcom: smp2p: Add support for remoteproc early attach Bjorn Andersson
  2 siblings, 1 reply; 10+ messages in thread
From: Deepak Kumar Singh @ 2026-01-27 10:38 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio
  Cc: linux-arm-msm, linux-kernel, Deepak Kumar Singh,
	linux-remoteproc, Chris Lew

From: Chris Lew <chris.lew@oss.qualcomm.com>

A remoteproc booted during earlier boot stages such as UEFI or the
bootloader, may need to be attached to without restarting the remoteproc
hardware. To do this the remoteproc will need to check the ready and
handover states in smp2p without an interrupt notification. Create
qcom_smp2p_start_in() to initialize the shadow state without notifying
clients because these early events happened in the past.

Add support for the .irq_get_irqchip_state callback so remoteproc can
read the current state of the fatal, ready and handover bits.

Signed-off-by: Chris Lew <chris.lew@oss.qualcomm.com>
Signed-off-by: Deepak Kumar Singh <deepak.singh@oss.qualcomm.com>
---
 drivers/soc/qcom/smp2p.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
index cb515c2340c1..c27ffb44b825 100644
--- a/drivers/soc/qcom/smp2p.c
+++ b/drivers/soc/qcom/smp2p.c
@@ -222,6 +222,39 @@ static void qcom_smp2p_negotiate(struct qcom_smp2p *smp2p)
 	}
 }
 
+static void qcom_smp2p_start_in(struct qcom_smp2p *smp2p)
+{
+	unsigned int smem_id = smp2p->smem_items[SMP2P_INBOUND];
+	unsigned int pid = smp2p->remote_pid;
+	char buf[SMP2P_MAX_ENTRY_NAME];
+	struct smp2p_smem_item *in;
+	struct smp2p_entry *entry;
+	size_t size;
+	int i;
+
+	in = qcom_smem_get(pid, smem_id, &size);
+	if (IS_ERR(in))
+		return;
+
+	smp2p->in = in;
+
+	/* Check if version is initialized by the remote. */
+	if (in->version == 0)
+		return;
+
+	for (i = smp2p->valid_entries; i < in->valid_entries; i++) {
+		list_for_each_entry(entry, &smp2p->inbound, node) {
+			memcpy(buf, in->entries[i].name, sizeof(buf));
+			if (!strcmp(buf, entry->name)) {
+				entry->value = &in->entries[i].value;
+				entry->last_value = readl(entry->value);
+				break;
+			}
+		}
+	}
+	smp2p->valid_entries = i;
+}
+
 static void qcom_smp2p_notify_in(struct qcom_smp2p *smp2p)
 {
 	struct smp2p_smem_item *in;
@@ -368,12 +401,31 @@ static void smp2p_irq_print_chip(struct irq_data *irqd, struct seq_file *p)
 	seq_printf(p, "%8s", dev_name(entry->smp2p->dev));
 }
 
+static int smp2p_irq_get_irqchip_state(struct irq_data *irqd, enum irqchip_irq_state which,
+				       bool *state)
+{
+	struct smp2p_entry *entry = irq_data_get_irq_chip_data(irqd);
+	u32 val;
+
+	if (which != IRQCHIP_STATE_LINE_LEVEL)
+		return -EINVAL;
+
+	if (!entry->value)
+		return -ENODEV;
+
+	val = readl(entry->value);
+	*state = !!(val & BIT(irqd_to_hwirq(irqd)));
+
+	return 0;
+}
+
 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,
+	.irq_get_irqchip_state = smp2p_irq_get_irqchip_state,
 };
 
 static int smp2p_irq_map(struct irq_domain *d,
@@ -618,6 +670,9 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
 		}
 	}
 
+	/* Check inbound entries in the case of early boot processor */
+	qcom_smp2p_start_in(smp2p);
+
 	/* Kick the outgoing edge after allocating entries */
 	qcom_smp2p_kick(smp2p);
 

-- 
2.34.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 2/2] soc: qcom: smp2p: Add support for smp2p v2
  2026-01-27 10:38 [PATCH v3 0/2] soc: qcom: smp2p: Add support for remoteproc early attach Deepak Kumar Singh
  2026-01-27 10:38 ` [PATCH v3 1/2] soc: qcom: smp2p: Add irqchip state support Deepak Kumar Singh
@ 2026-01-27 10:38 ` Deepak Kumar Singh
  2026-03-16  2:02 ` [PATCH v3 0/2] soc: qcom: smp2p: Add support for remoteproc early attach Bjorn Andersson
  2 siblings, 0 replies; 10+ messages in thread
From: Deepak Kumar Singh @ 2026-01-27 10:38 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio
  Cc: linux-arm-msm, linux-kernel, Deepak Kumar Singh,
	linux-remoteproc, Chris Lew

From: Chris Lew <chris.lew@oss.qualcomm.com>

smp2p v2 adds support for allowing remote processors to write outbound
smp2p items without completing the feature negotiation. This is required
for processors that start before linux to write out signals like error
and clock ready and unblock their bootup.

If a remote processor only supports v1, smp2p can version down by
mirroring the peer version during the negotiation stage.

When using smp2p version 2, the remote does not wait for the ssr ack
before setting the items. To accommodate this, set the last_value of all
the entries to 0 when SSR is detected. This forces smp2p to detect the
new values written by the remote. Because the SSR ack is skipped, the
down transition of bits is missed in smp2p version 2.

Signed-off-by: Chris Lew <chris.lew@oss.qualcomm.com>
Signed-off-by: Deepak Kumar Singh <deepak.singh@oss.qualcomm.com>
---
 drivers/soc/qcom/smp2p.c | 48 ++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 44 insertions(+), 4 deletions(-)

diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
index c27ffb44b825..af0ceeaf6e07 100644
--- a/drivers/soc/qcom/smp2p.c
+++ b/drivers/soc/qcom/smp2p.c
@@ -36,6 +36,10 @@
  * The driver uses the Linux GPIO and interrupt framework to expose a virtual
  * GPIO for each outbound entry and a virtual interrupt controller for each
  * inbound entry.
+ *
+ * V2 of SMP2P allows remote processors to write to outbound smp2p items before
+ * the full smp2p connection is negotiated. This is important for processors
+ * started before linux runs.
  */
 
 #define SMP2P_MAX_ENTRY 16
@@ -47,11 +51,12 @@
 
 #define SMP2P_MAGIC 0x504d5324
 #define SMP2P_ALL_FEATURES	SMP2P_FEATURE_SSR_ACK
+#define MAX_VERSION 2
 
 /**
  * struct smp2p_smem_item - in memory communication structure
  * @magic:		magic number
- * @version:		version - must be 1
+ * @version:		version
  * @features:		features flag - currently unused
  * @local_pid:		processor id of sending end
  * @remote_pid:		processor id of receiving end
@@ -180,14 +185,22 @@ static void qcom_smp2p_kick(struct qcom_smp2p *smp2p)
 static bool qcom_smp2p_check_ssr(struct qcom_smp2p *smp2p)
 {
 	struct smp2p_smem_item *in = smp2p->in;
+	struct smp2p_entry *entry;
+	bool restart_done;
 	bool restart;
 
 	if (!smp2p->ssr_ack_enabled)
 		return false;
 
-	restart = in->flags & BIT(SMP2P_FLAGS_RESTART_DONE_BIT);
+	restart_done = in->flags & BIT(SMP2P_FLAGS_RESTART_DONE_BIT);
+	restart = restart_done != smp2p->ssr_ack;
+	list_for_each_entry(entry, &smp2p->inbound, node) {
+		if (!entry->value)
+			continue;
+		entry->last_value = 0;
+	}
 
-	return restart != smp2p->ssr_ack;
+	return restart;
 }
 
 static void qcom_smp2p_do_ssr_ack(struct qcom_smp2p *smp2p)
@@ -219,9 +232,26 @@ static void qcom_smp2p_negotiate(struct qcom_smp2p *smp2p)
 
 		smp2p->negotiation_done = true;
 		trace_smp2p_negotiate(smp2p->dev, out->features);
+	} else if (in->version && in->version < out->version) {
+		out->version = in->version;
+		qcom_smp2p_kick(smp2p);
 	}
 }
 
+static int qcom_smp2p_in_version(struct qcom_smp2p *smp2p)
+{
+	unsigned int smem_id = smp2p->smem_items[SMP2P_INBOUND];
+	unsigned int pid = smp2p->remote_pid;
+	struct smp2p_smem_item *in;
+	size_t size;
+
+	in = qcom_smem_get(pid, smem_id, &size);
+	if (IS_ERR(in))
+		return 0;
+
+	return in->version;
+}
+
 static void qcom_smp2p_start_in(struct qcom_smp2p *smp2p)
 {
 	unsigned int smem_id = smp2p->smem_items[SMP2P_INBOUND];
@@ -516,6 +546,7 @@ static int qcom_smp2p_alloc_outbound_item(struct qcom_smp2p *smp2p)
 	struct smp2p_smem_item *out;
 	unsigned smem_id = smp2p->smem_items[SMP2P_OUTBOUND];
 	unsigned pid = smp2p->remote_pid;
+	u8 in_version;
 	int ret;
 
 	ret = qcom_smem_alloc(pid, smem_id, sizeof(*out));
@@ -537,12 +568,21 @@ static int qcom_smp2p_alloc_outbound_item(struct qcom_smp2p *smp2p)
 	out->valid_entries = 0;
 	out->features = SMP2P_ALL_FEATURES;
 
+	in_version = qcom_smp2p_in_version(smp2p);
+	if (in_version > MAX_VERSION) {
+		dev_err(smp2p->dev, "Unsupported smp2p version %d\n", in_version);
+		return -EINVAL;
+	}
+
 	/*
 	 * Make sure the rest of the header is written before we validate the
 	 * item by writing a valid version number.
 	 */
 	wmb();
-	out->version = 1;
+	if (in_version && in_version <= 2)
+		out->version = in_version;
+	else
+		out->version = 2;
 
 	qcom_smp2p_kick(smp2p);
 

-- 
2.34.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 1/2] soc: qcom: smp2p: Add irqchip state support
  2026-01-27 10:38 ` [PATCH v3 1/2] soc: qcom: smp2p: Add irqchip state support Deepak Kumar Singh
@ 2026-01-27 12:55   ` Konrad Dybcio
  2026-01-29 10:56     ` Deepak Kumar Singh
  0 siblings, 1 reply; 10+ messages in thread
From: Konrad Dybcio @ 2026-01-27 12:55 UTC (permalink / raw)
  To: Deepak Kumar Singh, Bjorn Andersson, Konrad Dybcio
  Cc: linux-arm-msm, linux-kernel, linux-remoteproc, Chris Lew

On 1/27/26 11:38 AM, Deepak Kumar Singh wrote:
> From: Chris Lew <chris.lew@oss.qualcomm.com>
> 
> A remoteproc booted during earlier boot stages such as UEFI or the
> bootloader, may need to be attached to without restarting the remoteproc
> hardware. To do this the remoteproc will need to check the ready and
> handover states in smp2p without an interrupt notification. Create
> qcom_smp2p_start_in() to initialize the shadow state without notifying
> clients because these early events happened in the past.
> 
> Add support for the .irq_get_irqchip_state callback so remoteproc can
> read the current state of the fatal, ready and handover bits.
> 
> Signed-off-by: Chris Lew <chris.lew@oss.qualcomm.com>
> Signed-off-by: Deepak Kumar Singh <deepak.singh@oss.qualcomm.com>
> ---
>  drivers/soc/qcom/smp2p.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 55 insertions(+)
> 
> diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
> index cb515c2340c1..c27ffb44b825 100644
> --- a/drivers/soc/qcom/smp2p.c
> +++ b/drivers/soc/qcom/smp2p.c
> @@ -222,6 +222,39 @@ static void qcom_smp2p_negotiate(struct qcom_smp2p *smp2p)
>  	}
>  }
>  
> +static void qcom_smp2p_start_in(struct qcom_smp2p *smp2p)
> +{
> +	unsigned int smem_id = smp2p->smem_items[SMP2P_INBOUND];
> +	unsigned int pid = smp2p->remote_pid;
> +	char buf[SMP2P_MAX_ENTRY_NAME];
> +	struct smp2p_smem_item *in;
> +	struct smp2p_entry *entry;
> +	size_t size;
> +	int i;
> +
> +	in = qcom_smem_get(pid, smem_id, &size);
> +	if (IS_ERR(in))
> +		return;
> +
> +	smp2p->in = in;
> +
> +	/* Check if version is initialized by the remote. */
> +	if (in->version == 0)
> +		return;
> +
> +	for (i = smp2p->valid_entries; i < in->valid_entries; i++) {
> +		list_for_each_entry(entry, &smp2p->inbound, node) {
> +			memcpy(buf, in->entries[i].name, sizeof(buf));

Is there a reason for this copy at all?

[...]

> +	/* Check inbound entries in the case of early boot processor */

"in case a remote processor has already been started"?

Konrad


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 1/2] soc: qcom: smp2p: Add irqchip state support
  2026-01-27 12:55   ` Konrad Dybcio
@ 2026-01-29 10:56     ` Deepak Kumar Singh
  2026-01-30  0:46       ` Chris Lew
  0 siblings, 1 reply; 10+ messages in thread
From: Deepak Kumar Singh @ 2026-01-29 10:56 UTC (permalink / raw)
  To: Konrad Dybcio, Bjorn Andersson, Konrad Dybcio
  Cc: linux-arm-msm, linux-kernel, linux-remoteproc, Chris Lew


On 1/27/2026 6:25 PM, Konrad Dybcio wrote:
> On 1/27/26 11:38 AM, Deepak Kumar Singh wrote:
>> From: Chris Lew <chris.lew@oss.qualcomm.com>
>>
>> A remoteproc booted during earlier boot stages such as UEFI or the
>> bootloader, may need to be attached to without restarting the remoteproc
>> hardware. To do this the remoteproc will need to check the ready and
>> handover states in smp2p without an interrupt notification. Create
>> qcom_smp2p_start_in() to initialize the shadow state without notifying
>> clients because these early events happened in the past.
>>
>> Add support for the .irq_get_irqchip_state callback so remoteproc can
>> read the current state of the fatal, ready and handover bits.
>>
>> Signed-off-by: Chris Lew <chris.lew@oss.qualcomm.com>
>> Signed-off-by: Deepak Kumar Singh <deepak.singh@oss.qualcomm.com>
>> ---
>>   drivers/soc/qcom/smp2p.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 55 insertions(+)
>>
>> diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
>> index cb515c2340c1..c27ffb44b825 100644
>> --- a/drivers/soc/qcom/smp2p.c
>> +++ b/drivers/soc/qcom/smp2p.c
>> @@ -222,6 +222,39 @@ static void qcom_smp2p_negotiate(struct qcom_smp2p *smp2p)
>>   	}
>>   }
>>   
>> +static void qcom_smp2p_start_in(struct qcom_smp2p *smp2p)
>> +{
>> +	unsigned int smem_id = smp2p->smem_items[SMP2P_INBOUND];
>> +	unsigned int pid = smp2p->remote_pid;
>> +	char buf[SMP2P_MAX_ENTRY_NAME];
>> +	struct smp2p_smem_item *in;
>> +	struct smp2p_entry *entry;
>> +	size_t size;
>> +	int i;
>> +
>> +	in = qcom_smem_get(pid, smem_id, &size);
>> +	if (IS_ERR(in))
>> +		return;
>> +
>> +	smp2p->in = in;
>> +
>> +	/* Check if version is initialized by the remote. */
>> +	if (in->version == 0)
>> +		return;
>> +
>> +	for (i = smp2p->valid_entries; i < in->valid_entries; i++) {
>> +		list_for_each_entry(entry, &smp2p->inbound, node) {
>> +			memcpy(buf, in->entries[i].name, sizeof(buf));
> Is there a reason for this copy at all?
I don't see a compelling reason. This code snippet is same as present in 
qcom_smp2p_notify_in().
> [...]
>
>> +	/* Check inbound entries in the case of early boot processor */
> "in case a remote processor has already been started"?
This i can update in case new patch set is required.
> Konrad
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 1/2] soc: qcom: smp2p: Add irqchip state support
  2026-01-29 10:56     ` Deepak Kumar Singh
@ 2026-01-30  0:46       ` Chris Lew
  2026-01-30 10:13         ` Konrad Dybcio
  2026-02-04  7:21         ` Deepak Kumar Singh
  0 siblings, 2 replies; 10+ messages in thread
From: Chris Lew @ 2026-01-30  0:46 UTC (permalink / raw)
  To: Deepak Kumar Singh
  Cc: Konrad Dybcio, Bjorn Andersson, Konrad Dybcio, linux-arm-msm,
	linux-kernel, linux-remoteproc, Chris Lew

On Thu, Jan 29, 2026 at 04:26:38PM +0530, Deepak Kumar Singh wrote:
> 
> On 1/27/2026 6:25 PM, Konrad Dybcio wrote:
> > On 1/27/26 11:38 AM, Deepak Kumar Singh wrote:
> > > From: Chris Lew <chris.lew@oss.qualcomm.com>
> > > 
> > > A remoteproc booted during earlier boot stages such as UEFI or the
> > > bootloader, may need to be attached to without restarting the remoteproc
> > > hardware. To do this the remoteproc will need to check the ready and
> > > handover states in smp2p without an interrupt notification. Create
> > > qcom_smp2p_start_in() to initialize the shadow state without notifying
> > > clients because these early events happened in the past.
> > > 
> > > Add support for the .irq_get_irqchip_state callback so remoteproc can
> > > read the current state of the fatal, ready and handover bits.
> > > 
> > > Signed-off-by: Chris Lew <chris.lew@oss.qualcomm.com>
> > > Signed-off-by: Deepak Kumar Singh <deepak.singh@oss.qualcomm.com>
> > > ---
> > >   drivers/soc/qcom/smp2p.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
> > >   1 file changed, 55 insertions(+)
> > > 
> > > diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
> > > index cb515c2340c1..c27ffb44b825 100644
> > > --- a/drivers/soc/qcom/smp2p.c
> > > +++ b/drivers/soc/qcom/smp2p.c
> > > @@ -222,6 +222,39 @@ static void qcom_smp2p_negotiate(struct qcom_smp2p *smp2p)
> > >   	}
> > >   }
> > > +static void qcom_smp2p_start_in(struct qcom_smp2p *smp2p)
> > > +{
> > > +	unsigned int smem_id = smp2p->smem_items[SMP2P_INBOUND];
> > > +	unsigned int pid = smp2p->remote_pid;
> > > +	char buf[SMP2P_MAX_ENTRY_NAME];
> > > +	struct smp2p_smem_item *in;
> > > +	struct smp2p_entry *entry;
> > > +	size_t size;
> > > +	int i;
> > > +
> > > +	in = qcom_smem_get(pid, smem_id, &size);
> > > +	if (IS_ERR(in))
> > > +		return;
> > > +
> > > +	smp2p->in = in;
> > > +
> > > +	/* Check if version is initialized by the remote. */
> > > +	if (in->version == 0)
> > > +		return;
> > > +
> > > +	for (i = smp2p->valid_entries; i < in->valid_entries; i++) {
> > > +		list_for_each_entry(entry, &smp2p->inbound, node) {
> > > +			memcpy(buf, in->entries[i].name, sizeof(buf));
> > Is there a reason for this copy at all?
> I don't see a compelling reason. This code snippet is same as present in
> qcom_smp2p_notify_in().

My understanding was that we do this copy because we don't want to do a
strcmp on memory that the remote could change at any time. Maybe it's
overkill but I thought it was considered good practice and as Deepak
mentioned, it is similarly present in qcom_smp2p_notify_in().

> > [...]
> > 
> > > +	/* Check inbound entries in the case of early boot processor */
> > "in case a remote processor has already been started"?
> This i can update in case new patch set is required.
> > Konrad
> > 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 1/2] soc: qcom: smp2p: Add irqchip state support
  2026-01-30  0:46       ` Chris Lew
@ 2026-01-30 10:13         ` Konrad Dybcio
  2026-02-04  7:21         ` Deepak Kumar Singh
  1 sibling, 0 replies; 10+ messages in thread
From: Konrad Dybcio @ 2026-01-30 10:13 UTC (permalink / raw)
  To: Chris Lew, Deepak Kumar Singh
  Cc: Bjorn Andersson, Konrad Dybcio, linux-arm-msm, linux-kernel,
	linux-remoteproc, Chris Lew

On 1/30/26 1:46 AM, Chris Lew wrote:
> On Thu, Jan 29, 2026 at 04:26:38PM +0530, Deepak Kumar Singh wrote:
>>
>> On 1/27/2026 6:25 PM, Konrad Dybcio wrote:
>>> On 1/27/26 11:38 AM, Deepak Kumar Singh wrote:
>>>> From: Chris Lew <chris.lew@oss.qualcomm.com>
>>>>
>>>> A remoteproc booted during earlier boot stages such as UEFI or the
>>>> bootloader, may need to be attached to without restarting the remoteproc
>>>> hardware. To do this the remoteproc will need to check the ready and
>>>> handover states in smp2p without an interrupt notification. Create
>>>> qcom_smp2p_start_in() to initialize the shadow state without notifying
>>>> clients because these early events happened in the past.
>>>>
>>>> Add support for the .irq_get_irqchip_state callback so remoteproc can
>>>> read the current state of the fatal, ready and handover bits.
>>>>
>>>> Signed-off-by: Chris Lew <chris.lew@oss.qualcomm.com>
>>>> Signed-off-by: Deepak Kumar Singh <deepak.singh@oss.qualcomm.com>
>>>> ---
>>>>   drivers/soc/qcom/smp2p.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
>>>>   1 file changed, 55 insertions(+)
>>>>
>>>> diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
>>>> index cb515c2340c1..c27ffb44b825 100644
>>>> --- a/drivers/soc/qcom/smp2p.c
>>>> +++ b/drivers/soc/qcom/smp2p.c
>>>> @@ -222,6 +222,39 @@ static void qcom_smp2p_negotiate(struct qcom_smp2p *smp2p)
>>>>   	}
>>>>   }
>>>> +static void qcom_smp2p_start_in(struct qcom_smp2p *smp2p)
>>>> +{
>>>> +	unsigned int smem_id = smp2p->smem_items[SMP2P_INBOUND];
>>>> +	unsigned int pid = smp2p->remote_pid;
>>>> +	char buf[SMP2P_MAX_ENTRY_NAME];
>>>> +	struct smp2p_smem_item *in;
>>>> +	struct smp2p_entry *entry;
>>>> +	size_t size;
>>>> +	int i;
>>>> +
>>>> +	in = qcom_smem_get(pid, smem_id, &size);
>>>> +	if (IS_ERR(in))
>>>> +		return;
>>>> +
>>>> +	smp2p->in = in;
>>>> +
>>>> +	/* Check if version is initialized by the remote. */
>>>> +	if (in->version == 0)
>>>> +		return;
>>>> +
>>>> +	for (i = smp2p->valid_entries; i < in->valid_entries; i++) {
>>>> +		list_for_each_entry(entry, &smp2p->inbound, node) {
>>>> +			memcpy(buf, in->entries[i].name, sizeof(buf));
>>> Is there a reason for this copy at all?
>> I don't see a compelling reason. This code snippet is same as present in
>> qcom_smp2p_notify_in().
> 
> My understanding was that we do this copy because we don't want to do a
> strcmp on memory that the remote could change at any time. Maybe it's
> overkill but I thought it was considered good practice and as Deepak
> mentioned, it is similarly present in qcom_smp2p_notify_in().

Ok, right, I didn't take that into account

Konrad

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 1/2] soc: qcom: smp2p: Add irqchip state support
  2026-01-30  0:46       ` Chris Lew
  2026-01-30 10:13         ` Konrad Dybcio
@ 2026-02-04  7:21         ` Deepak Kumar Singh
  2026-02-04 12:27           ` Konrad Dybcio
  1 sibling, 1 reply; 10+ messages in thread
From: Deepak Kumar Singh @ 2026-02-04  7:21 UTC (permalink / raw)
  To: Chris Lew
  Cc: Konrad Dybcio, Bjorn Andersson, Konrad Dybcio, linux-arm-msm,
	linux-kernel, linux-remoteproc, Chris Lew


On 1/30/2026 6:16 AM, Chris Lew wrote:
> On Thu, Jan 29, 2026 at 04:26:38PM +0530, Deepak Kumar Singh wrote:
>> On 1/27/2026 6:25 PM, Konrad Dybcio wrote:
>>> On 1/27/26 11:38 AM, Deepak Kumar Singh wrote:
>>>> From: Chris Lew <chris.lew@oss.qualcomm.com>
>>>>
>>>> A remoteproc booted during earlier boot stages such as UEFI or the
>>>> bootloader, may need to be attached to without restarting the remoteproc
>>>> hardware. To do this the remoteproc will need to check the ready and
>>>> handover states in smp2p without an interrupt notification. Create
>>>> qcom_smp2p_start_in() to initialize the shadow state without notifying
>>>> clients because these early events happened in the past.
>>>>
>>>> Add support for the .irq_get_irqchip_state callback so remoteproc can
>>>> read the current state of the fatal, ready and handover bits.
>>>>
>>>> Signed-off-by: Chris Lew <chris.lew@oss.qualcomm.com>
>>>> Signed-off-by: Deepak Kumar Singh <deepak.singh@oss.qualcomm.com>
>>>> ---
>>>>    drivers/soc/qcom/smp2p.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
>>>>    1 file changed, 55 insertions(+)
>>>>
>>>> diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
>>>> index cb515c2340c1..c27ffb44b825 100644
>>>> --- a/drivers/soc/qcom/smp2p.c
>>>> +++ b/drivers/soc/qcom/smp2p.c
>>>> @@ -222,6 +222,39 @@ static void qcom_smp2p_negotiate(struct qcom_smp2p *smp2p)
>>>>    	}
>>>>    }
>>>> +static void qcom_smp2p_start_in(struct qcom_smp2p *smp2p)
>>>> +{
>>>> +	unsigned int smem_id = smp2p->smem_items[SMP2P_INBOUND];
>>>> +	unsigned int pid = smp2p->remote_pid;
>>>> +	char buf[SMP2P_MAX_ENTRY_NAME];
>>>> +	struct smp2p_smem_item *in;
>>>> +	struct smp2p_entry *entry;
>>>> +	size_t size;
>>>> +	int i;
>>>> +
>>>> +	in = qcom_smem_get(pid, smem_id, &size);
>>>> +	if (IS_ERR(in))
>>>> +		return;
>>>> +
>>>> +	smp2p->in = in;
>>>> +
>>>> +	/* Check if version is initialized by the remote. */
>>>> +	if (in->version == 0)
>>>> +		return;
>>>> +
>>>> +	for (i = smp2p->valid_entries; i < in->valid_entries; i++) {
>>>> +		list_for_each_entry(entry, &smp2p->inbound, node) {
>>>> +			memcpy(buf, in->entries[i].name, sizeof(buf));
>>> Is there a reason for this copy at all?
>> I don't see a compelling reason. This code snippet is same as present in
>> qcom_smp2p_notify_in().
> My understanding was that we do this copy because we don't want to do a
> strcmp on memory that the remote could change at any time. Maybe it's
> overkill but I thought it was considered good practice and as Deepak
> mentioned, it is similarly present in qcom_smp2p_notify_in().
>
>>> [...]
>>>
>>>> +	/* Check inbound entries in the case of early boot processor */
>>> "in case a remote processor has already been started"?
>> This i can update in case new patch set is required.
>>> Konrad

Are you expecting new patch for this update or current one is ok?

Deepak

>>>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 1/2] soc: qcom: smp2p: Add irqchip state support
  2026-02-04  7:21         ` Deepak Kumar Singh
@ 2026-02-04 12:27           ` Konrad Dybcio
  0 siblings, 0 replies; 10+ messages in thread
From: Konrad Dybcio @ 2026-02-04 12:27 UTC (permalink / raw)
  To: Deepak Kumar Singh, Chris Lew
  Cc: Bjorn Andersson, Konrad Dybcio, linux-arm-msm, linux-kernel,
	linux-remoteproc, Chris Lew

On 2/4/26 8:21 AM, Deepak Kumar Singh wrote:
> 
> On 1/30/2026 6:16 AM, Chris Lew wrote:
>> On Thu, Jan 29, 2026 at 04:26:38PM +0530, Deepak Kumar Singh wrote:
>>> On 1/27/2026 6:25 PM, Konrad Dybcio wrote:
>>>> On 1/27/26 11:38 AM, Deepak Kumar Singh wrote:
>>>>> From: Chris Lew <chris.lew@oss.qualcomm.com>
>>>>>
>>>>> A remoteproc booted during earlier boot stages such as UEFI or the
>>>>> bootloader, may need to be attached to without restarting the remoteproc
>>>>> hardware. To do this the remoteproc will need to check the ready and
>>>>> handover states in smp2p without an interrupt notification. Create
>>>>> qcom_smp2p_start_in() to initialize the shadow state without notifying
>>>>> clients because these early events happened in the past.
>>>>>
>>>>> Add support for the .irq_get_irqchip_state callback so remoteproc can
>>>>> read the current state of the fatal, ready and handover bits.
>>>>>
>>>>> Signed-off-by: Chris Lew <chris.lew@oss.qualcomm.com>
>>>>> Signed-off-by: Deepak Kumar Singh <deepak.singh@oss.qualcomm.com>
>>>>> ---
>>>>>    drivers/soc/qcom/smp2p.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
>>>>>    1 file changed, 55 insertions(+)
>>>>>
>>>>> diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
>>>>> index cb515c2340c1..c27ffb44b825 100644
>>>>> --- a/drivers/soc/qcom/smp2p.c
>>>>> +++ b/drivers/soc/qcom/smp2p.c
>>>>> @@ -222,6 +222,39 @@ static void qcom_smp2p_negotiate(struct qcom_smp2p *smp2p)
>>>>>        }
>>>>>    }
>>>>> +static void qcom_smp2p_start_in(struct qcom_smp2p *smp2p)
>>>>> +{
>>>>> +    unsigned int smem_id = smp2p->smem_items[SMP2P_INBOUND];
>>>>> +    unsigned int pid = smp2p->remote_pid;
>>>>> +    char buf[SMP2P_MAX_ENTRY_NAME];
>>>>> +    struct smp2p_smem_item *in;
>>>>> +    struct smp2p_entry *entry;
>>>>> +    size_t size;
>>>>> +    int i;
>>>>> +
>>>>> +    in = qcom_smem_get(pid, smem_id, &size);
>>>>> +    if (IS_ERR(in))
>>>>> +        return;
>>>>> +
>>>>> +    smp2p->in = in;
>>>>> +
>>>>> +    /* Check if version is initialized by the remote. */
>>>>> +    if (in->version == 0)
>>>>> +        return;
>>>>> +
>>>>> +    for (i = smp2p->valid_entries; i < in->valid_entries; i++) {
>>>>> +        list_for_each_entry(entry, &smp2p->inbound, node) {
>>>>> +            memcpy(buf, in->entries[i].name, sizeof(buf));
>>>> Is there a reason for this copy at all?
>>> I don't see a compelling reason. This code snippet is same as present in
>>> qcom_smp2p_notify_in().
>> My understanding was that we do this copy because we don't want to do a
>> strcmp on memory that the remote could change at any time. Maybe it's
>> overkill but I thought it was considered good practice and as Deepak
>> mentioned, it is similarly present in qcom_smp2p_notify_in().
>>
>>>> [...]
>>>>
>>>>> +    /* Check inbound entries in the case of early boot processor */
>>>> "in case a remote processor has already been started"?
>>> This i can update in case new patch set is required.
>>>> Konrad
> 
> Are you expecting new patch for this update or current one is ok?

I don't have any more comments. Bjorn left a review on the previous
version so I'd be happy to see him ack this

Konrad

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 0/2] soc: qcom: smp2p: Add support for remoteproc early attach
  2026-01-27 10:38 [PATCH v3 0/2] soc: qcom: smp2p: Add support for remoteproc early attach Deepak Kumar Singh
  2026-01-27 10:38 ` [PATCH v3 1/2] soc: qcom: smp2p: Add irqchip state support Deepak Kumar Singh
  2026-01-27 10:38 ` [PATCH v3 2/2] soc: qcom: smp2p: Add support for smp2p v2 Deepak Kumar Singh
@ 2026-03-16  2:02 ` Bjorn Andersson
  2 siblings, 0 replies; 10+ messages in thread
From: Bjorn Andersson @ 2026-03-16  2:02 UTC (permalink / raw)
  To: Konrad Dybcio, Deepak Kumar Singh
  Cc: linux-arm-msm, linux-kernel, linux-remoteproc, Chris Lew


On Tue, 27 Jan 2026 16:08:44 +0530, Deepak Kumar Singh wrote:
> Some remoteproc will boot during earlier boot stages, add callback
> .irq_get_irqchip_state for remoteproc to check the states in smp2p
> and mark the state "attached", also add smp2p v2 support.
> 
> 

Applied, thanks!

[1/2] soc: qcom: smp2p: Add irqchip state support
      commit: 8a9a7b9d14c21d060301a8dd4a676ccb4ade5870
[2/2] soc: qcom: smp2p: Add support for smp2p v2
      commit: 42c4cf5d482813067789dd5ea2e33f3b7805e7e1

Best regards,
-- 
Bjorn Andersson <andersson@kernel.org>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-03-16  2:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-27 10:38 [PATCH v3 0/2] soc: qcom: smp2p: Add support for remoteproc early attach Deepak Kumar Singh
2026-01-27 10:38 ` [PATCH v3 1/2] soc: qcom: smp2p: Add irqchip state support Deepak Kumar Singh
2026-01-27 12:55   ` Konrad Dybcio
2026-01-29 10:56     ` Deepak Kumar Singh
2026-01-30  0:46       ` Chris Lew
2026-01-30 10:13         ` Konrad Dybcio
2026-02-04  7:21         ` Deepak Kumar Singh
2026-02-04 12:27           ` Konrad Dybcio
2026-01-27 10:38 ` [PATCH v3 2/2] soc: qcom: smp2p: Add support for smp2p v2 Deepak Kumar Singh
2026-03-16  2:02 ` [PATCH v3 0/2] soc: qcom: smp2p: Add support for remoteproc early attach Bjorn Andersson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®