25 Feb, 2017
1 commit
-
Dan's static checker caught a potential code path in phy_state_machine() where
we were not checking phydev->drv which is in phy_aneg_done().Reported-by: Dan Carpenter
Fixes: 25149ef9d25c ("net: phy: Check phydev->drv")
Signed-off-by: Florian Fainelli
Signed-off-by: David S. Miller
20 Feb, 2017
1 commit
-
There are number of function calls, originating from user-space,
typically through the Ethernet driver that can make us crash by
dereferencing phydev->drv which will be NULL once we unbind the driver
from the PHY.There are still functional issues that prevent an unbind then rebind to
work, but these will be addressed separately.Suggested-by: Russell King
Signed-off-by: Florian Fainelli
Signed-off-by: David S. Miller
26 Jan, 2017
1 commit
-
includes , which is not really
needed. Drop the include from , and add it to all users
that didn't include it explicitly.Suggested-by: Andrew Lunn
Signed-off-by: Geert Uytterhoeven
Reviewed-by: Andrew Lunn
Signed-off-by: David S. Miller
24 Jan, 2017
1 commit
-
phy_error() is called in the PHY state machine workqueue context, and
calls phy_trigger_machine() which does a cancel_delayed_work_sync() of
the workqueue we execute from, causing a deadlock situation.Augment phy_trigger_machine() machine with a sync boolean indicating
whether we should use cancel_*_sync() or just cancel_*_work().Fixes: 3c293f4e08b5 ("net: phy: Trigger state machine on state change and not polling.")
Reported-by: Russell King
Signed-off-by: Florian Fainelli
Signed-off-by: David S. Miller
10 Jan, 2017
1 commit
-
While in RUNNING state, phy_state_machine() checks for link changes by
comparing phydev->link before and after calling phy_read_status().
This works as long as it is guaranteed that phydev->link is never
changed outside the phy_state_machine().If in some setups this happens, it causes the state machine to miss
a link loss and remain RUNNING despite phydev->link being 0.This has been observed running a dsa setup with a process continuously
polling the link states over ethtool each second (SNMPD RFC-1213
agent). Disconnecting the link on a phy followed by a ETHTOOL_GSET
causes dsa_slave_get_settings() / dsa_slave_get_link_ksettings() to
call phy_read_status() and with that modify the link status - and
with that bricking the phy state machine.This patch adds a fail-safe check while in RUNNING, which causes to
move to CHANGELINK when the link is gone and we are still RUNNING.Signed-off-by: Zefir Kurtisi
Reviewed-by: Florian Fainelli
Signed-off-by: David S. Miller
02 Dec, 2016
1 commit
-
Update the mdix and mdix_ctrl with corresponding ethtool configuration
parameters.Signed-off-by: Raju Lakkaraju
Signed-off-by: David S. Miller
30 Nov, 2016
1 commit
-
This patch adds an option to disable EEE advertisement in the generic PHY
by providing a mask of prohibited modes corresponding to the value found in
the MDIO_AN_EEE_ADV register.On some platforms, PHY Low power idle seems to be causing issues, even
breaking the link some cases. The patch provides a convenient way for these
platforms to disable EEE advertisement and work around the issue.Signed-off-by: Jerome Brunet
Tested-by: Yegor Yefremov
Tested-by: Andreas Färber
Signed-off-by: David S. Miller
16 Nov, 2016
1 commit
-
This function just calls into genphy_restart_aneg() to perform an
autonegotation restart.Signed-off-by: Florian Fainelli
Signed-off-by: David S. Miller
13 Nov, 2016
1 commit
-
Make phy_aneg_done() available to drivers so that the result of the
auto-negotiation initiated by phy_start_aneg() can be determined.Remove the local implementation of phy_aneg_done() from the Aeroflex
driver and use the phy library version.Signed-off-by: Tom Lendacky
Signed-off-by: David S. Miller
18 Oct, 2016
3 commits
-
Create an option CONFIG_LED_TRIGGER_PHY (default n), which will create a
set of led triggers for each instantiated PHY device. There is one LED
trigger per link-speed, per-phy.
The triggers are registered during phy_attach and unregistered during
phy_detach.This allows for a user to configure their system to allow a set of LEDs
not controlled by the phy to represent link state changes on the phy.
LEDS controlled by the phy are unaffected.For example, we have a board where some of the leds in the
RJ45 socket are controlled by the phy, but others are not. Using the
triggers provided by this patch the leds not controlled by the phy can
be configured to show the current speed of the ethernet connection. The
leds controlled by the phy are unaffected.Signed-off-by: Josh Cartwright
Signed-off-by: Nathan Sullivan
Signed-off-by: Zach Brown
Signed-off-by: David S. Miller -
phy_supported_speeds provides a means to get a list of all the speeds a
phy device currently supports.Signed-off-by: Zach Brown
Signed-off-by: David S. Miller -
During phy state machine state transitions some set of actions should
occur whenever the link state changes. These actions should be
encapsulated into a single functionThis patch adds the phy_adjust_link function, which is called whenever
phydev->adjust_link would have been called before. Actions that should
occur whenever the phy link is adjusted can now be added to the
phy_adjust_link function.Signed-off-by: Zach Brown
Signed-off-by: David S. Miller
17 Oct, 2016
3 commits
-
Using the fixed name "phy_interrupt" is not very informative in
/proc/interrupts when there are a lot of phys, e.g. a device with an
Ethernet switch. So when requesting the interrupt, use the name of the
phy.Signed-off-by: Andrew Lunn
Acked-by: Florian Fainelli
Signed-off-by: David S. Miller -
The PHY interrupts are now handled in a threaded interrupt handler,
which can sleep. The work queue is no longer needed, phy_change() can
be called directly. phy_mac_interrupt() still needs to be safe to call
in interrupt context, so keep the work queue, and use a helper to call
phy_change().Signed-off-by: Andrew Lunn
Signed-off-by: David S. Miller -
The interrupt lines from PHYs maybe connected to I2C bus expanders, or
from switches on MDIO busses. Such interrupts are sourced from devices
which sleep, so use threaded interrupts. Threaded interrupts require
that the interrupt requester also uses the threaded API. Change the
phylib to use the threaded API, which is backwards compatible with
none-threaded IRQs.Signed-off-by: Andrew Lunn
Signed-off-by: David S. Miller
14 Oct, 2016
1 commit
-
The phy_start() is used to indicate the PHY is now ready to do its
work. The state is changed, normally to PHY_UP which means that both
the MAC and the PHY are ready.If the phy driver is using polling, when the next poll happens, the
state machine notices the PHY is now in PHY_UP, and kicks off
auto-negotiation, if needed.If however, the PHY is using interrupts, there is no polling. The phy
is stuck in PHY_UP until the next interrupt comes along. And there is
no reason for the PHY to interrupt.Have phy_start() schedule the state machine to run, which both speeds
up the polling use case, and makes the interrupt use case actually
work.This problems exists whenever there is a state change which will not
cause an interrupt. Trigger the state machine in these cases,
e.g. phy_error().Signed-off-by: Andrew Lunn
Cc: Kyle Roeschley
Tested-by: Kyle Roeschley
Signed-off-by: David S. Miller
26 Aug, 2016
1 commit
-
This reverts:
commit 33c133cc7598 ("phy: IRQ cannot be shared")On hardware with multiple PHY devices hooked up to the same IRQ line, allow
them to share it.Sergei Shtylyov says:
"I'm not sure now what was the reason I concluded that the IRQ sharing
was impossible... most probably I thought that the kernel IRQ handling
code exited the loop over the IRQ actions once IRQ_HANDLED was returned
-- which is obviously not so in reality..."Signed-off-by: Xander Huff
Signed-off-by: Nathan Sullivan
Signed-off-by: David S. Miller
16 May, 2016
1 commit
-
The nf_conntrack_core.c fix in 'net' is not relevant in 'net-next'
because we no longer have a per-netns conntrack hash.The ip_gre.c conflict as well as the iwlwifi ones were cases of
overlapping changes.Conflicts:
drivers/net/wireless/intel/iwlwifi/mvm/tx.c
net/ipv4/ip_gre.c
net/netfilter/nf_conntrack_core.cSigned-off-by: David S. Miller
11 May, 2016
2 commits
-
If phy was suspended and is starting, current driver always enable
phy's interrupts, if phy works in polling, phy can raise unexpected
interrupt which will not be handled, the interrupt will block system
enter suspend again. So interrupts should only be re-enabled if phy
works in interrupt.Signed-off-by: Shaohui Xie
Reviewed-by: Florian Fainelli
Signed-off-by: David S. Miller -
Ethtool callbacks {get|set}_link_ksettings are often the same, so
we add two generics functions phy_ethtool_{get|set}_link_ksettings
to avoid writing severals times the same function.Signed-off-by: Philippe Reynes
Acked-By: David Decotigny
Signed-off-by: David S. Miller
19 Apr, 2016
1 commit
-
The old ethtool api (get_setting and set_setting) has
generic phy functions phy_ethtool_sset and phy_ethtool_gset.
To supprt the new ethtool api (get_link_ksettings and
set_link_ksettings), we add generic phy function
phy_ethtool_ksettings_get and phy_ethtool_ksettings_set.Signed-off-by: Philippe Reynes
Signed-off-by: David S. Miller
22 Jan, 2016
2 commits
-
Commit 5ea94e7686a3 ("phy: add phy_mac_interrupt()") to use with
PHY_IGNORE_INTERRUPT added a cancel_work_sync() into phy_mac_interrupt()
which is allowed to sleep, whereas phy_mac_interrupt() is expected to be
callable from interrupt context.Now that we have fixed how the PHY state machine treats
PHY_IGNORE_INTERRUPT with respect to state changes, we can just set the
new link state, and queue the PHY state machine for execution so it is
going to read the new link state.For that to work properly, we need to update phy_change() not to try to
invoke any interrupt callbacks if we have configured the PHY device for
PHY_IGNORE_INTERRUPT, because that PHY device and its driver are not
required to implement those.Fixes: 5ea94e7686a3 ("phy: add phy_mac_interrupt() to use with PHY_IGNORE_INTERRUPT")
Signed-off-by: Florian Fainelli
Signed-off-by: David S. Miller -
Commit 2c7b49212a86 ("phy: fix the use of PHY_IGNORE_INTERRUPT") changed
a hunk in phy_state_machine() in the PHY_RUNNING case which was not
needed. The change essentially makes the PHY library treat PHY devices
with PHY_IGNORE_INTERRUPT to keep polling for the PHY device, even
though the intent is not to do it.Fix this by reverting that specific hunk, which makes the PHY state
machine wait for state changes, and stay in the PHY_RUNNING state for as
long as needed.Fixes: 2c7b49212a86 ("phy: fix the use of PHY_IGNORE_INTERRUPT")
Signed-off-by: Florian Fainelli
Signed-off-by: David S. Miller
08 Jan, 2016
3 commits
-
Not all devices attached to an MDIO bus are phys. So add an
mdio_device structure to represent the generic parts of an mdio
device, and place this structure into the phy_device.Signed-off-by: Andrew Lunn
Signed-off-by: David S. Miller -
The address of the device can be determined from the phydev structure,
rather than passing it as a parameter.Signed-off-by: Andrew Lunn
Reviewed-by: Florian Fainelli
Signed-off-by: David S. Miller -
In preparation for moving some of the phy_device structure members,
add macros for printing errors and debug information.Signed-off-by: Andrew Lunn
Reviewed-by: Florian Fainelli
Signed-off-by: David S. Miller
04 Dec, 2015
1 commit
-
It is possible to address another chip on same MDIO bus. The case is
correctly handled for media advertising. It is taken into account
only if mii_data->phy_id == phydev->addr. However, this condition
was missing for reset case.Signed-off-by: Jérôme Pouiller
Signed-off-by: David S. Miller
18 Nov, 2015
1 commit
-
The NOLINK state will poll the phy once a second to see if the link
has come up. If the phy has an interrupt line, this polling can be
skipped, since the phy should interrupt when the link returns.Signed-off-by: Andrew Lunn
Signed-off-by: David S. Miller
29 Aug, 2015
1 commit
-
Fix scripts/checkpatch.pl's messages like:
CHECK: Comparison to NULL could be written "!phydrv->read_mmd_indirect"
BTW, it doesn't detect the reversed comparisons (which I've fixed as well).
Signed-off-by: Sergei Shtylyov
Signed-off-by: David S. Miller
28 Aug, 2015
1 commit
26 Aug, 2015
1 commit
-
The phy layer is missing locking for the above two functions - it
has been observed that two threads (userspace and the phy worker
thread) can race, entering the bus ->write or ->read functions
simultaneously.This causes the FEC driver to initialise a completion while another
thread is waiting on it or while the interrupt is calling complete()
on it, which causes spinlock unlock-without-lock, spinlock lockups,
and completion timeouts.Fixes: a59a4d192 ("phy: add the EEE support and the way to access to the MMD registers.")
Fixes: 0c1d77dfb ("net: libphy: Add phy specific function to access mmd phy registers")
Signed-off-by: Russell King
Acked-by: Florian Fainelli
Signed-off-by: David S. Miller
22 Aug, 2015
1 commit
-
Conflicts:
drivers/net/usb/qmi_wwan.cOverlapping additions of new device IDs to qmi_wwan.c
Signed-off-by: David S. Miller
18 Aug, 2015
1 commit
-
Currently, if phy state is PHY_RUNNING, we always register a CHANGE
when phy works in polling or interrupt ignored, this will make the
adjust_link being called even the phy link did Not changed.checking the phy link to make sure the link did changed before we
register a CHANGE, if link did not changed, we do nothing.Signed-off-by: Shaohui Xie
Signed-off-by: David S. Miller
11 Jul, 2015
2 commits
-
Support manually setting the polarity to mdi or mdix
Signed-off-by: David Thomson
Signed-off-by: David S. Miller -
Pass the mdix setting from ethtool down to the phy driver, to allow
driver specific implementations of manually setting the polarity.Signed-off-by: David Thomson
Reviewed-by: Florian Fainelli
Signed-off-by: David S. Miller
27 May, 2015
1 commit
-
Update all open-coded tests for all 4 PHY_INTERFACE_MODE_RGMII* values
to use the newly introduced helper: phy_interface_is_rgmii.Signed-off-by: Florian Fainelli
Signed-off-by: David S. Miller
23 May, 2015
1 commit
-
Conflicts:
drivers/net/ethernet/cadence/macb.c
drivers/net/phy/phy.c
include/linux/skbuff.h
net/ipv4/tcp.c
net/switchdev/switchdev.cSwitchdev was a case of RTNH_H_{EXTERNAL --> OFFLOAD}
renaming overlapping with net-next changes of various
sorts.phy.c was a case of two changes, one adding a local
variable to a function whilst the second was removing
one.tcp.c overlapped a deadlock fix with the addition of new tcp_info
statistic values.macb.c involved the addition of two zyncq device entries.
skbuff.h involved adding back ipv4_daddr to nf_bridge_info
whilst net-next changes put two other existing members of
that struct into a union.Signed-off-by: David S. Miller
21 May, 2015
1 commit
-
This is an alternative way of fixing:
commit db9683fb412d ("net: phy: Make sure PHY_RESUMING state change
is always processed")When the PHY state transitions from PHY_HALTED to PHY_RESUMING, there are
two things we need to do:
1). Re-enable interrupts (and power up the physical link, if powered down)
2). Update the PHY state and net-device based on the link status.There's no strict reason why #1 has to be done from within the main
phy_state_machine() function. There is a risk that other changes to the
PHY (e.g. setting speed/duplex, which calls phy_start_aneg()) could cause
a subsequent state transition before phy_state_machine() has processed
the PHY_RESUMING state change. This would leave the PHY with interrupts
disabled and/or still in the BMCR_PDOWN/low-power mode.Moving enabling the interrupts and phy_resume() into phy_start() will
guarantee this work always gets done. As the PHY is already in the HALTED
state and interrupts are disabled, it shouldn't conflict with any work
being done in phy_state_machine(). The downside of this change is that if
the PHY_RESUMING state is ever entered from anywhere else, it'll also have
to repeat this work.Signed-off-by: Tim Beale
Signed-off-by: David S. Miller
17 May, 2015
2 commits
-
If phy_start_aneg() was called while the phydev is in the PHY_RESUMING
state, then its state would immediately transition to PHY_AN (or
PHY_FORCING). This meant the phy_state_machine() never processed the
PHY_RESUMING state change, which meant interrupts weren't enabled for the
PHY. If the PHY used low-power mode (i.e. using BMCR_PDOWN), then the
physical link wouldn't get powered up again.There seems no point for phy_start_aneg() to make the PHY_RESUMING -->
PHY_AN transition, as the state machine will do this anyway. I'm not sure
about the case where autoneg is disabled, as my patch will change
behaviour so that the PHY goes to PHY_NOLINK instead of PHY_FORCING. An
alternative solution would be to move the phy_config_interrupt() and
phy_resume() work out of the state machine and into phy_start().The background behind this: we're running linux v3.16.7 and from user-space
we want to enable the eth port (i.e. do a SIOCSIFFLAGS ioctl with the
IFF_UP flag) and immediately afterward set the interface's speed/duplex.
Enabling the interface calls .ndo_open() then phy_start() and the PHY
transitions PHY_HALTED --> PHY_RESUMING. Setting the speed/duplex ends up
calling phy_ethtool_sset(), which calls phy_start_aneg() (meanwhile the
phy_state_machine() hasn't processed the PHY_RESUMING state change yet).Signed-off-by: Tim Beale
Reviewed-by: Florian Fainelli
Signed-off-by: David S. Miller -
It can be useful to debug the PHY state machine, add dynamic debug
prints of the old and new PHY devices state under a friendly format.Signed-off-by: Florian Fainelli
Signed-off-by: David S. Miller