From: Niklas Schnelle <schnelle@linux.ibm.com>
To: Jason Gunthorpe <jgg@nvidia.com>, Christoph Hellwig <hch@lst.de>
Cc: Robin Murphy <robin.murphy@arm.com>,
Alex Williamson <alex.williamson@redhat.com>,
Lu Baolu <baolu.lu@linux.intel.com>,
Christian Benvenuti <benve@cisco.com>,
Cornelia Huck <cohuck@redhat.com>,
David Woodhouse <dwmw2@infradead.org>,
Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
iommu@lists.linux-foundation.org,
Jason Wang <jasowang@redhat.com>, Joerg Roedel <joro@8bytes.org>,
kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org, linux-rdma@vger.kernel.org,
linux-s390@vger.kernel.org,
Matthew Rosato <mjrosato@linux.ibm.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Nelson Escobar <neescoba@cisco.com>,
netdev@vger.kernel.org, Rob Clark <robdclark@gmail.com>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
virtualization@lists.linux-foundation.org,
Will Deacon <will@kernel.org>,
"Tian, Kevin" <kevin.tian@intel.com>
Subject: Re: [PATCH 1/5] iommu: Replace uses of IOMMU_CAP_CACHE_COHERENCY with dev_is_dma_coherent()
Date: Thu, 07 Apr 2022 10:53:03 +0200 [thread overview]
Message-ID: <49d40d562dbccdac58597b863c357b32f0798284.camel@linux.ibm.com> (raw)
In-Reply-To: <20220406171729.GJ2120790@nvidia.com>
On Wed, 2022-04-06 at 14:17 -0300, Jason Gunthorpe wrote:
> On Wed, Apr 06, 2022 at 06:10:31PM +0200, Christoph Hellwig wrote:
> > On Wed, Apr 06, 2022 at 01:06:23PM -0300, Jason Gunthorpe wrote:
> > > On Wed, Apr 06, 2022 at 05:50:56PM +0200, Christoph Hellwig wrote:
> > > > On Wed, Apr 06, 2022 at 12:18:23PM -0300, Jason Gunthorpe wrote:
> > > > > > Oh, I didn't know about device_get_dma_attr()..
> > > >
> > > > Which is completely broken for any non-OF, non-ACPI plaform.
> > >
> > > I saw that, but I spent some time searching and could not find an
> > > iommu driver that would load independently of OF or ACPI. ie no IOMMU
> > > platform drivers are created by board files. Things like Intel/AMD
> > > discover only from ACPI, etc.
> >
> > s390?
>
> Ah, I missed looking in s390, hyperv and virtio..
>
> hyperv is not creating iommu_domains, just IRQ remapping
>
> virtio is using OF
>
> And s390 indeed doesn't obviously have OF or ACPI parts..
>
> This seems like it would be consistent with other things:
>
> enum dev_dma_attr device_get_dma_attr(struct device *dev)
> {
> const struct fwnode_handle *fwnode = dev_fwnode(dev);
> struct acpi_device *adev = to_acpi_device_node(fwnode);
>
> if (is_of_node(fwnode)) {
> if (of_dma_is_coherent(to_of_node(fwnode)))
> return DEV_DMA_COHERENT;
> return DEV_DMA_NON_COHERENT;
> } else if (adev) {
> return acpi_get_dma_attr(adev);
> }
>
> /* Platform is always DMA coherent */
> if (!IS_ENABLED(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) &&
> !IS_ENABLED(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) &&
> !IS_ENABLED(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) &&
> device_iommu_mapped(dev))
> return DEV_DMA_COHERENT;
> return DEV_DMA_NOT_SUPPORTED;
> }
> EXPORT_SYMBOL_GPL(device_get_dma_attr);
>
> ie s390 has no of or acpi but the entire platform is known DMA
> coherent at config time so allow it. Not sure we need the
> device_iommu_mapped() or not.
I only took a short look but I think the device_iommu_mapped() call in
there is wrong. On s390 PCI always goes through IOMMU hardware both
when using the IOMMU API and when using the DMA API and this hardware
is always coherent. This is even true for s390 guests in QEMU/KVM and
under the z/VM hypervisor. As far as I can see device_iommu_mapped()'s
check for dev->iommu_group would only work while the device is under
IOMMU API control not DMA API, no?
Also, while it is true that s390 *hardware* devices are always cache
coherent there is also the case that SWIOTLB is used for protected
virtualization and then cache flushing APIs must be used.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-04-07 9:15 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-05 16:15 [PATCH 0/5] Make the iommu driver no-snoop block feature consistent Jason Gunthorpe
2022-04-05 16:16 ` [PATCH 1/5] iommu: Replace uses of IOMMU_CAP_CACHE_COHERENCY with dev_is_dma_coherent() Jason Gunthorpe
2022-04-06 5:30 ` Christoph Hellwig
2022-04-06 12:07 ` Jason Gunthorpe
2022-04-06 13:51 ` Christoph Hellwig
2022-04-06 14:14 ` Jason Gunthorpe
2022-04-06 15:47 ` Christoph Hellwig
2022-04-06 15:48 ` Jason Gunthorpe
2022-04-06 15:48 ` Robin Murphy
2022-04-06 13:56 ` Robin Murphy
2022-04-06 14:24 ` Jason Gunthorpe
2022-04-06 15:18 ` Jason Gunthorpe
2022-04-06 15:50 ` Christoph Hellwig
2022-04-06 16:06 ` Jason Gunthorpe
2022-04-06 16:10 ` Christoph Hellwig
2022-04-06 17:17 ` Jason Gunthorpe
2022-04-07 7:18 ` Tian, Kevin
2022-04-07 13:59 ` Jason Gunthorpe
2022-04-07 15:17 ` Robin Murphy
2022-04-07 15:23 ` Jason Gunthorpe
2022-04-07 22:37 ` Alex Williamson
2022-04-07 15:31 ` Christoph Hellwig
2022-04-07 8:53 ` Niklas Schnelle [this message]
2022-04-05 16:16 ` [PATCH 2/5] vfio: Require that devices support DMA cache coherence Jason Gunthorpe
2022-04-05 19:10 ` Alex Williamson
2022-04-05 19:29 ` Jason Gunthorpe
2022-04-06 7:02 ` Tian, Kevin
2022-04-07 14:53 ` Jason Gunthorpe
2022-04-05 16:16 ` [PATCH 3/5] iommu: Introduce the domain op enforce_cache_coherency() Jason Gunthorpe
2022-04-05 19:50 ` Alex Williamson
2022-04-05 22:57 ` Jason Gunthorpe
2022-04-05 23:31 ` Tian, Kevin
2022-04-06 0:08 ` Tian, Kevin
2022-04-06 7:09 ` Tian, Kevin
2022-04-06 12:27 ` Jason Gunthorpe
2022-04-05 16:16 ` [PATCH 4/5] vfio: Move the Intel no-snoop control off of IOMMU_CACHE Jason Gunthorpe
2022-04-05 16:16 ` [PATCH 5/5] iommu: Delete IOMMU_CAP_CACHE_COHERENCY Jason Gunthorpe
2022-04-06 6:52 ` [PATCH 0/5] Make the iommu driver no-snoop block feature consistent Tian, Kevin
2022-04-07 14:56 ` Jason Gunthorpe
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=49d40d562dbccdac58597b863c357b32f0798284.camel@linux.ibm.com \
--to=schnelle@linux.ibm.com \
--cc=alex.williamson@redhat.com \
--cc=baolu.lu@linux.intel.com \
--cc=benve@cisco.com \
--cc=cohuck@redhat.com \
--cc=dwmw2@infradead.org \
--cc=gerald.schaefer@linux.ibm.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=jasowang@redhat.com \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mjrosato@linux.ibm.com \
--cc=mst@redhat.com \
--cc=neescoba@cisco.com \
--cc=netdev@vger.kernel.org \
--cc=robdclark@gmail.com \
--cc=robin.murphy@arm.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=will@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 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).