* [PATCH] usb: chipidea: cleanup dma_pool if udc_start() fails
@ 2012-06-25 9:09 Marc Kleine-Budde
2012-06-25 9:12 ` Marc Kleine-Budde
0 siblings, 1 reply; 9+ messages in thread
From: Marc Kleine-Budde @ 2012-06-25 9:09 UTC (permalink / raw)
To: linux-arm-kernel
If udc_start() fails the qh_pool dma-pool cannot be closed because
it's still in use. This patch factors out the dma_pool_free() loop
into destroy_eps() and calls it in the error path of udc_start(),
too.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/usb/chipidea/udc.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index ebc88c1..6d166a7 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1483,6 +1483,17 @@ static int init_eps(struct ci13xxx *ci)
return retval;
}
+static void destroy_eps(struct ci13xxx *ci)
+{
+ int i;
+
+ for (i = 0; i < ci->hw_ep_max; i++) {
+ struct ci13xxx_ep *mEp = &ci->ci13xxx_ep[i];
+
+ dma_pool_free(ci->qh_pool, mEp->qh.ptr, mEp->qh.dma);
+ }
+}
+
/**
* ci13xxx_start: register a gadget driver
* @gadget: our gadget
@@ -1690,7 +1701,7 @@ static int udc_start(struct ci13xxx *ci)
if (ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
if (ci->transceiver == NULL) {
retval = -ENODEV;
- goto free_pools;
+ goto destroy_eps;
}
}
@@ -1741,6 +1752,8 @@ unreg_device:
put_transceiver:
if (ci->transceiver && ci->global_phy)
usb_put_transceiver(ci->transceiver);
+destroy_eps:
+ destroy_eps(ci);
free_pools:
dma_pool_destroy(ci->td_pool);
free_qh_pool:
@@ -1755,18 +1768,12 @@ free_qh_pool:
*/
static void udc_stop(struct ci13xxx *ci)
{
- int i;
-
if (ci == NULL)
return;
usb_del_gadget_udc(&ci->gadget);
- for (i = 0; i < ci->hw_ep_max; i++) {
- struct ci13xxx_ep *mEp = &ci->ci13xxx_ep[i];
-
- dma_pool_free(ci->qh_pool, mEp->qh.ptr, mEp->qh.dma);
- }
+ destroy_eps(ci);
dma_pool_destroy(ci->td_pool);
dma_pool_destroy(ci->qh_pool);
--
1.7.10
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH] usb: chipidea: cleanup dma_pool if udc_start() fails
2012-06-25 9:09 [PATCH] usb: chipidea: cleanup dma_pool if udc_start() fails Marc Kleine-Budde
@ 2012-06-25 9:12 ` Marc Kleine-Budde
2012-06-26 21:44 ` Greg KH
0 siblings, 1 reply; 9+ messages in thread
From: Marc Kleine-Budde @ 2012-06-25 9:12 UTC (permalink / raw)
To: linux-arm-kernel
On 06/25/2012 11:09 AM, Marc Kleine-Budde wrote:
> If udc_start() fails the qh_pool dma-pool cannot be closed because
> it's still in use. This patch factors out the dma_pool_free() loop
> into destroy_eps() and calls it in the error path of udc_start(),
> too.
>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
This patch applies on top of Richard's just published imx-chipindea
tree. (https://github.com/riczhao/kernel-imx/commits/topics/usb-driver)
regards, Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120625/f9d219da/attachment.sig>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] usb: chipidea: cleanup dma_pool if udc_start() fails
2012-06-25 9:12 ` Marc Kleine-Budde
@ 2012-06-26 21:44 ` Greg KH
2012-06-27 11:37 ` Richard Zhao
0 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2012-06-26 21:44 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Jun 25, 2012 at 11:12:07AM +0200, Marc Kleine-Budde wrote:
> On 06/25/2012 11:09 AM, Marc Kleine-Budde wrote:
> > If udc_start() fails the qh_pool dma-pool cannot be closed because
> > it's still in use. This patch factors out the dma_pool_free() loop
> > into destroy_eps() and calls it in the error path of udc_start(),
> > too.
> >
> > Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> > ---
>
> This patch applies on top of Richard's just published imx-chipindea
> tree. (https://github.com/riczhao/kernel-imx/commits/topics/usb-driver)
As that tree is still changing, is someone going to pick this up and add
it to that tree?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] usb: chipidea: cleanup dma_pool if udc_start() fails
2012-06-26 21:44 ` Greg KH
@ 2012-06-27 11:37 ` Richard Zhao
2012-06-27 11:41 ` Marc Kleine-Budde
0 siblings, 1 reply; 9+ messages in thread
From: Richard Zhao @ 2012-06-27 11:37 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jun 27, 2012 at 5:44 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Mon, Jun 25, 2012 at 11:12:07AM +0200, Marc Kleine-Budde wrote:
>> On 06/25/2012 11:09 AM, Marc Kleine-Budde wrote:
>> > If udc_start() fails the qh_pool dma-pool cannot be closed because
>> > it's still in use. This patch factors out the dma_pool_free() loop
>> > into destroy_eps() and calls it in the error path of udc_start(),
>> > too.
>> >
>> > Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
>> > ---
>>
>> This patch applies on top of Richard's just published imx-chipindea
>> tree. (https://github.com/riczhao/kernel-imx/commits/topics/usb-driver)
>
> As that tree is still changing, is someone going to pick this up and add
> it to that tree?
It's my tree.
Marc, If you agree, I can queue it and send it out when my patch get upstreamed.
Thanks
Richard
>
> thanks,
>
> greg k-h
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at ?http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] usb: chipidea: cleanup dma_pool if udc_start() fails
2012-06-27 11:37 ` Richard Zhao
@ 2012-06-27 11:41 ` Marc Kleine-Budde
0 siblings, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2012-06-27 11:41 UTC (permalink / raw)
To: linux-arm-kernel
On 06/27/2012 01:37 PM, Richard Zhao wrote:
> On Wed, Jun 27, 2012 at 5:44 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
>> On Mon, Jun 25, 2012 at 11:12:07AM +0200, Marc Kleine-Budde wrote:
>>> On 06/25/2012 11:09 AM, Marc Kleine-Budde wrote:
>>>> If udc_start() fails the qh_pool dma-pool cannot be closed because
>>>> it's still in use. This patch factors out the dma_pool_free() loop
>>>> into destroy_eps() and calls it in the error path of udc_start(),
>>>> too.
>>>>
>>>> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
>>>> ---
>>>
>>> This patch applies on top of Richard's just published imx-chipindea
>>> tree. (https://github.com/riczhao/kernel-imx/commits/topics/usb-driver)
>>
>> As that tree is still changing, is someone going to pick this up and add
>> it to that tree?
> It's my tree.
> Marc, If you agree, I can queue it and send it out when my patch get upstreamed.
Fine with me.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120627/2a4d2fec/attachment.sig>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] usb: chipidea: cleanup dma_pool if udc_start() fails
@ 2012-08-28 10:31 Marc Kleine-Budde
2012-08-28 10:46 ` Richard Zhao
0 siblings, 1 reply; 9+ messages in thread
From: Marc Kleine-Budde @ 2012-08-28 10:31 UTC (permalink / raw)
To: linux-arm-kernel
If udc_start() fails the qh_pool dma-pool cannot be closed because
it's still in use. This patch factors out the dma_pool_free() loop
into destroy_eps() and calls it in the error path of udc_start(),
too.
Cc: Richard Zhao <richard.zhao@freescale.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
Hello,
Richard, can you please include this patch in your stack. IIRC I think it once
was, but now it's not anymore.
regards, Marc
drivers/usb/chipidea/udc.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 2cb4498..0b18191 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1507,6 +1507,17 @@ static int init_eps(struct ci13xxx *ci)
return retval;
}
+static void destroy_eps(struct ci13xxx *ci)
+{
+ int i;
+
+ for (i = 0; i < ci->hw_ep_max; i++) {
+ struct ci13xxx_ep *mEp = &ci->ci13xxx_ep[i];
+
+ dma_pool_free(ci->qh_pool, mEp->qh.ptr, mEp->qh.dma);
+ }
+}
+
/**
* ci13xxx_start: register a gadget driver
* @gadget: our gadget
@@ -1723,7 +1734,7 @@ static int udc_start(struct ci13xxx *ci)
if (ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
if (ci->transceiver == NULL) {
retval = -ENODEV;
- goto free_pools;
+ goto destroy_eps;
}
}
@@ -1775,6 +1786,8 @@ unreg_device:
put_transceiver:
if (!IS_ERR_OR_NULL(ci->transceiver) && ci->global_phy)
usb_put_phy(ci->transceiver);
+destroy_eps:
+ destroy_eps(ci);
free_pools:
dma_pool_destroy(ci->td_pool);
free_qh_pool:
@@ -1790,8 +1803,6 @@ free_qh_pool:
*/
static void udc_stop(struct ci13xxx *ci)
{
- int i;
-
if (ci == NULL)
return;
@@ -1800,11 +1811,7 @@ static void udc_stop(struct ci13xxx *ci)
usb_del_gadget_udc(&ci->gadget);
- for (i = 0; i < ci->hw_ep_max; i++) {
- struct ci13xxx_ep *mEp = &ci->ci13xxx_ep[i];
-
- dma_pool_free(ci->qh_pool, mEp->qh.ptr, mEp->qh.dma);
- }
+ destroy_eps(ci);
dma_pool_destroy(ci->td_pool);
dma_pool_destroy(ci->qh_pool);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH] usb: chipidea: cleanup dma_pool if udc_start() fails
2012-08-28 10:31 Marc Kleine-Budde
@ 2012-08-28 10:46 ` Richard Zhao
2012-08-28 10:52 ` Marc Kleine-Budde
0 siblings, 1 reply; 9+ messages in thread
From: Richard Zhao @ 2012-08-28 10:46 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Aug 28, 2012 at 12:31:25PM +0200, Marc Kleine-Budde wrote:
> If udc_start() fails the qh_pool dma-pool cannot be closed because
> it's still in use. This patch factors out the dma_pool_free() loop
> into destroy_eps() and calls it in the error path of udc_start(),
> too.
>
> Cc: Richard Zhao <richard.zhao@freescale.com>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
> Hello,
>
> Richard, can you please include this patch in your stack. IIRC I think it once
> was, but now it's not anymore.
Sorry for that. I just push it to my topics/usb-driver branch.
Of course, it's better, if Alex can give a ACK and Greg could pick up.
Thanks
Richard
>
> regards, Marc
>
> drivers/usb/chipidea/udc.c | 23 +++++++++++++++--------
> 1 file changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> index 2cb4498..0b18191 100644
> --- a/drivers/usb/chipidea/udc.c
> +++ b/drivers/usb/chipidea/udc.c
> @@ -1507,6 +1507,17 @@ static int init_eps(struct ci13xxx *ci)
> return retval;
> }
>
> +static void destroy_eps(struct ci13xxx *ci)
> +{
> + int i;
> +
> + for (i = 0; i < ci->hw_ep_max; i++) {
> + struct ci13xxx_ep *mEp = &ci->ci13xxx_ep[i];
> +
> + dma_pool_free(ci->qh_pool, mEp->qh.ptr, mEp->qh.dma);
> + }
> +}
> +
> /**
> * ci13xxx_start: register a gadget driver
> * @gadget: our gadget
> @@ -1723,7 +1734,7 @@ static int udc_start(struct ci13xxx *ci)
> if (ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
> if (ci->transceiver == NULL) {
> retval = -ENODEV;
> - goto free_pools;
> + goto destroy_eps;
> }
> }
>
> @@ -1775,6 +1786,8 @@ unreg_device:
> put_transceiver:
> if (!IS_ERR_OR_NULL(ci->transceiver) && ci->global_phy)
> usb_put_phy(ci->transceiver);
> +destroy_eps:
> + destroy_eps(ci);
> free_pools:
> dma_pool_destroy(ci->td_pool);
> free_qh_pool:
> @@ -1790,8 +1803,6 @@ free_qh_pool:
> */
> static void udc_stop(struct ci13xxx *ci)
> {
> - int i;
> -
> if (ci == NULL)
> return;
>
> @@ -1800,11 +1811,7 @@ static void udc_stop(struct ci13xxx *ci)
>
> usb_del_gadget_udc(&ci->gadget);
>
> - for (i = 0; i < ci->hw_ep_max; i++) {
> - struct ci13xxx_ep *mEp = &ci->ci13xxx_ep[i];
> -
> - dma_pool_free(ci->qh_pool, mEp->qh.ptr, mEp->qh.dma);
> - }
> + destroy_eps(ci);
>
> dma_pool_destroy(ci->td_pool);
> dma_pool_destroy(ci->qh_pool);
> --
> 1.7.10.4
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] usb: chipidea: cleanup dma_pool if udc_start() fails
2012-08-28 10:46 ` Richard Zhao
@ 2012-08-28 10:52 ` Marc Kleine-Budde
2012-08-28 11:42 ` Richard Zhao
0 siblings, 1 reply; 9+ messages in thread
From: Marc Kleine-Budde @ 2012-08-28 10:52 UTC (permalink / raw)
To: linux-arm-kernel
On 08/28/2012 12:46 PM, Richard Zhao wrote:
> On Tue, Aug 28, 2012 at 12:31:25PM +0200, Marc Kleine-Budde wrote:
>> If udc_start() fails the qh_pool dma-pool cannot be closed because
>> it's still in use. This patch factors out the dma_pool_free() loop
>> into destroy_eps() and calls it in the error path of udc_start(),
>> too.
>>
>> Cc: Richard Zhao <richard.zhao@freescale.com>
>> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
>> ---
>> Hello,
>>
>> Richard, can you please include this patch in your stack. IIRC I think it once
>> was, but now it's not anymore.
> Sorry for that. I just push it to my topics/usb-driver branch.
> Of course, it's better, if Alex can give a ACK and Greg could pick up.
I'm not sure, if this [1] is the latest thread on this patch, but Greg
asked to queue this patch into your tree.
Marc
[1] http://comments.gmane.org/gmane.linux.usb.general/66440
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120828/6e88e645/attachment.sig>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] usb: chipidea: cleanup dma_pool if udc_start() fails
2012-08-28 10:52 ` Marc Kleine-Budde
@ 2012-08-28 11:42 ` Richard Zhao
0 siblings, 0 replies; 9+ messages in thread
From: Richard Zhao @ 2012-08-28 11:42 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Aug 28, 2012 at 12:52:19PM +0200, Marc Kleine-Budde wrote:
> On 08/28/2012 12:46 PM, Richard Zhao wrote:
> > On Tue, Aug 28, 2012 at 12:31:25PM +0200, Marc Kleine-Budde wrote:
> >> If udc_start() fails the qh_pool dma-pool cannot be closed because
> >> it's still in use. This patch factors out the dma_pool_free() loop
> >> into destroy_eps() and calls it in the error path of udc_start(),
> >> too.
> >>
> >> Cc: Richard Zhao <richard.zhao@freescale.com>
> >> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> >> ---
> >> Hello,
> >>
> >> Richard, can you please include this patch in your stack. IIRC I think it once
> >> was, but now it's not anymore.
> > Sorry for that. I just push it to my topics/usb-driver branch.
> > Of course, it's better, if Alex can give a ACK and Greg could pick up.
>
> I'm not sure, if this [1] is the latest thread on this patch, but Greg
> asked to queue this patch into your tree.
It does not depends on my tree any more. It can be applied directly on
Greg's tree.
Thanks
Richard
>
> Marc
>
> [1] http://comments.gmane.org/gmane.linux.usb.general/66440
> --
> Pengutronix e.K. | Marc Kleine-Budde |
> Industrial Linux Solutions | Phone: +49-231-2826-924 |
> Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
> Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-08-28 11:42 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-25 9:09 [PATCH] usb: chipidea: cleanup dma_pool if udc_start() fails Marc Kleine-Budde
2012-06-25 9:12 ` Marc Kleine-Budde
2012-06-26 21:44 ` Greg KH
2012-06-27 11:37 ` Richard Zhao
2012-06-27 11:41 ` Marc Kleine-Budde
-- strict thread matches above, loose matches on Subject: below --
2012-08-28 10:31 Marc Kleine-Budde
2012-08-28 10:46 ` Richard Zhao
2012-08-28 10:52 ` Marc Kleine-Budde
2012-08-28 11:42 ` Richard Zhao
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).