All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: David Miller <davem@davemloft.net>
Cc: hch@lst.de, iommu@lists.linux-foundation.org,
	torvalds@linux-foundation.org, linux-alpha@vger.kernel.org,
	linux-arch@vger.kernel.org, x86@kernel.org,
	linux-kernel@vger.kernel.org, Julia Lawall <Julia.Lawall@lip6.fr>,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [RFC] remove the ->mapping_error method from dma_map_ops
Date: Mon, 19 Nov 2018 14:55:00 +0100	[thread overview]
Message-ID: <20181119135459.GB16334@lst.de> (raw)
In-Reply-To: <20181109.151234.2231390463846593374.davem@davemloft.net>

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.

      reply	other threads:[~2018-11-19 13:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-09  8:46 [RFC] remove the ->mapping_error method from dma_map_ops Christoph Hellwig
2018-11-09  8:46 ` [PATCH 1/2] dma-mapping: remove ->mapping_error Christoph Hellwig
2018-11-09 14:41   ` Robin Murphy
2018-11-19 13:52     ` Christoph Hellwig
2018-11-09  8:46 ` [PATCH 2/2] dma-mapping: return errors from dma_map_page and dma_map_attrs Christoph Hellwig
2018-11-09 23:12 ` [RFC] remove the ->mapping_error method from dma_map_ops David Miller
2018-11-19 13:55   ` Christoph Hellwig [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181119135459.GB16334@lst.de \
    --to=hch@lst.de \
    --cc=Julia.Lawall@lip6.fr \
    --cc=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.