All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi-topcliff-pch: Fix probing when DMA mode is used
@ 2014-02-26 15:31 Alexander Stein
       [not found] ` <1393428679-18462-1-git-send-email-alexander.stein-93q1YBGzJSMe9JSWTWOYM3xStJ4P+DSV@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Stein @ 2014-02-26 15:31 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, Alexander Stein

If during registering SPI master due to SPI device probing a SPI transfer
is issued the DMA buffers are not allocated yet.

This fixes the following oops:
pch_spi 0000:02:0c.1: enabling device (0000 -> 0002)
pch_spi 0000:02:0c.1: master is unqueued, this is deprecated
BUG: unable to handle kernel NULL pointer dereference at   (null)
IP: [<c125aa05>] pch_spi_handle_dma+0x15c/0x6f4
[...]

Signed-off-by: Alexander Stein <alexander.stein-93q1YBGzJSMe9JSWTWOYM3xStJ4P+DSV@public.gmane.org>
---
 drivers/spi/spi-topcliff-pch.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
index c2a3435..f73fb77 100644
--- a/drivers/spi/spi-topcliff-pch.c
+++ b/drivers/spi/spi-topcliff-pch.c
@@ -1457,6 +1457,11 @@ static int pch_spi_pd_probe(struct platform_device *plat_dev)
 
 	pch_spi_set_master_mode(master);
 
+	if (use_dma) {
+		dev_info(&plat_dev->dev, "Use DMA for data transfers\n");
+		pch_alloc_dma_buf(board_dat, data);
+	}
+
 	ret = spi_register_master(master);
 	if (ret != 0) {
 		dev_err(&plat_dev->dev,
@@ -1464,14 +1469,10 @@ static int pch_spi_pd_probe(struct platform_device *plat_dev)
 		goto err_spi_register_master;
 	}
 
-	if (use_dma) {
-		dev_info(&plat_dev->dev, "Use DMA for data transfers\n");
-		pch_alloc_dma_buf(board_dat, data);
-	}
-
 	return 0;
 
 err_spi_register_master:
+	pch_free_dma_buf(board_dat, data);
 	free_irq(board_dat->pdev->irq, data);
 err_request_irq:
 	pch_spi_free_resources(board_dat, data);
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] spi-topcliff-pch: Fix probing when DMA mode is used
       [not found] ` <1393428679-18462-1-git-send-email-alexander.stein-93q1YBGzJSMe9JSWTWOYM3xStJ4P+DSV@public.gmane.org>
@ 2014-02-27  4:37   ` Mark Brown
       [not found]     ` <20140227043719.GH9383-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2014-02-27  4:37 UTC (permalink / raw)
  To: Alexander Stein; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 210 bytes --]

On Wed, Feb 26, 2014 at 04:31:19PM +0100, Alexander Stein wrote:
> If during registering SPI master due to SPI device probing a SPI transfer
> is issued the DMA buffers are not allocated yet.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] spi-topcliff-pch: Fix probing when DMA mode is used
       [not found]     ` <20140227043719.GH9383-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2014-02-27  8:13       ` Alexander Stein
  2014-02-28  3:43         ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Stein @ 2014-02-27  8:13 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

On Thursday 27 February 2014 13:37:19, Mark Brown wrote:
> On Wed, Feb 26, 2014 at 04:31:19PM +0100, Alexander Stein wrote:
> > If during registering SPI master due to SPI device probing a SPI transfer
> > is issued the DMA buffers are not allocated yet.
> 
> Applied, thanks.

Thinking about this patch over night, this also should go to stable, no?

