linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] PCI Devices for Loongson PCH
@ 2019-10-30 13:53 Jiaxun Yang
  2019-10-30 13:53 ` [PATCH 1/5] PCI: pci_ids: Add Loongson IDs Jiaxun Yang
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Jiaxun Yang @ 2019-10-30 13:53 UTC (permalink / raw)
  To: linux-mips
  Cc: davem, robh+dt, mark.rutland, axboe, peppe.cavallaro,
	alexandre.torgue, joabreu, bhelgaas, netdev, devicetree,
	linux-ide, linux-pci, Jiaxun Yang

Hi,

This series is adding quirks & configs for Loongson PCH Devices.


Jiaxun Yang (5):
  PCI: pci_ids: Add Loongson IDs
  net: stmmac: Split devicetree parse
  net: stmmac: pci: Add Loongson GMAC
  dt-bindings: net: document loongson.pci-gmac
  libata/ahci: Apply non-standard BAR fix for Loongson

 .../net/wireless/loongson,pci-gmac.yaml       | 71 +++++++++++++++++++
 drivers/ata/ahci.c                            |  7 ++
 .../net/ethernet/stmicro/stmmac/stmmac_pci.c  | 52 +++++++++++++-
 .../ethernet/stmicro/stmmac/stmmac_platform.c | 63 +++++++++++-----
 .../ethernet/stmicro/stmmac/stmmac_platform.h |  3 +
 include/linux/pci_ids.h                       |  4 ++
 6 files changed, 181 insertions(+), 19 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/loongson,pci-gmac.yaml

-- 
2.23.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/5] PCI: pci_ids: Add Loongson IDs
  2019-10-30 13:53 [PATCH 0/5] PCI Devices for Loongson PCH Jiaxun Yang
@ 2019-10-30 13:53 ` Jiaxun Yang
  2019-10-30 20:40   ` Bjorn Helgaas
  2019-10-30 13:53 ` [PATCH 2/5] net: stmmac: Split devicetree parse Jiaxun Yang
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Jiaxun Yang @ 2019-10-30 13:53 UTC (permalink / raw)
  To: linux-mips
  Cc: davem, robh+dt, mark.rutland, axboe, peppe.cavallaro,
	alexandre.torgue, joabreu, bhelgaas, netdev, devicetree,
	linux-ide, linux-pci, Jiaxun Yang

Add Loongson device IDs that will be used by drivers later.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 include/linux/pci_ids.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 21a572469a4e..75f3336116eb 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -148,6 +148,10 @@
 
 /* Vendors and devices.  Sort key: vendor first, device next. */
 
