From patchwork Wed Sep 14 05:12:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 12975605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 50E32ECAAD3 for ; Wed, 14 Sep 2022 05:14:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=d1qT8KsI9YWfiThof/ygg6QxTRbLHPFT4//HxFooZQ0=; b=4ArQWaC/QKhbXc XYRzPR9NdASbIHS+Yi79nhqU8l+BmXtCUN869Db3HdvgYWSyRw3jaWJNjqKxw5SCuHiU5zY0hB1je NUh+jT2E54JpTZL8eoGpq5W5Za95uI8NQQLp0VUnTHJAc+W17awOAcIcNF8nzXUJh/9cZUcCRsZjg /qXpOUNOSdqklCIug/3rGDxv7YThf+6rvXRwLn1Af+ygq1MzlVnslHEEEw6EviqYLaade9Nu2Jlzf THxcnuKjdKA7ebQFFwJ6z+ATDmYAtPS8znXF6hl8dNIlTmCgKzuJmOkVZklQ5T6i6s4R7tKej/lAz hAMs9E6ZlTnwOQsYzbRQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYKi7-007KMq-P4; Wed, 14 Sep 2022 05:13:19 +0000 Received: from mail-co1nam11on2085.outbound.protection.outlook.com ([40.107.220.85] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYKhp-007JxR-ON; Wed, 14 Sep 2022 05:13:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b8Q0KynZ9pHWl/oLZhuWD58YLjB/snepBQltfvm2meDfPwN2HGSw0h5+rQYd7DYFnHaZCkWOTaOsqfDB7rnb8hR3TBEZic7EhLopu9tsB6qDsS15vtnVTj9jSSCVJ+cEX5/hi32L1biGfMu4hAZh/JKTfvt4rkOVzUdNVk+cpxAayipq1N0CyXKoMRsWFO4+lIFUy1FHKsDCZeBS9jeD+dT6k+8fkVqC2ez2mgHnLf/dLBHX2zOKUiHB7wzAjW+52y2H1djK6Vg6syxa80191al0YzRYySPz8CllsweYxsIT3C3U2lIkpzjifodlM/gF3VGaHhJ80XdG5mJtQsHghA== 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=lE2hIVWhfjTEpuJG/EQ8E2pJreIJ8xNfuDZvqSktzVE=; b=gbijA2r/nMzHrDZd1nQe4Vw+BRPqN4BQf56Y7UJWE2iUY8SWWYcGsPtLzFwYfdh0O9PJ/b1yJitO0e/RgjYfyXHVhkjpjLV/3eKNsOxcrA6He5v7nQIqqF/yzg03xMQRLe+Z1Ezf7hbaI4FcR4s4+melX2ygM2N3Vm4idLtcjt+/amypvZ8Sf5Z8BvAzzoeqwjMvfaxdxIaLTmUkWjZw+HpoLzQzJCmOwj/G6TCp5MMqahZjAus/wrD6o2V+CJhMa1VEHO/99baGuKPddbna63ODechdcQeHtBerdSnHXeCDgG0PDmrhu1GVJyI7OlkrUjOZsy1Wnhfn1G3IKe2GjA== 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=lE2hIVWhfjTEpuJG/EQ8E2pJreIJ8xNfuDZvqSktzVE=; b=USTaB1YS4GHcOa657piQfpo38jnF3iiexlmFHoyguqAadOBHndClATA8uc2Y1BSPfHwbYvUIj6hxEriuhlUCDxmPLsOLqMYjuNPLDQdpowi2ERzlBTqMG1GfpPh+nJp2jmEza3IawHBBenh4WkgN5sHtbMycNCxW+lo+GfKCvZzCoRLvXxJy/qKWmJFc5xwKlDvPKsUrFGuVdq5TcqTX05dh9THKEw+is0r1PNqdlxJgK0QOmKO760RSDRNHORtnI3yx1t3RNlIRzp9AM5pYE85lTJXksefnhzHKgz3k7HM8Gh+KJ6iS+Q25Kf0G8Pyx1NmEIv6bT18v+9OF9eqEfg== Received: from BN9PR03CA0085.namprd03.prod.outlook.com (2603:10b6:408:fc::30) by DM6PR12MB4107.namprd12.prod.outlook.com (2603:10b6:5:218::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.16; Wed, 14 Sep 2022 05:12:53 +0000 Received: from BN8NAM11FT056.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fc:cafe::db) by BN9PR03CA0085.outlook.office365.com (2603:10b6:408:fc::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.19 via Frontend Transport; Wed, 14 Sep 2022 05:12:52 +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 BN8NAM11FT056.mail.protection.outlook.com (10.13.177.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.12 via Frontend Transport; Wed, 14 Sep 2022 05:12:52 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) 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; Tue, 13 Sep 2022 22:12:36 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 13 Sep 2022 22:12:36 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 13 Sep 2022 22:12:36 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.29 via Frontend Transport; Tue, 13 Sep 2022 22:12:34 -0700 From: Nicolin Chen To: , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 00/13] iommu: Define EINVAL as device/domain incompatibility Date: Tue, 13 Sep 2022 22:12:33 -0700 Message-ID: <20220914051234.10006-1-nicolinc@nvidia.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT056:EE_|DM6PR12MB4107:EE_ X-MS-Office365-Filtering-Correlation-Id: 00f1f3f1-e9cb-4b66-4acf-08da960fc6ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MDMHSQINcu3hNZLEpSHEggsqvNOC55e9B2UkrRtNaSyH77qfHoJuNzZq8rrrF/B8vwsC4h6IxScLBQJ4bG7PzAg9G26rYBWCUYioecklgh6G6crJtqaM6pVtsL/vpAu+4Vxjg/7Zl9WCr72+0YhANWEeRiFp5fnV/xCrjGb0fra1kCz4SLSeR9Zbu0HfhzQQo0YjA4kHhuGSVGA8s5+17ukvwwJrxJqumSokg8iBzocLAnTK7Hdp3zTWjKiLRFQ6AN7oIKhXIN9k3N7KNuMJ/JzSv2B9KRrSO1LhrKLHcazq/JkOkQPncb5663xzHOMC8zl/MKIyTnz9U3Q6UYo27QIGhtBhsfsc7spMNIkfKgodk/+8fE3kxks06DxrX7VXNuLj2Uvq54OG3tWDAsrvsvescg3Gszf+lH6KhnDyJ6Jv8m7P1nAfnqRN/p5SPN6LpXO/Ap8Yl4FO+MvrFkHs3HghvZu/NCStcmw9jUOp1Wt27n+qzFmqXTUYyACK4JbUbi1nZq+tyZiLl7Hjhn0B1cHU8uf2wije5dC1ghnFxexb6joETnw5jSdcFDVtb8eBnji7WpeeRMK6TXCoNaZmTC2n/rlnzhFn7lCyvZISuhjAsK4BAI8p9XIsVykMCZDHGFfQSyy+QeTabV/hWp9j3STNzNrM6sliPgJWmKiOpYh9xkUtXEMgrQCwNxuZDEEwMmSU2SMu/lpyk/+/6gN0rHMvejoEVg1fyxAvU5ViG489uu2KgGZYYr4zDJZb+TeKE5LEfNIQ7vuhmg18xOFIVbX1F3WADLGC3bPrOgTlt41+mhc+Wu6wVoJTyhhdU7hfsBW1VDNVaSr3iR+hiprSG7nwaWLv255HND3OUkeo0I6mL3cV6SsolClQRoek9FW6Fvma3NgMlIGQgf/yzCkfUMgjPgeHYsnVWy2wHrDVHIhV3Sy4+0jQwU4Q8OCLL9TY7zHitjGKxWhW+LY5Fy4RkA== 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)(376002)(396003)(39860400002)(136003)(346002)(451199015)(36840700001)(46966006)(40470700004)(82310400005)(8676002)(36860700001)(40460700003)(316002)(70586007)(47076005)(36756003)(478600001)(336012)(8936002)(41300700001)(2616005)(1076003)(110136005)(54906003)(966005)(40480700001)(7696005)(2906002)(26005)(82740400003)(4326008)(921005)(426003)(7416002)(7406005)(5660300002)(186003)(86362001)(83380400001)(70206006)(356005)(7636003)(2101003)(83996005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2022 05:12:52.6105 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 00f1f3f1-e9cb-4b66-4acf-08da960fc6ab 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: BN8NAM11FT056.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4107 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220913_221301_840915_E2EF5765 X-CRM114-Status: GOOD ( 14.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kevin.tian@intel.com, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, yangyingliang@huawei.com, jon@solid-run.com, iommu@lists.linux.dev, shameerali.kolothum.thodi@huawei.com, jonathanh@nvidia.com, linux-rockchip@lists.infradead.org, christophe.jaillet@wanadoo.fr, linux-arm-kernel@lists.infradead.org, thunder.leizhen@huawei.com, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, tglx@linutronix.de, virtualization@lists.linux-foundation.org, quic_jjohnson@quicinc.com, yong.wu@mediatek.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This series is to replace the previous EMEDIUMTYPE patch in a VFIO series: https://lore.kernel.org/kvm/Yxnt9uQTmbqul5lf@8bytes.org/ The purpose is to regulate all existing ->attach_dev callback functions to use EINVAL exclusively for an incompatibility error between a device and a domain. This allows VFIO and IOMMUFD to detect such a soft error, and then try a different domain with the same device. Among all the patches, the first two are preparatory changes. And then one patch to update kdocs and the rest of them are per-driver changes. Although it might be ideal to merge the previous VFIO series together with this series, given the number of new changes, the review in the IOMMU list might need a couple of rounds to finalize. Also, considering that v6.0 is at rc5 now, perhaps we could merge this IOMMU series and the VFIO one in different cycles to avoid merge conflicts. If there's less concern for it, I can respin the finalized version with VFIO to merge into the VFIO tree. This series is also available on Github: https://github.com/nicolinc/iommufd/commits/iommu_attach_dev-v2 Changelog v2: * Fixed kdocs format * Grouped with the virtio patch from Jean (with a small change) * Separated previous ENODEV and EINVAL changes to per-driver ones * Redone some of the changes to have explicit return values in the ->attach_dev() callback functions or their direct sub-functions. v1: https://lore.kernel.org/linux-iommu/20220913082448.31120-1-nicolinc@nvidia.com/ Thanks! Jean-Philippe Brucker (1): iommu/virtio: Constrain return value of ->attach_dev() Nicolin Chen (12): iommu/msm: Add missing __disable_clocks calls iommu/amd: Drop unnecessary checks in amd_iommu_attach_device() iommu: Add return value rules to attach_dev op iommu/arm: Constrain return value of ->attach_dev() iommu/fsl: Constrain return value of ->attach_dev() iommu/intel: Constrain return value of ->attach_dev() iommu/ipmmu-vmsa: Constrain return value of ->attach_dev() iommu/mtk: Constrain return value of ->attach_dev() iommu/omap: Constrain return value of ->attach_dev() iommu/rockchip: Constrain return value of ->attach_dev() iommu/sprd: Constrain return value of ->attach_dev() iommu/tegra: Constrain return value of ->attach_dev() drivers/iommu/amd/iommu.c | 12 ++---------- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 13 ++----------- drivers/iommu/arm/arm-smmu/arm-smmu.c | 7 ++----- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 9 ++------- drivers/iommu/fsl_pamu_domain.c | 12 ++++++++---- drivers/iommu/intel/iommu.c | 17 +++++++++-------- drivers/iommu/ipmmu-vmsa.c | 10 +++++----- drivers/iommu/msm_iommu.c | 2 ++ drivers/iommu/mtk_iommu.c | 9 +++++++-- drivers/iommu/omap-iommu.c | 7 ++++--- drivers/iommu/rockchip-iommu.c | 4 +++- drivers/iommu/sprd-iommu.c | 4 +--- drivers/iommu/tegra-gart.c | 2 +- drivers/iommu/tegra-smmu.c | 6 ++++-- drivers/iommu/virtio-iommu.c | 13 ++++++------- include/linux/iommu.h | 11 +++++++++++ 16 files changed, 69 insertions(+), 69 deletions(-)