Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp793772img; Thu, 21 Mar 2019 09:03:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqw15WlByU9BPKZLQfh01jrLIDiJZ4tmx85dhU6b3ImUScgp/C7rQdOmNa8Vr353Vcv3I3ze X-Received: by 2002:a17:902:b716:: with SMTP id d22mr4417218pls.9.1553184233423; Thu, 21 Mar 2019 09:03:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553184233; cv=none; d=google.com; s=arc-20160816; b=o+r04jYY9lWNMyuU4TXFiIFrBcKLAXD/pF5sINFQSQDfKzp014pWEdqmfU88aA37rR aKUgqOskQagwAHhN4//vfo9MWwAyiJwtZOjlvigUVpX8utIKM849sQbMANlwdZhGVOyF 6lfqoN3E0fLoslEELgfUPhLa8UkFXpMR0eup2dHqvcM/tgukeE2XGpkQQ/df5XQbTZlE aujpRceVmYGJgd/kp0w7UzX8rBh/6xaOLQWW730FSCb4EPDteAUPl5lx/ZZczYKB8MUs YTWduVP/5V/Z0G9K0UMgwktnT0o+OqHDMb1jvnkyvUJpgZDE/5ziEF/e0qgDLYi3TYyZ uWng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=QrseK9OxUIVk0C3z8KmrifFZ2Oe9zx/F5oOTN7fzq9E=; b=CxM2ETJ08WxDi5QUOiXmwzVAUwQShG1yirHrFxLDWpXSmKaaKpp6jUi0+mnxAJ1Dvd zlHh04oGx3MAVIZiZrtnXE//RBtya0BQF29G83pUmdidBJNQXcJAveVx85nxc9iodCBk PThRS92MFaDSr0n34P2ZhGxvPCfinDXXrir9MAXYcp0gFsLWmbw6/STLvEiN58Spzz5F IiDQDYX2ZQ44KQVq2bbNVL69COvX3J4Hp00XH7eIFcZ9e82o0tpKHc961xSHGgZBopek AFFfnjhuXXmljUr3jxtpvgbVFfkWXeUKiGkVVw3QjnOah+R7HR7hJKlZUWDy8HRDulk0 GW9A== 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 s26si4270445pfm.143.2019.03.21.09.03.28; Thu, 21 Mar 2019 09:03:53 -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 S1728353AbfCUQCe (ORCPT + 99 others); Thu, 21 Mar 2019 12:02:34 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:59006 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727987AbfCUQCd (ORCPT ); Thu, 21 Mar 2019 12:02:33 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 33268374; Thu, 21 Mar 2019 09:02:33 -0700 (PDT) Received: from why.wild-wind.fr.eu.org (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1BAD33F575; Thu, 21 Mar 2019 09:02:31 -0700 (PDT) Date: Thu, 21 Mar 2019 16:02:27 +0000 From: Marc Zyngier To: Heikki Krogerus Cc: Greg Kroah-Hartman , Guenter Roeck , , Subject: Re: [PATCH v2] usb: typec: fusb302: Fix debugfs mutex initialisation Message-ID: <20190321160227.32d32bba@why.wild-wind.fr.eu.org> In-Reply-To: <20190321132418.GE7752@kuha.fi.intel.com> References: <20190318174906.10429-1-marc.zyngier@arm.com> <20190319114511.GS7752@kuha.fi.intel.com> <20190320160708.5f31ff10@why.wild-wind.fr.eu.org> <20190320163433.GD7752@kuha.fi.intel.com> <20190321132418.GE7752@kuha.fi.intel.com> Organization: ARM Ltd X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 21 Mar 2019 15:24:18 +0200 Heikki Krogerus wrote: > Hi, > > On Wed, Mar 20, 2019 at 06:34:33PM +0200, Heikki Krogerus wrote: > > > > After applying this there was no more "fusb302" debugfs directory, and > > > > attempt to unload the fusb302 module dead locked. Also, attempt to > > > > reboot caused this to happen on my GDPWin board after applying the > > > > patch: > > > > > > > > BUG: Dentry 0000000012f2a05d{i=149,n=i2c-fusb302} still in use (1) [unmount of sysfs sysfs] > > > > WARNING: CPU: 3 PID: 1639 at fs/dcache.c:1529 umount_check.cold.55+0x2e/0x3a > > > > Modules linked in: intel_xhci_usb_role_switch roles pi3usb30532 typec i915 intel_gtt intel_cht_int33fe [last unloaded: tcpm] > > > > CPU: 3 PID: 1639 Comm: umount Not tainted 5.1.0-rc1-heikki+ #916 > > > > Hardware name: Default string Default string/Default string, BIOS 5.11 05/25/2017 > > > > RIP: 0010:umount_check.cold.55+0x2e/0x3a > > > > ... > > > > > > > > Note. Your patch has also a conflict with patches from Hans, I > > > > think with this one: https://patchwork.kernel.org/patch/10847275/ > > > > I can take care of that, but you can also rebase the next version on > > > > top of my typec-next branch to solve that problem: > > > > https://github.com/krohei/linux/commits/typec-next > > > > > > OK, this is very weird. I can't reproduce any of the issues you're > > > reporting: > > > > > > - the patch applies cleanly on top of typec-next > > > - removing the fusb302 module works > > > - I see the debugfs file whenever fsusb302 is inserted > > > > > > Maybe you were trying this on another branch? > > > > No, the branch is correct. Actually, I tested this on top of mainline > > and linux-next. I saw that happen on both. > > > > On these Intel Cherrytrail based boards like my GDBWin, fusb302 is one > > of the functions of a weir MFD device (the driver for that device is > > drivers/platform/x86/intel_cht_int33fe.c). It's entirely possible that > > we are doing something wrong in that driver, and your patch just makes > > the problem visible. > > > > I'll continue debugging. > > I figured out what's the problem. It seems that the driver does not > probe successfully, which is why I don't see that "fusb302" debugfs > directory. > > The reason is that if tcpm_register_port() returns with -EPROBE_DEFER, > we end up with that rootdir already pointing to something, even though > the entry is destroyed in that case. So next time the driver is > probed, that "fusb302" directory does get created as rootdir has a > value, and debugfs_create_file() fails. > > I think the correct fix is to just initialize the mutex earlier. > Something like this should work: > > diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c > index 261b82900fec..8e43ea27f26d 100644 > --- a/drivers/usb/typec/tcpm/fusb302.c > +++ b/drivers/usb/typec/tcpm/fusb302.c > @@ -211,7 +211,6 @@ static struct dentry *rootdir; > > static void fusb302_debugfs_init(struct fusb302_chip *chip) > { > - mutex_init(&chip->logbuffer_lock); > if (!rootdir) > rootdir = debugfs_create_dir("fusb302", NULL); > > @@ -1667,6 +1666,7 @@ static int fusb302_probe(struct i2c_client *client, > chip->tcpc_config = fusb302_tcpc_config; > chip->tcpc_dev.config = &chip->tcpc_config; > mutex_init(&chip->lock); > + mutex_init(&chip->logbuffer_lock); > > chip->tcpc_dev.fwnode = > device_get_named_child_node(dev, "connector"); Looks good to me, although you probably want to make that conditional on CONFIG_DEBUG_FS being set. Thanks, M. -- Without deviation from the norm, progress is not possible.