lantiq: 4.19: fix panic when using the DMA API
With kernel 4.19 the DMA API relies on a struct device to work properly. Backport upstream patches which passed a struct device instead of NULL to the DMA API. Fixes kernel panics during boot. Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Signed-off-by: Mathias Kresin <dev@kresin.me>master
parent
961b8efb5b
commit
7305e2057a
@ -0,0 +1,43 @@
|
||||
From 74e0deb89a8ba27c132b1f0e08643e215b5c1f92 Mon Sep 17 00:00:00 2001
|
||||
From: Christoph Hellwig <hch@lst.de>
|
||||
Date: Mon, 11 Feb 2019 14:20:00 +0100
|
||||
Subject: [PATCH] lantiq_etop: pass struct device to DMA API functions
|
||||
|
||||
The DMA API generally relies on a struct device to work properly, and
|
||||
only barely works without one for legacy reasons. Pass the easily
|
||||
available struct device from the platform_device to remedy this.
|
||||
|
||||
Note this driver seems to lack dma_unmap_* calls entirely, but fixing
|
||||
that is left for another time.
|
||||
|
||||
Signed-off-by: Christoph Hellwig <hch@lst.de>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/ethernet/lantiq_etop.c | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/lantiq_etop.c
|
||||
+++ b/drivers/net/ethernet/lantiq_etop.c
|
||||
@@ -112,10 +112,12 @@ struct ltq_etop_priv {
|
||||
static int
|
||||
ltq_etop_alloc_skb(struct ltq_etop_chan *ch)
|
||||
{
|
||||
+ struct ltq_etop_priv *priv = netdev_priv(ch->netdev);
|
||||
+
|
||||
ch->skb[ch->dma.desc] = netdev_alloc_skb(ch->netdev, MAX_DMA_DATA_LEN);
|
||||
if (!ch->skb[ch->dma.desc])
|
||||
return -ENOMEM;
|
||||
- ch->dma.desc_base[ch->dma.desc].addr = dma_map_single(NULL,
|
||||
+ ch->dma.desc_base[ch->dma.desc].addr = dma_map_single(&priv->pdev->dev,
|
||||
ch->skb[ch->dma.desc]->data, MAX_DMA_DATA_LEN,
|
||||
DMA_FROM_DEVICE);
|
||||
ch->dma.desc_base[ch->dma.desc].addr =
|
||||
@@ -493,7 +495,7 @@ ltq_etop_tx(struct sk_buff *skb, struct
|
||||
netif_trans_update(dev);
|
||||
|
||||
spin_lock_irqsave(&priv->lock, flags);
|
||||
- desc->addr = ((unsigned int) dma_map_single(NULL, skb->data, len,
|
||||
+ desc->addr = ((unsigned int) dma_map_single(&priv->pdev->dev, skb->data, len,
|
||||
DMA_TO_DEVICE)) - byte_offset;
|
||||
wmb();
|
||||
desc->ctl = LTQ_DMA_OWN | LTQ_DMA_SOP | LTQ_DMA_EOP |
|
@ -0,0 +1,50 @@
|
||||
From 74f03104ed465ff71b11076ef620e4eaa53dbf74 Mon Sep 17 00:00:00 2001
|
||||
From: Christoph Hellwig <hch@lst.de>
|
||||
Date: Fri, 1 Feb 2019 09:47:44 +0100
|
||||
Subject: [PATCH] MIPS: lantiq: pass struct device to DMA API functions
|
||||
|
||||
The DMA API generally relies on a struct device to work properly, and
|
||||
only barely works without one for legacy reasons. Pass the easily
|
||||
available struct device from the platform_device to remedy this.
|
||||
|
||||
Also use GFP_KERNEL instead of GFP_ATOMIC as the gfp_t for the memory
|
||||
allocation, as we aren't in interrupt context or under a lock.
|
||||
|
||||
Note that this whole function looks somewhat bogus given that we never
|
||||
even look at the returned dma address, and the CPHYSADDR magic on
|
||||
a returned noncached mapping looks "interesting". But I'll leave
|
||||
that to people more familiar with the code to sort out.
|
||||
|
||||
Signed-off-by: Christoph Hellwig <hch@lst.de>
|
||||
Signed-off-by: Paul Burton <paul.burton@mips.com>
|
||||
Cc: John Crispin <john@phrozen.org>
|
||||
Cc: Vinod Koul <vkoul@kernel.org>
|
||||
Cc: Dmitry Tarnyagin <dmitry.tarnyagin@lockless.no>
|
||||
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
|
||||
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
|
||||
Cc: Felipe Balbi <balbi@kernel.org>
|
||||
Cc: linux-mips@vger.kernel.org
|
||||
Cc: linux-kernel@vger.kernel.org
|
||||
Cc: dmaengine@vger.kernel.org
|
||||
Cc: netdev@vger.kernel.org
|
||||
Cc: linux-usb@vger.kernel.org
|
||||
Cc: linux-fbdev@vger.kernel.org
|
||||
Cc: alsa-devel@alsa-project.org
|
||||
Cc: iommu@lists.linux-foundation.org
|
||||
---
|
||||
arch/mips/lantiq/xway/vmmc.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/arch/mips/lantiq/xway/vmmc.c
|
||||
+++ b/arch/mips/lantiq/xway/vmmc.c
|
||||
@@ -31,8 +31,8 @@ static int vmmc_probe(struct platform_de
|
||||
dma_addr_t dma;
|
||||
|
||||
cp1_base =
|
||||
- (void *) CPHYSADDR(dma_alloc_coherent(NULL, CP1_SIZE,
|
||||
- &dma, GFP_ATOMIC));
|
||||
+ (void *) CPHYSADDR(dma_alloc_coherent(&pdev->dev, CP1_SIZE,
|
||||
+ &dma, GFP_KERNEL));
|
||||
|
||||
gpio_count = of_gpio_count(pdev->dev.of_node);
|
||||
while (gpio_count > 0) {
|
Loading…
Reference in New Issue