Re: [PATCH v8 26/29] vfio-pci: Register an iommu fault handler

2019-06-18 Thread Jean-Philippe Brucker
On 12/06/2019 19:53, Jacob Pan wrote: >>> You are right, the worst case of the spurious PS is to terminate the >>> group prematurely. Need to know the scope of the HW damage in case >>> of mdev where group IDs can be shared among mdevs belong to the >>> same PF. >> >> But from the IOMMU fault

Re: [PATCH v7 14/21] iommu/mediatek: Add mmu1 support

2019-06-18 Thread Tomasz Figa
On Tue, Jun 18, 2019 at 9:09 PM Yong Wu wrote: > > On Tue, 2019-06-18 at 15:19 +0900, Tomasz Figa wrote: > > On Mon, Jun 10, 2019 at 9:21 PM Yong Wu wrote: > > > > > > Normally the M4U HW connect EMI with smi. the diagram is like below: > > > EMI > > >| > > >

Re: [PATCH v4 10/22] iommu: Fix compile error without IOMMU_API

2019-06-18 Thread Jonathan Cameron
On Sun, 9 Jun 2019 06:44:10 -0700 Jacob Pan wrote: > struct page_response_msg needs to be defined outside CONFIG_IOMMU_API. What was the error? If this is a fix for an earlier patch in this series role it in there (or put it before it). If more general we should add a fixes tag. Jonathan >

Re: [PATCH] iommu: Add padding to struct iommu_fault

2019-06-18 Thread Joerg Roedel
On Wed, Jun 12, 2019 at 06:59:38PM +0100, Jean-Philippe Brucker wrote: > Ease future extensions of struct iommu_fault_page_request and struct > iommu_fault_unrecoverable by adding a few bytes of padding. That way, a > new field can be added to either of these structures by simply introducing > a

Re: [PATCH] iommu: fix integer truncation

2019-06-18 Thread Joerg Roedel
On Mon, Jun 17, 2019 at 03:30:54PM +0200, Arnd Bergmann wrote: > On 32-bit architectures, phys_addr_t may be different from dma_add_t, > both smaller and bigger. This can lead to an overflow during an assignment > that clang warns about: > > drivers/iommu/dma-iommu.c:230:10: error: implicit

Re: [PATCH v4 09/22] iommu: Introduce cache_invalidate API

2019-06-18 Thread Jonathan Cameron
On Sun, 9 Jun 2019 06:44:09 -0700 Jacob Pan wrote: > From: Liu Yi L > > In any virtualization use case, when the first translation stage > is "owned" by the guest OS, the host IOMMU driver has no knowledge > of caching structure updates unless the guest invalidation activities > are trapped by

Re: [PATCH 1/8] iommu: Add I/O ASID allocator

