Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4192496rwb; Tue, 6 Sep 2022 04:08:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR4bFwd9zSikghix0JfqcTW30ybnc+v0DOwDXCkKBHyqqfxA0V21p3xVJCV5atkG1byk1cAF X-Received: by 2002:a17:906:6a22:b0:73b:f069:e769 with SMTP id qw34-20020a1709066a2200b0073bf069e769mr39643397ejc.544.1662462530881; Tue, 06 Sep 2022 04:08:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662462530; cv=none; d=google.com; s=arc-20160816; b=ps90v1RAZrdypyHXpz5wGU6r948NW9nrB8yrgI5BReYlFIE9cTAalLQ5lZxUbNrUzd ksgaJDYZHzr9nZCWJ3GOwXRrENuVgPpaBfUkvKsvBXSZvCI32Ji4b0qLVZU1HKkM0VmR d8UXu8yhzCMhjC9WIQ5eZaXQ4o2IPpDmSBx63U+q2qKcezQXh2WuuDeoCBJVikMIKCy1 Phizyb8De6wuTQ3GT+Cr3B5W1Je8Qt4kI9g+6Y2pBwg99nETNx/dfLv2ndZGCHllkQ7q /fmdcHq/g1EfoUqNgPcvBnGb93Mq1HjxFpHKuI4Uc43cUPTpk3ZlqicSuZmfmlDjLb+t 2YNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:subject:from:user-agent:mime-version:date:message-id; bh=iyJwj0j5pdOTSSNOrAUzqZngg+sRUBU0s2fJF3HjF9w=; b=oxdf1VSVX9rNKErw35TOrjbI/HJ/Ut+3M4eF4oXd8s70/2bp+vhlVTK8FRZ/xFKVZz rWsN/m7YQ+KnQmFlyZ18JcVPo24i1g9s6Ty4zKqQVfbML1OFSzYYzYVbey0Xnc+zoMi0 jWmbXhvsp4CLf+SEzY8ZwvUMbJ7mbW1eC9G/0dr7wfrl0YvJUo5RRU26DMQmomVj3wCN 5ex6cZYPQiYtoxv2rAfmKwHimIgyjsj5js4tqrkdO8anR4TgYe8SJIqROQKvApfnak8g RJHx8asCyN3qhVcWHGGyYqpHSzvdQJGa+FAKF4xhFNrIYt/qCLpS8cpz3GF4uVGoh1qp dtHA== 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 dm15-20020a05640222cf00b0044ec6bf2978si1564284edb.458.2022.09.06.04.08.25; Tue, 06 Sep 2022 04:08:50 -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 S239196AbiIFKwz (ORCPT + 99 others); Tue, 6 Sep 2022 06:52:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240025AbiIFKwT (ORCPT ); Tue, 6 Sep 2022 06:52:19 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C75184BA6C for ; Tue, 6 Sep 2022 03:50:29 -0700 (PDT) Received: from fraeml742-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MMMWP5jc8z688r1; Tue, 6 Sep 2022 18:46:25 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml742-chm.china.huawei.com (10.206.15.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 6 Sep 2022 12:50:27 +0200 Received: from [10.126.175.248] (10.126.175.248) 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; Tue, 6 Sep 2022 11:50:26 +0100 Message-ID: <3fa23318-6fa7-eba0-30b8-1fb71e6c327e@huawei.com> Date: Tue, 6 Sep 2022 11:50:26 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 From: John Garry Subject: Re: [PATCH v2 1/2] iova: Remove some magazine pointer NULL checks To: Ethan Zhao , , , CC: , , References: <1662369083-238529-1-git-send-email-john.garry@huawei.com> <1662369083-238529-2-git-send-email-john.garry@huawei.com> <1d80f56c-bef7-6e5f-0bca-dad35f5e5a8e@linux.intel.com> In-Reply-To: <1d80f56c-bef7-6e5f-0bca-dad35f5e5a8e@linux.intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.126.175.248] X-ClientProxiedBy: lhrpeml100004.china.huawei.com (7.191.162.219) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 On 06/09/2022 10:28, Ethan Zhao wrote: Hi Ethan, >> Signed-off-by: John Garry >> Reviewed-by: Robin Murphy >> --- >>   drivers/iommu/iova.c | 7 ++----- >>   1 file changed, 2 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c >> index 47d1983dfa2a..580fdf669922 100644 >> --- a/drivers/iommu/iova.c >> +++ b/drivers/iommu/iova.c >> @@ -661,9 +661,6 @@ iova_magazine_free_pfns(struct iova_magazine *mag, >> struct iova_domain *iovad) >>       unsigned long flags; >>       int i; >> -    if (!mag) >> -        return; >> - > > iommu_probe_device >   ops->probe_finalize(dev); >     intel_iommu_probe_finalize >        iommu_setup_dma_ops >          iommu_dma_init_domain(domain, dma_base, dma_limit, dev) >            iova_domain_init_rcaches >              { >              ... >              cpu_rcache->loaded = iova_magazine_alloc(GFP_KERNEL); >              cpu_rcache->prev = iova_magazine_alloc(GFP_KERNEL); >            if (!cpu_rcache->loaded || !cpu_rcache->prev) { >                 ret = -ENOMEM; >                       goto out_err; > > Do you mean iova_magazine_alloc() is impossible to fail ? No, iova_magazine_alloc() may fail and return NULL. But if it does then we set iovad rcache pointer = NULL in the error path and don't use the rcache. However we have a !iovad->rcache check on the "fast" alloc but not "insert". I need to check why that is again. Thanks, john