Re: [RFC PATCH] component: Add common helpers for compare/release functions

2022-01-28 Thread Daniel Vetter
On Fri, Jan 28, 2022 at 04:11:01PM +0800, Yong Wu wrote: > The component requires the compare/release functions, there are so many > copy in current kernel. Just define three common helpers for them. > No functional change. > > Signed-off-by: Yong Wu > --- > Base on v5.17-rc1 > --- >

[PATCH v3 10/11] tools/objtool: Check for use of the ENQCMD instruction in the kernel

2022-01-28 Thread Fenghua Yu
The ENQCMD implicitly accesses the PASID_MSR to fill in the pasid field of the descriptor being submitted to an accelerator. But there is no precise (and stable across kernel changes) point at which the PASID_MSR is updated from the value for one task to the next. Kernel code that uses

[PATCH v3 03/11] iommu/ioasid: Introduce a helper to check for valid PASIDs

2022-01-28 Thread Fenghua Yu
pasid_valid() is defined to check if a given PASID is valid. Suggested-by: Ashok Raj Suggested-by: Jacob Pan Signed-off-by: Fenghua Yu Reviewed-by: Tony Luck --- v2: - Define a helper pasid_valid() (Ashok, Jacob, Thomas, Tony) include/linux/ioasid.h | 9 + 1 file changed, 9

[PATCH v3 11/11] docs: x86: Change documentation for SVA (Shared Virtual Addressing)

2022-01-28 Thread Fenghua Yu
Since allocating, freeing and fixing up PASID are changed, the documentation is updated to reflect the changes. Originally-by: Ashok Raj Signed-off-by: Fenghua Yu Reviewed-by: Tony Luck --- v3: - Remove PASID refcount description (Thomas). v2: - Update life cycle info (Tony and Thomas). -

[PATCH v3 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-01-28 Thread Fenghua Yu
To avoid complexity of updating each thread's PASID status (e.g. sending IPI to update IA32_PASID MSR) on allocating and freeing PASID, once allocated and assigned to an mm, the PASID stays with the mm for the rest of the mm's lifetime. A reference to the PASID is taken on allocating the PASID.

[PATCH v3 08/11] x86/traps: Demand-populate PASID MSR via #GP

2022-01-28 Thread Fenghua Yu
All tasks start with PASID state disabled. This means that the first time they execute an ENQCMD instruction they will take a #GP fault. Modify the #GP fault handler to check if the "mm" for the task has already been allocated a PASID. If so, try to fix the #GP fault by loading the IA32_PASID

[PATCH v3 01/11] iommu/sva: Rename CONFIG_IOMMU_SVA_LIB to CONFIG_IOMMU_SVA

2022-01-28 Thread Fenghua Yu
This CONFIG option originally only referred to the Shared Virtual Address (SVA) library. But it is now also used for non-library portions of code. Drop the "_LIB" suffix so that there is just one configuration options for all code relating to SVA. Signed-off-by: Fenghua Yu Reviewed-by: Tony

[PATCH v3 07/11] sched: Define and initialize a flag to identify valid PASID in the task

2022-01-28 Thread Fenghua Yu
From: Peter Zijlstra Add a new single bit field to the task structure to track whether this task has initialized the IA32_PASID MSR to the mm's PASID. Initialize the field to zero when creating a new task with fork/clone. Signed-off-by: Peter Zijlstra Co-developed-by: Fenghua Yu

[PATCH v3 09/11] x86/cpufeatures: Re-enable ENQCMD

2022-01-28 Thread Fenghua Yu
Since ENQCMD is handled by #GP fix up, it can be re-enabled. The ENQCMD feature can only be used if CONFIG_INTEL_IOMMU_SVM is set. Add X86_FEATURE_ENQCMD to the disabled features mask as appropriate so that cpu_feature_enabled() can be used to check the feature. Signed-off-by: Fenghua Yu

[PATCH v3 04/11] kernel/fork: Initialize mm's PASID

2022-01-28 Thread Fenghua Yu
A new mm doesn't have a PASID yet when it's created. Initialize the mm's PASID on fork() or for init_mm to INVALID_IOASID (-1). Suggested-by: Dave Hansen Signed-off-by: Fenghua Yu Reviewed-by: Tony Luck --- v2: - Change condition to more accurate CONFIG_IOMMU_SVA (Jacob)

[PATCH v3 06/11] x86/fpu: Clear PASID when copying fpstate

2022-01-28 Thread Fenghua Yu
The kernel must allocate a Process Address Space ID (PASID) on behalf of each process which will use ENQCMD and program it into the new MSR to communicate the process identity to platform hardware. ENQCMD uses the PASID stored in this MSR to tag requests from this process. The PASID state must be

[PATCH v3 00/11] Re-enable ENQCMD and PASID MSR

2022-01-28 Thread Fenghua Yu
Problems in the old code to manage SVM (Shared Virtual Memory) devices and the PASID (Process Address Space ID) led to that code being disabled. Subsequent discussions resulted in a far simpler approach: 1) PASID life cycle is from first allocation by a process until that process exits. 2)

