[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20181119135459.GB16334@lst.de>
Date: Mon, 19 Nov 2018 14:55:00 +0100
From: Christoph Hellwig <hch@....de>
To: David Miller <davem@...emloft.net>
Cc: hch@....de, iommu@...ts.linux-foundation.org,
torvalds@...ux-foundation.org, linux-alpha@...r.kernel.org,
linux-arch@...r.kernel.org, x86@...nel.org,
linux-kernel@...r.kernel.org, Julia Lawall <Julia.Lawall@...6.fr>,
Dan Carpenter <dan.carpenter@...cle.com>
Subject: Re: [RFC] remove the ->mapping_error method from dma_map_ops
On Fri, Nov 09, 2018 at 03:12:34PM -0800, David Miller wrote:
> But patch #2 on the other hand, not so much.
>
> I hate seeing values returned by reference, it adds cost especially
> on cpus where all argments and return values fit in registers (we end
> up forcing a stack slot and memory references).
>
> And we don't need it here.
>
> DMA addresses are like pointers, and therefore we can return errors and
> valid success values in the same dma_addr_t just fine. PTR_ERR() --> DMA_ERR(),
> IS_PTR_ERR() --> IS_DMA_ERR, etc.
In the end this is an inline function, so with a decently smart
compiler the generated code shouldn't change too much. The big problem
that prompted me to come up with this patch is that not handling failure
from dma_map* in a swiotlb setup can lead to grave data corruption, and
we have no easy way to force error checking on these return values.
I've added a few of the static typechecking suspect if they have a
better idea on how to make the return value of dma_map_single/pages
in a way that we get warnings if dma_mapping_error isn't called on them.
But I can't really think of a good way.
Powered by blists - more mailing lists