From patchwork Fri Mar 19 13:25:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 404790 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1377534jai; Fri, 19 Mar 2021 06:31:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKx7C2GBBPBg4MJTUdjXUQNhlqSvnySRLdI/YTT9DurMjmqrBly9gltN2GzT7y1ETPa+4q X-Received: by 2002:a17:907:104f:: with SMTP id oy15mr4444829ejb.252.1616160677562; Fri, 19 Mar 2021 06:31:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616160677; cv=none; d=google.com; s=arc-20160816; b=iarsPWre+IP8i9aWF/O6ILWbVKTSq0j28+hGMP4/Ab6LqqrDeKSu9Zc87uExof9Qjg 9q4Njx+Z+ElDd0ViewICshMoCGReNelCKOcCba/7QiwUbhOAswwhbn2nBk6Yg7hdKpQO irjsPB6a3/fqHL1W621VseRTJZPfU7Sn5QL2xnPNsEEWdaxUO2DHfQGKFaMSyL27BDNv DfAL0u808yKZS+nhh51GGcot+7SqdgmjwWOql0Z+b0lvN95Jq3OcnQAvH97nbqShuV9K fX2D2ly4oZRQtCN/yCjG+amDKOBEzf3u3cMSxxrtl9TeIkanKIIn+U1gvE2MEbz6cxWS WC5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=KdJq4QncHqOg+p4ezMA7i8W/lEhP89u6v+C93SCRISA=; b=GvGpiXqLjAKlisbTBOt3MysCJ8ORwb/LYutbHjeCqLDBrJPYuG32IQ1pg61GPTPtM1 uLGOb0w0eNg+/FOtHAG3hNihIzXodda3T5rSlhmYjn99+YTyosgGh3rcojRhIt9YjvjY bqj+6XYcdn0xuJ9EezEEa//6mjYLui+KMjUl5kuugTqsg9PIYCusGlXB1bbcoKhrVYKw gEcvcbOmpHHNbJqHPhpPOZXCCNxGDxY0O/hTg9R9enXCMfvCw0ftSpy4fcj+bgjJjp0F etZCPOwVv6fvYc6EUhF1ptem08zWjsvWOyCjnDXttLy0ynj2fDub0EcKTuu6Wh7nf2Ql mfkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m21si4292630ejx.725.2021.03.19.06.31.17 for ; Fri, 19 Mar 2021 06:31:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230274AbhCSNaq (ORCPT ); Fri, 19 Mar 2021 09:30:46 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:14019 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230258AbhCSNaU (ORCPT ); Fri, 19 Mar 2021 09:30:20 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4F24T24tC4zPkFh; Fri, 19 Mar 2021 21:27:50 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Fri, 19 Mar 2021 21:30:08 +0800 From: John Garry To: , , , , , , CC: , , , , John Garry Subject: [PATCH 5/6] dma-mapping/iommu: Add dma_set_max_opt_size() Date: Fri, 19 Mar 2021 21:25:47 +0800 Message-ID: <1616160348-29451-6-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1616160348-29451-1-git-send-email-john.garry@huawei.com> References: <1616160348-29451-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Add a function to allow the max size which we want to optimise DMA mappings for. Signed-off-by: John Garry --- drivers/iommu/dma-iommu.c | 2 +- include/linux/dma-map-ops.h | 1 + include/linux/dma-mapping.h | 5 +++++ kernel/dma/mapping.c | 11 +++++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) -- 2.26.2 diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index a5dfbd6c0496..d35881fcfb9c 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -447,7 +447,6 @@ static dma_addr_t iommu_dma_alloc_iova(struct iommu_domain *domain, return (dma_addr_t)iova << shift; } -__maybe_unused static void iommu_dma_set_opt_size(struct device *dev, size_t size) { struct iommu_domain *domain = iommu_get_dma_domain(dev); @@ -1278,6 +1277,7 @@ static const struct dma_map_ops iommu_dma_ops = { .map_resource = iommu_dma_map_resource, .unmap_resource = iommu_dma_unmap_resource, .get_merge_boundary = iommu_dma_get_merge_boundary, + .set_max_opt_size = iommu_dma_set_opt_size, }; /* diff --git a/include/linux/dma-map-ops.h b/include/linux/dma-map-ops.h index 51872e736e7b..fed7a183b3b9 100644 --- a/include/linux/dma-map-ops.h +++ b/include/linux/dma-map-ops.h @@ -64,6 +64,7 @@ struct dma_map_ops { u64 (*get_required_mask)(struct device *dev); size_t (*max_mapping_size)(struct device *dev); unsigned long (*get_merge_boundary)(struct device *dev); + void (*set_max_opt_size)(struct device *dev, size_t size); }; #ifdef CONFIG_DMA_OPS diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 2a984cb4d1e0..91fe770145d4 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -144,6 +144,7 @@ u64 dma_get_required_mask(struct device *dev); size_t dma_max_mapping_size(struct device *dev); bool dma_need_sync(struct device *dev, dma_addr_t dma_addr); unsigned long dma_get_merge_boundary(struct device *dev); +void dma_set_max_opt_size(struct device *dev, size_t size); #else /* CONFIG_HAS_DMA */ static inline dma_addr_t dma_map_page_attrs(struct device *dev, struct page *page, size_t offset, size_t size, @@ -257,6 +258,10 @@ static inline unsigned long dma_get_merge_boundary(struct device *dev) { return 0; } +static inline void dma_set_max_opt_size(struct device *dev, size_t size) +{ +} + #endif /* CONFIG_HAS_DMA */ struct page *dma_alloc_pages(struct device *dev, size_t size, diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c index b6a633679933..59e6acb1c471 100644 --- a/kernel/dma/mapping.c +++ b/kernel/dma/mapping.c @@ -608,3 +608,14 @@ unsigned long dma_get_merge_boundary(struct device *dev) return ops->get_merge_boundary(dev); } EXPORT_SYMBOL_GPL(dma_get_merge_boundary); + +void dma_set_max_opt_size(struct device *dev, size_t size) +{ + const struct dma_map_ops *ops = get_dma_ops(dev); + + if (!ops || !ops->set_max_opt_size) + return; + + ops->set_max_opt_size(dev, size); +} +EXPORT_SYMBOL_GPL(dma_set_max_opt_size);