From mboxrd@z Thu Jan 1 00:00:00 1970 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 75801ECAAD3 for ; Wed, 7 Sep 2022 10:11:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229829AbiIGKK6 (ORCPT ); Wed, 7 Sep 2022 06:10:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbiIGKKz (ORCPT ); Wed, 7 Sep 2022 06:10:55 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58DA04DB32 for ; Wed, 7 Sep 2022 03:10:54 -0700 (PDT) Received: from fraeml704-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MMyg42hXcz67vlM; Wed, 7 Sep 2022 18:10:08 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml704-chm.china.huawei.com (10.206.15.53) 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 12:10:51 +0200 Received: from [10.202.227.197] (10.202.227.197) 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 11:10:51 +0100 Message-ID: Date: Wed, 7 Sep 2022 11:10:50 +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 Subject: Re: [PATCH v2 1/2] iova: Remove some magazine pointer NULL checks To: Ethan Zhao , Robin Murphy , , 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> <3fa23318-6fa7-eba0-30b8-1fb71e6c327e@huawei.com> <555fa5aa-a575-d783-dc97-79f63dcf2f57@arm.com> From: John Garry In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.202.227.197] X-ClientProxiedBy: lhrpeml100003.china.huawei.com (7.191.160.210) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/09/2022 10:58, Ethan Zhao wrote: Hi Ethan, >> Or also add this: >> >> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c >> index 0d6d8edf782d..e8f0b8f47f45 100644 >> --- a/drivers/iommu/dma-iommu.c >> +++ b/drivers/iommu/dma-iommu.c >> @@ -578,6 +578,12 @@ static int iommu_dma_init_domain(struct >> iommu_domain *domain, dma_addr_t base, >>              goto done_unlock; >>          } >> >> +        if (!iovad->rcaches) { >> +            pr_warn("IOVA domain rcache not properly initialised\n"); >> +            ret = -EFAULT; >> +            goto done_unlock; >> +        } >> + >>          ret = 0; >>          goto done_unlock; >> > If the iovad->rcaches allocation failed, will skip iommu domain dma ops, > so no need *any* iovad,->rcaches check, right ? > > and there is already warning about the fallback. It's not as simple as that. We use the iovad->start_pfn member as a flag for the IOVA domain being initialized. However that does not mean always properly initialized. As above, the rcache init may fail, but in this case we still set start_pfn. This comes into play when we have multiple devices in the same IOMMU group, for example, as I mentioned yesterday. Thanks, John