linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] soc/fsl/qbman: DPAA QBMan fixes and additions
@ 2018-09-20 15:06 Madalin Bucur
  2018-09-20 15:06 ` [PATCH 1/4] soc/fsl/qbman: Check if CPU is offline when initializing portals Madalin Bucur
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Madalin Bucur @ 2018-09-20 15:06 UTC (permalink / raw)
  To: leoyang.li
  Cc: roy.pledge, claudiu.manoil, catalin.marinas, oss,
	linux-arm-kernel, linuxppc-dev, linux-kernel, Madalin Bucur

This patch set brings a number of fixes and the option to control
the QMan portal interrupt coalescing.

Madalin Bucur (1):
  soc/fsl_qbman: export coalesce change API

Roy Pledge (3):
  soc/fsl/qbman: Check if CPU is offline when initializing portals
  soc/fsl/qbman: Add 64 bit DMA addressing requirement to QBMan
  soc/fsl/qbman: Use last response to determine valid bit

 drivers/soc/fsl/qbman/Kconfig |  2 +-
 drivers/soc/fsl/qbman/bman.c  | 17 ++++++++---
 drivers/soc/fsl/qbman/qman.c  | 65 ++++++++++++++++++++++++++++++++++++++-----
 include/soc/fsl/qman.h        | 27 ++++++++++++++++++
 4 files changed, 99 insertions(+), 12 deletions(-)

-- 
2.1.0


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

* [PATCH 1/4] soc/fsl/qbman: Check if CPU is offline when initializing portals
  2018-09-20 15:06 [PATCH 0/4] soc/fsl/qbman: DPAA QBMan fixes and additions Madalin Bucur
@ 2018-09-20 15:06 ` Madalin Bucur
  2018-09-21 22:15   ` Li Yang
  2018-09-20 15:06 ` [PATCH 2/4] soc/fsl/qbman: Add 64 bit DMA addressing requirement to QBMan Madalin Bucur
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Madalin Bucur @ 2018-09-20 15:06 UTC (permalink / raw)
  To: leoyang.li
  Cc: roy.pledge, claudiu.manoil, catalin.marinas, oss,
	linux-arm-kernel, linuxppc-dev, linux-kernel, Madalin Bucur

From: Roy Pledge <roy.pledge@nxp.com>

If the affine portal for a specific CPU is offline at boot time
affine its interrupt to CPU 0. If the CPU is later brought online
the hotplug handler will correctly adjust the affinity.

Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
---
 drivers/soc/fsl/qbman/bman.c | 17 +++++++++++++----
 drivers/soc/fsl/qbman/qman.c | 18 +++++++++++++-----
 2 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/drivers/soc/fsl/qbman/bman.c b/drivers/soc/fsl/qbman/bman.c
index f9485cedc648..2e6e682bf16b 100644
--- a/drivers/soc/fsl/qbman/bman.c
+++ b/drivers/soc/fsl/qbman/bman.c
@@ -562,10 +562,19 @@ static int bman_create_portal(struct bman_portal *portal,
 		dev_err(c->dev, "request_irq() failed\n");
 		goto fail_irq;
 	}
-	if (c->cpu != -1 && irq_can_set_affinity(c->irq) &&
-	    irq_set_affinity(c->irq, cpumask_of(c->cpu))) {
-		dev_err(c->dev, "irq_set_affinity() failed\n");
-		goto fail_affinity;
+	if (cpu_online(c->cpu) && c->cpu != -1 &&
+	    irq_can_set_affinity(c->irq)) {
+		if (irq_set_affinity(c->irq, cpumask_of(c->cpu))) {
+			dev_err(c->dev, "irq_set_affinity() failed %d\n",
+				c->cpu);
+			goto fail_affinity;
+		}
+	} else {
+		/* CPU is offline, direct IRQ to CPU 0 */
+		if (irq_set_affinity(c->irq, cpumask_of(0))) {
+			dev_err(c->dev, "irq_set_affinity() cpu 0 failed\n");
+			goto fail_affinity;
+		}
 	}
 
 	/* Need RCR to be empty before continuing */
diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index ecb22749df0b..7dbcb475a59c 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -935,7 +935,6 @@ static inline int qm_mc_result_timeout(struct qm_portal *portal,
 			break;
 		udelay(1);
 	} while (--timeout);
-
 	return timeout;
 }
 