[PATCH v3 02/11] mm: Change CONFIG option for mm->pasid field

2022-01-28 Thread Fenghua Yu
This currently depends on CONFIG_IOMMU_SUPPORT. But it is only needed when CONFIG_IOMMU_SVA option is enabled. Change the CONFIG guards around definition and initialization of mm->pasid field. Suggested-by: Jacob Pan Signed-off-by: Fenghua Yu Reviewed-by: Tony Luck --- v2: - Change condition

RE: [PATCH 2/2] x86/hyperv: Set swiotlb_alloc_from_low_pages to false

2022-01-28 Thread Michael Kelley (LINUX) via iommu
From: Tianyu Lan Sent: Wednesday, January 26, 2022 8:11 AM > > In Hyper-V Isolation VM, swiotlb bnounce buffer size maybe 1G at most > and there maybe no enough memory from 0 to 4G according to memory layout. > Devices in Isolation VM can use memory above 4G as DMA memory. Set swiotlb_ >

RE: [PATCH 1/2] Swiotlb: Add swiotlb_alloc_from_low_pages switch

2022-01-28 Thread Michael Kelley (LINUX) via iommu
From: Tianyu Lan Sent: Wednesday, January 26, 2022 8:11 AM > > Hyper-V Isolation VM and AMD SEV VM uses swiotlb bounce buffer to > share memory with hypervisor. Current swiotlb bounce buffer is only > allocated from 0 to ARCH_LOW_ADDRESS_LIMIT which is default to > 0xUL. Isolation VM and

Re: [PATCH v5 02/24] mm: remove extra ZONE_DEVICE struct page refcount

2022-01-28 Thread Ralph Campbell via iommu
On 1/28/22 06:21, Jason Gunthorpe wrote: On Thu, Jan 27, 2022 at 05:25:52PM -0700, Logan Gunthorpe wrote: From: Ralph Campbell ZONE_DEVICE struct pages have an extra reference count that complicates the code for put_page() and several places in the kernel that need to check the reference

Re: [PATCH] iommu/iova: Separate out rcache init

2022-01-28 Thread Robin Murphy
On 2022-01-28 11:32, John Garry wrote: On 26/01/2022 17:00, Robin Murphy wrote: As above, I vote for just forward-declaring the free routine in iova.c and keeping it entirely private. BTW, speaking of forward declarations, it's possible to remove all the forward declarations in iova.c now

Re: [PATCH v5 22/24] mm: use custom page_free for P2PDMA pages

2022-01-28 Thread Logan Gunthorpe
On 2022-01-28 7:22 a.m., Jason Gunthorpe wrote: > On Thu, Jan 27, 2022 at 05:26:12PM -0700, Logan Gunthorpe wrote: >> When P2PDMA pages are passed to userspace, they will need to be >> reference counted properly and returned to their genalloc after their >> reference count returns to 1. This is

Re: [PATCH v5 02/24] mm: remove extra ZONE_DEVICE struct page refcount

2022-01-28 Thread Logan Gunthorpe
On 2022-01-28 7:21 a.m., Jason Gunthorpe wrote: > On Thu, Jan 27, 2022 at 05:25:52PM -0700, Logan Gunthorpe wrote: >> From: Ralph Campbell >> >> ZONE_DEVICE struct pages have an extra reference count that complicates the >> code for put_page() and several places in the kernel that need to

Re: [PATCH] iommu: Fix some W=1 warnings

2022-01-28 Thread Robin Murphy
On 2022-01-28 10:44, John Garry wrote: The code is mostly free of W=1 warning, so fix the following: drivers/iommu/iommu.c:996: warning: expecting prototype for iommu_group_for_each_dev(). Prototype was for __iommu_group_for_each_dev() instead drivers/iommu/iommu.c:3048: warning: Function

