Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5753212rwb; Wed, 7 Sep 2022 07:32:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR7c3xGfdA1Ev2nOjF9VxTewdvegxIsc6qwjIaWZZsacKaqvm+GIeVMKdb9hRNL8TOSjiGFp X-Received: by 2002:a17:90a:28a5:b0:200:43bc:5728 with SMTP id f34-20020a17090a28a500b0020043bc5728mr4375922pjd.188.1662561166956; Wed, 07 Sep 2022 07:32:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662561166; cv=none; d=google.com; s=arc-20160816; b=nD+ouFhXtky38Z3n2Ka2f9W0d7ph/xRnM6ABxGq3wXFXDpjstgBw7YZU8R4rh2YUkR hUOtVnkytnL1/XarewUIqkziHQ57JmOHrYEvyFpewkfXZKFKwxSobzntw+JgtHo9Pl6g fVk/EwUcfXVGFA+qQ4U5wAmbm+HTC+tKwiKv+L87lsP8LOORG92xGti/oxU2X/okHgnV NpxoPr/2jyvqqETyykxeLwwMzws7Ip0Wx2/z2VyAa/ilJOMUmY9msgVxZ1emSFkzPvJa LpdXYmUj46N5C7L5ni24mU+Sl7NvAxKsU6woVXryCemwvNP7aAU1/cdqFMmxPtbJITci 32mg== 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=7HW3dzVR6U4MynuYUfG4cG22uLxCGwKQeGB+W++1snw=; b=nIbxBdhbvT0+H1VKVMgo15b5/22EtPLrFjlHUj2aVuANP/WpI20k4+1LAbEOho7OuR KkjA31/sVPysNv3zvruvyuD9M5bvddT29wUBxFvViuJJBjC+BaLzTU+f9o+4GdhOdV1R sSIRIKAsW+dEHAV1QTuwCRKyC7qL5f5HFyjd5fHWMEXqNnNu9Nsa8S/cfZWmyWUG3MrV dA86OBbwLSL5/ZlwPnYlii9icEQiDMLVq4nmsqBk6i9C5mPK5DQRdFiK4cHJhDv6Gihu xDbK/BMRBc9fUuBnURHNZzINrWbYZn4NLwqgsQUCFOMki1Ma0CAPfi+jwD0Gr8ApF4HJ ksfw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 191-20020a6302c8000000b0043083edde08si14531143pgc.867.2022.09.07.07.32.34; Wed, 07 Sep 2022 07:32:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229672AbiIGNoD (ORCPT + 99 others); Wed, 7 Sep 2022 09:44:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229868AbiIGNnN (ORCPT ); Wed, 7 Sep 2022 09:43:13 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80E9B65278 for ; Wed, 7 Sep 2022 06:41:58 -0700 (PDT) Received: from fraeml703-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MN3L43CTKz688vC; Wed, 7 Sep 2022 21:40:44 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml703-chm.china.huawei.com (10.206.15.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.31; Wed, 7 Sep 2022 15:41:28 +0200 Received: from localhost.localdomain (10.69.192.58) by lhrpeml500003.china.huawei.com (7.191.162.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 7 Sep 2022 14:41:25 +0100 From: John Garry To: , , CC: , , , , , John Garry Subject: [PATCH v4 3/3] iova: Remove iovad->rcaches check in iova_rcache_get() Date: Wed, 7 Sep 2022 21:34:41 +0800 Message-ID: <1662557681-145906-4-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1662557681-145906-1-git-send-email-john.garry@huawei.com> References: <1662557681-145906-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The iovad->rcaches check in iova_rcache_get() is pretty much useless without the same check in iova_rcache_insert(). Instead of adding this symmetric check to fastpath iova_rcache_insert(), drop the check in iova_rcache_get() in favour of making the IOVA domain rcache init more robust to failure in future. Signed-off-by: John Garry Reviewed-by: Robin Murphy --- drivers/iommu/iova.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c index 8aece052ce72..a44ad92fc5eb 100644 --- a/drivers/iommu/iova.c +++ b/drivers/iommu/iova.c @@ -875,7 +875,7 @@ static unsigned long iova_rcache_get(struct iova_domain *iovad, { unsigned int log_size = order_base_2(size); - if (log_size >= IOVA_RANGE_CACHE_MAX_SIZE || !iovad->rcaches) + if (log_size >= IOVA_RANGE_CACHE_MAX_SIZE) return 0; return __iova_rcache_get(&iovad->rcaches[log_size], limit_pfn - size); -- 2.25.1