Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp457212imm; Fri, 29 Jun 2018 00:21:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKImFi41Tlc7mUTS+WTTgYqbFTt3jcAlZB6t/vm0rQ2VQg6nbRQG34+v4Z3itCFziV3Pe9zB X-Received: by 2002:a63:6441:: with SMTP id y62-v6mr11448091pgb.240.1530256874532; Fri, 29 Jun 2018 00:21:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530256874; cv=none; d=google.com; s=arc-20160816; b=blhL5+iXYP0DSKtnwXGDeKG+xUUAf71UH8Guxg6xQVpPEFYY+VtJJ49FCIGUf8QX7+ 01yKUk53mQX/Pz/Ob+ROl7rCkRYHksd7hdVVQiCXgwsn+wJapuPqt8R5op6nNSAqrUPs WZmZP7YG+JXKjA9uYImcmFwXZhhj6+qtYpFMLJAFNuOgJ2VIX+IlRsa1+vOflob9DHjR PPJY/wVRBd7rfaccU2l5cDZmum8n8AFcoNy9Hx0At3NhSpd4jhvu8asYKk4OCnMiiorg +MDHyryXoU41vB4Y7nZOIz+/jvEEW+f7phHijyUYgFWzoN8QczFugfWZobZN7s4mCNu+ 2VdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from :arc-authentication-results; bh=9VuTSoq0/IP4s53UgM4wtOld6JaSOfNvVmWrGmhkOLk=; b=JHZfcYsPbM2S7VCILl7S3iNHMbuNy2dT1wgY4qt6IUcPfDXNzhtzsi816CPn6yAXJD EkXRvh6mS3NpOd4TN44/EPyQos5SiZTmeTzwQjkA4H+u+j2VyGRXQkPaWiedtRLcZ2IH KmIKwytAU+KBI04nMhzYZ4CJrumAaDiZJvL+pkmFHMf8Rszfxxld2IrNoT9ZruY07/An g1hObqfDh6BY2TEX9awkqlKCL5OopXCKpCrymEH9e5i3uvKAkaWKl4itOFODC4ZqKwI/ 4wPmz1olnSFXGhwXqOSmHR6DBccv8ylz53YuoRyyzt5tVzBo2CwDoGqCYPhC8pcdeUOD Kp0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 92-v6si8481499plw.102.2018.06.29.00.21.00; Fri, 29 Jun 2018 00:21:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933736AbeF2Gsv (ORCPT + 99 others); Fri, 29 Jun 2018 02:48:51 -0400 Received: from smtp03.smtpout.orange.fr ([80.12.242.125]:25009 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752113AbeF2Gsu (ORCPT ); Fri, 29 Jun 2018 02:48:50 -0400 Received: from belgarion ([90.55.203.186]) by mwinf5d06 with ME id 4Won1y00941oiFu03Won1o; Fri, 29 Jun 2018 08:48:49 +0200 X-ME-Helo: belgarion X-ME-Auth: amFyem1pay5yb2JlcnRAb3JhbmdlLmZy X-ME-Date: Fri, 29 Jun 2018 08:48:49 +0200 X-ME-IP: 90.55.203.186 From: Robert Jarzmik To: Felipe Balbi Cc: Jia-Ju Bai , gregkh@linuxfoundation.org, nicolas.ferre@microchip.com, keescook@chromium.org, allen.lkml@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] usb: gadget: r8a66597: Fix two possible sleep-in-atomic-context bugs in init_controller() References: <20180620035453.7721-1-baijiaju1990@gmail.com> <87efh0o6f9.fsf@belgarion.home> <87y3eydrs1.fsf@linux.intel.com> X-URL: http://belgarath.falguerolles.org/ Date: Fri, 29 Jun 2018 08:48:46 +0200 In-Reply-To: <87y3eydrs1.fsf@linux.intel.com> (Felipe Balbi's message of "Fri, 29 Jun 2018 09:35:10 +0300") Message-ID: <87efgqkrzl.fsf@belgarion.home> User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Felipe Balbi writes: > Hi, > > Robert Jarzmik writes: > >> Jia-Ju Bai writes: >> >>> The driver may sleep with holding a spinlock. >>> The function call paths (from bottom to top) in Linux-4.16.7 are: >>> >>> [FUNC] msleep >>> drivers/usb/gadget/udc/r8a66597-udc.c, 839: >>> msleep in init_controller >>> drivers/usb/gadget/udc/r8a66597-udc.c, 96: >>> init_controller in r8a66597_usb_disconnect >>> drivers/usb/gadget/udc/r8a66597-udc.c, 93: >>> spin_lock in r8a66597_usb_disconnect >> >> That should not happen... >> >> If think the issue you have is that your usb_connect() and usb_disconnect() are >> called from interrupt context. I think the proper fix, as what is done in most >> udc phys, is to schedule a workqueue, see drivers/usb/phy/phy-gpio-vbus-usb.c, >> gpio_vbus_data.vbus. > > argh, no. No workqueues needed here. Sorry Technically why ? And as bonus question, why is it better to have mdelay() calls in the driver ? Cheers. -- Robert