All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] DMA fixes for PS3 device drivers
@ 2021-06-03 19:16 Geoff Levand
  2021-06-03 19:17 ` [PATCH v2 2/3] powerpc/ps3: Warn on PS3 device errors Geoff Levand
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Geoff Levand @ 2021-06-03 19:16 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Jakub Kicinski, linuxppc-dev, David S. Miller, netdev

Hi Michael,

This is a set of patches that fix various DMA related problems in the PS3
device drivers, and add better error checking and improved message logging.

Changes from V1:
  Split the V1 series into two, one series with powerpc changes, and one series
  with gelic network driver changes.
  
-Geoff

The following changes since commit 8124c8a6b35386f73523d27eacb71b5364a68c4c:

  Linux 5.13-rc4 (2021-05-30 11:58:25 -1000)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/geoff/ps3-linux.git for-merge-dma-powerpc

for you to fetch changes up to 562d0c9ea0100a30c3b186bcc7adb34b0bbd2cd7:

  powerpc/ps3: Add dma_mask to ps3_dma_region (2021-06-01 12:27:43 -0700)

----------------------------------------------------------------
Geoff Levand (3):
      powerpc/ps3: Add CONFIG_PS3_VERBOSE_RESULT option
      powerpc/ps3: Warn on PS3 device errors
      powerpc/ps3: Add dma_mask to ps3_dma_region

 arch/powerpc/include/asm/ps3.h          |  4 +++-
 arch/powerpc/platforms/ps3/Kconfig      |  9 +++++++++
 arch/powerpc/platforms/ps3/mm.c         | 12 ++++++++++++
 arch/powerpc/platforms/ps3/system-bus.c |  9 +++++----
 drivers/ps3/ps3-vuart.c                 |  2 +-
 drivers/ps3/ps3av.c                     | 22 +++++++++++-----------
 6 files changed, 41 insertions(+), 17 deletions(-)

-- 
2.25.1


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

* [PATCH v2 1/3] powerpc/ps3: Add CONFIG_PS3_VERBOSE_RESULT option
  2021-06-03 19:16 [PATCH v2 0/3] DMA fixes for PS3 device drivers Geoff Levand
  2021-06-03 19:17 ` [PATCH v2 2/3] powerpc/ps3: Warn on PS3 device errors Geoff Levand
