Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d1dc934a authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'r8169-fixes'



Chunhao Lin says:

====================
r8169: fix 3 runtime pm related issues.

v2:
use "struct device *d = &tp->pci_dev->dev" instead of "struct pci_dev *pdev = tp->pci_dev"

v1:
This series of patches fix 3 runtime pm related issues that are listed below.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents bb9c0fa3 f51d4a10
Loading
Loading
Loading
Loading
+33 −4
Original line number Diff line number Diff line
@@ -1749,13 +1749,21 @@ static u32 __rtl8169_get_wol(struct rtl8169_private *tp)
static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{
	struct rtl8169_private *tp = netdev_priv(dev);
	struct device *d = &tp->pci_dev->dev;

	pm_runtime_get_noresume(d);

	rtl_lock_work(tp);

	wol->supported = WAKE_ANY;
	if (pm_runtime_active(d))
		wol->wolopts = __rtl8169_get_wol(tp);
	else
		wol->wolopts = tp->saved_wolopts;

	rtl_unlock_work(tp);

	pm_runtime_put_noidle(d);
}

static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
@@ -1845,6 +1853,9 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{
	struct rtl8169_private *tp = netdev_priv(dev);
	struct device *d = &tp->pci_dev->dev;

	pm_runtime_get_noresume(d);

	rtl_lock_work(tp);

@@ -1852,12 +1863,17 @@ static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
		tp->features |= RTL_FEATURE_WOL;
	else
		tp->features &= ~RTL_FEATURE_WOL;
	if (pm_runtime_active(d))
		__rtl8169_set_wol(tp, wol->wolopts);
	else
		tp->saved_wolopts = wol->wolopts;

	rtl_unlock_work(tp);

	device_set_wakeup_enable(&tp->pci_dev->dev, wol->wolopts);

	pm_runtime_put_noidle(d);

	return 0;
}

@@ -2292,12 +2308,18 @@ static void rtl8169_get_ethtool_stats(struct net_device *dev,
				      struct ethtool_stats *stats, u64 *data)
{
	struct rtl8169_private *tp = netdev_priv(dev);
	struct device *d = &tp->pci_dev->dev;
	struct rtl8169_counters *counters = tp->counters;

	ASSERT_RTNL();

	pm_runtime_get_noresume(d);

	if (pm_runtime_active(d))
		rtl8169_update_counters(dev);

	pm_runtime_put_noidle(d);

	data[0] = le64_to_cpu(counters->tx_packets);
	data[1] = le64_to_cpu(counters->rx_packets);
	data[2] = le64_to_cpu(counters->tx_errors);
@@ -4458,6 +4480,7 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
static int rtl_set_mac_address(struct net_device *dev, void *p)
{
	struct rtl8169_private *tp = netdev_priv(dev);
	struct device *d = &tp->pci_dev->dev;
	struct sockaddr *addr = p;

	if (!is_valid_ether_addr(addr->sa_data))
@@ -4465,8 +4488,13 @@ static int rtl_set_mac_address(struct net_device *dev, void *p)

	memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);

	pm_runtime_get_noresume(d);

	if (pm_runtime_active(d))
		rtl_rar_set(tp, dev->dev_addr);

	pm_runtime_put_noidle(d);

	return 0;
}

@@ -7868,6 +7896,7 @@ static int rtl8169_runtime_resume(struct device *device)
	struct pci_dev *pdev = to_pci_dev(device);
	struct net_device *dev = pci_get_drvdata(pdev);
	struct rtl8169_private *tp = netdev_priv(dev);
	rtl_rar_set(tp, dev->dev_addr);

	if (!tp->TxDescArray)
		return 0;