[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZsO62fLuftny3NfB@hu-bjorande-lv.qualcomm.com>
Date: Mon, 19 Aug 2024 14:36:25 -0700
From: Bjorn Andersson <quic_bjorande@...cinc.com>
To: Krishna Kurapati <quic_kriskura@...cinc.com>
CC: Bjorn Andersson <andersson@...nel.org>,
Thinh Nguyen
<Thinh.Nguyen@...opsys.com>, <linux-usb@...r.kernel.org>,
<devicetree@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
"Greg
Kroah-Hartman" <gregkh@...uxfoundation.org>,
Rob Herring <robh@...nel.org>, Wesley Cheng <quic_wcheng@...cinc.com>,
<linux-arm-msm@...r.kernel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Konrad Dybcio <konrad.dybcio@...aro.org>,
Philipp Zabel
<p.zabel@...gutronix.de>,
Saravana Kannan <saravanak@...gle.com>,
"Felipe
Balbi" <balbi@...nel.org>
Subject: Re: [PATCH v2 4/7] usb: dwc3: core: Expose core driver as library
On Mon, Aug 19, 2024 at 11:18:15PM +0530, Krishna Kurapati wrote:
>
>
> On 8/12/2024 8:42 AM, Bjorn Andersson wrote:
> > From: Bjorn Andersson <quic_bjorande@...cinc.com>
> >
> > The DWC3 IP block is handled by three distinct device drivers: XHCI,
> > DWC3 core and a platform specific (optional) DWC3 glue driver.
> >
> > This has resulted in, at least in the case of the Qualcomm glue, the
> > presence of a number of layering violations, where the glue code either
> > can't handle, or has to work around, the fact that core might not probe
> > deterministically.
> >
> > An example of this is that the suspend path should operate slightly
> > different depending on the device operating in host or peripheral mode,
> > and the only way to determine the operating state is to peek into the
> > core's drvdata.
> >
> > The Qualcomm glue driver is expected to make updates in the qscratch
> > register region (the "glue" region) during role switch events, but with
> > the glue and core split using the driver model, there is no reasonable
> > way to introduce listeners for mode changes.
> >
> > Split the dwc3 core platform_driver callbacks and their implementation
> > and export the implementation, to make it possible to deterministically
> > instantiate the dwc3 core as part of the dwc3 glue drivers and to
> > allow flattening of the DeviceTree representation.
> >
> > Signed-off-by: Bjorn Andersson <quic_bjorande@...cinc.com>
>
> ...
>
> > -static int dwc3_probe(struct platform_device *pdev)
> > +struct dwc3 *dwc3_probe(struct platform_device *pdev, struct resource *res,
> > + bool ignore_clocks_and_resets, void *glue)
> > {
> > struct device *dev = &pdev->dev;
> > - struct resource *res, dwc_res;
> > + struct resource dwc_res;
> > unsigned int hw_mode;
> > void __iomem *regs;
> > struct dwc3 *dwc;
> > @@ -2087,15 +2089,10 @@ static int dwc3_probe(struct platform_device *pdev)
> > dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL);
> > if (!dwc)
> > - return -ENOMEM;
> > + return ERR_PTR(-ENOMEM);
> > dwc->dev = dev;
> > -
> > - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > - if (!res) {
> > - dev_err(dev, "missing memory resource\n");
> > - return -ENODEV;
> > - }
>
> ...
>
> > +static int dwc3_plat_probe(struct platform_device *pdev)
> > {
> > - struct dwc3 *dwc = platform_get_drvdata(pdev);
> > + struct resource *res;
> > + struct dwc3 *dwc;
> > +
> > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > + if (!res) {
> > + dev_err(&pdev->dev, "missing memory resource\n");
> > + return -ENODEV;
> > + }
> > - pm_runtime_get_sync(&pdev->dev);
> > + dwc = dwc3_probe(pdev, res, false, NULL);
> > + if (IS_ERR(dwc))
> > + return PTR_ERR(dwc);
> > +
> > + platform_set_drvdata(pdev, dwc);
>
> This setting of platform drvdata is redundant I believe. We already do it in
> dwc3_probe.
>
Good catch, you're certainly right.
Regards,
Bjorn
> > +
> > + return 0;
> > +}
> > +
Powered by blists - more mailing lists