linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] wifi: ath9k: cleanup ath_txq_skb_done()
@ 2024-12-09 15:50 Dmitry Antipov
  2024-12-09 15:50 ` [PATCH 2/3] wifi: ath9k: cleanup a few (mostly) TX-related routines Dmitry Antipov
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Dmitry Antipov @ 2024-12-09 15:50 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen
  Cc: Kalle Valo, linux-wireless, lvc-project, Dmitry Antipov

Since 'txq' argument of 'ath_txq_skb_done()' is actually
(mis|un)used, convert the former to local variable and
adjust all related users. Compile tested only.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 drivers/net/wireless/ath/ath9k/xmit.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 35aa47a9db90..fae96e3d66dd 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -208,10 +208,10 @@ static void ath_set_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta,
 				       ARRAY_SIZE(bf->rates));
 }
 
-static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
-			     struct sk_buff *skb)
+static void ath_txq_skb_done(struct ath_softc *sc, struct sk_buff *skb)
 {
 	struct ath_frame_info *fi = get_frame_info(skb);
+	struct ath_txq *txq;
 	int q = fi->txq;
 
 	if (q < 0)
@@ -294,7 +294,7 @@ static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
 		fi = get_frame_info(skb);
 		bf = fi->bf;
 		if (!bf) {
-			ath_txq_skb_done(sc, txq, skb);
+			ath_txq_skb_done(sc, skb);
 			ieee80211_free_txskb(sc->hw, skb);
 			continue;
 		}
@@ -962,7 +962,7 @@ ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq,
 			bf->bf_state.stale = false;
 
 		if (!bf) {
-			ath_txq_skb_done(sc, txq, skb);
+			ath_txq_skb_done(sc, skb);
 			ieee80211_free_txskb(sc->hw, skb);
 			continue;
 		}
@@ -2379,7 +2379,7 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
 
 	bf = ath_tx_setup_buffer(sc, txq, tid, skb);
 	if (!bf) {
-		ath_txq_skb_done(sc, txq, skb);
+		ath_txq_skb_done(sc, skb);
 		if (txctl->paprd)
 			dev_kfree_skb_any(skb);
 		else
@@ -2514,7 +2514,7 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
 	}
 	spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
 
-	ath_txq_skb_done(sc, txq, skb);
+	ath_txq_skb_done(sc, skb);
 	tx_info->status.status_driver_data[0] = sta;
 	__skb_queue_tail(&txq->complete_q, skb);
 }
-- 
2.47.1


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

* [PATCH 2/3] wifi: ath9k: cleanup a few (mostly) TX-related routines
  2024-12-09 15:50 [PATCH 1/3] wifi: ath9k: cleanup ath_txq_skb_done() Dmitry Antipov
@ 2024-12-09 15:50 ` Dmitry Antipov
  2024-12-10  9:59   ` Toke Høiland-Jørgensen
  2024-12-09 15:50 ` [PATCH 3/3] wifi: ath9k: simplify internal time management Dmitry Antipov
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Dmitry Antipov @ 2024-12-09 15:50 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen
  Cc: Kalle Valo, linux-wireless, lvc-project, Dmitry Antipov

Remove unused 'struct ath_softc *' argument of 'ath_pkt_duration()',
'ath_tx_update_baw()', 'ath_get_skb_tid()', 'ath_tx_addto_baw()' and
'ath_tx_count_frames()', adjust related users. Compile tested only.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 drivers/net/wireless/ath/ath9k/ath9k.h |  4 +--
 drivers/net/wireless/ath/ath9k/recv.c  |  4 +--
 drivers/net/wireless/ath/ath9k/xmit.c  | 40 ++++++++++++--------------
 3 files changed, 22 insertions(+), 26 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 29ca65a732a6..f68b96809ffa 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -592,8 +592,8 @@ void ath_txq_schedule_all(struct ath_softc *sc);
 int ath_tx_init(struct ath_softc *sc, int nbufs);
 int ath_txq_update(struct ath_softc *sc, int qnum,
 		   struct ath9k_tx_queue_info *q);