+#define PCI_VENDOR_ID_LOONGSON		0x0014
+#define PCI_DEVICE_ID_LOONGSON_GMAC	0x7a03
+#define PCI_DEVICE_ID_LOONGSON_AHCI	0x7a08
+
 #define PCI_VENDOR_ID_TTTECH		0x0357
 #define PCI_DEVICE_ID_TTTECH_MC322	0x000a
 
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/5] net: stmmac: Split devicetree parse
  2019-10-30 13:53 [PATCH 0/5] PCI Devices for Loongson PCH Jiaxun Yang
  2019-10-30 13:53 ` [PATCH 1/5] PCI: pci_ids: Add Loongson IDs Jiaxun Yang
@ 2019-10-30 13:53 ` Jiaxun Yang
  2019-11-01 12:18   ` Andrew Murray
  2019-11-01 22:43   ` kbuild test robot
  2019-10-30 13:53 ` [PATCH 3/5] net: stmmac: pci: Add Loongson GMAC Jiaxun Yang
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 14+ messages in thread
From: Jiaxun Yang @ 2019-10-30 13:53 UTC (permalink / raw)
  To: linux-mips
  Cc: davem, robh+dt, mark.rutland, axboe, peppe.cavallaro,
	alexandre.torgue, joabreu, bhelgaas, netdev, devicetree,
	linux-ide, linux-pci, Jiaxun Yang

PCI based devices can share devicetree info parse with platform
device based devices after split dt parse frpm dt probe.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 .../ethernet/stmicro/stmmac/stmmac_platform.c | 63 ++++++++++++++-----
 .../ethernet/stmicro/stmmac/stmmac_platform.h |  3 +
 2 files changed, 49 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 170c3a052b14..7e29bc76b7c3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -385,25 +385,19 @@ static int stmmac_of_get_mac_mode(struct device_node *np)
 }
 
 /**
- * stmmac_probe_config_dt - parse device-tree driver parameters
- * @pdev: platform_device structure
- * @mac: MAC address to use
+ * stmmac_parse_config_dt - parse device-tree driver parameters
+ * @np: device_mode structure
+ * @plat: plat_stmmacenet_data structure
  * Description:
  * this function is to read the driver parameters from device-tree and
  * set some private fields that will be used by the main at runtime.
  */
-struct plat_stmmacenet_data *
-stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
+int stmmac_parse_config_dt(struct device_node *np,
+				struct plat_stmmacenet_data *plat)
 {
-	struct device_node *np = pdev->dev.of_node;
-	struct plat_stmmacenet_data *plat;
 	struct stmmac_dma_cfg *dma_cfg;
 	int rc;
 
-	plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
-	if (!plat)
-		return ERR_PTR(-ENOMEM);
-
 	*mac = of_get_mac_address(np);
 	if (IS_ERR(*mac)) {
 		if (PTR_ERR(*mac) == -EPROBE_DEFER)
@@ -414,7 +408,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 
 	plat->phy_interface = of_get_phy_mode(np);
 	if (plat->phy_interface < 0)
-		return ERR_PTR(plat->phy_interface);
+		return plat->phy_interface;
 
 	plat->interface = stmmac_of_get_mac_mode(np);
 	if (plat->interface < 0)
@@ -453,7 +447,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 	/* To Configure PHY by using all device-tree supported properties */
 	rc = stmmac_dt_phy(plat, np, &pdev->dev);
 	if (rc)
-		return ERR_PTR(rc);
+		return rc;
 
 	of_property_read_u32(np, "tx-fifo-depth", &plat->tx_fifo_size);
 
@@ -531,7 +525,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 			       GFP_KERNEL);
 	if (!dma_cfg) {
 		stmmac_remove_config_dt(pdev, plat);
-		return ERR_PTR(-ENOMEM);
+		return -ENOMEM;
 	}
 	plat->dma_cfg = dma_cfg;
 
@@ -560,7 +554,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 	rc = stmmac_mtl_setup(pdev, plat);
 	if (rc) {
 		stmmac_remove_config_dt(pdev, plat);
-		return ERR_PTR(rc);
+		return rc;
 	}
 
 	/* clock setup */
@@ -604,14 +598,43 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 		plat->stmmac_rst = NULL;
 	}
 
-	return plat;
+	return 0;
 
 error_hw_init:
 	clk_disable_unprepare(plat->pclk);
 error_pclk_get:
 	clk_disable_unprepare(plat->stmmac_clk);
 
-	return ERR_PTR(-EPROBE_DEFER);
+	return -EPROBE_DEFER;
+}
+
+/**
+ * stmmac_probe_config_dt - probe and setup stmmac platform data by devicetree
+ * @pdev: platform_device structure
+ * @mac: MAC address to use
+ * Description:
+ * this function is to set up plat_stmmacenet_data  private structure
+ * for platform drivers.
+ */
+struct plat_stmmacenet_data *
+stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct plat_stmmacenet_data *plat;
+	int rc;
+
+	plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
+	if (!plat)
+		return ERR_PTR(-ENOMEM);
+
+	rc = stmmac_parse_config_dt(np, plat);
+
+	if (rc) {
+		free(plat);
+		return ERR_PTR(rc);
+	}
+
+	return plat;
 }
 
 /**
@@ -628,6 +651,11 @@ void stmmac_remove_config_dt(struct platform_device *pdev,
 	of_node_put(plat->mdio_node);
 }
 #else
+int stmmac_parse_config_dt(struct device_node *np,
+				struct plat_stmmacenet_data *plat)
+{
+	return -EINVAL;
+}
 struct plat_stmmacenet_data *
 stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 {
@@ -639,6 +667,7 @@ void stmmac_remove_config_dt(struct platform_device *pdev,
 {
 }
 #endif /* CONFIG_OF */
+EXPORT_SYMBOL_GPL(stmmac_parse_config_dt);
 EXPORT_SYMBOL_GPL(stmmac_probe_config_dt);
 EXPORT_SYMBOL_GPL(stmmac_remove_config_dt);
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
index 3a4663b7b460..0e4aec1f502a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
@@ -11,6 +11,9 @@
 
 #include "stmmac.h"
 
+int stmmac_parse_config_dt(struct device_node *np,
+				struct plat_stmmacenet_data *plat);
+
 struct plat_stmmacenet_data *
 stmmac_probe_config_dt(struct platform_device *pdev, const char **mac);
 void stmmac_remove_config_dt(struct platform_device *pdev,
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/5] net: stmmac: pci: Add Loongson GMAC
  2019-10-30 13:53 [PATCH 0/5] PCI Devices for Loongson PCH Jiaxun Yang
  2019-10-30 13:53 ` [PATCH 1/5] PCI: pci_ids: Add Loongson IDs Jiaxun Yang
  2019-10-30 13:53 ` [PATCH 2/5] net: stmmac: Split devicetree parse Jiaxun Yang
@ 2019-10-30 13:53 ` Jiaxun Yang
  2019-10-30 20:36   ` Bjorn Helgaas
  2019-10-30 13:53 ` [PATCH 4/5] dt-bindings: net: document loongson.pci-gmac Jiaxun Yang
  2019-10-30 13:53 ` [PATCH 5/5] libata/ahci: Apply non-standard BAR fix for Loongson Jiaxun Yang
  4 siblings, 1 reply; 14+ messages in thread
From: Jiaxun Yang @ 2019-10-30 13:53 UTC (permalink / raw)
  To: linux-mips
  Cc: davem, robh+dt, mark.rutland, axboe, peppe.cavallaro,
	alexandre.torgue, joabreu, bhelgaas, netdev, devicetree,
	linux-ide, linux-pci, Jiaxun Yang

This device will be setup by parsing DeviceTree node
of pci device.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 .../net/ethernet/stmicro/stmmac/stmmac_pci.c  | 52 ++++++++++++++++++-
 1 file changed, 50 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 292045f4581f..640a2a5b8d41 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -12,8 +12,11 @@
 #include <linux/clk-provider.h>
 #include <linux/pci.h>
 #include <linux/dmi.h>
+#include <linux/of.h>
+#include <linux/of_irq.h>
 
 #include "stmmac.h"
+#include "stmmac_platform.h"
 
 /*
  * This struct is used to associate PCI Function of MAC controller on a board,
@@ -33,6 +36,7 @@ struct stmmac_pci_dmi_data {
 
 struct stmmac_pci_info {
 	int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);
+	bool of_irq;
 };
 
 static int stmmac_pci_find_phy_addr(struct pci_dev *pdev,
@@ -444,6 +448,30 @@ static const struct stmmac_pci_info snps_gmac5_pci_info = {
 	.setup = snps_gmac5_default_data,
 };
 
+static int loongson_pci_of_setup(struct pci_dev *pdev,
+			struct plat_stmmacenet_data *plat)
+{
+	struct device_node  *np;
+	np = pci_device_to_OF_node(pdev);
+
+	if(!np) {
+		dev_err(&pdev->dev, "Unable to get OF node\n");
+		return -ENODEV;
+	}
+
+	if(!of_device_is_compatible(np, "loongson,pci-gmac")) {
+		dev_err(&pdev->dev, "Device compatible mismatch\n");
+		return -ENODEV;
+	}
+
+	return  stmmac_parse_config_dt(np, plat);
+}
+
+static const struct stmmac_pci_info loongson_of_pci_info = {
+	.setup = loongson_pci_of_setup,
+	.of_irq = true,
+};
+
 /**
  * stmmac_pci_probe
  *
@@ -508,8 +536,27 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
 
 	memset(&res, 0, sizeof(res));
 	res.addr = pcim_iomap_table(pdev)[i];
-	res.wol_irq = pdev->irq;
-	res.irq = pdev->irq;
+
+	if(info->of_irq) {
+		struct device_node  *np;	
+		np = pci_device_to_OF_node(pdev);
+
+		res.irq = of_irq_get_byname(np, "macirq");
+		if (res.irq < 0)
+			return res.irq;
+		res.wol_irq = of_irq_get_byname(np, "eth_wake_irq");
+		if (res.wol_irq < 0) {
+		if (res.wol_irq == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+		res.wol_irq = res.irq;
+		}
+		res.lpi_irq = of_irq_get_byname(np, "eth_lpi");
+		if (res.lpi_irq == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+	} else {
+		res.wol_irq = pdev->irq;
+		res.irq = pdev->irq;
+	}
 
 	return stmmac_dvr_probe(&pdev->dev, plat, &res);
 }
@@ -602,6 +649,7 @@ static const struct pci_device_id stmmac_id_table[] = {
 	STMMAC_DEVICE(INTEL, STMMAC_EHL_SGMII1G_ID, ehl_sgmii1g_pci_info),
 	STMMAC_DEVICE(INTEL, STMMAC_TGL_SGMII1G_ID, tgl_sgmii1g_pci_info),
 	STMMAC_DEVICE(SYNOPSYS, STMMAC_GMAC5_ID, snps_gmac5_pci_info),
+	STMMAC_DEVICE(LOONGSON,  PCI_DEVICE_ID_LOONGSON_GMAC, loongson_of_pci_info),
 	{}
 };
 
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/5] dt-bindings: net: document loongson.pci-gmac
  2019-10-30 13:53 [PATCH 0/5] PCI Devices for Loongson PCH Jiaxun Yang
                   ` (2 preceding siblings ...)
  2019-10-30 13:53 ` [PATCH 3/5] net: stmmac: pci: Add Loongson GMAC Jiaxun Yang
@ 2019-10-30 13:53 ` Jiaxun Yang
  2019-10-31  8:35   ` Simon Horman
  2019-10-30 13:53 ` [PATCH 5/5] libata/ahci: Apply non-standard BAR fix for Loongson Jiaxun Yang
  4 siblings, 1 reply; 14+ messages in thread
