diff options
author | Jonas Gorski <jonas.gorski@gmail.com> | 2016-09-29 12:16:51 +0200 |
---|---|---|
committer | Jonas Gorski <jonas.gorski@gmail.com> | 2016-09-29 13:47:18 +0200 |
commit | 4aa5d3e60d6007809a4b7fac9959645ef1600cf9 (patch) | |
tree | 7cb22196cbe77fccaec11c5606900a3713313225 /target/linux/mvebu/patches-4.4/124-phy-improve-safety-of-fixed-phy-MII-register-reading.patch | |
parent | a454756c913060977fd826ed421b9c7cfca3372e (diff) | |
download | upstream-4aa5d3e60d6007809a4b7fac9959645ef1600cf9.tar.gz upstream-4aa5d3e60d6007809a4b7fac9959645ef1600cf9.tar.bz2 upstream-4aa5d3e60d6007809a4b7fac9959645ef1600cf9.zip |
mvebu: add support for SFP
Add patches for SFP support and package it for ClearFog. Tested with a
Juniper SFP module.
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Acked-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'target/linux/mvebu/patches-4.4/124-phy-improve-safety-of-fixed-phy-MII-register-reading.patch')
-rw-r--r-- | target/linux/mvebu/patches-4.4/124-phy-improve-safety-of-fixed-phy-MII-register-reading.patch | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/target/linux/mvebu/patches-4.4/124-phy-improve-safety-of-fixed-phy-MII-register-reading.patch b/target/linux/mvebu/patches-4.4/124-phy-improve-safety-of-fixed-phy-MII-register-reading.patch new file mode 100644 index 0000000000..5167b07101 --- /dev/null +++ b/target/linux/mvebu/patches-4.4/124-phy-improve-safety-of-fixed-phy-MII-register-reading.patch @@ -0,0 +1,92 @@ +From c36739c3cfd277a4cc9820a29dd0f4b7fbac795b Mon Sep 17 00:00:00 2001 +From: Russell King <rmk+kernel@arm.linux.org.uk> +Date: Sun, 20 Sep 2015 18:31:36 +0100 +Subject: [PATCH 713/744] phy: improve safety of fixed-phy MII register reading + +There is no prevention of a concurrent call to both fixed_mdio_read() +and fixed_phy_update_state(), which can result in the state being +modified while it's being inspected. Fix this by using a seqcount +to detect modifications, and memcpy()ing the state. + +We remain slightly naughty here, calling link_update() and updating +the link status within the read-side loop - which would need rework +of the design to change. + +Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> +Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> +--- + drivers/net/phy/fixed_phy.c | 28 +++++++++++++++++++++------- + 1 file changed, 21 insertions(+), 7 deletions(-) + +--- a/drivers/net/phy/fixed_phy.c ++++ b/drivers/net/phy/fixed_phy.c +@@ -23,6 +23,7 @@ + #include <linux/slab.h> + #include <linux/of.h> + #include <linux/gpio.h> ++#include <linux/seqlock.h> + + #include "swphy.h" + +@@ -35,6 +36,7 @@ struct fixed_mdio_bus { + struct fixed_phy { + int addr; + struct phy_device *phydev; ++ seqcount_t seqcount; + struct fixed_phy_status status; + int (*link_update)(struct net_device *, struct fixed_phy_status *); + struct list_head node; +@@ -59,13 +61,21 @@ static int fixed_mdio_read(struct mii_bu + + list_for_each_entry(fp, &fmb->phys, node) { + if (fp->addr == phy_addr) { +- /* Issue callback if user registered it. */ +- if (fp->link_update) { +- fp->link_update(fp->phydev->attached_dev, +- &fp->status); +- fixed_phy_update(fp); +- } +- return swphy_read_reg(reg_num, &fp->status); ++ struct fixed_phy_status state; ++ int s; ++ ++ do { ++ s = read_seqcount_begin(&fp->seqcount); ++ /* Issue callback if user registered it. */ ++ if (fp->link_update) { ++ fp->link_update(fp->phydev->attached_dev, ++ &fp->status); ++ fixed_phy_update(fp); ++ } ++ state = fp->status; ++ } while (read_seqcount_retry(&fp->seqcount, s)); ++ ++ return swphy_read_reg(reg_num, &state); + } + } + +@@ -117,6 +127,7 @@ int fixed_phy_update_state(struct phy_de + + list_for_each_entry(fp, &fmb->phys, node) { + if (fp->addr == phydev->addr) { ++ write_seqcount_begin(&fp->seqcount); + #define _UPD(x) if (changed->x) \ + fp->status.x = status->x + _UPD(link); +@@ -126,6 +137,7 @@ int fixed_phy_update_state(struct phy_de + _UPD(asym_pause); + #undef _UPD + fixed_phy_update(fp); ++ write_seqcount_end(&fp->seqcount); + return 0; + } + } +@@ -150,6 +162,8 @@ int fixed_phy_add(unsigned int irq, int + if (!fp) + return -ENOMEM; + ++ seqcount_init(&fp->seqcount); ++ + fmb->irqs[phy_addr] = irq; + + fp->addr = phy_addr; |