From: Arnd Bergmann <arnd@arndb.de>
To: Timur Tabi <timur@codeaurora.org>
Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-msm@vger.kernel.org, sdharia@codeaurora.org,
shankerd@codeaurora.org, vikrams@codeaurora.org,
cov@codeaurora.org, gavidov@codeaurora.org, robh+dt@kernel.org,
andrew@lunn.ch, bjorn.andersson@linaro.org, mlangsdo@redhat.com,
jcm@redhat.com, agross@codeaurora.org, davem@davemloft.net,
f.fainelli@gmail.com, catalin.marinas@arm.com
Subject: Re: [PATCH] [v6] net: emac: emac gigabit ethernet controller driver
Date: Wed, 29 Jun 2016 17:04:45 +0200 [thread overview]
Message-ID: <5679359.84lXZytcOR@wuerfel> (raw)
In-Reply-To: <5773DC52.4010703@codeaurora.org>
On Wednesday, June 29, 2016 9:33:54 AM CEST Timur Tabi wrote:
> Arnd Bergmann wrote:
> > If the ranges property lists the bus as dma capable for only the
> > lower 32 bits, then dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
> > should fail, otherwise dma_alloc_coherent() will return an invalid
> > memory area.
>
> That seems wrong. dma_alloc_coherent() should be smart enough to
> restrict itself to the the dma-ranges property. Isn't that why the
> property exists? When dma_alloc_coherent() looks for memory, it should
> knows it has to create a 32-bit address. That's why we have ZONE_DMA.
No, dma_alloc_coherent() is documented to use the dma_mask as
its reference, it's supposed to be independent of the underlying
bus.
dma-ranges is just how we communicate the limitation of the
bus to the kernel, but relying on dma-ranges itself would fail
to consider drivers that impose additional limitations, i.e.
when a device needs a smaller mask and calls 'dma_set_mask(dev,
DMA_BIT_MASK(24))' or something like that.
> > Another twist is how arm64 currently uses SWIOTLB unconditionally:
> > As long as SWIOTLB (or iommu) is enabled, dma_set_mask_and_coherent()
> > should succeed for any mask(), but not actually update the mask of the
> > device to more than the bus can handle.
>
> That just seems like a bug in ARM64 SWIOTLB. SWIOTLB should inject
> itself when the driver tries to map memory outside of its DMA range.
Again, the dma mask is how swiotlb_map_*() finds whether a page
needs a bounce buffer or not, so it has to be set to whatever
the device can address.
> Without SWIOTLB/IOMMU, dma_alloc_coherent() should be aware of the
> platform-specific limitations of each device and ensure that it only
> allocates memory that conforms *all* limitations. For example, if the
> platform is capable of 64-bit DMA, but a legacy device can only handle
> 32-bit bus addresses, then the driver should do this:
>
> dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))
That's also not how it works: each device starts out with a 32-bit mask,
because that's what historically all PCI devices can do. If a device
is 64-bit DMA capable, it can extend the mask by passing DMA_BIT_MASK(64)
(or whatever it can support), and the platform code checks if that's
possible.
Arnd
next prev parent reply other threads:[~2016-06-29 15:09 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-24 23:46 [PATCH] [v6] net: emac: emac gigabit ethernet controller driver Timur Tabi
2016-06-28 20:56 ` Rob Herring
2016-06-29 7:55 ` David Miller
2016-06-29 8:17 ` Arnd Bergmann
2016-06-29 12:17 ` Timur Tabi
2016-06-29 14:07 ` Arnd Bergmann
2016-06-29 14:33 ` Timur Tabi
2016-06-29 15:04 ` Arnd Bergmann [this message]
2016-06-29 15:10 ` Timur Tabi
2016-06-29 15:34 ` Arnd Bergmann
2016-06-29 15:46 ` Timur Tabi
2016-06-29 19:45 ` Arnd Bergmann
2016-06-29 20:16 ` Timur Tabi
2016-07-01 13:54 ` Arnd Bergmann
2016-08-03 21:24 ` Timur Tabi
2016-08-04 9:21 ` Arnd Bergmann
2016-08-04 14:24 ` Timur Tabi
2016-07-03 23:04 ` Lino Sanfilippo
2016-07-28 19:12 ` Timur Tabi
2016-07-30 10:26 ` Lino Sanfilippo
2016-08-02 17:59 ` Timur Tabi
2016-08-03 20:00 ` Timur Tabi
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=5679359.84lXZytcOR@wuerfel \
--to=arnd@arndb.de \
--cc=agross@codeaurora.org \
--cc=andrew@lunn.ch \
--cc=bjorn.andersson@linaro.org \
--cc=catalin.marinas@arm.com \
--cc=cov@codeaurora.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=gavidov@codeaurora.org \
--cc=jcm@redhat.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=mlangsdo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=sdharia@codeaurora.org \
--cc=shankerd@codeaurora.org \
--cc=timur@codeaurora.org \
--cc=vikrams@codeaurora.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.