@ 2021-06-03 19:17 ` Geoff Levand
  2021-06-03 19:17 ` [PATCH v2 3/3] powerpc/ps3: Add dma_mask to ps3_dma_region Geoff Levand
  2021-06-18  3:51   ` Michael Ellerman
  3 siblings, 0 replies; 6+ messages in thread
From: Geoff Levand @ 2021-06-03 19:17 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Jakub Kicinski, linuxppc-dev, David S. Miller, netdev

To aid debugging, add a new PS3 kernel config option
PS3_VERBOSE_RESULT that, when enabled, will print more
verbose messages for the result of LV1 hypercalls.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 arch/powerpc/include/asm/ps3.h     | 2 +-
 arch/powerpc/platforms/ps3/Kconfig | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/ps3.h b/arch/powerpc/include/asm/ps3.h
index e646c7f218bc..7df145901def 100644
--- a/arch/powerpc/include/asm/ps3.h
+++ b/arch/powerpc/include/asm/ps3.h
@@ -232,7 +232,7 @@ enum lv1_result {
 
 static inline const char* ps3_result(int result)
 {
-#if defined(DEBUG) || defined(PS3_VERBOSE_RESULT)
+#if defined(DEBUG) || defined(PS3_VERBOSE_RESULT) || defined(CONFIG_PS3_VERBOSE_RESULT)
 	switch (result) {
 	case LV1_SUCCESS:
 		return "LV1_SUCCESS (0)";
diff --git a/arch/powerpc/platforms/ps3/Kconfig b/arch/powerpc/platforms/ps3/Kconfig
index e32406e918d0..ebed94942d39 100644
--- a/arch/powerpc/platforms/ps3/Kconfig
+++ b/arch/powerpc/platforms/ps3/Kconfig
@@ -85,6 +85,15 @@ config PS3_SYS_MANAGER
 	  This support is required for PS3 system control.  In
 	  general, all users will say Y or M.
 
+config PS3_VERBOSE_RESULT
+	bool "PS3 Verbose LV1 hypercall results" if PS3_ADVANCED
+	depends on PPC_PS3
+	help
+	  Enables more verbose log mesages for LV1 hypercall results.
+
+	  If in doubt, say N here and reduce the size of the kernel by a
+	  small amount.
+
 config PS3_REPOSITORY_WRITE
 	bool "PS3 Repository write support" if PS3_ADVANCED
 	depends on PPC_PS3
-- 
2.25.1



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

* [PATCH v2 2/3] powerpc/ps3: Warn on PS3 device errors
  2021-06-03 19:16 [PATCH v2 0/3] DMA fixes for PS3 device drivers Geoff Levand
@ 2021-06-03 19:17 ` Geoff Levand
  2021-06-03 19:17 ` [PATCH v2 1/3] powerpc/ps3: Add CONFIG_PS3_VERBOSE_RESULT option Geoff Levand
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Geoff Levand @ 2021-06-03 19:17 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Jakub Kicinski, linuxppc-dev, David S. Miller, netdev

To aid debugging PS3 boot problems change the log level
of several PS3 device errors from pr_debug to pr_warn.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 arch/powerpc/platforms/ps3/system-bus.c |  9 +++++----
 drivers/ps3/ps3-vuart.c                 |  2 +-
 drivers/ps3/ps3av.c                     | 22 +++++++++++-----------
 3 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/platforms/ps3/system-bus.c b/arch/powerpc/platforms/ps3/system-bus.c
index b431f41c6cb5..1a5665875165 100644
--- a/arch/powerpc/platforms/ps3/system-bus.c
+++ b/arch/powerpc/platforms/ps3/system-bus.c
@@ -64,9 +64,10 @@ static int ps3_open_hv_device_sb(struct ps3_system_bus_device *dev)
 	result = lv1_open_device(dev->bus_id, dev->dev_id, 0);
 
 	if (result) {
-		pr_debug("%s:%d: lv1_open_device failed: %s\n", __func__,
-			__LINE__, ps3_result(result));
-			result = -EPERM;
+		pr_warn("%s:%d: lv1_open_device dev=%u.%u(%s) failed: %s\n",
+			__func__, __LINE__, dev->match_id, dev->match_sub_id,
+			dev_name(&dev->core), ps3_result(result));
+		result = -EPERM;
 	}
 
 done:
@@ -120,7 +121,7 @@ static int ps3_open_hv_device_gpu(struct ps3_system_bus_device *dev)
 	result = lv1_gpu_open(0);
 
 	if (result) {
-		pr_debug("%s:%d: lv1_gpu_open failed: %s\n", __func__,
+		pr_warn("%s:%d: lv1_gpu_open failed: %s\n", __func__,
 			__LINE__, ps3_result(result));
 			result = -EPERM;
 	}
diff --git a/drivers/ps3/ps3-vuart.c b/drivers/ps3/ps3-vuart.c
index e34ae6a442c7..6328abd51ffa 100644
--- a/drivers/ps3/ps3-vuart.c
+++ b/drivers/ps3/ps3-vuart.c
@@ -358,7 +358,7 @@ static int ps3_vuart_raw_write(struct ps3_system_bus_device *dev,
 		ps3_mm_phys_to_lpar(__pa(buf)), bytes, bytes_written);
 
 	if (result) {
-		dev_dbg(&dev->core, "%s:%d: lv1_write_virtual_uart failed: "
+		dev_warn(&dev->core, "%s:%d: lv1_write_virtual_uart failed: "
 			"%s\n", __func__, __LINE__, ps3_result(result));
 		return result;
 	}
diff --git a/drivers/ps3/ps3av.c b/drivers/ps3/ps3av.c
index 9d66257e1da5..516e6d14d32e 100644
--- a/drivers/ps3/ps3av.c
+++ b/drivers/ps3/ps3av.c
@@ -217,9 +217,9 @@ static int ps3av_send_cmd_pkt(const struct ps3av_send_hdr *send_buf,
 	/* send pkt */
 	res = ps3av_vuart_write(ps3av->dev, send_buf, write_len);
 	if (res < 0) {
-		dev_dbg(&ps3av->dev->core,
-			"%s: ps3av_vuart_write() failed (result=%d)\n",
-			__func__, res);
+		dev_warn(&ps3av->dev->core,
+			"%s:%d: ps3av_vuart_write() failed: %s\n", __func__,
+			__LINE__, ps3_result(res));
 		return res;
 	}
 
@@ -230,9 +230,9 @@ static int ps3av_send_cmd_pkt(const struct ps3av_send_hdr *send_buf,
 		res = ps3av_vuart_read(ps3av->dev, recv_buf, PS3AV_HDR_SIZE,
 				       timeout);
 		if (res != PS3AV_HDR_SIZE) {
-			dev_dbg(&ps3av->dev->core,
-				"%s: ps3av_vuart_read() failed (result=%d)\n",
-				__func__, res);
+			dev_warn(&ps3av->dev->core,
+				"%s:%d: ps3av_vuart_read() failed: %s\n", __func__,
+				__LINE__, ps3_result(res));
 			return res;
 		}
 
@@ -240,9 +240,9 @@ static int ps3av_send_cmd_pkt(const struct ps3av_send_hdr *send_buf,
 		res = ps3av_vuart_read(ps3av->dev, &recv_buf->cid,
 				       recv_buf->size, timeout);
 		if (res < 0) {
-			dev_dbg(&ps3av->dev->core,
-				"%s: ps3av_vuart_read() failed (result=%d)\n",
-				__func__, res);
+			dev_warn(&ps3av->dev->core,
+				"%s:%d: ps3av_vuart_read() failed: %s\n", __func__,
+				__LINE__, ps3_result(res));
 			return res;
 		}
 		res += PS3AV_HDR_SIZE;	/* total len */
@@ -251,8 +251,8 @@ static int ps3av_send_cmd_pkt(const struct ps3av_send_hdr *send_buf,
 	} while (event);
 
 	if ((cmd | PS3AV_REPLY_BIT) != recv_buf->cid) {
-		dev_dbg(&ps3av->dev->core, "%s: reply err (result=%x)\n",
-			__func__, recv_buf->cid);
+		dev_warn(&ps3av->dev->core, "%s:%d: reply err: %x\n", __func__,
+			__LINE__, recv_buf->cid);
 		return -EINVAL;
 	}
 
-- 
2.25.1



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

* [PATCH v2 3/3] powerpc/ps3: Add dma_mask to ps3_dma_region
  2021-06-03 19:16 [PATCH v2 0/3] DMA fixes for PS3 device drivers Geoff Levand
  2021-06-03 19:17 ` [PATCH v2 2/3] powerpc/ps3: Warn on PS3 device errors Geoff Levand
  2021-06-03 19:17 ` [PATCH v2 1/3] powerpc/ps3: Add CONFIG_PS3_VERBOSE_RESULT option Geoff Levand
@ 2021-06-03 19:17 ` Geoff Levand
  2021-06-18  3:51   ` Michael Ellerman
  3 siblings, 0 replies; 6+ messages in thread
From: Geoff Levand @ 2021-06-03 19:17 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Jakub Kicinski, linuxppc-dev, David S. Miller, netdev

Commit f959dcd6ddfd29235030e8026471ac1b022ad2b0 (dma-direct: Fix
potential NULL pointer dereference) added a null check on the
dma_mask pointer of the kernel's device structure.

Add a dma_mask variable to the ps3_dma_region structure and set
the device structure's dma_mask pointer to point to this new variable.

Fixes runtime errors like these:

  ps3_system_bus_match:349: dev=8.0(sb_01), drv=8.0(ps3flash): match
  WARNING: CPU: 0 PID: 1 at kernel/dma/mapping.c:151 .dma_map_page_attrs+0x34/0x1e0
  ps3flash sb_01: ps3stor_setup:193: map DMA region failed

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 arch/powerpc/include/asm/ps3.h  |  2 ++
 arch/powerpc/platforms/ps3/mm.c | 12 ++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/arch/powerpc/include/asm/ps3.h b/arch/powerpc/include/asm/ps3.h
index 7df145901def..8a0d8fb35328 100644
--- a/arch/powerpc/include/asm/ps3.h
+++ b/arch/powerpc/include/asm/ps3.h
@@ -71,6 +71,7 @@ struct ps3_dma_region_ops;
  * @bus_addr: The 'translated' bus address of the region.
  * @len: The length in bytes of the region.
  * @offset: The offset from the start of memory of the region.
+ * @dma_mask: Device dma_mask.
  * @ioid: The IOID of the device who owns this region
  * @chunk_list: Opaque variable used by the ioc page manager.
  * @region_ops: struct ps3_dma_region_ops - dma region operations
@@ -85,6 +86,7 @@ struct ps3_dma_region {
 	enum ps3_dma_region_type region_type;
 	unsigned long len;
 	unsigned long offset;
+	u64 dma_mask;
 
 	/* driver variables  (set by ps3_dma_region_create) */
 	unsigned long bus_addr;
diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c
index d094321964fb..a81eac35d900 100644
--- a/arch/powerpc/platforms/ps3/mm.c
+++ b/arch/powerpc/platforms/ps3/mm.c
@@ -6,6 +6,7 @@
  *  Copyright 2006 Sony Corp.
  */
 
+#include <linux/dma-mapping.h>
 #include <linux/kernel.h>
 #include <linux/export.h>
 #include <linux/memblock.h>
@@ -1118,6 +1119,7 @@ int ps3_dma_region_init(struct ps3_system_bus_device *dev,
 	enum ps3_dma_region_type region_type, void *addr, unsigned long len)
 {
 	unsigned long lpar_addr;
+	int result;
 
 	lpar_addr = addr ? ps3_mm_phys_to_lpar(__pa(addr)) : 0;
 
@@ -1129,6 +1131,16 @@ int ps3_dma_region_init(struct ps3_system_bus_device *dev,
 		r->offset -= map.r1.offset;
 	r->len = len ? len : ALIGN(map.total, 1 << r->page_size);
 
+	dev->core.dma_mask = &r->dma_mask;
+
+	result = dma_set_mask_and_coherent(&dev->core, DMA_BIT_MASK(32));
+
+	if (result < 0) {
+		dev_err(&dev->core, "%s:%d: dma_set_mask_and_coherent failed: %d\n",
+			__func__, __LINE__, result);
+		return result;
+	}
+
 	switch (dev->dev_type) {
 	case PS3_DEVICE_TYPE_SB:
 		r->region_ops =  (USE_DYNAMIC_DMA)
-- 
2.25.1


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

* Re: [PATCH v2 0/3] DMA fixes for PS3 device drivers
  2021-06-03 19:16 [PATCH v2 0/3] DMA fixes for PS3 device drivers Geoff Levand
@ 2021-06-18  3:51   ` Michael Ellerman
  2021-06-03 19:17 ` [PATCH v2 1/3] powerpc/ps3: Add CONFIG_PS3_VERBOSE_RESULT option Geoff Levand
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2021-06-18  3:51 UTC (permalink / raw)
  To: Geoff Levand, Michael Ellerman
  Cc: Jakub Kicinski, netdev, linuxppc-dev, David S. Miller

On Thu, 03 Jun 2021 19:16:56 +0000, Geoff Levand wrote:
> This is a set of patches that fix various DMA related problems in the PS3
> device drivers, and add better error checking and improved message logging.
> 
> Changes from V1:
>   Split the V1 series into two, one series with powerpc changes, and one series
>   with gelic network driver changes.
> 
> [...]

Applied to powerpc/next.

[1/3] powerpc/ps3: Add CONFIG_PS3_VERBOSE_RESULT option
      https://git.kernel.org/powerpc/c/6caebff168235b6102e5dc57cb95a2374301720a
[2/3] powerpc/ps3: Warn on PS3 device errors
      https://git.kernel.org/powerpc/c/472b440fd26822c645befe459172dafdc2d225de
[3/3] powerpc/ps3: Add dma_mask to ps3_dma_region
      https://git.kernel.org/powerpc/c/9733862e50fdba55e7f1554e4286fcc5302ff28e

cheers

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

* Re: [PATCH v2 0/3] DMA fixes for PS3 device drivers
@ 2021-06-18  3:51   ` Michael Ellerman
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2021-06-18  3:51 UTC (permalink / raw)
  To: Geoff Levand, Michael Ellerman
  Cc: Jakub Kicinski, linuxppc-dev, David S. Miller, netdev