From: Jiaxun Yang @ 2019-10-30 13:53 UTC (permalink / raw)
  To: linux-mips
  Cc: davem, robh+dt, mark.rutland, axboe, peppe.cavallaro,
	alexandre.torgue, joabreu, bhelgaas, netdev, devicetree,
	linux-ide, linux-pci, Jiaxun Yang

This binding will provide extra information for PCI enabled
device.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 .../net/wireless/loongson,pci-gmac.yaml       | 71 +++++++++++++++++++
 1 file changed, 71 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/loongson,pci-gmac.yaml

diff --git a/Documentation/devicetree/bindings/net/wireless/loongson,pci-gmac.yaml b/Documentation/devicetree/bindings/net/wireless/loongson,pci-gmac.yaml
new file mode 100644
index 000000000000..5f764bd46735
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/wireless/loongson,pci-gmac.yaml
@@ -0,0 +1,71 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/allwinner,sun7i-a20-gmac.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson PCI GMAC Device Tree Bindings
+
+allOf:
+  - $ref: "snps,dwmac.yaml#"
+
+maintainers:
+  - Jiaxun Yang <jiaxun.yang@flygoat.com>
+
+properties:
+  compatible:
+    const: loongson,pci-gmac
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    minItems: 1
+    maxItems: 3
+    items:
+      - description: Combined signal for various interrupt events
+      - description: The interrupt to manage the remote wake-up packet detection
+      - description: The interrupt that occurs when Rx exits the LPI state
+
+  interrupt-names:
+    minItems: 1
+    maxItems: 3
+    items:
+      - const: macirq
+      - const: eth_wake_irq
+      - const: eth_lpi
+
+  clocks:
+    items:
+      - description: GMAC main clock
+
+  clock-names:
+    items:
+      - const: stmmaceth
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-names
+  - clocks
+  - clock-names
+  - phy-mode
+
+examples:
+  - |
+    gmac: ethernet@ {
+        compatible = "loongson,pci-irq";
+        reg = <0x00001800 0 0 0 0>;
+        interrupts = <12>, <13>;
+        interrupt-names = "macirq", "eth_lpi";
+        clocks =  <&clk_pch_gmac>;
+        clock-names = "stmmaceth";
+        phy-mode = "rgmii";
+    };
+
+# FIXME: We should set it, but it would report all the generic
+# properties as additional properties.
+# additionalProperties: false
+
+...
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/5] libata/ahci: Apply non-standard BAR fix for Loongson
  2019-10-30 13:53 [PATCH 0/5] PCI Devices for Loongson PCH Jiaxun Yang
                   ` (3 preceding siblings ...)
  2019-10-30 13:53 ` [PATCH 4/5] dt-bindings: net: document loongson.pci-gmac Jiaxun Yang
@ 2019-10-30 13:53 ` Jiaxun Yang
  2019-10-31 10:39   ` John Garry
  4 siblings, 1 reply; 14+ messages in thread
From: Jiaxun Yang @ 2019-10-30 13:53 UTC (permalink / raw)
  To: linux-mips
  Cc: davem, robh+dt, mark.rutland, axboe, peppe.cavallaro,
	alexandre.torgue, joabreu, bhelgaas, netdev, devicetree,
	linux-ide, linux-pci, Jiaxun Yang

Loongson is using BAR0 as AHCI registers BAR.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 drivers/ata/ahci.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index dd92faf197d5..db3d7b94ad53 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -42,6 +42,7 @@ enum {
 	AHCI_PCI_BAR_CAVIUM	= 0,
 	AHCI_PCI_BAR_ENMOTUS	= 2,
 	AHCI_PCI_BAR_CAVIUM_GEN5	= 4,
+	AHCI_PCI_BAR_LOONGSON	= 0,
 	AHCI_PCI_BAR_STANDARD	= 5,
 };
 
