linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] stmmac: pci: Refactor DMI probing
@ 2017-05-22 11:12 Jan Kiszka
  2017-05-22 11:12 ` [PATCH 1/3] stmmac: pci: Overcome stmmac_pci_info structure Jan Kiszka
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Jan Kiszka @ 2017-05-22 11:12 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, David Miller
  Cc: netdev, linux-kernel, Andy Shevchenko

Some cleanups of the way we probe DMI platforms in the driver. Reduces
a bit of open-coding and makes the logic easier reusable for any
potential DMI platform != Quark.

Tested on IOT2000 and Galileo Gen2.

Jan

Jan Kiszka (3):
  stmmac: pci: Overcome stmmac_pci_info structure
  stmmac: pci: Make stmmac_pci_find_phy_addr truly generic
  stmmac: pci: Use dmi_system_id table for retrieving PHY addresses

 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 184 ++++++++++++-----------
 1 file changed, 99 insertions(+), 85 deletions(-)

-- 
2.12.0

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

* [PATCH 1/3] stmmac: pci: Overcome stmmac_pci_info structure
  2017-05-22 11:12 [PATCH 0/3] stmmac: pci: Refactor DMI probing Jan Kiszka
@ 2017-05-22 11:12 ` Jan Kiszka
  2017-05-22 17:09   ` Andy Shevchenko
  2017-05-23 13:48   ` kbuild test robot
  2017-05-22 11:12 ` [PATCH 2/3] stmmac: pci: Make stmmac_pci_find_phy_addr truly generic Jan Kiszka
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 13+ messages in thread
From: Jan Kiszka @ 2017-05-22 11:12 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, David Miller
  Cc: netdev, linux-kernel, Andy Shevchenko

First, pass the PCI device reference as function parameter. Then the
setup function knows which stmmac_pci_dmi_data structure to use.
Finally, we are left with a setup function in stmmac_pci_info and can
convert the structure into a function pointer. By converting
stmmac_default_data to that type, we can make a setup function
mandatory, and probing becomes more regular.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 122 +++++++++++------------
 1 file changed, 59 insertions(+), 63 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 22f910795be4..990a61acd70e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -37,18 +37,46 @@ struct stmmac_pci_dmi_data {
 	int phy_addr;
 };
 
-struct stmmac_pci_info {
-	struct pci_dev *pdev;
-	int (*setup)(struct plat_stmmacenet_data *plat,
-		     struct stmmac_pci_info *info);
-	struct stmmac_pci_dmi_data *dmi;
+typedef int (*stmmac_setup)(struct pci_dev *, struct plat_stmmacenet_data *);
+
+static struct stmmac_pci_dmi_data quark_pci_dmi_data[] = {
+	{
+		.name = "Galileo",
+		.func = 6,
+		.phy_addr = 1,
+	},
+	{
+		.name = "GalileoGen2",
+		.func = 6,
+		.phy_addr = 1,
+	},
+	{
+		.name = "SIMATIC IOT2000",
+		.asset_tag = "6ES7647-0AA00-0YA2",
+		.func = 6,
+		.phy_addr = 1,
+	},
+	{
+		.name = "SIMATIC IOT2000",
+		.asset_tag = "6ES7647-0AA00-1YA2",
+		.func = 6,
+		.phy_addr = 1,
+	},
+	{
+		.name = "SIMATIC IOT2000",
+		.asset_tag = "6ES7647-0AA00-1YA2",
+		.func = 7,
+		.phy_addr = 1,
+	},
+	{}
 };
 
-static int stmmac_pci_find_phy_addr(struct stmmac_pci_info *info)
+static int stmmac_pci_find_phy_addr(struct pci_dev *pdev,
+				    struct stmmac_pci_dmi_data *dmi_data)
 {
 	const char *name = dmi_get_system_info(DMI_BOARD_NAME);
 	const char *asset_tag = dmi_get_system_info(DMI_BOARD_ASSET_TAG);
-	unsigned int func = PCI_FUNC(info->pdev->devfn);
+	unsigned int func = PCI_FUNC(pdev->devfn);
 	struct stmmac_pci_dmi_data *dmi;
 
 	/*
@@ -58,7 +86,7 @@ static int stmmac_pci_find_phy_addr(struct stmmac_pci_info *info)
 	if (!name)
 		return 1;
 
-	for (dmi = info->dmi; dmi->name && *dmi->name; dmi++) {
+	for (dmi = dmi_data; dmi->name && *dmi->name; dmi++) {
 		if (!strcmp(dmi->name, name) && dmi->func == func) {
 			/* If asset tag is provided, match on it as well. */
 			if (dmi->asset_tag && strcmp(dmi->asset_tag, asset_tag))
@@ -100,7 +128,8 @@ static void common_default_data(struct plat_stmmacenet_data *plat)
 	plat->rx_queues_cfg[0].pkt_route = 0x0;
 }
 
-static void stmmac_default_data(struct plat_stmmacenet_data *plat)
+static int stmmac_default_setup(struct pci_dev *pdev,
+				struct plat_stmmacenet_data *plat)
 {
 	/* Set common default data first */
 	common_default_data(plat);
@@ -112,12 +141,13 @@ static void stmmac_default_data(struct plat_stmmacenet_data *plat)
 	plat->dma_cfg->pbl = 32;
 	plat->dma_cfg->pblx8 = true;
 	/* TODO: AXI */
+
+	return 0;
 }
 
-static int quark_default_data(struct plat_stmmacenet_data *plat,
-			      struct stmmac_pci_info *info)
+static int quark_default_setup(struct pci_dev *pdev,
+			       struct plat_stmmacenet_data *plat)
 {
-	struct pci_dev *pdev = info->pdev;
 	int ret;
 
 	/* Set common default data first */
@@ -127,7 +157,7 @@ static int quark_default_data(struct plat_stmmacenet_data *plat,
 	 * Refuse to load the driver and register net device if MAC controller
 	 * does not connect to any PHY interface.
 	 */
-	ret = stmmac_pci_find_phy_addr(info);
+	ret = stmmac_pci_find_phy_addr(pdev, quark_pci_dmi_data);
 	if (ret < 0)
 		return ret;
 
@@ -143,43 +173,6 @@ static int quark_default_data(struct plat_stmmacenet_data *plat,
 	return 0;
 }
 
-static struct stmmac_pci_dmi_data quark_pci_dmi_data[] = {
-	{
-		.name = "Galileo",
-		.func = 6,
-		.phy_addr = 1,
-	},
-	{
-		.name = "GalileoGen2",
-		.func = 6,
-		.phy_addr = 1,
-	},
-	{
-		.name = "SIMATIC IOT2000",
-		.asset_tag = "6ES7647-0AA00-0YA2",
-		.func = 6,
-		.phy_addr = 1,
-	},
-	{
-		.name = "SIMATIC IOT2000",
-		.asset_tag = "6ES7647-0AA00-1YA2",
-		.func = 6,
-		.phy_addr = 1,
-	},
-	{
-		.name = "SIMATIC IOT2000",
-		.asset_tag = "6ES7647-0AA00-1YA2",
-		.func = 7,
-		.phy_addr = 1,
-	},
-	{}
-};
-
-static struct stmmac_pci_info quark_pci_info = {
-	.setup = quark_default_data,
-	.dmi = quark_pci_dmi_data,
-};
-
 /**
  * stmmac_pci_probe
  *
@@ -195,7 +188,7 @@ static struct stmmac_pci_info quark_pci_info = {
 static int stmmac_pci_probe(struct pci_dev *pdev,
 			    const struct pci_device_id *id)
 {
-	struct stmmac_pci_info *info = (struct stmmac_pci_info *)id->driver_data;
+	stmmac_setup setup = (stmmac_setup)id->driver_data;
 	struct plat_stmmacenet_data *plat;
 	struct stmmac_resources res;
 	int i;
@@ -236,15 +229,9 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
 
 	pci_set_master(pdev);
 
-	if (info) {
-		info->pdev = pdev;
-		if (info->setup) {
-			ret = info->setup(plat, info);
-			if (ret)
-				return ret;
-		}
-	} else
-		stmmac_default_data(plat);
+	ret = setup(pdev, plat);
+	if (ret)
+		return ret;
 
 	pci_enable_msi(pdev);
 
@@ -275,9 +262,18 @@ static SIMPLE_DEV_PM_OPS(stmmac_pm_ops, stmmac_suspend, stmmac_resume);
 #define STMMAC_DEVICE_ID 0x1108
 
 static const struct pci_device_id stmmac_id_table[] = {
-	{PCI_DEVICE(STMMAC_VENDOR_ID, STMMAC_DEVICE_ID)},
-	{PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_MAC)},
-	{PCI_VDEVICE(INTEL, STMMAC_QUARK_ID), (kernel_ulong_t)&quark_pci_info},
+	{
+		PCI_DEVICE(STMMAC_VENDOR_ID, STMMAC_DEVICE_ID),
+		(kernel_ulong_t)&stmmac_default_setup,
+	},
+	{
+		PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_MAC),
+		(kernel_ulong_t)&stmmac_default_setup,
+	},
+	{
+		PCI_VDEVICE(INTEL, STMMAC_QUARK_ID),
+		(kernel_ulong_t)&quark_default_setup,
+	},
 	{}
 };
 
-- 
2.12.0

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

* [PATCH 2/3] stmmac: pci: Make stmmac_pci_find_phy_addr truly generic
  2017-05-22 11:12 [PATCH 0/3] stmmac: pci: Refactor DMI probing Jan Kiszka
  2017-05-22 11:12 ` [PATCH 1/3] stmmac: pci: Overcome stmmac_pci_info structure Jan Kiszka
