linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] Few more FlexRM driver improvements
@ 2017-10-03  5:21 Anup Patel
  2017-10-03  5:21 ` [PATCH 1/5] mailbox: bcm-flexrm-mailbox: Fix FlexRM ring flush sequence Anup Patel
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Anup Patel @ 2017-10-03  5:21 UTC (permalink / raw)
  To: Jassi Brar
  Cc: Ray Jui, Scott Branden, Florian Fainelli, linux-kernel,
	linux-arm-kernel, bcm-kernel-feedback-list, Anup Patel

This patchset does few more improvements to Broadcom FlexRM mailbox
driver.

The patches are based on Linux-4.14-rc3 and can also be found at
flexrm-imp2-v1 branch of:
https://github.com/Broadcom/arm64-linux.git

Anup Patel (4):
  mailbox: bcm-flexrm-mailbox: Fix FlexRM ring flush sequence
  mailbox: bcm-flexrm-mailbox: Print ring number in errors and warnings
  mailbox: bcm-flexrm-mailbox: Use common GPL comment header
  mailbox: Build Broadcom FlexRM driver as loadable module for iProc
    SOCs

Scott Branden (1):
  mailbox: bcm-flexrm-mailbox: add depends on ARCH_BCM_IPROC

 drivers/mailbox/Kconfig              |  3 +-
 drivers/mailbox/bcm-flexrm-mailbox.c | 66 ++++++++++++++++++++++++++----------
 2 files changed, 51 insertions(+), 18 deletions(-)

-- 
2.7.4

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

* [PATCH 1/5] mailbox: bcm-flexrm-mailbox: Fix FlexRM ring flush sequence
  2017-10-03  5:21 [PATCH 0/5] Few more FlexRM driver improvements Anup Patel
@ 2017-10-03  5:21 ` Anup Patel
  2017-10-03  5:21 ` [PATCH 2/5] mailbox: bcm-flexrm-mailbox: Print ring number in errors and warnings Anup Patel
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Anup Patel @ 2017-10-03  5:21 UTC (permalink / raw)
  To: Jassi Brar
  Cc: Ray Jui, Scott Branden, Florian Fainelli, linux-kernel,
	linux-arm-kernel, bcm-kernel-feedback-list, Anup Patel, stable

As-per suggestion from FlexRM HW folks, we have to first set
FlexRM ring flush state and then clear it for FlexRM ring flush
to work properly.

Currently, the FlexRM driver has incomplete FlexRM ring flush
sequence which causes repeated insmod+rmmod of mailbox client
drivers to fail.

This patch fixes FlexRM ring flush sequence in flexrm_shutdown()
as described above.

Fixes: dbc049eee730 ("mailbox: Add driver for Broadcom FlexRM
ring manager")

Signed-off-by: Anup Patel <anup.patel@broadcom.com>
Reviewed-by: Scott Branden <scott.branden@broadcom.com>
Cc: stable@vger.kernel.org
---
 drivers/mailbox/bcm-flexrm-mailbox.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/mailbox/bcm-flexrm-mailbox.c b/drivers/mailbox/bcm-flexrm-mailbox.c
index ae61463..f052a3e 100644
--- a/drivers/mailbox/bcm-flexrm-mailbox.c
+++ b/drivers/mailbox/bcm-flexrm-mailbox.c
@@ -1365,8 +1365,8 @@ static void flexrm_shutdown(struct mbox_chan *chan)
 	/* Disable/inactivate ring */
 	writel_relaxed(0x0, ring->regs + RING_CONTROL);
 
-	/* Flush ring with timeout of 1s */
-	timeout = 1000;
+	/* Set ring flush state */
+	timeout = 1000; /* timeout of 1s */
 	writel_relaxed(BIT(CONTROL_FLUSH_SHIFT),
 			ring->regs + RING_CONTROL);
 	do {
@@ -1374,7 +1374,23 @@ static void flexrm_shutdown(struct mbox_chan *chan)
 		    FLUSH_DONE_MASK)
 			break;
 		mdelay(1);
-	} while (timeout--);
+	} while (--timeout);
+	if (!timeout)
+		dev_err(ring->mbox->dev,
+			"setting ring%d flush state timedout\n", ring->num);
+
+	/* Clear ring flush state */
+	timeout = 1000; /* timeout of 1s */
+	writel_relaxed(0x0, ring + RING_CONTROL);
+	do {
+		if (!(readl_relaxed(ring + RING_FLUSH_DONE) &
+		      FLUSH_DONE_MASK))
+			break;
+		mdelay(1);
+	} while (--timeout);
+	if (!timeout)
+		dev_err(ring->mbox->dev,
+			"clearing ring%d flush state timedout\n", ring->num);
 
 	/* Abort all in-flight requests */
 	for (reqid = 0; reqid < RING_MAX_REQ_COUNT; reqid++) {
-- 
2.7.4

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

* [PATCH 2/5] mailbox: bcm-flexrm-mailbox: Print ring number in errors and warnings
  2017-10-03  5:21 [PATCH 0/5] Few more FlexRM driver improvements Anup Patel
  2017-10-03  5:21 ` [PATCH 1/5] mailbox: bcm-flexrm-mailbox: Fix FlexRM ring flush sequence Anup Patel
