linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v9 01/18] arm: make SWIOTLB available
Date: Tue, 29 Oct 2013 18:01:05 +0000	[thread overview]
Message-ID: <20131029180105.GR16735@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <alpine.DEB.2.02.1310291716120.26077@kaball.uk.xensource.com>

On Tue, Oct 29, 2013 at 05:24:50PM +0000, Stefano Stabellini wrote:
> On Tue, 29 Oct 2013, Russell King - ARM Linux wrote:
> > This looks like a hack.  Either we want to use the streaming mask or
> > the coherent mask as appropriate for the caller.  That should be a choice
> > the caller makes, not the implementation of this behind the callers back.
> 
> How should I choose?
> Admittedly this is a workaround because some drivers (including Calxeda
> xgmac) don't set the dma_mask when they should:
> 
> http://marc.info/?l=linux-arm-kernel&m=138082570519601&w=2
> 
> I am happy to reduce this to:
> 
> if (dev->dma_mask)
>     mask = *dev->dma_mask;
> 
> even though it means that xgmac & co won't be dma_capable.

Well, if xgmac (there's two in the kernel tree so I'm not sure which
you're referring to) is using DMA of any kind, it really ought to be
setting a DMA mask via the standard functions - in todays kernel,
that is dma_set_mask() for the streaming mask and dma_set_coherent_mask()
for the coherent mask.  The appropriate mask which the driver is aware
of for the hardware should be set here.

In the case that a driver needs to call both, and the kernel has my
patch set applied, dma_set_mask_and_coherent() can be used to set both
at the same time.

dma_set_mask() (and dma_set_mask_and_coherent) will fail if storage for
the DMA mask has not been allocated previously - iow, if the dev->dma_mask
pointer is NULL.  The allocation of this storage is the responsibility
of the struct device creator, and the struct device creator should
initialise the DMA masks to a sensible default for the type of bus.

I provide one last call in my patch set - a method that drivers can
coerce the DMA mask to whatever they desire irrespective of whether
the DMA mask allocation has been setup.  This is provided as a way to
mark the drivers which are doing this and to ensure that drivers do
this in a safe manner - we've had drivers setting it to static storage
in module space if it isn't previously set, which is a problem if the
module ever gets unloaded.

So... what I'm saying is please fix xgmac to use the DMA API properly
rather than working around such problems. :)

  reply	other threads:[~2013-10-29 18:01 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-25 10:51 [PATCH v9 0/18] enable swiotlb-xen on arm and arm64 Stefano Stabellini
2013-10-25 10:51 ` [PATCH v9 01/18] arm: make SWIOTLB available Stefano Stabellini
2013-10-25 11:08   ` Stefano Stabellini
2013-10-29  4:41     ` Stefano Stabellini
2013-10-29 14:20       ` Konrad Rzeszutek Wilk
2013-10-29 14:26         ` Russell King - ARM Linux
2013-10-29 17:24           ` Stefano Stabellini
2013-10-29 18:01             ` Russell King - ARM Linux [this message]
2013-10-30  1:17               ` Stefano Stabellini
2013-11-04 18:38                 ` Stefano Stabellini
2013-10-25 10:51 ` [PATCH v9 02/18] arm64: define DMA_ERROR_CODE Stefano Stabellini
2013-10-25 10:51 ` [PATCH v9 03/18] arm/xen,arm64/xen: introduce p2m Stefano Stabellini
2013-11-07 14:42   ` Ian Campbell
2013-11-07 15:52     ` Stefano Stabellini
2013-10-25 10:51 ` [PATCH v9 04/18] xen/x86: allow __set_phys_to_machine for autotranslate guests Stefano Stabellini
2013-10-25 10:51 ` [PATCH v9 05/18] xen: make xen_create_contiguous_region return the dma address Stefano Stabellini
2013-10-25 10:51 ` [PATCH v9 06/18] xen/arm,arm64: enable SWIOTLB_XEN Stefano Stabellini
2013-10-25 10:51 ` [PATCH v9 07/18] swiotlb-xen: introduce xen_swiotlb_set_dma_mask Stefano Stabellini
2013-10-25 10:51 ` [PATCH v9 08/18] arm/xen: get_dma_ops: return xen_dma_ops if we are running as xen_initial_domain Stefano Stabellini
2013-10-25 10:51 ` [PATCH v9 09/18] arm64/xen: " Stefano Stabellini
2013-10-25 10:51 ` [PATCH v9 10/18] xen: introduce xen_alloc/free_coherent_pages Stefano Stabellini
2013-10-25 10:51 ` [PATCH v9 11/18] swiotlb-xen: use xen_alloc/free_coherent_pages Stefano Stabellini
2013-10-25 10:51 ` [PATCH v9 12/18] xen: introduce xen_dma_map/unmap_page and xen_dma_sync_single_for_cpu/device Stefano Stabellini
2013-10-25 10:51 ` [PATCH v9 13/18] swiotlb-xen: use xen_dma_map/unmap_page, xen_dma_sync_single_for_cpu/device Stefano Stabellini
2013-10-25 10:51 ` [PATCH v9 14/18] ASoC: Samsung: Rename dma_ops by samsung_dma_ops Stefano Stabellini
2013-10-25 10:51 ` [PATCH v9 15/18] swiotlb: print a warning when the swiotlb is full Stefano Stabellini
2013-10-25 10:51 ` [PATCH v9 16/18] arm, arm64: do not always merge biovec if we are running on Xen Stefano Stabellini
2013-11-05 22:46   ` Olof Johansson
2013-11-06 12:40     ` [PATCH v9 16/18] arm,arm64: " Stefano Stabellini
2013-11-06 15:27       ` [PATCH v9 16/18] arm, arm64: " Olof Johansson
2013-10-25 10:51 ` [PATCH v9 17/18] grant-table: call set_phys_to_machine after mapping grant refs Stefano Stabellini
2013-10-25 10:51 ` [PATCH v9 18/18] swiotlb-xen: static inline xen_phys_to_bus, xen_bus_to_phys, xen_virt_to_bus and range_straddles_page_boundary Stefano Stabellini

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=20131029180105.GR16735@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).