From: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
To: Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>,
Ingo Molnar <mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Tony Luck <tony.luck-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Fenghua Yu <fenghua.yu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
linux-ia64-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 1/7] core, dma-direct: add a flag 32-bit dma limits
Date: Fri, 25 May 2018 16:35:06 +0200 [thread overview]
Message-ID: <20180525143512.1466-2-hch@lst.de> (raw)
In-Reply-To: <20180525143512.1466-1-hch-jcswGhMUV9g@public.gmane.org>
Various PCI bridges (VIA PCI, Xilinx PCIe) limit DMA to only 32-bits
even if the device itself supports more. Add a single bit flag to
struct device (to be moved into the dma extension once we around it)
to flag such devices and reject larger DMA to them.
Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
include/linux/device.h | 3 +++
lib/dma-direct.c | 6 ++++++
2 files changed, 9 insertions(+)
diff --git a/include/linux/device.h b/include/linux/device.h
index 477956990f5e..fa317e45f5e6 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -904,6 +904,8 @@ struct dev_links_info {
* @offline: Set after successful invocation of bus type's .offline().
* @of_node_reused: Set if the device-tree node is shared with an ancestor
* device.
+ * @dma_32bit_limit: bridge limited to 32bit DMA even if the device itself
+ * indicates support for a higher limit in the dma_mask field.
*
* At the lowest level, every device in a Linux system is represented by an
* instance of struct device. The device structure contains the information
@@ -992,6 +994,7 @@ struct device {
bool offline_disabled:1;
bool offline:1;
bool of_node_reused:1;
+ bool dma_32bit_limit:1;
};
static inline struct device *kobj_to_dev(struct kobject *kobj)
diff --git a/lib/dma-direct.c b/lib/dma-direct.c
index bbfb229aa067..0151a7b2bc87 100644
--- a/lib/dma-direct.c
+++ b/lib/dma-direct.c
@@ -165,6 +165,12 @@ int dma_direct_supported(struct device *dev, u64 mask)
if (mask < DMA_BIT_MASK(32))
return 0;
#endif
+ /*
+ * Various PCI/PCIe bridges have broken support for > 32bit DMA even
+ * if the device itself might support it.
+ */
+ if (dev->dma_32bit_limit && mask > DMA_BIT_MASK(32))
+ return 0;
return 1;
}
--
2.17.0
next prev parent reply other threads:[~2018-05-25 14:35 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-25 14:35 refactor 32-bit dma limit quirks Christoph Hellwig
[not found] ` <20180525143512.1466-1-hch-jcswGhMUV9g@public.gmane.org>
2018-05-25 14:35 ` Christoph Hellwig [this message]
[not found] ` <20180525143512.1466-2-hch-jcswGhMUV9g@public.gmane.org>
2018-05-25 14:50 ` [PATCH 1/7] core, dma-direct: add a flag 32-bit dma limits Greg Kroah-Hartman
[not found] ` <20180525145012.GA3863-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2018-05-25 16:23 ` Christoph Hellwig
2018-05-25 16:35 ` Greg Kroah-Hartman
2018-05-25 14:35 ` [PATCH 3/7] ia64: remove iommu_dma_supported Christoph Hellwig
2018-05-25 14:35 ` [PATCH 4/7] x86: remove a stray reference to pci-nommu.c Christoph Hellwig
2018-05-26 19:23 ` Thomas Gleixner
2018-05-25 14:35 ` [PATCH 2/7] ia64: remove the dead iommu_sac_force variable Christoph Hellwig
2018-05-25 14:35 ` [PATCH 5/7] x86: remove the experimental forcesac boot option Christoph Hellwig
[not found] ` <20180525143512.1466-6-hch-jcswGhMUV9g@public.gmane.org>
2018-05-28 6:07 ` Thomas Gleixner
2018-05-25 14:35 ` [PATCH 6/7] x86: remove the explicit nodac and allowdac option Christoph Hellwig
[not found] ` <20180525143512.1466-7-hch-jcswGhMUV9g@public.gmane.org>
2018-05-28 6:08 ` Thomas Gleixner
2018-05-25 14:35 ` [PATCH 7/7] x86: switch the VIA 32-bit DMA quirk to use the struct device flag Christoph Hellwig
[not found] ` <20180525143512.1466-8-hch-jcswGhMUV9g@public.gmane.org>
2018-05-28 6:10 ` Thomas Gleixner
[not found] ` <alpine.DEB.2.21.1805280808280.1585-ecDvlHI5BZPZikZi3RtOZ1XZhhPuCNm+@public.gmane.org>
2018-05-28 6:19 ` Christoph Hellwig
[not found] ` <20180528061859.GA4145-jcswGhMUV9g@public.gmane.org>
2018-05-28 6:18 ` Thomas Gleixner
[not found] ` <alpine.DEB.2.21.1805280817310.1585-ecDvlHI5BZPZikZi3RtOZ1XZhhPuCNm+@public.gmane.org>
2018-05-28 6:27 ` Christoph Hellwig
[not found] ` <20180528062725.GA4309-jcswGhMUV9g@public.gmane.org>
2018-05-28 6:23 ` Thomas Gleixner
[not found] ` <alpine.DEB.2.21.1805280823240.1585-ecDvlHI5BZPZikZi3RtOZ1XZhhPuCNm+@public.gmane.org>
2018-05-28 8:39 ` Christoph Hellwig
[not found] ` <20180528083931.GA7169-jcswGhMUV9g@public.gmane.org>
2018-05-28 8:34 ` Thomas Gleixner
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=20180525143512.1466-2-hch@lst.de \
--to=hch-jcswghmuv9g@public.gmane.org \
--cc=fenghua.yu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=linux-ia64-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
--cc=tony.luck-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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).