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 X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D47D9C433DB for ; Wed, 27 Jan 2021 13:01:01 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 383452083E for ; Wed, 27 Jan 2021 13:01:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 383452083E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id AB54E226D4; Wed, 27 Jan 2021 13:01:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IYX+UyhgR+gX; Wed, 27 Jan 2021 13:00:57 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id E1FEB227CE; Wed, 27 Jan 2021 13:00:56 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B14E1C0FA7; Wed, 27 Jan 2021 13:00:56 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 85F03C013A for ; Wed, 27 Jan 2021 13:00:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 69039866E2 for ; Wed, 27 Jan 2021 13:00:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0GyBiDTYr5l3 for ; Wed, 27 Jan 2021 13:00:52 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by whitealder.osuosl.org (Postfix) with ESMTPS id 3CD6E866DA for ; Wed, 27 Jan 2021 13:00:52 +0000 (UTC) X-Originating-IP: 93.29.109.196 Received: from aptenodytes (196.109.29.93.rev.sfr.net [93.29.109.196]) (Authenticated sender: paul.kocialkowski@bootlin.com) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 9A2151C000A; Wed, 27 Jan 2021 13:00:40 +0000 (UTC) Date: Wed, 27 Jan 2021 14:00:39 +0100 From: Paul Kocialkowski To: Yong Wu Subject: Re: [PATCH v2] of/device: Update dma_range_map only when dev has valid dma-ranges Message-ID: References: <20210119105203.15530-1-yong.wu@mediatek.com> MIME-Version: 1.0 In-Reply-To: <20210119105203.15530-1-yong.wu@mediatek.com> Cc: devicetree@vger.kernel.org, Nicolas Boichat , srv_heupstream@mediatek.com, Will Deacon , Frank Rowand , linux-kernel@vger.kernel.org, Krzysztof Kozlowski , Tomasz Figa , iommu@lists.linux-foundation.org, Rob Herring , linux-mediatek@lists.infradead.org, Matthias Brugger , Robin Murphy , linux-arm-kernel@lists.infradead.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============7520230116542913406==" Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" --===============7520230116542913406== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="BIH3KrdpdMNN62Ds" Content-Disposition: inline --BIH3KrdpdMNN62Ds Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Tue 19 Jan 21, 18:52, Yong Wu wrote: > The commit e0d072782c73 ("dma-mapping: introduce DMA range map, > supplanting dma_pfn_offset") always update dma_range_map even though it w= as > already set, like in the sunxi_mbus driver. the issue is reported at [1]. > This patch avoid this(Updating it only when dev has valid dma-ranges). >=20 > Meanwhile, dma_range_map contains the devices' dma_ranges information, > This patch moves dma_range_map before of_iommu_configure. The iommu > driver may need to know the dma_address requirements of its iommu > consumer devices. Just a gentle ping on this issue, it would be nice to have this fix merged ASAP, in the next RC :) Cheers, Paul > [1] https://lore.kernel.org/linux-arm-kernel/5c7946f3-b56e-da00-a750-be09= 7c7ceb32@arm.com/ >=20 > CC: Rob Herring > CC: Frank Rowand > Fixes: e0d072782c73 ("dma-mapping: introduce DMA range map, supplanting d= ma_pfn_offset"), > Suggested-by: Robin Murphy > Signed-off-by: Yong Wu > Signed-off-by: Paul Kocialkowski > Reviewed-by: Rob Herring > --- > drivers/of/device.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) >=20 > diff --git a/drivers/of/device.c b/drivers/of/device.c > index aedfaaafd3e7..1122daa8e273 100644 > --- a/drivers/of/device.c > +++ b/drivers/of/device.c > @@ -162,9 +162,11 @@ int of_dma_configure_id(struct device *dev, struct d= evice_node *np, > mask =3D DMA_BIT_MASK(ilog2(end) + 1); > dev->coherent_dma_mask &=3D mask; > *dev->dma_mask &=3D mask; > - /* ...but only set bus limit if we found valid dma-ranges earlier */ > - if (!ret) > + /* ...but only set bus limit and range map if we found valid dma-ranges= earlier */ > + if (!ret) { > dev->bus_dma_limit =3D end; > + dev->dma_range_map =3D map; > + } > =20 > coherent =3D of_dma_is_coherent(np); > dev_dbg(dev, "device is%sdma coherent\n", > @@ -172,6 +174,9 @@ int of_dma_configure_id(struct device *dev, struct de= vice_node *np, > =20 > iommu =3D of_iommu_configure(dev, np, id); > if (PTR_ERR(iommu) =3D=3D -EPROBE_DEFER) { > + /* Don't touch range map if it wasn't set from a valid dma-ranges */ > + if (!ret) > + dev->dma_range_map =3D NULL; > kfree(map); > return -EPROBE_DEFER; > } > @@ -181,7 +186,6 @@ int of_dma_configure_id(struct device *dev, struct de= vice_node *np, > =20 > arch_setup_dma_ops(dev, dma_start, size, iommu, coherent); > =20 > - dev->dma_range_map =3D map; > return 0; > } > EXPORT_SYMBOL_GPL(of_dma_configure_id); > --=20 > 2.18.0 >=20 --=20 Paul Kocialkowski, Bootlin Embedded Linux and kernel engineering https://bootlin.com --BIH3KrdpdMNN62Ds Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEJZpWjZeIetVBefti3cLmz3+fv9EFAmARY/cACgkQ3cLmz3+f v9HHbgf/Rk9Hu0kUW5B3MNVJs1JlKh376ihTjnZEjV3Xo7c4YP4KwGcTzAB2AMY2 ja2o4bLiLOBTOVExH1kXCmXuxvlgvumq3H9Zxi0+Ef/5ZPPlmi915WuSw440Seg3 t3W638nzVrqrIcvKa6YiS41UV5CbYGKHhBiInpPDdK3FbSDzRMSFkr3EKFdhNK1F qgL/9PV6WpamufJW589cWXQFumazQN/kz+zop1kD0jqWbNiSKM4rNz5j4PvH5iwj uQFWwUF/nuPfiEMCTeICiFrtgMTpl6QqiZqAUenTk+wuPeB7Xk0mXg0kaFmeUYpX k9INUJJAqUv96+i8ZW2lfOnI7fo90g== =2oxl -----END PGP SIGNATURE----- --BIH3KrdpdMNN62Ds-- --===============7520230116542913406== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu --===============7520230116542913406==-- 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 X-Spam-Level: X-Spam-Status: No, score=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFA39C433E0 for ; Wed, 27 Jan 2021 13:01:23 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 68EF120853 for ; Wed, 27 Jan 2021 13:01:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68EF120853 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2DkYZTqh8tIJq0YiIJp4Ls0ut8jrf2S/jD2xenNLROQ=; b=0JyckE7D2qSwhuXuiFoE954eU R9rrlwRT2Vzt8VHbtj574zu4oEsGid3uYwAy67pkbuhwoHiSywQtq/crEqT22SoWIxoFmRx6nOd50 qA3MUaIaw/Kky0g2PN1dNKnI+aoQ/QW6GkIej5ZjQVLUk/b8CeCkHCG79J2lGVF7+GXXXEm71Y8fL krHJN0u9N4hnYlJcKj1Kg2U9hIi1ZCdcD9vtZuB1pW0pK8qiPrI7rQjH8nhXVFuLVdOHNguIjqS2X pBrQUpPjY2Y+WWqsVgHOqG+lwNBawZdyrO8Vjn2HOgBub7UkzaWkT35XpVSnm8baq79msmJ2BD9s1 YfUwgjdoQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4kRU-00046Z-TY; Wed, 27 Jan 2021 13:01:04 +0000 Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4kRJ-00041m-Fc; Wed, 27 Jan 2021 13:00:55 +0000 X-Originating-IP: 93.29.109.196 Received: from aptenodytes (196.109.29.93.rev.sfr.net [93.29.109.196]) (Authenticated sender: paul.kocialkowski@bootlin.com) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 9A2151C000A; Wed, 27 Jan 2021 13:00:40 +0000 (UTC) Date: Wed, 27 Jan 2021 14:00:39 +0100 From: Paul Kocialkowski To: Yong Wu Subject: Re: [PATCH v2] of/device: Update dma_range_map only when dev has valid dma-ranges Message-ID: References: <20210119105203.15530-1-yong.wu@mediatek.com> MIME-Version: 1.0 In-Reply-To: <20210119105203.15530-1-yong.wu@mediatek.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210127_080053_828908_3DF7F671 X-CRM114-Status: GOOD ( 22.85 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Nicolas Boichat , srv_heupstream@mediatek.com, Will Deacon , Joerg Roedel , Frank Rowand , linux-kernel@vger.kernel.org, Krzysztof Kozlowski , Tomasz Figa , iommu@lists.linux-foundation.org, Rob Herring , linux-mediatek@lists.infradead.org, Matthias Brugger , Robin Murphy , linux-arm-kernel@lists.infradead.org Content-Type: multipart/mixed; boundary="===============6210367405646461438==" Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org --===============6210367405646461438== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="BIH3KrdpdMNN62Ds" Content-Disposition: inline --BIH3KrdpdMNN62Ds Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Tue 19 Jan 21, 18:52, Yong Wu wrote: > The commit e0d072782c73 ("dma-mapping: introduce DMA range map, > supplanting dma_pfn_offset") always update dma_range_map even though it w= as > already set, like in the sunxi_mbus driver. the issue is reported at [1]. > This patch avoid this(Updating it only when dev has valid dma-ranges). >=20 > Meanwhile, dma_range_map contains the devices' dma_ranges information, > This patch moves dma_range_map before of_iommu_configure. The iommu > driver may need to know the dma_address requirements of its iommu > consumer devices. Just a gentle ping on this issue, it would be nice to have this fix merged ASAP, in the next RC :) Cheers, Paul > [1] https://lore.kernel.org/linux-arm-kernel/5c7946f3-b56e-da00-a750-be09= 7c7ceb32@arm.com/ >=20 > CC: Rob Herring > CC: Frank Rowand > Fixes: e0d072782c73 ("dma-mapping: introduce DMA range map, supplanting d= ma_pfn_offset"), > Suggested-by: Robin Murphy > Signed-off-by: Yong Wu > Signed-off-by: Paul Kocialkowski > Reviewed-by: Rob Herring > --- > drivers/of/device.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) >=20 > diff --git a/drivers/of/device.c b/drivers/of/device.c > index aedfaaafd3e7..1122daa8e273 100644 > --- a/drivers/of/device.c > +++ b/drivers/of/device.c > @@ -162,9 +162,11 @@ int of_dma_configure_id(struct device *dev, struct d= evice_node *np, > mask =3D DMA_BIT_MASK(ilog2(end) + 1); > dev->coherent_dma_mask &=3D mask; > *dev->dma_mask &=3D mask; > - /* ...but only set bus limit if we found valid dma-ranges earlier */ > - if (!ret) > + /* ...but only set bus limit and range map if we found valid dma-ranges= earlier */ > + if (!ret) { > dev->bus_dma_limit =3D end; > + dev->dma_range_map =3D map; > + } > =20 > coherent =3D of_dma_is_coherent(np); > dev_dbg(dev, "device is%sdma coherent\n", > @@ -172,6 +174,9 @@ int of_dma_configure_id(struct device *dev, struct de= vice_node *np, > =20 > iommu =3D of_iommu_configure(dev, np, id); > if (PTR_ERR(iommu) =3D=3D -EPROBE_DEFER) { > + /* Don't touch range map if it wasn't set from a valid dma-ranges */ > + if (!ret) > + dev->dma_range_map =3D NULL; > kfree(map); > return -EPROBE_DEFER; > } > @@ -181,7 +186,6 @@ int of_dma_configure_id(struct device *dev, struct de= vice_node *np, > =20 > arch_setup_dma_ops(dev, dma_start, size, iommu, coherent); > =20 > - dev->dma_range_map =3D map; > return 0; > } > EXPORT_SYMBOL_GPL(of_dma_configure_id); > --=20 > 2.18.0 >=20 --=20 Paul Kocialkowski, Bootlin Embedded Linux and kernel engineering https://bootlin.com --BIH3KrdpdMNN62Ds Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEJZpWjZeIetVBefti3cLmz3+fv9EFAmARY/cACgkQ3cLmz3+f v9HHbgf/Rk9Hu0kUW5B3MNVJs1JlKh376ihTjnZEjV3Xo7c4YP4KwGcTzAB2AMY2 ja2o4bLiLOBTOVExH1kXCmXuxvlgvumq3H9Zxi0+Ef/5ZPPlmi915WuSw440Seg3 t3W638nzVrqrIcvKa6YiS41UV5CbYGKHhBiInpPDdK3FbSDzRMSFkr3EKFdhNK1F qgL/9PV6WpamufJW589cWXQFumazQN/kz+zop1kD0jqWbNiSKM4rNz5j4PvH5iwj uQFWwUF/nuPfiEMCTeICiFrtgMTpl6QqiZqAUenTk+wuPeB7Xk0mXg0kaFmeUYpX k9INUJJAqUv96+i8ZW2lfOnI7fo90g== =2oxl -----END PGP SIGNATURE----- --BIH3KrdpdMNN62Ds-- --===============6210367405646461438== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek --===============6210367405646461438==-- 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 X-Spam-Level: X-Spam-Status: No, score=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B637AC433E6 for ; Wed, 27 Jan 2021 13:03:23 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 71706207A3 for ; Wed, 27 Jan 2021 13:03:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 71706207A3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PUDyW9vdW06+qhrbW8popjNDX535uPWg1ZKOly14R6I=; b=BnqM9/1DbzqfKOVtAt3JrAsEf FjcYUBlTz9doKAC4XyCzc8YhnhDRy+4LdCezcR0T7C3kjHJGF4dSeNad0D79531vLO51QaWODW8fJ s4L8QQcXij7yq28YrX8aBB2E7TZ452UBRXcmmCyhSKCvGuJlFgMm+2aB9yYDcRYkYFrM8JPIhcDRD ARWZ1VOKPUUq9Swf1u5QO5RGfCE05+abCMiZ8oYGWGxYuDII/scjUMoqo9BeiASPpko+QCKiWcak5 kIVO6ROUmxl9zSGKh8S+Gq38bhmWvZPdNo4LlHXoKl47z7JUfO1YEDRIMu9RqNDvX3PunG9n4oP1x tzMOfBInA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4kRS-00045M-Kl; Wed, 27 Jan 2021 13:01:02 +0000 Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4kRJ-00041m-Fc; Wed, 27 Jan 2021 13:00:55 +0000 X-Originating-IP: 93.29.109.196 Received: from aptenodytes (196.109.29.93.rev.sfr.net [93.29.109.196]) (Authenticated sender: paul.kocialkowski@bootlin.com) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 9A2151C000A; Wed, 27 Jan 2021 13:00:40 +0000 (UTC) Date: Wed, 27 Jan 2021 14:00:39 +0100 From: Paul Kocialkowski To: Yong Wu Subject: Re: [PATCH v2] of/device: Update dma_range_map only when dev has valid dma-ranges Message-ID: References: <20210119105203.15530-1-yong.wu@mediatek.com> MIME-Version: 1.0 In-Reply-To: <20210119105203.15530-1-yong.wu@mediatek.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210127_080053_828908_3DF7F671 X-CRM114-Status: GOOD ( 22.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Nicolas Boichat , srv_heupstream@mediatek.com, Will Deacon , Joerg Roedel , Frank Rowand , linux-kernel@vger.kernel.org, Krzysztof Kozlowski , Tomasz Figa , iommu@lists.linux-foundation.org, Rob Herring , linux-mediatek@lists.infradead.org, Matthias Brugger , Robin Murphy , linux-arm-kernel@lists.infradead.org Content-Type: multipart/mixed; boundary="===============6943755511374209491==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============6943755511374209491== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="BIH3KrdpdMNN62Ds" Content-Disposition: inline --BIH3KrdpdMNN62Ds Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Tue 19 Jan 21, 18:52, Yong Wu wrote: > The commit e0d072782c73 ("dma-mapping: introduce DMA range map, > supplanting dma_pfn_offset") always update dma_range_map even though it w= as > already set, like in the sunxi_mbus driver. the issue is reported at [1]. > This patch avoid this(Updating it only when dev has valid dma-ranges). >=20 > Meanwhile, dma_range_map contains the devices' dma_ranges information, > This patch moves dma_range_map before of_iommu_configure. The iommu > driver may need to know the dma_address requirements of its iommu > consumer devices. Just a gentle ping on this issue, it would be nice to have this fix merged ASAP, in the next RC :) Cheers, Paul > [1] https://lore.kernel.org/linux-arm-kernel/5c7946f3-b56e-da00-a750-be09= 7c7ceb32@arm.com/ >=20 > CC: Rob Herring > CC: Frank Rowand > Fixes: e0d072782c73 ("dma-mapping: introduce DMA range map, supplanting d= ma_pfn_offset"), > Suggested-by: Robin Murphy > Signed-off-by: Yong Wu > Signed-off-by: Paul Kocialkowski > Reviewed-by: Rob Herring > --- > drivers/of/device.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) >=20 > diff --git a/drivers/of/device.c b/drivers/of/device.c > index aedfaaafd3e7..1122daa8e273 100644 > --- a/drivers/of/device.c > +++ b/drivers/of/device.c > @@ -162,9 +162,11 @@ int of_dma_configure_id(struct device *dev, struct d= evice_node *np, > mask =3D DMA_BIT_MASK(ilog2(end) + 1); > dev->coherent_dma_mask &=3D mask; > *dev->dma_mask &=3D mask; > - /* ...but only set bus limit if we found valid dma-ranges earlier */ > - if (!ret) > + /* ...but only set bus limit and range map if we found valid dma-ranges= earlier */ > + if (!ret) { > dev->bus_dma_limit =3D end; > + dev->dma_range_map =3D map; > + } > =20 > coherent =3D of_dma_is_coherent(np); > dev_dbg(dev, "device is%sdma coherent\n", > @@ -172,6 +174,9 @@ int of_dma_configure_id(struct device *dev, struct de= vice_node *np, > =20 > iommu =3D of_iommu_configure(dev, np, id); > if (PTR_ERR(iommu) =3D=3D -EPROBE_DEFER) { > + /* Don't touch range map if it wasn't set from a valid dma-ranges */ > + if (!ret) > + dev->dma_range_map =3D NULL; > kfree(map); > return -EPROBE_DEFER; > } > @@ -181,7 +186,6 @@ int of_dma_configure_id(struct device *dev, struct de= vice_node *np, > =20 > arch_setup_dma_ops(dev, dma_start, size, iommu, coherent); > =20 > - dev->dma_range_map =3D map; > return 0; > } > EXPORT_SYMBOL_GPL(of_dma_configure_id); > --=20 > 2.18.0 >=20 --=20 Paul Kocialkowski, Bootlin Embedded Linux and kernel engineering https://bootlin.com --BIH3KrdpdMNN62Ds Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEJZpWjZeIetVBefti3cLmz3+fv9EFAmARY/cACgkQ3cLmz3+f v9HHbgf/Rk9Hu0kUW5B3MNVJs1JlKh376ihTjnZEjV3Xo7c4YP4KwGcTzAB2AMY2 ja2o4bLiLOBTOVExH1kXCmXuxvlgvumq3H9Zxi0+Ef/5ZPPlmi915WuSw440Seg3 t3W638nzVrqrIcvKa6YiS41UV5CbYGKHhBiInpPDdK3FbSDzRMSFkr3EKFdhNK1F qgL/9PV6WpamufJW589cWXQFumazQN/kz+zop1kD0jqWbNiSKM4rNz5j4PvH5iwj uQFWwUF/nuPfiEMCTeICiFrtgMTpl6QqiZqAUenTk+wuPeB7Xk0mXg0kaFmeUYpX k9INUJJAqUv96+i8ZW2lfOnI7fo90g== =2oxl -----END PGP SIGNATURE----- --BIH3KrdpdMNN62Ds-- --===============6943755511374209491== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============6943755511374209491==-- 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 X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CB95C433E0 for ; Wed, 27 Jan 2021 13:04:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B53D8207D8 for ; Wed, 27 Jan 2021 13:04:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238142AbhA0NEF (ORCPT ); Wed, 27 Jan 2021 08:04:05 -0500 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:35917 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237779AbhA0NBc (ORCPT ); Wed, 27 Jan 2021 08:01:32 -0500 X-Originating-IP: 93.29.109.196 Received: from aptenodytes (196.109.29.93.rev.sfr.net [93.29.109.196]) (Authenticated sender: paul.kocialkowski@bootlin.com) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 9A2151C000A; Wed, 27 Jan 2021 13:00:40 +0000 (UTC) Date: Wed, 27 Jan 2021 14:00:39 +0100 From: Paul Kocialkowski To: Yong Wu Cc: Joerg Roedel , Rob Herring , Matthias Brugger , Will Deacon , Robin Murphy , Krzysztof Kozlowski , Tomasz Figa , linux-mediatek@lists.infradead.org, srv_heupstream@mediatek.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, Nicolas Boichat , Frank Rowand Subject: Re: [PATCH v2] of/device: Update dma_range_map only when dev has valid dma-ranges Message-ID: References: <20210119105203.15530-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="BIH3KrdpdMNN62Ds" Content-Disposition: inline In-Reply-To: <20210119105203.15530-1-yong.wu@mediatek.com> Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org --BIH3KrdpdMNN62Ds Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Tue 19 Jan 21, 18:52, Yong Wu wrote: > The commit e0d072782c73 ("dma-mapping: introduce DMA range map, > supplanting dma_pfn_offset") always update dma_range_map even though it w= as > already set, like in the sunxi_mbus driver. the issue is reported at [1]. > This patch avoid this(Updating it only when dev has valid dma-ranges). >=20 > Meanwhile, dma_range_map contains the devices' dma_ranges information, > This patch moves dma_range_map before of_iommu_configure. The iommu > driver may need to know the dma_address requirements of its iommu > consumer devices. Just a gentle ping on this issue, it would be nice to have this fix merged ASAP, in the next RC :) Cheers, Paul > [1] https://lore.kernel.org/linux-arm-kernel/5c7946f3-b56e-da00-a750-be09= 7c7ceb32@arm.com/ >=20 > CC: Rob Herring > CC: Frank Rowand > Fixes: e0d072782c73 ("dma-mapping: introduce DMA range map, supplanting d= ma_pfn_offset"), > Suggested-by: Robin Murphy > Signed-off-by: Yong Wu > Signed-off-by: Paul Kocialkowski > Reviewed-by: Rob Herring > --- > drivers/of/device.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) >=20 > diff --git a/drivers/of/device.c b/drivers/of/device.c > index aedfaaafd3e7..1122daa8e273 100644 > --- a/drivers/of/device.c > +++ b/drivers/of/device.c > @@ -162,9 +162,11 @@ int of_dma_configure_id(struct device *dev, struct d= evice_node *np, > mask =3D DMA_BIT_MASK(ilog2(end) + 1); > dev->coherent_dma_mask &=3D mask; > *dev->dma_mask &=3D mask; > - /* ...but only set bus limit if we found valid dma-ranges earlier */ > - if (!ret) > + /* ...but only set bus limit and range map if we found valid dma-ranges= earlier */ > + if (!ret) { > dev->bus_dma_limit =3D end; > + dev->dma_range_map =3D map; > + } > =20 > coherent =3D of_dma_is_coherent(np); > dev_dbg(dev, "device is%sdma coherent\n", > @@ -172,6 +174,9 @@ int of_dma_configure_id(struct device *dev, struct de= vice_node *np, > =20 > iommu =3D of_iommu_configure(dev, np, id); > if (PTR_ERR(iommu) =3D=3D -EPROBE_DEFER) { > + /* Don't touch range map if it wasn't set from a valid dma-ranges */ > + if (!ret) > + dev->dma_range_map =3D NULL; > kfree(map); > return -EPROBE_DEFER; > } > @@ -181,7 +186,6 @@ int of_dma_configure_id(struct device *dev, struct de= vice_node *np, > =20 > arch_setup_dma_ops(dev, dma_start, size, iommu, coherent); > =20 > - dev->dma_range_map =3D map; > return 0; > } > EXPORT_SYMBOL_GPL(of_dma_configure_id); > --=20 > 2.18.0 >=20 --=20 Paul Kocialkowski, Bootlin Embedded Linux and kernel engineering https://bootlin.com --BIH3KrdpdMNN62Ds Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEJZpWjZeIetVBefti3cLmz3+fv9EFAmARY/cACgkQ3cLmz3+f v9HHbgf/Rk9Hu0kUW5B3MNVJs1JlKh376ihTjnZEjV3Xo7c4YP4KwGcTzAB2AMY2 ja2o4bLiLOBTOVExH1kXCmXuxvlgvumq3H9Zxi0+Ef/5ZPPlmi915WuSw440Seg3 t3W638nzVrqrIcvKa6YiS41UV5CbYGKHhBiInpPDdK3FbSDzRMSFkr3EKFdhNK1F qgL/9PV6WpamufJW589cWXQFumazQN/kz+zop1kD0jqWbNiSKM4rNz5j4PvH5iwj uQFWwUF/nuPfiEMCTeICiFrtgMTpl6QqiZqAUenTk+wuPeB7Xk0mXg0kaFmeUYpX k9INUJJAqUv96+i8ZW2lfOnI7fo90g== =2oxl -----END PGP SIGNATURE----- --BIH3KrdpdMNN62Ds--