-u32 ath_pkt_duration(struct ath_softc *sc, u8 rix, int pktlen,
-		     int width, int half_gi, bool shortPreamble);
+u32 ath_pkt_duration(u8 rix, int pktlen, int width,
+		     int half_gi, bool shortPreamble);
 void ath_update_max_aggr_framelen(struct ath_softc *sc, int queue, int txop);
 void ath_assign_seq(struct ath_common *common, struct sk_buff *skb);
 int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index 0c0624a3b40d..34c74ed99b7b 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -1042,8 +1042,8 @@ static void ath_rx_count_airtime(struct ath_softc *sc,
 	if (!!(rxs->encoding == RX_ENC_HT)) {
 		/* MCS rates */
 
-		airtime += ath_pkt_duration(sc, rxs->rate_idx, len,
-					is_40, is_sgi, is_sp);
+		airtime += ath_pkt_duration(rxs->rate_idx, len,
+					    is_40, is_sgi, is_sp);
 	} else {
 
 		phy = IS_CCK_RATE(rs->rs_rate) ? WLAN_RC_PHY_CCK : WLAN_RC_PHY_OFDM;
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index fae96e3d66dd..8242139051ef 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -67,8 +67,7 @@ static void ath_tx_txqaddbuf(struct ath_softc *sc, struct ath_txq *txq,
 static void ath_tx_rc_status(struct ath_softc *sc, struct ath_buf *bf,
 			     struct ath_tx_status *ts, int nframes, int nbad,
 			     int txok);
-static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
-			      struct ath_buf *bf);
+static void ath_tx_update_baw(struct ath_atx_tid *tid, struct ath_buf *bf);
 static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,
 					   struct ath_txq *txq,
 					   struct ath_atx_tid *tid,
@@ -224,7 +223,7 @@ static void ath_txq_skb_done(struct ath_softc *sc, struct sk_buff *skb)
 }
 
 static struct ath_atx_tid *
-ath_get_skb_tid(struct ath_softc *sc, struct ath_node *an, struct sk_buff *skb)
+ath_get_skb_tid(struct ath_node *an, struct sk_buff *skb)
 {
 	u8 tidno = skb->priority & IEEE80211_QOS_CTL_TID_MASK;
 	return ATH_AN_2_TID(an, tidno);
@@ -300,7 +299,7 @@ static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
 		}
 
 		if (fi->baw_tracked) {
-			ath_tx_update_baw(sc, tid, bf);
+			ath_tx_update_baw(tid, bf);
 			sendbar = true;
 		}
 
@@ -315,8 +314,7 @@ static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
 	}
 }
 
-static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
-			      struct ath_buf *bf)
+static void ath_tx_update_baw(struct ath_atx_tid *tid, struct ath_buf *bf)
 {
 	struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
 	u16 seqno = bf->bf_state.seqno;
@@ -338,8 +336,7 @@ static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
 	}
 }
 
-static void ath_tx_addto_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
-			     struct ath_buf *bf)
+static void ath_tx_addto_baw(struct ath_atx_tid *tid, struct ath_buf *bf)
 {
 	struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
 	u16 seqno = bf->bf_state.seqno;
@@ -452,9 +449,8 @@ static struct ath_buf* ath_clone_txbuf(struct ath_softc *sc, struct ath_buf *bf)
 	return tbf;
 }
 
