Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp583667imw; Wed, 13 Jul 2022 04:25:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1twQIycBwGabPHS9MHonXpkpPq5QGnceE13j7wFcZB+LI/zL1jH/j/Jav26/zVPmuY4rdX1 X-Received: by 2002:a17:902:d50e:b0:16c:1664:81e5 with SMTP id b14-20020a170902d50e00b0016c166481e5mr2731548plg.149.1657711537371; Wed, 13 Jul 2022 04:25:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657711537; cv=none; d=google.com; s=arc-20160816; b=UorHdViQfxdhIhFJwG7xP8k4odEwI7IKldd/OGtxMK2A3p0Y91d/udqI/SsRHIwExf 2mpTb9hZ8yhgcMcYYLN1lf/oVIuZ3Eq4b60gBtCXjO9MZemnBAh07p/dfaz229ZkxBAW 8DghiGBOsJRS6UHX7LbqkVKKYEHmUStdhT0WYHGnF1ZSl467vfSqYm+CpB90k9eZalhU haeVVEOCNELU42orWlh55j7MR3a3p+fAY4UUktlni/JZFfiMmxPbccSqKfM1BAmfnb5/ tSY6noZwwOQ6e/DcQx76er0BvQ6aOp/x4Gp1Fi72PJ+3hKazVR/62/OULZjUW6BzCARb IjQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=d1y+lLADgmTCLtCoaI3iaPKrfXDO+5/8sivizc5AU6I=; b=JYJqs9+CjH87d65mwV76ByEpgZOyorfY2nDP97mj9WG4hfan1+WesS2FcLFvfQkVzg 23CRh1+a+j4DNeY3w3s+z52Y/O48BAT+j5d82rEEBwOvdAJT350VQu1w1EIZu94Qh6ut DYaXRbtDz/8dxpU3OQ69J6tZYjee3YzkQ3WoRS+AxUoweasfVqDcinooi+YjUBk4ooUp 2fWMXk5KFq/ybtM7jzKZcuuyD1TQMWx0VDrNMbXHLWvx3Xr4PZMMRO060bCw2obdzZLz F5KZ1T8k34GNirfVAb75/4+WaJS3I10vjdqgP9XTs9Cv8bYYIVFsFmTkLBe5isR/XomT zwcw== 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 bt23-20020a056a00439700b0052ab0a74205si17284849pfb.190.2022.07.13.04.25.22; Wed, 13 Jul 2022 04:25:37 -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 S235120AbiGMLRm (ORCPT + 99 others); Wed, 13 Jul 2022 07:17:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231460AbiGMLRj (ORCPT ); Wed, 13 Jul 2022 07:17:39 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6747FAE3A5 for ; Wed, 13 Jul 2022 04:17:38 -0700 (PDT) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=[IPv6:::1]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oBaMw-00045N-ID; Wed, 13 Jul 2022 13:17:26 +0200 Message-ID: <5bb33ccf17f89cd398342922af6fd7a04f015c07.camel@pengutronix.de> Subject: Re: [PATCH v14 14/17] PCI: imx6: Do not hide phy driver callbacks and refine the error handling From: Lucas Stach To: Hongxing Zhu , "bhelgaas@google.com" , "robh+dt@kernel.org" , "broonie@kernel.org" , "lorenzo.pieralisi@arm.com" , "festevam@gmail.com" , "francesco.dolcini@toradex.com" Cc: "linux-pci@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "kernel@pengutronix.de" , dl-linux-imx Date: Wed, 13 Jul 2022 13:17:24 +0200 In-Reply-To: References: <1656645935-1370-1-git-send-email-hongxing.zhu@nxp.com> <1656645935-1370-15-git-send-email-hongxing.zhu@nxp.com> <4f49f28d15ad859e34aeeb714b5ddd5d6eba4b4a.camel@pengutronix.de> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4 (3.40.4-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Am Mittwoch, dem 13.07.2022 um 10:57 +0000 schrieb Hongxing Zhu: > > -----Original Message----- > > From: Lucas Stach > > Sent: 2022年7月13日 16:59 > > To: Hongxing Zhu ; bhelgaas@google.com; > > robh+dt@kernel.org; broonie@kernel.org; lorenzo.pieralisi@arm.com; > > festevam@gmail.com; francesco.dolcini@toradex.com > > Cc: linux-pci@vger.kernel.org; > > linux-arm-kernel@lists.infradead.org; > > linux-kernel@vger.kernel.org; kernel@pengutronix.de; dl-linux-imx > > > > Subject: Re: [PATCH v14 14/17] PCI: imx6: Do not hide phy driver > > callbacks and > > refine the error handling > > > > Am Freitag, dem 01.07.2022 um 11:25 +0800 schrieb Richard Zhu: > > > - Move the phy_power_on() to host_init from > > > imx6_pcie_clk_enable(). > > > - Move the phy_init() to host_init from > > > imx6_pcie_deassert_core_reset(). > > > > > > Refine the error handling in imx6_pcie_host_init() accordingly. > > > > > > Signed-off-by: Richard Zhu > > > Signed-off-by: Bjorn Helgaas > > > --- > > >  drivers/pci/controller/dwc/pci-imx6.c | 34 +++++++++++++++++---- > > > ------ > > >  1 file changed, 21 insertions(+), 13 deletions(-) > > > > > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c > > b/drivers/pci/controller/dwc/pci-imx6.c > > > index 5a06fbca82d6..0b2a5256fb0d 100644 > > > --- a/drivers/pci/controller/dwc/pci-imx6.c > > > +++ b/drivers/pci/controller/dwc/pci-imx6.c > > > @@ -639,14 +639,6 @@ static int imx6_pcie_clk_enable(struct > > > imx6_pcie > > *imx6_pcie) > > >   goto err_ref_clk; > > >   } > > > > > > - switch (imx6_pcie->drvdata->variant) { > > > - case IMX8MM: > > > - if (phy_power_on(imx6_pcie->phy)) > > > - dev_err(dev, "unable to power on > > > PHY\n"); > > > - break; > > > - default: > > > - break; > > > - } > > >   /* allow the clocks to stabilize */ > > >   usleep_range(200, 500); > > >   return 0; > > > @@ -723,10 +715,6 @@ static int > > > imx6_pcie_deassert_core_reset(struct > > imx6_pcie *imx6_pcie) > > >   case IMX8MQ: > > >   reset_control_deassert(imx6_pcie- > > > >pciephy_reset); > > >   break; > > > - case IMX8MM: > > > - if (phy_init(imx6_pcie->phy)) > > > - dev_err(dev, "waiting for phy ready > > > timeout!\n"); > > > - break; > > >   case IMX7D: > > >   reset_control_deassert(imx6_pcie- > > > >pciephy_reset); > > > > > > @@ -762,6 +750,7 @@ static int > > > imx6_pcie_deassert_core_reset(struct > > imx6_pcie *imx6_pcie) > > >   usleep_range(200, 500); > > >   break; > > >   case IMX6Q: /* Nothing to do */ > > > + case IMX8MM: > > >   break; > > >   } > > > > > > @@ -913,17 +902,36 @@ static int imx6_pcie_host_init(struct > > > pcie_port > > *pp) > > >   return ret; > > >   } > > >   } > > > + if (imx6_pcie->phy) { > > > + ret = phy_power_on(imx6_pcie->phy); > > > + if (ret) { > > > + dev_err(dev, "pcie phy power up > > > failed.\n"); > > > + goto err_reg_disable; > > > + } > > > + } > > > > > >   ret = imx6_pcie_deassert_core_reset(imx6_pcie); > > >   if (ret < 0) { > > >   dev_err(dev, "pcie deassert core reset failed: > > > %d\n", ret); > > > - goto err_reg_disable; > > > + goto err_phy_off; > > >   } > > > > > > + if (imx6_pcie->phy) { > > > + ret = phy_init(imx6_pcie->phy); > > > + if (ret) { > > > + dev_err(dev, "waiting for phy ready > > > timeout!\n"); > > > + goto err_clk_disable; > > > + } > > > + } > > > > Wouldn't it be more logical to put this into imx6_pcie_init_phy()? > > > Before adding i.MX8MM PCIe support, the imx6_pcie_init_phy() only > touches the >  GPR registers. PCIe clocks and so on are not required in this case. > But phy_init() used by i.MX8MM PCIe touches not only the GPR > registers but >  also the PHY's registers. > The clocks should be on and resets of PHY should be configured > properly when >  phy_init() is invoked. > So, phy_init() is placed behind of imx6_pcie_deassert_core_reset() > here. The PHY driver should be self-contained enough to not care about the state of the controller here, no? It should set all the necessary GPRs and enable clocks as needed on its own. Is this not the case with the current code? Also PHY init should be called before PHY power-on, to make things symmetric with the shutdown paths which do phy_power_off() first, then phy_exit(). Regards, Lucas