@ 2017-10-03  5:21 ` Anup Patel
  2017-10-03  5:21 ` [PATCH 3/5] mailbox: bcm-flexrm-mailbox: add depends on ARCH_BCM_IPROC Anup Patel
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Anup Patel @ 2017-10-03  5:21 UTC (permalink / raw)
  To: Jassi Brar
  Cc: Ray Jui, Scott Branden, Florian Fainelli, linux-kernel,
	linux-arm-kernel, bcm-kernel-feedback-list, Anup Patel

This patch updates all dev_err() and dev_warn() to print
ring number so that we have more info for debugging.

Signed-off-by: Anup Patel <anup.patel@broadcom.com>
Reviewed-by: Scott Branden <scott.branden@broadcom.com>
---
 drivers/mailbox/bcm-flexrm-mailbox.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/drivers/mailbox/bcm-flexrm-mailbox.c b/drivers/mailbox/bcm-flexrm-mailbox.c
index f052a3e..e0443ae 100644
--- a/drivers/mailbox/bcm-flexrm-mailbox.c
+++ b/drivers/mailbox/bcm-flexrm-mailbox.c
@@ -1116,8 +1116,8 @@ static int flexrm_process_completions(struct flexrm_ring *ring)
 		err = flexrm_cmpl_desc_to_error(desc);
 		if (err < 0) {
 			dev_warn(ring->mbox->dev,
-				 "got completion desc=0x%lx with error %d",
-				 (unsigned long)desc, err);
+			"ring%d got completion desc=0x%lx with error %d\n",
+			ring->num, (unsigned long)desc, err);
 		}
 
 		/* Determine request id from completion descriptor */
@@ -1127,8 +1127,8 @@ static int flexrm_process_completions(struct flexrm_ring *ring)
 		msg = ring->requests[reqid];
 		if (!msg) {
 			dev_warn(ring->mbox->dev,
-				 "null msg pointer for completion desc=0x%lx",
-				 (unsigned long)desc);
+			"ring%d null msg pointer for completion desc=0x%lx\n",
+			ring->num, (unsigned long)desc);
 			continue;
 		}
 
@@ -1238,7 +1238,9 @@ static int flexrm_startup(struct mbox_chan *chan)
 	ring->bd_base = dma_pool_alloc(ring->mbox->bd_pool,
 				       GFP_KERNEL, &ring->bd_dma_base);
 	if (!ring->bd_base) {
-		dev_err(ring->mbox->dev, "can't allocate BD memory\n");
+		dev_err(ring->mbox->dev,
+			"can't allocate BD memory for ring%d\n",
+			ring->num);
 		ret = -ENOMEM;
 		goto fail;
 	}
@@ -1261,7 +1263,9 @@ static int flexrm_startup(struct mbox_chan *chan)
 	ring->cmpl_base = dma_pool_alloc(ring->mbox->cmpl_pool,
 					 GFP_KERNEL, &ring->cmpl_dma_base);
 	if (!ring->cmpl_base) {
-		dev_err(ring->mbox->dev, "can't allocate completion memory\n");
+		dev_err(ring->mbox->dev,
+			"can't allocate completion memory for ring%d\n",
+			ring->num);
 		ret = -ENOMEM;
 		goto fail_free_bd_memory;
 	}
@@ -1269,7 +1273,8 @@ static int flexrm_startup(struct mbox_chan *chan)
 
 	/* Request IRQ */
 	if (ring->irq == UINT_MAX) {
-		dev_err(ring->mbox->dev, "ring IRQ not available\n");
+		dev_err(ring->mbox->dev,
+			"ring%d IRQ not available\n", ring->num);
 		ret = -ENODEV;
 		goto fail_free_cmpl_memory;
 	}
@@ -1278,7 +1283,8 @@ static int flexrm_startup(struct mbox_chan *chan)
 				   flexrm_irq_thread,
 				   0, dev_name(ring->mbox->dev), ring);
 	if (ret) {
-		dev_err(ring->mbox->dev, "failed to request ring IRQ\n");
+		dev_err(ring->mbox->dev,
+			"failed to request ring%d IRQ\n", ring->num);
 		goto fail_free_cmpl_memory;
 	}
 	ring->irq_requested = true;
