[RFC PATCH 17/36] iommu/amd: Update amd_irte_ops functions

2022-03-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 ++--

[RFC PATCH 15/36] iommu/amd: Update irq_remapping_alloc to use IOMMU lookup helper function

2022-03-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

[RFC PATCH 16/36] iommu/amd: Introduce struct amd_ir_data.iommu

2022-03-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 ---

[RFC PATCH 30/36] iommu/amd: Introduce get_device_sbdf_id() helper function

2022-03-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

[RFC PATCH 31/36] iommu/amd: Include PCI segment ID when initialize IOMMU

2022-03-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 ---

[RFC PATCH 29/36] iommu/amd: Flush upto last_bdf only

2022-03-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

[RFC PATCH 32/36] iommu/amd: Specify PCI segment ID when getting pci device

2022-03-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

[RFC PATCH 00/36] iommu/amd: Add multiple PCI segments support

2022-03-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

[RFC PATCH 01/36] iommu/amd: Introduce pci segment structure

2022-03-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

[RFC PATCH 03/36] iommu/amd: Introduce per PCI segment rlookup table

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

[RFC PATCH 02/36] iommu/amd: Introduce per PCI segment device table

2022-03-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

[RFC PATCH 18/36] iommu/amd: Update alloc_irq_table and alloc_irq_index

2022-03-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

[RFC PATCH 19/36] iommu/amd: Convert to use per PCI segment rlookup_table

2022-03-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 ++-

[RFC PATCH 20/36] iommu/amd: Update set_dte_entry and clear_dte_entry

2022-03-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

[RFC PATCH 34/36] iommu/amd: Print PCI segment ID in error log messages

2022-03-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

[RFC PATCH 33/36] iommu/amd: Add PCI segment support for ivrs_ioapic, ivrs_hpet, ivrs_acpihid commands

2022-03-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. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- .../admin-guide/kernel-parameters.txt

[RFC PATCH 36/36] iommu/amd: Update amd_iommu_fault structure to include PCI seg ID

2022-03-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

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

2022-03-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 ---

[RFC PATCH 14/36] iommu/amd: Convert to use rlookup_amd_iommu helper function

2022-03-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

[RFC PATCH 11/36] iommu/amd: Introduce per PCI segment alias table size

2022-03-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

[RFC PATCH 12/36] iommu/amd: Introduce per PCI segment rlookup table size

2022-03-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

[RFC PATCH 13/36] iommu/amd: Convert to use per PCI segment irq_lookup_table

2022-03-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

[RFC PATCH 08/36] iommu/amd: Introduce per PCI segment unity map list

2022-03-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

[RFC PATCH 07/36] iommu/amd: Introduce per PCI segment alias_table

2022-03-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

[RFC PATCH 09/36] iommu/amd: Introduce per PCI segment last_bdf

2022-03-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

[RFC PATCH 10/36] iommu/amd: Introduce per PCI segment device table size

2022-03-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

[RFC PATCH 24/36] iommu/amd: Update (un)init_device_table_dma()

2022-03-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

[RFC PATCH 25/36] iommu/amd: Update set_dev_entry_bit() and get_dev_entry_bit()

2022-03-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:

[RFC PATCH 26/36] iommu/amd: Remove global amd_iommu_dev_table

2022-03-11 Thread Vasant Hegde via iommu
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-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/amd_iommu_types.h | 6 --

[RFC PATCH 28/36] iommu/amd: Remove global amd_iommu_last_bdf

2022-03-11 Thread Vasant Hegde via iommu
Replace it with per PCI segment last_bdf 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| 35 ++---

[RFC PATCH 22/36] iommu/amd: Update dump_dte_entry

2022-03-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

[RFC PATCH 21/36] iommu/amd: Update iommu_ignore_device

2022-03-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

[RFC PATCH 27/36] iommu/amd: Remove global amd_iommu_alias_table

