Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp5038050rwb; Wed, 21 Sep 2022 02:12:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6oeiWCLdKQ5v/MZy0tB0df16UA4+vyI1FPgmIKdei71vNMNzaBekTU3Zgl2+WNkIjUi0O3 X-Received: by 2002:a17:907:96a1:b0:773:c47a:ae35 with SMTP id hd33-20020a17090796a100b00773c47aae35mr20402772ejc.368.1663751531494; Wed, 21 Sep 2022 02:12:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1663751531; cv=pass; d=google.com; s=arc-20160816; b=LsOYVJmcwcLnfKhQP3EffxDXy7p75UGvoBzyJw+PsvJQCTnUV97xwoYM5C7YT6weEt X7WNb3KQnKto7mNtLQk5oWwhLt2DCumtuz8NiG39KfEfYqo2934mENKk8hGyhgtgbP54 mI1maTBqojot2MDAFTUmIES/FwwSDxAvVwVczqiF+Xhg9KHipEHTlDJUE8E24AbMVbNU uKw010SRAdu8/aF8LCg8hyxCk5mHPn/a2cvrPAAVB23t8EvTP0JhBS2BXgkkFpMoPD0Z rhxMtI58Ub4KZxryAtwF53+xmRtLncdzzi3yydvYxq1N1SLP7ORz6KobCDi/Gt8dtjrC GpEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=++uoO3LawFXul3U/9kiNYyLITdupVpuzSrdELGwdTdw=; b=VPwgNPQsYlbx1y0rvVJpTIGgm+Xen4A1tNkvDiPsFMGaJov9SnmGdg818OEVCisM1I 5IjzCwj7hUaSY/I4UUXS0eHD0D1vlt/2GWXZPKPAnvNjV2TIwUQrGq7fM9OS0cz/kh+H 58V8VAjZRGXvu5YfOthYYOXZlVb1HxYme4lX6IAyQDJ/cokkYxhAUgvjrIO8FqqROC/i PiDeB71e5ShyIQSnfzk+WhawlLSitRTY45Qv/QL9CWtRLQDu693aHM73h82rDBf5T1Ul 2HNeM0heFydk95Zkt6s473reFjXyn3+P222JMX8B4kVFMg6TzY+6VE4eQEcKY9e24083 TUAg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=nf6kJ0AC; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 21-20020a170906319500b00780a882d32esi1786012ejy.459.2022.09.21.02.11.45; Wed, 21 Sep 2022 02:12:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=nf6kJ0AC; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231308AbiIUIY2 (ORCPT + 99 others); Wed, 21 Sep 2022 04:24:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231526AbiIUIXy (ORCPT ); Wed, 21 Sep 2022 04:23:54 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2082.outbound.protection.outlook.com [40.107.237.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5457A883ED; Wed, 21 Sep 2022 01:23:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dpb6mvB1iMGzd8g8dohRZy+NqAiihxMuCS2xBpoWDM42oHfZbJJkxaBIV6ofwRuG2V2Z2o1ltHqIpT/oLyU/I624SVnfFzzCDdOuMMhsHqvbD/zjx3Uyj6Beq73D2TVFGetdj0pm5Pb9bk1i2CREjN6CDbsOpUIxtlgwhe4eCNz01oRbIPtBpdho0qsEeI5Bx7m+J0RCaNwB0Pndy40dNn8s+2JpyfhJ2HRq7BqAQIXCTNMoIsAsdwo1LdKPo36hn+5oLcskkYBnpM/LwC2rnJylnlrHPcJ5ig/mmZqvfnUcKgrGNsu37QyccUijCZScbuv4tIs52dXYO5Ec5wy5IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=++uoO3LawFXul3U/9kiNYyLITdupVpuzSrdELGwdTdw=; b=MkNSaeYeWA79zpjV2JBJm4q4lK30FrHkujnqR9PwRF7FIPFWoFQbSfsia7QzF3zwyGGMU+XJTNo7p8pVZbzaIv0KJGnUvOhRlcqG9hkXxwG/sqIdQMh/iLKyrpJlQzjsEajdrNiEFKNqf/37I4rQRt+LrGRFVRaZAzWnNRPcs9wf1H/gZKPuhs8tsrd3up7pX4FyHQPeIkK0aryH3LO7pcwfH5qTMLNI+tmWvnQSHX3Ny89tx8GXbTuCuvy6cjjOKFFu+PQQnGJ4kXfCWQcHvnvVvaU2YM87Jw5KfNlp7DWDD+wgzftskBao4kxcn3vT2EMe/flsETOB6PsGAYChJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=8bytes.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=++uoO3LawFXul3U/9kiNYyLITdupVpuzSrdELGwdTdw=; b=nf6kJ0ACGRu+PyHKoxvndDnmBh8f+0huwPr9dAHLzs1HflMg6wWlbRDOhQfPsnebfypw38Xh3XygPA8G8GQwvP66dy1MJ232nH+SSa27/y+wGTL1gZESq6hGhhAN9IJrXpMAJpALPz5zArHCDaC7oyd8/Ejyo8t+CnJLdN+VNjg3d4DmxMe+jCXkLjttZrDgtiLpMKvh+zjQx2U2PM1rH0qdIsSXvB1Oaz7tKYDRVYUfK1W5qW4WHbMUd9JYMDsNhgiL3q7ICUK/ca9CcjSy9ZcN8CK+kgF4VujoCJE9+wR51HOSUDr1/Al+3naqOCLUCGa1Zm8OnPmJBCMj5onCAg== Received: from DS7PR05CA0038.namprd05.prod.outlook.com (2603:10b6:8:2f::23) by SN7PR12MB7156.namprd12.prod.outlook.com (2603:10b6:806:2a7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14; Wed, 21 Sep 2022 08:23:51 +0000 Received: from DS1PEPF0000B075.namprd05.prod.outlook.com (2603:10b6:8:2f:cafe::c) by DS7PR05CA0038.outlook.office365.com (2603:10b6:8:2f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.6 via Frontend Transport; Wed, 21 Sep 2022 08:23:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS1PEPF0000B075.mail.protection.outlook.com (10.167.17.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.11 via Frontend Transport; Wed, 21 Sep 2022 08:23:51 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 21 Sep 2022 01:23:43 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Wed, 21 Sep 2022 01:23:43 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Wed, 21 Sep 2022 01:23:42 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.29 via Frontend Transport; Wed, 21 Sep 2022 01:23:40 -0700 From: Nicolin Chen To: , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 5/6] iommu: Use EINVAL for incompatible device/domain in ->attach_dev Date: Wed, 21 Sep 2022 01:23:39 -0700 Message-ID: <4469b88b4460fc230b8c394f806c134e627aa5bd.1663744983.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000B075:EE_|SN7PR12MB7156:EE_ X-MS-Office365-Filtering-Correlation-Id: bf644beb-214b-47f1-829f-08da9baa9d59 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8fDJj9PvhhCdGRkkGOg5mZ7ZS1SoiRf5gp19Uz79DMqoOo6k/p7iUK7+PB+K/Dnzn65HqCC6r0Opfiu2Z0FVh/txTIV5cmgTcbXkkJX8wxiag2NQZ/oa2awcw2xdt46WnvgWkfA3DiI/wKc8xHTMUcWWPleHkjCf6uCwroeEKS3OEdCl4vE5Gi1s7v2uwBO5j8WDfaRydi+ClH+S/RV5+QtZerDtTZU0dWCm9DL5jH+4ZN/v/sBpK8yBJHPc1BdPu4DXlyTbGxp1rFWoA+c8DMwISp0Qre9lZCib6v04lNlwPnooFgdAJ77Z1M4ntnMm9jMRCm70sOVXd9BgsoNgI6fAYipNvVlxdJlXWWdmX6vQ2sHs9OemvUeekvizfJcKS2tRxnXp5JTWJ/6QQKf3fKxJ1SOoDPK0Jjg32v3Ykg4wfRYL802uOYIyThDqZsqzwHm1FbhjQ7rMxD9d0VDgrU55OO1Tw6FqYSq+DyRJO+XNBRcomflvNBqdzDiUiEGOoo3sfA+1Fq+NgYe4LhfGZAgNYxePOcoKaF8/tEbgdXcPN2OAQ3QrOnl4vUMVt2eLZlvYc499KmG9j7tHTFX4aziFtvzB+uiNyNa1Y4vvgb+5ZjHKZ/KbFhnAurJSgQ8ZM+oRN9BLSDBS+0ynEWWarKSoZZ5bd+J+7Y4i4TwRlouOUlbX9Y+1XNen+BHQIZ7MRhF7mXRqavqJu6GnC22bLk6N86LjXeqMdFfS93wYk0k4IPT+eUIvKHwOfLUcp3tX6/2+EURC9AzwHSO5Yavsf5E2ylHxqhJW5etS8PA3ADo7upKouCgumCaRvSy+WXDsLiAAlutB9+qI1O39TWiyQAbSPxMxrtI4O9CiSxS4DPg= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(136003)(376002)(396003)(346002)(451199015)(40470700004)(46966006)(36840700001)(478600001)(2616005)(426003)(186003)(26005)(336012)(47076005)(7696005)(2906002)(86362001)(54906003)(40460700003)(8936002)(7406005)(7416002)(5660300002)(82310400005)(40480700001)(110136005)(36756003)(70206006)(8676002)(316002)(41300700001)(4326008)(70586007)(82740400003)(356005)(83380400001)(7636003)(921005)(36860700001)(83996005)(2101003)(473944003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2022 08:23:51.1418 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bf644beb-214b-47f1-829f-08da9baa9d59 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000B075.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7156 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Following the new rules in include/linux/iommu.h kdocs, update all drivers ->attach_dev callback functions to return EINVAL in the failure paths that are related to domain incompatibility. Also, drop adjacent error prints to prevent a kernel log spam. Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 11 +---------- drivers/iommu/arm/arm-smmu/arm-smmu.c | 3 --- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 7 +------ drivers/iommu/intel/iommu.c | 10 +++------- drivers/iommu/ipmmu-vmsa.c | 2 -- drivers/iommu/omap-iommu.c | 2 +- drivers/iommu/sprd-iommu.c | 4 +--- drivers/iommu/tegra-gart.c | 2 +- drivers/iommu/virtio-iommu.c | 3 +-- 9 files changed, 9 insertions(+), 35 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index d32b02336411..f96f8aad8280 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2429,23 +2429,14 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) goto out_unlock; } } else if (smmu_domain->smmu != smmu) { - dev_err(dev, - "cannot attach to SMMU %s (upstream of %s)\n", - dev_name(smmu_domain->smmu->dev), - dev_name(smmu->dev)); - ret = -ENXIO; + ret = -EINVAL; goto out_unlock; } else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1 && master->ssid_bits != smmu_domain->s1_cfg.s1cdmax) { - dev_err(dev, - "cannot attach to incompatible domain (%u SSID bits != %u)\n", - smmu_domain->s1_cfg.s1cdmax, master->ssid_bits); ret = -EINVAL; goto out_unlock; } else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1 && smmu_domain->stall_enabled != master->stall_enabled) { - dev_err(dev, "cannot attach to stall-%s domain\n", - smmu_domain->stall_enabled ? "enabled" : "disabled"); ret = -EINVAL; goto out_unlock; } diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index dfa82df00342..dbd12da31707 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -1167,9 +1167,6 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) * different SMMUs. */ if (smmu_domain->smmu != smmu) { - dev_err(dev, - "cannot attach to SMMU %s whilst already attached to domain on SMMU %s\n", - dev_name(smmu_domain->smmu->dev), dev_name(smmu->dev)); ret = -EINVAL; goto rpm_put; } diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c index 17235116d3bb..37c5ddc212c1 100644 --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c @@ -381,13 +381,8 @@ static int qcom_iommu_attach_dev(struct iommu_domain *domain, struct device *dev * Sanity check the domain. We don't support domains across * different IOMMUs. */ - if (qcom_domain->iommu != qcom_iommu) { - dev_err(dev, "cannot attach to IOMMU %s while already " - "attached to domain on IOMMU %s\n", - dev_name(qcom_domain->iommu->dev), - dev_name(qcom_iommu->dev)); + if (qcom_domain->iommu != qcom_iommu) return -EINVAL; - } return 0; } diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 1f2cd43cf9bc..51ef42b1bd4e 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4158,19 +4158,15 @@ static int prepare_domain_attach_device(struct iommu_domain *domain, return -ENODEV; if (dmar_domain->force_snooping && !ecap_sc_support(iommu->ecap)) - return -EOPNOTSUPP; + return -EINVAL; /* check if this iommu agaw is sufficient for max mapped address */ addr_width = agaw_to_width(iommu->agaw); if (addr_width > cap_mgaw(iommu->cap)) addr_width = cap_mgaw(iommu->cap); - if (dmar_domain->max_addr > (1LL << addr_width)) { - dev_err(dev, "%s: iommu width (%d) is not " - "sufficient for the mapped address (%llx)\n", - __func__, addr_width, dmar_domain->max_addr); - return -EFAULT; - } + if (dmar_domain->max_addr > (1LL << addr_width)) + return -EINVAL; dmar_domain->gaw = addr_width; /* diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index 1d42084d0276..f5217a4cb9b3 100644 --- a/drivers/iommu/ipmmu-vmsa.c +++ b/drivers/iommu/ipmmu-vmsa.c @@ -628,8 +628,6 @@ static int ipmmu_attach_device(struct iommu_domain *io_domain, * Something is wrong, we can't attach two devices using * different IOMMUs to the same domain. */ - dev_err(dev, "Can't attach IPMMU %s to domain on IPMMU %s\n", - dev_name(mmu->dev), dev_name(domain->mmu->dev)); ret = -EINVAL; } else dev_info(dev, "Reusing IPMMU context %u\n", domain->context_id); diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index 447e40d55918..be12f49140c7 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -1472,7 +1472,7 @@ omap_iommu_attach_dev(struct iommu_domain *domain, struct device *dev) /* only a single client device can be attached to a domain */ if (omap_domain->dev) { dev_err(dev, "iommu domain is already attached\n"); - ret = -EBUSY; + ret = -EINVAL; goto out; } diff --git a/drivers/iommu/sprd-iommu.c b/drivers/iommu/sprd-iommu.c index 511959c8a14d..945576039c9e 100644 --- a/drivers/iommu/sprd-iommu.c +++ b/drivers/iommu/sprd-iommu.c @@ -237,10 +237,8 @@ static int sprd_iommu_attach_device(struct iommu_domain *domain, struct sprd_iommu_domain *dom = to_sprd_domain(domain); size_t pgt_size = sprd_iommu_pgt_size(domain); - if (dom->sdev) { - pr_err("There's already a device attached to this domain.\n"); + if (dom->sdev) return -EINVAL; - } dom->pgt_va = dma_alloc_coherent(sdev->dev, pgt_size, &dom->pgt_pa, GFP_KERNEL); if (!dom->pgt_va) diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c index e5ca3cf1a949..ed53279d1106 100644 --- a/drivers/iommu/tegra-gart.c +++ b/drivers/iommu/tegra-gart.c @@ -112,7 +112,7 @@ static int gart_iommu_attach_dev(struct iommu_domain *domain, spin_lock(&gart->dom_lock); if (gart->active_domain && gart->active_domain != domain) { - ret = -EBUSY; + ret = -EINVAL; } else if (dev_iommu_priv_get(dev) != domain) { dev_iommu_priv_set(dev, domain); gart->active_domain = domain; diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index 4c652773fd6c..87128266b6e3 100644 --- a/drivers/iommu/virtio-iommu.c +++ b/drivers/iommu/virtio-iommu.c @@ -733,8 +733,7 @@ static int viommu_attach_dev(struct iommu_domain *domain, struct device *dev) */ ret = viommu_domain_finalise(vdev, domain); } else if (vdomain->viommu != vdev->viommu) { - dev_err(dev, "cannot attach to foreign vIOMMU\n"); - ret = -EXDEV; + ret = -EINVAL; } mutex_unlock(&vdomain->mutex); -- 2.17.1