@@ -575,6 +576,9 @@ static const struct pci_device_id ahci_pci_tbl[] = {
 	/* Enmotus */
 	{ PCI_DEVICE(0x1c44, 0x8000), board_ahci },
 
+	/* Loongson */
+	{ PCI_VDEVICE(LOONGSON, 0x7a08), board_ahci },
+
 	/* Generic, PCI class code for AHCI */
 	{ PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
 	  PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci },
@@ -1663,6 +1667,9 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 			ahci_pci_bar = AHCI_PCI_BAR_CAVIUM;
 		if (pdev->device == 0xa084)
 			ahci_pci_bar = AHCI_PCI_BAR_CAVIUM_GEN5;
+	} else if (pdev->vendor == PCI_VENDOR_ID_LOONGSON) {
+		if (pdev->device == PCI_DEVICE_ID_LOONGSON_AHCI)
+			ahci_pci_bar = AHCI_PCI_BAR_LOONGSON;
 	}
 
 	/* acquire resources */
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/5] net: stmmac: pci: Add Loongson GMAC
  2019-10-30 13:53 ` [PATCH 3/5] net: stmmac: pci: Add Loongson GMAC Jiaxun Yang
@ 2019-10-30 20:36   ` Bjorn Helgaas
  0 siblings, 0 replies; 14+ messages in thread
From: Bjorn Helgaas @ 2019-10-30 20:36 UTC (permalink / raw)
  To: Jiaxun Yang
  Cc: linux-mips, davem, robh+dt, mark.rutland, axboe, peppe.cavallaro,
	alexandre.torgue, joabreu, netdev, devicetree, linux-ide,
	linux-pci

On Wed, Oct 30, 2019 at 09:53:45PM +0800, Jiaxun Yang wrote:
> This device will be setup by parsing DeviceTree node
> of pci device.
> 
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>

> +static int loongson_pci_of_setup(struct pci_dev *pdev,
> +			struct plat_stmmacenet_data *plat)
> +{
> +	struct device_node  *np;
> +	np = pci_device_to_OF_node(pdev);
> +
> +	if(!np) {

Please pay attention to the existing coding style in the file and
follow it.  In this and other cases below, add a space in "if (".

> +	if(!of_device_is_compatible(np, "loongson,pci-gmac")) {

> +	return  stmmac_parse_config_dt(np, plat);

Remove the double space here.

> +	if(info->of_irq) {

> +	STMMAC_DEVICE(LOONGSON,  PCI_DEVICE_ID_LOONGSON_GMAC, loongson_of_pci_info),

And here.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/5] PCI: pci_ids: Add Loongson IDs
  2019-10-30 13:53 ` [PATCH 1/5] PCI: pci_ids: Add Loongson IDs Jiaxun Yang
@ 2019-10-30 20:40   ` Bjorn Helgaas
  0 siblings, 0 replies; 14+ messages in thread
From: Bjorn Helgaas @ 2019-10-30 20:40 UTC (permalink / raw)
  To: Jiaxun Yang
  Cc: linux-mips, davem, robh+dt, mark.rutland, axboe, peppe.cavallaro,
	alexandre.torgue, joabreu, netdev, devicetree, linux-ide,
	linux-pci

Please pay attention to the "git log --oneline
include/linux/pci_ids.h" output and make yours match, e.g.,

  PCI: Add Loongson Vendor and Device IDs

On Wed, Oct 30, 2019 at 09:53:43PM +0800, Jiaxun Yang wrote:
> Add Loongson device IDs that will be used by drivers later.
> 
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>

With that change,

Acked-by: Bjorn Helgaas <bhelgaas@google.com>

> ---
>  include/linux/pci_ids.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
> index 21a572469a4e..75f3336116eb 100644
> --- a/include/linux/pci_ids.h
> +++ b/include/linux/pci_ids.h
> @@ -148,6 +148,10 @@
>  
>  /* Vendors and devices.  Sort key: vendor first, device next. */
>  
> +#define PCI_VENDOR_ID_LOONGSON		0x0014
> +#define PCI_DEVICE_ID_LOONGSON_GMAC	0x7a03
> +#define PCI_DEVICE_ID_LOONGSON_AHCI	0x7a08
> +
>  #define PCI_VENDOR_ID_TTTECH		0x0357
>  #define PCI_DEVICE_ID_TTTECH_MC322	0x000a
>  
> -- 
> 2.23.0
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/5] dt-bindings: net: document loongson.pci-gmac
  2019-10-30 13:53 ` [PATCH 4/5] dt-bindings: net: document loongson.pci-gmac Jiaxun Yang
@ 2019-10-31  8:35   ` Simon Horman
  2019-10-31 10:57     ` Jiaxun Yang
  0 siblings, 1 reply; 14+ messages in thread
From: Simon Horman @ 2019-10-31  8:35 UTC (permalink / raw)
  To: Jiaxun Yang
  Cc: linux-mips, davem, robh+dt, mark.rutland, axboe, peppe.cavallaro,
	alexandre.torgue, joabreu, bhelgaas, netdev, devicetree,
	linux-ide, linux-pci

Hi Jiaxun,

thanks for your patch.

On Wed, Oct 30, 2019 at 09:53:46PM +0800, Jiaxun Yang wrote:
> This binding will provide extra information for PCI enabled
> device.
> 
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>

Please verify the bindings using dtbs_check as described in
Documentation/devicetree/writing-schema.rst

> ---
>  .../net/wireless/loongson,pci-gmac.yaml       | 71 +++++++++++++++++++
>  1 file changed, 71 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/wireless/loongson,pci-gmac.yaml
> 
> diff --git a/Documentation/devicetree/bindings/net/wireless/loongson,pci-gmac.yaml b/Documentation/devicetree/bindings/net/wireless/loongson,pci-gmac.yaml
> new file mode 100644
> index 000000000000..5f764bd46735
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/wireless/loongson,pci-gmac.yaml
> @@ -0,0 +1,71 @@
> +# SPDX-License-Identifier: GPL-2.0
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/net/allwinner,sun7i-a20-gmac.yaml#

The id does not match the filename of the schema.

i.e. the above should be:

	$id: http://devicetree.org/schemas/net/wireless/loongson,pci-gmac.yaml#

> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Loongson PCI GMAC Device Tree Bindings
> +
> +allOf:
> +  - $ref: "snps,dwmac.yaml#"

snps,dwmac.yaml# is in the parent directory relative to loongson,pci-gmac.yaml.
So I think the above needs to be:

	$ref: "../snps,dwmac.yaml#"

> +
> +maintainers:
> +  - Jiaxun Yang <jiaxun.yang@flygoat.com>
> +
> +properties:
> +  compatible:
> +    const: loongson,pci-gmac
> +
> +  reg:
> +    maxItems: 1
> +
> +  interrupts:
> +    minItems: 1
> +    maxItems: 3
> +    items:
> +      - description: Combined signal for various interrupt events
> +      - description: The interrupt to manage the remote wake-up packet detection
> +      - description: The interrupt that occurs when Rx exits the LPI state
> +
> +  interrupt-names:
> +    minItems: 1
> +    maxItems: 3
> +    items:
> +      - const: macirq
> +      - const: eth_wake_irq
> +      - const: eth_lpi
> +
> +  clocks:
> +    items:
> +      - description: GMAC main clock
> +
> +  clock-names:
> +    items:
> +      - const: stmmaceth
> +
> +required:
> +  - compatible
> +  - reg
> +  - interrupts
> +  - interrupt-names
> +  - clocks
> +  - clock-names
> +  - phy-mode
> +
> +examples:
> +  - |
> +    gmac: ethernet@ {

I would have expected a bus address here, f.e.:

	gmac: ethernet@0x00001800

> +        compatible = "loongson,pci-irq";
> +        reg = <0x00001800 0 0 0 0>;

I think there is one to many cell in the above, perhaps it should be.

	reg = <0x00001800 0 0 0>;

Also, I would expect the registers to be wider than 0, i.e. no registers.

`
> +        interrupts = <12>, <13>;
> +        interrupt-names = "macirq", "eth_lpi";
> +        clocks =  <&clk_pch_gmac>;
> +        clock-names = "stmmaceth";
> +        phy-mode = "rgmii";
> +    };
> +
> +# FIXME: We should set it, but it would report all the generic
> +# properties as additional properties.
> +# additionalProperties: false
> +
> +...
> -- 
> 2.23.0
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] libata/ahci: Apply non-standard BAR fix for Loongson
  2019-10-30 13:53 ` [PATCH 5/5] libata/ahci: Apply non-standard BAR fix for Loongson Jiaxun Yang
@ 2019-10-31 10:39   ` John Garry
  0 siblings, 0 replies; 14+ messages in thread
From: John Garry @ 2019-10-31 10:39 UTC (permalink / raw)
  To: Jiaxun Yang, linux-mips
  Cc: davem, robh+dt, mark.rutland, axboe, peppe.cavallaro,
	alexandre.torgue, joabreu, bhelgaas, netdev, devicetree,
	linux-ide, linux-pci

On 30/10/2019 13:53, Jiaxun Yang wrote:
> Loongson is using BAR0 as AHCI registers BAR.
> 
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
>   drivers/ata/ahci.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
> index dd92faf197d5..db3d7b94ad53 100644
> --- a/drivers/ata/ahci.c
> +++ b/drivers/ata/ahci.c
> @@ -42,6 +42,7 @@ enum {
>   	AHCI_PCI_BAR_CAVIUM	= 0,
>   	AHCI_PCI_BAR_ENMOTUS	= 2,
>   	AHCI_PCI_BAR_CAVIUM_GEN5	= 4,
> +	AHCI_PCI_BAR_LOONGSON	= 0,

nit: these seem to be ordered by ascending BAR index

>   	AHCI_PCI_BAR_STANDARD	= 5,
>   };
>   
> @@ -575,6 +576,9 @@ static const struct pci_device_id ahci_pci_tbl[] = {
>   	/* Enmotus */
>   	{ PCI_DEVICE(0x1c44, 0x8000), board_ahci },
>   
> +	/* Loongson */
> +	{ PCI_VDEVICE(LOONGSON, 0x7a08), board_ahci },
> +
>   	/* Generic, PCI class code for AHCI */
>   	{ PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
>   	  PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci },
> @@ -1663,6 +1667,9 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
>   			ahci_pci_bar = AHCI_PCI_BAR_CAVIUM;
>   		if (pdev->device == 0xa084)
>   			ahci_pci_bar = AHCI_PCI_BAR_CAVIUM_GEN5;
> +	} else if (pdev->vendor == PCI_VENDOR_ID_LOONGSON) {
> +		if (pdev->device == PCI_DEVICE_ID_LOONGSON_AHCI)
> +			ahci_pci_bar = AHCI_PCI_BAR_LOONGSON;
>   	}
>   
>   	/* acquire resources */
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/5] dt-bindings: net: document loongson.pci-gmac
  2019-10-31  8:35   ` Simon Horman
@ 2019-10-31 10:57     ` Jiaxun Yang
  2019-10-31 20:42       ` Simon Horman
  0 siblings, 1 reply; 14+ messages in thread
From: Jiaxun Yang @ 2019-10-31 10:57 UTC (permalink / raw)
  To: Simon Horman
  Cc: linux-mips, davem, robh+dt, mark.rutland, axboe, peppe.cavallaro,
	alexandre.torgue, joabreu, bhelgaas, netdev, devicetree,
	linux-ide, linux-pci


在 2019/10/31 下午4:35, Simon Horman 写道:
> Hi Jiaxun,
>
> thanks for your patch.
>
> On Wed, Oct 30, 2019 at 09:53:46PM +0800, Jiaxun Yang wrote:
>> This binding will provide extra information for PCI enabled
>> device.
>>
>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Please verify the bindings using dtbs_check as described in
> Documentation/devicetree/writing-schema.rst
>
>> ---
>>   .../net/wireless/loongson,pci-gmac.yaml       | 71 +++++++++++++++++++
>>   1 file changed, 71 insertions(+)
>>   create mode 100644 Documentation/devicetree/bindings/net/wireless/loongson,pci-gmac.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/net/wireless/loongson,pci-gmac.yaml b/Documentation/devicetree/bindings/net/wireless/loongson,pci-gmac.yaml
>> new file mode 100644
>> index 000000000000..5f764bd46735
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/net/wireless/loongson,pci-gmac.yaml
>> @@ -0,0 +1,71 @@
>> +# SPDX-License-Identifier: GPL-2.0
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/net/allwinner,sun7i-a20-gmac.yaml#
> The id does not match the filename of the schema.
>
> i.e. the above should be:
>
> 	$id: http://devicetree.org/schemas/net/wireless/loongson,pci-gmac.yaml#
>
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Loongson PCI GMAC Device Tree Bindings
>> +
>> +allOf:
>> +  - $ref: "snps,dwmac.yaml#"
> snps,dwmac.yaml# is in the parent directory relative to loongson,pci-gmac.yaml.
> So I think the above needs to be:
>
> 	$ref: "../snps,dwmac.yaml#"
>
>> +
>> +maintainers:
>> +  - Jiaxun Yang <jiaxun.yang@flygoat.com>
>> +
>> +properties:
>> +  compatible:
>> +    const: loongson,pci-gmac
>> +
>> +  reg:
>> +    maxItems: 1
>> +
>> +  interrupts:
>> +    minItems: 1
>> +    maxItems: 3
>> +    items:
>> +      - description: Combined signal for various interrupt events
>> +      - description: The interrupt to manage the remote wake-up packet detection
>> +      - description: The interrupt that occurs when Rx exits the LPI state
>> +
>> +  interrupt-names:
>> +    minItems: 1
>> +    maxItems: 3
>> +    items:
>> +      - const: macirq
>> +      - const: eth_wake_irq
>> +      - const: eth_lpi
>> +
>> +  clocks:
>> +    items:
>> +      - description: GMAC main clock
>> +
>> +  clock-names:
>> +    items:
>> +      - const: stmmaceth
>> +
>> +required:
>> +  - compatible
>> +  - reg
>> +  - interrupts
>> +  - interrupt-names
>> +  - clocks
>> +  - clock-names
>> +  - phy-mode
>> +
>> +examples:
>> +  - |
>> +    gmac: ethernet@ {
> I would have expected a bus address here, f.e.:
>
> 	gmac: ethernet@0x00001800
>
>> +        compatible = "loongson,pci-irq";
>> +        reg = <0x00001800 0 0 0 0>;
> I think there is one to many cell in the above, perhaps it should be.
>
> 	reg = <0x00001800 0 0 0>;
>
> Also, I would expect the registers to be wider than 0, i.e. no registers.

Hi Simon,

Thanks for your suggestions above, will fix in v1.

Here, the reg domain is a standard 5-cell representing a PCI device,

See: Documentation/devicetree/bindings/pci/pci.txt and IEEE Std 
1275-1994,<https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/pci/pci.txt>

Should I add some description?

Jiaxun


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/5] dt-bindings: net: document loongson.pci-gmac
  2019-10-31 10:57     ` Jiaxun Yang
