From: Frank Zago <frank@zago.net>
To: Johan Hovold <johan@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
Wolfram Sang <wsa@kernel.org>,
linux-usb@vger.kernel.org, Lee Jones <lee.jones@linaro.org>,
Linus Walleij <linus.walleij@linaro.org>,
linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org
Subject: Re: [PATCH v5 2/3] gpio: ch341: add GPIO MFD cell driver for the CH341
Date: Wed, 15 Jun 2022 20:29:31 -0500 [thread overview]
Message-ID: <9b5b8cb4-7c05-b3cf-ca68-85d334a7f0b0@zago.net> (raw)
In-Reply-To: <YouzaO6ogxYj40Bp@hovoldconsulting.com>
On 5/23/22 11:16, Johan Hovold wrote:
>> +static void ch341_complete_intr_urb(struct urb *urb)
>> +{
>> + struct ch341_gpio *dev = urb->context;
>> + int rc;
>> +
>> + if (urb->status) {
>> + usb_unanchor_urb(dev->irq_urb);
>
> URBs are unanchored by USB core on completion.
Fixed.
>
>> +static void ch341_gpio_irq_enable(struct irq_data *data)
>> +{
>> + struct ch341_gpio *dev = irq_data_get_irq_chip_data(data);
>> + int rc;
>> +
>> + /*
>> + * The URB might have just been unlinked in
>> + * ch341_gpio_irq_disable, but the completion handler hasn't
>> + * been called yet.
>> + */
>> + if (!usb_wait_anchor_empty_timeout(&dev->irq_urb_out, 5000))
>> + usb_kill_anchored_urbs(&dev->irq_urb_out);
>> +
>> + usb_anchor_urb(dev->irq_urb, &dev->irq_urb_out);
>> + rc = usb_submit_urb(dev->irq_urb, GFP_ATOMIC);
>> + if (rc)
>> + usb_unanchor_urb(dev->irq_urb);
>
> This looks confused and broken.
>
> usb_kill_anchored_urbs() can sleep so either calling it is broken or
> using GFP_ATOMIC is unnecessary.
Right, that function can sleep. I changed GFP_ATOMIC to GFP_KERNEL.
>
> And isn't this function called multiple times when enabling more than
> one irq?!
There's only one IRQ, so only one URB will be posted at a time. It
is reposted as soon as it comes back unless the IRQ is disabled or
the device stops.
>
>> +}
>> +
>> +static void ch341_gpio_irq_disable(struct irq_data *data)
>> +{
>> + struct ch341_gpio *dev = irq_data_get_irq_chip_data(data);
>> +
>> + usb_unlink_urb(dev->irq_urb);
>
> Same here...
>
>> +}
>> +
>> +static int ch341_gpio_remove(struct platform_device *pdev)
>> +{
>> + struct ch341_gpio *dev = platform_get_drvdata(pdev);
>> +
>> + usb_kill_anchored_urbs(&dev->irq_urb_out);
>
> You only have one URB...
>
> And what prevents it from being resubmitted here?
I don't see what would resubmit it here. The gpio is being released.
Frank.
next prev parent reply other threads:[~2022-06-16 1:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-01 2:33 [PATCH v5 0/3] WCH CH341 GPIO and SPI support frank zago
2022-04-01 2:33 ` [PATCH v5 1/3] mfd: ch341: add core driver for the WCH CH341 in I2C/SPI/GPIO mode frank zago
2022-04-26 14:35 ` Lee Jones
2022-06-16 1:18 ` Frank Zago
2022-05-23 15:56 ` Johan Hovold
2022-06-16 1:24 ` Frank Zago
2022-04-01 2:33 ` [PATCH v5 2/3] gpio: ch341: add GPIO MFD cell driver for the CH341 frank zago
2022-04-19 22:52 ` Linus Walleij
2022-05-23 16:16 ` Johan Hovold
2022-06-16 1:29 ` Frank Zago [this message]
2022-06-20 10:04 ` Johan Hovold
2022-04-01 2:33 ` [PATCH v5 3/3] i2c: ch341: add I2C " frank zago
2022-04-01 11:49 ` Sergey Shtylyov
2022-05-21 12:03 ` Wolfram Sang
2022-05-23 15:51 ` Johan Hovold
2022-05-23 17:09 ` Wolfram Sang
2022-06-16 1:22 ` Frank Zago
2022-05-23 16:00 ` Lee Jones
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=9b5b8cb4-7c05-b3cf-ca68-85d334a7f0b0@zago.net \
--to=frank@zago.net \
--cc=bgolaszewski@baylibre.com \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=lee.jones@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=wsa@kernel.org \
/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
all inboxes | Powered by JetHome®