From nobody Fri May 3 05:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1569385043; cv=none; d=zoho.com; s=zohoarc; b=Aq5jhJHtDRTomgL+647yIyFTKgrUARhgPjB2iQqggbY6JIHcH3cy0fjIccyjL1vliW8UtQjzkjoYhzu7UMyKoBvj4WN5y7momZgZOF1hP33Rq4JN+g4arqJBHXYt3b3xHxIwHcIop5RIhT2ijUBUar9Upcw9CkqtjNpebugKaZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569385043; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=SqfcJ9q1Ol5aJKddQXWTVmiBzidyXW3HlskEPz2jnm8=; b=QL1JMf6h3jQArg6I9C5uLCsQIvj8WnN/mhfVUFO+tbUsI5NmTVhym2nb64YqROYiyv0y4bhMn37B4hr5W5jH0uE/SR9qNYrrrM5Q/z9h7NKyVtQcu88HPsnjG6ZAp9HDVtOEvRVxA7glq3FfeK2WJZHQtdPcHj9aXgioudtRHu8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1569385043651985.4537475664373; Tue, 24 Sep 2019 21:17:23 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCyj0-0000Pi-I1; Wed, 25 Sep 2019 04:16:22 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCpIz-0000EC-Ch for xen-devel@lists.xenproject.org; Tue, 24 Sep 2019 18:12:53 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by localhost (Halon) with ESMTPS id ec33552e-def6-11e9-8628-bc764e2007e4; Tue, 24 Sep 2019 18:12:52 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 3AA7DAEF1; Tue, 24 Sep 2019 18:12:51 +0000 (UTC) X-Inumbo-ID: ec33552e-def6-11e9-8628-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Nicolas Saenz Julienne To: robh+dt@kernel.org, devicetree@vger.kernel.org, frowand.list@gmail.com, linux-arm-kernel@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, xen-devel@lists.xenproject.org, linux-tegra@vger.kernel.org, linux-media@vger.kernel.org, linux-pci@vger.kernel.org Date: Tue, 24 Sep 2019 20:12:32 +0200 Message-Id: <20190924181244.7159-2-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190924181244.7159-1-nsaenzjulienne@suse.de> References: <20190924181244.7159-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 25 Sep 2019 04:16:20 +0000 Subject: [Xen-devel] [PATCH 01/11] of: address: clean-up unused variable in of_dma_get_range() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: f.fainelli@gmail.com, mbrugger@suse.com, wahrenst@gmx.net, james.quinlan@broadcom.com, robin.murphy@arm.com, Nicolas Saenz Julienne Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 'len' in of_dma_get_range() is used to check the 'dma-ranges' property length. After the fact, some calculations are run on the variable to be then left unused. Signed-off-by: Nicolas Saenz Julienne --- drivers/of/address.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/of/address.c b/drivers/of/address.c index 978427a9d5e6..0f898756199d 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -922,7 +922,7 @@ int of_dma_get_range(struct device_node *np, u64 *dma_a= ddr, u64 *paddr, u64 *siz { struct device_node *node =3D of_node_get(np); const __be32 *ranges =3D NULL; - int len, naddr, nsize, pna; + int naddr, nsize, pna; int ret =3D 0; u64 dmaaddr; =20 @@ -931,6 +931,7 @@ int of_dma_get_range(struct device_node *np, u64 *dma_a= ddr, u64 *paddr, u64 *siz =20 while (1) { struct device_node *parent; + int len; =20 naddr =3D of_n_addr_cells(node); nsize =3D of_n_size_cells(node); @@ -962,8 +963,6 @@ int of_dma_get_range(struct device_node *np, u64 *dma_a= ddr, u64 *paddr, u64 *siz goto out; } =20 - len /=3D sizeof(u32); - pna =3D of_n_addr_cells(node); =20 /* dma-ranges format: --=20 2.23.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri May 3 05:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1569385043; cv=none; d=zoho.com; s=zohoarc; b=BC25FXgR4e1A8b9guN6qiiwx9mqy/9kaNeV4h4cIAWi6us/skb3nAVeTPwxFji4ifedqug8HPvQ1bJe18pAE9d+DtFXrUIGblOUIr29v9t/wnyVbaTQJZTdJorEvvTBtclARutveVxegl+646PYs6Tb0A9S3ikwvArtYTRecZAg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569385043; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=oagCNKJ/SZXLScnipmge4nHsBK4g6ViGQr3+FUh34cE=; b=d2juSDrstdTq5MDkM/ZOIIGrn/ZsV5F8b/vjsn+/7k4LkzAOI2qKJE9Xi/4Rlpn+2ZDwisy3afqsXm4mnXKU5IzIXU4kg0lrcFgV3tH/7BCD0yaNm5fJaxo9eEhbcS3sAG+ZkM9yN3oqFugq5kV2Yy0v4MrCgGLxLBiWgL122f0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1569385043935752.9605654736941; Tue, 24 Sep 2019 21:17:23 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCyj2-0000RU-0X; Wed, 25 Sep 2019 04:16:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCpJ9-0000FG-DE for xen-devel@lists.xenproject.org; Tue, 24 Sep 2019 18:13:03 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by localhost (Halon) with ESMTPS id ece94744-def6-11e9-b588-bc764e2007e4; Tue, 24 Sep 2019 18:12:53 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A1202AF03; Tue, 24 Sep 2019 18:12:52 +0000 (UTC) X-Inumbo-ID: ece94744-def6-11e9-b588-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Nicolas Saenz Julienne To: robh+dt@kernel.org, devicetree@vger.kernel.org, frowand.list@gmail.com, linux-arm-kernel@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, xen-devel@lists.xenproject.org, linux-tegra@vger.kernel.org, linux-media@vger.kernel.org, linux-pci@vger.kernel.org Date: Tue, 24 Sep 2019 20:12:33 +0200 Message-Id: <20190924181244.7159-3-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190924181244.7159-1-nsaenzjulienne@suse.de> References: <20190924181244.7159-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 25 Sep 2019 04:16:20 +0000 Subject: [Xen-devel] [PATCH 02/11] of: base: introduce __of_n_*_cells_parent() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: f.fainelli@gmail.com, mbrugger@suse.com, wahrenst@gmx.net, james.quinlan@broadcom.com, robin.murphy@arm.com, Nicolas Saenz Julienne Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Master PCI devices might not appear in the device tree, yet they still need to get the underlying cells properties in order to calculate the bus DMA constraints. This conflicts with of_n_*_cells() as it's designed under the assumption it'll receive a device OF node. Create __of_n_*_cells_parent() in order to deal with this limitation. For now, it'll only be available privately to OF code. Signed-off-by: Nicolas Saenz Julienne --- drivers/of/base.c | 44 +++++++++++++++++++++++++++++------------ drivers/of/of_private.h | 3 +++ 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index 1d667eb730e1..94f83051910c 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -86,34 +86,52 @@ static bool __of_node_is_type(const struct device_node = *np, const char *type) return np && match && type && !strcmp(match, type); } =20 -int of_n_addr_cells(struct device_node *np) +int __of_n_addr_cells_parent(struct device_node *parent) { u32 cells; =20 - do { - if (np->parent) - np =3D np->parent; - if (!of_property_read_u32(np, "#address-cells", &cells)) + while (parent) { + if (!of_property_read_u32(parent, "#address-cells", &cells)) return cells; - } while (np->parent); + + parent =3D parent->parent; + } + /* No #address-cells property for the root node */ return OF_ROOT_NODE_ADDR_CELLS_DEFAULT; } + +int of_n_addr_cells(struct device_node *np) +{ + if (np->parent) + np =3D np->parent; + + return __of_n_addr_cells_parent(np); +} EXPORT_SYMBOL(of_n_addr_cells); =20 -int of_n_size_cells(struct device_node *np) +int __of_n_size_cells_parent(struct device_node *parent) { u32 cells; =20 - do { - if (np->parent) - np =3D np->parent; - if (!of_property_read_u32(np, "#size-cells", &cells)) + while (parent) { + if (!of_property_read_u32(parent, "#size-cells", &cells)) return cells; - } while (np->parent); - /* No #size-cells property for the root node */ + + parent =3D parent->parent; + } + + /* No #address-cells property for the root node */ return OF_ROOT_NODE_SIZE_CELLS_DEFAULT; } + +int of_n_size_cells(struct device_node *np) +{ + if (np->parent) + np =3D np->parent; + + return __of_n_size_cells_parent(np); +} EXPORT_SYMBOL(of_n_size_cells); =20 #ifdef CONFIG_NUMA diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index 24786818e32e..b528304be244 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -39,6 +39,9 @@ extern struct mutex of_mutex; extern struct list_head aliases_lookup; extern struct kset *of_kset; =20 +int __of_n_addr_cells_parent(struct device_node *parent); +int __of_n_size_cells_parent(struct device_node *parent); + #if defined(CONFIG_OF_DYNAMIC) extern int of_property_notify(int action, struct device_node *np, struct property *prop, struct property *old_prop); --=20 2.23.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri May 3 05:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1569385043; cv=none; d=zoho.com; s=zohoarc; b=LYcec11WFV70I5/32bFA2O14o8gEWUgv8PzGBrohNiom2KYVOgz4BwHNghTHt9ZrpYNVAFtDfofUC/qhUczihy6goJC4QiwvUwqAArnRxWmIHZ49JyWVNGbsnXRUeY5Spxt6TmOY1Ci3W3tpiJ4w1r9IQxDk6me+lGj1nXE8aN4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569385043; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=B3sIWF7cA6YpAvRuvIuwtmuWpxqd7O/oKcA9WL3ooSs=; b=nNdLokz5u+yjaa4mEmkJlXtNDEO/o4V8/e6wdTu46nW7dUibtK+sLIzf5aUoM3orXqYJ9uao7VPHbj/WJaDDyf5+jOZdmH4H/pv/iNIxnrokQcGRs0RDdKZZ8Zh4H8cCKwFRqdLMilxOXC5MBc/bKDvpo0hStAxBmFFx7GgqtJo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1569385043418853.55055035549; Tue, 24 Sep 2019 21:17:23 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCyj2-0000Sf-PN; Wed, 25 Sep 2019 04:16:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCpJE-0000Fs-DO for xen-devel@lists.xenproject.org; Tue, 24 Sep 2019 18:13:08 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by localhost (Halon) with ESMTPS id eda88f32-def6-11e9-97fb-bc764e2007e4; Tue, 24 Sep 2019 18:12:54 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E4980AEF8; Tue, 24 Sep 2019 18:12:53 +0000 (UTC) X-Inumbo-ID: eda88f32-def6-11e9-97fb-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Nicolas Saenz Julienne To: robh+dt@kernel.org, devicetree@vger.kernel.org, frowand.list@gmail.com, linux-arm-kernel@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, xen-devel@lists.xenproject.org, linux-tegra@vger.kernel.org, linux-media@vger.kernel.org, linux-pci@vger.kernel.org Date: Tue, 24 Sep 2019 20:12:34 +0200 Message-Id: <20190924181244.7159-4-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190924181244.7159-1-nsaenzjulienne@suse.de> References: <20190924181244.7159-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 25 Sep 2019 04:16:20 +0000 Subject: [Xen-devel] [PATCH 03/11] of: address: use parent DT node in bus->count_cells() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: f.fainelli@gmail.com, mbrugger@suse.com, wahrenst@gmx.net, james.quinlan@broadcom.com, robin.murphy@arm.com, Nicolas Saenz Julienne Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The function provides the cell sizes for a specific bus type. Instead of passing it the device DT node sitting on top of that bus we directly pass its parent which is the actual node the function will start looking from. Signed-off-by: Nicolas Saenz Julienne --- drivers/of/address.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/of/address.c b/drivers/of/address.c index 0f898756199d..9c1e638fa8ea 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -14,6 +14,8 @@ #include #include =20 +#include "of_private.h" + /* Max address size we deal with */ #define OF_MAX_ADDR_CELLS 4 #define OF_CHECK_ADDR_COUNT(na) ((na) > 0 && (na) <=3D OF_MAX_ADDR_CELLS) @@ -42,7 +44,7 @@ struct of_bus { const char *name; const char *addresses; int (*match)(struct device_node *parent); - void (*count_cells)(struct device_node *child, + void (*count_cells)(struct device_node *parent, int *addrc, int *sizec); u64 (*map)(__be32 *addr, const __be32 *range, int na, int ns, int pna); @@ -54,13 +56,13 @@ struct of_bus { * Default translator (generic bus) */ =20 -static void of_bus_default_count_cells(struct device_node *dev, +static void of_bus_default_count_cells(struct device_node *parent, int *addrc, int *sizec) { if (addrc) - *addrc =3D of_n_addr_cells(dev); + *addrc =3D __of_n_addr_cells_parent(parent); if (sizec) - *sizec =3D of_n_size_cells(dev); + *sizec =3D __of_n_size_cells_parent(parent); } =20 static u64 of_bus_default_map(__be32 *addr, const __be32 *range, @@ -192,7 +194,7 @@ const __be32 *of_get_pci_address(struct device_node *de= v, int bar_no, u64 *size, of_node_put(parent); return NULL; } - bus->count_cells(dev, &na, &ns); + bus->count_cells(parent, &na, &ns); of_node_put(parent); if (!OF_CHECK_ADDR_COUNT(na)) return NULL; @@ -592,7 +594,7 @@ static u64 __of_translate_address(struct device_node *d= ev, bus =3D of_match_bus(parent); =20 /* Count address cells & copy address locally */ - bus->count_cells(dev, &na, &ns); + bus->count_cells(parent, &na, &ns); if (!OF_CHECK_COUNTS(na, ns)) { pr_debug("Bad cell count for %pOF\n", dev); goto bail; @@ -634,7 +636,7 @@ static u64 __of_translate_address(struct device_node *d= ev, =20 /* Get new parent bus and counts */ pbus =3D of_match_bus(parent); - pbus->count_cells(dev, &pna, &pns); + pbus->count_cells(parent, &pna, &pns); if (!OF_CHECK_COUNTS(pna, pns)) { pr_err("Bad cell count for %pOF\n", dev); break; @@ -726,7 +728,7 @@ const __be32 *of_get_address(struct device_node *dev, i= nt index, u64 *size, if (parent =3D=3D NULL) return NULL; bus =3D of_match_bus(parent); - bus->count_cells(dev, &na, &ns); + bus->count_cells(parent, &na, &ns); of_node_put(parent); if (!OF_CHECK_ADDR_COUNT(na)) return NULL; --=20 2.23.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri May 3 05:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1569385044; cv=none; d=zoho.com; s=zohoarc; b=bWP/qLVfCwIlLtRr3OI7ra9U3TMq0RglecUIxq0To77weEwfNihM4LPin/oKE6k0Um1JUamIzftLZTa6mK1CFuxIVfVLN6+XEiDJLPjIvYlYdhPGnvGl5MonQQMPfQxsgs0+iW+EYQYD8oj9s5LkAVTEH+Fe0nq2RFCZimeJhUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569385044; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=cSOBWOW0mjwkJtBO0Pk8sZyLpKpS+5M9/D3oEUci4g8=; b=MSgo7OVGekbXHZvpsbruvWQLznOfWftfS4pHRxbgOpKgP1cE/O6I7To+lQKAnD6BJzRQ/ngMyRANDX8zKcgdpMUDig9gZffc/KhhcOKzafu6R5njk9mX8FyNH+oHr5OcXih15iJy7e2WmrpmmF+DtUP9jgv+59MPo2NVLFGCdN0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1569385044877231.88793491420336; Tue, 24 Sep 2019 21:17:24 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCyj0-0000Pq-Ri; Wed, 25 Sep 2019 04:16:22 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCpJ4-0000EZ-4G for xen-devel@lists.xenproject.org; Tue, 24 Sep 2019 18:12:58 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by localhost (Halon) with ESMTPS id ee742c50-def6-11e9-9625-12813bfff9fa; Tue, 24 Sep 2019 18:12:56 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 3CDFFABBD; Tue, 24 Sep 2019 18:12:55 +0000 (UTC) X-Inumbo-ID: ee742c50-def6-11e9-9625-12813bfff9fa X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Nicolas Saenz Julienne To: robh+dt@kernel.org, devicetree@vger.kernel.org, frowand.list@gmail.com, linux-arm-kernel@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, xen-devel@lists.xenproject.org, linux-tegra@vger.kernel.org, linux-media@vger.kernel.org, linux-pci@vger.kernel.org Date: Tue, 24 Sep 2019 20:12:35 +0200 Message-Id: <20190924181244.7159-5-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190924181244.7159-1-nsaenzjulienne@suse.de> References: <20190924181244.7159-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 25 Sep 2019 04:16:20 +0000 Subject: [Xen-devel] [PATCH 04/11] of: address: introduce of_translate_dma_address_parent() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: f.fainelli@gmail.com, mbrugger@suse.com, wahrenst@gmx.net, james.quinlan@broadcom.com, robin.murphy@arm.com, Nicolas Saenz Julienne Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Some devices might not have a DT node of their own, but might still need to translate DMA addresses based on their bus DT node. Update of_translate_dma_address() to only depend on the parent DT node. Rename it to of_translate_dma_address_parent(). The later will be still available as a wrapper around the new function. Signed-off-by: Nicolas Saenz Julienne --- drivers/of/address.c | 60 ++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/drivers/of/address.c b/drivers/of/address.c index 9c1e638fa8ea..c9eb4ebcc2e9 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -570,33 +570,32 @@ static int of_translate_one(struct device_node *paren= t, struct of_bus *bus, * device that had registered logical PIO mapping, and the return code is * relative to that node. */ -static u64 __of_translate_address(struct device_node *dev, - struct device_node *(*get_parent)(const struct device_node *), - const __be32 *in_addr, const char *rprop, - struct device_node **host) +static u64 __of_translate_address_parent(struct device_node *parent, + struct device_node *(*get_parent) + (const struct device_node *), + const __be32 *in_addr, + const char *rprop, + struct device_node **host) { - struct device_node *parent =3D NULL; + struct device_node *dev =3D NULL; struct of_bus *bus, *pbus; __be32 addr[OF_MAX_ADDR_CELLS]; int na, ns, pna, pns; u64 result =3D OF_BAD_ADDR; =20 - pr_debug("** translation for device %pOF **\n", dev); - - /* Increase refcount at current level */ - of_node_get(dev); - *host =3D NULL; - /* Get parent & match bus type */ - parent =3D get_parent(dev); - if (parent =3D=3D NULL) + + if (!parent) goto bail; + + /* Increase refcount at current level and match bus type */ + of_node_get(parent); bus =3D of_match_bus(parent); =20 /* Count address cells & copy address locally */ bus->count_cells(parent, &na, &ns); if (!OF_CHECK_COUNTS(na, ns)) { - pr_debug("Bad cell count for %pOF\n", dev); + pr_debug("Bad cell count for %pOF\n", parent); goto bail; } memcpy(addr, in_addr, na * 4); @@ -610,9 +609,8 @@ static u64 __of_translate_address(struct device_node *d= ev, struct logic_pio_hwaddr *iorange; =20 /* Switch to parent bus */ - of_node_put(dev); dev =3D parent; - parent =3D get_parent(dev); + parent =3D get_parent(parent); =20 /* If root, we have finished */ if (parent =3D=3D NULL) { @@ -650,6 +648,8 @@ static u64 __of_translate_address(struct device_node *d= ev, break; =20 /* Complete the move up one level */ + of_node_put(dev); + dev =3D parent; na =3D pna; ns =3D pns; bus =3D pbus; @@ -668,8 +668,10 @@ u64 of_translate_address(struct device_node *dev, cons= t __be32 *in_addr) struct device_node *host; u64 ret; =20 - ret =3D __of_translate_address(dev, of_get_parent, - in_addr, "ranges", &host); + pr_debug("** translation for device %pOF **\n", dev); + + ret =3D __of_translate_address_parent(dev->parent, of_get_parent, + in_addr, "ranges", &host); if (host) { of_node_put(host); return OF_BAD_ADDR; @@ -697,14 +699,14 @@ static struct device_node *__of_get_dma_parent(const = struct device_node *np) return of_node_get(args.np); } =20 -u64 of_translate_dma_address(struct device_node *dev, const __be32 *in_add= r) +static u64 of_translate_dma_address_parent(struct device_node *parent, + const __be32 *in_addr) { struct device_node *host; u64 ret; =20 - ret =3D __of_translate_address(dev, __of_get_dma_parent, - in_addr, "dma-ranges", &host); - + ret =3D __of_translate_address_parent(parent, __of_get_dma_parent, in_add= r, + "dma-ranges", &host); if (host) { of_node_put(host); return OF_BAD_ADDR; @@ -712,6 +714,14 @@ u64 of_translate_dma_address(struct device_node *dev, = const __be32 *in_addr) =20 return ret; } + +u64 of_translate_dma_address(struct device_node *dev, const __be32 *in_add= r) +{ + pr_debug("** translation for device %pOF **\n", dev); + + return of_translate_dma_address_parent(__of_get_dma_parent(dev->parent), + in_addr); +} EXPORT_SYMBOL(of_translate_dma_address); =20 const __be32 *of_get_address(struct device_node *dev, int index, u64 *size, @@ -759,8 +769,10 @@ static u64 of_translate_ioport(struct device_node *dev= , const __be32 *in_addr, unsigned long port; struct device_node *host; =20 - taddr =3D __of_translate_address(dev, of_get_parent, - in_addr, "ranges", &host); + pr_debug("** translation for device %pOF **\n", dev); + + taddr =3D __of_translate_address_parent(dev->parent, of_get_parent, + in_addr, "ranges", &host); if (host) { /* host-specific port access */ port =3D logic_pio_trans_hwaddr(&host->fwnode, taddr, size); --=20 2.23.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri May 3 05:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1569385046; cv=none; d=zoho.com; s=zohoarc; b=bSmpMWvFnW2TiFcrst8EpVcPFTDmKkCjLLi16QTpJz4ZgIJ2bvzYTwA6HtW1MP9vugxTxPCThAgZrRoC1sqFZnVe55r1A0osoP5MumRil2ncPI4O8p3Ot40RplV2wruaR3FDEizHkitz5EaX79mes8iy+aroxUtPsEZrZTmCRkY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569385046; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=EeltHyqGsw4xhJ8Ee3jnM12sRje4O6DFz84szR7nHFE=; b=GbUX8gNDUQqUkeV6YWUpVBwi8q9ZP3raQ4tIO3GQM0XRL/es2rVoUsCwRaSB23rZzYqJFK2wgAyp0wEJFkEk6WpcWG4wrS7Lh9EIafdReruwPQ7dxqY5CR4Pn//yxEfexj1WRajG2iiOyaDpZwKA16YVok935qO69hQm+5tdmU0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1569385045889703.4041719342766; Tue, 24 Sep 2019 21:17:25 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCyj1-0000Qu-Ji; Wed, 25 Sep 2019 04:16:23 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCpJ9-0000FB-1Q for xen-devel@lists.xenproject.org; Tue, 24 Sep 2019 18:13:03 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by localhost (Halon) with ESMTPS id ef6be1ac-def6-11e9-9625-12813bfff9fa; Tue, 24 Sep 2019 18:12:57 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id D66E4AE78; Tue, 24 Sep 2019 18:12:56 +0000 (UTC) X-Inumbo-ID: ef6be1ac-def6-11e9-9625-12813bfff9fa X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Nicolas Saenz Julienne To: robh+dt@kernel.org, devicetree@vger.kernel.org, frowand.list@gmail.com, linux-arm-kernel@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, xen-devel@lists.xenproject.org, linux-tegra@vger.kernel.org, linux-media@vger.kernel.org, linux-pci@vger.kernel.org Date: Tue, 24 Sep 2019 20:12:36 +0200 Message-Id: <20190924181244.7159-6-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190924181244.7159-1-nsaenzjulienne@suse.de> References: <20190924181244.7159-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 25 Sep 2019 04:16:20 +0000 Subject: [Xen-devel] [PATCH 05/11] of: expose __of_get_dma_parent() to OF subsystem X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: f.fainelli@gmail.com, mbrugger@suse.com, wahrenst@gmx.net, james.quinlan@broadcom.com, robin.murphy@arm.com, Nicolas Saenz Julienne Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The function was only available locally to of/address.c, make it available to the OF subsystem. Signed-off-by: Nicolas Saenz Julienne --- drivers/of/address.c | 18 ------------------ drivers/of/base.c | 25 +++++++++++++++++++++++++ drivers/of/of_private.h | 2 ++ 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/drivers/of/address.c b/drivers/of/address.c index c9eb4ebcc2e9..53666063e938 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -681,24 +681,6 @@ u64 of_translate_address(struct device_node *dev, cons= t __be32 *in_addr) } EXPORT_SYMBOL(of_translate_address); =20 -static struct device_node *__of_get_dma_parent(const struct device_node *n= p) -{ - struct of_phandle_args args; - int ret, index; - - index =3D of_property_match_string(np, "interconnect-names", "dma-mem"); - if (index < 0) - return of_get_parent(np); - - ret =3D of_parse_phandle_with_args(np, "interconnects", - "#interconnect-cells", - index, &args); - if (ret < 0) - return of_get_parent(np); - - return of_node_get(args.np); -} - static u64 of_translate_dma_address_parent(struct device_node *parent, const __be32 *in_addr) { diff --git a/drivers/of/base.c b/drivers/of/base.c index 94f83051910c..ec161e6b5222 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -716,6 +716,31 @@ struct device_node *of_get_parent(const struct device_= node *node) } EXPORT_SYMBOL(of_get_parent); =20 +/** + * __of_get_dma_parent - Get a node's dma parent if any + * @node: Node to get dma parent + * + * Returns a node pointer with refcount incremented, use + * of_node_put() on it when done. + */ +struct device_node *__of_get_dma_parent(const struct device_node *np) +{ + struct of_phandle_args args; + int ret, index; + + index =3D of_property_match_string(np, "interconnect-names", "dma-mem"); + if (index < 0) + return of_get_parent(np); + + ret =3D of_parse_phandle_with_args(np, "interconnects", + "#interconnect-cells", + index, &args); + if (ret < 0) + return of_get_parent(np); + + return of_node_get(args.np); +} + /** * of_get_next_parent - Iterate to a node's parent * @node: Node to get parent of diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index b528304be244..63bb16cc454c 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -42,6 +42,8 @@ extern struct kset *of_kset; int __of_n_addr_cells_parent(struct device_node *parent); int __of_n_size_cells_parent(struct device_node *parent); =20 +struct device_node *__of_get_dma_parent(const struct device_node *np); + #if defined(CONFIG_OF_DYNAMIC) extern int of_property_notify(int action, struct device_node *np, struct property *prop, struct property *old_prop); --=20 2.23.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri May 3 05:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1569385043; cv=none; d=zoho.com; s=zohoarc; b=QWFdVtsvVW54z6lnvv8Z2JNjaUwaQraizQVEUB3dcosvNuYAoMUXvyaN2jNVnKbXLIIg6XP/Db44H+QUxduBruuw6syFhYU4gx7fDN0v+cU/4tiZosMjdwwU0WFZE4pC6lh17jkUQRffzgi4OjgR1wqma5UUsHHRUDQ5HqeMxkc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569385043; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=LyPQhp6a4uTrced5A3mn3wLKw39UFwCI9LorL/W422o=; b=OBA4TAENFv1grBalzSydYv/RQ+0pMUEM99MXeZAY4jwvnIZAJsN+RO5rfQILFcoY6q47h0Mivt5XT7/7HYxbEqYA0cCRfe6Df6a4Cohcx1cQI/cwho6Zynmpxb42ud9eFDQEVTvkx9eV3GsyN/RocdLJ18Kk2xWKI0PC0X0bmao= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1569385043725640.0386924623054; Tue, 24 Sep 2019 21:17:23 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCyj3-0000UC-JV; Wed, 25 Sep 2019 04:16:25 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCpJJ-0000GV-EJ for xen-devel@lists.xenproject.org; Tue, 24 Sep 2019 18:13:13 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by localhost (Halon) with ESMTPS id f03d052a-def6-11e9-8628-bc764e2007e4; Tue, 24 Sep 2019 18:12:59 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 376C8AC93; Tue, 24 Sep 2019 18:12:58 +0000 (UTC) X-Inumbo-ID: f03d052a-def6-11e9-8628-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Nicolas Saenz Julienne To: robh+dt@kernel.org, devicetree@vger.kernel.org, frowand.list@gmail.com, linux-arm-kernel@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, xen-devel@lists.xenproject.org, linux-tegra@vger.kernel.org, linux-media@vger.kernel.org, linux-pci@vger.kernel.org Date: Tue, 24 Sep 2019 20:12:37 +0200 Message-Id: <20190924181244.7159-7-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190924181244.7159-1-nsaenzjulienne@suse.de> References: <20190924181244.7159-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 25 Sep 2019 04:16:20 +0000 Subject: [Xen-devel] [PATCH 06/11] of: address: use parent OF node in of_dma_get_range() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: f.fainelli@gmail.com, mbrugger@suse.com, wahrenst@gmx.net, james.quinlan@broadcom.com, robin.murphy@arm.com, Nicolas Saenz Julienne Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Some devices don't have their own OF node, and are stuck passing their bus node. Adapt the function for this use case. Signed-off-by: Nicolas Saenz Julienne --- drivers/of/address.c | 33 +++++++++++++++------------------ drivers/of/device.c | 3 ++- include/linux/of_address.h | 8 ++++---- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/drivers/of/address.c b/drivers/of/address.c index 53666063e938..b7b864b0ac75 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -914,30 +914,21 @@ EXPORT_SYMBOL(of_io_request_and_map); * It returns -ENODEV if "dma-ranges" property was not found * for this device in DT. */ -int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u6= 4 *size) +int of_dma_get_range(struct device_node *parent, u64 *dma_addr, + u64 *paddr, u64 *size) { - struct device_node *node =3D of_node_get(np); + struct device_node *node =3D of_node_get(parent); const __be32 *ranges =3D NULL; int naddr, nsize, pna; int ret =3D 0; u64 dmaaddr; =20 - if (!node) - return -EINVAL; - while (1) { - struct device_node *parent; + struct device_node *tmp; int len; =20 - naddr =3D of_n_addr_cells(node); - nsize =3D of_n_size_cells(node); - - parent =3D __of_get_dma_parent(node); - of_node_put(node); - - node =3D parent; - if (!node) - break; + naddr =3D __of_n_addr_cells_parent(node); + nsize =3D __of_n_size_cells_parent(node); =20 ranges =3D of_get_property(node, "dma-ranges", &len); =20 @@ -951,10 +942,16 @@ int of_dma_get_range(struct device_node *np, u64 *dma= _addr, u64 *paddr, u64 *siz */ if (!ranges) break; + + tmp =3D __of_get_dma_parent(node); + of_node_put(node); + node =3D tmp; + if (!node) + break; } =20 if (!ranges) { - pr_debug("no dma-ranges found for node(%pOF)\n", np); + pr_debug("no dma-ranges found for node(%pOF)\n", node); ret =3D -ENODEV; goto out; } @@ -967,10 +964,10 @@ int of_dma_get_range(struct device_node *np, u64 *dma= _addr, u64 *paddr, u64 *siz * size : nsize cells */ dmaaddr =3D of_read_number(ranges, naddr); - *paddr =3D of_translate_dma_address(np, ranges); + *paddr =3D of_translate_dma_address_parent(parent, ranges); if (*paddr =3D=3D OF_BAD_ADDR) { pr_err("translation of DMA address(%pad) to CPU address failed node(%pOF= )\n", - dma_addr, np); + dma_addr, parent); ret =3D -EINVAL; goto out; } diff --git a/drivers/of/device.c b/drivers/of/device.c index da8158392010..267b509df517 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -95,7 +95,8 @@ int of_dma_configure(struct device *dev, struct device_no= de *np, bool force_dma) const struct iommu_ops *iommu; u64 mask; =20 - ret =3D of_dma_get_range(np, &dma_addr, &paddr, &size); + ret =3D of_dma_get_range(__of_get_dma_parent(np), &dma_addr, + &paddr, &size); if (ret < 0) { /* * For legacy reasons, we have to assume some devices need diff --git a/include/linux/of_address.h b/include/linux/of_address.h index 30e40fb6936b..aa1ce0cb59a1 100644 --- a/include/linux/of_address.h +++ b/include/linux/of_address.h @@ -55,8 +55,8 @@ extern int of_pci_dma_range_parser_init(struct of_pci_ran= ge_parser *parser, extern struct of_pci_range *of_pci_range_parser_one( struct of_pci_range_parser *parser, struct of_pci_range *range); -extern int of_dma_get_range(struct device_node *np, u64 *dma_addr, - u64 *paddr, u64 *size); +extern int of_dma_get_range(struct device_node *parent, u64 *dma_addr, + u64 *paddr, u64 *size); extern bool of_dma_is_coherent(struct device_node *np); #else /* CONFIG_OF_ADDRESS */ static inline void __iomem *of_io_request_and_map(struct device_node *devi= ce, @@ -104,8 +104,8 @@ static inline struct of_pci_range *of_pci_range_parser_= one( return NULL; } =20 -static inline int of_dma_get_range(struct device_node *np, u64 *dma_addr, - u64 *paddr, u64 *size) +static inline int of_dma_get_range(struct device_node *parent, u64 *dma_ad= dr, + u64 *paddr, u64 *size) { return -ENODEV; } --=20 2.23.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri May 3 05:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1569385046; cv=none; d=zoho.com; s=zohoarc; b=CGZZidAOzNdHN33twqWlk92SOrwGNqppVRcVhUvZP62e+e+TLdWFyTKTiIaNuwJoJ24wr/R4GpY6Te0Xf7vLZyVjuBoyBHVJBKJIT6cIA1E51D3Pzu+odF1aZujwFQu5kmbc+d3VmptAXtMRy+vimatn6hUEp2csyWMrndVvY74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569385046; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=G6pvCyxtS8ESNk4Z9djk26pzZ+ugoDCrUq9fsPflBgI=; b=SMK0/mVmMK4xTGUiZWgJz71n2JdMB1rMsrIm/oW03a75eEht3HdPCxaQo5gEhPMPH0h6sWODOFOs7WX3SjjiWWfEqPyk4t4oKUMvI1ek+yxiybtpB2iv/kmcUCuafynETWppNNeHw1whINI/76Zel5ijNxbONY/0UTHU4LbMQyQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1569385046154474.46406054758006; Tue, 24 Sep 2019 21:17:26 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCyj4-0000Uv-3k; Wed, 25 Sep 2019 04:16:26 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCpJO-0000H7-EJ for xen-devel@lists.xenproject.org; Tue, 24 Sep 2019 18:13:18 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by localhost (Halon) with ESMTPS id f13de1b0-def6-11e9-b588-bc764e2007e4; Tue, 24 Sep 2019 18:13:00 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id D4F0DAF03; Tue, 24 Sep 2019 18:12:59 +0000 (UTC) X-Inumbo-ID: f13de1b0-def6-11e9-b588-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Nicolas Saenz Julienne To: robh+dt@kernel.org, devicetree@vger.kernel.org, frowand.list@gmail.com, linux-arm-kernel@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, xen-devel@lists.xenproject.org, linux-tegra@vger.kernel.org, linux-media@vger.kernel.org, linux-pci@vger.kernel.org, Shawn Guo , Li Yang Date: Tue, 24 Sep 2019 20:12:38 +0200 Message-Id: <20190924181244.7159-8-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190924181244.7159-1-nsaenzjulienne@suse.de> References: <20190924181244.7159-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 25 Sep 2019 04:16:20 +0000 Subject: [Xen-devel] [PATCH 07/11] dts: arm64: layerscape: add dma-ranges property to qoric-mc node X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , f.fainelli@gmail.com, mbrugger@suse.com, wahrenst@gmx.net, james.quinlan@broadcom.com, robin.murphy@arm.com, Nicolas Saenz Julienne Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" qoriq-mc's dpmacs DMA configuration is inherited from their parent node, which acts a bus in this regard. So far it maked all devices as dma-coherent but no dma-ranges recommendation is made. The truth is that the underlying interconnect has DMA constraints, so add an empty dma-ranges in qoriq-mc's node in order for DT's DMA configuration code to get the DMA constraints from it. Signed-off-by: Nicolas Saenz Julienne --- arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 1 + arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi | 1 + arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi | 1 + 3 files changed, 3 insertions(+) diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi b/arch/arm64/bo= ot/dts/freescale/fsl-ls1088a.dtsi index c676d0771762..f0d0b6145b72 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi @@ -698,6 +698,7 @@ <0x00000000 0x08340000 0 0x40000>; /* MC control reg */ msi-parent =3D <&its>; iommu-map =3D <0 &smmu 0 0>; /* This is fixed-up by u-boot */ + dma-ranges; dma-coherent; #address-cells =3D <3>; #size-cells =3D <1>; diff --git a/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi b/arch/arm64/bo= ot/dts/freescale/fsl-ls208xa.dtsi index 7a0be8eaa84a..fd6036b7865c 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi @@ -340,6 +340,7 @@ <0x00000000 0x08340000 0 0x40000>; /* MC control reg */ msi-parent =3D <&its>; iommu-map =3D <0 &smmu 0 0>; /* This is fixed-up by u-boot */ + dma-ranges; dma-coherent; #address-cells =3D <3>; #size-cells =3D <1>; diff --git a/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi b/arch/arm64/bo= ot/dts/freescale/fsl-lx2160a.dtsi index 408e0ecdce6a..3735bb139cb2 100644 --- a/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi @@ -868,6 +868,7 @@ msi-parent =3D <&its>; /* iommu-map property is fixed up by u-boot */ iommu-map =3D <0 &smmu 0 0>; + dma-ranges; dma-coherent; #address-cells =3D <3>; #size-cells =3D <1>; --=20 2.23.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri May 3 05:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1569385042; cv=none; d=zoho.com; s=zohoarc; b=RV0hlh7ZK/Fc59PNtkTxxPRF2K0qZcpfIeMDm6PStdQ0lZZKnB20lb9up3bb6PwGmLEimOi9HJ+6BWucp/V6sD+eiHqNQsejX7ud8qXOnCt+L7MeTSe9UFfOHVGroHiYjI+E2GEJC60TpxXNgZNCATIaK6a1Cgydvyj5CN3rCTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569385042; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=haMBBmRXkOD+0PLtHoumjYi6HH0gyFTeRn6MZajCW4k=; b=aEqmq/nvHnJvs2XScFzM1ZXKgLG1+x/UH3iMEz4V9UvYEEUqD5wvYUlsscn/p9NclOkuM+xznAtg9v8TCqdwhUXD07xQu3UKh6WrBita/REyl1CoG2ZVG0PWWT67ftGdCDyXQitCjO4a5EW9305DBEP8aEmalz/+yRGByzTJTFE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1569385042023385.4910404928165; Tue, 24 Sep 2019 21:17:22 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCyj2-0000S1-DD; Wed, 25 Sep 2019 04:16:24 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCpJE-0000Fn-1j for xen-devel@lists.xenproject.org; Tue, 24 Sep 2019 18:13:08 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by localhost (Halon) with ESMTPS id f2101d6a-def6-11e9-9625-12813bfff9fa; Tue, 24 Sep 2019 18:13:02 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 4A5C4ABBD; Tue, 24 Sep 2019 18:13:01 +0000 (UTC) X-Inumbo-ID: f2101d6a-def6-11e9-9625-12813bfff9fa X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Nicolas Saenz Julienne To: robh+dt@kernel.org, devicetree@vger.kernel.org, frowand.list@gmail.com, linux-arm-kernel@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, xen-devel@lists.xenproject.org, linux-tegra@vger.kernel.org, linux-media@vger.kernel.org, linux-pci@vger.kernel.org, Shawn Guo , Li Yang Date: Tue, 24 Sep 2019 20:12:39 +0200 Message-Id: <20190924181244.7159-9-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190924181244.7159-1-nsaenzjulienne@suse.de> References: <20190924181244.7159-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 25 Sep 2019 04:16:20 +0000 Subject: [Xen-devel] [PATCH 08/11] dts: arm64: layerscape: add dma-ranges property to pcie nodes X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , f.fainelli@gmail.com, mbrugger@suse.com, wahrenst@gmx.net, james.quinlan@broadcom.com, robin.murphy@arm.com, Nicolas Saenz Julienne Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The bus behind the board's PCIe core has DMA addressing limitations. Add an empty 'dma-ranges' property on all PCIe bus descriptions to inform the OF core that a translation is due further down the line. Signed-off-by: Nicolas Saenz Julienne --- arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi b/arch/arm64/bo= ot/dts/freescale/fsl-ls208xa.dtsi index fd6036b7865c..2c41cfc66bb9 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi @@ -640,6 +640,7 @@ #size-cells =3D <2>; device_type =3D "pci"; dma-coherent; + dma-ranges; num-viewport =3D <6>; bus-range =3D <0x0 0xff>; msi-parent =3D <&its>; @@ -661,6 +662,7 @@ #size-cells =3D <2>; device_type =3D "pci"; dma-coherent; + dma-ranges; num-viewport =3D <6>; bus-range =3D <0x0 0xff>; msi-parent =3D <&its>; @@ -682,6 +684,7 @@ #size-cells =3D <2>; device_type =3D "pci"; dma-coherent; + dma-ranges; num-viewport =3D <256>; bus-range =3D <0x0 0xff>; msi-parent =3D <&its>; @@ -703,6 +706,7 @@ #size-cells =3D <2>; device_type =3D "pci"; dma-coherent; + dma-ranges; num-viewport =3D <6>; bus-range =3D <0x0 0xff>; msi-parent =3D <&its>; --=20 2.23.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri May 3 05:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1569385046; cv=none; d=zoho.com; s=zohoarc; b=i3X7x7CrRcc/W+jlQn/D6H68LfZ4tVy/H9mHf3w9nBb6DTlg28gyf/cyqOIprMelpy1Mt3IO2+taJvS5uVF90iRkyU3n3fxzKMMZ7gcdCak/u6B65h+OfSgQdHhf4OchjrTLUJH4S89ttjuCZbwxEMSquL1iUgqHXENDDLrKsoc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569385046; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Q6xJKEZPmHNPjBcgDOyfEjkVDpEbd6BYOtfjptFxSAI=; b=cOJtp2RpJtJWFHu5fhLs924B8hbBuPCvcmy9MT1DKMI2fZIHPFfNkquVQv5b6rngisRhiM2Q+mc2KxByOyfJAfVDRtHSTOvhmVvH8U9tCBF2KhANOQ+JsJgIgUn/dmiRCxxchyI8aEgxwZqxNeK4VEOp9F6OFJF6zOTYmVvlvBA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1569385046380166.0534565121343; Tue, 24 Sep 2019 21:17:26 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCyj4-0000Vr-JA; Wed, 25 Sep 2019 04:16:26 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCpJT-0000HQ-E3 for xen-devel@lists.xenproject.org; Tue, 24 Sep 2019 18:13:23 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by localhost (Halon) with ESMTPS id f2d65750-def6-11e9-8628-bc764e2007e4; Tue, 24 Sep 2019 18:13:03 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 93C9FAEF1; Tue, 24 Sep 2019 18:13:02 +0000 (UTC) X-Inumbo-ID: f2d65750-def6-11e9-8628-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Nicolas Saenz Julienne To: robh+dt@kernel.org, devicetree@vger.kernel.org, frowand.list@gmail.com, linux-arm-kernel@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, xen-devel@lists.xenproject.org, linux-tegra@vger.kernel.org, linux-media@vger.kernel.org, linux-pci@vger.kernel.org Date: Tue, 24 Sep 2019 20:12:40 +0200 Message-Id: <20190924181244.7159-10-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190924181244.7159-1-nsaenzjulienne@suse.de> References: <20190924181244.7159-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 25 Sep 2019 04:16:20 +0000 Subject: [Xen-devel] [PATCH 09/11] of: device: remove comment in of_dma_configure() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: f.fainelli@gmail.com, mbrugger@suse.com, wahrenst@gmx.net, james.quinlan@broadcom.com, robin.murphy@arm.com, Nicolas Saenz Julienne Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" It's not longer advised to use notifiers in order to setup custom DMA ops. Signed-off-by: Nicolas Saenz Julienne --- drivers/of/device.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/of/device.c b/drivers/of/device.c index 267b509df517..018c52688546 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -81,10 +81,6 @@ int of_device_add(struct platform_device *ofdev) * * Try to get devices's DMA configuration from DT and update it * accordingly. - * - * If platform code needs to use its own special DMA configuration, it - * can use a platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE events - * to fix up DMA configuration. */ int of_dma_configure(struct device *dev, struct device_node *np, bool forc= e_dma) { --=20 2.23.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri May 3 05:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1569385046; cv=none; d=zoho.com; s=zohoarc; b=QRy2QS3zgKrvWZFTCp+c1Kv/YHttN6hQfcvgEpPJAXzcHhxjKjvLD6P/WEKdSTCqXzBbQOTH6V8w+PUK0IjWshubAzoXPKbCu/lF8rOXGh5sl87xImV7J+WjdMEDZ8jq2egYB524ciiYfEwFS/PwZ3H+6m98KFHk/t2F5wsxM84= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569385046; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Sqdu/6DKAdeeB304qp6Ws3+c+FxQ5mm4q6QHL8BRfFo=; b=drf3ZpHeS5EXKvNmx7+GcSI7Kg/TjioDcyPDybq/k2dn9owDZMKJ9pDawPIcdR53c6cv4CpiFBC+x+FULCQhoogm7gGmCaZCxz3sS8gi3sCejKAlVXvOCjH9XScP64uJqyjb2JKf/3wwmGxByDCZOQ/Tj8/TSOgsnsLLRehx9Vg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1569385046578273.8304270413638; Tue, 24 Sep 2019 21:17:26 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCyj3-0000TN-4t; Wed, 25 Sep 2019 04:16:25 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCpJJ-0000GQ-3q for xen-devel@lists.xenproject.org; Tue, 24 Sep 2019 18:13:13 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by localhost (Halon) with ESMTPS id f3ee48b4-def6-11e9-9625-12813bfff9fa; Tue, 24 Sep 2019 18:13:05 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 67856AC93; Tue, 24 Sep 2019 18:13:04 +0000 (UTC) X-Inumbo-ID: f3ee48b4-def6-11e9-9625-12813bfff9fa X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Nicolas Saenz Julienne To: robh+dt@kernel.org, devicetree@vger.kernel.org, frowand.list@gmail.com, linux-arm-kernel@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, xen-devel@lists.xenproject.org, linux-tegra@vger.kernel.org, linux-media@vger.kernel.org, linux-pci@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Thierry Reding , Bjorn Helgaas Date: Tue, 24 Sep 2019 20:12:41 +0200 Message-Id: <20190924181244.7159-11-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190924181244.7159-1-nsaenzjulienne@suse.de> References: <20190924181244.7159-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 25 Sep 2019 04:16:20 +0000 Subject: [Xen-devel] [PATCH 10/11] of: device: introduce of_dma_configure_parent() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: f.fainelli@gmail.com, mbrugger@suse.com, wahrenst@gmx.net, james.quinlan@broadcom.com, robin.murphy@arm.com, Nicolas Saenz Julienne Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Devices not represented in DT, placed behind a bus that autodetects them, pass of_dma_configure() their bus' DT node. This misses that bus' 'dma-ranges' property as the function's implementation expects the DT node to be one of a device. Create of_dma_configure_parent() which takes the given DT node as the device's underlying bus and parses it accordingly. Signed-off-by: Nicolas Saenz Julienne --- drivers/bus/fsl-mc/fsl-mc-bus.c | 2 +- drivers/gpu/host1x/bus.c | 2 +- drivers/of/device.c | 30 ++++++++++++++++++++++++++++-- drivers/pci/pci-driver.c | 3 ++- include/linux/of_device.h | 13 ++++++++++--- 5 files changed, 42 insertions(+), 8 deletions(-) diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bu= s.c index 5c9bf2e06552..217e64119497 100644 --- a/drivers/bus/fsl-mc/fsl-mc-bus.c +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c @@ -134,7 +134,7 @@ static int fsl_mc_dma_configure(struct device *dev) while (dev_is_fsl_mc(dma_dev)) dma_dev =3D dma_dev->parent; =20 - return of_dma_configure(dev, dma_dev->of_node, 0); + return of_dma_configure_parent(dev, dma_dev->of_node, false); } =20 static ssize_t modalias_show(struct device *dev, struct device_attribute *= attr, diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c index 742aa9ff21b8..2fdc04383a60 100644 --- a/drivers/gpu/host1x/bus.c +++ b/drivers/gpu/host1x/bus.c @@ -442,7 +442,7 @@ static int host1x_device_add(struct host1x *host1x, device->dev.bus =3D &host1x_bus_type; device->dev.parent =3D host1x->dev; =20 - of_dma_configure(&device->dev, host1x->dev->of_node, true); + of_dma_configure_parent(&device->dev, host1x->dev->of_node, true); =20 device->dev.dma_parms =3D &device->dma_parms; dma_set_max_seg_size(&device->dev, SZ_4M); diff --git a/drivers/of/device.c b/drivers/of/device.c index 018c52688546..1d0b1127d05e 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -83,6 +83,31 @@ int of_device_add(struct platform_device *ofdev) * accordingly. */ int of_dma_configure(struct device *dev, struct device_node *np, bool forc= e_dma) +{ + struct device_node *dma_parent; + int ret; + + dma_parent =3D __of_get_dma_parent(np); + ret =3D of_dma_configure_parent(dev, dma_parent, force_dma); + of_node_put(dma_parent); + + return ret; +} +EXPORT_SYMBOL_GPL(of_dma_configure); + +/** + * of_dma_configure_parent - Setup DMA configuration based on a parent bus' + * DT node + * @dev: Device to apply DMA configuration + * @parent: Parent bus device node + * @force_dma: Whether device is to be set up by of_dma_configure() even = if + * DMA capability is not explicitly described by firmware. + * + * Try to get devices's DMA configuration from parent bus' DT and update it + * accordingly. + */ +int of_dma_configure_parent(struct device *dev, struct device_node *parent, + bool force_dma) { u64 dma_addr, paddr, size =3D 0; int ret; @@ -91,8 +116,9 @@ int of_dma_configure(struct device *dev, struct device_n= ode *np, bool force_dma) const struct iommu_ops *iommu; u64 mask; =20 - ret =3D of_dma_get_range(__of_get_dma_parent(np), &dma_addr, - &paddr, &size); + dev_dbg(dev, "starting at %pOF\n", parent); + + ret =3D of_dma_get_range(parent, &dma_addr, &paddr, &size); if (ret < 0) { /* * For legacy reasons, we have to assume some devices need diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index a8124e47bf6e..25073d68a0f6 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -1628,7 +1628,8 @@ static int pci_dma_configure(struct device *dev) =20 if (IS_ENABLED(CONFIG_OF) && bridge->parent && bridge->parent->of_node) { - ret =3D of_dma_configure(dev, bridge->parent->of_node, true); + ret =3D of_dma_configure_parent(dev, bridge->parent->of_node, + true); } else if (has_acpi_companion(bridge)) { struct acpi_device *adev =3D to_acpi_device_node(bridge->fwnode); =20 diff --git a/include/linux/of_device.h b/include/linux/of_device.h index 8d31e39dd564..8f319b8c9deb 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h @@ -55,9 +55,9 @@ static inline struct device_node *of_cpu_device_node_get(= int cpu) return of_node_get(cpu_dev->of_node); } =20 -int of_dma_configure(struct device *dev, - struct device_node *np, - bool force_dma); +int of_dma_configure(struct device *dev, struct devce_node *np, bool force= _dma); +int of_dma_configure_parent(struct device *dev, struct device_node *parent, + bool force_dma); #else /* CONFIG_OF */ =20 static inline int of_driver_match_device(struct device *dev, @@ -112,6 +112,13 @@ static inline int of_dma_configure(struct device *dev, { return 0; } + +static inline int of_dma_configure_parent(struct device *dev, + struct device_node *parent, + bool force_dma) +{ + return 0; +} #endif /* CONFIG_OF */ =20 #endif /* _LINUX_OF_DEVICE_H */ --=20 2.23.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri May 3 05:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1569385047; cv=none; d=zoho.com; s=zohoarc; b=m8BPoGgefMJZ8Nk7EmkSuoC+XgRw0ELz/mOntCuIM/hDD71Sptu/fjy8Gaukl3VQoSXZvWhc78ApEFDftIIyKWn4JKI9aSCMlzq0LS5w30WcHzG9HgOVu6Yx1snvf7lqmFlVXNzx2gv3gWdVIE3Eof/WrY8IUKPtkpppFsvm4DM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569385047; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=T36tVt8GU3MsyefTeHKpFy3lWhxkmmIHjn5KP2Ja9+Q=; b=MrFr3r8aAojXGj6AF5ZKSB1dOIU4dHvZq1IMFgsco/zZuKu8wlDIO20ChFX/Klp5uXKWD7hPz53R/uXUDj8j9FY58OESBksecZZpYMH/deuHsWIMpKoLLGC2lqbNPFu64crKGe9VpFPQnutwy5J2D5IFI8QHAOhei3lMb2+bqy0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 156938504757454.0140146363417; Tue, 24 Sep 2019 21:17:27 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCyj5-0000Wm-4A; Wed, 25 Sep 2019 04:16:27 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCpJY-0000Hj-Ee for xen-devel@lists.xenproject.org; Tue, 24 Sep 2019 18:13:28 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by localhost (Halon) with ESMTPS id f8c21a78-def6-11e9-8628-bc764e2007e4; Tue, 24 Sep 2019 18:13:13 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 71267ABBD; Tue, 24 Sep 2019 18:13:11 +0000 (UTC) X-Inumbo-ID: f8c21a78-def6-11e9-8628-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Nicolas Saenz Julienne To: robh+dt@kernel.org, devicetree@vger.kernel.org, frowand.list@gmail.com, linux-arm-kernel@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, xen-devel@lists.xenproject.org, linux-tegra@vger.kernel.org, linux-media@vger.kernel.org, linux-pci@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , Sinan Kaya , Andy Gross , Lucas Stach , Russell King , Christian Gmeiner , Maxime Ripard , Chen-Yu Tsai , Oleksandr Andrushchenko , Thierry Reding , Stanimir Varbanov , Kyungmin Park , Kamil Debski , Jeongtae Park , Andrzej Hajda , Boris Ostrovsky , Juergen Gross , Stefano Stabellini Date: Tue, 24 Sep 2019 20:12:42 +0200 Message-Id: <20190924181244.7159-12-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190924181244.7159-1-nsaenzjulienne@suse.de> References: <20190924181244.7159-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 25 Sep 2019 04:16:20 +0000 Subject: [Xen-devel] [PATCH 11/11] of: simplify of_dma_config()'s arguments X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: freedreno@lists.freedesktop.org, f.fainelli@gmail.com, Daniel Vetter , David Airlie , Sean Paul , Rob Clark , Vinod Koul , mbrugger@suse.com, wahrenst@gmx.net, james.quinlan@broadcom.com, Dan Williams , Mauro Carvalho Chehab , robin.murphy@arm.com, Nicolas Saenz Julienne Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The widespread use case for of_dma_config() highlights a redundant argument. Most callers provide both 'dev' and 'dev->of_node'. The rest of users use it to copy some device's DMA configuration into a device not represented in DT. In order to simplify the common use case, and make code a little more explicit, create of_dma_config_copy() which will take another device's DT node as an argument and simplify of_dma_config() by removing one of it's redundant arguments. Signed-off-by: Nicolas Saenz Julienne --- drivers/base/platform.c | 2 +- drivers/bcma/main.c | 2 +- drivers/dma/qcom/hidma_mgmt.c | 2 +- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 2 +- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 2 +- drivers/gpu/drm/sun4i/sun4i_backend.c | 2 +- drivers/gpu/drm/xen/xen_drm_front.c | 2 +- drivers/gpu/host1x/bus.c | 2 +- drivers/media/platform/qcom/venus/firmware.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc.c | 2 +- drivers/of/device.c | 30 ++++++++++++++++++-- drivers/xen/gntdev.c | 2 +- include/linux/of_device.h | 12 ++++++-- 13 files changed, 48 insertions(+), 16 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index b6c6c7d97d5b..4e252028aee9 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -1221,7 +1221,7 @@ int platform_dma_configure(struct device *dev) int ret =3D 0; =20 if (dev->of_node) { - ret =3D of_dma_configure(dev, dev->of_node, true); + ret =3D of_dma_configure(dev, true); } else if (has_acpi_companion(dev)) { attr =3D acpi_get_dma_attr(to_acpi_device_node(dev->fwnode)); ret =3D acpi_dma_configure(dev, attr); diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c index 6535614a7dc1..4c7e8b35525c 100644 --- a/drivers/bcma/main.c +++ b/drivers/bcma/main.c @@ -207,7 +207,7 @@ static void bcma_of_fill_device(struct device *parent, =20 core->irq =3D bcma_of_get_irq(parent, core, 0); =20 - of_dma_configure(&core->dev, node, false); + of_dma_configure(&core->dev, false); } =20 unsigned int bcma_core_irq(struct bcma_device *core, int num) diff --git a/drivers/dma/qcom/hidma_mgmt.c b/drivers/dma/qcom/hidma_mgmt.c index 806ca02c52d7..4ea901537902 100644 --- a/drivers/dma/qcom/hidma_mgmt.c +++ b/drivers/dma/qcom/hidma_mgmt.c @@ -388,7 +388,7 @@ static int __init hidma_mgmt_of_populate_channels(struc= t device_node *np) goto out; } new_pdev->dev.of_node =3D child; - of_dma_configure(&new_pdev->dev, child, true); + of_dma_configure(&new_pdev->dev, true); /* * It is assumed that calling of_msi_configure is safe on * platforms with or without MSI support. diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnavi= v/etnaviv_drv.c index 1f9c01be40d7..1375f41593ef 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -706,7 +706,7 @@ static int __init etnaviv_init(void) * device as the GPU we found. This assumes that all Vivante * GPUs in the system share the same DMA constraints. */ - of_dma_configure(&pdev->dev, np, true); + of_dma_configure_copy(&pdev->dev, np, true); =20 ret =3D platform_device_add(pdev); if (ret) { diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/ad= reno/a6xx_gmu.c index 85f14feafdec..825fcdc72bd9 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c @@ -1268,7 +1268,7 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct d= evice_node *node) =20 gmu->dev =3D &pdev->dev; =20 - of_dma_configure(gmu->dev, node, true); + of_dma_configure(gmu->dev, true); =20 /* Fow now, don't do anything fancy until we get our feet under us */ gmu->idle_level =3D GMU_IDLE_STATE_ACTIVE; diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/= sun4i_backend.c index 4e29f4fe4a05..97dd5d31e38d 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -802,7 +802,7 @@ static int sun4i_backend_bind(struct device *dev, struc= t device *master, * for us, and DRM doesn't do per-device allocation either, so * we would need to fix DRM first... */ - ret =3D of_dma_configure(drm->dev, dev->of_node, true); + ret =3D of_dma_configure_copy(drm->dev, dev->of_node, true); if (ret) return ret; } else { diff --git a/drivers/gpu/drm/xen/xen_drm_front.c b/drivers/gpu/drm/xen/xen_= drm_front.c index ba1828acd8c9..fa0bfd6517fa 100644 --- a/drivers/gpu/drm/xen/xen_drm_front.c +++ b/drivers/gpu/drm/xen/xen_drm_front.c @@ -726,7 +726,7 @@ static int xen_drv_probe(struct xenbus_device *xb_dev, * node to set default DMA ops. */ dev->coherent_dma_mask =3D DMA_BIT_MASK(32); - ret =3D of_dma_configure(dev, NULL, true); + ret =3D of_dma_configure(dev, true); if (ret < 0) { DRM_ERROR("Cannot setup DMA ops, ret %d", ret); return ret; diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c index 2fdc04383a60..4eb531906e4a 100644 --- a/drivers/gpu/host1x/bus.c +++ b/drivers/gpu/host1x/bus.c @@ -337,7 +337,7 @@ static int host1x_device_uevent(struct device *dev, =20 static int host1x_dma_configure(struct device *dev) { - return of_dma_configure(dev, dev->of_node, true); + return of_dma_configure(dev, true); } =20 static const struct dev_pm_ops host1x_device_pm_ops =3D { diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/p= latform/qcom/venus/firmware.c index d3d1748a7ef6..82f433218d99 100644 --- a/drivers/media/platform/qcom/venus/firmware.c +++ b/drivers/media/platform/qcom/venus/firmware.c @@ -238,7 +238,7 @@ int venus_firmware_init(struct venus_core *core) =20 pdev->dev.of_node =3D np; =20 - ret =3D of_dma_configure(&pdev->dev, np, true); + ret =3D of_dma_configure(&pdev->dev, true); if (ret) { dev_err(core->dev, "dma configure fail\n"); goto err_unregister; diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platf= orm/s5p-mfc/s5p_mfc.c index b776f83e395e..ad33e7a655aa 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -1095,7 +1095,7 @@ static struct device *s5p_mfc_alloc_memdev(struct dev= ice *dev, * to be treated as valid DMA masters we need a bit of a hack to force * them to inherit the MFC node's DMA configuration. */ - of_dma_configure(child, dev->of_node, true); + of_dma_configure_copy(child, dev->of_node, true); =20 if (device_add(child) =3D=3D 0) { ret =3D of_reserved_mem_device_init_by_idx(child, dev->of_node, diff --git a/drivers/of/device.c b/drivers/of/device.c index 1d0b1127d05e..66726a2499d3 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -75,19 +75,18 @@ int of_device_add(struct platform_device *ofdev) /** * of_dma_configure - Setup DMA configuration * @dev: Device to apply DMA configuration - * @np: Pointer to OF node having DMA configuration * @force_dma: Whether device is to be set up by of_dma_configure() even = if * DMA capability is not explicitly described by firmware. * * Try to get devices's DMA configuration from DT and update it * accordingly. */ -int of_dma_configure(struct device *dev, struct device_node *np, bool forc= e_dma) +int of_dma_configure(struct device *dev, bool force_dma) { struct device_node *dma_parent; int ret; =20 - dma_parent =3D __of_get_dma_parent(np); + dma_parent =3D __of_get_dma_parent(dev->of_node); ret =3D of_dma_configure_parent(dev, dma_parent, force_dma); of_node_put(dma_parent); =20 @@ -95,6 +94,31 @@ int of_dma_configure(struct device *dev, struct device_n= ode *np, bool force_dma) } EXPORT_SYMBOL_GPL(of_dma_configure); =20 +/** + * of_dma_configure_copy - Setup DMA configuration based on another device= 's DT + * node + * @dev: Device to apply DMA configuration + * @np: Device node to copy the configuration from + * @force_dma: Whether device is to be set up by of_dma_configure() even = if + * DMA capability is not explicitly described by firmware. + * + * Try to get devices's DMA configuration from DT and update it + * accordingly. + */ +int of_dma_configure_copy(struct device *dev, struct device_node *np, + bool force_dma) +{ + struct device_node *dma_parent; + int ret; + + dma_parent =3D __of_get_dma_parent(np); + ret =3D of_dma_configure_parent(dev, dma_parent, force_dma); + of_node_put(dma_parent); + + return ret; +} +EXPORT_SYMBOL_GPL(of_dma_configure_copy); + /** * of_dma_configure_parent - Setup DMA configuration based on a parent bus' * DT node diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index a446a7221e13..115e39f9f67a 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -632,7 +632,7 @@ static int gntdev_open(struct inode *inode, struct file= *flip) * Fix this by calling of_dma_configure() with a NULL node to set * default DMA ops. */ - of_dma_configure(priv->dma_dev, NULL, true); + of_dma_configure(priv->dma_dev, true); #endif pr_debug("priv %p\n", priv); =20 diff --git a/include/linux/of_device.h b/include/linux/of_device.h index 8f319b8c9deb..b05a86fd35a4 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h @@ -55,7 +55,9 @@ static inline struct device_node *of_cpu_device_node_get(= int cpu) return of_node_get(cpu_dev->of_node); } =20 -int of_dma_configure(struct device *dev, struct devce_node *np, bool force= _dma); +int of_dma_configure(struct device *dev, bool force_dma); +int of_dma_configure_copy(struct device *dev, struct device_node *np, + bool force_dma); int of_dma_configure_parent(struct device *dev, struct device_node *parent, bool force_dma); #else /* CONFIG_OF */ @@ -107,12 +109,18 @@ static inline struct device_node *of_cpu_device_node_= get(int cpu) } =20 static inline int of_dma_configure(struct device *dev, - struct device_node *np, bool force_dma) { return 0; } =20 +static inline int of_dma_configure_copy(struct device *dev, + struct device_node *np, + bool force_dma) +{ + return 0; +} + static inline int of_dma_configure_parent(struct device *dev, struct device_node *parent, bool force_dma) --=20 2.23.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel