From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Vasant Hegde <vasant.hegde@amd.com>,
Matt Fagnani <matt.fagnani@bell.net>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Joerg Roedel <jroedel@suse.de>, Sasha Levin <sashal@kernel.org>,
joro@8bytes.org, will@kernel.org, iommu@lists.linux.dev
Subject: [PATCH AUTOSEL 5.4 01/20] iommu/amd: Fix error handling for pdev_pri_ats_enable()
Date: Fri, 3 Mar 2023 16:47:47 -0500 [thread overview]
Message-ID: <20230303214806.1453287-1-sashal@kernel.org> (raw)
From: Vasant Hegde <vasant.hegde@amd.com>
[ Upstream commit 080920e52148b4fbbf9360d5345fdcd7846e4841 ]
Current code throws kernel warning if it fails to enable pasid/pri [1].
Do not call pci_disable_[pasid/pri] if pci_enable_[pasid/pri] failed.
[1] https://lore.kernel.org/linux-iommu/15d0f9ff-2a56-b3e9-5b45-e6b23300ae3b@leemhuis.info/
Reported-by: Matt Fagnani <matt.fagnani@bell.net>
Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
Reviewed-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Link: https://lore.kernel.org/r/20230111121503.5931-1-vasant.hegde@amd.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/iommu/amd_iommu.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index b79309928d786..a51e78caa9c8e 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -2120,17 +2120,17 @@ static int pdev_iommuv2_enable(struct pci_dev *pdev)
/* Only allow access to user-accessible pages */
ret = pci_enable_pasid(pdev, 0);
if (ret)
- goto out_err;
+ return ret;
/* First reset the PRI state of the device */
ret = pci_reset_pri(pdev);
if (ret)
- goto out_err;
+ goto out_err_pasid;
/* Enable PRI */
ret = pci_enable_pri(pdev, reqs);
if (ret)
- goto out_err;
+ goto out_err_pasid;
if (reset_enable) {
ret = pri_reset_while_enabled(pdev);
@@ -2140,12 +2140,14 @@ static int pdev_iommuv2_enable(struct pci_dev *pdev)
ret = pci_enable_ats(pdev, PAGE_SHIFT);
if (ret)
- goto out_err;
+ goto out_err_pri;
return 0;
-out_err:
+out_err_pri:
pci_disable_pri(pdev);
+
+out_err_pasid:
pci_disable_pasid(pdev);
return ret;
--
2.39.2
next reply other threads:[~2023-03-03 21:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-03 21:47 Sasha Levin [this message]
2023-03-03 21:47 ` [PATCH AUTOSEL 5.4 02/20] media: uvcvideo: Handle cameras with invalid descriptors Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.4 03/20] media: uvcvideo: Handle errors from calls to usb_string Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.4 04/20] media: uvcvideo: Quirk for autosuspend in Logitech B910 and C910 Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.4 05/20] media: uvcvideo: Silence memcpy() run-time false positive warnings Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.4 06/20] staging: emxx_udc: Add checks for dma_alloc_coherent() Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.4 07/20] tty: fix out-of-bounds access in tty_driver_lookup_tty() Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.4 08/20] tty: serial: fsl_lpuart: disable the CTS when send break signal Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.4 09/20] mei: bus-fixup:upon error print return values of send and receive Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.4 10/20] parport_pc: Set up mode and ECR masks for Oxford Semiconductor devices Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.4 11/20] tools/iio/iio_utils:fix memory leak Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.4 12/20] iio: accel: mma9551_core: Prevent uninitialized variable in mma9551_read_status_word() Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.4 13/20] iio: accel: mma9551_core: Prevent uninitialized variable in mma9551_read_config_word() Sasha Levin
2023-03-03 21:48 ` [PATCH AUTOSEL 5.4 14/20] firmware: coreboot: framebuffer: Ignore reserved pixel color bits Sasha Levin
2023-03-03 21:48 ` [PATCH AUTOSEL 5.4 15/20] usb: host: xhci: mvebu: Iterate over array indexes instead of using pointer math Sasha Levin
2023-03-03 21:48 ` [PATCH AUTOSEL 5.4 16/20] USB: ene_usb6250: Allocate enough memory for full object Sasha Levin
2023-03-03 21:48 ` [PATCH AUTOSEL 5.4 17/20] usb: uvc: Enumerate valid values for color matching Sasha Levin
2023-03-03 21:48 ` [PATCH AUTOSEL 5.4 18/20] kernel/fail_function: fix memory leak with using debugfs_lookup() Sasha Levin
2023-03-03 21:48 ` [PATCH AUTOSEL 5.4 19/20] PCI: Add ACS quirk for Wangxun NICs Sasha Levin
2023-03-03 21:48 ` [PATCH AUTOSEL 5.4 20/20] phy: rockchip-typec: Fix unsigned comparison with less than zero Sasha Levin
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=20230303214806.1453287-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=jroedel@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.fagnani@bell.net \
--cc=stable@vger.kernel.org \
--cc=suravee.suthikulpanit@amd.com \
--cc=vasant.hegde@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;
as well as URLs for NNTP newsgroup(s).