iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Nicolin Chen <nicolinc@nvidia.com>
To: <yong.wu@mediatek.com>, <joro@8bytes.org>, <will@kernel.org>,
	<robin.murphy@arm.com>, <matthias.bgg@gmail.com>,
	<jean-philippe@linaro.org>
Cc: <jgg@nvidia.com>, <kevin.tian@intel.com>, <iommu@lists.linux.dev>,
	<linux-mediatek@lists.infradead.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>,
	<virtualization@lists.linux-foundation.org>
Subject: [PATCH v3 6/6] iommu: Propagate ret for a potential soft failure EINVAL
Date: Thu, 15 Sep 2022 00:58:45 -0700	[thread overview]
Message-ID: <cd613152e5175b5ffac643ee017b1d800e766d99.1663227492.git.nicolinc@nvidia.com> (raw)
In-Reply-To: <cover.1663227492.git.nicolinc@nvidia.com>

Following the new rules in include/linux/iommu.h kdocs, EINVAL now can be
used to indicate that domain and device are incompatible by a caller that
treats it as a soft failure and tries attaching to another domain.

Either mtk_iommu or virtio driver has a place that returns a hard failure
instead of the return value from the function call, where an incompatible
errno EINVAL could potentially occur.

Propagate the real return value to not miss a potential soft failure.

Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
 drivers/iommu/mtk_iommu.c    | 2 +-
 drivers/iommu/virtio-iommu.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index be1a7d1cc630..c30dc8f81778 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -666,7 +666,7 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain,
 		ret = mtk_iommu_domain_finalise(dom, frstdata, region_id);
 		if (ret) {
 			mutex_unlock(&dom->mutex);
-			return -ENODEV;
+			return ret;
 		}
 		dom->bank = &data->bank[bankid];
 	}
diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c
index caca0a638c4d..f1ecc5589626 100644
--- a/drivers/iommu/virtio-iommu.c
+++ b/drivers/iommu/virtio-iommu.c
@@ -696,7 +696,7 @@ static int viommu_domain_finalise(struct viommu_endpoint *vdev,
 		if (ret) {
 			ida_free(&viommu->domain_ids, vdomain->id);
 			vdomain->viommu = NULL;
-			return -EOPNOTSUPP;
+			return ret;
 		}
 	}
 
-- 
2.17.1


  parent reply	other threads:[~2022-09-15  7:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-15  7:53 [PATCH v3 0/6] Define EINVAL as device/domain incompatibility Nicolin Chen
2022-09-15  7:53 ` [PATCH v3 3/6] iommu: Add return value rules to attach_dev op and APIs Nicolin Chen
2022-09-20  6:24   ` Tian, Kevin
2022-09-20 19:26     ` Nicolin Chen
2022-09-15  7:53 ` [PATCH v3 5/6] iommu: Use EINVAL for incompatible device/domain in ->attach_dev Nicolin Chen
2022-09-20  6:38   ` Tian, Kevin
2022-09-20 18:06     ` Jason Gunthorpe
2022-09-21  8:14       ` Tian, Kevin
2022-09-15  7:56 ` [PATCH v3 1/6] iommu/msm: Add missing __disable_clocks calls Nicolin Chen
2022-09-20  6:15   ` Tian, Kevin
2022-09-20 18:46     ` Nicolin Chen
2022-09-21  7:27       ` Tian, Kevin
2022-09-15  7:58 ` [PATCH v3 2/6] iommu/amd: Drop unnecessary checks in amd_iommu_attach_device() Nicolin Chen
2022-09-15  7:58 ` [PATCH v3 4/6] iommu: Regulate EINVAL in ->attach_dev callback functions Nicolin Chen
2022-09-20  6:29   ` Tian, Kevin
2022-09-20 16:08     ` Nicolin Chen
2022-09-15  7:58 ` Nicolin Chen [this message]
2022-09-20  6:50   ` [PATCH v3 6/6] iommu: Propagate ret for a potential soft failure EINVAL Tian, Kevin
2022-09-20 20:39     ` Nicolin Chen

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=cd613152e5175b5ffac643ee017b1d800e766d99.1663227492.git.nicolinc@nvidia.com \
    --to=nicolinc@nvidia.com \
    --cc=iommu@lists.linux.dev \
    --cc=jean-philippe@linaro.org \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=robin.murphy@arm.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=will@kernel.org \
    --cc=yong.wu@mediatek.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).