public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* amd-iommu: get_highest_supported_ivhd_type question
@ 2023-05-15 14:36 Bui Quang Minh
  0 siblings, 0 replies; only message in thread
From: Bui Quang Minh @ 2023-05-15 14:36 UTC (permalink / raw)
  To: Suravee Suthikulpanit, Wan Zongshun
  Cc: Joerg Roedel, Suravee Suthikulpanit, Will Deacon, Robin Murphy,
	iommu, linux-kernel, Michael S. Tsirkin

Hello everyone,

Since this commit 8c7142f56fedfc6824b5bca56fee1f443e01746b (iommu/amd: 
Use the most comprehensive IVHD type that the driver can support), 
amd_iommu driver can support IVHD type 0x11 and 0x40 beside old type 
0x10. This commit introduces a new function to determine the appropriate 
IVHD type

	/**
	 * get_highest_supported_ivhd_type - Look up the appropriate IVHD type
	 * @ivrs          Pointer to the IVRS header
	 *
	 * This function search through all IVDB of the maximum supported IVHD
	 */
	static u8 get_highest_supported_ivhd_type(struct acpi_table_header *ivrs)
	{
		u8 *base = (u8 *)ivrs;
		struct ivhd_header *ivhd = (struct ivhd_header *)
						(base + IVRS_HEADER_LENGTH);
		u8 last_type = ivhd->type;
		u16 devid = ivhd->devid;

		while (((u8 *)ivhd - base < ivrs->length) &&
		       (ivhd->type <= ACPI_IVHD_TYPE_MAX_SUPPORTED)) {
			u8 *p = (u8 *) ivhd;

			if (ivhd->devid == devid)
				last_type = ivhd->type;
			ivhd = (struct ivhd_header *)(p + ivhd->length);
		}

		return last_type;
	}

As the name and comment suggest, the driver is intended to use the 
highest IVHD type provided in ACPI table. However, looking at the 
implementation, I see that it chooses to use the last IVHD type of the 
first devid appears in the ACPI table. Are there any reasons behind this 
implementation?

Thank you,
Quang Minh.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-15 14:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-15 14:36 amd-iommu: get_highest_supported_ivhd_type question Bui Quang Minh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox