diff --git a/include/kernel-version.mk b/include/kernel-version.mk index dee3f7f80..e7ebf5efc 100644 --- a/include/kernel-version.mk +++ b/include/kernel-version.mk @@ -7,12 +7,12 @@ ifdef CONFIG_TESTING_KERNEL endif LINUX_VERSION-4.9 = .208 -LINUX_VERSION-4.14 = .162 -LINUX_VERSION-4.19 = .93 +LINUX_VERSION-4.14 = .167 +LINUX_VERSION-4.19 = .98 LINUX_KERNEL_HASH-4.9.208 = b7ad1c9841d671d026c55a4c91c77205f8b488ca5f980f838591c68662e0525a -LINUX_KERNEL_HASH-4.14.162 = f65170224cd4359ce8b2793b492bd8127abdd0b91350484e001bce13f0c98b4b -LINUX_KERNEL_HASH-4.19.93 = 2af5d23f82a8bf69a6e4d8407579293b7beeebd3054dc464d48bdb5d2d7f5834 +LINUX_KERNEL_HASH-4.14.167 = 2bb78fc7a902faf4f5dad47fdbc2f4bf3df3cf9b41f408e7260f36656659fe43 +LINUX_KERNEL_HASH-4.19.98 = 91feb13bc22d60d69596ab1d01dfecbec13ef70f00c89a483e0733af94dd2937 remove_uri_prefix=$(subst git://,,$(subst http://,,$(subst https://,,$(1)))) sanitize_uri=$(call qstrip,$(subst @,_,$(subst :,_,$(subst .,_,$(subst -,_,$(subst /,_,$(1))))))) diff --git a/package/boot/uboot-tegra/Makefile b/package/boot/uboot-tegra/Makefile new file mode 100644 index 000000000..4b9f7876f --- /dev/null +++ b/package/boot/uboot-tegra/Makefile @@ -0,0 +1,64 @@ +# +# Copyright (C) 2017-2019 Tomasz Maciej Nowak +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +include $(TOPDIR)/rules.mk + +PKG_VERSION := 2019.04 +PKG_RELEASE := 1 + +PKG_HASH := 76b7772d156b3ddd7644c8a1736081e55b78828537ff714065d21dbade229bef + +PKG_MAINTAINER := Tomasz Maciej Nowak + +include $(INCLUDE_DIR)/u-boot.mk +include $(INCLUDE_DIR)/package.mk + +define U-Boot/Default + BUILD_TARGET := tegra + HIDDEN := y +endef + +define U-Boot/trimslice + NAME := CompuLab TrimSlice + BUILD_DEVICES := compulab_trimslice + UBOOT_IMAGE := trimslice-mmc.img trimslice-spi.img + SOC := tegra20 + VENDOR := compulab +endef + +UBOOT_TARGETS := trimslice + +define Build/bct-image + $(CP) $(PKG_BUILD_DIR)/u-boot-dtb-tegra.bin $(PKG_BUILD_DIR)/u-boot.bin + $(foreach bct,$(basename $(UBOOT_IMAGE)), \ + cd $(PKG_BUILD_DIR); \ + cbootimage -s $(SOC) -gbct \ + $(STAGING_DIR_HOST)/share/cbootimage-configs/$(SOC)/$(VENDOR)/$(VARIANT)/$(bct).bct.cfg \ + $(bct).bct; \ + cbootimage -s $(SOC) \ + $(STAGING_DIR_HOST)/share/cbootimage-configs/$(SOC)/$(VENDOR)/$(VARIANT)/$(bct).img.cfg \ + $(PKG_BUILD_DIR)/$(bct).img; \ + rm -f $(bct).bct; \ + ) +endef + +define Build/Configure + sed '/select BINMAN/d' -i $(PKG_BUILD_DIR)/arch/arm/mach-tegra/Kconfig + $(call Build/Configure/U-Boot) +endef + +define Build/Compile + $(call Build/Compile/U-Boot) + $(call Build/bct-image) +endef + +define Build/InstallDev + $(INSTALL_DIR) $(STAGING_DIR_IMAGE) + $(foreach img,$(UBOOT_IMAGE), \ + $(CP) $(PKG_BUILD_DIR)/$(img) $(STAGING_DIR_IMAGE)/;) +endef + +$(eval $(call BuildPackage/U-Boot)) diff --git a/target/linux/ar71xx/patches-4.14/411-mtd-cfi_cmdset_0002-force-word-write.patch b/target/linux/ar71xx/patches-4.14/411-mtd-cfi_cmdset_0002-force-word-write.patch index 5a6eb77d0..bb013c6cf 100644 --- a/target/linux/ar71xx/patches-4.14/411-mtd-cfi_cmdset_0002-force-word-write.patch +++ b/target/linux/ar71xx/patches-4.14/411-mtd-cfi_cmdset_0002-force-word-write.patch @@ -35,7 +35,7 @@ /* Atmel chips don't use the same PRI format as AMD chips */ static void fixup_convert_atmel_pri(struct mtd_info *mtd) -@@ -1800,6 +1804,7 @@ static int cfi_amdstd_write_words(struct +@@ -1798,6 +1802,7 @@ static int cfi_amdstd_write_words(struct /* * FIXME: interleaved mode not tested, and probably not supported! */ @@ -43,7 +43,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, unsigned long adr, const u_char *buf, int len) -@@ -1928,7 +1933,6 @@ static int __xipram do_write_buffer(stru +@@ -1926,7 +1931,6 @@ static int __xipram do_write_buffer(stru return ret; } @@ -51,7 +51,7 @@ static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) { -@@ -2003,6 +2007,7 @@ static int cfi_amdstd_write_buffers(stru +@@ -2001,6 +2005,7 @@ static int cfi_amdstd_write_buffers(stru return 0; } diff --git a/target/linux/ar71xx/patches-4.14/902-at803x-add-reset-gpio-pdata.patch b/target/linux/ar71xx/patches-4.14/902-at803x-add-reset-gpio-pdata.patch index 81de68c9c..e4e51963b 100644 --- a/target/linux/ar71xx/patches-4.14/902-at803x-add-reset-gpio-pdata.patch +++ b/target/linux/ar71xx/patches-4.14/902-at803x-add-reset-gpio-pdata.patch @@ -37,7 +37,7 @@ Signed-off-by: Felix Fietkau gpiod_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(gpiod_reset)) return PTR_ERR(gpiod_reset); -@@ -411,15 +418,23 @@ static void at803x_link_change_notify(st +@@ -402,15 +409,23 @@ static void at803x_link_change_notify(st * cannot recover from by software. */ if (phydev->state == PHY_NOLINK) { diff --git a/target/linux/ar71xx/patches-4.14/903-at803x-add-sgmii-aneg-override-pdata.patch b/target/linux/ar71xx/patches-4.14/903-at803x-add-sgmii-aneg-override-pdata.patch index 8948fd495..600f8ff6d 100644 --- a/target/linux/ar71xx/patches-4.14/903-at803x-add-sgmii-aneg-override-pdata.patch +++ b/target/linux/ar71xx/patches-4.14/903-at803x-add-sgmii-aneg-override-pdata.patch @@ -1,6 +1,6 @@ --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c -@@ -478,12 +478,15 @@ static void at803x_link_change_notify(st +@@ -458,12 +458,15 @@ static void at803x_link_change_notify(st static int at803x_aneg_done(struct phy_device *phydev) { @@ -16,7 +16,7 @@ /* * in SGMII mode, if copper side autoneg is successful, * also check SGMII side autoneg result -@@ -498,7 +501,8 @@ static int at803x_aneg_done(struct phy_d +@@ -478,7 +481,8 @@ static int at803x_aneg_done(struct phy_d /* check if the SGMII link is OK. */ if (!(phy_read(phydev, AT803X_PSSR) & AT803X_PSSR_MR_AN_COMPLETE)) { pr_warn("803x_aneg_done: SGMII link is not ok\n"); diff --git a/target/linux/ar71xx/patches-4.14/910-unaligned_access_hacks.patch b/target/linux/ar71xx/patches-4.14/910-unaligned_access_hacks.patch index a3d4ef285..f2732ebb2 100644 --- a/target/linux/ar71xx/patches-4.14/910-unaligned_access_hacks.patch +++ b/target/linux/ar71xx/patches-4.14/910-unaligned_access_hacks.patch @@ -757,7 +757,7 @@ EXPORT_SYMBOL(xfrm_parse_spi); --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c -@@ -3874,14 +3874,16 @@ static bool tcp_parse_aligned_timestamp( +@@ -3878,14 +3878,16 @@ static bool tcp_parse_aligned_timestamp( { const __be32 *ptr = (const __be32 *)(th + 1); diff --git a/target/linux/ath79/patches-4.14/0038-MIPS-ath79-add-missing-QCA955x-GMAC-registers.patch b/target/linux/ath79/patches-4.14/0038-MIPS-ath79-add-missing-QCA955x-GMAC-registers.patch new file mode 100644 index 000000000..dc0af2fe9 --- /dev/null +++ b/target/linux/ath79/patches-4.14/0038-MIPS-ath79-add-missing-QCA955x-GMAC-registers.patch @@ -0,0 +1,90 @@ +From 60efe35257b063ce584968f9f80b437030ce6ba6 Mon Sep 17 00:00:00 2001 +From: David Bauer +Date: Mon, 18 Mar 2019 00:54:06 +0100 +Subject: [PATCH] MIPS: ath79: add missing QCA955x GMAC registers + +This adds missing GMAC register definitions for the Qualcomm Atheros +QCA955X series MIPS SoCs. + +They originate from the platforms U-Boot code and the AVM FRITZ!WLAN +Repeater 450E's GPL tarball. + +Signed-off-by: David Bauer +--- + .../mips/include/asm/mach-ath79/ar71xx_regs.h | 54 +++++++++++++++++++ + 1 file changed, 54 insertions(+) + +--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h ++++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h +@@ -1249,7 +1249,12 @@ + */ + + #define QCA955X_GMAC_REG_ETH_CFG 0x00 ++#define QCA955X_GMAC_REG_SGMII_RESET 0x14 + #define QCA955X_GMAC_REG_SGMII_SERDES 0x18 ++#define QCA955X_GMAC_REG_MR_AN_CONTROL 0x1c ++#define QCA955X_GMAC_REG_MR_AN_STATUS 0x20 ++#define QCA955X_GMAC_REG_SGMII_CONFIG 0x34 ++#define QCA955X_GMAC_REG_SGMII_DEBUG 0x58 + + #define QCA955X_ETH_CFG_RGMII_EN BIT(0) + #define QCA955X_ETH_CFG_MII_GE0 BIT(1) +@@ -1271,9 +1276,58 @@ + #define QCA955X_ETH_CFG_TXE_DELAY_MASK 0x3 + #define QCA955X_ETH_CFG_TXE_DELAY_SHIFT 20 + ++#define QCA955X_SGMII_RESET_RX_CLK_N_RESET 0 ++#define QCA955X_SGMII_RESET_RX_CLK_N BIT(0) ++#define QCA955X_SGMII_RESET_TX_CLK_N BIT(1) ++#define QCA955X_SGMII_RESET_RX_125M_N BIT(2) ++#define QCA955X_SGMII_RESET_TX_125M_N BIT(3) ++#define QCA955X_SGMII_RESET_HW_RX_125M_N BIT(4) ++ + #define QCA955X_SGMII_SERDES_LOCK_DETECT_STATUS BIT(15) + #define QCA955X_SGMII_SERDES_RES_CALIBRATION_SHIFT 23 + #define QCA955X_SGMII_SERDES_RES_CALIBRATION_MASK 0xf ++ ++#define QCA955X_MR_AN_CONTROL_SPEED_SEL1 BIT(6) ++#define QCA955X_MR_AN_CONTROL_DUPLEX_MODE BIT(8) ++#define QCA955X_MR_AN_CONTROL_RESTART_AN BIT(9) ++#define QCA955X_MR_AN_CONTROL_POWER_DOWN BIT(11) ++#define QCA955X_MR_AN_CONTROL_AN_ENABLE BIT(12) ++#define QCA955X_MR_AN_CONTROL_SPEED_SEL0 BIT(13) ++#define QCA955X_MR_AN_CONTROL_LOOPBACK BIT(14) ++#define QCA955X_MR_AN_CONTROL_PHY_RESET BIT(15) ++ ++#define QCA955X_MR_AN_STATUS_EXT_CAP BIT(0) ++#define QCA955X_MR_AN_STATUS_LINK_UP BIT(2) ++#define QCA955X_MR_AN_STATUS_AN_ABILITY BIT(3) ++#define QCA955X_MR_AN_STATUS_REMOTE_FAULT BIT(4) ++#define QCA955X_MR_AN_STATUS_AN_COMPLETE BIT(5) ++#define QCA955X_MR_AN_STATUS_NO_PREAMBLE BIT(6) ++#define QCA955X_MR_AN_STATUS_BASE_PAGE BIT(7) ++ ++#define QCA955X_SGMII_CONFIG_MODE_CTRL_SHIFT 0 ++#define QCA955X_SGMII_CONFIG_MODE_CTRL_MASK 0x7 ++#define QCA955X_SGMII_CONFIG_ENABLE_SGMII_TX_PAUSE BIT(3) ++#define QCA955X_SGMII_CONFIG_MR_REG4_CHANGED BIT(4) ++#define QCA955X_SGMII_CONFIG_FORCE_SPEED BIT(5) ++#define QCA955X_SGMII_CONFIG_SPEED_SHIFT 6 ++#define QCA955X_SGMII_CONFIG_SPEED_MASK 0xc0 ++#define QCA955X_SGMII_CONFIG_REMOTE_PHY_LOOPBACK BIT(8) ++#define QCA955X_SGMII_CONFIG_NEXT_PAGE_LOADED BIT(9) ++#define QCA955X_SGMII_CONFIG_MDIO_ENABLE BIT(10) ++#define QCA955X_SGMII_CONFIG_MDIO_PULSE BIT(11) ++#define QCA955X_SGMII_CONFIG_MDIO_COMPLETE BIT(12) ++#define QCA955X_SGMII_CONFIG_PRBS_ENABLE BIT(13) ++#define QCA955X_SGMII_CONFIG_BERT_ENABLE BIT(14) ++ ++#define QCA955X_SGMII_DEBUG_TX_STATE_MASK 0xff ++#define QCA955X_SGMII_DEBUG_TX_STATE_SHIFT 0 ++#define QCA955X_SGMII_DEBUG_RX_STATE_MASK 0xff00 ++#define QCA955X_SGMII_DEBUG_RX_STATE_SHIFT 8 ++#define QCA955X_SGMII_DEBUG_RX_SYNC_STATE_MASK 0xff0000 ++#define QCA955X_SGMII_DEBUG_RX_SYNC_STATE_SHIFT 16 ++#define QCA955X_SGMII_DEBUG_ARB_STATE_MASK 0xf000000 ++#define QCA955X_SGMII_DEBUG_ARB_STATE_SHIFT 24 ++ + /* + * QCA956X GMAC Interface + */ diff --git a/target/linux/ath79/patches-4.14/403-mtd_fix_cfi_cmdset_0002_status_check.patch b/target/linux/ath79/patches-4.14/403-mtd_fix_cfi_cmdset_0002_status_check.patch deleted file mode 100644 index 4ef230376..000000000 --- a/target/linux/ath79/patches-4.14/403-mtd_fix_cfi_cmdset_0002_status_check.patch +++ /dev/null @@ -1,62 +0,0 @@ ---- a/drivers/mtd/chips/cfi_cmdset_0002.c -+++ b/drivers/mtd/chips/cfi_cmdset_0002.c -@@ -1641,7 +1641,7 @@ static int __xipram do_write_oneword(str - } - - if (chip_good(map, adr, datum)) -- break; -+ goto enable_xip; - - /* Latency issues. Drop the lock, wait a while and retry */ - UDELAY(map, chip, adr, 1); -@@ -1658,6 +1658,8 @@ static int __xipram do_write_oneword(str - goto retry; - } - } -+ -+ enable_xip: - xip_enable(map, chip, adr); - op_done: - if (mode == FL_OTP_WRITE) -@@ -2236,7 +2238,6 @@ static int cfi_amdstd_panic_write(struct - return 0; - } - -- - /* - * Handle devices with one erase region, that only implement - * the chip erase command. -@@ -2304,7 +2305,7 @@ static int __xipram do_erase_chip(struct - } - - if (chip_good(map, adr, map_word_ff(map))) -- break; -+ goto op_done; - - if (time_after(jiffies, timeo)) { - printk(KERN_WARNING "MTD %s(): software timeout\n", -@@ -2328,6 +2329,7 @@ static int __xipram do_erase_chip(struct - } - } - -+ op_done: - chip->state = FL_READY; - xip_enable(map, chip, adr); - DISABLE_VPP(map); -@@ -2401,7 +2403,7 @@ static int __xipram do_erase_oneblock(st - - if (chip_good(map, adr, map_word_ff(map))) { - xip_enable(map, chip, adr); -- break; -+ goto op_done; - } - - if (time_after(jiffies, timeo)) { -@@ -2427,6 +2429,7 @@ static int __xipram do_erase_oneblock(st - } - } - -+ op_done: - chip->state = FL_READY; - DISABLE_VPP(map); - put_chip(map, chip, adr); diff --git a/target/linux/ath79/patches-4.14/425-at803x-allow-sgmii-aneg-override.patch b/target/linux/ath79/patches-4.14/425-at803x-allow-sgmii-aneg-override.patch new file mode 100644 index 000000000..3b302dcd9 --- /dev/null +++ b/target/linux/ath79/patches-4.14/425-at803x-allow-sgmii-aneg-override.patch @@ -0,0 +1,16 @@ +--- a/drivers/net/phy/at803x.c ++++ b/drivers/net/phy/at803x.c +@@ -472,6 +472,13 @@ static int at803x_aneg_done(struct phy_d + if (!(phy_read(phydev, AT803X_PSSR) & AT803X_PSSR_MR_AN_COMPLETE)) { + pr_warn("803x_aneg_done: SGMII link is not ok\n"); + aneg_done = 0; ++#ifdef CONFIG_OF_MDIO ++ if (phydev->mdio.dev.of_node && ++ of_property_read_bool(phydev->mdio.dev.of_node, ++ "at803x-override-sgmii-link-check")) { ++ aneg_done = 1; ++ } ++#endif + } + /* switch back to copper page */ + phy_write(phydev, AT803X_REG_CHIP_CONFIG, ccr | AT803X_BT_BX_REG_SEL); diff --git a/target/linux/ath79/patches-4.14/490-usb-ehci-add-quirks-for-qca-socs.patch b/target/linux/ath79/patches-4.14/490-usb-ehci-add-quirks-for-qca-socs.patch deleted file mode 100644 index 1d1979cd6..000000000 --- a/target/linux/ath79/patches-4.14/490-usb-ehci-add-quirks-for-qca-socs.patch +++ /dev/null @@ -1,103 +0,0 @@ ---- a/drivers/usb/host/ehci-hcd.c -+++ b/drivers/usb/host/ehci-hcd.c -@@ -252,6 +252,37 @@ int ehci_reset(struct ehci_hcd *ehci) - command |= CMD_RESET; - dbg_cmd (ehci, "reset", command); - ehci_writel(ehci, command, &ehci->regs->command); -+ -+ if (ehci->qca_force_host_mode) { -+ u32 usbmode; -+ -+ udelay(1000); -+ -+ usbmode = ehci_readl(ehci, &ehci->regs->usbmode); -+ usbmode |= USBMODE_CM_HC | (1 << 4); -+ ehci_writel(ehci, usbmode, &ehci->regs->usbmode); -+ -+ ehci_dbg(ehci, "forced host mode, usbmode: %08x\n", -+ ehci_readl(ehci, &ehci->regs->usbmode)); -+ } -+ -+ if (ehci->qca_force_16bit_ptw) { -+ u32 port_status; -+ -+ udelay(1000); -+ -+ /* enable 16-bit UTMI interface */ -+ port_status = ehci_readl(ehci, &ehci->regs->port_status[0]); -+ port_status |= BIT(28); -+ ehci_writel(ehci, port_status, &ehci->regs->port_status[0]); -+ -+ ehci_dbg(ehci, "16-bit UTMI interface enabled, status: %08x\n", -+ ehci_readl(ehci, &ehci->regs->port_status[0])); -+ } -+ -+ if (ehci->reset_notifier) -+ ehci->reset_notifier(ehci_to_hcd(ehci)); -+ - ehci->rh_state = EHCI_RH_HALTED; - ehci->next_statechange = jiffies; - retval = ehci_handshake(ehci, &ehci->regs->command, ---- a/drivers/usb/host/ehci.h -+++ b/drivers/usb/host/ehci.h -@@ -232,6 +232,10 @@ struct ehci_hcd { /* one per controlle - unsigned need_oc_pp_cycle:1; /* MPC834X port power */ - unsigned imx28_write_fix:1; /* For Freescale i.MX28 */ - unsigned ignore_oc:1; -+ unsigned qca_force_host_mode:1; -+ unsigned qca_force_16bit_ptw:1; /* force 16 bit UTMI */ -+ -+ void (*reset_notifier)(struct usb_hcd *hcd); - - /* required for usb32 quirk */ - #define OHCI_CTRL_HCFS (3 << 6) ---- a/include/linux/usb/ehci_pdriver.h -+++ b/include/linux/usb/ehci_pdriver.h -@@ -50,6 +50,8 @@ struct usb_ehci_pdata { - unsigned reset_on_resume:1; - unsigned dma_mask_64:1; - unsigned ignore_oc:1; -+ unsigned qca_force_host_mode:1; -+ unsigned qca_force_16bit_ptw:1; - - /* Turn on all power and clocks */ - int (*power_on)(struct platform_device *pdev); -@@ -59,6 +61,7 @@ struct usb_ehci_pdata { - * turn off everything else */ - void (*power_suspend)(struct platform_device *pdev); - int (*pre_setup)(struct usb_hcd *hcd); -+ void (*reset_notifier)(struct platform_device *pdev); - }; - - #endif /* __USB_CORE_EHCI_PDRIVER_H */ ---- a/drivers/usb/host/ehci-platform.c -+++ b/drivers/usb/host/ehci-platform.c -@@ -53,6 +53,14 @@ struct ehci_platform_priv { - - static const char hcd_name[] = "ehci-platform"; - -+static void ehci_platform_reset_notifier(struct usb_hcd *hcd) -+{ -+ struct platform_device *pdev = to_platform_device(hcd->self.controller); -+ struct usb_ehci_pdata *pdata = pdev->dev.platform_data; -+ -+ pdata->reset_notifier(pdev); -+} -+ - static int ehci_platform_reset(struct usb_hcd *hcd) - { - struct platform_device *pdev = to_platform_device(hcd->self.controller); -@@ -270,6 +278,13 @@ static int ehci_platform_probe(struct pl - priv->reset_on_resume = true; - if (pdata->ignore_oc) - ehci->ignore_oc = 1; -+ if (pdata->qca_force_host_mode) -+ ehci->qca_force_host_mode = 1; -+ if (pdata->qca_force_16bit_ptw) -+ ehci->qca_force_16bit_ptw = 1; -+ -+ if (pdata->reset_notifier) -+ ehci->reset_notifier = ehci_platform_reset_notifier; - - #ifndef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO - if (ehci->big_endian_mmio) { diff --git a/target/linux/ath79/patches-4.14/910-unaligned_access_hacks.patch b/target/linux/ath79/patches-4.14/910-unaligned_access_hacks.patch index a3a9dcad9..6234ba470 100644 --- a/target/linux/ath79/patches-4.14/910-unaligned_access_hacks.patch +++ b/target/linux/ath79/patches-4.14/910-unaligned_access_hacks.patch @@ -737,7 +737,7 @@ EXPORT_SYMBOL(xfrm_parse_spi); --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c -@@ -3874,14 +3874,16 @@ static bool tcp_parse_aligned_timestamp( +@@ -3878,14 +3878,16 @@ static bool tcp_parse_aligned_timestamp( { const __be32 *ptr = (const __be32 *)(th + 1); diff --git a/target/linux/ath79/patches-4.19/0004-phy-add-ath79-usb-phys.patch b/target/linux/ath79/patches-4.19/0004-phy-add-ath79-usb-phys.patch index 6280baf91..fa3487d39 100644 --- a/target/linux/ath79/patches-4.19/0004-phy-add-ath79-usb-phys.patch +++ b/target/linux/ath79/patches-4.19/0004-phy-add-ath79-usb-phys.patch @@ -194,7 +194,7 @@ Signed-off-by: John Crispin +MODULE_LICENSE("GPL"); --- /dev/null +++ b/drivers/phy/phy-ar7200-usb.c -@@ -0,0 +1,123 @@ +@@ -0,0 +1,135 @@ +/* + * Copyright (C) 2015 Alban Bedel + * @@ -212,6 +212,7 @@ Signed-off-by: John Crispin + +struct ar7200_usb_phy { + struct reset_control *rst_phy; ++ struct reset_control *rst_phy_analog; + struct reset_control *suspend_override; + struct phy *phy; + int gpio; @@ -222,12 +223,12 @@ Signed-off-by: John Crispin + struct ar7200_usb_phy *priv = phy_get_drvdata(phy); + int err = 0; + -+ if (priv->rst_phy) -+ err = reset_control_deassert(priv->rst_phy); -+ if (!err && priv->suspend_override) ++ if (priv->suspend_override) + err = reset_control_assert(priv->suspend_override); -+ if (err && priv->rst_phy) -+ err = reset_control_assert(priv->rst_phy); ++ if (priv->rst_phy) ++ err |= reset_control_deassert(priv->rst_phy); ++ if (priv->rst_phy_analog) ++ err |= reset_control_deassert(priv->rst_phy_analog); + + return err; +} @@ -241,6 +242,8 @@ Signed-off-by: John Crispin + err = reset_control_deassert(priv->suspend_override); + if (priv->rst_phy) + err |= reset_control_assert(priv->rst_phy); ++ if (priv->rst_phy_analog) ++ err |= reset_control_assert(priv->rst_phy_analog); + + return err; +} @@ -266,6 +269,15 @@ Signed-off-by: John Crispin + return PTR_ERR(priv->rst_phy); + } + ++ priv->rst_phy_analog = devm_reset_control_get_optional( ++ &pdev->dev, "usb-phy-analog"); ++ if (IS_ERR(priv->rst_phy_analog)) { ++ if (PTR_ERR(priv->rst_phy_analog) == -ENOENT) ++ priv->rst_phy_analog = NULL; ++ else ++ return PTR_ERR(priv->rst_phy_analog); ++ } ++ + priv->suspend_override = devm_reset_control_get_optional( + &pdev->dev, "usb-suspend-override"); + if (IS_ERR(priv->suspend_override)) { diff --git a/target/linux/ath79/patches-4.19/0038-MIPS-ath79-add-missing-QCA955x-GMAC-registers.patch b/target/linux/ath79/patches-4.19/0038-MIPS-ath79-add-missing-QCA955x-GMAC-registers.patch new file mode 100644 index 000000000..dc0af2fe9 --- /dev/null +++ b/target/linux/ath79/patches-4.19/0038-MIPS-ath79-add-missing-QCA955x-GMAC-registers.patch @@ -0,0 +1,90 @@ +From 60efe35257b063ce584968f9f80b437030ce6ba6 Mon Sep 17 00:00:00 2001 +From: David Bauer +Date: Mon, 18 Mar 2019 00:54:06 +0100 +Subject: [PATCH] MIPS: ath79: add missing QCA955x GMAC registers + +This adds missing GMAC register definitions for the Qualcomm Atheros +QCA955X series MIPS SoCs. + +They originate from the platforms U-Boot code and the AVM FRITZ!WLAN +Repeater 450E's GPL tarball. + +Signed-off-by: David Bauer +--- + .../mips/include/asm/mach-ath79/ar71xx_regs.h | 54 +++++++++++++++++++ + 1 file changed, 54 insertions(+) + +--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h ++++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h +@@ -1249,7 +1249,12 @@ + */ + + #define QCA955X_GMAC_REG_ETH_CFG 0x00 ++#define QCA955X_GMAC_REG_SGMII_RESET 0x14 + #define QCA955X_GMAC_REG_SGMII_SERDES 0x18 ++#define QCA955X_GMAC_REG_MR_AN_CONTROL 0x1c ++#define QCA955X_GMAC_REG_MR_AN_STATUS 0x20 ++#define QCA955X_GMAC_REG_SGMII_CONFIG 0x34 ++#define QCA955X_GMAC_REG_SGMII_DEBUG 0x58 + + #define QCA955X_ETH_CFG_RGMII_EN BIT(0) + #define QCA955X_ETH_CFG_MII_GE0 BIT(1) +@@ -1271,9 +1276,58 @@ + #define QCA955X_ETH_CFG_TXE_DELAY_MASK 0x3 + #define QCA955X_ETH_CFG_TXE_DELAY_SHIFT 20 + ++#define QCA955X_SGMII_RESET_RX_CLK_N_RESET 0 ++#define QCA955X_SGMII_RESET_RX_CLK_N BIT(0) ++#define QCA955X_SGMII_RESET_TX_CLK_N BIT(1) ++#define QCA955X_SGMII_RESET_RX_125M_N BIT(2) ++#define QCA955X_SGMII_RESET_TX_125M_N BIT(3) ++#define QCA955X_SGMII_RESET_HW_RX_125M_N BIT(4) ++ + #define QCA955X_SGMII_SERDES_LOCK_DETECT_STATUS BIT(15) + #define QCA955X_SGMII_SERDES_RES_CALIBRATION_SHIFT 23 + #define QCA955X_SGMII_SERDES_RES_CALIBRATION_MASK 0xf ++ ++#define QCA955X_MR_AN_CONTROL_SPEED_SEL1 BIT(6) ++#define QCA955X_MR_AN_CONTROL_DUPLEX_MODE BIT(8) ++#define QCA955X_MR_AN_CONTROL_RESTART_AN BIT(9) ++#define QCA955X_MR_AN_CONTROL_POWER_DOWN BIT(11) ++#define QCA955X_MR_AN_CONTROL_AN_ENABLE BIT(12) ++#define QCA955X_MR_AN_CONTROL_SPEED_SEL0 BIT(13) ++#define QCA955X_MR_AN_CONTROL_LOOPBACK BIT(14) ++#define QCA955X_MR_AN_CONTROL_PHY_RESET BIT(15) ++ ++#define QCA955X_MR_AN_STATUS_EXT_CAP BIT(0) ++#define QCA955X_MR_AN_STATUS_LINK_UP BIT(2) ++#define QCA955X_MR_AN_STATUS_AN_ABILITY BIT(3) ++#define QCA955X_MR_AN_STATUS_REMOTE_FAULT BIT(4) ++#define QCA955X_MR_AN_STATUS_AN_COMPLETE BIT(5) ++#define QCA955X_MR_AN_STATUS_NO_PREAMBLE BIT(6) ++#define QCA955X_MR_AN_STATUS_BASE_PAGE BIT(7) ++ ++#define QCA955X_SGMII_CONFIG_MODE_CTRL_SHIFT 0 ++#define QCA955X_SGMII_CONFIG_MODE_CTRL_MASK 0x7 ++#define QCA955X_SGMII_CONFIG_ENABLE_SGMII_TX_PAUSE BIT(3) ++#define QCA955X_SGMII_CONFIG_MR_REG4_CHANGED BIT(4) ++#define QCA955X_SGMII_CONFIG_FORCE_SPEED BIT(5) ++#define QCA955X_SGMII_CONFIG_SPEED_SHIFT 6 ++#define QCA955X_SGMII_CONFIG_SPEED_MASK 0xc0 ++#define QCA955X_SGMII_CONFIG_REMOTE_PHY_LOOPBACK BIT(8) ++#define QCA955X_SGMII_CONFIG_NEXT_PAGE_LOADED BIT(9) ++#define QCA955X_SGMII_CONFIG_MDIO_ENABLE BIT(10) ++#define QCA955X_SGMII_CONFIG_MDIO_PULSE BIT(11) ++#define QCA955X_SGMII_CONFIG_MDIO_COMPLETE BIT(12) ++#define QCA955X_SGMII_CONFIG_PRBS_ENABLE BIT(13) ++#define QCA955X_SGMII_CONFIG_BERT_ENABLE BIT(14) ++ ++#define QCA955X_SGMII_DEBUG_TX_STATE_MASK 0xff ++#define QCA955X_SGMII_DEBUG_TX_STATE_SHIFT 0 ++#define QCA955X_SGMII_DEBUG_RX_STATE_MASK 0xff00 ++#define QCA955X_SGMII_DEBUG_RX_STATE_SHIFT 8 ++#define QCA955X_SGMII_DEBUG_RX_SYNC_STATE_MASK 0xff0000 ++#define QCA955X_SGMII_DEBUG_RX_SYNC_STATE_SHIFT 16 ++#define QCA955X_SGMII_DEBUG_ARB_STATE_MASK 0xf000000 ++#define QCA955X_SGMII_DEBUG_ARB_STATE_SHIFT 24 ++ + /* + * QCA956X GMAC Interface + */ diff --git a/target/linux/ath79/patches-4.19/0038-at803x-disable-delays.patch b/target/linux/ath79/patches-4.19/0038-at803x-disable-delays.patch index 56325a831..c7a9b3cc7 100644 --- a/target/linux/ath79/patches-4.19/0038-at803x-disable-delays.patch +++ b/target/linux/ath79/patches-4.19/0038-at803x-disable-delays.patch @@ -10,7 +10,7 @@ with kernel 5.1 and higher. It can be safely dropped with kernel 5.1. --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c -@@ -295,6 +295,14 @@ static int at803x_config_init(struct phy +@@ -279,6 +279,14 @@ static int at803x_config_init(struct phy if (ret < 0) return ret; diff --git a/target/linux/ath79/patches-4.19/403-mtd_fix_cfi_cmdset_0002_status_check.patch b/target/linux/ath79/patches-4.19/403-mtd_fix_cfi_cmdset_0002_status_check.patch deleted file mode 100644 index 702e2a5b0..000000000 --- a/target/linux/ath79/patches-4.19/403-mtd_fix_cfi_cmdset_0002_status_check.patch +++ /dev/null @@ -1,62 +0,0 @@ ---- a/drivers/mtd/chips/cfi_cmdset_0002.c -+++ b/drivers/mtd/chips/cfi_cmdset_0002.c -@@ -1640,7 +1640,7 @@ static int __xipram do_write_oneword(str - } - - if (chip_good(map, adr, datum)) -- break; -+ goto enable_xip; - - /* Latency issues. Drop the lock, wait a while and retry */ - UDELAY(map, chip, adr, 1); -@@ -1657,6 +1657,8 @@ static int __xipram do_write_oneword(str - goto retry; - } - } -+ -+ enable_xip: - xip_enable(map, chip, adr); - op_done: - if (mode == FL_OTP_WRITE) -@@ -2235,7 +2237,6 @@ static int cfi_amdstd_panic_write(struct - return 0; - } - -- - /* - * Handle devices with one erase region, that only implement - * the chip erase command. -@@ -2303,7 +2304,7 @@ static int __xipram do_erase_chip(struct - } - - if (chip_good(map, adr, map_word_ff(map))) -- break; -+ goto op_done; - - if (time_after(jiffies, timeo)) { - printk(KERN_WARNING "MTD %s(): software timeout\n", -@@ -2327,6 +2328,7 @@ static int __xipram do_erase_chip(struct - } - } - -+ op_done: - chip->state = FL_READY; - xip_enable(map, chip, adr); - DISABLE_VPP(map); -@@ -2399,7 +2401,7 @@ static int __xipram do_erase_oneblock(st - } - - if (chip_good(map, adr, map_word_ff(map))) -- break; -+ goto op_done; - - if (time_after(jiffies, timeo)) { - printk(KERN_WARNING "MTD %s(): software timeout\n", -@@ -2423,6 +2425,7 @@ static int __xipram do_erase_oneblock(st - } - } - -+ op_done: - chip->state = FL_READY; - xip_enable(map, chip, adr); - DISABLE_VPP(map); diff --git a/target/linux/ath79/patches-4.19/425-at803x-allow-sgmii-aneg-override.patch b/target/linux/ath79/patches-4.19/425-at803x-allow-sgmii-aneg-override.patch new file mode 100644 index 000000000..43c11386c --- /dev/null +++ b/target/linux/ath79/patches-4.19/425-at803x-allow-sgmii-aneg-override.patch @@ -0,0 +1,16 @@ +--- a/drivers/net/phy/at803x.c ++++ b/drivers/net/phy/at803x.c +@@ -391,6 +391,13 @@ static int at803x_aneg_done(struct phy_d + if (!(phy_read(phydev, AT803X_PSSR) & AT803X_PSSR_MR_AN_COMPLETE)) { + pr_warn("803x_aneg_done: SGMII link is not ok\n"); + aneg_done = 0; ++#ifdef CONFIG_OF_MDIO ++ if (phydev->mdio.dev.of_node && ++ of_property_read_bool(phydev->mdio.dev.of_node, ++ "at803x-override-sgmii-link-check")) { ++ aneg_done = 1; ++ } ++#endif + } + /* switch back to copper page */ + phy_write(phydev, AT803X_REG_CHIP_CONFIG, ccr | AT803X_BT_BX_REG_SEL); diff --git a/target/linux/ath79/patches-4.19/490-usb-ehci-add-quirks-for-qca-socs.patch b/target/linux/ath79/patches-4.19/490-usb-ehci-add-quirks-for-qca-socs.patch deleted file mode 100644 index 4e2a6fece..000000000 --- a/target/linux/ath79/patches-4.19/490-usb-ehci-add-quirks-for-qca-socs.patch +++ /dev/null @@ -1,103 +0,0 @@ ---- a/drivers/usb/host/ehci-hcd.c -+++ b/drivers/usb/host/ehci-hcd.c -@@ -239,6 +239,37 @@ int ehci_reset(struct ehci_hcd *ehci) - command |= CMD_RESET; - dbg_cmd (ehci, "reset", command); - ehci_writel(ehci, command, &ehci->regs->command); -+ -+ if (ehci->qca_force_host_mode) { -+ u32 usbmode; -+ -+ udelay(1000); -+ -+ usbmode = ehci_readl(ehci, &ehci->regs->usbmode); -+ usbmode |= USBMODE_CM_HC | (1 << 4); -+ ehci_writel(ehci, usbmode, &ehci->regs->usbmode); -+ -+ ehci_dbg(ehci, "forced host mode, usbmode: %08x\n", -+ ehci_readl(ehci, &ehci->regs->usbmode)); -+ } -+ -+ if (ehci->qca_force_16bit_ptw) { -+ u32 port_status; -+ -+ udelay(1000); -+ -+ /* enable 16-bit UTMI interface */ -+ port_status = ehci_readl(ehci, &ehci->regs->port_status[0]); -+ port_status |= BIT(28); -+ ehci_writel(ehci, port_status, &ehci->regs->port_status[0]); -+ -+ ehci_dbg(ehci, "16-bit UTMI interface enabled, status: %08x\n", -+ ehci_readl(ehci, &ehci->regs->port_status[0])); -+ } -+ -+ if (ehci->reset_notifier) -+ ehci->reset_notifier(ehci_to_hcd(ehci)); -+ - ehci->rh_state = EHCI_RH_HALTED; - ehci->next_statechange = jiffies; - retval = ehci_handshake(ehci, &ehci->regs->command, ---- a/drivers/usb/host/ehci.h -+++ b/drivers/usb/host/ehci.h -@@ -219,6 +219,10 @@ struct ehci_hcd { /* one per controlle - unsigned need_oc_pp_cycle:1; /* MPC834X port power */ - unsigned imx28_write_fix:1; /* For Freescale i.MX28 */ - unsigned ignore_oc:1; -+ unsigned qca_force_host_mode:1; -+ unsigned qca_force_16bit_ptw:1; /* force 16 bit UTMI */ -+ -+ void (*reset_notifier)(struct usb_hcd *hcd); - - /* required for usb32 quirk */ - #define OHCI_CTRL_HCFS (3 << 6) ---- a/include/linux/usb/ehci_pdriver.h -+++ b/include/linux/usb/ehci_pdriver.h -@@ -51,6 +51,8 @@ struct usb_ehci_pdata { - unsigned reset_on_resume:1; - unsigned dma_mask_64:1; - unsigned ignore_oc:1; -+ unsigned qca_force_host_mode:1; -+ unsigned qca_force_16bit_ptw:1; - - /* Turn on all power and clocks */ - int (*power_on)(struct platform_device *pdev); -@@ -60,6 +62,7 @@ struct usb_ehci_pdata { - * turn off everything else */ - void (*power_suspend)(struct platform_device *pdev); - int (*pre_setup)(struct usb_hcd *hcd); -+ void (*reset_notifier)(struct platform_device *pdev); - }; - - #endif /* __USB_CORE_EHCI_PDRIVER_H */ ---- a/drivers/usb/host/ehci-platform.c -+++ b/drivers/usb/host/ehci-platform.c -@@ -48,6 +48,14 @@ struct ehci_platform_priv { - - static const char hcd_name[] = "ehci-platform"; - -+static void ehci_platform_reset_notifier(struct usb_hcd *hcd) -+{ -+ struct platform_device *pdev = to_platform_device(hcd->self.controller); -+ struct usb_ehci_pdata *pdata = pdev->dev.platform_data; -+ -+ pdata->reset_notifier(pdev); -+} -+ - static int ehci_platform_reset(struct usb_hcd *hcd) - { - struct platform_device *pdev = to_platform_device(hcd->self.controller); -@@ -215,6 +223,13 @@ static int ehci_platform_probe(struct pl - priv->reset_on_resume = true; - if (pdata->ignore_oc) - ehci->ignore_oc = 1; -+ if (pdata->qca_force_host_mode) -+ ehci->qca_force_host_mode = 1; -+ if (pdata->qca_force_16bit_ptw) -+ ehci->qca_force_16bit_ptw = 1; -+ -+ if (pdata->reset_notifier) -+ ehci->reset_notifier = ehci_platform_reset_notifier; - - #ifndef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO - if (ehci->big_endian_mmio) { diff --git a/target/linux/ath79/patches-4.19/910-unaligned_access_hacks.patch b/target/linux/ath79/patches-4.19/910-unaligned_access_hacks.patch index dba7df5f3..6f36dc683 100644 --- a/target/linux/ath79/patches-4.19/910-unaligned_access_hacks.patch +++ b/target/linux/ath79/patches-4.19/910-unaligned_access_hacks.patch @@ -728,7 +728,7 @@ EXPORT_SYMBOL(xfrm_parse_spi); --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c -@@ -3891,14 +3891,16 @@ static bool tcp_parse_aligned_timestamp( +@@ -3895,14 +3895,16 @@ static bool tcp_parse_aligned_timestamp( { const __be32 *ptr = (const __be32 *)(th + 1); diff --git a/target/linux/brcm2708/image/gen_rpi_sdcard_img.sh b/target/linux/brcm2708/image/gen_rpi_sdcard_img.sh index 60b66c372..c8140ec3d 100755 --- a/target/linux/brcm2708/image/gen_rpi_sdcard_img.sh +++ b/target/linux/brcm2708/image/gen_rpi_sdcard_img.sh @@ -1,6 +1,6 @@ -#!/usr/bin/env bash +#!/bin/sh -set -x +set -x [ $# -eq 5 ] || { echo "SYNTAX: $0 " exit 1 @@ -24,6 +24,3 @@ ROOTFSSIZE="$(($4 / 512))" dd bs=512 if="$BOOTFS" of="$OUTPUT" seek="$BOOTOFFSET" conv=notrunc dd bs=512 if="$ROOTFS" of="$OUTPUT" seek="$ROOTFSOFFSET" conv=notrunc - - - diff --git a/target/linux/brcm2708/patches-4.19/950-0039-Add-dwc_otg-driver.patch b/target/linux/brcm2708/patches-4.19/950-0039-Add-dwc_otg-driver.patch index 346a57505..79c2aa17f 100644 --- a/target/linux/brcm2708/patches-4.19/950-0039-Add-dwc_otg-driver.patch +++ b/target/linux/brcm2708/patches-4.19/950-0039-Add-dwc_otg-driver.patch @@ -917,7 +917,7 @@ Fixes https://github.com/raspberrypi/linux/issues/2408 } --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c -@@ -5221,7 +5221,7 @@ static void port_event(struct usb_hub *h +@@ -5222,7 +5222,7 @@ static void port_event(struct usb_hub *h u16 status = 0, unused; port_dev->over_current_count++; diff --git a/target/linux/brcm2708/patches-4.19/950-0122-gpiolib-Don-t-prevent-IRQ-usage-of-output-GPIOs.patch b/target/linux/brcm2708/patches-4.19/950-0122-gpiolib-Don-t-prevent-IRQ-usage-of-output-GPIOs.patch index 17867c330..5cec38351 100644 --- a/target/linux/brcm2708/patches-4.19/950-0122-gpiolib-Don-t-prevent-IRQ-usage-of-output-GPIOs.patch +++ b/target/linux/brcm2708/patches-4.19/950-0122-gpiolib-Don-t-prevent-IRQ-usage-of-output-GPIOs.patch @@ -26,7 +26,7 @@ Signed-off-by: Phil Elwell /* Device and char device-related information */ static DEFINE_IDA(gpio_ida); static dev_t gpio_devt; -@@ -2654,7 +2656,7 @@ int gpiod_direction_output(struct gpio_d +@@ -2662,7 +2664,7 @@ int gpiod_direction_output(struct gpio_d value = !!value; /* GPIOs used for IRQs shall not be set as output */ @@ -35,7 +35,7 @@ Signed-off-by: Phil Elwell gpiod_err(desc, "%s: tried to set a GPIO tied to an IRQ as output\n", __func__); -@@ -3353,7 +3355,7 @@ int gpiochip_lock_as_irq(struct gpio_chi +@@ -3361,7 +3363,7 @@ int gpiochip_lock_as_irq(struct gpio_chi } } diff --git a/target/linux/brcm2708/patches-4.19/950-0127-net-lan78xx-Disable-TCP-Segmentation-Offload-TSO.patch b/target/linux/brcm2708/patches-4.19/950-0127-net-lan78xx-Disable-TCP-Segmentation-Offload-TSO.patch index ef1bbaac6..28515c9d0 100644 --- a/target/linux/brcm2708/patches-4.19/950-0127-net-lan78xx-Disable-TCP-Segmentation-Offload-TSO.patch +++ b/target/linux/brcm2708/patches-4.19/950-0127-net-lan78xx-Disable-TCP-Segmentation-Offload-TSO.patch @@ -37,7 +37,7 @@ Signed-off-by: Dave Stevenson static int lan78xx_read_reg(struct lan78xx_net *dev, u32 index, u32 *data) { u32 *buf = kmalloc(sizeof(u32), GFP_KERNEL); -@@ -3012,8 +3021,14 @@ static int lan78xx_bind(struct lan78xx_n +@@ -3009,8 +3018,14 @@ static int lan78xx_bind(struct lan78xx_n if (DEFAULT_RX_CSUM_ENABLE) dev->net->features |= NETIF_F_RXCSUM; diff --git a/target/linux/brcm2708/patches-4.19/950-0261-lan78xx-Debounce-link-events-to-minimize-poll-storm.patch b/target/linux/brcm2708/patches-4.19/950-0261-lan78xx-Debounce-link-events-to-minimize-poll-storm.patch index b552cc0b9..98e97706b 100644 --- a/target/linux/brcm2708/patches-4.19/950-0261-lan78xx-Debounce-link-events-to-minimize-poll-storm.patch +++ b/target/linux/brcm2708/patches-4.19/950-0261-lan78xx-Debounce-link-events-to-minimize-poll-storm.patch @@ -28,7 +28,7 @@ See: https://github.com/raspberrypi/linux/issues/2447 static int lan78xx_read_reg(struct lan78xx_net *dev, u32 index, u32 *data) { u32 *buf = kmalloc(sizeof(u32), GFP_KERNEL); -@@ -3825,7 +3830,12 @@ static int lan78xx_probe(struct usb_inte +@@ -3823,7 +3828,12 @@ static int lan78xx_probe(struct usb_inte dev->pipe_intr = usb_rcvintpipe(dev->udev, dev->ep_intr->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); diff --git a/target/linux/brcm2708/patches-4.19/950-0415-lan78xx-use-default-alignment-for-rx-buffers.patch b/target/linux/brcm2708/patches-4.19/950-0415-lan78xx-use-default-alignment-for-rx-buffers.patch index f5313aec3..c5eca2e07 100644 --- a/target/linux/brcm2708/patches-4.19/950-0415-lan78xx-use-default-alignment-for-rx-buffers.patch +++ b/target/linux/brcm2708/patches-4.19/950-0415-lan78xx-use-default-alignment-for-rx-buffers.patch @@ -12,7 +12,7 @@ in both dwc_otg and in ipv6 processing. --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c -@@ -3259,7 +3259,7 @@ static int rx_submit(struct lan78xx_net +@@ -3256,7 +3256,7 @@ static int rx_submit(struct lan78xx_net size_t size = dev->rx_urb_size; int ret = 0; diff --git a/target/linux/brcm2708/patches-4.19/950-0429-Bluetooth-Check-key-sizes-only-when-Secure-Simple-Pa.patch b/target/linux/brcm2708/patches-4.19/950-0429-Bluetooth-Check-key-sizes-only-when-Secure-Simple-Pa.patch index 7bbee63f4..ac7a9aea3 100644 --- a/target/linux/brcm2708/patches-4.19/950-0429-Bluetooth-Check-key-sizes-only-when-Secure-Simple-Pa.patch +++ b/target/linux/brcm2708/patches-4.19/950-0429-Bluetooth-Check-key-sizes-only-when-Secure-Simple-Pa.patch @@ -21,7 +21,7 @@ Cc: stable@vger.kernel.org --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c -@@ -1280,8 +1280,13 @@ int hci_conn_check_link_mode(struct hci_ +@@ -1282,8 +1282,13 @@ int hci_conn_check_link_mode(struct hci_ return 0; } diff --git a/target/linux/brcm2708/patches-4.19/950-0642-drm-modes-Support-modes-names-on-the-command-line.patch b/target/linux/brcm2708/patches-4.19/950-0642-drm-modes-Support-modes-names-on-the-command-line.patch index aee684a95..1cacab25e 100644 --- a/target/linux/brcm2708/patches-4.19/950-0642-drm-modes-Support-modes-names-on-the-command-line.patch +++ b/target/linux/brcm2708/patches-4.19/950-0642-drm-modes-Support-modes-names-on-the-command-line.patch @@ -45,7 +45,7 @@ Link: https://patchwork.freedesktop.org/patch/msgid/18443e0c3bdbbd16cea4ec63bc7f mode->rb ? " reduced blanking" : "", --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c -@@ -2099,6 +2099,10 @@ struct drm_display_mode *drm_pick_cmdlin +@@ -2104,6 +2104,10 @@ struct drm_display_mode *drm_pick_cmdlin prefer_non_interlace = !cmdline_mode->interlace; again: list_for_each_entry(mode, &fb_helper_conn->connector->modes, head) { diff --git a/target/linux/brcm2708/patches-4.19/950-0643-drm-modes-Allow-to-specify-rotation-and-reflection-o.patch b/target/linux/brcm2708/patches-4.19/950-0643-drm-modes-Allow-to-specify-rotation-and-reflection-o.patch index f9ba856c4..0b2a18544 100644 --- a/target/linux/brcm2708/patches-4.19/950-0643-drm-modes-Allow-to-specify-rotation-and-reflection-o.patch +++ b/target/linux/brcm2708/patches-4.19/950-0643-drm-modes-Allow-to-specify-rotation-and-reflection-o.patch @@ -52,7 +52,7 @@ Link: https://patchwork.freedesktop.org/patch/msgid/777da16e42db757c1f5b414b5ca3 What is the VESA(TM) Coordinated Video Timings (CVT)? --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c -@@ -2464,6 +2464,7 @@ static void drm_setup_crtc_rotation(stru +@@ -2469,6 +2469,7 @@ static void drm_setup_crtc_rotation(stru struct drm_connector *connector) { struct drm_plane *plane = fb_crtc->mode_set.crtc->primary; @@ -60,7 +60,7 @@ Link: https://patchwork.freedesktop.org/patch/msgid/777da16e42db757c1f5b414b5ca3 uint64_t valid_mask = 0; int i, rotation; -@@ -2483,6 +2484,35 @@ static void drm_setup_crtc_rotation(stru +@@ -2488,6 +2489,35 @@ static void drm_setup_crtc_rotation(stru rotation = DRM_MODE_ROTATE_0; } diff --git a/target/linux/brcm2708/patches-4.19/950-0649-drm-modes-Don-t-apply-cmdline-s-rotation-if-it-wasn-.patch b/target/linux/brcm2708/patches-4.19/950-0649-drm-modes-Don-t-apply-cmdline-s-rotation-if-it-wasn-.patch index 4cb0a543c..b97d01879 100644 --- a/target/linux/brcm2708/patches-4.19/950-0649-drm-modes-Don-t-apply-cmdline-s-rotation-if-it-wasn-.patch +++ b/target/linux/brcm2708/patches-4.19/950-0649-drm-modes-Don-t-apply-cmdline-s-rotation-if-it-wasn-.patch @@ -23,7 +23,7 @@ Signed-off-by: Dave Stevenson --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c -@@ -2497,7 +2497,7 @@ static void drm_setup_crtc_rotation(stru +@@ -2502,7 +2502,7 @@ static void drm_setup_crtc_rotation(stru * simple XOR between the two handle the addition nicely. */ cmdline = &connector->cmdline_mode; diff --git a/target/linux/brcm2708/patches-4.19/950-0700-regulator-gpio-Allow-nonexclusive-GPIO-access.patch b/target/linux/brcm2708/patches-4.19/950-0700-regulator-gpio-Allow-nonexclusive-GPIO-access.patch index e0ffaae20..a940736c3 100644 --- a/target/linux/brcm2708/patches-4.19/950-0700-regulator-gpio-Allow-nonexclusive-GPIO-access.patch +++ b/target/linux/brcm2708/patches-4.19/950-0700-regulator-gpio-Allow-nonexclusive-GPIO-access.patch @@ -41,7 +41,7 @@ Signed-off-by: Mark Brown --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c -@@ -3979,8 +3979,23 @@ struct gpio_desc *__must_check gpiod_get +@@ -3988,8 +3988,23 @@ struct gpio_desc *__must_check gpiod_get * the device name as label */ status = gpiod_request(desc, con_id ? con_id : devname); diff --git a/target/linux/brcm2708/patches-4.19/950-0701-gpio-Enable-nonexclusive-gpiods-from-DT-nodes.patch b/target/linux/brcm2708/patches-4.19/950-0701-gpio-Enable-nonexclusive-gpiods-from-DT-nodes.patch index e8e63a279..a4139e6d3 100644 --- a/target/linux/brcm2708/patches-4.19/950-0701-gpio-Enable-nonexclusive-gpiods-from-DT-nodes.patch +++ b/target/linux/brcm2708/patches-4.19/950-0701-gpio-Enable-nonexclusive-gpiods-from-DT-nodes.patch @@ -23,7 +23,7 @@ Signed-off-by: Mark Brown --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c -@@ -4053,6 +4053,8 @@ struct gpio_desc *gpiod_get_from_of_node +@@ -4062,6 +4062,8 @@ struct gpio_desc *gpiod_get_from_of_node transitory = flags & OF_GPIO_TRANSITORY; ret = gpiod_request(desc, label); diff --git a/target/linux/brcm63xx/patches-4.14/143-gpio-fix-device-tree-gpio-hogs-on-dual-role-gpio-pin.patch b/target/linux/brcm63xx/patches-4.14/143-gpio-fix-device-tree-gpio-hogs-on-dual-role-gpio-pin.patch index 31d2a1794..bbd39811c 100644 --- a/target/linux/brcm63xx/patches-4.14/143-gpio-fix-device-tree-gpio-hogs-on-dual-role-gpio-pin.patch +++ b/target/linux/brcm63xx/patches-4.14/143-gpio-fix-device-tree-gpio-hogs-on-dual-role-gpio-pin.patch @@ -89,7 +89,7 @@ Signed-off-by: Jonas Gorski --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c -@@ -1950,7 +1950,8 @@ int gpiochip_add_pingroup_range(struct g +@@ -1958,7 +1958,8 @@ int gpiochip_add_pingroup_range(struct g list_add_tail(&pin_range->node, &gdev->pin_ranges); @@ -99,7 +99,7 @@ Signed-off-by: Jonas Gorski } EXPORT_SYMBOL_GPL(gpiochip_add_pingroup_range); -@@ -2002,7 +2003,7 @@ int gpiochip_add_pin_range(struct gpio_c +@@ -2010,7 +2011,7 @@ int gpiochip_add_pin_range(struct gpio_c list_add_tail(&pin_range->node, &gdev->pin_ranges); diff --git a/target/linux/brcm63xx/patches-4.19/143-gpio-fix-device-tree-gpio-hogs-on-dual-role-gpio-pin.patch b/target/linux/brcm63xx/patches-4.19/143-gpio-fix-device-tree-gpio-hogs-on-dual-role-gpio-pin.patch index 395b17c8d..13225beae 100644 --- a/target/linux/brcm63xx/patches-4.19/143-gpio-fix-device-tree-gpio-hogs-on-dual-role-gpio-pin.patch +++ b/target/linux/brcm63xx/patches-4.19/143-gpio-fix-device-tree-gpio-hogs-on-dual-role-gpio-pin.patch @@ -89,7 +89,7 @@ Signed-off-by: Jonas Gorski --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c -@@ -2197,7 +2197,8 @@ int gpiochip_add_pingroup_range(struct g +@@ -2205,7 +2205,8 @@ int gpiochip_add_pingroup_range(struct g list_add_tail(&pin_range->node, &gdev->pin_ranges); @@ -99,7 +99,7 @@ Signed-off-by: Jonas Gorski } EXPORT_SYMBOL_GPL(gpiochip_add_pingroup_range); -@@ -2254,7 +2255,7 @@ int gpiochip_add_pin_range(struct gpio_c +@@ -2262,7 +2263,7 @@ int gpiochip_add_pin_range(struct gpio_c list_add_tail(&pin_range->node, &gdev->pin_ranges); diff --git a/target/linux/generic/backport-4.14/030-USB-serial-option-fix-dwm-158-3g-modem-interface.patch b/target/linux/generic/backport-4.14/030-USB-serial-option-fix-dwm-158-3g-modem-interface.patch index 817b112f9..c09a5e47f 100644 --- a/target/linux/generic/backport-4.14/030-USB-serial-option-fix-dwm-158-3g-modem-interface.patch +++ b/target/linux/generic/backport-4.14/030-USB-serial-option-fix-dwm-158-3g-modem-interface.patch @@ -30,7 +30,7 @@ Signed-off-by: Johan Hovold --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c -@@ -1968,7 +1968,8 @@ static const struct usb_device_id option +@@ -1981,7 +1981,8 @@ static const struct usb_device_id option { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7d01, 0xff) }, /* D-Link DWM-156 (variant) */ { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7d02, 0xff) }, { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7d03, 0xff) }, diff --git a/target/linux/generic/backport-4.14/303-v4.16-netfilter-nf_tables-remove-multihook-chains-and-fami.patch b/target/linux/generic/backport-4.14/303-v4.16-netfilter-nf_tables-remove-multihook-chains-and-fami.patch index a2388a1b9..f43456a99 100644 --- a/target/linux/generic/backport-4.14/303-v4.16-netfilter-nf_tables-remove-multihook-chains-and-fami.patch +++ b/target/linux/generic/backport-4.14/303-v4.16-netfilter-nf_tables-remove-multihook-chains-and-fami.patch @@ -264,7 +264,7 @@ Signed-off-by: Pablo Neira Ayuso } nft_chain_release_hook(&hook); } -@@ -5156,10 +5144,9 @@ static int nf_tables_commit(struct net * +@@ -5162,10 +5150,9 @@ static int nf_tables_commit(struct net * case NFT_MSG_DELCHAIN: list_del_rcu(&trans->ctx.chain->list); nf_tables_chain_notify(&trans->ctx, NFT_MSG_DELCHAIN); @@ -278,7 +278,7 @@ Signed-off-by: Pablo Neira Ayuso break; case NFT_MSG_NEWRULE: nft_clear(trans->ctx.net, nft_trans_rule(trans)); -@@ -5296,10 +5283,9 @@ static int nf_tables_abort(struct net *n +@@ -5302,10 +5289,9 @@ static int nf_tables_abort(struct net *n } else { trans->ctx.table->use--; list_del_rcu(&trans->ctx.chain->list); @@ -292,7 +292,7 @@ Signed-off-by: Pablo Neira Ayuso } break; case NFT_MSG_DELCHAIN: -@@ -5402,7 +5388,7 @@ int nft_chain_validate_hooks(const struc +@@ -5408,7 +5394,7 @@ int nft_chain_validate_hooks(const struc if (nft_is_base_chain(chain)) { basechain = nft_base_chain(chain); @@ -301,7 +301,7 @@ Signed-off-by: Pablo Neira Ayuso return 0; return -EOPNOTSUPP; -@@ -5884,8 +5870,7 @@ int __nft_release_basechain(struct nft_c +@@ -5890,8 +5876,7 @@ int __nft_release_basechain(struct nft_c BUG_ON(!nft_is_base_chain(ctx->chain)); @@ -311,7 +311,7 @@ Signed-off-by: Pablo Neira Ayuso list_for_each_entry_safe(rule, nr, &ctx->chain->rules, list) { list_del(&rule->list); ctx->chain->use--; -@@ -5914,8 +5899,7 @@ static void __nft_release_afinfo(struct +@@ -5920,8 +5905,7 @@ static void __nft_release_afinfo(struct list_for_each_entry_safe(table, nt, &afi->tables, list) { list_for_each_entry(chain, &table->chains, list) diff --git a/target/linux/generic/backport-4.14/321-v4.16-netfilter-nf_tables-add-flow-table-netlink-frontend.patch b/target/linux/generic/backport-4.14/321-v4.16-netfilter-nf_tables-add-flow-table-netlink-frontend.patch index 3b090a6f1..f0109e482 100644 --- a/target/linux/generic/backport-4.14/321-v4.16-netfilter-nf_tables-add-flow-table-netlink-frontend.patch +++ b/target/linux/generic/backport-4.14/321-v4.16-netfilter-nf_tables-add-flow-table-netlink-frontend.patch @@ -292,7 +292,7 @@ Signed-off-by: Pablo Neira Ayuso list_for_each_entry_safe(obj, ne, &ctx->table->objects, list) { err = nft_delobj(ctx, obj); if (err < 0) -@@ -4856,6 +4900,605 @@ static void nf_tables_obj_notify(const s +@@ -4862,6 +4906,605 @@ static void nf_tables_obj_notify(const s ctx->afi->family, ctx->report, GFP_KERNEL); } @@ -898,7 +898,7 @@ Signed-off-by: Pablo Neira Ayuso static int nf_tables_fill_gen_info(struct sk_buff *skb, struct net *net, u32 portid, u32 seq) { -@@ -4886,6 +5529,49 @@ nla_put_failure: +@@ -4892,6 +5535,49 @@ nla_put_failure: return -EMSGSIZE; } @@ -948,7 +948,7 @@ Signed-off-by: Pablo Neira Ayuso static void nf_tables_gen_notify(struct net *net, struct sk_buff *skb, int event) { -@@ -5038,6 +5724,21 @@ static const struct nfnl_callback nf_tab +@@ -5044,6 +5730,21 @@ static const struct nfnl_callback nf_tab .attr_count = NFTA_OBJ_MAX, .policy = nft_obj_policy, }, @@ -970,7 +970,7 @@ Signed-off-by: Pablo Neira Ayuso }; static void nft_chain_commit_update(struct nft_trans *trans) -@@ -5086,6 +5787,9 @@ static void nf_tables_commit_release(str +@@ -5092,6 +5793,9 @@ static void nf_tables_commit_release(str case NFT_MSG_DELOBJ: nft_obj_destroy(nft_trans_obj(trans)); break; @@ -980,7 +980,7 @@ Signed-off-by: Pablo Neira Ayuso } kfree(trans); } -@@ -5205,6 +5909,21 @@ static int nf_tables_commit(struct net * +@@ -5211,6 +5915,21 @@ static int nf_tables_commit(struct net * nf_tables_obj_notify(&trans->ctx, nft_trans_obj(trans), NFT_MSG_DELOBJ); break; @@ -1002,7 +1002,7 @@ Signed-off-by: Pablo Neira Ayuso } } -@@ -5242,6 +5961,9 @@ static void nf_tables_abort_release(stru +@@ -5248,6 +5967,9 @@ static void nf_tables_abort_release(stru case NFT_MSG_NEWOBJ: nft_obj_destroy(nft_trans_obj(trans)); break; @@ -1012,7 +1012,7 @@ Signed-off-by: Pablo Neira Ayuso } kfree(trans); } -@@ -5333,6 +6055,17 @@ static int nf_tables_abort(struct net *n +@@ -5339,6 +6061,17 @@ static int nf_tables_abort(struct net *n nft_clear(trans->ctx.net, nft_trans_obj(trans)); nft_trans_destroy(trans); break; @@ -1030,7 +1030,7 @@ Signed-off-by: Pablo Neira Ayuso } } -@@ -5883,6 +6616,7 @@ EXPORT_SYMBOL_GPL(__nft_release_basechai +@@ -5889,6 +6622,7 @@ EXPORT_SYMBOL_GPL(__nft_release_basechai /* Called by nft_unregister_afinfo() from __net_exit path, nfnl_lock is held. */ static void __nft_release_afinfo(struct net *net, struct nft_af_info *afi) { @@ -1038,7 +1038,7 @@ Signed-off-by: Pablo Neira Ayuso struct nft_table *table, *nt; struct nft_chain *chain, *nc; struct nft_object *obj, *ne; -@@ -5896,6 +6630,9 @@ static void __nft_release_afinfo(struct +@@ -5902,6 +6636,9 @@ static void __nft_release_afinfo(struct list_for_each_entry_safe(table, nt, &afi->tables, list) { list_for_each_entry(chain, &table->chains, list) nf_tables_unregister_hook(net, table, chain); @@ -1048,7 +1048,7 @@ Signed-off-by: Pablo Neira Ayuso /* No packets are walking on these chains anymore. */ ctx.table = table; list_for_each_entry(chain, &table->chains, list) { -@@ -5906,6 +6643,11 @@ static void __nft_release_afinfo(struct +@@ -5912,6 +6649,11 @@ static void __nft_release_afinfo(struct nf_tables_rule_release(&ctx, rule); } } @@ -1060,7 +1060,7 @@ Signed-off-by: Pablo Neira Ayuso list_for_each_entry_safe(set, ns, &table->sets, list) { list_del(&set->list); table->use--; -@@ -5949,6 +6691,8 @@ static int __init nf_tables_module_init( +@@ -5955,6 +6697,8 @@ static int __init nf_tables_module_init( if (err < 0) goto err3; @@ -1069,7 +1069,7 @@ Signed-off-by: Pablo Neira Ayuso pr_info("nf_tables: (c) 2007-2009 Patrick McHardy \n"); return register_pernet_subsys(&nf_tables_net_ops); err3: -@@ -5963,6 +6707,7 @@ static void __exit nf_tables_module_exit +@@ -5969,6 +6713,7 @@ static void __exit nf_tables_module_exit { unregister_pernet_subsys(&nf_tables_net_ops); nfnetlink_subsys_unregister(&nf_tables_subsys); diff --git a/target/linux/generic/backport-4.14/327-v4.16-netfilter-nf_tables-remove-nhooks-field-from-struct-.patch b/target/linux/generic/backport-4.14/327-v4.16-netfilter-nf_tables-remove-nhooks-field-from-struct-.patch index ec1492999..188ee11b8 100644 --- a/target/linux/generic/backport-4.14/327-v4.16-netfilter-nf_tables-remove-nhooks-field-from-struct-.patch +++ b/target/linux/generic/backport-4.14/327-v4.16-netfilter-nf_tables-remove-nhooks-field-from-struct-.patch @@ -82,7 +82,7 @@ Signed-off-by: Pablo Neira Ayuso hook->priority = ntohl(nla_get_be32(ha[NFTA_HOOK_PRIORITY])); type = chain_type[afi->family][NFT_CHAIN_T_DEFAULT]; -@@ -5008,7 +5005,7 @@ static int nf_tables_flowtable_parse_hoo +@@ -5014,7 +5011,7 @@ static int nf_tables_flowtable_parse_hoo return -EINVAL; hooknum = ntohl(nla_get_be32(tb[NFTA_FLOWTABLE_HOOK_NUM])); diff --git a/target/linux/generic/backport-4.14/328-v4.16-netfilter-nf_tables-fix-a-typo-in-nf_tables_getflowt.patch b/target/linux/generic/backport-4.14/328-v4.16-netfilter-nf_tables-fix-a-typo-in-nf_tables_getflowt.patch index d4551f294..1f0a5a2bb 100644 --- a/target/linux/generic/backport-4.14/328-v4.16-netfilter-nf_tables-fix-a-typo-in-nf_tables_getflowt.patch +++ b/target/linux/generic/backport-4.14/328-v4.16-netfilter-nf_tables-fix-a-typo-in-nf_tables_getflowt.patch @@ -11,7 +11,7 @@ Signed-off-by: Pablo Neira Ayuso --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c -@@ -5432,7 +5432,7 @@ static int nf_tables_getflowtable(struct +@@ -5438,7 +5438,7 @@ static int nf_tables_getflowtable(struct flowtable = nf_tables_flowtable_lookup(table, nla[NFTA_FLOWTABLE_NAME], genmask); diff --git a/target/linux/generic/backport-4.14/331-v4.16-netfilter-nf_tables-no-need-for-struct-nft_af_info-t.patch b/target/linux/generic/backport-4.14/331-v4.16-netfilter-nf_tables-no-need-for-struct-nft_af_info-t.patch index 925a4739e..f7e7eeaa0 100644 --- a/target/linux/generic/backport-4.14/331-v4.16-netfilter-nf_tables-no-need-for-struct-nft_af_info-t.patch +++ b/target/linux/generic/backport-4.14/331-v4.16-netfilter-nf_tables-no-need-for-struct-nft_af_info-t.patch @@ -62,7 +62,7 @@ Signed-off-by: Pablo Neira Ayuso if (ret >= 0) { ctx->table->flags &= ~NFT_TABLE_F_DORMANT; nft_trans_table_enable(trans) = true; -@@ -5813,7 +5806,6 @@ static int nf_tables_commit(struct net * +@@ -5819,7 +5812,6 @@ static int nf_tables_commit(struct net * if (nft_trans_table_update(trans)) { if (!nft_trans_table_enable(trans)) { nf_tables_table_disable(net, @@ -70,7 +70,7 @@ Signed-off-by: Pablo Neira Ayuso trans->ctx.table); trans->ctx.table->flags |= NFT_TABLE_F_DORMANT; } -@@ -5977,7 +5969,6 @@ static int nf_tables_abort(struct net *n +@@ -5983,7 +5975,6 @@ static int nf_tables_abort(struct net *n if (nft_trans_table_update(trans)) { if (nft_trans_table_enable(trans)) { nf_tables_table_disable(net, diff --git a/target/linux/generic/backport-4.14/334-v4.15-netfilter-nf_tables-fix-potential-NULL-ptr-deref-in-.patch b/target/linux/generic/backport-4.14/334-v4.15-netfilter-nf_tables-fix-potential-NULL-ptr-deref-in-.patch index 6d9880d09..f6e1ef082 100644 --- a/target/linux/generic/backport-4.14/334-v4.15-netfilter-nf_tables-fix-potential-NULL-ptr-deref-in-.patch +++ b/target/linux/generic/backport-4.14/334-v4.15-netfilter-nf_tables-fix-potential-NULL-ptr-deref-in-.patch @@ -15,7 +15,7 @@ Signed-off-by: Pablo Neira Ayuso --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c -@@ -5351,8 +5351,10 @@ static int nf_tables_dump_flowtable_done +@@ -5357,8 +5357,10 @@ static int nf_tables_dump_flowtable_done if (!filter) return 0; diff --git a/target/linux/generic/backport-4.14/335-v4.16-netfilter-nf_tables-add-single-table-list-for-all-fa.patch b/target/linux/generic/backport-4.14/335-v4.16-netfilter-nf_tables-add-single-table-list-for-all-fa.patch index 9108a5e4d..340d7167e 100644 --- a/target/linux/generic/backport-4.14/335-v4.16-netfilter-nf_tables-add-single-table-list-for-all-fa.patch +++ b/target/linux/generic/backport-4.14/335-v4.16-netfilter-nf_tables-add-single-table-list-for-all-fa.patch @@ -859,7 +859,7 @@ Signed-off-by: Pablo Neira Ayuso nfmsg->version = NFNETLINK_V0; nfmsg->res_id = htons(ctx->net->nft.base_seq & 0xffff); -@@ -3996,7 +3982,7 @@ static int nft_add_set_elem(struct nft_c +@@ -4002,7 +3988,7 @@ static int nft_add_set_elem(struct nft_c list_for_each_entry(binding, &set->bindings, list) { struct nft_ctx bind_ctx = { .net = ctx->net, @@ -868,7 +868,7 @@ Signed-off-by: Pablo Neira Ayuso .table = ctx->table, .chain = (struct nft_chain *)binding->chain, }; -@@ -4548,7 +4534,8 @@ static int nf_tables_newobj(struct net * +@@ -4554,7 +4540,8 @@ static int nf_tables_newobj(struct net * if (IS_ERR(afi)) return PTR_ERR(afi); @@ -878,7 +878,7 @@ Signed-off-by: Pablo Neira Ayuso if (IS_ERR(table)) return PTR_ERR(table); -@@ -4566,7 +4553,7 @@ static int nf_tables_newobj(struct net * +@@ -4572,7 +4559,7 @@ static int nf_tables_newobj(struct net * return 0; } @@ -887,7 +887,7 @@ Signed-off-by: Pablo Neira Ayuso type = nft_obj_type_get(objtype); if (IS_ERR(type)) -@@ -4643,7 +4630,6 @@ struct nft_obj_filter { +@@ -4649,7 +4636,6 @@ struct nft_obj_filter { static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb) { const struct nfgenmsg *nfmsg = nlmsg_data(cb->nlh); @@ -895,7 +895,7 @@ Signed-off-by: Pablo Neira Ayuso const struct nft_table *table; unsigned int idx = 0, s_idx = cb->args[0]; struct nft_obj_filter *filter = cb->data; -@@ -4658,38 +4644,37 @@ static int nf_tables_dump_obj(struct sk_ +@@ -4664,38 +4650,37 @@ static int nf_tables_dump_obj(struct sk_ rcu_read_lock(); cb->seq = net->nft.base_seq; @@ -960,7 +960,7 @@ Signed-off-by: Pablo Neira Ayuso } } done: -@@ -4776,7 +4761,8 @@ static int nf_tables_getobj(struct net * +@@ -4782,7 +4767,8 @@ static int nf_tables_getobj(struct net * if (IS_ERR(afi)) return PTR_ERR(afi); @@ -970,7 +970,7 @@ Signed-off-by: Pablo Neira Ayuso if (IS_ERR(table)) return PTR_ERR(table); -@@ -4836,7 +4822,8 @@ static int nf_tables_delobj(struct net * +@@ -4842,7 +4828,8 @@ static int nf_tables_delobj(struct net * if (IS_ERR(afi)) return PTR_ERR(afi); @@ -980,7 +980,7 @@ Signed-off-by: Pablo Neira Ayuso if (IS_ERR(table)) return PTR_ERR(table); -@@ -4847,7 +4834,7 @@ static int nf_tables_delobj(struct net * +@@ -4853,7 +4840,7 @@ static int nf_tables_delobj(struct net * if (obj->use > 0) return -EBUSY; @@ -989,7 +989,7 @@ Signed-off-by: Pablo Neira Ayuso return nft_delobj(&ctx, obj); } -@@ -4885,7 +4872,7 @@ static void nf_tables_obj_notify(const s +@@ -4891,7 +4878,7 @@ static void nf_tables_obj_notify(const s struct nft_object *obj, int event) { nft_obj_notify(ctx->net, ctx->table, obj, ctx->portid, ctx->seq, event, @@ -998,7 +998,7 @@ Signed-off-by: Pablo Neira Ayuso } /* -@@ -5075,7 +5062,7 @@ void nft_flow_table_iterate(struct net * +@@ -5081,7 +5068,7 @@ void nft_flow_table_iterate(struct net * rcu_read_lock(); list_for_each_entry_rcu(afi, &net->nft.af_info, list) { @@ -1007,7 +1007,7 @@ Signed-off-by: Pablo Neira Ayuso list_for_each_entry_rcu(flowtable, &table->flowtables, list) { iter(&flowtable->data, data); } -@@ -5123,7 +5110,8 @@ static int nf_tables_newflowtable(struct +@@ -5129,7 +5116,8 @@ static int nf_tables_newflowtable(struct if (IS_ERR(afi)) return PTR_ERR(afi); @@ -1017,7 +1017,7 @@ Signed-off-by: Pablo Neira Ayuso if (IS_ERR(table)) return PTR_ERR(table); -@@ -5140,7 +5128,7 @@ static int nf_tables_newflowtable(struct +@@ -5146,7 +5134,7 @@ static int nf_tables_newflowtable(struct return 0; } @@ -1026,7 +1026,7 @@ Signed-off-by: Pablo Neira Ayuso flowtable = kzalloc(sizeof(*flowtable), GFP_KERNEL); if (!flowtable) -@@ -5221,7 +5209,8 @@ static int nf_tables_delflowtable(struct +@@ -5227,7 +5215,8 @@ static int nf_tables_delflowtable(struct if (IS_ERR(afi)) return PTR_ERR(afi); @@ -1036,7 +1036,7 @@ Signed-off-by: Pablo Neira Ayuso if (IS_ERR(table)) return PTR_ERR(table); -@@ -5232,7 +5221,7 @@ static int nf_tables_delflowtable(struct +@@ -5238,7 +5227,7 @@ static int nf_tables_delflowtable(struct if (flowtable->use > 0) return -EBUSY; @@ -1045,7 +1045,7 @@ Signed-off-by: Pablo Neira Ayuso return nft_delflowtable(&ctx, flowtable); } -@@ -5301,40 +5290,37 @@ static int nf_tables_dump_flowtable(stru +@@ -5307,40 +5296,37 @@ static int nf_tables_dump_flowtable(stru struct net *net = sock_net(skb->sk); int family = nfmsg->nfgen_family; struct nft_flowtable *flowtable; @@ -1107,7 +1107,7 @@ Signed-off-by: Pablo Neira Ayuso } } done: -@@ -5419,7 +5405,8 @@ static int nf_tables_getflowtable(struct +@@ -5425,7 +5411,8 @@ static int nf_tables_getflowtable(struct if (IS_ERR(afi)) return PTR_ERR(afi); @@ -1117,7 +1117,7 @@ Signed-off-by: Pablo Neira Ayuso if (IS_ERR(table)) return PTR_ERR(table); -@@ -5462,7 +5449,7 @@ static void nf_tables_flowtable_notify(s +@@ -5468,7 +5455,7 @@ static void nf_tables_flowtable_notify(s err = nf_tables_fill_flowtable_info(skb, ctx->net, ctx->portid, ctx->seq, event, 0, @@ -1126,7 +1126,7 @@ Signed-off-by: Pablo Neira Ayuso if (err < 0) { kfree_skb(skb); goto err; -@@ -5540,17 +5527,14 @@ static int nf_tables_flowtable_event(str +@@ -5546,17 +5533,14 @@ static int nf_tables_flowtable_event(str struct net_device *dev = netdev_notifier_info_to_dev(ptr); struct nft_flowtable *flowtable; struct nft_table *table; @@ -1147,7 +1147,7 @@ Signed-off-by: Pablo Neira Ayuso } } nfnl_unlock(NFNL_SUBSYS_NFTABLES); -@@ -6576,6 +6560,7 @@ EXPORT_SYMBOL_GPL(nft_data_dump); +@@ -6582,6 +6566,7 @@ EXPORT_SYMBOL_GPL(nft_data_dump); static int __net_init nf_tables_init_net(struct net *net) { INIT_LIST_HEAD(&net->nft.af_info); @@ -1155,7 +1155,7 @@ Signed-off-by: Pablo Neira Ayuso INIT_LIST_HEAD(&net->nft.commit_list); net->nft.base_seq = 1; return 0; -@@ -6612,10 +6597,10 @@ static void __nft_release_afinfo(struct +@@ -6618,10 +6603,10 @@ static void __nft_release_afinfo(struct struct nft_set *set, *ns; struct nft_ctx ctx = { .net = net, diff --git a/target/linux/generic/backport-4.14/336-v4.15-netfilter-exit_net-cleanup-check-added.patch b/target/linux/generic/backport-4.14/336-v4.15-netfilter-exit_net-cleanup-check-added.patch index 8d0d62b1e..b00675df2 100644 --- a/target/linux/generic/backport-4.14/336-v4.15-netfilter-exit_net-cleanup-check-added.patch +++ b/target/linux/generic/backport-4.14/336-v4.15-netfilter-exit_net-cleanup-check-added.patch @@ -21,7 +21,7 @@ Signed-off-by: Pablo Neira Ayuso static struct pernet_operations clusterip_net_ops = { --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c -@@ -6566,6 +6566,12 @@ static int __net_init nf_tables_init_net +@@ -6572,6 +6572,12 @@ static int __net_init nf_tables_init_net return 0; } @@ -34,7 +34,7 @@ Signed-off-by: Pablo Neira Ayuso int __nft_release_basechain(struct nft_ctx *ctx) { struct nft_rule *rule, *nr; -@@ -6643,6 +6649,7 @@ static void __nft_release_afinfo(struct +@@ -6649,6 +6655,7 @@ static void __nft_release_afinfo(struct static struct pernet_operations nf_tables_net_ops = { .init = nf_tables_init_net, diff --git a/target/linux/generic/backport-4.14/337-v4.16-netfilter-nf_tables-get-rid-of-pernet-families.patch b/target/linux/generic/backport-4.14/337-v4.16-netfilter-nf_tables-get-rid-of-pernet-families.patch index da9d4ffd0..a42581a4b 100644 --- a/target/linux/generic/backport-4.14/337-v4.16-netfilter-nf_tables-get-rid-of-pernet-families.patch +++ b/target/linux/generic/backport-4.14/337-v4.16-netfilter-nf_tables-get-rid-of-pernet-families.patch @@ -364,7 +364,7 @@ Signed-off-by: Pablo Neira Ayuso if (afi->family == family) return afi; } -@@ -5057,15 +5055,12 @@ void nft_flow_table_iterate(struct net * +@@ -5063,15 +5061,12 @@ void nft_flow_table_iterate(struct net * void *data) { struct nft_flowtable *flowtable; @@ -383,7 +383,7 @@ Signed-off-by: Pablo Neira Ayuso } } rcu_read_unlock(); -@@ -6557,21 +6552,6 @@ int nft_data_dump(struct sk_buff *skb, i +@@ -6563,21 +6558,6 @@ int nft_data_dump(struct sk_buff *skb, i } EXPORT_SYMBOL_GPL(nft_data_dump); @@ -405,7 +405,7 @@ Signed-off-by: Pablo Neira Ayuso int __nft_release_basechain(struct nft_ctx *ctx) { struct nft_rule *rule, *nr; -@@ -6592,8 +6572,7 @@ int __nft_release_basechain(struct nft_c +@@ -6598,8 +6578,7 @@ int __nft_release_basechain(struct nft_c } EXPORT_SYMBOL_GPL(__nft_release_basechain); @@ -415,7 +415,7 @@ Signed-off-by: Pablo Neira Ayuso { struct nft_flowtable *flowtable, *nf; struct nft_table *table, *nt; -@@ -6603,10 +6582,11 @@ static void __nft_release_afinfo(struct +@@ -6609,10 +6588,11 @@ static void __nft_release_afinfo(struct struct nft_set *set, *ns; struct nft_ctx ctx = { .net = net, @@ -428,7 +428,7 @@ Signed-off-by: Pablo Neira Ayuso list_for_each_entry(chain, &table->chains, list) nf_tables_unregister_hook(net, table, chain); list_for_each_entry(flowtable, &table->flowtables, list) -@@ -6647,6 +6627,21 @@ static void __nft_release_afinfo(struct +@@ -6653,6 +6633,21 @@ static void __nft_release_afinfo(struct } } diff --git a/target/linux/generic/backport-4.14/338-v4.16-netfilter-nf_tables-get-rid-of-struct-nft_af_info-ab.patch b/target/linux/generic/backport-4.14/338-v4.16-netfilter-nf_tables-get-rid-of-struct-nft_af_info-ab.patch index ed159d520..781671846 100644 --- a/target/linux/generic/backport-4.14/338-v4.16-netfilter-nf_tables-get-rid-of-struct-nft_af_info-ab.patch +++ b/target/linux/generic/backport-4.14/338-v4.16-netfilter-nf_tables-get-rid-of-struct-nft_af_info-ab.patch @@ -817,7 +817,7 @@ Signed-off-by: Pablo Neira Ayuso nfmsg->version = NFNETLINK_V0; nfmsg->res_id = htons(net->nft.base_seq & 0xffff); -@@ -4516,7 +4383,6 @@ static int nf_tables_newobj(struct net * +@@ -4522,7 +4389,6 @@ static int nf_tables_newobj(struct net * const struct nft_object_type *type; u8 genmask = nft_genmask_next(net); int family = nfmsg->nfgen_family; @@ -825,7 +825,7 @@ Signed-off-by: Pablo Neira Ayuso struct nft_table *table; struct nft_object *obj; struct nft_ctx ctx; -@@ -4528,11 +4394,7 @@ static int nf_tables_newobj(struct net * +@@ -4534,11 +4400,7 @@ static int nf_tables_newobj(struct net * !nla[NFTA_OBJ_DATA]) return -EINVAL; @@ -838,7 +838,7 @@ Signed-off-by: Pablo Neira Ayuso genmask); if (IS_ERR(table)) return PTR_ERR(table); -@@ -4551,7 +4413,7 @@ static int nf_tables_newobj(struct net * +@@ -4557,7 +4419,7 @@ static int nf_tables_newobj(struct net * return 0; } @@ -847,7 +847,7 @@ Signed-off-by: Pablo Neira Ayuso type = nft_obj_type_get(objtype); if (IS_ERR(type)) -@@ -4643,7 +4505,7 @@ static int nf_tables_dump_obj(struct sk_ +@@ -4649,7 +4511,7 @@ static int nf_tables_dump_obj(struct sk_ cb->seq = net->nft.base_seq; list_for_each_entry_rcu(table, &net->nft.tables, list) { @@ -856,7 +856,7 @@ Signed-off-by: Pablo Neira Ayuso continue; list_for_each_entry_rcu(obj, &table->objects, list) { -@@ -4666,7 +4528,7 @@ static int nf_tables_dump_obj(struct sk_ +@@ -4672,7 +4534,7 @@ static int nf_tables_dump_obj(struct sk_ cb->nlh->nlmsg_seq, NFT_MSG_NEWOBJ, NLM_F_MULTI | NLM_F_APPEND, @@ -865,7 +865,7 @@ Signed-off-by: Pablo Neira Ayuso obj, reset) < 0) goto done; -@@ -4724,7 +4586,6 @@ static int nf_tables_getobj(struct net * +@@ -4730,7 +4592,6 @@ static int nf_tables_getobj(struct net * const struct nfgenmsg *nfmsg = nlmsg_data(nlh); u8 genmask = nft_genmask_cur(net); int family = nfmsg->nfgen_family; @@ -873,7 +873,7 @@ Signed-off-by: Pablo Neira Ayuso const struct nft_table *table; struct nft_object *obj; struct sk_buff *skb2; -@@ -4755,11 +4616,7 @@ static int nf_tables_getobj(struct net * +@@ -4761,11 +4622,7 @@ static int nf_tables_getobj(struct net * !nla[NFTA_OBJ_TYPE]) return -EINVAL; @@ -886,7 +886,7 @@ Signed-off-by: Pablo Neira Ayuso genmask); if (IS_ERR(table)) return PTR_ERR(table); -@@ -4806,7 +4663,6 @@ static int nf_tables_delobj(struct net * +@@ -4812,7 +4669,6 @@ static int nf_tables_delobj(struct net * const struct nfgenmsg *nfmsg = nlmsg_data(nlh); u8 genmask = nft_genmask_next(net); int family = nfmsg->nfgen_family; @@ -894,7 +894,7 @@ Signed-off-by: Pablo Neira Ayuso struct nft_table *table; struct nft_object *obj; struct nft_ctx ctx; -@@ -4816,11 +4672,7 @@ static int nf_tables_delobj(struct net * +@@ -4822,11 +4678,7 @@ static int nf_tables_delobj(struct net * !nla[NFTA_OBJ_NAME]) return -EINVAL; @@ -907,7 +907,7 @@ Signed-off-by: Pablo Neira Ayuso genmask); if (IS_ERR(table)) return PTR_ERR(table); -@@ -4832,7 +4684,7 @@ static int nf_tables_delobj(struct net * +@@ -4838,7 +4690,7 @@ static int nf_tables_delobj(struct net * if (obj->use > 0) return -EBUSY; @@ -916,7 +916,7 @@ Signed-off-by: Pablo Neira Ayuso return nft_delobj(&ctx, obj); } -@@ -5017,33 +4869,31 @@ err1: +@@ -5023,33 +4875,31 @@ err1: return err; } @@ -956,7 +956,7 @@ Signed-off-by: Pablo Neira Ayuso return ERR_PTR(-EAGAIN); } #endif -@@ -5091,7 +4941,6 @@ static int nf_tables_newflowtable(struct +@@ -5097,7 +4947,6 @@ static int nf_tables_newflowtable(struct u8 genmask = nft_genmask_next(net); int family = nfmsg->nfgen_family; struct nft_flowtable *flowtable; @@ -964,7 +964,7 @@ Signed-off-by: Pablo Neira Ayuso struct nft_table *table; struct nft_ctx ctx; int err, i, k; -@@ -5101,12 +4950,8 @@ static int nf_tables_newflowtable(struct +@@ -5107,12 +4956,8 @@ static int nf_tables_newflowtable(struct !nla[NFTA_FLOWTABLE_HOOK]) return -EINVAL; @@ -978,7 +978,7 @@ Signed-off-by: Pablo Neira Ayuso if (IS_ERR(table)) return PTR_ERR(table); -@@ -5123,7 +4968,7 @@ static int nf_tables_newflowtable(struct +@@ -5129,7 +4974,7 @@ static int nf_tables_newflowtable(struct return 0; } @@ -987,7 +987,7 @@ Signed-off-by: Pablo Neira Ayuso flowtable = kzalloc(sizeof(*flowtable), GFP_KERNEL); if (!flowtable) -@@ -5136,7 +4981,7 @@ static int nf_tables_newflowtable(struct +@@ -5142,7 +4987,7 @@ static int nf_tables_newflowtable(struct goto err1; } @@ -996,7 +996,7 @@ Signed-off-by: Pablo Neira Ayuso if (IS_ERR(type)) { err = PTR_ERR(type); goto err2; -@@ -5196,16 +5041,11 @@ static int nf_tables_delflowtable(struct +@@ -5202,16 +5047,11 @@ static int nf_tables_delflowtable(struct u8 genmask = nft_genmask_next(net); int family = nfmsg->nfgen_family; struct nft_flowtable *flowtable; @@ -1014,7 +1014,7 @@ Signed-off-by: Pablo Neira Ayuso if (IS_ERR(table)) return PTR_ERR(table); -@@ -5216,7 +5056,7 @@ static int nf_tables_delflowtable(struct +@@ -5222,7 +5062,7 @@ static int nf_tables_delflowtable(struct if (flowtable->use > 0) return -EBUSY; @@ -1023,7 +1023,7 @@ Signed-off-by: Pablo Neira Ayuso return nft_delflowtable(&ctx, flowtable); } -@@ -5291,7 +5131,7 @@ static int nf_tables_dump_flowtable(stru +@@ -5297,7 +5137,7 @@ static int nf_tables_dump_flowtable(stru cb->seq = net->nft.base_seq; list_for_each_entry_rcu(table, &net->nft.tables, list) { @@ -1032,7 +1032,7 @@ Signed-off-by: Pablo Neira Ayuso continue; list_for_each_entry_rcu(flowtable, &table->flowtables, list) { -@@ -5310,7 +5150,7 @@ static int nf_tables_dump_flowtable(stru +@@ -5316,7 +5156,7 @@ static int nf_tables_dump_flowtable(stru cb->nlh->nlmsg_seq, NFT_MSG_NEWFLOWTABLE, NLM_F_MULTI | NLM_F_APPEND, @@ -1041,7 +1041,7 @@ Signed-off-by: Pablo Neira Ayuso goto done; nl_dump_check_consistent(cb, nlmsg_hdr(skb)); -@@ -5370,7 +5210,6 @@ static int nf_tables_getflowtable(struct +@@ -5376,7 +5216,6 @@ static int nf_tables_getflowtable(struct u8 genmask = nft_genmask_cur(net); int family = nfmsg->nfgen_family; struct nft_flowtable *flowtable; @@ -1049,7 +1049,7 @@ Signed-off-by: Pablo Neira Ayuso const struct nft_table *table; struct sk_buff *skb2; int err; -@@ -5396,12 +5235,8 @@ static int nf_tables_getflowtable(struct +@@ -5402,12 +5241,8 @@ static int nf_tables_getflowtable(struct if (!nla[NFTA_FLOWTABLE_NAME]) return -EINVAL; @@ -1063,7 +1063,7 @@ Signed-off-by: Pablo Neira Ayuso if (IS_ERR(table)) return PTR_ERR(table); -@@ -6572,7 +6407,7 @@ int __nft_release_basechain(struct nft_c +@@ -6578,7 +6413,7 @@ int __nft_release_basechain(struct nft_c } EXPORT_SYMBOL_GPL(__nft_release_basechain); @@ -1072,7 +1072,7 @@ Signed-off-by: Pablo Neira Ayuso { struct nft_flowtable *flowtable, *nf; struct nft_table *table, *nt; -@@ -6585,7 +6420,7 @@ static void __nft_release_afinfo(struct +@@ -6591,7 +6426,7 @@ static void __nft_release_afinfo(struct }; list_for_each_entry_safe(table, nt, &net->nft.tables, list) { @@ -1081,7 +1081,7 @@ Signed-off-by: Pablo Neira Ayuso list_for_each_entry(chain, &table->chains, list) nf_tables_unregister_hook(net, table, chain); -@@ -6637,7 +6472,7 @@ static int __net_init nf_tables_init_net +@@ -6643,7 +6478,7 @@ static int __net_init nf_tables_init_net static void __net_exit nf_tables_exit_net(struct net *net) { diff --git a/target/linux/generic/backport-4.14/339-v4.16-netfilter-nft_flow_offload-wait-for-garbage-collecto.patch b/target/linux/generic/backport-4.14/339-v4.16-netfilter-nft_flow_offload-wait-for-garbage-collecto.patch index 7a67f0731..5ae917ff5 100644 --- a/target/linux/generic/backport-4.14/339-v4.16-netfilter-nft_flow_offload-wait-for-garbage-collecto.patch +++ b/target/linux/generic/backport-4.14/339-v4.16-netfilter-nft_flow_offload-wait-for-garbage-collecto.patch @@ -17,7 +17,7 @@ Signed-off-by: Pablo Neira Ayuso --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c -@@ -4907,13 +4907,13 @@ void nft_flow_table_iterate(struct net * +@@ -4913,13 +4913,13 @@ void nft_flow_table_iterate(struct net * struct nft_flowtable *flowtable; const struct nft_table *table; diff --git a/target/linux/generic/backport-4.14/342-v4.16-netfilter-nf_tables-fix-flowtable-free.patch b/target/linux/generic/backport-4.14/342-v4.16-netfilter-nf_tables-fix-flowtable-free.patch index 633564122..b8c85fc2a 100644 --- a/target/linux/generic/backport-4.14/342-v4.16-netfilter-nf_tables-fix-flowtable-free.patch +++ b/target/linux/generic/backport-4.14/342-v4.16-netfilter-nf_tables-fix-flowtable-free.patch @@ -118,7 +118,7 @@ Signed-off-by: Pablo Neira Ayuso }; --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c -@@ -5292,17 +5292,12 @@ err: +@@ -5298,17 +5298,12 @@ err: nfnetlink_set_err(ctx->net, ctx->portid, NFNLGRP_NFTABLES, -ENOBUFS); } diff --git a/target/linux/generic/backport-4.14/344-v4.16-netfilter-nf_tables-allocate-handle-and-delete-objec.patch b/target/linux/generic/backport-4.14/344-v4.16-netfilter-nf_tables-allocate-handle-and-delete-objec.patch index 3356781cc..e6c9fd2f7 100644 --- a/target/linux/generic/backport-4.14/344-v4.16-netfilter-nf_tables-allocate-handle-and-delete-objec.patch +++ b/target/linux/generic/backport-4.14/344-v4.16-netfilter-nf_tables-allocate-handle-and-delete-objec.patch @@ -327,7 +327,7 @@ Signed-off-by: Pablo Neira Ayuso if (IS_ERR(set)) return PTR_ERR(set); -@@ -4271,6 +4343,21 @@ struct nft_object *nf_tables_obj_lookup( +@@ -4277,6 +4349,21 @@ struct nft_object *nf_tables_obj_lookup( } EXPORT_SYMBOL_GPL(nf_tables_obj_lookup); @@ -349,7 +349,7 @@ Signed-off-by: Pablo Neira Ayuso static const struct nla_policy nft_obj_policy[NFTA_OBJ_MAX + 1] = { [NFTA_OBJ_TABLE] = { .type = NLA_STRING, .len = NFT_TABLE_MAXNAMELEN - 1 }, -@@ -4278,6 +4365,7 @@ static const struct nla_policy nft_obj_p +@@ -4284,6 +4371,7 @@ static const struct nla_policy nft_obj_p .len = NFT_OBJ_MAXNAMELEN - 1 }, [NFTA_OBJ_TYPE] = { .type = NLA_U32 }, [NFTA_OBJ_DATA] = { .type = NLA_NESTED }, @@ -357,7 +357,7 @@ Signed-off-by: Pablo Neira Ayuso }; static struct nft_object *nft_obj_init(const struct nft_ctx *ctx, -@@ -4425,6 +4513,8 @@ static int nf_tables_newobj(struct net * +@@ -4431,6 +4519,8 @@ static int nf_tables_newobj(struct net * goto err1; } obj->table = table; @@ -366,7 +366,7 @@ Signed-off-by: Pablo Neira Ayuso obj->name = nla_strdup(nla[NFTA_OBJ_NAME], GFP_KERNEL); if (!obj->name) { err = -ENOMEM; -@@ -4471,7 +4561,9 @@ static int nf_tables_fill_obj_info(struc +@@ -4477,7 +4567,9 @@ static int nf_tables_fill_obj_info(struc nla_put_string(skb, NFTA_OBJ_NAME, obj->name) || nla_put_be32(skb, NFTA_OBJ_TYPE, htonl(obj->ops->type->type)) || nla_put_be32(skb, NFTA_OBJ_USE, htonl(obj->use)) || @@ -377,7 +377,7 @@ Signed-off-by: Pablo Neira Ayuso goto nla_put_failure; nlmsg_end(skb, nlh); -@@ -4669,7 +4761,7 @@ static int nf_tables_delobj(struct net * +@@ -4675,7 +4767,7 @@ static int nf_tables_delobj(struct net * u32 objtype; if (!nla[NFTA_OBJ_TYPE] || @@ -386,7 +386,7 @@ Signed-off-by: Pablo Neira Ayuso return -EINVAL; table = nf_tables_table_lookup(net, nla[NFTA_OBJ_TABLE], family, -@@ -4678,7 +4770,12 @@ static int nf_tables_delobj(struct net * +@@ -4684,7 +4776,12 @@ static int nf_tables_delobj(struct net * return PTR_ERR(table); objtype = ntohl(nla_get_be32(nla[NFTA_OBJ_TYPE])); @@ -400,7 +400,7 @@ Signed-off-by: Pablo Neira Ayuso if (IS_ERR(obj)) return PTR_ERR(obj); if (obj->use > 0) -@@ -4750,6 +4847,7 @@ static const struct nla_policy nft_flowt +@@ -4756,6 +4853,7 @@ static const struct nla_policy nft_flowt [NFTA_FLOWTABLE_NAME] = { .type = NLA_STRING, .len = NFT_NAME_MAXLEN - 1 }, [NFTA_FLOWTABLE_HOOK] = { .type = NLA_NESTED }, @@ -408,7 +408,7 @@ Signed-off-by: Pablo Neira Ayuso }; struct nft_flowtable *nf_tables_flowtable_lookup(const struct nft_table *table, -@@ -4767,6 +4865,20 @@ struct nft_flowtable *nf_tables_flowtabl +@@ -4773,6 +4871,20 @@ struct nft_flowtable *nf_tables_flowtabl } EXPORT_SYMBOL_GPL(nf_tables_flowtable_lookup); @@ -429,7 +429,7 @@ Signed-off-by: Pablo Neira Ayuso #define NFT_FLOWTABLE_DEVICE_MAX 8 static int nf_tables_parse_devices(const struct nft_ctx *ctx, -@@ -4975,6 +5087,8 @@ static int nf_tables_newflowtable(struct +@@ -4981,6 +5093,8 @@ static int nf_tables_newflowtable(struct return -ENOMEM; flowtable->table = table; @@ -438,7 +438,7 @@ Signed-off-by: Pablo Neira Ayuso flowtable->name = nla_strdup(nla[NFTA_FLOWTABLE_NAME], GFP_KERNEL); if (!flowtable->name) { err = -ENOMEM; -@@ -5049,8 +5163,14 @@ static int nf_tables_delflowtable(struct +@@ -5055,8 +5169,14 @@ static int nf_tables_delflowtable(struct if (IS_ERR(table)) return PTR_ERR(table); @@ -455,7 +455,7 @@ Signed-off-by: Pablo Neira Ayuso if (IS_ERR(flowtable)) return PTR_ERR(flowtable); if (flowtable->use > 0) -@@ -5083,7 +5203,9 @@ static int nf_tables_fill_flowtable_info +@@ -5089,7 +5209,9 @@ static int nf_tables_fill_flowtable_info if (nla_put_string(skb, NFTA_FLOWTABLE_TABLE, flowtable->table->name) || nla_put_string(skb, NFTA_FLOWTABLE_NAME, flowtable->name) || diff --git a/target/linux/generic/backport-4.14/357-v4.18-netfilter-nf_flow_table-move-init-code-to-nf_flow_ta.patch b/target/linux/generic/backport-4.14/357-v4.18-netfilter-nf_flow_table-move-init-code-to-nf_flow_ta.patch index b15a01e06..96acb6887 100644 --- a/target/linux/generic/backport-4.14/357-v4.18-netfilter-nf_flow_table-move-init-code-to-nf_flow_ta.patch +++ b/target/linux/generic/backport-4.14/357-v4.18-netfilter-nf_flow_table-move-init-code-to-nf_flow_ta.patch @@ -236,7 +236,7 @@ Signed-off-by: Felix Fietkau .owner = THIS_MODULE, --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c -@@ -5102,40 +5102,38 @@ static int nf_tables_newflowtable(struct +@@ -5108,40 +5108,38 @@ static int nf_tables_newflowtable(struct } flowtable->data.type = type; @@ -285,7 +285,7 @@ Signed-off-by: Felix Fietkau err3: module_put(type->owner); err2: -@@ -5416,10 +5414,8 @@ err: +@@ -5422,10 +5420,8 @@ err: static void nf_tables_flowtable_destroy(struct nft_flowtable *flowtable) { diff --git a/target/linux/generic/backport-4.14/358-v4.18-netfilter-nf_flow_table-fix-priv-pointer-for-netdev-.patch b/target/linux/generic/backport-4.14/358-v4.18-netfilter-nf_flow_table-fix-priv-pointer-for-netdev-.patch index 2e68aef42..ea86e761d 100644 --- a/target/linux/generic/backport-4.14/358-v4.18-netfilter-nf_flow_table-fix-priv-pointer-for-netdev-.patch +++ b/target/linux/generic/backport-4.14/358-v4.18-netfilter-nf_flow_table-fix-priv-pointer-for-netdev-.patch @@ -11,7 +11,7 @@ Signed-off-by: Felix Fietkau --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c -@@ -4968,7 +4968,7 @@ static int nf_tables_flowtable_parse_hoo +@@ -4974,7 +4974,7 @@ static int nf_tables_flowtable_parse_hoo flowtable->ops[i].pf = NFPROTO_NETDEV; flowtable->ops[i].hooknum = hooknum; flowtable->ops[i].priority = priority; diff --git a/target/linux/generic/backport-4.14/359-v4.18-netfilter-nf_flow_table-track-flow-tables-in-nf_flow.patch b/target/linux/generic/backport-4.14/359-v4.18-netfilter-nf_flow_table-track-flow-tables-in-nf_flow.patch index e39daf892..643189b5c 100644 --- a/target/linux/generic/backport-4.14/359-v4.18-netfilter-nf_flow_table-track-flow-tables-in-nf_flow.patch +++ b/target/linux/generic/backport-4.14/359-v4.18-netfilter-nf_flow_table-track-flow-tables-in-nf_flow.patch @@ -88,7 +88,7 @@ Signed-off-by: Felix Fietkau WARN_ON(!nf_flow_offload_gc_step(flow_table)); --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c -@@ -5012,23 +5012,6 @@ static const struct nf_flowtable_type *n +@@ -5018,23 +5018,6 @@ static const struct nf_flowtable_type *n return ERR_PTR(-ENOENT); } diff --git a/target/linux/generic/backport-4.14/380-v5.3-net-sched-Introduce-act_ctinfo-action.patch b/target/linux/generic/backport-4.14/380-v5.3-net-sched-Introduce-act_ctinfo-action.patch index f58ceb3ac..96f458f9c 100644 --- a/target/linux/generic/backport-4.14/380-v5.3-net-sched-Introduce-act_ctinfo-action.patch +++ b/target/linux/generic/backport-4.14/380-v5.3-net-sched-Introduce-act_ctinfo-action.patch @@ -1,4 +1,4 @@ -From 147b0d133b53635db0cc572294840652c9c7b662 Mon Sep 17 00:00:00 2001 +From 85fc2a6db8279c5e43c38ef7e715d14e57287997 Mon Sep 17 00:00:00 2001 From: Kevin Darbyshire-Bryant Date: Wed, 13 Mar 2019 20:54:49 +0000 Subject: [PATCH] net: sched: Backport Introduce act_ctinfo action @@ -112,8 +112,8 @@ Signed-off-by: Kevin Darbyshire-Bryant include/uapi/linux/tc_act/tc_ctinfo.h | 29 ++ net/sched/Kconfig | 13 + net/sched/Makefile | 1 + - net/sched/act_ctinfo.c | 394 ++++++++++++++++++++++++++ - 6 files changed, 472 insertions(+), 1 deletion(-) + net/sched/act_ctinfo.c | 405 ++++++++++++++++++++++++++ + 6 files changed, 482 insertions(+), 1 deletion(-) create mode 100644 include/net/tc_act/tc_ctinfo.h create mode 100644 include/uapi/linux/tc_act/tc_ctinfo.h create mode 100644 net/sched/act_ctinfo.c @@ -232,7 +232,7 @@ Signed-off-by: Kevin Darbyshire-Bryant obj-$(CONFIG_NET_IFE_SKBMARK) += act_meta_mark.o --- /dev/null +++ b/net/sched/act_ctinfo.c -@@ -0,0 +1,394 @@ +@@ -0,0 +1,405 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* net/sched/act_ctinfo.c netfilter ctinfo connmark actions + * @@ -579,6 +579,16 @@ Signed-off-by: Kevin Darbyshire-Bryant + return tcf_idr_search(tn, a, index); +} + ++static void tcf_ctinfo_cleanup(struct tc_action *a, int bind) ++{ ++ struct tcf_ctinfo *ci = to_ctinfo(a); ++ struct tcf_ctinfo_params *cp; ++ ++ cp = rcu_dereference_protected(ci->params, 1); ++ if (cp) ++ kfree_rcu(cp, rcu); ++} ++ +static struct tc_action_ops act_ctinfo_ops = { + .kind = "ctinfo", + .type = TCA_ID_CTINFO, @@ -586,6 +596,7 @@ Signed-off-by: Kevin Darbyshire-Bryant + .act = tcf_ctinfo_act, + .dump = tcf_ctinfo_dump, + .init = tcf_ctinfo_init, ++ .cleanup= tcf_ctinfo_cleanup, + .walk = tcf_ctinfo_walker, + .lookup = tcf_ctinfo_search, + .size = sizeof(struct tcf_ctinfo), @@ -595,7 +606,7 @@ Signed-off-by: Kevin Darbyshire-Bryant +{ + struct tc_action_net *tn = net_generic(net, ctinfo_net_id); + -+ return tc_action_net_init(tn, &act_ctinfo_ops); ++ return tc_action_net_init(net, tn, &act_ctinfo_ops); +} + +static void __net_exit ctinfo_exit_net(struct net *net) diff --git a/target/linux/generic/backport-4.14/500-v4.20-ubifs-Fix-default-compression-selection-in-ubifs.patch b/target/linux/generic/backport-4.14/500-v4.20-ubifs-Fix-default-compression-selection-in-ubifs.patch new file mode 100644 index 000000000..4782fc9ed --- /dev/null +++ b/target/linux/generic/backport-4.14/500-v4.20-ubifs-Fix-default-compression-selection-in-ubifs.patch @@ -0,0 +1,37 @@ +From: Gabor Juhos +Subject: fs: ubifs: fix default compression selection in ubifs + +Signed-off-by: Gabor Juhos +--- + fs/ubifs/sb.c | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +--- a/fs/ubifs/sb.c ++++ b/fs/ubifs/sb.c +@@ -63,6 +63,17 @@ + /* Default time granularity in nanoseconds */ + #define DEFAULT_TIME_GRAN 1000000000 + ++static int get_default_compressor(void) ++{ ++ if (ubifs_compr_present(UBIFS_COMPR_LZO)) ++ return UBIFS_COMPR_LZO; ++ ++ if (ubifs_compr_present(UBIFS_COMPR_ZLIB)) ++ return UBIFS_COMPR_ZLIB; ++ ++ return UBIFS_COMPR_NONE; ++} ++ + /** + * create_default_filesystem - format empty UBI volume. + * @c: UBIFS file-system description object +@@ -186,7 +197,7 @@ static int create_default_filesystem(str + if (c->mount_opts.override_compr) + sup->default_compr = cpu_to_le16(c->mount_opts.compr_type); + else +- sup->default_compr = cpu_to_le16(UBIFS_COMPR_LZO); ++ sup->default_compr = cpu_to_le16(get_default_compressor()); + + generate_random_uuid(sup->uuid); + diff --git a/target/linux/generic/backport-4.14/900-v4.18-firmware-dmi-Add-access-to-the-SKU-ID-string.patch b/target/linux/generic/backport-4.14/900-v4.18-firmware-dmi-Add-access-to-the-SKU-ID-string.patch new file mode 100644 index 000000000..9c80b4760 --- /dev/null +++ b/target/linux/generic/backport-4.14/900-v4.18-firmware-dmi-Add-access-to-the-SKU-ID-string.patch @@ -0,0 +1,57 @@ +From b23908d3c48a37c46c6a26df2cdeab1610b360ba Mon Sep 17 00:00:00 2001 +From: Simon Glass +Date: Sun, 17 Jun 2018 14:09:42 +0200 +Subject: [PATCH] firmware: dmi: Add access to the SKU ID string + +This is used in some systems from user space for determining the identity +of the device. + +Expose this as a file so that that user-space tools don't need to read +from /sys/firmware/dmi/tables/DMI + +Signed-off-by: Simon Glass +Signed-off-by: Jean Delvare +--- + drivers/firmware/dmi-id.c | 2 ++ + drivers/firmware/dmi_scan.c | 1 + + include/linux/mod_devicetable.h | 1 + + 3 files changed, 4 insertions(+) + +--- a/drivers/firmware/dmi-id.c ++++ b/drivers/firmware/dmi-id.c +@@ -47,6 +47,7 @@ DEFINE_DMI_ATTR_WITH_SHOW(product_name, + DEFINE_DMI_ATTR_WITH_SHOW(product_version, 0444, DMI_PRODUCT_VERSION); + DEFINE_DMI_ATTR_WITH_SHOW(product_serial, 0400, DMI_PRODUCT_SERIAL); + DEFINE_DMI_ATTR_WITH_SHOW(product_uuid, 0400, DMI_PRODUCT_UUID); ++DEFINE_DMI_ATTR_WITH_SHOW(product_sku, 0444, DMI_PRODUCT_SKU); + DEFINE_DMI_ATTR_WITH_SHOW(product_family, 0444, DMI_PRODUCT_FAMILY); + DEFINE_DMI_ATTR_WITH_SHOW(board_vendor, 0444, DMI_BOARD_VENDOR); + DEFINE_DMI_ATTR_WITH_SHOW(board_name, 0444, DMI_BOARD_NAME); +@@ -193,6 +194,7 @@ static void __init dmi_id_init_attr_tabl + ADD_DMI_ATTR(product_serial, DMI_PRODUCT_SERIAL); + ADD_DMI_ATTR(product_uuid, DMI_PRODUCT_UUID); + ADD_DMI_ATTR(product_family, DMI_PRODUCT_FAMILY); ++ ADD_DMI_ATTR(product_sku, DMI_PRODUCT_SKU); + ADD_DMI_ATTR(board_vendor, DMI_BOARD_VENDOR); + ADD_DMI_ATTR(board_name, DMI_BOARD_NAME); + ADD_DMI_ATTR(board_version, DMI_BOARD_VERSION); +--- a/drivers/firmware/dmi_scan.c ++++ b/drivers/firmware/dmi_scan.c +@@ -435,6 +435,7 @@ static void __init dmi_decode(const stru + dmi_save_ident(dm, DMI_PRODUCT_VERSION, 6); + dmi_save_ident(dm, DMI_PRODUCT_SERIAL, 7); + dmi_save_uuid(dm, DMI_PRODUCT_UUID, 8); ++ dmi_save_ident(dm, DMI_PRODUCT_SKU, 25); + dmi_save_ident(dm, DMI_PRODUCT_FAMILY, 26); + break; + case 2: /* Base Board Information */ +--- a/include/linux/mod_devicetable.h ++++ b/include/linux/mod_devicetable.h +@@ -471,6 +471,7 @@ enum dmi_field { + DMI_PRODUCT_VERSION, + DMI_PRODUCT_SERIAL, + DMI_PRODUCT_UUID, ++ DMI_PRODUCT_SKU, + DMI_PRODUCT_FAMILY, + DMI_BOARD_VENDOR, + DMI_BOARD_NAME, diff --git a/target/linux/generic/backport-4.14/950-tty-serial-exar-generalize-rs485-setup.patch b/target/linux/generic/backport-4.14/950-tty-serial-exar-generalize-rs485-setup.patch new file mode 100644 index 000000000..42c4705e5 --- /dev/null +++ b/target/linux/generic/backport-4.14/950-tty-serial-exar-generalize-rs485-setup.patch @@ -0,0 +1,75 @@ +From 9d9398944488cd3a3e1e0912b26fbc4d5921e547 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Mon, 4 Jun 2018 23:33:07 +0200 +Subject: [PATCH] tty: serial: exar: generalize RS485 setup + +Move the non-board-specific part of the RS485 initialization from +iot2040_rs485_config function to a new generic function used also for +other boards. +This allows using TIOCGRS485 and TIOCSRS485 on boards (such as mPCIe +serial IO modules) which are hard-wired to RS485 or have jumpers for +their configurations. + +Signed-off-by: Daniel Golle +Reviewed-by: Jan Kiszka +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/serial/8250/8250_exar.c | 38 +++++++++++++++++++---------- + 1 file changed, 25 insertions(+), 13 deletions(-) + +--- a/drivers/tty/serial/8250/8250_exar.c ++++ b/drivers/tty/serial/8250/8250_exar.c +@@ -275,8 +275,32 @@ static int xr17v35x_register_gpio(struct + return 0; + } + ++static int generic_rs485_config(struct uart_port *port, ++ struct serial_rs485 *rs485) ++{ ++ bool is_rs485 = !!(rs485->flags & SER_RS485_ENABLED); ++ u8 __iomem *p = port->membase; ++ u8 value; ++ ++ value = readb(p + UART_EXAR_FCTR); ++ if (is_rs485) ++ value |= UART_FCTR_EXAR_485; ++ else ++ value &= ~UART_FCTR_EXAR_485; ++ ++ writeb(value, p + UART_EXAR_FCTR); ++ ++ if (is_rs485) ++ writeb(UART_EXAR_RS485_DLY(4), p + UART_MSR); ++ ++ port->rs485 = *rs485; ++ ++ return 0; ++} ++ + static const struct exar8250_platform exar8250_default_platform = { + .register_gpio = xr17v35x_register_gpio, ++ .rs485_config = generic_rs485_config, + }; + + static int iot2040_rs485_config(struct uart_port *port, +@@ -309,19 +333,7 @@ static int iot2040_rs485_config(struct u + value |= mode; + writeb(value, p + UART_EXAR_MPIOLVL_7_0); + +- value = readb(p + UART_EXAR_FCTR); +- if (is_rs485) +- value |= UART_FCTR_EXAR_485; +- else +- value &= ~UART_FCTR_EXAR_485; +- writeb(value, p + UART_EXAR_FCTR); +- +- if (is_rs485) +- writeb(UART_EXAR_RS485_DLY(4), p + UART_MSR); +- +- port->rs485 = *rs485; +- +- return 0; ++ return generic_rs485_config(port, rs485); + } + + static const struct property_entry iot2040_gpio_properties[] = { diff --git a/target/linux/generic/backport-4.19/210-arm64-sve-Disentangle-uapi-asm-ptrace.h-from-uapi-as.patch b/target/linux/generic/backport-4.19/210-arm64-sve-Disentangle-uapi-asm-ptrace.h-from-uapi-as.patch new file mode 100644 index 000000000..e638e0702 --- /dev/null +++ b/target/linux/generic/backport-4.19/210-arm64-sve-Disentangle-uapi-asm-ptrace.h-from-uapi-as.patch @@ -0,0 +1,280 @@ +From 9966a05c7b80f075f2bc7e48dbb108d3f2927234 Mon Sep 17 00:00:00 2001 +From: Dave Martin +Date: Fri, 4 Jan 2019 13:09:51 +0000 +Subject: [PATCH] arm64/sve: Disentangle from + + +Currently, provides common definitions for +describing SVE context structures that are also used by the ptrace +definitions in . + +For this reason, a #include of was added in +ptrace.h, but it this turns out that this can interact badly with +userspace code that tries to include ptrace.h on top of the libc +headers (which may provide their own shadow definitions for +sigcontext.h). + +To make the headers easier for userspace to consume, this patch +bounces the common definitions into an __SVE_* namespace and moves +them to a backend header that can be +included by the other headers as appropriate. This should allow +ptrace.h to be used alongside libc's sigcontext.h (if any) without +ill effects. + +This should make the situation unambiguous: is +the header to include for the sigframe-specific definitions, while + is the header to include for ptrace-specific +definitions. + +To avoid conflicting with existing usage, +remains the canonical way to get the common definitions for +SVE_VQ_MIN, sve_vq_from_vl() etc., both in userspace and in the +kernel: relying on these being defined as a side effect of +including just was never intended to be safe. + +Signed-off-by: Dave Martin +Signed-off-by: Will Deacon +--- + arch/arm64/include/uapi/asm/ptrace.h | 39 ++++++++-------- + arch/arm64/include/uapi/asm/sigcontext.h | 56 +++++++++++------------ + arch/arm64/include/uapi/asm/sve_context.h | 53 +++++++++++++++++++++ + 3 files changed, 99 insertions(+), 49 deletions(-) + create mode 100644 arch/arm64/include/uapi/asm/sve_context.h + +--- a/arch/arm64/include/uapi/asm/ptrace.h ++++ b/arch/arm64/include/uapi/asm/ptrace.h +@@ -23,7 +23,7 @@ + #include + + #include +-#include ++#include + + + /* +@@ -128,9 +128,9 @@ struct user_sve_header { + */ + + /* Offset from the start of struct user_sve_header to the register data */ +-#define SVE_PT_REGS_OFFSET \ +- ((sizeof(struct user_sve_header) + (SVE_VQ_BYTES - 1)) \ +- / SVE_VQ_BYTES * SVE_VQ_BYTES) ++#define SVE_PT_REGS_OFFSET \ ++ ((sizeof(struct user_sve_header) + (__SVE_VQ_BYTES - 1)) \ ++ / __SVE_VQ_BYTES * __SVE_VQ_BYTES) + + /* + * The register data content and layout depends on the value of the +@@ -176,39 +176,36 @@ struct user_sve_header { + * Additional data might be appended in the future. + */ + +-#define SVE_PT_SVE_ZREG_SIZE(vq) SVE_SIG_ZREG_SIZE(vq) +-#define SVE_PT_SVE_PREG_SIZE(vq) SVE_SIG_PREG_SIZE(vq) +-#define SVE_PT_SVE_FFR_SIZE(vq) SVE_SIG_FFR_SIZE(vq) ++#define SVE_PT_SVE_ZREG_SIZE(vq) __SVE_ZREG_SIZE(vq) ++#define SVE_PT_SVE_PREG_SIZE(vq) __SVE_PREG_SIZE(vq) ++#define SVE_PT_SVE_FFR_SIZE(vq) __SVE_FFR_SIZE(vq) + #define SVE_PT_SVE_FPSR_SIZE sizeof(__u32) + #define SVE_PT_SVE_FPCR_SIZE sizeof(__u32) + +-#define __SVE_SIG_TO_PT(offset) \ +- ((offset) - SVE_SIG_REGS_OFFSET + SVE_PT_REGS_OFFSET) +- + #define SVE_PT_SVE_OFFSET SVE_PT_REGS_OFFSET + + #define SVE_PT_SVE_ZREGS_OFFSET \ +- __SVE_SIG_TO_PT(SVE_SIG_ZREGS_OFFSET) ++ (SVE_PT_REGS_OFFSET + __SVE_ZREGS_OFFSET) + #define SVE_PT_SVE_ZREG_OFFSET(vq, n) \ +- __SVE_SIG_TO_PT(SVE_SIG_ZREG_OFFSET(vq, n)) ++ (SVE_PT_REGS_OFFSET + __SVE_ZREG_OFFSET(vq, n)) + #define SVE_PT_SVE_ZREGS_SIZE(vq) \ +- (SVE_PT_SVE_ZREG_OFFSET(vq, SVE_NUM_ZREGS) - SVE_PT_SVE_ZREGS_OFFSET) ++ (SVE_PT_SVE_ZREG_OFFSET(vq, __SVE_NUM_ZREGS) - SVE_PT_SVE_ZREGS_OFFSET) + + #define SVE_PT_SVE_PREGS_OFFSET(vq) \ +- __SVE_SIG_TO_PT(SVE_SIG_PREGS_OFFSET(vq)) ++ (SVE_PT_REGS_OFFSET + __SVE_PREGS_OFFSET(vq)) + #define SVE_PT_SVE_PREG_OFFSET(vq, n) \ +- __SVE_SIG_TO_PT(SVE_SIG_PREG_OFFSET(vq, n)) ++ (SVE_PT_REGS_OFFSET + __SVE_PREG_OFFSET(vq, n)) + #define SVE_PT_SVE_PREGS_SIZE(vq) \ +- (SVE_PT_SVE_PREG_OFFSET(vq, SVE_NUM_PREGS) - \ ++ (SVE_PT_SVE_PREG_OFFSET(vq, __SVE_NUM_PREGS) - \ + SVE_PT_SVE_PREGS_OFFSET(vq)) + + #define SVE_PT_SVE_FFR_OFFSET(vq) \ +- __SVE_SIG_TO_PT(SVE_SIG_FFR_OFFSET(vq)) ++ (SVE_PT_REGS_OFFSET + __SVE_FFR_OFFSET(vq)) + + #define SVE_PT_SVE_FPSR_OFFSET(vq) \ + ((SVE_PT_SVE_FFR_OFFSET(vq) + SVE_PT_SVE_FFR_SIZE(vq) + \ +- (SVE_VQ_BYTES - 1)) \ +- / SVE_VQ_BYTES * SVE_VQ_BYTES) ++ (__SVE_VQ_BYTES - 1)) \ ++ / __SVE_VQ_BYTES * __SVE_VQ_BYTES) + #define SVE_PT_SVE_FPCR_OFFSET(vq) \ + (SVE_PT_SVE_FPSR_OFFSET(vq) + SVE_PT_SVE_FPSR_SIZE) + +@@ -219,8 +216,8 @@ struct user_sve_header { + + #define SVE_PT_SVE_SIZE(vq, flags) \ + ((SVE_PT_SVE_FPCR_OFFSET(vq) + SVE_PT_SVE_FPCR_SIZE \ +- - SVE_PT_SVE_OFFSET + (SVE_VQ_BYTES - 1)) \ +- / SVE_VQ_BYTES * SVE_VQ_BYTES) ++ - SVE_PT_SVE_OFFSET + (__SVE_VQ_BYTES - 1)) \ ++ / __SVE_VQ_BYTES * __SVE_VQ_BYTES) + + #define SVE_PT_SIZE(vq, flags) \ + (((flags) & SVE_PT_REGS_MASK) == SVE_PT_REGS_SVE ? \ +--- a/arch/arm64/include/uapi/asm/sigcontext.h ++++ b/arch/arm64/include/uapi/asm/sigcontext.h +@@ -130,6 +130,8 @@ struct sve_context { + + #endif /* !__ASSEMBLY__ */ + ++#include ++ + /* + * The SVE architecture leaves space for future expansion of the + * vector length beyond its initial architectural limit of 2048 bits +@@ -138,21 +140,20 @@ struct sve_context { + * See linux/Documentation/arm64/sve.txt for a description of the VL/VQ + * terminology. + */ +-#define SVE_VQ_BYTES 16 /* number of bytes per quadword */ ++#define SVE_VQ_BYTES __SVE_VQ_BYTES /* bytes per quadword */ + +-#define SVE_VQ_MIN 1 +-#define SVE_VQ_MAX 512 ++#define SVE_VQ_MIN __SVE_VQ_MIN ++#define SVE_VQ_MAX __SVE_VQ_MAX + +-#define SVE_VL_MIN (SVE_VQ_MIN * SVE_VQ_BYTES) +-#define SVE_VL_MAX (SVE_VQ_MAX * SVE_VQ_BYTES) ++#define SVE_VL_MIN __SVE_VL_MIN ++#define SVE_VL_MAX __SVE_VL_MAX + +-#define SVE_NUM_ZREGS 32 +-#define SVE_NUM_PREGS 16 ++#define SVE_NUM_ZREGS __SVE_NUM_ZREGS ++#define SVE_NUM_PREGS __SVE_NUM_PREGS + +-#define sve_vl_valid(vl) \ +- ((vl) % SVE_VQ_BYTES == 0 && (vl) >= SVE_VL_MIN && (vl) <= SVE_VL_MAX) +-#define sve_vq_from_vl(vl) ((vl) / SVE_VQ_BYTES) +-#define sve_vl_from_vq(vq) ((vq) * SVE_VQ_BYTES) ++#define sve_vl_valid(vl) __sve_vl_valid(vl) ++#define sve_vq_from_vl(vl) __sve_vq_from_vl(vl) ++#define sve_vl_from_vq(vq) __sve_vl_from_vq(vq) + + /* + * If the SVE registers are currently live for the thread at signal delivery, +@@ -205,34 +206,33 @@ struct sve_context { + * Additional data might be appended in the future. + */ + +-#define SVE_SIG_ZREG_SIZE(vq) ((__u32)(vq) * SVE_VQ_BYTES) +-#define SVE_SIG_PREG_SIZE(vq) ((__u32)(vq) * (SVE_VQ_BYTES / 8)) +-#define SVE_SIG_FFR_SIZE(vq) SVE_SIG_PREG_SIZE(vq) ++#define SVE_SIG_ZREG_SIZE(vq) __SVE_ZREG_SIZE(vq) ++#define SVE_SIG_PREG_SIZE(vq) __SVE_PREG_SIZE(vq) ++#define SVE_SIG_FFR_SIZE(vq) __SVE_FFR_SIZE(vq) + + #define SVE_SIG_REGS_OFFSET \ +- ((sizeof(struct sve_context) + (SVE_VQ_BYTES - 1)) \ +- / SVE_VQ_BYTES * SVE_VQ_BYTES) ++ ((sizeof(struct sve_context) + (__SVE_VQ_BYTES - 1)) \ ++ / __SVE_VQ_BYTES * __SVE_VQ_BYTES) + +-#define SVE_SIG_ZREGS_OFFSET SVE_SIG_REGS_OFFSET ++#define SVE_SIG_ZREGS_OFFSET \ ++ (SVE_SIG_REGS_OFFSET + __SVE_ZREGS_OFFSET) + #define SVE_SIG_ZREG_OFFSET(vq, n) \ +- (SVE_SIG_ZREGS_OFFSET + SVE_SIG_ZREG_SIZE(vq) * (n)) +-#define SVE_SIG_ZREGS_SIZE(vq) \ +- (SVE_SIG_ZREG_OFFSET(vq, SVE_NUM_ZREGS) - SVE_SIG_ZREGS_OFFSET) ++ (SVE_SIG_REGS_OFFSET + __SVE_ZREG_OFFSET(vq, n)) ++#define SVE_SIG_ZREGS_SIZE(vq) __SVE_ZREGS_SIZE(vq) + + #define SVE_SIG_PREGS_OFFSET(vq) \ +- (SVE_SIG_ZREGS_OFFSET + SVE_SIG_ZREGS_SIZE(vq)) ++ (SVE_SIG_REGS_OFFSET + __SVE_PREGS_OFFSET(vq)) + #define SVE_SIG_PREG_OFFSET(vq, n) \ +- (SVE_SIG_PREGS_OFFSET(vq) + SVE_SIG_PREG_SIZE(vq) * (n)) +-#define SVE_SIG_PREGS_SIZE(vq) \ +- (SVE_SIG_PREG_OFFSET(vq, SVE_NUM_PREGS) - SVE_SIG_PREGS_OFFSET(vq)) ++ (SVE_SIG_REGS_OFFSET + __SVE_PREG_OFFSET(vq, n)) ++#define SVE_SIG_PREGS_SIZE(vq) __SVE_PREGS_SIZE(vq) + + #define SVE_SIG_FFR_OFFSET(vq) \ +- (SVE_SIG_PREGS_OFFSET(vq) + SVE_SIG_PREGS_SIZE(vq)) ++ (SVE_SIG_REGS_OFFSET + __SVE_FFR_OFFSET(vq)) + + #define SVE_SIG_REGS_SIZE(vq) \ +- (SVE_SIG_FFR_OFFSET(vq) + SVE_SIG_FFR_SIZE(vq) - SVE_SIG_REGS_OFFSET) +- +-#define SVE_SIG_CONTEXT_SIZE(vq) (SVE_SIG_REGS_OFFSET + SVE_SIG_REGS_SIZE(vq)) ++ (__SVE_FFR_OFFSET(vq) + __SVE_FFR_SIZE(vq)) + ++#define SVE_SIG_CONTEXT_SIZE(vq) \ ++ (SVE_SIG_REGS_OFFSET + SVE_SIG_REGS_SIZE(vq)) + + #endif /* _UAPI__ASM_SIGCONTEXT_H */ +--- /dev/null ++++ b/arch/arm64/include/uapi/asm/sve_context.h +@@ -0,0 +1,53 @@ ++/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ ++/* Copyright (C) 2017-2018 ARM Limited */ ++ ++/* ++ * For use by other UAPI headers only. ++ * Do not make direct use of header or its definitions. ++ */ ++ ++#ifndef _UAPI__ASM_SVE_CONTEXT_H ++#define _UAPI__ASM_SVE_CONTEXT_H ++ ++#include ++ ++#define __SVE_VQ_BYTES 16 /* number of bytes per quadword */ ++ ++#define __SVE_VQ_MIN 1 ++#define __SVE_VQ_MAX 512 ++ ++#define __SVE_VL_MIN (__SVE_VQ_MIN * __SVE_VQ_BYTES) ++#define __SVE_VL_MAX (__SVE_VQ_MAX * __SVE_VQ_BYTES) ++ ++#define __SVE_NUM_ZREGS 32 ++#define __SVE_NUM_PREGS 16 ++ ++#define __sve_vl_valid(vl) \ ++ ((vl) % __SVE_VQ_BYTES == 0 && \ ++ (vl) >= __SVE_VL_MIN && \ ++ (vl) <= __SVE_VL_MAX) ++ ++#define __sve_vq_from_vl(vl) ((vl) / __SVE_VQ_BYTES) ++#define __sve_vl_from_vq(vq) ((vq) * __SVE_VQ_BYTES) ++ ++#define __SVE_ZREG_SIZE(vq) ((__u32)(vq) * __SVE_VQ_BYTES) ++#define __SVE_PREG_SIZE(vq) ((__u32)(vq) * (__SVE_VQ_BYTES / 8)) ++#define __SVE_FFR_SIZE(vq) __SVE_PREG_SIZE(vq) ++ ++#define __SVE_ZREGS_OFFSET 0 ++#define __SVE_ZREG_OFFSET(vq, n) \ ++ (__SVE_ZREGS_OFFSET + __SVE_ZREG_SIZE(vq) * (n)) ++#define __SVE_ZREGS_SIZE(vq) \ ++ (__SVE_ZREG_OFFSET(vq, __SVE_NUM_ZREGS) - __SVE_ZREGS_OFFSET) ++ ++#define __SVE_PREGS_OFFSET(vq) \ ++ (__SVE_ZREGS_OFFSET + __SVE_ZREGS_SIZE(vq)) ++#define __SVE_PREG_OFFSET(vq, n) \ ++ (__SVE_PREGS_OFFSET(vq) + __SVE_PREG_SIZE(vq) * (n)) ++#define __SVE_PREGS_SIZE(vq) \ ++ (__SVE_PREG_OFFSET(vq, __SVE_NUM_PREGS) - __SVE_PREGS_OFFSET(vq)) ++ ++#define __SVE_FFR_OFFSET(vq) \ ++ (__SVE_PREGS_OFFSET(vq) + __SVE_PREGS_SIZE(vq)) ++ ++#endif /* ! _UAPI__ASM_SVE_CONTEXT_H */ diff --git a/target/linux/generic/backport-4.19/380-v5.3-net-sched-Introduce-act_ctinfo-action.patch b/target/linux/generic/backport-4.19/380-v5.3-net-sched-Introduce-act_ctinfo-action.patch index 8e04dce30..a680402f2 100644 --- a/target/linux/generic/backport-4.19/380-v5.3-net-sched-Introduce-act_ctinfo-action.patch +++ b/target/linux/generic/backport-4.19/380-v5.3-net-sched-Introduce-act_ctinfo-action.patch @@ -1,4 +1,4 @@ -From 6d8071bbbdcd9d3a2fbb49e55b51617906e3b816 Mon Sep 17 00:00:00 2001 +From d129a72f465dab2d9fc8f1580c38600a8b808327 Mon Sep 17 00:00:00 2001 From: Kevin Darbyshire-Bryant Date: Wed, 13 Mar 2019 20:54:49 +0000 Subject: [PATCH] net: sched: Backport Introduce act_ctinfo action @@ -112,9 +112,9 @@ Signed-off-by: Kevin Darbyshire-Bryant include/uapi/linux/tc_act/tc_ctinfo.h | 29 ++ net/sched/Kconfig | 17 + net/sched/Makefile | 1 + - net/sched/act_ctinfo.c | 409 ++++++++++++++++++++++ + net/sched/act_ctinfo.c | 420 ++++++++++++++++++++++ tools/testing/selftests/tc-testing/config | 1 + - 7 files changed, 492 insertions(+), 1 deletion(-) + 7 files changed, 503 insertions(+), 1 deletion(-) create mode 100644 include/net/tc_act/tc_ctinfo.h create mode 100644 include/uapi/linux/tc_act/tc_ctinfo.h create mode 100644 net/sched/act_ctinfo.c @@ -237,7 +237,7 @@ Signed-off-by: Kevin Darbyshire-Bryant obj-$(CONFIG_NET_IFE_SKBMARK) += act_meta_mark.o --- /dev/null +++ b/net/sched/act_ctinfo.c -@@ -0,0 +1,409 @@ +@@ -0,0 +1,420 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* net/sched/act_ctinfo.c netfilter ctinfo connmark actions + * @@ -601,6 +601,16 @@ Signed-off-by: Kevin Darbyshire-Bryant + return tcf_idr_search(tn, a, index); +} + ++static void tcf_ctinfo_cleanup(struct tc_action *a) ++{ ++ struct tcf_ctinfo *ci = to_ctinfo(a); ++ struct tcf_ctinfo_params *cp; ++ ++ cp = rcu_dereference_protected(ci->params, 1); ++ if (cp) ++ kfree_rcu(cp, rcu); ++} ++ +static struct tc_action_ops act_ctinfo_ops = { + .kind = "ctinfo", + .type = TCA_ID_CTINFO, @@ -609,6 +619,7 @@ Signed-off-by: Kevin Darbyshire-Bryant + .dump = tcf_ctinfo_dump, + .init = tcf_ctinfo_init, + .walk = tcf_ctinfo_walker, ++ .cleanup= tcf_ctinfo_cleanup, + .lookup = tcf_ctinfo_search, + .size = sizeof(struct tcf_ctinfo), +}; diff --git a/target/linux/generic/backport-4.19/450-v5.0-mtd-spinand-winbond-Add-support-for-W25N01GV.patch b/target/linux/generic/backport-4.19/450-v5.0-mtd-spinand-winbond-Add-support-for-W25N01GV.patch new file mode 100644 index 000000000..2024577b8 --- /dev/null +++ b/target/linux/generic/backport-4.19/450-v5.0-mtd-spinand-winbond-Add-support-for-W25N01GV.patch @@ -0,0 +1,37 @@ +From 9a4d83074769d6ecf1f5c3fef0f183b09abf3726 Mon Sep 17 00:00:00 2001 +From: Robert Marko +Date: Sat, 6 Oct 2018 17:36:42 +0200 +Subject: [PATCH 1/8] mtd: spinand: winbond: Add support for W25N01GV + +W25N01GV is a single die version of the already supported +W25M02GV with half the capacity. Everything else is the +same so introduce support for W25N01GV. + +Datasheet:http://www.winbond.com/resource-files/w25n01gv%20revl%20050918%20unsecured.pdf + +Tested on 8devices Jalapeno dev board under OpenWrt running 4.19-rc5. + +Signed-off-by: Robert Marko +Reviewed-by: Boris Brezillon +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/spi/winbond.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +--- a/drivers/mtd/nand/spi/winbond.c ++++ b/drivers/mtd/nand/spi/winbond.c +@@ -84,6 +84,14 @@ static const struct spinand_info winbond + 0, + SPINAND_ECCINFO(&w25m02gv_ooblayout, NULL), + SPINAND_SELECT_TARGET(w25m02gv_select_target)), ++ SPINAND_INFO("W25N01GV", 0xAA, ++ NAND_MEMORG(1, 2048, 64, 64, 1024, 1, 1, 1), ++ NAND_ECCREQ(1, 512), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, ++ &write_cache_variants, ++ &update_cache_variants), ++ 0, ++ SPINAND_ECCINFO(&w25m02gv_ooblayout, NULL)), + }; + + /** diff --git a/target/linux/generic/backport-4.19/451-v5.0-mtd-spinand-Add-initial-support-for-Toshiba-TC58CVG2.patch b/target/linux/generic/backport-4.19/451-v5.0-mtd-spinand-Add-initial-support-for-Toshiba-TC58CVG2.patch new file mode 100644 index 000000000..ed42f0024 --- /dev/null +++ b/target/linux/generic/backport-4.19/451-v5.0-mtd-spinand-Add-initial-support-for-Toshiba-TC58CVG2.patch @@ -0,0 +1,188 @@ +From 10949af1681d5bb5cdbcc012815c6e40eec17d02 Mon Sep 17 00:00:00 2001 +From: Schrempf Frieder +Date: Thu, 8 Nov 2018 08:32:11 +0000 +Subject: [PATCH 2/8] mtd: spinand: Add initial support for Toshiba TC58CVG2S0H +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add minimal support for the Toshiba TC58CVG2S0H SPI NAND chip. + +Signed-off-by: Frieder Schrempf +Acked-by: Clément Péron +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/spi/Makefile | 2 +- + drivers/mtd/nand/spi/core.c | 1 + + drivers/mtd/nand/spi/toshiba.c | 137 +++++++++++++++++++++++++++++++++ + include/linux/mtd/spinand.h | 1 + + 4 files changed, 140 insertions(+), 1 deletion(-) + create mode 100644 drivers/mtd/nand/spi/toshiba.c + +--- a/drivers/mtd/nand/spi/Makefile ++++ b/drivers/mtd/nand/spi/Makefile +@@ -1,3 +1,3 @@ + # SPDX-License-Identifier: GPL-2.0 +-spinand-objs := core.o macronix.o micron.o winbond.o ++spinand-objs := core.o macronix.o micron.o toshiba.o winbond.o + obj-$(CONFIG_MTD_SPI_NAND) += spinand.o +--- a/drivers/mtd/nand/spi/core.c ++++ b/drivers/mtd/nand/spi/core.c +@@ -764,6 +764,7 @@ static const struct nand_ops spinand_ops + static const struct spinand_manufacturer *spinand_manufacturers[] = { + ¯onix_spinand_manufacturer, + µn_spinand_manufacturer, ++ &toshiba_spinand_manufacturer, + &winbond_spinand_manufacturer, + }; + +--- /dev/null ++++ b/drivers/mtd/nand/spi/toshiba.c +@@ -0,0 +1,137 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Copyright (c) 2018 exceet electronics GmbH ++ * Copyright (c) 2018 Kontron Electronics GmbH ++ * ++ * Author: Frieder Schrempf ++ */ ++ ++#include ++#include ++#include ++ ++#define SPINAND_MFR_TOSHIBA 0x98 ++#define TOSH_STATUS_ECC_HAS_BITFLIPS_T (3 << 4) ++ ++static SPINAND_OP_VARIANTS(read_cache_variants, ++ SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0)); ++ ++static SPINAND_OP_VARIANTS(write_cache_variants, ++ SPINAND_PROG_LOAD(true, 0, NULL, 0)); ++ ++static SPINAND_OP_VARIANTS(update_cache_variants, ++ SPINAND_PROG_LOAD(false, 0, NULL, 0)); ++ ++static int tc58cvg2s0h_ooblayout_ecc(struct mtd_info *mtd, int section, ++ struct mtd_oob_region *region) ++{ ++ if (section > 7) ++ return -ERANGE; ++ ++ region->offset = 128 + 16 * section; ++ region->length = 16; ++ ++ return 0; ++} ++ ++static int tc58cvg2s0h_ooblayout_free(struct mtd_info *mtd, int section, ++ struct mtd_oob_region *region) ++{ ++ if (section > 0) ++ return -ERANGE; ++ ++ /* 2 bytes reserved for BBM */ ++ region->offset = 2; ++ region->length = 126; ++ ++ return 0; ++} ++ ++static const struct mtd_ooblayout_ops tc58cvg2s0h_ooblayout = { ++ .ecc = tc58cvg2s0h_ooblayout_ecc, ++ .free = tc58cvg2s0h_ooblayout_free, ++}; ++ ++static int tc58cvg2s0h_ecc_get_status(struct spinand_device *spinand, ++ u8 status) ++{ ++ struct nand_device *nand = spinand_to_nand(spinand); ++ u8 mbf = 0; ++ struct spi_mem_op op = SPINAND_GET_FEATURE_OP(0x30, &mbf); ++ ++ switch (status & STATUS_ECC_MASK) { ++ case STATUS_ECC_NO_BITFLIPS: ++ return 0; ++ ++ case STATUS_ECC_UNCOR_ERROR: ++ return -EBADMSG; ++ ++ case STATUS_ECC_HAS_BITFLIPS: ++ case TOSH_STATUS_ECC_HAS_BITFLIPS_T: ++ /* ++ * Let's try to retrieve the real maximum number of bitflips ++ * in order to avoid forcing the wear-leveling layer to move ++ * data around if it's not necessary. ++ */ ++ if (spi_mem_exec_op(spinand->spimem, &op)) ++ return nand->eccreq.strength; ++ ++ mbf >>= 4; ++ ++ if (WARN_ON(mbf > nand->eccreq.strength || !mbf)) ++ return nand->eccreq.strength; ++ ++ return mbf; ++ ++ default: ++ break; ++ } ++ ++ return -EINVAL; ++} ++ ++static const struct spinand_info toshiba_spinand_table[] = { ++ SPINAND_INFO("TC58CVG2S0H", 0xCD, ++ NAND_MEMORG(1, 4096, 256, 64, 2048, 1, 1, 1), ++ NAND_ECCREQ(8, 512), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, ++ &write_cache_variants, ++ &update_cache_variants), ++ SPINAND_HAS_QE_BIT, ++ SPINAND_ECCINFO(&tc58cvg2s0h_ooblayout, ++ tc58cvg2s0h_ecc_get_status)), ++}; ++ ++static int toshiba_spinand_detect(struct spinand_device *spinand) ++{ ++ u8 *id = spinand->id.data; ++ int ret; ++ ++ /* ++ * Toshiba SPI NAND read ID needs a dummy byte, ++ * so the first byte in id is garbage. ++ */ ++ if (id[1] != SPINAND_MFR_TOSHIBA) ++ return 0; ++ ++ ret = spinand_match_and_init(spinand, toshiba_spinand_table, ++ ARRAY_SIZE(toshiba_spinand_table), ++ id[2]); ++ if (ret) ++ return ret; ++ ++ return 1; ++} ++ ++static const struct spinand_manufacturer_ops toshiba_spinand_manuf_ops = { ++ .detect = toshiba_spinand_detect, ++}; ++ ++const struct spinand_manufacturer toshiba_spinand_manufacturer = { ++ .id = SPINAND_MFR_TOSHIBA, ++ .name = "Toshiba", ++ .ops = &toshiba_spinand_manuf_ops, ++}; +--- a/include/linux/mtd/spinand.h ++++ b/include/linux/mtd/spinand.h +@@ -196,6 +196,7 @@ struct spinand_manufacturer { + /* SPI NAND manufacturers */ + extern const struct spinand_manufacturer macronix_spinand_manufacturer; + extern const struct spinand_manufacturer micron_spinand_manufacturer; ++extern const struct spinand_manufacturer toshiba_spinand_manufacturer; + extern const struct spinand_manufacturer winbond_spinand_manufacturer; + + /** diff --git a/target/linux/generic/backport-4.19/450-v5.0-mtd-spinand-add-support-for-GigaDevice-GD5FxGQ4xA.patch b/target/linux/generic/backport-4.19/452-v5.0-mtd-spinand-add-support-for-GigaDevice-GD5FxGQ4xA.patch similarity index 94% rename from target/linux/generic/backport-4.19/450-v5.0-mtd-spinand-add-support-for-GigaDevice-GD5FxGQ4xA.patch rename to target/linux/generic/backport-4.19/452-v5.0-mtd-spinand-add-support-for-GigaDevice-GD5FxGQ4xA.patch index 15f761ab9..4e6f18a4c 100644 --- a/target/linux/generic/backport-4.19/450-v5.0-mtd-spinand-add-support-for-GigaDevice-GD5FxGQ4xA.patch +++ b/target/linux/generic/backport-4.19/452-v5.0-mtd-spinand-add-support-for-GigaDevice-GD5FxGQ4xA.patch @@ -1,7 +1,7 @@ From c93c613214ac70c87beab5422a60077bf126b855 Mon Sep 17 00:00:00 2001 From: Chuanhong Guo Date: Wed, 28 Nov 2018 21:07:25 +0800 -Subject: [PATCH] mtd: spinand: add support for GigaDevice GD5FxGQ4xA +Subject: [PATCH 3/8] mtd: spinand: add support for GigaDevice GD5FxGQ4xA Add support for GigaDevice GD5F1G/2G/4GQ4xA SPI NAND. @@ -11,7 +11,7 @@ Signed-off-by: Miquel Raynal --- drivers/mtd/nand/spi/Makefile | 2 +- drivers/mtd/nand/spi/core.c | 1 + - drivers/mtd/nand/spi/gigadevice.c | 148 ++++++++++++++++++++++++++++++++++++++ + drivers/mtd/nand/spi/gigadevice.c | 148 ++++++++++++++++++++++++++++++ include/linux/mtd/spinand.h | 1 + 4 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 drivers/mtd/nand/spi/gigadevice.c @@ -20,8 +20,8 @@ Signed-off-by: Miquel Raynal +++ b/drivers/mtd/nand/spi/Makefile @@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 --spinand-objs := core.o macronix.o micron.o winbond.o -+spinand-objs := core.o gigadevice.o macronix.o micron.o winbond.o +-spinand-objs := core.o macronix.o micron.o toshiba.o winbond.o ++spinand-objs := core.o gigadevice.o macronix.o micron.o toshiba.o winbond.o obj-$(CONFIG_MTD_SPI_NAND) += spinand.o --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -32,7 +32,7 @@ Signed-off-by: Miquel Raynal + &gigadevice_spinand_manufacturer, ¯onix_spinand_manufacturer, µn_spinand_manufacturer, - &winbond_spinand_manufacturer, + &toshiba_spinand_manufacturer, --- /dev/null +++ b/drivers/mtd/nand/spi/gigadevice.c @@ -0,0 +1,148 @@ @@ -193,4 +193,4 @@ Signed-off-by: Miquel Raynal +extern const struct spinand_manufacturer gigadevice_spinand_manufacturer; extern const struct spinand_manufacturer macronix_spinand_manufacturer; extern const struct spinand_manufacturer micron_spinand_manufacturer; - extern const struct spinand_manufacturer winbond_spinand_manufacturer; + extern const struct spinand_manufacturer toshiba_spinand_manufacturer; diff --git a/target/linux/generic/backport-4.19/455-v5.1-mtd-spinand-Add-support-for-all-Toshiba-Memory-produ.patch b/target/linux/generic/backport-4.19/455-v5.1-mtd-spinand-Add-support-for-all-Toshiba-Memory-produ.patch new file mode 100644 index 000000000..aad82dcf7 --- /dev/null +++ b/target/linux/generic/backport-4.19/455-v5.1-mtd-spinand-Add-support-for-all-Toshiba-Memory-produ.patch @@ -0,0 +1,136 @@ +From db214513f62fd13c0a9af3bd5c5d634dba37e65d Mon Sep 17 00:00:00 2001 +From: Yoshio Furuyama +Date: Wed, 16 Jan 2019 14:53:19 +0900 +Subject: [PATCH 7/8] mtd: spinand: Add support for all Toshiba Memory products + +Add device table for Toshiba Memory products. +Also, generalize OOB layout structure and function names. + +Signed-off-by: Yoshio Furuyama +Reviewed-by: Frieder Schrempf +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/spi/toshiba.c | 79 ++++++++++++++++++++++++++++------ + 1 file changed, 65 insertions(+), 14 deletions(-) + +--- a/drivers/mtd/nand/spi/toshiba.c ++++ b/drivers/mtd/nand/spi/toshiba.c +@@ -25,19 +25,19 @@ static SPINAND_OP_VARIANTS(write_cache_v + static SPINAND_OP_VARIANTS(update_cache_variants, + SPINAND_PROG_LOAD(false, 0, NULL, 0)); + +-static int tc58cvg2s0h_ooblayout_ecc(struct mtd_info *mtd, int section, ++static int tc58cxgxsx_ooblayout_ecc(struct mtd_info *mtd, int section, + struct mtd_oob_region *region) + { +- if (section > 7) ++ if (section > 0) + return -ERANGE; + +- region->offset = 128 + 16 * section; +- region->length = 16; ++ region->offset = mtd->oobsize / 2; ++ region->length = mtd->oobsize / 2; + + return 0; + } + +-static int tc58cvg2s0h_ooblayout_free(struct mtd_info *mtd, int section, ++static int tc58cxgxsx_ooblayout_free(struct mtd_info *mtd, int section, + struct mtd_oob_region *region) + { + if (section > 0) +@@ -45,17 +45,17 @@ static int tc58cvg2s0h_ooblayout_free(st + + /* 2 bytes reserved for BBM */ + region->offset = 2; +- region->length = 126; ++ region->length = (mtd->oobsize / 2) - 2; + + return 0; + } + +-static const struct mtd_ooblayout_ops tc58cvg2s0h_ooblayout = { +- .ecc = tc58cvg2s0h_ooblayout_ecc, +- .free = tc58cvg2s0h_ooblayout_free, ++static const struct mtd_ooblayout_ops tc58cxgxsx_ooblayout = { ++ .ecc = tc58cxgxsx_ooblayout_ecc, ++ .free = tc58cxgxsx_ooblayout_free, + }; + +-static int tc58cvg2s0h_ecc_get_status(struct spinand_device *spinand, ++static int tc58cxgxsx_ecc_get_status(struct spinand_device *spinand, + u8 status) + { + struct nand_device *nand = spinand_to_nand(spinand); +@@ -94,15 +94,66 @@ static int tc58cvg2s0h_ecc_get_status(st + } + + static const struct spinand_info toshiba_spinand_table[] = { +- SPINAND_INFO("TC58CVG2S0H", 0xCD, ++ /* 3.3V 1Gb */ ++ SPINAND_INFO("TC58CVG0S3", 0xC2, ++ NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), ++ NAND_ECCREQ(8, 512), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, ++ &write_cache_variants, ++ &update_cache_variants), ++ 0, ++ SPINAND_ECCINFO(&tc58cxgxsx_ooblayout, ++ tc58cxgxsx_ecc_get_status)), ++ /* 3.3V 2Gb */ ++ SPINAND_INFO("TC58CVG1S3", 0xCB, ++ NAND_MEMORG(1, 2048, 128, 64, 2048, 1, 1, 1), ++ NAND_ECCREQ(8, 512), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, ++ &write_cache_variants, ++ &update_cache_variants), ++ 0, ++ SPINAND_ECCINFO(&tc58cxgxsx_ooblayout, ++ tc58cxgxsx_ecc_get_status)), ++ /* 3.3V 4Gb */ ++ SPINAND_INFO("TC58CVG2S0", 0xCD, ++ NAND_MEMORG(1, 4096, 256, 64, 2048, 1, 1, 1), ++ NAND_ECCREQ(8, 512), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, ++ &write_cache_variants, ++ &update_cache_variants), ++ 0, ++ SPINAND_ECCINFO(&tc58cxgxsx_ooblayout, ++ tc58cxgxsx_ecc_get_status)), ++ /* 1.8V 1Gb */ ++ SPINAND_INFO("TC58CYG0S3", 0xB2, ++ NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), ++ NAND_ECCREQ(8, 512), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, ++ &write_cache_variants, ++ &update_cache_variants), ++ 0, ++ SPINAND_ECCINFO(&tc58cxgxsx_ooblayout, ++ tc58cxgxsx_ecc_get_status)), ++ /* 1.8V 2Gb */ ++ SPINAND_INFO("TC58CYG1S3", 0xBB, ++ NAND_MEMORG(1, 2048, 128, 64, 2048, 1, 1, 1), ++ NAND_ECCREQ(8, 512), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, ++ &write_cache_variants, ++ &update_cache_variants), ++ 0, ++ SPINAND_ECCINFO(&tc58cxgxsx_ooblayout, ++ tc58cxgxsx_ecc_get_status)), ++ /* 1.8V 4Gb */ ++ SPINAND_INFO("TC58CYG2S0", 0xBD, + NAND_MEMORG(1, 4096, 256, 64, 2048, 1, 1, 1), + NAND_ECCREQ(8, 512), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, + &update_cache_variants), +- SPINAND_HAS_QE_BIT, +- SPINAND_ECCINFO(&tc58cvg2s0h_ooblayout, +- tc58cvg2s0h_ecc_get_status)), ++ 0, ++ SPINAND_ECCINFO(&tc58cxgxsx_ooblayout, ++ tc58cxgxsx_ecc_get_status)), + }; + + static int toshiba_spinand_detect(struct spinand_device *spinand) diff --git a/target/linux/generic/backport-4.19/451-v5.1-mtd-spinand-Add-support-for-GigaDevice-GD5F1GQ4UExxG.patch b/target/linux/generic/backport-4.19/456-v5.1-mtd-spinand-Add-support-for-GigaDevice-GD5F1GQ4UExxG.patch similarity index 97% rename from target/linux/generic/backport-4.19/451-v5.1-mtd-spinand-Add-support-for-GigaDevice-GD5F1GQ4UExxG.patch rename to target/linux/generic/backport-4.19/456-v5.1-mtd-spinand-Add-support-for-GigaDevice-GD5F1GQ4UExxG.patch index f6d676470..8e48debf4 100644 --- a/target/linux/generic/backport-4.19/451-v5.1-mtd-spinand-Add-support-for-GigaDevice-GD5F1GQ4UExxG.patch +++ b/target/linux/generic/backport-4.19/456-v5.1-mtd-spinand-Add-support-for-GigaDevice-GD5F1GQ4UExxG.patch @@ -1,7 +1,7 @@ From c40c7a990a46e5102a1cc4190557bf315d32d80d Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Thu, 24 Jan 2019 13:48:06 +0100 -Subject: [PATCH] mtd: spinand: Add support for GigaDevice GD5F1GQ4UExxG +Subject: [PATCH 8/8] mtd: spinand: Add support for GigaDevice GD5F1GQ4UExxG Add support for GigaDevice GD5F1GQ4UExxG SPI NAND chip. @@ -13,7 +13,7 @@ Cc: Boris Brezillon Reviewed-by: Boris Brezillon Signed-off-by: Miquel Raynal --- - drivers/mtd/nand/spi/gigadevice.c | 83 +++++++++++++++++++++++++++++++++++++++ + drivers/mtd/nand/spi/gigadevice.c | 83 +++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) --- a/drivers/mtd/nand/spi/gigadevice.c diff --git a/target/linux/generic/backport-4.19/460-v5.3-mtd-spinand-Define-macros-for-page-read-ops-with-thr.patch b/target/linux/generic/backport-4.19/460-v5.3-mtd-spinand-Define-macros-for-page-read-ops-with-thr.patch new file mode 100644 index 000000000..c28ae1d79 --- /dev/null +++ b/target/linux/generic/backport-4.19/460-v5.3-mtd-spinand-Define-macros-for-page-read-ops-with-thr.patch @@ -0,0 +1,81 @@ +From d014717d50b1efd011a3a028ce92563a4dc9bae5 Mon Sep 17 00:00:00 2001 +From: Jeff Kletsky +Date: Wed, 22 May 2019 15:05:53 -0700 +Subject: [PATCH 1/3] mtd: spinand: Define macros for page-read ops with + three-byte addresses + +The GigaDevice GD5F1GQ4UFxxG SPI NAND utilizes three-byte addresses +for its page-read ops. + +http://www.gigadevice.com/datasheet/gd5f1gq4xfxxg/ + +Signed-off-by: Jeff Kletsky +Reviewed-by: Frieder Schrempf +Signed-off-by: Miquel Raynal +--- + include/linux/mtd/spinand.h | 30 ++++++++++++++++++++++++++++++ + 1 file changed, 30 insertions(+) + +--- a/include/linux/mtd/spinand.h ++++ b/include/linux/mtd/spinand.h +@@ -68,30 +68,60 @@ + SPI_MEM_OP_DUMMY(ndummy, 1), \ + SPI_MEM_OP_DATA_IN(len, buf, 1)) + ++#define SPINAND_PAGE_READ_FROM_CACHE_OP_3A(fast, addr, ndummy, buf, len) \ ++ SPI_MEM_OP(SPI_MEM_OP_CMD(fast ? 0x0b : 0x03, 1), \ ++ SPI_MEM_OP_ADDR(3, addr, 1), \ ++ SPI_MEM_OP_DUMMY(ndummy, 1), \ ++ SPI_MEM_OP_DATA_IN(len, buf, 1)) ++ + #define SPINAND_PAGE_READ_FROM_CACHE_X2_OP(addr, ndummy, buf, len) \ + SPI_MEM_OP(SPI_MEM_OP_CMD(0x3b, 1), \ + SPI_MEM_OP_ADDR(2, addr, 1), \ + SPI_MEM_OP_DUMMY(ndummy, 1), \ + SPI_MEM_OP_DATA_IN(len, buf, 2)) + ++#define SPINAND_PAGE_READ_FROM_CACHE_X2_OP_3A(addr, ndummy, buf, len) \ ++ SPI_MEM_OP(SPI_MEM_OP_CMD(0x3b, 1), \ ++ SPI_MEM_OP_ADDR(3, addr, 1), \ ++ SPI_MEM_OP_DUMMY(ndummy, 1), \ ++ SPI_MEM_OP_DATA_IN(len, buf, 2)) ++ + #define SPINAND_PAGE_READ_FROM_CACHE_X4_OP(addr, ndummy, buf, len) \ + SPI_MEM_OP(SPI_MEM_OP_CMD(0x6b, 1), \ + SPI_MEM_OP_ADDR(2, addr, 1), \ + SPI_MEM_OP_DUMMY(ndummy, 1), \ + SPI_MEM_OP_DATA_IN(len, buf, 4)) + ++#define SPINAND_PAGE_READ_FROM_CACHE_X4_OP_3A(addr, ndummy, buf, len) \ ++ SPI_MEM_OP(SPI_MEM_OP_CMD(0x6b, 1), \ ++ SPI_MEM_OP_ADDR(3, addr, 1), \ ++ SPI_MEM_OP_DUMMY(ndummy, 1), \ ++ SPI_MEM_OP_DATA_IN(len, buf, 4)) ++ + #define SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(addr, ndummy, buf, len) \ + SPI_MEM_OP(SPI_MEM_OP_CMD(0xbb, 1), \ + SPI_MEM_OP_ADDR(2, addr, 2), \ + SPI_MEM_OP_DUMMY(ndummy, 2), \ + SPI_MEM_OP_DATA_IN(len, buf, 2)) + ++#define SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP_3A(addr, ndummy, buf, len) \ ++ SPI_MEM_OP(SPI_MEM_OP_CMD(0xbb, 1), \ ++ SPI_MEM_OP_ADDR(3, addr, 2), \ ++ SPI_MEM_OP_DUMMY(ndummy, 2), \ ++ SPI_MEM_OP_DATA_IN(len, buf, 2)) ++ + #define SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(addr, ndummy, buf, len) \ + SPI_MEM_OP(SPI_MEM_OP_CMD(0xeb, 1), \ + SPI_MEM_OP_ADDR(2, addr, 4), \ + SPI_MEM_OP_DUMMY(ndummy, 4), \ + SPI_MEM_OP_DATA_IN(len, buf, 4)) + ++#define SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP_3A(addr, ndummy, buf, len) \ ++ SPI_MEM_OP(SPI_MEM_OP_CMD(0xeb, 1), \ ++ SPI_MEM_OP_ADDR(3, addr, 4), \ ++ SPI_MEM_OP_DUMMY(ndummy, 4), \ ++ SPI_MEM_OP_DATA_IN(len, buf, 4)) ++ + #define SPINAND_PROG_EXEC_OP(addr) \ + SPI_MEM_OP(SPI_MEM_OP_CMD(0x10, 1), \ + SPI_MEM_OP_ADDR(3, addr, 1), \ diff --git a/target/linux/generic/backport-4.19/461-v5.3-mtd-spinand-Add-support-for-two-byte-device-IDs.patch b/target/linux/generic/backport-4.19/461-v5.3-mtd-spinand-Add-support-for-two-byte-device-IDs.patch new file mode 100644 index 000000000..fcbecbb76 --- /dev/null +++ b/target/linux/generic/backport-4.19/461-v5.3-mtd-spinand-Add-support-for-two-byte-device-IDs.patch @@ -0,0 +1,48 @@ +From 53dd94a79d3bfdaae30e5a4ebf474ea1af1d572e Mon Sep 17 00:00:00 2001 +From: Jeff Kletsky +Date: Wed, 22 May 2019 15:05:54 -0700 +Subject: [PATCH 2/3] mtd: spinand: Add support for two-byte device IDs + +The GigaDevice GD5F1GQ4UFxxG SPI NAND utilizes two-byte device IDs. + +http://www.gigadevice.com/datasheet/gd5f1gq4xfxxg/ + +Signed-off-by: Jeff Kletsky +Reviewed-by: Frieder Schrempf +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/spi/core.c | 2 +- + include/linux/mtd/spinand.h | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/mtd/nand/spi/core.c ++++ b/drivers/mtd/nand/spi/core.c +@@ -853,7 +853,7 @@ spinand_select_op_variant(struct spinand + */ + int spinand_match_and_init(struct spinand_device *spinand, + const struct spinand_info *table, +- unsigned int table_size, u8 devid) ++ unsigned int table_size, u16 devid) + { + struct nand_device *nand = spinand_to_nand(spinand); + unsigned int i; +--- a/include/linux/mtd/spinand.h ++++ b/include/linux/mtd/spinand.h +@@ -290,7 +290,7 @@ struct spinand_ecc_info { + */ + struct spinand_info { + const char *model; +- u8 devid; ++ u16 devid; + u32 flags; + struct nand_memory_organization memorg; + struct nand_ecc_req eccreq; +@@ -445,7 +445,7 @@ static inline void spinand_set_of_node(s + + int spinand_match_and_init(struct spinand_device *dev, + const struct spinand_info *table, +- unsigned int table_size, u8 devid); ++ unsigned int table_size, u16 devid); + + int spinand_upd_cfg(struct spinand_device *spinand, u8 mask, u8 val); + int spinand_select_target(struct spinand_device *spinand, unsigned int target); diff --git a/target/linux/generic/backport-4.19/462-v5.3-mtd-spinand-Add-support-for-GigaDevice-GD5F1GQ4UFxxG.patch b/target/linux/generic/backport-4.19/462-v5.3-mtd-spinand-Add-support-for-GigaDevice-GD5F1GQ4UFxxG.patch new file mode 100644 index 000000000..06d87ba5e --- /dev/null +++ b/target/linux/generic/backport-4.19/462-v5.3-mtd-spinand-Add-support-for-GigaDevice-GD5F1GQ4UFxxG.patch @@ -0,0 +1,197 @@ + +IMPORTANT NOTE +============== + +The content of this patch has been adapted for Linux 4.19 + +Changes were made in Linux 5.x to add the bad-block limit +to the metadata available to the driver, adding a parameter + +NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1), + ^- New bad-block limit + +This patch omits that parameter from the upstream patch +for compatibility with the Linux 4.19 driver. + +===== + +From 049df13c4e63884fe6634db5568e08f65922256e Mon Sep 17 00:00:00 2001 +From: Jeff Kletsky +Date: Wed, 22 May 2019 15:05:55 -0700 +Subject: [PATCH 3/3] mtd: spinand: Add support for GigaDevice GD5F1GQ4UFxxG + +The GigaDevice GD5F1GQ4UFxxG SPI NAND is in current production devices +and, while it has the same logical layout as the E-series devices, +it differs in the SPI interfacing in significant ways. + +This support is contingent on previous commits to: + + * Add support for two-byte device IDs + * Define macros for page-read ops with three-byte addresses + +http://www.gigadevice.com/datasheet/gd5f1gq4xfxxg/ + +Signed-off-by: Jeff Kletsky +Reviewed-by: Frieder Schrempf +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/spi/gigadevice.c | 79 +++++++++++++++++++++++++------ + 1 file changed, 64 insertions(+), 15 deletions(-) + +--- a/drivers/mtd/nand/spi/gigadevice.c ++++ b/drivers/mtd/nand/spi/gigadevice.c +@@ -9,11 +9,17 @@ + #include + + #define SPINAND_MFR_GIGADEVICE 0xC8 ++ + #define GD5FXGQ4XA_STATUS_ECC_1_7_BITFLIPS (1 << 4) + #define GD5FXGQ4XA_STATUS_ECC_8_BITFLIPS (3 << 4) + + #define GD5FXGQ4UEXXG_REG_STATUS2 0xf0 + ++#define GD5FXGQ4UXFXXG_STATUS_ECC_MASK (7 << 4) ++#define GD5FXGQ4UXFXXG_STATUS_ECC_NO_BITFLIPS (0 << 4) ++#define GD5FXGQ4UXFXXG_STATUS_ECC_1_3_BITFLIPS (1 << 4) ++#define GD5FXGQ4UXFXXG_STATUS_ECC_UNCOR_ERROR (7 << 4) ++ + static SPINAND_OP_VARIANTS(read_cache_variants, + SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0), + SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0), +@@ -22,6 +28,14 @@ static SPINAND_OP_VARIANTS(read_cache_va + SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0), + SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0)); + ++static SPINAND_OP_VARIANTS(read_cache_variants_f, ++ SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_X4_OP_3A(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_X2_OP_3A(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_OP_3A(true, 0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_OP_3A(false, 0, 0, NULL, 0)); ++ + static SPINAND_OP_VARIANTS(write_cache_variants, + SPINAND_PROG_LOAD_X4(true, 0, NULL, 0), + SPINAND_PROG_LOAD(true, 0, NULL, 0)); +@@ -59,6 +73,11 @@ static int gd5fxgq4xa_ooblayout_free(str + return 0; + } + ++static const struct mtd_ooblayout_ops gd5fxgq4xa_ooblayout = { ++ .ecc = gd5fxgq4xa_ooblayout_ecc, ++ .free = gd5fxgq4xa_ooblayout_free, ++}; ++ + static int gd5fxgq4xa_ecc_get_status(struct spinand_device *spinand, + u8 status) + { +@@ -83,7 +102,7 @@ static int gd5fxgq4xa_ecc_get_status(str + return -EINVAL; + } + +-static int gd5fxgq4uexxg_ooblayout_ecc(struct mtd_info *mtd, int section, ++static int gd5fxgq4_variant2_ooblayout_ecc(struct mtd_info *mtd, int section, + struct mtd_oob_region *region) + { + if (section) +@@ -95,7 +114,7 @@ static int gd5fxgq4uexxg_ooblayout_ecc(s + return 0; + } + +-static int gd5fxgq4uexxg_ooblayout_free(struct mtd_info *mtd, int section, ++static int gd5fxgq4_variant2_ooblayout_free(struct mtd_info *mtd, int section, + struct mtd_oob_region *region) + { + if (section) +@@ -108,6 +127,11 @@ static int gd5fxgq4uexxg_ooblayout_free( + return 0; + } + ++static const struct mtd_ooblayout_ops gd5fxgq4_variant2_ooblayout = { ++ .ecc = gd5fxgq4_variant2_ooblayout_ecc, ++ .free = gd5fxgq4_variant2_ooblayout_free, ++}; ++ + static int gd5fxgq4uexxg_ecc_get_status(struct spinand_device *spinand, + u8 status) + { +@@ -150,15 +174,25 @@ static int gd5fxgq4uexxg_ecc_get_status( + return -EINVAL; + } + +-static const struct mtd_ooblayout_ops gd5fxgq4xa_ooblayout = { +- .ecc = gd5fxgq4xa_ooblayout_ecc, +- .free = gd5fxgq4xa_ooblayout_free, +-}; ++static int gd5fxgq4ufxxg_ecc_get_status(struct spinand_device *spinand, ++ u8 status) ++{ ++ switch (status & GD5FXGQ4UXFXXG_STATUS_ECC_MASK) { ++ case GD5FXGQ4UXFXXG_STATUS_ECC_NO_BITFLIPS: ++ return 0; + +-static const struct mtd_ooblayout_ops gd5fxgq4uexxg_ooblayout = { +- .ecc = gd5fxgq4uexxg_ooblayout_ecc, +- .free = gd5fxgq4uexxg_ooblayout_free, +-}; ++ case GD5FXGQ4UXFXXG_STATUS_ECC_1_3_BITFLIPS: ++ return 3; ++ ++ case GD5FXGQ4UXFXXG_STATUS_ECC_UNCOR_ERROR: ++ return -EBADMSG; ++ ++ default: /* (2 << 4) through (6 << 4) are 4-8 corrected errors */ ++ return ((status & GD5FXGQ4UXFXXG_STATUS_ECC_MASK) >> 4) + 2; ++ } ++ ++ return -EINVAL; ++} + + static const struct spinand_info gigadevice_spinand_table[] = { + SPINAND_INFO("GD5F1GQ4xA", 0xF1, +@@ -195,25 +229,40 @@ static const struct spinand_info gigadev + &write_cache_variants, + &update_cache_variants), + 0, +- SPINAND_ECCINFO(&gd5fxgq4uexxg_ooblayout, ++ SPINAND_ECCINFO(&gd5fxgq4_variant2_ooblayout, + gd5fxgq4uexxg_ecc_get_status)), ++ SPINAND_INFO("GD5F1GQ4UFxxG", 0xb148, ++ NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), ++ NAND_ECCREQ(8, 512), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants_f, ++ &write_cache_variants, ++ &update_cache_variants), ++ 0, ++ SPINAND_ECCINFO(&gd5fxgq4_variant2_ooblayout, ++ gd5fxgq4ufxxg_ecc_get_status)), + }; + + static int gigadevice_spinand_detect(struct spinand_device *spinand) + { + u8 *id = spinand->id.data; ++ u16 did; + int ret; + + /* +- * For GD NANDs, There is an address byte needed to shift in before IDs +- * are read out, so the first byte in raw_id is dummy. ++ * Earlier GDF5-series devices (A,E) return [0][MID][DID] ++ * Later (F) devices return [MID][DID1][DID2] + */ +- if (id[1] != SPINAND_MFR_GIGADEVICE) ++ ++ if (id[0] == SPINAND_MFR_GIGADEVICE) ++ did = (id[1] << 8) + id[2]; ++ else if (id[0] == 0 && id[1] == SPINAND_MFR_GIGADEVICE) ++ did = id[2]; ++ else + return 0; + + ret = spinand_match_and_init(spinand, gigadevice_spinand_table, + ARRAY_SIZE(gigadevice_spinand_table), +- id[2]); ++ did); + if (ret) + return ret; + diff --git a/target/linux/generic/backport-4.19/463-v5.3-mtd-spinand-Add-initial-support-for-Paragon-PN26G0xA.patch b/target/linux/generic/backport-4.19/463-v5.3-mtd-spinand-Add-initial-support-for-Paragon-PN26G0xA.patch new file mode 100644 index 000000000..17b8e779b --- /dev/null +++ b/target/linux/generic/backport-4.19/463-v5.3-mtd-spinand-Add-initial-support-for-Paragon-PN26G0xA.patch @@ -0,0 +1,203 @@ +From 3552691616c940a7c4125c2678ba816653cd725e Mon Sep 17 00:00:00 2001 +From: Jeff Kletsky +Date: Tue, 18 Jun 2019 10:08:05 -0700 +Subject: [PATCH] mtd: spinand: Add initial support for Paragon PN26G0xA + +Add initial support for Paragon Technology +PN26G01Axxxxx and PN26G02Axxxxx SPI NAND + +Datasheets available at +http://www.xtxtech.com/upfile/2016082517274590.pdf +http://www.xtxtech.com/upfile/2016082517282329.pdf + +Signed-off-by: Jeff Kletsky +Reviewed-by: Frieder Schrempf +Signed-off-by: Miquel Raynal + +ADOPTED FROM UPSTREAM due to upstream commit 377e517b5fa5 in Linux 5.2 + which added another parameter to NAND_MEMORG +--- + drivers/mtd/nand/spi/Makefile | 2 +- + drivers/mtd/nand/spi/core.c | 1 + + drivers/mtd/nand/spi/paragon.c | 147 +++++++++++++++++++++++++++++++++ + include/linux/mtd/spinand.h | 1 + + 4 files changed, 150 insertions(+), 1 deletion(-) + create mode 100644 drivers/mtd/nand/spi/paragon.c + +--- a/drivers/mtd/nand/spi/Makefile ++++ b/drivers/mtd/nand/spi/Makefile +@@ -1,3 +1,3 @@ + # SPDX-License-Identifier: GPL-2.0 +-spinand-objs := core.o gigadevice.o macronix.o micron.o toshiba.o winbond.o ++spinand-objs := core.o gigadevice.o macronix.o micron.o paragon.o toshiba.o winbond.o + obj-$(CONFIG_MTD_SPI_NAND) += spinand.o +--- a/drivers/mtd/nand/spi/core.c ++++ b/drivers/mtd/nand/spi/core.c +@@ -765,6 +765,7 @@ static const struct spinand_manufacturer + &gigadevice_spinand_manufacturer, + ¯onix_spinand_manufacturer, + µn_spinand_manufacturer, ++ ¶gon_spinand_manufacturer, + &toshiba_spinand_manufacturer, + &winbond_spinand_manufacturer, + }; +--- /dev/null ++++ b/drivers/mtd/nand/spi/paragon.c +@@ -0,0 +1,147 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Copyright (C) 2019 Jeff Kletsky ++ * ++ * Author: Jeff Kletsky ++ */ ++ ++#include ++#include ++#include ++ ++ ++#define SPINAND_MFR_PARAGON 0xa1 ++ ++ ++#define PN26G0XA_STATUS_ECC_BITMASK (3 << 4) ++ ++#define PN26G0XA_STATUS_ECC_NONE_DETECTED (0 << 4) ++#define PN26G0XA_STATUS_ECC_1_7_CORRECTED (1 << 4) ++#define PN26G0XA_STATUS_ECC_ERRORED (2 << 4) ++#define PN26G0XA_STATUS_ECC_8_CORRECTED (3 << 4) ++ ++ ++static SPINAND_OP_VARIANTS(read_cache_variants, ++ SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0)); ++ ++static SPINAND_OP_VARIANTS(write_cache_variants, ++ SPINAND_PROG_LOAD_X4(true, 0, NULL, 0), ++ SPINAND_PROG_LOAD(true, 0, NULL, 0)); ++ ++static SPINAND_OP_VARIANTS(update_cache_variants, ++ SPINAND_PROG_LOAD_X4(false, 0, NULL, 0), ++ SPINAND_PROG_LOAD(false, 0, NULL, 0)); ++ ++ ++static int pn26g0xa_ooblayout_ecc(struct mtd_info *mtd, int section, ++ struct mtd_oob_region *region) ++{ ++ if (section > 3) ++ return -ERANGE; ++ ++ region->offset = 6 + (15 * section); /* 4 BBM + 2 user bytes */ ++ region->length = 13; ++ ++ return 0; ++} ++ ++static int pn26g0xa_ooblayout_free(struct mtd_info *mtd, int section, ++ struct mtd_oob_region *region) ++{ ++ if (section > 4) ++ return -ERANGE; ++ ++ if (section == 4) { ++ region->offset = 64; ++ region->length = 64; ++ } else { ++ region->offset = 4 + (15 * section); ++ region->length = 2; ++ } ++ ++ return 0; ++} ++ ++static int pn26g0xa_ecc_get_status(struct spinand_device *spinand, ++ u8 status) ++{ ++ switch (status & PN26G0XA_STATUS_ECC_BITMASK) { ++ case PN26G0XA_STATUS_ECC_NONE_DETECTED: ++ return 0; ++ ++ case PN26G0XA_STATUS_ECC_1_7_CORRECTED: ++ return 7; /* Return upper limit by convention */ ++ ++ case PN26G0XA_STATUS_ECC_8_CORRECTED: ++ return 8; ++ ++ case PN26G0XA_STATUS_ECC_ERRORED: ++ return -EBADMSG; ++ ++ default: ++ break; ++ } ++ ++ return -EINVAL; ++} ++ ++static const struct mtd_ooblayout_ops pn26g0xa_ooblayout = { ++ .ecc = pn26g0xa_ooblayout_ecc, ++ .free = pn26g0xa_ooblayout_free, ++}; ++ ++ ++static const struct spinand_info paragon_spinand_table[] = { ++ SPINAND_INFO("PN26G01A", 0xe1, ++ NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), ++ NAND_ECCREQ(8, 512), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, ++ &write_cache_variants, ++ &update_cache_variants), ++ 0, ++ SPINAND_ECCINFO(&pn26g0xa_ooblayout, ++ pn26g0xa_ecc_get_status)), ++ SPINAND_INFO("PN26G02A", 0xe2, ++ NAND_MEMORG(1, 2048, 128, 64, 2048, 1, 1, 1), ++ NAND_ECCREQ(8, 512), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, ++ &write_cache_variants, ++ &update_cache_variants), ++ 0, ++ SPINAND_ECCINFO(&pn26g0xa_ooblayout, ++ pn26g0xa_ecc_get_status)), ++}; ++ ++static int paragon_spinand_detect(struct spinand_device *spinand) ++{ ++ u8 *id = spinand->id.data; ++ int ret; ++ ++ /* Read ID returns [0][MID][DID] */ ++ ++ if (id[1] != SPINAND_MFR_PARAGON) ++ return 0; ++ ++ ret = spinand_match_and_init(spinand, paragon_spinand_table, ++ ARRAY_SIZE(paragon_spinand_table), ++ id[2]); ++ if (ret) ++ return ret; ++ ++ return 1; ++} ++ ++static const struct spinand_manufacturer_ops paragon_spinand_manuf_ops = { ++ .detect = paragon_spinand_detect, ++}; ++ ++const struct spinand_manufacturer paragon_spinand_manufacturer = { ++ .id = SPINAND_MFR_PARAGON, ++ .name = "Paragon", ++ .ops = ¶gon_spinand_manuf_ops, ++}; +--- a/include/linux/mtd/spinand.h ++++ b/include/linux/mtd/spinand.h +@@ -227,6 +227,7 @@ struct spinand_manufacturer { + extern const struct spinand_manufacturer gigadevice_spinand_manufacturer; + extern const struct spinand_manufacturer macronix_spinand_manufacturer; + extern const struct spinand_manufacturer micron_spinand_manufacturer; ++extern const struct spinand_manufacturer paragon_spinand_manufacturer; + extern const struct spinand_manufacturer toshiba_spinand_manufacturer; + extern const struct spinand_manufacturer winbond_spinand_manufacturer; + diff --git a/target/linux/mvebu/patches-4.19/402-net-phylink-only-call-mac_config-during-resolve-when.patch b/target/linux/generic/backport-4.19/700-v5.1-net-phylink-only-call-mac_config-during-resolve-when.patch similarity index 100% rename from target/linux/mvebu/patches-4.19/402-net-phylink-only-call-mac_config-during-resolve-when.patch rename to target/linux/generic/backport-4.19/700-v5.1-net-phylink-only-call-mac_config-during-resolve-when.patch diff --git a/target/linux/mvebu/patches-4.19/403-net-phylink-ensure-inband-AN-works-correctly.patch b/target/linux/generic/backport-4.19/701-v5.2-net-phylink-ensure-inband-AN-works-correctly.patch similarity index 100% rename from target/linux/mvebu/patches-4.19/403-net-phylink-ensure-inband-AN-works-correctly.patch rename to target/linux/generic/backport-4.19/701-v5.2-net-phylink-ensure-inband-AN-works-correctly.patch diff --git a/target/linux/generic/backport-4.19/702-v4.20-net-ethernet-Add-helper-for-MACs-which-support-asym-.patch b/target/linux/generic/backport-4.19/702-v4.20-net-ethernet-Add-helper-for-MACs-which-support-asym-.patch new file mode 100644 index 000000000..ee6e6a6da --- /dev/null +++ b/target/linux/generic/backport-4.19/702-v4.20-net-ethernet-Add-helper-for-MACs-which-support-asym-.patch @@ -0,0 +1,49 @@ +From 1da223db3a0c522300b519ecbe1dc45927e28088 Mon Sep 17 00:00:00 2001 +From: Andrew Lunn +Date: Wed, 12 Sep 2018 01:53:15 +0200 +Subject: [PATCH 600/660] net: ethernet: Add helper for MACs which support asym + pause + +Rather than have the MAC drivers manipulate phydev members to indicate +they support Asym Pause, add a helper function. + +Signed-off-by: Andrew Lunn +Reviewed-by: Florian Fainelli +Signed-off-by: David S. Miller +--- + drivers/net/phy/phy_device.c | 13 +++++++++++++ + include/linux/phy.h | 1 + + 2 files changed, 14 insertions(+) + +--- a/drivers/net/phy/phy_device.c ++++ b/drivers/net/phy/phy_device.c +@@ -1776,6 +1776,19 @@ int phy_set_max_speed(struct phy_device + } + EXPORT_SYMBOL(phy_set_max_speed); + ++/** ++ * phy_support_asym_pause - Enable support of asym pause ++ * @phydev: target phy_device struct ++ * ++ * Description: Called by the MAC to indicate is supports Asym Pause. ++ */ ++void phy_support_asym_pause(struct phy_device *phydev) ++{ ++ phydev->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; ++ phydev->advertising = phydev->supported; ++} ++EXPORT_SYMBOL(phy_support_asym_pause); ++ + static void of_set_phy_supported(struct phy_device *phydev) + { + struct device_node *node = phydev->mdio.dev.of_node; +--- a/include/linux/phy.h ++++ b/include/linux/phy.h +@@ -1049,6 +1049,7 @@ int phy_mii_ioctl(struct phy_device *phy + int phy_start_interrupts(struct phy_device *phydev); + void phy_print_status(struct phy_device *phydev); + int phy_set_max_speed(struct phy_device *phydev, u32 max_speed); ++void phy_support_asym_pause(struct phy_device *phydev); + + int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask, + int (*run)(struct phy_device *)); diff --git a/target/linux/generic/backport-4.19/703-v4.20-net-ethernet-Add-helper-for-set_pauseparam-for-Asym-.patch b/target/linux/generic/backport-4.19/703-v4.20-net-ethernet-Add-helper-for-set_pauseparam-for-Asym-.patch new file mode 100644 index 000000000..8d68fbfe0 --- /dev/null +++ b/target/linux/generic/backport-4.19/703-v4.20-net-ethernet-Add-helper-for-set_pauseparam-for-Asym-.patch @@ -0,0 +1,66 @@ +From ce825df56e0480a2cbb296e38976babafb57e503 Mon Sep 17 00:00:00 2001 +From: Andrew Lunn +Date: Wed, 12 Sep 2018 01:53:17 +0200 +Subject: [PATCH 601/660] net: ethernet: Add helper for set_pauseparam for Asym + Pause + +ethtool can be used to enable/disable pause. Add a helper to configure +the PHY when asym pause is supported. + +Signed-off-by: Andrew Lunn +Reviewed-by: Florian Fainelli +Signed-off-by: David S. Miller +--- + drivers/net/phy/phy_device.c | 30 ++++++++++++++++++++++++++++++ + include/linux/phy.h | 1 + + 2 files changed, 31 insertions(+) + +--- a/drivers/net/phy/phy_device.c ++++ b/drivers/net/phy/phy_device.c +@@ -1789,6 +1789,36 @@ void phy_support_asym_pause(struct phy_d + } + EXPORT_SYMBOL(phy_support_asym_pause); + ++/** ++ * phy_set_asym_pause - Configure Pause and Asym Pause ++ * @phydev: target phy_device struct ++ * @rx: Receiver Pause is supported ++ * @tx: Transmit Pause is supported ++ * ++ * Description: Configure advertised Pause support depending on if ++ * transmit and receiver pause is supported. If there has been a ++ * change in adverting, trigger a new autoneg. Generally called from ++ * the set_pauseparam .ndo. ++ */ ++void phy_set_asym_pause(struct phy_device *phydev, bool rx, bool tx) ++{ ++ u16 oldadv = phydev->advertising; ++ u16 newadv = oldadv &= ~(SUPPORTED_Pause | SUPPORTED_Asym_Pause); ++ ++ if (rx) ++ newadv |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; ++ if (tx) ++ newadv ^= SUPPORTED_Asym_Pause; ++ ++ if (oldadv != newadv) { ++ phydev->advertising = newadv; ++ ++ if (phydev->autoneg) ++ phy_start_aneg(phydev); ++ } ++} ++EXPORT_SYMBOL(phy_set_asym_pause); ++ + static void of_set_phy_supported(struct phy_device *phydev) + { + struct device_node *node = phydev->mdio.dev.of_node; +--- a/include/linux/phy.h ++++ b/include/linux/phy.h +@@ -1050,6 +1050,7 @@ int phy_start_interrupts(struct phy_devi + void phy_print_status(struct phy_device *phydev); + int phy_set_max_speed(struct phy_device *phydev, u32 max_speed); + void phy_support_asym_pause(struct phy_device *phydev); ++void phy_set_asym_pause(struct phy_device *phydev, bool rx, bool tx); + + int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask, + int (*run)(struct phy_device *)); diff --git a/target/linux/generic/backport-4.19/704-v4.20-net-phy-Stop-with-excessive-soft-reset.patch b/target/linux/generic/backport-4.19/704-v4.20-net-phy-Stop-with-excessive-soft-reset.patch new file mode 100644 index 000000000..77ad5b96d --- /dev/null +++ b/target/linux/generic/backport-4.19/704-v4.20-net-phy-Stop-with-excessive-soft-reset.patch @@ -0,0 +1,40 @@ +From 1541649a9dd79e9b941d399de564475e426a2d0b Mon Sep 17 00:00:00 2001 +From: Florian Fainelli +Date: Tue, 25 Sep 2018 11:28:45 -0700 +Subject: [PATCH 602/660] net: phy: Stop with excessive soft reset + +While consolidating the PHY reset in phy_init_hw() an unconditionaly +BMCR soft-reset I became quite trigger happy with those. This was later +on deactivated for the Generic PHY driver on the premise that a prior +software entity (e.g: bootloader) might have applied workarounds in +commit 0878fff1f42c ("net: phy: Do not perform software reset for +Generic PHY"). + +Since we have a hook to wire-up a soft_reset callback, just use that and +get rid of the call to genphy_soft_reset() entirely. This speeds up +initialization and link establishment for most PHYs out there that do +not require a reset. + +Fixes: 87aa9f9c61ad ("net: phy: consolidate PHY reset in phy_init_hw()") +Tested-by: Wang, Dongsheng +Tested-by: Chris Healy +Tested-by: Andrew Lunn +Tested-by: Clemens Gruber +Signed-off-by: Florian Fainelli +Signed-off-by: David S. Miller +Signed-off-by: Russell King +--- + drivers/net/phy/phy_device.c | 2 -- + 1 file changed, 2 deletions(-) + +--- a/drivers/net/phy/phy_device.c ++++ b/drivers/net/phy/phy_device.c +@@ -885,8 +885,6 @@ int phy_init_hw(struct phy_device *phyde + + if (phydev->drv->soft_reset) + ret = phydev->drv->soft_reset(phydev); +- else +- ret = genphy_soft_reset(phydev); + + if (ret < 0) + return ret; diff --git a/target/linux/generic/backport-4.19/705-v5.1-net-phy-provide-full-set-of-accessor-functions-to-MM.patch b/target/linux/generic/backport-4.19/705-v5.1-net-phy-provide-full-set-of-accessor-functions-to-MM.patch new file mode 100644 index 000000000..9a587ad3a --- /dev/null +++ b/target/linux/generic/backport-4.19/705-v5.1-net-phy-provide-full-set-of-accessor-functions-to-MM.patch @@ -0,0 +1,375 @@ +From 80758d9542205cd2e9fa730067bc3888d4f5a096 Mon Sep 17 00:00:00 2001 +From: Nikita Yushchenko +Date: Wed, 6 Feb 2019 07:36:40 +0100 +Subject: [PATCH 603/660] net: phy: provide full set of accessor functions to + MMD registers + +This adds full set of locked and unlocked accessor functions to read and +write PHY MMD registers and/or bitfields. + +Set of functions exactly matches what is already available for PHY +legacy registers. + +Signed-off-by: Nikita Yushchenko +Signed-off-by: Andrew Lunn +Signed-off-by: Heiner Kallweit +Signed-off-by: David S. Miller +Signed-off-by: Russell King +--- + drivers/net/phy/phy-core.c | 116 ++++++++++++++++++++++++++++---- + include/linux/phy.h | 134 ++++++++++++++++++++++++++++++------- + 2 files changed, 214 insertions(+), 36 deletions(-) + +--- a/drivers/net/phy/phy-core.c ++++ b/drivers/net/phy/phy-core.c +@@ -247,15 +247,15 @@ static void mmd_phy_indirect(struct mii_ + } + + /** +- * phy_read_mmd - Convenience function for reading a register ++ * __phy_read_mmd - Convenience function for reading a register + * from an MMD on a given PHY. + * @phydev: The phy_device struct + * @devad: The MMD to read from (0..31) + * @regnum: The register on the MMD to read (0..65535) + * +- * Same rules as for phy_read(); ++ * Same rules as for __phy_read(); + */ +-int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum) ++int __phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum) + { + int val; + +@@ -267,33 +267,52 @@ int phy_read_mmd(struct phy_device *phyd + } else if (phydev->is_c45) { + u32 addr = MII_ADDR_C45 | (devad << 16) | (regnum & 0xffff); + +- val = mdiobus_read(phydev->mdio.bus, phydev->mdio.addr, addr); ++ val = __mdiobus_read(phydev->mdio.bus, phydev->mdio.addr, addr); + } else { + struct mii_bus *bus = phydev->mdio.bus; + int phy_addr = phydev->mdio.addr; + +- mutex_lock(&bus->mdio_lock); + mmd_phy_indirect(bus, phy_addr, devad, regnum); + + /* Read the content of the MMD's selected register */ + val = __mdiobus_read(bus, phy_addr, MII_MMD_DATA); +- mutex_unlock(&bus->mdio_lock); + } + return val; + } ++EXPORT_SYMBOL(__phy_read_mmd); ++ ++/** ++ * phy_read_mmd - Convenience function for reading a register ++ * from an MMD on a given PHY. ++ * @phydev: The phy_device struct ++ * @devad: The MMD to read from ++ * @regnum: The register on the MMD to read ++ * ++ * Same rules as for phy_read(); ++ */ ++int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum) ++{ ++ int ret; ++ ++ mutex_lock(&phydev->mdio.bus->mdio_lock); ++ ret = __phy_read_mmd(phydev, devad, regnum); ++ mutex_unlock(&phydev->mdio.bus->mdio_lock); ++ ++ return ret; ++} + EXPORT_SYMBOL(phy_read_mmd); + + /** +- * phy_write_mmd - Convenience function for writing a register ++ * __phy_write_mmd - Convenience function for writing a register + * on an MMD on a given PHY. + * @phydev: The phy_device struct + * @devad: The MMD to read from + * @regnum: The register on the MMD to read + * @val: value to write to @regnum + * +- * Same rules as for phy_write(); ++ * Same rules as for __phy_write(); + */ +-int phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val) ++int __phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val) + { + int ret; + +@@ -305,23 +324,43 @@ int phy_write_mmd(struct phy_device *phy + } else if (phydev->is_c45) { + u32 addr = MII_ADDR_C45 | (devad << 16) | (regnum & 0xffff); + +- ret = mdiobus_write(phydev->mdio.bus, phydev->mdio.addr, +- addr, val); ++ ret = __mdiobus_write(phydev->mdio.bus, phydev->mdio.addr, ++ addr, val); + } else { + struct mii_bus *bus = phydev->mdio.bus; + int phy_addr = phydev->mdio.addr; + +- mutex_lock(&bus->mdio_lock); + mmd_phy_indirect(bus, phy_addr, devad, regnum); + + /* Write the data into MMD's selected register */ + __mdiobus_write(bus, phy_addr, MII_MMD_DATA, val); +- mutex_unlock(&bus->mdio_lock); + + ret = 0; + } + return ret; + } ++EXPORT_SYMBOL(__phy_write_mmd); ++ ++/** ++ * phy_write_mmd - Convenience function for writing a register ++ * on an MMD on a given PHY. ++ * @phydev: The phy_device struct ++ * @devad: The MMD to read from ++ * @regnum: The register on the MMD to read ++ * @val: value to write to @regnum ++ * ++ * Same rules as for phy_write(); ++ */ ++int phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val) ++{ ++ int ret; ++ ++ mutex_lock(&phydev->mdio.bus->mdio_lock); ++ ret = __phy_write_mmd(phydev, devad, regnum, val); ++ mutex_unlock(&phydev->mdio.bus->mdio_lock); ++ ++ return ret; ++} + EXPORT_SYMBOL(phy_write_mmd); + + /** +@@ -371,6 +410,57 @@ int phy_modify(struct phy_device *phydev + } + EXPORT_SYMBOL_GPL(phy_modify); + ++/** ++ * __phy_modify_mmd - Convenience function for modifying a register on MMD ++ * @phydev: the phy_device struct ++ * @devad: the MMD containing register to modify ++ * @regnum: register number to modify ++ * @mask: bit mask of bits to clear ++ * @set: new value of bits set in mask to write to @regnum ++ * ++ * Unlocked helper function which allows a MMD register to be modified as ++ * new register value = (old register value & ~mask) | set ++ */ ++int __phy_modify_mmd(struct phy_device *phydev, int devad, u32 regnum, ++ u16 mask, u16 set) ++{ ++ int ret; ++ ++ ret = __phy_read_mmd(phydev, devad, regnum); ++ if (ret < 0) ++ return ret; ++ ++ ret = __phy_write_mmd(phydev, devad, regnum, (ret & ~mask) | set); ++ ++ return ret < 0 ? ret : 0; ++} ++EXPORT_SYMBOL_GPL(__phy_modify_mmd); ++ ++/** ++ * phy_modify_mmd - Convenience function for modifying a register on MMD ++ * @phydev: the phy_device struct ++ * @devad: the MMD containing register to modify ++ * @regnum: register number to modify ++ * @mask: bit mask of bits to clear ++ * @set: new value of bits set in mask to write to @regnum ++ * ++ * NOTE: MUST NOT be called from interrupt context, ++ * because the bus read/write functions may wait for an interrupt ++ * to conclude the operation. ++ */ ++int phy_modify_mmd(struct phy_device *phydev, int devad, u32 regnum, ++ u16 mask, u16 set) ++{ ++ int ret; ++ ++ mutex_lock(&phydev->mdio.bus->mdio_lock); ++ ret = __phy_modify_mmd(phydev, devad, regnum, mask, set); ++ mutex_unlock(&phydev->mdio.bus->mdio_lock); ++ ++ return ret; ++} ++EXPORT_SYMBOL_GPL(phy_modify_mmd); ++ + static int __phy_read_page(struct phy_device *phydev) + { + return phydev->drv->read_page(phydev); +--- a/include/linux/phy.h ++++ b/include/linux/phy.h +@@ -695,17 +695,6 @@ size_t phy_speeds(unsigned int *speeds, + void phy_resolve_aneg_linkmode(struct phy_device *phydev); + + /** +- * phy_read_mmd - Convenience function for reading a register +- * from an MMD on a given PHY. +- * @phydev: The phy_device struct +- * @devad: The MMD to read from +- * @regnum: The register on the MMD to read +- * +- * Same rules as for phy_read(); +- */ +-int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum); +- +-/** + * phy_read - Convenience function for reading a given PHY register + * @phydev: the phy_device struct + * @regnum: register number to read +@@ -760,9 +749,60 @@ static inline int __phy_write(struct phy + val); + } + ++/** ++ * phy_read_mmd - Convenience function for reading a register ++ * from an MMD on a given PHY. ++ * @phydev: The phy_device struct ++ * @devad: The MMD to read from ++ * @regnum: The register on the MMD to read ++ * ++ * Same rules as for phy_read(); ++ */ ++int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum); ++ ++/** ++ * __phy_read_mmd - Convenience function for reading a register ++ * from an MMD on a given PHY. ++ * @phydev: The phy_device struct ++ * @devad: The MMD to read from ++ * @regnum: The register on the MMD to read ++ * ++ * Same rules as for __phy_read(); ++ */ ++int __phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum); ++ ++/** ++ * phy_write_mmd - Convenience function for writing a register ++ * on an MMD on a given PHY. ++ * @phydev: The phy_device struct ++ * @devad: The MMD to write to ++ * @regnum: The register on the MMD to read ++ * @val: value to write to @regnum ++ * ++ * Same rules as for phy_write(); ++ */ ++int phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val); ++ ++/** ++ * __phy_write_mmd - Convenience function for writing a register ++ * on an MMD on a given PHY. ++ * @phydev: The phy_device struct ++ * @devad: The MMD to write to ++ * @regnum: The register on the MMD to read ++ * @val: value to write to @regnum ++ * ++ * Same rules as for __phy_write(); ++ */ ++int __phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val); ++ + int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set); + int phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set); + ++int __phy_modify_mmd(struct phy_device *phydev, int devad, u32 regnum, ++ u16 mask, u16 set); ++int phy_modify_mmd(struct phy_device *phydev, int devad, u32 regnum, ++ u16 mask, u16 set); ++ + /** + * __phy_set_bits - Convenience function for setting bits in a PHY register + * @phydev: the phy_device struct +@@ -813,6 +853,66 @@ static inline int phy_clear_bits(struct + } + + /** ++ * __phy_set_bits_mmd - Convenience function for setting bits in a register ++ * on MMD ++ * @phydev: the phy_device struct ++ * @devad: the MMD containing register to modify ++ * @regnum: register number to modify ++ * @val: bits to set ++ * ++ * The caller must have taken the MDIO bus lock. ++ */ ++static inline int __phy_set_bits_mmd(struct phy_device *phydev, int devad, ++ u32 regnum, u16 val) ++{ ++ return __phy_modify_mmd(phydev, devad, regnum, 0, val); ++} ++ ++/** ++ * __phy_clear_bits_mmd - Convenience function for clearing bits in a register ++ * on MMD ++ * @phydev: the phy_device struct ++ * @devad: the MMD containing register to modify ++ * @regnum: register number to modify ++ * @val: bits to clear ++ * ++ * The caller must have taken the MDIO bus lock. ++ */ ++static inline int __phy_clear_bits_mmd(struct phy_device *phydev, int devad, ++ u32 regnum, u16 val) ++{ ++ return __phy_modify_mmd(phydev, devad, regnum, val, 0); ++} ++ ++/** ++ * phy_set_bits_mmd - Convenience function for setting bits in a register ++ * on MMD ++ * @phydev: the phy_device struct ++ * @devad: the MMD containing register to modify ++ * @regnum: register number to modify ++ * @val: bits to set ++ */ ++static inline int phy_set_bits_mmd(struct phy_device *phydev, int devad, ++ u32 regnum, u16 val) ++{ ++ return phy_modify_mmd(phydev, devad, regnum, 0, val); ++} ++ ++/** ++ * phy_clear_bits_mmd - Convenience function for clearing bits in a register ++ * on MMD ++ * @phydev: the phy_device struct ++ * @devad: the MMD containing register to modify ++ * @regnum: register number to modify ++ * @val: bits to clear ++ */ ++static inline int phy_clear_bits_mmd(struct phy_device *phydev, int devad, ++ u32 regnum, u16 val) ++{ ++ return phy_modify_mmd(phydev, devad, regnum, val, 0); ++} ++ ++/** + * phy_interrupt_is_valid - Convenience function for testing a given PHY irq + * @phydev: the phy_device struct + * +@@ -888,18 +988,6 @@ static inline bool phy_is_pseudo_fixed_l + return phydev->is_pseudo_fixed_link; + } + +-/** +- * phy_write_mmd - Convenience function for writing a register +- * on an MMD on a given PHY. +- * @phydev: The phy_device struct +- * @devad: The MMD to read from +- * @regnum: The register on the MMD to read +- * @val: value to write to @regnum +- * +- * Same rules as for phy_write(); +- */ +-int phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val); +- + int phy_save_page(struct phy_device *phydev); + int phy_select_page(struct phy_device *phydev, int page); + int phy_restore_page(struct phy_device *phydev, int oldpage, int ret); diff --git a/target/linux/generic/backport-4.19/706-v5.1-net-phy-add-register-modifying-helpers-returning-1-o.patch b/target/linux/generic/backport-4.19/706-v5.1-net-phy-add-register-modifying-helpers-returning-1-o.patch new file mode 100644 index 000000000..dddfcc201 --- /dev/null +++ b/target/linux/generic/backport-4.19/706-v5.1-net-phy-add-register-modifying-helpers-returning-1-o.patch @@ -0,0 +1,217 @@ +From c1e3f753f6b85d7636024159bb78f764e09492f1 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Sun, 10 Feb 2019 19:57:56 +0100 +Subject: [PATCH 604/660] net: phy: add register modifying helpers returning 1 + on change + +When modifying registers there are scenarios where we need to know +whether the register content actually changed. This patch adds +new helpers to not break users of the current ones, phy_modify() etc. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Andrew Lunn +Reviewed-by: Florian Fainelli +Signed-off-by: David S. Miller +Signed-off-by: Russell King +--- + drivers/net/phy/phy-core.c | 127 ++++++++++++++++++++++++++++++++++--- + include/linux/phy.h | 12 +++- + 2 files changed, 128 insertions(+), 11 deletions(-) + +--- a/drivers/net/phy/phy-core.c ++++ b/drivers/net/phy/phy-core.c +@@ -364,7 +364,7 @@ int phy_write_mmd(struct phy_device *phy + EXPORT_SYMBOL(phy_write_mmd); + + /** +- * __phy_modify() - Convenience function for modifying a PHY register ++ * __phy_modify_changed() - Convenience function for modifying a PHY register + * @phydev: a pointer to a &struct phy_device + * @regnum: register number + * @mask: bit mask of bits to clear +@@ -372,16 +372,69 @@ EXPORT_SYMBOL(phy_write_mmd); + * + * Unlocked helper function which allows a PHY register to be modified as + * new register value = (old register value & ~mask) | set ++ * ++ * Returns negative errno, 0 if there was no change, and 1 in case of change + */ +-int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set) ++int __phy_modify_changed(struct phy_device *phydev, u32 regnum, u16 mask, ++ u16 set) + { +- int ret; ++ int new, ret; + + ret = __phy_read(phydev, regnum); + if (ret < 0) + return ret; + +- ret = __phy_write(phydev, regnum, (ret & ~mask) | set); ++ new = (ret & ~mask) | set; ++ if (new == ret) ++ return 0; ++ ++ ret = __phy_write(phydev, regnum, new); ++ ++ return ret < 0 ? ret : 1; ++} ++EXPORT_SYMBOL_GPL(__phy_modify_changed); ++ ++/** ++ * phy_modify_changed - Function for modifying a PHY register ++ * @phydev: the phy_device struct ++ * @regnum: register number to modify ++ * @mask: bit mask of bits to clear ++ * @set: new value of bits set in mask to write to @regnum ++ * ++ * NOTE: MUST NOT be called from interrupt context, ++ * because the bus read/write functions may wait for an interrupt ++ * to conclude the operation. ++ * ++ * Returns negative errno, 0 if there was no change, and 1 in case of change ++ */ ++int phy_modify_changed(struct phy_device *phydev, u32 regnum, u16 mask, u16 set) ++{ ++ int ret; ++ ++ mutex_lock(&phydev->mdio.bus->mdio_lock); ++ ret = __phy_modify_changed(phydev, regnum, mask, set); ++ mutex_unlock(&phydev->mdio.bus->mdio_lock); ++ ++ return ret; ++} ++EXPORT_SYMBOL_GPL(phy_modify_changed); ++ ++/** ++ * __phy_modify - Convenience function for modifying a PHY register ++ * @phydev: the phy_device struct ++ * @regnum: register number to modify ++ * @mask: bit mask of bits to clear ++ * @set: new value of bits set in mask to write to @regnum ++ * ++ * NOTE: MUST NOT be called from interrupt context, ++ * because the bus read/write functions may wait for an interrupt ++ * to conclude the operation. ++ */ ++int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set) ++{ ++ int ret; ++ ++ ret = __phy_modify_changed(phydev, regnum, mask, set); + + return ret < 0 ? ret : 0; + } +@@ -411,7 +464,7 @@ int phy_modify(struct phy_device *phydev + EXPORT_SYMBOL_GPL(phy_modify); + + /** +- * __phy_modify_mmd - Convenience function for modifying a register on MMD ++ * __phy_modify_mmd_changed - Function for modifying a register on MMD + * @phydev: the phy_device struct + * @devad: the MMD containing register to modify + * @regnum: register number to modify +@@ -420,17 +473,73 @@ EXPORT_SYMBOL_GPL(phy_modify); + * + * Unlocked helper function which allows a MMD register to be modified as + * new register value = (old register value & ~mask) | set ++ * ++ * Returns negative errno, 0 if there was no change, and 1 in case of change + */ +-int __phy_modify_mmd(struct phy_device *phydev, int devad, u32 regnum, +- u16 mask, u16 set) ++int __phy_modify_mmd_changed(struct phy_device *phydev, int devad, u32 regnum, ++ u16 mask, u16 set) + { +- int ret; ++ int new, ret; + + ret = __phy_read_mmd(phydev, devad, regnum); + if (ret < 0) + return ret; + +- ret = __phy_write_mmd(phydev, devad, regnum, (ret & ~mask) | set); ++ new = (ret & ~mask) | set; ++ if (new == ret) ++ return 0; ++ ++ ret = __phy_write_mmd(phydev, devad, regnum, new); ++ ++ return ret < 0 ? ret : 1; ++} ++EXPORT_SYMBOL_GPL(__phy_modify_mmd_changed); ++ ++/** ++ * phy_modify_mmd_changed - Function for modifying a register on MMD ++ * @phydev: the phy_device struct ++ * @devad: the MMD containing register to modify ++ * @regnum: register number to modify ++ * @mask: bit mask of bits to clear ++ * @set: new value of bits set in mask to write to @regnum ++ * ++ * NOTE: MUST NOT be called from interrupt context, ++ * because the bus read/write functions may wait for an interrupt ++ * to conclude the operation. ++ * ++ * Returns negative errno, 0 if there was no change, and 1 in case of change ++ */ ++int phy_modify_mmd_changed(struct phy_device *phydev, int devad, u32 regnum, ++ u16 mask, u16 set) ++{ ++ int ret; ++ ++ mutex_lock(&phydev->mdio.bus->mdio_lock); ++ ret = __phy_modify_mmd_changed(phydev, devad, regnum, mask, set); ++ mutex_unlock(&phydev->mdio.bus->mdio_lock); ++ ++ return ret; ++} ++EXPORT_SYMBOL_GPL(phy_modify_mmd_changed); ++ ++/** ++ * __phy_modify_mmd - Convenience function for modifying a register on MMD ++ * @phydev: the phy_device struct ++ * @devad: the MMD containing register to modify ++ * @regnum: register number to modify ++ * @mask: bit mask of bits to clear ++ * @set: new value of bits set in mask to write to @regnum ++ * ++ * NOTE: MUST NOT be called from interrupt context, ++ * because the bus read/write functions may wait for an interrupt ++ * to conclude the operation. ++ */ ++int __phy_modify_mmd(struct phy_device *phydev, int devad, u32 regnum, ++ u16 mask, u16 set) ++{ ++ int ret; ++ ++ ret = __phy_modify_mmd_changed(phydev, devad, regnum, mask, set); + + return ret < 0 ? ret : 0; + } +--- a/include/linux/phy.h ++++ b/include/linux/phy.h +@@ -795,13 +795,21 @@ int phy_write_mmd(struct phy_device *phy + */ + int __phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val); + ++int __phy_modify_changed(struct phy_device *phydev, u32 regnum, u16 mask, ++ u16 set); ++int phy_modify_changed(struct phy_device *phydev, u32 regnum, u16 mask, ++ u16 set); + int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set); + int phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set); + ++int __phy_modify_mmd_changed(struct phy_device *phydev, int devad, u32 regnum, ++ u16 mask, u16 set); ++int phy_modify_mmd_changed(struct phy_device *phydev, int devad, u32 regnum, ++ u16 mask, u16 set); + int __phy_modify_mmd(struct phy_device *phydev, int devad, u32 regnum, +- u16 mask, u16 set); ++ u16 mask, u16 set); + int phy_modify_mmd(struct phy_device *phydev, int devad, u32 regnum, +- u16 mask, u16 set); ++ u16 mask, u16 set); + + /** + * __phy_set_bits - Convenience function for setting bits in a PHY register diff --git a/target/linux/generic/backport-4.19/707-v5.1-net-phy-add-genphy_c45_check_and_restart_aneg.patch b/target/linux/generic/backport-4.19/707-v5.1-net-phy-add-genphy_c45_check_and_restart_aneg.patch new file mode 100644 index 000000000..6d47fa963 --- /dev/null +++ b/target/linux/generic/backport-4.19/707-v5.1-net-phy-add-genphy_c45_check_and_restart_aneg.patch @@ -0,0 +1,64 @@ +From 2c3db705737cf52d7d24c993f0889b25b956c718 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Mon, 18 Feb 2019 21:27:18 +0100 +Subject: [PATCH 605/660] net: phy: add genphy_c45_check_and_restart_aneg + +This function will be used by config_aneg callback implementations of +PHY drivers and allows to reduce boilerplate code. + +Signed-off-by: Heiner Kallweit +Signed-off-by: David S. Miller +--- + drivers/net/phy/phy-c45.c | 30 ++++++++++++++++++++++++++++++ + include/linux/phy.h | 1 + + 2 files changed, 31 insertions(+) + +--- a/drivers/net/phy/phy-c45.c ++++ b/drivers/net/phy/phy-c45.c +@@ -110,6 +110,36 @@ int genphy_c45_restart_aneg(struct phy_d + EXPORT_SYMBOL_GPL(genphy_c45_restart_aneg); + + /** ++ * genphy_c45_check_and_restart_aneg - Enable and restart auto-negotiation ++ * @phydev: target phy_device struct ++ * @restart: whether aneg restart is requested ++ * ++ * This assumes that the auto-negotiation MMD is present. ++ * ++ * Check, and restart auto-negotiation if needed. ++ */ ++int genphy_c45_check_and_restart_aneg(struct phy_device *phydev, bool restart) ++{ ++ int ret = 0; ++ ++ if (!restart) { ++ /* Configure and restart aneg if it wasn't set before */ ++ ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_CTRL1); ++ if (ret < 0) ++ return ret; ++ ++ if (!(ret & MDIO_AN_CTRL1_ENABLE)) ++ restart = true; ++ } ++ ++ if (restart) ++ ret = genphy_c45_restart_aneg(phydev); ++ ++ return ret; ++} ++EXPORT_SYMBOL_GPL(genphy_c45_check_and_restart_aneg); ++ ++/** + * genphy_c45_aneg_done - return auto-negotiation complete status + * @phydev: target phy_device struct + * +--- a/include/linux/phy.h ++++ b/include/linux/phy.h +@@ -1098,6 +1098,7 @@ int genphy_write_mmd_unsupported(struct + + /* Clause 45 PHY */ + int genphy_c45_restart_aneg(struct phy_device *phydev); ++int genphy_c45_check_and_restart_aneg(struct phy_device *phydev, bool restart); + int genphy_c45_aneg_done(struct phy_device *phydev); + int genphy_c45_read_link(struct phy_device *phydev, u32 mmd_mask); + int genphy_c45_read_lpa(struct phy_device *phydev); diff --git a/target/linux/generic/backport-4.19/708-v5.3-net-phylink-remove-netdev-from-phylink-mii-ioctl-emu.patch b/target/linux/generic/backport-4.19/708-v5.3-net-phylink-remove-netdev-from-phylink-mii-ioctl-emu.patch new file mode 100644 index 000000000..1c3f1cc01 --- /dev/null +++ b/target/linux/generic/backport-4.19/708-v5.3-net-phylink-remove-netdev-from-phylink-mii-ioctl-emu.patch @@ -0,0 +1,59 @@ +From 4c4323084e9a67210c8d269dceba1be99356c414 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 28 May 2019 10:57:18 +0100 +Subject: [PATCH 606/660] net: phylink: remove netdev from phylink mii ioctl + emulation + +The netdev used in the phylink ioctl emulation is never used, so let's +remove it. + +Signed-off-by: Russell King +Reviewed-by: Andrew Lunn +Signed-off-by: David S. Miller +Signed-off-by: Russell King +--- + drivers/net/phy/phylink.c | 12 ++++-------- + 1 file changed, 4 insertions(+), 8 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -1360,8 +1360,8 @@ EXPORT_SYMBOL_GPL(phylink_ethtool_set_ee + * + * FIXME: should deal with negotiation state too. + */ +-static int phylink_mii_emul_read(struct net_device *ndev, unsigned int reg, +- struct phylink_link_state *state, bool aneg) ++static int phylink_mii_emul_read(unsigned int reg, ++ struct phylink_link_state *state) + { + struct fixed_phy_status fs; + int val; +@@ -1376,8 +1376,6 @@ static int phylink_mii_emul_read(struct + if (reg == MII_BMSR) { + if (!state->an_complete) + val &= ~BMSR_ANEGCOMPLETE; +- if (!aneg) +- val &= ~BMSR_ANEGCAPABLE; + } + return val; + } +@@ -1473,8 +1471,7 @@ static int phylink_mii_read(struct phyli + case MLO_AN_FIXED: + if (phy_id == 0) { + phylink_get_fixed_state(pl, &state); +- val = phylink_mii_emul_read(pl->netdev, reg, &state, +- true); ++ val = phylink_mii_emul_read(reg, &state); + } + break; + +@@ -1487,8 +1484,7 @@ static int phylink_mii_read(struct phyli + if (val < 0) + return val; + +- val = phylink_mii_emul_read(pl->netdev, reg, &state, +- true); ++ val = phylink_mii_emul_read(reg, &state); + } + break; + } diff --git a/target/linux/generic/backport-4.19/709-v5.3-net-phylink-support-for-link-gpio-interrupt.patch b/target/linux/generic/backport-4.19/709-v5.3-net-phylink-support-for-link-gpio-interrupt.patch new file mode 100644 index 000000000..84a1c853d --- /dev/null +++ b/target/linux/generic/backport-4.19/709-v5.3-net-phylink-support-for-link-gpio-interrupt.patch @@ -0,0 +1,90 @@ +From cba0aba37d2228556e0d1f776d403435868cdbfa Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 28 May 2019 10:57:23 +0100 +Subject: [PATCH 607/660] net: phylink: support for link gpio interrupt + +Add support for using GPIO interrupts with a fixed-link GPIO rather than +polling the GPIO every second and invoking the phylink resolution. This +avoids unnecessary calls to mac_config(). + +Reviewed-by: Florian Fainelli +Signed-off-by: Russell King +Signed-off-by: David S. Miller +Signed-off-by: Russell King +--- + drivers/net/phy/phylink.c | 36 ++++++++++++++++++++++++++++++++---- + 1 file changed, 32 insertions(+), 4 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -59,6 +59,7 @@ struct phylink { + phy_interface_t cur_interface; + + struct gpio_desc *link_gpio; ++ unsigned int link_irq; + struct timer_list link_poll; + void (*get_fixed_state)(struct net_device *dev, + struct phylink_link_state *s); +@@ -645,7 +646,7 @@ void phylink_destroy(struct phylink *pl) + { + if (pl->sfp_bus) + sfp_unregister_upstream(pl->sfp_bus); +- if (!IS_ERR_OR_NULL(pl->link_gpio)) ++ if (pl->link_gpio) + gpiod_put(pl->link_gpio); + + cancel_work_sync(&pl->resolve); +@@ -912,6 +913,15 @@ void phylink_mac_change(struct phylink * + } + EXPORT_SYMBOL_GPL(phylink_mac_change); + ++static irqreturn_t phylink_link_handler(int irq, void *data) ++{ ++ struct phylink *pl = data; ++ ++ phylink_run_resolve(pl); ++ ++ return IRQ_HANDLED; ++} ++ + /** + * phylink_start() - start a phylink instance + * @pl: a pointer to a &struct phylink returned from phylink_create() +@@ -947,7 +957,22 @@ void phylink_start(struct phylink *pl) + clear_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state); + phylink_run_resolve(pl); + +- if (pl->link_an_mode == MLO_AN_FIXED && !IS_ERR(pl->link_gpio)) ++ if (pl->link_an_mode == MLO_AN_FIXED && pl->link_gpio) { ++ int irq = gpiod_to_irq(pl->link_gpio); ++ ++ if (irq > 0) { ++ if (!request_irq(irq, phylink_link_handler, ++ IRQF_TRIGGER_RISING | ++ IRQF_TRIGGER_FALLING, ++ "netdev link", pl)) ++ pl->link_irq = irq; ++ else ++ irq = 0; ++ } ++ if (irq <= 0) ++ mod_timer(&pl->link_poll, jiffies + HZ); ++ } ++ if (pl->link_an_mode == MLO_AN_FIXED && pl->get_fixed_state) + mod_timer(&pl->link_poll, jiffies + HZ); + if (pl->sfp_bus) + sfp_upstream_start(pl->sfp_bus); +@@ -973,8 +998,11 @@ void phylink_stop(struct phylink *pl) + phy_stop(pl->phydev); + if (pl->sfp_bus) + sfp_upstream_stop(pl->sfp_bus); +- if (pl->link_an_mode == MLO_AN_FIXED && !IS_ERR(pl->link_gpio)) +- del_timer_sync(&pl->link_poll); ++ del_timer_sync(&pl->link_poll); ++ if (pl->link_irq) { ++ free_irq(pl->link_irq, pl); ++ pl->link_irq = 0; ++ } + + phylink_run_resolve_and_disable(pl, PHYLINK_DISABLE_STOPPED); + } diff --git a/target/linux/generic/backport-4.19/710-v5.3-net-phy-allow-Clause-45-access-via-mii-ioctl.patch b/target/linux/generic/backport-4.19/710-v5.3-net-phy-allow-Clause-45-access-via-mii-ioctl.patch new file mode 100644 index 000000000..3a601c65b --- /dev/null +++ b/target/linux/generic/backport-4.19/710-v5.3-net-phy-allow-Clause-45-access-via-mii-ioctl.patch @@ -0,0 +1,77 @@ +From eb5df3d026824832831376bbdf04e01a52776eea Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 28 May 2019 10:57:29 +0100 +Subject: [PATCH 608/660] net: phy: allow Clause 45 access via mii ioctl + +Allow userspace to generate Clause 45 MII access cycles via phylib. +This is useful for tools such as mii-diag to be able to inspect Clause +45 PHYs. + +Reviewed-by: Florian Fainelli +Signed-off-by: Russell King +Signed-off-by: David S. Miller +Signed-off-by: Russell King +--- + drivers/net/phy/phy.c | 33 ++++++++++++++++++++++++--------- + 1 file changed, 24 insertions(+), 9 deletions(-) + +--- a/drivers/net/phy/phy.c ++++ b/drivers/net/phy/phy.c +@@ -397,6 +397,7 @@ int phy_mii_ioctl(struct phy_device *phy + struct mii_ioctl_data *mii_data = if_mii(ifr); + u16 val = mii_data->val_in; + bool change_autoneg = false; ++ int prtad, devad; + + switch (cmd) { + case SIOCGMIIPHY: +@@ -404,14 +405,29 @@ int phy_mii_ioctl(struct phy_device *phy + /* fall through */ + + case SIOCGMIIREG: +- mii_data->val_out = mdiobus_read(phydev->mdio.bus, +- mii_data->phy_id, +- mii_data->reg_num); ++ if (mdio_phy_id_is_c45(mii_data->phy_id)) { ++ prtad = mdio_phy_id_prtad(mii_data->phy_id); ++ devad = mdio_phy_id_devad(mii_data->phy_id); ++ devad = MII_ADDR_C45 | devad << 16 | mii_data->reg_num; ++ } else { ++ prtad = mii_data->phy_id; ++ devad = mii_data->reg_num; ++ } ++ mii_data->val_out = mdiobus_read(phydev->mdio.bus, prtad, ++ devad); + return 0; + + case SIOCSMIIREG: +- if (mii_data->phy_id == phydev->mdio.addr) { +- switch (mii_data->reg_num) { ++ if (mdio_phy_id_is_c45(mii_data->phy_id)) { ++ prtad = mdio_phy_id_prtad(mii_data->phy_id); ++ devad = mdio_phy_id_devad(mii_data->phy_id); ++ devad = MII_ADDR_C45 | devad << 16 | mii_data->reg_num; ++ } else { ++ prtad = mii_data->phy_id; ++ devad = mii_data->reg_num; ++ } ++ if (prtad == phydev->mdio.addr) { ++ switch (devad) { + case MII_BMCR: + if ((val & (BMCR_RESET | BMCR_ANENABLE)) == 0) { + if (phydev->autoneg == AUTONEG_ENABLE) +@@ -443,11 +459,10 @@ int phy_mii_ioctl(struct phy_device *phy + } + } + +- mdiobus_write(phydev->mdio.bus, mii_data->phy_id, +- mii_data->reg_num, val); ++ mdiobus_write(phydev->mdio.bus, prtad, devad, val); + +- if (mii_data->phy_id == phydev->mdio.addr && +- mii_data->reg_num == MII_BMCR && ++ if (prtad == phydev->mdio.addr && ++ devad == MII_BMCR && + val & BMCR_RESET) + return phy_init_hw(phydev); + diff --git a/target/linux/generic/backport-4.19/711-v5.3-net-sfp-add-mandatory-attach-detach-methods-for-sfp-.patch b/target/linux/generic/backport-4.19/711-v5.3-net-sfp-add-mandatory-attach-detach-methods-for-sfp-.patch new file mode 100644 index 000000000..74dc39fa7 --- /dev/null +++ b/target/linux/generic/backport-4.19/711-v5.3-net-sfp-add-mandatory-attach-detach-methods-for-sfp-.patch @@ -0,0 +1,94 @@ +From aeabfaa63285470e81fa341e14f92d68880aa160 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 28 May 2019 10:57:34 +0100 +Subject: [PATCH 609/660] net: sfp: add mandatory attach/detach methods for sfp + buses + +Add attach and detach methods for SFP buses, which will allow us to get +rid of the netdev storage in sfp-bus. + +Signed-off-by: Russell King +Reviewed-by: Andrew Lunn +Signed-off-by: David S. Miller +Signed-off-by: Russell King +--- + drivers/net/phy/phylink.c | 16 ++++++++++++++++ + drivers/net/phy/sfp-bus.c | 4 ++-- + include/linux/sfp.h | 6 ++++++ + 3 files changed, 24 insertions(+), 2 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -1615,6 +1615,20 @@ int phylink_mii_ioctl(struct phylink *pl + } + EXPORT_SYMBOL_GPL(phylink_mii_ioctl); + ++static void phylink_sfp_attach(void *upstream, struct sfp_bus *bus) ++{ ++ struct phylink *pl = upstream; ++ ++ pl->netdev->sfp_bus = bus; ++} ++ ++static void phylink_sfp_detach(void *upstream, struct sfp_bus *bus) ++{ ++ struct phylink *pl = upstream; ++ ++ pl->netdev->sfp_bus = NULL; ++} ++ + static int phylink_sfp_module_insert(void *upstream, + const struct sfp_eeprom_id *id) + { +@@ -1733,6 +1747,8 @@ static void phylink_sfp_disconnect_phy(v + } + + static const struct sfp_upstream_ops sfp_phylink_ops = { ++ .attach = phylink_sfp_attach, ++ .detach = phylink_sfp_detach, + .module_insert = phylink_sfp_module_insert, + .link_up = phylink_sfp_link_up, + .link_down = phylink_sfp_link_down, +--- a/drivers/net/phy/sfp-bus.c ++++ b/drivers/net/phy/sfp-bus.c +@@ -350,7 +350,7 @@ static int sfp_register_bus(struct sfp_b + bus->socket_ops->attach(bus->sfp); + if (bus->started) + bus->socket_ops->start(bus->sfp); +- bus->netdev->sfp_bus = bus; ++ bus->upstream_ops->attach(bus->upstream, bus); + bus->registered = true; + return 0; + } +@@ -359,8 +359,8 @@ static void sfp_unregister_bus(struct sf + { + const struct sfp_upstream_ops *ops = bus->upstream_ops; + +- bus->netdev->sfp_bus = NULL; + if (bus->registered) { ++ bus->upstream_ops->detach(bus->upstream, bus); + if (bus->started) + bus->socket_ops->stop(bus->sfp); + bus->socket_ops->detach(bus->sfp); +--- a/include/linux/sfp.h ++++ b/include/linux/sfp.h +@@ -469,6 +469,10 @@ struct sfp_bus; + + /** + * struct sfp_upstream_ops - upstream operations structure ++ * @attach: called when the sfp socket driver is bound to the upstream ++ * (mandatory). ++ * @detach: called when the sfp socket driver is unbound from the upstream ++ * (mandatory). + * @module_insert: called after a module has been detected to determine + * whether the module is supported for the upstream device. + * @module_remove: called after the module has been removed. +@@ -481,6 +485,8 @@ struct sfp_bus; + * been removed. + */ + struct sfp_upstream_ops { ++ void (*attach)(void *priv, struct sfp_bus *bus); ++ void (*detach)(void *priv, struct sfp_bus *bus); + int (*module_insert)(void *priv, const struct sfp_eeprom_id *id); + void (*module_remove)(void *priv); + void (*link_down)(void *priv); diff --git a/target/linux/generic/backport-4.19/712-v5.3-net-sfp-remove-sfp-bus-use-of-netdevs.patch b/target/linux/generic/backport-4.19/712-v5.3-net-sfp-remove-sfp-bus-use-of-netdevs.patch new file mode 100644 index 000000000..8f0c37e09 --- /dev/null +++ b/target/linux/generic/backport-4.19/712-v5.3-net-sfp-remove-sfp-bus-use-of-netdevs.patch @@ -0,0 +1,118 @@ +From 60d756717d772be90d07a07cd2cc140c76da3e4a Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 28 May 2019 10:57:39 +0100 +Subject: [PATCH 610/660] net: sfp: remove sfp-bus use of netdevs + +The sfp-bus code now no longer has any use for the network device +structure, so remove its use. + +Signed-off-by: Russell King +Reviewed-by: Andrew Lunn +Signed-off-by: David S. Miller +Signed-off-by: Russell King +--- + drivers/net/phy/phylink.c | 3 +-- + drivers/net/phy/sfp-bus.c | 10 +++------- + include/linux/sfp.h | 6 ++---- + 3 files changed, 6 insertions(+), 13 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -555,8 +555,7 @@ static int phylink_register_sfp(struct p + return ret; + } + +- pl->sfp_bus = sfp_register_upstream(ref.fwnode, pl->netdev, pl, +- &sfp_phylink_ops); ++ pl->sfp_bus = sfp_register_upstream(ref.fwnode, pl, &sfp_phylink_ops); + if (!pl->sfp_bus) + return -ENOMEM; + +--- a/drivers/net/phy/sfp-bus.c ++++ b/drivers/net/phy/sfp-bus.c +@@ -23,7 +23,6 @@ struct sfp_bus { + + const struct sfp_upstream_ops *upstream_ops; + void *upstream; +- struct net_device *netdev; + struct phy_device *phydev; + + bool registered; +@@ -442,13 +441,11 @@ static void sfp_upstream_clear(struct sf + { + bus->upstream_ops = NULL; + bus->upstream = NULL; +- bus->netdev = NULL; + } + + /** + * sfp_register_upstream() - Register the neighbouring device + * @fwnode: firmware node for the SFP bus +- * @ndev: network device associated with the interface + * @upstream: the upstream private data + * @ops: the upstream's &struct sfp_upstream_ops + * +@@ -459,7 +456,7 @@ static void sfp_upstream_clear(struct sf + * On error, returns %NULL. + */ + struct sfp_bus *sfp_register_upstream(struct fwnode_handle *fwnode, +- struct net_device *ndev, void *upstream, ++ void *upstream, + const struct sfp_upstream_ops *ops) + { + struct sfp_bus *bus = sfp_bus_get(fwnode); +@@ -469,7 +466,6 @@ struct sfp_bus *sfp_register_upstream(st + rtnl_lock(); + bus->upstream_ops = ops; + bus->upstream = upstream; +- bus->netdev = ndev; + + if (bus->sfp) { + ret = sfp_register_bus(bus); +@@ -591,7 +587,7 @@ struct sfp_bus *sfp_register_socket(stru + bus->sfp = sfp; + bus->socket_ops = ops; + +- if (bus->netdev) { ++ if (bus->upstream_ops) { + ret = sfp_register_bus(bus); + if (ret) + sfp_socket_clear(bus); +@@ -611,7 +607,7 @@ EXPORT_SYMBOL_GPL(sfp_register_socket); + void sfp_unregister_socket(struct sfp_bus *bus) + { + rtnl_lock(); +- if (bus->netdev) ++ if (bus->upstream_ops) + sfp_unregister_bus(bus); + sfp_socket_clear(bus); + rtnl_unlock(); +--- a/include/linux/sfp.h ++++ b/include/linux/sfp.h +@@ -464,7 +464,6 @@ enum { + struct fwnode_handle; + struct ethtool_eeprom; + struct ethtool_modinfo; +-struct net_device; + struct sfp_bus; + + /** +@@ -510,7 +509,7 @@ int sfp_get_module_eeprom(struct sfp_bus + void sfp_upstream_start(struct sfp_bus *bus); + void sfp_upstream_stop(struct sfp_bus *bus); + struct sfp_bus *sfp_register_upstream(struct fwnode_handle *fwnode, +- struct net_device *ndev, void *upstream, ++ void *upstream, + const struct sfp_upstream_ops *ops); + void sfp_unregister_upstream(struct sfp_bus *bus); + #else +@@ -555,8 +554,7 @@ static inline void sfp_upstream_stop(str + } + + static inline struct sfp_bus *sfp_register_upstream( +- struct fwnode_handle *fwnode, +- struct net_device *ndev, void *upstream, ++ struct fwnode_handle *fwnode, void *upstream, + const struct sfp_upstream_ops *ops) + { + return (struct sfp_bus *)-1; diff --git a/target/linux/generic/backport-4.19/713-v5.2-net-phylink-avoid-reducing-support-mask.patch b/target/linux/generic/backport-4.19/713-v5.2-net-phylink-avoid-reducing-support-mask.patch new file mode 100644 index 000000000..3aa8d9e57 --- /dev/null +++ b/target/linux/generic/backport-4.19/713-v5.2-net-phylink-avoid-reducing-support-mask.patch @@ -0,0 +1,84 @@ +From 8ac1d3e5cf7d277769ba3403d99f643fab1e3fae Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Sat, 23 Nov 2019 14:19:54 +0000 +Subject: [PATCH 611/660] net: phylink: avoid reducing support mask + +Avoid reducing the support mask as a result of the interface type +selected for SFP modules, or when setting the link settings through +ethtool - this should only change when the supported link modes of +the hardware combination change. + +Signed-off-by: Russell King +Signed-off-by: David S. Miller +--- + drivers/net/phy/phylink.c | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -1137,6 +1137,7 @@ EXPORT_SYMBOL_GPL(phylink_ethtool_ksetti + int phylink_ethtool_ksettings_set(struct phylink *pl, + const struct ethtool_link_ksettings *kset) + { ++ __ETHTOOL_DECLARE_LINK_MODE_MASK(support); + struct ethtool_link_ksettings our_kset; + struct phylink_link_state config; + int ret; +@@ -1147,11 +1148,12 @@ int phylink_ethtool_ksettings_set(struct + kset->base.autoneg != AUTONEG_ENABLE) + return -EINVAL; + ++ linkmode_copy(support, pl->supported); + config = pl->link_config; + + /* Mask out unsupported advertisements */ + linkmode_and(config.advertising, kset->link_modes.advertising, +- pl->supported); ++ support); + + /* FIXME: should we reject autoneg if phy/mac does not support it? */ + if (kset->base.autoneg == AUTONEG_DISABLE) { +@@ -1161,7 +1163,7 @@ int phylink_ethtool_ksettings_set(struct + * duplex. + */ + s = phy_lookup_setting(kset->base.speed, kset->base.duplex, +- pl->supported, ++ support, + __ETHTOOL_LINK_MODE_MASK_NBITS, false); + if (!s) + return -EINVAL; +@@ -1191,7 +1193,7 @@ int phylink_ethtool_ksettings_set(struct + __set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, config.advertising); + } + +- if (phylink_validate(pl, pl->supported, &config)) ++ if (phylink_validate(pl, support, &config)) + return -EINVAL; + + /* If autonegotiation is enabled, we must have an advertisement */ +@@ -1633,6 +1635,7 @@ static int phylink_sfp_module_insert(voi + { + struct phylink *pl = upstream; + __ETHTOOL_DECLARE_LINK_MODE_MASK(support) = { 0, }; ++ __ETHTOOL_DECLARE_LINK_MODE_MASK(support1); + struct phylink_link_state config; + phy_interface_t iface; + int ret = 0; +@@ -1660,6 +1663,8 @@ static int phylink_sfp_module_insert(voi + return ret; + } + ++ linkmode_copy(support1, support); ++ + iface = sfp_select_interface(pl->sfp_bus, id, config.advertising); + if (iface == PHY_INTERFACE_MODE_NA) { + netdev_err(pl->netdev, +@@ -1669,7 +1674,7 @@ static int phylink_sfp_module_insert(voi + } + + config.interface = iface; +- ret = phylink_validate(pl, support, &config); ++ ret = phylink_validate(pl, support1, &config); + if (ret) { + netdev_err(pl->netdev, "validation of %s/%s with support %*pb failed: %d\n", + phylink_an_mode_str(MLO_AN_INBAND), diff --git a/target/linux/generic/backport-4.19/714-v5.3-net-sfp-Stop-SFP-polling-and-interrupt-handling-duri.patch b/target/linux/generic/backport-4.19/714-v5.3-net-sfp-Stop-SFP-polling-and-interrupt-handling-duri.patch new file mode 100644 index 000000000..050995029 --- /dev/null +++ b/target/linux/generic/backport-4.19/714-v5.3-net-sfp-Stop-SFP-polling-and-interrupt-handling-duri.patch @@ -0,0 +1,94 @@ +From 254236a22109efa84c9e9f5a9c76a1719439e309 Mon Sep 17 00:00:00 2001 +From: Robert Hancock +Date: Fri, 7 Jun 2019 10:42:35 -0600 +Subject: [PATCH 612/660] net: sfp: Stop SFP polling and interrupt handling + during shutdown + +SFP device polling can cause problems during the shutdown process if the +parent devices of the network controller have been shut down already. +This problem was seen on the iMX6 platform with PCIe devices, where +accessing the device after the bus is shut down causes a hang. + +Free any acquired GPIO interrupts and stop all delayed work in the SFP +driver during the shutdown process, so that we ensure that no pending +operations are still occurring after the SFP shutdown completes. + +Signed-off-by: Robert Hancock +Signed-off-by: David S. Miller +--- + drivers/net/phy/sfp.c | 31 ++++++++++++++++++++++++++----- + 1 file changed, 26 insertions(+), 5 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -183,6 +183,7 @@ struct sfp { + int (*write)(struct sfp *, bool, u8, void *, size_t); + + struct gpio_desc *gpio[GPIO_MAX]; ++ int gpio_irq[GPIO_MAX]; + + bool attached; + struct mutex st_mutex; /* Protects state */ +@@ -1803,7 +1804,7 @@ static int sfp_probe(struct platform_dev + const struct sff_data *sff; + struct sfp *sfp; + bool poll = false; +- int irq, err, i; ++ int err, i; + + sfp = sfp_alloc(&pdev->dev); + if (IS_ERR(sfp)) +@@ -1885,19 +1886,22 @@ static int sfp_probe(struct platform_dev + if (gpio_flags[i] != GPIOD_IN || !sfp->gpio[i]) + continue; + +- irq = gpiod_to_irq(sfp->gpio[i]); +- if (!irq) { ++ sfp->gpio_irq[i] = gpiod_to_irq(sfp->gpio[i]); ++ if (!sfp->gpio_irq[i]) { + poll = true; + continue; + } + +- err = devm_request_threaded_irq(sfp->dev, irq, NULL, sfp_irq, ++ err = devm_request_threaded_irq(sfp->dev, sfp->gpio_irq[i], ++ NULL, sfp_irq, + IRQF_ONESHOT | + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING, + dev_name(sfp->dev), sfp); +- if (err) ++ if (err) { ++ sfp->gpio_irq[i] = 0; + poll = true; ++ } + } + + if (poll) +@@ -1928,9 +1932,26 @@ static int sfp_remove(struct platform_de + return 0; + } + ++static void sfp_shutdown(struct platform_device *pdev) ++{ ++ struct sfp *sfp = platform_get_drvdata(pdev); ++ int i; ++ ++ for (i = 0; i < GPIO_MAX; i++) { ++ if (!sfp->gpio_irq[i]) ++ continue; ++ ++ devm_free_irq(sfp->dev, sfp->gpio_irq[i], sfp); ++ } ++ ++ cancel_delayed_work_sync(&sfp->poll); ++ cancel_delayed_work_sync(&sfp->timeout); ++} ++ + static struct platform_driver sfp_driver = { + .probe = sfp_probe, + .remove = sfp_remove, ++ .shutdown = sfp_shutdown, + .driver = { + .name = "sfp", + .of_match_table = sfp_of_match, diff --git a/target/linux/generic/backport-4.19/715-v5.3-net-phylink-don-t-start-and-stop-SGMII-PHYs-in-SFP-m.patch b/target/linux/generic/backport-4.19/715-v5.3-net-phylink-don-t-start-and-stop-SGMII-PHYs-in-SFP-m.patch new file mode 100644 index 000000000..94fb2fb3e --- /dev/null +++ b/target/linux/generic/backport-4.19/715-v5.3-net-phylink-don-t-start-and-stop-SGMII-PHYs-in-SFP-m.patch @@ -0,0 +1,141 @@ +From b8803113537a1c1f457eba6270d46e3af305031f Mon Sep 17 00:00:00 2001 +From: Arseny Solokha +Date: Wed, 24 Jul 2019 20:31:39 +0700 +Subject: [PATCH 613/660] net: phylink: don't start and stop SGMII PHYs in SFP + modules twice + +SFP modules connected using the SGMII interface have their own PHYs which +are handled by the struct phylink's phydev field. On the other hand, for +the modules connected using 1000Base-X interface that field is not set. + +Since commit ce0aa27ff3f6 ("sfp: add sfp-bus to bridge between network +devices and sfp cages") phylink_start() ends up setting the phydev field +using the sfp-bus infrastructure, which eventually calls phy_start() on it, +and then calling phy_start() again on the same phydev from phylink_start() +itself. Similar call sequence holds for phylink_stop(), only in the reverse +order. This results in WARNs during network interface bringup and shutdown +when a copper SFP module is connected, as phy_start() and phy_stop() are +called twice in a row for the same phy_device: + + % ip link set up dev eth0 + ------------[ cut here ]------------ + called from state UP + WARNING: CPU: 1 PID: 155 at drivers/net/phy/phy.c:895 phy_start+0x74/0xc0 + Modules linked in: + CPU: 1 PID: 155 Comm: backend Not tainted 5.2.0+ #1 + NIP: c0227bf0 LR: c0227bf0 CTR: c004d224 + REGS: df547720 TRAP: 0700 Not tainted (5.2.0+) + MSR: 00029000 CR: 24002822 XER: 00000000 + + GPR00: c0227bf0 df5477d8 df5d7080 00000014 df9d2370 df9d5ac4 1f4eb000 00000001 + GPR08: c061fe58 00000000 00000000 df5477d8 0000003c 100c8768 00000000 00000000 + GPR16: df486a00 c046f1c8 c046eea0 00000000 c046e904 c0239604 db68449c 00000000 + GPR24: e9083204 00000000 00000001 db684460 e9083404 00000000 db6dce00 db6dcc00 + NIP [c0227bf0] phy_start+0x74/0xc0 + LR [c0227bf0] phy_start+0x74/0xc0 + Call Trace: + [df5477d8] [c0227bf0] phy_start+0x74/0xc0 (unreliable) + [df5477e8] [c023cad0] startup_gfar+0x398/0x3f4 + [df547828] [c023cf08] gfar_enet_open+0x364/0x374 + [df547898] [c029d870] __dev_open+0xe4/0x140 + [df5478c8] [c029db70] __dev_change_flags+0xf0/0x188 + [df5478f8] [c029dc28] dev_change_flags+0x20/0x54 + [df547918] [c02ae304] do_setlink+0x310/0x818 + [df547a08] [c02b1eb8] __rtnl_newlink+0x384/0x6b0 + [df547c28] [c02b222c] rtnl_newlink+0x48/0x68 + [df547c48] [c02ad7c8] rtnetlink_rcv_msg+0x240/0x27c + [df547c98] [c02cc068] netlink_rcv_skb+0x8c/0xf0 + [df547cd8] [c02cba3c] netlink_unicast+0x114/0x19c + [df547d08] [c02cbd74] netlink_sendmsg+0x2b0/0x2c0 + [df547d58] [c027b668] sock_sendmsg_nosec+0x20/0x40 + [df547d68] [c027d080] ___sys_sendmsg+0x17c/0x1dc + [df547e98] [c027df7c] __sys_sendmsg+0x68/0x84 + [df547ef8] [c027e430] sys_socketcall+0x1a0/0x204 + [df547f38] [c000d1d8] ret_from_syscall+0x0/0x38 + --- interrupt: c01 at 0xfd4e030 + LR = 0xfd4e010 + Instruction dump: + 813f0188 38800000 2b890005 419d0014 3d40c046 5529103a 394aa208 7c8a482e + 3c60c046 3863a1b8 4cc63182 4be009a1 <0fe00000> 48000030 3c60c046 3863a1d0 + ---[ end trace d4c095aeaf6ea998 ]--- + +and + + % ip link set down dev eth0 + ------------[ cut here ]------------ + called from state HALTED + WARNING: CPU: 1 PID: 184 at drivers/net/phy/phy.c:858 phy_stop+0x3c/0x88 + + <...> + + Call Trace: + [df581788] [c0228450] phy_stop+0x3c/0x88 (unreliable) + [df581798] [c022d548] sfp_sm_phy_detach+0x1c/0x44 + [df5817a8] [c022e8cc] sfp_sm_event+0x4b0/0x87c + [df581848] [c022f04c] sfp_upstream_stop+0x34/0x44 + [df581858] [c0225608] phylink_stop+0x7c/0xe4 + [df581868] [c023c57c] stop_gfar+0x7c/0x94 + [df581888] [c023c5b8] gfar_close+0x24/0x94 + [df5818a8] [c0298688] __dev_close_many+0xdc/0xf8 + [df5818c8] [c029db58] __dev_change_flags+0xd8/0x188 + [df5818f8] [c029dc28] dev_change_flags+0x20/0x54 + [df581918] [c02ae304] do_setlink+0x310/0x818 + [df581a08] [c02b1eb8] __rtnl_newlink+0x384/0x6b0 + [df581c28] [c02b222c] rtnl_newlink+0x48/0x68 + [df581c48] [c02ad7c8] rtnetlink_rcv_msg+0x240/0x27c + [df581c98] [c02cc068] netlink_rcv_skb+0x8c/0xf0 + [df581cd8] [c02cba3c] netlink_unicast+0x114/0x19c + [df581d08] [c02cbd74] netlink_sendmsg+0x2b0/0x2c0 + [df581d58] [c027b668] sock_sendmsg_nosec+0x20/0x40 + [df581d68] [c027d080] ___sys_sendmsg+0x17c/0x1dc + [df581e98] [c027df7c] __sys_sendmsg+0x68/0x84 + [df581ef8] [c027e430] sys_socketcall+0x1a0/0x204 + [df581f38] [c000d1d8] ret_from_syscall+0x0/0x38 + + <...> + + ---[ end trace d4c095aeaf6ea999 ]--- + +SFP modules with the 1000Base-X interface are not affected. + +Place explicit calls to phy_start() and phy_stop() before enabling or after +disabling an attached SFP module, where phydev is not yet set (or is +already unset), so they will be made only from the inside of sfp-bus, if +needed. + +Fixes: 217962615662 ("net: phy: warn if phy_start is called from invalid state") +Signed-off-by: Arseny Solokha +Acked-by: Russell King +Signed-off-by: David S. Miller +--- + drivers/net/phy/phylink.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -973,10 +973,10 @@ void phylink_start(struct phylink *pl) + } + if (pl->link_an_mode == MLO_AN_FIXED && pl->get_fixed_state) + mod_timer(&pl->link_poll, jiffies + HZ); +- if (pl->sfp_bus) +- sfp_upstream_start(pl->sfp_bus); + if (pl->phydev) + phy_start(pl->phydev); ++ if (pl->sfp_bus) ++ sfp_upstream_start(pl->sfp_bus); + } + EXPORT_SYMBOL_GPL(phylink_start); + +@@ -993,10 +993,10 @@ void phylink_stop(struct phylink *pl) + { + ASSERT_RTNL(); + +- if (pl->phydev) +- phy_stop(pl->phydev); + if (pl->sfp_bus) + sfp_upstream_stop(pl->sfp_bus); ++ if (pl->phydev) ++ phy_stop(pl->phydev); + del_timer_sync(&pl->link_poll); + if (pl->link_irq) { + free_irq(pl->link_irq, pl); diff --git a/target/linux/generic/backport-4.19/716-v5.4-net-sfp-move-fwnode-parsing-into-sfp-bus-layer.patch b/target/linux/generic/backport-4.19/716-v5.4-net-sfp-move-fwnode-parsing-into-sfp-bus-layer.patch new file mode 100644 index 000000000..27ab78f3e --- /dev/null +++ b/target/linux/generic/backport-4.19/716-v5.4-net-sfp-move-fwnode-parsing-into-sfp-bus-layer.patch @@ -0,0 +1,179 @@ +From 4054955f0da08c81d42220cb445820d474f1ac92 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Sat, 14 Sep 2019 14:21:22 +0100 +Subject: [PATCH 614/660] net: sfp: move fwnode parsing into sfp-bus layer + +Rather than parsing the sfp firmware node in phylink, parse it in the +sfp-bus code, so we can re-use this code for PHYs without having to +duplicate the parsing. + +Signed-off-by: Russell King +--- + drivers/net/phy/phylink.c | 21 ++++--------- + drivers/net/phy/sfp-bus.c | 65 +++++++++++++++++++++++++-------------- + include/linux/sfp.h | 10 +++--- + 3 files changed, 53 insertions(+), 43 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -538,26 +538,17 @@ static const struct sfp_upstream_ops sfp + static int phylink_register_sfp(struct phylink *pl, + struct fwnode_handle *fwnode) + { +- struct fwnode_reference_args ref; ++ struct sfp_bus *bus; + int ret; + +- if (!fwnode) +- return 0; +- +- ret = fwnode_property_get_reference_args(fwnode, "sfp", NULL, +- 0, 0, &ref); +- if (ret < 0) { +- if (ret == -ENOENT) +- return 0; +- +- netdev_err(pl->netdev, "unable to parse \"sfp\" node: %d\n", +- ret); ++ bus = sfp_register_upstream_node(fwnode, pl, &sfp_phylink_ops); ++ if (IS_ERR(bus)) { ++ ret = PTR_ERR(bus); ++ netdev_err(pl->netdev, "unable to attach SFP bus: %d\n", ret); + return ret; + } + +- pl->sfp_bus = sfp_register_upstream(ref.fwnode, pl, &sfp_phylink_ops); +- if (!pl->sfp_bus) +- return -ENOMEM; ++ pl->sfp_bus = bus; + + return 0; + } +--- a/drivers/net/phy/sfp-bus.c ++++ b/drivers/net/phy/sfp-bus.c +@@ -3,6 +3,7 @@ + #include + #include + #include ++#include + #include + #include + +@@ -444,45 +445,63 @@ static void sfp_upstream_clear(struct sf + } + + /** +- * sfp_register_upstream() - Register the neighbouring device +- * @fwnode: firmware node for the SFP bus ++ * sfp_register_upstream_node() - parse and register the neighbouring device ++ * @fwnode: firmware node for the parent device (MAC or PHY) + * @upstream: the upstream private data + * @ops: the upstream's &struct sfp_upstream_ops + * +- * Register the upstream device (eg, PHY) with the SFP bus. MAC drivers +- * should use phylink, which will call this function for them. Returns +- * a pointer to the allocated &struct sfp_bus. ++ * Parse the parent device's firmware node for a SFP bus, and register the ++ * SFP bus using sfp_register_upstream(). + * +- * On error, returns %NULL. ++ * Returns: on success, a pointer to the sfp_bus structure, ++ * %NULL if no SFP is specified, ++ * on failure, an error pointer value: ++ * corresponding to the errors detailed for ++ * fwnode_property_get_reference_args(). ++ * %-ENOMEM if we failed to allocate the bus. ++ * an error from the upstream's connect_phy() method. + */ +-struct sfp_bus *sfp_register_upstream(struct fwnode_handle *fwnode, +- void *upstream, +- const struct sfp_upstream_ops *ops) +-{ +- struct sfp_bus *bus = sfp_bus_get(fwnode); +- int ret = 0; +- +- if (bus) { +- rtnl_lock(); +- bus->upstream_ops = ops; +- bus->upstream = upstream; ++struct sfp_bus *sfp_register_upstream_node(struct fwnode_handle *fwnode, ++ void *upstream, ++ const struct sfp_upstream_ops *ops) ++{ ++ struct fwnode_reference_args ref; ++ struct sfp_bus *bus; ++ int ret; + +- if (bus->sfp) { +- ret = sfp_register_bus(bus); +- if (ret) +- sfp_upstream_clear(bus); +- } +- rtnl_unlock(); ++ ret = fwnode_property_get_reference_args(fwnode, "sfp", NULL, ++ 0, 0, &ref); ++ if (ret == -ENOENT) ++ return NULL; ++ else if (ret < 0) ++ return ERR_PTR(ret); ++ ++ bus = sfp_bus_get(ref.fwnode); ++ fwnode_handle_put(ref.fwnode); ++ if (!bus) ++ return ERR_PTR(-ENOMEM); ++ ++ rtnl_lock(); ++ bus->upstream_ops = ops; ++ bus->upstream = upstream; ++ ++ if (bus->sfp) { ++ ret = sfp_register_bus(bus); ++ if (ret) ++ sfp_upstream_clear(bus); ++ } else { ++ ret = 0; + } ++ rtnl_unlock(); + + if (ret) { + sfp_bus_put(bus); +- bus = NULL; ++ bus = ERR_PTR(ret); + } + + return bus; + } +-EXPORT_SYMBOL_GPL(sfp_register_upstream); ++EXPORT_SYMBOL_GPL(sfp_register_upstream_node); + + /** + * sfp_unregister_upstream() - Unregister sfp bus +--- a/include/linux/sfp.h ++++ b/include/linux/sfp.h +@@ -508,9 +508,9 @@ int sfp_get_module_eeprom(struct sfp_bus + u8 *data); + void sfp_upstream_start(struct sfp_bus *bus); + void sfp_upstream_stop(struct sfp_bus *bus); +-struct sfp_bus *sfp_register_upstream(struct fwnode_handle *fwnode, +- void *upstream, +- const struct sfp_upstream_ops *ops); ++struct sfp_bus *sfp_register_upstream_node(struct fwnode_handle *fwnode, ++ void *upstream, ++ const struct sfp_upstream_ops *ops); + void sfp_unregister_upstream(struct sfp_bus *bus); + #else + static inline int sfp_parse_port(struct sfp_bus *bus, +@@ -553,11 +553,11 @@ static inline void sfp_upstream_stop(str + { + } + +-static inline struct sfp_bus *sfp_register_upstream( ++static inline struct sfp_bus *sfp_register_upstream_node( + struct fwnode_handle *fwnode, void *upstream, + const struct sfp_upstream_ops *ops) + { +- return (struct sfp_bus *)-1; ++ return NULL; + } + + static inline void sfp_unregister_upstream(struct sfp_bus *bus) diff --git a/target/linux/generic/backport-4.19/717-v5.5-net-sfp-rework-upstream-interface.patch b/target/linux/generic/backport-4.19/717-v5.5-net-sfp-rework-upstream-interface.patch new file mode 100644 index 000000000..f7dd187c1 --- /dev/null +++ b/target/linux/generic/backport-4.19/717-v5.5-net-sfp-rework-upstream-interface.patch @@ -0,0 +1,254 @@ +From 863b5b6941f9f43b924393b6ba2b36647e7dee42 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Thu, 7 Nov 2019 17:06:08 +0000 +Subject: [PATCH 615/660] net: sfp: rework upstream interface + +The current upstream interface is an all-or-nothing, which is +sub-optimal for future changes, as it doesn't allow the upstream driver +to prepare for the SFP module becoming available, as it is at boot. + +Switch to a find-sfp-bus, add-upstream, del-upstream, put-sfp-bus +interface structure instead, which allows the upstream driver to +prepare for a module being available as soon as add-upstream is called. + +Signed-off-by: Russell King +--- + drivers/net/phy/phylink.c | 10 +++-- + drivers/net/phy/sfp-bus.c | 92 +++++++++++++++++++++++++++------------ + include/linux/sfp.h | 25 +++++++---- + 3 files changed, 88 insertions(+), 39 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -541,7 +541,7 @@ static int phylink_register_sfp(struct p + struct sfp_bus *bus; + int ret; + +- bus = sfp_register_upstream_node(fwnode, pl, &sfp_phylink_ops); ++ bus = sfp_bus_find_fwnode(fwnode); + if (IS_ERR(bus)) { + ret = PTR_ERR(bus); + netdev_err(pl->netdev, "unable to attach SFP bus: %d\n", ret); +@@ -550,7 +550,10 @@ static int phylink_register_sfp(struct p + + pl->sfp_bus = bus; + +- return 0; ++ ret = sfp_bus_add_upstream(bus, pl, &sfp_phylink_ops); ++ sfp_bus_put(bus); ++ ++ return ret; + } + + /** +@@ -634,8 +637,7 @@ EXPORT_SYMBOL_GPL(phylink_create); + */ + void phylink_destroy(struct phylink *pl) + { +- if (pl->sfp_bus) +- sfp_unregister_upstream(pl->sfp_bus); ++ sfp_bus_del_upstream(pl->sfp_bus); + if (pl->link_gpio) + gpiod_put(pl->link_gpio); + +--- a/drivers/net/phy/sfp-bus.c ++++ b/drivers/net/phy/sfp-bus.c +@@ -328,10 +328,19 @@ static void sfp_bus_release(struct kref + kfree(bus); + } + +-static void sfp_bus_put(struct sfp_bus *bus) ++/** ++ * sfp_bus_put() - put a reference on the &struct sfp_bus ++ * bus: the &struct sfp_bus found via sfp_bus_find_fwnode() ++ * ++ * Put a reference on the &struct sfp_bus and free the underlying structure ++ * if this was the last reference. ++ */ ++void sfp_bus_put(struct sfp_bus *bus) + { +- kref_put_mutex(&bus->kref, sfp_bus_release, &sfp_mutex); ++ if (bus) ++ kref_put_mutex(&bus->kref, sfp_bus_release, &sfp_mutex); + } ++EXPORT_SYMBOL_GPL(sfp_bus_put); + + static int sfp_register_bus(struct sfp_bus *bus) + { +@@ -347,11 +356,11 @@ static int sfp_register_bus(struct sfp_b + return ret; + } + } ++ bus->registered = true; + bus->socket_ops->attach(bus->sfp); + if (bus->started) + bus->socket_ops->start(bus->sfp); + bus->upstream_ops->attach(bus->upstream, bus); +- bus->registered = true; + return 0; + } + +@@ -445,13 +454,12 @@ static void sfp_upstream_clear(struct sf + } + + /** +- * sfp_register_upstream_node() - parse and register the neighbouring device ++ * sfp_bus_find_fwnode() - parse and locate the SFP bus from fwnode + * @fwnode: firmware node for the parent device (MAC or PHY) +- * @upstream: the upstream private data +- * @ops: the upstream's &struct sfp_upstream_ops + * +- * Parse the parent device's firmware node for a SFP bus, and register the +- * SFP bus using sfp_register_upstream(). ++ * Parse the parent device's firmware node for a SFP bus, and locate ++ * the sfp_bus structure, incrementing its reference count. This must ++ * be put via sfp_bus_put() when done. + * + * Returns: on success, a pointer to the sfp_bus structure, + * %NULL if no SFP is specified, +@@ -461,9 +469,7 @@ static void sfp_upstream_clear(struct sf + * %-ENOMEM if we failed to allocate the bus. + * an error from the upstream's connect_phy() method. + */ +-struct sfp_bus *sfp_register_upstream_node(struct fwnode_handle *fwnode, +- void *upstream, +- const struct sfp_upstream_ops *ops) ++struct sfp_bus *sfp_bus_find_fwnode(struct fwnode_handle *fwnode) + { + struct fwnode_reference_args ref; + struct sfp_bus *bus; +@@ -481,7 +487,39 @@ struct sfp_bus *sfp_register_upstream_no + if (!bus) + return ERR_PTR(-ENOMEM); + ++ return bus; ++} ++EXPORT_SYMBOL_GPL(sfp_bus_find_fwnode); ++ ++/** ++ * sfp_bus_add_upstream() - parse and register the neighbouring device ++ * @bus: the &struct sfp_bus found via sfp_bus_find_fwnode() ++ * @upstream: the upstream private data ++ * @ops: the upstream's &struct sfp_upstream_ops ++ * ++ * Add upstream driver for the SFP bus, and if the bus is complete, register ++ * the SFP bus using sfp_register_upstream(). This takes a reference on the ++ * bus, so it is safe to put the bus after this call. ++ * ++ * Returns: on success, a pointer to the sfp_bus structure, ++ * %NULL if no SFP is specified, ++ * on failure, an error pointer value: ++ * corresponding to the errors detailed for ++ * fwnode_property_get_reference_args(). ++ * %-ENOMEM if we failed to allocate the bus. ++ * an error from the upstream's connect_phy() method. ++ */ ++int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, ++ const struct sfp_upstream_ops *ops) ++{ ++ int ret; ++ ++ /* If no bus, return success */ ++ if (!bus) ++ return 0; ++ + rtnl_lock(); ++ kref_get(&bus->kref); + bus->upstream_ops = ops; + bus->upstream = upstream; + +@@ -494,33 +532,33 @@ struct sfp_bus *sfp_register_upstream_no + } + rtnl_unlock(); + +- if (ret) { ++ if (ret) + sfp_bus_put(bus); +- bus = ERR_PTR(ret); +- } + +- return bus; ++ return ret; + } +-EXPORT_SYMBOL_GPL(sfp_register_upstream_node); ++EXPORT_SYMBOL_GPL(sfp_bus_add_upstream); + + /** +- * sfp_unregister_upstream() - Unregister sfp bus ++ * sfp_bus_del_upstream() - Delete a sfp bus + * @bus: a pointer to the &struct sfp_bus structure for the sfp module + * +- * Unregister a previously registered upstream connection for the SFP +- * module. @bus is returned from sfp_register_upstream(). ++ * Delete a previously registered upstream connection for the SFP ++ * module. @bus should have been added by sfp_bus_add_upstream(). + */ +-void sfp_unregister_upstream(struct sfp_bus *bus) ++void sfp_bus_del_upstream(struct sfp_bus *bus) + { +- rtnl_lock(); +- if (bus->sfp) +- sfp_unregister_bus(bus); +- sfp_upstream_clear(bus); +- rtnl_unlock(); ++ if (bus) { ++ rtnl_lock(); ++ if (bus->sfp) ++ sfp_unregister_bus(bus); ++ sfp_upstream_clear(bus); ++ rtnl_unlock(); + +- sfp_bus_put(bus); ++ sfp_bus_put(bus); ++ } + } +-EXPORT_SYMBOL_GPL(sfp_unregister_upstream); ++EXPORT_SYMBOL_GPL(sfp_bus_del_upstream); + + /* Socket driver entry points */ + int sfp_add_phy(struct sfp_bus *bus, struct phy_device *phydev) +--- a/include/linux/sfp.h ++++ b/include/linux/sfp.h +@@ -508,10 +508,11 @@ int sfp_get_module_eeprom(struct sfp_bus + u8 *data); + void sfp_upstream_start(struct sfp_bus *bus); + void sfp_upstream_stop(struct sfp_bus *bus); +-struct sfp_bus *sfp_register_upstream_node(struct fwnode_handle *fwnode, +- void *upstream, +- const struct sfp_upstream_ops *ops); +-void sfp_unregister_upstream(struct sfp_bus *bus); ++void sfp_bus_put(struct sfp_bus *bus); ++struct sfp_bus *sfp_bus_find_fwnode(struct fwnode_handle *fwnode); ++int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, ++ const struct sfp_upstream_ops *ops); ++void sfp_bus_del_upstream(struct sfp_bus *bus); + #else + static inline int sfp_parse_port(struct sfp_bus *bus, + const struct sfp_eeprom_id *id, +@@ -553,14 +554,22 @@ static inline void sfp_upstream_stop(str + { + } + +-static inline struct sfp_bus *sfp_register_upstream_node( +- struct fwnode_handle *fwnode, void *upstream, +- const struct sfp_upstream_ops *ops) ++static inline void sfp_bus_put(struct sfp_bus *bus) ++{ ++} ++ ++static inline struct sfp_bus *sfp_bus_find_fwnode(struct fwnode_handle *fwnode) + { + return NULL; + } + +-static inline void sfp_unregister_upstream(struct sfp_bus *bus) ++static int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, ++ const struct sfp_upstream_ops *ops) ++{ ++ return 0; ++} ++ ++static inline void sfp_bus_del_upstream(struct sfp_bus *bus) + { + } + #endif diff --git a/target/linux/generic/backport-4.19/718-v5.5-net-sfp-fix-sfp_bus_put-kernel-documentation.patch b/target/linux/generic/backport-4.19/718-v5.5-net-sfp-fix-sfp_bus_put-kernel-documentation.patch new file mode 100644 index 000000000..59d2ce588 --- /dev/null +++ b/target/linux/generic/backport-4.19/718-v5.5-net-sfp-fix-sfp_bus_put-kernel-documentation.patch @@ -0,0 +1,27 @@ +From ea7bfd81921827d334c2a23bd11ef0e4e2abafd2 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Sat, 9 Nov 2019 08:13:50 +0000 +Subject: [PATCH 616/660] net: sfp: fix sfp_bus_put() kernel documentation + +The kbuild test robot found a problem with htmldocs with the recent +change to the SFP interfaces. Fix the kernel documentation for +sfp_bus_put() which was missing an '@' before the argument name +description. + +Fixes: 727b3668b730 ("net: sfp: rework upstream interface") +Signed-off-by: Russell King +--- + drivers/net/phy/sfp-bus.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/phy/sfp-bus.c ++++ b/drivers/net/phy/sfp-bus.c +@@ -330,7 +330,7 @@ static void sfp_bus_release(struct kref + + /** + * sfp_bus_put() - put a reference on the &struct sfp_bus +- * bus: the &struct sfp_bus found via sfp_bus_find_fwnode() ++ * @bus: the &struct sfp_bus found via sfp_bus_find_fwnode() + * + * Put a reference on the &struct sfp_bus and free the underlying structure + * if this was the last reference. diff --git a/target/linux/generic/backport-4.19/719-v5.5-net-sfp-fix-sfp_bus_add_upstream-warning.patch b/target/linux/generic/backport-4.19/719-v5.5-net-sfp-fix-sfp_bus_add_upstream-warning.patch new file mode 100644 index 000000000..9528049e1 --- /dev/null +++ b/target/linux/generic/backport-4.19/719-v5.5-net-sfp-fix-sfp_bus_add_upstream-warning.patch @@ -0,0 +1,27 @@ +From f76d84cd85f8bd3f083495f7ca723822cba8abc9 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Mon, 11 Nov 2019 10:23:35 +0000 +Subject: [PATCH 617/660] net: sfp: fix sfp_bus_add_upstream() warning + +When building with SFP disabled, the stub for sfp_bus_add_upstream() +missed "inline". Add it. + +Fixes: 727b3668b730 ("net: sfp: rework upstream interface") +Signed-off-by: Russell King +--- + include/linux/sfp.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/include/linux/sfp.h ++++ b/include/linux/sfp.h +@@ -563,8 +563,8 @@ static inline struct sfp_bus *sfp_bus_fi + return NULL; + } + +-static int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, +- const struct sfp_upstream_ops *ops) ++static inline int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, ++ const struct sfp_upstream_ops *ops) + { + return 0; + } diff --git a/target/linux/generic/backport-4.19/720-v5.5-net-sfp-move-sfp-sub-state-machines-into-separate-fu.patch b/target/linux/generic/backport-4.19/720-v5.5-net-sfp-move-sfp-sub-state-machines-into-separate-fu.patch new file mode 100644 index 000000000..2f90b0043 --- /dev/null +++ b/target/linux/generic/backport-4.19/720-v5.5-net-sfp-move-sfp-sub-state-machines-into-separate-fu.patch @@ -0,0 +1,124 @@ +From b9d6ed5cdb67533feda7f221eb06f2f9f1ff5047 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Fri, 11 Oct 2019 19:33:58 +0100 +Subject: [PATCH 618/660] net: sfp: move sfp sub-state machines into separate + functions + +Move the SFP sub-state machines out of the main state machine function, +in preparation for it doing a bit more with the device state. By doing +so, we ensure that our debug after the main state machine is always +printed. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 74 +++++++++++++++++++++++++------------------ + 1 file changed, 43 insertions(+), 31 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -1479,19 +1479,34 @@ static void sfp_sm_mod_remove(struct sfp + dev_info(sfp->dev, "module removed\n"); + } + +-static void sfp_sm_event(struct sfp *sfp, unsigned int event) ++/* This state machine tracks the netdev up/down state */ ++static void sfp_sm_device(struct sfp *sfp, unsigned int event) + { +- mutex_lock(&sfp->sm_mutex); ++ switch (sfp->sm_dev_state) { ++ default: ++ if (event == SFP_E_DEV_UP) ++ sfp->sm_dev_state = SFP_DEV_UP; ++ break; + +- dev_dbg(sfp->dev, "SM: enter %s:%s:%s event %s\n", +- mod_state_to_str(sfp->sm_mod_state), +- dev_state_to_str(sfp->sm_dev_state), +- sm_state_to_str(sfp->sm_state), +- event_to_str(event)); ++ case SFP_DEV_UP: ++ if (event == SFP_E_DEV_DOWN) { ++ /* If the module has a PHY, avoid raising TX disable ++ * as this resets the PHY. Otherwise, raise it to ++ * turn the laser off. ++ */ ++ if (!sfp->mod_phy) ++ sfp_module_tx_disable(sfp); ++ sfp->sm_dev_state = SFP_DEV_DOWN; ++ } ++ break; ++ } ++} + +- /* This state machine tracks the insert/remove state of +- * the module, and handles probing the on-board EEPROM. +- */ ++/* This state machine tracks the insert/remove state of ++ * the module, and handles probing the on-board EEPROM. ++ */ ++static void sfp_sm_module(struct sfp *sfp, unsigned int event) ++{ + switch (sfp->sm_mod_state) { + default: + if (event == SFP_E_INSERT && sfp->attached) { +@@ -1531,27 +1546,10 @@ static void sfp_sm_event(struct sfp *sfp + } + break; + } ++} + +- /* This state machine tracks the netdev up/down state */ +- switch (sfp->sm_dev_state) { +- default: +- if (event == SFP_E_DEV_UP) +- sfp->sm_dev_state = SFP_DEV_UP; +- break; +- +- case SFP_DEV_UP: +- if (event == SFP_E_DEV_DOWN) { +- /* If the module has a PHY, avoid raising TX disable +- * as this resets the PHY. Otherwise, raise it to +- * turn the laser off. +- */ +- if (!sfp->mod_phy) +- sfp_module_tx_disable(sfp); +- sfp->sm_dev_state = SFP_DEV_DOWN; +- } +- break; +- } +- ++static void sfp_sm_main(struct sfp *sfp, unsigned int event) ++{ + /* Some events are global */ + if (sfp->sm_state != SFP_S_DOWN && + (sfp->sm_mod_state != SFP_MOD_PRESENT || +@@ -1562,7 +1560,6 @@ static void sfp_sm_event(struct sfp *sfp + if (sfp->mod_phy) + sfp_sm_phy_detach(sfp); + sfp_sm_next(sfp, SFP_S_DOWN, 0); +- mutex_unlock(&sfp->sm_mutex); + return; + } + +@@ -1617,6 +1614,21 @@ static void sfp_sm_event(struct sfp *sfp + case SFP_S_TX_DISABLE: + break; + } ++} ++ ++static void sfp_sm_event(struct sfp *sfp, unsigned int event) ++{ ++ mutex_lock(&sfp->sm_mutex); ++ ++ dev_dbg(sfp->dev, "SM: enter %s:%s:%s event %s\n", ++ mod_state_to_str(sfp->sm_mod_state), ++ dev_state_to_str(sfp->sm_dev_state), ++ sm_state_to_str(sfp->sm_state), ++ event_to_str(event)); ++ ++ sfp_sm_module(sfp, event); ++ sfp_sm_device(sfp, event); ++ sfp_sm_main(sfp, event); + + dev_dbg(sfp->dev, "SM: exit %s:%s:%s\n", + mod_state_to_str(sfp->sm_mod_state), diff --git a/target/linux/generic/backport-4.19/721-v5.5-net-sfp-move-tx-disable-on-device-down-to-main-state.patch b/target/linux/generic/backport-4.19/721-v5.5-net-sfp-move-tx-disable-on-device-down-to-main-state.patch new file mode 100644 index 000000000..5b3caaf0f --- /dev/null +++ b/target/linux/generic/backport-4.19/721-v5.5-net-sfp-move-tx-disable-on-device-down-to-main-state.patch @@ -0,0 +1,41 @@ +From 7e89b737c97a9e7a81dd1584000bc136b92f12fd Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Fri, 11 Oct 2019 22:14:47 +0100 +Subject: [PATCH 619/660] net: sfp: move tx disable on device down to main + state machine + +Move the tx disable assertion on device down to the main state +machine. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 10 ++-------- + 1 file changed, 2 insertions(+), 8 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -1489,15 +1489,8 @@ static void sfp_sm_device(struct sfp *sf + break; + + case SFP_DEV_UP: +- if (event == SFP_E_DEV_DOWN) { +- /* If the module has a PHY, avoid raising TX disable +- * as this resets the PHY. Otherwise, raise it to +- * turn the laser off. +- */ +- if (!sfp->mod_phy) +- sfp_module_tx_disable(sfp); ++ if (event == SFP_E_DEV_DOWN) + sfp->sm_dev_state = SFP_DEV_DOWN; +- } + break; + } + } +@@ -1559,6 +1552,7 @@ static void sfp_sm_main(struct sfp *sfp, + sfp_sm_link_down(sfp); + if (sfp->mod_phy) + sfp_sm_phy_detach(sfp); ++ sfp_module_tx_disable(sfp); + sfp_sm_next(sfp, SFP_S_DOWN, 0); + return; + } diff --git a/target/linux/generic/backport-4.19/722-v5.5-net-sfp-rename-sfp_sm_ins_next-as-sfp_sm_mod_next.patch b/target/linux/generic/backport-4.19/722-v5.5-net-sfp-rename-sfp_sm_ins_next-as-sfp_sm_mod_next.patch new file mode 100644 index 000000000..ed84e76fd --- /dev/null +++ b/target/linux/generic/backport-4.19/722-v5.5-net-sfp-rename-sfp_sm_ins_next-as-sfp_sm_mod_next.patch @@ -0,0 +1,71 @@ +From f2a1ccfc4ad4f97c98c3cc18eb32992151ce089a Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Fri, 11 Oct 2019 22:27:21 +0100 +Subject: [PATCH 620/660] net: sfp: rename sfp_sm_ins_next() as + sfp_sm_mod_next() + +sfp_sm_ins_next() modifies the module state machine. Change it's name +to reflect this. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -1180,7 +1180,7 @@ static void sfp_sm_next(struct sfp *sfp, + sfp_sm_set_timer(sfp, timeout); + } + +-static void sfp_sm_ins_next(struct sfp *sfp, unsigned int state, ++static void sfp_sm_mod_next(struct sfp *sfp, unsigned int state, + unsigned int timeout) + { + sfp->sm_mod_state = state; +@@ -1504,22 +1504,22 @@ static void sfp_sm_module(struct sfp *sf + default: + if (event == SFP_E_INSERT && sfp->attached) { + sfp_module_tx_disable(sfp); +- sfp_sm_ins_next(sfp, SFP_MOD_PROBE, T_PROBE_INIT); ++ sfp_sm_mod_next(sfp, SFP_MOD_PROBE, T_PROBE_INIT); + } + break; + + case SFP_MOD_PROBE: + if (event == SFP_E_REMOVE) { +- sfp_sm_ins_next(sfp, SFP_MOD_EMPTY, 0); ++ sfp_sm_mod_next(sfp, SFP_MOD_EMPTY, 0); + } else if (event == SFP_E_TIMEOUT) { + int val = sfp_sm_mod_probe(sfp); + + if (val == 0) +- sfp_sm_ins_next(sfp, SFP_MOD_PRESENT, 0); ++ sfp_sm_mod_next(sfp, SFP_MOD_PRESENT, 0); + else if (val > 0) +- sfp_sm_ins_next(sfp, SFP_MOD_HPOWER, val); ++ sfp_sm_mod_next(sfp, SFP_MOD_HPOWER, val); + else if (val != -EAGAIN) +- sfp_sm_ins_next(sfp, SFP_MOD_ERROR, 0); ++ sfp_sm_mod_next(sfp, SFP_MOD_ERROR, 0); + else + sfp_sm_set_timer(sfp, T_PROBE_RETRY); + } +@@ -1527,7 +1527,7 @@ static void sfp_sm_module(struct sfp *sf + + case SFP_MOD_HPOWER: + if (event == SFP_E_TIMEOUT) { +- sfp_sm_ins_next(sfp, SFP_MOD_PRESENT, 0); ++ sfp_sm_mod_next(sfp, SFP_MOD_PRESENT, 0); + break; + } + /* fallthrough */ +@@ -1535,7 +1535,7 @@ static void sfp_sm_module(struct sfp *sf + case SFP_MOD_ERROR: + if (event == SFP_E_REMOVE) { + sfp_sm_mod_remove(sfp); +- sfp_sm_ins_next(sfp, SFP_MOD_EMPTY, 0); ++ sfp_sm_mod_next(sfp, SFP_MOD_EMPTY, 0); + } + break; + } diff --git a/target/linux/generic/backport-4.19/723-v5.5-net-sfp-handle-module-remove-outside-state-machine.patch b/target/linux/generic/backport-4.19/723-v5.5-net-sfp-handle-module-remove-outside-state-machine.patch new file mode 100644 index 000000000..542aeaea7 --- /dev/null +++ b/target/linux/generic/backport-4.19/723-v5.5-net-sfp-handle-module-remove-outside-state-machine.patch @@ -0,0 +1,53 @@ +From d2591ea5520e2ee8fa557f96bb64c23cafac4b20 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 15 Oct 2019 10:33:13 +0100 +Subject: [PATCH 621/660] net: sfp: handle module remove outside state machine + +Removing a module resets the module state machine back to its initial +state. Rather than explicitly handling this in every state, handle it +early on outside of the state machine. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 16 +++++++++------- + 1 file changed, 9 insertions(+), 7 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -1500,6 +1500,14 @@ static void sfp_sm_device(struct sfp *sf + */ + static void sfp_sm_module(struct sfp *sfp, unsigned int event) + { ++ /* Handle remove event globally, it resets this state machine */ ++ if (event == SFP_E_REMOVE) { ++ if (sfp->sm_mod_state > SFP_MOD_PROBE) ++ sfp_sm_mod_remove(sfp); ++ sfp_sm_mod_next(sfp, SFP_MOD_EMPTY, 0); ++ return; ++ } ++ + switch (sfp->sm_mod_state) { + default: + if (event == SFP_E_INSERT && sfp->attached) { +@@ -1509,9 +1517,7 @@ static void sfp_sm_module(struct sfp *sf + break; + + case SFP_MOD_PROBE: +- if (event == SFP_E_REMOVE) { +- sfp_sm_mod_next(sfp, SFP_MOD_EMPTY, 0); +- } else if (event == SFP_E_TIMEOUT) { ++ if (event == SFP_E_TIMEOUT) { + int val = sfp_sm_mod_probe(sfp); + + if (val == 0) +@@ -1533,10 +1539,6 @@ static void sfp_sm_module(struct sfp *sf + /* fallthrough */ + case SFP_MOD_PRESENT: + case SFP_MOD_ERROR: +- if (event == SFP_E_REMOVE) { +- sfp_sm_mod_remove(sfp); +- sfp_sm_mod_next(sfp, SFP_MOD_EMPTY, 0); +- } + break; + } + } diff --git a/target/linux/generic/backport-4.19/724-v5.5-net-sfp-rename-T_PROBE_WAIT-to-T_SERIAL.patch b/target/linux/generic/backport-4.19/724-v5.5-net-sfp-rename-T_PROBE_WAIT-to-T_SERIAL.patch new file mode 100644 index 000000000..e0c35feea --- /dev/null +++ b/target/linux/generic/backport-4.19/724-v5.5-net-sfp-rename-T_PROBE_WAIT-to-T_SERIAL.patch @@ -0,0 +1,51 @@ +From 615090acb3c0b41691f3a03522ea38350387c0e4 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 15 Oct 2019 10:54:15 +0100 +Subject: [PATCH 622/660] net: sfp: rename T_PROBE_WAIT to T_SERIAL + +SFF-8472 rev 12.2 defines the time for the serial bus to become ready +using t_serial. Use this as our identifier for this timeout to make +it clear what we are referring to. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 13 ++++++------- + 1 file changed, 6 insertions(+), 7 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -147,11 +147,10 @@ static const enum gpiod_flags gpio_flags + * the same length on the PCB, which means it's possible for MOD DEF 0 to + * connect before the I2C bus on MOD DEF 1/2. + * +- * The SFP MSA specifies 300ms as t_init (the time taken for TX_FAULT to +- * be deasserted) but makes no mention of the earliest time before we can +- * access the I2C EEPROM. However, Avago modules require 300ms. ++ * The SFF-8472 specifies t_serial ("Time from power on until module is ++ * ready for data transmission over the two wire serial bus.") as 300ms. + */ +-#define T_PROBE_INIT msecs_to_jiffies(300) ++#define T_SERIAL msecs_to_jiffies(300) + #define T_HPOWER_LEVEL msecs_to_jiffies(300) + #define T_PROBE_RETRY msecs_to_jiffies(100) + +@@ -1495,8 +1494,8 @@ static void sfp_sm_device(struct sfp *sf + } + } + +-/* This state machine tracks the insert/remove state of +- * the module, and handles probing the on-board EEPROM. ++/* This state machine tracks the insert/remove state of the module, probes ++ * the on-board EEPROM, and sets up the power level. + */ + static void sfp_sm_module(struct sfp *sfp, unsigned int event) + { +@@ -1512,7 +1511,7 @@ static void sfp_sm_module(struct sfp *sf + default: + if (event == SFP_E_INSERT && sfp->attached) { + sfp_module_tx_disable(sfp); +- sfp_sm_mod_next(sfp, SFP_MOD_PROBE, T_PROBE_INIT); ++ sfp_sm_mod_next(sfp, SFP_MOD_PROBE, T_SERIAL); + } + break; + diff --git a/target/linux/generic/backport-4.19/725-v5.5-net-sfp-parse-SFP-power-requirement-earlier.patch b/target/linux/generic/backport-4.19/725-v5.5-net-sfp-parse-SFP-power-requirement-earlier.patch new file mode 100644 index 000000000..0b358f86d --- /dev/null +++ b/target/linux/generic/backport-4.19/725-v5.5-net-sfp-parse-SFP-power-requirement-earlier.patch @@ -0,0 +1,115 @@ +From d4b8746219e8c0361e5ed6e440ab3a8a600d1f76 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Fri, 11 Oct 2019 17:24:40 +0100 +Subject: [PATCH 623/660] net: sfp: parse SFP power requirement earlier + +Parse the SFP power requirement earlier, in preparation for moving the +power level setup code. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 42 +++++++++++++++++++++++++++++------------- + 1 file changed, 29 insertions(+), 13 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -196,6 +196,8 @@ struct sfp { + unsigned int sm_retries; + + struct sfp_eeprom_id id; ++ unsigned int module_power_mW; ++ + #if IS_ENABLED(CONFIG_HWMON) + struct sfp_diag diag; + struct device *hwmon_dev; +@@ -1309,17 +1311,14 @@ static void sfp_sm_mod_init(struct sfp * + sfp_sm_probe_phy(sfp); + } + +-static int sfp_sm_mod_hpower(struct sfp *sfp) ++static int sfp_module_parse_power(struct sfp *sfp) + { +- u32 power; +- u8 val; +- int err; ++ u32 power_mW = 1000; + +- power = 1000; + if (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_POWER_DECL)) +- power = 1500; ++ power_mW = 1500; + if (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_HIGH_POWER_LEVEL)) +- power = 2000; ++ power_mW = 2000; + + if (sfp->id.ext.sff8472_compliance == SFP_SFF8472_COMPLIANCE_NONE && + (sfp->id.ext.diagmon & (SFP_DIAGMON_DDM | SFP_DIAGMON_ADDRMODE)) != +@@ -1328,23 +1327,33 @@ static int sfp_sm_mod_hpower(struct sfp + * or requires an address change sequence, so assume that + * the module powers up in the indicated power mode. + */ +- if (power > sfp->max_power_mW) { ++ if (power_mW > sfp->max_power_mW) { + dev_err(sfp->dev, + "Host does not support %u.%uW modules\n", +- power / 1000, (power / 100) % 10); ++ power_mW / 1000, (power_mW / 100) % 10); + return -EINVAL; + } + return 0; + } + +- if (power > sfp->max_power_mW) { ++ if (power_mW > sfp->max_power_mW) { + dev_warn(sfp->dev, + "Host does not support %u.%uW modules, module left in power mode 1\n", +- power / 1000, (power / 100) % 10); ++ power_mW / 1000, (power_mW / 100) % 10); + return 0; + } + +- if (power <= 1000) ++ sfp->module_power_mW = power_mW; ++ ++ return 0; ++} ++ ++static int sfp_sm_mod_hpower(struct sfp *sfp) ++{ ++ u8 val; ++ int err; ++ ++ if (sfp->module_power_mW <= 1000) + return 0; + + err = sfp_read(sfp, true, SFP_EXT_STATUS, &val, sizeof(val)); +@@ -1364,7 +1373,8 @@ static int sfp_sm_mod_hpower(struct sfp + } + + dev_info(sfp->dev, "Module switched to %u.%uW power level\n", +- power / 1000, (power / 100) % 10); ++ sfp->module_power_mW / 1000, ++ (sfp->module_power_mW / 100) % 10); + return T_HPOWER_LEVEL; + + err: +@@ -1451,6 +1461,11 @@ static int sfp_sm_mod_probe(struct sfp * + dev_warn(sfp->dev, + "module address swap to access page 0xA2 is not supported.\n"); + ++ /* Parse the module power requirement */ ++ ret = sfp_module_parse_power(sfp); ++ if (ret < 0) ++ return ret; ++ + ret = sfp_hwmon_insert(sfp); + if (ret < 0) + return ret; +@@ -1474,6 +1489,7 @@ static void sfp_sm_mod_remove(struct sfp + sfp_module_tx_disable(sfp); + + memset(&sfp->id, 0, sizeof(sfp->id)); ++ sfp->module_power_mW = 0; + + dev_info(sfp->dev, "module removed\n"); + } diff --git a/target/linux/generic/backport-4.19/726-v5.5-net-sfp-avoid-power-switch-on-address-change-modules.patch b/target/linux/generic/backport-4.19/726-v5.5-net-sfp-avoid-power-switch-on-address-change-modules.patch new file mode 100644 index 000000000..2ddd4c4d0 --- /dev/null +++ b/target/linux/generic/backport-4.19/726-v5.5-net-sfp-avoid-power-switch-on-address-change-modules.patch @@ -0,0 +1,65 @@ +From dca678b8838945572cf50584cb33a7199c1fd397 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Thu, 17 Oct 2019 00:24:18 +0100 +Subject: [PATCH 624/660] net: sfp: avoid power switch on address-change + modules + +If the module indicates that it requires an address change sequence to +switch between address 0x50 and 0x51, which we don't support, we can't +write to the register that controls the power mode to switch to high +power mode. Warn the user that the module may not be functional in +this case, and don't try to change the power mode. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 31 ++++++++++++++++++++----------- + 1 file changed, 20 insertions(+), 11 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -1320,25 +1320,34 @@ static int sfp_module_parse_power(struct + if (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_HIGH_POWER_LEVEL)) + power_mW = 2000; + +- if (sfp->id.ext.sff8472_compliance == SFP_SFF8472_COMPLIANCE_NONE && +- (sfp->id.ext.diagmon & (SFP_DIAGMON_DDM | SFP_DIAGMON_ADDRMODE)) != +- SFP_DIAGMON_DDM) { +- /* The module appears not to implement bus address 0xa2, +- * or requires an address change sequence, so assume that +- * the module powers up in the indicated power mode. +- */ +- if (power_mW > sfp->max_power_mW) { ++ if (power_mW > sfp->max_power_mW) { ++ /* Module power specification exceeds the allowed maximum. */ ++ if (sfp->id.ext.sff8472_compliance == ++ SFP_SFF8472_COMPLIANCE_NONE && ++ !(sfp->id.ext.diagmon & SFP_DIAGMON_DDM)) { ++ /* The module appears not to implement bus address ++ * 0xa2, so assume that the module powers up in the ++ * indicated mode. ++ */ + dev_err(sfp->dev, + "Host does not support %u.%uW modules\n", + power_mW / 1000, (power_mW / 100) % 10); + return -EINVAL; ++ } else { ++ dev_warn(sfp->dev, ++ "Host does not support %u.%uW modules, module left in power mode 1\n", ++ power_mW / 1000, (power_mW / 100) % 10); ++ return 0; + } +- return 0; + } + +- if (power_mW > sfp->max_power_mW) { ++ /* If the module requires a higher power mode, but also requires ++ * an address change sequence, warn the user that the module may ++ * not be functional. ++ */ ++ if (sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE && power_mW > 1000) { + dev_warn(sfp->dev, +- "Host does not support %u.%uW modules, module left in power mode 1\n", ++ "Address Change Sequence not supported but module requies %u.%uW, module may not be functional\n", + power_mW / 1000, (power_mW / 100) % 10); + return 0; + } diff --git a/target/linux/generic/backport-4.19/727-v5.5-net-sfp-control-TX_DISABLE-and-phy-only-from-main-st.patch b/target/linux/generic/backport-4.19/727-v5.5-net-sfp-control-TX_DISABLE-and-phy-only-from-main-st.patch new file mode 100644 index 000000000..0eac6abb8 --- /dev/null +++ b/target/linux/generic/backport-4.19/727-v5.5-net-sfp-control-TX_DISABLE-and-phy-only-from-main-st.patch @@ -0,0 +1,52 @@ +From df5c4d93c5a59cba0f7479a4cd4e22b50726ce88 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Thu, 17 Oct 2019 11:12:42 +0100 +Subject: [PATCH 625/660] net: sfp: control TX_DISABLE and phy only from main + state machine + +We initialise TX_DISABLE when the sfp cage is probed, and then +maintain its state in the main state machine. However, the module +state machine: +- negates it when detecting a newly inserted module when it's already + guaranteed to be negated. +- negates it when the module is removed, but the main state machine + will do this anyway. + +Make TX_DISABLE entirely controlled by the main state machine. + +The main state machine also probes the module for a PHY, and removes +the PHY when the the module is removed. Hence, removing the PHY in +sfp_sm_module_remove() is also redundant, and is a left-over from +when we tried to probe for the PHY from the module state machine. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 9 +-------- + 1 file changed, 1 insertion(+), 8 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -1492,11 +1492,6 @@ static void sfp_sm_mod_remove(struct sfp + + sfp_hwmon_remove(sfp); + +- if (sfp->mod_phy) +- sfp_sm_phy_detach(sfp); +- +- sfp_module_tx_disable(sfp); +- + memset(&sfp->id, 0, sizeof(sfp->id)); + sfp->module_power_mW = 0; + +@@ -1534,10 +1529,8 @@ static void sfp_sm_module(struct sfp *sf + + switch (sfp->sm_mod_state) { + default: +- if (event == SFP_E_INSERT && sfp->attached) { +- sfp_module_tx_disable(sfp); ++ if (event == SFP_E_INSERT && sfp->attached) + sfp_sm_mod_next(sfp, SFP_MOD_PROBE, T_SERIAL); +- } + break; + + case SFP_MOD_PROBE: diff --git a/target/linux/generic/backport-4.19/728-v5.5-net-sfp-split-the-PHY-probe-from-sfp_sm_mod_init.patch b/target/linux/generic/backport-4.19/728-v5.5-net-sfp-split-the-PHY-probe-from-sfp_sm_mod_init.patch new file mode 100644 index 000000000..7830b9268 --- /dev/null +++ b/target/linux/generic/backport-4.19/728-v5.5-net-sfp-split-the-PHY-probe-from-sfp_sm_mod_init.patch @@ -0,0 +1,53 @@ +From 5ed0bd49b2d3ac4439c2d7f44e5a82b7cf6f409a Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Fri, 18 Oct 2019 10:09:02 +0100 +Subject: [PATCH 626/660] net: sfp: split the PHY probe from sfp_sm_mod_init() + +Move the PHY probe into a separate function, splitting it from +sfp_sm_mod_init(). This will allow us to eliminate the 50ms mdelay() +inside the state machine. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 21 +++++++++++++-------- + 1 file changed, 13 insertions(+), 8 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -1288,14 +1288,10 @@ static void sfp_sm_fault(struct sfp *sfp + static void sfp_sm_mod_init(struct sfp *sfp) + { + sfp_module_tx_enable(sfp); ++} + +- /* Wait t_init before indicating that the link is up, provided the +- * current state indicates no TX_FAULT. If TX_FAULT clears before +- * this time, that's fine too. +- */ +- sfp_sm_next(sfp, SFP_S_INIT, T_INIT_JIFFIES); +- sfp->sm_retries = 5; +- ++static void sfp_sm_probe_for_phy(struct sfp *sfp) ++{ + /* Setting the serdes link mode is guesswork: there's no + * field in the EEPROM which indicates what mode should + * be used. +@@ -1580,8 +1576,17 @@ static void sfp_sm_main(struct sfp *sfp, + switch (sfp->sm_state) { + case SFP_S_DOWN: + if (sfp->sm_mod_state == SFP_MOD_PRESENT && +- sfp->sm_dev_state == SFP_DEV_UP) ++ sfp->sm_dev_state == SFP_DEV_UP) { + sfp_sm_mod_init(sfp); ++ sfp_sm_probe_for_phy(sfp); ++ ++ /* Wait t_init before indicating that the link is up, ++ * provided the current state indicates no TX_FAULT. If ++ * TX_FAULT clears before this time, that's fine too. ++ */ ++ sfp_sm_next(sfp, SFP_S_INIT, T_INIT_JIFFIES); ++ sfp->sm_retries = 5; ++ } + break; + + case SFP_S_INIT: diff --git a/target/linux/generic/backport-4.19/729-v5.5-net-sfp-eliminate-mdelay-from-PHY-probe.patch b/target/linux/generic/backport-4.19/729-v5.5-net-sfp-eliminate-mdelay-from-PHY-probe.patch new file mode 100644 index 000000000..5dc92bd10 --- /dev/null +++ b/target/linux/generic/backport-4.19/729-v5.5-net-sfp-eliminate-mdelay-from-PHY-probe.patch @@ -0,0 +1,130 @@ +From 0fe72afaa31f98ebd71bd6683fc47021105d0157 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Fri, 18 Oct 2019 10:21:46 +0100 +Subject: [PATCH 627/660] net: sfp: eliminate mdelay() from PHY probe + +Rather than using mdelay() to wait before probing the PHY (which holds +several locks, including the rtnl lock), add an extra wait state to +the state machine to introduce the 50ms delay without holding any +locks. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 52 +++++++++++++++++++++++++++++++++---------- + 1 file changed, 40 insertions(+), 12 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -52,6 +52,7 @@ enum { + SFP_DEV_UP, + + SFP_S_DOWN = 0, ++ SFP_S_WAIT, + SFP_S_INIT, + SFP_S_WAIT_LOS, + SFP_S_LINK_UP, +@@ -108,6 +109,7 @@ static const char *event_to_str(unsigned + + static const char * const sm_state_strings[] = { + [SFP_S_DOWN] = "down", ++ [SFP_S_WAIT] = "wait", + [SFP_S_INIT] = "init", + [SFP_S_WAIT_LOS] = "wait_los", + [SFP_S_LINK_UP] = "link_up", +@@ -139,6 +141,7 @@ static const enum gpiod_flags gpio_flags + GPIOD_ASIS, + }; + ++#define T_WAIT msecs_to_jiffies(50) + #define T_INIT_JIFFIES msecs_to_jiffies(300) + #define T_RESET_US 10 + #define T_FAULT_RECOVER msecs_to_jiffies(1000) +@@ -159,9 +162,6 @@ static const enum gpiod_flags gpio_flags + */ + #define SFP_PHY_ADDR 22 + +-/* Give this long for the PHY to reset. */ +-#define T_PHY_RESET_MS 50 +- + struct sff_data { + unsigned int gpios; + bool (*module_supported)(const struct sfp_eeprom_id *id); +@@ -1202,8 +1202,6 @@ static void sfp_sm_probe_phy(struct sfp + struct phy_device *phy; + int err; + +- msleep(T_PHY_RESET_MS); +- + phy = mdiobus_scan(sfp->i2c_mii, SFP_PHY_ADDR); + if (phy == ERR_PTR(-ENODEV)) { + dev_info(sfp->dev, "no PHY detected\n"); +@@ -1558,6 +1556,8 @@ static void sfp_sm_module(struct sfp *sf + + static void sfp_sm_main(struct sfp *sfp, unsigned int event) + { ++ unsigned long timeout; ++ + /* Some events are global */ + if (sfp->sm_state != SFP_S_DOWN && + (sfp->sm_mod_state != SFP_MOD_PRESENT || +@@ -1575,17 +1575,45 @@ static void sfp_sm_main(struct sfp *sfp, + /* The main state machine */ + switch (sfp->sm_state) { + case SFP_S_DOWN: +- if (sfp->sm_mod_state == SFP_MOD_PRESENT && +- sfp->sm_dev_state == SFP_DEV_UP) { +- sfp_sm_mod_init(sfp); +- sfp_sm_probe_for_phy(sfp); ++ if (sfp->sm_mod_state != SFP_MOD_PRESENT || ++ sfp->sm_dev_state != SFP_DEV_UP) ++ break; ++ ++ sfp_sm_mod_init(sfp); ++ ++ /* Initialise the fault clearance retries */ ++ sfp->sm_retries = 5; ++ ++ /* We need to check the TX_FAULT state, which is not defined ++ * while TX_DISABLE is asserted. The earliest we want to do ++ * anything (such as probe for a PHY) is 50ms. ++ */ ++ sfp_sm_next(sfp, SFP_S_WAIT, T_WAIT); ++ break; ++ ++ case SFP_S_WAIT: ++ if (event != SFP_E_TIMEOUT) ++ break; ++ ++ sfp_sm_probe_for_phy(sfp); + ++ if (sfp->state & SFP_F_TX_FAULT) { + /* Wait t_init before indicating that the link is up, + * provided the current state indicates no TX_FAULT. If + * TX_FAULT clears before this time, that's fine too. + */ +- sfp_sm_next(sfp, SFP_S_INIT, T_INIT_JIFFIES); +- sfp->sm_retries = 5; ++ timeout = T_INIT_JIFFIES; ++ if (timeout > T_WAIT) ++ timeout -= T_WAIT; ++ else ++ timeout = 1; ++ ++ sfp_sm_next(sfp, SFP_S_INIT, timeout); ++ } else { ++ /* TX_FAULT is not asserted, assume the module has ++ * finished initialising. ++ */ ++ goto init_done; + } + break; + +@@ -1593,7 +1621,7 @@ static void sfp_sm_main(struct sfp *sfp, + if (event == SFP_E_TIMEOUT && sfp->state & SFP_F_TX_FAULT) + sfp_sm_fault(sfp, true); + else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) +- sfp_sm_link_check_los(sfp); ++ init_done: sfp_sm_link_check_los(sfp); + break; + + case SFP_S_WAIT_LOS: diff --git a/target/linux/generic/backport-4.19/730-v5.5-net-sfp-allow-fault-processing-to-transition-to-othe.patch b/target/linux/generic/backport-4.19/730-v5.5-net-sfp-allow-fault-processing-to-transition-to-othe.patch new file mode 100644 index 000000000..6e34e6cc0 --- /dev/null +++ b/target/linux/generic/backport-4.19/730-v5.5-net-sfp-allow-fault-processing-to-transition-to-othe.patch @@ -0,0 +1,69 @@ +From 2aa424ee7fbe43e2cd24e28c2f6388c4e1796bd2 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Fri, 18 Oct 2019 09:58:33 +0100 +Subject: [PATCH 628/660] net: sfp: allow fault processing to transition to + other states + +Add the next state to sfp_sm_fault() so that it can branch to other +states. This will be necessary to improve the initialisation path. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -1269,7 +1269,7 @@ static bool sfp_los_event_inactive(struc + event == SFP_E_LOS_LOW); + } + +-static void sfp_sm_fault(struct sfp *sfp, bool warn) ++static void sfp_sm_fault(struct sfp *sfp, unsigned int next_state, bool warn) + { + if (sfp->sm_retries && !--sfp->sm_retries) { + dev_err(sfp->dev, +@@ -1279,7 +1279,7 @@ static void sfp_sm_fault(struct sfp *sfp + if (warn) + dev_err(sfp->dev, "module transmit fault indicated\n"); + +- sfp_sm_next(sfp, SFP_S_TX_FAULT, T_FAULT_RECOVER); ++ sfp_sm_next(sfp, next_state, T_FAULT_RECOVER); + } + } + +@@ -1619,14 +1619,14 @@ static void sfp_sm_main(struct sfp *sfp, + + case SFP_S_INIT: + if (event == SFP_E_TIMEOUT && sfp->state & SFP_F_TX_FAULT) +- sfp_sm_fault(sfp, true); ++ sfp_sm_fault(sfp, SFP_S_TX_FAULT, true); + else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) + init_done: sfp_sm_link_check_los(sfp); + break; + + case SFP_S_WAIT_LOS: + if (event == SFP_E_TX_FAULT) +- sfp_sm_fault(sfp, true); ++ sfp_sm_fault(sfp, SFP_S_TX_FAULT, true); + else if (sfp_los_event_inactive(sfp, event)) + sfp_sm_link_up(sfp); + break; +@@ -1634,7 +1634,7 @@ static void sfp_sm_main(struct sfp *sfp, + case SFP_S_LINK_UP: + if (event == SFP_E_TX_FAULT) { + sfp_sm_link_down(sfp); +- sfp_sm_fault(sfp, true); ++ sfp_sm_fault(sfp, SFP_S_TX_FAULT, true); + } else if (sfp_los_event_active(sfp, event)) { + sfp_sm_link_down(sfp); + sfp_sm_next(sfp, SFP_S_WAIT_LOS, 0); +@@ -1650,7 +1650,7 @@ static void sfp_sm_main(struct sfp *sfp, + + case SFP_S_REINIT: + if (event == SFP_E_TIMEOUT && sfp->state & SFP_F_TX_FAULT) { +- sfp_sm_fault(sfp, false); ++ sfp_sm_fault(sfp, SFP_S_TX_FAULT, false); + } else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) { + dev_info(sfp->dev, "module transmit fault recovered\n"); + sfp_sm_link_check_los(sfp); diff --git a/target/linux/generic/backport-4.19/731-v5.5-net-sfp-ensure-TX_FAULT-has-deasserted-before-probin.patch b/target/linux/generic/backport-4.19/731-v5.5-net-sfp-ensure-TX_FAULT-has-deasserted-before-probin.patch new file mode 100644 index 000000000..03415fb6e --- /dev/null +++ b/target/linux/generic/backport-4.19/731-v5.5-net-sfp-ensure-TX_FAULT-has-deasserted-before-probin.patch @@ -0,0 +1,80 @@ +From 38b62a12231be4b86fc5ca5477579d29831c02a5 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Fri, 18 Oct 2019 10:31:07 +0100 +Subject: [PATCH 629/660] net: sfp: ensure TX_FAULT has deasserted before + probing the PHY + +TX_FAULT should be deasserted to indicate that the module has completed +its initialisation. This may include the on-board PHY, so wait until +the module has deasserted TX_FAULT before probing the PHY. + +This means that we need an extra state to handle a TX_FAULT that +remains set for longer than t_init, since using the existing handling +state would bypass the PHY probe. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 31 +++++++++++++++++++++++++------ + 1 file changed, 25 insertions(+), 6 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -54,6 +54,7 @@ enum { + SFP_S_DOWN = 0, + SFP_S_WAIT, + SFP_S_INIT, ++ SFP_S_INIT_TX_FAULT, + SFP_S_WAIT_LOS, + SFP_S_LINK_UP, + SFP_S_TX_FAULT, +@@ -111,6 +112,7 @@ static const char * const sm_state_strin + [SFP_S_DOWN] = "down", + [SFP_S_WAIT] = "wait", + [SFP_S_INIT] = "init", ++ [SFP_S_INIT_TX_FAULT] = "init_tx_fault", + [SFP_S_WAIT_LOS] = "wait_los", + [SFP_S_LINK_UP] = "link_up", + [SFP_S_TX_FAULT] = "tx_fault", +@@ -1595,8 +1597,6 @@ static void sfp_sm_main(struct sfp *sfp, + if (event != SFP_E_TIMEOUT) + break; + +- sfp_sm_probe_for_phy(sfp); +- + if (sfp->state & SFP_F_TX_FAULT) { + /* Wait t_init before indicating that the link is up, + * provided the current state indicates no TX_FAULT. If +@@ -1618,10 +1618,29 @@ static void sfp_sm_main(struct sfp *sfp, + break; + + case SFP_S_INIT: +- if (event == SFP_E_TIMEOUT && sfp->state & SFP_F_TX_FAULT) +- sfp_sm_fault(sfp, SFP_S_TX_FAULT, true); +- else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) +- init_done: sfp_sm_link_check_los(sfp); ++ if (event == SFP_E_TIMEOUT && sfp->state & SFP_F_TX_FAULT) { ++ /* TX_FAULT is still asserted after t_init, so assume ++ * there is a fault. ++ */ ++ sfp_sm_fault(sfp, SFP_S_INIT_TX_FAULT, ++ sfp->sm_retries == 5); ++ } else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) { ++ init_done: /* TX_FAULT deasserted or we timed out with TX_FAULT ++ * clear. Probe for the PHY and check the LOS state. ++ */ ++ sfp_sm_probe_for_phy(sfp); ++ sfp_sm_link_check_los(sfp); ++ ++ /* Reset the fault retry count */ ++ sfp->sm_retries = 5; ++ } ++ break; ++ ++ case SFP_S_INIT_TX_FAULT: ++ if (event == SFP_E_TIMEOUT) { ++ sfp_module_tx_fault_reset(sfp); ++ sfp_sm_next(sfp, SFP_S_INIT, T_INIT_JIFFIES); ++ } + break; + + case SFP_S_WAIT_LOS: diff --git a/target/linux/generic/backport-4.19/732-v5.5-net-sfp-track-upstream-s-attachment-state-in-state-m.patch b/target/linux/generic/backport-4.19/732-v5.5-net-sfp-track-upstream-s-attachment-state-in-state-m.patch new file mode 100644 index 000000000..5ee44dbf0 --- /dev/null +++ b/target/linux/generic/backport-4.19/732-v5.5-net-sfp-track-upstream-s-attachment-state-in-state-m.patch @@ -0,0 +1,153 @@ +From ec6036a58f979c66bbd5cd9d0d1c783a98c2c644 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 5 Nov 2019 12:57:40 +0000 +Subject: [PATCH 630/660] net: sfp: track upstream's attachment state in state + machine + +Track the upstream's attachment state in the state machine rather than +maintaining a boolean, which ensures that we have a strict order of +ATTACH followed by an UP event - we can never believe that a newly +attached upstream will be anything but down. + +Rearrange the order of state machines so we run the module state +machine after the upstream device's state machine, so the module state +machine can check the current state of the device and take action to +e.g. reset back to empty state when the upstream is detached. + +This is to allow the module detection to run independently of the +network device becoming available. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 42 +++++++++++++++++++++++++++++------------- + 1 file changed, 29 insertions(+), 13 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -34,6 +34,8 @@ enum { + + SFP_E_INSERT = 0, + SFP_E_REMOVE, ++ SFP_E_DEV_ATTACH, ++ SFP_E_DEV_DETACH, + SFP_E_DEV_DOWN, + SFP_E_DEV_UP, + SFP_E_TX_FAULT, +@@ -48,7 +50,8 @@ enum { + SFP_MOD_PRESENT, + SFP_MOD_ERROR, + +- SFP_DEV_DOWN = 0, ++ SFP_DEV_DETACHED = 0, ++ SFP_DEV_DOWN, + SFP_DEV_UP, + + SFP_S_DOWN = 0, +@@ -78,6 +81,7 @@ static const char *mod_state_to_str(unsi + } + + static const char * const dev_state_strings[] = { ++ [SFP_DEV_DETACHED] = "detached", + [SFP_DEV_DOWN] = "down", + [SFP_DEV_UP] = "up", + }; +@@ -92,6 +96,8 @@ static const char *dev_state_to_str(unsi + static const char * const event_strings[] = { + [SFP_E_INSERT] = "insert", + [SFP_E_REMOVE] = "remove", ++ [SFP_E_DEV_ATTACH] = "dev_attach", ++ [SFP_E_DEV_DETACH] = "dev_detach", + [SFP_E_DEV_DOWN] = "dev_down", + [SFP_E_DEV_UP] = "dev_up", + [SFP_E_TX_FAULT] = "tx_fault", +@@ -186,7 +192,6 @@ struct sfp { + struct gpio_desc *gpio[GPIO_MAX]; + int gpio_irq[GPIO_MAX]; + +- bool attached; + struct mutex st_mutex; /* Protects state */ + unsigned int state; + struct delayed_work poll; +@@ -1494,17 +1499,26 @@ static void sfp_sm_mod_remove(struct sfp + dev_info(sfp->dev, "module removed\n"); + } + +-/* This state machine tracks the netdev up/down state */ ++/* This state machine tracks the upstream's state */ + static void sfp_sm_device(struct sfp *sfp, unsigned int event) + { + switch (sfp->sm_dev_state) { + default: +- if (event == SFP_E_DEV_UP) ++ if (event == SFP_E_DEV_ATTACH) ++ sfp->sm_dev_state = SFP_DEV_DOWN; ++ break; ++ ++ case SFP_DEV_DOWN: ++ if (event == SFP_E_DEV_DETACH) ++ sfp->sm_dev_state = SFP_DEV_DETACHED; ++ else if (event == SFP_E_DEV_UP) + sfp->sm_dev_state = SFP_DEV_UP; + break; + + case SFP_DEV_UP: +- if (event == SFP_E_DEV_DOWN) ++ if (event == SFP_E_DEV_DETACH) ++ sfp->sm_dev_state = SFP_DEV_DETACHED; ++ else if (event == SFP_E_DEV_DOWN) + sfp->sm_dev_state = SFP_DEV_DOWN; + break; + } +@@ -1515,17 +1529,20 @@ static void sfp_sm_device(struct sfp *sf + */ + static void sfp_sm_module(struct sfp *sfp, unsigned int event) + { +- /* Handle remove event globally, it resets this state machine */ +- if (event == SFP_E_REMOVE) { ++ /* Handle remove event globally, it resets this state machine. ++ * Also deal with upstream detachment. ++ */ ++ if (event == SFP_E_REMOVE || sfp->sm_dev_state < SFP_DEV_DOWN) { + if (sfp->sm_mod_state > SFP_MOD_PROBE) + sfp_sm_mod_remove(sfp); +- sfp_sm_mod_next(sfp, SFP_MOD_EMPTY, 0); ++ if (sfp->sm_mod_state != SFP_MOD_EMPTY) ++ sfp_sm_mod_next(sfp, SFP_MOD_EMPTY, 0); + return; + } + + switch (sfp->sm_mod_state) { + default: +- if (event == SFP_E_INSERT && sfp->attached) ++ if (event == SFP_E_INSERT) + sfp_sm_mod_next(sfp, SFP_MOD_PROBE, T_SERIAL); + break; + +@@ -1691,8 +1708,8 @@ static void sfp_sm_event(struct sfp *sfp + sm_state_to_str(sfp->sm_state), + event_to_str(event)); + +- sfp_sm_module(sfp, event); + sfp_sm_device(sfp, event); ++ sfp_sm_module(sfp, event); + sfp_sm_main(sfp, event); + + dev_dbg(sfp->dev, "SM: exit %s:%s:%s\n", +@@ -1705,15 +1722,14 @@ static void sfp_sm_event(struct sfp *sfp + + static void sfp_attach(struct sfp *sfp) + { +- sfp->attached = true; ++ sfp_sm_event(sfp, SFP_E_DEV_ATTACH); + if (sfp->state & SFP_F_PRESENT) + sfp_sm_event(sfp, SFP_E_INSERT); + } + + static void sfp_detach(struct sfp *sfp) + { +- sfp->attached = false; +- sfp_sm_event(sfp, SFP_E_REMOVE); ++ sfp_sm_event(sfp, SFP_E_DEV_DETACH); + } + + static void sfp_start(struct sfp *sfp) diff --git a/target/linux/generic/backport-4.19/733-v5.5-net-sfp-split-power-mode-switching-from-probe.patch b/target/linux/generic/backport-4.19/733-v5.5-net-sfp-split-power-mode-switching-from-probe.patch new file mode 100644 index 000000000..06b3cb542 --- /dev/null +++ b/target/linux/generic/backport-4.19/733-v5.5-net-sfp-split-power-mode-switching-from-probe.patch @@ -0,0 +1,184 @@ +From fdff863a4ce3677907f64396e34c45025abb6600 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 5 Nov 2019 12:59:36 +0000 +Subject: [PATCH 631/660] net: sfp: split power mode switching from probe + +Switch the power mode switching from the probe, so that we don't +repeatedly re-probe the SFP device if there is a problem accessing +the registers at I2C address 0x51. + +In splitting this out, we can also fix a bug where we leave the module +in high-power mode when the upstream device is detached but the module +is still inserted. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 101 ++++++++++++++++++++++++++---------------- + 1 file changed, 64 insertions(+), 37 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -47,6 +47,7 @@ enum { + SFP_MOD_EMPTY = 0, + SFP_MOD_PROBE, + SFP_MOD_HPOWER, ++ SFP_MOD_WAITPWR, + SFP_MOD_PRESENT, + SFP_MOD_ERROR, + +@@ -69,6 +70,7 @@ static const char * const mod_state_str + [SFP_MOD_EMPTY] = "empty", + [SFP_MOD_PROBE] = "probe", + [SFP_MOD_HPOWER] = "hpower", ++ [SFP_MOD_WAITPWR] = "waitpwr", + [SFP_MOD_PRESENT] = "present", + [SFP_MOD_ERROR] = "error", + }; +@@ -1358,37 +1360,34 @@ static int sfp_module_parse_power(struct + return 0; + } + +-static int sfp_sm_mod_hpower(struct sfp *sfp) ++static int sfp_sm_mod_hpower(struct sfp *sfp, bool enable) + { + u8 val; + int err; + +- if (sfp->module_power_mW <= 1000) +- return 0; +- + err = sfp_read(sfp, true, SFP_EXT_STATUS, &val, sizeof(val)); + if (err != sizeof(val)) { + dev_err(sfp->dev, "Failed to read EEPROM: %d\n", err); +- err = -EAGAIN; +- goto err; ++ return -EAGAIN; + } + +- val |= BIT(0); ++ if (enable) ++ val |= BIT(0); ++ else ++ val &= ~BIT(0); + + err = sfp_write(sfp, true, SFP_EXT_STATUS, &val, sizeof(val)); + if (err != sizeof(val)) { + dev_err(sfp->dev, "Failed to write EEPROM: %d\n", err); +- err = -EAGAIN; +- goto err; ++ return -EAGAIN; + } + +- dev_info(sfp->dev, "Module switched to %u.%uW power level\n", +- sfp->module_power_mW / 1000, +- (sfp->module_power_mW / 100) % 10); +- return T_HPOWER_LEVEL; ++ if (enable) ++ dev_info(sfp->dev, "Module switched to %u.%uW power level\n", ++ sfp->module_power_mW / 1000, ++ (sfp->module_power_mW / 100) % 10); + +-err: +- return err; ++ return 0; + } + + static int sfp_sm_mod_probe(struct sfp *sfp) +@@ -1484,7 +1483,7 @@ static int sfp_sm_mod_probe(struct sfp * + if (ret < 0) + return ret; + +- return sfp_sm_mod_hpower(sfp); ++ return 0; + } + + static void sfp_sm_mod_remove(struct sfp *sfp) +@@ -1529,13 +1528,22 @@ static void sfp_sm_device(struct sfp *sf + */ + static void sfp_sm_module(struct sfp *sfp, unsigned int event) + { +- /* Handle remove event globally, it resets this state machine. +- * Also deal with upstream detachment. +- */ +- if (event == SFP_E_REMOVE || sfp->sm_dev_state < SFP_DEV_DOWN) { ++ int err; ++ ++ /* Handle remove event globally, it resets this state machine */ ++ if (event == SFP_E_REMOVE) { + if (sfp->sm_mod_state > SFP_MOD_PROBE) + sfp_sm_mod_remove(sfp); +- if (sfp->sm_mod_state != SFP_MOD_EMPTY) ++ sfp_sm_mod_next(sfp, SFP_MOD_EMPTY, 0); ++ return; ++ } ++ ++ /* Handle device detach globally */ ++ if (sfp->sm_dev_state < SFP_DEV_DOWN) { ++ if (sfp->module_power_mW > 1000 && ++ sfp->sm_mod_state > SFP_MOD_HPOWER) ++ sfp_sm_mod_hpower(sfp, false); ++ if (sfp->sm_mod_state > SFP_MOD_EMPTY) + sfp_sm_mod_next(sfp, SFP_MOD_EMPTY, 0); + return; + } +@@ -1547,26 +1555,45 @@ static void sfp_sm_module(struct sfp *sf + break; + + case SFP_MOD_PROBE: +- if (event == SFP_E_TIMEOUT) { +- int val = sfp_sm_mod_probe(sfp); ++ if (event != SFP_E_TIMEOUT) ++ break; + +- if (val == 0) +- sfp_sm_mod_next(sfp, SFP_MOD_PRESENT, 0); +- else if (val > 0) +- sfp_sm_mod_next(sfp, SFP_MOD_HPOWER, val); +- else if (val != -EAGAIN) +- sfp_sm_mod_next(sfp, SFP_MOD_ERROR, 0); +- else +- sfp_sm_set_timer(sfp, T_PROBE_RETRY); ++ err = sfp_sm_mod_probe(sfp); ++ if (err == -EAGAIN) { ++ sfp_sm_set_timer(sfp, T_PROBE_RETRY); ++ break; + } +- break; ++ if (err < 0) { ++ sfp_sm_mod_next(sfp, SFP_MOD_ERROR, 0); ++ break; ++ } ++ ++ /* If this is a power level 1 module, we are done */ ++ if (sfp->module_power_mW <= 1000) ++ goto insert; + ++ sfp_sm_mod_next(sfp, SFP_MOD_HPOWER, 0); ++ /* fall through */ + case SFP_MOD_HPOWER: +- if (event == SFP_E_TIMEOUT) { +- sfp_sm_mod_next(sfp, SFP_MOD_PRESENT, 0); ++ /* Enable high power mode */ ++ err = sfp_sm_mod_hpower(sfp, true); ++ if (err == 0) ++ sfp_sm_mod_next(sfp, SFP_MOD_WAITPWR, T_HPOWER_LEVEL); ++ else if (err != -EAGAIN) ++ sfp_sm_mod_next(sfp, SFP_MOD_ERROR, 0); ++ else ++ sfp_sm_set_timer(sfp, T_PROBE_RETRY); ++ break; ++ ++ case SFP_MOD_WAITPWR: ++ /* Wait for T_HPOWER_LEVEL to time out */ ++ if (event != SFP_E_TIMEOUT) + break; +- } +- /* fallthrough */ ++ ++ insert: ++ sfp_sm_mod_next(sfp, SFP_MOD_PRESENT, 0); ++ break; ++ + case SFP_MOD_PRESENT: + case SFP_MOD_ERROR: + break; diff --git a/target/linux/generic/backport-4.19/734-v5.5-net-sfp-move-module-insert-reporting-out-of-probe.patch b/target/linux/generic/backport-4.19/734-v5.5-net-sfp-move-module-insert-reporting-out-of-probe.patch new file mode 100644 index 000000000..26b6a6b0e --- /dev/null +++ b/target/linux/generic/backport-4.19/734-v5.5-net-sfp-move-module-insert-reporting-out-of-probe.patch @@ -0,0 +1,159 @@ +From 57cbf7453551db1df619b79410d79fc418d862d5 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 5 Nov 2019 13:00:45 +0000 +Subject: [PATCH 632/660] net: sfp: move module insert reporting out of probe + +Move the module insertion reporting out of the probe handling, but +after we have detected that the upstream has attached (since that is +whom we are reporting insertion to.) + +Only report module removal if we had previously reported a module +insertion. + +This gives cleaner semantics, and means we can probe the module before +we have an upstream attached. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 58 +++++++++++++++++++++++++++++-------------- + 1 file changed, 40 insertions(+), 18 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -45,11 +45,12 @@ enum { + SFP_E_TIMEOUT, + + SFP_MOD_EMPTY = 0, ++ SFP_MOD_ERROR, + SFP_MOD_PROBE, ++ SFP_MOD_WAITDEV, + SFP_MOD_HPOWER, + SFP_MOD_WAITPWR, + SFP_MOD_PRESENT, +- SFP_MOD_ERROR, + + SFP_DEV_DETACHED = 0, + SFP_DEV_DOWN, +@@ -68,11 +69,12 @@ enum { + + static const char * const mod_state_strings[] = { + [SFP_MOD_EMPTY] = "empty", ++ [SFP_MOD_ERROR] = "error", + [SFP_MOD_PROBE] = "probe", ++ [SFP_MOD_WAITDEV] = "waitdev", + [SFP_MOD_HPOWER] = "hpower", + [SFP_MOD_WAITPWR] = "waitpwr", + [SFP_MOD_PRESENT] = "present", +- [SFP_MOD_ERROR] = "error", + }; + + static const char *mod_state_to_str(unsigned short mod_state) +@@ -1479,16 +1481,13 @@ static int sfp_sm_mod_probe(struct sfp * + if (ret < 0) + return ret; + +- ret = sfp_module_insert(sfp->sfp_bus, &sfp->id); +- if (ret < 0) +- return ret; +- + return 0; + } + + static void sfp_sm_mod_remove(struct sfp *sfp) + { +- sfp_module_remove(sfp->sfp_bus); ++ if (sfp->sm_mod_state > SFP_MOD_WAITDEV) ++ sfp_module_remove(sfp->sfp_bus); + + sfp_hwmon_remove(sfp); + +@@ -1539,12 +1538,12 @@ static void sfp_sm_module(struct sfp *sf + } + + /* Handle device detach globally */ +- if (sfp->sm_dev_state < SFP_DEV_DOWN) { ++ if (sfp->sm_dev_state < SFP_DEV_DOWN && ++ sfp->sm_mod_state > SFP_MOD_WAITDEV) { + if (sfp->module_power_mW > 1000 && + sfp->sm_mod_state > SFP_MOD_HPOWER) + sfp_sm_mod_hpower(sfp, false); +- if (sfp->sm_mod_state > SFP_MOD_EMPTY) +- sfp_sm_mod_next(sfp, SFP_MOD_EMPTY, 0); ++ sfp_sm_mod_next(sfp, SFP_MOD_WAITDEV, 0); + return; + } + +@@ -1555,6 +1554,7 @@ static void sfp_sm_module(struct sfp *sf + break; + + case SFP_MOD_PROBE: ++ /* Wait for T_PROBE_INIT to time out */ + if (event != SFP_E_TIMEOUT) + break; + +@@ -1568,6 +1568,20 @@ static void sfp_sm_module(struct sfp *sf + break; + } + ++ sfp_sm_mod_next(sfp, SFP_MOD_WAITDEV, 0); ++ /* fall through */ ++ case SFP_MOD_WAITDEV: ++ /* Ensure that the device is attached before proceeding */ ++ if (sfp->sm_dev_state < SFP_DEV_DOWN) ++ break; ++ ++ /* Report the module insertion to the upstream device */ ++ err = sfp_module_insert(sfp->sfp_bus, &sfp->id); ++ if (err < 0) { ++ sfp_sm_mod_next(sfp, SFP_MOD_ERROR, 0); ++ break; ++ } ++ + /* If this is a power level 1 module, we are done */ + if (sfp->module_power_mW <= 1000) + goto insert; +@@ -1577,12 +1591,17 @@ static void sfp_sm_module(struct sfp *sf + case SFP_MOD_HPOWER: + /* Enable high power mode */ + err = sfp_sm_mod_hpower(sfp, true); +- if (err == 0) +- sfp_sm_mod_next(sfp, SFP_MOD_WAITPWR, T_HPOWER_LEVEL); +- else if (err != -EAGAIN) +- sfp_sm_mod_next(sfp, SFP_MOD_ERROR, 0); +- else +- sfp_sm_set_timer(sfp, T_PROBE_RETRY); ++ if (err < 0) { ++ if (err != -EAGAIN) { ++ sfp_module_remove(sfp->sfp_bus); ++ sfp_sm_mod_next(sfp, SFP_MOD_ERROR, 0); ++ } else { ++ sfp_sm_set_timer(sfp, T_PROBE_RETRY); ++ } ++ break; ++ } ++ ++ sfp_sm_mod_next(sfp, SFP_MOD_WAITPWR, T_HPOWER_LEVEL); + break; + + case SFP_MOD_WAITPWR: +@@ -1750,8 +1769,6 @@ static void sfp_sm_event(struct sfp *sfp + static void sfp_attach(struct sfp *sfp) + { + sfp_sm_event(sfp, SFP_E_DEV_ATTACH); +- if (sfp->state & SFP_F_PRESENT) +- sfp_sm_event(sfp, SFP_E_INSERT); + } + + static void sfp_detach(struct sfp *sfp) +@@ -2001,6 +2018,11 @@ static int sfp_probe(struct platform_dev + sfp->state |= SFP_F_RATE_SELECT; + sfp_set_state(sfp, sfp->state); + sfp_module_tx_disable(sfp); ++ if (sfp->state & SFP_F_PRESENT) { ++ rtnl_lock(); ++ sfp_sm_event(sfp, SFP_E_INSERT); ++ rtnl_unlock(); ++ } + + for (i = 0; i < GPIO_MAX; i++) { + if (gpio_flags[i] != GPIOD_IN || !sfp->gpio[i]) diff --git a/target/linux/generic/backport-4.19/735-v5.5-net-sfp-allow-sfp-to-probe-slow-to-initialise-GPON-m.patch b/target/linux/generic/backport-4.19/735-v5.5-net-sfp-allow-sfp-to-probe-slow-to-initialise-GPON-m.patch new file mode 100644 index 000000000..6cbd0864f --- /dev/null +++ b/target/linux/generic/backport-4.19/735-v5.5-net-sfp-allow-sfp-to-probe-slow-to-initialise-GPON-m.patch @@ -0,0 +1,110 @@ +From fb56cd08880aff8fb030e684fa4311bef712a499 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 5 Nov 2019 13:02:30 +0000 +Subject: [PATCH 633/660] net: sfp: allow sfp to probe slow to initialise GPON + modules + +Some GPON modules (e.g. Huawei MA5671A) take a significant amount of +time to start responding on the I2C bus, contary to the SFF +specifications. + +Work around this by implementing a two-level timeout strategy, where +we initially quickly retry for the module, and then use a slower retry +after we exceed a maximum number of quick attempts. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 38 ++++++++++++++++++++++++++++---------- + 1 file changed, 28 insertions(+), 10 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -165,9 +165,12 @@ static const enum gpiod_flags gpio_flags + * The SFF-8472 specifies t_serial ("Time from power on until module is + * ready for data transmission over the two wire serial bus.") as 300ms. + */ +-#define T_SERIAL msecs_to_jiffies(300) +-#define T_HPOWER_LEVEL msecs_to_jiffies(300) +-#define T_PROBE_RETRY msecs_to_jiffies(100) ++#define T_SERIAL msecs_to_jiffies(300) ++#define T_HPOWER_LEVEL msecs_to_jiffies(300) ++#define T_PROBE_RETRY_INIT msecs_to_jiffies(100) ++#define R_PROBE_RETRY_INIT 10 ++#define T_PROBE_RETRY_SLOW msecs_to_jiffies(5000) ++#define R_PROBE_RETRY_SLOW 12 + + /* SFP modules appear to always have their PHY configured for bus address + * 0x56 (which with mdio-i2c, translates to a PHY address of 22). +@@ -202,6 +205,8 @@ struct sfp { + struct delayed_work timeout; + struct mutex sm_mutex; /* Protects state machine */ + unsigned char sm_mod_state; ++ unsigned char sm_mod_tries_init; ++ unsigned char sm_mod_tries; + unsigned char sm_dev_state; + unsigned short sm_state; + unsigned int sm_retries; +@@ -1392,7 +1397,7 @@ static int sfp_sm_mod_hpower(struct sfp + return 0; + } + +-static int sfp_sm_mod_probe(struct sfp *sfp) ++static int sfp_sm_mod_probe(struct sfp *sfp, bool report) + { + /* SFP module inserted - read I2C data */ + struct sfp_eeprom_id id; +@@ -1402,7 +1407,8 @@ static int sfp_sm_mod_probe(struct sfp * + + ret = sfp_read(sfp, false, 0, &id, sizeof(id)); + if (ret < 0) { +- dev_err(sfp->dev, "failed to read EEPROM: %d\n", ret); ++ if (report) ++ dev_err(sfp->dev, "failed to read EEPROM: %d\n", ret); + return -EAGAIN; + } + +@@ -1549,8 +1555,11 @@ static void sfp_sm_module(struct sfp *sf + + switch (sfp->sm_mod_state) { + default: +- if (event == SFP_E_INSERT) ++ if (event == SFP_E_INSERT) { + sfp_sm_mod_next(sfp, SFP_MOD_PROBE, T_SERIAL); ++ sfp->sm_mod_tries_init = R_PROBE_RETRY_INIT; ++ sfp->sm_mod_tries = R_PROBE_RETRY_SLOW; ++ } + break; + + case SFP_MOD_PROBE: +@@ -1558,10 +1567,19 @@ static void sfp_sm_module(struct sfp *sf + if (event != SFP_E_TIMEOUT) + break; + +- err = sfp_sm_mod_probe(sfp); ++ err = sfp_sm_mod_probe(sfp, sfp->sm_mod_tries == 1); + if (err == -EAGAIN) { +- sfp_sm_set_timer(sfp, T_PROBE_RETRY); +- break; ++ if (sfp->sm_mod_tries_init && ++ --sfp->sm_mod_tries_init) { ++ sfp_sm_set_timer(sfp, T_PROBE_RETRY_INIT); ++ break; ++ } else if (sfp->sm_mod_tries && --sfp->sm_mod_tries) { ++ if (sfp->sm_mod_tries == R_PROBE_RETRY_SLOW - 1) ++ dev_warn(sfp->dev, ++ "please wait, module slow to respond\n"); ++ sfp_sm_set_timer(sfp, T_PROBE_RETRY_SLOW); ++ break; ++ } + } + if (err < 0) { + sfp_sm_mod_next(sfp, SFP_MOD_ERROR, 0); +@@ -1596,7 +1614,7 @@ static void sfp_sm_module(struct sfp *sf + sfp_module_remove(sfp->sfp_bus); + sfp_sm_mod_next(sfp, SFP_MOD_ERROR, 0); + } else { +- sfp_sm_set_timer(sfp, T_PROBE_RETRY); ++ sfp_sm_set_timer(sfp, T_PROBE_RETRY_INIT); + } + break; + } diff --git a/target/linux/generic/backport-4.19/736-v5.5-net-sfp-allow-modules-with-slow-diagnostics-to-probe.patch b/target/linux/generic/backport-4.19/736-v5.5-net-sfp-allow-modules-with-slow-diagnostics-to-probe.patch new file mode 100644 index 000000000..fe1e6c482 --- /dev/null +++ b/target/linux/generic/backport-4.19/736-v5.5-net-sfp-allow-modules-with-slow-diagnostics-to-probe.patch @@ -0,0 +1,198 @@ +From 559391fc20fae506adcb311b904cc544c76436c0 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Thu, 7 Nov 2019 18:52:07 +0000 +Subject: [PATCH 634/660] net: sfp: allow modules with slow diagnostics to + probe + +When a module is inserted, we attempt to read read the ID from address +0x50. Once we are able to read the ID, we immediately attempt to +initialise the hwmon support by reading from address 0x51. If this +fails, then we fall into error state, and assume that the module is +not usable. + +Modules such as the ALCATELLUCENT 3FE46541AA use a real EEPROM for +I2C address 0x50, which responds immediately. However, address 0x51 +is an emulated, which only becomes available once the on-board firmware +has booted. This prompts us to fall into the error state. + +Since the module may be usable without diagnostics, arrange for the +hwmon probe independent of the rest of the SFP itself, retrying every +5s for up to about 60s for the monitoring to become available, and +print an error message if it doesn't become available. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 96 +++++++++++++++++++++++++++++++++---------- + 1 file changed, 74 insertions(+), 22 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -216,6 +216,8 @@ struct sfp { + + #if IS_ENABLED(CONFIG_HWMON) + struct sfp_diag diag; ++ struct delayed_work hwmon_probe; ++ unsigned int hwmon_tries; + struct device *hwmon_dev; + char *hwmon_name; + #endif +@@ -1094,29 +1096,27 @@ static const struct hwmon_chip_info sfp_ + .info = sfp_hwmon_info, + }; + +-static int sfp_hwmon_insert(struct sfp *sfp) ++static void sfp_hwmon_probe(struct work_struct *work) + { ++ struct sfp *sfp = container_of(work, struct sfp, hwmon_probe.work); + int err, i; + +- if (sfp->id.ext.sff8472_compliance == SFP_SFF8472_COMPLIANCE_NONE) +- return 0; +- +- if (!(sfp->id.ext.diagmon & SFP_DIAGMON_DDM)) +- return 0; +- +- if (sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE) +- /* This driver in general does not support address +- * change. +- */ +- return 0; +- + err = sfp_read(sfp, true, 0, &sfp->diag, sizeof(sfp->diag)); +- if (err < 0) +- return err; ++ if (err < 0) { ++ if (sfp->hwmon_tries--) { ++ mod_delayed_work(system_wq, &sfp->hwmon_probe, ++ T_PROBE_RETRY_SLOW); ++ } else { ++ dev_warn(sfp->dev, "hwmon probe failed: %d\n", err); ++ } ++ return; ++ } + + sfp->hwmon_name = kstrdup(dev_name(sfp->dev), GFP_KERNEL); +- if (!sfp->hwmon_name) +- return -ENODEV; ++ if (!sfp->hwmon_name) { ++ dev_err(sfp->dev, "out of memory for hwmon name\n"); ++ return; ++ } + + for (i = 0; sfp->hwmon_name[i]; i++) + if (hwmon_is_bad_char(sfp->hwmon_name[i])) +@@ -1126,18 +1126,52 @@ static int sfp_hwmon_insert(struct sfp * + sfp->hwmon_name, sfp, + &sfp_hwmon_chip_info, + NULL); ++ if (IS_ERR(sfp->hwmon_dev)) ++ dev_err(sfp->dev, "failed to register hwmon device: %ld\n", ++ PTR_ERR(sfp->hwmon_dev)); ++} ++ ++static int sfp_hwmon_insert(struct sfp *sfp) ++{ ++ if (sfp->id.ext.sff8472_compliance == SFP_SFF8472_COMPLIANCE_NONE) ++ return 0; ++ ++ if (!(sfp->id.ext.diagmon & SFP_DIAGMON_DDM)) ++ return 0; ++ ++ if (sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE) ++ /* This driver in general does not support address ++ * change. ++ */ ++ return 0; ++ ++ mod_delayed_work(system_wq, &sfp->hwmon_probe, 1); ++ sfp->hwmon_tries = R_PROBE_RETRY_SLOW; + +- return PTR_ERR_OR_ZERO(sfp->hwmon_dev); ++ return 0; + } + + static void sfp_hwmon_remove(struct sfp *sfp) + { ++ cancel_delayed_work_sync(&sfp->hwmon_probe); + if (!IS_ERR_OR_NULL(sfp->hwmon_dev)) { + hwmon_device_unregister(sfp->hwmon_dev); + sfp->hwmon_dev = NULL; + kfree(sfp->hwmon_name); + } + } ++ ++static int sfp_hwmon_init(struct sfp *sfp) ++{ ++ INIT_DELAYED_WORK(&sfp->hwmon_probe, sfp_hwmon_probe); ++ ++ return 0; ++} ++ ++static void sfp_hwmon_exit(struct sfp *sfp) ++{ ++ cancel_delayed_work_sync(&sfp->hwmon_probe); ++} + #else + static int sfp_hwmon_insert(struct sfp *sfp) + { +@@ -1147,6 +1181,15 @@ static int sfp_hwmon_insert(struct sfp * + static void sfp_hwmon_remove(struct sfp *sfp) + { + } ++ ++static int sfp_hwmon_init(struct sfp *sfp) ++{ ++ return 0; ++} ++ ++static void sfp_hwmon_exit(struct sfp *sfp) ++{ ++} + #endif + + /* Helpers */ +@@ -1483,10 +1526,6 @@ static int sfp_sm_mod_probe(struct sfp * + if (ret < 0) + return ret; + +- ret = sfp_hwmon_insert(sfp); +- if (ret < 0) +- return ret; +- + return 0; + } + +@@ -1635,6 +1674,15 @@ static void sfp_sm_module(struct sfp *sf + case SFP_MOD_ERROR: + break; + } ++ ++#if IS_ENABLED(CONFIG_HWMON) ++ if (sfp->sm_mod_state >= SFP_MOD_WAITDEV && ++ IS_ERR_OR_NULL(sfp->hwmon_dev)) { ++ err = sfp_hwmon_insert(sfp); ++ if (err) ++ dev_warn(sfp->dev, "hwmon probe failed: %d\n", err); ++ } ++#endif + } + + static void sfp_sm_main(struct sfp *sfp, unsigned int event) +@@ -1936,6 +1984,8 @@ static struct sfp *sfp_alloc(struct devi + INIT_DELAYED_WORK(&sfp->poll, sfp_poll); + INIT_DELAYED_WORK(&sfp->timeout, sfp_timeout); + ++ sfp_hwmon_init(sfp); ++ + return sfp; + } + +@@ -1943,6 +1993,8 @@ static void sfp_cleanup(void *data) + { + struct sfp *sfp = data; + ++ sfp_hwmon_exit(sfp); ++ + cancel_delayed_work_sync(&sfp->poll); + cancel_delayed_work_sync(&sfp->timeout); + if (sfp->i2c_mii) { diff --git a/target/linux/generic/backport-4.19/737-v5.5-net-phy-add-core-phylib-sfp-support.patch b/target/linux/generic/backport-4.19/737-v5.5-net-phy-add-core-phylib-sfp-support.patch new file mode 100644 index 000000000..8dcad2fa5 --- /dev/null +++ b/target/linux/generic/backport-4.19/737-v5.5-net-phy-add-core-phylib-sfp-support.patch @@ -0,0 +1,183 @@ +From eb156db588ac583cdae7b91eaac9c0ad3a358e63 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Sun, 15 Sep 2019 20:05:34 +0100 +Subject: [PATCH 635/660] net: phy: add core phylib sfp support + +Add core phylib help for supporting SFP sockets on PHYs. This provides +a mechanism to inform the SFP layer about PHY up/down events, and also +unregister the SFP bus when the PHY is going away. + +Signed-off-by: Russell King +--- + drivers/net/phy/phy.c | 7 ++++ + drivers/net/phy/phy_device.c | 66 ++++++++++++++++++++++++++++++++++++ + include/linux/phy.h | 11 ++++++ + 3 files changed, 84 insertions(+) + +--- a/drivers/net/phy/phy.c ++++ b/drivers/net/phy/phy.c +@@ -30,6 +30,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -871,6 +872,9 @@ void phy_stop(struct phy_device *phydev) + if (phy_interrupt_is_valid(phydev)) + phy_disable_interrupts(phydev); + ++ if (phydev->sfp_bus) ++ sfp_upstream_stop(phydev->sfp_bus); ++ + phydev->state = PHY_HALTED; + + out_unlock: +@@ -899,6 +903,9 @@ void phy_start(struct phy_device *phydev + + mutex_lock(&phydev->lock); + ++ if (phydev->sfp_bus) ++ sfp_upstream_start(phydev->sfp_bus); ++ + switch (phydev->state) { + case PHY_STARTING: + phydev->state = PHY_PENDING; +--- a/drivers/net/phy/phy_device.c ++++ b/drivers/net/phy/phy_device.c +@@ -31,6 +31,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -943,6 +944,65 @@ void phy_attached_print(struct phy_devic + EXPORT_SYMBOL(phy_attached_print); + + /** ++ * phy_sfp_attach - attach the SFP bus to the PHY upstream network device ++ * @upstream: pointer to the phy device ++ * @bus: sfp bus representing cage being attached ++ * ++ * This is used to fill in the sfp_upstream_ops .attach member. ++ */ ++void phy_sfp_attach(void *upstream, struct sfp_bus *bus) ++{ ++ struct phy_device *phydev = upstream; ++ ++ if (phydev->attached_dev) ++ phydev->attached_dev->sfp_bus = bus; ++ phydev->sfp_bus_attached = true; ++} ++EXPORT_SYMBOL(phy_sfp_attach); ++ ++/** ++ * phy_sfp_detach - detach the SFP bus from the PHY upstream network device ++ * @upstream: pointer to the phy device ++ * @bus: sfp bus representing cage being attached ++ * ++ * This is used to fill in the sfp_upstream_ops .detach member. ++ */ ++void phy_sfp_detach(void *upstream, struct sfp_bus *bus) ++{ ++ struct phy_device *phydev = upstream; ++ ++ if (phydev->attached_dev) ++ phydev->attached_dev->sfp_bus = NULL; ++ phydev->sfp_bus_attached = false; ++} ++EXPORT_SYMBOL(phy_sfp_detach); ++ ++/** ++ * phy_sfp_probe - probe for a SFP cage attached to this PHY device ++ * @phydev: Pointer to phy_device ++ * @ops: SFP's upstream operations ++ */ ++int phy_sfp_probe(struct phy_device *phydev, ++ const struct sfp_upstream_ops *ops) ++{ ++ struct sfp_bus *bus; ++ int ret; ++ ++ if (phydev->mdio.dev.fwnode) { ++ bus = sfp_bus_find_fwnode(phydev->mdio.dev.fwnode); ++ if (IS_ERR(bus)) ++ return PTR_ERR(bus); ++ ++ phydev->sfp_bus = bus; ++ ++ ret = sfp_bus_add_upstream(bus, phydev, ops); ++ sfp_bus_put(bus); ++ } ++ return 0; ++} ++EXPORT_SYMBOL(phy_sfp_probe); ++ ++/** + * phy_attach_direct - attach a network device to a given PHY device pointer + * @dev: network device to attach + * @phydev: Pointer to phy_device to attach +@@ -1015,6 +1075,9 @@ int phy_attach_direct(struct net_device + phydev->attached_dev = dev; + dev->phydev = phydev; + ++ if (phydev->sfp_bus_attached) ++ dev->sfp_bus = phydev->sfp_bus; ++ + /* Some Ethernet drivers try to connect to a PHY device before + * calling register_netdevice() -> netdev_register_kobject() and + * does the dev->dev.kobj initialization. Here we only check for +@@ -1949,6 +2012,9 @@ static int phy_remove(struct device *dev + phydev->state = PHY_DOWN; + mutex_unlock(&phydev->lock); + ++ sfp_bus_del_upstream(phydev->sfp_bus); ++ phydev->sfp_bus = NULL; ++ + if (phydev->drv && phydev->drv->remove) { + phydev->drv->remove(phydev); + +--- a/include/linux/phy.h ++++ b/include/linux/phy.h +@@ -184,6 +184,8 @@ static inline const char *phy_modes(phy_ + + struct device; + struct phylink; ++struct sfp_bus; ++struct sfp_upstream_ops; + struct sk_buff; + + /* +@@ -382,6 +384,8 @@ struct phy_c45_device_ids { + * irq: IRQ number of the PHY's interrupt (-1 if none) + * phy_timer: The timer for handling the state machine + * phy_queue: A work_queue for the phy_mac_interrupt ++ * sfp_bus_attached: flag indicating whether the SFP bus has been attached ++ * sfp_bus: SFP bus attached to this PHY's fiber port + * attached_dev: The attached enet driver's device instance ptr + * adjust_link: Callback for the enet controller to respond to + * changes in the link state. +@@ -471,6 +475,9 @@ struct phy_device { + + struct mutex lock; + ++ /* This may be modified under the rtnl lock */ ++ bool sfp_bus_attached; ++ struct sfp_bus *sfp_bus; + struct phylink *phylink; + struct net_device *attached_dev; + +@@ -1031,6 +1038,10 @@ int phy_suspend(struct phy_device *phyde + int phy_resume(struct phy_device *phydev); + int __phy_resume(struct phy_device *phydev); + int phy_loopback(struct phy_device *phydev, bool enable); ++void phy_sfp_attach(void *upstream, struct sfp_bus *bus); ++void phy_sfp_detach(void *upstream, struct sfp_bus *bus); ++int phy_sfp_probe(struct phy_device *phydev, ++ const struct sfp_upstream_ops *ops); + struct phy_device *phy_attach(struct net_device *dev, const char *bus_id, + phy_interface_t interface); + struct phy_device *phy_find_first(struct mii_bus *bus); diff --git a/target/linux/generic/backport-4.19/738-v5.5-net-phy-marvell10g-add-SFP-support.patch b/target/linux/generic/backport-4.19/738-v5.5-net-phy-marvell10g-add-SFP-support.patch new file mode 100644 index 000000000..a67431ce5 --- /dev/null +++ b/target/linux/generic/backport-4.19/738-v5.5-net-phy-marvell10g-add-SFP-support.patch @@ -0,0 +1,67 @@ +From 0836d9fb41ed90090ef4af0d7abe784ee7706f80 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Fri, 14 Apr 2017 14:21:25 +0100 +Subject: [PATCH 636/660] net: phy: marvell10g: add SFP+ support + +Add support for SFP+ cages to the Marvell 10G PHY driver. This is +slightly complicated by the way phylib works in that we need to use +a multi-step process to attach the SFP bus, and we also need to track +the phylink state machine to know when the module's transmit disable +signal should change state. + +With appropriate DT changes, this allows the SFP+ canges on the +Macchiatobin platform to be functional. + +Signed-off-by: Russell King +--- + drivers/net/phy/marvell10g.c | 25 ++++++++++++++++++++++++- + 1 file changed, 24 insertions(+), 1 deletion(-) + +--- a/drivers/net/phy/marvell10g.c ++++ b/drivers/net/phy/marvell10g.c +@@ -25,6 +25,7 @@ + #include + #include + #include ++#include + + enum { + MV_PMA_BOOT = 0xc050, +@@ -219,6 +220,28 @@ static int mv3310_hwmon_probe(struct phy + } + #endif + ++static int mv3310_sfp_insert(void *upstream, const struct sfp_eeprom_id *id) ++{ ++ struct phy_device *phydev = upstream; ++ __ETHTOOL_DECLARE_LINK_MODE_MASK(support) = { 0, }; ++ phy_interface_t iface; ++ ++ sfp_parse_support(phydev->sfp_bus, id, support); ++ iface = sfp_select_interface(phydev->sfp_bus, id, support); ++ ++ if (iface != PHY_INTERFACE_MODE_10GKR) { ++ dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n"); ++ return -EINVAL; ++ } ++ return 0; ++} ++ ++static const struct sfp_upstream_ops mv3310_sfp_ops = { ++ .attach = phy_sfp_attach, ++ .detach = phy_sfp_detach, ++ .module_insert = mv3310_sfp_insert, ++}; ++ + static int mv3310_probe(struct phy_device *phydev) + { + struct mv3310_priv *priv; +@@ -249,7 +272,7 @@ static int mv3310_probe(struct phy_devic + if (ret) + return ret; + +- return 0; ++ return phy_sfp_probe(phydev, &mv3310_sfp_ops); + } + + static int mv3310_suspend(struct phy_device *phydev) diff --git a/target/linux/generic/backport-4.19/739-v5.5-net-phylink-update-to-use-phy_support_asym_pause.patch b/target/linux/generic/backport-4.19/739-v5.5-net-phylink-update-to-use-phy_support_asym_pause.patch new file mode 100644 index 000000000..15db0abc9 --- /dev/null +++ b/target/linux/generic/backport-4.19/739-v5.5-net-phylink-update-to-use-phy_support_asym_pause.patch @@ -0,0 +1,45 @@ +From 09d7d8395ec61fba4392b35baa6f71c4e36489df Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Fri, 8 Nov 2019 15:18:02 +0000 +Subject: [PATCH 637/660] net: phylink: update to use phy_support_asym_pause() + +Use phy_support_asym_pause() rather than open-coding it. + +Signed-off-by: Russell King +--- + drivers/net/phy/phylink.c | 17 +++++++---------- + 1 file changed, 7 insertions(+), 10 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -678,12 +678,6 @@ static int phylink_bringup_phy(struct ph + u32 advertising; + int ret; + +- memset(&config, 0, sizeof(config)); +- ethtool_convert_legacy_u32_to_link_mode(supported, phy->supported); +- ethtool_convert_legacy_u32_to_link_mode(config.advertising, +- phy->advertising); +- config.interface = pl->link_config.interface; +- + /* + * This is the new way of dealing with flow control for PHYs, + * as described by Timur Tabi in commit 529ed1275263 ("net: phy: +@@ -691,10 +685,13 @@ static int phylink_bringup_phy(struct ph + * using our validate call to the MAC, we rely upon the MAC + * clearing the bits from both supported and advertising fields. + */ +- if (phylink_test(supported, Pause)) +- phylink_set(config.advertising, Pause); +- if (phylink_test(supported, Asym_Pause)) +- phylink_set(config.advertising, Asym_Pause); ++ phy_support_asym_pause(phy); ++ ++ memset(&config, 0, sizeof(config)); ++ ethtool_convert_legacy_u32_to_link_mode(supported, phy->supported); ++ ethtool_convert_legacy_u32_to_link_mode(config.advertising, ++ phy->advertising); ++ config.interface = pl->link_config.interface; + + ret = phylink_validate(pl, supported, &config); + if (ret) diff --git a/target/linux/generic/backport-4.19/740-v5.5-net-phy-avoid-matching-all-ones-clause-45-PHY-IDs.patch b/target/linux/generic/backport-4.19/740-v5.5-net-phy-avoid-matching-all-ones-clause-45-PHY-IDs.patch new file mode 100644 index 000000000..d6c012019 --- /dev/null +++ b/target/linux/generic/backport-4.19/740-v5.5-net-phy-avoid-matching-all-ones-clause-45-PHY-IDs.patch @@ -0,0 +1,63 @@ +From 1be8018db381200c24854e0c299206c557f76fe0 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Mon, 11 Nov 2019 11:58:09 +0000 +Subject: [PATCH 638/660] net: phy: avoid matching all-ones clause 45 PHY IDs + +We currently match clause 45 PHYs using any ID read from a MMD marked +as present in the "Devices in package" registers 5 and 6. However, +this is incorrect. 45.2 says: + + "The definition of the term package is vendor specific and could be + a chip, module, or other similar entity." + +so a package could be more or less than the whole PHY - a PHY could be +made up of several modules instantiated onto a single chip such as the +Marvell 88x3310, or some of the MMDs could be disabled according to +chip configuration, such as the Broadcom 84881. + +In the case of Broadcom 84881, the "Devices in package" registers +contain 0xc000009b, meaning that there is a PHYXS present in the +package, but all registers in MMD 4 return 0xffff. This leads to our +matching code incorrectly binding this PHY to one of our generic PHY +drivers. + +This patch changes the way we determine whether to attempt to match a +MMD identifier, or use it to request a module - if the identifier is +all-ones, then we skip over it. When reading the identifiers, we +initialise phydev->c45_ids.device_ids to all-ones, only reading the +device ID if the "Devices in package" registers indicates we should. + +This avoids the generic drivers incorrectly matching on a PHY ID of +0xffffffff. + +Signed-off-by: Russell King +--- + drivers/net/phy/phy_device.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +--- a/drivers/net/phy/phy_device.c ++++ b/drivers/net/phy/phy_device.c +@@ -334,7 +334,7 @@ static int phy_bus_match(struct device * + + if (phydev->is_c45) { + for (i = 1; i < num_ids; i++) { +- if (!(phydev->c45_ids.devices_in_package & (1 << i))) ++ if (phydev->c45_ids.device_ids[i] == 0xffffffff) + continue; + + if ((phydrv->phy_id & phydrv->phy_id_mask) == +@@ -622,10 +622,13 @@ static int get_phy_id(struct mii_bus *bu + */ + struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45) + { +- struct phy_c45_device_ids c45_ids = {0}; ++ struct phy_c45_device_ids c45_ids; + u32 phy_id = 0; + int r; + ++ c45_ids.devices_in_package = 0; ++ memset(c45_ids.device_ids, 0xff, sizeof(c45_ids.device_ids)); ++ + r = get_phy_id(bus, addr, &phy_id, is_c45, &c45_ids); + if (r) + return ERR_PTR(r); diff --git a/target/linux/generic/backport-4.19/741-v5.5-net-phylink-fix-link-mode-modification-in-PHY-mode.patch b/target/linux/generic/backport-4.19/741-v5.5-net-phylink-fix-link-mode-modification-in-PHY-mode.patch new file mode 100644 index 000000000..596ecc827 --- /dev/null +++ b/target/linux/generic/backport-4.19/741-v5.5-net-phylink-fix-link-mode-modification-in-PHY-mode.patch @@ -0,0 +1,66 @@ +From 4c9633f75dc35abe1b9261e0415d77802f35741d Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 5 Nov 2019 11:58:00 +0000 +Subject: [PATCH 639/660] net: phylink: fix link mode modification in PHY mode + +Modifying the link settings via phylink_ethtool_ksettings_set() and +phylink_ethtool_set_pauseparam() didn't always work as intended for +PHY based setups, as calling phylink_mac_config() would result in the +unresolved configuration being committed to the MAC, rather than the +configuration with the speed and duplex setting. + +This would work fine if the update caused the link to renegotiate, +but if no settings have changed, phylib won't trigger a renegotiation +cycle, and the MAC will be left incorrectly configured. + +Avoid calling phylink_mac_config() unless we are using an inband mode +in phylink_ethtool_ksettings_set(), and use phy_set_asym_pause() as +introduced in 4.20 to set the PHY settings in +phylink_ethtool_set_pauseparam(). + +Signed-off-by: Russell King +--- + drivers/net/phy/phylink.c | 24 ++++++++++++++++-------- + 1 file changed, 16 insertions(+), 8 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -1210,7 +1210,13 @@ int phylink_ethtool_ksettings_set(struct + pl->link_config.duplex = our_kset.base.duplex; + pl->link_config.an_enabled = our_kset.base.autoneg != AUTONEG_DISABLE; + +- if (!test_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state)) { ++ /* If we have a PHY, phylib will call our link state function if the ++ * mode has changed, which will trigger a resolve and update the MAC ++ * configuration. For a fixed link, this isn't able to change any ++ * parameters, which just leaves inband mode. ++ */ ++ if (pl->link_an_mode == MLO_AN_INBAND && ++ !test_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state)) { + phylink_mac_config(pl, &pl->link_config); + phylink_mac_an_restart(pl); + } +@@ -1290,14 +1296,16 @@ int phylink_ethtool_set_pauseparam(struc + if (pause->tx_pause) + config->pause |= MLO_PAUSE_TX; + +- if (!test_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state)) { ++ /* If we have a PHY, phylib will call our link state function if the ++ * mode has changed, which will trigger a resolve and update the MAC ++ * configuration. ++ */ ++ if (pl->phydev) { ++ phy_set_asym_pause(pl->phydev, pause->rx_pause, ++ pause->tx_pause); ++ } else if (!test_bit(PHYLINK_DISABLE_STOPPED, ++ &pl->phylink_disable_state)) { + switch (pl->link_an_mode) { +- case MLO_AN_PHY: +- /* Silently mark the carrier down, and then trigger a resolve */ +- netif_carrier_off(pl->netdev); +- phylink_run_resolve(pl); +- break; +- + case MLO_AN_FIXED: + /* Should we allow fixed links to change against the config? */ + phylink_resolve_flow(pl, config); diff --git a/target/linux/generic/backport-4.19/742-v5.5-net-sfp-add-support-for-module-quirks.patch b/target/linux/generic/backport-4.19/742-v5.5-net-sfp-add-support-for-module-quirks.patch new file mode 100644 index 000000000..5068bd468 --- /dev/null +++ b/target/linux/generic/backport-4.19/742-v5.5-net-sfp-add-support-for-module-quirks.patch @@ -0,0 +1,111 @@ +From 8df5dd55cef48c0769379e04dbc085a899b106d4 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Fri, 8 Mar 2019 14:02:25 +0000 +Subject: [PATCH 640/660] net: sfp: add support for module quirks + +Add support for applying module quirks to the list of supported +ethtool link modes. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp-bus.c | 54 +++++++++++++++++++++++++++++++++++++++ + 1 file changed, 54 insertions(+) + +--- a/drivers/net/phy/sfp-bus.c ++++ b/drivers/net/phy/sfp-bus.c +@@ -9,6 +9,12 @@ + + #include "sfp.h" + ++struct sfp_quirk { ++ const char *vendor; ++ const char *part; ++ void (*modes)(const struct sfp_eeprom_id *id, unsigned long *modes); ++}; ++ + /** + * struct sfp_bus - internal representation of a sfp bus + */ +@@ -21,6 +27,7 @@ struct sfp_bus { + const struct sfp_socket_ops *socket_ops; + struct device *sfp_dev; + struct sfp *sfp; ++ const struct sfp_quirk *sfp_quirk; + + const struct sfp_upstream_ops *upstream_ops; + void *upstream; +@@ -30,6 +37,46 @@ struct sfp_bus { + bool started; + }; + ++static const struct sfp_quirk sfp_quirks[] = { ++}; ++ ++static size_t sfp_strlen(const char *str, size_t maxlen) ++{ ++ size_t size, i; ++ ++ /* Trailing characters should be filled with space chars */ ++ for (i = 0, size = 0; i < maxlen; i++) ++ if (str[i] != ' ') ++ size = i + 1; ++ ++ return size; ++} ++ ++static bool sfp_match(const char *qs, const char *str, size_t len) ++{ ++ if (!qs) ++ return true; ++ if (strlen(qs) != len) ++ return false; ++ return !strncmp(qs, str, len); ++} ++ ++static const struct sfp_quirk *sfp_lookup_quirk(const struct sfp_eeprom_id *id) ++{ ++ const struct sfp_quirk *q; ++ unsigned int i; ++ size_t vs, ps; ++ ++ vs = sfp_strlen(id->base.vendor_name, ARRAY_SIZE(id->base.vendor_name)); ++ ps = sfp_strlen(id->base.vendor_pn, ARRAY_SIZE(id->base.vendor_pn)); ++ ++ for (i = 0, q = sfp_quirks; i < ARRAY_SIZE(sfp_quirks); i++, q++) ++ if (sfp_match(q->vendor, id->base.vendor_name, vs) && ++ sfp_match(q->part, id->base.vendor_pn, ps)) ++ return q; ++ ++ return NULL; ++} + /** + * sfp_parse_port() - Parse the EEPROM base ID, setting the port type + * @bus: a pointer to the &struct sfp_bus structure for the sfp module +@@ -233,6 +280,9 @@ void sfp_parse_support(struct sfp_bus *b + phylink_set(modes, 1000baseX_Full); + } + ++ if (bus->sfp_quirk) ++ bus->sfp_quirk->modes(id, modes); ++ + bitmap_or(support, support, modes, __ETHTOOL_LINK_MODE_MASK_NBITS); + + phylink_set(support, Autoneg); +@@ -609,6 +659,8 @@ int sfp_module_insert(struct sfp_bus *bu + const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); + int ret = 0; + ++ bus->sfp_quirk = sfp_lookup_quirk(id); ++ + if (ops && ops->module_insert) + ret = ops->module_insert(bus->upstream, id); + +@@ -622,6 +674,8 @@ void sfp_module_remove(struct sfp_bus *b + + if (ops && ops->module_remove) + ops->module_remove(bus->upstream); ++ ++ bus->sfp_quirk = NULL; + } + EXPORT_SYMBOL_GPL(sfp_module_remove); + diff --git a/target/linux/generic/backport-4.19/743-v5.5-net-sfp-add-some-quirks-for-GPON-modules.patch b/target/linux/generic/backport-4.19/743-v5.5-net-sfp-add-some-quirks-for-GPON-modules.patch new file mode 100644 index 000000000..10c34881d --- /dev/null +++ b/target/linux/generic/backport-4.19/743-v5.5-net-sfp-add-some-quirks-for-GPON-modules.patch @@ -0,0 +1,52 @@ +From ecaa542cfed078dbc356dadff0bad4b6a8e704a0 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Fri, 17 May 2019 10:14:45 +0100 +Subject: [PATCH 641/660] net: sfp: add some quirks for GPON modules + +Marc Micalizzi reports that Huawei MA5671A and Alcatel/Lucent G-010S-P +modules are capable of 2500base-X, but incorrectly report their +capabilities in the EEPROM. It seems rather common that GPON modules +mis-report. + +Let's fix these modules by adding some quirks. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp-bus.c | 25 +++++++++++++++++++++++++ + 1 file changed, 25 insertions(+) + +--- a/drivers/net/phy/sfp-bus.c ++++ b/drivers/net/phy/sfp-bus.c +@@ -37,7 +37,32 @@ struct sfp_bus { + bool started; + }; + ++static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id, ++ unsigned long *modes) ++{ ++ phylink_set(modes, 2500baseX_Full); ++} ++ + static const struct sfp_quirk sfp_quirks[] = { ++ { ++ // Alcatel Lucent G-010S-P can operate at 2500base-X, but ++ // incorrectly report 2500MBd NRZ in their EEPROM ++ .vendor = "ALCATELLUCENT", ++ .part = "G010SP", ++ .modes = sfp_quirk_2500basex, ++ }, { ++ // Alcatel Lucent G-010S-A can operate at 2500base-X, but ++ // report 3.2GBd NRZ in their EEPROM ++ .vendor = "ALCATELLUCENT", ++ .part = "3FE46541AA", ++ .modes = sfp_quirk_2500basex, ++ }, { ++ // Huawei MA5671A can operate at 2500base-X, but report 1.2GBd ++ // NRZ in their EEPROM ++ .vendor = "HUAWEI", ++ .part = "MA5671A", ++ .modes = sfp_quirk_2500basex, ++ }, + }; + + static size_t sfp_strlen(const char *str, size_t maxlen) diff --git a/target/linux/generic/backport-4.19/744-v5.5-net-sfp-soft-status-and-control-support.patch b/target/linux/generic/backport-4.19/744-v5.5-net-sfp-soft-status-and-control-support.patch new file mode 100644 index 000000000..163d8072e --- /dev/null +++ b/target/linux/generic/backport-4.19/744-v5.5-net-sfp-soft-status-and-control-support.patch @@ -0,0 +1,225 @@ +From 40e0b3b15f7da92e6b065292b14af7b9bfb1c6e0 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Fri, 13 Sep 2019 23:00:35 +0100 +Subject: [PATCH 642/660] net: sfp: soft status and control support + +Add support for the soft status and control register, which allows +TX_FAULT and RX_LOS to be monitored and TX_DISABLE to be set. We +make use of this when the board does not support GPIOs for these +signals. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 110 ++++++++++++++++++++++++++++++++++-------- + include/linux/sfp.h | 4 ++ + 2 files changed, 94 insertions(+), 20 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -199,7 +199,10 @@ struct sfp { + struct gpio_desc *gpio[GPIO_MAX]; + int gpio_irq[GPIO_MAX]; + ++ bool need_poll; ++ + struct mutex st_mutex; /* Protects state */ ++ unsigned int state_soft_mask; + unsigned int state; + struct delayed_work poll; + struct delayed_work timeout; +@@ -393,24 +396,90 @@ static int sfp_i2c_configure(struct sfp + } + + /* Interface */ +-static unsigned int sfp_get_state(struct sfp *sfp) ++static int sfp_read(struct sfp *sfp, bool a2, u8 addr, void *buf, size_t len) + { +- return sfp->get_state(sfp); ++ return sfp->read(sfp, a2, addr, buf, len); + } + +-static void sfp_set_state(struct sfp *sfp, unsigned int state) ++static int sfp_write(struct sfp *sfp, bool a2, u8 addr, void *buf, size_t len) + { +- sfp->set_state(sfp, state); ++ return sfp->write(sfp, a2, addr, buf, len); + } + +-static int sfp_read(struct sfp *sfp, bool a2, u8 addr, void *buf, size_t len) ++static unsigned int sfp_soft_get_state(struct sfp *sfp) + { +- return sfp->read(sfp, a2, addr, buf, len); ++ unsigned int state = 0; ++ u8 status; ++ ++ if (sfp_read(sfp, true, SFP_STATUS, &status, sizeof(status)) == ++ sizeof(status)) { ++ if (status & SFP_STATUS_RX_LOS) ++ state |= SFP_F_LOS; ++ if (status & SFP_STATUS_TX_FAULT) ++ state |= SFP_F_TX_FAULT; ++ } ++ ++ return state & sfp->state_soft_mask; + } + +-static int sfp_write(struct sfp *sfp, bool a2, u8 addr, void *buf, size_t len) ++static void sfp_soft_set_state(struct sfp *sfp, unsigned int state) + { +- return sfp->write(sfp, a2, addr, buf, len); ++ u8 status; ++ ++ if (sfp_read(sfp, true, SFP_STATUS, &status, sizeof(status)) == ++ sizeof(status)) { ++ if (state & SFP_F_TX_DISABLE) ++ status |= SFP_STATUS_TX_DISABLE_FORCE; ++ else ++ status &= ~SFP_STATUS_TX_DISABLE_FORCE; ++ ++ sfp_write(sfp, true, SFP_STATUS, &status, sizeof(status)); ++ } ++} ++ ++static void sfp_soft_start_poll(struct sfp *sfp) ++{ ++ const struct sfp_eeprom_id *id = &sfp->id; ++ ++ sfp->state_soft_mask = 0; ++ if (id->ext.enhopts & SFP_ENHOPTS_SOFT_TX_DISABLE && ++ !sfp->gpio[GPIO_TX_DISABLE]) ++ sfp->state_soft_mask |= SFP_F_TX_DISABLE; ++ if (id->ext.enhopts & SFP_ENHOPTS_SOFT_TX_FAULT && ++ !sfp->gpio[GPIO_TX_FAULT]) ++ sfp->state_soft_mask |= SFP_F_TX_FAULT; ++ if (id->ext.enhopts & SFP_ENHOPTS_SOFT_RX_LOS && ++ !sfp->gpio[GPIO_LOS]) ++ sfp->state_soft_mask |= SFP_F_LOS; ++ ++ if (sfp->state_soft_mask & (SFP_F_LOS | SFP_F_TX_FAULT) && ++ !sfp->need_poll) ++ mod_delayed_work(system_wq, &sfp->poll, poll_jiffies); ++} ++ ++static void sfp_soft_stop_poll(struct sfp *sfp) ++{ ++ sfp->state_soft_mask = 0; ++} ++ ++static unsigned int sfp_get_state(struct sfp *sfp) ++{ ++ unsigned int state = sfp->get_state(sfp); ++ ++ if (state & SFP_F_PRESENT && ++ sfp->state_soft_mask & (SFP_F_LOS | SFP_F_TX_FAULT)) ++ state |= sfp_soft_get_state(sfp); ++ ++ return state; ++} ++ ++static void sfp_set_state(struct sfp *sfp, unsigned int state) ++{ ++ sfp->set_state(sfp, state); ++ ++ if (state & SFP_F_PRESENT && ++ sfp->state_soft_mask & SFP_F_TX_DISABLE) ++ sfp_soft_set_state(sfp, state); + } + + static unsigned int sfp_check(void *buf, size_t len) +@@ -1342,11 +1411,6 @@ static void sfp_sm_fault(struct sfp *sfp + } + } + +-static void sfp_sm_mod_init(struct sfp *sfp) +-{ +- sfp_module_tx_enable(sfp); +-} +- + static void sfp_sm_probe_for_phy(struct sfp *sfp) + { + /* Setting the serdes link mode is guesswork: there's no +@@ -1509,7 +1573,7 @@ static int sfp_sm_mod_probe(struct sfp * + (int)sizeof(id.ext.datecode), id.ext.datecode); + + /* Check whether we support this module */ +- if (!sfp->type->module_supported(&sfp->id)) { ++ if (!sfp->type->module_supported(&id)) { + dev_err(sfp->dev, + "module is not supported - phys id 0x%02x 0x%02x\n", + sfp->id.base.phys_id, sfp->id.base.phys_ext_id); +@@ -1699,6 +1763,7 @@ static void sfp_sm_main(struct sfp *sfp, + if (sfp->mod_phy) + sfp_sm_phy_detach(sfp); + sfp_module_tx_disable(sfp); ++ sfp_soft_stop_poll(sfp); + sfp_sm_next(sfp, SFP_S_DOWN, 0); + return; + } +@@ -1710,7 +1775,10 @@ static void sfp_sm_main(struct sfp *sfp, + sfp->sm_dev_state != SFP_DEV_UP) + break; + +- sfp_sm_mod_init(sfp); ++ if (!(sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE)) ++ sfp_soft_start_poll(sfp); ++ ++ sfp_module_tx_enable(sfp); + + /* Initialise the fault clearance retries */ + sfp->sm_retries = 5; +@@ -1966,7 +2034,10 @@ static void sfp_poll(struct work_struct + struct sfp *sfp = container_of(work, struct sfp, poll.work); + + sfp_check_state(sfp); +- mod_delayed_work(system_wq, &sfp->poll, poll_jiffies); ++ ++ if (sfp->state_soft_mask & (SFP_F_LOS | SFP_F_TX_FAULT) || ++ sfp->need_poll) ++ mod_delayed_work(system_wq, &sfp->poll, poll_jiffies); + } + + static struct sfp *sfp_alloc(struct device *dev) +@@ -2010,7 +2081,6 @@ static int sfp_probe(struct platform_dev + { + const struct sff_data *sff; + struct sfp *sfp; +- bool poll = false; + int err, i; + + sfp = sfp_alloc(&pdev->dev); +@@ -2100,7 +2170,7 @@ static int sfp_probe(struct platform_dev + + sfp->gpio_irq[i] = gpiod_to_irq(sfp->gpio[i]); + if (!sfp->gpio_irq[i]) { +- poll = true; ++ sfp->need_poll = true; + continue; + } + +@@ -2112,11 +2182,11 @@ static int sfp_probe(struct platform_dev + dev_name(sfp->dev), sfp); + if (err) { + sfp->gpio_irq[i] = 0; +- poll = true; ++ sfp->need_poll = true; + } + } + +- if (poll) ++ if (sfp->need_poll) + mod_delayed_work(system_wq, &sfp->poll, poll_jiffies); + + /* We could have an issue in cases no Tx disable pin is available or +--- a/include/linux/sfp.h ++++ b/include/linux/sfp.h +@@ -428,6 +428,10 @@ enum { + SFP_TEC_CUR = 0x6c, + + SFP_STATUS = 0x6e, ++ SFP_STATUS_TX_DISABLE = BIT(7), ++ SFP_STATUS_TX_DISABLE_FORCE = BIT(6), ++ SFP_STATUS_TX_FAULT = BIT(2), ++ SFP_STATUS_RX_LOS = BIT(1), + SFP_ALARM0 = 0x70, + SFP_ALARM0_TEMP_HIGH = BIT(7), + SFP_ALARM0_TEMP_LOW = BIT(6), diff --git a/target/linux/generic/config-4.14 b/target/linux/generic/config-4.14 index daf988630..2d001e80c 100644 --- a/target/linux/generic/config-4.14 +++ b/target/linux/generic/config-4.14 @@ -2233,6 +2233,7 @@ CONFIG_KERNFS=y # CONFIG_KEYBOARD_SUNKBD is not set # CONFIG_KEYBOARD_TCA6416 is not set # CONFIG_KEYBOARD_TCA8418 is not set +# CONFIG_KEYBOARD_TEGRA is not set # CONFIG_KEYBOARD_TM2_TOUCHKEY is not set # CONFIG_KEYBOARD_TWL4030 is not set # CONFIG_KEYBOARD_XTKBD is not set @@ -5386,6 +5387,7 @@ CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y # CONFIG_USB_WUSB is not set # CONFIG_USB_WUSB_CBAF is not set # CONFIG_USB_XHCI_HCD is not set +# CONFIG_USB_XHCI_TEGRA is not set # CONFIG_USB_XUSBATM is not set # CONFIG_USB_YUREX is not set # CONFIG_USB_ZD1201 is not set diff --git a/target/linux/generic/hack-4.19/721-phy_packets.patch b/target/linux/generic/hack-4.19/721-phy_packets.patch index b6cbef1e4..1ad7d4676 100644 --- a/target/linux/generic/hack-4.19/721-phy_packets.patch +++ b/target/linux/generic/hack-4.19/721-phy_packets.patch @@ -31,7 +31,7 @@ Signed-off-by: Felix Fietkau /** * struct net_device - The DEVICE structure. -@@ -1844,6 +1846,11 @@ struct net_device { +@@ -1846,6 +1848,11 @@ struct net_device { const struct tlsdev_ops *tlsdev_ops; #endif @@ -43,7 +43,7 @@ Signed-off-by: Felix Fietkau const struct header_ops *header_ops; unsigned int flags; -@@ -1924,6 +1931,10 @@ struct net_device { +@@ -1928,6 +1935,10 @@ struct net_device { struct mpls_dev __rcu *mpls_ptr; #endif @@ -101,7 +101,7 @@ Signed-off-by: Felix Fietkau help --- a/net/core/dev.c +++ b/net/core/dev.c -@@ -3252,10 +3252,20 @@ static int xmit_one(struct sk_buff *skb, +@@ -3253,10 +3253,20 @@ static int xmit_one(struct sk_buff *skb, if (!list_empty(&ptype_all) || !list_empty(&dev->ptype_all)) dev_queue_xmit_nit(skb, dev); diff --git a/target/linux/generic/pending-4.14/640-netfilter-nf_flow_table-add-hardware-offload-support.patch b/target/linux/generic/pending-4.14/640-netfilter-nf_flow_table-add-hardware-offload-support.patch index 9634d3c27..f2aa14c23 100644 --- a/target/linux/generic/pending-4.14/640-netfilter-nf_flow_table-add-hardware-offload-support.patch +++ b/target/linux/generic/pending-4.14/640-netfilter-nf_flow_table-add-hardware-offload-support.patch @@ -506,7 +506,7 @@ Signed-off-by: Pablo Neira Ayuso +MODULE_ALIAS("nf-flow-table-hw"); --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c -@@ -4955,6 +4955,14 @@ static int nf_tables_flowtable_parse_hoo +@@ -4961,6 +4961,14 @@ static int nf_tables_flowtable_parse_hoo if (err < 0) goto err1; @@ -521,7 +521,7 @@ Signed-off-by: Pablo Neira Ayuso ops = kzalloc(sizeof(struct nf_hook_ops) * n, GFP_KERNEL); if (!ops) { err = -ENOMEM; -@@ -5085,10 +5093,19 @@ static int nf_tables_newflowtable(struct +@@ -5091,10 +5099,19 @@ static int nf_tables_newflowtable(struct } flowtable->data.type = type; @@ -541,7 +541,7 @@ Signed-off-by: Pablo Neira Ayuso err = nf_tables_flowtable_parse_hook(&ctx, nla[NFTA_FLOWTABLE_HOOK], flowtable); if (err < 0) -@@ -5186,7 +5203,8 @@ static int nf_tables_fill_flowtable_info +@@ -5192,7 +5209,8 @@ static int nf_tables_fill_flowtable_info nla_put_string(skb, NFTA_FLOWTABLE_NAME, flowtable->name) || nla_put_be32(skb, NFTA_FLOWTABLE_USE, htonl(flowtable->use)) || nla_put_be64(skb, NFTA_FLOWTABLE_HANDLE, cpu_to_be64(flowtable->handle), diff --git a/target/linux/generic/pending-4.14/642-net-8021q-support-hardware-flow-table-offload.patch b/target/linux/generic/pending-4.14/642-net-8021q-support-hardware-flow-table-offload.patch index 4fabfdcb6..4adad67d5 100644 --- a/target/linux/generic/pending-4.14/642-net-8021q-support-hardware-flow-table-offload.patch +++ b/target/linux/generic/pending-4.14/642-net-8021q-support-hardware-flow-table-offload.patch @@ -20,7 +20,7 @@ Signed-off-by: Felix Fietkau #include "vlan.h" #include "vlanproc.h" -@@ -768,6 +772,27 @@ static int vlan_dev_get_iflink(const str +@@ -769,6 +773,27 @@ static int vlan_dev_get_iflink(const str return real_dev->ifindex; } @@ -48,7 +48,7 @@ Signed-off-by: Felix Fietkau static const struct ethtool_ops vlan_ethtool_ops = { .get_link_ksettings = vlan_ethtool_get_link_ksettings, .get_drvinfo = vlan_ethtool_get_drvinfo, -@@ -805,6 +830,9 @@ static const struct net_device_ops vlan_ +@@ -806,6 +831,9 @@ static const struct net_device_ops vlan_ .ndo_fix_features = vlan_dev_fix_features, .ndo_get_lock_subclass = vlan_dev_get_lock_subclass, .ndo_get_iflink = vlan_dev_get_iflink, diff --git a/target/linux/generic/pending-4.14/736-net-phy-at803x-allow-to-configure-via-dt.patch b/target/linux/generic/pending-4.14/736-net-phy-at803x-allow-to-configure-via-dt.patch deleted file mode 100644 index 6bc626dd6..000000000 --- a/target/linux/generic/pending-4.14/736-net-phy-at803x-allow-to-configure-via-dt.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- a/drivers/net/phy/at803x.c -+++ b/drivers/net/phy/at803x.c -@@ -354,6 +354,14 @@ static int at803x_config_init(struct phy - AT803X_DEBUG_TX_CLK_DLY_EN, 0); - } - -+#ifdef CONFIG_OF_MDIO -+ if (phydev->mdio.dev.of_node && -+ of_property_read_bool(phydev->mdio.dev.of_node, -+ "at803x-disable-smarteee")) { -+ at803x_disable_smarteee(phydev); -+ } -+#endif -+ - return 0; - } - -@@ -392,6 +400,7 @@ static void at803x_link_change_notify(st - { - struct at803x_priv *priv = phydev->priv; - struct at803x_platform_data *pdata; -+ u8 fixup_rgmii_tx_delay = 0; - pdata = dev_get_platdata(&phydev->mdio.dev); - - /* -@@ -421,8 +430,19 @@ static void at803x_link_change_notify(st - } else { - priv->phy_reset = false; - } -- if (pdata && pdata->fixup_rgmii_tx_delay && -- phydev->speed != priv->prev_speed) { -+ -+ if (pdata && pdata->fixup_rgmii_tx_delay) -+ fixup_rgmii_tx_delay = 1; -+ -+#ifdef CONFIG_OF_MDIO -+ if (phydev->mdio.dev.of_node && -+ of_property_read_bool(phydev->mdio.dev.of_node, -+ "at803x-fixup-rgmii-tx-delay")) { -+ fixup_rgmii_tx_delay = 1; -+ } -+#endif -+ -+ if (fixup_rgmii_tx_delay && phydev->speed != priv->prev_speed) { - switch (phydev->speed) { - case SPEED_10: - case SPEED_100: diff --git a/target/linux/generic/pending-4.19/330-MIPS-kexec-Accept-command-line-parameters-from-users.patch b/target/linux/generic/pending-4.19/330-MIPS-kexec-Accept-command-line-parameters-from-users.patch index 1187543a4..44d85b5b8 100644 --- a/target/linux/generic/pending-4.19/330-MIPS-kexec-Accept-command-line-parameters-from-users.patch +++ b/target/linux/generic/pending-4.19/330-MIPS-kexec-Accept-command-line-parameters-from-users.patch @@ -29,7 +29,7 @@ Signed-off-by: Yousong Zhou int (*_machine_kexec_prepare)(struct kimage *) = NULL; void (*_machine_kexec_shutdown)(void) = NULL; -@@ -28,6 +25,99 @@ atomic_t kexec_ready_to_reboot = ATOMIC_ +@@ -28,6 +25,101 @@ atomic_t kexec_ready_to_reboot = ATOMIC_ void (*_crash_smp_send_stop)(void) = NULL; #endif @@ -81,7 +81,9 @@ Signed-off-by: Yousong Zhou + pr_warn("kexec command line truncated to %zd bytes\n", size); + + /* Copy to kernel space */ -+ copy_from_user(kexec_argv_buf, buf, size); ++ if (copy_from_user(kexec_argv_buf, buf, size)) ++ pr_warn("kexec command line copy to kernel space failed\n"); ++ + kexec_argv_buf[size - 1] = 0; +} + @@ -129,7 +131,7 @@ Signed-off-by: Yousong Zhou static void kexec_image_info(const struct kimage *kimage) { unsigned long i; -@@ -52,6 +142,18 @@ int +@@ -52,6 +144,18 @@ int machine_kexec_prepare(struct kimage *kimage) { kexec_image_info(kimage); @@ -148,7 +150,7 @@ Signed-off-by: Yousong Zhou if (_machine_kexec_prepare) return _machine_kexec_prepare(kimage); -@@ -89,10 +191,12 @@ machine_kexec(struct kimage *image) +@@ -89,10 +193,12 @@ machine_kexec(struct kimage *image) unsigned long *ptr; reboot_code_buffer = @@ -162,7 +164,7 @@ Signed-off-by: Yousong Zhou if (image->type == KEXEC_TYPE_DEFAULT) { kexec_indirection_page = -@@ -100,9 +204,19 @@ machine_kexec(struct kimage *image) +@@ -100,9 +206,19 @@ machine_kexec(struct kimage *image) } else { kexec_indirection_page = (unsigned long)&image->head; } @@ -184,7 +186,7 @@ Signed-off-by: Yousong Zhou /* * The generic kexec code builds a page list with physical -@@ -124,15 +238,16 @@ machine_kexec(struct kimage *image) +@@ -124,15 +240,16 @@ machine_kexec(struct kimage *image) /* * we do not want to be bothered. */ diff --git a/target/linux/generic/pending-4.19/640-netfilter-nf_flow_table-add-hardware-offload-support.patch b/target/linux/generic/pending-4.19/640-netfilter-nf_flow_table-add-hardware-offload-support.patch index 0a1e017f8..a4996efbc 100644 --- a/target/linux/generic/pending-4.19/640-netfilter-nf_flow_table-add-hardware-offload-support.patch +++ b/target/linux/generic/pending-4.19/640-netfilter-nf_flow_table-add-hardware-offload-support.patch @@ -506,7 +506,7 @@ Signed-off-by: Pablo Neira Ayuso +MODULE_ALIAS("nf-flow-table-hw"); --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c -@@ -5470,6 +5470,13 @@ static int nf_tables_flowtable_parse_hoo +@@ -5490,6 +5490,13 @@ static int nf_tables_flowtable_parse_hoo if (err < 0) return err; @@ -520,7 +520,7 @@ Signed-off-by: Pablo Neira Ayuso ops = kcalloc(n, sizeof(struct nf_hook_ops), GFP_KERNEL); if (!ops) return -ENOMEM; -@@ -5601,10 +5608,19 @@ static int nf_tables_newflowtable(struct +@@ -5621,10 +5628,19 @@ static int nf_tables_newflowtable(struct } flowtable->data.type = type; @@ -540,7 +540,7 @@ Signed-off-by: Pablo Neira Ayuso err = nf_tables_flowtable_parse_hook(&ctx, nla[NFTA_FLOWTABLE_HOOK], flowtable); if (err < 0) -@@ -5730,7 +5746,8 @@ static int nf_tables_fill_flowtable_info +@@ -5750,7 +5766,8 @@ static int nf_tables_fill_flowtable_info nla_put_string(skb, NFTA_FLOWTABLE_NAME, flowtable->name) || nla_put_be32(skb, NFTA_FLOWTABLE_USE, htonl(flowtable->use)) || nla_put_be64(skb, NFTA_FLOWTABLE_HANDLE, cpu_to_be64(flowtable->handle), diff --git a/target/linux/generic/pending-4.19/642-net-8021q-support-hardware-flow-table-offload.patch b/target/linux/generic/pending-4.19/642-net-8021q-support-hardware-flow-table-offload.patch index 724f1c46c..7547c14be 100644 --- a/target/linux/generic/pending-4.19/642-net-8021q-support-hardware-flow-table-offload.patch +++ b/target/linux/generic/pending-4.19/642-net-8021q-support-hardware-flow-table-offload.patch @@ -20,7 +20,7 @@ Signed-off-by: Felix Fietkau #include "vlan.h" #include "vlanproc.h" -@@ -770,6 +774,27 @@ static int vlan_dev_get_iflink(const str +@@ -771,6 +775,27 @@ static int vlan_dev_get_iflink(const str return real_dev->ifindex; } @@ -48,7 +48,7 @@ Signed-off-by: Felix Fietkau static const struct ethtool_ops vlan_ethtool_ops = { .get_link_ksettings = vlan_ethtool_get_link_ksettings, .get_drvinfo = vlan_ethtool_get_drvinfo, -@@ -807,6 +832,9 @@ static const struct net_device_ops vlan_ +@@ -808,6 +833,9 @@ static const struct net_device_ops vlan_ .ndo_fix_features = vlan_dev_fix_features, .ndo_get_lock_subclass = vlan_dev_get_lock_subclass, .ndo_get_iflink = vlan_dev_get_iflink, diff --git a/target/linux/generic/pending-4.19/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch b/target/linux/generic/pending-4.19/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch index 842a3fa37..c35aca8a1 100644 --- a/target/linux/generic/pending-4.19/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch +++ b/target/linux/generic/pending-4.19/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch @@ -218,7 +218,7 @@ Signed-off-by: Jonas Gorski #endif net->ipv6.sysctl.flush_delay = 0; -@@ -5327,6 +5372,8 @@ out: +@@ -5307,6 +5350,8 @@ out: return ret; #ifdef CONFIG_IPV6_MULTIPLE_TABLES @@ -227,7 +227,7 @@ Signed-off-by: Jonas Gorski out_ip6_prohibit_entry: kfree(net->ipv6.ip6_prohibit_entry); out_ip6_null_entry: -@@ -5403,6 +5449,7 @@ static void __net_exit ip6_route_net_exi +@@ -5327,6 +5372,7 @@ static void __net_exit ip6_route_net_exi #ifdef CONFIG_IPV6_MULTIPLE_TABLES kfree(net->ipv6.ip6_prohibit_entry); kfree(net->ipv6.ip6_blk_hole_entry); @@ -235,7 +235,7 @@ Signed-off-by: Jonas Gorski #endif dst_entries_destroy(&net->ipv6.ip6_dst_ops); } -@@ -5395,6 +5441,9 @@ void __init ip6_route_init_special_entri +@@ -5403,6 +5449,9 @@ void __init ip6_route_init_special_entri init_net.ipv6.ip6_prohibit_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev); init_net.ipv6.ip6_blk_hole_entry->dst.dev = init_net.loopback_dev; init_net.ipv6.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev); diff --git a/target/linux/generic/pending-4.19/680-NET-skip-GRO-for-foreign-MAC-addresses.patch b/target/linux/generic/pending-4.19/680-NET-skip-GRO-for-foreign-MAC-addresses.patch index 1e52d2f2a..ad7ccdb04 100644 --- a/target/linux/generic/pending-4.19/680-NET-skip-GRO-for-foreign-MAC-addresses.patch +++ b/target/linux/generic/pending-4.19/680-NET-skip-GRO-for-foreign-MAC-addresses.patch @@ -11,7 +11,7 @@ Signed-off-by: Felix Fietkau --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h -@@ -1887,6 +1887,8 @@ struct net_device { +@@ -1891,6 +1891,8 @@ struct net_device { struct netdev_hw_addr_list mc; struct netdev_hw_addr_list dev_addrs; @@ -32,7 +32,7 @@ Signed-off-by: Felix Fietkau __u16 tc_index; /* traffic control index */ --- a/net/core/dev.c +++ b/net/core/dev.c -@@ -5482,6 +5482,9 @@ static enum gro_result dev_gro_receive(s +@@ -5483,6 +5483,9 @@ static enum gro_result dev_gro_receive(s int same_flow; int grow; @@ -42,7 +42,7 @@ Signed-off-by: Felix Fietkau if (netif_elide_gro(skb->dev)) goto normal; -@@ -6976,6 +6979,48 @@ static void __netdev_adjacent_dev_unlink +@@ -7141,6 +7144,48 @@ static void __netdev_adjacent_dev_unlink &upper_dev->adj_list.lower); } @@ -91,7 +91,7 @@ Signed-off-by: Felix Fietkau static int __netdev_upper_dev_link(struct net_device *dev, struct net_device *upper_dev, bool master, void *upper_priv, void *upper_info, -@@ -7023,6 +7068,7 @@ static int __netdev_upper_dev_link(struc +@@ -7191,6 +7236,7 @@ static int __netdev_upper_dev_link(struc if (ret) return ret; @@ -99,15 +99,15 @@ Signed-off-by: Felix Fietkau ret = call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, &changeupper_info.info); ret = notifier_to_errno(ret); -@@ -7109,6 +7155,7 @@ void netdev_upper_dev_unlink(struct net_ +@@ -7283,6 +7329,7 @@ void netdev_upper_dev_unlink(struct net_ __netdev_adjacent_dev_unlink_neighbour(dev, upper_dev); + netdev_update_addr_mask(dev); call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, &changeupper_info.info); - } -@@ -7733,6 +7780,7 @@ int dev_set_mac_address(struct net_devic + +@@ -7913,6 +7960,7 @@ int dev_set_mac_address(struct net_devic if (err) return err; dev->addr_assign_type = NET_ADDR_SET; diff --git a/target/linux/generic/pending-4.19/703-phy-add-detach-callback-to-struct-phy_driver.patch b/target/linux/generic/pending-4.19/703-phy-add-detach-callback-to-struct-phy_driver.patch index f86323820..dafd84759 100644 --- a/target/linux/generic/pending-4.19/703-phy-add-detach-callback-to-struct-phy_driver.patch +++ b/target/linux/generic/pending-4.19/703-phy-add-detach-callback-to-struct-phy_driver.patch @@ -11,7 +11,7 @@ Signed-off-by: Gabor Juhos --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c -@@ -1136,6 +1136,9 @@ void phy_detach(struct phy_device *phyde +@@ -1200,6 +1200,9 @@ void phy_detach(struct phy_device *phyde struct module *ndev_owner = dev->dev.parent->driver->owner; struct mii_bus *bus; @@ -23,7 +23,7 @@ Signed-off-by: Gabor Juhos sysfs_remove_link(&phydev->mdio.dev.kobj, "attached_dev"); --- a/include/linux/phy.h +++ b/include/linux/phy.h -@@ -560,6 +560,12 @@ struct phy_driver { +@@ -567,6 +567,12 @@ struct phy_driver { */ int (*did_interrupt)(struct phy_device *phydev); diff --git a/target/linux/generic/pending-4.19/734-net-phy-at803x-allow-to-configure-via-pdata.patch b/target/linux/generic/pending-4.19/734-net-phy-at803x-allow-to-configure-via-pdata.patch deleted file mode 100644 index e56e77add..000000000 --- a/target/linux/generic/pending-4.19/734-net-phy-at803x-allow-to-configure-via-pdata.patch +++ /dev/null @@ -1,142 +0,0 @@ -From: Gabor Juhos -Subject: net: phy: allow to configure AR803x PHYs via platform data - -Add a patch for the at803x phy driver, in order to be able -to configure some register settings via platform data. - -Signed-off-by: Gabor Juhos ---- - drivers/net/phy/at803x.c | 56 ++++++++++++++++++++++++++++++++ - include/linux/platform_data/phy-at803x.h | 11 +++++++ - 2 files changed, 67 insertions(+) - create mode 100644 include/linux/platform_data/phy-at803x.h - ---- a/drivers/net/phy/at803x.c -+++ b/drivers/net/phy/at803x.c -@@ -12,12 +12,14 @@ - */ - - #include -+#include - #include - #include - #include - #include - #include - #include -+#include - - #define AT803X_INTR_ENABLE 0x12 - #define AT803X_INTR_ENABLE_AUTONEG_ERR BIT(15) -@@ -45,6 +47,11 @@ - #define AT803X_REG_CHIP_CONFIG 0x1f - #define AT803X_BT_BX_REG_SEL 0x8000 - -+#define AT803X_PCS_SMART_EEE_CTRL3 0x805D -+#define AT803X_SMART_EEE_CTRL3_LPI_TX_DELAY_SEL_MASK 0x3 -+#define AT803X_SMART_EEE_CTRL3_LPI_TX_DELAY_SEL_SHIFT 12 -+#define AT803X_SMART_EEE_CTRL3_LPI_EN BIT(8) -+ - #define AT803X_DEBUG_ADDR 0x1D - #define AT803X_DEBUG_DATA 0x1E - -@@ -73,6 +80,7 @@ MODULE_LICENSE("GPL"); - - struct at803x_priv { - bool phy_reset:1; -+ int prev_speed; - }; - - struct at803x_context { -@@ -249,8 +257,16 @@ static int at803x_probe(struct phy_devic - return 0; - } - -+static void at803x_disable_smarteee(struct phy_device *phydev) -+{ -+ phy_write_mmd(phydev, MDIO_MMD_PCS, AT803X_PCS_SMART_EEE_CTRL3, -+ 1 << AT803X_SMART_EEE_CTRL3_LPI_TX_DELAY_SEL_SHIFT); -+ phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, 0); -+} -+ - static int at803x_config_init(struct phy_device *phydev) - { -+ struct at803x_platform_data *pdata; - int ret; - - ret = genphy_config_init(phydev); -@@ -271,6 +287,26 @@ static int at803x_config_init(struct phy - return ret; - } - -+ pdata = dev_get_platdata(&phydev->mdio.dev); -+ if (pdata) { -+ if (pdata->disable_smarteee) -+ at803x_disable_smarteee(phydev); -+ -+ if (pdata->enable_rgmii_rx_delay) -+ at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0, 0, -+ AT803X_DEBUG_RX_CLK_DLY_EN); -+ else -+ at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0, -+ AT803X_DEBUG_RX_CLK_DLY_EN, 0); -+ -+ if (pdata->enable_rgmii_tx_delay) -+ at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_5, 0, -+ AT803X_DEBUG_TX_CLK_DLY_EN); -+ else -+ at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_5, -+ AT803X_DEBUG_TX_CLK_DLY_EN, 0); -+ } -+ - return 0; - } - -@@ -308,6 +344,8 @@ static int at803x_config_intr(struct phy - static void at803x_link_change_notify(struct phy_device *phydev) - { - struct at803x_priv *priv = phydev->priv; -+ struct at803x_platform_data *pdata; -+ pdata = dev_get_platdata(&phydev->mdio.dev); - - /* - * Conduct a hardware reset for AT8030/2 every time a link loss is -@@ -336,6 +374,24 @@ static void at803x_link_change_notify(st - } else { - priv->phy_reset = false; - } -+ if (pdata && pdata->fixup_rgmii_tx_delay && -+ phydev->speed != priv->prev_speed) { -+ switch (phydev->speed) { -+ case SPEED_10: -+ case SPEED_100: -+ at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_5, 0, -+ AT803X_DEBUG_TX_CLK_DLY_EN); -+ break; -+ case SPEED_1000: -+ at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_5, -+ AT803X_DEBUG_TX_CLK_DLY_EN, 0); -+ break; -+ default: -+ break; -+ } -+ -+ priv->prev_speed = phydev->speed; -+ } - } - - static int at803x_aneg_done(struct phy_device *phydev) ---- /dev/null -+++ b/include/linux/platform_data/phy-at803x.h -@@ -0,0 +1,11 @@ -+#ifndef _PHY_AT803X_PDATA_H -+#define _PHY_AT803X_PDATA_H -+ -+struct at803x_platform_data { -+ int disable_smarteee:1; -+ int enable_rgmii_tx_delay:1; -+ int enable_rgmii_rx_delay:1; -+ int fixup_rgmii_tx_delay:1; -+}; -+ -+#endif /* _PHY_AT803X_PDATA_H */ diff --git a/target/linux/generic/pending-4.19/735-net-phy-at803x-fix-at8033-sgmii-mode.patch b/target/linux/generic/pending-4.19/735-net-phy-at803x-fix-at8033-sgmii-mode.patch index 1f81b37f7..5c00b8781 100644 --- a/target/linux/generic/pending-4.19/735-net-phy-at803x-fix-at8033-sgmii-mode.patch +++ b/target/linux/generic/pending-4.19/735-net-phy-at803x-fix-at8033-sgmii-mode.patch @@ -13,17 +13,17 @@ Signed-off-by: Roman Yeryomin --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c -@@ -46,6 +46,7 @@ +@@ -44,6 +44,7 @@ #define AT803X_FUNC_DATA 0x4003 #define AT803X_REG_CHIP_CONFIG 0x1f #define AT803X_BT_BX_REG_SEL 0x8000 +#define AT803X_SGMII_ANEG_EN 0x1000 - #define AT803X_PCS_SMART_EEE_CTRL3 0x805D - #define AT803X_SMART_EEE_CTRL3_LPI_TX_DELAY_SEL_MASK 0x3 -@@ -268,6 +269,27 @@ static int at803x_config_init(struct phy + #define AT803X_DEBUG_ADDR 0x1D + #define AT803X_DEBUG_DATA 0x1E +@@ -252,6 +253,27 @@ static int at803x_probe(struct phy_devic + static int at803x_config_init(struct phy_device *phydev) { - struct at803x_platform_data *pdata; int ret; + u32 v; + diff --git a/target/linux/generic/pending-4.19/736-net-phy-at803x-allow-to-configure-via-dt.patch b/target/linux/generic/pending-4.19/736-net-phy-at803x-allow-to-configure-via-dt.patch deleted file mode 100644 index 496700f37..000000000 --- a/target/linux/generic/pending-4.19/736-net-phy-at803x-allow-to-configure-via-dt.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- a/drivers/net/phy/at803x.c -+++ b/drivers/net/phy/at803x.c -@@ -329,6 +329,14 @@ static int at803x_config_init(struct phy - AT803X_DEBUG_TX_CLK_DLY_EN, 0); - } - -+#ifdef CONFIG_OF_MDIO -+ if (phydev->mdio.dev.of_node && -+ of_property_read_bool(phydev->mdio.dev.of_node, -+ "at803x-disable-smarteee")) { -+ at803x_disable_smarteee(phydev); -+ } -+#endif -+ - return 0; - } - -@@ -367,6 +375,7 @@ static void at803x_link_change_notify(st - { - struct at803x_priv *priv = phydev->priv; - struct at803x_platform_data *pdata; -+ u8 fixup_rgmii_tx_delay = 0; - pdata = dev_get_platdata(&phydev->mdio.dev); - - /* -@@ -396,8 +405,19 @@ static void at803x_link_change_notify(st - } else { - priv->phy_reset = false; - } -- if (pdata && pdata->fixup_rgmii_tx_delay && -- phydev->speed != priv->prev_speed) { -+ -+ if (pdata && pdata->fixup_rgmii_tx_delay) -+ fixup_rgmii_tx_delay = 1; -+ -+#ifdef CONFIG_OF_MDIO -+ if (phydev->mdio.dev.of_node && -+ of_property_read_bool(phydev->mdio.dev.of_node, -+ "at803x-fixup-rgmii-tx-delay")) { -+ fixup_rgmii_tx_delay = 1; -+ } -+#endif -+ -+ if (fixup_rgmii_tx_delay && phydev->speed != priv->prev_speed) { - switch (phydev->speed) { - case SPEED_10: - case SPEED_100: diff --git a/target/linux/generic/pending-4.19/739-net-avoid-tx-fault-with-Nokia-GPON-module.patch b/target/linux/generic/pending-4.19/739-net-avoid-tx-fault-with-Nokia-GPON-module.patch new file mode 100644 index 000000000..b540e1dbc --- /dev/null +++ b/target/linux/generic/pending-4.19/739-net-avoid-tx-fault-with-Nokia-GPON-module.patch @@ -0,0 +1,108 @@ +From 283b211aa01bdae94dffb3121655dbb20bf237f4 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 3 Dec 2019 15:22:05 +0000 +Subject: net: sfp: avoid tx-fault with Nokia GPON module + +The Nokia GPON module can hold tx-fault active while it is initialising +which can take up to 60s. Avoid this causing the module to be declared +faulty after the SFP MSA defined non-cooled module timeout. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 42 ++++++++++++++++++++++++++++++------------ + 1 file changed, 30 insertions(+), 12 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -153,10 +153,20 @@ static const enum gpiod_flags gpio_flags + GPIOD_ASIS, + }; + +-#define T_WAIT msecs_to_jiffies(50) +-#define T_INIT_JIFFIES msecs_to_jiffies(300) +-#define T_RESET_US 10 +-#define T_FAULT_RECOVER msecs_to_jiffies(1000) ++/* t_start_up (SFF-8431) or t_init (SFF-8472) is the time required for a ++ * non-cooled module to initialise its laser safety circuitry. We wait ++ * an initial T_WAIT period before we check the tx fault to give any PHY ++ * on board (for a copper SFP) time to initialise. ++ */ ++#define T_WAIT msecs_to_jiffies(50) ++#define T_START_UP msecs_to_jiffies(300) ++#define T_START_UP_BAD_GPON msecs_to_jiffies(60000) ++ ++/* t_reset is the time required to assert the TX_DISABLE signal to reset ++ * an indicated TX_FAULT. ++ */ ++#define T_RESET_US 10 ++#define T_FAULT_RECOVER msecs_to_jiffies(1000) + + /* SFP module presence detection is poor: the three MOD DEF signals are + * the same length on the PCB, which means it's possible for MOD DEF 0 to +@@ -216,6 +226,7 @@ struct sfp { + + struct sfp_eeprom_id id; + unsigned int module_power_mW; ++ unsigned int module_t_start_up; + + #if IS_ENABLED(CONFIG_HWMON) + struct sfp_diag diag; +@@ -1590,6 +1601,12 @@ static int sfp_sm_mod_probe(struct sfp * + if (ret < 0) + return ret; + ++ if (!memcmp(id.base.vendor_name, "ALCATELLUCENT ", 16) && ++ !memcmp(id.base.vendor_pn, "3FE46541AA ", 16)) ++ sfp->module_t_start_up = T_START_UP_BAD_GPON; ++ else ++ sfp->module_t_start_up = T_START_UP; ++ + return 0; + } + +@@ -1795,11 +1812,12 @@ static void sfp_sm_main(struct sfp *sfp, + break; + + if (sfp->state & SFP_F_TX_FAULT) { +- /* Wait t_init before indicating that the link is up, +- * provided the current state indicates no TX_FAULT. If +- * TX_FAULT clears before this time, that's fine too. ++ /* Wait up to t_init (SFF-8472) or t_start_up (SFF-8431) ++ * from the TX_DISABLE deassertion for the module to ++ * initialise, which is indicated by TX_FAULT ++ * deasserting. + */ +- timeout = T_INIT_JIFFIES; ++ timeout = sfp->module_t_start_up; + if (timeout > T_WAIT) + timeout -= T_WAIT; + else +@@ -1816,8 +1834,8 @@ static void sfp_sm_main(struct sfp *sfp, + + case SFP_S_INIT: + if (event == SFP_E_TIMEOUT && sfp->state & SFP_F_TX_FAULT) { +- /* TX_FAULT is still asserted after t_init, so assume +- * there is a fault. ++ /* TX_FAULT is still asserted after t_init or ++ * or t_start_up, so assume there is a fault. + */ + sfp_sm_fault(sfp, SFP_S_INIT_TX_FAULT, + sfp->sm_retries == 5); +@@ -1836,7 +1854,7 @@ static void sfp_sm_main(struct sfp *sfp, + case SFP_S_INIT_TX_FAULT: + if (event == SFP_E_TIMEOUT) { + sfp_module_tx_fault_reset(sfp); +- sfp_sm_next(sfp, SFP_S_INIT, T_INIT_JIFFIES); ++ sfp_sm_next(sfp, SFP_S_INIT, sfp->module_t_start_up); + } + break; + +@@ -1860,7 +1878,7 @@ static void sfp_sm_main(struct sfp *sfp, + case SFP_S_TX_FAULT: + if (event == SFP_E_TIMEOUT) { + sfp_module_tx_fault_reset(sfp); +- sfp_sm_next(sfp, SFP_S_REINIT, T_INIT_JIFFIES); ++ sfp_sm_next(sfp, SFP_S_REINIT, sfp->module_t_start_up); + } + break; + diff --git a/target/linux/generic/pending-4.19/740-net-sfp-remove-incomplete-100BASE-FX-and-100BASE-LX-.patch b/target/linux/generic/pending-4.19/740-net-sfp-remove-incomplete-100BASE-FX-and-100BASE-LX-.patch new file mode 100644 index 000000000..304d9b40b --- /dev/null +++ b/target/linux/generic/pending-4.19/740-net-sfp-remove-incomplete-100BASE-FX-and-100BASE-LX-.patch @@ -0,0 +1,52 @@ +From 29cd215aaf6c2050c43e4de03aee436c16f90b96 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Thu, 21 Nov 2019 17:27:14 +0000 +Subject: [PATCH 643/660] net: sfp: remove incomplete 100BASE-FX and 100BASE-LX + support + +The 100BASE-FX and 100BASE-LX support assumes a PHY is present; this +is probably an incorrect assumption. In any case, sfp_parse_support() +will fail such a module. Let's stop pretending we support these +modules. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp-bus.c | 4 +--- + drivers/net/phy/sfp.c | 13 +------------ + 2 files changed, 2 insertions(+), 15 deletions(-) + +--- a/drivers/net/phy/sfp-bus.c ++++ b/drivers/net/phy/sfp-bus.c +@@ -341,9 +341,7 @@ phy_interface_t sfp_select_interface(str + if (phylink_test(link_modes, 2500baseX_Full)) + return PHY_INTERFACE_MODE_2500BASEX; + +- if (id->base.e1000_base_t || +- id->base.e100_base_lx || +- id->base.e100_base_fx) ++ if (id->base.e1000_base_t) + return PHY_INTERFACE_MODE_SGMII; + + if (phylink_test(link_modes, 1000baseX_Full)) +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -1424,18 +1424,7 @@ static void sfp_sm_fault(struct sfp *sfp + + static void sfp_sm_probe_for_phy(struct sfp *sfp) + { +- /* Setting the serdes link mode is guesswork: there's no +- * field in the EEPROM which indicates what mode should +- * be used. +- * +- * If it's a gigabit-only fiber module, it probably does +- * not have a PHY, so switch to 802.3z negotiation mode. +- * Otherwise, switch to SGMII mode (which is required to +- * support non-gigabit speeds) and probe for a PHY. +- */ +- if (sfp->id.base.e1000_base_t || +- sfp->id.base.e100_base_lx || +- sfp->id.base.e100_base_fx) ++ if (sfp->id.base.e1000_base_t) + sfp_sm_probe_phy(sfp); + } + diff --git a/target/linux/generic/pending-4.19/741-net-sfp-derive-interface-mode-from-ethtool-link-mode.patch b/target/linux/generic/pending-4.19/741-net-sfp-derive-interface-mode-from-ethtool-link-mode.patch new file mode 100644 index 000000000..f20b66eae --- /dev/null +++ b/target/linux/generic/pending-4.19/741-net-sfp-derive-interface-mode-from-ethtool-link-mode.patch @@ -0,0 +1,89 @@ +From dc45d9e04572b5cd6d32f51cdf9f62b18022e6dd Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Thu, 21 Nov 2019 17:32:59 +0000 +Subject: [PATCH 644/660] net: sfp: derive interface mode from ethtool link + modes + +We don't need the EEPROM ID to derive the phy interface mode as we can +derive it merely from the ethtool link modes. Remove the EEPROM ID +argument to sfp_select_interface(). + +Signed-off-by: Russell King +--- + drivers/net/phy/marvell10g.c | 2 +- + drivers/net/phy/phylink.c | 2 +- + drivers/net/phy/sfp-bus.c | 11 ++++------- + include/linux/sfp.h | 2 -- + 4 files changed, 6 insertions(+), 11 deletions(-) + +--- a/drivers/net/phy/marvell10g.c ++++ b/drivers/net/phy/marvell10g.c +@@ -227,7 +227,7 @@ static int mv3310_sfp_insert(void *upstr + phy_interface_t iface; + + sfp_parse_support(phydev->sfp_bus, id, support); +- iface = sfp_select_interface(phydev->sfp_bus, id, support); ++ iface = sfp_select_interface(phydev->sfp_bus, support); + + if (iface != PHY_INTERFACE_MODE_10GKR) { + dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n"); +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -1663,7 +1663,7 @@ static int phylink_sfp_module_insert(voi + + linkmode_copy(support1, support); + +- iface = sfp_select_interface(pl->sfp_bus, id, config.advertising); ++ iface = sfp_select_interface(pl->sfp_bus, config.advertising); + if (iface == PHY_INTERFACE_MODE_NA) { + netdev_err(pl->netdev, + "selection of interface failed, advertisement %*pb\n", +--- a/drivers/net/phy/sfp-bus.c ++++ b/drivers/net/phy/sfp-bus.c +@@ -319,16 +319,12 @@ EXPORT_SYMBOL_GPL(sfp_parse_support); + /** + * sfp_select_interface() - Select appropriate phy_interface_t mode + * @bus: a pointer to the &struct sfp_bus structure for the sfp module +- * @id: a pointer to the module's &struct sfp_eeprom_id + * @link_modes: ethtool link modes mask + * +- * Derive the phy_interface_t mode for the information found in the +- * module's identifying EEPROM and the link modes mask. There is no +- * standard or defined way to derive this information, so we decide +- * based upon the link mode mask. ++ * Derive the phy_interface_t mode for the SFP module from the link ++ * modes mask. + */ + phy_interface_t sfp_select_interface(struct sfp_bus *bus, +- const struct sfp_eeprom_id *id, + unsigned long *link_modes) + { + if (phylink_test(link_modes, 10000baseCR_Full) || +@@ -341,7 +337,8 @@ phy_interface_t sfp_select_interface(str + if (phylink_test(link_modes, 2500baseX_Full)) + return PHY_INTERFACE_MODE_2500BASEX; + +- if (id->base.e1000_base_t) ++ if (phylink_test(link_modes, 1000baseT_Half) || ++ phylink_test(link_modes, 1000baseT_Full)) + return PHY_INTERFACE_MODE_SGMII; + + if (phylink_test(link_modes, 1000baseX_Full)) +--- a/include/linux/sfp.h ++++ b/include/linux/sfp.h +@@ -504,7 +504,6 @@ int sfp_parse_port(struct sfp_bus *bus, + void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id, + unsigned long *support); + phy_interface_t sfp_select_interface(struct sfp_bus *bus, +- const struct sfp_eeprom_id *id, + unsigned long *link_modes); + + int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo); +@@ -532,7 +531,6 @@ static inline void sfp_parse_support(str + } + + static inline phy_interface_t sfp_select_interface(struct sfp_bus *bus, +- const struct sfp_eeprom_id *id, + unsigned long *link_modes) + { + return PHY_INTERFACE_MODE_NA; diff --git a/target/linux/generic/pending-4.19/742-net-sfp-add-more-extended-compliance-codes.patch b/target/linux/generic/pending-4.19/742-net-sfp-add-more-extended-compliance-codes.patch new file mode 100644 index 000000000..4ca0ded55 --- /dev/null +++ b/target/linux/generic/pending-4.19/742-net-sfp-add-more-extended-compliance-codes.patch @@ -0,0 +1,251 @@ +From c66a4e76c8554c84e64b9315314576ac403c6641 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Thu, 26 Sep 2019 15:14:18 +0100 +Subject: [PATCH 645/660] net: sfp: add more extended compliance codes + +SFF-8024 is used to define various constants re-used in several SFF +SFP-related specifications. Split these constants from the enum, and +rename them to indicate that they're defined by SFF-8024. + +Add and use updated SFF-8024 extended compliance code definitions for +10GBASE-T, 5GBASE-T and 2.5GBASE-T modules. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp-bus.c | 60 ++++++++++++++++------------ + drivers/net/phy/sfp.c | 4 +- + include/linux/sfp.h | 82 ++++++++++++++++++++++++++------------- + 3 files changed, 93 insertions(+), 53 deletions(-) + +--- a/drivers/net/phy/sfp-bus.c ++++ b/drivers/net/phy/sfp-bus.c +@@ -123,35 +123,35 @@ int sfp_parse_port(struct sfp_bus *bus, + + /* port is the physical connector, set this from the connector field. */ + switch (id->base.connector) { +- case SFP_CONNECTOR_SC: +- case SFP_CONNECTOR_FIBERJACK: +- case SFP_CONNECTOR_LC: +- case SFP_CONNECTOR_MT_RJ: +- case SFP_CONNECTOR_MU: +- case SFP_CONNECTOR_OPTICAL_PIGTAIL: ++ case SFF8024_CONNECTOR_SC: ++ case SFF8024_CONNECTOR_FIBERJACK: ++ case SFF8024_CONNECTOR_LC: ++ case SFF8024_CONNECTOR_MT_RJ: ++ case SFF8024_CONNECTOR_MU: ++ case SFF8024_CONNECTOR_OPTICAL_PIGTAIL: ++ case SFF8024_CONNECTOR_MPO_1X12: ++ case SFF8024_CONNECTOR_MPO_2X16: + port = PORT_FIBRE; + break; + +- case SFP_CONNECTOR_RJ45: ++ case SFF8024_CONNECTOR_RJ45: + port = PORT_TP; + break; + +- case SFP_CONNECTOR_COPPER_PIGTAIL: ++ case SFF8024_CONNECTOR_COPPER_PIGTAIL: + port = PORT_DA; + break; + +- case SFP_CONNECTOR_UNSPEC: ++ case SFF8024_CONNECTOR_UNSPEC: + if (id->base.e1000_base_t) { + port = PORT_TP; + break; + } + /* fallthrough */ +- case SFP_CONNECTOR_SG: /* guess */ +- case SFP_CONNECTOR_MPO_1X12: +- case SFP_CONNECTOR_MPO_2X16: +- case SFP_CONNECTOR_HSSDC_II: +- case SFP_CONNECTOR_NOSEPARATE: +- case SFP_CONNECTOR_MXC_2X16: ++ case SFF8024_CONNECTOR_SG: /* guess */ ++ case SFF8024_CONNECTOR_HSSDC_II: ++ case SFF8024_CONNECTOR_NOSEPARATE: ++ case SFF8024_CONNECTOR_MXC_2X16: + port = PORT_OTHER; + break; + default: +@@ -260,22 +260,33 @@ void sfp_parse_support(struct sfp_bus *b + } + + switch (id->base.extended_cc) { +- case 0x00: /* Unspecified */ ++ case SFF8024_ECC_UNSPEC: + break; +- case 0x02: /* 100Gbase-SR4 or 25Gbase-SR */ ++ case SFF8024_ECC_100GBASE_SR4_25GBASE_SR: + phylink_set(modes, 100000baseSR4_Full); + phylink_set(modes, 25000baseSR_Full); + break; +- case 0x03: /* 100Gbase-LR4 or 25Gbase-LR */ +- case 0x04: /* 100Gbase-ER4 or 25Gbase-ER */ ++ case SFF8024_ECC_100GBASE_LR4_25GBASE_LR: ++ case SFF8024_ECC_100GBASE_ER4_25GBASE_ER: + phylink_set(modes, 100000baseLR4_ER4_Full); + break; +- case 0x0b: /* 100Gbase-CR4 or 25Gbase-CR CA-L */ +- case 0x0c: /* 25Gbase-CR CA-S */ +- case 0x0d: /* 25Gbase-CR CA-N */ ++ case SFF8024_ECC_100GBASE_CR4: + phylink_set(modes, 100000baseCR4_Full); ++ /* fallthrough */ ++ case SFF8024_ECC_25GBASE_CR_S: ++ case SFF8024_ECC_25GBASE_CR_N: + phylink_set(modes, 25000baseCR_Full); + break; ++ case SFF8024_ECC_10GBASE_T_SFI: ++ case SFF8024_ECC_10GBASE_T_SR: ++ phylink_set(modes, 10000baseT_Full); ++ break; ++ case SFF8024_ECC_5GBASE_T: ++ phylink_set(modes, 5000baseT_Full); ++ break; ++ case SFF8024_ECC_2_5GBASE_T: ++ phylink_set(modes, 2500baseT_Full); ++ break; + default: + dev_warn(bus->sfp_dev, + "Unknown/unsupported extended compliance code: 0x%02x\n", +@@ -300,7 +311,7 @@ void sfp_parse_support(struct sfp_bus *b + */ + if (bitmap_empty(modes, __ETHTOOL_LINK_MODE_MASK_NBITS)) { + /* If the encoding and bit rate allows 1000baseX */ +- if (id->base.encoding == SFP_ENCODING_8B10B && br_nom && ++ if (id->base.encoding == SFF8024_ENCODING_8B10B && br_nom && + br_min <= 1300 && br_max >= 1200) + phylink_set(modes, 1000baseX_Full); + } +@@ -331,7 +342,8 @@ phy_interface_t sfp_select_interface(str + phylink_test(link_modes, 10000baseSR_Full) || + phylink_test(link_modes, 10000baseLR_Full) || + phylink_test(link_modes, 10000baseLRM_Full) || +- phylink_test(link_modes, 10000baseER_Full)) ++ phylink_test(link_modes, 10000baseER_Full) || ++ phylink_test(link_modes, 10000baseT_Full)) + return PHY_INTERFACE_MODE_10GKR; + + if (phylink_test(link_modes, 2500baseX_Full)) +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -240,7 +240,7 @@ struct sfp { + + static bool sff_module_supported(const struct sfp_eeprom_id *id) + { +- return id->base.phys_id == SFP_PHYS_ID_SFF && ++ return id->base.phys_id == SFF8024_ID_SFF_8472 && + id->base.phys_ext_id == SFP_PHYS_EXT_ID_SFP; + } + +@@ -251,7 +251,7 @@ static const struct sff_data sff_data = + + static bool sfp_module_supported(const struct sfp_eeprom_id *id) + { +- return id->base.phys_id == SFP_PHYS_ID_SFP && ++ return id->base.phys_id == SFF8024_ID_SFP && + id->base.phys_ext_id == SFP_PHYS_EXT_ID_SFP; + } + +--- a/include/linux/sfp.h ++++ b/include/linux/sfp.h +@@ -275,6 +275,61 @@ struct sfp_diag { + __be16 cal_v_offset; + } __packed; + ++/* SFF8024 defined constants */ ++enum { ++ SFF8024_ID_UNK = 0x00, ++ SFF8024_ID_SFF_8472 = 0x02, ++ SFF8024_ID_SFP = 0x03, ++ SFF8024_ID_DWDM_SFP = 0x0b, ++ SFF8024_ID_QSFP_8438 = 0x0c, ++ SFF8024_ID_QSFP_8436_8636 = 0x0d, ++ SFF8024_ID_QSFP28_8636 = 0x11, ++ ++ SFF8024_ENCODING_UNSPEC = 0x00, ++ SFF8024_ENCODING_8B10B = 0x01, ++ SFF8024_ENCODING_4B5B = 0x02, ++ SFF8024_ENCODING_NRZ = 0x03, ++ SFF8024_ENCODING_8472_MANCHESTER= 0x04, ++ SFF8024_ENCODING_8472_SONET = 0x05, ++ SFF8024_ENCODING_8472_64B66B = 0x06, ++ SFF8024_ENCODING_8436_MANCHESTER= 0x06, ++ SFF8024_ENCODING_8436_SONET = 0x04, ++ SFF8024_ENCODING_8436_64B66B = 0x05, ++ SFF8024_ENCODING_256B257B = 0x07, ++ SFF8024_ENCODING_PAM4 = 0x08, ++ ++ SFF8024_CONNECTOR_UNSPEC = 0x00, ++ /* codes 01-05 not supportable on SFP, but some modules have single SC */ ++ SFF8024_CONNECTOR_SC = 0x01, ++ SFF8024_CONNECTOR_FIBERJACK = 0x06, ++ SFF8024_CONNECTOR_LC = 0x07, ++ SFF8024_CONNECTOR_MT_RJ = 0x08, ++ SFF8024_CONNECTOR_MU = 0x09, ++ SFF8024_CONNECTOR_SG = 0x0a, ++ SFF8024_CONNECTOR_OPTICAL_PIGTAIL= 0x0b, ++ SFF8024_CONNECTOR_MPO_1X12 = 0x0c, ++ SFF8024_CONNECTOR_MPO_2X16 = 0x0d, ++ SFF8024_CONNECTOR_HSSDC_II = 0x20, ++ SFF8024_CONNECTOR_COPPER_PIGTAIL= 0x21, ++ SFF8024_CONNECTOR_RJ45 = 0x22, ++ SFF8024_CONNECTOR_NOSEPARATE = 0x23, ++ SFF8024_CONNECTOR_MXC_2X16 = 0x24, ++ ++ SFF8024_ECC_UNSPEC = 0x00, ++ SFF8024_ECC_100G_25GAUI_C2M_AOC = 0x01, ++ SFF8024_ECC_100GBASE_SR4_25GBASE_SR = 0x02, ++ SFF8024_ECC_100GBASE_LR4_25GBASE_LR = 0x03, ++ SFF8024_ECC_100GBASE_ER4_25GBASE_ER = 0x04, ++ SFF8024_ECC_100GBASE_SR10 = 0x05, ++ SFF8024_ECC_100GBASE_CR4 = 0x0b, ++ SFF8024_ECC_25GBASE_CR_S = 0x0c, ++ SFF8024_ECC_25GBASE_CR_N = 0x0d, ++ SFF8024_ECC_10GBASE_T_SFI = 0x16, ++ SFF8024_ECC_10GBASE_T_SR = 0x1c, ++ SFF8024_ECC_5GBASE_T = 0x1d, ++ SFF8024_ECC_2_5GBASE_T = 0x1e, ++}; ++ + /* SFP EEPROM registers */ + enum { + SFP_PHYS_ID = 0x00, +@@ -309,34 +364,7 @@ enum { + SFP_SFF8472_COMPLIANCE = 0x5e, + SFP_CC_EXT = 0x5f, + +- SFP_PHYS_ID_SFF = 0x02, +- SFP_PHYS_ID_SFP = 0x03, + SFP_PHYS_EXT_ID_SFP = 0x04, +- SFP_CONNECTOR_UNSPEC = 0x00, +- /* codes 01-05 not supportable on SFP, but some modules have single SC */ +- SFP_CONNECTOR_SC = 0x01, +- SFP_CONNECTOR_FIBERJACK = 0x06, +- SFP_CONNECTOR_LC = 0x07, +- SFP_CONNECTOR_MT_RJ = 0x08, +- SFP_CONNECTOR_MU = 0x09, +- SFP_CONNECTOR_SG = 0x0a, +- SFP_CONNECTOR_OPTICAL_PIGTAIL = 0x0b, +- SFP_CONNECTOR_MPO_1X12 = 0x0c, +- SFP_CONNECTOR_MPO_2X16 = 0x0d, +- SFP_CONNECTOR_HSSDC_II = 0x20, +- SFP_CONNECTOR_COPPER_PIGTAIL = 0x21, +- SFP_CONNECTOR_RJ45 = 0x22, +- SFP_CONNECTOR_NOSEPARATE = 0x23, +- SFP_CONNECTOR_MXC_2X16 = 0x24, +- SFP_ENCODING_UNSPEC = 0x00, +- SFP_ENCODING_8B10B = 0x01, +- SFP_ENCODING_4B5B = 0x02, +- SFP_ENCODING_NRZ = 0x03, +- SFP_ENCODING_8472_MANCHESTER = 0x04, +- SFP_ENCODING_8472_SONET = 0x05, +- SFP_ENCODING_8472_64B66B = 0x06, +- SFP_ENCODING_256B257B = 0x07, +- SFP_ENCODING_PAM4 = 0x08, + SFP_OPTIONS_HIGH_POWER_LEVEL = BIT(13), + SFP_OPTIONS_PAGING_A2 = BIT(12), + SFP_OPTIONS_RETIMER = BIT(11), diff --git a/target/linux/generic/pending-4.19/743-net-sfp-add-module-start-stop-upstream-notifications.patch b/target/linux/generic/pending-4.19/743-net-sfp-add-module-start-stop-upstream-notifications.patch new file mode 100644 index 000000000..c0c3e9e57 --- /dev/null +++ b/target/linux/generic/pending-4.19/743-net-sfp-add-module-start-stop-upstream-notifications.patch @@ -0,0 +1,131 @@ +From f9a5a54b59cb904b37bf7409a43635ab195d0214 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 19 Nov 2019 10:13:25 +0000 +Subject: [PATCH 646/660] net: sfp: add module start/stop upstream + notifications + +When dealing with some copper modules, we can't positively know the +module capabilities are until we have probed the PHY. Without the full +capabilities, we may end up failing a module that we could otherwise +drive with a restricted set of capabilities. + +An example of this would be a module with a NBASE-T PHY plugged into +a host that supports phy interface modes 2500BASE-X and SGMII. The +PHY supports 10GBASE-R, 5000BASE-X, 2500BASE-X, SGMII interface modes, +which means a subset of the capabilities are compatible with the host. + +However, reading the module EEPROM leads us to believe that the module +only supports ethtool link mode 10GBASE-T, which is incompatible with +the host - and thus results in the module being rejected. + +This patch adds an extra notification which are triggered after the +SFP module's PHY probe, and a corresponding notification just before +the PHY is removed. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp-bus.c | 21 +++++++++++++++++++++ + drivers/net/phy/sfp.c | 8 ++++++++ + drivers/net/phy/sfp.h | 2 ++ + include/linux/sfp.h | 4 ++++ + 4 files changed, 35 insertions(+) + +--- a/drivers/net/phy/sfp-bus.c ++++ b/drivers/net/phy/sfp-bus.c +@@ -711,6 +711,27 @@ void sfp_module_remove(struct sfp_bus *b + } + EXPORT_SYMBOL_GPL(sfp_module_remove); + ++int sfp_module_start(struct sfp_bus *bus) ++{ ++ const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); ++ int ret = 0; ++ ++ if (ops && ops->module_start) ++ ret = ops->module_start(bus->upstream); ++ ++ return ret; ++} ++EXPORT_SYMBOL_GPL(sfp_module_start); ++ ++void sfp_module_stop(struct sfp_bus *bus) ++{ ++ const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); ++ ++ if (ops && ops->module_stop) ++ ops->module_stop(bus->upstream); ++} ++EXPORT_SYMBOL_GPL(sfp_module_stop); ++ + static void sfp_socket_clear(struct sfp_bus *bus) + { + bus->sfp_dev = NULL; +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -57,6 +57,7 @@ enum { + SFP_DEV_UP, + + SFP_S_DOWN = 0, ++ SFP_S_FAIL, + SFP_S_WAIT, + SFP_S_INIT, + SFP_S_INIT_TX_FAULT, +@@ -120,6 +121,7 @@ static const char *event_to_str(unsigned + + static const char * const sm_state_strings[] = { + [SFP_S_DOWN] = "down", ++ [SFP_S_FAIL] = "fail", + [SFP_S_WAIT] = "wait", + [SFP_S_INIT] = "init", + [SFP_S_INIT_TX_FAULT] = "init_tx_fault", +@@ -1766,6 +1768,8 @@ static void sfp_sm_main(struct sfp *sfp, + if (sfp->sm_state == SFP_S_LINK_UP && + sfp->sm_dev_state == SFP_DEV_UP) + sfp_sm_link_down(sfp); ++ if (sfp->sm_state > SFP_S_INIT) ++ sfp_module_stop(sfp->sfp_bus); + if (sfp->mod_phy) + sfp_sm_phy_detach(sfp); + sfp_module_tx_disable(sfp); +@@ -1833,6 +1837,10 @@ static void sfp_sm_main(struct sfp *sfp, + * clear. Probe for the PHY and check the LOS state. + */ + sfp_sm_probe_for_phy(sfp); ++ if (sfp_module_start(sfp->sfp_bus)) { ++ sfp_sm_next(sfp, SFP_S_FAIL, 0); ++ break; ++ } + sfp_sm_link_check_los(sfp); + + /* Reset the fault retry count */ +--- a/drivers/net/phy/sfp.h ++++ b/drivers/net/phy/sfp.h +@@ -22,6 +22,8 @@ void sfp_link_up(struct sfp_bus *bus); + void sfp_link_down(struct sfp_bus *bus); + int sfp_module_insert(struct sfp_bus *bus, const struct sfp_eeprom_id *id); + void sfp_module_remove(struct sfp_bus *bus); ++int sfp_module_start(struct sfp_bus *bus); ++void sfp_module_stop(struct sfp_bus *bus); + int sfp_link_configure(struct sfp_bus *bus, const struct sfp_eeprom_id *id); + struct sfp_bus *sfp_register_socket(struct device *dev, struct sfp *sfp, + const struct sfp_socket_ops *ops); +--- a/include/linux/sfp.h ++++ b/include/linux/sfp.h +@@ -507,6 +507,8 @@ struct sfp_bus; + * @module_insert: called after a module has been detected to determine + * whether the module is supported for the upstream device. + * @module_remove: called after the module has been removed. ++ * @module_start: called after the PHY probe step ++ * @module_stop: called before the PHY is removed + * @link_down: called when the link is non-operational for whatever + * reason. + * @link_up: called when the link is operational. +@@ -520,6 +522,8 @@ struct sfp_upstream_ops { + void (*detach)(void *priv, struct sfp_bus *bus); + int (*module_insert)(void *priv, const struct sfp_eeprom_id *id); + void (*module_remove)(void *priv); ++ int (*module_start)(void *priv); ++ void (*module_stop)(void *priv); + void (*link_down)(void *priv); + void (*link_up)(void *priv); + int (*connect_phy)(void *priv, struct phy_device *); diff --git a/target/linux/generic/pending-4.19/744-net-sfp-move-phy_start-phy_stop-to-phylink.patch b/target/linux/generic/pending-4.19/744-net-sfp-move-phy_start-phy_stop-to-phylink.patch new file mode 100644 index 000000000..a646fcd40 --- /dev/null +++ b/target/linux/generic/pending-4.19/744-net-sfp-move-phy_start-phy_stop-to-phylink.patch @@ -0,0 +1,72 @@ +From e2dc261b872a92a055eb2e86ac136baf9b20f2f2 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Thu, 21 Nov 2019 17:21:33 +0000 +Subject: [PATCH 647/660] net: sfp: move phy_start()/phy_stop() to phylink + +Move phy_start() and phy_stop() into the module_start and module_stop +notifications in phylink, rather than having them in the SFP code. +This gives phylink responsibility for controlling the PHY, rather +than having SFP start and stop the PHY state machine. + +Signed-off-by: Russell King +--- + drivers/net/phy/phylink.c | 22 ++++++++++++++++++++++ + drivers/net/phy/sfp.c | 2 -- + 2 files changed, 22 insertions(+), 2 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -1717,6 +1717,26 @@ static int phylink_sfp_module_insert(voi + return ret; + } + ++static int phylink_sfp_module_start(void *upstream) ++{ ++ struct phylink *pl = upstream; ++ ++ /* If this SFP module has a PHY, start the PHY now. */ ++ if (pl->phydev) ++ phy_start(pl->phydev); ++ ++ return 0; ++} ++ ++static void phylink_sfp_module_stop(void *upstream) ++{ ++ struct phylink *pl = upstream; ++ ++ /* If this SFP module has a PHY, stop it. */ ++ if (pl->phydev) ++ phy_stop(pl->phydev); ++} ++ + static void phylink_sfp_link_down(void *upstream) + { + struct phylink *pl = upstream; +@@ -1752,6 +1772,8 @@ static const struct sfp_upstream_ops sfp + .attach = phylink_sfp_attach, + .detach = phylink_sfp_detach, + .module_insert = phylink_sfp_module_insert, ++ .module_start = phylink_sfp_module_start, ++ .module_stop = phylink_sfp_module_stop, + .link_up = phylink_sfp_link_up, + .link_down = phylink_sfp_link_down, + .connect_phy = phylink_sfp_connect_phy, +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -1331,7 +1331,6 @@ static void sfp_sm_mod_next(struct sfp * + + static void sfp_sm_phy_detach(struct sfp *sfp) + { +- phy_stop(sfp->mod_phy); + sfp_remove_phy(sfp->sfp_bus); + phy_device_remove(sfp->mod_phy); + phy_device_free(sfp->mod_phy); +@@ -1362,7 +1361,6 @@ static void sfp_sm_probe_phy(struct sfp + } + + sfp->mod_phy = phy; +- phy_start(phy); + } + + static void sfp_sm_link_up(struct sfp *sfp) diff --git a/target/linux/generic/pending-4.19/745-net-mdio-i2c-add-support-for-Clause-45-accesses.patch b/target/linux/generic/pending-4.19/745-net-mdio-i2c-add-support-for-Clause-45-accesses.patch new file mode 100644 index 000000000..9a4bb5bb7 --- /dev/null +++ b/target/linux/generic/pending-4.19/745-net-mdio-i2c-add-support-for-Clause-45-accesses.patch @@ -0,0 +1,74 @@ +From c9de73988a35c6c85810a992954ac568cca503e5 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Wed, 2 Oct 2019 10:31:10 +0100 +Subject: [PATCH 648/660] net: mdio-i2c: add support for Clause 45 accesses + +Some SFP+ modules have PHYs on them just like SFP modules do, except +they are Clause 45 PHYs. The I2C protocol used to access them is +modified slightly in order to send the device address and 16-bit +register index. + +Signed-off-by: Russell King +--- + drivers/net/phy/mdio-i2c.c | 28 ++++++++++++++++++++-------- + 1 file changed, 20 insertions(+), 8 deletions(-) + +--- a/drivers/net/phy/mdio-i2c.c ++++ b/drivers/net/phy/mdio-i2c.c +@@ -36,17 +36,24 @@ static int i2c_mii_read(struct mii_bus * + { + struct i2c_adapter *i2c = bus->priv; + struct i2c_msg msgs[2]; +- u8 data[2], dev_addr = reg; ++ u8 addr[3], data[2], *p; + int bus_addr, ret; + + if (!i2c_mii_valid_phy_id(phy_id)) + return 0xffff; + ++ p = addr; ++ if (reg & MII_ADDR_C45) { ++ *p++ = 0x20 | ((reg >> 16) & 31); ++ *p++ = reg >> 8; ++ } ++ *p++ = reg; ++ + bus_addr = i2c_mii_phy_addr(phy_id); + msgs[0].addr = bus_addr; + msgs[0].flags = 0; +- msgs[0].len = 1; +- msgs[0].buf = &dev_addr; ++ msgs[0].len = p - addr; ++ msgs[0].buf = addr; + msgs[1].addr = bus_addr; + msgs[1].flags = I2C_M_RD; + msgs[1].len = sizeof(data); +@@ -64,18 +71,23 @@ static int i2c_mii_write(struct mii_bus + struct i2c_adapter *i2c = bus->priv; + struct i2c_msg msg; + int ret; +- u8 data[3]; ++ u8 data[5], *p; + + if (!i2c_mii_valid_phy_id(phy_id)) + return 0; + +- data[0] = reg; +- data[1] = val >> 8; +- data[2] = val; ++ p = data; ++ if (reg & MII_ADDR_C45) { ++ *p++ = (reg >> 16) & 31; ++ *p++ = reg >> 8; ++ } ++ *p++ = reg; ++ *p++ = val >> 8; ++ *p++ = val; + + msg.addr = i2c_mii_phy_addr(phy_id); + msg.flags = 0; +- msg.len = 3; ++ msg.len = p - data; + msg.buf = data; + + ret = i2c_transfer(i2c, &msg, 1); diff --git a/target/linux/generic/pending-4.19/746-net-phylink-re-split-__phylink_connect_phy.patch b/target/linux/generic/pending-4.19/746-net-phylink-re-split-__phylink_connect_phy.patch new file mode 100644 index 000000000..c74a56c57 --- /dev/null +++ b/target/linux/generic/pending-4.19/746-net-phylink-re-split-__phylink_connect_phy.patch @@ -0,0 +1,93 @@ +From 0db7fba746b5608c30d4e2ba1c99a2a309e2d288 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Fri, 8 Nov 2019 15:22:48 +0000 +Subject: [PATCH 649/660] net: phylink: re-split __phylink_connect_phy() + +In order to support Clause 45 PHYs on SFP+ modules, which have an +indeterminant phy interface mode, we need to be able to call +phylink_bringup_phy() with a different interface mode to that used when +binding the PHY. Reduce __phylink_connect_phy() to an attach operation, +and move the call to phylink_bringup_phy() to its call sites. + +Signed-off-by: Russell King +--- + drivers/net/phy/phylink.c | 39 ++++++++++++++++++++++++--------------- + 1 file changed, 24 insertions(+), 15 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -728,11 +728,9 @@ static int phylink_bringup_phy(struct ph + return 0; + } + +-static int __phylink_connect_phy(struct phylink *pl, struct phy_device *phy, +- phy_interface_t interface) ++static int phylink_attach_phy(struct phylink *pl, struct phy_device *phy, ++ phy_interface_t interface) + { +- int ret; +- + if (WARN_ON(pl->link_an_mode == MLO_AN_FIXED || + (pl->link_an_mode == MLO_AN_INBAND && + phy_interface_mode_is_8023z(interface)))) +@@ -741,15 +739,7 @@ static int __phylink_connect_phy(struct + if (pl->phydev) + return -EBUSY; + +- ret = phy_attach_direct(pl->netdev, phy, 0, interface); +- if (ret) +- return ret; +- +- ret = phylink_bringup_phy(pl, phy); +- if (ret) +- phy_detach(phy); +- +- return ret; ++ return phy_attach_direct(pl->netdev, phy, 0, interface); + } + + /** +@@ -769,13 +759,23 @@ static int __phylink_connect_phy(struct + */ + int phylink_connect_phy(struct phylink *pl, struct phy_device *phy) + { ++ int ret; ++ + /* Use PHY device/driver interface */ + if (pl->link_interface == PHY_INTERFACE_MODE_NA) { + pl->link_interface = phy->interface; + pl->link_config.interface = pl->link_interface; + } + +- return __phylink_connect_phy(pl, phy, pl->link_interface); ++ ret = phylink_attach_phy(pl, phy, pl->link_interface); ++ if (ret < 0) ++ return ret; ++ ++ ret = phylink_bringup_phy(pl, phy); ++ if (ret) ++ phy_detach(phy); ++ ++ return ret; + } + EXPORT_SYMBOL_GPL(phylink_connect_phy); + +@@ -1759,8 +1759,17 @@ static void phylink_sfp_link_up(void *up + static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy) + { + struct phylink *pl = upstream; ++ int ret; + +- return __phylink_connect_phy(upstream, phy, pl->link_config.interface); ++ ret = phylink_attach_phy(pl, phy, pl->link_config.interface); ++ if (ret < 0) ++ return ret; ++ ++ ret = phylink_bringup_phy(pl, phy); ++ if (ret) ++ phy_detach(phy); ++ ++ return ret; + } + + static void phylink_sfp_disconnect_phy(void *upstream) diff --git a/target/linux/generic/pending-4.19/747-net-phylink-support-Clause-45-PHYs-on-SFP-modules.patch b/target/linux/generic/pending-4.19/747-net-phylink-support-Clause-45-PHYs-on-SFP-modules.patch new file mode 100644 index 000000000..2cea118c8 --- /dev/null +++ b/target/linux/generic/pending-4.19/747-net-phylink-support-Clause-45-PHYs-on-SFP-modules.patch @@ -0,0 +1,89 @@ +From caf32f96f13df7d3ae6cb8bf8001c88ae22025ca Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Fri, 8 Nov 2019 15:28:22 +0000 +Subject: [PATCH 650/660] net: phylink: support Clause 45 PHYs on SFP+ modules + +Some SFP+ modules have Clause 45 PHYs embedded on them, which need a +little more handling in order to ensure that they are correctly setup, +as they switch the PHY link mode according to the negotiated speed. + +With Clause 22 PHYs, we assumed that they would operate in SGMII mode, +but this assumption is now false. Adapt phylink to support Clause 45 +PHYs on SFP+ modules. + +Signed-off-by: Russell King +--- + drivers/net/phy/phylink.c | 21 ++++++++++++++++----- + 1 file changed, 16 insertions(+), 5 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -671,7 +671,8 @@ static void phylink_phy_change(struct ph + phy_duplex_to_str(phydev->duplex)); + } + +-static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy) ++static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy, ++ phy_interface_t interface) + { + struct phylink_link_state config; + __ETHTOOL_DECLARE_LINK_MODE_MASK(supported); +@@ -691,7 +692,7 @@ static int phylink_bringup_phy(struct ph + ethtool_convert_legacy_u32_to_link_mode(supported, phy->supported); + ethtool_convert_legacy_u32_to_link_mode(config.advertising, + phy->advertising); +- config.interface = pl->link_config.interface; ++ config.interface = interface; + + ret = phylink_validate(pl, supported, &config); + if (ret) +@@ -707,6 +708,7 @@ static int phylink_bringup_phy(struct ph + mutex_lock(&phy->lock); + mutex_lock(&pl->state_mutex); + pl->phydev = phy; ++ pl->phy_state.interface = interface; + linkmode_copy(pl->supported, supported); + linkmode_copy(pl->link_config.advertising, config.advertising); + +@@ -771,7 +773,7 @@ int phylink_connect_phy(struct phylink * + if (ret < 0) + return ret; + +- ret = phylink_bringup_phy(pl, phy); ++ ret = phylink_bringup_phy(pl, phy, pl->link_config.interface); + if (ret) + phy_detach(phy); + +@@ -824,7 +826,7 @@ int phylink_of_phy_connect(struct phylin + if (!phy_dev) + return -ENODEV; + +- ret = phylink_bringup_phy(pl, phy_dev); ++ ret = phylink_bringup_phy(pl, phy_dev, pl->link_config.interface); + if (ret) + phy_detach(phy_dev); + +@@ -1759,13 +1761,22 @@ static void phylink_sfp_link_up(void *up + static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy) + { + struct phylink *pl = upstream; ++ phy_interface_t interface = pl->link_config.interface; + int ret; + + ret = phylink_attach_phy(pl, phy, pl->link_config.interface); + if (ret < 0) + return ret; + +- ret = phylink_bringup_phy(pl, phy); ++ /* Clause 45 PHYs switch their Serdes lane between several different ++ * modes, normally 10GBASE-R, SGMII. Some use 2500BASE-X for 2.5G ++ * speeds. We really need to know which interface modes the PHY and ++ * MAC supports to properly work out which linkmodes can be supported. ++ */ ++ if (phy->is_c45) ++ interface = PHY_INTERFACE_MODE_NA; ++ ++ ret = phylink_bringup_phy(pl, phy, interface); + if (ret) + phy_detach(phy); + diff --git a/target/linux/generic/pending-4.19/748-net-phylink-split-link_an_mode-configured-and-curren.patch b/target/linux/generic/pending-4.19/748-net-phylink-split-link_an_mode-configured-and-curren.patch new file mode 100644 index 000000000..f30d37f0c --- /dev/null +++ b/target/linux/generic/pending-4.19/748-net-phylink-split-link_an_mode-configured-and-curren.patch @@ -0,0 +1,254 @@ +From d1339d6956f0255b6ce2412328a98945be8cc3ca Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Sat, 16 Nov 2019 11:30:18 +0000 +Subject: [PATCH 651/660] net: phylink: split link_an_mode configured and + current settings + +Split link_an_mode between the configured setting and the current +operating setting. This is an important distinction to make when we +need to configure PHY mode for a plugged SFP+ module that does not +use in-band signalling. + +Signed-off-by: Russell King +--- + drivers/net/phy/phylink.c | 59 ++++++++++++++++++++------------------- + 1 file changed, 31 insertions(+), 28 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -48,7 +48,8 @@ struct phylink { + unsigned long phylink_disable_state; /* bitmask of disables */ + struct phy_device *phydev; + phy_interface_t link_interface; /* PHY_INTERFACE_xxx */ +- u8 link_an_mode; /* MLO_AN_xxx */ ++ u8 cfg_link_an_mode; /* MLO_AN_xxx */ ++ u8 cur_link_an_mode; + u8 link_port; /* The current non-phy ethtool port */ + __ETHTOOL_DECLARE_LINK_MODE_MASK(supported); + +@@ -253,12 +254,12 @@ static int phylink_parse_mode(struct phy + + dn = fwnode_get_named_child_node(fwnode, "fixed-link"); + if (dn || fwnode_property_present(fwnode, "fixed-link")) +- pl->link_an_mode = MLO_AN_FIXED; ++ pl->cfg_link_an_mode = MLO_AN_FIXED; + fwnode_handle_put(dn); + + if (fwnode_property_read_string(fwnode, "managed", &managed) == 0 && + strcmp(managed, "in-band-status") == 0) { +- if (pl->link_an_mode == MLO_AN_FIXED) { ++ if (pl->cfg_link_an_mode == MLO_AN_FIXED) { + netdev_err(pl->netdev, + "can't use both fixed-link and in-band-status\n"); + return -EINVAL; +@@ -270,7 +271,7 @@ static int phylink_parse_mode(struct phy + phylink_set(pl->supported, Asym_Pause); + phylink_set(pl->supported, Pause); + pl->link_config.an_enabled = true; +- pl->link_an_mode = MLO_AN_INBAND; ++ pl->cfg_link_an_mode = MLO_AN_INBAND; + + switch (pl->link_config.interface) { + case PHY_INTERFACE_MODE_SGMII: +@@ -330,14 +331,14 @@ static void phylink_mac_config(struct ph + { + netdev_dbg(pl->netdev, + "%s: mode=%s/%s/%s/%s adv=%*pb pause=%02x link=%u an=%u\n", +- __func__, phylink_an_mode_str(pl->link_an_mode), ++ __func__, phylink_an_mode_str(pl->cur_link_an_mode), + phy_modes(state->interface), + phy_speed_to_str(state->speed), + phy_duplex_to_str(state->duplex), + __ETHTOOL_LINK_MODE_MASK_NBITS, state->advertising, + state->pause, state->link, state->an_enabled); + +- pl->ops->mac_config(pl->netdev, pl->link_an_mode, state); ++ pl->ops->mac_config(pl->netdev, pl->cur_link_an_mode, state); + } + + static void phylink_mac_config_up(struct phylink *pl, +@@ -446,7 +447,7 @@ static void phylink_resolve(struct work_ + } else if (pl->mac_link_dropped) { + link_state.link = false; + } else { +- switch (pl->link_an_mode) { ++ switch (pl->cur_link_an_mode) { + case MLO_AN_PHY: + link_state = pl->phy_state; + phylink_resolve_flow(pl, &link_state); +@@ -483,12 +484,12 @@ static void phylink_resolve(struct work_ + if (link_state.link != netif_carrier_ok(ndev)) { + if (!link_state.link) { + netif_carrier_off(ndev); +- pl->ops->mac_link_down(ndev, pl->link_an_mode, ++ pl->ops->mac_link_down(ndev, pl->cur_link_an_mode, + pl->cur_interface); + netdev_info(ndev, "Link is Down\n"); + } else { + pl->cur_interface = link_state.interface; +- pl->ops->mac_link_up(ndev, pl->link_an_mode, ++ pl->ops->mac_link_up(ndev, pl->cur_link_an_mode, + pl->cur_interface, pl->phydev); + + netif_carrier_on(ndev); +@@ -610,7 +611,7 @@ struct phylink *phylink_create(struct ne + return ERR_PTR(ret); + } + +- if (pl->link_an_mode == MLO_AN_FIXED) { ++ if (pl->cfg_link_an_mode == MLO_AN_FIXED) { + ret = phylink_parse_fixedlink(pl, fwnode); + if (ret < 0) { + kfree(pl); +@@ -618,6 +619,8 @@ struct phylink *phylink_create(struct ne + } + } + ++ pl->cur_link_an_mode = pl->cfg_link_an_mode; ++ + ret = phylink_register_sfp(pl, fwnode); + if (ret < 0) { + kfree(pl); +@@ -733,8 +736,8 @@ static int phylink_bringup_phy(struct ph + static int phylink_attach_phy(struct phylink *pl, struct phy_device *phy, + phy_interface_t interface) + { +- if (WARN_ON(pl->link_an_mode == MLO_AN_FIXED || +- (pl->link_an_mode == MLO_AN_INBAND && ++ if (WARN_ON(pl->cfg_link_an_mode == MLO_AN_FIXED || ++ (pl->cfg_link_an_mode == MLO_AN_INBAND && + phy_interface_mode_is_8023z(interface)))) + return -EINVAL; + +@@ -801,8 +804,8 @@ int phylink_of_phy_connect(struct phylin + int ret; + + /* Fixed links and 802.3z are handled without needing a PHY */ +- if (pl->link_an_mode == MLO_AN_FIXED || +- (pl->link_an_mode == MLO_AN_INBAND && ++ if (pl->cfg_link_an_mode == MLO_AN_FIXED || ++ (pl->cfg_link_an_mode == MLO_AN_INBAND && + phy_interface_mode_is_8023z(pl->link_interface))) + return 0; + +@@ -813,7 +816,7 @@ int phylink_of_phy_connect(struct phylin + phy_node = of_parse_phandle(dn, "phy-device", 0); + + if (!phy_node) { +- if (pl->link_an_mode == MLO_AN_PHY) ++ if (pl->cfg_link_an_mode == MLO_AN_PHY) + return -ENODEV; + return 0; + } +@@ -876,7 +879,7 @@ int phylink_fixed_state_cb(struct phylin + /* It does not make sense to let the link be overriden unless we use + * MLO_AN_FIXED + */ +- if (pl->link_an_mode != MLO_AN_FIXED) ++ if (pl->cfg_link_an_mode != MLO_AN_FIXED) + return -EINVAL; + + mutex_lock(&pl->state_mutex); +@@ -926,7 +929,7 @@ void phylink_start(struct phylink *pl) + ASSERT_RTNL(); + + netdev_info(pl->netdev, "configuring for %s/%s link mode\n", +- phylink_an_mode_str(pl->link_an_mode), ++ phylink_an_mode_str(pl->cur_link_an_mode), + phy_modes(pl->link_config.interface)); + + /* Always set the carrier off */ +@@ -948,7 +951,7 @@ void phylink_start(struct phylink *pl) + clear_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state); + phylink_run_resolve(pl); + +- if (pl->link_an_mode == MLO_AN_FIXED && pl->link_gpio) { ++ if (pl->cfg_link_an_mode == MLO_AN_FIXED && pl->link_gpio) { + int irq = gpiod_to_irq(pl->link_gpio); + + if (irq > 0) { +@@ -963,7 +966,7 @@ void phylink_start(struct phylink *pl) + if (irq <= 0) + mod_timer(&pl->link_poll, jiffies + HZ); + } +- if (pl->link_an_mode == MLO_AN_FIXED && pl->get_fixed_state) ++ if (pl->cfg_link_an_mode == MLO_AN_FIXED && pl->get_fixed_state) + mod_timer(&pl->link_poll, jiffies + HZ); + if (pl->phydev) + phy_start(pl->phydev); +@@ -1090,7 +1093,7 @@ int phylink_ethtool_ksettings_get(struct + + linkmode_copy(kset->link_modes.supported, pl->supported); + +- switch (pl->link_an_mode) { ++ switch (pl->cur_link_an_mode) { + case MLO_AN_FIXED: + /* We are using fixed settings. Report these as the + * current link settings - and note that these also +@@ -1163,7 +1166,7 @@ int phylink_ethtool_ksettings_set(struct + /* If we have a fixed link (as specified by firmware), refuse + * to change link parameters. + */ +- if (pl->link_an_mode == MLO_AN_FIXED && ++ if (pl->cur_link_an_mode == MLO_AN_FIXED && + (s->speed != pl->link_config.speed || + s->duplex != pl->link_config.duplex)) + return -EINVAL; +@@ -1175,7 +1178,7 @@ int phylink_ethtool_ksettings_set(struct + __clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, config.advertising); + } else { + /* If we have a fixed link, refuse to enable autonegotiation */ +- if (pl->link_an_mode == MLO_AN_FIXED) ++ if (pl->cur_link_an_mode == MLO_AN_FIXED) + return -EINVAL; + + config.speed = SPEED_UNKNOWN; +@@ -1217,7 +1220,7 @@ int phylink_ethtool_ksettings_set(struct + * configuration. For a fixed link, this isn't able to change any + * parameters, which just leaves inband mode. + */ +- if (pl->link_an_mode == MLO_AN_INBAND && ++ if (pl->cur_link_an_mode == MLO_AN_INBAND && + !test_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state)) { + phylink_mac_config(pl, &pl->link_config); + phylink_mac_an_restart(pl); +@@ -1307,7 +1310,7 @@ int phylink_ethtool_set_pauseparam(struc + pause->tx_pause); + } else if (!test_bit(PHYLINK_DISABLE_STOPPED, + &pl->phylink_disable_state)) { +- switch (pl->link_an_mode) { ++ switch (pl->cur_link_an_mode) { + case MLO_AN_FIXED: + /* Should we allow fixed links to change against the config? */ + phylink_resolve_flow(pl, config); +@@ -1496,7 +1499,7 @@ static int phylink_mii_read(struct phyli + struct phylink_link_state state; + int val = 0xffff; + +- switch (pl->link_an_mode) { ++ switch (pl->cur_link_an_mode) { + case MLO_AN_FIXED: + if (phy_id == 0) { + phylink_get_fixed_state(pl, &state); +@@ -1524,7 +1527,7 @@ static int phylink_mii_read(struct phyli + static int phylink_mii_write(struct phylink *pl, unsigned int phy_id, + unsigned int reg, unsigned int val) + { +- switch (pl->link_an_mode) { ++ switch (pl->cur_link_an_mode) { + case MLO_AN_FIXED: + break; + +@@ -1698,10 +1701,10 @@ static int phylink_sfp_module_insert(voi + linkmode_copy(pl->link_config.advertising, config.advertising); + } + +- if (pl->link_an_mode != MLO_AN_INBAND || ++ if (pl->cur_link_an_mode != MLO_AN_INBAND || + pl->link_config.interface != config.interface) { + pl->link_config.interface = config.interface; +- pl->link_an_mode = MLO_AN_INBAND; ++ pl->cur_link_an_mode = MLO_AN_INBAND; + + changed = true; + diff --git a/target/linux/generic/pending-4.19/749-net-phylink-split-phylink_sfp_module_insert.patch b/target/linux/generic/pending-4.19/749-net-phylink-split-phylink_sfp_module_insert.patch new file mode 100644 index 000000000..87d70d143 --- /dev/null +++ b/target/linux/generic/pending-4.19/749-net-phylink-split-phylink_sfp_module_insert.patch @@ -0,0 +1,120 @@ +From 36569971241ae6b81376da4937d2c8760122d10b Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Thu, 21 Nov 2019 17:58:58 +0000 +Subject: [PATCH 652/660] net: phylink: split phylink_sfp_module_insert() + +Split out the configuration step from phylink_sfp_module_insert() so +we can re-use this later. + +Signed-off-by: Russell King +--- + drivers/net/phy/phylink.c | 47 +++++++++++++++++++++++---------------- + 1 file changed, 28 insertions(+), 19 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -1633,25 +1633,21 @@ static void phylink_sfp_detach(void *ups + pl->netdev->sfp_bus = NULL; + } + +-static int phylink_sfp_module_insert(void *upstream, +- const struct sfp_eeprom_id *id) ++static int phylink_sfp_config(struct phylink *pl, u8 mode, u8 port, ++ const unsigned long *supported, ++ const unsigned long *advertising) + { +- struct phylink *pl = upstream; +- __ETHTOOL_DECLARE_LINK_MODE_MASK(support) = { 0, }; + __ETHTOOL_DECLARE_LINK_MODE_MASK(support1); ++ __ETHTOOL_DECLARE_LINK_MODE_MASK(support); + struct phylink_link_state config; + phy_interface_t iface; +- int ret = 0; + bool changed; +- u8 port; ++ int ret; + +- ASSERT_RTNL(); +- +- sfp_parse_support(pl->sfp_bus, id, support); +- port = sfp_parse_port(pl->sfp_bus, id, support); ++ linkmode_copy(support, supported); + + memset(&config, 0, sizeof(config)); +- linkmode_copy(config.advertising, support); ++ linkmode_copy(config.advertising, advertising); + config.interface = PHY_INTERFACE_MODE_NA; + config.speed = SPEED_UNKNOWN; + config.duplex = DUPLEX_UNKNOWN; +@@ -1666,8 +1662,6 @@ static int phylink_sfp_module_insert(voi + return ret; + } + +- linkmode_copy(support1, support); +- + iface = sfp_select_interface(pl->sfp_bus, config.advertising); + if (iface == PHY_INTERFACE_MODE_NA) { + netdev_err(pl->netdev, +@@ -1677,18 +1671,18 @@ static int phylink_sfp_module_insert(voi + } + + config.interface = iface; ++ linkmode_copy(support1, support); + ret = phylink_validate(pl, support1, &config); + if (ret) { + netdev_err(pl->netdev, "validation of %s/%s with support %*pb failed: %d\n", +- phylink_an_mode_str(MLO_AN_INBAND), ++ phylink_an_mode_str(mode), + phy_modes(config.interface), + __ETHTOOL_LINK_MODE_MASK_NBITS, support, ret); + return ret; + } + + netdev_dbg(pl->netdev, "requesting link mode %s/%s with support %*pb\n", +- phylink_an_mode_str(MLO_AN_INBAND), +- phy_modes(config.interface), ++ phylink_an_mode_str(mode), phy_modes(config.interface), + __ETHTOOL_LINK_MODE_MASK_NBITS, support); + + if (phy_interface_mode_is_8023z(iface) && pl->phydev) +@@ -1701,15 +1695,15 @@ static int phylink_sfp_module_insert(voi + linkmode_copy(pl->link_config.advertising, config.advertising); + } + +- if (pl->cur_link_an_mode != MLO_AN_INBAND || ++ if (pl->cur_link_an_mode != mode || + pl->link_config.interface != config.interface) { + pl->link_config.interface = config.interface; +- pl->cur_link_an_mode = MLO_AN_INBAND; ++ pl->cur_link_an_mode = mode; + + changed = true; + + netdev_info(pl->netdev, "switched to %s/%s link mode\n", +- phylink_an_mode_str(MLO_AN_INBAND), ++ phylink_an_mode_str(mode), + phy_modes(config.interface)); + } + +@@ -1722,6 +1716,21 @@ static int phylink_sfp_module_insert(voi + return ret; + } + ++static int phylink_sfp_module_insert(void *upstream, ++ const struct sfp_eeprom_id *id) ++{ ++ struct phylink *pl = upstream; ++ __ETHTOOL_DECLARE_LINK_MODE_MASK(support) = { 0, }; ++ u8 port; ++ ++ ASSERT_RTNL(); ++ ++ sfp_parse_support(pl->sfp_bus, id, support); ++ port = sfp_parse_port(pl->sfp_bus, id, support); ++ ++ return phylink_sfp_config(pl, MLO_AN_INBAND, port, support, support); ++} ++ + static int phylink_sfp_module_start(void *upstream) + { + struct phylink *pl = upstream; diff --git a/target/linux/generic/pending-4.19/750-net-phylink-delay-MAC-configuration-for-copper-SFP-m.patch b/target/linux/generic/pending-4.19/750-net-phylink-delay-MAC-configuration-for-copper-SFP-m.patch new file mode 100644 index 000000000..358b9a108 --- /dev/null +++ b/target/linux/generic/pending-4.19/750-net-phylink-delay-MAC-configuration-for-copper-SFP-m.patch @@ -0,0 +1,204 @@ +From eb514428f75bc67d12ff019c44a8f8ca9f33c54c Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Thu, 21 Nov 2019 17:42:49 +0000 +Subject: [PATCH 653/660] net: phylink: delay MAC configuration for copper SFP + modules + +Knowing whether we need to delay the MAC configuration because a module +may have a PHY is useful to phylink to allow NBASE-T modules to work on +systems supporting no more than 2.5G speeds. + +This commit allows us to delay such configuration until after the PHY +has been probed by recording the parsed capabilities, and if the module +may have a PHY, doing no more until the module_start() notification is +called. At that point, we either have a PHY, or we don't. + +We move the PHY-based setup a little later, and use the PHYs support +capabilities rather than the EEPROM parsed capabilities to determine +whether we can support the PHY. + +Signed-off-by: Russell King +--- + drivers/net/phy/phylink.c | 59 +++++++++++++++++++++++++++++++-------- + drivers/net/phy/sfp-bus.c | 28 +++++++++++++++++++ + include/linux/sfp.h | 7 +++++ + 3 files changed, 83 insertions(+), 11 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -72,6 +72,9 @@ struct phylink { + bool mac_link_dropped; + + struct sfp_bus *sfp_bus; ++ bool sfp_may_have_phy; ++ __ETHTOOL_DECLARE_LINK_MODE_MASK(sfp_support); ++ u8 sfp_port; + }; + + static inline void linkmode_zero(unsigned long *dst) +@@ -1633,7 +1636,7 @@ static void phylink_sfp_detach(void *ups + pl->netdev->sfp_bus = NULL; + } + +-static int phylink_sfp_config(struct phylink *pl, u8 mode, u8 port, ++static int phylink_sfp_config(struct phylink *pl, u8 mode, + const unsigned long *supported, + const unsigned long *advertising) + { +@@ -1707,7 +1710,7 @@ static int phylink_sfp_config(struct phy + phy_modes(config.interface)); + } + +- pl->link_port = port; ++ pl->link_port = pl->sfp_port; + + if (changed && !test_bit(PHYLINK_DISABLE_STOPPED, + &pl->phylink_disable_state)) +@@ -1720,15 +1723,20 @@ static int phylink_sfp_module_insert(voi + const struct sfp_eeprom_id *id) + { + struct phylink *pl = upstream; +- __ETHTOOL_DECLARE_LINK_MODE_MASK(support) = { 0, }; +- u8 port; ++ unsigned long *support = pl->sfp_support; + + ASSERT_RTNL(); + ++ linkmode_zero(support); + sfp_parse_support(pl->sfp_bus, id, support); +- port = sfp_parse_port(pl->sfp_bus, id, support); ++ pl->sfp_port = sfp_parse_port(pl->sfp_bus, id, support); + +- return phylink_sfp_config(pl, MLO_AN_INBAND, port, support, support); ++ /* If this module may have a PHY connecting later, defer until later */ ++ pl->sfp_may_have_phy = sfp_may_have_phy(pl->sfp_bus, id); ++ if (pl->sfp_may_have_phy) ++ return 0; ++ ++ return phylink_sfp_config(pl, MLO_AN_INBAND, support, support); + } + + static int phylink_sfp_module_start(void *upstream) +@@ -1736,10 +1744,19 @@ static int phylink_sfp_module_start(void + struct phylink *pl = upstream; + + /* If this SFP module has a PHY, start the PHY now. */ +- if (pl->phydev) ++ if (pl->phydev) { + phy_start(pl->phydev); +- +- return 0; ++ return 0; ++ } ++ ++ /* If the module may have a PHY but we didn't detect one we ++ * need to configure the MAC here. ++ */ ++ if (!pl->sfp_may_have_phy) ++ return 0; ++ ++ return phylink_sfp_config(pl, MLO_AN_INBAND, ++ pl->sfp_support, pl->sfp_support); + } + + static void phylink_sfp_module_stop(void *upstream) +@@ -1773,10 +1790,30 @@ static void phylink_sfp_link_up(void *up + static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy) + { + struct phylink *pl = upstream; +- phy_interface_t interface = pl->link_config.interface; ++ __ETHTOOL_DECLARE_LINK_MODE_MASK(supported); ++ __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising); ++ phy_interface_t interface; + int ret; + +- ret = phylink_attach_phy(pl, phy, pl->link_config.interface); ++ /* ++ * This is the new way of dealing with flow control for PHYs, ++ * as described by Timur Tabi in commit 529ed1275263 ("net: phy: ++ * phy drivers should not set SUPPORTED_[Asym_]Pause") except ++ * using our validate call to the MAC, we rely upon the MAC ++ * clearing the bits from both supported and advertising fields. ++ */ ++ phy_support_asym_pause(phy); ++ ++ ethtool_convert_legacy_u32_to_link_mode(supported, phy->supported); ++ ethtool_convert_legacy_u32_to_link_mode(advertising, phy->advertising); ++ ++ /* Do the initial configuration */ ++ ret = phylink_sfp_config(pl, ML_AN_INBAND, supported, advertising); ++ if (ret < 0) ++ return ret; ++ ++ interface = pl->link_config.interface; ++ ret = phylink_attach_phy(pl, phy, interface); + if (ret < 0) + return ret; + +--- a/drivers/net/phy/sfp-bus.c ++++ b/drivers/net/phy/sfp-bus.c +@@ -102,6 +102,7 @@ static const struct sfp_quirk *sfp_looku + + return NULL; + } ++ + /** + * sfp_parse_port() - Parse the EEPROM base ID, setting the port type + * @bus: a pointer to the &struct sfp_bus structure for the sfp module +@@ -178,6 +179,33 @@ int sfp_parse_port(struct sfp_bus *bus, + EXPORT_SYMBOL_GPL(sfp_parse_port); + + /** ++ * sfp_may_have_phy() - indicate whether the module may have a PHY ++ * @bus: a pointer to the &struct sfp_bus structure for the sfp module ++ * @id: a pointer to the module's &struct sfp_eeprom_id ++ * ++ * Parse the EEPROM identification given in @id, and return whether ++ * this module may have a PHY. ++ */ ++bool sfp_may_have_phy(struct sfp_bus *bus, const struct sfp_eeprom_id *id) ++{ ++ if (id->base.e1000_base_t) ++ return true; ++ ++ if (id->base.phys_id != SFF8024_ID_DWDM_SFP) { ++ switch (id->base.extended_cc) { ++ case SFF8024_ECC_10GBASE_T_SFI: ++ case SFF8024_ECC_10GBASE_T_SR: ++ case SFF8024_ECC_5GBASE_T: ++ case SFF8024_ECC_2_5GBASE_T: ++ return true; ++ } ++ } ++ ++ return false; ++} ++EXPORT_SYMBOL_GPL(sfp_may_have_phy); ++ ++/** + * sfp_parse_support() - Parse the eeprom id for supported link modes + * @bus: a pointer to the &struct sfp_bus structure for the sfp module + * @id: a pointer to the module's &struct sfp_eeprom_id +--- a/include/linux/sfp.h ++++ b/include/linux/sfp.h +@@ -533,6 +533,7 @@ struct sfp_upstream_ops { + #if IS_ENABLED(CONFIG_SFP) + int sfp_parse_port(struct sfp_bus *bus, const struct sfp_eeprom_id *id, + unsigned long *support); ++bool sfp_may_have_phy(struct sfp_bus *bus, const struct sfp_eeprom_id *id); + void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id, + unsigned long *support); + phy_interface_t sfp_select_interface(struct sfp_bus *bus, +@@ -556,6 +557,12 @@ static inline int sfp_parse_port(struct + return PORT_OTHER; + } + ++static inline bool sfp_may_have_phy(struct sfp_bus *bus, ++ const struct sfp_eeprom_id *id) ++{ ++ return false; ++} ++ + static inline void sfp_parse_support(struct sfp_bus *bus, + const struct sfp_eeprom_id *id, + unsigned long *support) diff --git a/target/linux/generic/pending-4.19/751-net-phylink-make-Broadcom-BCM84881-based-SFPs-work.patch b/target/linux/generic/pending-4.19/751-net-phylink-make-Broadcom-BCM84881-based-SFPs-work.patch new file mode 100644 index 000000000..1724d445b --- /dev/null +++ b/target/linux/generic/pending-4.19/751-net-phylink-make-Broadcom-BCM84881-based-SFPs-work.patch @@ -0,0 +1,58 @@ +From 3d8592a23dd67fb78ad85ddf711a059d3880fcb4 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Fri, 8 Nov 2019 17:19:16 +0000 +Subject: [PATCH 654/660] net: phylink: make Broadcom BCM84881 based SFPs work + +The Broadcom BCM84881 does not appear to send the SGMII control word +when operating in SGMII mode, which causes network adapters to fail +to link with the PHY, or decide to operate at fixed 1G speed, even if +the PHY negotiated 100M. + +Work around this by detecting the Broadcom BCM84881 and switch to phy +mode rather than inband mode. + +Signed-off-by: Russell King +--- + drivers/net/phy/phylink.c | 17 ++++++++++++++++- + 1 file changed, 16 insertions(+), 1 deletion(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -1787,12 +1787,22 @@ static void phylink_sfp_link_up(void *up + phylink_run_resolve(pl); + } + ++/* The Broadcom BCM84881 in the Methode DM7052 is unable to provide a SGMII ++ * or 802.3z control word, so inband will not work. ++ */ ++static bool phylink_phy_no_inband(struct phy_device *phy) ++{ ++ return phy->is_c45 && ++ (phy->c45_ids.device_ids[1] & 0xfffffff0) == 0xae025150; ++} ++ + static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy) + { + struct phylink *pl = upstream; + __ETHTOOL_DECLARE_LINK_MODE_MASK(supported); + __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising); + phy_interface_t interface; ++ u8 mode; + int ret; + + /* +@@ -1807,8 +1817,13 @@ static int phylink_sfp_connect_phy(void + ethtool_convert_legacy_u32_to_link_mode(supported, phy->supported); + ethtool_convert_legacy_u32_to_link_mode(advertising, phy->advertising); + ++ if (phylink_phy_no_inband(phy)) ++ mode = MLO_AN_PHY; ++ else ++ mode = MLO_AN_INBAND; ++ + /* Do the initial configuration */ +- ret = phylink_sfp_config(pl, ML_AN_INBAND, supported, advertising); ++ ret = phylink_sfp_config(pl, mode, supported, advertising); + if (ret < 0) + return ret; + diff --git a/target/linux/generic/pending-4.19/752-net-phy-add-Broadcom-BCM84881-PHY-driver.patch b/target/linux/generic/pending-4.19/752-net-phy-add-Broadcom-BCM84881-PHY-driver.patch new file mode 100644 index 000000000..a69cf397a --- /dev/null +++ b/target/linux/generic/pending-4.19/752-net-phy-add-Broadcom-BCM84881-PHY-driver.patch @@ -0,0 +1,333 @@ +From 0f669e10ede7f06bb998373de6a9d169f47fcc66 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 5 Nov 2019 11:54:30 +0000 +Subject: [PATCH 655/660] net: phy: add Broadcom BCM84881 PHY driver + +Add a rudimentary Clause 45 driver for the BCM84881 PHY, found on +Methode DM7052 SFPs. + +Signed-off-by: Russell King +--- + drivers/net/phy/Kconfig | 5 + + drivers/net/phy/Makefile | 1 + + drivers/net/phy/bcm84881.c | 290 +++++++++++++++++++++++++++++++++++++ + 3 files changed, 296 insertions(+) + create mode 100644 drivers/net/phy/bcm84881.c + +--- a/drivers/net/phy/Kconfig ++++ b/drivers/net/phy/Kconfig +@@ -280,6 +280,11 @@ config BROADCOM_PHY + Currently supports the BCM5411, BCM5421, BCM5461, BCM54616S, BCM5464, + BCM5481, BCM54810 and BCM5482 PHYs. + ++config BCM84881_PHY ++ tristate "Broadcom BCM84881 PHY" ++ ---help--- ++ Support the Broadcom BCM84881 PHY. ++ + config CICADA_PHY + tristate "Cicada PHYs" + ---help--- +--- a/drivers/net/phy/Makefile ++++ b/drivers/net/phy/Makefile +@@ -54,6 +54,7 @@ obj-$(CONFIG_BCM87XX_PHY) += bcm87xx.o + obj-$(CONFIG_BCM_CYGNUS_PHY) += bcm-cygnus.o + obj-$(CONFIG_BCM_NET_PHYLIB) += bcm-phy-lib.o + obj-$(CONFIG_BROADCOM_PHY) += broadcom.o ++obj-$(CONFIG_BCM84881_PHY) += bcm84881.o + obj-$(CONFIG_CICADA_PHY) += cicada.o + obj-$(CONFIG_CORTINA_PHY) += cortina.o + obj-$(CONFIG_DAVICOM_PHY) += davicom.o +--- /dev/null ++++ b/drivers/net/phy/bcm84881.c +@@ -0,0 +1,290 @@ ++// SPDX-License-Identifier: GPL-2.0 ++// Broadcom BCM84881 NBASE-T PHY driver, as found on a SFP+ module. ++// Copyright (C) 2019 Russell King, Deep Blue Solutions Ltd. ++// ++// Like the Marvell 88x3310, the Broadcom 84881 changes its host-side ++// interface according to the operating speed between 10GBASE-R, ++// 2500BASE-X and SGMII (but unlike the 88x3310, without the control ++// word). ++// ++// This driver only supports those aspects of the PHY that I'm able to ++// observe and test with the SFP+ module, which is an incomplete subset ++// of what this PHY is able to support. For example, I only assume it ++// supports a single lane Serdes connection, but it may be that the PHY ++// is able to support more than that. ++#include ++#include ++#include ++ ++enum { ++ MDIO_AN_C22 = 0xffe0, ++}; ++ ++static int bcm84881_wait_init(struct phy_device *phydev) ++{ ++ unsigned int tries = 20; ++ int ret, val; ++ ++ do { ++ val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_CTRL1); ++ if (val < 0) { ++ ret = val; ++ break; ++ } ++ if (!(val & MDIO_CTRL1_RESET)) { ++ ret = 0; ++ break; ++ } ++ if (!--tries) { ++ ret = -ETIMEDOUT; ++ break; ++ } ++ msleep(100); ++ } while (1); ++ ++ if (ret) ++ phydev_err(phydev, "%s failed: %d\n", __func__, ret); ++ ++ return ret; ++} ++ ++static int bcm84881_config_init(struct phy_device *phydev) ++{ ++ switch (phydev->interface) { ++ case PHY_INTERFACE_MODE_SGMII: ++ case PHY_INTERFACE_MODE_2500BASEX: ++ case PHY_INTERFACE_MODE_10GKR: ++ break; ++ default: ++ return -ENODEV; ++ } ++ return 0; ++} ++ ++static int bcm84881_probe(struct phy_device *phydev) ++{ ++ /* This driver requires PMAPMD and AN blocks */ ++ const u32 mmd_mask = MDIO_DEVS_PMAPMD | MDIO_DEVS_AN; ++ ++ if (!phydev->is_c45 || ++ (phydev->c45_ids.devices_in_package & mmd_mask) != mmd_mask) ++ return -ENODEV; ++ ++ return 0; ++} ++ ++static int genphy_c45_an_config_aneg(struct phy_device *phydev) ++{ ++ bool changed = false; ++ u32 advertising; ++ int ret; ++ ++ phydev->advertising &= phydev->supported; ++ advertising = phydev->advertising; ++ ++ ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_ADVERTISE, ++ ADVERTISE_ALL | ADVERTISE_100BASE4 | ++ ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM, ++ ethtool_adv_to_mii_adv_t(advertising)); ++ if (ret < 0) ++ return ret; ++ if (ret > 0) ++ changed = true; ++ ++ ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL, ++ MDIO_AN_10GBT_CTRL_ADV10G, ++ advertising & ADVERTISED_10000baseT_Full ? ++ MDIO_AN_10GBT_CTRL_ADV10G : 0); ++ if (ret < 0) ++ return ret; ++ if (ret > 0) ++ changed = true; ++ ++ return genphy_c45_check_and_restart_aneg(phydev, changed); ++} ++ ++static int bcm84881_config_aneg(struct phy_device *phydev) ++{ ++ bool changed = false; ++ u32 adv; ++ int ret; ++ ++ /* Wait for the PHY to finish initialising, otherwise our ++ * advertisement may be overwritten. ++ */ ++ ret = bcm84881_wait_init(phydev); ++ if (ret) ++ return ret; ++ ++ /* We don't support manual MDI control */ ++ phydev->mdix_ctrl = ETH_TP_MDI_AUTO; ++ ++ /* disabled autoneg doesn't seem to work with this PHY */ ++ if (phydev->autoneg == AUTONEG_DISABLE) ++ return -EINVAL; ++ ++ ret = genphy_c45_an_config_aneg(phydev); ++ if (ret < 0) ++ return ret; ++ if (ret > 0) ++ changed = true; ++ ++ adv = ethtool_adv_to_mii_ctrl1000_t(phydev->advertising); ++ ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, ++ MDIO_AN_C22 + MII_CTRL1000, ++ ADVERTISE_1000FULL | ADVERTISE_1000HALF, ++ adv); ++ if (ret < 0) ++ return ret; ++ if (ret > 0) ++ changed = true; ++ ++ return genphy_c45_check_and_restart_aneg(phydev, changed); ++} ++ ++static int bcm84881_aneg_done(struct phy_device *phydev) ++{ ++ int bmsr, val; ++ ++ val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_STAT1); ++ if (val < 0) ++ return val; ++ ++ bmsr = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_C22 + MII_BMSR); ++ if (bmsr < 0) ++ return val; ++ ++ return !!(val & MDIO_AN_STAT1_COMPLETE) && ++ !!(bmsr & BMSR_ANEGCOMPLETE); ++} ++ ++static int bcm84881_read_status(struct phy_device *phydev) ++{ ++ bool autoneg_complete; ++ unsigned int mode; ++ int bmsr, val; ++ ++ val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_CTRL1); ++ if (val < 0) ++ return val; ++ ++ if (val & MDIO_AN_CTRL1_RESTART) { ++ phydev->link = 0; ++ return 0; ++ } ++ ++ val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_STAT1); ++ if (val < 0) ++ return val; ++ ++ bmsr = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_C22 + MII_BMSR); ++ if (bmsr < 0) ++ return val; ++ ++ autoneg_complete = !!(val & MDIO_AN_STAT1_COMPLETE) && ++ !!(bmsr & BMSR_ANEGCOMPLETE); ++ phydev->link = !!(val & MDIO_STAT1_LSTATUS) && ++ !!(bmsr & BMSR_LSTATUS); ++ if (phydev->autoneg == AUTONEG_ENABLE && !autoneg_complete) ++ phydev->link = false; ++ ++ if (!phydev->link) ++ return 0; ++ ++ phydev->lp_advertising = 0; ++ phydev->speed = SPEED_UNKNOWN; ++ phydev->duplex = DUPLEX_UNKNOWN; ++ phydev->pause = 0; ++ phydev->asym_pause = 0; ++ phydev->mdix = 0; ++ ++ if (autoneg_complete) { ++ val = genphy_c45_read_lpa(phydev); ++ if (val < 0) ++ return val; ++ ++ val = phy_read_mmd(phydev, MDIO_MMD_AN, ++ MDIO_AN_C22 + MII_STAT1000); ++ if (val < 0) ++ return val; ++ ++ phydev->lp_advertising |= mii_stat1000_to_ethtool_lpa_t(val); ++ ++ if (phydev->autoneg == AUTONEG_ENABLE) ++ phy_resolve_aneg_linkmode(phydev); ++ } ++ ++ if (phydev->autoneg == AUTONEG_DISABLE) { ++ /* disabled autoneg doesn't seem to work, so force the link ++ * down. ++ */ ++ phydev->link = 0; ++ return 0; ++ } ++ ++ /* Set the host link mode - we set the phy interface mode and ++ * the speed according to this register so that downshift works. ++ * We leave the duplex setting as per the resolution from the ++ * above. ++ */ ++ val = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x4011); ++ mode = (val & 0x1e) >> 1; ++ if (mode == 1 || mode == 2) ++ phydev->interface = PHY_INTERFACE_MODE_SGMII; ++ else if (mode == 3) ++ phydev->interface = PHY_INTERFACE_MODE_10GKR; ++ else if (mode == 4) ++ phydev->interface = PHY_INTERFACE_MODE_2500BASEX; ++ switch (mode & 7) { ++ case 1: ++ phydev->speed = SPEED_100; ++ break; ++ case 2: ++ phydev->speed = SPEED_1000; ++ break; ++ case 3: ++ phydev->speed = SPEED_10000; ++ break; ++ case 4: ++ phydev->speed = SPEED_2500; ++ break; ++ case 5: ++ phydev->speed = SPEED_5000; ++ break; ++ } ++ ++ return genphy_c45_read_mdix(phydev); ++} ++ ++static struct phy_driver bcm84881_drivers[] = { ++ { ++ .phy_id = 0xae025150, ++ .phy_id_mask = 0xfffffff0, ++ .name = "Broadcom BCM84881", ++ .features = SUPPORTED_100baseT_Full | ++ SUPPORTED_100baseT_Half | ++ SUPPORTED_1000baseT_Full | ++ SUPPORTED_Autoneg | ++ SUPPORTED_TP | ++ SUPPORTED_FIBRE | ++ SUPPORTED_10000baseT_Full | ++ SUPPORTED_Backplane, ++ .config_init = bcm84881_config_init, ++ .probe = bcm84881_probe, ++ .config_aneg = bcm84881_config_aneg, ++ .aneg_done = bcm84881_aneg_done, ++ .read_status = bcm84881_read_status, ++ }, ++}; ++ ++module_phy_driver(bcm84881_drivers); ++ ++/* FIXME: module auto-loading for Clause 45 PHYs seems non-functional */ ++static struct mdio_device_id __maybe_unused bcm84881_tbl[] = { ++ { 0xae025150, 0xfffffff0 }, ++ { }, ++}; ++MODULE_AUTHOR("Russell King"); ++MODULE_DESCRIPTION("Broadcom BCM84881 PHY driver"); ++MODULE_DEVICE_TABLE(mdio, bcm84881_tbl); ++MODULE_LICENSE("GPL"); diff --git a/target/linux/generic/pending-4.19/753-net-sfp-add-support-for-Clause-45-PHYs.patch b/target/linux/generic/pending-4.19/753-net-sfp-add-support-for-Clause-45-PHYs.patch new file mode 100644 index 000000000..ea2677084 --- /dev/null +++ b/target/linux/generic/pending-4.19/753-net-sfp-add-support-for-Clause-45-PHYs.patch @@ -0,0 +1,94 @@ +From 6df6709dc3d00e0bc948d45dfa8d8f18ba379c48 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 5 Nov 2019 11:56:18 +0000 +Subject: [PATCH 656/660] net: sfp: add support for Clause 45 PHYs + +Some SFP+ modules have a Clause 45 PHY onboard, which is accessible via +the normal I2C address. Detect 10G BASE-T PHYs which may have an +accessible PHY and probe for it. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 44 +++++++++++++++++++++++++++++++++++++++---- + 1 file changed, 40 insertions(+), 4 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -1337,12 +1337,12 @@ static void sfp_sm_phy_detach(struct sfp + sfp->mod_phy = NULL; + } + +-static void sfp_sm_probe_phy(struct sfp *sfp) ++static void sfp_sm_probe_phy(struct sfp *sfp, bool is_c45) + { + struct phy_device *phy; + int err; + +- phy = mdiobus_scan(sfp->i2c_mii, SFP_PHY_ADDR); ++ phy = get_phy_device(sfp->i2c_mii, SFP_PHY_ADDR, is_c45); + if (phy == ERR_PTR(-ENODEV)) { + dev_info(sfp->dev, "no PHY detected\n"); + return; +@@ -1352,6 +1352,13 @@ static void sfp_sm_probe_phy(struct sfp + return; + } + ++ err = phy_device_register(phy); ++ if (err) { ++ phy_device_free(phy); ++ dev_err(sfp->dev, "phy_device_register failed: %d\n", err); ++ return; ++ } ++ + err = sfp_add_phy(sfp->sfp_bus, phy); + if (err) { + phy_device_remove(phy); +@@ -1422,10 +1429,32 @@ static void sfp_sm_fault(struct sfp *sfp + } + } + ++/* Probe a SFP for a PHY device if the module supports copper - the PHY ++ * normally sits at I2C bus address 0x56, and may either be a clause 22 ++ * or clause 45 PHY. ++ * ++ * Clause 22 copper SFP modules normally operate in Cisco SGMII mode with ++ * negotiation enabled, but some may be in 1000base-X - which is for the ++ * PHY driver to determine. ++ * ++ * Clause 45 copper SFP+ modules (10G) appear to switch their interface ++ * mode according to the negotiated line speed. ++ */ + static void sfp_sm_probe_for_phy(struct sfp *sfp) + { +- if (sfp->id.base.e1000_base_t) +- sfp_sm_probe_phy(sfp); ++ switch (sfp->id.base.extended_cc) { ++ case SFF8024_ECC_10GBASE_T_SFI: ++ case SFF8024_ECC_10GBASE_T_SR: ++ case SFF8024_ECC_5GBASE_T: ++ case SFF8024_ECC_2_5GBASE_T: ++ sfp_sm_probe_phy(sfp, true); ++ break; ++ ++ default: ++ if (sfp->id.base.e1000_base_t) ++ sfp_sm_probe_phy(sfp, false); ++ break; ++ } + } + + static int sfp_module_parse_power(struct sfp *sfp) +@@ -1485,6 +1514,13 @@ static int sfp_sm_mod_hpower(struct sfp + return -EAGAIN; + } + ++ /* DM7052 reports as a high power module, responds to reads (with ++ * all bytes 0xff) at 0x51 but does not accept writes. In any case, ++ * if the bit is already set, we're already in high power mode. ++ */ ++ if (!!(val & BIT(0)) == enable) ++ return 0; ++ + if (enable) + val |= BIT(0); + else diff --git a/target/linux/generic/pending-4.19/754-net-sfp-fix-unbind.patch b/target/linux/generic/pending-4.19/754-net-sfp-fix-unbind.patch new file mode 100644 index 000000000..55fabafa8 --- /dev/null +++ b/target/linux/generic/pending-4.19/754-net-sfp-fix-unbind.patch @@ -0,0 +1,28 @@ +From 729fd05aac22cdf1e502fbf1bf80e5ebba0d9fbc Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 3 Dec 2019 17:48:28 +0000 +Subject: [PATCH] net: sfp: fix unbind + +When unbinding, we don't correctly tear down the module state, leaving +(for example) the hwmon registration behind. Ensure everything is +properly removed by sending a remove event at unbind. + +Fixes: 6b0da5c9c1a3 ("net: sfp: track upstream's attachment state in state machine") +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -2260,6 +2260,10 @@ static int sfp_remove(struct platform_de + + sfp_unregister_socket(sfp->sfp_bus); + ++ rtnl_lock(); ++ sfp_sm_event(sfp, SFP_E_REMOVE); ++ rtnl_unlock(); ++ + return 0; + } + diff --git a/target/linux/generic/pending-4.19/755-net-sfp-fix-hwmon.patch b/target/linux/generic/pending-4.19/755-net-sfp-fix-hwmon.patch new file mode 100644 index 000000000..d003df4e1 --- /dev/null +++ b/target/linux/generic/pending-4.19/755-net-sfp-fix-hwmon.patch @@ -0,0 +1,44 @@ +From 5eb0df5023c6ae8a71a7848fd5e1f788d86e51ae Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 3 Dec 2019 18:46:04 +0000 +Subject: [PATCH] net: sfp: fix hwmon + +The referenced commit below allowed more than one hwmon device to be +created per SFP, which is definitely not what we want. Avoid this by +only creating the hwmon device just as we transition to WAITDEV state. + +Fixes: 139d3a212a1f ("net: sfp: allow modules with slow diagnostics to probe") +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 13 ++++--------- + 1 file changed, 4 insertions(+), 9 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -1731,6 +1731,10 @@ static void sfp_sm_module(struct sfp *sf + break; + } + ++ err = sfp_hwmon_insert(sfp); ++ if (err) ++ dev_warn(sfp->dev, "hwmon probe failed: %d\n", err); ++ + sfp_sm_mod_next(sfp, SFP_MOD_WAITDEV, 0); + /* fall through */ + case SFP_MOD_WAITDEV: +@@ -1780,15 +1784,6 @@ static void sfp_sm_module(struct sfp *sf + case SFP_MOD_ERROR: + break; + } +- +-#if IS_ENABLED(CONFIG_HWMON) +- if (sfp->sm_mod_state >= SFP_MOD_WAITDEV && +- IS_ERR_OR_NULL(sfp->hwmon_dev)) { +- err = sfp_hwmon_insert(sfp); +- if (err) +- dev_warn(sfp->dev, "hwmon probe failed: %d\n", err); +- } +-#endif + } + + static void sfp_sm_main(struct sfp *sfp, unsigned int event) diff --git a/target/linux/generic/pending-4.19/756-net-sfp-use-a-definition-for-the-fault-recovery-atte.patch b/target/linux/generic/pending-4.19/756-net-sfp-use-a-definition-for-the-fault-recovery-atte.patch new file mode 100644 index 000000000..8362f73f4 --- /dev/null +++ b/target/linux/generic/pending-4.19/756-net-sfp-use-a-definition-for-the-fault-recovery-atte.patch @@ -0,0 +1,55 @@ +From 4d6bfb6fbb00af38402db4d1ce464e22def9fd9e Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Thu, 28 Nov 2019 14:24:40 +0000 +Subject: [PATCH 1/4] net: sfp: use a definition for the fault recovery + attempts + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 14 +++++++++++--- + 1 file changed, 11 insertions(+), 3 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -170,6 +170,14 @@ static const enum gpiod_flags gpio_flags + #define T_RESET_US 10 + #define T_FAULT_RECOVER msecs_to_jiffies(1000) + ++/* N_FAULT_INIT is the number of recovery attempts at module initialisation ++ * time. If the TX_FAULT signal is not deasserted after this number of ++ * attempts at clearing it, we decide that the module is faulty. ++ * N_FAULT is the same but after the module has initialised. ++ */ ++#define N_FAULT_INIT 5 ++#define N_FAULT 5 ++ + /* SFP module presence detection is poor: the three MOD DEF signals are + * the same length on the PCB, which means it's possible for MOD DEF 0 to + * connect before the I2C bus on MOD DEF 1/2. +@@ -1820,7 +1828,7 @@ static void sfp_sm_main(struct sfp *sfp, + sfp_module_tx_enable(sfp); + + /* Initialise the fault clearance retries */ +- sfp->sm_retries = 5; ++ sfp->sm_retries = N_FAULT_INIT; + + /* We need to check the TX_FAULT state, which is not defined + * while TX_DISABLE is asserted. The earliest we want to do +@@ -1860,7 +1868,7 @@ static void sfp_sm_main(struct sfp *sfp, + * or t_start_up, so assume there is a fault. + */ + sfp_sm_fault(sfp, SFP_S_INIT_TX_FAULT, +- sfp->sm_retries == 5); ++ sfp->sm_retries == N_FAULT_INIT); + } else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) { + init_done: /* TX_FAULT deasserted or we timed out with TX_FAULT + * clear. Probe for the PHY and check the LOS state. +@@ -1873,7 +1881,7 @@ static void sfp_sm_main(struct sfp *sfp, + sfp_sm_link_check_los(sfp); + + /* Reset the fault retry count */ +- sfp->sm_retries = 5; ++ sfp->sm_retries = N_FAULT; + } + break; + diff --git a/target/linux/generic/pending-4.19/757-net-sfp-rename-sm_retries.patch b/target/linux/generic/pending-4.19/757-net-sfp-rename-sm_retries.patch new file mode 100644 index 000000000..c6f43729d --- /dev/null +++ b/target/linux/generic/pending-4.19/757-net-sfp-rename-sm_retries.patch @@ -0,0 +1,60 @@ +From bfa3cbb01c7ea34d7369c9bd2ec1b2dc67082b04 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Mon, 2 Dec 2019 18:06:44 +0000 +Subject: [PATCH 2/4] net: sfp: rename sm_retries + +Rename sm_retries as sm_fault_retries, as this is what this member is +tracking. + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -232,7 +232,7 @@ struct sfp { + unsigned char sm_mod_tries; + unsigned char sm_dev_state; + unsigned short sm_state; +- unsigned int sm_retries; ++ unsigned char sm_fault_retries; + + struct sfp_eeprom_id id; + unsigned int module_power_mW; +@@ -1425,7 +1425,7 @@ static bool sfp_los_event_inactive(struc + + static void sfp_sm_fault(struct sfp *sfp, unsigned int next_state, bool warn) + { +- if (sfp->sm_retries && !--sfp->sm_retries) { ++ if (sfp->sm_fault_retries && !--sfp->sm_fault_retries) { + dev_err(sfp->dev, + "module persistently indicates fault, disabling\n"); + sfp_sm_next(sfp, SFP_S_TX_DISABLE, 0); +@@ -1828,7 +1828,7 @@ static void sfp_sm_main(struct sfp *sfp, + sfp_module_tx_enable(sfp); + + /* Initialise the fault clearance retries */ +- sfp->sm_retries = N_FAULT_INIT; ++ sfp->sm_fault_retries = N_FAULT_INIT; + + /* We need to check the TX_FAULT state, which is not defined + * while TX_DISABLE is asserted. The earliest we want to do +@@ -1868,7 +1868,7 @@ static void sfp_sm_main(struct sfp *sfp, + * or t_start_up, so assume there is a fault. + */ + sfp_sm_fault(sfp, SFP_S_INIT_TX_FAULT, +- sfp->sm_retries == N_FAULT_INIT); ++ sfp->sm_fault_retries == N_FAULT_INIT); + } else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) { + init_done: /* TX_FAULT deasserted or we timed out with TX_FAULT + * clear. Probe for the PHY and check the LOS state. +@@ -1881,7 +1881,7 @@ static void sfp_sm_main(struct sfp *sfp, + sfp_sm_link_check_los(sfp); + + /* Reset the fault retry count */ +- sfp->sm_retries = N_FAULT; ++ sfp->sm_fault_retries = N_FAULT; + } + break; + diff --git a/target/linux/generic/pending-4.19/758-net-sfp-error-handling-for-phy-probe.patch b/target/linux/generic/pending-4.19/758-net-sfp-error-handling-for-phy-probe.patch new file mode 100644 index 000000000..8191e622a --- /dev/null +++ b/target/linux/generic/pending-4.19/758-net-sfp-error-handling-for-phy-probe.patch @@ -0,0 +1,97 @@ +From 1fba543dc8edf4a43bff3276306648bb27c1e207 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Fri, 29 Nov 2019 00:30:08 +0000 +Subject: [PATCH 3/4] net: sfp: error handling for phy probe + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 26 +++++++++++++++++--------- + 1 file changed, 17 insertions(+), 9 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -1345,7 +1345,7 @@ static void sfp_sm_phy_detach(struct sfp + sfp->mod_phy = NULL; + } + +-static void sfp_sm_probe_phy(struct sfp *sfp, bool is_c45) ++static int sfp_sm_probe_phy(struct sfp *sfp, bool is_c45) + { + struct phy_device *phy; + int err; +@@ -1353,18 +1353,18 @@ static void sfp_sm_probe_phy(struct sfp + phy = get_phy_device(sfp->i2c_mii, SFP_PHY_ADDR, is_c45); + if (phy == ERR_PTR(-ENODEV)) { + dev_info(sfp->dev, "no PHY detected\n"); +- return; ++ return 0; + } + if (IS_ERR(phy)) { + dev_err(sfp->dev, "mdiobus scan returned %ld\n", PTR_ERR(phy)); +- return; ++ return PTR_ERR(phy); + } + + err = phy_device_register(phy); + if (err) { + phy_device_free(phy); + dev_err(sfp->dev, "phy_device_register failed: %d\n", err); +- return; ++ return err; + } + + err = sfp_add_phy(sfp->sfp_bus, phy); +@@ -1372,10 +1372,12 @@ static void sfp_sm_probe_phy(struct sfp + phy_device_remove(phy); + phy_device_free(phy); + dev_err(sfp->dev, "sfp_add_phy failed: %d\n", err); +- return; ++ return err; + } + + sfp->mod_phy = phy; ++ ++ return 0; + } + + static void sfp_sm_link_up(struct sfp *sfp) +@@ -1448,21 +1450,24 @@ static void sfp_sm_fault(struct sfp *sfp + * Clause 45 copper SFP+ modules (10G) appear to switch their interface + * mode according to the negotiated line speed. + */ +-static void sfp_sm_probe_for_phy(struct sfp *sfp) ++static int sfp_sm_probe_for_phy(struct sfp *sfp) + { ++ int err = 0; ++ + switch (sfp->id.base.extended_cc) { + case SFF8024_ECC_10GBASE_T_SFI: + case SFF8024_ECC_10GBASE_T_SR: + case SFF8024_ECC_5GBASE_T: + case SFF8024_ECC_2_5GBASE_T: +- sfp_sm_probe_phy(sfp, true); ++ err = sfp_sm_probe_phy(sfp, true); + break; + + default: + if (sfp->id.base.e1000_base_t) +- sfp_sm_probe_phy(sfp, false); ++ err = sfp_sm_probe_phy(sfp, false); + break; + } ++ return err; + } + + static int sfp_module_parse_power(struct sfp *sfp) +@@ -1873,7 +1878,10 @@ static void sfp_sm_main(struct sfp *sfp, + init_done: /* TX_FAULT deasserted or we timed out with TX_FAULT + * clear. Probe for the PHY and check the LOS state. + */ +- sfp_sm_probe_for_phy(sfp); ++ if (sfp_sm_probe_for_phy(sfp)) { ++ sfp_sm_next(sfp, SFP_S_FAIL, 0); ++ break; ++ } + if (sfp_module_start(sfp->sfp_bus)) { + sfp_sm_next(sfp, SFP_S_FAIL, 0); + break; diff --git a/target/linux/generic/pending-4.19/759-net-sfp-re-attempt-probing-for-phy.patch b/target/linux/generic/pending-4.19/759-net-sfp-re-attempt-probing-for-phy.patch new file mode 100644 index 000000000..46d987344 --- /dev/null +++ b/target/linux/generic/pending-4.19/759-net-sfp-re-attempt-probing-for-phy.patch @@ -0,0 +1,132 @@ +From 6c4efe83a0acf6f06c89ae17b885fa5739eb5be7 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Mon, 2 Dec 2019 18:20:22 +0000 +Subject: [PATCH 4/4] net: sfp: re-attempt probing for phy + +Some 1000BASE-T PHY modules take a while for the PHY to wake up. +Retry the probe a number of times before deciding that the module has +no PHY. + +Tested with: + Sourcephotonics SPGBTXCNFC - PHY takes less than 50ms to respond. + Champion One 1000SFPT - PHY takes about 200ms to respond. + Mikrotik S-RJ01 - no PHY + +Signed-off-by: Russell King +--- + drivers/net/phy/sfp.c | 59 ++++++++++++++++++++++++++++++++++++--------------- + 1 file changed, 42 insertions(+), 17 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -60,6 +60,7 @@ enum { + SFP_S_FAIL, + SFP_S_WAIT, + SFP_S_INIT, ++ SFP_S_INIT_PHY, + SFP_S_INIT_TX_FAULT, + SFP_S_WAIT_LOS, + SFP_S_LINK_UP, +@@ -124,6 +125,7 @@ static const char * const sm_state_strin + [SFP_S_FAIL] = "fail", + [SFP_S_WAIT] = "wait", + [SFP_S_INIT] = "init", ++ [SFP_S_INIT_PHY] = "init_phy", + [SFP_S_INIT_TX_FAULT] = "init_tx_fault", + [SFP_S_WAIT_LOS] = "wait_los", + [SFP_S_LINK_UP] = "link_up", +@@ -178,6 +180,12 @@ static const enum gpiod_flags gpio_flags + #define N_FAULT_INIT 5 + #define N_FAULT 5 + ++/* T_PHY_RETRY is the time interval between attempts to probe the PHY. ++ * R_PHY_RETRY is the number of attempts. ++ */ ++#define T_PHY_RETRY msecs_to_jiffies(50) ++#define R_PHY_RETRY 12 ++ + /* SFP module presence detection is poor: the three MOD DEF signals are + * the same length on the PCB, which means it's possible for MOD DEF 0 to + * connect before the I2C bus on MOD DEF 1/2. +@@ -233,6 +241,7 @@ struct sfp { + unsigned char sm_dev_state; + unsigned short sm_state; + unsigned char sm_fault_retries; ++ unsigned char sm_phy_retries; + + struct sfp_eeprom_id id; + unsigned int module_power_mW; +@@ -1351,10 +1360,8 @@ static int sfp_sm_probe_phy(struct sfp * + int err; + + phy = get_phy_device(sfp->i2c_mii, SFP_PHY_ADDR, is_c45); +- if (phy == ERR_PTR(-ENODEV)) { +- dev_info(sfp->dev, "no PHY detected\n"); +- return 0; +- } ++ if (phy == ERR_PTR(-ENODEV)) ++ return PTR_ERR(phy); + if (IS_ERR(phy)) { + dev_err(sfp->dev, "mdiobus scan returned %ld\n", PTR_ERR(phy)); + return PTR_ERR(phy); +@@ -1802,6 +1809,7 @@ static void sfp_sm_module(struct sfp *sf + static void sfp_sm_main(struct sfp *sfp, unsigned int event) + { + unsigned long timeout; ++ int ret; + + /* Some events are global */ + if (sfp->sm_state != SFP_S_DOWN && +@@ -1875,22 +1883,39 @@ static void sfp_sm_main(struct sfp *sfp, + sfp_sm_fault(sfp, SFP_S_INIT_TX_FAULT, + sfp->sm_fault_retries == N_FAULT_INIT); + } else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) { +- init_done: /* TX_FAULT deasserted or we timed out with TX_FAULT +- * clear. Probe for the PHY and check the LOS state. +- */ +- if (sfp_sm_probe_for_phy(sfp)) { +- sfp_sm_next(sfp, SFP_S_FAIL, 0); +- break; +- } +- if (sfp_module_start(sfp->sfp_bus)) { +- sfp_sm_next(sfp, SFP_S_FAIL, 0); ++ init_done: ++ sfp->sm_phy_retries = R_PHY_RETRY; ++ goto phy_probe; ++ } ++ break; ++ ++ case SFP_S_INIT_PHY: ++ if (event != SFP_E_TIMEOUT) ++ break; ++ phy_probe: ++ /* TX_FAULT deasserted or we timed out with TX_FAULT ++ * clear. Probe for the PHY and check the LOS state. ++ */ ++ ret = sfp_sm_probe_for_phy(sfp); ++ if (ret == -ENODEV) { ++ if (--sfp->sm_phy_retries) { ++ sfp_sm_next(sfp, SFP_S_INIT_PHY, T_PHY_RETRY); + break; ++ } else { ++ dev_info(sfp->dev, "no PHY detected\n"); + } +- sfp_sm_link_check_los(sfp); +- +- /* Reset the fault retry count */ +- sfp->sm_fault_retries = N_FAULT; ++ } else if (ret) { ++ sfp_sm_next(sfp, SFP_S_FAIL, 0); ++ break; + } ++ if (sfp_module_start(sfp->sfp_bus)) { ++ sfp_sm_next(sfp, SFP_S_FAIL, 0); ++ break; ++ } ++ sfp_sm_link_check_los(sfp); ++ ++ /* Reset the fault retry count */ ++ sfp->sm_fault_retries = N_FAULT; + break; + + case SFP_S_INIT_TX_FAULT: diff --git a/target/linux/generic/pending-4.19/834-ledtrig-libata.patch b/target/linux/generic/pending-4.19/834-ledtrig-libata.patch index de029fafe..f1dc0e599 100644 --- a/target/linux/generic/pending-4.19/834-ledtrig-libata.patch +++ b/target/linux/generic/pending-4.19/834-ledtrig-libata.patch @@ -75,7 +75,7 @@ Signed-off-by: Daniel Golle qc = __ata_qc_from_tag(ap, tag); qc->tag = qc->hw_tag = tag; -@@ -6044,6 +6060,9 @@ struct ata_port *ata_port_alloc(struct a +@@ -6068,6 +6084,9 @@ struct ata_port *ata_port_alloc(struct a ap->stats.unhandled_irq = 1; ap->stats.idle_irq = 1; #endif @@ -85,7 +85,7 @@ Signed-off-by: Daniel Golle ata_sff_port_init(ap); return ap; -@@ -6079,6 +6098,12 @@ static void ata_host_release(struct kref +@@ -6103,6 +6122,12 @@ static void ata_host_release(struct kref kfree(ap->pmp_link); kfree(ap->slave_link); @@ -98,7 +98,7 @@ Signed-off-by: Daniel Golle kfree(ap); host->ports[i] = NULL; } -@@ -6542,7 +6567,23 @@ int ata_host_register(struct ata_host *h +@@ -6566,7 +6591,23 @@ int ata_host_register(struct ata_host *h host->ports[i]->print_id = atomic_inc_return(&ata_print_id); host->ports[i]->local_port_no = i + 1; } diff --git a/target/linux/ipq40xx/Makefile b/target/linux/ipq40xx/Makefile index 875b75c8e..55182a876 100644 --- a/target/linux/ipq40xx/Makefile +++ b/target/linux/ipq40xx/Makefile @@ -20,7 +20,7 @@ DEFAULT_PACKAGES += \ kmod-ath10k wpad-openssl \ kmod-usb3 kmod-usb-dwc3 ath10k-firmware-qca4019 \ automount autosamba luci-app-ipsec-vpnd v2ray shadowsocks-libev-ss-redir shadowsocksr-libev-server \ - luci-app-unblockmusic luci-app-qbittorrent luci-app-zerotier luci-app-xlnetacc ddns-scripts_aliyun ca-certificates \ + luci-app-unblockmusic luci-app-qbittorrent luci-app-zerotier luci-app-xlnetacc ca-certificates \ htop fdisk e2fsprogs $(eval $(call BuildTarget)) diff --git a/target/linux/ipq40xx/patches-4.14/085-mtd-nand-add-macronix-mx35lf1ge4ab.patch b/target/linux/ipq40xx/patches-4.14/085-mtd-nand-add-macronix-mx35lf1ge4ab.patch new file mode 100644 index 000000000..56316aa51 --- /dev/null +++ b/target/linux/ipq40xx/patches-4.14/085-mtd-nand-add-macronix-mx35lf1ge4ab.patch @@ -0,0 +1,13 @@ +--- a/drivers/mtd/nand/nand_ids.c ++++ b/drivers/mtd/nand/nand_ids.c +@@ -54,6 +54,10 @@ struct nand_flash_dev nand_flash_ids[] = + { .id = {0xad, 0xde, 0x94, 0xda, 0x74, 0xc4} }, + SZ_8K, SZ_8K, SZ_2M, NAND_NEED_SCRAMBLING, 6, 640, + NAND_ECC_INFO(40, SZ_1K), 4 }, ++ {"MX35LF1GE4AB 1G 3.3V 8-bit", ++ { .id = {0xc2, 0x12} }, ++ SZ_2K, SZ_128, SZ_128K, NAND_NO_SUBPAGE_WRITE, ++ 2, 64, NAND_ECC_INFO(4, SZ_512) }, + {"W25N01GV 1G 3.3V 8-bit", + { .id = {0xef, 0xaa} }, + SZ_2K, SZ_128, SZ_128K, NAND_NO_SUBPAGE_WRITE, diff --git a/target/linux/ipq40xx/patches-4.14/706-ar40xx-abort-probe-on-missig-phy.patch b/target/linux/ipq40xx/patches-4.14/706-ar40xx-abort-probe-on-missig-phy.patch new file mode 100644 index 000000000..19474bff0 --- /dev/null +++ b/target/linux/ipq40xx/patches-4.14/706-ar40xx-abort-probe-on-missig-phy.patch @@ -0,0 +1,23 @@ +--- a/drivers/net/phy/ar40xx.c ++++ b/drivers/net/phy/ar40xx.c +@@ -2021,6 +2021,12 @@ static int ar40xx_probe(struct platform_ + /* register switch */ + swdev = &priv->dev; + ++ if (priv->mii_bus == NULL) { ++ dev_err(&pdev->dev, "Probe failed - Missing PHYs!\n"); ++ ret = -ENODEV; ++ goto err_missing_phy; ++ } ++ + swdev->alias = dev_name(&priv->mii_bus->dev); + + swdev->cpu_port = AR40XX_PORT_CPU; +@@ -2052,6 +2058,7 @@ err_unregister_switch: + unregister_switch(&priv->dev); + err_unregister_phy: + phy_driver_unregister(&ar40xx_phy_driver); ++err_missing_phy: + platform_set_drvdata(pdev, NULL); + return ret; + } diff --git a/target/linux/ipq40xx/patches-4.14/710-net-add-qualcomm-essedma-ethernet-driver.patch b/target/linux/ipq40xx/patches-4.14/710-net-add-qualcomm-essedma-ethernet-driver.patch index a6e5d461e..1e47f2fe9 100644 --- a/target/linux/ipq40xx/patches-4.14/710-net-add-qualcomm-essedma-ethernet-driver.patch +++ b/target/linux/ipq40xx/patches-4.14/710-net-add-qualcomm-essedma-ethernet-driver.patch @@ -1523,7 +1523,7 @@ Signed-off-by: Christian Lamparter + int res; + + if (skb->protocol == htons(ETH_P_IPV6)) { -+ ++ dev_err(&adapter->pdev->dev, "IPv6 not supported\n"); + res = -EINVAL; + goto no_protocol_err; + } @@ -2775,7 +2775,7 @@ Signed-off-by: Christian Lamparter + int i; + u32 stat; + -+ spin_lock(&edma_cinfo->stats_lock); ++ spin_lock_bh(&edma_cinfo->stats_lock); + p = (uint32_t *)&(edma_cinfo->edma_ethstats); + + for (i = 0; i < EDMA_MAX_TRANSMIT_QUEUE; i++) { @@ -2802,7 +2802,7 @@ Signed-off-by: Christian Lamparter + p++; + } + -+ spin_unlock(&edma_cinfo->stats_lock); ++ spin_unlock_bh(&edma_cinfo->stats_lock); +} + +static void edma_statistics_timer(unsigned long data) diff --git a/target/linux/ipq40xx/patches-4.14/714-essedma-add-fix-for-memory-allocation.patch b/target/linux/ipq40xx/patches-4.14/714-essedma-add-fix-for-memory-allocation.patch new file mode 100644 index 000000000..6c696caf4 --- /dev/null +++ b/target/linux/ipq40xx/patches-4.14/714-essedma-add-fix-for-memory-allocation.patch @@ -0,0 +1,199 @@ +From 72c050acbc425ef99313d5c2e4c866e25567e569 Mon Sep 17 00:00:00 2001 +From: Rakesh Nair +Date: Thu, 8 Jun 2017 14:29:20 +0530 +Subject: [PATCH] CHROMIUM: net: qualcomm: Add fix for memory allocation issues + +Added ethtool counters for memory allocation failures accounting. +Added support to track number of allocation failures that could +not be fulfilled in the current iteration in the rx descriptor +field and use the info to allocate in the subsequent iteration. + +Change-Id: Ie4fd3b6cf25304e5db2c9247a498791e7e9bb4aa +Signed-off-by: Rakesh Nair +Signed-off-by: Kan Yan +Reviewed-on: https://chromium-review.googlesource.com/535419 +Reviewed-by: Grant Grundler +--- + drivers/net/ethernet/qualcomm/essedma/edma.c | 54 ++++++++++++++----- + drivers/net/ethernet/qualcomm/essedma/edma.h | 2 + + .../ethernet/qualcomm/essedma/edma_ethtool.c | 1 + + 3 files changed, 43 insertions(+), 14 deletions(-) + +--- a/drivers/net/ethernet/qualcomm/essedma/edma.c ++++ b/drivers/net/ethernet/qualcomm/essedma/edma.c +@@ -103,6 +103,9 @@ static int edma_alloc_rx_ring(struct edm + return -ENOMEM; + } + ++ /* Initialize pending_fill */ ++ erxd->pending_fill = 0; ++ + return 0; + } + +@@ -185,11 +188,8 @@ static int edma_alloc_rx_buf(struct edma + u16 prod_idx, length; + u32 reg_data; + +- if (cleaned_count > erdr->count) { +- dev_err(&pdev->dev, "Incorrect cleaned_count %d", +- cleaned_count); +- return -1; +- } ++ if (cleaned_count > erdr->count) ++ cleaned_count = erdr->count - 1; + + i = erdr->sw_next_to_fill; + +@@ -199,6 +199,9 @@ static int edma_alloc_rx_buf(struct edma + + if (sw_desc->flags & EDMA_SW_DESC_FLAG_SKB_REUSE) { + skb = sw_desc->skb; ++ ++ /* Clear REUSE Flag */ ++ sw_desc->flags &= ~EDMA_SW_DESC_FLAG_SKB_REUSE; + } else { + /* alloc skb */ + skb = netdev_alloc_skb_ip_align(edma_netdev[0], length); +@@ -264,6 +267,13 @@ static int edma_alloc_rx_buf(struct edma + reg_data &= ~EDMA_RFD_PROD_IDX_BITS; + reg_data |= prod_idx; + edma_write_reg(EDMA_REG_RFD_IDX_Q(queue_id), reg_data); ++ ++ /* If we couldn't allocate all the buffers ++ * we increment the alloc failure counters ++ */ ++ if (cleaned_count) ++ edma_cinfo->edma_ethstats.rx_alloc_fail_ctr++; ++ + return cleaned_count; + } + +@@ -534,7 +544,7 @@ static int edma_rx_complete_paged(struct + * edma_rx_complete() + * Main api called from the poll function to process rx packets. + */ +-static void edma_rx_complete(struct edma_common_info *edma_cinfo, ++static u16 edma_rx_complete(struct edma_common_info *edma_cinfo, + int *work_done, int work_to_do, int queue_id, + struct napi_struct *napi) + { +@@ -554,6 +564,7 @@ static void edma_rx_complete(struct edma + u16 count = erdr->count, rfd_avail; + u8 queue_to_rxid[8] = {0, 0, 1, 1, 2, 2, 3, 3}; + ++ cleaned_count = erdr->pending_fill; + sw_next_to_clean = erdr->sw_next_to_clean; + + edma_read_reg(EDMA_REG_RFD_IDX_Q(queue_id), &data); +@@ -652,12 +663,13 @@ static void edma_rx_complete(struct edma + (*work_done)++; + drop_count = 0; + } +- if (cleaned_count == EDMA_RX_BUFFER_WRITE) { ++ if (cleaned_count >= EDMA_RX_BUFFER_WRITE) { + /* If buffer clean count reaches 16, we replenish HW buffers. */ + ret_count = edma_alloc_rx_buf(edma_cinfo, erdr, cleaned_count, queue_id); + edma_write_reg(EDMA_REG_RX_SW_CONS_IDX_Q(queue_id), + sw_next_to_clean); + cleaned_count = ret_count; ++ erdr->pending_fill = ret_count; + } + continue; + } +@@ -730,11 +742,12 @@ static void edma_rx_complete(struct edma + adapter->stats.rx_bytes += length; + + /* Check if we reached refill threshold */ +- if (cleaned_count == EDMA_RX_BUFFER_WRITE) { ++ if (cleaned_count >= EDMA_RX_BUFFER_WRITE) { + ret_count = edma_alloc_rx_buf(edma_cinfo, erdr, cleaned_count, queue_id); + edma_write_reg(EDMA_REG_RX_SW_CONS_IDX_Q(queue_id), + sw_next_to_clean); + cleaned_count = ret_count; ++ erdr->pending_fill = ret_count; + } + + /* At this point skb should go to stack */ +@@ -756,13 +769,17 @@ static u16 edma_rx_complete(struct edma_common_info *edma_cinfo, + /* Refill here in case refill threshold wasn't reached */ + if (edma_rfd_desc_unused(erdr)) { + ret_count = edma_alloc_rx_buf(edma_cinfo, erdr, edma_rfd_desc_unused(erdr), queue_id); +- if (ret_count) { +- dev_dbg(&pdev->dev, "Not all buffers was reallocated"); +- edma_realloc_timer_start(napi, queue_id); +- } ++ erdr->pending_fill = ret_count; ++ if (ret_count) { ++ if (net_ratelimit()) ++ dev_dbg(&pdev->dev, "Not all buffers was reallocated"); ++ } ++ + edma_write_reg(EDMA_REG_RX_SW_CONS_IDX_Q(queue_id), + erdr->sw_next_to_clean); + } ++ ++ return erdr->pending_fill; + } + + /* edma_delete_rfs_filter() +@@ -2064,6 +2081,7 @@ int edma_poll(struct napi_struct *napi, + u32 shadow_rx_status, shadow_tx_status; + int queue_id; + int i, work_done = 0; ++ u16 rx_pending_fill; + + /* Store the Rx/Tx status by ANDing it with + * appropriate CPU RX?TX mask +@@ -2097,13 +2115,19 @@ int edma_poll(struct napi_struct *napi, + */ + while (edma_percpu_info->rx_status) { + queue_id = ffs(edma_percpu_info->rx_status) - 1; +- edma_rx_complete(edma_cinfo, &work_done, +- budget, queue_id, napi); ++ rx_pending_fill = edma_rx_complete(edma_cinfo, &work_done, ++ budget, queue_id, napi); + +- if (likely(work_done < budget)) ++ if (likely(work_done < budget)) { ++ if (rx_pending_fill) { ++ /* reschedule poll() to refill rx buffer deficit */ ++ work_done = budget; ++ break; ++ } + edma_percpu_info->rx_status &= ~(1 << queue_id); +- else ++ } else { + break; ++ } + } + + /* Clear the status register, to avoid the interrupts to +--- a/drivers/net/ethernet/qualcomm/essedma/edma.h ++++ b/drivers/net/ethernet/qualcomm/essedma/edma.h +@@ -225,6 +225,7 @@ struct edma_ethtool_statistics { + u32 rx_q6_byte; + u32 rx_q7_byte; + u32 tx_desc_error; ++ u32 rx_alloc_fail_ctr; + }; + + struct edma_mdio_data { +@@ -362,6 +363,7 @@ struct edma_rfd_desc_ring { + dma_addr_t dma; /* descriptor ring physical address */ + u16 sw_next_to_fill; /* next descriptor to fill */ + u16 sw_next_to_clean; /* next descriptor to clean */ ++ u16 pending_fill; /* fill pending from previous iteration */ + }; + + /* edma_rfs_flter_node - rfs filter node in hash table */ +--- a/drivers/net/ethernet/qualcomm/essedma/edma_ethtool.c ++++ b/drivers/net/ethernet/qualcomm/essedma/edma_ethtool.c +@@ -78,6 +78,7 @@ static const struct edma_ethtool_stats e + {"rx_q6_byte", EDMA_STAT(rx_q6_byte)}, + {"rx_q7_byte", EDMA_STAT(rx_q7_byte)}, + {"tx_desc_error", EDMA_STAT(tx_desc_error)}, ++ {"rx_alloc_fail_ctr", EDMA_STAT(rx_alloc_fail_ctr)}, + }; + + #define EDMA_STATS_LEN ARRAY_SIZE(edma_gstrings_stats) diff --git a/target/linux/ipq40xx/patches-4.14/901-arm-boot-add-dts-files.patch b/target/linux/ipq40xx/patches-4.14/901-arm-boot-add-dts-files.patch index d6e9ace0d..75797cf37 100644 --- a/target/linux/ipq40xx/patches-4.14/901-arm-boot-add-dts-files.patch +++ b/target/linux/ipq40xx/patches-4.14/901-arm-boot-add-dts-files.patch @@ -27,14 +27,14 @@ Signed-off-by: John Crispin qcom-ipq4019-ap.dk01.1-c1.dtb \ + qcom-ipq4019-a62.dtb \ + qcom-ipq4019-ap.dk04.1-c1.dtb \ ++ qcom-ipq4019-hugo-ac1200.dtb \ + qcom-ipq4019-map-ac2200.dtb \ + qcom-ipq4019-r619ac.dtb \ + qcom-ipq4019-r619ac-128m.dtb \ -+ qcom-ipq4019-hugo-ac1200.dtb \ + qcom-ipq4019-rt-acrh17.dtb \ + qcom-ipq4028-wpj428.dtb \ + qcom-ipq4029-gl-b1300.dtb \ + qcom-ipq4029-mr33.dtb \ qcom-ipq8064-ap148.dtb \ qcom-msm8660-surf.dtb \ - qcom-msm8960-cdp.dtb \ \ No newline at end of file + qcom-msm8960-cdp.dtb \ diff --git a/target/linux/ipq40xx/patches-4.19/700-net-add-qualcomm-mdio.patch b/target/linux/ipq40xx/patches-4.19/700-net-add-qualcomm-mdio.patch index e939597b8..847e2e870 100644 --- a/target/linux/ipq40xx/patches-4.19/700-net-add-qualcomm-mdio.patch +++ b/target/linux/ipq40xx/patches-4.19/700-net-add-qualcomm-mdio.patch @@ -1,6 +1,6 @@ --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig -@@ -519,6 +519,13 @@ config XILINX_GMII2RGMII +@@ -524,6 +524,13 @@ config XILINX_GMII2RGMII the Reduced Gigabit Media Independent Interface(RGMII) between Ethernet physical media devices and the Gigabit Ethernet controller. diff --git a/target/linux/ipq40xx/patches-4.19/705-net-add-qualcomm-ar40xx-phy.patch b/target/linux/ipq40xx/patches-4.19/705-net-add-qualcomm-ar40xx-phy.patch index 735ea945f..bc75aab08 100644 --- a/target/linux/ipq40xx/patches-4.19/705-net-add-qualcomm-ar40xx-phy.patch +++ b/target/linux/ipq40xx/patches-4.19/705-net-add-qualcomm-ar40xx-phy.patch @@ -1,6 +1,6 @@ --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig -@@ -526,6 +526,13 @@ config MDIO_IPQ40XX +@@ -531,6 +531,13 @@ config MDIO_IPQ40XX This driver supports the MDIO interface found in Qualcomm Atheros ipq40xx Soc chip. diff --git a/target/linux/layerscape/patches-4.14/301-arch-support-layerscape.patch b/target/linux/layerscape/patches-4.14/301-arch-support-layerscape.patch index e8b730f95..59ed13056 100644 --- a/target/linux/layerscape/patches-4.14/301-arch-support-layerscape.patch +++ b/target/linux/layerscape/patches-4.14/301-arch-support-layerscape.patch @@ -285,7 +285,7 @@ Signed-off-by: Zhao Qiang #define PAGE_NONE __pgprot(((_PAGE_DEFAULT) & ~PTE_VALID) | PTE_PROT_NONE | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN) --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h -@@ -360,6 +360,11 @@ static inline int pmd_protnone(pmd_t pmd +@@ -357,6 +357,11 @@ static inline int pmd_protnone(pmd_t pmd __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_DEVICE_nGnRnE) | PTE_PXN | PTE_UXN) #define pgprot_writecombine(prot) \ __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_NORMAL_NC) | PTE_PXN | PTE_UXN) diff --git a/target/linux/layerscape/patches-4.14/821-smmu-support-layerscape.patch b/target/linux/layerscape/patches-4.14/821-smmu-support-layerscape.patch index 8b845dd71..931e09a9f 100644 --- a/target/linux/layerscape/patches-4.14/821-smmu-support-layerscape.patch +++ b/target/linux/layerscape/patches-4.14/821-smmu-support-layerscape.patch @@ -123,7 +123,7 @@ Signed-off-by: Biwen Li static struct kset *iommu_group_kset; static DEFINE_IDA(iommu_group_ida); -@@ -989,6 +990,26 @@ struct iommu_group *pci_device_group(str +@@ -990,6 +991,26 @@ struct iommu_group *pci_device_group(str return iommu_group_alloc(); } diff --git a/target/linux/mediatek/patches-4.19/0003-switch-add-mt7531.patch b/target/linux/mediatek/patches-4.19/0003-switch-add-mt7531.patch index 096802a30..43c8d01da 100644 --- a/target/linux/mediatek/patches-4.19/0003-switch-add-mt7531.patch +++ b/target/linux/mediatek/patches-4.19/0003-switch-add-mt7531.patch @@ -11,7 +11,7 @@ config SFP --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile -@@ -100,3 +100,5 @@ obj-$(CONFIG_STE10XP) += ste10Xp.o +@@ -101,3 +101,5 @@ obj-$(CONFIG_STE10XP) += ste10Xp.o obj-$(CONFIG_TERANETICS_PHY) += teranetics.o obj-$(CONFIG_VITESSE_PHY) += vitesse.o obj-$(CONFIG_XILINX_GMII2RGMII) += xilinx_gmii2rgmii.o diff --git a/target/linux/mvebu/patches-4.19/404-sfp-provide-netdev-sfp_bus-and-use-for-start-stop.patch b/target/linux/mvebu/patches-4.19/404-sfp-provide-netdev-sfp_bus-and-use-for-start-stop.patch deleted file mode 100644 index f2581ca6b..000000000 --- a/target/linux/mvebu/patches-4.19/404-sfp-provide-netdev-sfp_bus-and-use-for-start-stop.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 0068a89747e7c1d9a0bbb7282a34382a4274638a Mon Sep 17 00:00:00 2001 -From: Russell King -Date: Fri, 14 Apr 2017 16:41:55 +0100 -Subject: [PATCH] sfp: provide netdev sfp_bus and use for start/stop - -Add a netdev sfp_bus pointer for propagating the phylink start/stop -actions to the SFP cage: the SFP cage may not be directly connected to -phylink, but may be the other side of a fixed PHY, and SFP needs to -know when the netdev is brought up or taken down. - -Signed-off-by: Russell King ---- - drivers/net/phy/phylink.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - ---- a/drivers/net/phy/phylink.c -+++ b/drivers/net/phy/phylink.c -@@ -949,8 +949,8 @@ void phylink_start(struct phylink *pl) - - if (pl->link_an_mode == MLO_AN_FIXED && !IS_ERR(pl->link_gpio)) - mod_timer(&pl->link_poll, jiffies + HZ); -- if (pl->sfp_bus) -- sfp_upstream_start(pl->sfp_bus); -+ if (pl->netdev->sfp_bus) -+ sfp_upstream_start(pl->netdev->sfp_bus); - if (pl->phydev) - phy_start(pl->phydev); - } -@@ -971,8 +971,8 @@ void phylink_stop(struct phylink *pl) - - if (pl->phydev) - phy_stop(pl->phydev); -- if (pl->sfp_bus) -- sfp_upstream_stop(pl->sfp_bus); -+ if (pl->netdev->sfp_bus) -+ sfp_upstream_stop(pl->netdev->sfp_bus); - if (pl->link_an_mode == MLO_AN_FIXED && !IS_ERR(pl->link_gpio)) - del_timer_sync(&pl->link_poll); - diff --git a/target/linux/mvebu/patches-4.19/405-net-phy-marvell10g-add-SFP-support.patch b/target/linux/mvebu/patches-4.19/405-net-phy-marvell10g-add-SFP-support.patch deleted file mode 100644 index 9624b6cd8..000000000 --- a/target/linux/mvebu/patches-4.19/405-net-phy-marvell10g-add-SFP-support.patch +++ /dev/null @@ -1,155 +0,0 @@ -From 5f3ac54810055fec0cc667bb04c16f783830abff Mon Sep 17 00:00:00 2001 -From: Russell King -Date: Fri, 14 Apr 2017 14:21:25 +0100 -Subject: [PATCH] net: phy: marvell10g: add SFP+ support - -Add support for SFP+ cages to the Marvell 10G PHY driver. This is -slightly complicated by the way phylib works in that we need to use -a multi-step process to attach the SFP bus, and we also need to track -the phylink state machine to know when the module's transmit disable -signal should change state. - -With appropriate DT changes, this allows the SFP+ canges on the -Macchiatobin platform to be functional. - -Signed-off-by: Russell King ---- - drivers/net/phy/marvell10g.c | 80 ++++++++++++++++++++++++++++++++++++ - 1 file changed, 80 insertions(+) - ---- a/drivers/net/phy/marvell10g.c -+++ b/drivers/net/phy/marvell10g.c -@@ -25,6 +25,8 @@ - #include - #include - #include -+#include -+#include - - enum { - MV_PMA_BOOT = 0xc050, -@@ -56,6 +58,11 @@ enum { - }; - - struct mv3310_priv { -+ struct fwnode_handle *sfp_fwnode; -+ struct sfp_bus *sfp_bus; -+ enum phy_state state; -+ bool running; -+ - struct device *hwmon_dev; - char *hwmon_name; - }; -@@ -219,6 +226,27 @@ static int mv3310_hwmon_probe(struct phy - } - #endif - -+static int mv3310_sfp_insert(void *upstream, const struct sfp_eeprom_id *id) -+{ -+ struct phy_device *phydev = upstream; -+ struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev); -+ __ETHTOOL_DECLARE_LINK_MODE_MASK(support) = { 0, }; -+ phy_interface_t iface; -+ -+ sfp_parse_support(priv->sfp_bus, id, support); -+ iface = sfp_select_interface(priv->sfp_bus, id, support); -+ -+ if (iface != PHY_INTERFACE_MODE_10GKR) { -+ dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n"); -+ return -EINVAL; -+ } -+ return 0; -+} -+ -+static const struct sfp_upstream_ops mv3310_sfp_ops = { -+ .module_insert = mv3310_sfp_insert, -+}; -+ - static int mv3310_probe(struct phy_device *phydev) - { - struct mv3310_priv *priv; -@@ -249,9 +277,30 @@ static int mv3310_probe(struct phy_devic - if (ret) - return ret; - -+ if (phydev->mdio.dev.fwnode) { -+ struct fwnode_reference_args ref; -+ int ret; -+ -+ ret = fwnode_property_get_reference_args(phydev->mdio.dev.fwnode, -+ "sfp", NULL, 0, 0, -+ &ref); -+ if (ret == 0) -+ priv->sfp_fwnode = ref.fwnode; -+ } -+ - return 0; - } - -+static void mv3310_remove(struct phy_device *phydev) -+{ -+ struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev); -+ -+ if (priv->sfp_bus) -+ sfp_unregister_upstream(priv->sfp_bus); -+ -+ fwnode_handle_put(priv->sfp_fwnode); -+} -+ - static int mv3310_suspend(struct phy_device *phydev) - { - return 0; -@@ -262,8 +311,29 @@ static int mv3310_resume(struct phy_devi - return mv3310_hwmon_config(phydev, true); - } - -+static void mv3310_link_change_notify(struct phy_device *phydev) -+{ -+ struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev); -+ enum phy_state state = phydev->state; -+ bool running; -+ -+ if (priv->sfp_bus && priv->state != state) { -+ priv->state = state; -+ -+ running = state >= PHY_UP && state < PHY_HALTED; -+ if (priv->running != running) { -+ priv->running = running; -+ if (running) -+ sfp_upstream_start(priv->sfp_bus); -+ else -+ sfp_upstream_stop(priv->sfp_bus); -+ } -+ } -+} -+ - static int mv3310_config_init(struct phy_device *phydev) - { -+ struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev); - __ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = { 0, }; - u32 mask; - int val; -@@ -357,6 +427,14 @@ static int mv3310_config_init(struct phy - phydev->supported &= mask; - phydev->advertising &= phydev->supported; - -+ /* Would be nice to do this in the probe function, but unfortunately, -+ * phylib doesn't have phydev->attached_dev set there. -+ */ -+ if (priv->sfp_fwnode && !priv->sfp_bus) -+ priv->sfp_bus = sfp_register_upstream(priv->sfp_fwnode, -+ phydev->attached_dev, -+ phydev, &mv3310_sfp_ops); -+ - return 0; - } - -@@ -566,6 +644,8 @@ static struct phy_driver mv3310_drivers[ - .config_aneg = mv3310_config_aneg, - .aneg_done = mv3310_aneg_done, - .read_status = mv3310_read_status, -+ .remove = mv3310_remove, -+ .link_change_notify = mv3310_link_change_notify, - }, - }; - diff --git a/target/linux/mvebu/patches-4.19/406-sfp-add-sfp-compatible.patch b/target/linux/mvebu/patches-4.19/406-sfp-add-sfp-compatible.patch deleted file mode 100644 index 0c6cb72cb..000000000 --- a/target/linux/mvebu/patches-4.19/406-sfp-add-sfp-compatible.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 7e8bf5227f87601d8d74948bcae8846d2bdd6995 Mon Sep 17 00:00:00 2001 -From: Russell King -Date: Fri, 14 Apr 2017 20:17:13 +0100 -Subject: [PATCH] sfp: add sfp+ compatible - -Add a compatible for SFP+ cages. SFP+ cages are backwards compatible, -but the ethernet device behind them may not support the slower speeds -of SFP modules. - -Signed-off-by: Russell King ---- - drivers/net/phy/sfp.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/drivers/net/phy/sfp.c -+++ b/drivers/net/phy/sfp.c -@@ -230,6 +230,7 @@ static const struct sff_data sfp_data = - static const struct of_device_id sfp_of_match[] = { - { .compatible = "sff,sff", .data = &sff_data, }, - { .compatible = "sff,sfp", .data = &sfp_data, }, -+ { .compatible = "sff,sfp+", .data = &sfp_data, }, - { }, - }; - MODULE_DEVICE_TABLE(of, sfp_of_match); diff --git a/target/linux/mvebu/patches-4.19/407-sfp-display-SFP-module-information.patch b/target/linux/mvebu/patches-4.19/407-sfp-display-SFP-module-information.patch deleted file mode 100644 index 854ac6876..000000000 --- a/target/linux/mvebu/patches-4.19/407-sfp-display-SFP-module-information.patch +++ /dev/null @@ -1,297 +0,0 @@ -From 4ce55fb01c473bf1ad2048f8b4db62dca392e6d2 Mon Sep 17 00:00:00 2001 -From: Russell King -Date: Sun, 13 Sep 2015 01:06:31 +0100 -Subject: [PATCH] sfp: display SFP module information - -Signed-off-by: Russell King ---- - drivers/net/phy/sfp.c | 261 +++++++++++++++++++++++++++++++++++++++++- - 1 file changed, 258 insertions(+), 3 deletions(-) - ---- a/drivers/net/phy/sfp.c -+++ b/drivers/net/phy/sfp.c -@@ -1132,6 +1132,184 @@ static void sfp_hwmon_remove(struct sfp - } - #endif - -+static const char *sfp_link_len(char *buf, size_t size, unsigned int length, -+ unsigned int multiplier) -+{ -+ if (length == 0) -+ return "unsupported/unspecified"; -+ -+ if (length == 255) { -+ *buf++ = '>'; -+ size -= 1; -+ length -= 1; -+ } -+ -+ length *= multiplier; -+ -+ if (length >= 1000) -+ snprintf(buf, size, "%u.%0*ukm", -+ length / 1000, -+ multiplier > 100 ? 1 : -+ multiplier > 10 ? 2 : 3, -+ length % 1000); -+ else -+ snprintf(buf, size, "%um", length); -+ -+ return buf; -+} -+ -+struct bitfield { -+ unsigned int mask; -+ unsigned int val; -+ const char *str; -+}; -+ -+static const struct bitfield sfp_options[] = { -+ { -+ .mask = SFP_OPTIONS_HIGH_POWER_LEVEL, -+ .val = SFP_OPTIONS_HIGH_POWER_LEVEL, -+ .str = "hpl", -+ }, { -+ .mask = SFP_OPTIONS_PAGING_A2, -+ .val = SFP_OPTIONS_PAGING_A2, -+ .str = "paginga2", -+ }, { -+ .mask = SFP_OPTIONS_RETIMER, -+ .val = SFP_OPTIONS_RETIMER, -+ .str = "retimer", -+ }, { -+ .mask = SFP_OPTIONS_COOLED_XCVR, -+ .val = SFP_OPTIONS_COOLED_XCVR, -+ .str = "cooled", -+ }, { -+ .mask = SFP_OPTIONS_POWER_DECL, -+ .val = SFP_OPTIONS_POWER_DECL, -+ .str = "powerdecl", -+ }, { -+ .mask = SFP_OPTIONS_RX_LINEAR_OUT, -+ .val = SFP_OPTIONS_RX_LINEAR_OUT, -+ .str = "rxlinear", -+ }, { -+ .mask = SFP_OPTIONS_RX_DECISION_THRESH, -+ .val = SFP_OPTIONS_RX_DECISION_THRESH, -+ .str = "rxthresh", -+ }, { -+ .mask = SFP_OPTIONS_TUNABLE_TX, -+ .val = SFP_OPTIONS_TUNABLE_TX, -+ .str = "tunabletx", -+ }, { -+ .mask = SFP_OPTIONS_RATE_SELECT, -+ .val = SFP_OPTIONS_RATE_SELECT, -+ .str = "ratesel", -+ }, { -+ .mask = SFP_OPTIONS_TX_DISABLE, -+ .val = SFP_OPTIONS_TX_DISABLE, -+ .str = "txdisable", -+ }, { -+ .mask = SFP_OPTIONS_TX_FAULT, -+ .val = SFP_OPTIONS_TX_FAULT, -+ .str = "txfault", -+ }, { -+ .mask = SFP_OPTIONS_LOS_INVERTED, -+ .val = SFP_OPTIONS_LOS_INVERTED, -+ .str = "los-", -+ }, { -+ .mask = SFP_OPTIONS_LOS_NORMAL, -+ .val = SFP_OPTIONS_LOS_NORMAL, -+ .str = "los+", -+ }, { } -+}; -+ -+static const struct bitfield diagmon[] = { -+ { -+ .mask = SFP_DIAGMON_DDM, -+ .val = SFP_DIAGMON_DDM, -+ .str = "ddm", -+ }, { -+ .mask = SFP_DIAGMON_INT_CAL, -+ .val = SFP_DIAGMON_INT_CAL, -+ .str = "intcal", -+ }, { -+ .mask = SFP_DIAGMON_EXT_CAL, -+ .val = SFP_DIAGMON_EXT_CAL, -+ .str = "extcal", -+ }, { -+ .mask = SFP_DIAGMON_RXPWR_AVG, -+ .val = SFP_DIAGMON_RXPWR_AVG, -+ .str = "rxpwravg", -+ }, { } -+}; -+ -+static const char *sfp_bitfield(char *out, size_t outsz, const struct bitfield *bits, unsigned int val) -+{ -+ char *p = out; -+ int n; -+ -+ *p = '\0'; -+ while (bits->mask) { -+ if ((val & bits->mask) == bits->val) { -+ n = snprintf(p, outsz, "%s%s", -+ out != p ? ", " : "", -+ bits->str); -+ if (n == outsz) -+ break; -+ p += n; -+ outsz -= n; -+ } -+ bits++; -+ } -+ -+ return out; -+} -+ -+static const char *sfp_connector(unsigned int connector) -+{ -+ switch (connector) { -+ case SFP_CONNECTOR_UNSPEC: -+ return "unknown/unspecified"; -+ case SFP_CONNECTOR_SC: -+ return "SC"; -+ case SFP_CONNECTOR_FIBERJACK: -+ return "Fiberjack"; -+ case SFP_CONNECTOR_LC: -+ return "LC"; -+ case SFP_CONNECTOR_MT_RJ: -+ return "MT-RJ"; -+ case SFP_CONNECTOR_MU: -+ return "MU"; -+ case SFP_CONNECTOR_SG: -+ return "SG"; -+ case SFP_CONNECTOR_OPTICAL_PIGTAIL: -+ return "Optical pigtail"; -+ case SFP_CONNECTOR_HSSDC_II: -+ return "HSSDC II"; -+ case SFP_CONNECTOR_COPPER_PIGTAIL: -+ return "Copper pigtail"; -+ default: -+ return "unknown"; -+ } -+} -+ -+static const char *sfp_encoding(unsigned int encoding) -+{ -+ switch (encoding) { -+ case SFP_ENCODING_UNSPEC: -+ return "unspecified"; -+ case SFP_ENCODING_8472_64B66B: -+ return "64b66b"; -+ case SFP_ENCODING_8B10B: -+ return "8b10b"; -+ case SFP_ENCODING_4B5B: -+ return "4b5b"; -+ case SFP_ENCODING_NRZ: -+ return "NRZ"; -+ case SFP_ENCODING_8472_MANCHESTER: -+ return "MANCHESTER"; -+ default: -+ return "unknown"; -+ } -+} -+ - /* Helpers */ - static void sfp_module_tx_disable(struct sfp *sfp) - { -@@ -1376,6 +1554,8 @@ static int sfp_sm_mod_probe(struct sfp * - { - /* SFP module inserted - read I2C data */ - struct sfp_eeprom_id id; -+ char date[9]; -+ char options[80]; - bool cotsworks; - u8 check; - int ret; -@@ -1432,12 +1612,87 @@ static int sfp_sm_mod_probe(struct sfp * - - sfp->id = id; - -- dev_info(sfp->dev, "module %.*s %.*s rev %.*s sn %.*s dc %.*s\n", -+ date[0] = sfp->id.ext.datecode[4]; -+ date[1] = sfp->id.ext.datecode[5]; -+ date[2] = '-'; -+ date[3] = sfp->id.ext.datecode[2]; -+ date[4] = sfp->id.ext.datecode[3]; -+ date[5] = '-'; -+ date[6] = sfp->id.ext.datecode[0]; -+ date[7] = sfp->id.ext.datecode[1]; -+ date[8] = '\0'; -+ -+ dev_info(sfp->dev, "module %.*s %.*s rev %.*s sn %.*s dc %s\n", - (int)sizeof(id.base.vendor_name), id.base.vendor_name, - (int)sizeof(id.base.vendor_pn), id.base.vendor_pn, - (int)sizeof(id.base.vendor_rev), id.base.vendor_rev, -- (int)sizeof(id.ext.vendor_sn), id.ext.vendor_sn, -- (int)sizeof(id.ext.datecode), id.ext.datecode); -+ (int)sizeof(id.ext.vendor_sn), id.ext.vendor_sn, date); -+ dev_info(sfp->dev, " %s connector, encoding %s, nominal bitrate %u.%uGbps +%u%% -%u%%\n", -+ sfp_connector(sfp->id.base.connector), -+ sfp_encoding(sfp->id.base.encoding), -+ sfp->id.base.br_nominal / 10, -+ sfp->id.base.br_nominal % 10, -+ sfp->id.ext.br_max, sfp->id.ext.br_min); -+ dev_info(sfp->dev, " 1000BaseSX%c 1000BaseLX%c 1000BaseCX%c 1000BaseT%c 100BaseLX%c 100BaseFX%c BaseBX10%c BasePX%c\n", -+ sfp->id.base.e1000_base_sx ? '+' : '-', -+ sfp->id.base.e1000_base_lx ? '+' : '-', -+ sfp->id.base.e1000_base_cx ? '+' : '-', -+ sfp->id.base.e1000_base_t ? '+' : '-', -+ sfp->id.base.e100_base_lx ? '+' : '-', -+ sfp->id.base.e100_base_fx ? '+' : '-', -+ sfp->id.base.e_base_bx10 ? '+' : '-', -+ sfp->id.base.e_base_px ? '+' : '-'); -+ dev_info(sfp->dev, " 10GBaseSR%c 10GBaseLR%c 10GBaseLRM%c 10GBaseER%c\n", -+ sfp->id.base.e10g_base_sr ? '+' : '-', -+ sfp->id.base.e10g_base_lr ? '+' : '-', -+ sfp->id.base.e10g_base_lrm ? '+' : '-', -+ sfp->id.base.e10g_base_er ? '+' : '-'); -+ -+ if (!sfp->id.base.sfp_ct_passive && !sfp->id.base.sfp_ct_active && -+ !sfp->id.base.e1000_base_t) { -+ char len_9um[16], len_om[16]; -+ -+ dev_info(sfp->dev, " Wavelength %unm, fiber lengths:\n", -+ be16_to_cpup(&sfp->id.base.optical_wavelength)); -+ -+ if (sfp->id.base.link_len[0] == 255) -+ strcpy(len_9um, ">254km"); -+ else if (sfp->id.base.link_len[1] && sfp->id.base.link_len[1] != 255) -+ sprintf(len_9um, "%um", -+ sfp->id.base.link_len[1] * 100); -+ else if (sfp->id.base.link_len[0]) -+ sprintf(len_9um, "%ukm", sfp->id.base.link_len[0]); -+ else if (sfp->id.base.link_len[1] == 255) -+ strcpy(len_9um, ">25.4km"); -+ else -+ strcpy(len_9um, "unsupported"); -+ -+ dev_info(sfp->dev, " 9µm SM : %s\n", len_9um); -+ dev_info(sfp->dev, " 62.5µm MM OM1: %s\n", -+ sfp_link_len(len_om, sizeof(len_om), -+ sfp->id.base.link_len[3], 10)); -+ dev_info(sfp->dev, " 50µm MM OM2: %s\n", -+ sfp_link_len(len_om, sizeof(len_om), -+ sfp->id.base.link_len[2], 10)); -+ dev_info(sfp->dev, " 50µm MM OM3: %s\n", -+ sfp_link_len(len_om, sizeof(len_om), -+ sfp->id.base.link_len[5], 10)); -+ dev_info(sfp->dev, " 50µm MM OM4: %s\n", -+ sfp_link_len(len_om, sizeof(len_om), -+ sfp->id.base.link_len[4], 10)); -+ } else { -+ char len[16]; -+ dev_info(sfp->dev, " Copper length: %s\n", -+ sfp_link_len(len, sizeof(len), -+ sfp->id.base.link_len[4], 1)); -+ } -+ -+ dev_info(sfp->dev, " Options: %s\n", -+ sfp_bitfield(options, sizeof(options), sfp_options, -+ be16_to_cpu(sfp->id.ext.options))); -+ dev_info(sfp->dev, " Diagnostics: %s\n", -+ sfp_bitfield(options, sizeof(options), diagmon, -+ sfp->id.ext.diagmon)); - - /* Check whether we support this module */ - if (!sfp->type->module_supported(&sfp->id)) { diff --git a/target/linux/mvebu/patches-4.19/408-sfp-more-cotsworks-fixes.patch b/target/linux/mvebu/patches-4.19/408-sfp-more-cotsworks-fixes.patch deleted file mode 100644 index 69a31cb9f..000000000 --- a/target/linux/mvebu/patches-4.19/408-sfp-more-cotsworks-fixes.patch +++ /dev/null @@ -1,44 +0,0 @@ -From e26af2726067ff260b77485df6af8375b82bfb1d Mon Sep 17 00:00:00 2001 -From: Russell King -Date: Sat, 23 Dec 2017 12:22:58 +0000 -Subject: [PATCH] sfp: more cotsworks fixes - -Cotsworks also gets the date code wrong. - -Signed-off-by: Russell King ---- - drivers/net/phy/sfp.c | 15 ++++++++------- - 1 file changed, 8 insertions(+), 7 deletions(-) - ---- a/drivers/net/phy/sfp.c -+++ b/drivers/net/phy/sfp.c -@@ -1571,9 +1571,9 @@ static int sfp_sm_mod_probe(struct sfp * - return -EAGAIN; - } - -- /* Cotsworks do not seem to update the checksums when they -- * do the final programming with the final module part number, -- * serial number and date code. -+ /* Cotsworks do not seem to update the checksums when they update the -+ * module part number, serial number and date code. They also format -+ * the date code incorrectly. - */ - cotsworks = !memcmp(id.base.vendor_name, "COTSWORKS ", 16); - -@@ -1612,11 +1612,12 @@ static int sfp_sm_mod_probe(struct sfp * - - sfp->id = id; - -- date[0] = sfp->id.ext.datecode[4]; -- date[1] = sfp->id.ext.datecode[5]; -+ /* Cotsworks also gets the date code wrong. */ -+ date[0] = sfp->id.ext.datecode[4 - 2 * cotsworks]; -+ date[1] = sfp->id.ext.datecode[5 - 2 * cotsworks]; - date[2] = '-'; -- date[3] = sfp->id.ext.datecode[2]; -- date[4] = sfp->id.ext.datecode[3]; -+ date[3] = sfp->id.ext.datecode[2 + 2 * cotsworks]; -+ date[4] = sfp->id.ext.datecode[3 + 2 * cotsworks]; - date[5] = '-'; - date[6] = sfp->id.ext.datecode[0]; - date[7] = sfp->id.ext.datecode[1]; diff --git a/target/linux/mvebu/patches-4.19/450-reprobe_sfp_phy.patch b/target/linux/mvebu/patches-4.19/450-reprobe_sfp_phy.patch deleted file mode 100644 index 833c515a1..000000000 --- a/target/linux/mvebu/patches-4.19/450-reprobe_sfp_phy.patch +++ /dev/null @@ -1,94 +0,0 @@ -From 28baa5e2635285b178326b301f534ed95c65dd01 Mon Sep 17 00:00:00 2001 -From: Jonas Gorski -Date: Thu, 29 Sep 2016 11:44:39 +0200 -Subject: [PATCH] sfp: retry phy probe if unsuccessful - -Some phys seem to take longer than 50 ms to come out of reset, so retry -until we find a phy. - -Signed-off-by: Jonas Gorski ---- - drivers/net/phy/sfp.c | 38 +++++++++++++++++++++++++------------- - 1 file changed, 25 insertions(+), 13 deletions(-) - ---- a/drivers/net/phy/sfp.c -+++ b/drivers/net/phy/sfp.c -@@ -1374,7 +1374,7 @@ static void sfp_sm_phy_detach(struct sfp - sfp->mod_phy = NULL; - } - --static void sfp_sm_probe_phy(struct sfp *sfp) -+static int sfp_sm_probe_phy(struct sfp *sfp) - { - struct phy_device *phy; - int err; -@@ -1384,11 +1384,11 @@ static void sfp_sm_probe_phy(struct sfp - phy = mdiobus_scan(sfp->i2c_mii, SFP_PHY_ADDR); - if (phy == ERR_PTR(-ENODEV)) { - dev_info(sfp->dev, "no PHY detected\n"); -- return; -+ return -EAGAIN; - } - if (IS_ERR(phy)) { - dev_err(sfp->dev, "mdiobus scan returned %ld\n", PTR_ERR(phy)); -- return; -+ return PTR_ERR(phy); - } - - err = sfp_add_phy(sfp->sfp_bus, phy); -@@ -1396,11 +1396,13 @@ static void sfp_sm_probe_phy(struct sfp - phy_device_remove(phy); - phy_device_free(phy); - dev_err(sfp->dev, "sfp_add_phy failed: %d\n", err); -- return; -+ return err; - } - - sfp->mod_phy = phy; - phy_start(phy); -+ -+ return 0; - } - - static void sfp_sm_link_up(struct sfp *sfp) -@@ -1464,14 +1466,9 @@ static void sfp_sm_fault(struct sfp *sfp - - static void sfp_sm_mod_init(struct sfp *sfp) - { -- sfp_module_tx_enable(sfp); -+ int ret = 0; - -- /* Wait t_init before indicating that the link is up, provided the -- * current state indicates no TX_FAULT. If TX_FAULT clears before -- * this time, that's fine too. -- */ -- sfp_sm_next(sfp, SFP_S_INIT, T_INIT_JIFFIES); -- sfp->sm_retries = 5; -+ sfp_module_tx_enable(sfp); - - /* Setting the serdes link mode is guesswork: there's no - * field in the EEPROM which indicates what mode should -@@ -1485,7 +1482,22 @@ static void sfp_sm_mod_init(struct sfp * - if (sfp->id.base.e1000_base_t || - sfp->id.base.e100_base_lx || - sfp->id.base.e100_base_fx) -- sfp_sm_probe_phy(sfp); -+ ret = sfp_sm_probe_phy(sfp); -+ -+ if (!ret) { -+ /* Wait t_init before indicating that the link is up, provided -+ * the current state indicates no TX_FAULT. If TX_FAULT clears -+ * this time, that's fine too. -+ */ -+ sfp_sm_next(sfp, SFP_S_INIT, T_INIT_JIFFIES); -+ sfp->sm_retries = 5; -+ return; -+ } -+ -+ if (ret == -EAGAIN) -+ sfp_sm_set_timer(sfp, T_PROBE_RETRY); -+ else -+ sfp_sm_next(sfp, SFP_S_TX_DISABLE, 0); - } - - static int sfp_sm_mod_hpower(struct sfp *sfp) diff --git a/target/linux/mvebu/patches-4.19/544-arm64-dts-uDPU-fix-comphy-definitions.patch b/target/linux/mvebu/patches-4.19/544-arm64-dts-uDPU-fix-comphy-definitions.patch new file mode 100644 index 000000000..f72ea93b9 --- /dev/null +++ b/target/linux/mvebu/patches-4.19/544-arm64-dts-uDPU-fix-comphy-definitions.patch @@ -0,0 +1,35 @@ +From 9c222a1d78a1700220e38feb270f00d2ddd3c5ab Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Wed, 6 Nov 2019 13:44:21 +0000 +Subject: [PATCH 657/660] arm64: dts: uDPU: fix comphy definitions + +The uDPU uses both ethernet controllers, which ties up COMPHY 0 for +eth1 and COMPHY 1 for eth0, with no USB3 comphy. The addition of +COMPHY support made the kernel override the setup by the boot loader +breaking this platform. Delete the USB3 COMPHY definition at platform +level, and add phy specifications for the ethernet channels. + +Fixes: bd3d25b07342 ("arm64: dts: marvell: armada-37xx: link USB hosts with their PHYs") +Signed-off-by: Russell King +--- + arch/arm64/boot/dts/marvell/armada-3720-uDPU.dts | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/arch/arm64/boot/dts/marvell/armada-3720-uDPU.dts ++++ b/arch/arm64/boot/dts/marvell/armada-3720-uDPU.dts +@@ -143,6 +143,7 @@ + status = "okay"; + phy-mode = "sgmii"; + managed = "in-band-status"; ++ phys = <&comphy1 0>; + sfp = <&sfp_eth0>; + }; + +@@ -150,6 +151,7 @@ + status = "okay"; + phy-mode = "sgmii"; + managed = "in-band-status"; ++ phys = <&comphy0 1>; + sfp = <&sfp_eth1>; + }; + diff --git a/target/linux/mvebu/patches-4.19/545-arm64-dts-uDPU-remove-i2c-fast-mode.patch b/target/linux/mvebu/patches-4.19/545-arm64-dts-uDPU-remove-i2c-fast-mode.patch new file mode 100644 index 000000000..b984eb4ba --- /dev/null +++ b/target/linux/mvebu/patches-4.19/545-arm64-dts-uDPU-remove-i2c-fast-mode.patch @@ -0,0 +1,30 @@ +From 662eb8fc87f982e63ccb9a9df25c7aeabf9fe341 Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Thu, 14 Nov 2019 00:23:35 +0000 +Subject: [PATCH 658/660] arm64: dts: uDPU: remove i2c-fast-mode + +The I2C bus violates the timing specifications when run in fast mode +on the uDPU, so switch to 100kHz mode. + +Signed-off-by: Russell King +--- + arch/arm64/boot/dts/marvell/armada-3720-uDPU.dts | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/arch/arm64/boot/dts/marvell/armada-3720-uDPU.dts ++++ b/arch/arm64/boot/dts/marvell/armada-3720-uDPU.dts +@@ -119,12 +119,14 @@ + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&i2c1_pins>; ++ /delete-property/mrvl,i2c-fast-mode; + }; + + &i2c1 { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&i2c2_pins>; ++ /delete-property/mrvl,i2c-fast-mode; + + lm75@48 { + status = "okay"; diff --git a/target/linux/mvebu/patches-4.19/546-arm64-dts-uDPU-SFP-cages-support-3W-modules.patch b/target/linux/mvebu/patches-4.19/546-arm64-dts-uDPU-SFP-cages-support-3W-modules.patch new file mode 100644 index 000000000..d025f36a5 --- /dev/null +++ b/target/linux/mvebu/patches-4.19/546-arm64-dts-uDPU-SFP-cages-support-3W-modules.patch @@ -0,0 +1,33 @@ +From 1cb114a20854e34324a2cb308f23054ff8227ffa Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Tue, 19 Nov 2019 22:48:50 +0000 +Subject: [PATCH 659/660] arm64: dts: uDPU: SFP cages support 3W modules + +The SFP cages are designed to support up to 3W modules, such as G.hn, +G.fast and MoCA modules. Although there is no way for such modules to +declare to software that they consume 3W, we document in DT that this +is the designed power level for these cages. + +Signed-off-by: Russell King +--- + arch/arm64/boot/dts/marvell/armada-3720-uDPU.dts | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/arch/arm64/boot/dts/marvell/armada-3720-uDPU.dts ++++ b/arch/arm64/boot/dts/marvell/armada-3720-uDPU.dts +@@ -69,6 +69,7 @@ + mod-def0-gpio = <&gpiosb 3 GPIO_ACTIVE_LOW>; + tx-disable-gpio = <&gpiosb 4 GPIO_ACTIVE_HIGH>; + tx-fault-gpio = <&gpiosb 5 GPIO_ACTIVE_HIGH>; ++ maximum-power-milliwatt = <3000>; + }; + + sfp_eth1: sfp-eth1 { +@@ -78,6 +79,7 @@ + mod-def0-gpio = <&gpiosb 8 GPIO_ACTIVE_LOW>; + tx-disable-gpio = <&gpiosb 9 GPIO_ACTIVE_HIGH>; + tx-fault-gpio = <&gpiosb 10 GPIO_ACTIVE_HIGH>; ++ maximum-power-milliwatt = <3000>; + }; + }; + diff --git a/target/linux/sunxi/patches-4.14/002-net-stmmac-dwmac-sun8i-Handle-integrated-external-MD.patch b/target/linux/sunxi/patches-4.14/002-net-stmmac-dwmac-sun8i-Handle-integrated-external-MD.patch index b354c1334..9f7f89c7e 100644 --- a/target/linux/sunxi/patches-4.14/002-net-stmmac-dwmac-sun8i-Handle-integrated-external-MD.patch +++ b/target/linux/sunxi/patches-4.14/002-net-stmmac-dwmac-sun8i-Handle-integrated-external-MD.patch @@ -329,7 +329,7 @@ Signed-off-by: David S. Miller } if (!of_property_read_u32(node, "allwinner,tx-delay-ps", &val)) { -@@ -747,81 +896,21 @@ static void sun8i_dwmac_unset_syscon(str +@@ -750,81 +899,21 @@ static void sun8i_dwmac_unset_syscon(str regmap_write(gmac->regmap, SYSCON_EMAC_REG, reg); } @@ -420,7 +420,7 @@ Signed-off-by: David S. Miller clk_disable_unprepare(gmac->tx_clk); -@@ -850,7 +939,7 @@ static struct mac_device_info *sun8i_dwm +@@ -853,7 +942,7 @@ static struct mac_device_info *sun8i_dwm if (!mac) return NULL; @@ -429,7 +429,7 @@ Signed-off-by: David S. Miller if (ret) return NULL; -@@ -892,6 +981,8 @@ static int sun8i_dwmac_probe(struct plat +@@ -895,6 +984,8 @@ static int sun8i_dwmac_probe(struct plat struct sunxi_priv_data *gmac; struct device *dev = &pdev->dev; int ret; @@ -438,7 +438,7 @@ Signed-off-by: David S. Miller ret = stmmac_get_platform_resources(pdev, &stmmac_res); if (ret) -@@ -935,29 +1026,6 @@ static int sun8i_dwmac_probe(struct plat +@@ -938,29 +1029,6 @@ static int sun8i_dwmac_probe(struct plat } plat_dat->interface = of_get_phy_mode(dev->of_node); @@ -468,7 +468,7 @@ Signed-off-by: David S. Miller /* platform data specifying hardware features and callbacks. * hardware features were copied from Allwinner drivers. -@@ -976,9 +1044,34 @@ static int sun8i_dwmac_probe(struct plat +@@ -979,9 +1047,34 @@ static int sun8i_dwmac_probe(struct plat ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); if (ret) diff --git a/target/linux/sunxi/patches-4.14/003-net-stmmac-sun8i-Restore-the-compatibles.patch b/target/linux/sunxi/patches-4.14/003-net-stmmac-sun8i-Restore-the-compatibles.patch index 02115c832..0e8d808b4 100644 --- a/target/linux/sunxi/patches-4.14/003-net-stmmac-sun8i-Restore-the-compatibles.patch +++ b/target/linux/sunxi/patches-4.14/003-net-stmmac-sun8i-Restore-the-compatibles.patch @@ -18,7 +18,7 @@ Signed-off-by: David S. Miller --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c -@@ -1075,6 +1075,14 @@ return ret; +@@ -1078,6 +1078,14 @@ return ret; } static const struct of_device_id sun8i_dwmac_match[] = { diff --git a/target/linux/tegra/Makefile b/target/linux/tegra/Makefile new file mode 100644 index 000000000..db58bf53d --- /dev/null +++ b/target/linux/tegra/Makefile @@ -0,0 +1,29 @@ +# +# Copyright (C) 2017-2019 Tomasz Maciej Nowak +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +include $(TOPDIR)/rules.mk + +ARCH := arm +BOARD := tegra +BOARDNAME := NVIDIA Tegra +FEATURES := audio boot-part display ext4 fpu gpio pci pcie rootfs-part rtc squashfs usb +CPU_TYPE := cortex-a9 +CPU_SUBTYPE := vfpv3 +MAINTAINER := Tomasz Maciej Nowak + +KERNEL_PATCHVER := 4.19 + +include $(INCLUDE_DIR)/target.mk + +KERNELNAME := zImage dtbs + +DEFAULT_PACKAGES += e2fsprogs mkf2fs partx-utils + +define Target/Description + Build firmware image for NVIDIA Tegra SoC devices. +endef + +$(eval $(call BuildTarget)) diff --git a/target/linux/tegra/base-files/etc/inittab b/target/linux/tegra/base-files/etc/inittab new file mode 100644 index 000000000..b944a93ad --- /dev/null +++ b/target/linux/tegra/base-files/etc/inittab @@ -0,0 +1,4 @@ +::sysinit:/etc/init.d/rcS S boot +::shutdown:/etc/init.d/rcS K shutdown +::askconsole:/usr/libexec/login.sh +tty1::askfirst:/usr/libexec/login.sh diff --git a/target/linux/tegra/base-files/lib/preinit/79_move_config b/target/linux/tegra/base-files/lib/preinit/79_move_config new file mode 100644 index 000000000..64ea55e5f --- /dev/null +++ b/target/linux/tegra/base-files/lib/preinit/79_move_config @@ -0,0 +1,21 @@ +#!/bin/sh + +move_config() { + local partdev + + . /lib/upgrade/common.sh + + if export_bootdevice && export_partdevice partdev 1; then + mkdir -p /boot + if mount -o ro,noatime "/dev/$partdev" /boot; then + if [ -f /boot/sysupgrade.tgz ]; then + mount /boot -o remount,rw,noatime + mv -f /boot/sysupgrade.tgz / + fi + umount /boot + rm -fR /boot + fi + fi +} + +boot_hook_add preinit_mount_root move_config diff --git a/target/linux/tegra/base-files/lib/upgrade/platform.sh b/target/linux/tegra/base-files/lib/upgrade/platform.sh new file mode 100644 index 000000000..be453bdf9 --- /dev/null +++ b/target/linux/tegra/base-files/lib/upgrade/platform.sh @@ -0,0 +1,103 @@ +REQUIRE_IMAGE_METADATA=1 + +get_magic_at() { + local pos="$2" + get_image "$1" | dd bs=1 count=2 skip="$pos" 2>/dev/null | hexdump -v -n 2 -e '1/1 "%02x"' +} + +platform_check_image() { + local diskdev partdev diff + + [ "$#" -gt 1 ] && return 1 + + case "$(get_magic_at "$1" 510)" in + 55aa) ;; + *) + echo "Failed to verify MBR boot signature." + return 1 + ;; + esac + + export_bootdevice && export_partdevice diskdev 0 || { + echo "Unable to determine upgrade device" + return 1 + } + + get_partitions "/dev/$diskdev" bootdisk + + #extract the boot sector from the image + get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b 2>/dev/null + + get_partitions /tmp/image.bs image + + #compare tables + diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)" + + rm -f /tmp/image.bs /tmp/partmap.bootdisk /tmp/partmap.image + + if [ -n "$diff" ]; then + echo "Partition layout has changed. Full image will be written." + ask_bool 0 "Abort" && exit 1 + return 0 + fi +} + +platform_copy_config() { + local partdev + + if export_partdevice partdev 1; then + mount -o rw,noatime "/dev/$partdev" /mnt + cp -af "$CONF_TAR" /mnt/ + umount /mnt + fi +} + +platform_do_upgrade() { + local diskdev partdev diff + + export_bootdevice && export_partdevice diskdev 0 || { + echo "Unable to determine upgrade device" + return 1 + } + + sync + + if [ "$SAVE_PARTITIONS" = "1" ]; then + get_partitions "/dev/$diskdev" bootdisk + + #extract the boot sector from the image + get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b + + get_partitions /tmp/image.bs image + + #compare tables + diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)" + else + diff=1 + fi + + if [ -n "$diff" ]; then + get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync + + # Separate removal and addtion is necessary; otherwise, partition 1 + # will be missing if it overlaps with the old partition 2 + partx -d - "/dev/$diskdev" + partx -a - "/dev/$diskdev" + + return 0 + fi + + #iterate over each partition from the image and write it to the boot disk + while read part start size; do + if export_partdevice partdev $part; then + echo "Writing image to /dev/$partdev..." + get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync + else + echo "Unable to find partition $part device, skipped." + fi + done < /tmp/partmap.image + + #copy partition uuid + echo "Writing new UUID to /dev/$diskdev..." + get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync +} diff --git a/target/linux/tegra/config-4.14 b/target/linux/tegra/config-4.14 new file mode 100644 index 000000000..42547da30 --- /dev/null +++ b/target/linux/tegra/config-4.14 @@ -0,0 +1,558 @@ +CONFIG_AC97_BUS=y +# CONFIG_AHCI_TEGRA is not set +CONFIG_ALIGNMENT_TRAP=y +CONFIG_ARCH_CLOCKSOURCE_DATA=y +CONFIG_ARCH_HAS_DEBUG_VIRTUAL=y +CONFIG_ARCH_HAS_ELF_RANDOMIZE=y +CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y +CONFIG_ARCH_HAS_RESET_CONTROLLER=y +CONFIG_ARCH_HAS_SET_MEMORY=y +CONFIG_ARCH_HAS_SG_CHAIN=y +CONFIG_ARCH_HAS_STRICT_KERNEL_RWX=y +CONFIG_ARCH_HAS_STRICT_MODULE_RWX=y +CONFIG_ARCH_HAS_TICK_BROADCAST=y +CONFIG_ARCH_HAVE_CUSTOM_GPIO_H=y +CONFIG_ARCH_HIBERNATION_POSSIBLE=y +CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y +CONFIG_ARCH_MULTIPLATFORM=y +# CONFIG_ARCH_MULTI_CPU_AUTO is not set +CONFIG_ARCH_MULTI_V6_V7=y +CONFIG_ARCH_MULTI_V7=y +CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED=y +CONFIG_ARCH_NR_GPIO=1024 +CONFIG_ARCH_OPTIONAL_KERNEL_RWX=y +CONFIG_ARCH_OPTIONAL_KERNEL_RWX_DEFAULT=y +# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set +# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set +CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y +CONFIG_ARCH_SUPPORTS_FIRMWARE=y +CONFIG_ARCH_SUPPORTS_TRUSTED_FOUNDATIONS=y +CONFIG_ARCH_SUPPORTS_UPROBES=y +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_ARCH_TEGRA=y +# CONFIG_ARCH_TEGRA_114_SOC is not set +# CONFIG_ARCH_TEGRA_124_SOC is not set +CONFIG_ARCH_TEGRA_2x_SOC=y +# CONFIG_ARCH_TEGRA_3x_SOC is not set +CONFIG_ARCH_USE_BUILTIN_BSWAP=y +CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y +CONFIG_ARCH_WANT_GENERAL_HUGETLB=y +CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y +CONFIG_ARM=y +CONFIG_ARM_AMBA=y +CONFIG_ARM_ARCH_TIMER=y +CONFIG_ARM_ARCH_TIMER_EVTSTREAM=y +CONFIG_ARM_CPU_SUSPEND=y +CONFIG_ARM_CRYPTO=y +CONFIG_ARM_ERRATA_720789=y +CONFIG_ARM_ERRATA_754327=y +CONFIG_ARM_ERRATA_764369=y +CONFIG_ARM_GIC=y +CONFIG_ARM_HAS_SG_CHAIN=y +CONFIG_ARM_HEAVY_MB=y +CONFIG_ARM_L1_CACHE_SHIFT=6 +CONFIG_ARM_L1_CACHE_SHIFT_6=y +# CONFIG_ARM_LPAE is not set +CONFIG_ARM_PATCH_IDIV=y +CONFIG_ARM_PATCH_PHYS_VIRT=y +# CONFIG_ARM_PL172_MPMC is not set +# CONFIG_ARM_SMMU is not set +# CONFIG_ARM_SP805_WATCHDOG is not set +CONFIG_ARM_TEGRA20_CPUFREQ=y +CONFIG_ARM_THUMB=y +CONFIG_ARM_THUMBEE=y +CONFIG_ARM_VIRT_EXT=y +CONFIG_ASN1=y +CONFIG_ATA=y +CONFIG_ATAGS=y +CONFIG_AUTO_ZRELADDR=y +CONFIG_BLK_DEV_BSG=y +CONFIG_BLK_DEV_LOOP=y +CONFIG_BLK_MQ_PCI=y +CONFIG_BLK_SCSI_REQUEST=y +CONFIG_BOUNCE=y +CONFIG_CACHE_L2X0=y +CONFIG_CLKDEV_LOOKUP=y +CONFIG_CLKSRC_MMIO=y +CONFIG_CLONE_BACKWARDS=y +CONFIG_CLZ_TAB=y +CONFIG_CMA=y +CONFIG_CMA_ALIGNMENT=8 +CONFIG_CMA_AREAS=7 +# CONFIG_CMA_DEBUG is not set +# CONFIG_CMA_DEBUGFS is not set +CONFIG_CMA_SIZE_MBYTES=16 +# CONFIG_CMA_SIZE_SEL_MAX is not set +CONFIG_CMA_SIZE_SEL_MBYTES=y +# CONFIG_CMA_SIZE_SEL_MIN is not set +# CONFIG_CMA_SIZE_SEL_PERCENTAGE is not set +CONFIG_COMMON_CLK=y +# CONFIG_CPUFREQ_DT is not set +CONFIG_CPU_32v6K=y +CONFIG_CPU_32v7=y +CONFIG_CPU_ABRT_EV7=y +# CONFIG_CPU_BPREDICT_DISABLE is not set +CONFIG_CPU_CACHE_V7=y +CONFIG_CPU_CACHE_VIPT=y +CONFIG_CPU_COPY_V6=y +CONFIG_CPU_CP15=y +CONFIG_CPU_CP15_MMU=y +CONFIG_CPU_FREQ=y +CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y +# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set +CONFIG_CPU_FREQ_GOV_ATTR_SET=y +CONFIG_CPU_FREQ_GOV_COMMON=y +CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y +CONFIG_CPU_FREQ_GOV_ONDEMAND=y +CONFIG_CPU_FREQ_GOV_PERFORMANCE=y +CONFIG_CPU_FREQ_GOV_POWERSAVE=y +CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y +CONFIG_CPU_FREQ_GOV_USERSPACE=y +# CONFIG_CPU_FREQ_STAT is not set +CONFIG_CPU_HAS_ASID=y +# CONFIG_CPU_HOTPLUG_STATE_CONTROL is not set +# CONFIG_CPU_ICACHE_DISABLE is not set +CONFIG_CPU_IDLE=y +CONFIG_CPU_IDLE_GOV_LADDER=y +CONFIG_CPU_PABRT_V7=y +CONFIG_CPU_PM=y +CONFIG_CPU_RMAP=y +CONFIG_CPU_SPECTRE=y +CONFIG_CPU_THUMB_CAPABLE=y +CONFIG_CPU_TLB_V7=y +CONFIG_CPU_V7=y +CONFIG_CRC16=y +# CONFIG_CRC32_SARWATE is not set +CONFIG_CRC32_SLICEBY8=y +CONFIG_CROSS_MEMORY_ATTACH=y +CONFIG_CRYPTO_ACOMP2=y +CONFIG_CRYPTO_AEAD=y +CONFIG_CRYPTO_AEAD2=y +CONFIG_CRYPTO_AES_ARM=y +CONFIG_CRYPTO_AKCIPHER=y +CONFIG_CRYPTO_AKCIPHER2=y +CONFIG_CRYPTO_CRC32=y +CONFIG_CRYPTO_CRC32C=y +CONFIG_CRYPTO_CRYPTD=y +CONFIG_CRYPTO_DEFLATE=y +CONFIG_CRYPTO_DRBG=y +CONFIG_CRYPTO_DRBG_HMAC=y +CONFIG_CRYPTO_DRBG_MENU=y +CONFIG_CRYPTO_ECHAINIV=y +CONFIG_CRYPTO_HASH=y +CONFIG_CRYPTO_HASH2=y +CONFIG_CRYPTO_HMAC=y +CONFIG_CRYPTO_JITTERENTROPY=y +CONFIG_CRYPTO_LZ4=y +CONFIG_CRYPTO_LZ4HC=y +CONFIG_CRYPTO_LZO=y +CONFIG_CRYPTO_MANAGER=y +CONFIG_CRYPTO_MANAGER2=y +CONFIG_CRYPTO_NULL=y +CONFIG_CRYPTO_NULL2=y +CONFIG_CRYPTO_RNG=y +CONFIG_CRYPTO_RNG2=y +CONFIG_CRYPTO_RNG_DEFAULT=y +CONFIG_CRYPTO_RSA=y +CONFIG_CRYPTO_SEQIV=y +CONFIG_CRYPTO_SHA1=y +CONFIG_CRYPTO_SHA1_ARM=y +CONFIG_CRYPTO_SHA256=y +CONFIG_CRYPTO_SHA256_ARM=y +CONFIG_CRYPTO_SHA512_ARM=y +CONFIG_CRYPTO_TWOFISH=y +CONFIG_CRYPTO_TWOFISH_COMMON=y +CONFIG_CRYPTO_WORKQUEUE=y +CONFIG_DCACHE_WORD_ACCESS=y +CONFIG_DEBUG_ALIGN_RODATA=y +CONFIG_DEBUG_LL_INCLUDE="mach/debug-macro.S" +# CONFIG_DEBUG_UART_8250 is not set +# CONFIG_DEBUG_USER is not set +# CONFIG_DEVPORT is not set +CONFIG_DMADEVICES=y +CONFIG_DMA_CMA=y +CONFIG_DMA_ENGINE=y +CONFIG_DMA_OF=y +CONFIG_DMA_SHARED_BUFFER=y +CONFIG_DNOTIFY=y +CONFIG_DRM=y +CONFIG_DRM_BRIDGE=y +CONFIG_DRM_FBDEV_EMULATION=y +CONFIG_DRM_FBDEV_OVERALLOC=100 +CONFIG_DRM_KMS_FB_HELPER=y +CONFIG_DRM_KMS_HELPER=y +CONFIG_DRM_MIPI_DSI=y +CONFIG_DRM_PANEL=y +CONFIG_DRM_PANEL_BRIDGE=y +CONFIG_DRM_TEGRA=y +# CONFIG_DRM_TEGRA_DEBUG is not set +# CONFIG_DRM_TEGRA_STAGING is not set +CONFIG_DTC=y +CONFIG_EDAC_ATOMIC_SCRUB=y +CONFIG_EDAC_SUPPORT=y +CONFIG_ENABLE_MUST_CHECK=y +CONFIG_EXT4_FS=y +CONFIG_EXTCON=y +# CONFIG_F2FS_CHECK_FS is not set +CONFIG_F2FS_FS=y +# CONFIG_F2FS_FS_SECURITY is not set +CONFIG_F2FS_FS_XATTR=y +CONFIG_F2FS_STAT_FS=y +CONFIG_FB=y +CONFIG_FB_CFB_COPYAREA=y +CONFIG_FB_CFB_FILLRECT=y +CONFIG_FB_CFB_IMAGEBLIT=y +CONFIG_FB_CMDLINE=y +CONFIG_FB_DEFERRED_IO=y +# CONFIG_FB_PROVIDE_GET_FB_UNMAPPED_AREA is not set +CONFIG_FB_SYS_COPYAREA=y +CONFIG_FB_SYS_FILLRECT=y +CONFIG_FB_SYS_FOPS=y +CONFIG_FB_SYS_IMAGEBLIT=y +CONFIG_FIX_EARLYCON_MEM=y +CONFIG_FRAME_POINTER=y +CONFIG_FREEZER=y +CONFIG_FS_MBCACHE=y +CONFIG_GENERIC_ALLOCATOR=y +CONFIG_GENERIC_ARCH_TOPOLOGY=y +CONFIG_GENERIC_BUG=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y +CONFIG_GENERIC_CPU_AUTOPROBE=y +CONFIG_GENERIC_EARLY_IOREMAP=y +CONFIG_GENERIC_IDLE_POLL_SETUP=y +CONFIG_GENERIC_IO=y +CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK=y +CONFIG_GENERIC_IRQ_MIGRATION=y +CONFIG_GENERIC_IRQ_SHOW=y +CONFIG_GENERIC_IRQ_SHOW_LEVEL=y +CONFIG_GENERIC_MSI_IRQ=y +CONFIG_GENERIC_MSI_IRQ_DOMAIN=y +CONFIG_GENERIC_PCI_IOMAP=y +CONFIG_GENERIC_PHY=y +CONFIG_GENERIC_PINCONF=y +CONFIG_GENERIC_PINCTRL_GROUPS=y +CONFIG_GENERIC_PINMUX_FUNCTIONS=y +CONFIG_GENERIC_SCHED_CLOCK=y +CONFIG_GENERIC_SMP_IDLE_THREAD=y +CONFIG_GENERIC_STRNCPY_FROM_USER=y +CONFIG_GENERIC_STRNLEN_USER=y +CONFIG_GENERIC_TIME_VSYSCALL=y +CONFIG_GLOB=y +CONFIG_GPIOLIB=y +CONFIG_GPIO_SYSFS=y +CONFIG_GPIO_TEGRA=y +# CONFIG_GRO_CELLS is not set +CONFIG_HANDLE_DOMAIN_IRQ=y +CONFIG_HARDEN_BRANCH_PREDICTOR=y +CONFIG_HARDIRQS_SW_RESEND=y +CONFIG_HAS_DMA=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT_MAP=y +# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set +CONFIG_HAVE_ARCH_AUDITSYSCALL=y +CONFIG_HAVE_ARCH_BITREVERSE=y +CONFIG_HAVE_ARCH_JUMP_LABEL=y +CONFIG_HAVE_ARCH_KGDB=y +CONFIG_HAVE_ARCH_PFN_VALID=y +CONFIG_HAVE_ARCH_SECCOMP_FILTER=y +CONFIG_HAVE_ARCH_TRACEHOOK=y +CONFIG_HAVE_ARM_ARCH_TIMER=y +CONFIG_HAVE_ARM_SCU=y +CONFIG_HAVE_ARM_SMCCC=y +CONFIG_HAVE_ARM_TWD=y +# CONFIG_HAVE_BOOTMEM_INFO_NODE is not set +CONFIG_HAVE_CC_STACKPROTECTOR=y +CONFIG_HAVE_CLK=y +CONFIG_HAVE_CLK_PREPARE=y +CONFIG_HAVE_CONTEXT_TRACKING=y +CONFIG_HAVE_C_RECORDMCOUNT=y +CONFIG_HAVE_DEBUG_KMEMLEAK=y +CONFIG_HAVE_DMA_API_DEBUG=y +CONFIG_HAVE_DMA_CONTIGUOUS=y +CONFIG_HAVE_DYNAMIC_FTRACE=y +CONFIG_HAVE_DYNAMIC_FTRACE_WITH_REGS=y +CONFIG_HAVE_EBPF_JIT=y +CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y +CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y +CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y +CONFIG_HAVE_FUNCTION_TRACER=y +CONFIG_HAVE_GENERIC_DMA_COHERENT=y +CONFIG_HAVE_IDE=y +CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y +CONFIG_HAVE_MEMBLOCK=y +CONFIG_HAVE_MOD_ARCH_SPECIFIC=y +CONFIG_HAVE_NET_DSA=y +CONFIG_HAVE_OPROFILE=y +CONFIG_HAVE_OPTPROBES=y +CONFIG_HAVE_PERF_EVENTS=y +CONFIG_HAVE_PERF_REGS=y +CONFIG_HAVE_PERF_USER_STACK_DUMP=y +CONFIG_HAVE_PROC_CPU=y +CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y +CONFIG_HAVE_SMP=y +CONFIG_HAVE_SYSCALL_TRACEPOINTS=y +CONFIG_HAVE_UID16=y +CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y +CONFIG_HDMI=y +CONFIG_HID=y +CONFIG_HIDRAW=y +CONFIG_HID_GENERIC=y +CONFIG_HIGHMEM=y +CONFIG_HIGHPTE=y +CONFIG_HOTPLUG_CPU=y +CONFIG_HWMON=y +CONFIG_HZ_FIXED=0 +CONFIG_HZ_PERIODIC=y +CONFIG_I2C=y +CONFIG_I2C_ALGOBIT=y +CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_COMPAT=y +CONFIG_I2C_TEGRA=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_INPUT=y +CONFIG_INPUT_KEYBOARD=y +CONFIG_IOMMU_API=y +CONFIG_IOMMU_HELPER=y +CONFIG_IOMMU_IOVA=y +# CONFIG_IOMMU_IO_PGTABLE_ARMV7S is not set +# CONFIG_IOMMU_IO_PGTABLE_LPAE is not set +CONFIG_IOMMU_SUPPORT=y +CONFIG_IRQCHIP=y +CONFIG_IRQ_DOMAIN=y +CONFIG_IRQ_DOMAIN_HIERARCHY=y +CONFIG_IRQ_FORCED_THREADING=y +CONFIG_IRQ_WORK=y +CONFIG_JBD2=y +CONFIG_KEYBOARD_ATKBD=y +CONFIG_LIBFDT=y +CONFIG_LOCK_SPIN_ON_OWNER=y +CONFIG_LZ4HC_COMPRESS=y +CONFIG_LZ4_COMPRESS=y +CONFIG_LZ4_DECOMPRESS=y +CONFIG_LZO_COMPRESS=y +CONFIG_LZO_DECOMPRESS=y +# CONFIG_MDIO_BUS is not set +CONFIG_MEMORY=y +CONFIG_MEMORY_ISOLATION=y +# CONFIG_MFD_NVEC is not set +CONFIG_MIGHT_HAVE_CACHE_L2X0=y +CONFIG_MIGHT_HAVE_PCI=y +CONFIG_MIGRATION=y +CONFIG_MMC=y +CONFIG_MMC_BLOCK=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_IO_ACCESSORS=y +# CONFIG_MMC_SDHCI_PCI is not set +CONFIG_MMC_SDHCI_PLTFM=y +CONFIG_MMC_SDHCI_TEGRA=y +# CONFIG_MMC_TIFM_SD is not set +CONFIG_MODULES_USE_ELF_REL=y +CONFIG_MPILIB=y +CONFIG_MTD_M25P80=y +CONFIG_MTD_SPI_NOR=y +CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y +CONFIG_MULTI_IRQ_HANDLER=y +CONFIG_MUTEX_SPIN_ON_OWNER=y +CONFIG_NEED_DMA_MAP_STATE=y +# CONFIG_NEON is not set +CONFIG_NET_FLOW_LIMIT=y +CONFIG_NLS=y +CONFIG_NO_BOOTMEM=y +CONFIG_NR_CPUS=4 +CONFIG_NVMEM=y +CONFIG_OF=y +CONFIG_OF_ADDRESS=y +CONFIG_OF_ADDRESS_PCI=y +CONFIG_OF_EARLY_FLATTREE=y +CONFIG_OF_FLATTREE=y +CONFIG_OF_GPIO=y +CONFIG_OF_IOMMU=y +CONFIG_OF_IRQ=y +CONFIG_OF_NET=y +CONFIG_OF_PCI=y +CONFIG_OF_PCI_IRQ=y +CONFIG_OF_RESERVED_MEM=y +CONFIG_OLD_SIGACTION=y +CONFIG_OLD_SIGSUSPEND3=y +CONFIG_OUTER_CACHE=y +CONFIG_OUTER_CACHE_SYNC=y +CONFIG_PADATA=y +CONFIG_PAGE_OFFSET=0xC0000000 +CONFIG_PCI=y +CONFIG_PCIEAER=y +CONFIG_PCIEASPM=y +# CONFIG_PCIEASPM_DEBUG is not set +CONFIG_PCIEASPM_DEFAULT=y +# CONFIG_PCIEASPM_PERFORMANCE is not set +# CONFIG_PCIEASPM_POWERSAVE is not set +# CONFIG_PCIEASPM_POWER_SUPERSAVE is not set +CONFIG_PCIEPORTBUS=y +CONFIG_PCIE_PME=y +CONFIG_PCI_DOMAINS=y +CONFIG_PCI_DOMAINS_GENERIC=y +CONFIG_PCI_MSI=y +CONFIG_PCI_MSI_IRQ_DOMAIN=y +CONFIG_PCI_TEGRA=y +CONFIG_PERF_USE_VMALLOC=y +CONFIG_PGTABLE_LEVELS=2 +CONFIG_PHY_TEGRA_XUSB=y +CONFIG_PINCTRL=y +CONFIG_PINCTRL_TEGRA=y +CONFIG_PINCTRL_TEGRA20=y +CONFIG_PINCTRL_TEGRA_XUSB=y +# CONFIG_PL310_ERRATA_588369 is not set +CONFIG_PL310_ERRATA_727915=y +# CONFIG_PL310_ERRATA_753970 is not set +CONFIG_PL310_ERRATA_769419=y +CONFIG_PM=y +CONFIG_PM_CLK=y +# CONFIG_PM_DEBUG is not set +CONFIG_PM_OPP=y +CONFIG_PM_SLEEP=y +CONFIG_PM_SLEEP_SMP=y +CONFIG_POWER_RESET=y +CONFIG_POWER_RESET_GPIO=y +CONFIG_POWER_SUPPLY=y +CONFIG_PROC_PAGE_MONITOR=y +CONFIG_PWM=y +CONFIG_PWM_SYSFS=y +CONFIG_PWM_TEGRA=y +CONFIG_RAS=y +CONFIG_RATIONAL=y +CONFIG_RCU_CPU_STALL_TIMEOUT=21 +# CONFIG_RCU_EXPERT is not set +CONFIG_RCU_NEED_SEGCBLIST=y +CONFIG_RCU_STALL_COMMON=y +CONFIG_REGMAP=y +CONFIG_REGMAP_I2C=y +CONFIG_REGMAP_MMIO=y +CONFIG_REGMAP_SPI=y +CONFIG_REGULATOR=y +CONFIG_REGULATOR_FIXED_VOLTAGE=y +CONFIG_REGULATOR_GPIO=y +CONFIG_RESET_CONTROLLER=y +CONFIG_RFS_ACCEL=y +CONFIG_RPS=y +CONFIG_RTC_CLASS=y +# CONFIG_RTC_DRV_CMOS is not set +CONFIG_RTC_DRV_TEGRA=y +CONFIG_RTC_I2C_AND_SPI=y +CONFIG_RTC_NVMEM=y +CONFIG_RWSEM_SPIN_ON_OWNER=y +CONFIG_RWSEM_XCHGADD_ALGORITHM=y +# CONFIG_SCHED_INFO is not set +CONFIG_SCSI=y +# CONFIG_SCSI_LOWLEVEL is not set +# CONFIG_SCSI_PROC_FS is not set +CONFIG_SERIAL_8250_FSL=y +# CONFIG_SERIAL_AMBA_PL011 is not set +CONFIG_SERIAL_OF_PLATFORM=y +CONFIG_SERIAL_TEGRA=y +CONFIG_SERIO=y +CONFIG_SERIO_LIBPS2=y +CONFIG_SG_POOL=y +CONFIG_SMP=y +CONFIG_SMP_ON_UP=y +CONFIG_SND=y +# CONFIG_SND_COMPRESS_OFFLOAD is not set +CONFIG_SND_DMAENGINE_PCM=y +# CONFIG_SND_DRIVERS is not set +# CONFIG_SND_HDA_TEGRA is not set +CONFIG_SND_JACK=y +CONFIG_SND_JACK_INPUT_DEV=y +# CONFIG_SND_PCI is not set +CONFIG_SND_PCM=y +# CONFIG_SND_PROC_FS is not set +CONFIG_SND_SIMPLE_CARD=y +CONFIG_SND_SIMPLE_CARD_UTILS=y +CONFIG_SND_SOC=y +CONFIG_SND_SOC_AC97_BUS=y +CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM=y +CONFIG_SND_SOC_I2C_AND_SPI=y +CONFIG_SND_SOC_TEGRA=y +CONFIG_SND_SOC_TEGRA20_AC97=y +CONFIG_SND_SOC_TEGRA20_DAS=y +CONFIG_SND_SOC_TEGRA20_I2S=y +CONFIG_SND_SOC_TEGRA20_SPDIF=y +# CONFIG_SND_SOC_TEGRA30_AHUB is not set +# CONFIG_SND_SOC_TEGRA30_I2S is not set +# CONFIG_SND_SOC_TEGRA_ALC5632 is not set +# CONFIG_SND_SOC_TEGRA_MAX98090 is not set +# CONFIG_SND_SOC_TEGRA_RT5640 is not set +# CONFIG_SND_SOC_TEGRA_RT5677 is not set +# CONFIG_SND_SOC_TEGRA_SGTL5000 is not set +CONFIG_SND_SOC_TEGRA_TRIMSLICE=y +# CONFIG_SND_SOC_TEGRA_WM8753 is not set +# CONFIG_SND_SOC_TEGRA_WM8903 is not set +# CONFIG_SND_SOC_TEGRA_WM9712 is not set +CONFIG_SND_SOC_TLV320AIC23=y +CONFIG_SND_SOC_TLV320AIC23_I2C=y +# CONFIG_SND_USB is not set +CONFIG_SOC_BUS=y +CONFIG_SOC_TEGRA_FLOWCTRL=y +CONFIG_SOC_TEGRA_FUSE=y +CONFIG_SOC_TEGRA_PMC=y +CONFIG_SOUND=y +CONFIG_SOUND_OSS_CORE=y +CONFIG_SOUND_OSS_CORE_PRECLAIM=y +CONFIG_SPARSE_IRQ=y +CONFIG_SPI=y +CONFIG_SPI_MASTER=y +# CONFIG_SPI_TEGRA114 is not set +CONFIG_SPI_TEGRA20_SFLASH=y +CONFIG_SPI_TEGRA20_SLINK=y +CONFIG_SRCU=y +CONFIG_SUSPEND=y +CONFIG_SUSPEND_FREEZER=y +CONFIG_SWIOTLB=y +CONFIG_SWP_EMULATE=y +CONFIG_SYNC_FILE=y +CONFIG_SYS_SUPPORTS_APM_EMULATION=y +CONFIG_TEGRA20_APB_DMA=y +CONFIG_TEGRA20_MC=y +CONFIG_TEGRA_AHB=y +CONFIG_TEGRA_GMI=y +CONFIG_TEGRA_HOST1X=y +CONFIG_TEGRA_HOST1X_FIREWALL=y +CONFIG_TEGRA_IOMMU_GART=y +# CONFIG_TEGRA_IOMMU_SMMU is not set +# CONFIG_TEGRA_IVC is not set +CONFIG_TEGRA_MC=y +CONFIG_TEGRA_TIMER=y +CONFIG_TEGRA_WATCHDOG=y +# CONFIG_THUMB2_KERNEL is not set +CONFIG_TICK_CPU_ACCOUNTING=y +CONFIG_TIMER_OF=y +CONFIG_TIMER_PROBE=y +CONFIG_TREE_RCU=y +CONFIG_TREE_SRCU=y +CONFIG_TRUSTED_FOUNDATIONS=y +CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h" +CONFIG_USB=y +CONFIG_USB_COMMON=y +CONFIG_USB_EHCI_HCD=y +# CONFIG_USB_EHCI_HCD_PLATFORM is not set +CONFIG_USB_EHCI_TEGRA=y +CONFIG_USB_HID=y +CONFIG_USB_HIDDEV=y +CONFIG_USB_PHY=y +CONFIG_USB_SUPPORT=y +CONFIG_USB_ULPI=y +CONFIG_USB_ULPI_VIEWPORT=y +# CONFIG_USERIO is not set +CONFIG_USE_OF=y +CONFIG_VDSO=y +CONFIG_VECTORS_BASE=0xffff0000 +# CONFIG_VFIO is not set +CONFIG_VFP=y +CONFIG_VFPv3=y +CONFIG_WATCHDOG_CORE=y +CONFIG_XPS=y +CONFIG_XZ_DEC_ARM=y +CONFIG_XZ_DEC_ARMTHUMB=y +CONFIG_XZ_DEC_BCJ=y +CONFIG_ZBOOT_ROM_BSS=0 +CONFIG_ZBOOT_ROM_TEXT=0 +CONFIG_ZLIB_DEFLATE=y +CONFIG_ZLIB_INFLATE=y diff --git a/target/linux/tegra/config-4.19 b/target/linux/tegra/config-4.19 new file mode 100644 index 000000000..ea2177a86 --- /dev/null +++ b/target/linux/tegra/config-4.19 @@ -0,0 +1,559 @@ +CONFIG_AC97_BUS=y +# CONFIG_AHCI_TEGRA is not set +CONFIG_ALIGNMENT_TRAP=y +CONFIG_ARCH_CLOCKSOURCE_DATA=y +CONFIG_ARCH_HAS_DEBUG_VIRTUAL=y +CONFIG_ARCH_HAS_ELF_RANDOMIZE=y +CONFIG_ARCH_HAS_FORTIFY_SOURCE=y +CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y +CONFIG_ARCH_HAS_KCOV=y +CONFIG_ARCH_HAS_MEMBARRIER_SYNC_CORE=y +CONFIG_ARCH_HAS_PHYS_TO_DMA=y +CONFIG_ARCH_HAS_RESET_CONTROLLER=y +CONFIG_ARCH_HAS_SET_MEMORY=y +CONFIG_ARCH_HAS_SG_CHAIN=y +CONFIG_ARCH_HAS_STRICT_KERNEL_RWX=y +CONFIG_ARCH_HAS_STRICT_MODULE_RWX=y +CONFIG_ARCH_HAS_TICK_BROADCAST=y +CONFIG_ARCH_HAVE_CUSTOM_GPIO_H=y +CONFIG_ARCH_HIBERNATION_POSSIBLE=y +CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y +CONFIG_ARCH_MULTIPLATFORM=y +CONFIG_ARCH_MULTI_V6_V7=y +CONFIG_ARCH_MULTI_V7=y +CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED=y +CONFIG_ARCH_NR_GPIO=1024 +CONFIG_ARCH_OPTIONAL_KERNEL_RWX=y +CONFIG_ARCH_OPTIONAL_KERNEL_RWX_DEFAULT=y +CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y +CONFIG_ARCH_SUPPORTS_FIRMWARE=y +CONFIG_ARCH_SUPPORTS_TRUSTED_FOUNDATIONS=y +CONFIG_ARCH_SUPPORTS_UPROBES=y +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_ARCH_TEGRA=y +# CONFIG_ARCH_TEGRA_114_SOC is not set +# CONFIG_ARCH_TEGRA_124_SOC is not set +CONFIG_ARCH_TEGRA_2x_SOC=y +# CONFIG_ARCH_TEGRA_3x_SOC is not set +CONFIG_ARCH_USE_BUILTIN_BSWAP=y +CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y +CONFIG_ARCH_WANT_GENERAL_HUGETLB=y +CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y +CONFIG_ARM=y +CONFIG_ARM_AMBA=y +CONFIG_ARM_ARCH_TIMER=y +CONFIG_ARM_ARCH_TIMER_EVTSTREAM=y +CONFIG_ARM_CPU_SUSPEND=y +CONFIG_ARM_CRYPTO=y +CONFIG_ARM_ERRATA_720789=y +CONFIG_ARM_ERRATA_754327=y +CONFIG_ARM_ERRATA_764369=y +CONFIG_ARM_GIC=y +CONFIG_ARM_HAS_SG_CHAIN=y +CONFIG_ARM_HEAVY_MB=y +CONFIG_ARM_L1_CACHE_SHIFT=6 +CONFIG_ARM_L1_CACHE_SHIFT_6=y +# CONFIG_ARM_LPAE is not set +CONFIG_ARM_PATCH_IDIV=y +CONFIG_ARM_PATCH_PHYS_VIRT=y +# CONFIG_ARM_PL172_MPMC is not set +# CONFIG_ARM_SMMU is not set +# CONFIG_ARM_SP805_WATCHDOG is not set +CONFIG_ARM_TEGRA20_CPUFREQ=y +CONFIG_ARM_THUMB=y +CONFIG_ARM_THUMBEE=y +CONFIG_ARM_VIRT_EXT=y +CONFIG_ASN1=y +CONFIG_ATA=y +CONFIG_ATAGS=y +CONFIG_AUTO_ZRELADDR=y +CONFIG_BLK_DEV_BSG=y +CONFIG_BLK_DEV_LOOP=y +CONFIG_BLK_MQ_PCI=y +CONFIG_BLK_SCSI_REQUEST=y +CONFIG_BOUNCE=y +CONFIG_CACHE_L2X0=y +CONFIG_CLKDEV_LOOKUP=y +CONFIG_CLKSRC_MMIO=y +CONFIG_CLONE_BACKWARDS=y +CONFIG_CLZ_TAB=y +CONFIG_CMA=y +CONFIG_CMA_ALIGNMENT=8 +CONFIG_CMA_AREAS=7 +# CONFIG_CMA_DEBUG is not set +# CONFIG_CMA_DEBUGFS is not set +CONFIG_CMA_SIZE_MBYTES=16 +# CONFIG_CMA_SIZE_SEL_MAX is not set +CONFIG_CMA_SIZE_SEL_MBYTES=y +# CONFIG_CMA_SIZE_SEL_MIN is not set +# CONFIG_CMA_SIZE_SEL_PERCENTAGE is not set +CONFIG_COMMON_CLK=y +# CONFIG_CPUFREQ_DT is not set +CONFIG_CPU_32v6K=y +CONFIG_CPU_32v7=y +CONFIG_CPU_ABRT_EV7=y +# CONFIG_CPU_BPREDICT_DISABLE is not set +CONFIG_CPU_CACHE_V7=y +CONFIG_CPU_CACHE_VIPT=y +CONFIG_CPU_COPY_V6=y +CONFIG_CPU_CP15=y +CONFIG_CPU_CP15_MMU=y +CONFIG_CPU_FREQ=y +CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y +# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set +CONFIG_CPU_FREQ_GOV_ATTR_SET=y +CONFIG_CPU_FREQ_GOV_COMMON=y +CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y +CONFIG_CPU_FREQ_GOV_ONDEMAND=y +CONFIG_CPU_FREQ_GOV_PERFORMANCE=y +CONFIG_CPU_FREQ_GOV_POWERSAVE=y +CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y +CONFIG_CPU_FREQ_GOV_USERSPACE=y +# CONFIG_CPU_FREQ_STAT is not set +CONFIG_CPU_HAS_ASID=y +# CONFIG_CPU_HOTPLUG_STATE_CONTROL is not set +# CONFIG_CPU_ICACHE_DISABLE is not set +CONFIG_CPU_IDLE=y +CONFIG_CPU_IDLE_GOV_LADDER=y +CONFIG_CPU_PABRT_V7=y +CONFIG_CPU_PM=y +CONFIG_CPU_RMAP=y +CONFIG_CPU_SPECTRE=y +CONFIG_CPU_THUMB_CAPABLE=y +CONFIG_CPU_TLB_V7=y +CONFIG_CPU_V7=y +CONFIG_CRC16=y +# CONFIG_CRC32_SARWATE is not set +CONFIG_CRC32_SLICEBY8=y +CONFIG_CROSS_MEMORY_ATTACH=y +CONFIG_CRYPTO_ACOMP2=y +CONFIG_CRYPTO_AEAD=y +CONFIG_CRYPTO_AEAD2=y +CONFIG_CRYPTO_AES_ARM=y +CONFIG_CRYPTO_AKCIPHER=y +CONFIG_CRYPTO_AKCIPHER2=y +CONFIG_CRYPTO_CRC32=y +CONFIG_CRYPTO_CRC32C=y +CONFIG_CRYPTO_CRYPTD=y +CONFIG_CRYPTO_DEFLATE=y +CONFIG_CRYPTO_DRBG=y +CONFIG_CRYPTO_DRBG_HMAC=y +CONFIG_CRYPTO_DRBG_MENU=y +CONFIG_CRYPTO_ECHAINIV=y +CONFIG_CRYPTO_HASH=y +CONFIG_CRYPTO_HASH2=y +CONFIG_CRYPTO_HMAC=y +CONFIG_CRYPTO_JITTERENTROPY=y +CONFIG_CRYPTO_LZ4=y +CONFIG_CRYPTO_LZ4HC=y +CONFIG_CRYPTO_LZO=y +CONFIG_CRYPTO_MANAGER=y +CONFIG_CRYPTO_MANAGER2=y +CONFIG_CRYPTO_NULL=y +CONFIG_CRYPTO_NULL2=y +CONFIG_CRYPTO_RNG=y +CONFIG_CRYPTO_RNG2=y +CONFIG_CRYPTO_RNG_DEFAULT=y +CONFIG_CRYPTO_RSA=y +CONFIG_CRYPTO_SEQIV=y +CONFIG_CRYPTO_SHA1=y +CONFIG_CRYPTO_SHA1_ARM=y +CONFIG_CRYPTO_SHA256=y +CONFIG_CRYPTO_SHA256_ARM=y +CONFIG_CRYPTO_SHA512_ARM=y +CONFIG_CRYPTO_TWOFISH=y +CONFIG_CRYPTO_TWOFISH_COMMON=y +CONFIG_CRYPTO_WORKQUEUE=y +CONFIG_DCACHE_WORD_ACCESS=y +CONFIG_DEBUG_ALIGN_RODATA=y +CONFIG_DEBUG_LL_INCLUDE="mach/debug-macro.S" +# CONFIG_DEBUG_USER is not set +# CONFIG_DEVPORT is not set +CONFIG_DMADEVICES=y +CONFIG_DMA_CMA=y +CONFIG_DMA_ENGINE=y +CONFIG_DMA_OF=y +CONFIG_DMA_SHARED_BUFFER=y +CONFIG_DNOTIFY=y +CONFIG_DRM=y +CONFIG_DRM_BRIDGE=y +CONFIG_DRM_FBDEV_EMULATION=y +CONFIG_DRM_FBDEV_OVERALLOC=100 +CONFIG_DRM_KMS_FB_HELPER=y +CONFIG_DRM_KMS_HELPER=y +CONFIG_DRM_MIPI_DSI=y +CONFIG_DRM_PANEL=y +CONFIG_DRM_PANEL_BRIDGE=y +CONFIG_DRM_PANEL_ORIENTATION_QUIRKS=y +CONFIG_DRM_TEGRA=y +# CONFIG_DRM_TEGRA_DEBUG is not set +# CONFIG_DRM_TEGRA_STAGING is not set +# CONFIG_DRM_TVE200 is not set +CONFIG_DTC=y +CONFIG_EDAC_ATOMIC_SCRUB=y +CONFIG_EDAC_SUPPORT=y +CONFIG_ENABLE_MUST_CHECK=y +CONFIG_EXT4_FS=y +CONFIG_EXTCON=y +# CONFIG_F2FS_CHECK_FS is not set +CONFIG_F2FS_FS=y +# CONFIG_F2FS_FS_SECURITY is not set +CONFIG_F2FS_FS_XATTR=y +CONFIG_F2FS_STAT_FS=y +CONFIG_FB=y +CONFIG_FB_CFB_COPYAREA=y +CONFIG_FB_CFB_FILLRECT=y +CONFIG_FB_CFB_IMAGEBLIT=y +CONFIG_FB_CMDLINE=y +CONFIG_FB_DEFERRED_IO=y +CONFIG_FB_SYS_COPYAREA=y +CONFIG_FB_SYS_FILLRECT=y +CONFIG_FB_SYS_FOPS=y +CONFIG_FB_SYS_IMAGEBLIT=y +CONFIG_FIX_EARLYCON_MEM=y +CONFIG_FRAME_POINTER=y +CONFIG_FREEZER=y +CONFIG_FS_IOMAP=y +CONFIG_FS_MBCACHE=y +CONFIG_GENERIC_ALLOCATOR=y +CONFIG_GENERIC_ARCH_TOPOLOGY=y +CONFIG_GENERIC_BUG=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y +CONFIG_GENERIC_CPU_AUTOPROBE=y +CONFIG_GENERIC_EARLY_IOREMAP=y +CONFIG_GENERIC_IDLE_POLL_SETUP=y +CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK=y +CONFIG_GENERIC_IRQ_MIGRATION=y +CONFIG_GENERIC_IRQ_MULTI_HANDLER=y +CONFIG_GENERIC_IRQ_SHOW=y +CONFIG_GENERIC_IRQ_SHOW_LEVEL=y +CONFIG_GENERIC_MSI_IRQ=y +CONFIG_GENERIC_MSI_IRQ_DOMAIN=y +CONFIG_GENERIC_PCI_IOMAP=y +CONFIG_GENERIC_PHY=y +CONFIG_GENERIC_PINCONF=y +CONFIG_GENERIC_PINCTRL_GROUPS=y +CONFIG_GENERIC_PINMUX_FUNCTIONS=y +CONFIG_GENERIC_SCHED_CLOCK=y +CONFIG_GENERIC_SMP_IDLE_THREAD=y +CONFIG_GENERIC_STRNCPY_FROM_USER=y +CONFIG_GENERIC_STRNLEN_USER=y +CONFIG_GENERIC_TIME_VSYSCALL=y +CONFIG_GLOB=y +CONFIG_GPIOLIB=y +CONFIG_GPIO_SYSFS=y +CONFIG_GPIO_TEGRA=y +CONFIG_HANDLE_DOMAIN_IRQ=y +CONFIG_HARDEN_BRANCH_PREDICTOR=y +CONFIG_HARDIRQS_SW_RESEND=y +CONFIG_HAS_DMA=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT_MAP=y +CONFIG_HAVE_ARCH_AUDITSYSCALL=y +CONFIG_HAVE_ARCH_BITREVERSE=y +CONFIG_HAVE_ARCH_JUMP_LABEL=y +CONFIG_HAVE_ARCH_KGDB=y +CONFIG_HAVE_ARCH_PFN_VALID=y +CONFIG_HAVE_ARCH_SECCOMP_FILTER=y +CONFIG_HAVE_ARCH_THREAD_STRUCT_WHITELIST=y +CONFIG_HAVE_ARCH_TRACEHOOK=y +CONFIG_HAVE_ARM_ARCH_TIMER=y +CONFIG_HAVE_ARM_SCU=y +CONFIG_HAVE_ARM_SMCCC=y +CONFIG_HAVE_ARM_TWD=y +CONFIG_HAVE_CLK=y +CONFIG_HAVE_CLK_PREPARE=y +CONFIG_HAVE_CONTEXT_TRACKING=y +CONFIG_HAVE_C_RECORDMCOUNT=y +CONFIG_HAVE_DEBUG_KMEMLEAK=y +CONFIG_HAVE_DMA_CONTIGUOUS=y +CONFIG_HAVE_DYNAMIC_FTRACE=y +CONFIG_HAVE_DYNAMIC_FTRACE_WITH_REGS=y +CONFIG_HAVE_EBPF_JIT=y +CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y +CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y +CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y +CONFIG_HAVE_FUNCTION_TRACER=y +CONFIG_HAVE_GENERIC_DMA_COHERENT=y +CONFIG_HAVE_IDE=y +CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y +CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION=y +CONFIG_HAVE_MEMBLOCK=y +CONFIG_HAVE_MOD_ARCH_SPECIFIC=y +CONFIG_HAVE_NET_DSA=y +CONFIG_HAVE_OPROFILE=y +CONFIG_HAVE_OPTPROBES=y +CONFIG_HAVE_PERF_EVENTS=y +CONFIG_HAVE_PERF_REGS=y +CONFIG_HAVE_PERF_USER_STACK_DUMP=y +CONFIG_HAVE_PROC_CPU=y +CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y +CONFIG_HAVE_RSEQ=y +CONFIG_HAVE_SMP=y +CONFIG_HAVE_SYSCALL_TRACEPOINTS=y +CONFIG_HAVE_UID16=y +CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y +CONFIG_HDMI=y +CONFIG_HID=y +CONFIG_HIDRAW=y +CONFIG_HID_GENERIC=y +CONFIG_HIGHMEM=y +CONFIG_HIGHPTE=y +CONFIG_HOTPLUG_CPU=y +CONFIG_HWMON=y +CONFIG_HZ_FIXED=0 +CONFIG_HZ_PERIODIC=y +CONFIG_I2C=y +CONFIG_I2C_ALGOBIT=y +CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_COMPAT=y +CONFIG_I2C_TEGRA=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_INPUT=y +CONFIG_INPUT_KEYBOARD=y +CONFIG_IOMMU_API=y +# CONFIG_IOMMU_DEBUGFS is not set +# CONFIG_IOMMU_DEFAULT_PASSTHROUGH is not set +CONFIG_IOMMU_IOVA=y +# CONFIG_IOMMU_IO_PGTABLE_ARMV7S is not set +# CONFIG_IOMMU_IO_PGTABLE_LPAE is not set +CONFIG_IOMMU_SUPPORT=y +CONFIG_IRQCHIP=y +CONFIG_IRQ_DOMAIN=y +CONFIG_IRQ_DOMAIN_HIERARCHY=y +CONFIG_IRQ_FORCED_THREADING=y +CONFIG_IRQ_WORK=y +CONFIG_JBD2=y +CONFIG_KEYBOARD_ATKBD=y +CONFIG_LIBFDT=y +CONFIG_LOCK_DEBUGGING_SUPPORT=y +CONFIG_LOCK_SPIN_ON_OWNER=y +CONFIG_LZ4HC_COMPRESS=y +CONFIG_LZ4_COMPRESS=y +CONFIG_LZ4_DECOMPRESS=y +CONFIG_LZO_COMPRESS=y +CONFIG_LZO_DECOMPRESS=y +CONFIG_MEMFD_CREATE=y +CONFIG_MEMORY=y +CONFIG_MEMORY_ISOLATION=y +# CONFIG_MFD_NVEC is not set +CONFIG_MIGHT_HAVE_CACHE_L2X0=y +CONFIG_MIGHT_HAVE_PCI=y +CONFIG_MIGRATION=y +CONFIG_MMC=y +CONFIG_MMC_BLOCK=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_IO_ACCESSORS=y +# CONFIG_MMC_SDHCI_PCI is not set +CONFIG_MMC_SDHCI_PLTFM=y +CONFIG_MMC_SDHCI_TEGRA=y +# CONFIG_MMC_TIFM_SD is not set +CONFIG_MODULES_USE_ELF_REL=y +CONFIG_MPILIB=y +CONFIG_MTD_M25P80=y +CONFIG_MTD_SPI_NOR=y +CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y +CONFIG_MUTEX_SPIN_ON_OWNER=y +CONFIG_NEED_DMA_MAP_STATE=y +# CONFIG_NEON is not set +CONFIG_NET_FLOW_LIMIT=y +CONFIG_NLS=y +CONFIG_NO_BOOTMEM=y +CONFIG_NR_CPUS=4 +CONFIG_NVMEM=y +CONFIG_OF=y +CONFIG_OF_ADDRESS=y +CONFIG_OF_EARLY_FLATTREE=y +CONFIG_OF_FLATTREE=y +CONFIG_OF_GPIO=y +CONFIG_OF_IOMMU=y +CONFIG_OF_IRQ=y +CONFIG_OF_KOBJ=y +CONFIG_OF_NET=y +CONFIG_OF_RESERVED_MEM=y +CONFIG_OLD_SIGACTION=y +CONFIG_OLD_SIGSUSPEND3=y +CONFIG_OUTER_CACHE=y +CONFIG_OUTER_CACHE_SYNC=y +CONFIG_PADATA=y +CONFIG_PAGE_OFFSET=0xC0000000 +CONFIG_PCI=y +CONFIG_PCIEAER=y +CONFIG_PCIEASPM=y +# CONFIG_PCIEASPM_DEBUG is not set +CONFIG_PCIEASPM_DEFAULT=y +# CONFIG_PCIEASPM_PERFORMANCE is not set +# CONFIG_PCIEASPM_POWERSAVE is not set +# CONFIG_PCIEASPM_POWER_SUPERSAVE is not set +CONFIG_PCIEPORTBUS=y +CONFIG_PCIE_PME=y +CONFIG_PCI_DOMAINS=y +CONFIG_PCI_DOMAINS_GENERIC=y +CONFIG_PCI_MSI=y +CONFIG_PCI_MSI_IRQ_DOMAIN=y +CONFIG_PCI_TEGRA=y +# CONFIG_PCI_V3_SEMI is not set +CONFIG_PERF_USE_VMALLOC=y +CONFIG_PGTABLE_LEVELS=2 +CONFIG_PHY_TEGRA_XUSB=y +CONFIG_PINCTRL=y +CONFIG_PINCTRL_TEGRA=y +CONFIG_PINCTRL_TEGRA20=y +CONFIG_PINCTRL_TEGRA_XUSB=y +# CONFIG_PL310_ERRATA_588369 is not set +CONFIG_PL310_ERRATA_727915=y +# CONFIG_PL310_ERRATA_753970 is not set +CONFIG_PL310_ERRATA_769419=y +CONFIG_PM=y +CONFIG_PM_CLK=y +# CONFIG_PM_DEBUG is not set +CONFIG_PM_OPP=y +CONFIG_PM_SLEEP=y +CONFIG_PM_SLEEP_SMP=y +CONFIG_POWER_RESET=y +CONFIG_POWER_RESET_GPIO=y +CONFIG_POWER_SUPPLY=y +CONFIG_PROC_PAGE_MONITOR=y +CONFIG_PWM=y +CONFIG_PWM_SYSFS=y +CONFIG_PWM_TEGRA=y +CONFIG_RAS=y +CONFIG_RATIONAL=y +CONFIG_RCU_CPU_STALL_TIMEOUT=21 +# CONFIG_RCU_EXPERT is not set +CONFIG_RCU_NEED_SEGCBLIST=y +CONFIG_RCU_STALL_COMMON=y +CONFIG_REFCOUNT_FULL=y +CONFIG_REGMAP=y +CONFIG_REGMAP_I2C=y +CONFIG_REGMAP_MMIO=y +CONFIG_REGMAP_SPI=y +CONFIG_REGULATOR=y +CONFIG_REGULATOR_FIXED_VOLTAGE=y +CONFIG_REGULATOR_GPIO=y +CONFIG_RESET_CONTROLLER=y +CONFIG_RFS_ACCEL=y +CONFIG_RPS=y +CONFIG_RTC_CLASS=y +# CONFIG_RTC_DRV_CMOS is not set +CONFIG_RTC_DRV_TEGRA=y +CONFIG_RTC_I2C_AND_SPI=y +CONFIG_RTC_NVMEM=y +CONFIG_RWSEM_SPIN_ON_OWNER=y +CONFIG_RWSEM_XCHGADD_ALGORITHM=y +CONFIG_SCSI=y +# CONFIG_SCSI_LOWLEVEL is not set +# CONFIG_SCSI_PROC_FS is not set +CONFIG_SERIAL_8250_FSL=y +# CONFIG_SERIAL_AMBA_PL011 is not set +CONFIG_SERIAL_OF_PLATFORM=y +CONFIG_SERIAL_TEGRA=y +CONFIG_SERIO=y +CONFIG_SERIO_LIBPS2=y +CONFIG_SGL_ALLOC=y +CONFIG_SG_POOL=y +CONFIG_SMP=y +CONFIG_SMP_ON_UP=y +CONFIG_SND=y +# CONFIG_SND_COMPRESS_OFFLOAD is not set +CONFIG_SND_DMAENGINE_PCM=y +# CONFIG_SND_DRIVERS is not set +# CONFIG_SND_HDA_TEGRA is not set +CONFIG_SND_JACK=y +CONFIG_SND_JACK_INPUT_DEV=y +# CONFIG_SND_PCI is not set +CONFIG_SND_PCM=y +# CONFIG_SND_PROC_FS is not set +CONFIG_SND_SIMPLE_CARD=y +CONFIG_SND_SIMPLE_CARD_UTILS=y +CONFIG_SND_SOC=y +CONFIG_SND_SOC_AC97_BUS=y +CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM=y +CONFIG_SND_SOC_I2C_AND_SPI=y +CONFIG_SND_SOC_TEGRA=y +CONFIG_SND_SOC_TEGRA20_AC97=y +CONFIG_SND_SOC_TEGRA20_DAS=y +CONFIG_SND_SOC_TEGRA20_I2S=y +CONFIG_SND_SOC_TEGRA20_SPDIF=y +# CONFIG_SND_SOC_TEGRA30_AHUB is not set +# CONFIG_SND_SOC_TEGRA30_I2S is not set +# CONFIG_SND_SOC_TEGRA_ALC5632 is not set +# CONFIG_SND_SOC_TEGRA_MAX98090 is not set +# CONFIG_SND_SOC_TEGRA_RT5640 is not set +# CONFIG_SND_SOC_TEGRA_RT5677 is not set +# CONFIG_SND_SOC_TEGRA_SGTL5000 is not set +CONFIG_SND_SOC_TEGRA_TRIMSLICE=y +# CONFIG_SND_SOC_TEGRA_WM8753 is not set +# CONFIG_SND_SOC_TEGRA_WM8903 is not set +# CONFIG_SND_SOC_TEGRA_WM9712 is not set +CONFIG_SND_SOC_TLV320AIC23=y +CONFIG_SND_SOC_TLV320AIC23_I2C=y +# CONFIG_SND_USB is not set +CONFIG_SOC_BUS=y +CONFIG_SOC_TEGRA_FLOWCTRL=y +CONFIG_SOC_TEGRA_FUSE=y +CONFIG_SOC_TEGRA_PMC=y +CONFIG_SOUND=y +CONFIG_SOUND_OSS_CORE=y +CONFIG_SOUND_OSS_CORE_PRECLAIM=y +CONFIG_SPARSE_IRQ=y +CONFIG_SPI=y +CONFIG_SPI_MASTER=y +CONFIG_SPI_MEM=y +# CONFIG_SPI_TEGRA114 is not set +CONFIG_SPI_TEGRA20_SFLASH=y +CONFIG_SPI_TEGRA20_SLINK=y +CONFIG_SRCU=y +CONFIG_SUSPEND=y +CONFIG_SUSPEND_FREEZER=y +CONFIG_SWP_EMULATE=y +CONFIG_SYNC_FILE=y +CONFIG_SYS_SUPPORTS_APM_EMULATION=y +CONFIG_TEGRA20_APB_DMA=y +CONFIG_TEGRA_AHB=y +CONFIG_TEGRA_GMI=y +CONFIG_TEGRA_HOST1X=y +CONFIG_TEGRA_HOST1X_FIREWALL=y +CONFIG_TEGRA_IOMMU_GART=y +# CONFIG_TEGRA_IOMMU_SMMU is not set +# CONFIG_TEGRA_IVC is not set +CONFIG_TEGRA_MC=y +CONFIG_TEGRA_TIMER=y +CONFIG_TEGRA_WATCHDOG=y +# CONFIG_THUMB2_KERNEL is not set +CONFIG_TICK_CPU_ACCOUNTING=y +CONFIG_TIMER_OF=y +CONFIG_TIMER_PROBE=y +CONFIG_TREE_RCU=y +CONFIG_TREE_SRCU=y +CONFIG_TRUSTED_FOUNDATIONS=y +CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h" +CONFIG_USB=y +CONFIG_USB_COMMON=y +CONFIG_USB_EHCI_HCD=y +# CONFIG_USB_XHCI_TEGRA is not set +# CONFIG_USB_EHCI_HCD_PLATFORM is not set +CONFIG_USB_EHCI_TEGRA=y +CONFIG_USB_HID=y +CONFIG_USB_HIDDEV=y +CONFIG_USB_PHY=y +CONFIG_USB_SUPPORT=y +CONFIG_USB_TEGRA_PHY=y +CONFIG_USB_ULPI=y +CONFIG_USB_ULPI_VIEWPORT=y +# CONFIG_USERIO is not set +CONFIG_USE_OF=y +CONFIG_VDSO=y +# CONFIG_VFIO is not set +CONFIG_VFP=y +CONFIG_VFPv3=y +CONFIG_WATCHDOG_CORE=y +CONFIG_XPS=y +CONFIG_XZ_DEC_ARM=y +CONFIG_XZ_DEC_ARMTHUMB=y +CONFIG_XZ_DEC_BCJ=y +CONFIG_ZBOOT_ROM_BSS=0 +CONFIG_ZBOOT_ROM_TEXT=0 +CONFIG_ZLIB_DEFLATE=y +CONFIG_ZLIB_INFLATE=y diff --git a/target/linux/tegra/image/Makefile b/target/linux/tegra/image/Makefile new file mode 100644 index 000000000..10bada9c3 --- /dev/null +++ b/target/linux/tegra/image/Makefile @@ -0,0 +1,57 @@ +# +# Copyright (C) 2017-2019 Tomasz Maciej Nowak +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/image.mk + +define Build/tegra-sdcard + rm -fR $@.boot + mkdir -p $@.boot + $(CP) $(KDIR)/$(KERNEL_NAME) $@.boot + $(if $(DEVICE_DTS),\ + $(foreach dtb,$(DEVICE_DTS),$(CP) $(DTS_DIR)/$(dtb).dtb $@.boot), \ + $(CP) $(DTS_DIR)/*.dtb $@.boot) + sed \ + -e 's#@ROOT@#$(IMG_PART_SIGNATURE)#g' \ + -e 's#@KERNEL@#$(KERNEL_NAME)#g' \ + $(BOOT_SCRIPT) > $@-boot.scr + mkimage -A arm -O linux -T script -C none -a 0 -e 0 \ + -n '$(DEVICE_TITLE) OpenWrt bootscript' \ + -d $@-boot.scr \ + $@.boot/boot.scr + + SIGNATURE="$(IMG_PART_SIGNATURE)" \ + $(SCRIPT_DIR)/gen_image_generic.sh \ + $@ \ + $(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \ + $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) \ + 2048 + + $(if $(UBOOT),dd if=$(STAGING_DIR_IMAGE)/$(UBOOT).img of=$@ bs=512 skip=1 seek=1 conv=notrunc) +endef + +DEVICE_VARS += BOOT_SCRIPT UBOOT +define Device/Default + BOOT_SCRIPT := generic-bootscript + IMAGES := sdcard.img.gz + IMAGE/sdcard.img.gz := tegra-sdcard | gzip | append-metadata + KERNEL_NAME := zImage + KERNEL := kernel-bin + PROFILES := Default + SUPPORTED_DEVICES := $(subst _,$(comma),$(1)) +endef + +define Device/compulab_trimslice + DEVICE_VENDOR := CompuLab + DEVICE_MODEL := TrimSlice + DEVICE_DTS := tegra20-trimslice + DEVICE_PACKAGES := kmod-r8169 kmod-rt2800-usb kmod-rtc-em3027 \ + kmod-usb-storage wpad-mini + UBOOT := trimslice-mmc +endef +TARGET_DEVICES += compulab_trimslice + +$(eval $(call BuildImage)) diff --git a/target/linux/tegra/image/generic-bootscript b/target/linux/tegra/image/generic-bootscript new file mode 100644 index 000000000..7e86afdf5 --- /dev/null +++ b/target/linux/tegra/image/generic-bootscript @@ -0,0 +1,6 @@ +setenv bootargs "root=PARTUUID=@ROOT@-02 rw rootwait console=ttyS0,115200 console=tty0" + +load ${devtype} ${devnum}:${bootpart} ${kernel_addr_r} /@KERNEL@ +load ${devtype} ${devnum}:${bootpart} ${fdt_addr_r} /${soc}-${board}.dtb + +bootz ${kernel_addr_r} - ${fdt_addr_r} diff --git a/target/linux/tegra/patches-4.14/100-serial8250-on-tegra-hsuart-recover-from-spurious-interrupts-due-to-tegra2-silicon-bug.patch b/target/linux/tegra/patches-4.14/100-serial8250-on-tegra-hsuart-recover-from-spurious-interrupts-due-to-tegra2-silicon-bug.patch new file mode 100644 index 000000000..cfbc5d9c4 --- /dev/null +++ b/target/linux/tegra/patches-4.14/100-serial8250-on-tegra-hsuart-recover-from-spurious-interrupts-due-to-tegra2-silicon-bug.patch @@ -0,0 +1,77 @@ +From patchwork Fri Jul 13 11:32:42 2018 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Subject: serial8250 on tegra hsuart: recover from spurious interrupts due to + tegra2 silicon bug +X-Patchwork-Submitter: "David R. Piegdon" +X-Patchwork-Id: 943440 +Message-Id: <4676ea34-69ce-5422-1ded-94218b89f7d9@p23q.org> +To: linux-tegra@vger.kernel.org +Date: Fri, 13 Jul 2018 11:32:42 +0000 +From: "David R. Piegdon" +List-Id: + +Hi, +a while back I sent a few mails regarding spurious interrupts in the +UARTA (hsuart) block of the Tegra2 SoC, when using the 8250 driver for +it instead of the hsuart driver. After going down a pretty deep +debugging/testing hole, I think I found a patch that fixes the issue. So +far testing in a reboot-cycle suggests that the error frequency dropped +from >3% of all reboots to at least <0.05% of all reboots. Tests +continue to run over the weekend. + +The patch below already is a second iteration; the first did not reset +the MCR or contain the lines below '// clear interrupts'. This resulted +in no more spurious interrupts, but in a few % of spurious interrupts +that were recovered the UART block did not receive any characters any +more. So further resetting was required to fully reacquire operational +state of the UART block. + +I'd love any comments/suggestions on this! + +Cheers, + +David + +--- a/drivers/tty/serial/8250/8250_core.c ++++ b/drivers/tty/serial/8250/8250_core.c +@@ -140,6 +140,38 @@ static irqreturn_t serial8250_interrupt( + "serial8250: too much work for irq%d\n", irq); + break; + } ++ ++#ifdef CONFIG_ARCH_TEGRA_2x_SOC ++ if (!handled && (port->type == PORT_TEGRA)) { ++ /* ++ * Fix Tegra 2 CPU silicon bug where sometimes ++ * "TX holding register empty" interrupts result in a ++ * bad (metastable?) state in Tegras HSUART IP core. ++ * Only way to recover seems to be to reset all ++ * interrupts as well as the TX queue and the MCR. ++ * But we don't want to loose any outgoing characters, ++ * so only do it if the RX and TX queues are empty. ++ */ ++ unsigned char lsr = port->serial_in(port, UART_LSR); ++ const unsigned char fifo_empty_mask = ++ (UART_LSR_TEMT | UART_LSR_THRE); ++ if (((lsr & (UART_LSR_DR | fifo_empty_mask)) == ++ fifo_empty_mask)) { ++ port->serial_out(port, UART_IER, 0); ++ port->serial_out(port, UART_MCR, 0); ++ serial8250_clear_and_reinit_fifos(up); ++ port->serial_out(port, UART_MCR, up->mcr); ++ port->serial_out(port, UART_IER, up->ier); ++ // clear interrupts ++ serial_port_in(port, UART_LSR); ++ serial_port_in(port, UART_RX); ++ serial_port_in(port, UART_IIR); ++ serial_port_in(port, UART_MSR); ++ up->lsr_saved_flags = 0; ++ up->msr_saved_flags = 0; ++ } ++ } ++#endif + } while (l != end); + + spin_unlock(&i->lock); diff --git a/target/linux/tegra/patches-4.14/101-ARM-dtc-tegra-enable-front-panel-leds-in-TrimSlice.patch b/target/linux/tegra/patches-4.14/101-ARM-dtc-tegra-enable-front-panel-leds-in-TrimSlice.patch new file mode 100644 index 000000000..ae48e8d86 --- /dev/null +++ b/target/linux/tegra/patches-4.14/101-ARM-dtc-tegra-enable-front-panel-leds-in-TrimSlice.patch @@ -0,0 +1,46 @@ +--- a/arch/arm/boot/dts/tegra20-trimslice.dts ++++ b/arch/arm/boot/dts/tegra20-trimslice.dts +@@ -200,16 +200,17 @@ + conf_ata { + nvidia,pins = "ata", "atc", "atd", "ate", + "crtp", "dap2", "dap3", "dap4", "dta", +- "dtb", "dtc", "dtd", "dte", "gmb", +- "gme", "i2cp", "pta", "slxc", "slxd", +- "spdi", "spdo", "uda"; ++ "dtb", "dtc", "dtd", "gmb", "gme", ++ "i2cp", "pta", "slxc", "slxd", "spdi", ++ "spdo", "uda"; + nvidia,pull = ; + nvidia,tristate = ; + }; + conf_atb { + nvidia,pins = "atb", "cdev1", "cdev2", "dap1", +- "gma", "gmc", "gmd", "gpu", "gpu7", +- "gpv", "sdio1", "slxa", "slxk", "uac"; ++ "dte", "gma", "gmc", "gmd", "gpu", ++ "gpu7", "gpv", "sdio1", "slxa", "slxk", ++ "uac"; + nvidia,pull = ; + nvidia,tristate = ; + }; +@@ -402,6 +403,20 @@ + }; + }; + ++ gpio-leds { ++ compatible = "gpio-leds"; ++ ++ ds2 { ++ label = "trimslice:green:right"; ++ gpios = <&gpio TEGRA_GPIO(D, 2) GPIO_ACTIVE_LOW>; ++ }; ++ ++ ds3 { ++ label = "trimslice:green:left"; ++ gpios = <&gpio TEGRA_GPIO(BB, 5) GPIO_ACTIVE_LOW>; ++ }; ++ }; ++ + poweroff { + compatible = "gpio-poweroff"; + gpios = <&gpio TEGRA_GPIO(X, 7) GPIO_ACTIVE_LOW>; diff --git a/target/linux/tegra/patches-4.19/100-serial8250-on-tegra-hsuart-recover-from-spurious-interrupts-due-to-tegra2-silicon-bug.patch b/target/linux/tegra/patches-4.19/100-serial8250-on-tegra-hsuart-recover-from-spurious-interrupts-due-to-tegra2-silicon-bug.patch new file mode 100644 index 000000000..9e8c33193 --- /dev/null +++ b/target/linux/tegra/patches-4.19/100-serial8250-on-tegra-hsuart-recover-from-spurious-interrupts-due-to-tegra2-silicon-bug.patch @@ -0,0 +1,77 @@ +From patchwork Fri Jul 13 11:32:42 2018 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Subject: serial8250 on tegra hsuart: recover from spurious interrupts due to + tegra2 silicon bug +X-Patchwork-Submitter: "David R. Piegdon" +X-Patchwork-Id: 943440 +Message-Id: <4676ea34-69ce-5422-1ded-94218b89f7d9@p23q.org> +To: linux-tegra@vger.kernel.org +Date: Fri, 13 Jul 2018 11:32:42 +0000 +From: "David R. Piegdon" +List-Id: + +Hi, +a while back I sent a few mails regarding spurious interrupts in the +UARTA (hsuart) block of the Tegra2 SoC, when using the 8250 driver for +it instead of the hsuart driver. After going down a pretty deep +debugging/testing hole, I think I found a patch that fixes the issue. So +far testing in a reboot-cycle suggests that the error frequency dropped +from >3% of all reboots to at least <0.05% of all reboots. Tests +continue to run over the weekend. + +The patch below already is a second iteration; the first did not reset +the MCR or contain the lines below '// clear interrupts'. This resulted +in no more spurious interrupts, but in a few % of spurious interrupts +that were recovered the UART block did not receive any characters any +more. So further resetting was required to fully reacquire operational +state of the UART block. + +I'd love any comments/suggestions on this! + +Cheers, + +David + +--- a/drivers/tty/serial/8250/8250_core.c ++++ b/drivers/tty/serial/8250/8250_core.c +@@ -136,6 +136,38 @@ static irqreturn_t serial8250_interrupt( + "serial8250: too much work for irq%d\n", irq); + break; + } ++ ++#ifdef CONFIG_ARCH_TEGRA_2x_SOC ++ if (!handled && (port->type == PORT_TEGRA)) { ++ /* ++ * Fix Tegra 2 CPU silicon bug where sometimes ++ * "TX holding register empty" interrupts result in a ++ * bad (metastable?) state in Tegras HSUART IP core. ++ * Only way to recover seems to be to reset all ++ * interrupts as well as the TX queue and the MCR. ++ * But we don't want to loose any outgoing characters, ++ * so only do it if the RX and TX queues are empty. ++ */ ++ unsigned char lsr = port->serial_in(port, UART_LSR); ++ const unsigned char fifo_empty_mask = ++ (UART_LSR_TEMT | UART_LSR_THRE); ++ if (((lsr & (UART_LSR_DR | fifo_empty_mask)) == ++ fifo_empty_mask)) { ++ port->serial_out(port, UART_IER, 0); ++ port->serial_out(port, UART_MCR, 0); ++ serial8250_clear_and_reinit_fifos(up); ++ port->serial_out(port, UART_MCR, up->mcr); ++ port->serial_out(port, UART_IER, up->ier); ++ // clear interrupts ++ serial_port_in(port, UART_LSR); ++ serial_port_in(port, UART_RX); ++ serial_port_in(port, UART_IIR); ++ serial_port_in(port, UART_MSR); ++ up->lsr_saved_flags = 0; ++ up->msr_saved_flags = 0; ++ } ++ } ++#endif + } while (l != end); + + spin_unlock(&i->lock); diff --git a/target/linux/tegra/patches-4.19/101-ARM-dtc-tegra-enable-front-panel-leds-in-TrimSlice.patch b/target/linux/tegra/patches-4.19/101-ARM-dtc-tegra-enable-front-panel-leds-in-TrimSlice.patch new file mode 100644 index 000000000..ae48e8d86 --- /dev/null +++ b/target/linux/tegra/patches-4.19/101-ARM-dtc-tegra-enable-front-panel-leds-in-TrimSlice.patch @@ -0,0 +1,46 @@ +--- a/arch/arm/boot/dts/tegra20-trimslice.dts ++++ b/arch/arm/boot/dts/tegra20-trimslice.dts +@@ -200,16 +200,17 @@ + conf_ata { + nvidia,pins = "ata", "atc", "atd", "ate", + "crtp", "dap2", "dap3", "dap4", "dta", +- "dtb", "dtc", "dtd", "dte", "gmb", +- "gme", "i2cp", "pta", "slxc", "slxd", +- "spdi", "spdo", "uda"; ++ "dtb", "dtc", "dtd", "gmb", "gme", ++ "i2cp", "pta", "slxc", "slxd", "spdi", ++ "spdo", "uda"; + nvidia,pull = ; + nvidia,tristate = ; + }; + conf_atb { + nvidia,pins = "atb", "cdev1", "cdev2", "dap1", +- "gma", "gmc", "gmd", "gpu", "gpu7", +- "gpv", "sdio1", "slxa", "slxk", "uac"; ++ "dte", "gma", "gmc", "gmd", "gpu", ++ "gpu7", "gpv", "sdio1", "slxa", "slxk", ++ "uac"; + nvidia,pull = ; + nvidia,tristate = ; + }; +@@ -402,6 +403,20 @@ + }; + }; + ++ gpio-leds { ++ compatible = "gpio-leds"; ++ ++ ds2 { ++ label = "trimslice:green:right"; ++ gpios = <&gpio TEGRA_GPIO(D, 2) GPIO_ACTIVE_LOW>; ++ }; ++ ++ ds3 { ++ label = "trimslice:green:left"; ++ gpios = <&gpio TEGRA_GPIO(BB, 5) GPIO_ACTIVE_LOW>; ++ }; ++ }; ++ + poweroff { + compatible = "gpio-poweroff"; + gpios = <&gpio TEGRA_GPIO(X, 7) GPIO_ACTIVE_LOW>;