Best regards,
Alexander

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] spi-topcliff-pch: Fix probing when DMA mode is used
  2014-02-27  8:13       ` Alexander Stein
@ 2014-02-28  3:43         ` Mark Brown
       [not found]           ` <20140228034331.GG9383-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2014-02-28  3:43 UTC (permalink / raw)
  To: Alexander Stein; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 549 bytes --]

On Thu, Feb 27, 2014 at 09:13:21AM +0100, Alexander Stein wrote:
> On Thursday 27 February 2014 13:37:19, Mark Brown wrote:
> > On Wed, Feb 26, 2014 at 04:31:19PM +0100, Alexander Stein wrote:
> > > If during registering SPI master due to SPI device probing a SPI transfer
> > > is issued the DMA buffers are not allocated yet.

> > Applied, thanks.

> Thinking about this patch over night, this also should go to stable, no?

Possibly, though I'd have thought that someone would have noticed by now
if there were any affected systems using stable?

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] spi-topcliff-pch: Fix probing when DMA mode is used
       [not found]           ` <20140228034331.GG9383-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2014-03-03  7:21             ` Alexander Stein
  2014-03-04  4:44               ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Stein @ 2014-03-03  7:21 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

On Friday 28 February 2014 12:43:31, Mark Brown wrote:
> On Thu, Feb 27, 2014 at 09:13:21AM +0100, Alexander Stein wrote:
> > On Thursday 27 February 2014 13:37:19, Mark Brown wrote:
> > > On Wed, Feb 26, 2014 at 04:31:19PM +0100, Alexander Stein wrote:
> > > > If during registering SPI master due to SPI device probing a SPI transfer
> > > > is issued the DMA buffers are not allocated yet.
> 
> > > Applied, thanks.
> 
> > Thinking about this patch over night, this also should go to stable, no?
> 
> Possibly, though I'd have thought that someone would have noticed by now
> if there were any affected systems using stable?

Well, i think this is a rather rarely use case. You need either all drivers compiled in where the SPI device driver is loaded before SPI master or you need SPI master als module while the SPI device driver is already compiled in. Oh, and the SPI device driver must do a SPI transfer during probe. So the conditions are reptty strict when this problem might happen.

Alexander

PS: On EG20T (PCH) it seems this will never happen as the DMA channels are allocated wrongly (see other patch from me) andso DMA will never be used.

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] spi-topcliff-pch: Fix probing when DMA mode is used
  2014-03-03  7:21             ` Alexander Stein
@ 2014-03-04  4:44               ` Mark Brown
       [not found]                 ` <20140304044422.GJ2411-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2014-03-04  4:44 UTC (permalink / raw)
  To: Alexander Stein; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 797 bytes --]

On Mon, Mar 03, 2014 at 08:21:16AM +0100, Alexander Stein wrote:

Fix your mailer to word wrap within paragraphs so that your mail is
legible.

> Well, i think this is a rather rarely use case. You need either all
> drivers compiled in where the SPI device driver is loaded before SPI
> master or you need SPI master als module while the SPI device driver
> is already compiled in. Oh, and the SPI device driver must do a SPI
> transfer during probe. So the conditions are reptty strict when this
> problem might happen.

> PS: On EG20T (PCH) it seems this will never happen as the DMA channels
> are allocated wrongly (see other patch from me) andso DMA will never
> be used.

OK, so this doesn't sound terribly urgent then?  It's hard to see and
other bugs mean it wouldn't be triggered anyway?

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] spi-topcliff-pch: Fix probing when DMA mode is used
       [not found]                 ` <20140304044422.GJ2411-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2014-03-04  6:52                   ` Alexander Stein
  0 siblings, 0 replies; 7+ messages in thread
From: Alexander Stein @ 2014-03-04  6:52 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

On Tuesday 04 March 2014 12:44:22, Mark Brown wrote:
> On Mon, Mar 03, 2014 at 08:21:16AM +0100, Alexander Stein wrote:
> > Well, i think this is a rather rarely use case. You need either all
> > drivers compiled in where the SPI device driver is loaded before SPI
> > master or you need SPI master als module while the SPI device driver
> > is already compiled in. Oh, and the SPI device driver must do a SPI
> > transfer during probe. So the conditions are reptty strict when this
> > problem might happen.
> 
> > PS: On EG20T (PCH) it seems this will never happen as the DMA channels
> > are allocated wrongly (see other patch from me) andso DMA will never
> > be used.
> 
> OK, so this doesn't sound terribly urgent then?  It's hard to see and
> other bugs mean it wouldn't be triggered anyway?

Yes, at least for EG20T. I have no idea about those MLxxxx IOH.

Alexander

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2014-03-04  6:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-26 15:31 [PATCH] spi-topcliff-pch: Fix probing when DMA mode is used Alexander Stein
     [not found] ` <1393428679-18462-1-git-send-email-alexander.stein-93q1YBGzJSMe9JSWTWOYM3xStJ4P+DSV@public.gmane.org>
2014-02-27  4:37   ` Mark Brown
     [not found]     ` <20140227043719.GH9383-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-02-27  8:13       ` Alexander Stein
2014-02-28  3:43         ` Mark Brown
     [not found]           ` <20140228034331.GG9383-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-03-03  7:21             ` Alexander Stein
2014-03-04  4:44               ` Mark Brown
     [not found]                 ` <20140304044422.GJ2411-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-03-04  6:52                   ` Alexander Stein

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.