Skip to contentSkip to conversation

Fix rtl8169 compile warning and add a new device ID

PATCH In review Minda Chen 2 participants 9 messages Jul 20, 2023 – Jul 24, 2023 Network drivers

lore
Share & tools
lore
author
#3 lore raw

PATCH v2 2/4 net: rtl8169: Fix DMA minimal aligned compile warning in RISC-V

In reply to Minda Chen

For RISC-V architeture, hardware maintain the dcache coherency. Software do not flush the cache. So even cache-line size larger than descriptor size, driver can work.

---
 drivers/net/rtl8169.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/rtl8169.c +3 -1
index dcba51590d..34e4cff1e9 100644
@@ -311,10 +311,12 @@ static unsigned char rxdata[RX_BUF_LEN];
  *
  * This can be fixed by defining CONFIG_SYS_NONCACHED_MEMORY which will cause
  * the driver to allocate descriptors from a pool of non-cached memory.
+ *
+ * Hardware maintain D-cache coherency in RISC-V architecture.
  */
 #if RTL8169_DESC_SIZE < ARCH_DMA_MINALIGN
 #if !defined(CONFIG_SYS_NONCACHED_MEMORY) && \
-	!CONFIG_IS_ENABLED(SYS_DCACHE_OFF) && !defined(CONFIG_X86)
+	!CONFIG_IS_ENABLED(SYS_DCACHE_OFF) && !defined(CONFIG_X86) && !defined(CONFIG_RISCV)
 #warning cache-line size is larger than descriptor size
 #endif
 #endif
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 1/4 net: rtl8169: Fix compile warning in rtl8169

In reply to Minda Chen

While compiling rtl8169.c, There are many "make pointer from integer without a cast" compile warnings. fix them with adding cast.

---
 drivers/net/rtl8169.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/rtl8169.c +6 -6
index 2276a465e7..dcba51590d 100644
@@ -96,12 +96,12 @@ static int media[MAX_UNITS] = { -1, -1, -1, -1, -1, -1, -1, -1 };
 #define TX_TIMEOUT  (6*HZ)
 
 /* write/read MMIO register. Notice: {read,write}[wl] do the necessary swapping */
-#define RTL_W8(reg, val8)	writeb((val8), ioaddr + (reg))
-#define RTL_W16(reg, val16)	writew((val16), ioaddr + (reg))
-#define RTL_W32(reg, val32)	writel((val32), ioaddr + (reg))
-#define RTL_R8(reg)		readb(ioaddr + (reg))
-#define RTL_R16(reg)		readw(ioaddr + (reg))
-#define RTL_R32(reg)		readl(ioaddr + (reg))
+#define RTL_W8(reg, val8)	writeb((val8), (void *)(ioaddr + (reg)))
+#define RTL_W16(reg, val16)	writew((val16), (void *)(ioaddr + (reg)))
+#define RTL_W32(reg, val32)	writel((val32), (void *)(ioaddr + (reg)))
+#define RTL_R8(reg)		readb((void *)(ioaddr + (reg)))
+#define RTL_R16(reg)		readw((void *)(ioaddr + (reg)))
+#define RTL_R32(reg)		readl((void *)(ioaddr + (reg)))
 
 #define bus_to_phys(a)	pci_mem_to_phys((pci_dev_t)(unsigned long)dev->priv, \
 	(pci_addr_t)(unsigned long)a)
Signature · 1 line
2.17.1
author
#7 lore raw

PATCH v2 4/4 configs: starfive-jh7110: Add CONFIG_RTL8169

In reply to Minda Chen

Add PCIe device rtl8169 net adapter driver support.

---
 configs/starfive_visionfive2_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/starfive_visionfive2_defconfig +1 -0
index 59e39c6f9b..7fc1569b59 100644
@@ -95,6 +95,7 @@ CONFIG_DWC_ETH_QOS=y
 CONFIG_DWC_ETH_QOS_STARFIVE=y
 CONFIG_RGMII=y
 CONFIG_RMII=y
+CONFIG_RTL8169=y
 CONFIG_NVME_PCI=y
 CONFIG_DM_PCI_COMPAT=y
 # CONFIG_PCI_PNP is not set
Signature · 1 line
2.17.1

Minda Chen

author
#0 lore raw

v2 cover Fix rtl8169 compile warning and add a new device ID

StarFive JH7110 uboot support PCIe and using rtl8169 network adapter PCIe device. But compile warning in rtl8169 driver cause CI test fail. So commit this patch set to fix it, Also a new device ID to adjust the PCI bar regions in rtl8169.

The StarFive JH7110 PCIe driver link, patch 4 rely on this.
https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/

previous version:
[1] https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/

change:
v2: patch 1- 3 modify the commit messages.
rebase to latest mainline codes.

patch 1 is fix make pointer from integer warning.
eg: /home/minda/vf2/visionfive/u-boot/drivers/net/rtl8169.c:103:52: warning:
passing argument 2 of ‘writew’ makes pointer from integer without a cast [-Wint-conversion]
patch 2 fix RISC-V 8169 descriptor less than DMA min aligned size warning
patch 3 add new device ID
patch 4 enable 8169 in JH7110 SoC configs file.

Minda Chen (4):
net: rtl8169: Fix compile warning in rtl8169
net: rtl8169: Fix DMA minimal aligned compile warning in RISC-V
net: rtl8169: Add one device ID 0x8161
configs: starfive-jh7110: Add CONFIG_RTL8169

 configs/starfive_visionfive2_defconfig |  1 +
 drivers/net/rtl8169.c                  | 22 +++++++++++++---------
 2 files changed, 14 insertions(+), 9 deletions(-)

base-commit: e6e67bb9e0a40f3eb3c87d16935192821987c3e0

Signature · 1 line
2.17.1
author
#5 lore raw

PATCH v2 3/4 net: rtl8169: Add one device ID 0x8161

Add rtl8169 NIC device ID and reorder the device ID.

---
 drivers/net/rtl8169.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/rtl8169.c +4 -2
index 34e4cff1e9..963702777c 100644
@@ -353,10 +353,11 @@ static const unsigned int rtl8169_rx_config =
     (RX_FIFO_THRESH << RxCfgFIFOShift) | (RX_DMA_BURST << RxCfgDMAShift);
 
 static struct pci_device_id supported[] = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8125) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8161) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8167) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169) },
-	{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8125) },
 	{}
 };
 
@@ -1051,8 +1052,9 @@ static int rtl8169_eth_probe(struct udevice *dev)
 	int ret;
 
 	switch (pplat->device) {
-	case 0x8168:
 	case 0x8125:
+	case 0x8161:
+	case 0x8168:
 		region = 2;
 		break;
 	default:
Signature · 1 line
2.17.1
Reviewed-by on v2 2/4
#4 lore raw

Re: [PATCH v2 2/4] net: rtl8169: Fix DMA minimal aligned compile warning in RISC-V

In reply to Minda Chen
Quoted 8 lines · Minda Chen

For RISC-V architeture, hardware maintain the dcache coherency. Software do not flush the cache. So even cache-line size larger than descriptor size, driver can work.

---
 drivers/net/rtl8169.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)