Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1729794imu; Wed, 12 Dec 2018 03:22:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/W06Zitm5oHBF+fnAhEXC3ak4keXbD5dM+6My2QU4v++pAywPg3lYVj3sauijG21GH2IiE7 X-Received: by 2002:a17:902:d911:: with SMTP id c17mr15592178plz.151.1544613726027; Wed, 12 Dec 2018 03:22:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544613726; cv=none; d=google.com; s=arc-20160816; b=y6IIoY53pAbJVuV73quOoiSOecLI9MTQFaZq8d5UG++IdnBAMOtDrmErUgNNpj5Wyh 66a5+ix6j6KIqHG4XAiAIaHK+MdJiweiutVb7AVuLJrY4+XQi9oYS6pzjkkHXa6qGO0T N7onxz+ESsmomzhDpTfFGN4ViAExUaTmMl0PBPFpFnSwsFYYJTJSgdajDYiHOCgg0Rwu /Zpyl9KjwAmsSgD0sZvz5MQDmg9kqgyyuwrwS0o0PuIJyyHGtjN3IAP4+U1GgWmK6a1c GiWoDwenSxKRqyB2xewaASWsOV+9/OA7sU/w4PjVO20JUQv+M+RCLQ/yGHzKCKB3/Lug TLvw== 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:message-id:subject:to :from:date:dkim-signature; bh=KZBOueQ+z207STWAXpx4E2e4anwe0GdptDLRg5iUPV8=; b=hJ9QsdeLB+gkS4j2uF1rFw3yw7Nd8ADKoAahrfueRlGuCx/YPDILWmAE0wgdkahFzl O6Wy+MBEFN/C4jyHLFq6nwyLVZJw4V2jfkJh0w9Ne7tO+ttw4T84sv8bZjH5G4bauqnS Xx7a2w74FDzHSi/lwkiuDbI44Q8EP2Tp5GB4w0CMGCLtVAYUWVsVA6fFOuMQC2oL0m/i OsdP5cvW60NMkWe2uLD11CgVNEpS4EZSdubjRp3N5x5/nI6ICo+vLAr/CanS6tzi3RYW 4EzPCntU5nrzVULbwawqbw9MIrWkgwvubn3GkFngbMLx8lHInyw0y+ksfpk3Ia11hp8C GaXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Cl2Q80dX; 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 r27si11945194pgl.494.2018.12.12.03.21.50; Wed, 12 Dec 2018 03:22:05 -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=pass header.i=@kernel.org header.s=default header.b=Cl2Q80dX; 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 S1727204AbeLLLTu (ORCPT + 99 others); Wed, 12 Dec 2018 06:19:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:45866 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726856AbeLLLTu (ORCPT ); Wed, 12 Dec 2018 06:19:50 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 413B42084E; Wed, 12 Dec 2018 11:19:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544613589; bh=QKa5zYsHxYI1aGgEq7tsjj3bty4Nm9iYE05hv42O6e4=; h=Date:From:To:Subject:References:In-Reply-To:From; b=Cl2Q80dXbOcBc+Df03jR+jtq9eWnLR1q5QYzbJ2n+3zl3onRFKOMHDEgye5GJSKDU YMjJQ7PShVMnAbp2wvPUoK+yO8fdkdVFbw/4k4WzlJIWwS/Dwo6x4fSxHMhKTkYK4j d9xsJwUZFo5ZU1cAwqrPdfluDOrTlb43iOBHRQtY= Date: Wed, 12 Dec 2018 12:19:47 +0100 From: Greg Kroah-Hartman To: LKML , DRI Development , Ramalingam C , "Rafael J. Wysocki" , Daniel Vetter Subject: Re: [PATCH] drivers/base: use a worker for sysfs unbind Message-ID: <20181212111947.GA12685@kroah.com> References: <20181210084653.7268-1-daniel.vetter@ffwll.ch> <20181210100634.GA8836@kroah.com> <20181210101832.GN21184@phenom.ffwll.local> <20181210102058.GO21184@phenom.ffwll.local> <20181212110840.GA21184@phenom.ffwll.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181212110840.GA21184@phenom.ffwll.local> User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 12, 2018 at 12:08:40PM +0100, Daniel Vetter wrote: > 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. Sorry for the delay. Look at sdev_store_delete() in drivers/scsi/scsi_sysfs.c and see if the logic there makes sense to do here instead. It still seems odd that removing a sysfs file by writing to a sysfs file at the same level really invokes lockdep as I would have thought that this path is well-tested by now. thanks, greg k-h