-static void ath_tx_count_frames(struct ath_softc *sc, struct ath_buf *bf,
-			        struct ath_tx_status *ts, int txok,
-			        int *nframes, int *nbad)
+static void ath_tx_count_frames(struct ath_buf *bf, struct ath_tx_status *ts,
+				int txok, int *nframes, int *nbad)
 {
 	u16 seq_st = 0;
 	u32 ba[WME_BA_BMP_SIZE >> 5];
@@ -568,7 +564,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
 
 	__skb_queue_head_init(&bf_pending);
 
-	ath_tx_count_frames(sc, bf, ts, txok, &nframes, &nbad);
+	ath_tx_count_frames(bf, ts, txok, &nframes, &nbad);
 	while (bf) {
 		u16 seqno = bf->bf_state.seqno;
 
@@ -621,7 +617,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
 			 * complete the acked-ones/xretried ones; update
 			 * block-ack window
 			 */
-			ath_tx_update_baw(sc, tid, bf);
+			ath_tx_update_baw(tid, bf);
 
 			if (rc_update && (acked_cnt == 1 || txfail_cnt == 1)) {
 				memcpy(tx_info->control.rates, rates, sizeof(rates));
@@ -651,7 +647,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
 				 * run out of tx buf.
 				 */
 				if (!tbf) {
-					ath_tx_update_baw(sc, tid, bf);
+					ath_tx_update_baw(tid, bf);
 
 					ath_tx_complete_buf(sc, bf, txq,
 							    &bf_head, NULL, ts,
@@ -752,7 +748,7 @@ static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq,
 	sta = ieee80211_find_sta_by_ifaddr(hw, hdr->addr1, hdr->addr2);
 	if (sta) {
 		struct ath_node *an = (struct ath_node *)sta->drv_priv;
-		tid = ath_get_skb_tid(sc, an, bf->bf_mpdu);
+		tid = ath_get_skb_tid(an, bf->bf_mpdu);
 		ath_tx_count_airtime(sc, sta, bf, ts, tid->tidno);
 		if (ts->ts_status & (ATH9K_TXERR_FILT | ATH9K_TXERR_XRETRY))
 			tid->clear_ps_filter = true;
@@ -1012,13 +1008,13 @@ ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq,
 
 			INIT_LIST_HEAD(&bf_head);
 			list_add(&bf->list, &bf_head);
-			ath_tx_update_baw(sc, tid, bf);
+			ath_tx_update_baw(tid, bf);
 			ath_tx_complete_buf(sc, bf, txq, &bf_head, NULL, &ts, 0);
 			continue;
 		}
 
 		if (bf_isampdu(bf))
-			ath_tx_addto_baw(sc, tid, bf);
+			ath_tx_addto_baw(tid, bf);
 
 		break;
 	}
@@ -1114,8 +1110,8 @@ ath_tx_form_aggr(struct ath_softc *sc, struct ath_txq *txq,
  * width  - 0 for 20 MHz, 1 for 40 MHz
  * half_gi - to use 4us v/s 3.6 us for symbol time
  */
-u32 ath_pkt_duration(struct ath_softc *sc, u8 rix, int pktlen,
-		     int width, int half_gi, bool shortPreamble)
+u32 ath_pkt_duration(u8 rix, int pktlen, int width,
+		     int half_gi, bool shortPreamble)
 {
 	u32 nbits, nsymbits, duration, nsymbols;
 	int streams;
@@ -1327,7 +1323,7 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf,
 			info->rates[i].Rate = rix | 0x80;
 			info->rates[i].ChSel = ath_txchainmask_reduction(sc,
 					ah->txchainmask, info->rates[i].Rate);
-			info->rates[i].PktDuration = ath_pkt_duration(sc, rix, len,
+			info->rates[i].PktDuration = ath_pkt_duration(rix, len,
 				 is_40, is_sgi, is_sp);
 			if (rix < 8 && (tx_info->flags & IEEE80211_TX_CTL_STBC))
 				info->rates[i].RateFlags |= ATH9K_RATESERIES_STBC;
@@ -2122,7 +2118,7 @@ static void ath_tx_send_normal(struct ath_softc *sc, struct ath_txq *txq,
 	bf->bf_state.bf_type = 0;
 	if (tid && (tx_info->flags & IEEE80211_TX_CTL_AMPDU)) {
 		bf->bf_state.bf_type = BUF_AMPDU;
-		ath_tx_addto_baw(sc, tid, bf);
+		ath_tx_addto_baw(tid, bf);
 	}
 
 	bf->bf_next = NULL;
@@ -2368,7 +2364,7 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
 
 	if (txctl->sta) {
 		an = (struct ath_node *) sta->drv_priv;
-		tid = ath_get_skb_tid(sc, an, skb);
+		tid = ath_get_skb_tid(an, skb);
 	}
 
 	ath_txq_lock(sc, txq);
-- 
2.47.1


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

* [PATCH 3/3] wifi: ath9k: simplify internal time management
  2024-12-09 15:50 [PATCH 1/3] wifi: ath9k: cleanup ath_txq_skb_done() Dmitry Antipov
  2024-12-09 15:50 ` [PATCH 2/3] wifi: ath9k: cleanup a few (mostly) TX-related routines Dmitry Antipov
@ 2024-12-09 15:50 ` Dmitry Antipov
  2024-12-10  9:58   ` Toke Høiland-Jørgensen
  2024-12-10  9:59 ` [PATCH 1/3] wifi: ath9k: cleanup ath_txq_skb_done() Toke Høiland-Jørgensen
  2024-12-19 17:54 ` Jeff Johnson
  3 siblings, 1 reply; 11+ messages in thread
From: Dmitry Antipov @ 2024-12-09 15:50 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen
  Cc: Kalle Valo, linux-wireless, lvc-project, Dmitry Antipov

Prefer 'ktime_t' over 'struct timespec64' for 'struct ath_chanctx' and
'struct ath_softc' timestamps, choose standard kernel time API over an
ad-hoc math in 'chanctx_event_delta()' and 'ath9k_hw_get_tsf_offset()',
adjust related users. Compile tested only.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 drivers/net/wireless/ath/ath9k/ath9k.h   |  4 ++--
 drivers/net/wireless/ath/ath9k/beacon.c  |  2 +-
 drivers/net/wireless/ath/ath9k/channel.c | 29 ++++++++++--------------
 drivers/net/wireless/ath/ath9k/hw.c      | 25 +++++++-------------
 drivers/net/wireless/ath/ath9k/hw.h      |  2 +-
 drivers/net/wireless/ath/ath9k/main.c    | 12 ++++------
 6 files changed, 29 insertions(+), 45 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index f68b96809ffa..ac70036f7f69 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -338,7 +338,7 @@ struct ath_chanctx {
 
 	struct ath_beacon_config beacon;
 	struct ath9k_hw_cal_data caldata;
-	struct timespec64 tsf_ts;
+	ktime_t tsf_ts;
 	u64 tsf_val;
 	u32 last_beacon;
 
@@ -1011,7 +1011,7 @@ struct ath_softc {
 	struct ath_offchannel offchannel;
 	struct ath_chanctx *next_chan;
 	struct completion go_beacon;
-	struct timespec64 last_event_time;
+	ktime_t last_event_time;
 #endif
 
 	unsigned long driver_data;
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
index b399a7926ef5..4a27e3753c03 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -293,7 +293,7 @@ void ath9k_beacon_ensure_primary_slot(struct ath_softc *sc)
 	/* Modify TSF as required and update the HW. */
 	avp->chanctx->tsf_val += tsfadjust;
 	if (sc->cur_chan == avp->chanctx) {
-		offset = ath9k_hw_get_tsf_offset(&avp->chanctx->tsf_ts, NULL);
+		offset = ath9k_hw_get_tsf_offset(avp->chanctx->tsf_ts, 0);
 		ath9k_hw_settsf64(sc->sc_ah, avp->chanctx->tsf_val + offset);
 	}
 
diff --git a/drivers/net/wireless/ath/ath9k/channel.c b/drivers/net/wireless/ath/ath9k/channel.c
index 571062f2e82a..499bbf042906 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -232,16 +232,11 @@ static const char *chanctx_state_string(enum ath_chanctx_state state)
 
 static u32 chanctx_event_delta(struct ath_softc *sc)
 {
-	u64 ms;
-	struct timespec64 ts, *old;
+	ktime_t ts = ktime_get_raw();
+	s64 ms = ktime_ms_delta(ts, sc->last_event_time);
 
-	ktime_get_raw_ts64(&ts);
-	old = &sc->last_event_time;
-	ms = ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
-	ms -= old->tv_sec * 1000 + old->tv_nsec / 1000000;
 	sc->last_event_time = ts;
-
-	return (u32)ms;
+	return ms;
 }
 
 void ath_chanctx_check_active(struct ath_softc *sc, struct ath_chanctx *ctx)
@@ -334,8 +329,8 @@ ath_chanctx_get_next(struct ath_softc *sc, struct ath_chanctx *ctx)
 static void ath_chanctx_adjust_tbtt_delta(struct ath_softc *sc)
 {
 	struct ath_chanctx *prev, *cur;
-	struct timespec64 ts;
 	u32 cur_tsf, prev_tsf, beacon_int;
+	ktime_t ts;
 	s32 offset;
 
 	beacon_int = TU_TO_USEC(sc->cur_chan->beacon.beacon_interval);
@@ -346,12 +341,12 @@ static void ath_chanctx_adjust_tbtt_delta(struct ath_softc *sc)
 	if (!prev->switch_after_beacon)
 		return;
 
-	ktime_get_raw_ts64(&ts);
+	ts = ktime_get_raw();
 	cur_tsf = (u32) cur->tsf_val +
-		  ath9k_hw_get_tsf_offset(&cur->tsf_ts, &ts);
+		  ath9k_hw_get_tsf_offset(cur->tsf_ts, ts);
 
 	prev_tsf = prev->last_beacon - (u32) prev->tsf_val + cur_tsf;
-	prev_tsf -= ath9k_hw_get_tsf_offset(&prev->tsf_ts, &ts);
+	prev_tsf -= ath9k_hw_get_tsf_offset(prev->tsf_ts, ts);
 
 	/* Adjust the TSF time of the AP chanctx to keep its beacons
 	 * at half beacon interval offset relative to the STA chanctx.
@@ -691,7 +686,7 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
 		 */
 		tsf_time = sc->sched.switch_start_time;
 		tsf_time -= (u32) sc->cur_chan->tsf_val +
-			ath9k_hw_get_tsf_offset(&sc->cur_chan->tsf_ts, NULL);
+			ath9k_hw_get_tsf_offset(sc->cur_chan->tsf_ts, 0);
 		tsf_time += ath9k_hw_gettsf32(ah);
 
 		sc->sched.beacon_adjust = false;
@@ -1230,10 +1225,10 @@ void ath_chanctx_set_next(struct ath_softc *sc, bool force)
 {
 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 	struct ath_chanctx *old_ctx;
-	struct timespec64 ts;
 	bool measure_time = false;
 	bool send_ps = false;
 	bool queues_stopped = false;
+	ktime_t ts;
 
 	spin_lock_bh(&sc->chan_lock);
 	if (!sc->next_chan) {
@@ -1260,7 +1255,7 @@ void ath_chanctx_set_next(struct ath_softc *sc, bool force)
 		spin_unlock_bh(&sc->chan_lock);
 
 		if (sc->next_chan == &sc->offchannel.chan) {
-			ktime_get_raw_ts64(&ts);
+			ts = ktime_get_raw();
 			measure_time = true;
 		}
 
@@ -1277,7 +1272,7 @@ void ath_chanctx_set_next(struct ath_softc *sc, bool force)
 		spin_lock_bh(&sc->chan_lock);
 
 		if (sc->cur_chan != &sc->offchannel.chan) {
-			ktime_get_raw_ts64(&sc->cur_chan->tsf_ts);
+			sc->cur_chan->tsf_ts = ktime_get_raw();
 			sc->cur_chan->tsf_val = ath9k_hw_gettsf64(sc->sc_ah);
 		}
 	}
@@ -1303,7 +1298,7 @@ void ath_chanctx_set_next(struct ath_softc *sc, bool force)
 		ath_set_channel(sc);
 		if (measure_time)
 			sc->sched.channel_switch_time =
-				ath9k_hw_get_tsf_offset(&ts, NULL);
+				ath9k_hw_get_tsf_offset(ts, 0);
 		/*
 		 * A reset will ensure that all queues are woken up,
 		 * so there is no need to awaken them again.
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index e2bef099adb3..81983062705c 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -1847,20 +1847,11 @@ static int ath9k_hw_do_fastcc(struct ath_hw *ah, struct ath9k_channel *chan)
 	return -EINVAL;
 }
 
-u32 ath9k_hw_get_tsf_offset(struct timespec64 *last, struct timespec64 *cur)
+u32 ath9k_hw_get_tsf_offset(ktime_t last, ktime_t cur)
 {
-	struct timespec64 ts;
-	s64 usec;
-
-	if (!cur) {
-		ktime_get_raw_ts64(&ts);
-		cur = &ts;
-	}
-
-	usec = cur->tv_sec * 1000000ULL + cur->tv_nsec / 1000;
-	usec -= last->tv_sec * 1000000ULL + last->tv_nsec / 1000;
-
-	return (u32) usec;
+	if (cur == 0)
+		cur = ktime_get_raw();
+	return ktime_us_delta(cur, last);
 }
 EXPORT_SYMBOL(ath9k_hw_get_tsf_offset);
 
@@ -1871,7 +1862,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
 	u32 saveLedState;
 	u32 saveDefAntenna;
 	u32 macStaId1;
-	struct timespec64 tsf_ts;
+	ktime_t tsf_ts;
 	u32 tsf_offset;
 	u64 tsf = 0;
 	int r;
@@ -1917,7 +1908,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
 	macStaId1 = REG_READ(ah, AR_STA_ID1) & AR_STA_ID1_BASE_RATE_11B;
 
 	/* Save TSF before chip reset, a cold reset clears it */
-	ktime_get_raw_ts64(&tsf_ts);
+	tsf_ts = ktime_get_raw();
 	tsf = ath9k_hw_gettsf64(ah);
 
 	saveLedState = REG_READ(ah, AR_CFG_LED) &
@@ -1951,7 +1942,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
 	}
 
 	/* Restore TSF */
-	tsf_offset = ath9k_hw_get_tsf_offset(&tsf_ts, NULL);
+	tsf_offset = ath9k_hw_get_tsf_offset(tsf_ts, 0);
 	ath9k_hw_settsf64(ah, tsf + tsf_offset);
 
 	if (AR_SREV_9280_20_OR_LATER(ah))
@@ -1975,7 +1966,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
 	 * value after the initvals have been applied.
 	 */
 	if (AR_SREV_9100(ah) && (ath9k_hw_gettsf64(ah) < tsf)) {
-		tsf_offset = ath9k_hw_get_tsf_offset(&tsf_ts, NULL);
+		tsf_offset = ath9k_hw_get_tsf_offset(tsf_ts, 0);
 		ath9k_hw_settsf64(ah, tsf + tsf_offset);
 	}
 
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 450ab19b1d4e..7a08b533b8af 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -1066,7 +1066,7 @@ u32 ath9k_hw_gettsf32(struct ath_hw *ah);
 u64 ath9k_hw_gettsf64(struct ath_hw *ah);
 void ath9k_hw_settsf64(struct ath_hw *ah, u64 tsf64);
 void ath9k_hw_reset_tsf(struct ath_hw *ah);
-u32 ath9k_hw_get_tsf_offset(struct timespec64 *last, struct timespec64 *cur);
+u32 ath9k_hw_get_tsf_offset(ktime_t last, ktime_t cur);
 void ath9k_hw_set_tsfadjust(struct ath_hw *ah, bool set);
 void ath9k_hw_init_global_settings(struct ath_hw *ah);
 u32 ar9003_get_pll_sqsum_dvc(struct ath_hw *ah);
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 2f137856a823..cf664a0dedaa 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -247,10 +247,8 @@ static bool ath_complete_reset(struct ath_softc *sc, bool start)
 	if (!sc->cur_chan->offchannel && start) {
 		/* restore per chanctx TSF timer */
 		if (sc->cur_chan->tsf_val) {
-			u32 offset;
-
-			offset = ath9k_hw_get_tsf_offset(&sc->cur_chan->tsf_ts,
-							 NULL);
+			u32 offset = ath9k_hw_get_tsf_offset
+				(sc->cur_chan->tsf_ts, 0);
 			ath9k_hw_settsf64(ah, sc->cur_chan->tsf_val + offset);
 		}
 
@@ -1955,7 +1953,7 @@ static u64 ath9k_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 		tsf = ath9k_hw_gettsf64(sc->sc_ah);
 	} else {
 		tsf = sc->cur_chan->tsf_val +
-		      ath9k_hw_get_tsf_offset(&sc->cur_chan->tsf_ts, NULL);
+		      ath9k_hw_get_tsf_offset(sc->cur_chan->tsf_ts, 0);
 	}
 	tsf += le64_to_cpu(avp->tsf_adjust);
 	ath9k_ps_restore(sc);
@@ -1974,7 +1972,7 @@ static void ath9k_set_tsf(struct ieee80211_hw *hw,
 	mutex_lock(&sc->mutex);
 	ath9k_ps_wakeup(sc);
 	tsf -= le64_to_cpu(avp->tsf_adjust);
-	ktime_get_raw_ts64(&avp->chanctx->tsf_ts);
+	avp->chanctx->tsf_ts = ktime_get_raw();
 	if (sc->cur_chan == avp->chanctx)
 		ath9k_hw_settsf64(sc->sc_ah, tsf);
 	avp->chanctx->tsf_val = tsf;
@@ -1990,7 +1988,7 @@ static void ath9k_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 	mutex_lock(&sc->mutex);
 
 	ath9k_ps_wakeup(sc);
-	ktime_get_raw_ts64(&avp->chanctx->tsf_ts);
+	avp->chanctx->tsf_ts = ktime_get_raw();
 	if (sc->cur_chan == avp->chanctx)
 		ath9k_hw_reset_tsf(sc->sc_ah);
 	avp->chanctx->tsf_val = 0;
-- 
2.47.1


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

* Re: [PATCH 3/3] wifi: ath9k: simplify internal time management
  2024-12-09 15:50 ` [PATCH 3/3] wifi: ath9k: simplify internal time management Dmitry Antipov
@ 2024-12-10  9:58   ` Toke Høiland-Jørgensen
  2024-12-10 11:37     ` Dmitry Antipov
  2024-12-14 17:29     ` Toke Høiland-Jørgensen
  0 siblings, 2 replies; 11+ messages in thread
From: Toke Høiland-Jørgensen @ 2024-12-10  9:58 UTC (permalink / raw)
  To: Dmitry Antipov; +Cc: Kalle Valo, linux-wireless, lvc-project, Dmitry Antipov

Dmitry Antipov <dmantipov@yandex.ru> writes:

> Prefer 'ktime_t' over 'struct timespec64' for 'struct ath_chanctx' and
> 'struct ath_softc' timestamps, choose standard kernel time API over an
> ad-hoc math in 'chanctx_event_delta()' and 'ath9k_hw_get_tsf_offset()',
> adjust related users. Compile tested only.
>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>

Nice cleanup! Just one formatting nit:

[...]
> diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
> index 2f137856a823..cf664a0dedaa 100644
> --- a/drivers/net/wireless/ath/ath9k/main.c
> +++ b/drivers/net/wireless/ath/ath9k/main.c
> @@ -247,10 +247,8 @@ static bool ath_complete_reset(struct ath_softc *sc, bool start)
>  	if (!sc->cur_chan->offchannel && start) {
>  		/* restore per chanctx TSF timer */
>  		if (sc->cur_chan->tsf_val) {
> -			u32 offset;
> -
> -			offset = ath9k_hw_get_tsf_offset(&sc->cur_chan->tsf_ts,
> -							 NULL);
> +			u32 offset = ath9k_hw_get_tsf_offset
> +				(sc->cur_chan->tsf_ts, 0);

This turned into a really odd line break. Let's just keep the variable
definition on its own line like it was before, so we can keep the
function call the way it is as well...

-Toke

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

* Re: [PATCH 1/3] wifi: ath9k: cleanup ath_txq_skb_done()
  2024-12-09 15:50 [PATCH 1/3] wifi: ath9k: cleanup ath_txq_skb_done() Dmitry Antipov
  2024-12-09 15:50 ` [PATCH 2/3] wifi: ath9k: cleanup a few (mostly) TX-related routines Dmitry Antipov
  2024-12-09 15:50 ` [PATCH 3/3] wifi: ath9k: simplify internal time management Dmitry Antipov
@ 2024-12-10  9:59 ` Toke Høiland-Jørgensen
  2024-12-19 17:54 ` Jeff Johnson
  3 siblings, 0 replies; 11+ messages in thread
From: Toke Høiland-Jørgensen @ 2024-12-10  9:59 UTC (permalink / raw)
  To: Dmitry Antipov; +Cc: Kalle Valo, linux-wireless, lvc-project, Dmitry Antipov

Dmitry Antipov <dmantipov@yandex.ru> writes:

> Since 'txq' argument of 'ath_txq_skb_done()' is actually
> (mis|un)used, convert the former to local variable and
> adjust all related users. Compile tested only.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>

Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>

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

* Re: [PATCH 2/3] wifi: ath9k: cleanup a few (mostly) TX-related routines
  2024-12-09 15:50 ` [PATCH 2/3] wifi: ath9k: cleanup a few (mostly) TX-related routines Dmitry Antipov
@ 2024-12-10  9:59   ` Toke Høiland-Jørgensen
  0 siblings, 0 replies; 11+ messages in thread
From: Toke Høiland-Jørgensen @ 2024-12-10  9:59 UTC (permalink / raw)
  To: Dmitry Antipov; +Cc: Kalle Valo, linux-wireless, lvc-project, Dmitry Antipov

Dmitry Antipov <dmantipov@yandex.ru> writes:

> Remove unused 'struct ath_softc *' argument of 'ath_pkt_duration()',
> 'ath_tx_update_baw()', 'ath_get_skb_tid()', 'ath_tx_addto_baw()' and
> 'ath_tx_count_frames()', adjust related users. Compile tested only.
>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>

Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>

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

* Re: [PATCH 3/3] wifi: ath9k: simplify internal time management
  2024-12-10  9:58   ` Toke Høiland-Jørgensen
@ 2024-12-10 11:37     ` Dmitry Antipov
  2024-12-14 17:29     ` Toke Høiland-Jørgensen
  1 sibling, 0 replies; 11+ messages in thread
From: Dmitry Antipov @ 2024-12-10 11:37 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen; +Cc: Kalle Valo, linux-wireless, lvc-project

On 12/10/24 12:58 PM, Toke Høiland-Jørgensen wrote:

> Nice cleanup! Just one formatting nit:

Thanks. Feel free to merge with any formatting adjustments.

Dmitry

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

* Re: [PATCH 3/3] wifi: ath9k: simplify internal time management
  2024-12-10  9:58   ` Toke Høiland-Jørgensen
  2024-12-10 11:37     ` Dmitry Antipov
@ 2024-12-14 17:29     ` Toke Høiland-Jørgensen
  2024-12-16 17:42       ` Jeff Johnson
  1 sibling, 1 reply; 11+ messages in thread
From: Toke Høiland-Jørgensen @ 2024-12-14 17:29 UTC (permalink / raw)
  To: Dmitry Antipov; +Cc: Kalle Valo, linux-wireless, lvc-project, Dmitry Antipov

Toke Høiland-Jørgensen <toke@toke.dk> writes:

> Dmitry Antipov <dmantipov@yandex.ru> writes:
>
>> Prefer 'ktime_t' over 'struct timespec64' for 'struct ath_chanctx' and
>> 'struct ath_softc' timestamps, choose standard kernel time API over an
>> ad-hoc math in 'chanctx_event_delta()' and 'ath9k_hw_get_tsf_offset()',
>> adjust related users. Compile tested only.
>>
>> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
>
> Nice cleanup! Just one formatting nit:
>
> [...]
>> diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
>> index 2f137856a823..cf664a0dedaa 100644
>> --- a/drivers/net/wireless/ath/ath9k/main.c
>> +++ b/drivers/net/wireless/ath/ath9k/main.c
>> @@ -247,10 +247,8 @@ static bool ath_complete_reset(struct ath_softc *sc, bool start)
>>  	if (!sc->cur_chan->offchannel && start) {
>>  		/* restore per chanctx TSF timer */
>>  		if (sc->cur_chan->tsf_val) {
>> -			u32 offset;
>> -
>> -			offset = ath9k_hw_get_tsf_offset(&sc->cur_chan->tsf_ts,
>> -							 NULL);
>> +			u32 offset = ath9k_hw_get_tsf_offset
>> +				(sc->cur_chan->tsf_ts, 0);
>
> This turned into a really odd line break. Let's just keep the variable
> definition on its own line like it was before, so we can keep the
> function call the way it is as well...

And since Jeff has agreed to fix the line break when applying, with that
fixed:

Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>

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

* Re: [PATCH 3/3] wifi: ath9k: simplify internal time management
  2024-12-14 17:29     ` Toke Høiland-Jørgensen
@ 2024-12-16 17:42       ` Jeff Johnson
  2024-12-16 19:42         ` Toke Høiland-Jørgensen
  0 siblings, 1 reply; 11+ messages in thread
From: Jeff Johnson @ 2024-12-16 17:42 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen, Dmitry Antipov
  Cc: Kalle Valo, linux-wireless, lvc-project

On 12/14/2024 9:29 AM, Toke Høiland-Jørgensen wrote:
> Toke Høiland-Jørgensen <toke@toke.dk> writes:
> 
>> Dmitry Antipov <dmantipov@yandex.ru> writes:
>>
>>> Prefer 'ktime_t' over 'struct timespec64' for 'struct ath_chanctx' and
>>> 'struct ath_softc' timestamps, choose standard kernel time API over an
>>> ad-hoc math in 'chanctx_event_delta()' and 'ath9k_hw_get_tsf_offset()',
>>> adjust related users. Compile tested only.
>>>
>>> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
>>
>> Nice cleanup! Just one formatting nit:
>>
>> [...]
>>> diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
>>> index 2f137856a823..cf664a0dedaa 100644
>>> --- a/drivers/net/wireless/ath/ath9k/main.c
>>> +++ b/drivers/net/wireless/ath/ath9k/main.c
>>> @@ -247,10 +247,8 @@ static bool ath_complete_reset(struct ath_softc *sc, bool start)
>>>  	if (!sc->cur_chan->offchannel && start) {
>>>  		/* restore per chanctx TSF timer */
>>>  		if (sc->cur_chan->tsf_val) {
>>> -			u32 offset;
>>> -
>>> -			offset = ath9k_hw_get_tsf_offset(&sc->cur_chan->tsf_ts,
>>> -							 NULL);
>>> +			u32 offset = ath9k_hw_get_tsf_offset
>>> +				(sc->cur_chan->tsf_ts, 0);
>>
>> This turned into a really odd line break. Let's just keep the variable
>> definition on its own line like it was before, so we can keep the
>> function call the way it is as well...
> 
> And since Jeff has agreed to fix the line break when applying, with that
> fixed:
> 
> Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
> 

Please check:
https://git.kernel.org/pub/scm/linux/kernel/git/ath/ath.git/commit/?h=pending&id=d953ce0fcc7ce69edb5a3a39ea3a98ba2347976d

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

* Re: [PATCH 3/3] wifi: ath9k: simplify internal time management
  2024-12-16 17:42       ` Jeff Johnson
@ 2024-12-16 19:42         ` Toke Høiland-Jørgensen
  0 siblings, 0 replies; 11+ messages in thread
From: Toke Høiland-Jørgensen @ 2024-12-16 19:42 UTC (permalink / raw)
  To: Jeff Johnson, Dmitry Antipov; +Cc: Kalle Valo, linux-wireless, lvc-project

Jeff Johnson <jeff.johnson@oss.qualcomm.com> writes:

> On 12/14/2024 9:29 AM, Toke Høiland-Jørgensen wrote:
>> Toke Høiland-Jørgensen <toke@toke.dk> writes:
>> 
>>> Dmitry Antipov <dmantipov@yandex.ru> writes:
>>>
>>>> Prefer 'ktime_t' over 'struct timespec64' for 'struct ath_chanctx' and
>>>> 'struct ath_softc' timestamps, choose standard kernel time API over an
>>>> ad-hoc math in 'chanctx_event_delta()' and 'ath9k_hw_get_tsf_offset()',
>>>> adjust related users. Compile tested only.
>>>>
>>>> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
>>>
>>> Nice cleanup! Just one formatting nit:
>>>
>>> [...]
>>>> diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
>>>> index 2f137856a823..cf664a0dedaa 100644
>>>> --- a/drivers/net/wireless/ath/ath9k/main.c
>>>> +++ b/drivers/net/wireless/ath/ath9k/main.c
>>>> @@ -247,10 +247,8 @@ static bool ath_complete_reset(struct ath_softc *sc, bool start)
>>>>  	if (!sc->cur_chan->offchannel && start) {
>>>>  		/* restore per chanctx TSF timer */
>>>>  		if (sc->cur_chan->tsf_val) {
>>>> -			u32 offset;
>>>> -
>>>> -			offset = ath9k_hw_get_tsf_offset(&sc->cur_chan->tsf_ts,
>>>> -							 NULL);
>>>> +			u32 offset = ath9k_hw_get_tsf_offset
>>>> +				(sc->cur_chan->tsf_ts, 0);
>>>
>>> This turned into a really odd line break. Let's just keep the variable
>>> definition on its own line like it was before, so we can keep the
>>> function call the way it is as well...
>> 
>> And since Jeff has agreed to fix the line break when applying, with that
>> fixed:
>> 
>> Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
>> 
>
> Please check:
> https://git.kernel.org/pub/scm/linux/kernel/git/ath/ath.git/commit/?h=pending&id=d953ce0fcc7ce69edb5a3a39ea3a98ba2347976d

LGTM - thanks!

-Toke

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

* Re: [PATCH 1/3] wifi: ath9k: cleanup ath_txq_skb_done()
  2024-12-09 15:50 [PATCH 1/3] wifi: ath9k: cleanup ath_txq_skb_done() Dmitry Antipov
                   ` (2 preceding siblings ...)
  2024-12-10  9:59 ` [PATCH 1/3] wifi: ath9k: cleanup ath_txq_skb_done() Toke Høiland-Jørgensen
@ 2024-12-19 17:54 ` Jeff Johnson
  3 siblings, 0 replies; 11+ messages in thread
From: Jeff Johnson @ 2024-12-19 17:54 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen, Dmitry Antipov
  Cc: Kalle Valo, linux-wireless, lvc-project


On Mon, 09 Dec 2024 18:50:25 +0300, Dmitry Antipov wrote:
> Since 'txq' argument of 'ath_txq_skb_done()' is actually
> (mis|un)used, convert the former to local variable and
> adjust all related users. Compile tested only.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> 
> [...]

Applied, thanks!

[1/3] wifi: ath9k: cleanup ath_txq_skb_done()
      commit: 2a7e02fa9116d9b077983257774e6644af064857
[2/3] wifi: ath9k: cleanup a few (mostly) TX-related routines
      commit: d19ac7ef6ee997298a42335d0dd09b67c6cb19bf
[3/3] wifi: ath9k: simplify internal time management
      commit: 0cc6510ca4639a20c8921f223f05faa485795204

Best regards,
-- 
Jeff Johnson <jeff.johnson@oss.qualcomm.com>


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

end of thread, other threads:[~2024-12-19 17:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-09 15:50 [PATCH 1/3] wifi: ath9k: cleanup ath_txq_skb_done() Dmitry Antipov
2024-12-09 15:50 ` [PATCH 2/3] wifi: ath9k: cleanup a few (mostly) TX-related routines Dmitry Antipov
2024-12-10  9:59   ` Toke Høiland-Jørgensen
2024-12-09 15:50 ` [PATCH 3/3] wifi: ath9k: simplify internal time management Dmitry Antipov
2024-12-10  9:58   ` Toke Høiland-Jørgensen
2024-12-10 11:37     ` Dmitry Antipov
2024-12-14 17:29     ` Toke Høiland-Jørgensen
2024-12-16 17:42       ` Jeff Johnson
2024-12-16 19:42         ` Toke Høiland-Jørgensen
2024-12-10  9:59 ` [PATCH 1/3] wifi: ath9k: cleanup ath_txq_skb_done() Toke Høiland-Jørgensen
2024-12-19 17:54 ` Jeff Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).