public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Bui Quang Minh <minhquangbui99@gmail.com>
To: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>,
	Wan Zongshun <vincent.wan@amd.com>
Cc: Joerg Roedel <joro@8bytes.org>,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
	Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: amd-iommu: get_highest_supported_ivhd_type question
Date: Mon, 15 May 2023 21:36:05 +0700	[thread overview]
Message-ID: <e8a87c2b-a29a-ccf9-49c6-3cfceaa208bb@gmail.com> (raw)

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.

                 reply	other threads:[~2023-05-15 14:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e8a87c2b-a29a-ccf9-49c6-3cfceaa208bb@gmail.com \
    --to=minhquangbui99@gmail.com \
    --cc=Suravee.Suthikulpanit@amd.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=robin.murphy@arm.com \
    --cc=vincent.wan@amd.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox