Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1023722iog; Wed, 15 Jun 2022 18:39:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tfBFYlGOIVo4uzHNoNKDoWKOsIYX3sHH93+GSejTm0GtRbLCFdk5MZlUBh5v7bFz4wpvYN X-Received: by 2002:a17:907:3f97:b0:711:d61d:df9 with SMTP id hr23-20020a1709073f9700b00711d61d0df9mr2432430ejc.644.1655343543394; Wed, 15 Jun 2022 18:39:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655343543; cv=none; d=google.com; s=arc-20160816; b=qAWgseeNEoGbQDHYDzBw1Cwm8u03yrMEHlcvufmHo9/7N+bNxgLvT0IuQrrVamxSCT jmYfg2l/mgyTEUYk3md7AhFQaAteVV8NIQ3euOkBmSsZLfxOOQl5w9Ajl1Fz/+KoloVR BbKHfz1nZg+CN/x/NlwZTlg71T9FYnpPJRkkko0AG+/pQhIYclLhu2taJc/YaLVTsfra uxbjELG/gDfj2jgMRJCL1MSI0wuhDzCDlskW57QR7x5PbqTKGdpM4RbhSA5b9OnoWrPp AwfTaCJqaDr583a8A/VlNh+5cT7ymZlJs2S2WyTCJM42nh54j02X8JHGP/RXa8QTVvhT 7xWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=GqgSEAftTbz45WJishrAzJzHWU+neykCTYNp/YPsD+A=; b=I6Eqz3VsFXb0mSvPxJqzAI08W+UtKQIAs3UrgfMoDRf2PsH9BE1fxF5B4q+EwtYCsc G4KlmeR5GXo6ObwID0d440jisoEUM0b/UAUKimD/mFSFSq0t223JMenCTYro2I0l3h2x DmDxuobFdrrofJE7qGCKc71YsVUHTreo3ohBnYz9RVjUyDElHum8VuIeW3yrVvOdRVcN B0Cm5p77YQCL/CpMvVorLRbanYZi5sbc0o4LirKONRWug82/aMOzlDhaPPlut2M6Z7jv IxDGbpzrv8Y4hvJ7OX8wEkQeXa3RXJjPo8z0TizIsFpn/DabNMtLI4zO6GXErLyGkTGK MEmg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b7-20020a056402350700b00427e39bf3d4si1081387edd.480.2022.06.15.18.38.38; Wed, 15 Jun 2022 18:39:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344735AbiFPB3k (ORCPT + 99 others); Wed, 15 Jun 2022 21:29:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231406AbiFPB3i (ORCPT ); Wed, 15 Jun 2022 21:29:38 -0400 X-Greylist: delayed 643 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 15 Jun 2022 18:29:37 PDT Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BAD752E53; Wed, 15 Jun 2022 18:29:37 -0700 (PDT) Received: (Authenticated sender: frank@zago.net) by mail.gandi.net (Postfix) with ESMTPSA id BD55B60004; Thu, 16 Jun 2022 01:29:32 +0000 (UTC) Message-ID: <9b5b8cb4-7c05-b3cf-ca68-85d334a7f0b0@zago.net> Date: Wed, 15 Jun 2022 20:29:31 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v5 2/3] gpio: ch341: add GPIO MFD cell driver for the CH341 Content-Language: en-US To: Johan Hovold Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Bartosz Golaszewski , Wolfram Sang , linux-usb@vger.kernel.org, Lee Jones , Linus Walleij , linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org References: <20220401023306.79532-1-frank@zago.net> <20220401023306.79532-3-frank@zago.net> From: Frank Zago In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.