Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1720180imu; Wed, 12 Dec 2018 03:11:10 -0800 (PST) X-Google-Smtp-Source: AFSGD/XLuG8PjUiVX5dBk3cuNOAyprmehDDL/SouS1mbynVeT0sSldamgGtR8/CvduTBeTTU6APB X-Received: by 2002:a62:ca9c:: with SMTP id y28mr19670834pfk.236.1544613070441; Wed, 12 Dec 2018 03:11:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544613070; cv=none; d=google.com; s=arc-20160816; b=gb7ia2NWBnhN0fK8zEpxWR5kpPwIoMSFAy92B42DR1RmePWaxgs5Ge3iuciMspp9wl AZdgzbVrn0pAXgaTUQbpVmiTYGm5V1CU2S2y2wAwH/JS8tZUt5Tm8jhU9XUCnZxlr7cn JKjcL2sSphzS+r9H4voGEQGstOfwLu78G7cYd6CzCjGVQIfNn3Snell5dXARWDD8+DPI edZrYKjsCF0t+shRyiQlHMUAsmXwilYMrx8xbW3MGweG0Xhxc8cNdfRVUl/rCVIspoE+ hAowoObs4wpwnsrOzhIcEuRoBRl2ppPVUnM1/Fpxc4jDjVTi785q3m10eeQao9WOxpeg lcqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:to:from:date:dkim-signature; bh=NBYG3dt8oCcJhuzZ/ytmAIKIqhgaPKq+Vtgqx15x1NE=; b=Jjf5Lewk4o7c8EfN2aYD5WTTnOgNK3WTFN/xgd+NnNSDMO9FSsDOlaKXg8qAknDzww P/T/AVQGREqFn5I6yclK3xYzlYMwlROTZSB6O0aGEff1oy06yP9gRktfPdxqvE+OPcCk 1OthnS2RXFjbqvVTqcF6BFWMNpGv1gQulNaiOcgufiTSRiiE+mVGvJib4SbjuSxNYi0Q 2Z0JbxMLvqZc7sKmA4TETG4xdetrazP+tUSrNoURhGAMZ+7/W3DvvMPVpgAxWf9Bt0gH GElztj+Up/Zj3jkW6kleWi87zXQHAgCypfpZwZJy8af8KK9utb3atiH5M8+NwMJx3CrV BX/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=K9qZ2lFD; 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 t3si14432666pgo.585.2018.12.12.03.10.48; Wed, 12 Dec 2018 03:11:10 -0800 (PST) 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; dkim=fail header.i=@ffwll.ch header.s=google header.b=K9qZ2lFD; 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 S1727292AbeLLLIp (ORCPT + 99 others); Wed, 12 Dec 2018 06:08:45 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:46496 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726856AbeLLLIo (ORCPT ); Wed, 12 Dec 2018 06:08:44 -0500 Received: by mail-ed1-f67.google.com with SMTP id o10so15159385edt.13 for ; Wed, 12 Dec 2018 03:08:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=NBYG3dt8oCcJhuzZ/ytmAIKIqhgaPKq+Vtgqx15x1NE=; b=K9qZ2lFDi55edB+wKp0bhgT1qGjYlHspyJOw1xaol6RZwjfl2VA4VoNy9pAnBG0yrN FwEEOjJOnVlW1HP5WIXddviOT3Tm2Cn26cPuJuQF0tmY593W4O7ZMVfL7Veg811PG4ep pDJ4/XSni2TEXj/KhT/xBwcw0vtk+fzIY6k78= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=NBYG3dt8oCcJhuzZ/ytmAIKIqhgaPKq+Vtgqx15x1NE=; b=ANHCMkL0nr6rL1Y9zbVJh/m5vplTHa8KRQaDYzAEQahh1leE8A3VaBbb+uwYJYGXy7 qngyt40iSQM0XBVE4a1X9waeDQNQrNe91ptP3Ngaf1IY/kf0hMy/tSvVacniwptogVjz OhpBD5K3CnUGmpRxEANyS95BG9UAkeHDWvdQlGmIEKOxfsHLfipmwYf+BEA8yQV5kyLp y8KDsyGixN6CapPMV65vZq2VTGCBRv2LlXywnI8eYz7ZnKDkW9ZSZ3JlxI9jTZ4T8VVB SO7oq6gKz1VSSLGmez7o906ydArb6RAagN17Br9ELLCkj+GyeakBzkNwDCNoWcN9lfbD 4Tjw== X-Gm-Message-State: AA+aEWZwXEuadkMCdRt76QJjg3R0RddlikIy6rJS4n4t9N9bN3RLG3+5 mN2HQJke//i+5OQz4empQmhjPQ== X-Received: by 2002:a17:906:2989:: with SMTP id x9-v6mr15372950eje.156.1544612923013; Wed, 12 Dec 2018 03:08:43 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id j23sm4670364edr.89.2018.12.12.03.08.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Dec 2018 03:08:41 -0800 (PST) Date: Wed, 12 Dec 2018 12:08:40 +0100 From: Daniel Vetter To: Greg Kroah-Hartman , LKML , DRI Development , Ramalingam C , "Rafael J. Wysocki" , Daniel Vetter Subject: Re: [PATCH] drivers/base: use a worker for sysfs unbind Message-ID: <20181212110840.GA21184@phenom.ffwll.local> Mail-Followup-To: Greg Kroah-Hartman , LKML , DRI Development , Ramalingam C , "Rafael J. Wysocki" , Daniel Vetter References: <20181210084653.7268-1-daniel.vetter@ffwll.ch> <20181210100634.GA8836@kroah.com> <20181210101832.GN21184@phenom.ffwll.local> <20181210102058.GO21184@phenom.ffwll.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181210102058.GO21184@phenom.ffwll.local> X-Operating-System: Linux phenom 4.18.0-2-amd64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 10, 2018 at 11:20:58AM +0100, Daniel Vetter wrote: > On Mon, Dec 10, 2018 at 11:18:32AM +0100, Daniel Vetter wrote: > > On Mon, Dec 10, 2018 at 11:06:34AM +0100, Greg Kroah-Hartman wrote: > > > On Mon, Dec 10, 2018 at 09:46:53AM +0100, Daniel Vetter wrote: > > > > Drivers might want to remove some sysfs files, which needs the same > > > > locks and ends up angering lockdep. Relevant snippet of the stack > > > > trace: > > > > > > > > kernfs_remove_by_name_ns+0x3b/0x80 > > > > bus_remove_driver+0x92/0xa0 > > > > acpi_video_unregister+0x24/0x40 > > > > i915_driver_unload+0x42/0x130 [i915] > > > > i915_pci_remove+0x19/0x30 [i915] > > > > pci_device_remove+0x36/0xb0 > > > > device_release_driver_internal+0x185/0x250 > > > > unbind_store+0xaf/0x180 > > > > kernfs_fop_write+0x104/0x190 > > > > > > > > I've stumbled over this because some new patches by Ram connect the > > > > snd-hda-intel unload (where we do use sysfs unbind) with the locking > > > > chains in the i915 unload code (but without creating a new loop), > > > > which upset our CI. But the bug is already there and can be easily > > > > reproduced by unbind i915 directly. > > > > > > This is odd, why wouldn't any driver hit this issue? And why now since > > > you say this is triggerable today? > > > > The above backtrace is triggered by unbinding i915 on current upstream > > kernels. Note: Will crash later on rather badly in the > > fbdev/fbcon/vtconsole hell, but that's separate issue (which can be worked > > around by first unbinding fbcon manually through sysfs). > > > > > I know scsi was doing some strange things like trying to remove the > > > device itself from a sysfs callback on the device, which requires it to > > > just call a different kobject function created just for that type of > > > thing. Would that also make sense to do here instead of your workqueue? > > > > Note how we blow up on unregistering sw device instances supported by i915 > > in entirely different subsystems. I guess most drivers just have sysfs > > files for their own stuff, where this is done as you describe. The problem > > is that there's an awful lot of unrelated stuff hanging off i915. > > > > Or maybe acpi_video is busted, and should be using a different function. > > You haven't said which one, and I have no idea which one it is ... > > > > And in case the context wasn't clear: This is unbinding the i915 pci > > driver which triggers the above lockdep splat recursion. > > btw another option for "fixing" this would be to annotate the mutex_lock > in kernfs_remove_by_name_ns as recursive. Which just shuts up lockdep (and > might hide some real bugs), but would get the job done since there's not > actually a deadlock here. Just lockdep being annoyed. So what's the pick? I can do the typing, but I don't understand all the driver core interactions to know what we should be doing here best. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch