From: Robin Murphy <robin.murphy@arm.com>
To: Jason Gunthorpe <jgg@nvidia.com>, "Tian, Kevin" <kevin.tian@intel.com>
Cc: Nelson Escobar <neescoba@cisco.com>,
Matthew Rosato <mjrosato@linux.ibm.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"virtualization@lists.linux-foundation.org"
<virtualization@lists.linux-foundation.org>,
Will Deacon <will@kernel.org>, Christoph Hellwig <hch@lst.de>,
"linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
Joerg Roedel <joro@8bytes.org>, Rob Clark <robdclark@gmail.com>,
Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Cornelia Huck <cohuck@redhat.com>,
"iommu@lists.linux-foundation.org"
<iommu@lists.linux-foundation.org>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Christian Benvenuti <benve@cisco.com>,
David Woodhouse <dwmw2@infradead.org>,
Lu Baolu <baolu.lu@linux.intel.com>
Subject: Re: [PATCH 1/5] iommu: Replace uses of IOMMU_CAP_CACHE_COHERENCY with dev_is_dma_coherent()
Date: Thu, 7 Apr 2022 16:17:11 +0100 [thread overview]
Message-ID: <fb55a025-348e-800c-e368-48be075d8e9c@arm.com> (raw)
In-Reply-To: <20220407135946.GM2120790@nvidia.com>
On 2022-04-07 14:59, Jason Gunthorpe wrote:
> On Thu, Apr 07, 2022 at 07:18:48AM +0000, Tian, Kevin wrote:
>>> From: Jason Gunthorpe <jgg@nvidia.com>
>>> Sent: Thursday, April 7, 2022 1:17 AM
>>>
>>> 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.
>>
>> Intel discovers IOMMUs (and optionally ACPI namespace devices) from
>> ACPI, but there is no ACPI description for PCI devices i.e. the current
>> logic of device_get_dma_attr() cannot be used on PCI devices.
>
> Oh? So on x86 acpi_get_dma_attr() returns DEV_DMA_NON_COHERENT or
> DEV_DMA_NOT_SUPPORTED?
I think it _should_ return DEV_DMA_COHERENT on x86/IA-64 (unless a _CCA
method was actually present to say otherwise), based on
acpi_init_coherency(), but I only know for sure what happens on arm64.
> I think I should give up on this and just redefine the existing iommu
> cap flag to IOMMU_CAP_CACHE_SUPPORTED or something.
TBH I don't see any issue with current name, but I'd certainly be happy
to nail down a specific definition for it, along the lines of "this
means that IOMMU_CACHE mappings are generally coherent". That works for
things like Arm's S2FWB making it OK to assign an otherwise-non-coherent
device without extra hassle.
For the specific case of overriding PCIe No Snoop (which is more
problematic from an Arm SMMU PoV) when assigning to a VM, would that not
be easier solved by just having vfio-pci clear the "Enable No Snoop"
control bit in the endpoint's PCIe capability?
>>> We could alternatively use existing device_get_dma_attr() as a default
>>> with an iommu wrapper and push the exception down through the iommu
>>> driver and s390 can override it.
>>>
>>
>> if going this way probably device_get_dma_attr() should be renamed to
>> device_fwnode_get_dma_attr() instead to make it clearer?
>
> I'm looking at the few users:
>
> drivers/ata/ahci_ceva.c
> drivers/ata/ahci_qoriq.c
> - These are ARM only drivers. They are trying to copy the dma-coherent
> property from its DT/ACPI definition to internal register settings
> which look like they tune how the AXI bus transactions are created.
>
> I'm guessing the SATA IP block's AXI interface can be configured to
> generate coherent or non-coherent requests and it has to be set
> in a way that is consistent with the SOC architecture and match
> what the DMA API expects the device will do.
>
> drivers/crypto/ccp/sp-platform.c
> - Only used on ARM64 and also programs a HW register similar to the
> sata drivers. Refuses to work if the FW property is not present.
>
> drivers/net/ethernet/amd/xgbe/xgbe-platform.c
> - Seems to be configuring another ARM AXI block
>
> drivers/gpu/drm/panfrost/panfrost_drv.c
> - Robin's commit comment here is good, and one of the things this
> controls is if the coherent_walk is set for the io-pgtable-arm.c
> code which avoids DMA API calls
>
> drivers/gpu/drm/tegra/uapi.c
> - Returns DRM_TEGRA_CHANNEL_CAP_CACHE_COHERENT to userspace. No idea.
>
> My take is that the drivers using this API are doing it to make sure
> their HW blocks are setup in a way that is consistent with the DMA API
> they are also using, and run in constrained embedded-style
> environments that know the firmware support is present.
>
> So in the end it does not seem suitable right now for linking to
> IOMMU_CACHE..
That seems a pretty good summary - I think they're basically all
"firmware told Linux I'm coherent so I'd better act coherent" cases, but
that still doesn't necessarily mean that they're *forced* to respect
that. One of the things on my to-do list is to try adding a
DMA_ATTR_NO_SNOOP that can force DMA cache maintenance for coherent
devices, primarily to hook up in Panfrost (where there is a bit of a
performance to claw back on the coherent AmLogic SoCs by leaving certain
buffers non-cacheable).
Cheers,
Robin.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2022-04-07 15:17 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <0-v1-ef02c60ddb76+12ca2-intel_no_snoop_jgg@nvidia.com>
[not found] ` <2-v1-ef02c60ddb76+12ca2-intel_no_snoop_jgg@nvidia.com>
2022-04-05 19:10 ` [PATCH 2/5] vfio: Require that devices support DMA cache coherence Alex Williamson
[not found] ` <20220405192916.GT2120790@nvidia.com>
2022-04-06 7:02 ` Tian, Kevin
[not found] ` <1-v1-ef02c60ddb76+12ca2-intel_no_snoop_jgg@nvidia.com>
2022-04-06 5:30 ` [PATCH 1/5] iommu: Replace uses of IOMMU_CAP_CACHE_COHERENCY with dev_is_dma_coherent() Christoph Hellwig
[not found] ` <20220406120730.GA2120790@nvidia.com>
2022-04-06 13:51 ` Christoph Hellwig
[not found] ` <20220406141446.GE2120790@nvidia.com>
2022-04-06 15:47 ` Christoph Hellwig
2022-04-06 15:48 ` Robin Murphy
2022-04-06 13:56 ` Robin Murphy
[not found] ` <20220406142432.GF2120790@nvidia.com>
[not found] ` <20220406151823.GG2120790@nvidia.com>
2022-04-06 15:50 ` Christoph Hellwig
[not found] ` <20220406160623.GI2120790@nvidia.com>
2022-04-06 16:10 ` Christoph Hellwig
[not found] ` <20220406171729.GJ2120790@nvidia.com>
2022-04-07 7:18 ` Tian, Kevin
[not found] ` <20220407135946.GM2120790@nvidia.com>
2022-04-07 15:17 ` Robin Murphy [this message]
2022-04-07 15:31 ` Christoph Hellwig
[not found] ` <20220407152331.GN2120790@nvidia.com>
2022-04-07 22:37 ` Alex Williamson
2022-04-06 6:52 ` [PATCH 0/5] Make the iommu driver no-snoop block feature consistent Tian, Kevin
[not found] ` <3-v1-ef02c60ddb76+12ca2-intel_no_snoop_jgg@nvidia.com>
2022-04-05 19:50 ` [PATCH 3/5] iommu: Introduce the domain op enforce_cache_coherency() Alex Williamson
[not found] ` <20220405225739.GW2120790@nvidia.com>
2022-04-05 23:31 ` Tian, Kevin
2022-04-06 0:08 ` Tian, Kevin
2022-04-06 7:09 ` Tian, Kevin
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=fb55a025-348e-800c-e368-48be075d8e9c@arm.com \
--to=robin.murphy@arm.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=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=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).