Fix ns82830 driver for x86-64
Subsystems (2)
PATCH 1/1 Fix ns82830 driver for x86-64
Fix up some dodgy ifdefs in the ns82820 driver
and support DAC mode on x86-64. Do proper sizeof(dma_addr_t) checks instead.
Only compile tested due to lack of hardware.
Originally pointed out by Al Viro
drivers/net/ns83820.c +11 -29
@@ -1,4 +1,4 @@ -#define _VERSION "0.20" +#define VERSION "0.20"/* ns83820.c by Benjamin LaHaise with contributions. * * Questions/comments/discussion to [email protected].
@@ -129,18 +129,6 @@#undef Dprintk#define Dprintk dprintk -#if defined(CONFIG_HIGHMEM64G ) || defined(__ia64__) -#define USE_64BIT_ADDR "+" -#endif - -#if defined(USE_64BIT_ADDR ) -#define VERSION _VERSION USE_64BIT_ADDR -#define TRY_DAC 1 -#else -#define VERSION _VERSION -#define TRY_DAC 0 -#endif -/* tunables */ #define RX_BUF_SIZE 1500/* 8192 */ #if defined(CONFIG_VLAN_8021Q ) || defined(CONFIG_VLAN_8021Q_MODULE )
@@ -386,22 +374,16 @@#define LINK_DOWN 0x02#define LINK_UP 0x04 -#ifdef USE_64BIT_ADDR -#define HW_ADDR_LEN 8 +#define HW_ADDR_LEN sizeof(dma_addr_t)#define desc_addr_set (desc, addr) \ do { \ - u64 __addr = (addr); \ - (desc)[0] = cpu_to_le32(__addr); \ - (desc)[1] = cpu_to_le32(__addr >> 32); \ + ((desc)[0] = cpu_to_le32(addr)); \ + if (HW_ADDR_LEN == 8) \ + (desc)[1] = cpu_to_le32(((u64)addr) >> 32); \ } while(0)#define desc_addr_get (desc) \ - (((u64)le32_to_cpu((desc)[1]) << 32) \ - | le32_to_cpu((desc)[0])) -#else -#define HW_ADDR_LEN 4 -#define desc_addr_set (desc, addr) ((desc)[0] = cpu_to_le32(addr)) -#define desc_addr_get (desc) (le32_to_cpu((desc)[0])) -#endif + (le32_to_cpu((desc)[0]) | \ + (HW_ADDR_LEN == 8 ? ((dma_addr_t)le32_to_cpu((desc)[1]))<<32 : 0))#define DESC_LINK 0#define DESC_BUFPTR (DESC_LINK + HW_ADDR_LEN/4)
@@ -1841,7 +1823,8 @@int using_dac =0 ;/* See if we can set the dma mask early on; failure is fatal. */ -if (TRY_DAC && !pci_set_dma_mask (pci_dev,0xffffffffffffffffULL )) { +if (sizeof (dma_addr_t) ==8 && + !pci_set_dma_mask (pci_dev,0xffffffffffffffffULL )) { using_dac =1 ; }else if (!pci_set_dma_mask (pci_dev,0xffffffff )) { using_dac =0 ;
@@ -1972,9 +1955,8 @@/* When compiled with 64 bit addressing, we must always enable * the 64 bit descriptor format. */ -#ifdef USE_64BIT_ADDR - dev->CFG_cache |=CFG_M64ADDR ; -#endif +if (sizeof (dma_addr_t) ==8 ) + dev->CFG_cache |=CFG_M64ADDR ;if (using_dac) dev->CFG_cache |=CFG_T64ADDR ;
I'll have a closer look at this when I'm back in Canada later this week, as there are a few other ns83820 patches which should be applied. The patch looks right -- those ifdefs date back to the 2.4.9 days.
-ben
Quoted 90 lines · Andi Kleen
Fix up some dodgy ifdefs in the ns82820 driver
and support DAC mode on x86-64. Do propersizeof(dma_addr_t)checks instead.Only compile tested due to lack of hardware.
Originally pointed out by Al Viro
Signed-off-by Andi Kleen <[email protected]>Index:
linux/drivers/net/ns83820.c
===================================================================drivers/net/ns83820.c +11
-29@@ -1,4 +1,4 @@ -#define _VERSION "0.20" +#define VERSION "0.20"/* ns83820.c by Benjamin LaHaise with contributions. * * Questions/comments/discussion to [email protected]. @@ -129,18 +129,6 @@#undef Dprintk#define Dprintk dprintk -#if defined(CONFIG_HIGHMEM64G ) || defined(__ia64__) -#define USE_64BIT_ADDR "+" -#endif - -#if defined(USE_64BIT_ADDR ) -#define VERSION _VERSION USE_64BIT_ADDR -#define TRY_DAC 1 -#else -#define VERSION _VERSION -#define TRY_DAC 0 -#endif -/* tunables */ #define RX_BUF_SIZE 1500/* 8192 */ #if defined(CONFIG_VLAN_8021Q ) || defined(CONFIG_VLAN_8021Q_MODULE )@@ -386,22 +374,16 @@#define LINK_DOWN 0x02#define LINK_UP 0x04 -#ifdef USE_64BIT_ADDR -#define HW_ADDR_LEN 8 +#define HW_ADDR_LEN sizeof(dma_addr_t)#define desc_addr_set (desc, addr) \ do { \ - u64 __addr = (addr); \ - (desc)[0] = cpu_to_le32(__addr); \ - (desc)[1] = cpu_to_le32(__addr >> 32); \ + ((desc)[0] = cpu_to_le32(addr)); \ + if (HW_ADDR_LEN == 8) \ + (desc)[1] = cpu_to_le32(((u64)addr) >> 32); \ } while(0)#define desc_addr_get (desc) \ - (((u64)le32_to_cpu((desc)[1]) << 32) \ - | le32_to_cpu((desc)[0])) -#else -#define HW_ADDR_LEN 4 -#define desc_addr_set (desc, addr) ((desc)[0] = cpu_to_le32(addr)) -#define desc_addr_get (desc) (le32_to_cpu((desc)[0])) -#endif + (le32_to_cpu((desc)[0]) | \ + (HW_ADDR_LEN == 8 ? ((dma_addr_t)le32_to_cpu((desc)[1]))<<32 : 0))#define DESC_LINK 0#define DESC_BUFPTR (DESC_LINK + HW_ADDR_LEN/4)@@ -1841,7 +1823,8 @@int using_dac =0 ;/* See if we can set the dma mask early on; failure is fatal. */ -if (TRY_DAC && !pci_set_dma_mask (pci_dev,0xffffffffffffffffULL )) { +if (sizeof (dma_addr_t) ==8 && + !pci_set_dma_mask (pci_dev,0xffffffffffffffffULL )) { using_dac =1 ; }else if (!pci_set_dma_mask (pci_dev,0xffffffff )) { using_dac =0 ;@@ -1972,9 +1955,8 @@/* When compiled with 64 bit addressing, we must always enable * the 64 bit descriptor format. */ -#ifdef USE_64BIT_ADDR - dev->CFG_cache |=CFG_M64ADDR ; -#endif +if (sizeof (dma_addr_t) ==8 ) + dev->CFG_cache |=CFG_M64ADDR ;if (using_dac) dev->CFG_cache |=CFG_T64ADDR ;
Signature · 1 line
"Time is what keeps everything from happening all at once." -- John Wheeler