2022-03-11 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit This is replaced by the per PCI segment alias table. Also remove alias_table_size variable. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/amd_iommu_types.h | 6 --

[RFC PATCH 23/36] iommu/amd: Update set_dte_irq_entry

2022-03-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

[RFC PATCH 05/36] iommu/amd: Introduce per PCI segment dev_data_list

2022-03-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

[RFC PATCH 04/36] iommu/amd: Introduce per PCI segment irq_lookup_table

2022-03-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

[RFC PATCH 06/36] iommu/amd: Introduce per PCI segment old_dev_tbl_cpy

2022-03-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 ++

[PATCH] iommu/amd: Remove redundant check

2022-03-14 Thread Vasant Hegde via iommu
smatch static checker warning: drivers/iommu/amd/init.c:1989 amd_iommu_init_pci() warn: duplicate check 'ret' (previous on line 1978) Reported-by: Dan Carpenter Fixes: 06687a03805e ("iommu/amd: Improve error handling for amd_iommu_init_pci") Signed-off-by: Vasant Hegde ---

Re: [PATCH v2 1/2] Documentation: x86: Add documenation for AMD IOMMU

2022-03-09 Thread Vasant Hegde via iommu
On 3/9/2022 11:28 PM, Alex Deucher via iommu wrote: > Add preliminary documenation for AMD IOMMU. s/documenation /documentation/ > > Signed-off-by: Alex Deucher > --- > > V2: incorporate feedback from Robin to clarify IOMMU vs DMA engine (e.g., > a device) and document proper DMA API.

Re: [bug report] iommu/amd: Improve error handling for amd_iommu_init_pci

2022-03-09 Thread Vasant Hegde via iommu
On 3/9/2022 12:41 PM, Dan Carpenter wrote: > Hello Suravee Suthikulpanit, Dan, Thanks for the bug report. .../... > > 1979 pr_err("IOMMU: Failed to initialize IOMMU-API > interface (error=%d)!\n", > 1980ret); > 1981 goto

[PATCH 5/5] iommu/amd: Improve amd_iommu_v2_exit()

2022-02-21 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit During module exit, the current logic loops through all possible 16-bit device ID space to search for existing devices and clean up device state structures. This can be simplified by looping through the device state list. Also, refactor various clean up logic into

[PATCH 3/5] iommu/amd: Clean up function declarations

2022-02-21 Thread Vasant Hegde via iommu
Remove unused declarations and add static keyword as needed. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu.h | 4 drivers/iommu/amd/init.c | 2 +- 2 files changed, 1 insertion(+), 5

[PATCH 2/5] iommu/amd: Call memunmap in error path

2022-02-21 Thread Vasant Hegde via iommu
From: Vasant Hegde Unmap old_devtb in error path. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c

[PATCH 1/5] iommu/amd: Improve error handling for amd_iommu_init_pci

2022-02-21 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Add error messages to prevent silent failure. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/init.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/amd/init.c

[PATCH 0/5] iommu/amd: Cleanup and fixes

2022-02-21 Thread Vasant Hegde via iommu
This series contains various cleanup and trivial fixes. Suravee Suthikulpanit (2): iommu/amd: Improve error handling for amd_iommu_init_pci iommu/amd: Improve amd_iommu_v2_exit() Vasant Hegde (3): iommu/amd: Call memunmap in error path iommu/amd: Clean up function declarations

[PATCH 4/5] iommu/amd: Remove unused struct fault.devid

2022-02-21 Thread Vasant Hegde via iommu
This variable has not been used since it was introduced. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu_v2.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iommu/amd/iommu_v2.c

[PATCH v2 5/5] iommu/amd: Improve amd_iommu_v2_exit()

2022-03-01 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit During module exit, the current logic loops through all possible 16-bit device ID space to search for existing devices and clean up device state structures. This can be simplified by looping through the device state list. Also, refactor various clean up logic into

Re: [PATCH 1/5] iommu/amd: Improve error handling for amd_iommu_init_pci

