From patchwork Mon May 10 14:17:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 433149 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp2895404jao; Mon, 10 May 2021 07:25:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFr+yJnIPBrEtJfOqEKsh2EbFKO/Pec/lvHC3BGmqUDqNTHGvsjqjb8cU0aESvMBi4ob0/ X-Received: by 2002:a05:6602:181:: with SMTP id m1mr19034394ioo.153.1620656755851; Mon, 10 May 2021 07:25:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620656755; cv=none; d=google.com; s=arc-20160816; b=HetK99OKFkyJfaNw3YpBqdGGXFRL9ZYGXkSeLgbsiCOzit0RbXFgiQm4YumzL+WLE1 bIGt2GvTUhE4G9Bi3V1MXLIQrlIDvyfztAzKsbApFzvSSTr7nX6KqVTOZetG05Jig9Jf OIdCBWIAhQ8sVOH1IAG46gf/wMwJ2hYjMY4sR+JYq5pl/xfjrI/y5M9kFONvJbX/leIv 2vSaC1y7TbgYYhhucpvn6rC3V+ugZqxvA8RlvKQFtVqL8mWtPxUUm39P28cF4fqz/MFY 42TmTjW3BNDVU8L/KvCqzru5yCDg2QcrDgNsSuWD54sdZ0VOKqRK0fv1e5ZrRh5pml6/ /+GA== 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=brR+MYHF8iTRFkbwgRyb5TbgRqRu13/U0EQtDUfyyz4=; b=rll14L6RVYjQ3I76FObe7iDZ4rLsjng5WqnbLKN2wS4XE0vpVr3G9Dv+wtZxoX+mM2 i8UIJhS+KmL8FxGV9/j3SOCo9St8dJpd8AO7SuIATFcznRzEBayEi2k8+hbcvV+rRmwq RSUK12QzPTp9FBPstJ15d379kqFQS7XuYRl8rRqMtsT9D93OC2ILkHFLFqYorZNOKVL6 UMqYihl8PoN4piEkK2qB4e2YsPQL8/eIU26Az0N4TYoy1yML7ZjRpT1AXVPNbx7PFeOt uqRFmJwyyUs1+K+fAa6RAi3ds0gGQErYxgySJH+7zFSNg4BX38mkGOZp29S7eVqpqUom gyAA== 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 g19si19729924jat.91.2021.05.10.07.25.55 for ; Mon, 10 May 2021 07:25:55 -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 S235670AbhEJO06 (ORCPT ); Mon, 10 May 2021 10:26:58 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2675 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235453AbhEJOXq (ORCPT ); Mon, 10 May 2021 10:23:46 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Ff39B2nMzz1BKvg; Mon, 10 May 2021 22:19:58 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.498.0; Mon, 10 May 2021 22:22:27 +0800 From: John Garry To: , , , , CC: , , , , , , John Garry Subject: [PATCH v2 09/15] iova: Add init_iova_domain_ext() Date: Mon, 10 May 2021 22:17:23 +0800 Message-ID: <1620656249-68890-10-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1620656249-68890-1-git-send-email-john.garry@huawei.com> References: <1620656249-68890-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 extended version of init_iova_domain() which accepts an max opt iova length argument, and use it to set the rcaches range. Signed-off-by: John Garry --- drivers/iommu/iova.c | 29 +++++++++++++++++++++++------ include/linux/iova.h | 9 +++++++++ 2 files changed, 32 insertions(+), 6 deletions(-) -- 2.26.2 Reported-by: kernel test robot diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c index 95892a0433cc..273a689006c3 100644 --- a/drivers/iommu/iova.c +++ b/drivers/iommu/iova.c @@ -23,7 +23,7 @@ static bool iova_rcache_insert(struct iova_domain *iovad, static unsigned long iova_rcache_get(struct iova_domain *iovad, unsigned long size, unsigned long limit_pfn); -static void init_iova_rcaches(struct iova_domain *iovad); +static void init_iova_rcaches(struct iova_domain *iovad, unsigned long iova_len); static void free_cpu_cached_iovas(unsigned int cpu, struct iova_domain *iovad); static void free_iova_rcaches(struct iova_domain *iovad); static void fq_destroy_all_entries(struct iova_domain *iovad); @@ -47,8 +47,8 @@ static struct iova *to_iova(struct rb_node *node) } void -init_iova_domain(struct iova_domain *iovad, unsigned long granule, - unsigned long start_pfn) +__init_iova_domain(struct iova_domain *iovad, unsigned long granule, + unsigned long start_pfn, unsigned long iova_len) { /* * IOVA granularity will normally be equal to the smallest @@ -71,7 +71,21 @@ init_iova_domain(struct iova_domain *iovad, unsigned long granule, rb_link_node(&iovad->anchor.node, NULL, &iovad->rbroot.rb_node); rb_insert_color(&iovad->anchor.node, &iovad->rbroot); cpuhp_state_add_instance_nocalls(CPUHP_IOMMU_IOVA_DEAD, &iovad->cpuhp_dead); - init_iova_rcaches(iovad); + init_iova_rcaches(iovad, iova_len); +} + +void +init_iova_domain_ext(struct iova_domain *iovad, unsigned long granule, + unsigned long start_pfn, unsigned long iova_len) +{ + __init_iova_domain(iovad, granule, start_pfn, iova_len); +} + +void +init_iova_domain(struct iova_domain *iovad, unsigned long granule, + unsigned long start_pfn) +{ + __init_iova_domain(iovad, granule, start_pfn, 0); } EXPORT_SYMBOL_GPL(init_iova_domain); @@ -883,14 +897,17 @@ bool iova_domain_len_is_cached(struct iova_domain *iovad, unsigned long iova_len return iova_len_to_rcache_max(iova_len) == iovad->rcache_max_size; } -static void init_iova_rcaches(struct iova_domain *iovad) +static void init_iova_rcaches(struct iova_domain *iovad, unsigned long iova_len) { struct iova_cpu_rcache *cpu_rcache; struct iova_rcache *rcache; unsigned int cpu; int i; - iovad->rcache_max_size = IOVA_RANGE_CACHE_MAX_SIZE; + if (iova_len) + iovad->rcache_max_size = iova_len_to_rcache_max(iova_len); + else + iovad->rcache_max_size = IOVA_RANGE_CACHE_MAX_SIZE; iovad->rcaches = kcalloc(iovad->rcache_max_size, sizeof(*iovad->rcaches), GFP_KERNEL); diff --git a/include/linux/iova.h b/include/linux/iova.h index 04cc8eb6de38..cfe416b6a8c7 100644 --- a/include/linux/iova.h +++ b/include/linux/iova.h @@ -154,6 +154,8 @@ struct iova *reserve_iova(struct iova_domain *iovad, unsigned long pfn_lo, unsigned long pfn_hi); void init_iova_domain(struct iova_domain *iovad, unsigned long granule, unsigned long start_pfn); +void init_iova_domain_ext(struct iova_domain *iovad, unsigned long granule, + unsigned long start_pfn, unsigned long iova_len); int init_iova_flush_queue(struct iova_domain *iovad, iova_flush_cb flush_cb, iova_entry_dtor entry_dtor); struct iova *find_iova(struct iova_domain *iovad, unsigned long pfn); @@ -222,6 +224,13 @@ static inline void init_iova_domain(struct iova_domain *iovad, { } +static inline void init_iova_domain_ext(struct iova_domain *iovad, + unsigned long granule, + unsigned long start_pfn, + unsigned long iova_len) +{ +} + static inline int init_iova_flush_queue(struct iova_domain *iovad, iova_flush_cb flush_cb, iova_entry_dtor entry_dtor)