From de2ecea45f4a4ba191366439af2fa2c806d296f0 Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Sun, 19 Mar 2017 21:13:16 +0000 Subject: [PATCH] Add upstream patches to improve xgene_enet stability a little --- kernel.spec | 6 + xgene-Fix-crash-on-DT-systems.patch | 43 ++++ ...et-remove-bogus-forward-declarations.patch | 197 ++++++++++++++++++ 3 files changed, 246 insertions(+) create mode 100644 xgene-Fix-crash-on-DT-systems.patch create mode 100644 xgene_enet-remove-bogus-forward-declarations.patch diff --git a/kernel.spec b/kernel.spec index e06f75b98..1189d6f53 100644 --- a/kernel.spec +++ b/kernel.spec @@ -517,6 +517,9 @@ Patch425: ARM-tegra-usb-no-reset.patch Patch426: AllWinner-net-emac.patch +Patch427: xgene_enet-remove-bogus-forward-declarations.patch +Patch428: xgene-Fix-crash-on-DT-systems.patch + # http://www.spinics.net/lists/devicetree/msg163238.html Patch430: bcm2837-initial-support.patch @@ -2184,6 +2187,9 @@ fi # # %changelog +* Sun Mar 19 2017 Peter Robinson +- Add upstream patches to improve xgene_enet stability a little + * Wed Mar 15 2017 Justin M. Forbes - 4.10.3-200 - Linux v4.10.3 rebase - CVE-2017-6874 Fix race condition in ucount.c (rhbz 1432429 1432430) diff --git a/xgene-Fix-crash-on-DT-systems.patch b/xgene-Fix-crash-on-DT-systems.patch new file mode 100644 index 000000000..d91005af9 --- /dev/null +++ b/xgene-Fix-crash-on-DT-systems.patch @@ -0,0 +1,43 @@ +From patchwork Tue Feb 28 17:08:55 2017 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Subject: drivers: net: xgene: Fix crash on DT systems +From: Alban Bedel +X-Patchwork-Id: 733734 +X-Patchwork-Delegate: davem@davemloft.net +Message-Id: <20170228170855.8123-1-alban.bedel@avionic-design.de> +To: netdev@vger.kernel.org +Cc: Iyappan Subramanian , + Keyur Chudgar , linux-kernel@vger.kernel.org, + Alban Bedel +Date: Tue, 28 Feb 2017 18:08:55 +0100 + +On DT systems the driver require a clock, but the probe just print a +warning and continue, leading to a crash when resetting the device. +To fix this crash and properly handle probe deferals only ignore the +missing clock if DT isn't used or if the clock doesn't exist. + +Signed-off-by: Alban Bedel +Acked-by: Iyappan Subramanian +--- + drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c +index d0d0d12b531f..68b48edc5921 100644 +--- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c ++++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c +@@ -1756,6 +1756,12 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata) + + pdata->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(pdata->clk)) { ++ /* Abort if the clock is defined but couldn't be retrived. ++ * Always abort if the clock is missing on DT system as ++ * the driver can't cope with this case. ++ */ ++ if (PTR_ERR(pdata->clk) != -ENOENT || dev->of_node) ++ return PTR_ERR(pdata->clk); + /* Firmware may have set up the clock already. */ + dev_info(dev, "clocks have been setup already\n"); + } diff --git a/xgene_enet-remove-bogus-forward-declarations.patch b/xgene_enet-remove-bogus-forward-declarations.patch new file mode 100644 index 000000000..f1262db85 --- /dev/null +++ b/xgene_enet-remove-bogus-forward-declarations.patch @@ -0,0 +1,197 @@ +From patchwork Wed Feb 1 16:46:02 2017 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Subject: [net-next] xgene_enet: remove bogus forward declarations +From: Arnd Bergmann +X-Patchwork-Id: 9550123 +Message-Id: <20170201164639.2474782-1-arnd@arndb.de> +To: "David S . Miller" +Cc: Arnd Bergmann , Iyappan Subramanian , + Keyur Chudgar , + Florian Fainelli , Quan Nguyen , + Tanmay Inamdar , + stephen hemminger , + netdev@vger.kernel.org, linux-kernel@vger.kernel.org +Date: Wed, 1 Feb 2017 17:46:02 +0100 + +The device match tables for both the xgene_enet driver and its phy driver +have forward declarations that declare an array without a length, leading +to a clang warning when they are not followed by an actual defitinition: + +drivers/net/ethernet/apm/xgene/../../../phy/mdio-xgene.h:135:34: warning: tentative array definition assumed to have one element +drivers/net/ethernet/apm/xgene/xgene_enet_main.c:33:36: warning: tentative array definition assumed to have one element + +The declarations for the mdio driver are even in a header file, so they +cause duplicate definitions of the tables for each file that includes +them. + +This removes all four forward declarations and moves the actual +definitions up a little, so they are in front of their first user. For +the OF match tables, this means having to remove the #ifdef around them, +and passing the actual structure into of_match_device(). This has no +effect on the generated object code though, as the of_match_device +function has an empty stub that does not evaluate its argument, and +the symbol gets dropped either way. + +Fixes: 43b3cf6634a4 ("drivers: net: phy: xgene: Add MDIO driver") +Signed-off-by: Arnd Bergmann +--- +The bug is old, but relatively harmless, so not needed as a fixup for 4.10 +--- + drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 50 ++++++++++++------------ + drivers/net/phy/mdio-xgene.c | 50 ++++++++++++------------ + drivers/net/phy/mdio-xgene.h | 4 -- + 3 files changed, 48 insertions(+), 56 deletions(-) + +diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c +index ab43c52723df..d0d0d12b531f 100644 +--- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c ++++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c +@@ -1964,6 +1964,30 @@ static void xgene_enet_napi_add(struct xgene_enet_pdata *pdata) + } + } + ++#ifdef CONFIG_ACPI ++static const struct acpi_device_id xgene_enet_acpi_match[] = { ++ { "APMC0D05", XGENE_ENET1}, ++ { "APMC0D30", XGENE_ENET1}, ++ { "APMC0D31", XGENE_ENET1}, ++ { "APMC0D3F", XGENE_ENET1}, ++ { "APMC0D26", XGENE_ENET2}, ++ { "APMC0D25", XGENE_ENET2}, ++ { } ++}; ++MODULE_DEVICE_TABLE(acpi, xgene_enet_acpi_match); ++#endif ++ ++static const struct of_device_id xgene_enet_of_match[] = { ++ {.compatible = "apm,xgene-enet", .data = (void *)XGENE_ENET1}, ++ {.compatible = "apm,xgene1-sgenet", .data = (void *)XGENE_ENET1}, ++ {.compatible = "apm,xgene1-xgenet", .data = (void *)XGENE_ENET1}, ++ {.compatible = "apm,xgene2-sgenet", .data = (void *)XGENE_ENET2}, ++ {.compatible = "apm,xgene2-xgenet", .data = (void *)XGENE_ENET2}, ++ {}, ++}; ++ ++MODULE_DEVICE_TABLE(of, xgene_enet_of_match); ++ + static int xgene_enet_probe(struct platform_device *pdev) + { + struct net_device *ndev; +@@ -2110,32 +2134,6 @@ static void xgene_enet_shutdown(struct platform_device *pdev) + xgene_enet_remove(pdev); + } + +-#ifdef CONFIG_ACPI +-static const struct acpi_device_id xgene_enet_acpi_match[] = { +- { "APMC0D05", XGENE_ENET1}, +- { "APMC0D30", XGENE_ENET1}, +- { "APMC0D31", XGENE_ENET1}, +- { "APMC0D3F", XGENE_ENET1}, +- { "APMC0D26", XGENE_ENET2}, +- { "APMC0D25", XGENE_ENET2}, +- { } +-}; +-MODULE_DEVICE_TABLE(acpi, xgene_enet_acpi_match); +-#endif +- +-#ifdef CONFIG_OF +-static const struct of_device_id xgene_enet_of_match[] = { +- {.compatible = "apm,xgene-enet", .data = (void *)XGENE_ENET1}, +- {.compatible = "apm,xgene1-sgenet", .data = (void *)XGENE_ENET1}, +- {.compatible = "apm,xgene1-xgenet", .data = (void *)XGENE_ENET1}, +- {.compatible = "apm,xgene2-sgenet", .data = (void *)XGENE_ENET2}, +- {.compatible = "apm,xgene2-xgenet", .data = (void *)XGENE_ENET2}, +- {}, +-}; +- +-MODULE_DEVICE_TABLE(of, xgene_enet_of_match); +-#endif +- + static struct platform_driver xgene_enet_driver = { + .driver = { + .name = "xgene-enet", +diff --git a/drivers/net/phy/mdio-xgene.c b/drivers/net/phy/mdio-xgene.c +index 92af182951be..f095051beb54 100644 +--- a/drivers/net/phy/mdio-xgene.c ++++ b/drivers/net/phy/mdio-xgene.c +@@ -311,6 +311,30 @@ static acpi_status acpi_register_phy(acpi_handle handle, u32 lvl, + } + #endif + ++static const struct of_device_id xgene_mdio_of_match[] = { ++ { ++ .compatible = "apm,xgene-mdio-rgmii", ++ .data = (void *)XGENE_MDIO_RGMII ++ }, ++ { ++ .compatible = "apm,xgene-mdio-xfi", ++ .data = (void *)XGENE_MDIO_XFI ++ }, ++ {}, ++}; ++MODULE_DEVICE_TABLE(of, xgene_mdio_of_match); ++ ++#ifdef CONFIG_ACPI ++static const struct acpi_device_id xgene_mdio_acpi_match[] = { ++ { "APMC0D65", XGENE_MDIO_RGMII }, ++ { "APMC0D66", XGENE_MDIO_XFI }, ++ { } ++}; ++ ++MODULE_DEVICE_TABLE(acpi, xgene_mdio_acpi_match); ++#endif ++ ++ + static int xgene_mdio_probe(struct platform_device *pdev) + { + struct device *dev = &pdev->dev; +@@ -430,32 +454,6 @@ static int xgene_mdio_remove(struct platform_device *pdev) + return 0; + } + +-#ifdef CONFIG_OF +-static const struct of_device_id xgene_mdio_of_match[] = { +- { +- .compatible = "apm,xgene-mdio-rgmii", +- .data = (void *)XGENE_MDIO_RGMII +- }, +- { +- .compatible = "apm,xgene-mdio-xfi", +- .data = (void *)XGENE_MDIO_XFI +- }, +- {}, +-}; +- +-MODULE_DEVICE_TABLE(of, xgene_mdio_of_match); +-#endif +- +-#ifdef CONFIG_ACPI +-static const struct acpi_device_id xgene_mdio_acpi_match[] = { +- { "APMC0D65", XGENE_MDIO_RGMII }, +- { "APMC0D66", XGENE_MDIO_XFI }, +- { } +-}; +- +-MODULE_DEVICE_TABLE(acpi, xgene_mdio_acpi_match); +-#endif +- + static struct platform_driver xgene_mdio_driver = { + .driver = { + .name = "xgene-mdio", +diff --git a/drivers/net/phy/mdio-xgene.h b/drivers/net/phy/mdio-xgene.h +index 354241b53c1d..594a11d42401 100644 +--- a/drivers/net/phy/mdio-xgene.h ++++ b/drivers/net/phy/mdio-xgene.h +@@ -132,10 +132,6 @@ static inline u64 xgene_enet_get_field_value(int pos, int len, u64 src) + #define GET_BIT(field, src) \ + xgene_enet_get_field_value(field ## _POS, 1, src) + +-static const struct of_device_id xgene_mdio_of_match[]; +-#ifdef CONFIG_ACPI +-static const struct acpi_device_id xgene_mdio_acpi_match[]; +-#endif + int xgene_mdio_rgmii_read(struct mii_bus *bus, int phy_id, int reg); + int xgene_mdio_rgmii_write(struct mii_bus *bus, int phy_id, int reg, u16 data); + struct phy_device *xgene_enet_phy_register(struct mii_bus *bus, int phy_addr);