Re: [PATCH 22/28] sgiseeq: convert from dma_cache_sync to dma_sync_single_for_device
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: Thomas Bogendoerfer <tsbogend@xxxxxxxxxxxxxxxx>
- Subject: Re: [PATCH 22/28] sgiseeq: convert from dma_cache_sync to dma_sync_single_for_device
- From: Christoph Hellwig <hch@xxxxxx>
- Date: Thu, 3 Sep 2020 10:42:26 +0200
- Cc: Christoph Hellwig <hch@xxxxxx>, alsa-devel@xxxxxxxxxxxxxxxx, linux-ia64@xxxxxxxxxxxxxxx, linux-doc@xxxxxxxxxxxxxxx, nouveau@xxxxxxxxxxxxxxxxxxxxx, linux-nvme@xxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, "James E.J. Bottomley" <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx>, linux-mm@xxxxxxxxx, Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>, linux-samsung-soc@xxxxxxxxxxxxxxx, Joonyoung Shim <jy0922.shim@xxxxxxxxxxx>, linux-scsi@xxxxxxxxxxxxxxx, Kyungmin Park <kyungmin.park@xxxxxxxxxxx>, Ben Skeggs <bskeggs@xxxxxxxxxx>, Matt Porter <mporter@xxxxxxxxxxxxxxxxxxx>, linux-media@xxxxxxxxxxxxxxx, Tom Lendacky <thomas.lendacky@xxxxxxx>, Pawel Osciak <pawel@xxxxxxxxxx>, Mauro Carvalho Chehab <mchehab@xxxxxxxxxx>, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, linux-parisc@xxxxxxxxxxxxxxx, netdev@xxxxxxxxxxxxxxx, Seung-Woo Kim <sw0312.kim@xxxxxxxxxxx>, linux-mips@xxxxxxxxxxxxxxx, iommu@xxxxxxxxxxxxxxxxxxxxxxxxxx
- In-reply-to: <20200902213809.GA7998@alpha.franken.de>
- References: <20200819065555.1802761-1-hch@lst.de> <20200819065555.1802761-23-hch@lst.de> <20200901152209.GA14288@alpha.franken.de> <20200901171241.GA20685@alpha.franken.de> <20200901171627.GA8255@lst.de> <20200901173810.GA25282@alpha.franken.de> <20200902213809.GA7998@alpha.franken.de>
- User-agent: Mutt/1.5.17 (2007-11-01)
On Wed, Sep 02, 2020 at 11:38:09PM +0200, Thomas Bogendoerfer wrote:
> the patch below fixes the problem.
But is very wrong unfortunately.
> static inline void dma_sync_desc_cpu(struct net_device *dev, void *addr)
> {
> - dma_cache_sync(dev->dev.parent, addr, sizeof(struct sgiseeq_rx_desc),
> - DMA_FROM_DEVICE);
> + struct sgiseeq_private *sp = netdev_priv(dev);
> +
> + dma_sync_single_for_device(dev->dev.parent, VIRT_TO_DMA(sp, addr),
> + sizeof(struct sgiseeq_rx_desc), DMA_FROM_DEVICE);
> }
>
> static inline void dma_sync_desc_dev(struct net_device *dev, void *addr)
> {
> - dma_cache_sync(dev->dev.parent, addr, sizeof(struct sgiseeq_rx_desc),
> - DMA_TO_DEVICE);
> + struct sgiseeq_private *sp = netdev_priv(dev);
> +
> + dma_sync_single_for_device(dev->dev.parent, VIRT_TO_DMA(sp, addr),
> + sizeof(struct sgiseeq_rx_desc), DMA_TO_DEVICE);
This is not how the DMA API works. You can only call
dma_sync_single_for_{device,cpu} with the direction that the memory
was mapped. It then transfer ownership to the device or the cpu,
and the ownership of the memory is a fundamental concept that allows
for reasoning about the caching interaction.
> }
>
> --
> Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
> good idea. [ RFC1925, 2.3 ]
---end quoted text---
[Index of Archives]
[Linux Kernel]
[Sparc Linux]
[DCCP]
[Linux ARM]
[Yosemite News]
[Linux SCSI]
[Linux x86_64]
[Linux for Ham Radio]