All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/7] Stop losing firmware-set DMA masks
@ 2018-07-23 22:16 ` Robin Murphy
  0 siblings, 0 replies; 82+ messages in thread
From: Robin Murphy @ 2018-07-23 22:16 UTC (permalink / raw)
  To: hch-jcswGhMUV9g, m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ
  Cc: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	x86-DgEjT+Ai2ygdnm+yROfE0A, linux-acpi-u79uwXL29TY76Z2rM5mHXA,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, sudeep.holla-5wv7dgnIgG8,
	frowand.list-Re5JQEeQqe8AvxtiuMwx3w,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Whilst the common firmware code invoked by dma_configure() initialises
devices' DMA masks according to limitations described by the respective
properties ("dma-ranges" for OF and _DMA/IORT for ACPI), the nature of
the dma_set_mask() API leads to that information getting lost when
well-behaved drivers probe and set a 64-bit mask, since in general
there's no way to tell the difference between a firmware-described mask
(which should be respected) and whatever default may have come from the
bus code (which should be replaced outright). This can break DMA on
systems with certain IOMMU topologies (e.g. [1]) where the IOMMU driver
only knows its maximum supported address size, not how many of those
address bits might actually be wired up between any of its input
interfaces and the associated DMA master devices. Similarly, some PCIe
root complexes only have a 32-bit native interface on their host bridge,
which leads to the same DMA-address-truncation problem in systems with a
larger physical memory map and RAM above 4GB (e.g. [2]).

These patches attempt to deal with this in the simplest way possible by
generalising the specific quirk for 32-bit bridges into an arbitrary
mask which can then also be plumbed into the firmware code. In the
interest of being minimally invasive, I've only included a point fix
for the IOMMU issue as seen on arm64 - there may be further tweaks
needed in DMA ops (e.g. in arch/arm/ and other OF users) to catch all
possible incarnations of this problem, but at least any that I'm not
fixing here have always been broken. It is also noteworthy that
of_dma_get_range() has never worked properly for the way PCI host
bridges are passed into of_dma_configure() - I'll be working on
further patches to sort that out once this part is done.

Changes since v1 (RFC):
- Pull in patch #1 (previously sent separately) to avoid conflicts
- Fix up comment and silly build-breaking typo in patch #2
- Add patches #6 and #7 since fiddling with coherent masks no longer
  serves a reasonable purpose

Robin.


[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2018-May/580804.html
[2] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-December/474443.html

Robin Murphy (7):
  ACPI/IORT: Support address size limit for root complexes
  dma-mapping: Generalise dma_32bit_limit flag
  ACPI/IORT: Set bus DMA mask as appropriate
  of/device: Set bus DMA mask as appropriate
  iommu/dma: Respect bus DMA limit for IOVAs
  ACPI/IORT: Don't set default coherent DMA mask
  OF: Don't set default coherent DMA mask

 arch/x86/kernel/pci-dma.c |  2 +-
 drivers/acpi/arm64/iort.c | 50 ++++++++++++++++++++++++++++-----------
 drivers/iommu/dma-iommu.c |  3 +++
 drivers/of/device.c       | 21 ++++++++--------
 include/linux/device.h    |  6 ++---
 kernel/dma/direct.c       |  6 ++---
 6 files changed, 57 insertions(+), 31 deletions(-)

-- 
2.17.1.dirty

^ permalink raw reply	[flat|nested] 82+ messages in thread

end of thread, other threads:[~2018-08-06 12:13 UTC | newest]

Thread overview: 82+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-23 22:16 [PATCH v2 0/7] Stop losing firmware-set DMA masks Robin Murphy
2018-07-23 22:16 ` Robin Murphy
2018-07-23 22:16 ` [PATCH v2 1/7] ACPI/IORT: Support address size limit for root complexes Robin Murphy
2018-07-23 22:16   ` Robin Murphy
2018-07-23 22:16 ` [PATCH v2 2/7] dma-mapping: Generalise dma_32bit_limit flag Robin Murphy
2018-07-23 22:16   ` Robin Murphy
     [not found]   ` <c1720f0181b66f711e4097d85149757b16a7b0a7.1532382222.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
2018-07-25 11:29     ` Christoph Hellwig
2018-07-25 11:29       ` Christoph Hellwig
2018-07-27 17:45     ` Grygorii Strashko via iommu
2018-07-27 17:45       ` Grygorii Strashko
     [not found]       ` <7872d914-8ea7-06e4-4a0c-489023e098d6-l0cyMroinI0@public.gmane.org>