2022-03-01 Thread Vasant Hegde via iommu
On 2/28/2022 6:17 PM, Joerg Roedel wrote: > On Mon, Feb 21, 2022 at 10:29:12AM +0530, Vasant Hegde wrote: >> From: Suravee Suthikulpanit >> >> Add error messages to prevent silent failure. >> >> Signed-off-by: Suravee Suthikulpanit >> Signed-off-by: Vasant Hegde >> --- >>

[PATCH v2 3/5] iommu/amd: Clean up function declarations

2022-03-01 Thread Vasant Hegde via iommu
Remove unused declarations and add static keyword as needed. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu.h | 4 drivers/iommu/amd/init.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git

[PATCH v2 0/5] iommu/amd: Cleanup and fixes

2022-03-01 Thread Vasant Hegde via iommu
This series contains various cleanup and trivial fixes. Changes in v2: - Fixed error log message in patch 1 as suggested by Joerg. Suravee Suthikulpanit (2): iommu/amd: Improve error handling for amd_iommu_init_pci iommu/amd: Improve amd_iommu_v2_exit() Vasant Hegde (3): iommu/amd:

[PATCH v2 2/5] iommu/amd: Call memunmap in error path

2022-03-01 Thread Vasant Hegde via iommu
Unmap old_devtb in error path. Signed-off-by: Vasant Hegde --- drivers/iommu/amd/init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c index 6b5af568f3d5..f7e7d208063c 100644 --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c

[PATCH v2 1/5] iommu/amd: Improve error handling for amd_iommu_init_pci

2022-03-01 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Add error messages to prevent silent failure. Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/init.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/amd/init.c

[PATCH v2 4/5] iommu/amd: Remove unused struct fault.devid

2022-03-01 Thread Vasant Hegde via iommu
This variable has not been used since it was introduced. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu_v2.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iommu/amd/iommu_v2.c b/drivers/iommu/amd/iommu_v2.c index

Re: [PATCH] iommu/amd: Remove redundant check

2022-03-28 Thread Vasant Hegde via iommu
Joerg, Ping. -Vasant On 3/14/2022 12:32 PM, Vasant Hegde via iommu wrote: > smatch static checker warning: > drivers/iommu/amd/init.c:1989 amd_iommu_init_pci() > warn: duplicate check 'ret' (previous on line 1978) > > Reported-by: Dan Carpenter > Fixes: 06687a03805e (&

[PATCH v1 15/37] iommu/amd: Convert to use rlookup_amd_iommu helper function

2022-04-04 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

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

2022-04-04 Thread Vasant Hegde via iommu
On 4/4/2022 3:10 PM, Vasant Hegde via iommu 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. > Hi, Please ignore this series. Looks like I

[PATCH v1 03/37] iommu/amd: Introduce per PCI segment device table

2022-04-04 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

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

2022-04-04 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

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

2022-04-04 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 v1 00/37] iommu/amd: Add multiple PCI segments support

2022-04-04 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

[RESEND PATCH v1 32/37] iommu/amd: Include PCI segment ID when initialize IOMMU

2022-04-04 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 ---

[RESEND PATCH v1 28/37] iommu/amd: Remove global amd_iommu_alias_table

2022-04-04 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit This is replaced by the per PCI segment alias table. Also remove alias_table_size variable. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/amd_iommu_types.h | 6 --

[RESEND PATCH v1 29/37] iommu/amd: Remove global amd_iommu_last_bdf

2022-04-04 Thread Vasant Hegde via iommu
Replace it with per PCI segment last_bdf 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| 35 ++---

[RESEND PATCH v1 31/37] iommu/amd: Introduce get_device_sbdf_id() helper function

2022-04-04 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

[RESEND PATCH v1 27/37] iommu/amd: Remove global amd_iommu_dev_table

2022-04-04 Thread Vasant Hegde via iommu
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-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/amd_iommu_types.h | 6 --