@@ -1291,7 +1297,9 @@ static int flexrm_startup(struct mbox_chan *chan)
 			&ring->irq_aff_hint);
 	ret = irq_set_affinity_hint(ring->irq, &ring->irq_aff_hint);
 	if (ret) {
-		dev_err(ring->mbox->dev, "failed to set IRQ affinity hint\n");
+		dev_err(ring->mbox->dev,
+			"failed to set IRQ affinity hint for ring%d\n",
+			ring->num);
 		goto fail_free_irq;
 	}
 
-- 
2.7.4

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

* [PATCH 3/5] mailbox: bcm-flexrm-mailbox: add depends on ARCH_BCM_IPROC
  2017-10-03  5:21 [PATCH 0/5] Few more FlexRM driver improvements Anup Patel
  2017-10-03  5:21 ` [PATCH 1/5] mailbox: bcm-flexrm-mailbox: Fix FlexRM ring flush sequence Anup Patel
  2017-10-03  5:21 ` [PATCH 2/5] mailbox: bcm-flexrm-mailbox: Print ring number in errors and warnings Anup Patel
@ 2017-10-03  5:21 ` Anup Patel
  2017-10-03  5:21 ` [PATCH 4/5] mailbox: bcm-flexrm-mailbox: Use common GPL comment header Anup Patel
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Anup Patel @ 2017-10-03  5:21 UTC (permalink / raw)
  To: Jassi Brar
  Cc: Ray Jui, Scott Branden, Florian Fainelli, linux-kernel,
	linux-arm-kernel, bcm-kernel-feedback-list, Scott Branden

From: Scott Branden <scott.branden@broadcom.com>

The Broadcom FlexRM Mailbox is only present in the Broadcom IPROC SoCs.
Add depends on ARCH_BCM_IPROC to BCM_FLEXRX_MBOX.

Signed-off-by: Scott Branden <scott.branden@broadcom.com>
Reviewed-by: Ray Jui <ray.jui@broadcom.com>
---
 drivers/mailbox/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
index c5731e5..3161f23 100644
--- a/drivers/mailbox/Kconfig
+++ b/drivers/mailbox/Kconfig
@@ -163,6 +163,7 @@ config BCM_PDC_MBOX
 config BCM_FLEXRM_MBOX
 	tristate "Broadcom FlexRM Mailbox"
 	depends on ARM64
+	depends on ARCH_BCM_IPROC || COMPILE_TEST
 	depends on HAS_DMA
 	select GENERIC_MSI_IRQ_DOMAIN
 	default ARCH_BCM_IPROC
-- 
2.7.4

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

* [PATCH 4/5] mailbox: bcm-flexrm-mailbox: Use common GPL comment header
  2017-10-03  5:21 [PATCH 0/5] Few more FlexRM driver improvements Anup Patel
                   ` (2 preceding siblings ...)
  2017-10-03  5:21 ` [PATCH 3/5] mailbox: bcm-flexrm-mailbox: add depends on ARCH_BCM_IPROC Anup Patel
