From: Grant Likely <grant.likely@secretlab.ca>
To: b-cousson@ti.com, devicetree-discuss@lists.ozlabs.org
Cc: vinod.koul@linux.intel.com, Stephen Warren <swarren@nvidia.com>,
Arnd Bergmann <arnd@arndb.de>,
Nicolas Ferre <nicolas.ferre@atmel.com>,
Rob Herring <rob.herring@calxeda.com>,
Russell King <linux@arm.linux.org.uk>,
linux-omap@vger.kernel.org, plagnioj@jcrosoft.com,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/2] of: selftest/dma: Add selftest for new DT DMA request helpers
Date: Tue, 20 Mar 2012 14:16:54 +0000 [thread overview]
Message-ID: <20120320141654.15D943E0A04@localhost> (raw)
In-Reply-To: <066e4deaddca8ac368c2c355c3a77daa9e9057cf.1332237596.git.nicolas.ferre@atmel.com>
On Tue, 20 Mar 2012 11:13:32 +0100, Nicolas Ferre <nicolas.ferre@atmel.com> wrote:
> Those selftests are covering the new DT DMA helpers. They will test both
> error and normal cases.
> A custom .xlate() function is also provided to show the use of this API in case
> of a different need than the single cell argument.
I'm very happy to see test case code. Thanks.
However, since we both understand that this series doesn't address my
major concerns, I'm not spending any time reviewing this version.
g.
>
> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> Cc: Benoit Cousson <b-cousson@ti.com>
> Cc: Stephen Warren <swarren@nvidia.com>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/arm/boot/dts/at91sam9m10g45ek.dts | 2 +
> arch/arm/boot/dts/testcases/tests-dma.dtsi | 24 +++++++
> arch/arm/boot/dts/testcases/tests.dtsi | 1 +
> drivers/of/selftest.c | 100 ++++++++++++++++++++++++++++
> 4 files changed, 127 insertions(+), 0 deletions(-)
> create mode 100644 arch/arm/boot/dts/testcases/tests-dma.dtsi
>
> diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts
> index a387e77..18a8f3c 100644
> --- a/arch/arm/boot/dts/at91sam9m10g45ek.dts
> +++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts
> @@ -38,3 +38,5 @@
> };
> };
> };
> +
> +/include/ "testcases/tests.dtsi"
> diff --git a/arch/arm/boot/dts/testcases/tests-dma.dtsi b/arch/arm/boot/dts/testcases/tests-dma.dtsi
> new file mode 100644
> index 0000000..5f0ba93
> --- /dev/null
> +++ b/arch/arm/boot/dts/testcases/tests-dma.dtsi
> @@ -0,0 +1,24 @@
> +
> +/ {
> + testcase-data {
> + dma-tests {
> + testdmac0: test-dma-controller0 {
> + #dma-cells = <1>;
> + };
> +
> + testdmac1: test-dma-controller1 {
> + #dma-cells = <2>;
> + };
> +
> + dma-slave-a {
> + dma-request = <&testdmac0 42>;
> + };
> + dma-slave-b {
> + dma-request = <&testdmac1 24>; /* wrong number of values */
> + };
> + dma-slave-c {
> + dma-request = <&testdmac1 24 25>;
> + };
> + };
> + };
> +};
> diff --git a/arch/arm/boot/dts/testcases/tests.dtsi b/arch/arm/boot/dts/testcases/tests.dtsi
> index a7c5067..e3afb2b 100644
> --- a/arch/arm/boot/dts/testcases/tests.dtsi
> +++ b/arch/arm/boot/dts/testcases/tests.dtsi
> @@ -1 +1,2 @@
> /include/ "tests-phandle.dtsi"
> +/include/ "tests-dma.dtsi"
> diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c
> index f24ffd7..3281bfd 100644
> --- a/drivers/of/selftest.c
> +++ b/drivers/of/selftest.c
> @@ -9,6 +9,7 @@
> #include <linux/errno.h>
> #include <linux/module.h>
> #include <linux/of.h>
> +#include <linux/of_dma.h>
> #include <linux/list.h>
> #include <linux/mutex.h>
> #include <linux/slab.h>
> @@ -148,6 +149,104 @@ static void __init of_selftest_property_match_string(void)
> selftest(rc == -EILSEQ, "unterminated string; rc=%i", rc);
> }
>
> +struct two_cells {
> + int cell1;
> + int cell2;
> +};
> +
> +static int of_dma_xlate_twonumbercell(struct of_phandle_args *dma_spec, void *cells)
> +{
> + struct two_cells *tc;
> +
> + if (!dma_spec)
> + return -EINVAL;
> + if (!cells)
> + return -ENOBUFS;
> + if (WARN_ON(dma_spec->args_count != 2))
> + return -EINVAL;
> +
> + tc = (struct two_cells *)cells;
> +
> + tc->cell1 = dma_spec->args[0];
> + tc->cell2 = dma_spec->args[1];
> + return 0;
> +}
> +
> +static void __init of_selftest_dma(void)
> +{
> + struct device_node *dma_controller0_np;
> + struct device_node *dma_controller1_np;
> + struct device_node *dma_slave_np;
> + int rc;
> + int dma_req;
> + struct two_cells tc;
> +
> + pr_info("start\n");
> + dma_controller0_np = of_find_node_by_path("/testcase-data/dma-tests/test-dma-controller0");
> + dma_slave_np = of_find_node_by_path("/testcase-data/dma-tests/dma-slave-a");
> + if (!dma_controller0_np || !dma_slave_np) {
> + pr_err("No testcase data in device tree\n");
> + return;
> + }
> +
> + /* wrong usage: DMA controller not registered yet! */
> + rc = of_get_dma_request(dma_slave_np, 0, &dma_req);
> + selftest(rc == -ENODEV, "selftest DMA slave request expected:-ENODEV got:%i\n", rc);
> +
> + /* test DMA controller registration */
> + rc = of_dma_controller_register(dma_controller0_np, of_dma_xlate_onenumbercell);
> + selftest(rc == 0, "selftest DMA controller not found: got:%i\n", rc);
> +
> + /* wrong usage and error code tests */
> + rc = of_get_dma_request(dma_slave_np, 1, &dma_req);
> + selftest(rc == -EINVAL, "selftest DMA slave request expected:-EINVAL got:%i\n", rc);
> +
> + rc = of_get_dma_request(dma_slave_np, 0, NULL);
> + selftest(rc == -ENOBUFS, "selftest DMA slave request expected:-ENOBUFS got:%i\n", rc);
> +
> + /* proper use of the API */
> + rc = of_get_dma_request(dma_slave_np, 0, &dma_req);
> + selftest(rc == 0, "selftest DMA slave request error: got:%i\n", rc);
> + selftest(dma_req == 42, "selftest DMA slave request line expected:42 got:%i\n", dma_req);
> +
> + of_dma_controller_free(dma_controller0_np);
> +
> + /* wrong usage: DMA controller not registered anymore! */
> + rc = of_get_dma_request(dma_slave_np, 0, &dma_req);
> + selftest(rc == -ENODEV, "selftest DMA slave request expected:-ENODEV got:%i\n", rc);
> +
> + /* use with a two values DMA request specification */
> + dma_controller1_np = of_find_node_by_path("/testcase-data/dma-tests/test-dma-controller1");
> + dma_slave_np = of_find_node_by_path("/testcase-data/dma-tests/dma-slave-b");
> + if (!dma_controller1_np || !dma_slave_np) {
> + pr_err("No testcase data in device tree\n");
> + return;
> + }
> +
> + /* DMA controller registration with custom .xlate() function */
> + rc = of_dma_controller_register(dma_controller1_np, of_dma_xlate_twonumbercell);
> + selftest(rc == 0, "selftest DMA controller not found: got:%i\n", rc);
> +
> + /* wrong number of cells */
> + rc = of_get_dma_request(dma_slave_np, 0, &tc);
> + selftest(rc == -EINVAL, "selftest DMA slave request expected:-EINVAL got:%i\n", rc);
> +
> + dma_slave_np = of_find_node_by_path("/testcase-data/dma-tests/dma-slave-c");
> + if (!dma_slave_np) {
> + pr_err("No dma-slave-c data in device tree\n");
> + return;
> + }
> +
> + /* proper use of the API */
> + rc = of_get_dma_request(dma_slave_np, 0, &tc);
> + selftest(rc == 0, "selftest DMA slave request error: got:%i\n", rc);
> + selftest(tc.cell1 == 24, "selftest DMA slave request line expected:24 got:%i\n", tc.cell1);
> + selftest(tc.cell2 == 25, "selftest DMA slave request line expected:25 got:%i\n", tc.cell2);
> +
> + of_dma_controller_free(dma_controller1_np);
> + pr_info("end - %s\n", selftest_passed ? "PASS" : "FAIL");
> +}
> +
> static int __init of_selftest(void)
> {
> struct device_node *np;
> @@ -162,6 +261,7 @@ static int __init of_selftest(void)
> pr_info("start of selftest - you will see error messages\n");
> of_selftest_parse_phandle_with_args();
> of_selftest_property_match_string();
> + of_selftest_dma();
> pr_info("end of selftest - %s\n", selftest_passed ? "PASS" : "FAIL");
> return 0;
> }
> --
> 1.7.9
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies,Ltd.
next prev parent reply other threads:[~2012-03-20 14:16 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-27 17:29 [RFC PATCH 1/2] of: Add generic device tree DMA helpers Cousson, Benoit
2012-01-27 18:13 ` Stephen Warren
2012-01-27 20:36 ` Cousson, Benoit
2012-01-28 18:12 ` Grant Likely
2012-01-28 18:06 ` Grant Likely
2012-01-31 21:26 ` Cousson, Benoit
2012-02-02 4:52 ` Grant Likely
2012-01-31 23:09 ` Russell King - ARM Linux
2012-02-01 10:50 ` Cousson, Benoit
[not found] ` <4F2918F6.9040100-l0cyMroinI0@public.gmane.org>
2012-02-02 8:45 ` Russell King - ARM Linux
[not found] ` <20120202084539.GC1275-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2012-02-02 8:54 ` Cousson, Benoit
2012-02-22 10:59 ` Nicolas Ferre
2012-02-23 10:03 ` Cousson, Benoit
2012-02-23 15:51 ` Nicolas Ferre
2012-02-23 15:57 ` Cousson, Benoit
[not found] ` <4F4661DE.90704-l0cyMroinI0@public.gmane.org>
2012-02-27 13:09 ` Nicolas Ferre
2012-02-27 14:22 ` Cousson, Benoit
2012-02-27 17:28 ` Nicolas Ferre
2012-02-29 14:54 ` [RFC PATCH] of: DMA helpers: manage generic requests specification Nicolas Ferre
2012-02-29 20:54 ` Stephen Warren
2012-03-05 13:14 ` Cousson, Benoit
2012-03-05 18:30 ` Stephen Warren
2012-03-05 19:57 ` Russell King - ARM Linux
2012-03-05 10:55 ` Cousson, Benoit
2012-03-05 15:36 ` Grant Likely
2012-03-14 17:47 ` Nicolas Ferre
2012-03-14 18:16 ` Stephen Warren
[not found] ` <4F22DEF2.5000807-l0cyMroinI0@public.gmane.org>
2012-03-15 8:38 ` [PATCH] of: Add generic device tree DMA helpers Nicolas Ferre
2012-03-15 9:22 ` Arnd Bergmann
2012-03-15 9:26 ` Russell King - ARM Linux
2012-03-15 10:09 ` Arnd Bergmann
2012-03-17 9:42 ` Grant Likely
2012-03-17 16:03 ` Arnd Bergmann
2012-03-18 9:08 ` Grant Likely
2012-03-15 10:27 ` Thierry Reding
2012-03-17 10:47 ` Grant Likely
2012-03-18 9:22 ` Thierry Reding
2012-03-18 15:10 ` Arnd Bergmann
2012-03-18 18:22 ` Grant Likely
2012-03-19 13:02 ` Mark Brown
2012-03-19 15:01 ` Arnd Bergmann
2012-03-19 15:07 ` Stephen Warren
2012-03-19 15:45 ` Arnd Bergmann
[not found] ` <201203191545.40933.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-19 16:54 ` Stephen Warren
2012-03-15 16:30 ` Cousson, Benoit
2012-03-15 19:57 ` Russell King - ARM Linux
[not found] ` <20120315195753.GA2842-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2012-03-15 20:41 ` Arnd Bergmann
2012-03-15 21:39 ` Cousson, Benoit
2012-03-15 21:55 ` Russell King - ARM Linux
2012-03-16 9:56 ` Arnd Bergmann
2012-03-20 14:02 ` Matt Porter
2012-03-15 23:45 ` Nicolas Pitre
2012-03-16 10:03 ` Arnd Bergmann
2012-03-16 11:19 ` Cousson, Benoit
2012-03-16 12:04 ` Arnd Bergmann
2012-03-16 13:28 ` Cousson, Benoit
2012-03-16 13:36 ` Nicolas Ferre
2012-03-17 9:40 ` Grant Likely
2012-03-18 20:13 ` Arnd Bergmann
2012-03-18 20:44 ` Grant Likely
2012-03-18 21:58 ` Arnd Bergmann
2012-03-18 22:12 ` Arnd Bergmann
2012-03-19 13:37 ` Nicolas Ferre
2012-03-19 15:20 ` Russell King - ARM Linux
2012-03-19 15:58 ` Cousson, Benoit
2012-03-19 13:30 ` Nicolas Ferre
2012-03-19 14:06 ` Arnd Bergmann
2012-03-19 15:33 ` Russell King - ARM Linux
2012-03-19 16:11 ` Arnd Bergmann
2012-03-19 18:06 ` Jassi Brar
2012-03-19 16:31 ` Nicolas Ferre
2012-03-19 17:49 ` Cousson, Benoit
2012-03-19 14:45 ` Grant Likely
2012-03-20 14:54 ` Nicolas Ferre
2012-03-20 10:13 ` [PATCH v2 1/2] " Nicolas Ferre
2012-03-20 10:13 ` [PATCH 2/2] of: selftest/dma: Add selftest for new DT DMA request helpers Nicolas Ferre
2012-03-20 14:16 ` Grant Likely [this message]
2012-03-20 10:17 ` [PATCH] of: dma/fixup Nicolas Ferre
[not found] ` <6b5dc1fadfd03a48093338b6981c0a7ae7662212.1332237596.git.nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2012-03-20 13:03 ` [PATCH v2 1/2] of: Add generic device tree DMA helpers Arnd Bergmann
2012-03-20 15:38 ` Stephen Warren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120320141654.15D943E0A04@localhost \
--to=grant.likely@secretlab.ca \
--cc=arnd@arndb.de \
--cc=b-cousson@ti.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=nicolas.ferre@atmel.com \
--cc=plagnioj@jcrosoft.com \
--cc=rob.herring@calxeda.com \
--cc=swarren@nvidia.com \
--cc=vinod.koul@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).