[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BN9PR11MB5276F7ACEBCDAB8C0FF5390E8CB22@BN9PR11MB5276.namprd11.prod.outlook.com>
Date: Thu, 1 Aug 2024 08:10:57 +0000
From: "Tian, Kevin" <kevin.tian@...el.com>
To: Nicolin Chen <nicolinc@...dia.com>, "jgg@...dia.com" <jgg@...dia.com>
CC: "Liu, Yi L" <yi.l.liu@...el.com>, "iommu@...ts.linux.dev"
<iommu@...ts.linux.dev>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] iommufd: Enforce IOMMU_RESV_SW_MSI upon hwpt_paging
allocation
> From: Nicolin Chen <nicolinc@...dia.com>
> Sent: Thursday, August 1, 2024 5:22 AM
>
> @@ -316,7 +316,9 @@ static inline bool hwpt_is_paging(struct
> iommufd_hw_pagetable *hwpt)
> static inline struct iommufd_hwpt_paging *
> to_hwpt_paging(struct iommufd_hw_pagetable *hwpt)
> {
> - return container_of(hwpt, struct iommufd_hwpt_paging, common);
> + if (hwpt_is_paging(hwpt))
> + return container_of(hwpt, struct iommufd_hwpt_paging,
> common);
> + return container_of(hwpt, struct iommufd_hwpt_nested, common)-
> >parent;
> }
>
hmm this doesn't work with future new hwpt types.
It's clearer to pass hwpt into earlier helpers and then do the type check
insided and make it a nop for types other than paging/nesting.
Powered by blists - more mailing lists