From patchwork Fri Nov 3 16:44:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13444848 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 C003FC001DB for ; Fri, 3 Nov 2023 17:46:01 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=M2RgxXxhysLarHUS9m4gDhu/EYoQSrEjq2rVK1SNijY=; b=zDZ6JmGeti4xiB yKyhCFH/BkO0m0l6LitJ619425ZIxt07hva9FPRKcm58XBY7XqoX0FAJ0Lg+F4hdiVm9z4qxANWds 5NiM1z7SVrnQW2Irx3XAXo49ve0isbSWWGmmX42RvPLMW8qey689GGlRgH9FHZu8MhF528YuvW67P ciu9k49rHtQrhNPEUtfAikdEogYBUI4c8l/fWe2My+VvMmx3NRQR17woN3rBk9TdwxkpBnVPLnTdg i7ThnSbSvvTFKYm0xnn5BT8U5bIISkjSNn+4BloA46KroVb2bC9PkPeSpclHnsycY78wn5EeGy6+x u7RekLe2MNJUU0tJSfhw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qyyEv-00Bu1j-2r; Fri, 03 Nov 2023 17:45:49 +0000 Received: from mail-dm6nam11on2061e.outbound.protection.outlook.com ([2a01:111:f400:7eaa::61e] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qyxIJ-00Bo7Y-23; Fri, 03 Nov 2023 16:45:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FVhdUo+X2FOY4JuB0/pPr+RnbDrEodMCH5QyfzY5NngA2YJXLBMx53Et7VcUGEcAzzsWFM0AWB2lXipYY7zL5+EO4VesaeepJOBeyYgdeMapIDoW987qOHrNjbSHpu8nPWgKnRTk3xC2SB4L6p9fxVTRUguS2A0fqq/tVJoinNva7l61GwT0HiWv3XBHtTCsS1vXAOSh3h07smWBWnqfGj1j6+jUV3ltn/7jqf4NTU32N83i66u4WdEMj8SrMnFw5xf7QHnesdqOLIvMxZT4z1VMGCJMOsGSdIpN+QWsFTopuPVl1DnFMCFGhSazJrAiGkLCO2H34MMTZwtvdGuRMg== 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=TnoHHRW9wGxYObBfp5jd7EnMs8P21nURFY58S4rMak0=; b=ca+YpUMoFGwmuSQLnpZBZWTy+JOkfEKOEVFngkR/yUo7hWLNu9//6HugxRq4ZWPJBsvNGmOdDvakptciRQOHKI7QdzFdH/sfJ9CQiL8Zz6QzipAH/7R7TCzbj8d/qb8iHbWA58bSy8YfuDTJtPt2S7YeYofw+FEWxvnNoqRW03K2/2jgTuVASLS3mnOM68z307MAKBQ3SyQXgXF7zKZ82ndNSgwdPY9UqEeqLUtcUn7zZRcRIrxx56hfdOPfncVt3IFWtMjl+d06bLIsULjTXVkbm5GLdYUU81rULtqiX2FnU4Yc5B9tX8iOy9g8w9+6y26N64CtPtB42PMKxtj5eg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=TnoHHRW9wGxYObBfp5jd7EnMs8P21nURFY58S4rMak0=; b=fgFyWL8y2hhCPeRB3QREn7Uuh58Tup5xgeQRI1TAYRqqv27pTe6tsY9S0SQc6yUa9BaQx/XIqo1k/RqOXF/+AkiFVPZSVYIfhdiDmnAsXFx81d2o5yCRGZ0a6eBPF8TqDMWkjqXR2m5GKehRjHva6egvNif895ewxMZ6rSmeSQfsj7TE67zwPQbQwJpD09DbSQNXLviiCBZOyBkzQYCuZ+O8TQXBG9Sf3FLGLauPLm7JLs5qbxF3RcIC+lmPk9MDwu0ZT6HhksJLU25EywFBSKDUL633ZfBYTLUkaZNI3Rm/tw2w8VkA7P4ibnDKT0koO6zlJrj0B+YCKVpj2JMqEA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by PH0PR12MB7886.namprd12.prod.outlook.com (2603:10b6:510:26e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.21; Fri, 3 Nov 2023 16:45:04 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::b53a:1092:9be2:cfb9]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::b53a:1092:9be2:cfb9%4]) with mapi id 15.20.6933.027; Fri, 3 Nov 2023 16:45:03 +0000 From: Jason Gunthorpe To: acpica-devel@lists.linuxfoundation.org, Alyssa Rosenzweig , Albert Ou , asahi@lists.linux.dev, Lu Baolu , Catalin Marinas , Dexuan Cui , devicetree@vger.kernel.org, David Woodhouse , Frank Rowand , Hanjun Guo , Haiyang Zhang , Christoph Hellwig , iommu@lists.linux.dev, Jean-Philippe Brucker , Jonathan Hunter , Joerg Roedel , "K. Y. Srinivasan" , Len Brown , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, linux-snps-arc@lists.infradead.org, linux-tegra@vger.kernel.org, Russell King , Lorenzo Pieralisi , Marek Szyprowski , Hector Martin , Palmer Dabbelt , Paul Walmsley , "Rafael J. Wysocki" , Robert Moore , Rob Herring , Robin Murphy , Sudeep Holla , Suravee Suthikulpanit , Sven Peter , Thierry Reding , Thomas Bogendoerfer , Krishna Reddy , Vineet Gupta , virtualization@lists.linux-foundation.org, Wei Liu , Will Deacon Cc: Zhenhua Huang Subject: [PATCH RFC 04/17] acpi: Do not return struct iommu_ops from acpi_iommu_configure_id() Date: Fri, 3 Nov 2023 13:44:49 -0300 Message-ID: <4-v1-5f734af130a3+34f-iommu_fwspec_jgg@nvidia.com> In-Reply-To: <0-v1-5f734af130a3+34f-iommu_fwspec_jgg@nvidia.com> References: X-ClientProxiedBy: BL1PR13CA0187.namprd13.prod.outlook.com (2603:10b6:208:2be::12) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|PH0PR12MB7886:EE_ X-MS-Office365-Filtering-Correlation-Id: 1627afca-1b54-4898-fd7d-08dbdc8c3a5f X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e8QoeXLZ+gfP4uFtmX3rpPUEYK4aMVIdFjtnwwv0LWasitsNVPChD1F9rU/qPrILSEBI/JTl0bv2y1Ku/SEFHMeYFVcPDN0VA57mc7mu2IXzyNJ9IjFMi6hz6K5vSqgsQI63k/uxDgv5oV4thGFeoE9vWdEJOdvOzBLnG9nqdPW02mrBkVnlrYsnrwkDf7Qn1NTeFC4t+pufkZn6DAKMvxs7OBbKk+qPvbX9cgTbGt2CooJarL9xFVUCdS+DKjx48iwEAtH32MFE/MCUBmQMh5yP88yVMgVRksdBLG+IRvKr6PA9E5Kon25B+5AgNwWxyVHLg5ZJaNU+cBKNfXqYKbzrLsl64ZpbA/O1Cv7cI+p+i6w05nDql+O2pAG/Tv2NLEFMQ6zusfiVWzxKF7zpjpSTMg3aFGxAJxoc8SqE2z6DZDmX/TuVeqknPF8vdaPiHp5/Q2AN5v1c7bQSvZ0KoUWtD2cIY7FSvpIyLrpkezAIsJe/b8T0qTkCrbL9Xl9ssF8UQXO753GZJfbQu3qZ7L+jgVOGVgDqbSJL1DghBrZHuK1jOGXuS9GbOp93P+rfAyFwXF09zqWh3SzQ0KfP3CHFQNeoWCOumMxnn7ky+Ltoodco4JUJZh7bdEQPR/Ey X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(39860400002)(396003)(366004)(376002)(136003)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(6486002)(66946007)(8936002)(66556008)(8676002)(316002)(4326008)(2906002)(7416002)(7406005)(110136005)(66476007)(5660300002)(6666004)(478600001)(6512007)(2616005)(41300700001)(26005)(6506007)(83380400001)(921008)(38100700002)(86362001)(36756003)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: c4NbtvSKUiJgXewWvYQXS49KGtlWWqE19IrJwNq2h1/ubx5Nb6Jq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ppD5TCbrPASTvbbOB0qW7Iq/YAbreoh5BfEwRldWW1RDpmQuD44HKa6yxz1R3UUgo1mck18m0+dOffYWmq/SjZ5/SJiL/u8LTpAjaMvV/opyASuVSqHe+Xqjr4Ycnm+7m7P/aqG4VyDT2TDKTM3lLFyigI8r3G9EInd/7+K0EHvrwLv1C18aq0UsXkrj78YhlUQ9zAppp9+qnp1EY78NZ7siNgfLCOL0flhStbRGjNLf78/rhI5jM2ZU+dVAQnqJsPoY/UWWhg706NsT87h/G0ODZrH+1yw+OpCX/bkSLj2JJpBjscEiP/5P8JBkm7oimomhU4WGtCXP/DCuG65Q1lnABgaIoDRxXTx2ba6AINPfHDGwewBnvvBYktd/z71X+Nc2+uUTxNyOMLaz/iY/YqLdCmiz3Yzh7w/RyFPbYDVZXkfTDcNK7sq3Knk3lSukf97Fkwms= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1627afca-1b54-4898-fd7d-08dbdc8c3a5f X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2023 16:45:03.7907 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oat6TdcMlK87Pn45YNa4lzlJQZrxRi5y3G9EyZQgkWg2oJ8Vzvos60W26a9ynCo/ X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7886 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_094515_679776_95F537E7 X-CRM114-Status: GOOD ( 14.24 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Nothing needs this pointer. Return a normal error code with the usual IOMMU semantic that ENODEV means 'there is no IOMMU driver'. Signed-off-by: Jason Gunthorpe Acked-by: Rafael J. Wysocki --- drivers/acpi/scan.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index a6891ad0ceee2c..fbabde001a23a2 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1562,8 +1562,7 @@ static inline const struct iommu_ops *acpi_iommu_fwspec_ops(struct device *dev) return fwspec ? fwspec->ops : NULL; } -static const struct iommu_ops *acpi_iommu_configure_id(struct device *dev, - const u32 *id_in) +static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in) { int err; const struct iommu_ops *ops; @@ -1574,7 +1573,7 @@ static const struct iommu_ops *acpi_iommu_configure_id(struct device *dev, */ ops = acpi_iommu_fwspec_ops(dev); if (ops) - return ops; + return 0; err = iort_iommu_configure_id(dev, id_in); if (err && err != -EPROBE_DEFER) @@ -1589,12 +1588,14 @@ static const struct iommu_ops *acpi_iommu_configure_id(struct device *dev, /* Ignore all other errors apart from EPROBE_DEFER */ if (err == -EPROBE_DEFER) { - return ERR_PTR(err); + return err; } else if (err) { dev_dbg(dev, "Adding to IOMMU failed: %d\n", err); - return NULL; + return -ENODEV; } - return acpi_iommu_fwspec_ops(dev); + if (!acpi_iommu_fwspec_ops(dev)) + return -ENODEV; + return 0; } #else /* !CONFIG_IOMMU_API */ @@ -1623,7 +1624,7 @@ static const struct iommu_ops *acpi_iommu_configure_id(struct device *dev, int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr, const u32 *input_id) { - const struct iommu_ops *iommu; + int ret; if (attr == DEV_DMA_NOT_SUPPORTED) { set_dma_ops(dev, &dma_dummy_ops); @@ -1632,10 +1633,15 @@ int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr, acpi_arch_dma_setup(dev); - iommu = acpi_iommu_configure_id(dev, input_id); - if (PTR_ERR(iommu) == -EPROBE_DEFER) + ret = acpi_iommu_configure_id(dev, input_id); + if (ret == -EPROBE_DEFER) return -EPROBE_DEFER; + /* + * Historically this routine doesn't fail driver probing due to errors + * in acpi_iommu_configure() + */ + arch_setup_dma_ops(dev, 0, U64_MAX, attr == DEV_DMA_COHERENT); return 0;