Re: [PATCH v2 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-01-28 Thread Thomas Gleixner
On Thu, Jan 27 2022 at 18:42, Fenghua Yu wrote: > On Wed, Jan 26, 2022 at 10:38:04PM +0100, Thomas Gleixner wrote: >> Against Linus tree please so that the bugfix applies. >> >> > I will fold the following patch into patch #5. The patch #11 (the doc >> > patch) >> > also needs to remove one

Re: [PATCH v5 22/24] mm: use custom page_free for P2PDMA pages

2022-01-28 Thread Jason Gunthorpe
On Thu, Jan 27, 2022 at 05:26:12PM -0700, Logan Gunthorpe wrote: > When P2PDMA pages are passed to userspace, they will need to be > reference counted properly and returned to their genalloc after their > reference count returns to 1. This is accomplished with the existing It is reference count

Re: [PATCH v5 02/24] mm: remove extra ZONE_DEVICE struct page refcount

2022-01-28 Thread Jason Gunthorpe
On Thu, Jan 27, 2022 at 05:25:52PM -0700, Logan Gunthorpe wrote: > From: Ralph Campbell > > ZONE_DEVICE struct pages have an extra reference count that complicates the > code for put_page() and several places in the kernel that need to check the > reference count to see that a page is not being

Re: [RFC PATCH] component: Add common helpers for compare/release functions

2022-01-28 Thread Robin Murphy
On 2022-01-28 08:11, Yong Wu wrote: [...] diff --git a/include/linux/component.h b/include/linux/component.h index 16de18f473d7..5a7468ea827c 100644 --- a/include/linux/component.h +++ b/include/linux/component.h @@ -2,6 +2,8 @@ #ifndef COMPONENT_H #define COMPONENT_H +#include

Re: [PATCH v10 02/13] iommu/mediatek-v1: Free the existed fwspec if the master dev already has

2022-01-28 Thread Mauro Carvalho Chehab
Hi Matthias/Yong, Are you ok if this patch gets merged via the media tree together with the remaining series, or do you prefer to apply it via SoC tree instead? Regards, Mauro Em Mon, 17 Jan 2022 15:04:59 +0800 Yong Wu escreveu: > When the iommu master device enters of_iommu_xlate, the ops

Re: [PATCH v10 02/13] iommu/mediatek-v1: Free the existed fwspec if the master dev already has

2022-01-28 Thread Mauro Carvalho Chehab
Em Fri, 28 Jan 2022 13:40:55 +0100 Mauro Carvalho Chehab escreveu: > Hi Matthias/Yong, > > Are you ok if this patch gets merged via the media tree together with the > remaining series, or do you prefer to apply it via SoC tree instead? Same questions for other patches touching files outside

Re: [PATCH] iommu/iova: Separate out rcache init

2022-01-28 Thread John Garry via iommu
On 26/01/2022 17:00, Robin Murphy wrote: As above, I vote for just forward-declaring the free routine in iova.c and keeping it entirely private. BTW, speaking of forward declarations, it's possible to remove all the forward declarations in iova.c now that the FQ code is gone - but with a

[PATCH] iommu: Fix some W=1 warnings

2022-01-28 Thread John Garry via iommu
The code is mostly free of W=1 warning, so fix the following: drivers/iommu/iommu.c:996: warning: expecting prototype for iommu_group_for_each_dev(). Prototype was for __iommu_group_for_each_dev() instead drivers/iommu/iommu.c:3048: warning: Function parameter or member 'drvdata' not described

Re: [PATCH 2/2] iommu/mediatek: Add mt8186 iommu support

2022-01-28 Thread Yong Wu
On Thu, 2022-01-27 at 12:28 +0100, AngeloGioacchino Del Regno wrote: > Il 25/01/22 10:32, Yong Wu ha scritto: > > Add mt8186 iommu supports. > > > > Signed-off-by: Anan Sun > > Signed-off-by: Yong Wu > > --- > > drivers/iommu/mtk_iommu.c | 17 + > > 1 file changed, 17

Re: [PATCH v5 01/24] ext4/xfs: add page refcount helper

2022-01-28 Thread Chaitanya Kulkarni via iommu
On 1/27/22 4:25 PM, Logan Gunthorpe wrote: > External email: Use caution opening links or attachments > > > From: Ralph Campbell > > There are several places where ZONE_DEVICE struct pages assume a reference > count == 1 means the page is idle and free. Instead of open coding this, > add a

Re: [PATCH v5 12/24] nvme-pci: convert to using dma_map_sgtable()

2022-01-28 Thread Chaitanya Kulkarni via iommu
On 1/27/22 4:26 PM, Logan Gunthorpe wrote: > External email: Use caution opening links or attachments > > > The dma_map operations now support P2PDMA pages directly. So remove > the calls to pci_p2pdma_[un]map_sg_attrs() and replace them with calls > to dma_map_sgtable(). > > dma_map_sgtable()

[RFC PATCH] component: Add common helpers for compare/release functions

2022-01-28 Thread Yong Wu
The component requires the compare/release functions, there are so many copy in current kernel. Just define three common helpers for them. No functional change. Signed-off-by: Yong Wu --- Base on v5.17-rc1 --- .../gpu/drm/arm/display/komeda/komeda_drv.c| 5 -