From: Joerg Roedel <joro@8bytes.org>
To: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Cc: Mark Rutland <Mark.Rutland@arm.com>,
"xieyisheng1@huawei.com" <xieyisheng1@huawei.com>,
"gabriele.paoloni@huawei.com" <gabriele.paoloni@huawei.com>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
Will Deacon <Will.Deacon@arm.com>,
"okaya@codeaurora.org" <okaya@codeaurora.org>,
"yi.l.liu@intel.com" <yi.l.liu@intel.com>,
Lorenzo Pieralisi <Lorenzo.Pieralisi@arm.com>,
"ashok.raj@intel.com" <ashok.raj@intel.com>,
"tn@semihalf.com" <tn@semihalf.com>,
"robdclark@gmail.com" <robdclark@gmail.com>,
"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
Catalin Marinas <Catalin.Marinas@arm.com>,
"rfranz@cavium.com" <rfranz@cavium.com>,
"lenb@kernel.org" <lenb@kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"jacob.jun.pan@linux.intel.com" <jacob.jun.pan@linux.intel.com>,
"alex.williamson@redhat.com" <alex.williamson@redhat.com>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
"thunder.leizhen@huawei.com" <thunder.leizhen@huawei.com>,
"bhelgaas@google.com" <bhelgaas@google.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"dwmw2@infradead.org" <dwmw2@infradead.org>,
"liubo95@huawei.com" <liubo95@huawei.com>,
"rjw@rjwysocki.net" <rjw@rjwysocki.net>,
"iommu@lists.linux-foundation.org"
<iommu@lists.linux-foundation.org>,
"hanjun.guo@linaro.org" <hanjun.guo@linaro.org>,
Sudeep Holla <Sudeep.Holla@arm.com>,
Robin Murphy <Robin.Murphy@arm.com>,
"nwatters@codeaurora.org" <nwatters@codeaurora.org>
Subject: Re: [RFCv2 PATCH 05/36] iommu/process: Bind and unbind process to and from devices
Date: Thu, 12 Oct 2017 14:47:38 +0200 [thread overview]
Message-ID: <20171012124738.r5lihlxaedwkw4oq@8bytes.org> (raw)
In-Reply-To: <ee7f80e3-ca30-0ee7-53f3-3e57b2b58df6@arm.com>
Hi Jean-Philippe,
On Thu, Oct 12, 2017 at 12:13:20PM +0100, Jean-Philippe Brucker wrote:
> On 11/10/17 12:33, Joerg Roedel wrote:
> > Here is how I think the base API should look like:
> >
> > * iommu_iovm_device_init(struct device *dev);
> > iommu_iovm_device_shutdown(struct device *dev);
> >
> > These two functions do the device specific setup/shutdown. For
> > PCI this would include enabling the PRI, PASID, and ATS
> > capabilities and setting up a PASID table for the device.
>
> Ok. On SMMU the PASID table also hosts the non-PASID page table pointer,
> so the table and capability cannot be setup later than attach_device (and
> we'll probably have to enable PASID in add_device). But I suppose it's an
> implementation detail.
Right, when the capabilities are enabled is an implementation detail of
the iommu-drivers.
> Some device drivers will want to use ATS alone, for accelerating IOVA
> traffic. Should we enable it automatically, or provide device drivers with
> a way to enable it manually? According to the PCI spec, PASID has to be
> enabled before ATS, so device_init would have to first disable ATS in that
> case.
Yes, driver can enable ATS for normal use of a device, and
disable/re-enable it when the driver requests PASID/PRI functionality.
That is also an implementation detail. You should probably also document
that the init/shutdown functions may interrupt device operation, so that
driver writers are aware of that.
>
> > * iommu_iovm_bind_mm(struct device *dev, struct mm_struct *mm,
> > iovm_shutdown_cb *cb);
> > iommu_iovm_unbind_mm(struct device *dev, struct mm_struct *mm);
> >
> > These functions add and delete the entries in the PASID table
> > for the device and setup mmu_notifiers for the mm_struct to
> > keep IOMMU TLBs in sync with the CPU TLBs.
> >
> > The shutdown_cb is invoked by the IOMMU core code when the
> > mm_struct goes away, for example because the process
> > segfaults.
> >
> > The PASID handling is best done these functions as well, unless
> > there is a strong reason to allow device drivers to do the
> > handling themselves.
> >
> > The context data can be stored directly in mm_struct, including the
> > PASID for that mm.
>
> Changing mm_struct probably isn't required at the moment, since the mm
> subsystem won't use the context data or the PASID. Outside of
> drivers/iommu/, only the caller of bind_mm needs the PASID in order to
> program it into the device. The only advantage I see would be slightly
> faster bind(), when finding out if a mm is already bound to devices. But
> we don't really need fast bind(), so I don't think we'd have enough
> material to argue for a change in mm_struct.
The idea behind storing the PASID in mm_struct is that we have a
system-wide PASID-allocator and only one PASID per address space, even
when accessed from multiple devices.
There will be hardware implemenations where this is required, afaik. It
doesn't mean that it _needs_ to be part of mm_struct, but it is
certainly easier than tracking this 1-1 relation separatly.
> We do need to allocate a separate "iommu_mm_struct" wrapper to store the
> mmu_notifier. Maybe bind() could return this structure (that contains the
> PASID), and unbind() would take this iommu_mm_struct as argument?
I'd like to track this iommu_mm_struct only in iommu-code, otherwise
drivers need to track the pointer somewhere. And we need to track the
mm_struct->iommu_mm_struct relation anyway in core-code to handle events
like segfaults, when the whole mm_struct goes away under us. So when we
track this in core code, there is no need to track this again in the
device drivers.
Regards,
Joerg
_______________________________________________
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:[~2017-10-12 12:47 UTC|newest]
Thread overview: 93+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-06 13:31 [RFCv2 PATCH 00/36] Process management for IOMMU + SVM for SMMUv3 Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 01/36] iommu: Keep track of processes and PASIDs Jean-Philippe Brucker
2017-10-20 23:32 ` Sinan Kaya
2017-11-02 16:20 ` Jean-Philippe Brucker
2017-10-23 11:04 ` Liu, Yi L
2017-10-23 12:17 ` Jean-Philippe Brucker
2017-10-25 18:05 ` Raj, Ashok
2017-10-30 10:28 ` Jean-Philippe Brucker
2017-11-08 17:50 ` Bharat Kumar Gogada
2017-11-09 12:13 ` Jean-Philippe Brucker
2017-11-09 12:16 ` Jean-Philippe Brucker
2017-11-13 11:06 ` Bharat Kumar Gogada
2017-11-22 3:15 ` Bob Liu
2017-11-22 13:04 ` Jean-Philippe Brucker
2017-11-23 10:33 ` Bob Liu
2017-10-06 13:31 ` [RFCv2 PATCH 02/36] iommu: Add a process_exit callback for device drivers Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 03/36] iommu/process: Add public function to search for a process Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 04/36] iommu/process: Track process changes with an mmu_notifier Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 05/36] iommu/process: Bind and unbind process to and from devices Jean-Philippe Brucker
2017-10-11 11:33 ` Joerg Roedel
2017-10-12 11:13 ` Jean-Philippe Brucker
2017-10-12 12:47 ` Joerg Roedel [this message]
2017-10-21 15:47 ` Sinan Kaya
2017-11-02 16:21 ` Jean-Philippe Brucker
2017-11-29 6:08 ` Yisheng Xie
2017-11-29 15:01 ` Jean-Philippe Brucker
2017-11-30 1:11 ` Yisheng Xie
2017-11-30 13:39 ` Jean-Philippe Brucker
2018-01-19 4:52 ` Sinan Kaya
2018-01-19 10:27 ` Jean-Philippe Brucker
2018-01-19 13:07 ` okaya
2017-10-06 13:31 ` [RFCv2 PATCH 06/36] iommu: Extend fault reporting Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 07/36] iommu: Add a fault handler Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 08/36] iommu/fault: Handle mm faults Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 09/36] iommu/fault: Allow blocking fault handlers Jean-Philippe Brucker
2017-11-29 6:15 ` Yisheng Xie
2017-11-29 15:01 ` Jean-Philippe Brucker
2017-11-30 2:45 ` Yisheng Xie
2017-10-06 13:31 ` [RFCv2 PATCH 10/36] vfio: Add support for Shared Virtual Memory Jean-Philippe Brucker
2017-11-24 8:23 ` Bob Liu
2017-11-24 10:58 ` Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 11/36] iommu/arm-smmu-v3: Link domains and devices Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 12/36] dt-bindings: document stall and PASID properties for IOMMU masters Jean-Philippe Brucker
2017-10-13 19:10 ` Rob Herring
2017-10-16 10:23 ` Jean-Philippe Brucker
2017-10-18 2:06 ` Rob Herring
2017-10-06 13:31 ` [RFCv2 PATCH 13/36] iommu/of: Add stall and pasid properties to iommu_fwspec Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 14/36] iommu/arm-smmu-v3: Add support for Substream IDs Jean-Philippe Brucker
2017-11-02 12:49 ` Shameerali Kolothum Thodi
2017-11-02 15:51 ` Jean-Philippe Brucker
2017-11-02 17:02 ` Shameerali Kolothum Thodi
2017-11-03 5:45 ` Yisheng Xie
2017-11-03 9:37 ` Jean-Philippe Brucker
2017-11-03 9:39 ` Shameerali Kolothum Thodi
2017-11-06 0:50 ` Yisheng Xie
2017-10-06 13:31 ` [RFCv2 PATCH 15/36] iommu/arm-smmu-v3: Add second level of context descriptor table Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 16/36] iommu/arm-smmu-v3: Add support for VHE Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 17/36] iommu/arm-smmu-v3: Support broadcast TLB maintenance Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 18/36] iommu/arm-smmu-v3: Add SVM feature checking Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 19/36] arm64: mm: Pin down ASIDs for sharing contexts with devices Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 20/36] iommu/arm-smmu-v3: Track ASID state Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 21/36] iommu/arm-smmu-v3: Implement process operations Jean-Philippe Brucker
2017-11-09 3:32 ` Yisheng Xie
2017-11-09 12:08 ` Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 22/36] iommu/io-pgtable-arm: Factor out ARM LPAE register defines Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 23/36] iommu/arm-smmu-v3: Share process page tables Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 24/36] iommu/arm-smmu-v3: Steal private ASID from a domain Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 25/36] iommu/arm-smmu-v3: Use shared ASID set Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 26/36] iommu/arm-smmu-v3: Add support for Hardware Translation Table Update Jean-Philippe Brucker
2017-12-06 6:51 ` Yisheng Xie
2017-12-06 11:06 ` Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 27/36] iommu/arm-smmu-v3: Register fault workqueue Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 28/36] iommu/arm-smmu-v3: Maintain a SID->device structure Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 29/36] iommu/arm-smmu-v3: Add stall support for platform devices Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 30/36] ACPI/IORT: Check ATS capability in root complex nodes Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 31/36] iommu/arm-smmu-v3: Add support for PCI ATS Jean-Philippe Brucker
2017-11-16 14:19 ` Bharat Kumar Gogada
2017-11-16 15:03 ` Jean-Philippe Brucker
2017-11-17 6:11 ` Bharat Kumar Gogada
2017-11-17 11:39 ` Jean-Philippe Brucker
2017-10-06 13:31 ` [RFCv2 PATCH 32/36] iommu/arm-smmu-v3: Hook ATC invalidation to process ops Jean-Philippe Brucker
2017-10-06 13:32 ` [RFCv2 PATCH 33/36] iommu/arm-smmu-v3: Disable tagged pointers Jean-Philippe Brucker
2017-10-06 13:32 ` [RFCv2 PATCH 34/36] PCI: Make "PRG Response PASID Required" handling common Jean-Philippe Brucker
2017-10-06 18:11 ` Bjorn Helgaas
2017-10-06 13:32 ` [RFCv2 PATCH 35/36] iommu/arm-smmu-v3: Add support for PRI Jean-Philippe Brucker
2017-10-06 13:32 ` [RFCv2 PATCH 36/36] iommu/arm-smmu-v3: Add support for PCI PASID Jean-Philippe Brucker
2017-10-09 9:49 ` [RFCv2 PATCH 00/36] Process management for IOMMU + SVM for SMMUv3 Yisheng Xie
2017-10-09 11:36 ` Jean-Philippe Brucker
2017-10-12 12:05 ` Yisheng Xie
2017-10-12 12:55 ` Jean-Philippe Brucker
2017-10-12 15:28 ` Jordan Crouse
2017-11-08 1:21 ` Bob Liu
2017-11-08 10:50 ` Jean-Philippe Brucker
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=20171012124738.r5lihlxaedwkw4oq@8bytes.org \
--to=joro@8bytes.org \
--cc=Catalin.Marinas@arm.com \
--cc=Lorenzo.Pieralisi@arm.com \
--cc=Mark.Rutland@arm.com \
--cc=Robin.Murphy@arm.com \
--cc=Sudeep.Holla@arm.com \
--cc=Will.Deacon@arm.com \
--cc=alex.williamson@redhat.com \
--cc=ashok.raj@intel.com \
--cc=bhelgaas@google.com \
--cc=devicetree@vger.kernel.org \
--cc=dwmw2@infradead.org \
--cc=gabriele.paoloni@huawei.com \
--cc=hanjun.guo@linaro.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jean-philippe.brucker@arm.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=liubo95@huawei.com \
--cc=nwatters@codeaurora.org \
--cc=okaya@codeaurora.org \
--cc=rfranz@cavium.com \
--cc=rjw@rjwysocki.net \
--cc=robdclark@gmail.com \
--cc=robh+dt@kernel.org \
--cc=thunder.leizhen@huawei.com \
--cc=tn@semihalf.com \
--cc=xieyisheng1@huawei.com \
--cc=yi.l.liu@intel.com \
/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).