From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
To: Alexander Monakov <amonakov@ispras.ru>, linux-kernel@vger.kernel.org
Cc: iommu@lists.linux-foundation.org
Subject: Re: [PATCH] iommu/amd: Fix event counter availability check
Date: Mon, 1 Jun 2020 14:37:46 +0700 [thread overview]
Message-ID: <56761139-f794-39b1-4dfa-dfc05fbe5f60@amd.com> (raw)
In-Reply-To: <20200529200738.1923-1-amonakov@ispras.ru>
Hi Alexander,
On 5/30/20 3:07 AM, Alexander Monakov wrote:
> The driver performs an extra check if the IOMMU's capabilities advertise
> presence of performance counters: it verifies that counters are writable
> by writing a hard-coded value to a counter and testing that reading that
> counter gives back the same value.
>
> Unfortunately it does so quite early, even before pci_enable_device is
> called for the IOMMU, i.e. when accessing its MMIO space is not
> guaranteed to work. On Ryzen 4500U CPU, this actually breaks the test:
> the driver assumes the counters are not writable, and disables the
> functionality.
>
> Moving init_iommu_perf_ctr just after iommu_flush_all_caches resolves
> the issue. This is the earliest point in amd_iommu_init_pci where the
> call succeeds on my laptop.
According to your description, it should just need to be anywhere after the pci_enable_device() is called for the IOMMU
device, isn't it? So, on your system, what if we just move the init_iommu_perf_ctr() here:
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 5b81fd16f5fa..17b9ac9491e0 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -1875,6 +1875,7 @@ static int __init amd_iommu_init_pci(void)
ret = iommu_init_pci(iommu);
if (ret)
break;
+ init_iommu_perf_ctr(iommu);
}
/*
--
2.17.1
Does this works?
Thanks,
Suravee
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2020-06-01 7:37 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-29 20:07 [PATCH] iommu/amd: Fix event counter availability check Alexander Monakov
2020-05-31 7:22 ` Alexander Monakov
2020-06-01 2:48 ` Paul Menzel
2021-02-21 13:44 ` Paul Menzel
2020-06-02 23:51 ` Shuah Khan
2020-06-03 6:54 ` Alexander Monakov
2021-02-26 21:44 ` Paul Menzel
2021-02-26 21:55 ` Shuah Khan
2020-06-01 7:37 ` Suravee Suthikulpanit [this message]
2020-06-01 9:01 ` Alexander Monakov
2020-06-01 15:10 ` Suravee Suthikulpanit
2020-06-01 16:09 ` Alexander Monakov
2020-06-15 20:48 ` Alexander Monakov
2020-06-16 9:35 ` Suravee Suthikulpanit
2020-06-30 19:22 ` Alexander Monakov
2020-09-17 17:55 ` Alexander Monakov
2021-02-21 13:49 ` Paul Menzel
2021-02-22 17:59 ` Suravee Suthikulpanit
2021-02-24 20:35 ` Paul Menzel
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=56761139-f794-39b1-4dfa-dfc05fbe5f60@amd.com \
--to=suravee.suthikulpanit@amd.com \
--cc=amonakov@ispras.ru \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-kernel@vger.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;
as well as URLs for NNTP newsgroup(s).