Skip to content

Commit 6c6aa15

Browse files
hkallweitdavem330
authored andcommitted
r8169: improve interrupt handling
This patch improves few aspects of interrupt handling: - update to current interrupt allocation API (use pci_alloc_irq_vectors() instead of deprecated pci_enable_msi()) - this implicitly will allocate a MSI-X interrupt if available - get rid of flag RTL_FEATURE_MSI - remove some dead code, intentionally disabling (unreliable) MSI being partially available on old PCI chips. The patch works fine on a RTL8168evl (chip version 34) and on a RTL8169SB (chip version 04). Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a52b839 commit 6c6aa15

File tree

1 file changed

+21
-27
lines changed
  • drivers/net/ethernet/realtek

1 file changed

+21
-27
lines changed

drivers/net/ethernet/realtek/r8169.c

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -736,8 +736,7 @@ struct ring_info {
736736
};
737737

738738
enum features {
739-
RTL_FEATURE_MSI = (1 << 0),
740-
RTL_FEATURE_GMII = (1 << 1),
739+
RTL_FEATURE_GMII = (1 << 0),
741740
};
742741

743742
struct rtl8169_counters {
@@ -7847,7 +7846,7 @@ static int rtl8169_close(struct net_device *dev)
78477846

78487847
cancel_work_sync(&tp->wk.work);
78497848

7850-
free_irq(pdev->irq, dev);
7849+
pci_free_irq(pdev, 0, dev);
78517850

78527851
dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray,
78537852
tp->RxPhyAddr);
@@ -7903,9 +7902,8 @@ static int rtl_open(struct net_device *dev)
79037902

79047903
rtl_request_firmware(tp);
79057904

7906-
retval = request_irq(pdev->irq, rtl8169_interrupt,
7907-
(tp->features & RTL_FEATURE_MSI) ? 0 : IRQF_SHARED,
7908-
dev->name, dev);
7905+
retval = pci_request_irq(pdev, 0, rtl8169_interrupt, NULL, dev,
7906+
dev->name);
79097907
if (retval < 0)
79107908
goto err_release_fw_2;
79117909

@@ -8253,7 +8251,7 @@ static const struct rtl_cfg_info {
82538251
.region = 2,
82548252
.align = 8,
82558253
.event_slow = SYSErr | LinkChg | RxOverflow,
8256-
.features = RTL_FEATURE_GMII | RTL_FEATURE_MSI,
8254+
.features = RTL_FEATURE_GMII,
82578255
.coalesce_info = rtl_coalesce_info_8168_8136,
82588256
.default_ver = RTL_GIGA_MAC_VER_11,
82598257
},
@@ -8263,32 +8261,26 @@ static const struct rtl_cfg_info {
82638261
.align = 8,
82648262
.event_slow = SYSErr | LinkChg | RxOverflow | RxFIFOOver |
82658263
PCSTimeout,
8266-
.features = RTL_FEATURE_MSI,
82678264
.coalesce_info = rtl_coalesce_info_8168_8136,
82688265
.default_ver = RTL_GIGA_MAC_VER_13,
82698266
}
82708267
};
82718268

8272-
/* Cfg9346_Unlock assumed. */
8273-
static unsigned rtl_try_msi(struct rtl8169_private *tp,
8274-
const struct rtl_cfg_info *cfg)
8269+
static int rtl_alloc_irq(struct rtl8169_private *tp)
82758270
{
82768271
void __iomem *ioaddr = tp->mmio_addr;
8277-
unsigned msi = 0;
8278-
u8 cfg2;
8272+
unsigned int flags;
82798273

8280-
cfg2 = RTL_R8(Config2) & ~MSIEnable;
8281-
if (cfg->features & RTL_FEATURE_MSI) {
8282-
if (pci_enable_msi(tp->pci_dev)) {
8283-
netif_info(tp, hw, tp->dev, "no MSI. Back to INTx.\n");
8284-
} else {
8285-
cfg2 |= MSIEnable;
8286-
msi = RTL_FEATURE_MSI;
8287-
}
8274+
if (tp->mac_version <= RTL_GIGA_MAC_VER_06) {
8275+
RTL_W8(Cfg9346, Cfg9346_Unlock);
8276+
RTL_W8(Config2, RTL_R8(Config2) & ~MSIEnable);
8277+
RTL_W8(Cfg9346, Cfg9346_Lock);
8278+
flags = PCI_IRQ_LEGACY;
8279+
} else {
8280+
flags = PCI_IRQ_ALL_TYPES;
82888281
}
8289-
if (tp->mac_version <= RTL_GIGA_MAC_VER_06)
8290-
RTL_W8(Config2, cfg2);
8291-
return msi;
8282+
8283+
return pci_alloc_irq_vectors(tp->pci_dev, 1, 1, flags);
82928284
}
82938285

82948286
DECLARE_RTL_COND(rtl_link_list_ready_cond)
@@ -8497,9 +8489,11 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
84978489
chipset = tp->mac_version;
84988490
tp->txd_version = rtl_chip_infos[chipset].txd_version;
84998491

8500-
RTL_W8(Cfg9346, Cfg9346_Unlock);
8501-
tp->features |= rtl_try_msi(tp, cfg);
8502-
RTL_W8(Cfg9346, Cfg9346_Lock);
8492+
rc = rtl_alloc_irq(tp);
8493+
if (rc < 0) {
8494+
netif_err(tp, probe, dev, "Can't allocate interrupt\n");
8495+
return rc;
8496+
}
85038497

85048498
/* override BIOS settings, use userspace tools to enable WOL */
85058499
__rtl8169_set_wol(tp, 0);

0 commit comments

Comments
 (0)