@@ -1210,10 +1209,19 @@ static int qman_create_portal(struct qman_portal *portal,
 		dev_err(c->dev, "request_irq() failed\n");
 		goto fail_irq;
 	}
-	if (c->cpu != -1 && irq_can_set_affinity(c->irq) &&
-	    irq_set_affinity(c->irq, cpumask_of(c->cpu))) {
-		dev_err(c->dev, "irq_set_affinity() failed\n");
-		goto fail_affinity;
+	if (cpu_online(c->cpu) && c->cpu != -1 &&
+	    irq_can_set_affinity(c->irq)) {
+		if (irq_set_affinity(c->irq, cpumask_of(c->cpu))) {
+			dev_err(c->dev, "irq_set_affinity() failed %d\n",
+				c->cpu);
+			goto fail_affinity;
+		}
+	} else {
+		/* CPU is offline, direct IRQ to CPU 0 */
+		if (irq_set_affinity(c->irq, cpumask_of(0))) {
+			dev_err(c->dev, "irq_set_affinity() cpu 0 failed\n");
+			goto fail_affinity;
+		}
 	}
 
 	/* Need EQCR to be empty before continuing */
-- 
2.1.0


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

* [PATCH 2/4] soc/fsl/qbman: Add 64 bit DMA addressing requirement to QBMan
  2018-09-20 15:06 [PATCH 0/4] soc/fsl/qbman: DPAA QBMan fixes and additions Madalin Bucur
  2018-09-20 15:06 ` [PATCH 1/4] soc/fsl/qbman: Check if CPU is offline when initializing portals Madalin Bucur
@ 2018-09-20 15:06 ` Madalin Bucur
  2018-09-20 18:54   ` Li Yang
  2018-09-20 15:06 ` [PATCH 3/4] soc/fsl/qbman: Use last response to determine valid bit Madalin Bucur
  2018-09-20 15:06 ` [PATCH 4/4] soc/fsl_qbman: export coalesce change API Madalin Bucur
  3 siblings, 1 reply; 8+ messages in thread
From: Madalin Bucur @ 2018-09-20 15:06 UTC (permalink / raw)
  To: leoyang.li
  Cc: roy.pledge, claudiu.manoil, catalin.marinas, oss,
	linux-arm-kernel, linuxppc-dev, linux-kernel, Madalin Bucur

From: Roy Pledge <roy.pledge@nxp.com>

The QBMan block is memory mapped on SoCs above a 32 bit (4 Gigabyte)
boundary so enabling 64 bit DMA addressing is needed for QBMan to
be usable.

Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
---
 drivers/soc/fsl/qbman/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/fsl/qbman/Kconfig b/drivers/soc/fsl/qbman/Kconfig
index d570cb5fd381..19d6f4621e23 100644
--- a/drivers/soc/fsl/qbman/Kconfig
+++ b/drivers/soc/fsl/qbman/Kconfig
@@ -1,6 +1,6 @@
 menuconfig FSL_DPAA
 	bool "QorIQ DPAA1 framework support"
-	depends on (FSL_SOC_BOOKE || ARCH_LAYERSCAPE)
+	depends on ((FSL_SOC_BOOKE || ARCH_LAYERSCAPE || ARM) && ARCH_DMA_ADDR_T_64BIT)
 	select GENERIC_ALLOCATOR
 	help
 	  The Freescale Data Path Acceleration Architecture (DPAA) is a set of
-- 
2.1.0


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

* [PATCH 3/4] soc/fsl/qbman: Use last response to determine valid bit
  2018-09-20 15:06 [PATCH 0/4] soc/fsl/qbman: DPAA QBMan fixes and additions Madalin Bucur
  2018-09-20 15:06 ` [PATCH 1/4] soc/fsl/qbman: Check if CPU is offline when initializing portals Madalin Bucur
  2018-09-20 15:06 ` [PATCH 2/4] soc/fsl/qbman: Add 64 bit DMA addressing requirement to QBMan Madalin Bucur
@ 2018-09-20 15:06 ` Madalin Bucur
  2018-09-20 15:06 ` [PATCH 4/4] soc/fsl_qbman: export coalesce change API Madalin Bucur
  3 siblings, 0 replies; 8+ messages in thread
From: Madalin Bucur @ 2018-09-20 15:06 UTC (permalink / raw)
  To: leoyang.li
  Cc: roy.pledge, claudiu.manoil, catalin.marinas, oss,
	linux-arm-kernel, linuxppc-dev, linux-kernel, Madalin Bucur

From: Roy Pledge <roy.pledge@nxp.com>

Use the last valid response when determining what valid bit
to use next for management commands. This is needed in the
case that the portal was previously used by other software
like a bootloader or if the kernel is restarted without a
hardware reset.

Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
---
 drivers/soc/fsl/qbman/qman.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index 7dbcb475a59c..7f4c57999e08 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -850,12 +850,24 @@ static inline void qm_mr_set_ithresh(struct qm_portal *portal, u8 ithresh)
 
 static inline int qm_mc_init(struct qm_portal *portal)
 {
+	u8 rr0, rr1;
 	struct qm_mc *mc = &portal->mc;
 
 	mc->cr = portal->addr.ce + QM_CL_CR;
 	mc->rr = portal->addr.ce + QM_CL_RR0;
-	mc->rridx = (mc->cr->_ncw_verb & QM_MCC_VERB_VBIT)
-		    ? 0 : 1;
+	/*
+	 * The expected valid bit polarity for the next CR command is 0
+	 * if RR1 contains a valid response, and is 1 if RR0 contains a
+	 * valid response. If both RR contain all 0, this indicates either
+	 * that no command has been executed since reset (in which case the
+	 * expected valid bit polarity is 1)
+	 */
+	rr0 = mc->rr->verb;
+	rr1 = (mc->rr+1)->verb;
+	if ((rr0 == 0 && rr1 == 0) || rr0 != 0)
+		mc->rridx = 1;
+	else
+		mc->rridx = 0;
 	mc->vbit = mc->rridx ? QM_MCC_VERB_VBIT : 0;
 #ifdef CONFIG_FSL_DPAA_CHECKING
 	mc->state = qman_mc_idle;
-- 
2.1.0


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

* [PATCH 4/4] soc/fsl_qbman: export coalesce change API
  2018-09-20 15:06 [PATCH 0/4] soc/fsl/qbman: DPAA QBMan fixes and additions Madalin Bucur
                   ` (2 preceding siblings ...)
  2018-09-20 15:06 ` [PATCH 3/4] soc/fsl/qbman: Use last response to determine valid bit Madalin Bucur
@ 2018-09-20 15:06 ` Madalin Bucur
  3 siblings, 0 replies; 8+ messages in thread
From: Madalin Bucur @ 2018-09-20 15:06 UTC (permalink / raw)
  To: leoyang.li
  Cc: roy.pledge, claudiu.manoil, catalin.marinas, oss,
	linux-arm-kernel, linuxppc-dev, linux-kernel, Madalin Bucur

Allow changing the QMan portal interrupt coalescing settings.

Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
---
 drivers/soc/fsl/qbman/qman.c | 31 +++++++++++++++++++++++++++++++
 include/soc/fsl/qman.h       | 27 +++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index 7f4c57999e08..c270471a6e47 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -1011,6 +1011,37 @@ static inline void put_affine_portal(void)
 
 static struct workqueue_struct *qm_portal_wq;
 
+void qman_dqrr_set_ithresh(struct qman_portal *portal, u8 ithresh)
+{
+	if (!portal)
+		return;
+
+	qm_dqrr_set_ithresh(&portal->p, ithresh);
+	portal->p.dqrr.ithresh = ithresh;
+}
+EXPORT_SYMBOL(qman_dqrr_set_ithresh);
+
+void qman_dqrr_get_ithresh(struct qman_portal *portal, u8 *ithresh)
+{
+	if (portal && ithresh)
+		*ithresh = portal->p.dqrr.ithresh;
+}
+EXPORT_SYMBOL(qman_dqrr_get_ithresh);
+
+void qman_portal_get_iperiod(struct qman_portal *portal, u32 *iperiod)
+{
+	if (portal && iperiod)
+		*iperiod = qm_in(&portal->p, QM_REG_ITPR);
+}
+EXPORT_SYMBOL(qman_portal_get_iperiod);
+
+void qman_portal_set_iperiod(struct qman_portal *portal, u32 iperiod)
+{
+	if (portal)
+		qm_out(&portal->p, QM_REG_ITPR, iperiod);
+}
+EXPORT_SYMBOL(qman_portal_set_iperiod);
+
 int qman_wq_alloc(void)
 {
 	qm_portal_wq = alloc_workqueue("qman_portal_wq", 0, 1);
diff --git a/include/soc/fsl/qman.h b/include/soc/fsl/qman.h
index d4dfefdee6c1..42f50eb51529 100644
--- a/include/soc/fsl/qman.h
+++ b/include/soc/fsl/qman.h
@@ -1186,4 +1186,31 @@ int qman_alloc_cgrid_range(u32 *result, u32 count);
  */
 int qman_release_cgrid(u32 id);
 
+/**
+ * qman_dqrr_get_ithresh - Get coalesce interrupt threshold
+ * @portal: portal to get the value for
+ * @ithresh: threshold pointer
+ */
+void qman_dqrr_get_ithresh(struct qman_portal *portal, u8 *ithresh);
+
+/**
+ * qman_dqrr_set_ithresh - Set coalesce interrupt threshold
+ * @portal: portal to set the new value on
+ * @ithresh: new threshold value
+ */
+void qman_dqrr_set_ithresh(struct qman_portal *portal, u8 ithresh);
+
+/**
+ * qman_dqrr_get_iperiod - Get coalesce interrupt period
+ * @portal: portal to get the value for
+ * @iperiod: period pointer
+ */
+void qman_portal_get_iperiod(struct qman_portal *portal, u32 *iperiod);
+/*
+ * qman_dqrr_set_iperiod - Set coalesce interrupt period
+ * @portal: portal to set the new value on
+ * @ithresh: new period value
+ */
+void qman_portal_set_iperiod(struct qman_portal *portal, u32 iperiod);
+
 #endif	/* __FSL_QMAN_H */
-- 
2.1.0


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

* Re: [PATCH 2/4] soc/fsl/qbman: Add 64 bit DMA addressing requirement to QBMan
  2018-09-20 15:06 ` [PATCH 2/4] soc/fsl/qbman: Add 64 bit DMA addressing requirement to QBMan Madalin Bucur
@ 2018-09-20 18:54   ` Li Yang
  0 siblings, 0 replies; 8+ messages in thread
From: Li Yang @ 2018-09-20 18:54 UTC (permalink / raw)
  To: madalin.bucur
  Cc: Roy Pledge, claudiu.manoil, Catalin Marinas, Scott Wood,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	linuxppc-dev, lkml

On Thu, Sep 20, 2018 at 10:09 AM Madalin Bucur <madalin.bucur@nxp.com> wrote:
>
> From: Roy Pledge <roy.pledge@nxp.com>
>
> The QBMan block is memory mapped on SoCs above a 32 bit (4 Gigabyte)
> boundary so enabling 64 bit DMA addressing is needed for QBMan to
> be usable.
>
> Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
> Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
> ---
>  drivers/soc/fsl/qbman/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/soc/fsl/qbman/Kconfig b/drivers/soc/fsl/qbman/Kconfig
> index d570cb5fd381..19d6f4621e23 100644
> --- a/drivers/soc/fsl/qbman/Kconfig
> +++ b/drivers/soc/fsl/qbman/Kconfig
> @@ -1,6 +1,6 @@
>  menuconfig FSL_DPAA
>         bool "QorIQ DPAA1 framework support"
> -       depends on (FSL_SOC_BOOKE || ARCH_LAYERSCAPE)
> +       depends on ((FSL_SOC_BOOKE || ARCH_LAYERSCAPE || ARM) && ARCH_DMA_ADDR_T_64BIT)

You also added ARM support here.  Actually the dependency on
ARCH_DMA_ADDR_T_64BIT is only explicitly needed by ARM(other platforms
already implies ARCH_DMA_ADDR_T_64BIT).  So I think the patch title
should be like: adding 32-bit ARM support.  The ARCH_DMA_ADDR_T_64BIT
is enabled by ARM_LPAE on ARM.  Probably we should make that
straightforward in the Kconfig, so that people better understand what
is needed for 32-bit ARM.

>         select GENERIC_ALLOCATOR
>         help
>           The Freescale Data Path Acceleration Architecture (DPAA) is a set of
> --
> 2.1.0
>

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

* Re: [PATCH 1/4] soc/fsl/qbman: Check if CPU is offline when initializing portals
  2018-09-20 15:06 ` [PATCH 1/4] soc/fsl/qbman: Check if CPU is offline when initializing portals Madalin Bucur
@ 2018-09-21 22:15   ` Li Yang
  2018-09-24  8:54     ` Madalin-cristian Bucur
  0 siblings, 1 reply; 8+ messages in thread
From: Li Yang @ 2018-09-21 22:15 UTC (permalink / raw)
  To: madalin.bucur
  Cc: Roy Pledge, claudiu.manoil, Catalin Marinas, Scott Wood,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	linuxppc-dev, lkml

On Thu, Sep 20, 2018 at 10:09 AM Madalin Bucur <madalin.bucur@nxp.com> wrote:
>
> From: Roy Pledge <roy.pledge@nxp.com>
>
> If the affine portal for a specific CPU is offline at boot time
> affine its interrupt to CPU 0. If the CPU is later brought online
> the hotplug handler will correctly adjust the affinity.

Although this does provide better compatibility with cpu hotplug, we
still have a problem.  You are assuming the CPU0 is always online
which is not the case for arm64.  How about not setting the affinity
and let the system decide if the dedicated CPU is offline?

>
> Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
> Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
> ---
>  drivers/soc/fsl/qbman/bman.c | 17 +++++++++++++----
>  drivers/soc/fsl/qbman/qman.c | 18 +++++++++++++-----
>  2 files changed, 26 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/soc/fsl/qbman/bman.c b/drivers/soc/fsl/qbman/bman.c
> index f9485cedc648..2e6e682bf16b 100644
> --- a/drivers/soc/fsl/qbman/bman.c
> +++ b/drivers/soc/fsl/qbman/bman.c
> @@ -562,10 +562,19 @@ static int bman_create_portal(struct bman_portal *portal,
>                 dev_err(c->dev, "request_irq() failed\n");
>                 goto fail_irq;
>         }
> -       if (c->cpu != -1 && irq_can_set_affinity(c->irq) &&
> -           irq_set_affinity(c->irq, cpumask_of(c->cpu))) {
> -               dev_err(c->dev, "irq_set_affinity() failed\n");
> -               goto fail_affinity;
> +       if (cpu_online(c->cpu) && c->cpu != -1 &&
> +           irq_can_set_affinity(c->irq)) {
> +               if (irq_set_affinity(c->irq, cpumask_of(c->cpu))) {
> +                       dev_err(c->dev, "irq_set_affinity() failed %d\n",
> +                               c->cpu);
> +                       goto fail_affinity;
> +               }
> +       } else {
> +               /* CPU is offline, direct IRQ to CPU 0 */
> +               if (irq_set_affinity(c->irq, cpumask_of(0))) {
> +                       dev_err(c->dev, "irq_set_affinity() cpu 0 failed\n");
> +                       goto fail_affinity;
> +               }
>         }
>
>         /* Need RCR to be empty before continuing */
> diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
> index ecb22749df0b..7dbcb475a59c 100644
> --- a/drivers/soc/fsl/qbman/qman.c
> +++ b/drivers/soc/fsl/qbman/qman.c
> @@ -935,7 +935,6 @@ static inline int qm_mc_result_timeout(struct qm_portal *portal,
>                         break;
>                 udelay(1);
>         } while (--timeout);
> -
>         return timeout;
>  }
>
> @@ -1210,10 +1209,19 @@ static int qman_create_portal(struct qman_portal *portal,
>                 dev_err(c->dev, "request_irq() failed\n");
>                 goto fail_irq;
>         }
> -       if (c->cpu != -1 && irq_can_set_affinity(c->irq) &&
> -           irq_set_affinity(c->irq, cpumask_of(c->cpu))) {
> -               dev_err(c->dev, "irq_set_affinity() failed\n");
> -               goto fail_affinity;
> +       if (cpu_online(c->cpu) && c->cpu != -1 &&
> +           irq_can_set_affinity(c->irq)) {
> +               if (irq_set_affinity(c->irq, cpumask_of(c->cpu))) {
> +                       dev_err(c->dev, "irq_set_affinity() failed %d\n",
> +                               c->cpu);
> +                       goto fail_affinity;
> +               }
> +       } else {
> +               /* CPU is offline, direct IRQ to CPU 0 */
> +               if (irq_set_affinity(c->irq, cpumask_of(0))) {
> +                       dev_err(c->dev, "irq_set_affinity() cpu 0 failed\n");
> +                       goto fail_affinity;
> +               }
>         }
>
>         /* Need EQCR to be empty before continuing */
> --
> 2.1.0
>

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

* RE: [PATCH 1/4] soc/fsl/qbman: Check if CPU is offline when initializing portals
  2018-09-21 22:15   ` Li Yang
@ 2018-09-24  8:54     ` Madalin-cristian Bucur
  0 siblings, 0 replies; 8+ messages in thread
From: Madalin-cristian Bucur @ 2018-09-24  8:54 UTC (permalink / raw)
  To: Leo Li, Roy Pledge
  Cc: Claudiu Manoil, Catalin Marinas, Scott Wood,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	linuxppc-dev, lkml

> -----Original Message-----
> From: Li Yang [mailto:leoyang.li@nxp.com]
> Sent: Saturday, September 22, 2018 1:15 AM
> To: Madalin-cristian Bucur <madalin.bucur@nxp.com>
> Subject: Re: [PATCH 1/4] soc/fsl/qbman: Check if CPU is offline when
> initializing portals
> 
> On Thu, Sep 20, 2018 at 10:09 AM Madalin Bucur <madalin.bucur@nxp.com>
> wrote:
> >
> > From: Roy Pledge <roy.pledge@nxp.com>
> >
> > If the affine portal for a specific CPU is offline at boot time
> > affine its interrupt to CPU 0. If the CPU is later brought online
> > the hotplug handler will correctly adjust the affinity.
> 
> Although this does provide better compatibility with cpu hotplug, we
> still have a problem.  You are assuming the CPU0 is always online
> which is not the case for arm64.  How about not setting the affinity
> and let the system decide if the dedicated CPU is offline?

I can change the hardcoding of CPU 0 with raw_smp_processor_id().
While we're at it, I'd move the introduced code into a helper function
to avoid duplication:

static inline void dpaa_set_portal_irq_affinity(struct device* dev,
								int cpu, int irq)

> >
> > Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
> > Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
> > ---
> >  drivers/soc/fsl/qbman/bman.c | 17 +++++++++++++----
> >  drivers/soc/fsl/qbman/qman.c | 18 +++++++++++++-----
> >  2 files changed, 26 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/soc/fsl/qbman/bman.c b/drivers/soc/fsl/qbman/bman.c
> > index f9485cedc648..2e6e682bf16b 100644
> > --- a/drivers/soc/fsl/qbman/bman.c
> > +++ b/drivers/soc/fsl/qbman/bman.c
> > @@ -562,10 +562,19 @@ static int bman_create_portal(struct bman_portal
> *portal,
> >                 dev_err(c->dev, "request_irq() failed\n");
> >                 goto fail_irq;
> >         }
> > -       if (c->cpu != -1 && irq_can_set_affinity(c->irq) &&
> > -           irq_set_affinity(c->irq, cpumask_of(c->cpu))) {
> > -               dev_err(c->dev, "irq_set_affinity() failed\n");
> > -               goto fail_affinity;
> > +       if (cpu_online(c->cpu) && c->cpu != -1 &&
> > +           irq_can_set_affinity(c->irq)) {
> > +               if (irq_set_affinity(c->irq, cpumask_of(c->cpu))) {
> > +                       dev_err(c->dev, "irq_set_affinity() failed
> %d\n",
> > +                               c->cpu);
> > +                       goto fail_affinity;
> > +               }
> > +       } else {
> > +               /* CPU is offline, direct IRQ to CPU 0 */
> > +               if (irq_set_affinity(c->irq, cpumask_of(0))) {
> > +                       dev_err(c->dev, "irq_set_affinity() cpu 0
> failed\n");
> > +                       goto fail_affinity;
> > +               }
> >         }
> >
> >         /* Need RCR to be empty before continuing */
> > diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
> > index ecb22749df0b..7dbcb475a59c 100644
> > --- a/drivers/soc/fsl/qbman/qman.c
> > +++ b/drivers/soc/fsl/qbman/qman.c
> > @@ -935,7 +935,6 @@ static inline int qm_mc_result_timeout(struct
> qm_portal *portal,
> >                         break;
> >                 udelay(1);
> >         } while (--timeout);
> > -
> >         return timeout;
> >  }
> >
> > @@ -1210,10 +1209,19 @@ static int qman_create_portal(struct qman_portal
> *portal,
> >                 dev_err(c->dev, "request_irq() failed\n");
> >                 goto fail_irq;
> >         }
> > -       if (c->cpu != -1 && irq_can_set_affinity(c->irq) &&
> > -           irq_set_affinity(c->irq, cpumask_of(c->cpu))) {
> > -               dev_err(c->dev, "irq_set_affinity() failed\n");
> > -               goto fail_affinity;
> > +       if (cpu_online(c->cpu) && c->cpu != -1 &&
> > +           irq_can_set_affinity(c->irq)) {
> > +               if (irq_set_affinity(c->irq, cpumask_of(c->cpu))) {
> > +                       dev_err(c->dev, "irq_set_affinity() failed
> %d\n",
> > +                               c->cpu);
> > +                       goto fail_affinity;
> > +               }
> > +       } else {
> > +               /* CPU is offline, direct IRQ to CPU 0 */
> > +               if (irq_set_affinity(c->irq, cpumask_of(0))) {
> > +                       dev_err(c->dev, "irq_set_affinity() cpu 0
> failed\n");
> > +                       goto fail_affinity;
> > +               }
> >         }
> >
> >         /* Need EQCR to be empty before continuing */
> > --
> > 2.1.0
> >

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

end of thread, other threads:[~2018-09-24  8:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-20 15:06 [PATCH 0/4] soc/fsl/qbman: DPAA QBMan fixes and additions Madalin Bucur
2018-09-20 15:06 ` [PATCH 1/4] soc/fsl/qbman: Check if CPU is offline when initializing portals Madalin Bucur
2018-09-21 22:15   ` Li Yang
2018-09-24  8:54     ` Madalin-cristian Bucur
2018-09-20 15:06 ` [PATCH 2/4] soc/fsl/qbman: Add 64 bit DMA addressing requirement to QBMan Madalin Bucur
2018-09-20 18:54   ` Li Yang
2018-09-20 15:06 ` [PATCH 3/4] soc/fsl/qbman: Use last response to determine valid bit Madalin Bucur
2018-09-20 15:06 ` [PATCH 4/4] soc/fsl_qbman: export coalesce change API Madalin Bucur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).