diff mbox

PCI: Designware: Move num-lanes property read to dw_pcie_setup_rc

Message ID 1440587656-84224-1-git-send-email-gabriele.paoloni@huawei.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Gabriele Paoloni Aug. 26, 2015, 11:14 a.m. UTC
From: gabriele paoloni <gabriele.paoloni@huawei.com>

Currently num-lanes is read in dw_pcie_host_init().
for A SoC that performs the link-up operation in UEFI num-lanes
is not needed in the DTS but it has to be specified to any value;
otherwise dw_pcie_host_init will fail.
This patch moves the num-lanes property read in dw_pcie_setup_rc()
as num-lanes is only used there and, if the link is already up,
the PCIe controller driver can decide either to leave host_init
NULL or to return straightforward without proceeding to call
dw_pcie_setup_rc().

Signed-off-by: Gabriele Paoloni <gabriele.paoloni@huawei.com>
---
 drivers/pci/host/pcie-designware.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Gabriele Paoloni Sept. 8, 2015, 8:32 a.m. UTC | #1
Hi Jingoo, Pratyush

Any comment on this patch?

Thanks

Gab
> -----Original Message-----

> From: Gabriele Paoloni

> Sent: Wednesday, August 26, 2015 12:14 PM

> To: jingoohan1@gmail.com; Wangzhou (B); pratyush.anand@gmail.com

> Cc: linux-pci@vger.kernel.org; qiuzhenfa; zhangjukuo; liudongdong (C);

> Liguozhu (Kenneth); qiujiang; Gabriele Paoloni

> Subject: [PATCH] PCI: Designware: Move num-lanes property read to

> dw_pcie_setup_rc

> 

> From: gabriele paoloni <gabriele.paoloni@huawei.com>

> 

> Currently num-lanes is read in dw_pcie_host_init().

> for A SoC that performs the link-up operation in UEFI num-lanes

> is not needed in the DTS but it has to be specified to any value;

> otherwise dw_pcie_host_init will fail.

> This patch moves the num-lanes property read in dw_pcie_setup_rc()

> as num-lanes is only used there and, if the link is already up,

> the PCIe controller driver can decide either to leave host_init

> NULL or to return straightforward without proceeding to call

> dw_pcie_setup_rc().

> 

> Signed-off-by: Gabriele Paoloni <gabriele.paoloni@huawei.com>

> ---

>  drivers/pci/host/pcie-designware.c | 10 +++++-----

>  1 file changed, 5 insertions(+), 5 deletions(-)

> 

> diff --git a/drivers/pci/host/pcie-designware.c

> b/drivers/pci/host/pcie-designware.c

> index 69486be..7d707b7 100644

> --- a/drivers/pci/host/pcie-designware.c

> +++ b/drivers/pci/host/pcie-designware.c

> @@ -483,11 +483,6 @@ int dw_pcie_host_init(struct pcie_port *pp)

>  		}

>  	}

> 

> -	if (of_property_read_u32(np, "num-lanes", &pp->lanes)) {

> -		dev_err(pp->dev, "Failed to parse the number of lanes\n");

> -		return -EINVAL;

> -	}

> -

