- Jul 15, 2022
-
-
Suravee Suthikulpanit authored
Some IOMMU features require that all IOMMUs must support the feature, which is determined by checking the support bit in the Extended Feature Register 1 and 2 (EFR/EFR2) on all IOMMUs. This check is done by the function check_feature_on_all_iommus(), which iterates through all IOMMUs everytime it is called. Instead, introduce a global variable to store common EFR/EFR2 among all IOMMUs. In case of inconsistent EFR/EFR2 masks are detected on an IOMMU, a FW_BUG warning is reported. Suggested-by:
Joerg Roedel <joro@8bytes.org> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20220713225651.20758-4-suravee.suthikulpanit@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
AMD IOMMU spec introduces additional extended feature register in the IVRS IVHD offset 80h (for IVHD type 11h and 40h) and MMIO offset 1A0h. Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20220713225651.20758-3-suravee.suthikulpanit@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
There is no functional change. Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20220713225651.20758-2-suravee.suthikulpanit@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
- Jul 07, 2022
-
-
Vasant Hegde authored
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 <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-36-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Vasant Hegde authored
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 <suravee.suthikulpanit@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-35-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Vasant Hegde authored
Print pci segment ID along with bdf. Useful for debugging. Co-developed-by:
Suravee Suthikulpaint <suravee.suthikulpanit@amd.com> Signed-off-by:
Suravee Suthikulpaint <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-34-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
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 <vasant.hegde@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-33-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
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 <vasant.hegde@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-32-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
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 <vasant.hegde@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-31-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
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(). Co-developed-by:
Vasant Hegde <vasant.hegde@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-30-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Vasant Hegde authored
Fix amd_iommu_flush_dte_all() and amd_iommu_flush_tlb_all() to flush upto last_bdf only. Co-developed-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-29-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
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 <vasant.hegde@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-28-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
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 <vasant.hegde@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-27-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
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 <vasant.hegde@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-26-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
Start using per PCI segment device table instead of global device table. Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-25-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
Start using per PCI segment device table instead of global device table. Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-24-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
Start using per PCI segment device table instead of global device table. Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-23-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
Start using per PCI segment data structures instead of global data structures. Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-22-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Vasant Hegde authored
Then, remove the global amd_iommu_rlookup_table and rlookup_table_size. Co-developed-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-21-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
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 <vasant.hegde@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-20-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
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 <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-19-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
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 <vasant.hegde@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-18-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
To allow IOMMU rlookup using both PCI segment and device ID. Co-developed-by:
Vasant Hegde <vasant.hegde@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-17-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
Use rlookup_amd_iommu() helper function which will give per PCI segment rlookup_table. Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-16-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Vasant Hegde authored
Then, remove the global irq_lookup_table. Co-developed-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-15-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Vasant Hegde authored
It will replace global "rlookup_table_size" variable. Co-developed-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-14-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Vasant Hegde authored
It will replace global "alias_table_size" variable. Co-developed-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-13-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Vasant Hegde authored
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 <suravee.suthikulpanit@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-12-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Vasant Hegde authored
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 for all per segment memory allocations. Eventually it will replace global "amd_iommu_last_bdf". Co-developed-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-11-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Vasant Hegde authored
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_unity_map list. Note that we have used "reserved" field in IVMD table to include "pci_seg id" which was set to zero. It will take care of backward compatibility (new kernel will work fine on older systems). Co-developed-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-10-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
This will replace global alias table (amd_iommu_alias_table). Co-developed-by:
Vasant Hegde <vasant.hegde@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-9-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
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 <vasant.hegde@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-8-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Vasant Hegde authored
This will replace global dev_data_list. Co-developed-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-7-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Vasant Hegde authored
This will replace global irq lookup table (irq_lookup_table). Co-developed-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-6-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
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 <vasant.hegde@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-5-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Suravee Suthikulpanit authored
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 Hegde <vasant.hegde@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-4-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Vasant Hegde authored
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 device table, rlookup table, etc. Introducing per PCI segment data structure, which contains segment specific data structures. This will eventually replace the global data structures. Also update `amd_iommu->pci_seg` variable to point to PCI segment structure instead of PCI segment ID. Co-developed-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-3-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Vasant Hegde authored
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 reference as needed. Also adjust setup_aliases() and clone_aliases() function. No functional change intended. Co-developed-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by:
Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-2-vasant.hegde@amd.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
Bo Liu authored
As iommu_device_sysfs_add() can fail, we should check the return value. Signed-off-by:
Bo Liu <liubo03@inspur.com> Link: https://lore.kernel.org/r/20220701062008.6988-1-liubo03@inspur.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-
- Jun 23, 2022
-
-
Uros Bizjak authored
Use try_cmpxchg64 instead of cmpxchg64 (*ptr, old, new) != old in alloc_pte and free_clear_pte. cmpxchg returns success in ZF flag, so this change saves a compare after cmpxchg (and related move instruction in front of cmpxchg). Also, remove racy explicit assignment to pteval when cmpxchg fails, this is what try_cmpxchg does implicitly from *pte in an atomic way. Signed-off-by:
Uros Bizjak <ubizjak@gmail.com> Cc: Joerg Roedel <joro@8bytes.org> Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Cc: Will Deacon <will@kernel.org> Link: https://lore.kernel.org/r/20220525145416.10816-1-ubizjak@gmail.com Signed-off-by:
Joerg Roedel <jroedel@suse.de>
-