cxgb4: speed up reading on-chip memory
Subsystems (3)
v2 cover cxgb4: speed up reading on-chip memory
This series of patches speed up reading on-chip memory (EDC and MC) by reading 64-bits at a time.
Patch 1 reworks logic to read EDC and MC.
Patch 2 adds logic to read EDC and MC 64-bits at a time.
Thanks,
Rahul
---
v2:
- Dropped AVX CPU intrinsic instructions.
- Use readq() to read 64-bits at a time.
Rahul Lakkireddy (2):
cxgb4: rework on-chip memory read
cxgb4: speed up on-chip memory read
drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c | 86 ++++++++++- drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 5 + drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 193 ++++++++++++++++--------- 3 files changed, 211 insertions(+), 73 deletions(-)
Signature · 1 line
2.14.1
PATCH v2 1/2 cxgb4: rework on-chip memory read
Rework logic to read EDC and MC. Do 32-bit reads at a time.
---
v2:
- Dropped exporting callback to register AVX CPU intrinsic to do 256-bit reads at a time.
drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c | 67 ++++++++- drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 5 + drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 193 ++++++++++++++++--------- 3 files changed, 192 insertions(+), 73 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c +63 -4
@@ -878,6 +878,67 @@ static int cudbg_get_payload_range(struct adapter *padap, u8 mem_type, &payload->start, &payload->end); } +static int cudbg_memory_read (struct cudbg_init *pdbg_init,int win, +int mtype,u32 addr,u32 len,void *hbuf) +{ +u32 win_pf, memoffset, mem_aperture, mem_base; +struct adapter *adap = pdbg_init->adap; +u32 pos, offset, resid; +u32 *buf; +int ret; + +/* Argument sanity checks ... +*/ +if (addr &0x3 || (uintptr_t )hbuf &0x3 ) +return -EINVAL ; + + buf = (u32 *)hbuf; + +/* Try to do 32-bit reads. Residual will be handled later. */ + resid = len &0x3 ; + len -= resid; + + ret =t4_memory_rw_init (adap, win, mtype, &memoffset, &mem_base, + &mem_aperture); +if (ret) +return ret; + + addr = addr + memoffset; + win_pf =is_t4 (adap->params.chip) ?0 :PFNUM_V (adap->pf); + + pos = addr & ~(mem_aperture -1 ); + offset = addr - pos; + +/* Set up initial PCI-E Memory Window to cover the start of our +* transfer. +*/ +t4_memory_update_win (adap, win, pos | win_pf); + +/* Transfer data from the adapter */ +while (len >0 ) { + *buf++ =le32_to_cpu ((__force __le32 ) +t4_read_reg (adap, mem_base + offset)); + offset +=sizeof (u32); + len -=sizeof (u32); + +/* If we've reached the end of our current window aperture, +* move the PCI-E Memory Window on to the next. +*/ +if (offset == mem_aperture) { + pos += mem_aperture; + offset =0 ; +t4_memory_update_win (adap, win, pos | win_pf); + } + } + +/* Transfer residual */ +if (resid) +t4_memory_rw_residual (adap, resid, mem_base + offset, + (u8 *)buf,T4_MEMORY_READ ); + +return 0 ; +} +#define CUDBG_YIELD_ITERATION 256 static int cudbg_read_fw_mem(struct cudbg_init *pdbg_init,
@@ -937,10 +998,8 @@ static int cudbg_read_fw_mem(struct cudbg_init *pdbg_init, goto skip_read;spin_lock (&padap->win0_lock); - rc =t4_memory_rw (padap,MEMWIN_NIC , mem_type, - bytes_read, bytes, - (__be32 *)temp_buff.data, -1 ); + rc =cudbg_memory_read (pdbg_init,MEMWIN_NIC , mem_type, + bytes_read, bytes, temp_buff.data);spin_unlock (&padap->win0_lock);if (rc) { cudbg_err->sys_err = rc;
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +5 -0
@@ -1488,6 +1488,11 @@ u32 t4_read_pcie_cfg4(struct adapter *adap, int reg);u32 t4_get_util_window (struct adapter *adap);void t4_setup_memwin (struct adapter *adap,u32 memwin_base,u32 window); +int t4_memory_rw_init (struct adapter *adap,int win,int mtype,u32 *mem_off, +u32 *mem_base,u32 *mem_aperture); +void t4_memory_update_win (struct adapter *adap,int win,u32 addr); +void t4_memory_rw_residual (struct adapter *adap,u32 off,u32 addr,u8 *buf, +int dir);#define T4_MEMORY_WRITE 0#define T4_MEMORY_READ 1 int t4_memory_rw(struct adapter *adap, int win, int mtype, u32 addr, u32 len,
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +124 -69
237 lines not on this page · raw message
Signature · 1 line
2.14.1
PATCH v2 2/2 cxgb4: speed up on-chip memory read
In reply to Rahul LakkireddyUse readq() (via t4_read_reg64()) to read 64-bits at a time. Read residual in 32-bit multiples.
---
v2:
- Dropped AVX CPU intrinisc instructions.
- Use readq() (via t4_read_reg64()) to read 64-bits at a time.
drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c | 37 +++++++++++++++++++------- 1 file changed, 28 insertions(+), 9 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c +28 -9
@@ -884,7 +884,8 @@ static int cudbg_memory_read(struct cudbg_init *pdbg_init, int win,u32 win_pf, memoffset, mem_aperture, mem_base;struct adapter *adap = pdbg_init->adap;u32 pos, offset, resid; -u32 *buf; +u32 *res_buf; +u64 *buf;int ret;/* Argument sanity checks ...
@@ -892,10 +893,10 @@ static int cudbg_memory_read(struct cudbg_init *pdbg_init, int win,if (addr &0x3 || (uintptr_t )hbuf &0x3 )return -EINVAL ; - buf = (u32 *)hbuf; + buf = (u64 *)hbuf; -/* Try to do 32-bit reads. Residual will be handled later. */ - resid = len &0x3 ; +/* Try to do 64-bit reads. Residual will be handled later. */ + resid = len &0x7 ; len -= resid; ret = t4_memory_rw_init(adap, win, mtype, &memoffset, &mem_base,
@@ -916,10 +917,28 @@ static int cudbg_memory_read(struct cudbg_init *pdbg_init, int win,/* Transfer data from the adapter */ while (len >0 ) { - *buf++ =le32_to_cpu ((__force __le32 ) -t4_read_reg (adap, mem_base + offset)); + *buf++ =le64_to_cpu ((__force __le64 ) +t4_read_reg64 (adap, mem_base + offset)); + offset +=sizeof (u64); + len -=sizeof (u64); + +/* If we've reached the end of our current window aperture, +* move the PCI-E Memory Window on to the next. +*/ +if (offset == mem_aperture) { + pos += mem_aperture; + offset =0 ; +t4_memory_update_win (adap, win, pos | win_pf); + } + } + + res_buf = (u32 *)buf; +/* Read residual in 32-bit multiples */ +while (resid >sizeof (u32)) { + *res_buf++ =le32_to_cpu ((__force __le32 ) +t4_read_reg (adap, mem_base + offset)); offset +=sizeof (u32); - len -=sizeof (u32); + resid -=sizeof (u32);/* If we've reached the end of our current window aperture, * move the PCI-E Memory Window on to the next.
@@ -931,10 +950,10 @@ static int cudbg_memory_read(struct cudbg_init *pdbg_init, int win, } } -/* Transfer residual */ +/* Transfer residual < 32-bits */ if (resid)t4_memory_rw_residual (adap, resid, mem_base + offset, - (u8 *)buf,T4_MEMORY_READ ); + (u8 *)res_buf,T4_MEMORY_READ );return 0 ; }
Signature · 1 line
2.14.1
David Miller
maintainerFrom: Rahul Lakkireddy <[email protected]>
Date: Wed, 14 Feb 2018 12:56:26 +0530
Quoted 7 lines
This series of patches speed up reading on-chip memory (EDC and MC) by reading 64-bits at a time.
Patch 1 reworks logic to read EDC and MC.
Patch 2 adds logic to read EDC and MC 64-bits at a time.
Quoted 7 lines
Thanks,
Rahul---
v2:
- Dropped AVX CPU intrinsic instructions.
- Usereadq()to read 64-bits at a time.
This looks a lot better, much more portable.
Series applied, thanks.