From: Joao Martins <joao.m.martins@oracle.com>
To: Vasant Hegde <vasant.hegde@amd.com>
Cc: suravee.suthikulpanit@amd.com, iommu@lists.linux.dev, joro@8bytes.org
Subject: Re: [PATCH 2/2] iommu/amd: Handle PPR log overflow
Date: Tue, 20 Jun 2023 15:53:51 +0100 [thread overview]
Message-ID: <590897b2-7b50-545b-1b5e-651bd0589df3@oracle.com> (raw)
In-Reply-To: <20230609101746.6412-3-vasant.hegde@amd.com>
On 09/06/2023 11:17, Vasant Hegde wrote:
> Some ATS-capable peripherals can issue requests to the processor to service
> peripheral page requests using PCIe PRI (the Page Request Interface). IOMMU
> supports PRI using PPR log buffer. IOMMU writes PRI request to PPR log
> buffer and sends PPR interrupt to host. When there is no space in the
> PPR log buffer (PPR log overflow) it will set PprOverflow bit in 'MMIO
> Offset 2020h IOMMU Status Register'. When this happens PPR log needs to be
> restarted as specified in IOMMU spec [1] section 2.6.2.
>
> When handling the event it just resumes the PPR log without resizing
> (similar to the way event and GA log overflow is handled).
>
> Failing to handle PPR overflow means device may not work properly as
> IOMMU stops processing new PPR events from device.
>
> [1] https://www.amd.com/system/files/TechDocs/48882_3.07_PUB.pdf
>
> Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
> ---
> drivers/iommu/amd/amd_iommu.h | 1 +
> drivers/iommu/amd/amd_iommu_types.h | 2 ++
> drivers/iommu/amd/init.c | 11 +++++++++++
> drivers/iommu/amd/iommu.c | 9 ++++++++-
> 4 files changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/amd/amd_iommu.h b/drivers/iommu/amd/amd_iommu.h
> index 317d5c26c614..156f57b4f78c 100644
> --- a/drivers/iommu/amd/amd_iommu.h
> +++ b/drivers/iommu/amd/amd_iommu.h
> @@ -16,6 +16,7 @@ irqreturn_t amd_iommu_int_handler(int irq, void *data);
> void amd_iommu_apply_erratum_63(struct amd_iommu *iommu, u16 devid);
> void amd_iommu_restart_event_logging(struct amd_iommu *iommu);
> void amd_iommu_restart_ga_log(struct amd_iommu *iommu);
> +void amd_iommu_restart_ppr_log(struct amd_iommu *iommu);
> void amd_iommu_set_rlookup_table(struct amd_iommu *iommu, u16 devid);
>
> #ifdef CONFIG_AMD_IOMMU_DEBUGFS
> diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h
> index 318b84cf47f6..a993e1bdb70b 100644
> --- a/drivers/iommu/amd/amd_iommu_types.h
> +++ b/drivers/iommu/amd/amd_iommu_types.h
> @@ -124,7 +124,9 @@
> #define MMIO_STATUS_EVT_INT_MASK BIT(1)
> #define MMIO_STATUS_COM_WAIT_INT_MASK BIT(2)
> #define MMIO_STATUS_EVT_RUN_MASK BIT(3)
> +#define MMIO_STATUS_PPR_OVERFLOW_MASK BIT(5)
> #define MMIO_STATUS_PPR_INT_MASK BIT(6)
> +#define MMIO_STATUS_PPR_RUN_MASK BIT(7)
> #define MMIO_STATUS_GALOG_RUN_MASK BIT(8)
> #define MMIO_STATUS_GALOG_OVERFLOW_MASK BIT(9)
> #define MMIO_STATUS_GALOG_INT_MASK BIT(10)
> diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
> index 3c21e9333899..9908cd4f1c31 100644
> --- a/drivers/iommu/amd/init.c
> +++ b/drivers/iommu/amd/init.c
> @@ -795,6 +795,17 @@ void amd_iommu_restart_ga_log(struct amd_iommu *iommu)
> MMIO_STATUS_GALOG_OVERFLOW_MASK);
> }
>
> +/*
> + * This function restarts ppr logging in case the IOMMU experienced
> + * PPR log overflow.
> + */
> +void amd_iommu_restart_ppr_log(struct amd_iommu *iommu)
> +{
> + amd_iommu_restart_log(iommu, "PPR", CONTROL_PPRINT_EN,
> + CONTROL_PPRLOG_EN, MMIO_STATUS_PPR_RUN_MASK,
> + MMIO_STATUS_PPR_OVERFLOW_MASK);
> +}
> +
> /*
> * This function resets the command buffer if the IOMMU stopped fetching
> * commands from it.
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index a29548d98b6a..3c179d548ecd 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -844,6 +844,7 @@ amd_iommu_set_pci_msi_domain(struct device *dev, struct amd_iommu *iommu) { }
> #define AMD_IOMMU_INT_MASK \
> (MMIO_STATUS_EVT_OVERFLOW_MASK | \
> MMIO_STATUS_EVT_INT_MASK | \
> + MMIO_STATUS_PPR_OVERFLOW_MASK | \
> MMIO_STATUS_PPR_INT_MASK | \
> MMIO_STATUS_GALOG_OVERFLOW_MASK | \
> MMIO_STATUS_GALOG_INT_MASK)
> @@ -863,11 +864,17 @@ irqreturn_t amd_iommu_int_thread(int irq, void *data)
> iommu_poll_events(iommu);
> }
>
> - if (status & MMIO_STATUS_PPR_INT_MASK) {
> + if (status & (MMIO_STATUS_PPR_INT_MASK |
> + MMIO_STATUS_PPR_OVERFLOW_MASK)) {
> pr_devel("Processing IOMMU PPR Log\n");
> iommu_poll_ppr_log(iommu);
> }
>
> + if (status & MMIO_STATUS_PPR_OVERFLOW_MASK) {
> + pr_info_ratelimited("IOMMU PPR log overflow\n");
> + amd_iommu_restart_ppr_log(iommu);
> + }
> +
> #ifdef CONFIG_IRQ_REMAP
> if (status & (MMIO_STATUS_GALOG_INT_MASK |
> MMIO_STATUS_GALOG_OVERFLOW_MASK)) {
prev parent reply other threads:[~2023-06-20 14:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-09 10:17 [PATCH 0/2] iommu/amd: Add PPR overflow support Vasant Hegde
2023-06-09 10:17 ` [PATCH 1/2] iommu/amd: Generalize log overflow handling Vasant Hegde
2023-06-13 20:22 ` Jerry Snitselaar
2023-06-20 14:51 ` Joao Martins
2023-06-20 16:01 ` Vasant Hegde
2023-06-09 10:17 ` [PATCH 2/2] iommu/amd: Handle PPR log overflow Vasant Hegde
2023-06-13 20:29 ` Jerry Snitselaar
2023-06-14 7:28 ` Vasant Hegde
2023-06-20 14:53 ` Joao Martins [this message]
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=590897b2-7b50-545b-1b5e-651bd0589df3@oracle.com \
--to=joao.m.martins@oracle.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.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 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).