Skip to contentSkip to conversation

staging: r8188eu: remove unused members of struct xmit_buf

PATCH In review Ivan Safonov 3 participants 7 messages Jul 12, 2020 – Jul 13, 2020 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: r8188eu: remove unused members of struct xmit_buf

Remove unused members of struct xmit_buf: alloc_sz, ff_hwaddr, dma_transfer_addr, bpending and last.

---
 drivers/staging/rtl8188eu/include/rtw_xmit.h  | 5 -----
 drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 1 -
 2 files changed, 6 deletions(-)
drivers/staging/rtl8188eu/include/rtw_xmit.h +0 -5
index 12d16e98176a..3c03987c81a1 100644
@@ -193,14 +193,9 @@ struct xmit_buf {
 	void *priv_data;
 	u16 ext_tag; /*  0: Normal xmitbuf, 1: extension xmitbuf. */
 	u16 flags;
-	u32 alloc_sz;
 	u32  len;
 	struct submit_ctx *sctx;
-	u32	ff_hwaddr;
 	struct urb *pxmit_urb[8];
-	dma_addr_t dma_transfer_addr;	/* (in) dma addr for transfer_buffer */
-	u8 bpending[8];
-	int last[8];
 };
 
 struct xmit_frame {
drivers/staging/rtl8188eu/os_dep/xmit_linux.c +0 -1
index 017e1d628461..61ced1160951 100644
@@ -24,7 +24,6 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter,
 		return _FAIL;
 
 	pxmitbuf->pbuf = PTR_ALIGN(pxmitbuf->pallocated_buf, XMITBUF_ALIGN_SZ);
-	pxmitbuf->dma_transfer_addr = 0;
 
 	for (i = 0; i < 8; i++) {
 		pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
Signature · 1 line
2.26.2
#1 lore raw
Quoted 5 lines · Ivan Safonov

Remove unused members of struct xmit_buf: alloc_sz, ff_hwaddr, dma_transfer_addr, bpending and last.

---

Have you tested this change? Previously with this driver, an unused quantity was removed from one of the structs and the driver failed. Apparently, the alignment of some other quantity was affected. I do not think that this change would have that affect; however, you should be testing whenever the changes are more than cosmetic.

Larry

#2 lore raw
Quoted 11 lines · Larry Finger
Quoted 5 lines · Ivan Safonov

Remove unused members of struct xmit_buf: alloc_sz, ff_hwaddr, dma_transfer_addr, bpending and last.

---

Have you tested this change? Previously with this driver, an unused quantity was removed from one of the structs and the driver failed. Apparently, the alignment of some other quantity was affected. I do not think that this change would have that affect; however, you should be testing whenever the changes are more than cosmetic.

Larry

I have not tested this patch.

Ivan.

#3 lore raw
In reply to Ivan Safonov
Quoted 33 lines · Ivan Safonov

Remove unused members of struct xmit_buf: alloc_sz, ff_hwaddr, dma_transfer_addr, bpending and last.

---
 drivers/staging/rtl8188eu/include/rtw_xmit.h  | 5 -----
 drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 1 -
 2 files changed, 6 deletions(-)
drivers/staging/rtl8188eu/include/rtw_xmit.h +0 -5
index 12d16e98176a..3c03987c81a1 100644
@@ -193,14 +193,9 @@ struct xmit_buf {
 	void *priv_data;
 	u16 ext_tag; /*  0: Normal xmitbuf, 1: extension xmitbuf. */
 	u16 flags;
-	u32 alloc_sz;
 	u32  len;
 	struct submit_ctx *sctx;
-	u32	ff_hwaddr;
 	struct urb *pxmit_urb[8];
-	dma_addr_t dma_transfer_addr;	/* (in) dma addr for transfer_buffer */
-	u8 bpending[8];
-	int last[8];
 };
 
 struct xmit_frame {
drivers/staging/rtl8188eu/os_dep/xmit_linux.c +0 -0
index 017e1d628461..61ced1160951 100644

drivers/staging/rtl8188eu/os_dep/xmit_linux.c int rtw_os_xmit_resource_alloc(struct adapter *padapter, · line 26

Quoted 3 lines
drivers/staging/rtl8188eu/os_dep/xmit_linux.c +0 -0
@@ -24,7 +24,6 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter,
 		return _FAIL;
 
 	pxmitbuf->pbuf = PTR_ALIGN(pxmitbuf->pallocated_buf, XMITBUF_ALIGN_SZ);

Not related to this patch but kmalloc always returns data which is at least ARCH_KMALLOC_MINALIGN aligned which is never less than XMITBUF_ALIGN_SZ (4) so this is a no-op.

drivers/staging/rtl8188eu/os_dep/xmit_linux.c int rtw_os_xmit_resource_alloc(struct adapter *padapter, · line 27

Quoted 1 line
drivers/staging/rtl8188eu/os_dep/xmit_linux.c +0 -1
-	pxmitbuf->dma_transfer_addr = 0;

regards,
dan carpenter

#4 lore raw
Quoted 36 lines · Dan Carpenter
Quoted 35 lines · Ivan Safonov

Remove unused members of struct xmit_buf: alloc_sz, ff_hwaddr, dma_transfer_addr, bpending and last.

---
 drivers/staging/rtl8188eu/include/rtw_xmit.h  | 5 -----
 drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 1 -
 2 files changed, 6 deletions(-)
drivers/staging/rtl8188eu/include/rtw_xmit.h +0 -5
index 12d16e98176a..3c03987c81a1 100644
@@ -193,14 +193,9 @@ struct xmit_buf {
 	void *priv_data;
 	u16 ext_tag; /*  0: Normal xmitbuf, 1: extension xmitbuf. */
 	u16 flags;
-	u32 alloc_sz;
 	u32  len;
 	struct submit_ctx *sctx;
-	u32	ff_hwaddr;
 	struct urb *pxmit_urb[8];
-	dma_addr_t dma_transfer_addr;	/* (in) dma addr for transfer_buffer */
-	u8 bpending[8];
-	int last[8];
 };
 
 struct xmit_frame {
drivers/staging/rtl8188eu/os_dep/xmit_linux.c +0 -0
index 017e1d628461..61ced1160951 100644
@@ -24,7 +24,6 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter,
 		return _FAIL;
 
Quoted 5 lines

drivers/staging/rtl8188eu/os_dep/xmit_linux.c int rtw_os_xmit_resource_alloc(struct adapter *padapter, · line 26

Quoted 1 line
drivers/staging/rtl8188eu/os_dep/xmit_linux.c +0 -0
 	pxmitbuf->pbuf = PTR_ALIGN(pxmitbuf->pallocated_buf, XMITBUF_ALIGN_SZ);

Not related to this patch but kmalloc always returns data which is at least ARCH_KMALLOC_MINALIGN aligned which is never less than XMITBUF_ALIGN_SZ (4) so this is a no-op.

The alignment in the driver is pretty crazy because it's all unnecessary and so complicated. Every allocation is 4 bytes extra so we can align it later.

Also every buffer is called "pbuf" which stands for pointer to buffer. "pallocated_buf" is not really useful either.

I tried to look at this to see if we could change the alignment, and it's complicated because of the naming and the alignment.

regards,
dan carpenter

#5 lore raw
Quoted 37 lines · Dan Carpenter
Quoted 36 lines · Dan Carpenter
Quoted 35 lines · Ivan Safonov

Remove unused members of struct xmit_buf: alloc_sz, ff_hwaddr, dma_transfer_addr, bpending and last.

---
  drivers/staging/rtl8188eu/include/rtw_xmit.h  | 5 -----
  drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 1 -
  2 files changed, 6 deletions(-)
drivers/staging/rtl8188eu/include/rtw_xmit.h +0 -5
index 12d16e98176a..3c03987c81a1 100644
@@ -193,14 +193,9 @@ struct xmit_buf {
  	void *priv_data;
  	u16 ext_tag; /*  0: Normal xmitbuf, 1: extension xmitbuf. */
  	u16 flags;
-	u32 alloc_sz;
  	u32  len;
  	struct submit_ctx *sctx;
-	u32	ff_hwaddr;
  	struct urb *pxmit_urb[8];
-	dma_addr_t dma_transfer_addr;	/* (in) dma addr for transfer_buffer */
-	u8 bpending[8];
-	int last[8];
  };
 
  struct xmit_frame {
drivers/staging/rtl8188eu/os_dep/xmit_linux.c +0 -0
index 017e1d628461..61ced1160951 100644
@@ -24,7 +24,6 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter,
  		return _FAIL;
 
Quoted 5 lines
Quoted 5 lines

drivers/staging/rtl8188eu/os_dep/xmit_linux.c int rtw_os_xmit_resource_alloc(struct adapter *padapter, · line 26

Quoted 1 line
drivers/staging/rtl8188eu/os_dep/xmit_linux.c +0 -0
  	pxmitbuf->pbuf = PTR_ALIGN(pxmitbuf->pallocated_buf, XMITBUF_ALIGN_SZ);

Not related to this patch but kmalloc always returns data which is at least ARCH_KMALLOC_MINALIGN aligned which is never less than XMITBUF_ALIGN_SZ (4) so this is a no-op.

4-byte alignment for 8-byte pointer (for example void *priv_data) on 64-bit arch is an _error_. It’s good that kmalloc (and vmalloc) is already aligned to 8 bytes.

Quoted 5 lines

The alignment in the driver is pretty crazy because it's all unnecessary and so complicated. Every allocation is 4 bytes extra so we can align it later.

Quoted 9 lines

Also every buffer is called "pbuf" which stands for pointer to buffer. "pallocated_buf" is not really useful either.

I tried to look at this to see if we could change the alignment, and it's complicated because of the naming and the alignment.

regards,
dan carpenter

I have already fixed 4 places with unnecessary alignment, but, alas, there is no great desire to test them on real hardware.

Ivan.

Acked-by
#6 lore raw
Quoted 52 lines · Ivan Safonov
Quoted 32 lines · Dan Carpenter
Quoted 31 lines · Dan Carpenter
Quoted 30 lines · Ivan Safonov

Remove unused members of struct xmit_buf: alloc_sz, ff_hwaddr, dma_transfer_addr, bpending and last.

---
  drivers/staging/rtl8188eu/include/rtw_xmit.h  | 5 ----- drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 1 -

  2 files changed, 6 deletions(-)
drivers/staging/rtl8188eu/include/rtw_xmit.h +0 -0
index 12d16e98176a..3c03987c81a1 100644
@@ -193,14 +193,9 @@ struct xmit_buf {
       void *priv_data;

      u16 ext_tag; /*  0: Normal xmitbuf, 1: extension xmitbuf. */ u16 flags;
-    u32 alloc_sz;
      u32  len;
      struct submit_ctx *sctx;
-    u32    ff_hwaddr;
      struct urb *pxmit_urb[8];
-    dma_addr_t dma_transfer_addr;    /* (in) dma addr for transfer_buffer */ -    u8 bpending[8];
-    int last[8];
  };
  struct xmit_frame {

drivers/staging/rtl8188eu/os_dep/xmit_linux.c +0 -1
index 017e1d628461..61ced1160951 100644
--- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
Quoted 8 lines
Quoted 8 lines

drivers/staging/rtl8188eu/os_dep/xmit_linux.c int rtw_os_xmit_resource_alloc(struct adapter *padapter, · line 25

Quoted 4 lines

+++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c

drivers/staging/rtl8188eu/os_dep/xmit_linux.c +0 -0
@@ -24,7 +24,6 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter,
           return _FAIL;
       pxmitbuf->pbuf = PTR_ALIGN(pxmitbuf->pallocated_buf, XMITBUF_ALIGN_SZ);

Not related to this patch but kmalloc always returns data which is at least ARCH_KMALLOC_MINALIGN aligned which is never less than XMITBUF_ALIGN_SZ (4) so this is a no-op.

4-byte alignment for 8-byte pointer (for example void *priv_data) on 64-bit arch is an _error_. It’s good that kmalloc (and vmalloc) is already aligned to 8 bytes.

Quoted 8 lines

The alignment in the driver is pretty crazy because it's all unnecessary and so complicated.  Every allocation is 4 bytes extra so we can align it later.

Also every buffer is called "pbuf" which stands for pointer to buffer. "pallocated_buf" is not really useful either.

Quoted 8 lines
Quoted 6 lines

I tried to look at this to see if we could change the alignment, and it's complicated because of the naming and the alignment.

regards,
dan carpenter

I have already fixed 4 places with unnecessary alignment, but, alas, there is no great desire to test them on real hardware.

I have now tested on real hardware and it works fine.

Larry