public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [rtl8723bs] Remove unnecessary atomic operations for continual_io_error
@ 2026-01-19  8:06 2023060904
  2026-01-19  8:20 ` Greg KH
  2026-01-19  8:25 ` [PATCH] [rtl8723bs] Remove unnecessary atomic operations for continual_io_error Dan Carpenter
  0 siblings, 2 replies; 11+ messages in thread
From: 2023060904 @ 2026-01-19  8:06 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, linux-kernel, 2023060904, guagua210311

From: Changjun Zheng <guagua210311@qq.com>

continual_io_error is only accessed in SDIO IO single execution flow,
no multi-thread race condition exists, so atomic operations are redundant.
Change atomic_t to s32 and replace atomic_inc_return/atomic_set with normal ops.

Signed-off-by: Changjun Zheng <guagua210311@qq.com>
---
 drivers/staging/rtl8723bs/core/rtw_io.c       | 16 ++++++++++++----
 drivers/staging/rtl8723bs/include/drv_types.h |  2 +-
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_io.c b/drivers/staging/rtl8723bs/core/rtw_io.c
index fe9f94001eed..95d42025807e 100644
--- a/drivers/staging/rtl8723bs/core/rtw_io.c
+++ b/drivers/staging/rtl8723bs/core/rtw_io.c
@@ -135,11 +135,15 @@ int rtw_init_io_priv(struct adapter *padapter, void (*set_intf_ops)(struct adapt
 /*
  * Increase and check if the continual_io_error of this @param dvobjprive is larger than MAX_CONTINUAL_IO_ERR
  * @return true:
- * @return false:
+ * @return false:
+
+ * Note: Original implementation used atomic_inc_return for atomic increment.
+ * Reason for change: continual_io_error is only accessed in SDIO IO single execution flow,
+ * no race condition, so normal increment is safe (remove redundant atomic operation).
  */
 int rtw_inc_and_chk_continual_io_error(struct dvobj_priv *dvobj)
 {
-	int error_count = atomic_inc_return(&dvobj->continual_io_error);
+	s32 error_count = ++dvobj->continual_io_error;
 
 	if (error_count > MAX_CONTINUAL_IO_ERR)
 		return true;
@@ -147,8 +151,12 @@ int rtw_inc_and_chk_continual_io_error(struct dvobj_priv *dvobj)
 	return false;
 }
 
-/* Set the continual_io_error of this @param dvobjprive to 0 */
+/* Set the continual_io_error of this @param dvobjprive to 0
+ * Note: Original implementation used atomic_set for atomic assignment.
+ * Reason for change: continual_io_error is only accessed in SDIO IO single execution flow,
+ * no race condition, so normal assignment is safe (remove redundant atomic operation).
+ */
 void rtw_reset_continual_io_error(struct dvobj_priv *dvobj)
 {
-	atomic_set(&dvobj->continual_io_error, 0);
+	dvobj->continual_io_error = 0;
 }
diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h
index f86180dc350c..9112ee5f80ca 100644
--- a/drivers/staging/rtl8723bs/include/drv_types.h
+++ b/drivers/staging/rtl8723bs/include/drv_types.h
@@ -279,7 +279,7 @@ struct dvobj_priv {
 	u8 Queue2Pipe[HW_QUEUE_ENTRY];/* for out pipe mapping */
 
 	u8 irq_alloc;
-	atomic_t continual_io_error;
+	s32 continual_io_error;
 
 	atomic_t disable_func;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-01-21 13:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-19  8:06 [PATCH] [rtl8723bs] Remove unnecessary atomic operations for continual_io_error 2023060904
2026-01-19  8:20 ` Greg KH
2026-01-20 14:11   ` [PATCH v2 1/2] rtl8723bs: Refactor continual_io_error check 2023060904
2026-01-20 14:34     ` Greg KH
2026-01-21 13:22     ` Dan Carpenter
2026-01-21 13:27       ` Greg KH
     [not found]   ` <20260120141129.8262-1-2023060904@ycu.edu.cn>
2026-01-20 14:11     ` [PATCH v2 2/2] rtl8723bs: Replace atomic ops with normal vars 2023060904
2026-01-19  8:25 ` [PATCH] [rtl8723bs] Remove unnecessary atomic operations for continual_io_error Dan Carpenter
2026-01-20 13:39   ` 2023060904
2026-01-20 14:05     ` Greg KH
2026-01-20 14:18     ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox