Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2306305iob; Sat, 30 Apr 2022 05:16:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvR0KEBODcPJlGTCQ/OxMqz51lte+UGiC68dgoRIabjHzJ82vq6kXgYh3Fv7ujBdj+qIq+ X-Received: by 2002:a05:651c:2112:b0:24f:4daa:6c86 with SMTP id a18-20020a05651c211200b0024f4daa6c86mr1020650ljq.113.1651320960713; Sat, 30 Apr 2022 05:16:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651320960; cv=none; d=google.com; s=arc-20160816; b=pYfE5NN/pedOWEXVApCkjN0wrCWSHGJYkwEPpURmq5ZldG+wiUuSurWeCVj0SUAmpo VIFcJaZJdgQophbT4/XePdXSig6nt2oOHwtBmJTc6iLeQFR4V/sr4HPzOyF93fjUC6ss snkipKYB+xOYj1LrVPvcHCfef2CAPhdhx5dZIvVvr2JZfGC7xJato15CAkaXyHF4hj3B dy0zEWwOga7ORtvlREqQWBke4mXG7IKvLORkmfgtK15yaWUuJN6TsStyDE0EXkPZh8yw y+VfuA3GktMuqOO643VAW5O4IeZwnKQus8NIriRL93f8+o+q/WvsLZCldLWcsWvdvzxJ UfLA== 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; bh=bqU316qGVtDWHm8NT2hHFJbW7iE4HgnLiZVO1bzx9DM=; b=JiAGETVGZnCRzmrzP7UYhs8UrPw4tArWYMYG0PzR3v9FPU1B193sLtRBmT6yPOLl1d 6Hz8uWZQ8sjLnxWuD2qixzO5IxMsSYauke95tg7PkDM2eeEEmSQqqIbCMmpV72RT66gl R4Ym5Ep05R/0TpD210/o7sIhSgW/vXLYxlOK9iDrTso7x3qYSm61QyFqfluLKOsnEAFM M6eNc59jpu5ULaAzpJRuFlHUHFxt86Lyuhs9QjwgWRdnzIDeh2xEZF0KyB/dcrw7eiKI 2FCOL5MT3PinvFT909Y9gDZtjRnHP3BVIDMy89SRZ+IbQcCgp6+P15AV4v17kXCzvV78 ++eA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 75-20020a2e094e000000b0024f250a3a7esi9374551ljj.109.2022.04.30.05.15.16; Sat, 30 Apr 2022 05:16:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378568AbiD2Pk7 (ORCPT + 99 others); Fri, 29 Apr 2022 11:40:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378571AbiD2Pky (ORCPT ); Fri, 29 Apr 2022 11:40:54 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 55BF4D64FA for ; Fri, 29 Apr 2022 08:37:33 -0700 (PDT) Received: (qmail 950759 invoked by uid 1000); 29 Apr 2022 11:37:32 -0400 Date: Fri, 29 Apr 2022 11:37:32 -0400 From: Alan Stern To: Vincent Shih Cc: gregkh@linuxfoundation.org, p.zabel@pengutronix.de, davem@davemloft.net, vladimir.oltean@nxp.com, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, devicetree@vger.kernel.org, wells.lu@sunplus.com Subject: Re: [PATCH v4 1/2] usb: host: ehci-sunplus: Add driver for ehci in Sunplus SP7021 Message-ID: References: <1651220876-26705-1-git-send-email-vincent.sunplus@gmail.com> <1651220876-26705-2-git-send-email-vincent.sunplus@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1651220876-26705-2-git-send-email-vincent.sunplus@gmail.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 29, 2022 at 04:27:55PM +0800, Vincent Shih wrote: > Add driver for ehci in Sunplus SP7021 > > Signed-off-by: Vincent Shih > --- > Changes in v4: > - Implement power_on, power_off and power_suspend functions. Did you test these? Did you try to rmmod the ehci-sunplus module after adding these functions? > diff --git a/drivers/usb/host/ehci-sunplus.c b/drivers/usb/host/ehci-sunplus.c > new file mode 100644 > index 0000000..4d8e20d > --- /dev/null > +++ b/drivers/usb/host/ehci-sunplus.c > @@ -0,0 +1,289 @@ ... > +static void sp_ehci_platform_power_off(struct platform_device *pdev) > +{ > + struct usb_hcd *hcd = platform_get_drvdata(pdev); > + struct sp_ehci_priv *sp_priv = hcd_to_sp_ehci_priv(hcd); > + > + phy_power_off(sp_priv->phy); > + phy_exit(sp_priv->phy); Notice that this dereferences a field contained in the sp_ehci_priv extension to the usb_hcd structure. ... > +static int ehci_sunplus_remove(struct platform_device *pdev) > +{ > + struct usb_hcd *hcd = platform_get_drvdata(pdev); > + struct usb_ehci_pdata *pdata = pdev->dev.platform_data; > + > + usb_remove_hcd(hcd); > + usb_put_hcd(hcd); This call deallocates the usb_hcd structure. > + > + if (pdata->power_off) > + pdata->power_off(pdev); But here you dereference a field that it contains. This power-off operation must occur _before_ the usb_put_hcd() call. Alan Stern