2019-06-18 Thread Jacob Pan
On Tue, 18 Jun 2019 15:22:20 +0100 Jean-Philippe Brucker wrote: > On 11/06/2019 19:13, Jacob Pan wrote: > +/** > + * ioasid_find - Find IOASID data > + * @set: the IOASID set > + * @ioasid: the IOASID to find > + * @getter: function to call on the found object > + *

Re: [PATCH 1/8] iommu: Add I/O ASID allocator

2019-06-18 Thread Jean-Philippe Brucker
On 11/06/2019 19:13, Jacob Pan wrote: +/** + * ioasid_find - Find IOASID data + * @set: the IOASID set + * @ioasid: the IOASID to find + * @getter: function to call on the found object + * + * The optional getter function allows to take a reference to the

Re: [PATCH v4 04/22] iommu: Add recoverable fault reporting

2019-06-18 Thread Jonathan Cameron
On Sun, 9 Jun 2019 06:44:04 -0700 Jacob Pan wrote: > From: Jean-Philippe Brucker > > Some IOMMU hardware features, for example PCI's PRI and Arm SMMU's Stall, > enable recoverable I/O page faults. Allow IOMMU drivers to report PRI Page > Requests and Stall events through the new fault

Re: [PATCH v7 20/21] iommu/mediatek: Fix iova_to_phys PA start for 4GB mode

2019-06-18 Thread Matthias Brugger
On 10/06/2019 14:17, Yong Wu wrote: > In the 4GB mode, the physical address is remapped, > > Here is the detailed remap relationship. > CPU PA ->HW PA > 0x4000_ 0x1_4000_ (Add bit32) > 0x8000_ 0x1_8000_ ... > 0xc000_ 0x1_c000_ ...

Re: [PATCH v4 20/22] iommu/vt-d: Add bind guest PASID support

2019-06-18 Thread Jonathan Cameron
On Sun, 9 Jun 2019 06:44:20 -0700 Jacob Pan wrote: > When supporting guest SVA with emulated IOMMU, the guest PASID > table is shadowed in VMM. Updates to guest vIOMMU PASID table > will result in PASID cache flush which will be passed down to > the host as bind guest PASID calls. > > For the

Re: [PATCH] iommu/intel: remove an unused variable "length"

2019-06-18 Thread Joerg Roedel
On Mon, Jun 17, 2019 at 09:20:27AM -0400, Qian Cai wrote: > The linux-next commit "iommu/vt-d: Duplicate iommu_resv_region objects > per device list" [1] left out an unused variable, > > drivers/iommu/intel-iommu.c: In function 'dmar_parse_one_rmrr': > drivers/iommu/intel-iommu.c:4014:9: warning:

Re: [PATCH -next] iommu/intel: silence a variable set but not used

2019-06-18 Thread Joerg Roedel
On Mon, Jun 03, 2019 at 10:05:19AM -0400, Qian Cai wrote: > The commit "iommu/vt-d: Probe DMA-capable ACPI name space devices" > introduced a compilation warning due to the "iommu" variable in > for_each_active_iommu() but never used the for each element, i.e, > "drhd->iommu". > >

Re: [PATCH v4 15/22] iommu/vt-d: Replace Intel specific PASID allocator with IOASID

2019-06-18 Thread Jonathan Cameron
On Sun, 9 Jun 2019 06:44:15 -0700 Jacob Pan wrote: > Make use of generic IOASID code to manage PASID allocation, > free, and lookup. Replace Intel specific code. > > Signed-off-by: Jacob Pan Hi Jacob, One question inline. Jonathan > --- > drivers/iommu/intel-iommu.c | 11 +-- >

Re: [PATCH v4 17/22] iommu/vt-d: Avoid duplicated code for PASID setup

2019-06-18 Thread Jonathan Cameron
On Sun, 9 Jun 2019 06:44:17 -0700 Jacob Pan wrote: > After each setup for PASID entry, related translation caches must be flushed. > We can combine duplicated code into one function which is less error prone. > > Signed-off-by: Jacob Pan Formatting nitpick below ;) Otherwise it's cut and

Re: [PATCH v4 02/22] iommu: Introduce device fault data

2019-06-18 Thread Jonathan Cameron
On Sun, 9 Jun 2019 06:44:02 -0700 Jacob Pan wrote: > Device faults detected by IOMMU can be reported outside the IOMMU > subsystem for further processing. This patch introduces > a generic device fault data structure. > > The fault can be either an unrecoverable fault or a page request, > also

Re: [PATCH v4 08/22] iommu: Introduce attach/detach_pasid_table API

2019-06-18 Thread Jonathan Cameron
On Sun, 9 Jun 2019 06:44:08 -0700 Jacob Pan wrote: > In virtualization use case, when a guest is assigned > a PCI host device, protected by a virtual IOMMU on the guest, > the physical IOMMU must be programmed to be consistent with > the guest mappings. If the physical IOMMU supports two >

Re: How to resolve an issue in swiotlb environment?

2019-06-18 Thread shuah
On 6/14/19 8:44 AM, Alan Stern wrote: On Thu, 13 Jun 2019, shuah wrote: Great! So all we have to do is fix vhci-hcd. Then we can remove all the virt_boundary_mask stuff from usb-storage and uas entirely. (I'm assuming wireless USB isn't a genuine issue. As far as I know, it is pretty much

Re: [PATCH v4 11/22] iommu: Introduce guest PASID bind function

2019-06-18 Thread Jean-Philippe Brucker
On 09/06/2019 14:44, Jacob Pan wrote: > Guest shared virtual address (SVA) may require host to shadow guest > PASID tables. Guest PASID can also be allocated from the host via > enlightened interfaces. In this case, guest needs to bind the guest > mm, i.e. cr3 in guest physical address to the

Re: [PATCH v7 19/21] iommu/mediatek: Rename enable_4GB to dram_is_4gb

2019-06-18 Thread Matthias Brugger
On 10/06/2019 14:17, Yong Wu wrote: > This patch only rename the variable name from enable_4GB to > dram_is_4gb for readable. >From my understanding this is true when available RAM > 4GB so I think the name should be something like dram_bigger_4gb otherwise it may create confusion again.

Re: [PATCH v4 19/22] iommu/vt-d: Clean up for SVM device list

2019-06-18 Thread Jonathan Cameron
On Sun, 9 Jun 2019 06:44:19 -0700 Jacob Pan wrote: > Use combined macro for_each_svm_dev() to simplify SVM device iteration. > > Suggested-by: Andy Shevchenko > Signed-off-by: Jacob Pan > Reviewed-by: Eric Auger > --- > drivers/iommu/intel-svm.c | 79 >

Re: [PATCH v4 12/22] iommu: Add I/O ASID allocator

2019-06-18 Thread Jonathan Cameron
On Sun, 9 Jun 2019 06:44:12 -0700 Jacob Pan wrote: > From: Jean-Philippe Brucker > > Some devices might support multiple DMA address spaces, in particular > those that have the PCI PASID feature. PASID (Process Address Space ID) > allows to share process address spaces with devices (SVA),

Re: [PATCH] iommu: io-pgtable: Support non-coherent page tables

2019-06-18 Thread Will Deacon
Hi Bjorn, On Wed, May 15, 2019 at 04:32:34PM -0700, Bjorn Andersson wrote: > Describe the memory related to page table walks as non-cachable for iommu > instances that are not DMA coherent. > > Signed-off-by: Bjorn Andersson > --- > drivers/iommu/io-pgtable-arm.c | 12 +--- > 1 file

Re: [PATCH v3 1/4] firmware: qcom_scm-64: Add atomic version of qcom_scm_call

2019-06-18 Thread Will Deacon
On Wed, Jun 12, 2019 at 12:45:51PM +0530, Vivek Gautam wrote: > There are scnenarios where drivers are required to make a > scm call in atomic context, such as in one of the qcom's > arm-smmu-500 errata [1]. > > [1] ("https://source.codeaurora.org/quic/la/kernel/msm-4.9/commit/ >

Re: [PATCH v3 3/4] iommu/arm-smmu: Add support to handle Qcom's wait-for-safe logic

2019-06-18 Thread Will Deacon
Hi Vivek, On Fri, Jun 14, 2019 at 02:48:07PM +0530, Vivek Gautam wrote: > On 6/14/2019 9:35 AM, Bjorn Andersson wrote: > > On Wed 12 Jun 00:15 PDT 2019, Vivek Gautam wrote: > > > > > Qcom's implementation of arm,mmu-500 adds a WAIT-FOR-SAFE logic > > > to address under-performance issues in

Re: [PATCH 3/8] iommu/arm-smmu-v3: Support platform SSID

2019-06-18 Thread Will Deacon
On Mon, Jun 10, 2019 at 07:47:09PM +0100, Jean-Philippe Brucker wrote: > For platform devices that support SubstreamID (SSID), firmware provides > the number of supported SSID bits. Restrict it to what the SMMU supports > and cache it into master->ssid_bits. > > Signed-off-by: Jean-Philippe

[PATCH v1 15/22] docs: driver-api: add a chapter for memory-related API

2019-06-18 Thread Mauro Carvalho Chehab
There are some DMA files under the main dir. Move them to the new chapter and add an index file for them. Signed-off-by: Mauro Carvalho Chehab --- Documentation/PCI/pci.rst| 6 +++--- Documentation/block/biodoc.rst | 2 +-

Re: [RFC PATCH v4 03/21] x86/hpet: Calculate ticks-per-second in a separate function

2019-06-18 Thread Thomas Gleixner
On Tue, 18 Jun 2019, Ricardo Neri wrote: > On Fri, Jun 14, 2019 at 05:54:05PM +0200, Thomas Gleixner wrote: > > > > So we already have ticks per second, aka frequency, right? So why do we > > need yet another function instead of using the value which is computed > > once? The frequency of the

Re: [RFC PATCH v4 18/21] x86/apic: Add a parameter for the APIC delivery mode

2019-06-18 Thread Thomas Gleixner
On Tue, 18 Jun 2019, Ricardo Neri wrote: > On Sun, Jun 16, 2019 at 11:55:03AM +0200, Thomas Gleixner wrote: > > On Thu, 23 May 2019, Ricardo Neri wrote: > > > > > > struct irq_cfg { > > > - unsigned intdest_apicid; > > > - unsigned intvector; > > > + unsigned int

Re: [PATCH v8 26/29] vfio-pci: Register an iommu fault handler

2019-06-18 Thread Jacob Pan
On Tue, 18 Jun 2019 15:04:36 +0100 Jean-Philippe Brucker wrote: > On 12/06/2019 19:53, Jacob Pan wrote: > >>> You are right, the worst case of the spurious PS is to terminate > >>> the group prematurely. Need to know the scope of the HW damage in > >>> case of mdev where group IDs can be shared

Re: [PATCH v7 16/21] memory: mtk-smi: Add bus_sel for mt8183

2019-06-18 Thread Matthias Brugger
On 18/06/2019 14:10, Yong Wu wrote: > On Mon, 2019-06-17 at 18:23 +0200, Matthias Brugger wrote: >> >> On 10/06/2019 14:17, Yong Wu wrote: >>> There are 2 mmu cells in a M4U HW. we could adjust some larbs entering >>> mmu0 or mmu1 to balance the bandwidth via the smi-common register >>>

Re: [RFC PATCH v4 18/21] x86/apic: Add a parameter for the APIC delivery mode

2019-06-18 Thread Ricardo Neri
On Sun, Jun 16, 2019 at 11:55:03AM +0200, Thomas Gleixner wrote: > On Thu, 23 May 2019, Ricardo Neri wrote: > > > > struct irq_cfg { > > - unsigned intdest_apicid; > > - unsigned intvector; > > + unsigned intdest_apicid; > > + unsigned

Re: [RFC PATCH v4 04/21] x86/hpet: Add hpet_set_comparator() for periodic and one-shot modes

2019-06-18 Thread Ricardo Neri
On Fri, Jun 14, 2019 at 08:17:14PM +0200, Thomas Gleixner wrote: > On Thu, 23 May 2019, Ricardo Neri wrote: > > +/** > > + * hpet_set_comparator() - Helper function for setting comparator register > > + * @num: The timer ID > > + * @cmp: The value to be written to the comparator/accumulator >

Re: [RFC PATCH v4 05/21] x86/hpet: Reserve timer for the HPET hardlockup detector

2019-06-18 Thread Ricardo Neri
On Fri, Jun 14, 2019 at 06:10:18PM +0200, Thomas Gleixner wrote: > On Thu, 13 Jun 2019, Ricardo Neri wrote: > > > On Tue, Jun 11, 2019 at 09:54:25PM +0200, Thomas Gleixner wrote: > > > On Thu, 23 May 2019, Ricardo Neri wrote: > > > > > > > HPET timer 2 will be used to drive the HPET-based

Re: [RFC PATCH v4 03/21] x86/hpet: Calculate ticks-per-second in a separate function

2019-06-18 Thread Ricardo Neri
On Fri, Jun 14, 2019 at 05:54:05PM +0200, Thomas Gleixner wrote: > On Thu, 23 May 2019, Ricardo Neri wrote: > > > > +u64 hpet_get_ticks_per_sec(u64 hpet_caps) > > +{ > > + u64 ticks_per_sec, period; > > + > > + period = (hpet_caps & HPET_COUNTER_CLK_PERIOD_MASK) >> > > +

Re: [RFC PATCH v4 12/21] watchdog/hardlockup/hpet: Adjust timer expiration on the number of monitored CPUs

2019-06-18 Thread Ricardo Neri
On Tue, Jun 11, 2019 at 10:11:04PM +0200, Thomas Gleixner wrote: > On Thu, 23 May 2019, Ricardo Neri wrote: > > @@ -52,10 +59,10 @@ static void kick_timer(struct hpet_hld_data *hdata, > > bool force) > > return; > > > > if (hdata->has_periodic) > > - period =

Re: [PATCH 1/2] iommu/vt-d: Fix lock inversion between iommu->lock and device_domain_lock

2019-06-18 Thread Chris Wilson
Quoting Lu Baolu (2019-05-21 08:30:15) > From: Dave Jiang > > Lockdep debug reported lock inversion related with the iommu code > caused by dmar_insert_one_dev_info() grabbing the iommu->lock and > the device_domain_lock out of order versus the code path in > iommu_flush_dev_iotlb(). Expanding

Re: [RFC PATCH v4 20/21] iommu/vt-d: hpet: Reserve an interrupt remampping table entry for watchdog

2019-06-18 Thread Ricardo Neri
On Mon, Jun 17, 2019 at 10:25:35AM +0200, Thomas Gleixner wrote: > On Sun, 16 Jun 2019, Thomas Gleixner wrote: > > On Thu, 23 May 2019, Ricardo Neri wrote: > > > When the hardlockup detector is enabled, the function > > > hld_hpet_intremapactivate_irq() activates the recently created entry > > >

Re: [PATCH v7 14/21] iommu/mediatek: Add mmu1 support

2019-06-18 Thread Tomasz Figa via iommu
On Mon, Jun 10, 2019 at 9:21 PM Yong Wu wrote: > > Normally the M4U HW connect EMI with smi. the diagram is like below: > EMI >| > M4U >| > smi-common >| >- >||| |

Re: [PATCH v2 08/12] drm/mediatek: Get rid of mtk_smi_larb_get/put

2019-06-18 Thread CK Hu
Hi, Yong: On Mon, 2019-06-10 at 20:55 +0800, Yong Wu wrote: > MediaTek IOMMU has already added the device_link between the consumer > and smi-larb device. If the drm device call the pm_runtime_get_sync, > the smi-larb's pm_runtime_get_sync also be called automatically. > > CC: CK Hu > CC:

Re: [PATCH 1/2] iommu/vt-d: Fix lock inversion between iommu->lock and device_domain_lock

2019-06-18 Thread Lu Baolu
Hi Chris, On 6/19/19 5:02 AM, Chris Wilson wrote: Quoting Lu Baolu (2019-05-21 08:30:15) From: Dave Jiang Lockdep debug reported lock inversion related with the iommu code caused by dmar_insert_one_dev_info() grabbing the iommu->lock and the device_domain_lock out of order versus the code

Re: [RFC PATCH 2/2] soc: ti: Add Support for the TI Page-based Address Translator (PAT)

2019-06-18 Thread Tero Kristo via iommu
On 07/06/2019 22:35, Andrew F. Davis wrote: This patch adds a driver for the Page-based Address Translator (PAT) present on various TI SoCs. A PAT device performs address translation using tables stored in an internal SRAM. Each PAT supports a set number of pages, each occupying a programmable

Re: [PATCH v7 14/21] iommu/mediatek: Add mmu1 support

2019-06-18 Thread Yong Wu
On Tue, 2019-06-18 at 15:19 +0900, Tomasz Figa wrote: > On Mon, Jun 10, 2019 at 9:21 PM Yong Wu wrote: > > > > Normally the M4U HW connect EMI with smi. the diagram is like below: > > EMI > >| > > M4U > >| > > smi-common > >

Re: [PATCH v7 16/21] memory: mtk-smi: Add bus_sel for mt8183

2019-06-18 Thread Yong Wu
On Mon, 2019-06-17 at 18:23 +0200, Matthias Brugger wrote: > > On 10/06/2019 14:17, Yong Wu wrote: > > There are 2 mmu cells in a M4U HW. we could adjust some larbs entering > > mmu0 or mmu1 to balance the bandwidth via the smi-common register > > SMI_BUS_SEL(0x220)(Each larb occupy 2 bits). > >

Re: [PATCH v2 08/12] drm/mediatek: Get rid of mtk_smi_larb_get/put

2019-06-18 Thread Yong Wu
On Tue, 2019-06-18 at 14:35 +0800, CK Hu wrote: > Hi, Yong: > > On Mon, 2019-06-10 at 20:55 +0800, Yong Wu wrote: > > MediaTek IOMMU has already added the device_link between the consumer > > and smi-larb device. If the drm device call the pm_runtime_get_sync, > > the smi-larb's

Re: [PATCH v7 17/21] memory: mtk-smi: Get rid of need_larbid

2019-06-18 Thread Matthias Brugger
On 10/06/2019 14:17, Yong Wu wrote: > The "mediatek,larb-id" has already been parsed in MTK IOMMU driver. > It's no need to parse it again in SMI driver. Only clean some codes. > This patch is fit for all the current mt2701, mt2712, mt7623, mt8173 > and mt8183. > > After this patch, the