On Thu, 03 Jun 2021 19:16:56 +0000, Geoff Levand wrote:
> This is a set of patches that fix various DMA related problems in the PS3
> device drivers, and add better error checking and improved message logging.
> 
> Changes from V1:
>   Split the V1 series into two, one series with powerpc changes, and one series
>   with gelic network driver changes.
> 
> [...]

Applied to powerpc/next.

[1/3] powerpc/ps3: Add CONFIG_PS3_VERBOSE_RESULT option
      https://git.kernel.org/powerpc/c/6caebff168235b6102e5dc57cb95a2374301720a
[2/3] powerpc/ps3: Warn on PS3 device errors
      https://git.kernel.org/powerpc/c/472b440fd26822c645befe459172dafdc2d225de
[3/3] powerpc/ps3: Add dma_mask to ps3_dma_region
      https://git.kernel.org/powerpc/c/9733862e50fdba55e7f1554e4286fcc5302ff28e

cheers

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

end of thread, other threads:[~2021-06-18  4:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-03 19:16 [PATCH v2 0/3] DMA fixes for PS3 device drivers Geoff Levand
2021-06-03 19:17 ` [PATCH v2 2/3] powerpc/ps3: Warn on PS3 device errors Geoff Levand
2021-06-03 19:17 ` [PATCH v2 1/3] powerpc/ps3: Add CONFIG_PS3_VERBOSE_RESULT option Geoff Levand
2021-06-03 19:17 ` [PATCH v2 3/3] powerpc/ps3: Add dma_mask to ps3_dma_region Geoff Levand
2021-06-18  3:51 ` [PATCH v2 0/3] DMA fixes for PS3 device drivers Michael Ellerman
2021-06-18  3:51   ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.