[PATCH v3 RESEND 35/35] iommu/amd: Update amd_iommu_fault structure to include PCI seg ID

2022-07-06 Thread Vasant Hegde via iommu
Rename 'device_id' as 'sbdf' and extend it to 32bit so that we can pass PCI segment ID to ppr_notifier(). Also pass PCI segment ID to pci_get_domain_bus_and_slot() instead of default value. Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 2 +- drivers/iommu/amd/iommu.c

[PATCH v3 RESEND 34/35] iommu/amd: Update device_state structure to include PCI seg ID

2022-07-06 Thread Vasant Hegde via iommu
Rename struct device_state.devid variable to struct device_state.sbdf and extend it to 32-bit to include the 16-bit PCI segment ID via the helper function get_pci_sbdf_id(). Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iomm

[PATCH v3 RESEND 33/35] iommu/amd: Print PCI segment ID in error log messages

2022-07-06 Thread Vasant Hegde via iommu
Print pci segment ID along with bdf. Useful for debugging. Co-developed-by: Suravee Suthikulpaint Signed-off-by: Suravee Suthikulpaint Signed-off-by: Vasant Hegde --- drivers/iommu/amd/init.c | 10 +- drivers/iommu/amd/iommu.c | 36 ++-- 2 files changed

[PATCH v3 RESEND 32/35] iommu/amd: Add PCI segment support for ivrs_[ioapic/hpet/acpihid] commands

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit By default, PCI segment is zero and can be omitted. To support system with non-zero PCI segment ID, modify the parsing functions to allow PCI segment ID. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- .../admin-g

[PATCH v3 RESEND 31/35] iommu/amd: Specify PCI segment ID when getting pci device

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Upcoming AMD systems can have multiple PCI segments. Hence pass PCI segment ID to pci_get_domain_bus_and_slot() instead of '0'. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/init.c | 6 --

[PATCH v3 RESEND 30/35] iommu/amd: Include PCI segment ID when initialize IOMMU

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Extend current device ID variables to 32-bit to include the 16-bit segment ID when parsing device information from IVRS table to initialize each IOMMU. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu

