Linux IOMMU Development
 help / color / mirror / Atom feed
From: Vasant Hegde <vasant.hegde@amd.com>
To: <iommu@lists.linux.dev>, <joro@8bytes.org>
Cc: <suravee.suthikulpanit@amd.com>, <wei.huang2@amd.com>,
	<jsnitsel@redhat.com>, <jgg@ziepe.ca>,
	Vasant Hegde <vasant.hegde@amd.com>,
	Jason Gunthorpe <jgg@nvidia.com>
Subject: [PATCH v7 01/17] iommu/amd: Pass struct iommu_dev_data to set_dte_entry()
Date: Mon, 5 Feb 2024 11:55:59 +0000	[thread overview]
Message-ID: <20240205115615.6053-2-vasant.hegde@amd.com> (raw)
In-Reply-To: <20240205115615.6053-1-vasant.hegde@amd.com>

Pass iommu_dev_data structure instead of passing indivisual variables.

No functional changes intended.

Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
---
 drivers/iommu/amd/iommu.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 4283dd8191f0..5edde7fa3c63 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -1704,12 +1704,14 @@ static int setup_gcr3_table(struct protection_domain *domain, int pasids)
 	return 0;
 }
 
-static void set_dte_entry(struct amd_iommu *iommu, u16 devid,
-			  struct protection_domain *domain, bool ats, bool ppr)
+static void set_dte_entry(struct amd_iommu *iommu,
+			  struct iommu_dev_data *dev_data)
 {
 	u64 pte_root = 0;
 	u64 flags = 0;
 	u32 old_domid;
+	u16 devid = dev_data->devid;
+	struct protection_domain *domain = dev_data->domain;
 	struct dev_table_entry *dev_table = get_dev_table(iommu);
 
 	if (domain->iop.mode != PAGE_MODE_NONE)
@@ -1729,10 +1731,10 @@ static void set_dte_entry(struct amd_iommu *iommu, u16 devid,
 
 	flags = dev_table[devid].data[1];
 
-	if (ats)
+	if (dev_data->ats_enabled)
 		flags |= DTE_FLAG_IOTLB;
 
-	if (ppr)
+	if (dev_data->ppr)
 		pte_root |= 1ULL << DEV_ENTRY_PPR;
 
 	if (domain->dirty_tracking)
@@ -1808,12 +1810,10 @@ static void do_attach(struct iommu_dev_data *dev_data,
 		      struct protection_domain *domain)
 {
 	struct amd_iommu *iommu;
-	bool ats;
 
 	iommu = rlookup_amd_iommu(dev_data->dev);
 	if (!iommu)
 		return;
-	ats   = dev_data->ats_enabled;
 
 	/* Update data structures */
 	dev_data->domain = domain;
@@ -1828,8 +1828,7 @@ static void do_attach(struct iommu_dev_data *dev_data,
 	domain->dev_cnt                 += 1;
 
 	/* Update device table */
-	set_dte_entry(iommu, dev_data->devid, domain,
-		      ats, dev_data->ppr);
+	set_dte_entry(iommu, dev_data);
 	clone_aliases(iommu, dev_data->dev);
 
 	device_flush_dte(dev_data);
@@ -2013,8 +2012,7 @@ static void update_device_table(struct protection_domain *domain)
 
 		if (!iommu)
 			continue;
-		set_dte_entry(iommu, dev_data->devid, domain,
-			      dev_data->ats_enabled, dev_data->ppr);
+		set_dte_entry(iommu, dev_data);
 		clone_aliases(iommu, dev_data->dev);
 	}
 }
-- 
2.31.1


  reply	other threads:[~2024-02-05 11:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-05 11:55 [PATCH v7 00/17] iommu/amd: SVA Support (part 3) - refactor support for GCR3 table Vasant Hegde
2024-02-05 11:55 ` Vasant Hegde [this message]
2024-02-05 11:56 ` [PATCH v7 02/17] iommu/amd: Enable Guest Translation before registering devices Vasant Hegde
2024-02-05 11:56 ` [PATCH v7 03/17] iommu/amd: Introduce get_amd_iommu_from_dev() Vasant Hegde
2024-02-05 11:56 ` [PATCH v7 04/17] iommu/amd: Introduce struct protection_domain.pd_mode Vasant Hegde
2024-02-05 11:56 ` [PATCH v7 05/17] iommu/amd: Introduce per-device GCR3 table Vasant Hegde
2024-02-05 11:56 ` [PATCH v7 06/17] iommu/amd: Use protection_domain.flags to check page table mode Vasant Hegde
2024-02-05 11:56 ` [PATCH v7 07/17] iommu/amd: Add support for device based TLB invalidation Vasant Hegde
2024-02-05 11:56 ` [PATCH v7 08/17] iommu/amd: Rearrange GCR3 table setup code Vasant Hegde
2024-02-05 11:56 ` [PATCH v7 09/17] iommu: Introduce iommu_group_mutex_assert() Vasant Hegde
2024-02-05 11:56 ` [PATCH v7 10/17] iommu/amd: Refactor helper function for setting / clearing GCR3 Vasant Hegde
2024-02-05 11:56 ` [PATCH v7 11/17] iommu/amd: Refactor attaching / detaching device functions Vasant Hegde
2024-02-05 11:56 ` [PATCH v7 12/17] iommu/amd: Refactor protection_domain helper functions Vasant Hegde
2024-02-05 11:56 ` [PATCH v7 13/17] iommu/amd: Refactor GCR3 table " Vasant Hegde
2024-02-05 11:56 ` [PATCH v7 14/17] iommu/amd: Remove unused flush pasid functions Vasant Hegde
2024-02-05 11:56 ` [PATCH v7 15/17] iommu/amd: Rearrange device flush code Vasant Hegde
2024-02-05 11:56 ` [PATCH v7 16/17] iommu/amd: Remove unused GCR3 table parameters from struct protection_domain Vasant Hegde
2024-02-05 11:56 ` [PATCH v7 17/17] iommu/amd: Introduce per-device domain ID to fix potential TLB aliasing issue Vasant Hegde
2024-02-09 10:44 ` [PATCH v7 00/17] iommu/amd: SVA Support (part 3) - refactor support for GCR3 table Joerg Roedel

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=20240205115615.6053-2-vasant.hegde@amd.com \
    --to=vasant.hegde@amd.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=jsnitsel@redhat.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=wei.huang2@amd.com \
    /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