@ 2019-10-31 20:42       ` Simon Horman
  0 siblings, 0 replies; 14+ messages in thread
From: Simon Horman @ 2019-10-31 20:42 UTC (permalink / raw)
  To: Jiaxun Yang
  Cc: linux-mips, davem, robh+dt, mark.rutland, axboe, peppe.cavallaro,
	alexandre.torgue, joabreu, bhelgaas, netdev, devicetree,
	linux-ide, linux-pci

On Thu, Oct 31, 2019 at 06:57:16PM +0800, Jiaxun Yang wrote:
> 
> 在 2019/10/31 下午4:35, Simon Horman 写道:
> > Hi Jiaxun,
> > 
> > thanks for your patch.
> > 
> > On Wed, Oct 30, 2019 at 09:53:46PM +0800, Jiaxun Yang wrote:
> > > This binding will provide extra information for PCI enabled
> > > device.
> > > 
> > > Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> > Please verify the bindings using dtbs_check as described in
> > Documentation/devicetree/writing-schema.rst
> > 
> > > ---
> > >   .../net/wireless/loongson,pci-gmac.yaml       | 71 +++++++++++++++++++
> > >   1 file changed, 71 insertions(+)
> > >   create mode 100644 Documentation/devicetree/bindings/net/wireless/loongson,pci-gmac.yaml
> > > 
> > > diff --git a/Documentation/devicetree/bindings/net/wireless/loongson,pci-gmac.yaml b/Documentation/devicetree/bindings/net/wireless/loongson,pci-gmac.yaml
> > > new file mode 100644
> > > index 000000000000..5f764bd46735
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/net/wireless/loongson,pci-gmac.yaml
> > > @@ -0,0 +1,71 @@
> > > +# SPDX-License-Identifier: GPL-2.0
> > > +%YAML 1.2
> > > +---
> > > +$id: http://devicetree.org/schemas/net/allwinner,sun7i-a20-gmac.yaml#
> > The id does not match the filename of the schema.
> > 
> > i.e. the above should be:
> > 
> > 	$id: http://devicetree.org/schemas/net/wireless/loongson,pci-gmac.yaml#
> > 
> > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > +
> > > +title: Loongson PCI GMAC Device Tree Bindings
> > > +
> > > +allOf:
> > > +  - $ref: "snps,dwmac.yaml#"
> > snps,dwmac.yaml# is in the parent directory relative to loongson,pci-gmac.yaml.
> > So I think the above needs to be:
> > 
> > 	$ref: "../snps,dwmac.yaml#"
> > 
> > > +
> > > +maintainers:
> > > +  - Jiaxun Yang <jiaxun.yang@flygoat.com>
> > > +
> > > +properties:
> > > +  compatible:
> > > +    const: loongson,pci-gmac
> > > +
> > > +  reg:
> > > +    maxItems: 1
> > > +
> > > +  interrupts:
> > > +    minItems: 1
> > > +    maxItems: 3
> > > +    items:
> > > +      - description: Combined signal for various interrupt events
> > > +      - description: The interrupt to manage the remote wake-up packet detection
> > > +      - description: The interrupt that occurs when Rx exits the LPI state
> > > +
> > > +  interrupt-names:
> > > +    minItems: 1
> > > +    maxItems: 3
> > > +    items:
> > > +      - const: macirq
> > > +      - const: eth_wake_irq
> > > +      - const: eth_lpi
> > > +
> > > +  clocks:
> > > +    items:
> > > +      - description: GMAC main clock
> > > +
> > > +  clock-names:
> > > +    items:
> > > +      - const: stmmaceth
> > > +
> > > +required:
> > > +  - compatible
> > > +  - reg
> > > +  - interrupts
> > > +  - interrupt-names
> > > +  - clocks
> > > +  - clock-names
> > > +  - phy-mode
> > > +
> > > +examples:
> > > +  - |
> > > +    gmac: ethernet@ {
> > I would have expected a bus address here, f.e.:
> > 
> > 	gmac: ethernet@0x00001800
> > 
> > > +        compatible = "loongson,pci-irq";
> > > +        reg = <0x00001800 0 0 0 0>;
> > I think there is one to many cell in the above, perhaps it should be.
> > 
> > 	reg = <0x00001800 0 0 0>;
> > 
> > Also, I would expect the registers to be wider than 0, i.e. no registers.
> 
> Hi Simon,
> 
> Thanks for your suggestions above, will fix in v1.
> 
> Here, the reg domain is a standard 5-cell representing a PCI device,
> 
> See: Documentation/devicetree/bindings/pci/pci.txt and IEEE Std 1275-1994,<https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/pci/pci.txt>
> 
> Should I add some description?

Thanks, sorry for missing that.
As that is the case I think you need something like the following
as an example that compiles.

examples:
  - |
    pcie@0 {
        reg = <0 0 0 0>;
        #size-cells = <2>;
        #address-cells = <3>;
        ranges = <0 0 0 0 0 0>;
        device_type = "pci";

        gmac: ethernet@1800 {
            compatible = "loongson,pci-irq";
            reg = <0x00001800 0 0 0 0>;
            interrupts = <12>, <13>;
            interrupt-names = "macirq", "eth_lpi";
            clocks =  <&clk_pch_gmac>;
            clock-names = "stmmaceth";
            phy-mode = "rgmii";
        };
    };






^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/5] net: stmmac: Split devicetree parse
  2019-10-30 13:53 ` [PATCH 2/5] net: stmmac: Split devicetree parse Jiaxun Yang
