From patchwork Fri Sep 6 14:17:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 173239 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp778749ilq; Fri, 6 Sep 2019 07:17:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwUfDJaNcTUYWdzJUQ564oa6d7/bHnoKy5Larxo6DwhWtyjrdYk5XpWNjx8wTfZwdncTcEC X-Received: by 2002:a17:902:7c88:: with SMTP id y8mr9402004pll.306.1567779420561; Fri, 06 Sep 2019 07:17:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567779420; cv=none; d=google.com; s=arc-20160816; b=d4/ig2hkcO2WsBA9OvjduIb6XRmSddJHnvq/VsFNAk8Py0X8ATOnnoLLldpu06cZ7S VKe6YO/VSC36qoea/YczMqfN4C2jmGWxyZpMfdIHfeA8ykthernphvPZ5LAvZYtv2UD9 p9trXqPJ+Zc/L4VUQUKJPcHUVzQaSmByW1nQnEVxX7dbiHkbnR63XZIOM09dVZNzp6mK RxyKEZnvmLATkqlYlOHdUOSTxOEbqN+YDUT2OBQJ1kpexutPw459IMbrqeoG5oFmDfVk 0+/CqwVIsKTuMc/h9nSWUT/ecHG5SPL0LnQ6BEfsRTCcvIrf/FDFXoiiZszBkbieMcT4 P6cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lL+zXXpiAMPM0yEzqtzknYNhG5vy2NXPPxTYA7JesO0=; b=a36jGyhcGPwZxQKa3ZhZAXLZteBKHekvYVOpDLDCqZw/UtTRsIpNBbmROyguUohmrn J/pssZIQx0+4h1mxmvCvJy+pVTJVv3ziFXph5Y547nyJ5JE5kG0r25At7kIjZCzc3nZe uulaPf8IoS5PS26lF1lEX3rr1rluUMb8zYvvajFAByLOBtMOerYAa0KCLZ218V+ReqMn UborNNOWcfcabVisphs4OiN4i5MuGjTqHUOXUWr2Ujp0YEd0UmQyMYK/7nA2NjKdL7pS 2c/DiGRdsKYWxwaYAKehxSm+b7v6kahyNVPT/u7xvlzWYvESqYzQgqVllKFZXVSTivWG PZvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=bMPSYu3h; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d8si4521978pgv.61.2019.09.06.07.17.00; Fri, 06 Sep 2019 07:17:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=bMPSYu3h; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394119AbfIFOQ7 (ORCPT + 28 others); Fri, 6 Sep 2019 10:16:59 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:53072 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729017AbfIFOQ6 (ORCPT ); Fri, 6 Sep 2019 10:16:58 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x86EGrqM081318; Fri, 6 Sep 2019 09:16:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1567779413; bh=lL+zXXpiAMPM0yEzqtzknYNhG5vy2NXPPxTYA7JesO0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=bMPSYu3h2iINSzphkoyAysVXm0iwyvy1a2EUt0dQQ2CW6AglsVw2xIayp6CImvkpF HRT8Z/IvKAgoQdyC+D5FNdoVy/vScxAeC1a0CmnzFsh0kZ33Hh5Rvl76Sr/nRbPYlC 3QSOVssDCgoEaihU3HP5w3hah29dn2/QNSPPUoKs= Received: from DFLE107.ent.ti.com (dfle107.ent.ti.com [10.64.6.28]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x86EGrAd092427 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 6 Sep 2019 09:16:53 -0500 Received: from DFLE114.ent.ti.com (10.64.6.35) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Fri, 6 Sep 2019 09:16:53 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Fri, 6 Sep 2019 09:16:53 -0500 Received: from feketebors.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x86EGmad042400; Fri, 6 Sep 2019 09:16:51 -0500 From: Peter Ujfalusi To: , CC: , , , Subject: [RFC 1/3] dt-bindings: dma: Add documentation for DMA domains Date: Fri, 6 Sep 2019 17:17:15 +0300 Message-ID: <20190906141717.23859-2-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190906141717.23859-1-peter.ujfalusi@ti.com> References: <20190906141717.23859-1-peter.ujfalusi@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On systems where multiple DMA controllers available, none Slave (for example memcpy operation) users can not be described in DT as there is no device involved from the DMA controller's point of view, DMA binding is not usable. However in these systems still a peripheral might need to be serviced by or it is better to serviced by specific DMA controller. When a memcpy is used to/from a memory mapped region for example a DMA in the same domain can perform better. For generic software modules doing mem 2 mem operations it also matter that they will get a channel from a controller which is faster in DDR to DDR mode rather then from the first controller happen to be loaded. This property is inherited, so it may be specified in a device node or in any of its parent nodes. Signed-off-by: Peter Ujfalusi --- .../devicetree/bindings/dma/dma-domain.yaml | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/dma-domain.yaml -- Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/Documentation/devicetree/bindings/dma/dma-domain.yaml b/Documentation/devicetree/bindings/dma/dma-domain.yaml new file mode 100644 index 000000000000..c2f182f30081 --- /dev/null +++ b/Documentation/devicetree/bindings/dma/dma-domain.yaml @@ -0,0 +1,59 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/dma/dma-controller.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: DMA Domain Controller Definition + +maintainers: + - Vinod Koul + +allOf: + - $ref: "dma-controller.yaml#" + +description: + On systems where multiple DMA controllers available, none Slave (for example + memcpy operation) users can not be described in DT as there is no device + involved from the DMA controller's point of view, DMA binding is not usable. + However in these systems still a peripheral might need to be serviced by or + it is better to serviced by specific DMA controller. + When a memcpy is used to/from a memory mapped region for example a DMA in the + same domain can perform better. + For generic software modules doing mem 2 mem operations it also matter that + they will get a channel from a controller which is faster in DDR to DDR mode + rather then from the first controller happen to be loaded. + + This property is inherited, so it may be specified in a device node or in any + of its parent nodes. + +properties: + $dma-domain-controller: + $ref: /schemas/types.yaml#definitions/phandle + description: + phande to the DMA controller node which should be used for the device or + domain. + +examples: + - | + / { + model = "Texas Instruments K3 AM654 SoC"; + compatible = "ti,am654"; + interrupt-parent = <&gic500>; + /* For modules without device, DDR to DDR is faster on main UDMAP */ + dma-domain-controller = <&main_udmap>; + #address-cells = <2>; + #size-cells = <2>; + ... + }; + + &cbass_main { + /* For modules within MAIN domain, use main UDMAP */ + dma-domain-controller = <&main_udmap>; + }; + + &cbass_mcu { + /* For modules within MCU domain, use mcu UDMAP */ + dma-domain-controller = <&mcu_udmap>; + }; +... From patchwork Fri Sep 6 14:17:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 173242 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp778962ilq; Fri, 6 Sep 2019 07:17:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGwuTG96WTKRkh6AwGiluiW++HtNe1GYblekV30nYlLNpSzFljl/Qrh6E1dp/IpqAuJHhQ X-Received: by 2002:a65:640d:: with SMTP id a13mr8093110pgv.256.1567779429426; Fri, 06 Sep 2019 07:17:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567779429; cv=none; d=google.com; s=arc-20160816; b=F/P4TTNj3rcwZo5A3P51l+LXvrYkAxoK8cU2keVa8E8/PukSzaydCabywF0jxLPpTN Ir+g3GmBZT7jDPSACS7OT+d4DDgxfzazq11k9kEDojGJHC2viJIHxHzzMJLKsZ/Qz2ez qRMxLaLwTn5XSPo4qDNjX/9Vg4ht0eb38qJa21c2bwDrXjw7BUouIc26W/IVyTo2SBG3 Hrfx01VLbp9KuD21/lMdnBMRX8tsJNxc8i3xJOnktBBxCjModUHDdCGxnlvNZ9I2qAU3 K5qMQQf73f03e4X+QO7uFgomULiGA95qeVddR3shsu64Hv2PtqcOkI5U8iClgfz8kPlS bpbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Q0YSzmtvj7sqG004BV4lez3XreU1ptGoRlCRKi0kkXE=; b=tHc9iud385zVlzO964PMR7TpbkRpbgPL71M3UN/9mxOUvUXMlK6bbE11rhQ4ewZi0R m+4VRYTqujwfkS7bjpu+eL5ht/Y2iS8djeQrKLkzhxQVz8OuobNFTkFtoDrFIu3D+TKi vIj+N1VDYNcF2v8kQ5P12tfuDEdWNV8/w/xn7JknYBW/arvSYkj1KQ5XbxMiIH+TgkWt FH1WLLXgtmMTixvCM6Mt4brAlVRn8MRD3zSx55EiMDglwMPnA3YtT+BvhltcBo9x/Oew hIlgXxEmiWyD3kqRuOVDOwzIPYu/CC9wufDTZnaO3wl3LsFJV/Ks8mgmn33n4M4m0LfT Wtlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=kaSjK+uU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 89si5040842plf.367.2019.09.06.07.17.09; Fri, 06 Sep 2019 07:17:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=kaSjK+uU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392746AbfIFOQ7 (ORCPT + 28 others); Fri, 6 Sep 2019 10:16:59 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:53074 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730193AbfIFOQ6 (ORCPT ); Fri, 6 Sep 2019 10:16:58 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x86EGtVb081331; Fri, 6 Sep 2019 09:16:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1567779416; bh=Q0YSzmtvj7sqG004BV4lez3XreU1ptGoRlCRKi0kkXE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=kaSjK+uUbjW52iptdurvJMAQUbh3EfebBtj6Qmy6YTdE9dtVls6Vim7l7PCSAALjA 5SBPMxyhVQT89QM1ilLkJhdbHlovDn2v2u5LtwoQblW3SGCDdBPF7g4NAGoPyMjBc7 Kazi5ZowDUQlRUunuW2hINf1MNcLqY9DWcOySGK0= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x86EGtnm092456 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 6 Sep 2019 09:16:55 -0500 Received: from DLEE108.ent.ti.com (157.170.170.38) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Fri, 6 Sep 2019 09:16:55 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Fri, 6 Sep 2019 09:16:55 -0500 Received: from feketebors.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x86EGmae042400; Fri, 6 Sep 2019 09:16:53 -0500 From: Peter Ujfalusi To: , CC: , , , Subject: [RFC 2/3] dmaengine: of_dma: Function to look up the DMA domain of a client Date: Fri, 6 Sep 2019 17:17:16 +0300 Message-ID: <20190906141717.23859-3-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190906141717.23859-1-peter.ujfalusi@ti.com> References: <20190906141717.23859-1-peter.ujfalusi@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Find the DMA domain controller of the client device by iterating up in device tree looking for the closest 'dma-domain-controller' property. If the client's node is not provided then check the DT root for the controller. Signed-off-by: Peter Ujfalusi --- drivers/dma/of-dma.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/linux/of_dma.h | 7 +++++++ 2 files changed, 49 insertions(+) -- Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c index c2d779daa4b5..04b5795cd76b 100644 --- a/drivers/dma/of-dma.c +++ b/drivers/dma/of-dma.c @@ -18,6 +18,48 @@ static LIST_HEAD(of_dma_list); static DEFINE_MUTEX(of_dma_lock); +/** + * of_find_dma_domain - Get the domain DMA controller + * @np: device node of the client device + * + * Look up the DMA controller of the domain the client device is part of. + * Finds the dma-domain controller the client device belongs to. It is used when + * requesting non slave channels (like channel for memcpy) to make sure that the + * channel can be request from a DMA controller which can service the given + * domain best. + * + * Returns the device_node pointer of the DMA controller or succes or NULL on + * error. + */ +struct device_node *of_find_dma_domain(struct device_node *np) +{ + struct device_node *dma_domain = NULL; + phandle dma_phandle; + + /* + * If no device_node is provided look at the root level for system + * default DMA controller for modules. + */ + if (!np) + np = of_root; + + if (!np || !of_node_get(np)) + return NULL; + + do { + if (of_property_read_u32(np, "dma-domain-controller", + &dma_phandle)) + np = of_get_next_parent(np); + else { + dma_domain = of_find_node_by_phandle(dma_phandle); + of_node_put(np); + } + } while (!dma_domain && np); + + return dma_domain; +} +EXPORT_SYMBOL_GPL(of_find_dma_domain); + /** * of_dma_find_controller - Get a DMA controller in DT DMA helpers list * @dma_spec: pointer to DMA specifier as found in the device tree diff --git a/include/linux/of_dma.h b/include/linux/of_dma.h index fd706cdf255c..6eab0a8d3335 100644 --- a/include/linux/of_dma.h +++ b/include/linux/of_dma.h @@ -32,6 +32,8 @@ struct of_dma_filter_info { }; #ifdef CONFIG_DMA_OF +extern struct device_node *of_find_dma_domain(struct device_node *np); + extern int of_dma_controller_register(struct device_node *np, struct dma_chan *(*of_dma_xlate) (struct of_phandle_args *, struct of_dma *), @@ -52,6 +54,11 @@ extern struct dma_chan *of_dma_xlate_by_chan_id(struct of_phandle_args *dma_spec struct of_dma *ofdma); #else +static inline struct device_node *of_find_dma_domain(struct device_node *np) +{ + return NULL; +} + static inline int of_dma_controller_register(struct device_node *np, struct dma_chan *(*of_dma_xlate) (struct of_phandle_args *, struct of_dma *),