2018-07-27 20:11         ` Robin Murphy
2018-07-27 20:11           ` Robin Murphy
     [not found]           ` <5354ef69-c54e-170b-62d4-5110dc60aa8f-5wv7dgnIgG8@public.gmane.org>
2018-07-27 20:41             ` Grygorii Strashko via iommu
2018-07-27 20:41               ` Grygorii Strashko
2018-07-23 22:16 ` [PATCH v2 3/7] ACPI/IORT: Set bus DMA mask as appropriate Robin Murphy
2018-07-23 22:16   ` Robin Murphy
     [not found]   ` <07cbf8f77fac552dca9b4c85a9d3bd8ed5a4cd29.1532382222.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
2018-07-25 11:29     ` Christoph Hellwig
2018-07-25 11:29       ` Christoph Hellwig
2018-07-25 13:16     ` Lorenzo Pieralisi
2018-07-25 13:16       ` Lorenzo Pieralisi
2018-07-23 22:16 ` [PATCH v2 4/7] of/device: " Robin Murphy
2018-07-23 22:16   ` Robin Murphy
     [not found]   ` <cc56f074b8da7e03a187b2363b1f2c2955d62c1c.1532382222.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
2018-07-25 11:30     ` Christoph Hellwig
2018-07-25 11:30       ` Christoph Hellwig
2018-07-23 22:16 ` [PATCH v2 5/7] iommu/dma: Respect bus DMA limit for IOVAs Robin Murphy
2018-07-23 22:16   ` Robin Murphy
     [not found]   ` <d370670edae9c9c537a5280c5e7c96bf3ec7ed8f.1532382222.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
2018-07-26  8:58     ` Christoph Hellwig
2018-07-26  8:58       ` Christoph Hellwig
2018-07-23 22:16 ` [PATCH v2 6/7] ACPI/IORT: Don't set default coherent DMA mask Robin Murphy
2018-07-23 22:16   ` Robin Murphy
     [not found]   ` <3525869e8e7530128bf9718ae8af7d7564b3c684.1532382222.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
2018-07-25 15:27     ` Lorenzo Pieralisi
2018-07-25 15:27       ` Lorenzo Pieralisi
2018-07-25 15:43       ` Robin Murphy
2018-07-25 15:43         ` Robin Murphy
2018-07-23 22:16 ` [PATCH v2 7/7] OF: " Robin Murphy
2018-07-23 22:16   ` Robin Murphy
     [not found]   ` <66c08e4df2032fde82a2f97544f41fd3a2f24a94.1532382222.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
2018-07-26 23:52     ` Grygorii Strashko via iommu
2018-07-26 23:52       ` Grygorii Strashko
2018-07-27  0:22       ` Grygorii Strashko
2018-07-27  0:22         ` Grygorii Strashko
     [not found]         ` <92d6b010-b5c0-fc59-0668-5b455e26c912-l0cyMroinI0@public.gmane.org>
2018-07-27 11:36           ` Robin Murphy
2018-07-27 11:36             ` Robin Murphy
2018-07-27 17:34             ` Grygorii Strashko
2018-07-27 17:34               ` Grygorii Strashko
     [not found]               ` <108a6254-1257-5daf-deaa-69bc4db2ec77-l0cyMroinI0@public.gmane.org>
2018-07-27 19:46                 ` Robin Murphy
2018-07-27 19:46                   ` Robin Murphy
     [not found]             ` <c7a9c7ae-1f4a-af9d-df78-1f48bb5c28a5-5wv7dgnIgG8@public.gmane.org>
2018-07-27 18:13               ` Russell King - ARM Linux
2018-07-27 18:13                 ` Russell King - ARM Linux
     [not found]                 ` <20180727181302.GC17271-l+eeeJia6m9URfEZ8mYm6t73F7V6hmMc@public.gmane.org>
2018-07-27 18:45                   ` Grygorii Strashko via iommu
2018-07-27 18:45                     ` Grygorii Strashko
     [not found]                     ` <affa2718-5f3a-7439-db25-ce171a99414a-l0cyMroinI0@public.gmane.org>
2018-07-27 20:42                       ` Robin Murphy
2018-07-27 20:42                         ` Robin Murphy
2018-07-27 19:29                   ` Robin Murphy
2018-07-27 19:29                     ` Robin Murphy
2018-07-26 23:45 ` [PATCH v2 0/7] Stop losing firmware-set DMA masks Grygorii Strashko
2018-07-26 23:45   ` Grygorii Strashko
     [not found]   ` <c73bc8d2-b745-ff31-1949-7a59ab04ede6-l0cyMroinI0@public.gmane.org>
2018-07-27 10:55     ` Robin Murphy
2018-07-27 10:55       ` Robin Murphy
     [not found]       ` <8b8ac841-5c4c-ae27-21d5-d7aaaf4c277c-5wv7dgnIgG8@public.gmane.org>
2018-07-27 17:22         ` Grygorii Strashko via iommu
2018-07-27 17:22           ` Grygorii Strashko
     [not found] ` <cover.1532382222.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
2018-07-25 11:31   ` Christoph Hellwig
2018-07-25 11:31     ` Christoph Hellwig
     [not found]     ` <20180725113122.GD24736-jcswGhMUV9g@public.gmane.org>
2018-07-25 12:11       ` Joerg Roedel
2018-07-25 12:11         ` Joerg Roedel
2018-07-25 12:12       ` Robin Murphy
2018-07-25 12:12         ` Robin Murphy
     [not found]         ` <5e036ade-db0b-f628-a4a0-6d014d1d76c8-5wv7dgnIgG8@public.gmane.org>
2018-07-25 12:17           ` Will Deacon
2018-07-25 12:17             ` Will Deacon
2018-07-25 13:58       ` Ard Biesheuvel
2018-07-25 13:58         ` Ard Biesheuvel
2018-07-26  9:00   ` Christoph Hellwig
2018-07-26  9:00     ` Christoph Hellwig
2018-07-29 12:32   ` Arnd Bergmann
2018-07-29 12:32     ` Arnd Bergmann
     [not found]     ` <CAK8P3a3HDJ6svNN_cwvegxu20yNv8+tvc0D1A6Ooeq8agawbFg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-07-31 11:24       ` Robin Murphy
2018-07-31 11:24         ` Robin Murphy
     [not found]         ` <1ccccc4b-7d4c-a3ee-23a2-f108916705e9-5wv7dgnIgG8@public.gmane.org>
2018-08-06 10:01           ` Arnd Bergmann
2018-08-06 10:01             ` Arnd Bergmann
     [not found]             ` <CAK8P3a3ZcOeHMR_qFnsBdXED+2X8_AEMKoS5MeAQhbapbGmm9w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-08-06 12:13               ` Christoph Hellwig
2018-08-06 12:13                 ` Christoph Hellwig
     [not found]                 ` <20180806121334.GA5340-jcswGhMUV9g@public.gmane.org>
2018-08-06 12:13                   ` Arnd Bergmann
2018-08-06 12:13                     ` Arnd Bergmann

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.