Re: [PATCH 4/5] iommu/amd: skip updating the IRTE entry when is_run is already false

From: Joao Martins
Date: Thu Sep 28 2023 - 13:29:31 EST


On 28/09/2023 16:04, Maxim Levitsky wrote:
> When vCPU affinity of an IRTE which already has
> is_run == false, is updated and the update also sets is_run to false,
> there is nothing to do.
>
> The goal of this patch is to make a call to 'amd_iommu_update_ga()'
> to be relatively cheap if there is nothing to do.
>
> Signed-off-by: Maxim Levitsky <mlevitsk@xxxxxxxxxx>

Reviewed-by: Joao Martins <joao.m.martins@xxxxxxxxxx>

> ---
> drivers/iommu/amd/iommu.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index 95bd7c25ba6f366..10bcd436e984672 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -3774,6 +3774,15 @@ int amd_iommu_update_ga(int cpu, bool is_run, void *data)
> entry->hi.fields.destination =
> APICID_TO_IRTE_DEST_HI(cpu);
> }
> +
> + if (!is_run && !entry->lo.fields_vapic.is_run) {
> + /*
> + * No need to notify the IOMMU about an entry which
> + * already has is_run == False
> + */
> + return 0;
> + }
> +
> entry->lo.fields_vapic.is_run = is_run;
>
> return modify_irte_ga(ir_data->iommu, ir_data->irq_2_irte.devid,