@ 2017-10-03  5:21 ` Anup Patel
  2017-10-03  5:21 ` [PATCH 5/5] mailbox: Build Broadcom FlexRM driver as loadable module for iProc SOCs Anup Patel
  2017-10-27  5:20 ` [PATCH 0/5] Few more FlexRM driver improvements Anup Patel
  5 siblings, 0 replies; 7+ messages in thread
From: Anup Patel @ 2017-10-03  5:21 UTC (permalink / raw)
  To: Jassi Brar
  Cc: Ray Jui, Scott Branden, Florian Fainelli, linux-kernel,
	linux-arm-kernel, bcm-kernel-feedback-list, Anup Patel

This patch makes the comment header of Broadcom FlexRM driver
similar to the GPL comment header used across Broadcom driver
sources.

Signed-off-by: Anup Patel <anup.patel@broadcom.com>
---
 drivers/mailbox/bcm-flexrm-mailbox.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/mailbox/bcm-flexrm-mailbox.c b/drivers/mailbox/bcm-flexrm-mailbox.c
index e0443ae..a8cf433 100644
--- a/drivers/mailbox/bcm-flexrm-mailbox.c
+++ b/drivers/mailbox/bcm-flexrm-mailbox.c
@@ -1,10 +1,18 @@
-/* Broadcom FlexRM Mailbox Driver
- *
+/*
  * Copyright (C) 2017 Broadcom
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+/*
+ * Broadcom FlexRM Mailbox Driver
  *
  * Each Broadcom FlexSparx4 offload engine is implemented as an
  * extension to Broadcom FlexRM ring manager. The FlexRM ring
-- 
2.7.4

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

* [PATCH 5/5] mailbox: Build Broadcom FlexRM driver as loadable module for iProc SOCs
  2017-10-03  5:21 [PATCH 0/5] Few more FlexRM driver improvements Anup Patel
                   ` (3 preceding siblings ...)
  2017-10-03  5:21 ` [PATCH 4/5] mailbox: bcm-flexrm-mailbox: Use common GPL comment header Anup Patel
@ 2017-10-03  5:21 ` Anup Patel
  2017-10-27  5:20 ` [PATCH 0/5] Few more FlexRM driver improvements Anup Patel
  5 siblings, 0 replies; 7+ messages in thread
From: Anup Patel @ 2017-10-03  5:21 UTC (permalink / raw)
  To: Jassi Brar
  Cc: Ray Jui, Scott Branden, Florian Fainelli, linux-kernel,
	linux-arm-kernel, bcm-kernel-feedback-list, Anup Patel

By default, we build Broadcom FlexRM driver as loadable module for
iProc SOCs so that kernel image is little smaller and we load FlexRM
driver only when required.

Signed-off-by: Anup Patel <anup.patel@broadcom.com>
Reviewed-by: Scott Branden <scott.branden@broadcom.com>
---
 drivers/mailbox/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
index 3161f23..ba2f152 100644
--- a/drivers/mailbox/Kconfig
+++ b/drivers/mailbox/Kconfig
@@ -166,7 +166,7 @@ config BCM_FLEXRM_MBOX
 	depends on ARCH_BCM_IPROC || COMPILE_TEST
 	depends on HAS_DMA
 	select GENERIC_MSI_IRQ_DOMAIN
-	default ARCH_BCM_IPROC
+	default m if ARCH_BCM_IPROC
 	help
 	  Mailbox implementation of the Broadcom FlexRM ring manager,
 	  which provides access to various offload engines on Broadcom
-- 
2.7.4

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

* Re: [PATCH 0/5] Few more FlexRM driver improvements
  2017-10-03  5:21 [PATCH 0/5] Few more FlexRM driver improvements Anup Patel
                   ` (4 preceding siblings ...)
  2017-10-03  5:21 ` [PATCH 5/5] mailbox: Build Broadcom FlexRM driver as loadable module for iProc SOCs Anup Patel
@ 2017-10-27  5:20 ` Anup Patel
  5 siblings, 0 replies; 7+ messages in thread
From: Anup Patel @ 2017-10-27  5:20 UTC (permalink / raw)
  To: Jassi Brar
  Cc: Ray Jui, Scott Branden, Florian Fainelli, Linux Kernel,
	Linux ARM Kernel, BCM Kernel Feedback, Anup Patel

On Tue, Oct 3, 2017 at 10:51 AM, Anup Patel <anup.patel@broadcom.com> wrote:
> This patchset does few more improvements to Broadcom FlexRM mailbox
> driver.
>
> The patches are based on Linux-4.14-rc3 and can also be found at
> flexrm-imp2-v1 branch of:
> https://github.com/Broadcom/arm64-linux.git
>
> Anup Patel (4):
>   mailbox: bcm-flexrm-mailbox: Fix FlexRM ring flush sequence
>   mailbox: bcm-flexrm-mailbox: Print ring number in errors and warnings
>   mailbox: bcm-flexrm-mailbox: Use common GPL comment header
>   mailbox: Build Broadcom FlexRM driver as loadable module for iProc
>     SOCs
>
> Scott Branden (1):
>   mailbox: bcm-flexrm-mailbox: add depends on ARCH_BCM_IPROC
>
>  drivers/mailbox/Kconfig              |  3 +-
>  drivers/mailbox/bcm-flexrm-mailbox.c | 66 ++++++++++++++++++++++++++----------
>  2 files changed, 51 insertions(+), 18 deletions(-)
>
> --
> 2.7.4
>

Ping ??

Regards,
Anup

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

end of thread, other threads:[~2017-10-27  5:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-03  5:21 [PATCH 0/5] Few more FlexRM driver improvements Anup Patel
2017-10-03  5:21 ` [PATCH 1/5] mailbox: bcm-flexrm-mailbox: Fix FlexRM ring flush sequence Anup Patel
2017-10-03  5:21 ` [PATCH 2/5] mailbox: bcm-flexrm-mailbox: Print ring number in errors and warnings Anup Patel
2017-10-03  5:21 ` [PATCH 3/5] mailbox: bcm-flexrm-mailbox: add depends on ARCH_BCM_IPROC Anup Patel
2017-10-03  5:21 ` [PATCH 4/5] mailbox: bcm-flexrm-mailbox: Use common GPL comment header Anup Patel
2017-10-03  5:21 ` [PATCH 5/5] mailbox: Build Broadcom FlexRM driver as loadable module for iProc SOCs Anup Patel
2017-10-27  5:20 ` [PATCH 0/5] Few more FlexRM driver improvements Anup Patel

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).