From patchwork Wed Jan 18 18:00:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13106773 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B35AC678D6 for ; Wed, 18 Jan 2023 18:01:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231137AbjARSBQ (ORCPT ); Wed, 18 Jan 2023 13:01:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230250AbjARSAx (ORCPT ); Wed, 18 Jan 2023 13:00:53 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2062.outbound.protection.outlook.com [40.107.243.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06FF25999B; Wed, 18 Jan 2023 10:00:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XFjWMK9udofnRi0AnAqRtywz5K8lZXQ0q6Nf1LxnJ16Zs0a84cBlgRledY5xDIKCnskFtJYkcv7k+xibKGSmOGplL+Qys2XmBqtjNqyL5NK+USv5QbnH1p/0cbOSjLWuBR0810qpXeb3ApGZWPASPf+w6IF/yzxeZUfUlC3udT+IRU+59Nq9HYrKry2KRNADjpndN3ircywBQ3GNulRIc9hX21+VGniXH7aBP0s7cVqcWE+woolvR3IQrbo20m5ZYwvg/znPycl4+w9cUR/KzhpajAju6hluVSre0p0ngyodVXkFYcgWlRoDGnEStGCbqgrpZc6m0rY4pEOyW+XPFg== 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=8hpilVa2qjlCphllcpBP3r1l8+EaRmX8eQgl6ry1GCQ=; b=BzL6mZAJ+PxWr8iqJ7nnQv/1CzKhk87qiUk4000mOLVvWVXguTNPSAcxdyiWXbwIPqYfjPV7TwRtiO8F+6ANalj81pzqH9b9R3xjDwT20qTj0HnxXsrWMsS8l8YNs+vRGaic5ISEN43AUJZWt83RQSEqxplwaVQoor/WFttP1zDsYrMVjxio2lc+VfkpKyaw8pxXCiWpf35sMCJeny+RsaGsQT+4pWoxzf95iYpPho13hEzBCt1fJGVe6rm7Vdrtp8tlW4zBkYp/7GAdsquY1I0oTz9cOi0mKcPUvD2bcxAJFg0hqhLU1eUA8B91dvXkxWeeUDvPqsb6lTnA/XQ7Ew== 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=8hpilVa2qjlCphllcpBP3r1l8+EaRmX8eQgl6ry1GCQ=; b=rr32UewlZDIykiBe9q/ePW25oJVrqxi2CzRVby4gT6uZ8v7Kxa1l5mEQQwAUx7UObhGy3y1N5/F/g2L+b9xGsJT/p4w5snRlbfpx5cO7U5C5BRGWS08iJz+nxetTHyZqM4uwxBEqTeYGUOrBoBysMMaVXVRXVMyTsbDro7negtyqPg3SuXsP1kVu0ISVyb7CeQSiD2LTXp0lqhj0iYfoM9lvLFrTm5xSGgnl/uZ4J3k72I+jW8xD1NY9yx1HNPwGFxvhSr/Wb71gxQGT68zge3MEWANukXOBb6xZFhx/OrV8EYZEgTdKKrI8K56mnA4RWsduh6du97oKtoNMluHJ+Q== 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 IA1PR12MB7614.namprd12.prod.outlook.com (2603:10b6:208:429::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Wed, 18 Jan 2023 18:00:47 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.6002.013; Wed, 18 Jan 2023 18:00:47 +0000 From: Jason Gunthorpe To: Lu Baolu , Joerg Roedel , Kevin Tian , Matthew Rosato , Robin Murphy Cc: Alex Williamson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, Christian Borntraeger , dri-devel@lists.freedesktop.org, iommu@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org, linux-rdma@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-tegra@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, nouveau@lists.freedesktop.org, Niklas Schnelle , virtualization@lists.linux-foundation.org Subject: [PATCH v2 01/10] iommu: Add a gfp parameter to iommu_map() Date: Wed, 18 Jan 2023 14:00:35 -0400 Message-Id: <1-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> In-Reply-To: <0-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> References: X-ClientProxiedBy: BLAPR03CA0167.namprd03.prod.outlook.com (2603:10b6:208:32f::23) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|IA1PR12MB7614:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c51f368-152e-497e-f27f-08daf97dec29 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l+S6k5toC6HbuVGa0DKRRUgoCUFRoQlIojDEB9xfd7znLg53KBcjlXq3vDw4xCdczzHKGOuufYEcCqzQjHromUJJdnpsNPEst/nvxaWz6Wc2ytKmBIfx/+T9qVHz69pnwTYAXYPiuHqQ8L6c6mUfgZWxDLMoeU/tEvBjC0F+It8yqwQELn03wFgdlwZZpzBl67Xom8YiLD5a331RaSKZcZDsq6mNzxdWLA+/RYb8rX32RntIytOtKvPrasR9aBfJLJlaFpBNRl3i/YS8HlH7oVFA3R3iYqz6P/p0BNhaiGSTkXVdNxxSd3a6uV/Y9B4Qe5/Afhmli7j6W3M07QM234XienRQ29feJIzSQ1TCG3GpfVlhgHy/QF4ulZD/gkaJ4y8qZx5yHXcd2U20Kg7xwXaDhiEVmddaiauJ11zZTQm1WKFDs31t5cYKxLINXTyFFag0b1o8tGO6DnDEHlwnjIlYNyZ5B87srhRdUIZUtbyH3MNo+fl1zH8on3P1pH+LQO34O0fse4FkbHCtcX3NSkLpnERM3f2xsfYVXKkH0mTADkACmgc2N7XIqLFH7KSTQXKxlgwSBzrXm1IEOpJTsVkgxk6zxp+xvRUsUbjHymSIcKuK4Ksi5TGH0ntibvf89zBxPhjffANesZGcA3piQVPZiWss4TGbQgPD5Ty4W3Cvh0ebILw9f0hoCkAbvye/ 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:(13230022)(4636009)(346002)(39860400002)(396003)(136003)(366004)(376002)(451199015)(6506007)(186003)(26005)(478600001)(6512007)(6486002)(6666004)(54906003)(316002)(110136005)(4326008)(66946007)(66556008)(8676002)(66476007)(36756003)(2616005)(41300700001)(8936002)(83380400001)(30864003)(2906002)(7416002)(5660300002)(38100700002)(86362001)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +t9VJelzZ5bDxkojvRyRdj+eBlHibjHStMJhI+0mSZqQHSzhkBfa+olitL7Dzdtaq6hY8HL1sVfCEo4sF/juSu3Bq4o6+BYqIEefUsToBCrNNW0jwrWH/DeffI7LqODDrAsOUcBGcjmhloJMxifhDtTcVk0ayKRiPvuj/0RgTzMETe8+LtG9WeyO9TgRXIfuya2uCDzMojZbrX8DjRHUgxW2XYC7pjbblcoxY/EG4TV2iGIt7w4K0fEYLdm+N+ImN/N/9PfVssPMaQ1eqHK1fJ4qdYgfMJW2nG0XcSM4JYKcy4yjKbjgUnlRdJOfBorK2BMgOOYT8S5NFcKZ5wo0bygkJdsK7q3VJj1ND4rJBpQt1JIVh3NnXW455Vqy1PK3KPoz/9IledbWNOv+Ej1pQu8Wo2aTUmVmyfyXEjhA4IqSeVqbZ33vF/J3+IYv9OmqIr33O1mZEA9ZnpfjiuOBHxFgBnorZZLShri/X+pPMbv0/UMifKyWBW15HtnTQChr8T59mxJ9ZL2E6xaMvPEoNW3f8GT+Fomh1AvdwSr37DbgArrujARDVbSfPgtzOg1jdTtYOMjBpvCfFUp5xu7u7DU7ICsn9wTo66phZDUs1E8HLa0mKnvp6ZyYikeI8m6nEKE9lk/QkTfVkRR2UXypOv3ylYGSPps2MObGo6gitTa1aNWp/usO1A/pD7Hb50vde/w6TqaA2FpIOBrbR0uAz2IocHiKy+uiKIHyigICL9nzTIbTLcGwQaMzq8qIQMyvTzDEfe/pq81zTtwbHdYgjtKLb5V5p/mBcHpiMMvV+x6Wh69H+YuMBleA4gVUGhhyJ1aSGCV5/E5nnwZ2Oz5cOSG8kD0B1G9YfnXvZOJDmFcGtzhBiNo5kNGzltEwK+I2RdvJphlkHxOM3U48bJ+GJfnFhO2fVZyo0CzQEQRqXX6B6CWiQr9tVYITp0p3X2sBFAUzhXyXxxLK39MvCAnou8TYhG8ZQqt3eGOoa6n3cgu78no3gDygSNGJAIBatj5Ho3oO+BvhAjy7mN6Ifbn8tYfL/7daBI1zliBCDYV4fy6NHK0oj+n+O7aafxkst56mmXHD/IRKQNWgx20O5eI5w3N2Cwva6lEvzv7P2gGIYtlbWqOX406tyq6DTefgOEnv8lStg969C7IbM6lqiOetI+XfVXSXiqcNZfJn/UmcssZ3DNi3jvgfwzMe/uBXE4cmjPVxFBqqA1+0NFpL77/5IWGW/sJmjKD6YVWajOTZ6Uc+477KhmwcHuZka2sN2f+kiDDR7nAbwjRws9HXfLuQPaezh98gTJxFe2v2xIwO3XL14c/OMkbutBkXRu4K1O+slXsD2ps35pHHoeQtbiocMtacot+TDie2W25ysLiB6cgg+lmd5fXDjeGJwfVFWxXBp91J/2792QQwdvRiszVRwgDI1xZPqKXjAU0hCMmn+D+JuCYg2aqYyx9j5DOntGMap9iVixH333REf5iNW9+DAiaMalVugTuqJfHQO/Kp9OnR/CTARrudJ1cWQVrJTvOjwLPqpXuVALIFxq4Ru8KHHLcviLbx+hdulNgy1cdY/RCJoRk/uhubJtM9ed9rRbRv X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c51f368-152e-497e-f27f-08daf97dec29 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 18:00:45.7402 (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: kLJq1DAAm1BXkeBsE8kP6/QtYiyd4roNA4mlnx0OJaJr39QdtJXdeNwEnFTS0vyq X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7614 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The internal mechanisms support this, but instead of exposting the gfp to the caller it wrappers it into iommu_map() and iommu_map_atomic() Fix this instead of adding more variants for GFP_KERNEL_ACCOUNT. Signed-off-by: Jason Gunthorpe Reviewed-by: Kevin Tian --- arch/arm/mm/dma-mapping.c | 11 ++++++---- .../drm/nouveau/nvkm/subdev/instmem/gk20a.c | 3 ++- drivers/gpu/drm/tegra/drm.c | 2 +- drivers/gpu/host1x/cdma.c | 2 +- drivers/infiniband/hw/usnic/usnic_uiom.c | 4 ++-- drivers/iommu/dma-iommu.c | 2 +- drivers/iommu/iommu.c | 22 +++++++++---------- drivers/iommu/iommufd/pages.c | 6 +++-- drivers/media/platform/qcom/venus/firmware.c | 2 +- drivers/net/ipa/ipa_mem.c | 6 +++-- drivers/net/wireless/ath/ath10k/snoc.c | 2 +- drivers/net/wireless/ath/ath11k/ahb.c | 4 ++-- drivers/remoteproc/remoteproc_core.c | 5 +++-- drivers/vfio/vfio_iommu_type1.c | 9 ++++---- drivers/vhost/vdpa.c | 2 +- include/linux/iommu.h | 4 ++-- 16 files changed, 48 insertions(+), 38 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index c135f6e37a00ca..8bc01071474ab7 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -984,7 +984,8 @@ __iommu_create_mapping(struct device *dev, struct page **pages, size_t size, len = (j - i) << PAGE_SHIFT; ret = iommu_map(mapping->domain, iova, phys, len, - __dma_info_to_prot(DMA_BIDIRECTIONAL, attrs)); + __dma_info_to_prot(DMA_BIDIRECTIONAL, attrs), + GFP_KERNEL); if (ret < 0) goto fail; iova += len; @@ -1207,7 +1208,8 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, prot = __dma_info_to_prot(dir, attrs); - ret = iommu_map(mapping->domain, iova, phys, len, prot); + ret = iommu_map(mapping->domain, iova, phys, len, prot, + GFP_KERNEL); if (ret < 0) goto fail; count += len >> PAGE_SHIFT; @@ -1379,7 +1381,8 @@ static dma_addr_t arm_iommu_map_page(struct device *dev, struct page *page, prot = __dma_info_to_prot(dir, attrs); - ret = iommu_map(mapping->domain, dma_addr, page_to_phys(page), len, prot); + ret = iommu_map(mapping->domain, dma_addr, page_to_phys(page), len, + prot, GFP_KERNEL); if (ret < 0) goto fail; @@ -1443,7 +1446,7 @@ static dma_addr_t arm_iommu_map_resource(struct device *dev, prot = __dma_info_to_prot(dir, attrs) | IOMMU_MMIO; - ret = iommu_map(mapping->domain, dma_addr, addr, len, prot); + ret = iommu_map(mapping->domain, dma_addr, addr, len, prot, GFP_KERNEL); if (ret < 0) goto fail; diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c index 648ecf5a8fbc2a..a4ac94a2ab57fc 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c @@ -475,7 +475,8 @@ gk20a_instobj_ctor_iommu(struct gk20a_instmem *imem, u32 npages, u32 align, u32 offset = (r->offset + i) << imem->iommu_pgshift; ret = iommu_map(imem->domain, offset, node->dma_addrs[i], - PAGE_SIZE, IOMMU_READ | IOMMU_WRITE); + PAGE_SIZE, IOMMU_READ | IOMMU_WRITE, + GFP_KERNEL); if (ret < 0) { nvkm_error(subdev, "IOMMU mapping failure: %d\n", ret); diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 7bd2e65c2a16c5..6ca9f396e55be4 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -1057,7 +1057,7 @@ void *tegra_drm_alloc(struct tegra_drm *tegra, size_t size, dma_addr_t *dma) *dma = iova_dma_addr(&tegra->carveout.domain, alloc); err = iommu_map(tegra->domain, *dma, virt_to_phys(virt), - size, IOMMU_READ | IOMMU_WRITE); + size, IOMMU_READ | IOMMU_WRITE, GFP_KERNEL); if (err < 0) goto free_iova; diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c index 103fda055394ab..4ddfcd2138c95b 100644 --- a/drivers/gpu/host1x/cdma.c +++ b/drivers/gpu/host1x/cdma.c @@ -105,7 +105,7 @@ static int host1x_pushbuffer_init(struct push_buffer *pb) pb->dma = iova_dma_addr(&host1x->iova, alloc); err = iommu_map(host1x->domain, pb->dma, pb->phys, size, - IOMMU_READ); + IOMMU_READ, GFP_KERNEL); if (err) goto iommu_free_iova; } else { diff --git a/drivers/infiniband/hw/usnic/usnic_uiom.c b/drivers/infiniband/hw/usnic/usnic_uiom.c index c301b3be9f303d..aeeaca65ace96a 100644 --- a/drivers/infiniband/hw/usnic/usnic_uiom.c +++ b/drivers/infiniband/hw/usnic/usnic_uiom.c @@ -277,7 +277,7 @@ static int usnic_uiom_map_sorted_intervals(struct list_head *intervals, usnic_dbg("va 0x%lx pa %pa size 0x%zx flags 0x%x", va_start, &pa_start, size, flags); err = iommu_map(pd->domain, va_start, pa_start, - size, flags); + size, flags, GFP_KERNEL); if (err) { usnic_err("Failed to map va 0x%lx pa %pa size 0x%zx with err %d\n", va_start, &pa_start, size, err); @@ -294,7 +294,7 @@ static int usnic_uiom_map_sorted_intervals(struct list_head *intervals, usnic_dbg("va 0x%lx pa %pa size 0x%zx flags 0x%x\n", va_start, &pa_start, size, flags); err = iommu_map(pd->domain, va_start, pa_start, - size, flags); + size, flags, GFP_KERNEL); if (err) { usnic_err("Failed to map va 0x%lx pa %pa size 0x%zx with err %d\n", va_start, &pa_start, size, err); diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index f798c44e090337..8bdb65e7686ff9 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -1615,7 +1615,7 @@ static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev, if (!iova) goto out_free_page; - if (iommu_map(domain, iova, msi_addr, size, prot)) + if (iommu_map(domain, iova, msi_addr, size, prot, GFP_KERNEL)) goto out_free_iova; INIT_LIST_HEAD(&msi_page->list); diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 5f6a85aea501ec..7dac062b58f039 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -930,7 +930,7 @@ static int iommu_create_device_direct_mappings(struct iommu_group *group, if (map_size) { ret = iommu_map(domain, addr - map_size, addr - map_size, map_size, - entry->prot); + entry->prot, GFP_KERNEL); if (ret) goto out; map_size = 0; @@ -2360,31 +2360,31 @@ static int __iommu_map(struct iommu_domain *domain, unsigned long iova, return ret; } -static int _iommu_map(struct iommu_domain *domain, unsigned long iova, - phys_addr_t paddr, size_t size, int prot, gfp_t gfp) +int iommu_map(struct iommu_domain *domain, unsigned long iova, + phys_addr_t paddr, size_t size, int prot, gfp_t gfp) { const struct iommu_domain_ops *ops = domain->ops; int ret; + might_sleep_if(gfpflags_allow_blocking(gfp)); + + /* Discourage passing strange GFP flags */ + if (WARN_ON_ONCE(gfp & (__GFP_COMP | __GFP_DMA | __GFP_DMA32 | + __GFP_HIGHMEM))) + return -EINVAL; + ret = __iommu_map(domain, iova, paddr, size, prot, gfp); if (ret == 0 && ops->iotlb_sync_map) ops->iotlb_sync_map(domain, iova, size); return ret; } - -int iommu_map(struct iommu_domain *domain, unsigned long iova, - phys_addr_t paddr, size_t size, int prot) -{ - might_sleep(); - return _iommu_map(domain, iova, paddr, size, prot, GFP_KERNEL); -} EXPORT_SYMBOL_GPL(iommu_map); int iommu_map_atomic(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int prot) { - return _iommu_map(domain, iova, paddr, size, prot, GFP_ATOMIC); + return iommu_map(domain, iova, paddr, size, prot, GFP_ATOMIC); } EXPORT_SYMBOL_GPL(iommu_map_atomic); diff --git a/drivers/iommu/iommufd/pages.c b/drivers/iommu/iommufd/pages.c index 1e1d3509efae5e..22cc3bb0c6c55a 100644 --- a/drivers/iommu/iommufd/pages.c +++ b/drivers/iommu/iommufd/pages.c @@ -456,7 +456,8 @@ static int batch_iommu_map_small(struct iommu_domain *domain, size % PAGE_SIZE); while (size) { - rc = iommu_map(domain, iova, paddr, PAGE_SIZE, prot); + rc = iommu_map(domain, iova, paddr, PAGE_SIZE, prot, + GFP_KERNEL); if (rc) goto err_unmap; iova += PAGE_SIZE; @@ -500,7 +501,8 @@ static int batch_to_domain(struct pfn_batch *batch, struct iommu_domain *domain, else rc = iommu_map(domain, iova, PFN_PHYS(batch->pfns[cur]) + page_offset, - next_iova - iova, area->iommu_prot); + next_iova - iova, area->iommu_prot, + GFP_KERNEL); if (rc) goto err_unmap; iova = next_iova; diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/platform/qcom/venus/firmware.c index 142d4c74017c04..07d4dceb5e72c7 100644 --- a/drivers/media/platform/qcom/venus/firmware.c +++ b/drivers/media/platform/qcom/venus/firmware.c @@ -158,7 +158,7 @@ static int venus_boot_no_tz(struct venus_core *core, phys_addr_t mem_phys, core->fw.mapped_mem_size = mem_size; ret = iommu_map(iommu, VENUS_FW_START_ADDR, mem_phys, mem_size, - IOMMU_READ | IOMMU_WRITE | IOMMU_PRIV); + IOMMU_READ | IOMMU_WRITE | IOMMU_PRIV, GFP_KERNEL); if (ret) { dev_err(dev, "could not map video firmware region\n"); return ret; diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index 9ec5af323f731d..991a7d39f06661 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -466,7 +466,8 @@ static int ipa_imem_init(struct ipa *ipa, unsigned long addr, size_t size) size = PAGE_ALIGN(size + addr - phys); iova = phys; /* We just want a direct mapping */ - ret = iommu_map(domain, iova, phys, size, IOMMU_READ | IOMMU_WRITE); + ret = iommu_map(domain, iova, phys, size, IOMMU_READ | IOMMU_WRITE, + GFP_KERNEL); if (ret) return ret; @@ -574,7 +575,8 @@ static int ipa_smem_init(struct ipa *ipa, u32 item, size_t size) size = PAGE_ALIGN(size + addr - phys); iova = phys; /* We just want a direct mapping */ - ret = iommu_map(domain, iova, phys, size, IOMMU_READ | IOMMU_WRITE); + ret = iommu_map(domain, iova, phys, size, IOMMU_READ | IOMMU_WRITE, + GFP_KERNEL); if (ret) return ret; diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c index cfcb759a87deac..9a82f0336d9537 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -1639,7 +1639,7 @@ static int ath10k_fw_init(struct ath10k *ar) ret = iommu_map(iommu_dom, ar_snoc->fw.fw_start_addr, ar->msa.paddr, ar->msa.mem_size, - IOMMU_READ | IOMMU_WRITE); + IOMMU_READ | IOMMU_WRITE, GFP_KERNEL); if (ret) { ath10k_err(ar, "failed to map firmware region: %d\n", ret); goto err_iommu_detach; diff --git a/drivers/net/wireless/ath/ath11k/ahb.c b/drivers/net/wireless/ath/ath11k/ahb.c index d34a4d6325b2b4..df8fdc7067f99c 100644 --- a/drivers/net/wireless/ath/ath11k/ahb.c +++ b/drivers/net/wireless/ath/ath11k/ahb.c @@ -1021,7 +1021,7 @@ static int ath11k_ahb_fw_resources_init(struct ath11k_base *ab) ret = iommu_map(iommu_dom, ab_ahb->fw.msa_paddr, ab_ahb->fw.msa_paddr, ab_ahb->fw.msa_size, - IOMMU_READ | IOMMU_WRITE); + IOMMU_READ | IOMMU_WRITE, GFP_KERNEL); if (ret) { ath11k_err(ab, "failed to map firmware region: %d\n", ret); goto err_iommu_detach; @@ -1029,7 +1029,7 @@ static int ath11k_ahb_fw_resources_init(struct ath11k_base *ab) ret = iommu_map(iommu_dom, ab_ahb->fw.ce_paddr, ab_ahb->fw.ce_paddr, ab_ahb->fw.ce_size, - IOMMU_READ | IOMMU_WRITE); + IOMMU_READ | IOMMU_WRITE, GFP_KERNEL); if (ret) { ath11k_err(ab, "failed to map firmware CE region: %d\n", ret); goto err_iommu_unmap; diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 1cd4815a6dd197..80072b6b628358 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -643,7 +643,8 @@ static int rproc_handle_devmem(struct rproc *rproc, void *ptr, if (!mapping) return -ENOMEM; - ret = iommu_map(rproc->domain, rsc->da, rsc->pa, rsc->len, rsc->flags); + ret = iommu_map(rproc->domain, rsc->da, rsc->pa, rsc->len, rsc->flags, + GFP_KERNEL); if (ret) { dev_err(dev, "failed to map devmem: %d\n", ret); goto out; @@ -737,7 +738,7 @@ static int rproc_alloc_carveout(struct rproc *rproc, } ret = iommu_map(rproc->domain, mem->da, dma, mem->len, - mem->flags); + mem->flags, GFP_KERNEL); if (ret) { dev_err(dev, "iommu_map failed: %d\n", ret); goto free_mapping; diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 23c24fe98c00d4..e14f86a8ef5258 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -1480,7 +1480,8 @@ static int vfio_iommu_map(struct vfio_iommu *iommu, dma_addr_t iova, list_for_each_entry(d, &iommu->domain_list, next) { ret = iommu_map(d->domain, iova, (phys_addr_t)pfn << PAGE_SHIFT, - npage << PAGE_SHIFT, prot | IOMMU_CACHE); + npage << PAGE_SHIFT, prot | IOMMU_CACHE, + GFP_KERNEL); if (ret) goto unwind; @@ -1777,8 +1778,8 @@ static int vfio_iommu_replay(struct vfio_iommu *iommu, size = npage << PAGE_SHIFT; } - ret = iommu_map(domain->domain, iova, phys, - size, dma->prot | IOMMU_CACHE); + ret = iommu_map(domain->domain, iova, phys, size, + dma->prot | IOMMU_CACHE, GFP_KERNEL); if (ret) { if (!dma->iommu_mapped) { vfio_unpin_pages_remote(dma, iova, @@ -1866,7 +1867,7 @@ static void vfio_test_domain_fgsp(struct vfio_domain *domain) return; ret = iommu_map(domain->domain, 0, page_to_phys(pages), PAGE_SIZE * 2, - IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); + IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE, GFP_KERNEL); if (!ret) { size_t unmapped = iommu_unmap(domain->domain, 0, PAGE_SIZE); diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index ec32f785dfdec1..fd1536de5b1df0 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -792,7 +792,7 @@ static int vhost_vdpa_map(struct vhost_vdpa *v, struct vhost_iotlb *iotlb, r = ops->set_map(vdpa, asid, iotlb); } else { r = iommu_map(v->domain, iova, pa, size, - perm_to_iommu_flags(perm)); + perm_to_iommu_flags(perm), GFP_KERNEL); } if (r) { vhost_iotlb_del_range(iotlb, iova, iova + size - 1); diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 46e1347bfa2286..d2020994f292db 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -467,7 +467,7 @@ extern int iommu_sva_unbind_gpasid(struct iommu_domain *domain, extern struct iommu_domain *iommu_get_domain_for_dev(struct device *dev); extern struct iommu_domain *iommu_get_dma_domain(struct device *dev); extern int iommu_map(struct iommu_domain *domain, unsigned long iova, - phys_addr_t paddr, size_t size, int prot); + phys_addr_t paddr, size_t size, int prot, gfp_t gfp); extern int iommu_map_atomic(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int prot); extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, @@ -773,7 +773,7 @@ static inline struct iommu_domain *iommu_get_domain_for_dev(struct device *dev) } static inline int iommu_map(struct iommu_domain *domain, unsigned long iova, - phys_addr_t paddr, size_t size, int prot) + phys_addr_t paddr, size_t size, int prot, gfp_t gfp) { return -ENODEV; } From patchwork Wed Jan 18 18:00:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13106772 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27ADEC54EBE for ; Wed, 18 Jan 2023 18:01:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230487AbjARSBL (ORCPT ); Wed, 18 Jan 2023 13:01:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbjARSAt (ORCPT ); Wed, 18 Jan 2023 13:00:49 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2062.outbound.protection.outlook.com [40.107.243.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9F2E5529C; Wed, 18 Jan 2023 10:00:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wx7Mfi9c9598MGO7VDpFziWWxxJ4gz/TyUW7RXtkp7bJ7ZBCWOb3723JTda2aGRQDgncw9G4pNn9AKA+ejnI8Ork6hyWRKi78gVE4P2etY00UCqo/68ej7Pn83M28h7G0K6HVO4xTd1KoE2ev4YqwIT5Q7ggb22tlHOYYbIa+gLi6sdQbolWXiPAfjT2oeneJp2u0k3Etra6csnaZHNT1KX7xCLkLY4t9Mha77TZHlXVHxsCYVOnN1i/n99c03sUNxNdG2zUZDchoc4zYrChitoFllfziUMVSbEvl/Npfu6zfSFlqE4THnfcBzlt8oii0PDB49YlvBWcdZbkC8e+qg== 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=XnNRTH+1KqtZpYz+T8OWUErte65QR16s7yRZD6Lo1y0=; b=gsgwGo1wYMm92EInpIdGtISZKPN6kLP7zVMyzIG4XPaAYTptiwuNW1DRksSHQwzyZScuybg4/9uzwJ5trG9ABTJQXoSVTbK3gN70DjtdM8Skc+Lcd33d73gDkq84AiXa7jK1PSOaNn6FOoRGysZFCcZyYsl1JRvOsY5YwzaQy6qac4VrVxzax6wW58tnJ25QXkeE3FgNoRdDc5HBSv6v+TRxQIqIvVVFN+Vw3ynfknMDcLs2NySGrX9Ifqj8+iFKsWMRmcRoTiAcbq7cYHCFgFBiYsc3klXL+9Ufd9HiNVqjgyH32BBF+O9WN7y0vZR61NDrZSVj+u+47CTEpbc3ng== 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=XnNRTH+1KqtZpYz+T8OWUErte65QR16s7yRZD6Lo1y0=; b=Or3GiQS44xpDMh4YXT4PN+t+ZTtzD3XDn4nV7Hzgd8gmnDBYIUM5HoA8b88Vjc4fHCYpFerij12VAaCVaZoFMEBbDwDiMnCQ99PAlxSVFyMgW7d98QC49MSEv9AnYZqmgmRgPu/FRD/w/kR+Yyg181ToikOcAAKVTvZm1N/FAedaYiZHVb/Z49zLmjfamqS0kEeVCsMbqC3RdyweFsMNsYhExNc8kml5hGSgCziMpBva5Dp+VAOFMChbnljIfcMVzbePsZF4ml3QDBFeCxifFCi6MaEQk8gvRyqBGgK/dv9qcPgioNpjrfALNg0vz+eVB0Xd0RUrg7Nl4uO9zdzA/A== 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 IA1PR12MB7614.namprd12.prod.outlook.com (2603:10b6:208:429::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Wed, 18 Jan 2023 18:00:46 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.6002.013; Wed, 18 Jan 2023 18:00:46 +0000 From: Jason Gunthorpe To: Lu Baolu , Joerg Roedel , Kevin Tian , Matthew Rosato , Robin Murphy Cc: Alex Williamson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, Christian Borntraeger , dri-devel@lists.freedesktop.org, iommu@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org, linux-rdma@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-tegra@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, nouveau@lists.freedesktop.org, Niklas Schnelle , virtualization@lists.linux-foundation.org Subject: [PATCH v2 02/10] iommu: Remove iommu_map_atomic() Date: Wed, 18 Jan 2023 14:00:36 -0400 Message-Id: <2-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> In-Reply-To: <0-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> References: X-ClientProxiedBy: BLAPR03CA0077.namprd03.prod.outlook.com (2603:10b6:208:329::22) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|IA1PR12MB7614:EE_ X-MS-Office365-Filtering-Correlation-Id: 00ed64dc-f8c6-437e-d839-08daf97debfe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dipnW/eamyJcaoHLcKnIMEqSMmU5OsjSOROkII/0hH0rEUmWOqMUS4wQC6zUcuQ8R3kdiF3yLMXrN7rkIUNg9Nd48/YitoQLrp8xSN7xXqhRqLSWgb41djZfxt943UQDEQPcIwfYOKCnjs1hRFZbuZu7pp3xGYvlFBXIh9IqS+ZZR0uQMM2XM/lKneS7iv4SrgQWFwu4SWpl3mJezRDHFLPmUK3WCiIOfIBjdLtKHLOy7V5bhFU/hixjYvd73ctxwBYuCgft4xzSPzQBt3gzbC3QhotYaWmkjnUlIN3qyclrFI2C70B+2z+B5DA0f7wwoO2iqA6jEw0B9Nvi3qKS3C8ftpjmDHh35D5kPBJVVsD0PyI4GBE0rlIv0a3jsiib2BMRXZJ7aqTvOz7piDtUpT/0m1kVI68zO53NO88y9XQkhMqSLvWk78rRPU/YIujD1WWBvXs2MVLnE1UigM8jci1BYDVu63MM6K7X2DDoDJ00452vP61WFxjfjra4obMhyE/QJM/uhyxRALB+vdWdDbFL7qdZEEdU9O4ParU7+mpJirH3DaYUFfLnxZBY41XkfUd6T6fP6xEjqMG+aWh6PzDTB00WslGojzevCedglGIw/1FJp5UImlPi32Lo2hkmJB5oQDj1ZeVoFAo0C9ePutuCQlhJmI3bZDvr9KAM/m40JAZ5TNwsqvZAm06UI1Nu 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:(13230022)(4636009)(346002)(39860400002)(396003)(136003)(366004)(376002)(451199015)(6506007)(186003)(26005)(478600001)(6512007)(6486002)(6666004)(54906003)(316002)(110136005)(4326008)(66946007)(66556008)(8676002)(66476007)(36756003)(2616005)(41300700001)(8936002)(83380400001)(2906002)(7416002)(5660300002)(38100700002)(86362001)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Fck4Wpnziv2Cz+QwkZG5eG/tqENIhIvF1lMtUwsMzTzIeP6NZPu+49PmtcPtHGu1v7UMs7LwlUFq9PzEJHP+2eXENLnncNIdVmnQa/HNHmEwMjWYRAafVH/jE5qHVgRTKppgKacMifaqSNCWfPsFh5hPNoRPuujUmHczsGnFHcatERKQ4dSkKH00wxo6F22xyj2ZF4OLtBSRX+TODvPWhRClFblr1PuMLcbHoPOW8inlt0tCm67TXfHuVnvMTtnTPz1Wy8t8itxJsIFiy+gdV5quzmeAikCiAiwNH52JvC+Wfb79fE2gvMVBpze2Jc76U8YbFSoKR4h4ce7SUNn6ZbbZKAfuEgNzSOsKYQRY3SQiCCBwJfH5umQose98ZfKebiantQ39Mwqsbt/hR++3gxsbUTakzQ9CyZROoZQue0tnoceCVudOWeWZmfdjJHbXf1xmXZLQe1YsFTGLc74qhqplTiWXmCa6d5gblhnTiQxSy8aW3ChN0rFqFozi9wRG0leFHu+0KTcE1WWbg2yny4Nq2xf9U8Axb8ImXfE66cMqHsqOc3SitE4R6XLBU7Rc3MhWbVvSDqll7fo188UQnGQpEfhhR0ZMUtJiWE7kVkBEOtY995HtqjJ8FfANG8uDCFv1XHuLf7TM3e0XE4PbC2nlgKRUSJIslbFoyUgHFyBINwyeWbegOBoUHtv8WTKR7XPBlbIE+1eaIT2HaT2DAj6dv/MwdtZXdTeQaJFaV4/zR1GHSNhXvkPswx6ukmB+cdGUm9N5hVASNzomGwC6DpQePIWVeKHCrcjtRG5szMIqYinvzzJaQWar9OaSLBkthRVd0ZqwouT7tNEydsFmY79G6EnWPnFzl/ic0IcJuGAu80MpcHRSM6nDHT6ZB92qWNIqPfCLRKiye71yr3ZL5foJJ9Q9Xb3la8x8VfoYBBECrfbd5aKHlAIaqOvGmNBeu7x2rd2dQMo4h2/lsP6ff9ZOB+srrg3lWmHX4dsYqMBhV+abZD1fiDLqpnXdY2Cd/VCUzE1+KDnu+mqY6bywkrpKbptNtyqnddzVGnr3FHTytiQm+P7sukJWTbHw2ylNxbr0SyDb3NgiP0bMo4iYNaPAVkUmwxWwYWQvaTzvGTBkIkfDLGi0G0Jin6FMa7xuJPYQ3bZ6wWXPO9AjgbX1ZRTEPpgFAsbS/kI4bFsGehW3uHGlkm8arweoc1DSwzmd1/XmFp/Vw3o2btpRvklwAY4CXnyAKh3dG6ZEALWxSM/G0k+rrp9rdkasZK+uOF162moJUf6CiKUlgfbeALjPg72XHcTkJfCrSlGHtX/RZHjOFYu9x860w3sJJ+Q10X0PZsAm9C7EHoy2NGk53UrKnQPmJMCeASHvsWR1aBlmyigdY5NjIoWf3Hm+GDG7KEozB3DZHjdqmJxZJhjRtBpaBuTg6K49nTr7fsTHQh5cR//YUCkj3BGnCtBvABseMwnb0axlioDZVbugLtjNPR9Rd1pmGSdD9esGMmX14xln1DDetdBl+v1a4L3VVHnEXQt3HiIjLS3dUorxzx62sSre0xhdDUd8Xz5soNo/6wUN9PVOfUd439MNOD4otlohN5li X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00ed64dc-f8c6-437e-d839-08daf97debfe X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 18:00:45.4590 (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: +olxkA7gy+fLu/rmzQ4CvFah9pVF9kR60kmfMv20LRjO5anjsEGL3tWZl82WS655 X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7614 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There is only one call site and it can now just pass the GFP_ATOMIC to the normal iommu_map(). Signed-off-by: Jason Gunthorpe Reviewed-by: Kevin Tian --- drivers/iommu/dma-iommu.c | 2 +- drivers/iommu/iommu.c | 7 ------- include/linux/iommu.h | 9 --------- 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 8bdb65e7686ff9..7016db569f81fc 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -713,7 +713,7 @@ static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys, if (!iova) return DMA_MAPPING_ERROR; - if (iommu_map_atomic(domain, iova, phys - iova_off, size, prot)) { + if (iommu_map(domain, iova, phys - iova_off, size, prot, GFP_ATOMIC)) { iommu_dma_free_iova(cookie, iova, size, NULL); return DMA_MAPPING_ERROR; } diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 7dac062b58f039..9412b420d07257 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2381,13 +2381,6 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova, } EXPORT_SYMBOL_GPL(iommu_map); -int iommu_map_atomic(struct iommu_domain *domain, unsigned long iova, - phys_addr_t paddr, size_t size, int prot) -{ - return iommu_map(domain, iova, paddr, size, prot, GFP_ATOMIC); -} -EXPORT_SYMBOL_GPL(iommu_map_atomic); - static size_t __iommu_unmap_pages(struct iommu_domain *domain, unsigned long iova, size_t size, struct iommu_iotlb_gather *iotlb_gather) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index d2020994f292db..521cd79700f4d8 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -468,8 +468,6 @@ extern struct iommu_domain *iommu_get_domain_for_dev(struct device *dev); extern struct iommu_domain *iommu_get_dma_domain(struct device *dev); extern int iommu_map(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int prot, gfp_t gfp); -extern int iommu_map_atomic(struct iommu_domain *domain, unsigned long iova, - phys_addr_t paddr, size_t size, int prot); extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size); extern size_t iommu_unmap_fast(struct iommu_domain *domain, @@ -778,13 +776,6 @@ static inline int iommu_map(struct iommu_domain *domain, unsigned long iova, return -ENODEV; } -static inline int iommu_map_atomic(struct iommu_domain *domain, - unsigned long iova, phys_addr_t paddr, - size_t size, int prot) -{ - return -ENODEV; -} - static inline size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size) { From patchwork Wed Jan 18 18:00:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13106777 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A41E1C38147 for ; Wed, 18 Jan 2023 18:01:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230213AbjARSBf (ORCPT ); Wed, 18 Jan 2023 13:01:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229507AbjARSAs (ORCPT ); Wed, 18 Jan 2023 13:00:48 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2062.outbound.protection.outlook.com [40.107.243.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 964C555290; Wed, 18 Jan 2023 10:00:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hXoTCCFLZnOD9YXHQINsoNJysimNrVNAz3rNG+c2a8vlhmhYnZKx8Vvj5dsCJcNVEc5iBRKd7nmr76JNdkGzgliNRUSsmBWtS8zsDl4TDrNi6waQ0wAo5a/MwbvXVDcpAFHxjyXlFM53uQkNMqeQ1vfDypvRrHrPJ+knizM1bDSm+IhlkCA9apZ8VLrREpIggCSG/B+Et6xkako5nyUpbDGDYwgSSqczuSim6qSftxp0mqZzFt29HmXaOC6jOYZxL7VcR0KoIbjDkEyw2VN3VvAhpFTd8NFwi9ykBW4qF+pDw4UTW85zHEXPaYJxjmi95pt6+M0hHX+Hy/RW0fgoiA== 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=1rgow5diNk+hVt+Qqw0FXU33IcXQf0aq5YG3bZTDQaI=; b=YJHXP40dKqKDwVDEviHWtEf2+d4oYsiHyB21j7UWWRbiUo1Nkuvs2qZxeA4mscr/7D+HNp8dZjq05MnEiKxKWEilFwAceCsGtrfKiH8KnVPP7aIriRrPxsfvsNo4y5lzVxJbXgSKsb/gW5iIJ/sbLlaT3oaPDyPbIab9zByrLu3aallUoA6lx7MHTCoH2AFQ3Afvzfb1p5cvj0j5we87oVaq3Yzi49KORD5bRbr9rwUcV5eOc488WlKRHjBXZwzbfCBKA97Q27qvt65RNFJLvdgFLPUMhp6IgDzWQXU61MP6Rp9z1TGozcfxbNCdtvAoeMIRncmU6njoqWQkKWvaJg== 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=1rgow5diNk+hVt+Qqw0FXU33IcXQf0aq5YG3bZTDQaI=; b=tB8X5gTZH+CJRpWO9vB+DaX/UJdLa4S44i9WjPyrM+xIhyf75jrjn/O+2SFjtIpe9FHmJ9SKnJjBU2tmnseVEAhJUnJorjbYTudRDGkDhJE/VZEWU19NvDNXfePEa/bt+F1+VmhYXhYHXyYLCGe05jzXFURA8MqzIAbfu44YL1LokoKuHit7lJ3LwGQQlxmaN68vF+3wB0OTI2yfK4SyixAAryHmVM8TPs+KlcVUf0lfKtQ3h0ZV/aEfl8kpybw17TYv2BvUB0VApGiiO8I/sOnMC8qT4pakH5mykmv4xNRt+JTMh3kYPNGbIzVOfBq0rQzHREE9R0yjWNKbzqw9YQ== 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 IA1PR12MB7614.namprd12.prod.outlook.com (2603:10b6:208:429::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Wed, 18 Jan 2023 18:00:45 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.6002.013; Wed, 18 Jan 2023 18:00:45 +0000 From: Jason Gunthorpe To: Lu Baolu , Joerg Roedel , Kevin Tian , Matthew Rosato , Robin Murphy Cc: Alex Williamson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, Christian Borntraeger , dri-devel@lists.freedesktop.org, iommu@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org, linux-rdma@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-tegra@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, nouveau@lists.freedesktop.org, Niklas Schnelle , virtualization@lists.linux-foundation.org Subject: [PATCH v2 03/10] iommu: Add a gfp parameter to iommu_map_sg() Date: Wed, 18 Jan 2023 14:00:37 -0400 Message-Id: <3-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> In-Reply-To: <0-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> References: X-ClientProxiedBy: BLAPR03CA0064.namprd03.prod.outlook.com (2603:10b6:208:329::9) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|IA1PR12MB7614:EE_ X-MS-Office365-Filtering-Correlation-Id: 3289005d-6cf5-4741-cb9e-08daf97debe6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EAquh9wTbVTZvNn7pq2JL2hrLPhCXhIIKiU5KfbQCyQk4TWnAjyEY40G8WU8zObnfa+Vl3YB9E8rXOLTjVp0m1Drz4Kic1KbvCmDgfjjRsR2DJvlxOfJ+SkbtwPur6XFoWQfYD9AURxA0yjdOn7I5IOjKDdfueh3sz6AtUQQWbFRvaBAS4EDKvzUp3rTEa9MRfvGKwB06Ny4MCW5Pu4L+WvqcZxmmd809GDu/XGIakZsqFpDLcKl1HbQtGsmBqEnpmh4s8UI9jMTcRNDowLURHPCPSKLL0V2ltLTHPM0bvfgzZi+ObdeXhiQcuE/YZlzZcgjcLUoWayuOUOTRQWufPe+a0ZTd4mOjwwso9ESUQasoILWH858lzexVI6eIx/H5mQUuMUiVLcUtwJqbyfwGP9vwa/a5cGArI46mS9mflNOzIV7Ei1DjGB2PqQLCFiUZhksRGIEwqW4t30zPtZH7NRrcaJghGcVvsGSFPS7IgQYpVhAJRTV79aPi2HJBK42KbuVrAPKJd7XQpVqqi5eKAjri12Hyd/oUFumCqKr7+ymL4rY+KbY8JCoVlHSAd92Z5gyzMwEVvCQMOtSyi2lj2m5KruireIJRJ8vO+VoBLqYCJDfpxBfxnheo3AkW/XI+dT6xb4S3F4acVohgQrq0qffjgS0x7fZjM3sce39dUfGPKE5BeceJ/72mtC3fQcF 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:(13230022)(4636009)(346002)(39860400002)(396003)(136003)(366004)(376002)(451199015)(6506007)(186003)(26005)(478600001)(6512007)(6486002)(6666004)(54906003)(316002)(110136005)(4326008)(66946007)(66556008)(8676002)(66476007)(36756003)(2616005)(41300700001)(8936002)(83380400001)(2906002)(7416002)(5660300002)(38100700002)(86362001)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7f+aQxlhcqWHrfjoUc+2E6lpzU9E5X6C5dQ/JnnFutQxJSisp2jl5QB+Klo9JxohTCoUv5u4LiMOTNsIb20mWefqV3alHEu0oje2vWgGxZHHeDt4rczkIGYC/+a5tRdbxQlJp4B/2Bj79XdTLw6jyGkpOEIv5lPbzZn7jVUi1hyR56r3KnTqhV5lrPdFKcIAdx37myMNUYO/h8rhMaa7V9HRigmYNHAsX9msFduCX4vQmumrPC3QtX+rUxCsWAOOg+eoZoDsKhBUdUB2C4vm9RQZUq194e8c39+mltOJI7qlFaGShFVVQM99j1t1yd5d93XZpraZdUz+r7xcQwIxQ3/iSPbPGWxzbX/dFEkY+Nmn+Oa3lIpg+GBgRyoalwdeoDWDnD6CkM0IaGQYMBjQQonjxz+XvaB9+k+C/RBeJjBx8FxA7yFlSuXm0SD6G09CaO0xLHUwrywAJHpQJAXJH9VhEFeerOCZQQX1q0ITQWxD8BqDLofugTuRh21bnjgvqUZAxfMSzZo9tTMBR5vSbD2wpB8Xg7fIXAUl8k9uWuS89+FopjZXOCiabvKyoIvY36h0DPgRjI/kwtjNpD5rKJwKSrfVI0V5RyBxx+lx+gXFzpDeA0VwbeBOEU5sI5CYV3zfeGM3NJQGOpH3Vo36e6e1eXn1ZcYHhBU0Tn7xZFb8+nNEwcxm3Y1rNe/jOKEXyQ0D86J98F3YZHiYaitTN6I39iB99qkG0T6UcxqlD3k/qv0Ob55C0aC/qvMUrN1vB8La9e4clQRLHi0VutivUxPvAtbURdFEqMsk0eh1+wm6fLJlD+ks7+lV0DXXC2KrYAr8teDF4+RIOwZmlwJ3OpHL/xsfehiPHrjythoRXADm0vkBEe8K3ci9sbS87yAFYv6ldmKChfpD3v3MSLHFEO320DIIN+qgWbfsCt/HIHZtgHKhj3Og6U2DYRDrrLpymBtnY7nTMfupE5AoFRq/EqhPR4gYS7qpD9972GvVRFh/QKVh/Rtk9e3b/mBohMbrpJATKX4WXBrGIQtRkgm4bDaqtuh4Qc4ArAnWAnDsYrNQNT8rpEJP52M8ok5C1A5J4iGMVWUQNkbqZlmTkz+AbtgWehIQ8vKWUuFuFEUJMTygf8kCZzQ+l1kIRL8YnGQaiHa7nff7v09Ah+0nZiTkKoYhxL52+NAz74o6tbC47Jv70BQoor3Cx0bGEHaEXY1iG2iLfRBPqdy6B0jOmG106Pyby8xO/qlFU3Ue5ZdRClRcxxqybE9MJE/nJjQ6iaGvcj7JClHbZg880quf8K7KHMtW1yUL2jnKrkkSWWy9ce7uubi8ithEXhJZrvMlbgteuZ/vaOH48/gHmr4MheP6j6P5sapk8HNAOkHUbHxgC/aVuvDEcMUTQcSKdZV461mBt53e/9dxWnnSGfE6Li/nW95jW8Y7F1QrcGPrzVmPxMTh1o/snnk1Fjgk8sTxenPnYdes8DquN/7c8tT337lRCTGeq9eVMWmVJeHN3uT+HWGZ5Fn+GBIWBLKB6d00p3r+KQja/fpXYRFWejxZKuQhdGILasj6glqzU7D8jkj8sVGqWXaF4wEqHdehu9UHWSSL X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3289005d-6cf5-4741-cb9e-08daf97debe6 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 18:00:45.3015 (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: VQ1WX3Ma18fOY83qY8rk8IB+ZaB0YFwzIbDxfHZcEPBDEisJQmbDs0D2J/7qFl9k X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7614 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Follow the pattern for iommu_map() and remove iommu_map_sg_atomic(). This allows __iommu_dma_alloc_noncontiguous() to use a GFP_KERNEL allocation here, based on the provided gfp flags. Signed-off-by: Jason Gunthorpe Reviewed-by: Kevin Tian --- drivers/iommu/dma-iommu.c | 5 +++-- drivers/iommu/iommu.c | 26 ++++++++++---------------- include/linux/iommu.h | 18 +++++------------- 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 7016db569f81fc..8c2788633c1766 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -833,7 +833,8 @@ static struct page **__iommu_dma_alloc_noncontiguous(struct device *dev, arch_dma_prep_coherent(sg_page(sg), sg->length); } - ret = iommu_map_sg_atomic(domain, iova, sgt->sgl, sgt->orig_nents, ioprot); + ret = iommu_map_sg(domain, iova, sgt->sgl, sgt->orig_nents, ioprot, + gfp); if (ret < 0 || ret < size) goto out_free_sg; @@ -1281,7 +1282,7 @@ static int iommu_dma_map_sg(struct device *dev, struct scatterlist *sg, * We'll leave any physical concatenation to the IOMMU driver's * implementation - it knows better than we do. */ - ret = iommu_map_sg_atomic(domain, iova, sg, nents, prot); + ret = iommu_map_sg(domain, iova, sg, nents, prot, GFP_ATOMIC); if (ret < 0 || ret < iova_len) goto out_free_iova; diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 9412b420d07257..cc6e7c6bf72758 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2470,9 +2470,9 @@ size_t iommu_unmap_fast(struct iommu_domain *domain, } EXPORT_SYMBOL_GPL(iommu_unmap_fast); -static ssize_t __iommu_map_sg(struct iommu_domain *domain, unsigned long iova, - struct scatterlist *sg, unsigned int nents, int prot, - gfp_t gfp) +ssize_t iommu_map_sg(struct iommu_domain *domain, unsigned long iova, + struct scatterlist *sg, unsigned int nents, int prot, + gfp_t gfp) { const struct iommu_domain_ops *ops = domain->ops; size_t len = 0, mapped = 0; @@ -2480,6 +2480,13 @@ static ssize_t __iommu_map_sg(struct iommu_domain *domain, unsigned long iova, unsigned int i = 0; int ret; + might_sleep_if(gfpflags_allow_blocking(gfp)); + + /* Discourage passing strange GFP flags */ + if (WARN_ON_ONCE(gfp & (__GFP_COMP | __GFP_DMA | __GFP_DMA32 | + __GFP_HIGHMEM))) + return -EINVAL; + while (i <= nents) { phys_addr_t s_phys = sg_phys(sg); @@ -2519,21 +2526,8 @@ static ssize_t __iommu_map_sg(struct iommu_domain *domain, unsigned long iova, return ret; } - -ssize_t iommu_map_sg(struct iommu_domain *domain, unsigned long iova, - struct scatterlist *sg, unsigned int nents, int prot) -{ - might_sleep(); - return __iommu_map_sg(domain, iova, sg, nents, prot, GFP_KERNEL); -} EXPORT_SYMBOL_GPL(iommu_map_sg); -ssize_t iommu_map_sg_atomic(struct iommu_domain *domain, unsigned long iova, - struct scatterlist *sg, unsigned int nents, int prot) -{ - return __iommu_map_sg(domain, iova, sg, nents, prot, GFP_ATOMIC); -} - /** * report_iommu_fault() - report about an IOMMU fault to the IOMMU framework * @domain: the iommu domain where the fault has happened diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 521cd79700f4d8..d5c16dc33c87de 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -474,10 +474,8 @@ extern size_t iommu_unmap_fast(struct iommu_domain *domain, unsigned long iova, size_t size, struct iommu_iotlb_gather *iotlb_gather); extern ssize_t iommu_map_sg(struct iommu_domain *domain, unsigned long iova, - struct scatterlist *sg, unsigned int nents, int prot); -extern ssize_t iommu_map_sg_atomic(struct iommu_domain *domain, - unsigned long iova, struct scatterlist *sg, - unsigned int nents, int prot); + struct scatterlist *sg, unsigned int nents, + int prot, gfp_t gfp); extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova); extern void iommu_set_fault_handler(struct iommu_domain *domain, iommu_fault_handler_t handler, void *token); @@ -791,14 +789,7 @@ static inline size_t iommu_unmap_fast(struct iommu_domain *domain, static inline ssize_t iommu_map_sg(struct iommu_domain *domain, unsigned long iova, struct scatterlist *sg, - unsigned int nents, int prot) -{ - return -ENODEV; -} - -static inline ssize_t iommu_map_sg_atomic(struct iommu_domain *domain, - unsigned long iova, struct scatterlist *sg, - unsigned int nents, int prot) + unsigned int nents, int prot, gfp_t gfp) { return -ENODEV; } @@ -1109,7 +1100,8 @@ iommu_get_domain_for_dev_pasid(struct device *dev, ioasid_t pasid, static inline size_t iommu_map_sgtable(struct iommu_domain *domain, unsigned long iova, struct sg_table *sgt, int prot) { - return iommu_map_sg(domain, iova, sgt->sgl, sgt->orig_nents, prot); + return iommu_map_sg(domain, iova, sgt->sgl, sgt->orig_nents, prot, + GFP_KERNEL); } #ifdef CONFIG_IOMMU_DEBUGFS From patchwork Wed Jan 18 18:00:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13106780 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 956E9C46467 for ; Wed, 18 Jan 2023 18:02:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231269AbjARSB5 (ORCPT ); Wed, 18 Jan 2023 13:01:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230463AbjARSBI (ORCPT ); Wed, 18 Jan 2023 13:01:08 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2046.outbound.protection.outlook.com [40.107.243.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3972359E57; Wed, 18 Jan 2023 10:00:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b83gBiPSSsb14AVKvi1HBOtjheXFjagdsSRJfqakIFLmNfwUcBIp3FQaX+Q26xTDjyEAOgJTKf/+MNMRd4Ci+0wejL3ENaK2ZNIPK3NrnC47SQ0P4/PwsEZ7+78/eCg4CeXAwnuBcDYYDPNEcfRGDy001MUq80wIg3QJjO2YaKhrboO3juF1MmFFHTNmaqy4H6LqvHt6rzRzukhgyMX8BcswN2laocFzfbzm/tP/uin99Yt/D6gh8dsAgy87cfus4GNB6zy0ZyKWpQbu1MSWTlZSmCQFUs4FV+bxqoCk8VdWLAB/uCceRGCmzspX3Wq/LVz3J8rnLp+QAU+QPn+12A== 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=i28832YwpvUJbHlTSOfIPaYAPWwxtMVLBQ1NJ2uFvIs=; b=KJfNJ0Uc473qv0uSwI0jLzEs5yZujhCUZfIlS43l8p0sgD6cmWERbeGserqsFiENhX0p1mrpY8k5gq8kdcfSebO1VwFbLH0ZA418HVWbJHMQh8FJwXYtXuJp3AAeHz7j+ihdY6w90JB7jFMuWeVUkGNXFXCqz/dO2euh1NELN2qfcL4g5OG6XS67dY67c6waNSMzXouFCLzWyOeeiZReWdndsc7oCih4B5SwNv3lxf7YftQ5Fc/Tig/FCbHE9TzYhSdmyTFEvvZUuYfLidiIENZtnHZSEJYAQS+HV/CGbphcmaCa8Myh3kuZtyjqjq8yUH1y7CefsneAe0lA8J/2fA== 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=i28832YwpvUJbHlTSOfIPaYAPWwxtMVLBQ1NJ2uFvIs=; b=fHM+LdaFx5q7OjQ+Qb0rCCL7c8X8lPPC8rg9Cua2nMoIcWqLLL++dN7EY//pYEJvx5JFNmgst4FCBcxz4SKRZj+99Ghe6DUewGOa7HSBJoZsbNLq5L8hab2AyomYs0p52pbkrtPYEA9jDc8uPo4oq55qZkFGBeFmojHHtlc2qZuosoaYSAwalQupZ4EHNXKLKkLM9KPvBJSjO8TYflME/Y7jZxvtOiciEzfzH8WBT5pkZuOCv+8tZ/OG6mtL17kcsFRWVP3IQU/bW2EaCfJXLDbqF+VKvBaoGF479XgqEv7RA0z6HZATeuzHELd1rDwqQwBVV76ZCvHggj0edd8K5w== 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 DM4PR12MB5818.namprd12.prod.outlook.com (2603:10b6:8:62::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Wed, 18 Jan 2023 18:00:51 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.6002.013; Wed, 18 Jan 2023 18:00:51 +0000 From: Jason Gunthorpe To: Lu Baolu , Joerg Roedel , Kevin Tian , Matthew Rosato , Robin Murphy Cc: Alex Williamson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, Christian Borntraeger , dri-devel@lists.freedesktop.org, iommu@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org, linux-rdma@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-tegra@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, nouveau@lists.freedesktop.org, Niklas Schnelle , virtualization@lists.linux-foundation.org Subject: [PATCH v2 04/10] iommu/dma: Use the gfp parameter in __iommu_dma_alloc_noncontiguous() Date: Wed, 18 Jan 2023 14:00:38 -0400 Message-Id: <4-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> In-Reply-To: <0-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> References: X-ClientProxiedBy: BL0PR02CA0142.namprd02.prod.outlook.com (2603:10b6:208:35::47) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|DM4PR12MB5818:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a42fed2-83fa-4c5b-cefd-08daf97decd0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bTRKsduCS9s79AzQ2MPbrMF5hpDqAKyzymEHViYRnb1C1srzo58F3QjMCR4Hw6VIDvEXjcHw8aU7hoN6luCW0VnMQynULsRy1mmXvTrspYlF6GLwX7q49f/CXp5LN3U1tsLu2lOjasz3QV3QZD+ahgW/YVsW3KfdllkSrLk8YBi0rb5qUuye355+Z1l05faxOwwrjE1H5H2Ew5x93+eavvKDn7ywOn2C/Vd6Gvf6oK3QVcZ8y6MQfGb/Wfv167/4NY4O6xpbvlLmmEE31SyGculxQWiRkMrOdw7Fs0Tb/2hED5tUJBOxQCP3shI+sdRZzZqtdeHpUuCO8jxt0uZR/5B9R4Cn5+UZky9Rw83DIB0lVEjQuangj7zbzoMyD7kD//xU2Q2fqzmIpMH17KYGRHqScFprt3fjsTbs0zFcNwAbLk4ayIRsZrKdBO6PFiAjT0piW130GV+OXXIC7m9c0Xy/Sr14qQPZsXURab7B609fEaErIWbMqCFV3xT/xNVHXiCku4nChXZubUJQelPoIUOnxqW+J3VXu10GiRyeXDlzGQ0hdgCXNvNbdltr83urYejgTIindmlknZ+bKBqj/kA+ZZYE0SeJt5cy4OqjAVduTc4zTwLBN7fXLS6BLJnhMCknduphZ4UZosDPKWTF1pZQKGC/zJvzciSrm1gObSMKeifNu70bHJpcVUnR2Aol 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:(13230022)(4636009)(136003)(39860400002)(376002)(396003)(346002)(366004)(451199015)(8676002)(36756003)(83380400001)(41300700001)(8936002)(2906002)(66476007)(2616005)(110136005)(54906003)(4326008)(316002)(5660300002)(38100700002)(86362001)(66556008)(7416002)(4744005)(186003)(6486002)(6512007)(478600001)(26005)(66946007)(6666004)(6506007)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2f0Uut1aescwxLLm2nudPyU7lR6i3Jh6wJTsepXy+lAJ3Yrq567SDzNCsuxOn7miKfQDY2iNpOCM0oXGyjx7IP/msuTEWpM9zwBvY4XHYwUcoGKFk8rIOzUH2gAEYWSAnHJzOKncKycY4axodL28uBXKM0t9vCXSr5/shLIl7xeqb1gB1KVWDYLtjZL3sWa+4vWwCZgA8fpatbmj3WOyIj+VFQd3evRCQMTrJozUSTQ9Ok6hBsewM+03mr9n+BNLsQ8/FjnbUrbARlkxZioQK46336anodmBKw07jsr2eqjvYQuYU8aFA9nTB+A39r19ZjvS8o9ZwLw7J5k1SppIqw3FmGY7XSeveZlzlVw5CaxOrPG1VyXG21coMM4AzZwb3EGEqIDjcEwzDR6MdMX4Iw0Z8mqfIRSKG0RbYF9ux7NHebRge8S3fc8kkIT8Lysc2sIpdRfYoK2IZK67IHWWnHhUSaTWWNXQJodiAIrnU240OEsOy6qvK3PkeJ9BFKIB6MwyO9tsVS90SiDV2a0P/rCC2mqA7wzbxQB2ThVask+v2z+vP8Z5OiHGWgPe7r0Jvyj29gMOxmsteo22JDSQeH1BKNt8ZltYquKXNmJsmXRx2oOlha2TFrDHTuILS+9L9135DQs1tUe2ByCx68Oh+Hucd3GHcvBfvQdltLK0UulM+cj3rLp8xOWoHDqesa6Ft444kMMQRS27x0rH15bFHNBP59kkqHRo0a+2ArtQ58qInqElabz1ZaVCO20aQU/s69IibE92cZzRRritzZRGswxaZxTfx/WgWA7RmlvzRZ/0O/5Lmy/GWdi6EP1ZdRz7bnzonVwWTfze3MtHjmFEQpFF6K0MsJYKVnPbd02YbeembMH2JcrG8PT/i8zGTI86IT3oOSKtVl7Q9PmufMQfj/fj82NTsRiWDq3OZxcawXze00/0hBUW48QskqunCgcx2EufA5y7BqKDP2RWmQRpdN2CQ4rSUpz/Sr5w4i7MGsGkrKUYrKSJ/N/B3/lH3/Ie2pe61LI0lLKaGbqX15kqamrhG7irtnZEpCVFwrIXNdi/zpUJjoDJqXcNFUPeWGkg2U6flmzOYCo4+2RKBR0LIln6AbGgFidAn+VkbxBRPT4Scmc8Sp/YQ0nQlSZ7iS42ORrt/9GB7IlRRCTRbt4QgqKTstNmoacMBh2/afCVsHvRBCKHy+JHzYg+uk/f6NNs9bDhwtZ1sbLI7qBp04Xji7SOJa+Mf6MEdW/WtjmHk7CRvnOuniSJjCkny/+9LeR1g+l+bmWixAktIJP4LPCGcx97/USAS74G00y1rv3LWLSaQ2Ak16XOqsjvqAlyD0GBGZC60bv+S6cSRKi+qjIKGwbsrirt41SwG4LxNh3T3KbTTu2C14OaCNtxJFaZprakT0lNhYalLQ5CuTRDGxouYpZm7Pf9D+5YlgWFpIsdVbJxRsb27IAJ1bIzVXiz3cx+GqC5I2W+8TsUnA3HSb0hriInCtJL4jCBbbZrHYEZi5PrbhrASDoR02hMQZR3a8/x9e24xd9iZM4bRAd6fXAcNMhOKRq5hWo5a96jnjAuMZCUuwE9ngtT3S/kE9NACeLv X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a42fed2-83fa-4c5b-cefd-08daf97decd0 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 18:00:46.8806 (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: mzD/OnsX4Ro4ty43+yJ9jWAKT/OVO/tqlP+BiA2m7qlXlZRx8unJtenyDPa2RjUd X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5818 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Change the sg_alloc_table_from_pages() allocation that was hardwired to GFP_KERNEL to use the gfp parameter like the other allocations in this function. Auditing says this is never called from an atomic context, so it is safe as is, but reads wrong. Signed-off-by: Jason Gunthorpe Reviewed-by: Kevin Tian --- drivers/iommu/dma-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 8c2788633c1766..e4bf1bb159f7c7 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -822,7 +822,7 @@ static struct page **__iommu_dma_alloc_noncontiguous(struct device *dev, if (!iova) goto out_free_pages; - if (sg_alloc_table_from_pages(sgt, pages, count, 0, size, GFP_KERNEL)) + if (sg_alloc_table_from_pages(sgt, pages, count, 0, size, gfp)) goto out_free_iova; if (!(ioprot & IOMMU_CACHE)) { From patchwork Wed Jan 18 18:00:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13106775 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEF00C46467 for ; Wed, 18 Jan 2023 18:01:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231193AbjARSB1 (ORCPT ); Wed, 18 Jan 2023 13:01:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230181AbjARSAv (ORCPT ); Wed, 18 Jan 2023 13:00:51 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2062.outbound.protection.outlook.com [40.107.243.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BC68552AA; Wed, 18 Jan 2023 10:00:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M0wBWJ5PLq7u65SEgYt76cVl9XecEOjRo5m+JyAiD1lpJ/3L+nBQuTzGn0U5tehiqFbwP9WCK0VmPFnFTmmDg5taSBf6gZCqUT2ypCpNPEFo2mZJXn5IUT9wFsZrXYKxaDqH/ENe4ODpIzkPVxEz2tpl5qu72nxbeih170IWToqNSgokjHCG7wLXsgKW26WjryCMRlTr4UySgtOqCIi5fVYRSGIRurJjPqbSP2OMQa6rc9IvtuQO7Z9DlfxDFEkiOgbYzgn7FwCAZ91lYFq5NHKE6eT2ptjVAyUGXBZnElBFujZ7GKFtjrU3QRitK5yAU72EvoWW9rNcgwmNNJOnyg== 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=hW/5mujLMwqrzVEZt7wBA4VSpYB7Lob2U3kTzSD4quE=; b=mYNdaHQSWoNrNpq41kqgmJvWo+v/BX19qun3XweTQCVUq6Yey1GpebsiBQgF+XsWmPNbbmOTtwjdSYIgQLP5O5VA62aW7SpMSLghstgnCFrzbTDb8lQ5Kec4Tu4HQkop2KnRBtR0oMUY7/zKJyhZ5TFaHnyKSZ8MmU2xfzxcUYXyGi4RC5wlO4B+jOeeyMkau3V7WHlMDkLRiJrxSKX5PGyaF4YqyqMo9/rLsuvKicP7freGhyYXtZQ3tm3/wf3tmrITZ0VI1/Qqe5JDmq7KAEe9j1rLiN27DxaGgMj4Q0MUDrQwq3gPQW24vnjQdkJxBDbKMkB6gnUSCaZY9zqV8Q== 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=hW/5mujLMwqrzVEZt7wBA4VSpYB7Lob2U3kTzSD4quE=; b=IIS52DBDnuzB6GfbVJQb6RssA1TqQPqIywi8Emj3mrgbbWu3HmLg0AUD0Mc2NfvgOraj9jEhtP9LPhE5F7+Rmwv2gV4yriBSTropqB1oaD68ZKFPLiHwyFWi9lPR8dpUfFRM48P2x4tSNlMg9BKsKVE/OSos08v10r2WqfRZcvQFKBGd10gDwJ5I08KtB2uNNOKJ+d4ojThvIAXkVVzj3pJqOM7Gt0M3UwAFyxe76jVH/CJIs10OWkJ4RIds8i5MueImrQp+uqgB6VebWZANxB39ZfmURxUY/1bF6g5bexdvKfYUVJ5JDhNLIpuC3sRl/ZozlvkM77tf/XJxB5E/nQ== 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 IA1PR12MB7614.namprd12.prod.outlook.com (2603:10b6:208:429::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Wed, 18 Jan 2023 18:00:47 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.6002.013; Wed, 18 Jan 2023 18:00:47 +0000 From: Jason Gunthorpe To: Lu Baolu , Joerg Roedel , Kevin Tian , Matthew Rosato , Robin Murphy Cc: Alex Williamson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, Christian Borntraeger , dri-devel@lists.freedesktop.org, iommu@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org, linux-rdma@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-tegra@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, nouveau@lists.freedesktop.org, Niklas Schnelle , virtualization@lists.linux-foundation.org Subject: [PATCH v2 05/10] iommufd: Use GFP_KERNEL_ACCOUNT for iommu_map() Date: Wed, 18 Jan 2023 14:00:39 -0400 Message-Id: <5-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> In-Reply-To: <0-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> References: X-ClientProxiedBy: BLAPR03CA0072.namprd03.prod.outlook.com (2603:10b6:208:329::17) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|IA1PR12MB7614:EE_ X-MS-Office365-Filtering-Correlation-Id: 9212b8d5-7b00-4766-3780-08daf97dec20 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VhnY/VkdROsKqYj8be1fIWvj9/wmVvhCi5RdHSgcpUI3D7RXN7E/NlHyCI4IaGMavrRy7WNjLTj4gS7AK2XG0R/FnDvs9WhATGQa2YU6LxeWUKoL/vynL7JTTWUEPke5n3QrZfj9mXGYB7CYAiwt6jZMdowB2EcXF1GOlqIV+id3nw+evxRw/4Is4gBEq2bYD5OzLylzWikOdoRCsiT5NT9G5UhHG0KjehYI5QfYYd02QF9nmv8zsgZ5H2OJJKEM/V23Mmv1BZJPm/nS3n3OjalJI/aG38hqnjo7hwicwEeKGZfQY2Sl0QD5TSjgk6/h96NV6u/QLvrmLOyibsCaN92lDNgwEl7F7g/vQenbUi2xQLiBSjXtDJnKV2u/cCd0NJMP0cxBdgIC3YQ7N+wQ5TEpr/6Hdfk52AJAS7fGT6CBnZamQY+dDJv0Y/nHq5uLPRkPmMKzzptv5vNcNiiXgVUyonODB8Pkri5ht3WirfMhkhyPzsqphLwayA6Uu/Qi/9otYtdar/FZ4x8ecZ2zQWHy/fLGbV/SnPDZgfSzXUaqhBYaExRf0GtnYKjvrWUJsRFb8isvnw2n9T+3jKBIsRVWLwDfLFbVi44RMFAMzjiQGd61VBXqVLT5/HFWkfTT64Jpcgb7BiXKvjr9pQc3k4qxDZV+x4B1hFprJb6GCj+6O0LceZKU5GfeuLfapTEk 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:(13230022)(4636009)(346002)(39860400002)(396003)(136003)(366004)(376002)(451199015)(6506007)(186003)(26005)(478600001)(6512007)(6486002)(6666004)(54906003)(316002)(110136005)(4326008)(66946007)(66556008)(8676002)(66476007)(36756003)(2616005)(41300700001)(8936002)(83380400001)(2906002)(7416002)(5660300002)(38100700002)(86362001)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pY8Du1khAX41fW7ZAX/0US/CVQES0iyKzWtL1OlGRvz/lbP0CTnlZRWNiQXa8bCsNWsvg4HuoE4gwYaohFrBHl27vCZPqf18rHHjoZ/51VunMyNxuvsLGrZiz7O6rgnWEX6ktfnjJ7sALrwaqubswcWivYkgxNxZmUZ2QF303uRk+R6LvuFEkxv8zahtJ69IecGsJ5uYY5FYCbGhuUy8HeBf2m82qPSyYi14wgbzRVm+G7QR5Fw00MSRrQh6ZDECg+Hh/5smYwKkEuqGnp1u6Bzmv6COEozCO+ChMiBtyp2UNtasVwIWX4jrmA1rdOcnYxg6Tx6uSNuXHIJ1pk+U/PphREu1Gg3nXBlLoW1GcI09T4lutzexhtHyh8WxMUCk1hl190kBJlVoLw6MEathdsepBdDlTrcc/NoUufAZtgSGufjqQMUQvyihv3qUwXQRj4GHzqH2XhFuCdrzj0GX16R6D4Tp6nLIU33ZfmPlUJVu8yuCg+hMtq1AGNP768iTm64t+koJgPZGUx3E0q26P1tXe4x5+zyacnfBXxl91eVrorT7Ki7aX6YS8mI2qnL9F+99JDBzCI3K43q0L+qkMDIDJ0ed1qqSwnU8zEXQyT+GXr8Gdo6Dc3t0Tj2jTjBXhAcicKOXwfo6+4I9Df3C+r97pE0wobeaeDnC8L1pOL2wPlmcVV5k5qggVqidDqZkYJvOW3qLf2WFNprch5e+2BvLvJAKuHVYBryQgoBZKViS5MrDbRhKmafsZJDYA41jaqSlvsXpH2L6CiTCi4nP39cVY5FUrm/u1jmuicUozkHggXwDkbOR37e3tHQpQPTIrHuq6p/XAQBaDBHK2Wo0FyuOZsjwIFOlIDbFKffGpWz77JpR8F+EQXohs4YTHB98gP04knMn4gJNPFTS0tZFU4Rp3ZjewXavosr9aqpfYViV8HVWEl165CyQ/Hg/PVJKQUjPqvCQZb3jjP7zp8gWLGkRrOE1XwsLpXNQF6dvKxwrW+hDi1XuDedAmr0MNri18AhibuLCh+9TkCiwERGobeTpxHmRqDG1IGd7knCmQoOHDOAPzuOQZo7wnp79dbAuuIDvp48ZBeSPcMdkpF3VFJ1o2JHxFKVRjaJulhVNwDXMiPQHnTMlyAmi7D+V9Sc3ZUR8KqRSqOJNx8SeXx3lXftOfwjlhiwsRMWzsDMhlU2+p7OXfOWjU0b2yY0UMKtqBxQNz0btHFx64y3vmijmjTlnVaSUXrggGCxnN3cBjcSSo8Tf6pXa1v++GpmXSBKQhU9stZ4il6PShl57kw5uJfu7T/KMWgOY6Y57zTSeUtpQuPrWWBAkIlsSRXZIeEO9M56GAyLYKN0ijk36RnLl8JaWJIcA1mKZYrAPAD+7hRQ7YeCIJZ5VbIWCnFTcPNtU99KaSlgtsYzF7O9KByRA6pI+UQbZXCpSLwRQdB2IDx9rfiX/QyihqxndRqbkj3eRl3FvICX4BD2N2NHBUdqthY8WeHKx+JfTL9VpFFKerGKNcL8LCtPueI4JnikpeQCho4iw6MhcE1pOSWdP4Ip04cEf+HcwU4Mw3JA2+lOXwHw53Jg7A8Z+TqBeD4+qawsL X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9212b8d5-7b00-4766-3780-08daf97dec20 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 18:00:45.6308 (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: 55MBwQPcT8/1g4nIe30PL0YyKmHQHK4QDIV6WRiXYMhdJmqH/hRVQGW0CN50XO91 X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7614 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org iommufd follows the same design as KVM and uses memory cgroups to limit the amount of kernel memory a iommufd file descriptor can pin down. The various internal data structures already use GFP_KERNEL_ACCOUNT. However, one of the biggest consumers of kernel memory is the IOPTEs stored under the iommu_domain. Many drivers will allocate these at iommu_map() time and will trivially do the right thing if we pass in GFP_KERNEL_ACCOUNT. Signed-off-by: Jason Gunthorpe Reviewed-by: Kevin Tian --- drivers/iommu/iommufd/pages.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/iommufd/pages.c b/drivers/iommu/iommufd/pages.c index 22cc3bb0c6c55a..f8d92c9bb65b60 100644 --- a/drivers/iommu/iommufd/pages.c +++ b/drivers/iommu/iommufd/pages.c @@ -457,7 +457,7 @@ static int batch_iommu_map_small(struct iommu_domain *domain, while (size) { rc = iommu_map(domain, iova, paddr, PAGE_SIZE, prot, - GFP_KERNEL); + GFP_KERNEL_ACCOUNT); if (rc) goto err_unmap; iova += PAGE_SIZE; @@ -502,7 +502,7 @@ static int batch_to_domain(struct pfn_batch *batch, struct iommu_domain *domain, rc = iommu_map(domain, iova, PFN_PHYS(batch->pfns[cur]) + page_offset, next_iova - iova, area->iommu_prot, - GFP_KERNEL); + GFP_KERNEL_ACCOUNT); if (rc) goto err_unmap; iova = next_iova; From patchwork Wed Jan 18 18:00:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13106774 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E50DC46467 for ; Wed, 18 Jan 2023 18:01:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230312AbjARSBX (ORCPT ); Wed, 18 Jan 2023 13:01:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230121AbjARSAu (ORCPT ); Wed, 18 Jan 2023 13:00:50 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2062.outbound.protection.outlook.com [40.107.243.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72A6C55290; Wed, 18 Jan 2023 10:00:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GI2HIIwK3zS9S45jwmETnOThJouM5GrGCy7Xbk0ulvnB35bNAKDPrhPxWPLb7TX5BuNIkXSJsuWKc4jtrIzlrSuXou11iQxGo5C/e3dMTXNvaDNkSSEbI13i0Rv6GsgWCIjWV8KJXGar+onRKHQOG1V1LVxeorZ1WJ5+7S3/EFckff6aKEbwnOuzJFKL74CQ4mqUQ81wwfJK9xerW7iGJq5OR9uEAl4LhAtn+iGRzMeiBsYatGIt9HxM/mf2YxMTKqnWVzENtbos47vNS6mzapNNsj0rNu5ryCeePFOPyjgaaKNr/1upWMQ01+r7QPYIU0Cwr2SF+qbpFOj935XxQw== 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=LEwQDOFR0TbCX7RF0Ze8HpmxiFAMTveYfslQp1/pNBc=; b=bY4JWBszQpIab5JX7lLIoFMMPQWFS+2rxcyIl0J97PCGzUtKBCeqETG6X5XyCQJ13SKt/2Ley7WZU6jn9I/vVLVN0JpXekaipyNnakY3eXLofCtYnxm1fQgMf6rKf1GTYaN3e0Q/zdJgZcGEc5jyfzlSVXZvev5BMPXx9D3mvmuSbU7Iimy6oYpfKER4I9hBI6PZsmiSPqwm/vwGtNBkaf2rvmdIlwHfAkvUhSfeCsVJCec8O3IGFJOFpw1ZuFiSC2anPOz31EQs93cF8tGQ1xE4X38rTG/AdU40eEloTVaI6cHl8STwFAFPqkl+kscrJltDK8qVYvOhBogMDvdxYg== 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=LEwQDOFR0TbCX7RF0Ze8HpmxiFAMTveYfslQp1/pNBc=; b=OXpekDgKH+SYgcCWy1AXVS7cMTLRawijZmDtr8x8G6qtN6i7sgE7OoR05OD+OKC+CvOhXodlhR9ukLTV7XaMzTTRvvY6ztdOeI0Fgr1Sz5VZMvguiyCoaWvgNIWt+9uU2uyFQM9zmKkh5vsfCVWAtvPnRtHHycOb9oEyWuaMK26B5DuivYoBkS82poIU/KD25p47wi1Zjd7BFcVNRbupSAD50yQLomkYdAWX+PlqZb1H8VTiT7bApY0IYFD9NLLG1yBri5jSR0QIprDRlBYA+QhTqEDOX1y4wvCnRAqTZilBpxteYoGQ2HPh42KhtQjAcYLJfsbMQbtOk1LlE5DgLA== 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 IA1PR12MB7614.namprd12.prod.outlook.com (2603:10b6:208:429::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Wed, 18 Jan 2023 18:00:46 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.6002.013; Wed, 18 Jan 2023 18:00:46 +0000 From: Jason Gunthorpe To: Lu Baolu , Joerg Roedel , Kevin Tian , Matthew Rosato , Robin Murphy Cc: Alex Williamson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, Christian Borntraeger , dri-devel@lists.freedesktop.org, iommu@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org, linux-rdma@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-tegra@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, nouveau@lists.freedesktop.org, Niklas Schnelle , virtualization@lists.linux-foundation.org Subject: [PATCH v2 06/10] iommu/intel: Add a gfp parameter to alloc_pgtable_page() Date: Wed, 18 Jan 2023 14:00:40 -0400 Message-Id: <6-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> In-Reply-To: <0-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> References: X-ClientProxiedBy: BL0PR02CA0133.namprd02.prod.outlook.com (2603:10b6:208:35::38) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|IA1PR12MB7614:EE_ X-MS-Office365-Filtering-Correlation-Id: c471ff53-6006-4c87-612c-08daf97dec08 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P52R8Y79yja8EkhaUvF8Xv7rpZPa9bIDC18Qb5n+6s9m/kYptY4S78DIt0f5zQTAhkiSIN5YG86uOkG7MjCvnkrwc+8PDKZD+L85nTKOZBbRIz700Iunb07fMousmBWgYR2LwdmoH1i7uux/xXSH4uRmSlqz2RgG9/98d4yg0s8LRHg9RjzEdW4YQpN+l+V5+w0iCih9suDdh3aPnoycFmVY1XOsnvCUuSfhwzfxiFVSnN6aDRhejjWel95mIgg7C+yxtBPi4RcFRz1rERInnUhjIdzVTZWmDPFatbE9XE690NogG/sq0viCzkKS5ykMkXCPp3M3GZ0b1Cm+Yfxz76clIoicv49m+1VbH5Mamh0h7xHxQkm+gqq6+gBPWV49fWLonFLTEqld0FsPXmvKj3MTuG4GMmlLYMYJkn4aIW6W2I/A8m9GlGk+XFygr6+ELTJgXXsCKfyQQc1OP4MBvEyhCm16XObl0PCMeca5UVwcJU5VvPg2+VHw3J+JT8caLWx30XnQ2jDnMwt0GITMKCuijxtxq16WU9H16PYeYiFWVcVtL0avNaaPb+0uEywWk5wiy0bHLdhb1dZUphMYmk01pa2KnaKSbsI5UrcnzeN1Ohf/MaIeKzHzPvMIKk9k8KDiFk6SnK42DseEyuctioowTE5V0048oiq89wqO1dlUMcE2f1qezoglPlq12a/P 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:(13230022)(4636009)(346002)(39860400002)(396003)(136003)(366004)(376002)(451199015)(6506007)(186003)(26005)(478600001)(6512007)(6486002)(6666004)(54906003)(316002)(110136005)(4326008)(66946007)(66556008)(8676002)(66476007)(36756003)(2616005)(41300700001)(8936002)(83380400001)(2906002)(7416002)(5660300002)(38100700002)(86362001)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: j9B+qfr2ArgFXUux2Hx89VXIRx9EA3GG6tSWqdkMsDGn/qHDlONRkLod7wumBeswYpt/RImPc+Y9Y24PPe00826/ZwFU2NTs4wJi8CbVCt++XIivDp7Eb1UpeVKvUAZveVwbS0RnjRIP9JqfKtk27wkRvJ02/FF6uHQgtoU0TlUKYxUejWgNGzYL0dgemSvryvq0qUIom/1UHMBUD/luLls0DkcAcson6UxUSYz0SLCald4oC+4z2W75ZOeknEe6PFhzrf7u9wbYwdUp3O6e5Mnu2kcHu67NWbS8At0LI1mAUeXKaHgLlcWzgvEipUlALKuLgsKe1ZU9LGX87z3rSUSlgRKATM8edyiI1bOA2Oyg0/wU+LHilCcT0twf7VoTzagaATcNW5MyMXnM54qE7DVNEpajoaJgztBMIGeuOoYpDBMmnOi5k9QQBHB+uBa6R+6WNFCaFxBMnDVQ8oVi+mzGy45c1WUTb5RtAGpWQJMV0+6/bUI1pkiw84iVL4cqyYLRyEy5wufQiUGmT/hBWhcKDoj/OuDigosVa4s+NRxDB1sDr/fHQSK6S28+2StzUQfF1a48eStLSXpaIoMBpVE7JJXEPoeNGidHbkCCS5yhfLBykiJU7p50zswa/G26ey3aaFRnVbDb1abQdrlKDkMNzg+gxL+NkW0YlPSpeybPRaXs6oPMAreCJu5l6LP5YamHekac8gRoSiYtxhiL2+Ir+zcimpc77fAA/InGCcoFOVhmbf54AtNDJ3tcAF0nq5CkOUcz7q966OYOIXxItLcFjqbyHgwQBw8KdEkwIV1TqDeBh3zNhgywlFPAcJc5K4sKcAXukS6ly5pZfZw7NKlGajh55YBG0NC1WaSsnpi5glZHiGaPaMhXAfLkM/w94r1iLUw3TGAJyc9aWK1R/K1/qAap59tzD+kN8cpxnxs/UZvM/JF1tdJ7HcfDN7F9P26WFfhwiDsNp7pgqcUH5/vZaUwWaK7YvZy5x6v2PRyp+D9cMnnjGkE7JVJ5Nkp3T6g3EpPc8epEl49aF4Jc0NQoFiIcSBNs6jWtEJrwrU+tQN7reUPHNEynx+TUpDumFKgSL/osro9KF7q+Vzemr3CbxxFRLduBA4KjwXydX01YmRC3n5V0jkScULxXZBMq+wUQv2jDuTE7DxcTYTIFvHflmXkuZbTlVBXSQYW3RlTXg8kJlFmq1S7yp6cBK7bcDzDB/UtJhB3R2tysK3VITaWnfb4QB4j182qRMUE8HfSpNplNTTt9vqZbNKUbA9yuLILDj+4FHnmrDjn2rEyXcvYGGLzI1tbAdxeSxhcnTS9TdjJqU4boTtrpWC+jgEiBpAH48UDng6g4OgydfxJsGl5GCCtHzj3T/KSL6P9ac0EvbemG+VhmopRlOeqyWI+34s2A1TAi3oJS98OgsTIP3ATfTitle53sISTxAVd/DMf1DLR9+EcOGYd3s277r7ia3Qwr6F7bQZ+s/85Qzlwsp4wgaZ0kd4EkRMQaHeY+bgHsbRhxlVaYHONDQitLco3oMWeRkXHQlRGCmf6VKjQlNugs84uV+rXEYU4oLY3CL/SrVwhUW/ILvSgwwPHthqiM X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c471ff53-6006-4c87-612c-08daf97dec08 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 18:00:45.5059 (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: eR1G+sA4Vjr3Bbfb6ntV31Qw8QZTtT8TraOFac4JpoKqOYnzmVKt6F4lFVzsknd0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7614 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is eventually called by iommufd through intel_iommu_map_pages() and it should not be forced to atomic. Push the GFP_ATOMIC to all callers. Signed-off-by: Jason Gunthorpe Reviewed-by: Kevin Tian Reviewed-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 14 +++++++------- drivers/iommu/intel/iommu.h | 2 +- drivers/iommu/intel/pasid.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 59df7e42fd533c..aa29561d3549b3 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -362,12 +362,12 @@ static int __init intel_iommu_setup(char *str) } __setup("intel_iommu=", intel_iommu_setup); -void *alloc_pgtable_page(int node) +void *alloc_pgtable_page(int node, gfp_t gfp) { struct page *page; void *vaddr = NULL; - page = alloc_pages_node(node, GFP_ATOMIC | __GFP_ZERO, 0); + page = alloc_pages_node(node, gfp | __GFP_ZERO, 0); if (page) vaddr = page_address(page); return vaddr; @@ -612,7 +612,7 @@ struct context_entry *iommu_context_addr(struct intel_iommu *iommu, u8 bus, if (!alloc) return NULL; - context = alloc_pgtable_page(iommu->node); + context = alloc_pgtable_page(iommu->node, GFP_ATOMIC); if (!context) return NULL; @@ -935,7 +935,7 @@ static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain, if (!dma_pte_present(pte)) { uint64_t pteval; - tmp_page = alloc_pgtable_page(domain->nid); + tmp_page = alloc_pgtable_page(domain->nid, GFP_ATOMIC); if (!tmp_page) return NULL; @@ -1186,7 +1186,7 @@ static int iommu_alloc_root_entry(struct intel_iommu *iommu) { struct root_entry *root; - root = (struct root_entry *)alloc_pgtable_page(iommu->node); + root = (struct root_entry *)alloc_pgtable_page(iommu->node, GFP_ATOMIC); if (!root) { pr_err("Allocating root entry for %s failed\n", iommu->name); @@ -2676,7 +2676,7 @@ static int copy_context_table(struct intel_iommu *iommu, if (!old_ce) goto out; - new_ce = alloc_pgtable_page(iommu->node); + new_ce = alloc_pgtable_page(iommu->node, GFP_ATOMIC); if (!new_ce) goto out_unmap; @@ -4136,7 +4136,7 @@ static int md_domain_init(struct dmar_domain *domain, int guest_width) domain->max_addr = 0; /* always allocate the top pgd */ - domain->pgd = alloc_pgtable_page(domain->nid); + domain->pgd = alloc_pgtable_page(domain->nid, GFP_ATOMIC); if (!domain->pgd) return -ENOMEM; domain_flush_cache(domain, domain->pgd, PAGE_SIZE); diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h index 06e61e4748567a..ca9a035e0110af 100644 --- a/drivers/iommu/intel/iommu.h +++ b/drivers/iommu/intel/iommu.h @@ -737,7 +737,7 @@ int qi_submit_sync(struct intel_iommu *iommu, struct qi_desc *desc, extern int dmar_ir_support(void); -void *alloc_pgtable_page(int node); +void *alloc_pgtable_page(int node, gfp_t gfp); void free_pgtable_page(void *vaddr); void iommu_flush_write_buffer(struct intel_iommu *iommu); struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn); diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index fb3c7020028d07..c5bf74e9372d62 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -200,7 +200,7 @@ static struct pasid_entry *intel_pasid_get_entry(struct device *dev, u32 pasid) retry: entries = get_pasid_table_from_pde(&dir[dir_index]); if (!entries) { - entries = alloc_pgtable_page(info->iommu->node); + entries = alloc_pgtable_page(info->iommu->node, GFP_ATOMIC); if (!entries) return NULL; From patchwork Wed Jan 18 18:00:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13106781 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D9FFC6379F for ; Wed, 18 Jan 2023 18:02:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231286AbjARSCC (ORCPT ); Wed, 18 Jan 2023 13:02:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230508AbjARSBN (ORCPT ); Wed, 18 Jan 2023 13:01:13 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2046.outbound.protection.outlook.com [40.107.243.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8A6E59E49; Wed, 18 Jan 2023 10:00:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fkcoa9bO2DmLUEujoDK7cPqe7qArEmmGF5QJ9CftbCf/7ffDljQN0brr78iIwkJuIXN+n5lUl4GxTgbPUaDoEADzF6XW20qM4RTGX21aH1NBheTDw6/+VOIa4fQJZnwe6rMmy6qIaMq2Fn0x3FiDSu2EStY8OtROSu4bDCyQHVMRGhWnv9jaI6lh+/sctXRt15mBoP0ewe6af1smHLtH+LvluzUh9lwXMNwenOrEmVgpa90lSasm0HpW74RnW3gLEM21whLmwHumUFUWzlI27ClyDzm+2DEIGRlgPC5P4wakbZhnjrZ8xOOiTdk10yXtN+2dt5Lqj0QM5o9ucJNCoQ== 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=00QdWbWiUTWl/6S3U7Pl+WfF55hYSq8tk2e8Rg76hyc=; b=I/1o0wPH6qKccjsP8/2qplZC5zhMDAKQBY/hno/pr9qxFnpBwTNJQ/SYuz4ll0Z6RRdSmCkDqHS47eh0kKT++tTAIoJzmn4LPYXJ/dQpdW8ShAUaE3SAWDqbz9RMS2VFiC7mZA3P0FSL/iK4BNE7u4uWoXNaDFgaqtT7ZuVrn+GXGOLf1kixKtZzftJbvMB4u1GYxJqS+Glwcp+Rxvm24QNsxRqwPqvufjMV/DE3n92FpODEBTf4+8l0awd/6xywXaDPz4lJ9Vc9D+HkcNnQQaHtjd10hRN1M3ilVQyyQI2uBTZgZB+/k86nzaw877diVP8Hfe5iClmnJ4PaWtjS1Q== 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=00QdWbWiUTWl/6S3U7Pl+WfF55hYSq8tk2e8Rg76hyc=; b=Te+noWkSQrxmJdQR6nqmu5DkFCRE0NkGr8FdZOTuspMiC7dUnJ2NtDWvyS+149f7IolvrRWoBde7ZAus4WnrpiaQM069dTdAFHaUX1hJKSPRYzEy0wHv4FFtpVvgrc5H9LiCyab5ZLwp8Z6JLFFCnNO2n0oS2LRD9grKVXOiPPkN5WwiHKvFDDirBBvxjEgjhwt/o9tnt/MSSrSyoeILfyh3pacjcTzzfh79elHou/X/TLI8L+KoQ3gR6+P2tAPaA0BCi4SQRKLA2RogQ7AQ0Zw+7cYo/dVdbysHVCfoX8jNZaF1QZpP0jv4NoW5o9IRLaSPAEPbWcZSOqFNB01G3g== 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 DM4PR12MB5818.namprd12.prod.outlook.com (2603:10b6:8:62::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Wed, 18 Jan 2023 18:00:52 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.6002.013; Wed, 18 Jan 2023 18:00:52 +0000 From: Jason Gunthorpe To: Lu Baolu , Joerg Roedel , Kevin Tian , Matthew Rosato , Robin Murphy Cc: Alex Williamson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, Christian Borntraeger , dri-devel@lists.freedesktop.org, iommu@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org, linux-rdma@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-tegra@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, nouveau@lists.freedesktop.org, Niklas Schnelle , virtualization@lists.linux-foundation.org Subject: [PATCH v2 07/10] iommu/intel: Support the gfp argument to the map_pages op Date: Wed, 18 Jan 2023 14:00:41 -0400 Message-Id: <7-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> In-Reply-To: <0-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> References: X-ClientProxiedBy: BLAPR03CA0082.namprd03.prod.outlook.com (2603:10b6:208:329::27) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|DM4PR12MB5818:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b91501e-2a1c-42c1-a24e-08daf97ded07 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wXhR/hMOUioS+TAvae2HjS17kk210XPZwUSkleqGo2CZtoJYIv28foLDtPBjmiGcRuk5JA0ETaOD0kBLLuiJeOeIQCN69BjsNVrmJm8XqSXgjcBuVzO/gegL2jqIc54HKaPcKD7UzrB2Aq9kjyAnjmA6yltMi7CF8ItS4n4bbwEx+Wko318RCZ/Br1//Q98THuVsCg+/vZF1V4umCWFRaDfn/6y+JL4W1gmp/CLB9l+t/DP3zCymo1B3HtjznbmFivwGLE96SiBuKn0SWh1gatgs3PZxqKVjeYuAXioBsoN6VyLDny3F5btwGZiX4YKiShY4Y84Os0bnsqWVoD34K4xsUbzjHMd/sztC56gDWHG1C1C6kcGLzncTn6gqEkl5VxRnS0cE8GrUkM6F1NDG46OGGqAOobtdWmryd5B/5/zk6sEUDI2d+HAHzBuEeAc2XqZ9pEj4cHpLiXRnP71c8QSm+KxV/m4lqiwkjn3uCkEAF9Y5oWX4wYt6/qks97C5swEmAcYDFFNsCcWd9omrAegOAXBJ/6suZlU98in2X9k0F1u824/eQRVpqwpn+BX5yFFeYJqwFQMPlA3c8nSIqQlUSdTpVR1/5gpL7frb36He0VTN/ONjqbtMRV3WQoXPpuGXipmPU8pn77ZkPOQjDh9GPB4v+w75KcrQ9GFuPzKqm9AJeLmyXlILmKH6HEa9 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:(13230022)(4636009)(136003)(39860400002)(376002)(396003)(346002)(366004)(451199015)(8676002)(36756003)(83380400001)(41300700001)(8936002)(2906002)(66476007)(2616005)(110136005)(54906003)(4326008)(316002)(5660300002)(38100700002)(86362001)(66556008)(7416002)(186003)(6486002)(6512007)(478600001)(26005)(66946007)(6666004)(6506007)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YsC1oIu8+hWAQkFsEI3zbTnCo5RxDY24onOl1xpoKzQuHS9BKfd/5sC4mEFqWehTZC/nOd3HO7O2CZVcB8UJRa46pdSnBcHqco28s9xB1ioPgx+AZljqG9FnFNORWOlL1JAwyMtB6IDavDIVTC9YN2qNOGJPtX5lLDGQ9OPAngxJChRMiqK1Okw7l71v+VGthg2CIF2CKlIvfkm9vplAB6u40k6POtbE8ca2IGvLfjfu+EMLxiv14RkUNyzuHGG4k2rfGa8Df4VhMyttEfoIp8qFxGMbYOWanNgNyFsPYaHLeNn5CiggQaaL2hCTsFnAt+5OYUKgieQz2EJ+wA/o3XcBEcEcqXdcw2azWbaDy82NaAXBO+lhPyauArIS88j8Ml98VtPMQSI54t0tg9p030of1yxLBHHLqCm1CxW04AA+PbE64nb9dBaCqg+Q1r3K7e38D9JGNb8yZt6LXUC4efVwndLMyZ7AlUgKv22YrsNwTV3hLD/G3G0/OcKYlXUrE6EWHuyM6lFa7tATNvT8qs7imKMAsALQy06mW9XQClGr+yd6LGHBlF2nomEDyhHWToCSJD10MGPOr4s6A5sUyaDE14kBsor87lovQbvT+7IJxmHuiS9zxzz/QAtzkoaLdUAgWwtnNlnnhKRV/c0hPd3chFsngdoZbkJcVG89EWcJqgYWOVVpf9MO+fMJ61p5UeH622jaVgbtZyQ7vp7QHf277tqJ9rixzafEG7b4/3Qwnyet17al70JbtnzATVhz298WqEothDFh5OHR4IKEFKapQZ2LgXJn6YMhdxcBNVKc+itOpauY9oMdJB/sbh7YFzqgZAI8Jw4cekC+q0kTb6YWAANUU3zmcqHoLKDV5Ycl2gd5Tz+9TyR4FvVT18HlQK1/Zv07/xZAHBs0DLXEEso1DGGCmVHJkZVy3oMCEX/z9Y/R8CZcJRdXvfWWai5gKLVCNEDZPNMoxT7wuhZ7IavGoHbGUuqEKg5KJDMebBc2U60KyPFEQF6S76e/4PVVeP9akaPd8X0WQgnrambdJ3aCTt4EAp5DHy57K0voXA+PS66eAa7Mpot08LNHbv1RpMvs6TvvBYFZijT/n2ObCg6PllIQi0CwrqS6O3RAhDmavyAaOdrYnXj1bmVz2Eu4fXLgjKKF38Xo8UiJqkLFnhNRuwTU8chxiHZ3VtrDTI7lKd8Q1EaNag8+x0tD7Lypt8P5MYCF0KaIwQtLkGg6ne4WS7N/N+fcuuwUkbniG1lF0iG/C3Z7G7wxvL/+AY0C1d7TSopyVL1QO2Z0KgWE1fAJT1cASs2Ri7WJPPl9qFyRIVxI2kA4bPh0MU+tpd3qgcnTIyMjaPwOfd1yhfopMxUT9JzOQm/OYXy9Phf2AwmQfYFSUrpCZ+lSrqAh3tv9zglkrNEtDLoBU2/pB8QQyCMyJ+vWH5SAt/3u8xqb2d0xl4OsOCWtwHGHRSxIPdZVLFJQUBedmSvzcI6E0b9FvNXtBUJiDIFXRTKVS/V092I/+/3+y1hZHDHhZcPxBU58tIkqoCumxkoXhNXGm1kjLOK0JmBIh1JbwW7iVkmQILacRkuSwQvF/kfNCi2kBLYr X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b91501e-2a1c-42c1-a24e-08daf97ded07 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 18:00:47.1618 (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: C2DstoSMCrTqKjo6SEsEuyqVUk/YdC02pAn/7MeZ7gCKjrdJ6yWDp3WDlP8Ohi5C X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5818 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Flow it down to alloc_pgtable_page() via pfn_to_dma_pte() and __domain_mapping(). Signed-off-by: Jason Gunthorpe Reviewed-by: Kevin Tian Reviewed-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index aa29561d3549b3..e95f7703ce7b83 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -908,7 +908,8 @@ void dmar_fault_dump_ptes(struct intel_iommu *iommu, u16 source_id, #endif static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain, - unsigned long pfn, int *target_level) + unsigned long pfn, int *target_level, + gfp_t gfp) { struct dma_pte *parent, *pte; int level = agaw_to_level(domain->agaw); @@ -935,7 +936,7 @@ static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain, if (!dma_pte_present(pte)) { uint64_t pteval; - tmp_page = alloc_pgtable_page(domain->nid, GFP_ATOMIC); + tmp_page = alloc_pgtable_page(domain->nid, gfp); if (!tmp_page) return NULL; @@ -2150,7 +2151,8 @@ static void switch_to_super_page(struct dmar_domain *domain, while (start_pfn <= end_pfn) { if (!pte) - pte = pfn_to_dma_pte(domain, start_pfn, &level); + pte = pfn_to_dma_pte(domain, start_pfn, &level, + GFP_ATOMIC); if (dma_pte_present(pte)) { dma_pte_free_pagetable(domain, start_pfn, @@ -2172,7 +2174,8 @@ static void switch_to_super_page(struct dmar_domain *domain, static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn, - unsigned long phys_pfn, unsigned long nr_pages, int prot) + unsigned long phys_pfn, unsigned long nr_pages, int prot, + gfp_t gfp) { struct dma_pte *first_pte = NULL, *pte = NULL; unsigned int largepage_lvl = 0; @@ -2202,7 +2205,8 @@ __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn, largepage_lvl = hardware_largepage_caps(domain, iov_pfn, phys_pfn, nr_pages); - pte = pfn_to_dma_pte(domain, iov_pfn, &largepage_lvl); + pte = pfn_to_dma_pte(domain, iov_pfn, &largepage_lvl, + gfp); if (!pte) return -ENOMEM; first_pte = pte; @@ -2368,7 +2372,7 @@ static int iommu_domain_identity_map(struct dmar_domain *domain, return __domain_mapping(domain, first_vpfn, first_vpfn, last_vpfn - first_vpfn + 1, - DMA_PTE_READ|DMA_PTE_WRITE); + DMA_PTE_READ|DMA_PTE_WRITE, GFP_ATOMIC); } static int md_domain_init(struct dmar_domain *domain, int guest_width); @@ -4298,7 +4302,7 @@ static int intel_iommu_map(struct iommu_domain *domain, the low bits of hpa would take us onto the next page */ size = aligned_nrpages(hpa, size); return __domain_mapping(dmar_domain, iova >> VTD_PAGE_SHIFT, - hpa >> VTD_PAGE_SHIFT, size, prot); + hpa >> VTD_PAGE_SHIFT, size, prot, gfp); } static int intel_iommu_map_pages(struct iommu_domain *domain, @@ -4333,7 +4337,8 @@ static size_t intel_iommu_unmap(struct iommu_domain *domain, /* Cope with horrid API which requires us to unmap more than the size argument if it happens to be a large-page mapping. */ - BUG_ON(!pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT, &level)); + BUG_ON(!pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT, &level, + GFP_ATOMIC)); if (size < VTD_PAGE_SIZE << level_to_offset_bits(level)) size = VTD_PAGE_SIZE << level_to_offset_bits(level); @@ -4392,7 +4397,8 @@ static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain *domain, int level = 0; u64 phys = 0; - pte = pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT, &level); + pte = pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT, &level, + GFP_ATOMIC); if (pte && dma_pte_present(pte)) phys = dma_pte_addr(pte) + (iova & (BIT_MASK(level_to_offset_bits(level) + From patchwork Wed Jan 18 18:00:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13106771 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB450C46467 for ; Wed, 18 Jan 2023 18:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230418AbjARSBH (ORCPT ); Wed, 18 Jan 2023 13:01:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230211AbjARSAv (ORCPT ); Wed, 18 Jan 2023 13:00:51 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2062.outbound.protection.outlook.com [40.107.243.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C404552BD; Wed, 18 Jan 2023 10:00:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g1UKIXGh4R5oiPp7pZv4E87H25Dl5kJ6OhaNWVI/ohJOuHcmSiD7RENHZo35+y8+IjW2Q+NFL7H0eGCq+KcVgWei3+mqbATloGFQJd/sA2eQxlhZ4+Rb2G//NKrrr5Fcnnm3KZVugIcj3i1FODfHt1q0AMiDxn5X2AibQadqWBTkl+uSzWvBa4A5S/o5a7HEQdMDTWdgYJp0ouz0ybM16+USI/IwWaP9iksqAw1SWb5TCGt4grQhBy5PFcyj3sYpLSBafBp8L1wfw91X8WdvduGSxtW+M3hQUzDv+hSYJ/bX/K1488GUCYOuk0Aql712LkMaf8d/7Ln7VE27GUfc8w== 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=8uOOUUOL4gGvZRR+WN42+Xle0Izn4ZSA4TRUFQt6ShE=; b=cDaOpqv0PcJcjSL836icdtrRUvs5x7AT92Z9Ya7aw+nkdcajLzJjqnnGzYXgPRO8j7A44e15Bq5xCpubAw6ZjlmXKvberw0NlIxHM+UzRAirNJgT2gD7rwjRkYcy+BrJsBlWMS5cG1rLdTRWKWk/o7yESEiENxQKVvFR5dCDJNYyYsmkQgTe9560W+3E4pvmqeO4bwv/7wlebH68X7oqxp9K7MNMkBBJeF9ZlFD8JypMqHSY/ml/AIFZLWAXv4fM4Y8pfnY+lcftDq4z5ppINDv6RZMIQ1Y4uod5kA5QJfyZo4TFmHZsPiSpi18QEbK/RPJXTXLKncKd7Wt18l2gvg== 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=8uOOUUOL4gGvZRR+WN42+Xle0Izn4ZSA4TRUFQt6ShE=; b=b3bOFZJX4l6UWb3rWC7MFk/RD1L6GAH5EyVj5JF2TiN2BRD2bQoICw9aKx/iYvP0mMH0qrXb8rN4D1qBM3br7bDE6Z5kGsgPo/SiwHInCj/5TIdEM+b3VcrIVWjdLnG61aR6apBzdT3ks9XpsMG5RUwPGSqRrzHhccWwhn/uQGQ2jfACwhFrpp7RFTqPv+qEq0oL5cvlTZrO3vRIwmsSZLjFJ6hudwpqMCnyoZHKeSVj0XAeSyIJ3W5C0zmC6QaAANaXbTlCG7+QF6zaQXiUztT/rCCT+vUXKpUY6dZTLCUuYJtV4EonW7R6DQvEK1NzZzjsyP9REEDh/rEVRxr2RQ== 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 IA1PR12MB7614.namprd12.prod.outlook.com (2603:10b6:208:429::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Wed, 18 Jan 2023 18:00:48 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.6002.013; Wed, 18 Jan 2023 18:00:48 +0000 From: Jason Gunthorpe To: Lu Baolu , Joerg Roedel , Kevin Tian , Matthew Rosato , Robin Murphy Cc: Alex Williamson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, Christian Borntraeger , dri-devel@lists.freedesktop.org, iommu@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org, linux-rdma@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-tegra@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, nouveau@lists.freedesktop.org, Niklas Schnelle , virtualization@lists.linux-foundation.org Subject: [PATCH v2 08/10] iommu/intel: Use GFP_KERNEL in sleepable contexts Date: Wed, 18 Jan 2023 14:00:42 -0400 Message-Id: <8-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> In-Reply-To: <0-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> References: X-ClientProxiedBy: BLAPR03CA0070.namprd03.prod.outlook.com (2603:10b6:208:329::15) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|IA1PR12MB7614:EE_ X-MS-Office365-Filtering-Correlation-Id: a5a69345-a01c-436b-51ce-08daf97dec4b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M4CXtxxQO9qF+Sau11E0b1oaPPiAZpEwBPRQFKY6/wBqYu56uLQR8bZsbeymxlMrqN9Q475nf/4/saPyGaocs2r6FvsjNUZNO/Vb4BgNY+Cgl/I+DCjrZYhYsAefIgoiNgLQ2XR6hHgs9WAw5Y3CXmLDr/BafS2p0qZi+PUCzZQz7CFofPS/nN8QhF5ttfinWu/WB9g86VsOT/XgAWl53uiluz+5v9dMZfIOaSAi96vd4QCpvvDEzPSX6x0ZfPqZ4LouMItw8yFl4e4vXLlf+w+sLqnf3O1jX6tUXAEucswF6pA5IP+dcv9TH3/cv7imLclxptkhyEeMUPY3cE1IvcQW2HvwIOSKGK8e77MMzT2rjxff9Fu5zCDcHOhmG3372ufTdCbcz+sYYPseMCuMOZgKAJ9eBUSmwA5zx/oQPoHa0NHvtCsYpbUU3qsmbnpqbkDxTBBgQLyvy9ka0THmD7zQRkztUfJq/90Rbq6KO+Vnp+wXKo01WcAFYRwnwFWX/GjDobL/+r9HnuNRIdRN0Ent6rw0KKzzPyL+s93VKnbJEuJspsOQmC72KxCev83sUX5AE8iXicg832+/SIuHacpNPKwiF29fz/BX8DIpy3XRbxWn4Icom8EPmb3FEcWSBDjCoekMxHTfH1WcydM1sa28A+0U4Dce8R8gGdUlfBeXaWWBDXTi8YclIZHCdcOK 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:(13230022)(4636009)(346002)(39860400002)(396003)(136003)(366004)(376002)(451199015)(6506007)(186003)(26005)(478600001)(6512007)(6486002)(6666004)(54906003)(316002)(110136005)(4326008)(66946007)(66556008)(8676002)(66476007)(36756003)(2616005)(41300700001)(8936002)(83380400001)(2906002)(7416002)(5660300002)(38100700002)(86362001)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: D4pi8WCKPrVH02kCBQ7m5F2S4awYjEluHqNTutFAttYZlYMDYw21IAprhzB9U76DS9pfjusV7PZ1TUEYMC5hSLawd6G67XN9qymgSp0VYnjwvn6lEadrXsFDuR9lafgh3Jhu2s62/qf185IiNkNtQlo8nPZAOMC01uOEnPiOClYrYWceSeBjFHE+O1gMkO3hgj67d11ieqh7YfO7VuKo8ejGIHhHdomVi2BhD01TRPX89K1sHPAzG9x7tn/wc25zRzex4UJ9PgwYJvg2GH14+xWfEnv7dh642U8WgiJC/Tqv8ZEmFQ2QwOPZHJyjeGHa69mm61MI29Ck8T7/TBuEIEtrZFKljn6goFENT5hkOjMCQpvBIom5k6DhDkNlHMLYdkw1TWRAIObeQFQsxSy+T1XThM25bcapN+gQSh57NFHQRCPZ6h0rOvbGONbSIWr5ZHwx666/IvPM/aBJ7AXDct/b+FpxBMwymgsH38SYrIUvN09KzNSdcZo+AHPMn4GB8qb3gxXKjq0LgknJxtp570cV2SUJSSMm+OSABuBgdoe8q7bTtIylMpUwt+7xUCQd11khdRlbRRsbCEIIBnSuQtwNgCQCvYkCe0FTW2FhfyN3ZXTu+ecnZNutmAZ/p+AeFqtwxaGNxerHREu7yBCPPrJYjNluSH42+jynau/guFwqRRRCUA27+hLuqVCrdroqvgwKyEiWKyrfT6/4Y7EB+HTZq1A5XeMUtI+vQ+Y+uXpDNncGKwqD7U02d4P1zSUe0doXtCQSelY3nUd6eAI+ZbfpwKwGkUECWixMEQQ9VzTdR2qsLuxBqkWCG4Oo4BQrZcTkD7ChuQKOEKlf2SJErshLKp4K5MBIiciaBra9Szsy+d7UfugQXy9KwfcfxbUMrySoiduTj08enSaOSKOWJFuHgpClYsWYSUyeogtVJUe1BkhhOD+bXrOPSYhj5fLbH8+x2VmpKMbgcW7x5J0xpHG2+zUvCAvd3C5hxLt33WGVsQoprOvXrAOgLCCr+8tiReLlwOuzxlnAvRPoVrLEF3NyHQiDz6AdKfltgZ0zwZw8QVcA767jK3lGOxXuXjLlrslTRAri6wC+L+4K1/9PaFN8HgTDbfoyaX45DDsSywjDXOBNpcZlN857Aux5K1xnrq8hjBC637aDhX1tXSfhkRjdVy0M346r5aplQB6BXHqeUPcFWg7WA7qt8ndoa24WHIe8yD12ZG5QYFi2RuaQyp0oi6wcxtHmcwoWtFBMlhl9WSSmh1XKJkUfTB5fiqntrM+ugj722OCyPlLVWkDYgScv7i3ZxKClNdJgxpVbEDHgMgcOGc+eKCJizuoWjW66iHtUAcvFiNBMjm7hx4zesafkEBtQ2kM4g6p/r2o8A5fHFk7h2Zpo0jUImadYKbTlq1b3j8sCtVOfqR24mDzj9gK49vM/pjttnISUVK6iHyJkD0jHdxrjCp2n/m3Ny4/5mXrBaHf1BI+Ghw+4PQ8zfXbRqJmC+yEl8ko/wtcs48wBGKPs6DEcnb9AD097uUnnvs+uLohG5WqFlw7O4LfDJMuLE/5yXWWw54zirJxtFegH1/gMudn5jK9GKxGGOsBZ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5a69345-a01c-436b-51ce-08daf97dec4b X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 18:00:45.9902 (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: jIMex9DmzSNfbXvUopUHrmQVwxPw3OnGg2iXBoYF6MRDT132YRNeIOLlx7/qi50I X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7614 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org These contexts are sleepable, so use the proper annotation. The GFP_ATOMIC was added mechanically in the prior patches. Signed-off-by: Jason Gunthorpe Reviewed-by: Kevin Tian Reviewed-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index e95f7703ce7b83..a1a66798e1f06c 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -2372,7 +2372,7 @@ static int iommu_domain_identity_map(struct dmar_domain *domain, return __domain_mapping(domain, first_vpfn, first_vpfn, last_vpfn - first_vpfn + 1, - DMA_PTE_READ|DMA_PTE_WRITE, GFP_ATOMIC); + DMA_PTE_READ|DMA_PTE_WRITE, GFP_KERNEL); } static int md_domain_init(struct dmar_domain *domain, int guest_width); @@ -2680,7 +2680,7 @@ static int copy_context_table(struct intel_iommu *iommu, if (!old_ce) goto out; - new_ce = alloc_pgtable_page(iommu->node, GFP_ATOMIC); + new_ce = alloc_pgtable_page(iommu->node, GFP_KERNEL); if (!new_ce) goto out_unmap; From patchwork Wed Jan 18 18:00:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13106779 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3994EC46467 for ; Wed, 18 Jan 2023 18:01:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231253AbjARSBw (ORCPT ); Wed, 18 Jan 2023 13:01:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230461AbjARSBI (ORCPT ); Wed, 18 Jan 2023 13:01:08 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2046.outbound.protection.outlook.com [40.107.243.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54B0359E5A; Wed, 18 Jan 2023 10:00:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WiWjsrqKjtvOVCAvtrnb5mydyw0RB9yAjwq1VlPZy+74LuXD2yt1pVdibICj7XtUS7hJmQmmjOlRQgKotSvKm9VcZRMNJR+MV4pagzL5gXYREjtQyDxAVH7kabeu0NfnC7B+jshtzJHJboLpIlqdnsEFyGxCz5jZaMbvNd2hkPKv2OWqUOYMISbseDdaTCDzufcVfwHcJzag/mFn+ITsYx608jgxDevLXfiRCl7CpGt8xIcReYX8V+mVvPP5TvKyBQiFleOvp/MaHOq2BMfWKNv1PNLKWPJHSy4ueFDBEBDhq8eP4vwGoaNlRVWM/581YTEAupeuANR22grQ6WzAjQ== 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=M1xwhjMld43bunpt9PDVXY/d6PVY9W3hUPitUQLHOPs=; b=ViCptLNimGZzNfG7o3kyytAy2t0yDi/WX5MlJamOInmkcoMl5vKf3FmGMFtBEgChE+IRFQ5LNR7drwDOF7Efo9QV2Zt97KRrrKUeVCZ2nD/HLhDTUWt3C5sYao8AEAt4xaOs5DzOM9tNJ0caOiO+rZNb8nMyl3BM+2Db+Vgk9yvxkzrSmRNbOA0OCHOBNYYAtcFWfLQb98prcxsTzhxGCuyTAFfdnVsNyUh4IYQP5CwWJ/8IyUOTo+S479KjP7AXCXRwxnNQtyM50QCARTEvjpQHeH9ZWDOaRS+67vumqc7ODh7X8IkCm6v+gNx9TJR4cEeRdJN7UPcrQMfpjunCeQ== 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=M1xwhjMld43bunpt9PDVXY/d6PVY9W3hUPitUQLHOPs=; b=VukqlncPbWG+1BYjjk7I9xWT7DldWJA8zvyRqMkWK3Jz6eYcgm//kMpOUgALoflqCQxFy0OSQLAqEzx2ikFtd+BmzS1QfHAfVB0c3oc9RuR8243g1hVMbBJn90BckMeRKSQ2ts+F9AFuw8bkUvlVRiC9pspQIynJWNMJkulHfpWyrrMFBlzCQvKbWtiExmUfwM8H59or2m0SxC6p0za8BTaYq8PMm5cHCqN1JqeReFKXZjwttyVoVJzUwDLvp2OzBOjA/hndU1daeUewzCkwLrLqutVFHpDt+UifToitT8sZZj28qFyv+PJYunYeSgkTEfSKhmogc+NavMwM7sxPXg== 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 DM4PR12MB5818.namprd12.prod.outlook.com (2603:10b6:8:62::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Wed, 18 Jan 2023 18:00:51 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.6002.013; Wed, 18 Jan 2023 18:00:51 +0000 From: Jason Gunthorpe To: Lu Baolu , Joerg Roedel , Kevin Tian , Matthew Rosato , Robin Murphy Cc: Alex Williamson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, Christian Borntraeger , dri-devel@lists.freedesktop.org, iommu@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org, linux-rdma@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-tegra@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, nouveau@lists.freedesktop.org, Niklas Schnelle , virtualization@lists.linux-foundation.org Subject: [PATCH v2 09/10] iommu/s390: Push the gfp parameter to the kmem_cache_alloc()'s Date: Wed, 18 Jan 2023 14:00:43 -0400 Message-Id: <9-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> In-Reply-To: <0-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> References: X-ClientProxiedBy: BLAPR05CA0014.namprd05.prod.outlook.com (2603:10b6:208:36e::18) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|DM4PR12MB5818:EE_ X-MS-Office365-Filtering-Correlation-Id: e8d75bdf-3e7b-4587-bd0a-08daf97decbd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ckscbfr5WsT0dd8T7+NWZi955iLwXT90Ji5HZL5XmCpQbDJeq7yZJf9UUJROjS8qHd5duGEpuwmeC3BPaBcLokwwGYpaIKoTBJxivaTYLmkICz1QQXReTqr8NVa6LdjK+HYvlUZiDBZqlTiAmihQYZ+FoyrF/lfLzCP2NnwMAJxLcnRNoxJ9Uvvi2E/YbyNehcCMQX9LoXMhGYJANBcgK7sMGHIB9nIjZfUhW27lBU/tZz/ZvX2JwqpXZk+/ZS3vwLWChNfn1tLe6UVBdkP3Y7AS0wfxiPEUJR9t8CZm2TI0NnCrhGXxX2inKDZf3N7Qkh2S5pJxcBdfzhDYI1noDWJ4lU9exwhF6DJtgEo0LtY9OpvVuTqki5g46d8s092u0KFEvHlCammxGzDD9sEvAr6lh9HN18pSDa5ihfJmQahXaEywEPgVlFCFSA+irqkSlprboMnwf/CO4uiMLMVtmMWDbRbaVvI8Az6AfdX6/7ycuJkQE+fz9jp1yEPM8vnjAdCCYw42w4Oliz1pEY0eu8/PmfCkyj3zsi8L95hnI0SyEqnox7v1L9hn/5XvaNMTkMDJd+f3KrJtdpVGm80XlpS1nBKrQZepcd7n86bU+HFjcGFE4VGIv6byiUBRgN8r0o2puJSjBLLiuNBEQoaAMyrocP0jL9gAiKcRGo9sxlVY/EB3lOzPya9lyDpcJRRC 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:(13230022)(4636009)(136003)(39860400002)(376002)(396003)(346002)(366004)(451199015)(8676002)(36756003)(83380400001)(41300700001)(8936002)(2906002)(66476007)(2616005)(110136005)(54906003)(4326008)(316002)(5660300002)(38100700002)(86362001)(66556008)(7416002)(186003)(6486002)(6512007)(478600001)(26005)(66946007)(6666004)(6506007)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SJX4ukpYbXeJu+CCuanE9tXeZjV1+4ZZIu8EK4SE0f7zClv56y+oM2bkDqeH8sBE2CsYLRnMOimf71jZK9olbpQAiBPF/HvdfHgoBgOFcwl5lGDkq2bKRXCVhjeMAu3ZY2pRmVuQOnXU7tgGkDiZQbDbOQC4BYaS18yc5OOUJYlO1URDb0J2SYbyWRkMJix/DxMdeYIwTqs4iahBJavJIMwfs9QWgV6NDlMKxvm1FRsFmwMDNtdK9IH0Ol9bzbnVmEIGEW80YpDEyRIlNanp7bBTdlzMoktDhWLMZHoZNHQWc6tnGg5dKxft8e/y2nvW4PRNq7wfSNBoIDNmDKzja1CyIvJamWI2PVLUkOr4BMmjB4FBUuwqtSK5K4rP9nQlzayhOqQuEdVJwgkKl5bxGTMAfC8DpSuYlNqzD7slS/7VK46Dxv1mD2iW2ldZcxV7Cc61/XjCFoPEU+TyplPJ6zj2Ch0rElwTaGzk31HYiARuaZRZSwWZCA18biII+gnR34yGeLkNLAkN+vVqY/rRuGfMnBDeabCId9VFpidkJPMA6TVQO0HXNSP9Hr7jmg5SPfuafN5d3/x5fhfBtqsA5PAUVueUzPlrRfLGskvpgsUXMEt4pOczv7BmmNz5rAMUYQ2UJpLBXesipoWBSHayD3VirgKB1Ybx/VlAqePPdX2Y7c5VP7yj3HIfMZ0EuR1PexV2CW+T8jQ9HwhUHe31SR0eceluUICpSEASixf1CTYbmVPRj1PxgFfrSGZGdRGHFCfYV42zeSZc8UTs1BOabzMc5ECWiBYISNEcjTwHPQ4R2w3sxWnyqFXjNT+5sx7FadUwbv7wyUAiOVokZMyXcmmnmv+65TIUlsOM7eWQuQx1cVkJIYdpiOy4FUGhbna4aPm1HmiO7gChTlHDZZLmP9yWJ5x985Y0Gbq5ZuIZjOCBW3iQSl+jUZQMFILXv8OtH37scR9rG5ln80ZHJPHAFEHLYW5eQBGsR3yarkJAbFILTlSm/IsxcZWXUgdM93Are4l74/My/+kd0A0keUeoEraL3r9TmT63pSyBOtoBryGjogo4rXpvZF88TOJ89qWPiVAQsTrZxZaxfNJGo4qo/uc1m4/+HNnMGZnpRYdm5gtNmGKnk0Z42rUSJCJEVjA8DVSflD5PR0mheG/sRa5CEV3O+Wjfz0YVVP5A+tCK/tX0lUiAZwyBxsXP21FNH0ktf2YranrG5zbMkkc9mDYBV5MUQNHxVYaiDqX7EasIsRR8E8JsAe7EHTqU2I+bxPAs9+ufCs47mYlTn40RKg9QDOZyHHw49fzK19507rH+USlowM/J1vefGeOPFdM0G24SwOdTNKOiDYn9ldWEXGdOmChM7S6akQST3BcgXV9a6P91XOixwCGdueEcY+0F80zo6x9WBBoTAgzEeA3+NbWYLQVJ1QWqNSIeWdCQwAUNRRqIKqt1rc2y+xEj2UrJldW6WfcYPV2yXAMWJR+JlfzfCO2URqlXM+D2WKU+EXyYpJDBIETLSkm7rigP5x3Dl8IdkFdx/trpgLwn+O206CsfH6liV6Ws0JVUhEcx7YHkpgZ0q73s5AdImGR1AQQq9wuE X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8d75bdf-3e7b-4587-bd0a-08daf97decbd X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 18:00:46.6931 (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: kj9B0OeXC9AMFmSjSQKRKU4oER2+ssLk7PN/SYMvdFbPQ/LbUlcD1v2dT8GmOvqv X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5818 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org dma_alloc_cpu_table() and dma_alloc_page_table() are eventually called by iommufd through s390_iommu_map_pages() and it should not be forced to atomic. Thread the gfp parameter through the call chain starting from s390_iommu_map_pages(). Reviewed-by: Niklas Schnelle Signed-off-by: Jason Gunthorpe Reviewed-by: Matthew Rosato --- arch/s390/include/asm/pci_dma.h | 5 +++-- arch/s390/pci/pci_dma.c | 31 +++++++++++++++++-------------- drivers/iommu/s390-iommu.c | 15 +++++++++------ 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/arch/s390/include/asm/pci_dma.h b/arch/s390/include/asm/pci_dma.h index 91e63426bdc53f..7119c04c51c5c8 100644 --- a/arch/s390/include/asm/pci_dma.h +++ b/arch/s390/include/asm/pci_dma.h @@ -186,9 +186,10 @@ static inline unsigned long *get_st_pto(unsigned long entry) /* Prototypes */ void dma_free_seg_table(unsigned long); -unsigned long *dma_alloc_cpu_table(void); +unsigned long *dma_alloc_cpu_table(gfp_t gfp); void dma_cleanup_tables(unsigned long *); -unsigned long *dma_walk_cpu_trans(unsigned long *rto, dma_addr_t dma_addr); +unsigned long *dma_walk_cpu_trans(unsigned long *rto, dma_addr_t dma_addr, + gfp_t gfp); void dma_update_cpu_trans(unsigned long *entry, phys_addr_t page_addr, int flags); extern const struct dma_map_ops s390_pci_dma_ops; diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c index ea478d11fbd132..2f6d05d6da4f76 100644 --- a/arch/s390/pci/pci_dma.c +++ b/arch/s390/pci/pci_dma.c @@ -27,11 +27,11 @@ static int zpci_refresh_global(struct zpci_dev *zdev) zdev->iommu_pages * PAGE_SIZE); } -unsigned long *dma_alloc_cpu_table(void) +unsigned long *dma_alloc_cpu_table(gfp_t gfp) { unsigned long *table, *entry; - table = kmem_cache_alloc(dma_region_table_cache, GFP_ATOMIC); + table = kmem_cache_alloc(dma_region_table_cache, gfp); if (!table) return NULL; @@ -45,11 +45,11 @@ static void dma_free_cpu_table(void *table) kmem_cache_free(dma_region_table_cache, table); } -static unsigned long *dma_alloc_page_table(void) +static unsigned long *dma_alloc_page_table(gfp_t gfp) { unsigned long *table, *entry; - table = kmem_cache_alloc(dma_page_table_cache, GFP_ATOMIC); + table = kmem_cache_alloc(dma_page_table_cache, gfp); if (!table) return NULL; @@ -63,7 +63,7 @@ static void dma_free_page_table(void *table) kmem_cache_free(dma_page_table_cache, table); } -static unsigned long *dma_get_seg_table_origin(unsigned long *rtep) +static unsigned long *dma_get_seg_table_origin(unsigned long *rtep, gfp_t gfp) { unsigned long old_rte, rte; unsigned long *sto; @@ -72,7 +72,7 @@ static unsigned long *dma_get_seg_table_origin(unsigned long *rtep) if (reg_entry_isvalid(rte)) { sto = get_rt_sto(rte); } else { - sto = dma_alloc_cpu_table(); + sto = dma_alloc_cpu_table(gfp); if (!sto) return NULL; @@ -90,7 +90,7 @@ static unsigned long *dma_get_seg_table_origin(unsigned long *rtep) return sto; } -static unsigned long *dma_get_page_table_origin(unsigned long *step) +static unsigned long *dma_get_page_table_origin(unsigned long *step, gfp_t gfp) { unsigned long old_ste, ste; unsigned long *pto; @@ -99,7 +99,7 @@ static unsigned long *dma_get_page_table_origin(unsigned long *step) if (reg_entry_isvalid(ste)) { pto = get_st_pto(ste); } else { - pto = dma_alloc_page_table(); + pto = dma_alloc_page_table(gfp); if (!pto) return NULL; set_st_pto(&ste, virt_to_phys(pto)); @@ -116,18 +116,19 @@ static unsigned long *dma_get_page_table_origin(unsigned long *step) return pto; } -unsigned long *dma_walk_cpu_trans(unsigned long *rto, dma_addr_t dma_addr) +unsigned long *dma_walk_cpu_trans(unsigned long *rto, dma_addr_t dma_addr, + gfp_t gfp) { unsigned long *sto, *pto; unsigned int rtx, sx, px; rtx = calc_rtx(dma_addr); - sto = dma_get_seg_table_origin(&rto[rtx]); + sto = dma_get_seg_table_origin(&rto[rtx], gfp); if (!sto) return NULL; sx = calc_sx(dma_addr); - pto = dma_get_page_table_origin(&sto[sx]); + pto = dma_get_page_table_origin(&sto[sx], gfp); if (!pto) return NULL; @@ -170,7 +171,8 @@ static int __dma_update_trans(struct zpci_dev *zdev, phys_addr_t pa, return -EINVAL; for (i = 0; i < nr_pages; i++) { - entry = dma_walk_cpu_trans(zdev->dma_table, dma_addr); + entry = dma_walk_cpu_trans(zdev->dma_table, dma_addr, + GFP_ATOMIC); if (!entry) { rc = -ENOMEM; goto undo_cpu_trans; @@ -186,7 +188,8 @@ static int __dma_update_trans(struct zpci_dev *zdev, phys_addr_t pa, while (i-- > 0) { page_addr -= PAGE_SIZE; dma_addr -= PAGE_SIZE; - entry = dma_walk_cpu_trans(zdev->dma_table, dma_addr); + entry = dma_walk_cpu_trans(zdev->dma_table, dma_addr, + GFP_ATOMIC); if (!entry) break; dma_update_cpu_trans(entry, page_addr, flags); @@ -576,7 +579,7 @@ int zpci_dma_init_device(struct zpci_dev *zdev) spin_lock_init(&zdev->iommu_bitmap_lock); - zdev->dma_table = dma_alloc_cpu_table(); + zdev->dma_table = dma_alloc_cpu_table(GFP_ATOMIC); if (!zdev->dma_table) { rc = -ENOMEM; goto out; diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c index ed33c6cce08362..654ec4411fe36c 100644 --- a/drivers/iommu/s390-iommu.c +++ b/drivers/iommu/s390-iommu.c @@ -52,7 +52,7 @@ static struct iommu_domain *s390_domain_alloc(unsigned domain_type) if (!s390_domain) return NULL; - s390_domain->dma_table = dma_alloc_cpu_table(); + s390_domain->dma_table = dma_alloc_cpu_table(GFP_ATOMIC); if (!s390_domain->dma_table) { kfree(s390_domain); return NULL; @@ -260,7 +260,8 @@ static void s390_iommu_iotlb_sync_map(struct iommu_domain *domain, static int s390_iommu_validate_trans(struct s390_domain *s390_domain, phys_addr_t pa, dma_addr_t dma_addr, - unsigned long nr_pages, int flags) + unsigned long nr_pages, int flags, + gfp_t gfp) { phys_addr_t page_addr = pa & PAGE_MASK; unsigned long *entry; @@ -268,7 +269,8 @@ static int s390_iommu_validate_trans(struct s390_domain *s390_domain, int rc; for (i = 0; i < nr_pages; i++) { - entry = dma_walk_cpu_trans(s390_domain->dma_table, dma_addr); + entry = dma_walk_cpu_trans(s390_domain->dma_table, dma_addr, + gfp); if (unlikely(!entry)) { rc = -ENOMEM; goto undo_cpu_trans; @@ -284,7 +286,7 @@ static int s390_iommu_validate_trans(struct s390_domain *s390_domain, while (i-- > 0) { dma_addr -= PAGE_SIZE; entry = dma_walk_cpu_trans(s390_domain->dma_table, - dma_addr); + dma_addr, gfp); if (!entry) break; dma_update_cpu_trans(entry, 0, ZPCI_PTE_INVALID); @@ -301,7 +303,8 @@ static int s390_iommu_invalidate_trans(struct s390_domain *s390_domain, int rc = 0; for (i = 0; i < nr_pages; i++) { - entry = dma_walk_cpu_trans(s390_domain->dma_table, dma_addr); + entry = dma_walk_cpu_trans(s390_domain->dma_table, dma_addr, + GFP_ATOMIC); if (unlikely(!entry)) { rc = -EINVAL; break; @@ -339,7 +342,7 @@ static int s390_iommu_map_pages(struct iommu_domain *domain, flags |= ZPCI_TABLE_PROTECTED; rc = s390_iommu_validate_trans(s390_domain, paddr, iova, - pgcount, flags); + pgcount, flags, gfp); if (!rc) *mapped = size; From patchwork Wed Jan 18 18:00:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13106776 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62BCAC54EBE for ; Wed, 18 Jan 2023 18:01:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231218AbjARSBa (ORCPT ); Wed, 18 Jan 2023 13:01:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230249AbjARSAx (ORCPT ); Wed, 18 Jan 2023 13:00:53 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2046.outbound.protection.outlook.com [40.107.243.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72E8A56895; Wed, 18 Jan 2023 10:00:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NsA9cv7REBe37zw/vOhFLLGs49vLLa6GxZ9aW2n+1YdbHbZ5912j/snkSjQqBkWUahO+t99LZzGLzaDd/QeW0WyB2FCi+I8u34ULF+SHAklY6qgCr7YE6udA8Da+dfJFv1OOcEmjkvLRWGJBNQWoR8GmKx/sgXC1hkavbG/kJu4tGsDFnnPdzqOoJQmumOYphWMRn44SBv3J2wTlOnpOLls5D9zJVnsWZhOqWYu3nYs4PB6XafOLu2+YEAg1Dau6wDwX7+jDQJ2KyViTtbK/Vr4a8DhijDJQYF8bIIznmU575dcXZhg+pPodA8LzDslg1/3fjClHjgBsJX9Vm5Akjw== 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=vqPQQtTRQUpYSGOXmSqMnJWIpGPVCuIxL1bg187xZXs=; b=Jec7mNtiT7LwijgwO0G8/3sDu3mWO7u8/M/KcWNhYtyFFL2661UrrME42VBXYIGlcK+OlLkU+bE7U8aLlkCDC3g5tylwpRc4DInBU4S9TpG8EAx8lW/bSN4x4176+wAk2iKK0OEFR0aBG/Y7jx2gfc3LmPLx/spJ+J9h9/+1qDlZ1F2j2xUX0e5QDt0Yp8Awa5pW6h6PkycEB8r+wAvwPpYvZbfh1yv8GBczkpnhCNVFiIx6JB5iDDdlM3gXRgNtDknaMkc7d5rWjrrp34YP9Y6sDLErTfa6A9Rbyntqa0AzV8NoQ5Py1ssB83Ik5q39PKiK3bKdfjC4Ef+wugZSbQ== 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=vqPQQtTRQUpYSGOXmSqMnJWIpGPVCuIxL1bg187xZXs=; b=bEG7OuyKGPl10p6JweU4jUhea7ZDK3C9Q8Vw91dSN86drPLLuZTET+z/W8uqZiz35M1vjOhtlH5G1r9FH79YQp/Tg8gvgy7pTd1WoQZM+DJsf4RkXzhWoPmSIDyhNvWQo1ViRtRRs/PAeHOrHC5v/8HjTJW/eLR84Bl1oWpw12hCtD+a1/G3tszY9HQsNVcOojL1CuUX6MoEw1HmvUcui4i2PR94r6hG8Hu6QV6+9zDymfGl2K1V+eFnDOiECrQPpQXZks9QcBvudNrUFy2fmts3RdVSlBIllluATuN5LFXM0fbktEMStQkroPhltqHf55Ez/r1sT93w0/RcKq7HKw== 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 DM4PR12MB5818.namprd12.prod.outlook.com (2603:10b6:8:62::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Wed, 18 Jan 2023 18:00:49 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.6002.013; Wed, 18 Jan 2023 18:00:49 +0000 From: Jason Gunthorpe To: Lu Baolu , Joerg Roedel , Kevin Tian , Matthew Rosato , Robin Murphy Cc: Alex Williamson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, Christian Borntraeger , dri-devel@lists.freedesktop.org, iommu@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org, linux-rdma@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-tegra@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, nouveau@lists.freedesktop.org, Niklas Schnelle , virtualization@lists.linux-foundation.org Subject: [PATCH v2 10/10] iommu/s390: Use GFP_KERNEL in sleepable contexts Date: Wed, 18 Jan 2023 14:00:44 -0400 Message-Id: <10-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> In-Reply-To: <0-v2-ce66f632bd0d+484-iommu_map_gfp_jgg@nvidia.com> References: X-ClientProxiedBy: BLAPR03CA0085.namprd03.prod.outlook.com (2603:10b6:208:329::30) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|DM4PR12MB5818:EE_ X-MS-Office365-Filtering-Correlation-Id: c1721888-54a1-4925-7872-08daf97dec52 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EaU9ywwN6UQ6lqY9VmpkUIvlY4Azaf/JXeP0m37rNvOhCk1obBI5yEO2DbdCOn5hOUqKKp+g6+I8knVHS8WuwQkneJLcSsRH8EvQXA3uYk1VsXX0jCxW9xRIS6G0o17fQ1yoFnkeKPuqNFRiIOYKuqRgRZp3zEV6ZEQ9wsYRVPDBQ67oH4A7yU1s5oCBZVuukpTVZx+eO4Ab5tX87jRJJ3zBrELq3cswVHTsvCdOC/kXo+P4hg1wILAfXg2ytWip4CWFHFFkcbWSQeHoA3jyu2iO+EoTCefez440pPAFoRawGCZ7Kvbm9eb13QHbJ2gePeLN8g60wq1eigS/TxyCYVfhOcbmfwq1VdEMt8ciJHI3Av8E9/kW4c+XWJyQF0eZF4Uno3EHUMe6F8QyNHx2PFV8P0MKI/fhb+O1mNByHjTOWhwVzwq8d5AYM0KIBNBH3x1ub9h2omu3RvWj3KbFBSvqVxwQEre33r87EefeKbHxq05KKbC4lSRcvXE1rI5+XmyGm8WasoL8IpCC0xV9G269/6lDXfVgjdqoJkVrO4EtGDSsm+VssV38kjXQAZKTyrHzs3/Ilru+vBEAFrgaTL1/c9q8J2uTdugc4ezHojJ7kQPlsJE+frc4cOk6w1x8455A+jZojjtV3i+YGbwpxw== 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:(13230022)(4636009)(136003)(39860400002)(376002)(396003)(346002)(366004)(451199015)(8676002)(36756003)(83380400001)(41300700001)(8936002)(2906002)(66476007)(2616005)(110136005)(54906003)(4326008)(316002)(5660300002)(38100700002)(86362001)(66556008)(7416002)(186003)(6486002)(6512007)(478600001)(26005)(66946007)(6666004)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6xefLf1A7b6onibFJL4xcR/mMuhUGDqMKS+h80M4YEmmEQm1qxrS5ZvNBA+urzXhGvukVau1KVHteD9OVIjy5Hpn4QVACXetjIBiM2pZwrwGpjcBF7byuFM4CvnBEM6okyNEFDhCpP+D/SVeTTWHeZkQOJ0c0jcYEvQoFOrOKQEuOLsarNgjoXiX7CBxHOjN9cdHEyJy9wMs/k76zLk3j7xTPDw8YujTFtPT2lTal+vHn1mlWyY062z4c8SAP//YQmwYoWLZTLlVbl+9h8qTXZdADFoPwYwg7JhKSLv4oKpprliaTN2NCGdt2hwKWlW5yIChqE0jwXtOiBSIhaV4GMRKvFf0cS5MWOHEK7ZXCGRKE6iq7RzkQRbcbl6lrYntMyyngL++HfcCicCSovmQsQ8PQ8iBDIGdVnaEwkyHV5/GmYZTDrtvZDb2vrW5+4w0zyNnUeLctRcx4s8ZtkJZDkoz08MKWmTjH89W3yZXPp/CtFhQuIjqxLvFjcpt9qqdYptmd4Yx5GbJL3dfnBoEjzyTugMeFOAJob2OOiWNCOKhC6/JsNmPNnOcn7ffN0z6wj7yW66tJGmX9poL6ECKnST+m3MKXONv+LVbDRkBP3bhavohehSpmRRyBc0BgzIMcy2Krv5zpgF/YBf4JfrdfaW7+lk5qqFSB3ofVhvOv7JzVsbJyXpHVnAwoseO8KWtZdH9wKHuP5Jmu8UfMRpEpj57+sg6Cd4Gw6/WOH/vxp4iPNQqSX7MsH9FYeDUuJJNwYypKvRiJ8ulEnakRKsNNi8fsdwi/npFS/udPzBqU6MNsZi2O/UHC1lSRJKmMfxWpgSLRG1gcjxU0VQg3fyrpuV+KmWa0Uq38YNnHu5w/uN6OiDUX5ikEAPrkfVrKKy+VDeRN0Ntx4i+JSWH0eJuisJWHIh2qXVVoTgq1Oqamdhe0P2kc4pRvza6l4+auAMiMbBdnnus2k0uy4q9iQreHBry+Wa8GhRkkZP8qrsAiwvcAnQrQfK2gnnu2pzbKUu361hZ7BELWtZxIvWRX0J3UiKoxeE47Z5Fmf8UHE/Sn7HqZfG6EMenWmidvJoOODg2w1ax9440cMJZ/rJwXEx8jFTT4jFGaC0G5R7JTQgQM9B9RvE15H39kEsoU0S3fAZbPodLJKvhIsViAFIXa3U2P3067/Q5uOaVZ6KoRWSRf5VARQgY+HXqE37XEHznLELGAATEo0uY/6bZFh19zF2uV9CYJl53rDATZI/vOd3nh2+YZFmsvD1ykzkwGIcoAgSgAMhIof/d/ggKuQGyMn/Sr3Ig616JewsFopajyKzfLhzvqS4+YE4xj+iMgzrovgMtYc1SitPeFrkEOrUhMJzPqkdEMg61BeSDVRsslRB192lauuwRwe26ZAUCEL/Rfuecgyz39/YuaRhjVF6/90bPfwvSNFtw5MsG0aGxfDgXMXXRWV6BKMmQbl6Xv9e95uVNajmNROYyUpeQpdzKrKpDfl4P1RvPGrgOeb+LoN10DKH/ZCBWdHbwxoHdCfDaSqrTxUoPisnvbGaqzldqvIMamV5CFLPn+Cgug8S39DehW6LS1EXCoO3ttKP4ryLDCNcm X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c1721888-54a1-4925-7872-08daf97dec52 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 18:00:46.0214 (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: UZqc2vdieqmNxvGL7Dg7UiD0Zivm0glFD4RNBPiJvlFLC/n4oq87FtslIka/Q+t9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5818 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org These contexts are sleepable, so use the proper annotation. The GFP_ATOMIC was added mechanically in the prior patches. Reviewed-by: Niklas Schnelle Signed-off-by: Jason Gunthorpe Reviewed-by: Matthew Rosato --- arch/s390/pci/pci_dma.c | 2 +- drivers/iommu/s390-iommu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c index 2f6d05d6da4f76..2d9b01d7ca4c5c 100644 --- a/arch/s390/pci/pci_dma.c +++ b/arch/s390/pci/pci_dma.c @@ -579,7 +579,7 @@ int zpci_dma_init_device(struct zpci_dev *zdev) spin_lock_init(&zdev->iommu_bitmap_lock); - zdev->dma_table = dma_alloc_cpu_table(GFP_ATOMIC); + zdev->dma_table = dma_alloc_cpu_table(GFP_KERNEL); if (!zdev->dma_table) { rc = -ENOMEM; goto out; diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c index 654ec4411fe36c..7dcfffed260e6b 100644 --- a/drivers/iommu/s390-iommu.c +++ b/drivers/iommu/s390-iommu.c @@ -52,7 +52,7 @@ static struct iommu_domain *s390_domain_alloc(unsigned domain_type) if (!s390_domain) return NULL; - s390_domain->dma_table = dma_alloc_cpu_table(GFP_ATOMIC); + s390_domain->dma_table = dma_alloc_cpu_table(GFP_KERNEL); if (!s390_domain->dma_table) { kfree(s390_domain); return NULL;