Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1777663imm; Thu, 21 Jun 2018 02:08:09 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKu4XQhbQ/ByJUMuw1vQxQByDZM8BZacRp2rlv2q+DYFbrC6gNrOQ/G2kUgUU0dOQOZbi+4 X-Received: by 2002:a62:e03:: with SMTP id w3-v6mr26480650pfi.173.1529572089438; Thu, 21 Jun 2018 02:08:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529572089; cv=none; d=google.com; s=arc-20160816; b=lxshIdBJksjGAAA0YpSi6TGt4QWs2vocfk8jpSKWR5BTEaes5tIMWrXi9NNLVVF89A Z7NoRW+hHjyY9NT7639I8zLMhEn1oMn+8I3PPoCNlZj4GwfmUWR8bSOTlTtUyK0mJfRW rnV/AMog3Tz3SxHdhRrs8RT/Jo6Yzy/UP2LaA0KAsbP1knasMCA/cuSHdIGN68NZDRx7 4rVuvICjmOSS/uxKhw3vK3z7BGPlRbffT09awgdzrrRSg7x/YAEdiI4eriS4UPihxvhQ +k9ZfI7xH+0IJ9X6oLwHNPBVgeGHNEcf5Krd/vosvo0hb6z0FkNxyXJfUsvt03UoWUSF xrfw== 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=LyGd5apTFfxiPB5802c2g7VC+5/9ovqdidNPfe3OX74=; b=bd9aD9XSR0TcFGD6Bip1vdAnzyA6Q2b/P0RCj4MXuWXUZQFNmW2qLumr8bPqj1pBnx wI46k93Q6ogD50koiepOP0DvFy4mLpdwIOQUSdBIKGWIARwKmMTmTcbjjuYpWtAeCsvk NYgpHtyq3GxYSA8GlCp6JJFO7qriExp0pqFrIQBnTEbIcb5I3p8rHdrUzU2ElBqUZUfg YnIu9CZIrgc7fohF8Sxy7lDqPueyQul2DSBceDy/gEitEN6tDm8Sy5QWiAW6UQcI9T78 oveXIBeTMb8o1msV+aLimiGMlV0YuuNJE4vTqEdz1b4nSrZE2utPRsbB3hfaPP3X2Uzh JtFA== 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 e189-v6si4340184pfe.80.2018.06.21.02.07.53; Thu, 21 Jun 2018 02:08:09 -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 S932748AbeFUJGG (ORCPT + 99 others); Thu, 21 Jun 2018 05:06:06 -0400 Received: from smtp13.smtpout.orange.fr ([80.12.242.135]:30357 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932636AbeFUJGE (ORCPT ); Thu, 21 Jun 2018 05:06:04 -0400 Received: from belgarion ([90.55.203.186]) by mwinf5d76 with ME id 1M621y00641oiFu03M6285; Thu, 21 Jun 2018 11:06:03 +0200 X-ME-Helo: belgarion X-ME-Auth: amFyem1pay5yb2JlcnRAb3JhbmdlLmZy X-ME-Date: Thu, 21 Jun 2018 11:06:03 +0200 X-ME-IP: 90.55.203.186 From: Robert Jarzmik To: Jia-Ju Bai Cc: balbi@kernel.org, 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> X-URL: http://belgarath.falguerolles.org/ Date: Thu, 21 Jun 2018 11:06:02 +0200 In-Reply-To: <20180620035453.7721-1-baijiaju1990@gmail.com> (Jia-Ju Bai's message of "Wed, 20 Jun 2018 11:54:53 +0800") Message-ID: <87efh0o6f9.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 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. Cheers. -- Robert