Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3606963pxb; Fri, 11 Feb 2022 03:55:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwTFZGQSj4TIW7cnhutzUt+AcIKKwse8eWqjLS+IeuweEQQZLD11PM07yHDoVyJld9HQYVk X-Received: by 2002:a17:907:3f09:: with SMTP id hq9mr1075994ejc.388.1644580508757; Fri, 11 Feb 2022 03:55:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644580508; cv=none; d=google.com; s=arc-20160816; b=OzUasnufsIvG+YcbyBgax+OvpunaBK+Crz+9ZYMzmB9GYVzshBgsiyOQNCMisrgv6u sOVCJk4IxlxZ0K5fVSmbiUsrckJwbgjQO7zizURpeDxD5+NzpAdCEu43HzhcLRUdyPRh oKv4T9huj0xVxojNs7o32G5xx8+oBBBl8U2qd3Po+Dbf2SJOX3VKKaBWMliYdllaCxIr VGPguOePtU0fVBDpbQoV6HthZOcnl0ka40iyndKjtK3iH1sdgmbDuxSOZDTeGjXIiJ0j 10BrwTvAJdxJWobn7bdaNFoYCq/K7mocRkOXftdzQafDjag1fj8uhDa8MxWVOWgS8Fe5 q8kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:date :mime-version:subject:references:in-reply-to:cc:to:from :dkim-signature; bh=+QzWvPmQ9CrQg+9DVBPDGn2iMJvpYZnpZYUSGInu5DU=; b=C/yKjaiKtH/7GSbtufbgBo7f8sUAg3YsGja/IHZnT4UeC5qAlw+wczcRqTQOYo2UDu yJ1vbjysOIEPdbJmjAXuNmRGg+AsnJBEZP07kdRil/flKO3pkfmyBbhsIhmnXvnRyO+R bqAv1F56OE+dRhroedUlr6i6fm7fKQJrobvtRyc/rzf5D5d0U1GHbImoXiClaarNNpGq s0n/X93RNryGHZjRn/LkNfGcgXCbj2743z5QPxU44mojlwpfr4CcyhYS0sre6j8+upZm 5Gi83qApn0TZmvWRpPURZMuWh2vzw77eR8/tK5f/XEEuUgdWJsnHSWUjgsNHzo2yYKrV LffA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxt.ru header.s=mail header.b=Awe4H7r7; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ej21si3768137edb.242.2022.02.11.03.54.43; Fri, 11 Feb 2022 03:55:08 -0800 (PST) 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; dkim=pass header.i=@nxt.ru header.s=mail header.b=Awe4H7r7; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348867AbiBKKYI (ORCPT + 99 others); Fri, 11 Feb 2022 05:24:08 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346916AbiBKKYH (ORCPT ); Fri, 11 Feb 2022 05:24:07 -0500 X-Greylist: delayed 315 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 11 Feb 2022 02:24:01 PST Received: from forward500j.mail.yandex.net (forward500j.mail.yandex.net [5.45.198.250]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C146D220 for ; Fri, 11 Feb 2022 02:24:01 -0800 (PST) Received: from myt6-de4b83149afa.qloud-c.yandex.net (myt6-de4b83149afa.qloud-c.yandex.net [IPv6:2a02:6b8:c12:401e:0:640:de4b:8314]) by forward500j.mail.yandex.net (Yandex) with ESMTP id 7C1246CB6BA2; Fri, 11 Feb 2022 13:18:41 +0300 (MSK) Received: from 2a02:6b8:c12:1723:0:640:c7c2:e344 (2a02:6b8:c12:1723:0:640:c7c2:e344 [2a02:6b8:c12:1723:0:640:c7c2:e344]) by myt6-de4b83149afa.qloud-c.yandex.net (mxback/Yandex) with HTTP id dIYhLv0cJCg1-Iec4T0gI; Fri, 11 Feb 2022 13:18:40 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxt.ru; s=mail; t=1644574720; bh=+QzWvPmQ9CrQg+9DVBPDGn2iMJvpYZnpZYUSGInu5DU=; h=References:Date:Message-Id:Cc:Subject:In-Reply-To:To:From; b=Awe4H7r7545QR/+EprGABpQbh5FZaCRNU9KDR/ioLqCYK/a1mLKNXi3jaQ3D5PN++ z3fjCMFCboRoZ2yuZwBWPC5eFqS0a2yXksD8j9h8nxFKpbMwuQR1rV8HuChBo+UYci dSegY4N/LM9B7ol+wFKxSAllsbZM350uQp77JyPg= Authentication-Results: myt6-de4b83149afa.qloud-c.yandex.net; dkim=pass header.i=@nxt.ru Received: by myt5-c7c2e3441f25.qloud-c.yandex.net with HTTP; Fri, 11 Feb 2022 13:18:40 +0300 From: Aleksandr Fedorov To: Robin Murphy Cc: Joerg Roedel , Will Deacon , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org In-Reply-To: References: <5481021644415780@myt5-a5512e99e394.qloud-c.yandex.net> Subject: Re: [PATCH] iommu: explicitly check for NULL in iommu_dma_get_resv_regions() MIME-Version: 1.0 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Fri, 11 Feb 2022 13:18:40 +0300 Message-Id: <10011281644574720@myt5-c7c2e3441f25.qloud-c.yandex.net> Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 2022-02-09 14:09, Aleksandr Fedorov wrote: >> iommu_dma_get_resv_regions() assumes that iommu_fwspec field for >> corresponding device is set which is not always true. Since >> iommu_dma_get_resv_regions() seems to be a future-proof generic API >> that can be used by any iommu driver, add an explicit check for NULL. > > Except it's not a "generic" interface for drivers to call at random, > it's a helper for retrieving common firmware-based information > specifically for drivers already using the fwspec mechanism for common > firmware bindings. If any driver calls this with a device *without* a > valid fwnode, it deserves to crash because it's done something > fundamentally wrong. > > I concur that it's not exactly obvious that "non-IOMMU-specific" means > "based on common firmware bindings, thus implying fwspec". Thanks for the explanations, yes, this was the misunderstanding on my part. Maybe add a comment? diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index d85d54f2b549..ce5e7d4d054a 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -379,6 +379,9 @@ void iommu_put_dma_cookie(struct iommu_domain *domain) * for general non-IOMMU-specific reservations. Currently, this covers GICv3 * ITS region reservation on ACPI based ARM platforms that may require HW MSI * reservation. + * + * Note that this helper is meant to be used only by drivers that are already + * using the fwspec mechanism for common firmware bindings. */ void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list) {