From: Mario Limonciello <superm1@kernel.org>
To: Vasant Hegde <vasant.hegde@amd.com>, Jason Gunthorpe <jgg@ziepe.ca>
Cc: Alex Deucher <alexander.deucher@amd.com>,
Joerg Roedel <joro@8bytes.org>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
"open list:RADEON and AMDGPU DRM DRIVERS"
<amd-gfx@lists.freedesktop.org>,
open list <linux-kernel@vger.kernel.org>,
"open list:AMD IOMMU (AMD-VI)" <iommu@lists.linux.dev>
Subject: Re: [PATCH v2] iommu/amd: Make PerfOpt compulsory
Date: Wed, 30 Sep 2026 08:39:59 -0500 [thread overview]
Message-ID: <edae0bd0-e580-45f2-953e-dd117791c488@kernel.org> (raw)
In-Reply-To: <bd707bac-26c1-4330-9e29-a8eaec07745b@amd.com>
On 9/30/26 04:38, Vasant Hegde wrote:
> Mario,
>
> On 9/29/2026 7:04 AM, Mario Limonciello (AMD) wrote:
>> PerfOpt is only a feature usable by integrated GPUs and only in identity
>> mode. Instead of leaving a policy knob in amdgpu, just turn it on when
>> an integrated GPU is in identity.
>>
>> This drops quite a bit of compatibility glue. There was a refcounting
>> system, exported symbols, and device attach/detach logic. By just setting
>> it immediately it's a lot more straightforward.
>>
>> Suggested-by: Jason Gunthorpe <jgg@ziepe.ca>
>> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
>> ---
>> v2:
>> * Move WARN_ON to amd_iommu_perfopt_clear()
>> * Make amd_iommu_perfopt_clear() void
>> * Drop unnecessary cleanup/create paths that unset feature
>> * Enable the feature in IOMMU if supported (per guidance in IVRS spec)
>> * Use existing check_feature() helper instead
>> ---
>
>
> .../...
>
>> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
>> index c9b28e5e582ea..a1adb40d5b79d 100644
>> --- a/drivers/iommu/amd/iommu.c
>> +++ b/drivers/iommu/amd/iommu.c
>> @@ -2345,6 +2345,35 @@ static void pdom_detach_iommu(struct amd_iommu *iommu,
>> spin_unlock_irqrestore(&pdom->lock, flags);
>> }
>>
>> +/*
>> + * Program or clear the per-IOMMU PerfOpt enable bit
>> + * This allows a privileged internal GPU to be able to bypass IOMMU when
>> + * in identity mode.
>> + */
>> +int amd_iommu_perfopt_set(struct amd_iommu *iommu, bool enable)
>
> Please move this to init.c file
Thanks, good suggestion.
>
>> +{
>> + u32 old, val, readback;
>> +
>> + if (!check_feature(FEATURE_PERF_OPT))
>> + return enable ? -ENODEV : 0;
>> +
>> + old = readl(iommu->mmio_base + MMIO_PERF_OPT_OFFSET);
>> + if (old == U32_MAX)
>> + return -EIO;
>> +
>> + val = enable ? old | PERF_OPT_EN : old & ~PERF_OPT_EN;
>> + if (val != old)
>> + writel(val, iommu->mmio_base + MMIO_PERF_OPT_OFFSET);
>> + readback = readl(iommu->mmio_base + MMIO_PERF_OPT_OFFSET);
>> + if (readback == U32_MAX ||
>> + (readback & PERF_OPT_EN) != (val & PERF_OPT_EN)) {
>> + dev_err(iommu->iommu.dev, "Failed to set PerfOpt to %d\n", enable);
>> + return -EIO;
>> + }
>> +
>
> May be check return value before enabling dev_data->perfopt?
I thought about this.
Let me know what you think of the approach of clearing the bit in
amd_iommu_efr on failures within amd_iommu_perfopt_set().
That would mean that dev_data->perfopt doesn't get enabled later.
next prev parent reply other threads:[~2026-09-30 13:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 1:34 [PATCH v2] iommu/amd: Make PerfOpt compulsory Mario Limonciello (AMD)
2026-09-30 9:38 ` Vasant Hegde
2026-09-30 13:39 ` Mario Limonciello [this message]
2026-09-30 13:50 ` Vasant Hegde
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=edae0bd0-e580-45f2-953e-dd117791c488@kernel.org \
--to=superm1@kernel.org \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=suravee.suthikulpanit@amd.com \
--cc=vasant.hegde@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.