Re: [PATCH v7 04/10] iommu/amd: Introduce struct ivhd_dte_flags to store persistent DTE flags

From: Jason Gunthorpe
Date: Thu Oct 31 2024 - 08:43:45 EST


On Thu, Oct 31, 2024 at 09:16:18AM +0000, Suravee Suthikulpanit wrote:
> During early initialization, the driver parses IVRS IVHD block to get list
> of downstream devices along with their DTE flags (i.e INITPass, EIntPass,
> NMIPass, SysMgt, Lint0Pass, Lint1Pass). This information is currently
> store in the device DTE, and needs to be preserved when clearing
> and configuring each DTE, which makes it difficult to manage.
>
> Introduce struct ivhd_dte_flags to store IVHD DTE settings for a device or
> range of devices, which are stored in the amd_ivhd_dev_flags_list during
> initial IVHD parsing.
>
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@xxxxxxx>
> ---
> drivers/iommu/amd/amd_iommu_types.h | 15 ++++
> drivers/iommu/amd/init.c | 110 ++++++++++++++++++++--------
> 2 files changed, 96 insertions(+), 29 deletions(-)

Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>

> /* sets a specific bit in the device table entry. */
> +static void set_dte_bit(struct dev_table_entry *dte, u8 bit)
> +{
> + int i = (bit >> 6) & 0x03;
> + int _bit = bit & 0x3f;
> +
> + dte->data[i] |= (1UL << _bit);
> +}

It would be nice to see the remaining DEV_ENTRY constants harmonized
with the DTE_ constants so there aren't two schemes for working with
the struct dev_table_entry, but that is an idea for some other series

Jason