From patchwork Thu Dec 7 18:03:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13483737 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="i+Zgt48l" Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2087.outbound.protection.outlook.com [40.107.220.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBDF2170E; Thu, 7 Dec 2023 10:03:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LBSorxlVFpp4iiqPmDIEqBJ4YiZYj/sfJzsKOiF5/VjjHzBjZd7x6bhjzMSOAkAS0GCq+y8vIdbw2D6Wv8eB14L9diXul6I3Grzu+zzigPaNhVRyE1HMjA1KyJZLmEpwFYlBny+qSwfVQMIP3e1lAgjvnOLYrcWtERnBc4Qe67hRFhlDtz6GHkr68IeFERkkwe8LlgKfqeErWEzqbQSH2oWKXxnpjsUNHvERYqlhUcvZEbc8lXdCzy4ML02LXlqiXoSIrjEcnpgN0vg23KIQOq4ogSj5if3zuaps5mOPVC3fPHgWhy4qlLE0yOIcX1e76assfd6Py4Re4c/4gA0Jtw== 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=5zCTfF4sVYNlXnYLelIPf8oD6pJL97HFVRMxWc0iXZU=; b=FcxFWy7wpRdudP7vWxV4dcBbs5RSSmWsaYC4e5n1PPShKYNkiXsP+IbK76c4tfWVOZc9IPjDu2cVlM4/3DPkGNMz4wIop0F1UEZBBoOOOE2TC+3uKv0tPK60cBp39JWpFl5n/tScQCAAPkLqjwVWOauossHoRkoBhZRYVyTspq2gc/5ncE/IhRY9po6LqM0ijry+/GnVzfHrb/GlB0J5IESQr+xxzUcZdfiqAYX3U+5TK/S8GygEzGPHFZmyPaVo8zUPrzdoRjzZcbxLAAupm8khLzdGtRlM8zVIhRwoEx6jD1xZZx7jxud6lYYlmXKDZ6ds4KoxWWkvLj3bZJpQBQ== 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=5zCTfF4sVYNlXnYLelIPf8oD6pJL97HFVRMxWc0iXZU=; b=i+Zgt48l+bFtdScy7j1k6j0obuS0nnVPfVyjkK7FGmetuR1Nuc6JoAFSXIdSX+ViEyvwYdEOB3PmQtzj0uLp/b09ICYJ67k1UeaVZuzpY2NU4XthgyAzETu8xpzqf/mwrFkiD6SYPMasIP2hJQ576zKDe5aVcoSw37ZMW+no6+nr3bXNfIcx/2kedEuWQnAG8qKD6eb2jK0o3j7ztrBFJESz6w/+digKwvkshe5yTa5pcFj6EnswAJ4GykrqW+Zuc61CRqdsaZOhNejgjXuLj+ZYdJj/y802tobCP9E6pnVOmtz5QagcC2/nYKf8xVATjvFiWhB02G9oVY6JJOoe5w== 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 CH3PR12MB7667.namprd12.prod.outlook.com (2603:10b6:610:14f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25; Thu, 7 Dec 2023 18:03:17 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::60d4:c1e3:e1aa:8f93]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::60d4:c1e3:e1aa:8f93%4]) with mapi id 15.20.7046.038; Thu, 7 Dec 2023 18:03:17 +0000 From: Jason Gunthorpe To: David Airlie , Alyssa Rosenzweig , Albert Ou , asahi@lists.linux.dev, Catalin Marinas , Danilo Krummrich , Daniel Vetter , Dexuan Cui , devicetree@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, David Woodhouse , Frank Rowand , Haiyang Zhang , iommu@lists.linux.dev, Jon Hunter , Joerg Roedel , Karol Herbst , Krzysztof Kozlowski , "K. Y. Srinivasan" , Laxman Dewangan , 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 , Lyude Paul , Marek Szyprowski , nouveau@lists.freedesktop.org, Palmer Dabbelt , Paul Walmsley , "Rafael J. Wysocki" , Rob Herring , Robin Murphy , Suravee Suthikulpanit , Sven Peter , Thomas Bogendoerfer , Vineet Gupta , Vinod Koul , Wei Liu , Will Deacon Cc: Lu Baolu , Christoph Hellwig , Jerry Snitselaar , Hector Martin , Moritz Fischer , Moritz Fischer , patches@lists.linux.dev, "Rafael J. Wysocki" , Rob Herring , Thierry Reding , Thierry Reding Subject: [PATCH v2 6/7] acpi: Do not return struct iommu_ops from acpi_iommu_configure_id() Date: Thu, 7 Dec 2023 14:03:13 -0400 Message-ID: <6-v2-16e4def25ebb+820-iommu_fwspec_p1_jgg@nvidia.com> In-Reply-To: <0-v2-16e4def25ebb+820-iommu_fwspec_p1_jgg@nvidia.com> References: X-ClientProxiedBy: BL1P221CA0025.NAMP221.PROD.OUTLOOK.COM (2603:10b6:208:2c5::13) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|CH3PR12MB7667:EE_ X-MS-Office365-Filtering-Correlation-Id: 94f60b06-8b83-4788-5937-08dbf74ec920 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: 6pjzyakgO6WZSkr+3aQ01y5dJ/yHRr0D72iug9y5Z3l6xhxccxNqDXerZanhpWhQEGZwHpVRp6mEMe5G7tHFpWUMr10zhou1uJ4b9c+0zf9WOxHIrX5qqnywMTHbqu2lCQgCXAqyKvJu5vXtzlFFaLxtJgR1C6GzdfyRNSKbpwdg8iKFGpxPTnz5PrQsZS+RaHuOcVSN+WtHq/wBEY5CgljFHUqgmwDU3P9inQvlyFlqfgzrTJkKSHWB/8tsTcZNw0Jy8dBD9NQNf0RnikeODKXzuKeRYXdmFSh73QOjufZTpiuYPNhl7MrRsZJ1M9iYbQnUKVDml0K+wlBMd9//ZqPKYH7zGKbFv9pFkioOOsE8k03a6s/11xyVJ0nBcCZu3sLrZZROoz4zYop1J5hPQ5XRXtaavxI40O882l36OTRQZCFJ0B8fwJppG2GXwGtqprQk8HJmDBlBiXu5z0Lr0fB2K+VfAmtJVZxxEqh4eUEu/b2IzAlz2qcGeHpOk7q9zL22weJSP0Y7ezEeQ67A0m0NknY+9IOkrOnA0QrEMlPHRvw+ClqB5DB6ybpfCjWC8VEm5MWx6PqWkKxiYvsKiaMZrX4ykIxqYBdBuuG1hzyhv9YwC7Pi4288JnIKmr4+ 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)(39860400002)(366004)(376002)(346002)(136003)(396003)(230922051799003)(186009)(1800799012)(451199024)(64100799003)(7366002)(7416002)(2906002)(7406005)(5660300002)(41300700001)(86362001)(8676002)(4326008)(8936002)(36756003)(316002)(66946007)(66556008)(66476007)(54906003)(110136005)(921008)(38100700002)(6486002)(478600001)(107886003)(83380400001)(6666004)(6506007)(26005)(6512007)(2616005)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eLqj4kaGAHzd5LAMIZQ/hZPM88A2h5zXgC28I+ZkNCbo7s5gQh8jQRwbU2tPfe+ksUKz/TreBKAHf05cc8MmomeW11snYIdlPhYwxJg1bwrOciZeXZ5FP+mjWc8U76jXZ3+QckW6oda7CrxZ/WKIcjwrlHrpoq2+xCOsH0kKhWKv3grAjHM7Kvv/vglQHm9HUbnt0UPJk3vt0sz8SlMGyBdNOdP3IyMwGv0PlYSCOV+jOvzuOfNkdyrS9kiT07T1AJjIvMyXKwapp4vTz7A1RqkBF/pQFvFWQTMBtG0tJ+9ANJt8r2RBxV+KIzgHuKhT83k/sbKcJmq4z8W71vmQAgffOdgYrXxbk1IutQn8/ROrhtL+7mhUEvHcZmbGukfIC0ME+Mnya+ljHWGWxu0p+DABx1MIdSgXvZwIY+h4pTKjuY5tyJ5Vkp0xBhaYulqEsYoxNlrkLbXIZ5kaBND13q997mxYNFPuQKAbHztOa6XMTsUXzmOs7P21Fg+Uokgoa61lGjwDWPK9IAP5sfpW2SKz0Ll+80zl1FcQjoPDk02nTZ+DzBkvJFcwnJWhTFK5Jl61+iaYA7Ymwc/fiAdxNgeHAhIIY2fO6W5KeduOPY4Z3paKcXKVIqRSMVnlFlDtMN47TRhuRohj9E3ma5jSMvc4VVwbAAOvqvpYgk27JtvZi8XqU0sldstMJeFMrt9KvBlD0Tas5luyQZy/2OiSqNa4FqDrYsOjKNT1FY8Ou3xec5sf1A6+53Z3H19s/IS78hg49PHe+T+La2yACaKlh44G0ROlsYCCd0lcTxNHABGBMv1Euxvk+DBwpRoYwz4FpgkMujqf2A1pu0XSW5yuEgnMHkU5UrlE6cgyAyvc2yikvqqFJrsHRhFxCKHCtKsdPP9khEemR2MOydu1f+huddRYF5JZMf6ZjG2XKeXfquimERvxRYyT4/PsQkz7bmgph4A3U5jeTEJ+SJ1tWB0h95SfEp8j9s8iswe8QwlY6cVUa1q+2y9ZVxqTH55TGVMpW3/AHTYdlV4ChXn0K95xAvjC19L+EkbimJBj8QFrFXjzstFY6sKv2wEL2I2rdk7QimDbu68JJ7hkGLfwRJ4ePl+JTjt+h+meQHSaDdWPL9/0XR9lkXG6M6zuoqVh58DhY/vFHQhI8B2RMYa+ht6gLI+UeWDRw04JRpOLXorkVNI6clwWRdHGSGHzDhVgY0+JDjnfAO7+MeBki8LeznhCGmI6Dk2xxSalPwuMf21gCQ+2BSNl4NsD+z1o3Unai20O3FQhlbvNQRfqmCpk+OtXIQaGXTyHewjx+94wwq1mIMp45nKQIf6B8qK3QLDQA+GjDCj6aSAaxeZVwCcE06L28h6PLaIl5AnrNB0G38gkWGJHXcA4dLquVaJTlwHSJT/QgGmvJVLOYEgiTfWfH1rR+IoA5MHzxZurCYSyfZ+M2zFaUF665EJpUQFUS0wjwtETJdWKOJ9DdSAHrRRg/rBv4UI03H4/hyJZKq1Z+/O3QbBM9MIBX1da4BwBi+gHhapwewtizo3FvvW7FX+N2/cILDIuQ8RLJAzjQxyEfzNMfW2GnHP3mv0GLZZgHGUnHSLr X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94f60b06-8b83-4788-5937-08dbf74ec920 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2023 18:03:15.8580 (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: KreLPiS/tPu0PoY6hT4BaJs/2pHwl0AEbI48HLrDnJmtcTYizNJqe6V1LMlgUydH X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7667 Nothing needs this pointer. Return a normal error code with the usual IOMMU semantic that ENODEV means 'there is no IOMMU driver'. Acked-by: Rafael J. Wysocki Reviewed-by: Jerry Snitselaar Reviewed-by: Lu Baolu Reviewed-by: Moritz Fischer Tested-by: Hector Martin Signed-off-by: Jason Gunthorpe --- drivers/acpi/scan.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 444a0b3c72f2d8..340ba720c72129 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; @@ -1577,7 +1576,7 @@ static const struct iommu_ops *acpi_iommu_configure_id(struct device *dev, ops = acpi_iommu_fwspec_ops(dev); if (ops) { mutex_unlock(&iommu_probe_device_lock); - return ops; + return 0; } err = iort_iommu_configure_id(dev, id_in); @@ -1594,12 +1593,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 */ @@ -1611,10 +1612,9 @@ int acpi_iommu_fwspec_init(struct device *dev, u32 id, return -ENODEV; } -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) { - return NULL; + return -ENODEV; } #endif /* !CONFIG_IOMMU_API */ @@ -1628,7 +1628,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); @@ -1637,10 +1637,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_id() + */ + arch_setup_dma_ops(dev, 0, U64_MAX, attr == DEV_DMA_COHERENT); return 0;