Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5221366pxj; Wed, 9 Jun 2021 12:04:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/8wIv5Ej0aXGqLaoOv6HtPrwnqge8SdemwmUNzY0eJ0mJ3cD8MCNeUICH5hjz98h4dDTA X-Received: by 2002:a17:906:a203:: with SMTP id r3mr1213362ejy.361.1623265465677; Wed, 09 Jun 2021 12:04:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623265465; cv=none; d=google.com; s=arc-20160816; b=uy3GFLN/nlyLmx4muXSXEEd0Ye/xtGcAR1NkhCszABY4HNHjdiT2R7zuWAUH+frJsO KlcDnFB5Dwec/vpwMuw9ckj6Q8bwYlsThq8OVAMT1CG1YEn1tNpc+sIDpUXY4nNeJEHH 9dwH2dO0K8Wv1hQ7Yp2JsAbsIfSUjNnqXE8VJbtNQ5+zzMt8lxm5QuQ4tKGJ68YhDtYR COAciCrFan6ALmlncwPS2wMQac0uoI7s4q6xPWZAeTCBimYINcofTVL62XP8ziVXAuYS MvNNY5dccIg1ggUVq5BmcGa98kbcxbzYAb3JyxdbphJ8v+5ODmtJZqql+axsS6IYngs7 Xj7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=EIfnL40mkSB8KNG6oOViBv6YdQpuA7o+PS7LCw4c4ug=; b=zg7NdynElw2nUTieEIaCS65XVrG1qc38jrXi4lJBJOiWrV03aZ29k9wUOlY/gB081H v3QBfwjFNnFStrBjudSfu7IBkBNDp9tVZxT3+TyYOJJnN+ycWnmhgOt0Qz3nxmsvFP94 I62/0kXZmgbiyyYxbVDJEgSKqXeiHaVPyFGfsRKQKzf60m37jPU8UateP40XeK1h7FRc FjgqY+7G1iKz2uYVSK5gUspyKSP5LwliJ1KM+e9zZIIcFlSV7NpqC9c7fZqEtdRY5abb E/vER/fr9Ex7XHWpPBAwzGG/hIvpVcmlJRAnFJcQgPz9M2Eo+xoNSaWW4E3M7GeOOKMc zI0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=d5vtyGuX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a13si390922edy.153.2021.06.09.12.03.53; Wed, 09 Jun 2021 12:04:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=d5vtyGuX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230043AbhFITBP (ORCPT + 99 others); Wed, 9 Jun 2021 15:01:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:33644 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbhFITBP (ORCPT ); Wed, 9 Jun 2021 15:01:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EFFFF61364; Wed, 9 Jun 2021 18:59:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623265160; bh=nXoyJTJxIU3jLPEO7r7vkSzXDt/P6SnO6auwIHMlV/E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=d5vtyGuXmMyksM3Z7Ybx3hLNe6SGBJvUCtgsPr7YTMlCz1h51l2fjMxlmix04G5Jz 4Z2liKHYdyYSlJehNHJA/hBC3qac9U9znTMz6xobrAoKKGGzi1Kgb2jeL3CIv5wY4G dqmwEDO5mrmCfGJ+EJEznfWjXFcR9Auxqk3vIQII= Date: Wed, 9 Jun 2021 20:59:17 +0200 From: Greg Kroah-Hartman To: Jack Pham Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Felipe Balbi , Peter Chen Subject: Re: [PATCH] USB: dwc3: remove debugfs root dentry storage Message-ID: References: <20210609093924.3293230-1-gregkh@linuxfoundation.org> <20210609184715.GA28957@jackp-linux.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210609184715.GA28957@jackp-linux.qualcomm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 09, 2021 at 11:47:15AM -0700, Jack Pham wrote: > On Wed, Jun 09, 2021 at 11:39:24AM +0200, Greg Kroah-Hartman wrote: > > There is no need to keep around the debugfs "root" directory for the > > dwc3 device. Instead, look it up anytime we need to find it. This will > > help when callers get out-of-order and we had the potential to have a > > "stale" pointer around for the root dentry, as has happened in the past. > > > > Cc: Felipe Balbi > > Cc: Jack Pham > > Cc: Peter Chen > > Signed-off-by: Greg Kroah-Hartman > > --- > > drivers/usb/dwc3/core.h | 2 -- > > drivers/usb/dwc3/debugfs.c | 8 ++++---- > > drivers/usb/dwc3/gadget.c | 4 +++- > > 3 files changed, 7 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h > > index c5d5760cdf53..dccdf13b5f9e 100644 > > --- a/drivers/usb/dwc3/core.h > > +++ b/drivers/usb/dwc3/core.h > > @@ -1013,7 +1013,6 @@ struct dwc3_scratchpad_array { > > * @link_state: link state > > * @speed: device speed (super, high, full, low) > > * @hwparams: copy of hwparams registers > > - * @root: debugfs root folder pointer > > * @regset: debugfs pointer to regdump file > > * @dbg_lsp_select: current debug lsp mux register selection > > * @test_mode: true when we're entering a USB test mode > > @@ -1222,7 +1221,6 @@ struct dwc3 { > > u8 num_eps; > > > > struct dwc3_hwparams hwparams; > > - struct dentry *root; > > struct debugfs_regset32 *regset; > > > > u32 dbg_lsp_select; > > diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c > > index 5dbbe53269d3..f2b7675c7f62 100644 > > --- a/drivers/usb/dwc3/debugfs.c > > +++ b/drivers/usb/dwc3/debugfs.c > > @@ -889,8 +889,10 @@ static void dwc3_debugfs_create_endpoint_files(struct dwc3_ep *dep, > > void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep) > > { > > struct dentry *dir; > > + struct dentry *root; > > > > - dir = debugfs_create_dir(dep->name, dep->dwc->root); > > + root = debugfs_lookup(dev_name(dep->dwc->dev), usb_debug_root); > > + dir = debugfs_create_dir(dep->name, root); > > dwc3_debugfs_create_endpoint_files(dep, dir); > > } > > > > @@ -909,8 +911,6 @@ void dwc3_debugfs_init(struct dwc3 *dwc) > > dwc->regset->base = dwc->regs - DWC3_GLOBALS_REGS_START; > > > > root = debugfs_create_dir(dev_name(dwc->dev), usb_debug_root); > > - dwc->root = root; > > - > > debugfs_create_regset32("regdump", 0444, root, dwc->regset); > > debugfs_create_file("lsp_dump", 0644, root, dwc, &dwc3_lsp_fops); > > > > @@ -929,6 +929,6 @@ void dwc3_debugfs_init(struct dwc3 *dwc) > > > > void dwc3_debugfs_exit(struct dwc3 *dwc) > > { > > - debugfs_remove_recursive(dwc->root); > > + debugfs_remove(debugfs_lookup(dev_name(dwc->dev), usb_debug_root)); > > kfree(dwc->regset); > > } > > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c > > index 7cc99b6d0bfe..026a2ad0fc80 100644 > > --- a/drivers/usb/dwc3/gadget.c > > +++ b/drivers/usb/dwc3/gadget.c > > @@ -2799,7 +2799,9 @@ static void dwc3_gadget_free_endpoints(struct dwc3 *dwc) > > list_del(&dep->endpoint.ep_list); > > } > > > > - debugfs_remove_recursive(debugfs_lookup(dep->name, dwc->root)); > > + debugfs_remove_recursive(debugfs_lookup(dep->name, > > + debugfs_lookup(dev_name(dep->dwc->dev), > > + usb_debug_root))); > > Nested calls to debugfs_lookup() :). But it does work, and similarly > avoids the out-of-order debugfs removal issue as well even without > Peter's fix. Yeah, it's funny, but it's safer than trying to store a pointer around :) > Tested-by: Jack Pham Many thanks for testing. greg k-h