@ 2019-11-01 12:18   ` Andrew Murray
  2019-11-01 22:43   ` kbuild test robot
  1 sibling, 0 replies; 14+ messages in thread
From: Andrew Murray @ 2019-11-01 12:18 UTC (permalink / raw)
  To: Jiaxun Yang
  Cc: linux-mips, davem, robh+dt, mark.rutland, axboe, peppe.cavallaro,
	alexandre.torgue, joabreu, bhelgaas, netdev, devicetree,
	linux-ide, linux-pci

On Wed, Oct 30, 2019 at 09:53:44PM +0800, Jiaxun Yang wrote:
> PCI based devices can share devicetree info parse with platform
> device based devices after split dt parse frpm dt probe.

s/frpm/from/

> 
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
>  .../ethernet/stmicro/stmmac/stmmac_platform.c | 63 ++++++++++++++-----
>  .../ethernet/stmicro/stmmac/stmmac_platform.h |  3 +
>  2 files changed, 49 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> index 170c3a052b14..7e29bc76b7c3 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> @@ -385,25 +385,19 @@ static int stmmac_of_get_mac_mode(struct device_node *np)
>  }
>  
>  /**
> - * stmmac_probe_config_dt - parse device-tree driver parameters
> - * @pdev: platform_device structure
> - * @mac: MAC address to use
> + * stmmac_parse_config_dt - parse device-tree driver parameters
> + * @np: device_mode structure
> + * @plat: plat_stmmacenet_data structure
>   * Description:
>   * this function is to read the driver parameters from device-tree and
>   * set some private fields that will be used by the main at runtime.
>   */
> -struct plat_stmmacenet_data *
> -stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
> +int stmmac_parse_config_dt(struct device_node *np,
> +				struct plat_stmmacenet_data *plat)
>  {
> -	struct device_node *np = pdev->dev.of_node;
> -	struct plat_stmmacenet_data *plat;
>  	struct stmmac_dma_cfg *dma_cfg;
>  	int rc;
>  
> -	plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
> -	if (!plat)
> -		return ERR_PTR(-ENOMEM);
> -
>  	*mac = of_get_mac_address(np);
>  	if (IS_ERR(*mac)) {
>  		if (PTR_ERR(*mac) == -EPROBE_DEFER)
> @@ -414,7 +408,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
>  
>  	plat->phy_interface = of_get_phy_mode(np);
>  	if (plat->phy_interface < 0)
> -		return ERR_PTR(plat->phy_interface);
> +		return plat->phy_interface;
>  
>  	plat->interface = stmmac_of_get_mac_mode(np);
>  	if (plat->interface < 0)
> @@ -453,7 +447,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
>  	/* To Configure PHY by using all device-tree supported properties */
>  	rc = stmmac_dt_phy(plat, np, &pdev->dev);
>  	if (rc)
> -		return ERR_PTR(rc);
> +		return rc;
>  
>  	of_property_read_u32(np, "tx-fifo-depth", &plat->tx_fifo_size);
>  
> @@ -531,7 +525,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
>  			       GFP_KERNEL);
>  	if (!dma_cfg) {
>  		stmmac_remove_config_dt(pdev, plat);
> -		return ERR_PTR(-ENOMEM);
> +		return -ENOMEM;
>  	}
>  	plat->dma_cfg = dma_cfg;
>  
> @@ -560,7 +554,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
>  	rc = stmmac_mtl_setup(pdev, plat);
>  	if (rc) {
>  		stmmac_remove_config_dt(pdev, plat);
> -		return ERR_PTR(rc);
> +		return rc;
>  	}
>  
>  	/* clock setup */
> @@ -604,14 +598,43 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
>  		plat->stmmac_rst = NULL;
>  	}
>  
> -	return plat;
> +	return 0;
>  
>  error_hw_init:
>  	clk_disable_unprepare(plat->pclk);
>  error_pclk_get:
>  	clk_disable_unprepare(plat->stmmac_clk);
>  
> -	return ERR_PTR(-EPROBE_DEFER);
> +	return -EPROBE_DEFER;
> +}
> +
> +/**
> + * stmmac_probe_config_dt - probe and setup stmmac platform data by devicetree
> + * @pdev: platform_device structure
> + * @mac: MAC address to use
> + * Description:
> + * this function is to set up plat_stmmacenet_data  private structure
> + * for platform drivers.
> + */
> +struct plat_stmmacenet_data *
> +stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
> +{
> +	struct device_node *np = pdev->dev.of_node;
> +	struct plat_stmmacenet_data *plat;
> +	int rc;
> +
> +	plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
> +	if (!plat)
> +		return ERR_PTR(-ENOMEM);
> +
> +	rc = stmmac_parse_config_dt(np, plat);
> +
> +	if (rc) {
> +		free(plat);

Given the devm_kzalloc - is the free really needed here?

Thanks,

Andrew Murray

> +		return ERR_PTR(rc);
> +	}
> +
> +	return plat;
>  }
>  
>  /**
> @@ -628,6 +651,11 @@ void stmmac_remove_config_dt(struct platform_device *pdev,
>  	of_node_put(plat->mdio_node);
>  }
>  #else
> +int stmmac_parse_config_dt(struct device_node *np,
> +				struct plat_stmmacenet_data *plat)
> +{
> +	return -EINVAL;
> +}
>  struct plat_stmmacenet_data *
>  stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
>  {
> @@ -639,6 +667,7 @@ void stmmac_remove_config_dt(struct platform_device *pdev,
>  {
>  }
>  #endif /* CONFIG_OF */
> +EXPORT_SYMBOL_GPL(stmmac_parse_config_dt);
>  EXPORT_SYMBOL_GPL(stmmac_probe_config_dt);
>  EXPORT_SYMBOL_GPL(stmmac_remove_config_dt);
>  
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
> index 3a4663b7b460..0e4aec1f502a 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
> @@ -11,6 +11,9 @@
>  
>  #include "stmmac.h"
>  
> +int stmmac_parse_config_dt(struct device_node *np,
> +				struct plat_stmmacenet_data *plat);
> +
>  struct plat_stmmacenet_data *
>  stmmac_probe_config_dt(struct platform_device *pdev, const char **mac);
>  void stmmac_remove_config_dt(struct platform_device *pdev,
> -- 
> 2.23.0
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/5] net: stmmac: Split devicetree parse
  2019-10-30 13:53 ` [PATCH 2/5] net: stmmac: Split devicetree parse Jiaxun Yang
  2019-11-01 12:18   ` Andrew Murray