@ 2017-05-22 11:12 ` Jan Kiszka
  2017-05-22 11:12 ` [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses Jan Kiszka
  2017-05-22 16:35 ` [PATCH 0/3] stmmac: pci: Refactor DMI probing David Miller
  3 siblings, 0 replies; 13+ messages in thread
From: Jan Kiszka @ 2017-05-22 11:12 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, David Miller
  Cc: netdev, linux-kernel, Andy Shevchenko

Move the special case for the early Galileo firmware into
quark_default_setup. This allows to use stmmac_pci_find_phy_addr for
non-quark cases.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 990a61acd70e..ffa59b76e884 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -79,12 +79,8 @@ static int stmmac_pci_find_phy_addr(struct pci_dev *pdev,
 	unsigned int func = PCI_FUNC(pdev->devfn);
 	struct stmmac_pci_dmi_data *dmi;
 
-	/*
-	 * Galileo boards with old firmware don't support DMI. We always return
-	 * 1 here, so at least first found MAC controller would be probed.
-	 */
 	if (!name)
-		return 1;
+		return -ENODEV;
 
 	for (dmi = dmi_data; dmi->name && *dmi->name; dmi++) {
 		if (!strcmp(dmi->name, name) && dmi->func == func) {
@@ -158,8 +154,17 @@ static int quark_default_setup(struct pci_dev *pdev,
 	 * does not connect to any PHY interface.
 	 */
 	ret = stmmac_pci_find_phy_addr(pdev, quark_pci_dmi_data);
-	if (ret < 0)
-		return ret;
+	if (ret < 0) {
+		/*
+		 * Galileo boards with old firmware don't support DMI. We always
+		 * use 1 here as PHY address, so at least the first found MAC
+		 * controller would be probed.
+		 */
+		if (!dmi_get_system_info(DMI_BOARD_NAME))
+			ret = 1;
+		else
+			return ret;
+	}
 
 	plat->bus_id = PCI_DEVID(pdev->bus->number, pdev->devfn);
 	plat->phy_addr = ret;
-- 
2.12.0

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

* [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses
  2017-05-22 11:12 [PATCH 0/3] stmmac: pci: Refactor DMI probing Jan Kiszka
  2017-05-22 11:12 ` [PATCH 1/3] stmmac: pci: Overcome stmmac_pci_info structure Jan Kiszka
  2017-05-22 11:12 ` [PATCH 2/3] stmmac: pci: Make stmmac_pci_find_phy_addr truly generic Jan Kiszka
@ 2017-05-22 11:12 ` Jan Kiszka
  2017-05-22 11:33   ` Joe Perches
  2017-05-22 16:59   ` Andy Shevchenko
  2017-05-22 16:35 ` [PATCH 0/3] stmmac: pci: Refactor DMI probing David Miller
  3 siblings, 2 replies; 13+ messages in thread
From: Jan Kiszka @ 2017-05-22 11:12 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, David Miller
  Cc: netdev, linux-kernel, Andy Shevchenko

Avoids reimplementation of DMI matching in stmmac_pci_find_phy_addr.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 77 ++++++++++++++----------
 1 file changed, 45 insertions(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index ffa59b76e884..23ef235c6c0d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -31,65 +31,78 @@
  * with PHY.
  */
 struct stmmac_pci_dmi_data {
-	const char *name;
-	const char *asset_tag;
-	unsigned int func;
+	int func;
 	int phy_addr;
 };
 
 typedef int (*stmmac_setup)(struct pci_dev *, struct plat_stmmacenet_data *);
 
-static struct stmmac_pci_dmi_data quark_pci_dmi_data[] = {
+static const struct stmmac_pci_dmi_data galileo_stmmac_dmi_data[] = {
 	{
-		.name = "Galileo",
 		.func = 6,
 		.phy_addr = 1,
 	},
+	{-1, -1},
+};
+
+static const struct stmmac_pci_dmi_data iot2040_stmmac_dmi_data[] = {
 	{
-		.name = "GalileoGen2",
 		.func = 6,
 		.phy_addr = 1,
 	},
 	{
-		.name = "SIMATIC IOT2000",
-		.asset_tag = "6ES7647-0AA00-0YA2",
-		.func = 6,
+		.func = 7,
 		.phy_addr = 1,
 	},
+	{-1, -1},
+};
+
+static const struct dmi_system_id quark_pci_dmi[] = {
 	{
-		.name = "SIMATIC IOT2000",
-		.asset_tag = "6ES7647-0AA00-1YA2",
-		.func = 6,
-		.phy_addr = 1,
+		.matches = {
+			DMI_EXACT_MATCH(DMI_BOARD_NAME, "Galileo"),
+		},
+		.driver_data = (void *)galileo_stmmac_dmi_data,
 	},
 	{
-		.name = "SIMATIC IOT2000",
-		.asset_tag = "6ES7647-0AA00-1YA2",
-		.func = 7,
-		.phy_addr = 1,
+		.matches = {
+			DMI_EXACT_MATCH(DMI_BOARD_NAME, "GalileoGen2"),
+		},
+		.driver_data = (void *)galileo_stmmac_dmi_data,
+	},
+	{
+		.matches = {
+			DMI_EXACT_MATCH(DMI_BOARD_NAME, "SIMATIC IOT2000"),
+			DMI_EXACT_MATCH(DMI_BOARD_ASSET_TAG,
+					"6ES7647-0AA00-0YA2"),
+		},
+		.driver_data = (void *)galileo_stmmac_dmi_data,
+	},
+	{
+		.matches = {
+			DMI_EXACT_MATCH(DMI_BOARD_NAME, "SIMATIC IOT2000"),
+			DMI_EXACT_MATCH(DMI_BOARD_ASSET_TAG,
+					"6ES7647-0AA00-1YA2"),
+		},
+		.driver_data = (void *)iot2040_stmmac_dmi_data,
 	},
 	{}
 };
 
 static int stmmac_pci_find_phy_addr(struct pci_dev *pdev,
-				    struct stmmac_pci_dmi_data *dmi_data)
+				    const struct dmi_system_id *dmi_list)
 {
-	const char *name = dmi_get_system_info(DMI_BOARD_NAME);
-	const char *asset_tag = dmi_get_system_info(DMI_BOARD_ASSET_TAG);
-	unsigned int func = PCI_FUNC(pdev->devfn);
-	struct stmmac_pci_dmi_data *dmi;
+	const struct stmmac_pci_dmi_data *dmi_data;
+	const struct dmi_system_id *dmi_id;
+	int func = PCI_FUNC(pdev->devfn);
 
-	if (!name)
+	dmi_id = dmi_first_match(dmi_list);
+	if (!dmi_id)
 		return -ENODEV;
 
-	for (dmi = dmi_data; dmi->name && *dmi->name; dmi++) {
-		if (!strcmp(dmi->name, name) && dmi->func == func) {
-			/* If asset tag is provided, match on it as well. */
-			if (dmi->asset_tag && strcmp(dmi->asset_tag, asset_tag))
-				continue;
-			return dmi->phy_addr;
-		}
-	}
+	for (dmi_data = dmi_id->driver_data; dmi_data->func >= 0; dmi_data++)
+		if (dmi_data->func == func)
+			return dmi_data->phy_addr;
 
 	return -ENODEV;
 }
@@ -153,7 +166,7 @@ static int quark_default_setup(struct pci_dev *pdev,
 	 * Refuse to load the driver and register net device if MAC controller
 	 * does not connect to any PHY interface.
 	 */
-	ret = stmmac_pci_find_phy_addr(pdev, quark_pci_dmi_data);
+	ret = stmmac_pci_find_phy_addr(pdev, quark_pci_dmi);
 	if (ret < 0) {
 		/*
 		 * Galileo boards with old firmware don't support DMI. We always
-- 
2.12.0

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

* Re: [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses
  2017-05-22 11:12 ` [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses Jan Kiszka
@ 2017-05-22 11:33   ` Joe Perches
  2017-05-22 12:49     ` Jan Kiszka
  2017-05-22 16:59   ` Andy Shevchenko
  1 sibling, 1 reply; 13+ messages in thread
From: Joe Perches @ 2017-05-22 11:33 UTC (permalink / raw)
  To: Jan Kiszka, Giuseppe Cavallaro, Alexandre Torgue, David Miller
  Cc: netdev, linux-kernel, Andy Shevchenko

On Mon, 2017-05-22 at 13:12 +0200, Jan Kiszka wrote:
> Avoids reimplementation of DMI matching in stmmac_pci_find_phy_addr.
[]
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
[]
> @@ -31,65 +31,78 @@
[]
> +static const struct stmmac_pci_dmi_data iot2040_stmmac_dmi_data[] = {
>  	{
> -		.name = "GalileoGen2",
>  		.func = 6,
>  		.phy_addr = 1,
>  	},
>  	{
> -		.name = "SIMATIC IOT2000",
> -		.asset_tag = "6ES7647-0AA00-0YA2",
> -		.func = 6,
> +		.func = 7,

Why change this from 6 to 7?

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

* Re: [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses
  2017-05-22 11:33   ` Joe Perches
@ 2017-05-22 12:49     ` Jan Kiszka
  2017-05-22 13:13       ` Joe Perches
  0 siblings, 1 reply; 13+ messages in thread
From: Jan Kiszka @ 2017-05-22 12:49 UTC (permalink / raw)
  To: Joe Perches, Giuseppe Cavallaro, Alexandre Torgue, David Miller
  Cc: netdev, linux-kernel, Andy Shevchenko

On 2017-05-22 13:33, Joe Perches wrote:
> On Mon, 2017-05-22 at 13:12 +0200, Jan Kiszka wrote:
>> Avoids reimplementation of DMI matching in stmmac_pci_find_phy_addr.
> []
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> []
>> @@ -31,65 +31,78 @@
> []
>> +static const struct stmmac_pci_dmi_data iot2040_stmmac_dmi_data[] = {
>>  	{
>> -		.name = "GalileoGen2",
>>  		.func = 6,
>>  		.phy_addr = 1,
>>  	},
>>  	{
>> -		.name = "SIMATIC IOT2000",
>> -		.asset_tag = "6ES7647-0AA00-0YA2",
>> -		.func = 6,
>> +		.func = 7,
> 
> Why change this from 6 to 7?
> 

The diff is confusing here: If you look at the outcome, we now have
galileo_stmmac_dmi_data with function 6 only (also used for the
IOT2020), and iot2040_stmmac_dmi_data with both function 6 and 7 (both
MACs are wired up).

Jan

-- 
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux

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

* Re: [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses
  2017-05-22 12:49     ` Jan Kiszka
@ 2017-05-22 13:13       ` Joe Perches
  0 siblings, 0 replies; 13+ messages in thread
From: Joe Perches @ 2017-05-22 13:13 UTC (permalink / raw)
  To: Jan Kiszka, Giuseppe Cavallaro, Alexandre Torgue, David Miller
  Cc: netdev, linux-kernel, Andy Shevchenko

On Mon, 2017-05-22 at 14:49 +0200, Jan Kiszka wrote:
> On 2017-05-22 13:33, Joe Perches wrote:
> > On Mon, 2017-05-22 at 13:12 +0200, Jan Kiszka wrote:
> > > Avoids reimplementation of DMI matching in stmmac_pci_find_phy_addr.
> > 
> > []
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> > 
> > []
> > > @@ -31,65 +31,78 @@
> > 
> > []
> > > +static const struct stmmac_pci_dmi_data iot2040_stmmac_dmi_data[] = {
> > >  	{
> > > -		.name = "GalileoGen2",
> > >  		.func = 6,
> > >  		.phy_addr = 1,
> > >  	},
> > >  	{
> > > -		.name = "SIMATIC IOT2000",
> > > -		.asset_tag = "6ES7647-0AA00-0YA2",
> > > -		.func = 6,
> > > +		.func = 7,
> > 
> > Why change this from 6 to 7?
> > 
> 
> The diff is confusing here: If you look at the outcome, we now have
> galileo_stmmac_dmi_data with function 6 only (also used for the
> IOT2020), and iot2040_stmmac_dmi_data with both function 6 and 7 (both
> MACs are wired up).

Right.  Apologies for noise.

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

* Re: [PATCH 0/3] stmmac: pci: Refactor DMI probing
  2017-05-22 11:12 [PATCH 0/3] stmmac: pci: Refactor DMI probing Jan Kiszka
                   ` (2 preceding siblings ...)
  2017-05-22 11:12 ` [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses Jan Kiszka
@ 2017-05-22 16:35 ` David Miller
  2017-05-22 17:06   ` Jan Kiszka
  3 siblings, 1 reply; 13+ messages in thread
From: David Miller @ 2017-05-22 16:35 UTC (permalink / raw)
  To: jan.kiszka
  Cc: peppe.cavallaro, alexandre.torgue, netdev, linux-kernel, andy.shevchenko

From: Jan Kiszka <jan.kiszka@siemens.com>
Date: Mon, 22 May 2017 13:12:06 +0200

> Some cleanups of the way we probe DMI platforms in the driver. Reduces
> a bit of open-coding and makes the logic easier reusable for any
> potential DMI platform != Quark.
> 
> Tested on IOT2000 and Galileo Gen2.

This doesn't compile:

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:285:3: error: initializer element is not computable at load time
   (kernel_ulong_t)&stmmac_default_setup,
   ^
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:285:3: note: (near initialization for ‘stmmac_id_table[0].class’)
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:289:3: error: initializer element is not computable at load time
   (kernel_ulong_t)&stmmac_default_setup,
   ^
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:289:3: note: (near initialization for ‘stmmac_id_table[1].class’)
scripts/Makefile.build:302: recipe for target 'drivers/net/ethernet/stmicro/stmmac/stmmac_pci.o' failed
make[5]: *** [drivers/net/ethernet/stmicro/stmmac/stmmac_pci.o] Error 1

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

* Re: [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses
  2017-05-22 11:12 ` [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses Jan Kiszka
  2017-05-22 11:33   ` Joe Perches
@ 2017-05-22 16:59   ` Andy Shevchenko
  1 sibling, 0 replies; 13+ messages in thread
From: Andy Shevchenko @ 2017-05-22 16:59 UTC (permalink / raw)
  To: Jan Kiszka
  Cc: Giuseppe Cavallaro, Alexandre Torgue, David Miller, netdev, linux-kernel

On Mon, May 22, 2017 at 2:12 PM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
> Avoids reimplementation of DMI matching in stmmac_pci_find_phy_addr.

>  struct stmmac_pci_dmi_data {
> -       const char *name;
> -       const char *asset_tag;
> -       unsigned int func;
> +       int func;
>         int phy_addr;
>  };

Perhaps
  struct stmmac_pci_dmi_data {
     unsigned int func;
     int phy_addr;
  };

struct stmmac_pci_info {
  struct stmmac_pci_dmi_data *data;
  size_t nmaps;
 (*setup)(struct plat_stmmacenet_data *plat, struct stmmac_pci_info *info);
};

static const struct stmmac_pci_dmi_data galileo_stmmac_dmi_data[] = {
        {
                 .func = 6,
                 .phy_addr = 1,
        },
};

static struct stmmac_pci_info galileo_pci_info  = {
 .map = galileo_stmmac_dmi_data,
 .nmaps = ARRAY_SIZE(galileo_stmmac_dmi_data),
 .setup = quark_default_setup,
}


?

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 0/3] stmmac: pci: Refactor DMI probing
  2017-05-22 16:35 ` [PATCH 0/3] stmmac: pci: Refactor DMI probing David Miller
@ 2017-05-22 17:06   ` Jan Kiszka
  2017-05-22 18:23     ` David Miller
  0 siblings, 1 reply; 13+ messages in thread
From: Jan Kiszka @ 2017-05-22 17:06 UTC (permalink / raw)
  To: David Miller
  Cc: peppe.cavallaro, alexandre.torgue, netdev, linux-kernel, andy.shevchenko

On 2017-05-22 18:35, David Miller wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> Date: Mon, 22 May 2017 13:12:06 +0200
> 
>> Some cleanups of the way we probe DMI platforms in the driver. Reduces
>> a bit of open-coding and makes the logic easier reusable for any
>> potential DMI platform != Quark.
>>
>> Tested on IOT2000 and Galileo Gen2.
> 
> This doesn't compile:
> 
> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:285:3: error: initializer element is not computable at load time
>    (kernel_ulong_t)&stmmac_default_setup,
>    ^
> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:285:3: note: (near initialization for ‘stmmac_id_table[0].class’)
> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:289:3: error: initializer element is not computable at load time
>    (kernel_ulong_t)&stmmac_default_setup,
>    ^
> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:289:3: note: (near initialization for ‘stmmac_id_table[1].class’)
> scripts/Makefile.build:302: recipe for target 'drivers/net/ethernet/stmicro/stmmac/stmmac_pci.o' failed
> make[5]: *** [drivers/net/ethernet/stmicro/stmmac/stmmac_pci.o] Error 1
> 

Hmm. Which arch is this?

Jan

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

* Re: [PATCH 1/3] stmmac: pci: Overcome stmmac_pci_info structure
  2017-05-22 11:12 ` [PATCH 1/3] stmmac: pci: Overcome stmmac_pci_info structure Jan Kiszka
@ 2017-05-22 17:09   ` Andy Shevchenko
  2017-05-23 13:48   ` kbuild test robot
  1 sibling, 0 replies; 13+ messages in thread
From: Andy Shevchenko @ 2017-05-22 17:09 UTC (permalink / raw)
  To: Jan Kiszka
  Cc: Giuseppe Cavallaro, Alexandre Torgue, David Miller, netdev, linux-kernel

On Mon, May 22, 2017 at 2:12 PM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
> First, pass the PCI device reference as function parameter. Then the
> setup function knows which stmmac_pci_dmi_data structure to use.
> Finally, we are left with a setup function in stmmac_pci_info and can
> convert the structure into a function pointer. By converting
> stmmac_default_data to that type, we can make a setup function
> mandatory, and probing becomes more regular.

I don't see any good reason for this patch. Besides that it will not
compile (as David noticed already).

Can we modify structures with less intrusion?
I'm pretty sure we can convert (if you wish, however I would leave it
for now, there is no issue with current approach) with as twice less
lines.


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 0/3] stmmac: pci: Refactor DMI probing
  2017-05-22 17:06   ` Jan Kiszka
@ 2017-05-22 18:23     ` David Miller
  0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2017-05-22 18:23 UTC (permalink / raw)
  To: jan.kiszka
  Cc: peppe.cavallaro, alexandre.torgue, netdev, linux-kernel, andy.shevchenko

From: Jan Kiszka <jan.kiszka@siemens.com>
Date: Mon, 22 May 2017 19:06:07 +0200

> On 2017-05-22 18:35, David Miller wrote:
>> From: Jan Kiszka <jan.kiszka@siemens.com>
>> Date: Mon, 22 May 2017 13:12:06 +0200
>> 
>>> Some cleanups of the way we probe DMI platforms in the driver. Reduces
>>> a bit of open-coding and makes the logic easier reusable for any
>>> potential DMI platform != Quark.
>>>
>>> Tested on IOT2000 and Galileo Gen2.
>> 
>> This doesn't compile:
>> 
>> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:285:3: error: initializer element is not computable at load time
>>    (kernel_ulong_t)&stmmac_default_setup,
>>    ^
>> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:285:3: note: (near initialization for ‘stmmac_id_table[0].class’)
>> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:289:3: error: initializer element is not computable at load time
>>    (kernel_ulong_t)&stmmac_default_setup,
>>    ^
>> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:289:3: note: (near initialization for ‘stmmac_id_table[1].class’)
>> scripts/Makefile.build:302: recipe for target 'drivers/net/ethernet/stmicro/stmmac/stmmac_pci.o' failed
>> make[5]: *** [drivers/net/ethernet/stmicro/stmmac/stmmac_pci.o] Error 1
>> 
> 
> Hmm. Which arch is this?

x86_64, allmodconfig

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

* Re: [PATCH 1/3] stmmac: pci: Overcome stmmac_pci_info structure
  2017-05-22 11:12 ` [PATCH 1/3] stmmac: pci: Overcome stmmac_pci_info structure Jan Kiszka
  2017-05-22 17:09   ` Andy Shevchenko
@ 2017-05-23 13:48   ` kbuild test robot
  1 sibling, 0 replies; 13+ messages in thread
From: kbuild test robot @ 2017-05-23 13:48 UTC (permalink / raw)
  To: Jan Kiszka
  Cc: kbuild-all, Giuseppe Cavallaro, Alexandre Torgue, David Miller,
	netdev, linux-kernel, Andy Shevchenko

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

Hi Jan,

[auto build test ERROR on net-next/master]
[also build test ERROR on v4.12-rc2 next-20170523]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Jan-Kiszka/stmmac-pci-Refactor-DMI-probing/20170523-165305
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:267:3: error: initializer element is not computable at load time
      (kernel_ulong_t)&stmmac_default_setup,
      ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:267:3: note: (near initialization for 'stmmac_id_table[0].class')
   drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:271:3: error: initializer element is not computable at load time
      (kernel_ulong_t)&stmmac_default_setup,
      ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:271:3: note: (near initialization for 'stmmac_id_table[1].class')

vim +267 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c

   261	#define STMMAC_QUARK_ID  0x0937
   262	#define STMMAC_DEVICE_ID 0x1108
   263	
   264	static const struct pci_device_id stmmac_id_table[] = {
   265		{
   266			PCI_DEVICE(STMMAC_VENDOR_ID, STMMAC_DEVICE_ID),
 > 267			(kernel_ulong_t)&stmmac_default_setup,
   268		},
   269		{
   270			PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_MAC),

---
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: 60065 bytes --]

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

end of thread, other threads:[~2017-05-23 13:49 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-22 11:12 [PATCH 0/3] stmmac: pci: Refactor DMI probing Jan Kiszka
2017-05-22 11:12 ` [PATCH 1/3] stmmac: pci: Overcome stmmac_pci_info structure Jan Kiszka
2017-05-22 17:09   ` Andy Shevchenko
2017-05-23 13:48   ` kbuild test robot
2017-05-22 11:12 ` [PATCH 2/3] stmmac: pci: Make stmmac_pci_find_phy_addr truly generic Jan Kiszka
2017-05-22 11:12 ` [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses Jan Kiszka
2017-05-22 11:33   ` Joe Perches
2017-05-22 12:49     ` Jan Kiszka
2017-05-22 13:13       ` Joe Perches
2017-05-22 16:59   ` Andy Shevchenko
2017-05-22 16:35 ` [PATCH 0/3] stmmac: pci: Refactor DMI probing David Miller
2017-05-22 17:06   ` Jan Kiszka
2017-05-22 18:23     ` David Miller

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).