[RESEND PATCH v1 30/37] iommu/amd: Flush upto last_bdf only

2022-04-04 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

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

2022-04-04 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 ++-

[RESEND PATCH v1 21/37] iommu/amd: Update set_dte_entry and clear_dte_entry

2022-04-04 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

[RESEND PATCH v1 22/37] iommu/amd: Update iommu_ignore_device

2022-04-04 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

[RESEND PATCH v1 19/37] iommu/amd: Update alloc_irq_table and alloc_irq_index

2022-04-04 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 v1 08/37] iommu/amd: Introduce per PCI segment alias_table

2022-04-04 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 v1 09/37] iommu/amd: Introduce per PCI segment unity map list

2022-04-04 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

[PATCH v1 04/37] iommu/amd: Introduce per PCI segment rlookup table

2022-04-04 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit This will replace global rlookup table (amd_iommu_rlookup_table). Also add helper functions to set/get rlookup table for the given device. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit ---

[PATCH v1 07/37] iommu/amd: Introduce per PCI segment old_dev_tbl_cpy

2022-04-04 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 ++

[PATCH v1 06/37] iommu/amd: Introduce per PCI segment dev_data_list

2022-04-04 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 v1 05/37] iommu/amd: Introduce per PCI segment irq_lookup_table

2022-04-04 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

[RESEND PATCH v1 18/37] iommu/amd: Update amd_irte_ops functions

2022-04-04 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 ++--

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

2022-04-04 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

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

2022-04-04 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

[RESEND PATCH v1 15/37] iommu/amd: Convert to use rlookup_amd_iommu helper function

2022-04-04 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

[RESEND PATCH v1 17/37] iommu/amd: Introduce struct amd_ir_data.iommu

2022-04-04 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 ---

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

2022-04-04 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 v1 14/37] iommu/amd: Convert to use per PCI segment irq_lookup_table

2022-04-04 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 v1 10/37] iommu/amd: Introduce per PCI segment last_bdf

2022-04-04 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

[PATCH v1 11/37] iommu/amd: Introduce per PCI segment device table size

2022-04-04 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

[PATCH v1 13/37] iommu/amd: Introduce per PCI segment rlookup table size

2022-04-04 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

[PATCH v1 12/37] iommu/amd: Introduce per PCI segment alias table size

2022-04-04 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

[RESEND PATCH v1 25/37] iommu/amd: Update (un)init_device_table_dma()

2022-04-04 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

[RESEND PATCH v1 23/37] iommu/amd: Update dump_dte_entry

2022-04-04 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

[RESEND PATCH v1 26/37] iommu/amd: Update set_dev_entry_bit() and get_dev_entry_bit()

2022-04-04 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:

[RESEND PATCH v1 24/37] iommu/amd: Update set_dte_irq_entry

2022-04-04 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

[RESEND PATCH v1 00/37] iommu/amd: Add multiple PCI segments support

2022-04-04 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

[RESEND PATCH v1 01/37] iommu/amd: Update struct iommu_dev_data defination

2022-04-04 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

[RESEND PATCH v1 02/37] iommu/amd: Introduce pci segment structure

2022-04-04 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

[RESEND PATCH v1 07/37] iommu/amd: Introduce per PCI segment old_dev_tbl_cpy

2022-04-04 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 ++

[RESEND PATCH v1 04/37] iommu/amd: Introduce per PCI segment rlookup table

2022-04-04 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit This will replace global rlookup table (amd_iommu_rlookup_table). Also add helper functions to set/get rlookup table for the given device. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit ---

[RESEND PATCH v1 03/37] iommu/amd: Introduce per PCI segment device table

2022-04-04 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

[RESEND PATCH v1 06/37] iommu/amd: Introduce per PCI segment dev_data_list

2022-04-04 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

[RESEND PATCH v1 05/37] iommu/amd: Introduce per PCI segment irq_lookup_table

2022-04-04 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

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

2022-04-04 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

  1   2   3   >