>  	if (IS_ENABLED(CONFIG_PCI_MSI)) {

>  		if (!pp->ops->msi_host_init) {

>  			pp->irq_domain = irq_domain_add_linear(pp->dev-

> >of_node,

> @@ -742,7 +737,12 @@ void dw_pcie_setup_rc(struct pcie_port *pp)

>  	u32 val;

>  	u32 membase;

>  	u32 memlimit;

> +	struct device_node *np = pp->dev->of_node;

> 

> +	if (of_property_read_u32(np, "num-lanes", &pp->lanes)) {

> +		dev_err(pp->dev, "Failed to parse the number of lanes\n");

> +		return;

> +	}

>  	/* set the number of lanes */

>  	dw_pcie_readl_rc(pp, PCIE_PORT_LINK_CONTROL, &val);

>  	val &= ~PORT_LINK_MODE_MASK;

> --

> 1.9.1
Pratyush Anand Sept. 8, 2015, 9:05 a.m. UTC | #2
Hi Gab,

Sorry for the delayed response.

On Wed, Aug 26, 2015 at 4:44 PM, Gabriele Paoloni
<gabriele.paoloni@huawei.com> wrote:
> From: gabriele paoloni <gabriele.paoloni@huawei.com>
>
> Currently num-lanes is read in dw_pcie_host_init().
> for A SoC that performs the link-up operation in UEFI num-lanes
> is not needed in the DTS but it has to be specified to any value;
> otherwise dw_pcie_host_init will fail.

OK, So it means num-lanes is no longer "required property" and can be
an "optional property".
IMO,

* move num-lanes from "Required" to "Optional" in
Documentation/devicetree/bindings/pci/designware-pcie.txt
* Handle it in dw_pcie_host_init() itself (similar to bus-range)
     - s/dev_err/dev_dbg
     - set pp->lanes = 0;
* May be we can put a dev_err message in dw_pcie_setup_rc() for pp->lanes = 0.

~Pratyush
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gabriele Paoloni Sept. 8, 2015, 10:17 a.m. UTC | #3
SGkgUHJhdHl1c2gsIG1hbnkgdGhhbmtzIGZvciByZXBseWluZy4NCg0KPiAtLS0tLU9yaWdpbmFs
IE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBQcmF0eXVzaCBBbmFuZCBbbWFpbHRvOnByYXR5dXNoLmFu
YW5kQGdtYWlsLmNvbV0NCj4gU2VudDogVHVlc2RheSwgU2VwdGVtYmVyIDA4LCAyMDE1IDEwOjA2
IEFNDQo+IFRvOiBHYWJyaWVsZSBQYW9sb25pDQo+IENjOiBKaW5nb28gSGFuOyBXYW5nemhvdSAo
Qik7IGxpbnV4LXBjaUB2Z2VyLmtlcm5lbC5vcmc7IHFpdXpoZW5mYTsNCj4gemhhbmdqdWt1bzsg
bGl1ZG9uZ2RvbmcgKEMpOyBMaWd1b3podSAoS2VubmV0aCk7IHFpdWppYW5nDQo+IFN1YmplY3Q6
IFJlOiBbUEFUQ0hdIFBDSTogRGVzaWdud2FyZTogTW92ZSBudW0tbGFuZXMgcHJvcGVydHkgcmVh
ZCB0bw0KPiBkd19wY2llX3NldHVwX3JjDQo+IA0KPiBIaSBHYWIsDQo+IA0KPiBTb3JyeSBmb3Ig
dGhlIGRlbGF5ZWQgcmVzcG9uc2UuDQo+IA0KPiBPbiBXZWQsIEF1ZyAyNiwgMjAxNSBhdCA0OjQ0
IFBNLCBHYWJyaWVsZSBQYW9sb25pDQo+IDxnYWJyaWVsZS5wYW9sb25pQGh1YXdlaS5jb20+IHdy
b3RlOg0KPiA+IEZyb206IGdhYnJpZWxlIHBhb2xvbmkgPGdhYnJpZWxlLnBhb2xvbmlAaHVhd2Vp
LmNvbT4NCj4gPg0KPiA+IEN1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3
b3VsZA0Kc2F2ZSB0aGUgaGFzc2xlIG9mIHNldHRpbmcgcHAtPmxhbmVzIHRvIDAgYW5kIGhhdmlu
ZyBpdCBjaGVja2VkIGxhdGVyIA0KaW4gZHdfcGNpZV9zZXR1cF9yYygpLCBob3dldmVyIGlmIHlv
dSB0aGluayBpdCBpcyBtb3JlIGNsZWFuIHRvIGtlZXAgDQphbGwgdGhlIERUIHJlbGF0ZWQgcGFy
dCBpbiBkd19wY2llX2hvc3RfaW5pdCgpIEkgaGF2ZSBubyBwcm9icyBpbiBkb2luZw0KdGhlIHdh
eSB5b3Ugc3VnZ2VzdGVkLi4uIA0KDQo+IH5QcmF0eXVzaA0K
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
index 69486be..7d707b7 100644
--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -483,11 +483,6 @@  int dw_pcie_host_init(struct pcie_port *pp)
 		}
 	}
 
-	if (of_property_read_u32(np, "num-lanes", &pp->lanes)) {
-		dev_err(pp->dev, "Failed to parse the number of lanes\n");
-		return -EINVAL;
-	}
-
 	if (IS_ENABLED(CONFIG_PCI_MSI)) {
 		if (!pp->ops->msi_host_init) {
 			pp->irq_domain = irq_domain_add_linear(pp->dev->of_node,
@@ -742,7 +737,12 @@  void dw_pcie_setup_rc(struct pcie_port *pp)
 	u32 val;
 	u32 membase;
 	u32 memlimit;
+	struct device_node *np = pp->dev->of_node;
 
+	if (of_property_read_u32(np, "num-lanes", &pp->lanes)) {
+		dev_err(pp->dev, "Failed to parse the number of lanes\n");
+		return;
+	}
 	/* set the number of lanes */
 	dw_pcie_readl_rc(pp, PCIE_PORT_LINK_CONTROL, &val);
 	val &= ~PORT_LINK_MODE_MASK;