From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: vinod.koul@intel.com, tony@atomide.com, linux@arm.linux.org.uk,
grant.likely@linaro.org, dmaengine@vger.kernel.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
robh+dt@kernel.org, nm@ti.com, arnd@arndb.de
Subject: Re: [PATCH v4 3/8] dmaengine: Add driver for TI DMA crossbar on DRA7x
Date: Thu, 9 Apr 2015 11:09:07 +0300 [thread overview]
Message-ID: <552633A3.3070909@ti.com> (raw)
In-Reply-To: <20150408152349.GD26727@lukather>
>> +static inline void ti_dma_xbar_write(void __iomem *iomem, int xbar, int val)
>> +{
>> + writew_relaxed(val, iomem + (xbar * 2));
>
> Silently casting val (an integer) to a u16 isn't really nice I
> guess. At least you could be upfront about it in the prototype.
The value in val is guarantied not to overflow the u16, but sure, I can change
this.
>> + dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
>> + if (!dma_spec->np) {
>> + dev_err(&pdev->dev, "Can't get DMA master\n");
>> + return NULL;
>> + }
>> +
>> + map = kzalloc(sizeof(*map), GFP_KERNEL);
>> + if (!map)
>> + return NULL;
>
> You're leaking dma_spec->np.
If kzalloc fails we have other things to worry about, but true, I'll
restructure the code to avoid leaking the node.
>> + dma_node = of_parse_phandle(node, "dma-masters", 0);
>> + if (!dma_node) {
>> + dev_err(&pdev->dev, "Can't get DMA master node\n");
>> + return -ENODEV;
>> + }
>> +
>> + xbar = devm_kzalloc(&pdev->dev, sizeof(*xbar), GFP_KERNEL);
>> + if (!xbar)
>> + return -ENOMEM;
>
> And here too.
same here, I'll change the code to not leak.
>
>> + if (of_property_read_u32(dma_node, "dma-requests",
>> + &xbar->dma_requests)) {
>> + dev_info(&pdev->dev,
>> + "Missing XBAR output information, using %u.\n",
>> + TI_XBAR_OUTPUTS);
>> + xbar->dma_requests = TI_XBAR_OUTPUTS;
>> + }
>> + of_node_put(dma_node);
>> +
>> + if (of_property_read_u32(node, "dma-requests", &xbar->xbar_requests)) {
>> + dev_info(&pdev->dev,
>> + "Missing XBAR input information, using %u.\n",
>> + TI_XBAR_INPUTS);
>> + xbar->xbar_requests = TI_XBAR_INPUTS;
>> + }
>> +
>> + if (of_property_read_u32(node, "ti,dma-safe-map", &xbar->safe_val))
>> + xbar->safe_val = 0;
>> +
>> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> + if (!res)
>> + return -ENODEV;
>> +
>> + if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res),
>> + dev_name(&pdev->dev)))
>> + return -ENODEV;
>> +
>> + iomem = devm_ioremap(&pdev->dev, res->start, resource_size(res));
>> + if (!iomem)
>> + return -ENOMEM;
>
> You can use devm_ioremap_resource here.
I tend to forgot about this...
>> + xbar->iomem = iomem;
>> +
>> + xbar->dmarouter.dev = &pdev->dev;
>> + xbar->dmarouter.route_free = ti_dma_xbar_free;
>> +
>> + platform_set_drvdata(pdev, xbar);
>> +
>> + ret = of_dma_router_register(node, ti_dma_xbar_route_allocate,
>> + &xbar->dmarouter);
>> + if (ret)
>> + return -ENODEV;
>
> Starting here, I'd expect that your driver can be used....
>
>> +
>> + /* Reset the crossbar */
>> + for (i = 0; i < xbar->dma_requests; i++)
>> + ti_dma_xbar_write(xbar->iomem, i, xbar->safe_val);
>
> ... however, the hardware doesn't seem ready. Isn't it a race?
True, will change the order.
Thanks,
Péter
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: peter.ujfalusi@ti.com (Peter Ujfalusi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 3/8] dmaengine: Add driver for TI DMA crossbar on DRA7x
Date: Thu, 9 Apr 2015 11:09:07 +0300 [thread overview]
Message-ID: <552633A3.3070909@ti.com> (raw)
In-Reply-To: <20150408152349.GD26727@lukather>
>> +static inline void ti_dma_xbar_write(void __iomem *iomem, int xbar, int val)
>> +{
>> + writew_relaxed(val, iomem + (xbar * 2));
>
> Silently casting val (an integer) to a u16 isn't really nice I
> guess. At least you could be upfront about it in the prototype.
The value in val is guarantied not to overflow the u16, but sure, I can change
this.
>> + dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
>> + if (!dma_spec->np) {
>> + dev_err(&pdev->dev, "Can't get DMA master\n");
>> + return NULL;
>> + }
>> +
>> + map = kzalloc(sizeof(*map), GFP_KERNEL);
>> + if (!map)
>> + return NULL;
>
> You're leaking dma_spec->np.
If kzalloc fails we have other things to worry about, but true, I'll
restructure the code to avoid leaking the node.
>> + dma_node = of_parse_phandle(node, "dma-masters", 0);
>> + if (!dma_node) {
>> + dev_err(&pdev->dev, "Can't get DMA master node\n");
>> + return -ENODEV;
>> + }
>> +
>> + xbar = devm_kzalloc(&pdev->dev, sizeof(*xbar), GFP_KERNEL);
>> + if (!xbar)
>> + return -ENOMEM;
>
> And here too.
same here, I'll change the code to not leak.
>
>> + if (of_property_read_u32(dma_node, "dma-requests",
>> + &xbar->dma_requests)) {
>> + dev_info(&pdev->dev,
>> + "Missing XBAR output information, using %u.\n",
>> + TI_XBAR_OUTPUTS);
>> + xbar->dma_requests = TI_XBAR_OUTPUTS;
>> + }
>> + of_node_put(dma_node);
>> +
>> + if (of_property_read_u32(node, "dma-requests", &xbar->xbar_requests)) {
>> + dev_info(&pdev->dev,
>> + "Missing XBAR input information, using %u.\n",
>> + TI_XBAR_INPUTS);
>> + xbar->xbar_requests = TI_XBAR_INPUTS;
>> + }
>> +
>> + if (of_property_read_u32(node, "ti,dma-safe-map", &xbar->safe_val))
>> + xbar->safe_val = 0;
>> +
>> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> + if (!res)
>> + return -ENODEV;
>> +
>> + if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res),
>> + dev_name(&pdev->dev)))
>> + return -ENODEV;
>> +
>> + iomem = devm_ioremap(&pdev->dev, res->start, resource_size(res));
>> + if (!iomem)
>> + return -ENOMEM;
>
> You can use devm_ioremap_resource here.
I tend to forgot about this...
>> + xbar->iomem = iomem;
>> +
>> + xbar->dmarouter.dev = &pdev->dev;
>> + xbar->dmarouter.route_free = ti_dma_xbar_free;
>> +
>> + platform_set_drvdata(pdev, xbar);
>> +
>> + ret = of_dma_router_register(node, ti_dma_xbar_route_allocate,
>> + &xbar->dmarouter);
>> + if (ret)
>> + return -ENODEV;
>
> Starting here, I'd expect that your driver can be used....
>
>> +
>> + /* Reset the crossbar */
>> + for (i = 0; i < xbar->dma_requests; i++)
>> + ti_dma_xbar_write(xbar->iomem, i, xbar->safe_val);
>
> ... however, the hardware doesn't seem ready. Isn't it a race?
True, will change the order.
Thanks,
P?ter
WARNING: multiple messages have this Message-ID (diff)
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: <vinod.koul@intel.com>, <tony@atomide.com>,
<linux@arm.linux.org.uk>, <grant.likely@linaro.org>,
<dmaengine@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<devicetree@vger.kernel.org>, <linux-omap@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>, <robh+dt@kernel.org>,
<nm@ti.com>, <arnd@arndb.de>
Subject: Re: [PATCH v4 3/8] dmaengine: Add driver for TI DMA crossbar on DRA7x
Date: Thu, 9 Apr 2015 11:09:07 +0300 [thread overview]
Message-ID: <552633A3.3070909@ti.com> (raw)
In-Reply-To: <20150408152349.GD26727@lukather>
>> +static inline void ti_dma_xbar_write(void __iomem *iomem, int xbar, int val)
>> +{
>> + writew_relaxed(val, iomem + (xbar * 2));
>
> Silently casting val (an integer) to a u16 isn't really nice I
> guess. At least you could be upfront about it in the prototype.
The value in val is guarantied not to overflow the u16, but sure, I can change
this.
>> + dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
>> + if (!dma_spec->np) {
>> + dev_err(&pdev->dev, "Can't get DMA master\n");
>> + return NULL;
>> + }
>> +
>> + map = kzalloc(sizeof(*map), GFP_KERNEL);
>> + if (!map)
>> + return NULL;
>
> You're leaking dma_spec->np.
If kzalloc fails we have other things to worry about, but true, I'll
restructure the code to avoid leaking the node.
>> + dma_node = of_parse_phandle(node, "dma-masters", 0);
>> + if (!dma_node) {
>> + dev_err(&pdev->dev, "Can't get DMA master node\n");
>> + return -ENODEV;
>> + }
>> +
>> + xbar = devm_kzalloc(&pdev->dev, sizeof(*xbar), GFP_KERNEL);
>> + if (!xbar)
>> + return -ENOMEM;
>
> And here too.
same here, I'll change the code to not leak.
>
>> + if (of_property_read_u32(dma_node, "dma-requests",
>> + &xbar->dma_requests)) {
>> + dev_info(&pdev->dev,
>> + "Missing XBAR output information, using %u.\n",
>> + TI_XBAR_OUTPUTS);
>> + xbar->dma_requests = TI_XBAR_OUTPUTS;
>> + }
>> + of_node_put(dma_node);
>> +
>> + if (of_property_read_u32(node, "dma-requests", &xbar->xbar_requests)) {
>> + dev_info(&pdev->dev,
>> + "Missing XBAR input information, using %u.\n",
>> + TI_XBAR_INPUTS);
>> + xbar->xbar_requests = TI_XBAR_INPUTS;
>> + }
>> +
>> + if (of_property_read_u32(node, "ti,dma-safe-map", &xbar->safe_val))
>> + xbar->safe_val = 0;
>> +
>> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> + if (!res)
>> + return -ENODEV;
>> +
>> + if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res),
>> + dev_name(&pdev->dev)))
>> + return -ENODEV;
>> +
>> + iomem = devm_ioremap(&pdev->dev, res->start, resource_size(res));
>> + if (!iomem)
>> + return -ENOMEM;
>
> You can use devm_ioremap_resource here.
I tend to forgot about this...
>> + xbar->iomem = iomem;
>> +
>> + xbar->dmarouter.dev = &pdev->dev;
>> + xbar->dmarouter.route_free = ti_dma_xbar_free;
>> +
>> + platform_set_drvdata(pdev, xbar);
>> +
>> + ret = of_dma_router_register(node, ti_dma_xbar_route_allocate,
>> + &xbar->dmarouter);
>> + if (ret)
>> + return -ENODEV;
>
> Starting here, I'd expect that your driver can be used....
>
>> +
>> + /* Reset the crossbar */
>> + for (i = 0; i < xbar->dma_requests; i++)
>> + ti_dma_xbar_write(xbar->iomem, i, xbar->safe_val);
>
> ... however, the hardware doesn't seem ready. Isn't it a race?
True, will change the order.
Thanks,
Péter
next prev parent reply other threads:[~2015-04-09 8:10 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-08 13:14 [PATCH v4 0/8] dmaengine/dra7x: DMA router (crossbar support) Peter Ujfalusi
2015-04-08 13:14 ` Peter Ujfalusi
2015-04-08 13:14 ` Peter Ujfalusi
2015-04-08 13:14 ` [PATCH v4 1/8] dmaengine: of_dma: Support for DMA routers Peter Ujfalusi
2015-04-08 13:14 ` Peter Ujfalusi
2015-04-08 13:14 ` Peter Ujfalusi
2015-04-08 15:42 ` Maxime Ripard
2015-04-08 15:42 ` Maxime Ripard
2015-04-09 8:24 ` Peter Ujfalusi
2015-04-09 8:24 ` Peter Ujfalusi
2015-04-09 8:24 ` Peter Ujfalusi
2015-04-10 7:40 ` Maxime Ripard
2015-04-10 7:40 ` Maxime Ripard
2015-04-15 8:36 ` Peter Ujfalusi
2015-04-15 8:36 ` Peter Ujfalusi
2015-04-15 8:36 ` Peter Ujfalusi
2015-04-08 13:14 ` [PATCH v4 2/8] Documentation: devicetree: dma: Binding documentation for TI DMA crossbar Peter Ujfalusi
2015-04-08 13:14 ` Peter Ujfalusi
2015-04-08 13:14 ` Peter Ujfalusi
2015-04-08 13:14 ` [PATCH v4 3/8] dmaengine: Add driver for TI DMA crossbar on DRA7x Peter Ujfalusi
2015-04-08 13:14 ` Peter Ujfalusi
2015-04-08 13:14 ` Peter Ujfalusi
2015-04-08 15:23 ` Maxime Ripard
2015-04-08 15:23 ` Maxime Ripard
2015-04-09 8:09 ` Peter Ujfalusi [this message]
2015-04-09 8:09 ` Peter Ujfalusi
2015-04-09 8:09 ` Peter Ujfalusi
2015-04-08 13:14 ` [PATCH v4 4/8] dmaengine: omap-dma: Use defines for dma channels and request count Peter Ujfalusi
2015-04-08 13:14 ` Peter Ujfalusi
2015-04-08 13:14 ` Peter Ujfalusi
2015-04-08 13:14 ` [PATCH v4 5/8] dmaengine: omap-dma: Take DMA request number from DT if it is available Peter Ujfalusi
2015-04-08 13:14 ` Peter Ujfalusi
2015-04-08 13:14 ` Peter Ujfalusi
2015-04-08 13:14 ` [PATCH v4 6/8] dmaengine: omap-dma: Remove mapping between virtual channels and requests Peter Ujfalusi
2015-04-08 13:14 ` Peter Ujfalusi
2015-04-08 13:14 ` Peter Ujfalusi
2015-04-08 13:14 ` [PATCH v4 7/8] dmaengine: omap-dma: Reduce the number of virtual channels Peter Ujfalusi
2015-04-08 13:14 ` Peter Ujfalusi
2015-04-08 13:14 ` Peter Ujfalusi
2015-04-08 13:14 ` [PATCH v4 8/8] ARM: DTS: dra7x: Integrate sDMA crossbar Peter Ujfalusi
2015-04-08 13:14 ` Peter Ujfalusi
2015-04-08 13:14 ` Peter Ujfalusi
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=552633A3.3070909@ti.com \
--to=peter.ujfalusi@ti.com \
--cc=arnd@arndb.de \
--cc=devicetree@vger.kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=grant.likely@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=maxime.ripard@free-electrons.com \
--cc=nm@ti.com \
--cc=robh+dt@kernel.org \
--cc=tony@atomide.com \
--cc=vinod.koul@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.