@ 2019-11-01 22:43   ` kbuild test robot
  1 sibling, 0 replies; 14+ messages in thread
From: kbuild test robot @ 2019-11-01 22:43 UTC (permalink / raw)
  To: Jiaxun Yang
  Cc: kbuild-all, linux-mips, davem, robh+dt, mark.rutland, axboe,
	peppe.cavallaro, alexandre.torgue, joabreu, bhelgaas, netdev,
	devicetree, linux-ide, linux-pci, Jiaxun Yang

[-- Attachment #1: Type: text/plain, Size: 3514 bytes --]

Hi Jiaxun,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]
[also build test ERROR on v5.4-rc5 next-20191031]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Jiaxun-Yang/PCI-Devices-for-Loongson-PCH/20191102-045600
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 52340b82cf1a9c8d466b6e36a0881bc44174b969
config: mips-allmodconfig (attached as .config)
compiler: mips-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=mips 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/net//ethernet/stmicro/stmmac/stmmac_platform.c: In function 'stmmac_parse_config_dt':
   drivers/net//ethernet/stmicro/stmmac/stmmac_platform.c:401:3: error: 'mac' undeclared (first use in this function); did you mean 'max'?
     *mac = of_get_mac_address(np);
      ^~~
      max
   drivers/net//ethernet/stmicro/stmmac/stmmac_platform.c:401:3: note: each undeclared identifier is reported only once for each function it appears in
   In file included from include/linux/platform_device.h:13:0,
                    from drivers/net//ethernet/stmicro/stmmac/stmmac_platform.c:11:
   drivers/net//ethernet/stmicro/stmmac/stmmac_platform.c:445:13: error: 'pdev' undeclared (first use in this function); did you mean 'cdev'?
      dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n");
                ^
   include/linux/device.h:1743:12: note: in definition of macro 'dev_warn'
     _dev_warn(dev, dev_fmt(fmt), ##__VA_ARGS__)
               ^~~
   drivers/net//ethernet/stmicro/stmmac/stmmac_platform.c: In function 'stmmac_probe_config_dt':
>> drivers/net//ethernet/stmicro/stmmac/stmmac_platform.c:633:3: error: implicit declaration of function 'free'; did you mean 'kfree'? [-Werror=implicit-function-declaration]
      free(plat);
      ^~~~
      kfree
   cc1: some warnings being treated as errors

vim +633 drivers/net//ethernet/stmicro/stmmac/stmmac_platform.c

   610	
   611	/**
   612	 * stmmac_probe_config_dt - probe and setup stmmac platform data by devicetree
   613	 * @pdev: platform_device structure
   614	 * @mac: MAC address to use
   615	 * Description:
   616	 * this function is to set up plat_stmmacenet_data  private structure
   617	 * for platform drivers.
   618	 */
   619	struct plat_stmmacenet_data *
   620	stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
   621	{
   622		struct device_node *np = pdev->dev.of_node;
   623		struct plat_stmmacenet_data *plat;
   624		int rc;
   625	
   626		plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
   627		if (!plat)
   628			return ERR_PTR(-ENOMEM);
   629	
   630		rc = stmmac_parse_config_dt(np, plat);
   631	
   632		if (rc) {
 > 633			free(plat);
   634			return ERR_PTR(rc);
   635		}
   636	
   637		return plat;
   638	}
   639	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 62104 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-11-01 22:43 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30 13:53 [PATCH 0/5] PCI Devices for Loongson PCH Jiaxun Yang
2019-10-30 13:53 ` [PATCH 1/5] PCI: pci_ids: Add Loongson IDs Jiaxun Yang
2019-10-30 20:40   ` Bjorn Helgaas
2019-10-30 13:53 ` [PATCH 2/5] net: stmmac: Split devicetree parse Jiaxun Yang
2019-11-01 12:18   ` Andrew Murray
2019-11-01 22:43   ` kbuild test robot
2019-10-30 13:53 ` [PATCH 3/5] net: stmmac: pci: Add Loongson GMAC Jiaxun Yang
2019-10-30 20:36   ` Bjorn Helgaas
2019-10-30 13:53 ` [PATCH 4/5] dt-bindings: net: document loongson.pci-gmac Jiaxun Yang
2019-10-31  8:35   ` Simon Horman
2019-10-31 10:57     ` Jiaxun Yang
2019-10-31 20:42       ` Simon Horman
2019-10-30 13:53 ` [PATCH 5/5] libata/ahci: Apply non-standard BAR fix for Loongson Jiaxun Yang
2019-10-31 10:39   ` John Garry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).