[PATCH v3 RESEND 29/35] iommu/amd: Introduce get_device_sbdf_id() helper function

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Current get_device_id() only provide 16-bit PCI device ID (i.e. BDF). With multiple PCI segment support, we need to extend the helper function to include PCI segment ID. So, introduce a new helper function get_device_sbdf_id() to replace the current get_pci_device_id(

[PATCH v3 RESEND 28/35] iommu/amd: Flush upto last_bdf only

2022-07-06 Thread Vasant Hegde via iommu
Fix amd_iommu_flush_dte_all() and amd_iommu_flush_tlb_all() to flush upto last_bdf only. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --

[PATCH v3 RESEND 27/35] iommu/amd: Remove global amd_iommu_[dev_table/alias_table/last_bdf]

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Replace them with per PCI segment device table. Also remove dev_table_size, alias_table_size, amd_iommu_last_bdf variables. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/amd_iommu_types.h | 15

[PATCH v3 RESEND 26/35] iommu/amd: Update set_dev_entry_bit() and get_dev_entry_bit()

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit To include a pointer to per PCI segment device table. Also include struct amd_iommu as one of the function parameter to amd_iommu_apply_erratum_63() since it is needed when setting up DTE. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Sur

[PATCH v3 RESEND 25/35] iommu/amd: Update (un)init_device_table_dma()

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Include struct amd_iommu_pci_seg as a function parameter since we need to access per PCI segment device table. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/init.c | 27

[PATCH v3 RESEND 24/35] iommu/amd: Update set_dte_irq_entry

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Start using per PCI segment device table instead of global device table. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/a

[PATCH v3 RESEND 23/35] iommu/amd: Update dump_dte_entry

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Start using per PCI segment device table instead of global device table. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/amd/iom

[PATCH v3 RESEND 22/35] iommu/amd: Update iommu_ignore_device

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Start using per PCI segment device table instead of global device table. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/amd/iommu

[PATCH v3 RESEND 21/35] iommu/amd: Update set_dte_entry and clear_dte_entry

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Start using per PCI segment data structures instead of global data structures. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 19 +++ 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/dr

[PATCH v3 RESEND 20/35] iommu/amd: Convert to use per PCI segment rlookup_table

2022-07-06 Thread Vasant Hegde via iommu
Then, remove the global amd_iommu_rlookup_table and rlookup_table_size. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 5 - drivers/iommu/amd/init.c| 23 ++-

[PATCH v3 RESEND 19/35] iommu/amd: Update alloc_irq_table and alloc_irq_index

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Pass amd_iommu structure as one of the parameter to these functions as its needed to retrieve variable tables inside these functions. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/iommu.c | 26

[PATCH v3 RESEND 18/35] iommu/amd: Update amd_irte_ops functions

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Pass amd_iommu structure as one of the parameter to amd_irte_ops functions since its needed to activate/deactivate the iommu. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 6 ++-- drivers/iommu/amd/iommu

[PATCH v3 RESEND 17/35] iommu/amd: Introduce struct amd_ir_data.iommu

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Add a pointer to struct amd_iommu to amd_ir_data structure, which can be used to correlate interrupt remapping data to a per-PCI-segment interrupt remapping table. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- d

[PATCH v3 RESEND 16/35] iommu/amd: Update irq_remapping_alloc to use IOMMU lookup helper function

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit To allow IOMMU rlookup using both PCI segment and device ID. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/iommu.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff -

[PATCH v3 RESEND 15/35] iommu/amd: Convert to use rlookup_amd_iommu helper function

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Use rlookup_amd_iommu() helper function which will give per PCI segment rlookup_table. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 64 +++ 1 file changed, 38 insertions(+), 26

[PATCH v3 RESEND 14/35] iommu/amd: Convert to use per PCI segment irq_lookup_table

2022-07-06 Thread Vasant Hegde via iommu
Then, remove the global irq_lookup_table. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 2 -- drivers/iommu/amd/init.c| 19 --- drivers/iommu/amd/iommu.c | 36

[PATCH v3 RESEND 13/35] iommu/amd: Introduce per PCI segment rlookup table size

2022-07-06 Thread Vasant Hegde via iommu
It will replace global "rlookup_table_size" variable. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 3 +++ drivers/iommu/amd/init.c| 11 ++- 2 files changed, 9 insertions(+)

[PATCH v3 RESEND 12/35] iommu/amd: Introduce per PCI segment alias table size

2022-07-06 Thread Vasant Hegde via iommu
It will replace global "alias_table_size" variable. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 3 +++ drivers/iommu/amd/init.c| 5 +++-- 2 files changed, 6 insertions(+), 2 deleti

[PATCH v3 RESEND 11/35] iommu/amd: Introduce per PCI segment device table size

2022-07-06 Thread Vasant Hegde via iommu
With multiple pci segment support, number of BDF supported by each segment may differ. Hence introduce per segment device table size which depends on last_bdf. This will replace global "device_table_size" variable. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signe

[PATCH v3 RESEND 10/35] iommu/amd: Introduce per PCI segment last_bdf

2022-07-06 Thread Vasant Hegde via iommu
Current code uses global "amd_iommu_last_bdf" to track the last bdf supported by the system. This value is used for various memory allocation, device data flushing, etc. Introduce per PCI segment last_bdf which will be used to track last bdf supported by the given PCI segment and use this value fo

[PATCH v3 RESEND 09/35] iommu/amd: Introduce per PCI segment unity map list

2022-07-06 Thread Vasant Hegde via iommu
Newer AMD systems can support multiple PCI segments. In order to support multiple PCI segments IVMD table in IVRS structure is enhanced to include pci segment id. Update ivmd_header structure to include "pci_seg". Also introduce per PCI segment unity map list. It will replace global amd_iommu_unit

[PATCH v3 RESEND 08/35] iommu/amd: Introduce per PCI segment alias_table

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit This will replace global alias table (amd_iommu_alias_table). Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/amd_iommu_types.h | 7 + drivers/iommu/amd/init.c| 41 ++

[PATCH v3 RESEND 07/35] iommu/amd: Introduce per PCI segment old_dev_tbl_cpy

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit It will remove global old_dev_tbl_cpy. Also update copy_device_table() copy device table for all PCI segments. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/amd_iommu_types.h | 6 ++ drivers/

[PATCH v3 RESEND 06/35] iommu/amd: Introduce per PCI segment dev_data_list

2022-07-06 Thread Vasant Hegde via iommu
This will replace global dev_data_list. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 3 +++ drivers/iommu/amd/init.c| 1 + drivers/iommu/amd/iommu.c | 21 ++-

[PATCH v3 RESEND 05/35] iommu/amd: Introduce per PCI segment irq_lookup_table

2022-07-06 Thread Vasant Hegde via iommu
This will replace global irq lookup table (irq_lookup_table). Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 6 ++ drivers/iommu/amd/init.c| 27 +++ 2 fil

[PATCH v3 RESEND 04/35] iommu/amd: Introduce per PCI segment rlookup table

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit This will replace global rlookup table (amd_iommu_rlookup_table). Add helper functions to set/get rlookup table for the given device. Also add macros to get seg/devid from sbdf. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthiku

[PATCH v3 RESEND 03/35] iommu/amd: Introduce per PCI segment device table

2022-07-06 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Introduce per PCI segment device table. All IOMMUs within the segment will share this device table. This will replace global device table i.e. amd_iommu_dev_table. Also introduce helper function to get the device table for the given IOMMU. Co-developed-by: Vasant Heg

[PATCH v3 RESEND 02/35] iommu/amd: Introduce pci segment structure

2022-07-06 Thread Vasant Hegde via iommu
Newer AMD systems can support multiple PCI segments, where each segment contains one or more IOMMU instances. However, an IOMMU instance can only support a single PCI segment. Current code assumes that system contains only one pci segment (segment 0) and creates global data structures such as devi

[PATCH v3 RESEND 01/35] iommu/amd: Update struct iommu_dev_data definition

2022-07-06 Thread Vasant Hegde via iommu
struct iommu_dev_data contains member "pdev" to point to pci_dev. This is valid for only PCI devices and for other devices this will be NULL. This causes unnecessary "pdev != NULL" check at various places. Replace "struct pci_dev" member with "struct device" and use to_pci_dev() to get pci device

[PATCH v3 RESEND 00/35] iommu/amd: Add multiple PCI segments support

2022-07-06 Thread Vasant Hegde via iommu
Hi Joerg, As discussed in other thread, I have updated "From:" tag and resending patchset. No changes in the actual patch content. This patchset is based on top on "iommu/x86/amd" branch. Base commit : 0d10fe75911787 ("iommu/amd: Use try_cmpxchg64 in ") Newer AMD systems can suppor

Re: [PATCH v1 0/7] iommu/amd: Add Generic IO Page Table Framework Support for v2 Page Table

2022-06-28 Thread Vasant Hegde via iommu
Hi Joerg, On 6/23/2022 1:45 PM, Joerg Roedel wrote: > On Fri, Jun 03, 2022 at 04:51:00PM +0530, Vasant Hegde wrote: >> - Part 1 (patch 1-4 and 6) >> Refactor the current IOMMU page table code to adopt the generic IO page >> table framework, and add AMD IOMMU Guest (v2) page table management co

Re: [PATCH v1 7/7] iommu/amd: Introduce amd_iommu_pgtable command-line option

2022-06-28 Thread Vasant Hegde via iommu
Hi Joerg, On 6/23/2022 1:42 PM, Joerg Roedel wrote: > On Fri, Jun 03, 2022 at 04:51:07PM +0530, Vasant Hegde wrote: >> +amd_iommu_pgtable= [HW,X86-64] >> +Specifies one of the following AMD IOMMU page table to >> +be used for DMA remapping for DMA-API:

Re: [PATCH v3 00/35] iommu/amd: Add multiple PCI segments support

2022-06-28 Thread Vasant Hegde via iommu
Hi Joerg, On 6/23/2022 1:24 PM, Joerg Roedel wrote: > Hi Vasant, > > On Wed, May 11, 2022 at 12:51:06PM +0530, Vasant Hegde wrote: >> .../admin-guide/kernel-parameters.txt | 34 +- >> drivers/iommu/amd/amd_iommu.h | 13 +- >> drivers/iommu/amd/amd_iommu_types.h

Re: [PATCH v1 3/7] iommu/amd: Fix sparse warning

2022-06-27 Thread Vasant Hegde via iommu
On 6/23/2022 3:12 PM, Robin Murphy wrote: > On 2022-06-23 09:03, Joerg Roedel wrote: >> On Fri, Jun 03, 2022 at 04:51:03PM +0530, Vasant Hegde wrote: >>> Fix below sparse warning: >>>    CHECK   drivers/iommu/amd/iommu.c >>>    drivers/iommu/amd/iommu.c:73:24: warning: symbol 'amd_iommu_ops' was

Re: [PATCH v3 00/35] iommu/amd: Add multiple PCI segments support

2022-06-22 Thread Vasant Hegde via iommu
Hi Joerg, On 6/7/2022 4:17 PM, Vasant Hegde wrote: > Hello Joerg, > > > On 5/20/2022 5:42 PM, Vasant Hegde wrote: >> Joerg, >> >> >> On 5/20/2022 3:33 PM, Joerg Roedel wrote: >>> Hi Vasant, >>> >>> On Fri, May 20, 2022 at 03:25:38PM +0530, Vasant Hegde wrote: Ping. Did you get a chance to l

Re: [PATCH v3 00/35] iommu/amd: Add multiple PCI segments support

2022-06-07 Thread Vasant Hegde via iommu
Hello Joerg, On 5/20/2022 5:42 PM, Vasant Hegde wrote: > Joerg, > > > On 5/20/2022 3:33 PM, Joerg Roedel wrote: >> Hi Vasant, >> >> On Fri, May 20, 2022 at 03:25:38PM +0530, Vasant Hegde wrote: >>> Ping. Did you get a chance to look into this series? >> >> Sorry, too late for this round. The ch

[PATCH v1 7/7] iommu/amd: Introduce amd_iommu_pgtable command-line option

2022-06-03 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit To allow specification whether to use v1 or v2 IOMMU pagetable for DMA remapping when calling kernel DMA-API. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- Documentation/admin-guide/kernel-parameters.txt | 6 ++

[PATCH v1 6/7] iommu/amd: Add support for using AMD IOMMU v2 page table for DMA-API

2022-06-03 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Introduce init function for setting up DMA domain for DMA-API with the IOMMU v2 page table. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 21 + 1 file changed, 21 insertions(+) diff --git a/dri

[PATCH v1 5/7] iommu/amd: Add support for Guest IO protection

2022-06-03 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit AMD IOMMU introduces support for Guest I/O protection where the request from the I/O device without a PASID are treated as if they have PASID 0. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/am

[PATCH v1 4/7] iommu/amd: Initial support for AMD IOMMU v2 page table

2022-06-03 Thread Vasant Hegde via iommu
Introduce IO page table framework support for AMD IOMMU v2 page table. This patch implements 4 level page table within iommu amd driver and supports 4K/2M/1G page sizes. Signed-off-by: Vasant Hegde --- drivers/iommu/amd/Makefile | 2 +- drivers/iommu/amd/amd_iommu_types.h | 5 +- dr

[PATCH v1 3/7] iommu/amd: Fix sparse warning

2022-06-03 Thread Vasant Hegde via iommu
Fix below sparse warning: CHECK drivers/iommu/amd/iommu.c drivers/iommu/amd/iommu.c:73:24: warning: symbol 'amd_iommu_ops' was not declared. Should it be static? Also we are going to introduce v2 page table which has different pgsize_bitmaps. Hence remove 'const' qualifier. Signed-off-by:

[PATCH v1 2/7] iommu/amd: Update sanity check when enable PRI/ATS

2022-06-03 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Currently, PPR/ATS can be enabled only if the domain is type identity mapping. However, when we allow the IOMMU v2 page table to be used for DMA-API, the sanity check needs to be updated to only apply for the case when using AMD_IOMMU_V1 page table mode. Signed-off-by

[PATCH v1 1/7] iommu/amd: Refactor amd_iommu_domain_enable_v2

2022-06-03 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit The current function to enable IOMMU v2 also lock the domain. In order to reuse the same code in different code path, in which the domain has already been locked, refactor the function to separate the locking from the enabling logic. Co-developed-by: Vasant Hegde Sig

[PATCH v1 0/7] iommu/amd: Add Generic IO Page Table Framework Support for v2 Page Table

2022-06-03 Thread Vasant Hegde via iommu
This series introduces a new usage model for the v2 page table, where it can be used to implement support for DMA-API by adopting the generic IO page table framework. One of the target usecases is to support nested IO page tables where the guest uses the guest IO page table (v2) for translating GV

Re: [PATCH v3 00/35] iommu/amd: Add multiple PCI segments support

2022-05-20 Thread Vasant Hegde via iommu
Joerg, On 5/20/2022 3:33 PM, Joerg Roedel wrote: > Hi Vasant, > > On Fri, May 20, 2022 at 03:25:38PM +0530, Vasant Hegde wrote: >> Ping. Did you get a chance to look into this series? > > Sorry, too late for this round. The changes are pretty invasive and > merging them at -rc7 stage would not

Re: [PATCH v3 00/35] iommu/amd: Add multiple PCI segments support

2022-05-20 Thread Vasant Hegde via iommu
Hello Joerg, On 5/11/2022 12:51 PM, Vasant Hegde wrote: > Newer AMD systems can support multiple PCI segments, where each segment > contains one or more IOMMU instances. However, an IOMMU instance can only > support a single PCI segment. Ping. Did you get a chance to look into this series? -V

[PATCH v3 35/35] iommu/amd: Update amd_iommu_fault structure to include PCI seg ID

2022-05-11 Thread Vasant Hegde via iommu
Rename 'device_id' as 'sbdf' and extend it to 32bit so that we can pass PCI segment ID to ppr_notifier(). Also pass PCI segment ID to pci_get_domain_bus_and_slot() instead of default value. Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 2 +- drivers/iommu/amd/iommu.c

[PATCH v3 34/35] iommu/amd: Update device_state structure to include PCI seg ID

2022-05-11 Thread Vasant Hegde via iommu
Rename struct device_state.devid variable to struct device_state.sbdf and extend it to 32-bit to include the 16-bit PCI segment ID via the helper function get_pci_sbdf_id(). Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iomm

[PATCH v3 33/35] iommu/amd: Print PCI segment ID in error log messages

2022-05-11 Thread Vasant Hegde via iommu
Print pci segment ID along with bdf. Useful for debugging. Co-developed-by: Suravee Suthikulpaint Signed-off-by: Suravee Suthikulpaint Signed-off-by: Vasant Hegde --- drivers/iommu/amd/init.c | 10 +- drivers/iommu/amd/iommu.c | 36 ++-- 2 files changed

[PATCH v3 32/35] iommu/amd: Add PCI segment support for ivrs_[ioapic/hpet/acpihid] commands

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit By default, PCI segment is zero and can be omitted. To support system with non-zero PCI segment ID, modify the parsing functions to allow PCI segment ID. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- .../admin-g

[PATCH v3 31/35] iommu/amd: Specify PCI segment ID when getting pci device

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Upcoming AMD systems can have multiple PCI segments. Hence pass PCI segment ID to pci_get_domain_bus_and_slot() instead of '0'. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/init.c | 6 --

[PATCH v3 30/35] iommu/amd: Include PCI segment ID when initialize IOMMU

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Extend current device ID variables to 32-bit to include the 16-bit segment ID when parsing device information from IVRS table to initialize each IOMMU. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu

[PATCH v3 29/35] iommu/amd: Introduce get_device_sbdf_id() helper function

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Current get_device_id() only provide 16-bit PCI device ID (i.e. BDF). With multiple PCI segment support, we need to extend the helper function to include PCI segment ID. So, introduce a new helper function get_device_sbdf_id() to replace the current get_pci_device_id(

[PATCH v3 28/35] iommu/amd: Flush upto last_bdf only

2022-05-11 Thread Vasant Hegde via iommu
Fix amd_iommu_flush_dte_all() and amd_iommu_flush_tlb_all() to flush upto last_bdf only. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --

[PATCH v3 27/35] iommu/amd: Remove global amd_iommu_[dev_table/alias_table/last_bdf]

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Replace them with per PCI segment device table. Also remove dev_table_size, alias_table_size, amd_iommu_last_bdf variables. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/amd_iommu_types.h | 15

[PATCH v3 26/35] iommu/amd: Update set_dev_entry_bit() and get_dev_entry_bit()

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit To include a pointer to per PCI segment device table. Also include struct amd_iommu as one of the function parameter to amd_iommu_apply_erratum_63() since it is needed when setting up DTE. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Sur

[PATCH v3 25/35] iommu/amd: Update (un)init_device_table_dma()

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Include struct amd_iommu_pci_seg as a function parameter since we need to access per PCI segment device table. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/init.c | 27

[PATCH v3 24/35] iommu/amd: Update set_dte_irq_entry

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Start using per PCI segment device table instead of global device table. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/a

[PATCH v3 23/35] iommu/amd: Update dump_dte_entry

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Start using per PCI segment device table instead of global device table. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/amd/iom

[PATCH v3 22/35] iommu/amd: Update iommu_ignore_device

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Start using per PCI segment device table instead of global device table. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/amd/iommu

[PATCH v3 21/35] iommu/amd: Update set_dte_entry and clear_dte_entry

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Start using per PCI segment data structures instead of global data structures. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 19 +++ 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/dr

[PATCH v3 20/35] iommu/amd: Convert to use per PCI segment rlookup_table

2022-05-11 Thread Vasant Hegde via iommu
Then, remove the global amd_iommu_rlookup_table and rlookup_table_size. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 5 - drivers/iommu/amd/init.c| 23 ++-

[PATCH v3 19/35] iommu/amd: Update alloc_irq_table and alloc_irq_index

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Pass amd_iommu structure as one of the parameter to these functions as its needed to retrieve variable tables inside these functions. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/iommu.c | 26

[PATCH v3 18/35] iommu/amd: Update amd_irte_ops functions

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Pass amd_iommu structure as one of the parameter to amd_irte_ops functions since its needed to activate/deactivate the iommu. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 6 ++-- drivers/iommu/amd/iommu

[PATCH v3 17/35] iommu/amd: Introduce struct amd_ir_data.iommu

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Add a pointer to struct amd_iommu to amd_ir_data structure, which can be used to correlate interrupt remapping data to a per-PCI-segment interrupt remapping table. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- d

[PATCH v3 16/35] iommu/amd: Update irq_remapping_alloc to use IOMMU lookup helper function

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit To allow IOMMU rlookup using both PCI segment and device ID. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/iommu.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff -

[PATCH v3 15/35] iommu/amd: Convert to use rlookup_amd_iommu helper function

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Use rlookup_amd_iommu() helper function which will give per PCI segment rlookup_table. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 64 +++ 1 file changed, 38 insertions(+), 26

[PATCH v3 14/35] iommu/amd: Convert to use per PCI segment irq_lookup_table

2022-05-11 Thread Vasant Hegde via iommu
Then, remove the global irq_lookup_table. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 2 -- drivers/iommu/amd/init.c| 19 --- drivers/iommu/amd/iommu.c | 36

[PATCH v3 13/35] iommu/amd: Introduce per PCI segment rlookup table size

2022-05-11 Thread Vasant Hegde via iommu
It will replace global "rlookup_table_size" variable. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 3 +++ drivers/iommu/amd/init.c| 11 ++- 2 files changed, 9 insertions(+)

[PATCH v3 12/35] iommu/amd: Introduce per PCI segment alias table size

2022-05-11 Thread Vasant Hegde via iommu
It will replace global "alias_table_size" variable. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 3 +++ drivers/iommu/amd/init.c| 5 +++-- 2 files changed, 6 insertions(+), 2 deleti

[PATCH v3 11/35] iommu/amd: Introduce per PCI segment device table size

2022-05-11 Thread Vasant Hegde via iommu
With multiple pci segment support, number of BDF supported by each segment may differ. Hence introduce per segment device table size which depends on last_bdf. This will replace global "device_table_size" variable. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signe

[PATCH v3 10/35] iommu/amd: Introduce per PCI segment last_bdf

2022-05-11 Thread Vasant Hegde via iommu
Current code uses global "amd_iommu_last_bdf" to track the last bdf supported by the system. This value is used for various memory allocation, device data flushing, etc. Introduce per PCI segment last_bdf which will be used to track last bdf supported by the given PCI segment and use this value fo

[PATCH v3 09/35] iommu/amd: Introduce per PCI segment unity map list

2022-05-11 Thread Vasant Hegde via iommu
Newer AMD systems can support multiple PCI segments. In order to support multiple PCI segments IVMD table in IVRS structure is enhanced to include pci segment id. Update ivmd_header structure to include "pci_seg". Also introduce per PCI segment unity map list. It will replace global amd_iommu_unit

[PATCH v3 08/35] iommu/amd: Introduce per PCI segment alias_table

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit This will replace global alias table (amd_iommu_alias_table). Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/amd_iommu_types.h | 7 + drivers/iommu/amd/init.c| 41 ++

[PATCH v3 07/35] iommu/amd: Introduce per PCI segment old_dev_tbl_cpy

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit It will remove global old_dev_tbl_cpy. Also update copy_device_table() copy device table for all PCI segments. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/amd_iommu_types.h | 6 ++ drivers/

[PATCH v3 06/35] iommu/amd: Introduce per PCI segment dev_data_list

2022-05-11 Thread Vasant Hegde via iommu
This will replace global dev_data_list. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 3 +++ drivers/iommu/amd/init.c| 1 + drivers/iommu/amd/iommu.c | 21 ++-

[PATCH v3 05/35] iommu/amd: Introduce per PCI segment irq_lookup_table

2022-05-11 Thread Vasant Hegde via iommu
This will replace global irq lookup table (irq_lookup_table). Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 6 ++ drivers/iommu/amd/init.c| 27 +++ 2 fil

[PATCH v3 04/35] iommu/amd: Introduce per PCI segment rlookup table

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit This will replace global rlookup table (amd_iommu_rlookup_table). Add helper functions to set/get rlookup table for the given device. Also add macros to get seg/devid from sbdf. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthiku

[PATCH v3 03/35] iommu/amd: Introduce per PCI segment device table

2022-05-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Introduce per PCI segment device table. All IOMMUs within the segment will share this device table. This will replace global device table i.e. amd_iommu_dev_table. Also introduce helper function to get the device table for the given IOMMU. Co-developed-by: Vasant Heg

[PATCH v3 02/35] iommu/amd: Introduce pci segment structure

2022-05-11 Thread Vasant Hegde via iommu
Newer AMD systems can support multiple PCI segments, where each segment contains one or more IOMMU instances. However, an IOMMU instance can only support a single PCI segment. Current code assumes that system contains only one pci segment (segment 0) and creates global data structures such as devi

[PATCH v3 01/35] iommu/amd: Update struct iommu_dev_data definition

2022-05-11 Thread Vasant Hegde via iommu
struct iommu_dev_data contains member "pdev" to point to pci_dev. This is valid for only PCI devices and for other devices this will be NULL. This causes unnecessary "pdev != NULL" check at various places. Replace "struct pci_dev" member with "struct device" and use to_pci_dev() to get pci device

[PATCH v3 00/35] iommu/amd: Add multiple PCI segments support

2022-05-11 Thread Vasant Hegde via iommu
Newer AMD systems can support multiple PCI segments, where each segment contains one or more IOMMU instances. However, an IOMMU instance can only support a single PCI segment. Current code assumes a system contains only one PCI segment (segment 0) and creates global data structures such as device

Re: [PATCH v2 10/37] iommu/amd: Introduce per PCI segment last_bdf

2022-05-05 Thread Vasant Hegde via iommu
Hi Joerg, On 5/2/2022 4:24 PM, Joerg Roedel wrote: > Hi Vasant, > > On Fri, Apr 29, 2022 at 08:15:49PM +0530, Vasant Hegde wrote: >> We still need to parse IVHD to find max devices supported by each PCI segment >> (same as the way its doing it today). Hence we need all these variables. > > From

Re: [PATCH v2 10/37] iommu/amd: Introduce per PCI segment last_bdf

2022-04-29 Thread Vasant Hegde via iommu
Joerg, On 4/28/2022 3:40 PM, Joerg Roedel wrote: > On Mon, Apr 25, 2022 at 05:03:48PM +0530, Vasant Hegde wrote: >> +/* Largest PCI device id we expect translation requests for */ >> +u16 last_bdf; > > How does the IVRS table look like on these systems? Do they still > enumerate the whol

Re: [PATCH v2 02/37] iommu/amd: Introduce pci segment structure

2022-04-29 Thread Vasant Hegde via iommu
Joerg, On 4/28/2022 3:24 PM, Joerg Roedel wrote: > Hi Vasant, > > On Mon, Apr 25, 2022 at 05:03:40PM +0530, Vasant Hegde wrote: >> +/* >> + * This structure contains information about one PCI segment in the system. >> + */ >> +struct amd_iommu_pci_seg { >> +struct list_head list; > > The pur

Re: [PATCH v2 27/37] iommu/amd: Remove global amd_iommu_dev_table

2022-04-29 Thread Vasant Hegde via iommu
On 4/28/2022 3:45 PM, Joerg Roedel wrote: > On Mon, Apr 25, 2022 at 05:04:05PM +0530, Vasant Hegde wrote: >> From: Suravee Suthikulpanit >> >> Replace global amd_iommu_dev_table with per PCI segment device table. >> Also remove "dev_table_size". >> >> Co-developed-by: Vasant Hegde >> Signed-of

Re: [PATCH v2 37/37] iommu/amd: Update amd_iommu_fault structure to include PCI seg ID

2022-04-29 Thread Vasant Hegde via iommu
Joerg, On 4/28/2022 3:49 PM, Joerg Roedel wrote: > On Mon, Apr 25, 2022 at 05:04:15PM +0530, Vasant Hegde wrote: >> +seg_id = (iommu_fault->sbdf >> 16) & 0x; >> +devid = iommu_fault->sbdf & 0x; > > This deserves some macros for readability. Sure. Will add macros in next version

Re: [PATCH v2 00/37] iommu/amd: Add multiple PCI segments support

2022-04-29 Thread Vasant Hegde via iommu
Joerg, On 4/28/2022 3:52 PM, Joerg Roedel wrote: > Hi Vasant, Hi Suravee, > > On Mon, Apr 25, 2022 at 05:03:38PM +0530, Vasant Hegde wrote: >> Newer AMD systems can support multiple PCI segments, where each segment >> contains one or more IOMMU instances. However, an IOMMU instance can only >> su

Re: [PATCH v2 01/37] iommu/amd: Update struct iommu_dev_data defination

2022-04-29 Thread Vasant Hegde via iommu
Joerg, On 4/28/2022 3:25 PM, Joerg Roedel wrote: > On Mon, Apr 25, 2022 at 05:03:39PM +0530, Vasant Hegde wrote: > > Subject: iommu/amd: Update struct iommu_dev_data defination > ^^ Typo > Thanks for the review. Will fix it in v3. -Vasa

Re: [PATCH] iommu/amd: Set translation valid bit only when IO page tables are in used

2022-04-28 Thread Vasant Hegde via iommu
On 4/20/2022 4:59 PM, Suravee Suthikulpanit via iommu wrote: > On AMD system with SNP enabled, IOMMU hardware checks the host translation > valid (TV) and guest translation valid (GV) bits in the device > table entry (DTE) before accessing the corresponded page tables. > > However, current IOMMU d

[PATCH v2 37/37] iommu/amd: Update amd_iommu_fault structure to include PCI seg ID

2022-04-25 Thread Vasant Hegde via iommu
Rename 'device_id' as 'sbdf' and extend it to 32bit so that we can pass PCI segment ID to ppr_notifier(). Also pass PCI segment ID to pci_get_domain_bus_and_slot() instead of default value. Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 2 +- drivers/iommu/amd/iommu.c

[PATCH v2 36/37] iommu/amd: Update device_state structure to include PCI seg ID

2022-04-25 Thread Vasant Hegde via iommu
Rename struct device_state.devid variable to struct device_state.sbdf and extend it to 32-bit to include the 16-bit PCI segment ID via the helper function get_pci_sbdf_id(). Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iomm

[PATCH v2 35/37] iommu/amd: Print PCI segment ID in error log messages

2022-04-25 Thread Vasant Hegde via iommu
Print pci segment ID along with bdf. Useful for debugging. Co-developed-by: Suravee Suthikulpaint Signed-off-by: Suravee Suthikulpaint Signed-off-by: Vasant Hegde --- drivers/iommu/amd/init.c | 10 +- drivers/iommu/amd/iommu.c | 36 ++-- 2 files changed

[PATCH v2 34/37] iommu/amd: Add PCI segment support for ivrs_ioapic, ivrs_hpet, ivrs_acpihid commands

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit By default, PCI segment is zero and can be omitted. To support system with non-zero PCI segment ID, modify the parsing functions to allow PCI segment ID. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- .../admin-guide/kernel-parameters.txt

  1   2   3   >