ath10k: Check tx_stats before use it
Subsystems (8)
Sasha Levin
maintainerPATCH 1/219 ath10k: Check tx_stats before use it
From: Yingying Tang <[email protected]>
[ Upstream commit 9e7251fa38978b85108c44743e1436d48e8d0d76 ]
tx_stats will be freed and set to NULL before debugfs_sta node is removed in station disconnetion process. So if read the debugfs_sta node there may be NULL pointer error. Add check for tx_stats before use it to resove this issue.
--- drivers/net/wireless/ath/ath10k/debugfs_sta.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/wireless/ath/ath10k/debugfs_sta.c +7 -0
@@ -663,6 +663,13 @@ static ssize_t ath10k_dbg_sta_dump_tx_stats(struct file *file,mutex_lock (&ar->conf_mutex); +if (!arsta->tx_stats) { +ath10k_warn (ar,"failed to get tx stats" ); +mutex_unlock (&ar->conf_mutex); +kfree (buf); +return 0 ; + } +spin_lock_bh (&ar->data_lock);for (k =0 ; k <ATH10K_STATS_TYPE_MAX ; k++) {for (j =0 ; j <ATH10K_COUNTER_TYPE_MAX ; j++) {
Signature · 7 lines
2.20.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Sasha Levin
maintainerPATCH 2/219 ath10k: htt: don't use txdone_fifo with SDIO
From: Alagu Sankar <[email protected]>
[ Upstream commit e2a6b711282a371c5153239e0468a48254f17ca6 ]
HTT High Latency (ATH10K_DEV_TYPE_HL) does not use txdone_fifo at all, we don't even initialise it by skipping ath10k_htt_tx_alloc_buf() in ath10k_htt_tx_start(). Because of this using QCA6174 SDIO ath10k_htt_rx_tx_compl_ind() will crash when it accesses unitialised txdone_fifo. So skip txdone_fifo when using High Latency mode.
Tested with QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00007-QCARMSWP-1.
--- drivers/net/wireless/ath/ath10k/htt_rx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/htt_rx.c +3 -1
@@ -2277,7 +2277,9 @@ static void ath10k_htt_rx_tx_compl_ind(struct ath10k *ar,* Note that with only one concurrent reader and one concurrent * writer, you don't need extra locking to use these macro. */ -if (!kfifo_put (&htt->txdone_fifo, tx_done)) { +if (ar->bus_param.dev_type ==ATH10K_DEV_TYPE_HL ) { +ath10k_txrx_tx_unref (htt, &tx_done); + }else if (!kfifo_put (&htt->txdone_fifo, tx_done)) {ath10k_warn (ar,"txdone fifo overrun, msdu_id %d status %d\n" , tx_done.msdu_id, tx_done.status);ath10k_txrx_tx_unref (htt, &tx_done);
Signature · 7 lines
2.20.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Sasha Levin
maintainerPATCH 3/219 ath10k: fix incorrect multicast/broadcast rate setting
In reply to Sasha LevinFrom: Pradeep kumar Chitrapu <[email protected]>
[ Upstream commit 93ee3d108fc77e19efeac3ec5aa7d5886711bfef ]
Invalid rate code is sent to firmware when multicast rate value of 0 is sent to driver indicating disabled case, causing broken mesh path. so fix that.
Tested on QCA9984 with firmware 10.4-3.6.1-00827
Sven tested on IPQ4019 with 10.4-3.5.3-00057 and QCA9888 with 10.4-3.5.3-00053 (ath10k-firmware) and 10.4-3.6-00140 (linux-firmware 2018-12-16-211de167).
--- drivers/net/wireless/ath/ath10k/mac.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/mac.c +7 -3
@@ -5588,8 +5588,8 @@ static void ath10k_bss_info_changed(struct ieee80211_hw *hw,struct cfg80211_chan_def def;u32 vdev_param, pdev_param, slottime, preamble;u16 bitrate, hw_value; -u8 rate, basic_rate_idx; -int rateidx, ret =0 , hw_rate_code; +u8 rate, basic_rate_idx, rateidx; +int ret =0 , hw_rate_code, mcast_rate;enum nl80211_band band;const struct ieee80211_supported_band *sband;
@@ -5776,7 +5776,11 @@ static void ath10k_bss_info_changed(struct ieee80211_hw *hw,if (changed &BSS_CHANGED_MCAST_RATE && !ath10k_mac_vif_chan (arvif->vif, &def)) { band = def.chan->band; - rateidx = vif->bss_conf.mcast_rate[band] -1 ; + mcast_rate = vif->bss_conf.mcast_rate[band]; +if (mcast_rate >0 ) + rateidx = mcast_rate -1 ; +else + rateidx =ffs (vif->bss_conf.basic_rates) -1 ;if (ar->phy_capability &WHAL_WLAN_11A_CAPABILITY ) rateidx +=ATH10K_MAC_FIRST_OFDM_RATE_IDX ;
Signature · 7 lines
2.20.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Sasha Levin
maintainerPATCH 4/219 ath9k: Don't trust TX status TID number when reporting airtime
In reply to Sasha LevinFrom: Toke Høiland-Jørgensen <[email protected]>
[ Upstream commit 389b72e58259336c2d56d58b660b79cf4b9e0dcb ]
As already noted a comment in ath_tx_complete_aggr(), the hardware will occasionally send a TX status with the wrong tid number. If we trust the value, airtime usage will be reported to the wrong AC, which can cause the deficit on that AC to become very low, blocking subsequent attempts to transmit.
To fix this, account airtime usage to the TID number from the original skb, instead of the one in the hardware TX status report.
--- drivers/net/wireless/ath/ath9k/xmit.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath9k/xmit.c +4 -3
@@ -668,7 +668,8 @@ static bool bf_is_ampdu_not_probing(struct ath_buf *bf)static void ath_tx_count_airtime (struct ath_softc *sc,struct ieee80211_sta *sta,struct ath_buf *bf, -struct ath_tx_status *ts) +struct ath_tx_status *ts, +u8 tid) {u32 airtime =0 ;int i;
@@ -679,7 +680,7 @@ static void ath_tx_count_airtime(struct ath_softc *sc, airtime += rate_dur * bf->rates[i].count; } -ieee80211_sta_register_airtime (sta, ts->tid, airtime,0 ); +ieee80211_sta_register_airtime (sta, tid, airtime,0 ); } static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq,
@@ -709,7 +710,7 @@ static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq,if (sta) {struct ath_node *an = (struct ath_node *)sta->drv_priv; tid =ath_get_skb_tid (sc, an, bf->bf_mpdu); -ath_tx_count_airtime (sc, sta, bf, ts); +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; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 5/219 wil6210: fix potential out-of-bounds read
In reply to Sasha LevinFrom: "Gustavo A. R. Silva" <[email protected]>
[ Upstream commit bfabdd6997323adbedccb13a3fed1967fb8cf8f5 ]
Notice that *rc* can evaluate to up to 5, include/linux/netdevice.h:
enum gro_result {
GRO_MERGED,
GRO_MERGED_FREE,
GRO_HELD,
GRO_NORMAL,
GRO_DROP,
GRO_CONSUMED,
};
typedef enum gro_result gro_result_t;
In case *rc* evaluates to 5, we end up having an out-of-bounds read at drivers/net/wireless/ath/wil6210/txrx.c:821:
wil_dbg_txrx(wil, "Rx complete %d bytes => %s\n", len, gro_res_str[rc]);
Fix this by adding element "GRO_CONSUMED" to array gro_res_str.
Addresses-Coverity-ID: 1444666 ("Out-of-bounds read")
--- drivers/net/wireless/ath/wil6210/txrx.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/wil6210/txrx.c +1 -0
@@ -750,6 +750,7 @@ void wil_netif_rx_any(struct sk_buff *skb, struct net_device *ndev) [GRO_HELD] = "GRO_HELD", [GRO_NORMAL] = "GRO_NORMAL", [GRO_DROP] = "GRO_DROP", + [GRO_CONSUMED ] ="GRO_CONSUMED" , }; wil->txrx_ops.get_netif_rx_params (skb, &cid, &security);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 6/219 ath10k: Do not send probe response template for mesh
In reply to Sasha LevinFrom: Surabhi Vishnoi <[email protected]>
[ Upstream commit 97354f2c432788e3163134df6bb144f4b6289d87 ]
Currently mac80211 do not support probe response template for mesh point. When WMI_SERVICE_BEACON_OFFLOAD is enabled, host driver tries to configure probe response template for mesh, but it fails because the interface type is not NL80211_IFTYPE_AP but NL80211_IFTYPE_MESH_POINT.
To avoid this failure, skip sending probe response template to firmware for mesh point.
Tested HW: WCN3990/QCA6174/QCA9984
--- drivers/net/wireless/ath/ath10k/mac.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/ath10k/mac.c +4 -0
@@ -1630,6 +1630,10 @@ static int ath10k_mac_setup_prb_tmpl(struct ath10k_vif *arvif)if (arvif->vdev_type !=WMI_VDEV_TYPE_AP )return 0 ; +/* For mesh, probe response and beacon share the same template */ +if (ieee80211_vif_is_mesh (vif)) +return 0 ; + prb =ieee80211_proberesp_get (hw, vif);if (!prb) {ath10k_warn (ar,"failed to get probe resp template from mac80211\n" );
Signature · 7 lines
2.20.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Sasha Levin
maintainerPATCH 7/219 spi: rockchip: turn down tx dma bursts
In reply to Sasha LevinFrom: Emil Renner Berthing <[email protected]>
[ Upstream commit 47300728fb213486a830565d2af49da967c9d16a ]
This fixes tx and bi-directional dma transfers on rk3399-gru-kevin.
It seems the SPI fifo must have room for 2 bursts when the dma_tx_req signal is generated or it might skip some words. This in turn makes the rx dma channel never complete for bi-directional transfers.
Fix it by setting tx burst length to fifo_len / 4 and the dma watermark to fifo_len / 2.
However the rk3399 TRM says (sic):
"DMAC support incrementing-address burst and fixed-address burst. But in the case of access SPI and UART at byte or halfword size, DMAC only support fixed-address burst and the address must be aligned to word."
So this relies on fifo_len being a multiple of 16 such that the burst length (= fifo_len / 4) is a multiple of 4 and the addresses will be word-aligned.
--- drivers/spi/spi-rockchip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-rockchip.c +2 -2
@@ -425,7 +425,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs, .direction = DMA_MEM_TO_DEV, .dst_addr = rs->dma_addr_tx, .dst_addr_width = rs->n_bytes, - .dst_maxburst = rs->fifo_len / 2, + .dst_maxburst = rs->fifo_len / 4, };dmaengine_slave_config (master->dma_tx, &txconf);
@@ -526,7 +526,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs,else writel_relaxed (rs->fifo_len /2 -1 , rs->regs +ROCKCHIP_SPI_RXFTLR ); -writel_relaxed (rs->fifo_len /2 -1 , rs->regs +ROCKCHIP_SPI_DMATDLR ); +writel_relaxed (rs->fifo_len /2 , rs->regs +ROCKCHIP_SPI_DMATDLR );writel_relaxed (0 , rs->regs +ROCKCHIP_SPI_DMARDLR );writel_relaxed (dmacr, rs->regs +ROCKCHIP_SPI_DMACR );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 8/219 ath9k: Check for errors when reading SREV register
In reply to Sasha LevinFrom: Tim Schumacher <[email protected]>
[ Upstream commit 2f90c7e5d09437a4d8d5546feaae9f1cf48cfbe1 ]
Right now, if an error is encountered during the SREV register read (i.e. an EIO in ath9k_regread()), that error code gets passed all the way to __ath9k_hw_init(), where it is visible during the "Chip rev not supported" message.
ath9k_htc 1-1.4:1.0: ath9k_htc: HTC initialized with 33 credits
ath: phy2: Mac Chip Rev 0x0f.3 is not supported by this driver
ath: phy2: Unable to initialize hardware; initialization status: -95
ath: phy2: Unable to initialize hardware; initialization status: -95
ath9k_htc: Failed to initialize the device
Check for -EIO explicitly in ath9k_hw_read_revisions() and return a boolean based on the success of the operation. Check for that in __ath9k_hw_init() and abort with a more debugging-friendly message if reading the revisions wasn't successful.
ath9k_htc 1-1.4:1.0: ath9k_htc: HTC initialized with 33 credits
ath: phy2: Failed to read SREV register
ath: phy2: Could not read hardware revision
ath: phy2: Unable to initialize hardware; initialization status: -95
ath: phy2: Unable to initialize hardware; initialization status: -95
ath9k_htc: Failed to initialize the device
This helps when debugging by directly showing the first point of failure and it could prevent possible errors if a 0x0f.3 revision is ever supported.
--- drivers/net/wireless/ath/ath9k/hw.c | 32 +++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +23 -9
@@ -252,8 +252,9 @@ void ath9k_hw_get_channel_centers(struct ath_hw *ah,/* Chip Revisions */ /******************/ -static void ath9k_hw_read_revisions (struct ath_hw *ah) +static bool ath9k_hw_read_revisions (struct ath_hw *ah) { +u32 srev;u32 val;if (ah->get_mac_revision)
@@ -269,25 +270,33 @@ static void ath9k_hw_read_revisions(struct ath_hw *ah) val =REG_READ (ah,AR_SREV ); ah->hw_version.macRev =MS (val,AR_SREV_REVISION2 ); } -return ; +return true;case AR9300_DEVID_AR9340 : ah->hw_version.macVersion =AR_SREV_VERSION_9340 ; -return ; +return true;case AR9300_DEVID_QCA955X : ah->hw_version.macVersion =AR_SREV_VERSION_9550 ; -return ; +return true;case AR9300_DEVID_AR953X : ah->hw_version.macVersion =AR_SREV_VERSION_9531 ; -return ; +return true;case AR9300_DEVID_QCA956X : ah->hw_version.macVersion =AR_SREV_VERSION_9561 ; -return ; +return true; } - val =REG_READ (ah,AR_SREV ) &AR_SREV_ID ; + srev =REG_READ (ah,AR_SREV ); + +if (srev == -EIO ) { +ath_err (ath9k_hw_common (ah), +"Failed to read SREV register" ); +return false; + } + + val = srev &AR_SREV_ID ;if (val ==0xFF ) { - val =REG_READ (ah,AR_SREV ); + val = srev; ah->hw_version.macVersion = (val &AR_SREV_VERSION2 ) >>AR_SREV_TYPE2_S ; ah->hw_version.macRev =MS (val,AR_SREV_REVISION2 );
@@ -306,6 +315,8 @@ static void ath9k_hw_read_revisions(struct ath_hw *ah)if (ah->hw_version.macVersion ==AR_SREV_VERSION_5416_PCIE ) ah->is_pciexpress = true; } + +return true; }/************************************/
@@ -559,7 +570,10 @@ static int __ath9k_hw_init(struct ath_hw *ah)struct ath_common *common =ath9k_hw_common (ah);int r =0 ; -ath9k_hw_read_revisions (ah); +if (!ath9k_hw_read_revisions (ah)) { +ath_err (common,"Could not read hardware revisions" ); +return -EOPNOTSUPP ; + }switch (ah->hw_version.macVersion) {case AR_SREV_VERSION_5416_PCI :
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 9/219 ath10k: Fix the wrong value of enums for wmi tlv stats id
In reply to Sasha LevinFrom: Surabhi Vishnoi <[email protected]>
[ Upstream commit 9280f4fc06f44d0b4dc9e831f72d97b3d7cd35d3 ]
The enum value for WMI_TLV_STAT_PDEV, WMI_TLV_STAT_VDEV and WMI_TLV_STAT_PEER is wrong, due to which the vdev stats are not received from firmware in wmi_update_stats event.
Fix the enum values for above stats to receive all stats from firmware in WMI_TLV_UPDATE_STATS_EVENTID.
Tested HW: WCN3990
Tested FW: WLAN.HL.3.1-00784-QCAHLSWMTPLZ-1
--- drivers/net/wireless/ath/ath10k/wmi.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/wmi.h +4 -3
@@ -4535,9 +4535,10 @@ enum wmi_10_4_stats_id { };enum wmi_tlv_stats_id { -WMI_TLV_STAT_PDEV =BIT (0 ), -WMI_TLV_STAT_VDEV =BIT (1 ), -WMI_TLV_STAT_PEER =BIT (2 ), +WMI_TLV_STAT_PEER =BIT (0 ), +WMI_TLV_STAT_AP =BIT (1 ), +WMI_TLV_STAT_PDEV =BIT (2 ), +WMI_TLV_STAT_VDEV =BIT (3 ),WMI_TLV_STAT_PEER_EXTD =BIT (10 ), };
Signature · 7 lines
2.20.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Sasha Levin
maintainerPATCH 10/219 wil6210: fix missed MISC mbox interrupt
In reply to Sasha LevinFrom: Maya Erez <[email protected]>
[ Upstream commit 7441be71ba7e07791fd4fa2b07c932dff14ff4d9 ]
When MISC interrupt is triggered due to HALP bit, in parallel to mbox events handling by the MISC threaded IRQ, new mbox interrupt can be missed in the following scenario:
1. MISC ICR is read in the IRQ handler
2. Threaded IRQ is completed and all MISC interrupts are unmasked
3. mbox interrupt is set by FW
4. HALP is masked
The mbox interrupt in step 3 can be missed due to constant high level of ICM.
Masking all MISC IRQs instead of masking only HALP bit in step 4 will guarantee that ICM will drop to 0 and interrupt will be triggered once MISC interrupts will be unmasked.
--- drivers/net/wireless/ath/wil6210/interrupt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/wil6210/interrupt.c +1 -1
@@ -580,7 +580,7 @@ static irqreturn_t wil6210_irq_misc(int irq, void *cookie)/* no need to handle HALP ICRs until next vote */ wil->halp.handle_icr = false;wil_dbg_irq (wil,"irq_misc: HALP IRQ invoked\n" ); -wil6210_mask_halp (wil); +wil6210_mask_irq_misc (wil, true);complete (&wil->halp.comp); } }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 11/219 ath6kl: add some bounds checking
In reply to Sasha LevinFrom: Dan Carpenter <[email protected]>
[ Upstream commit 5d6751eaff672ea77642e74e92e6c0ac7f9709ab ]
The "ev->traffic_class" and "reply->ac" variables come from the network and they're used as an offset into the wmi->stream_exist_for_ac[] array. Those variables are u8 so they can be 0-255 but the stream_exist_for_ac[] array only has WMM_NUM_AC (4) elements. We need to add a couple bounds checks to prevent array overflows.
I also modified one existing check from "if (traffic_class > 3) {" to "if (traffic_class >= WMM_NUM_AC) {" just to make them all consistent.
--- drivers/net/wireless/ath/ath6kl/wmi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath6kl/wmi.c +9 -1
@@ -1176,6 +1176,10 @@ static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap,return -EINVAL ; ev = (struct wmi_pstream_timeout_event *) datap; +if (ev->traffic_class >=WMM_NUM_AC ) { +ath6kl_err ("invalid traffic class: %d\n" , ev->traffic_class); +return -EINVAL ; + }/* * When the pstream (fat pipe == AC) timesout, it means there were
@@ -1517,6 +1521,10 @@ static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len,return -EINVAL ; reply = (struct wmi_cac_event *) datap; +if (reply->ac >=WMM_NUM_AC ) { +ath6kl_err ("invalid AC: %d\n" , reply->ac); +return -EINVAL ; + }if ((reply->cac_indication ==CAC_INDICATION_ADMISSION_RESP ) && (reply->status_code !=IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED )) {
@@ -2633,7 +2641,7 @@ int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 if_idx, u8 traffic_class,u16 active_tsids =0 ;int ret; -if (traffic_class >3 ) { +if (traffic_class >=WMM_NUM_AC ) {ath6kl_err ("invalid traffic class: %d\n" , traffic_class);return -EINVAL ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 12/219 ath10k: add peer id check in ath10k_peer_find_by_id
In reply to Sasha LevinFrom: Wen Gong <[email protected]>
[ Upstream commit 49ed34b835e231aa941257394716bc689bc98d9f ]
For some SDIO chip, the peer id is 65535 for MPDU with error status, then test_bit will trigger buffer overflow for peer's memory, if kasan enabled, it will report error.
Reason is when station is in disconnecting status, firmware do not delete the peer info since it not disconnected completely, meanwhile some AP will still send data packet to station, then hardware will receive the packet and send to firmware, firmware's logic will report peer id of 65535 for MPDU with error status.
Add check for overflow the size of peer's peer_ids will avoid the buffer overflow access.
Call trace of kasan:
dump_backtrace+0x0/0x2ec show_stack+0x20/0x2c __dump_stack+0x20/0x28 dump_stack+0xc8/0xec print_address_description+0x74/0x240 kasan_report+0x250/0x26c __asan_report_load8_noabort+0x20/0x2c ath10k_peer_find_by_id+0x180/0x1e4 [ath10k_core] ath10k_htt_t2h_msg_handler+0x100c/0x2fd4 [ath10k_core] ath10k_htt_htc_t2h_msg_handler+0x20/0x34 [ath10k_core] ath10k_sdio_irq_handler+0xcc8/0x1678 [ath10k_sdio] process_sdio_pending_irqs+0xec/0x370 sdio_run_irqs+0x68/0xe4 sdio_irq_work+0x1c/0x28 process_one_work+0x3d8/0x8b0 worker_thread+0x508/0x7cc kthread+0x24c/0x264 ret_from_fork+0x10/0x18
Tested with QCA6174 SDIO with firmware
WLAN.RMH.4.4.1-00007-QCARMSWP-1.
--- drivers/net/wireless/ath/ath10k/txrx.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/ath/ath10k/txrx.c +3 -0
@@ -150,6 +150,9 @@ struct ath10k_peer *ath10k_peer_find_by_id(struct ath10k *ar, int peer_id) {struct ath10k_peer *peer; +if (peer_id >=BITS_PER_TYPE (peer->peer_ids)) +return NULL ; +lockdep_assert_held (&ar->data_lock);list_for_each_entry (peer, &ar->peers, list)
Signature · 7 lines
2.20.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Sasha Levin
maintainerPATCH 13/219 x86/tsc: Use CPUID.0x16 to calculate missing crystal frequency
In reply to Sasha LevinFrom: Daniel Drake <[email protected]>
[ Upstream commit 604dc9170f2435d27da5039a3efd757dceadc684 ]
native_calibrate_tsc() had a data mapping Intel CPU families and crystal clock speed, but hardcoded tables are not ideal, and this approach was already problematic at least in the Skylake X case, as seen in commit:
b51120309348 ("x86/tsc: Fix erroneous TSC rate on Skylake Xeon")
By examining CPUID data from http://instlatx64.atw.hu/ and units in the lab, we have found that 3 different scenarios need to be dealt with, and we can eliminate most of the hardcoded data using an approach a little more advanced than before:
1. ApolloLake, GeminiLake, CannonLake (and presumably all new chipsets from this point) report the crystal frequency directly via CPUID.0x15. That's definitive data that we can rely upon.
2. Skylake, Kabylake and all variants of those two chipsets report a crystal frequency of zero, however we can calculate the crystal clock speed by condidering data from CPUID.0x16.
This method correctly distinguishes between the two crystal clock frequencies present on different Skylake X variants that caused headaches before.
As the calculations do not quite match the previously-hardcoded values in some cases (e.g. 23913043Hz instead of 24MHz), TSC refinement is enabled on all platforms where we had to calculate the crystal frequency in this way.
3. Denverton (GOLDMONT_X) reports a crystal frequency of zero and does
not support CPUID.0x16, so we leave this entry hardcoded.
--- arch/x86/kernel/tsc.c | 47 +++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 20 deletions(-)
arch/x86/kernel/tsc.c +27 -20
@@ -629,31 +629,38 @@ unsigned long native_calibrate_tsc(void) crystal_khz = ecx_hz /1000 ; -if (crystal_khz ==0 ) { -switch (boot_cpu_data.x86_model) { -case INTEL_FAM6_SKYLAKE_MOBILE : -case INTEL_FAM6_SKYLAKE_DESKTOP : -case INTEL_FAM6_KABYLAKE_MOBILE : -case INTEL_FAM6_KABYLAKE_DESKTOP : - crystal_khz =24000 ;/* 24.0 MHz */ -break ; -case INTEL_FAM6_ATOM_GOLDMONT_X : - crystal_khz =25000 ;/* 25.0 MHz */ -break ; -case INTEL_FAM6_ATOM_GOLDMONT : - crystal_khz =19200 ;/* 19.2 MHz */ -break ; - } - } +/* +* Denverton SoCs don't report crystal clock, and also don't support +* CPUID.0x16 for the calculation below, so hardcode the 25MHz crystal +* clock. +*/ +if (crystal_khz ==0 && + boot_cpu_data.x86_model ==INTEL_FAM6_ATOM_GOLDMONT_X ) + crystal_khz =25000 ; -if (crystal_khz ==0 ) -return 0 ;/* -* TSC frequency determined by CPUID is a "hardware reported" +* TSC frequency reported directly by CPUID is a "hardware reported" * frequency and is the most accurate one so far we have. This * is considered a known frequency. */ -setup_force_cpu_cap (X86_FEATURE_TSC_KNOWN_FREQ ); +if (crystal_khz !=0 ) +setup_force_cpu_cap (X86_FEATURE_TSC_KNOWN_FREQ ); + +/* +* Some Intel SoCs like Skylake and Kabylake don't report the crystal +* clock, but we can easily calculate it to a high degree of accuracy +* by considering the crystal ratio and the CPU speed. +*/ +if (crystal_khz ==0 && boot_cpu_data.cpuid_level >=0x16 ) { +unsigned int eax_base_mhz, ebx, ecx, edx; + +cpuid (0x16 , &eax_base_mhz, &ebx, &ecx, &edx); + crystal_khz = eax_base_mhz *1000 * + eax_denominator / ebx_numerator; + } + +if (crystal_khz ==0 ) +return 0 ;/* * For Atom SoCs TSC is the only reliable clocksource.
Signature · 1 line
2.20.1
Re: [PATCH AUTOSEL 5.1 013/219] x86/tsc: Use CPUID.0x16 to calculate missing crystal frequency
Hi,
Quoted 3 lines · Sasha Levin
From: Daniel Drake <[email protected]>
[ Upstream commit
604dc9170f2435d27da5039a3efd757dceadc684]
In my opinion this is not stable kernel material.
It alone does not solve a particular bug. It's part of a larger effort to decrease usage of the 8254 PIT on modern platforms, which solves a real problem (see "x86: skip PIT initialization on modern chipsets"), but I'd conservatively recommend just leaving these patches out of the stable tree. The problem has existed for a while without a particularly wide impact, and there is a somewhat documented workaround of changing BIOS settings.
Daniel
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.1 013/219] x86/tsc: Use CPUID.0x16 to calculate missing crystal frequency
Quoted 9 lines · Daniel Drake
Hi,
Quoted 3 lines · Sasha Levin
From: Daniel Drake <[email protected]>
[ Upstream commit
604dc9170f2435d27da5039a3efd757dceadc684]In my opinion this is not stable kernel material.
Quoted 7 lines
It alone does not solve a particular bug. It's part of a larger effort to decrease usage of the 8254 PIT on modern platforms, which solves a real problem (see "x86: skip PIT initialization on modern chipsets"), but I'd conservatively recommend just leaving these patches out of the stable tree. The problem has existed for a while without a particularly wide impact, and there is a somewhat documented workaround of changing BIOS settings.
I've dropped it, thanks!
--
Thanks,
Sasha
Sasha Levin
maintainerPATCH 14/219 wil6210: fix spurious interrupts in 3-msi
In reply to Sasha LevinFrom: Maya Erez <[email protected]>
[ Upstream commit e10b0eddd5235aa5aef4e40b970e34e735611a80 ]
Interrupt is set in ICM (ICR & ~IMV) rising trigger. As the driver masks the IRQ after clearing it, there can be a race where an additional spurious interrupt is triggered when the driver unmask the IRQ.
This can happen in case HW triggers an interrupt after the clear and before the mask.
To prevent the second spurious interrupt the driver needs to mask the IRQ before reading and clearing it.
--- drivers/net/wireless/ath/wil6210/interrupt.c | 65 ++++++++++++-------- 1 file changed, 40 insertions(+), 25 deletions(-)
drivers/net/wireless/ath/wil6210/interrupt.c +40 -25
@@ -296,21 +296,24 @@ void wil_configure_interrupt_moderation(struct wil6210_priv *wil)static irqreturn_t wil6210_irq_rx (int irq,void *cookie) {struct wil6210_priv *wil = cookie; -u32 isr =wil_ioread32_and_clear (wil->csr + -HOSTADDR (RGF_DMA_EP_RX_ICR ) + - offsetof(struct RGF_ICR , ICR)); +u32 isr;bool need_unmask = true; +wil6210_mask_irq_rx (wil); + + isr =wil_ioread32_and_clear (wil->csr + +HOSTADDR (RGF_DMA_EP_RX_ICR ) + + offsetof(struct RGF_ICR , ICR)); +trace_wil6210_irq_rx (isr);wil_dbg_irq (wil,"ISR RX 0x%08x\n" , isr);if (unlikely (!isr)) {wil_err_ratelimited (wil,"spurious IRQ: RX\n" ); +wil6210_unmask_irq_rx (wil);return IRQ_NONE ; } -wil6210_mask_irq_rx (wil); -/* RX_DONE and RX_HTRSH interrupts are the same if interrupt * moderation is not used. Interrupt moderation may cause RX * buffer overflow while RX_DONE is delayed. The required
@@ -355,21 +358,24 @@ static irqreturn_t wil6210_irq_rx(int irq, void *cookie)static irqreturn_t wil6210_irq_rx_edma (int irq,void *cookie) {struct wil6210_priv *wil = cookie; -u32 isr =wil_ioread32_and_clear (wil->csr + -HOSTADDR (RGF_INT_GEN_RX_ICR ) + - offsetof(struct RGF_ICR , ICR)); +u32 isr;bool need_unmask = true; +wil6210_mask_irq_rx_edma (wil); + + isr =wil_ioread32_and_clear (wil->csr + +HOSTADDR (RGF_INT_GEN_RX_ICR ) + + offsetof(struct RGF_ICR , ICR)); +trace_wil6210_irq_rx (isr);wil_dbg_irq (wil,"ISR RX 0x%08x\n" , isr);if (unlikely (!isr)) {wil_err (wil,"spurious IRQ: RX\n" ); +wil6210_unmask_irq_rx_edma (wil);return IRQ_NONE ; } -wil6210_mask_irq_rx_edma (wil); -if (likely (isr &BIT_RX_STATUS_IRQ )) {wil_dbg_irq (wil,"RX status ring\n" ); isr &= ~BIT_RX_STATUS_IRQ ;
@@ -403,21 +409,24 @@ static irqreturn_t wil6210_irq_rx_edma(int irq, void *cookie)static irqreturn_t wil6210_irq_tx_edma (int irq,void *cookie) {struct wil6210_priv *wil = cookie; -u32 isr =wil_ioread32_and_clear (wil->csr + -HOSTADDR (RGF_INT_GEN_TX_ICR ) + - offsetof(struct RGF_ICR , ICR)); +u32 isr;bool need_unmask = true; +wil6210_mask_irq_tx_edma (wil); + + isr =wil_ioread32_and_clear (wil->csr + +HOSTADDR (RGF_INT_GEN_TX_ICR ) + + offsetof(struct RGF_ICR , ICR)); +trace_wil6210_irq_tx (isr);wil_dbg_irq (wil,"ISR TX 0x%08x\n" , isr);if (unlikely (!isr)) {wil_err (wil,"spurious IRQ: TX\n" ); +wil6210_unmask_irq_tx_edma (wil);return IRQ_NONE ; } -wil6210_mask_irq_tx_edma (wil); -if (likely (isr &BIT_TX_STATUS_IRQ )) {wil_dbg_irq (wil,"TX status ring\n" ); isr &= ~BIT_TX_STATUS_IRQ ;
@@ -446,21 +455,24 @@ static irqreturn_t wil6210_irq_tx_edma(int irq, void *cookie)static irqreturn_t wil6210_irq_tx (int irq,void *cookie) {struct wil6210_priv *wil = cookie; -u32 isr =wil_ioread32_and_clear (wil->csr + -HOSTADDR (RGF_DMA_EP_TX_ICR ) + - offsetof(struct RGF_ICR , ICR)); +u32 isr;bool need_unmask = true; +wil6210_mask_irq_tx (wil); + + isr =wil_ioread32_and_clear (wil->csr + +HOSTADDR (RGF_DMA_EP_TX_ICR ) + + offsetof(struct RGF_ICR , ICR)); +trace_wil6210_irq_tx (isr);wil_dbg_irq (wil,"ISR TX 0x%08x\n" , isr);if (unlikely (!isr)) {wil_err_ratelimited (wil,"spurious IRQ: TX\n" ); +wil6210_unmask_irq_tx (wil);return IRQ_NONE ; } -wil6210_mask_irq_tx (wil); -if (likely (isr &BIT_DMA_EP_TX_ICR_TX_DONE )) {wil_dbg_irq (wil,"TX done\n" ); isr &= ~BIT_DMA_EP_TX_ICR_TX_DONE ;
@@ -532,20 +544,23 @@ static bool wil_validate_mbox_regs(struct wil6210_priv *wil)static irqreturn_t wil6210_irq_misc (int irq,void *cookie) {struct wil6210_priv *wil = cookie; -u32 isr =wil_ioread32_and_clear (wil->csr + -HOSTADDR (RGF_DMA_EP_MISC_ICR ) + - offsetof(struct RGF_ICR , ICR)); +u32 isr; + +wil6210_mask_irq_misc (wil, false); + + isr =wil_ioread32_and_clear (wil->csr + +HOSTADDR (RGF_DMA_EP_MISC_ICR ) + + offsetof(struct RGF_ICR , ICR));trace_wil6210_irq_misc (isr);wil_dbg_irq (wil,"ISR MISC 0x%08x\n" , isr);if (!isr) {wil_err (wil,"spurious IRQ: MISC\n" ); +wil6210_unmask_irq_misc (wil, false);return IRQ_NONE ; } -wil6210_mask_irq_misc (wil, false); -if (isr &ISR_MISC_FW_ERROR ) {u32 fw_assert_code =wil_r (wil, wil->rgf_fw_assert_code_addr); u32 ucode_assert_code =
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 15/219 ath: DFS JP domain W56 fixed pulse type 3 RADAR detection
In reply to Sasha LevinFrom: Anilkumar Kolli <[email protected]>
[ Upstream commit d8792393a783158cbb2c39939cb897dc5e5299b6 ]
Increase pulse width range from 1-2usec to 0-4usec.
During data traffic HW occasionally fails detecting radar pulses, so that SW cannot get enough radar reports to achieve the success rate.
Tested ath10k hw and fw:
* QCA9888(10.4-3.5.1-00052)
* QCA4019(10.4-3.2.1.1-00017)
* QCA9984(10.4-3.6-00104)
* QCA988X(10.2.4-1.0-00041)
Tested ath9k hw: AR9300
--- drivers/net/wireless/ath/dfs_pattern_detector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/dfs_pattern_detector.c +1 -1
@@ -111,7 +111,7 @@ static const struct radar_detector_specs jp_radar_ref_types[] = {JP_PATTERN (0 ,0 ,1 ,1428 ,1428 ,1 ,18 ,29 , false),JP_PATTERN (1 ,2 ,3 ,3846 ,3846 ,1 ,18 ,29 , false),JP_PATTERN (2 ,0 ,1 ,1388 ,1388 ,1 ,18 ,50 , false), -JP_PATTERN (3 ,1 ,2 ,4000 ,4000 ,1 ,18 ,50 , false), +JP_PATTERN (3 ,0 ,4 ,4000 ,4000 ,1 ,18 ,50 , false),JP_PATTERN (4 ,0 ,5 ,150 ,230 ,1 ,23 ,50 , false),JP_PATTERN (5 ,6 ,10 ,200 ,500 ,1 ,16 ,50 , false), JP_PATTERN(6, 11, 20, 200, 500, 1, 12, 50, false),
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 16/219 ath10k: Fix encoding for protected management frames
In reply to Sasha LevinFrom: Rakesh Pillai <[email protected]>
[ Upstream commit 42f1bc43e6a97b9ddbe976eba9bd05306c990c75 ]
Currently the protected management frames are
not appended with the MIC_LEN which results in
the protected management frames being encoded
incorrectly.
Add the extra space at the end of the protected
management frames to fix this encoding error for
the protected management frames.
Tested HW: WCN3990
Tested FW: WLAN.HL.3.1-00784-QCAHLSWMTPLZ-1
--- drivers/net/wireless/ath/ath10k/wmi-tlv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/wmi-tlv.c +3 -1
@@ -2840,8 +2840,10 @@ ath10k_wmi_tlv_op_gen_mgmt_tx_send(struct ath10k *ar, struct sk_buff *msdu,if ((ieee80211_is_action (hdr->frame_control) ||ieee80211_is_deauth (hdr->frame_control) ||ieee80211_is_disassoc (hdr->frame_control)) && -ieee80211_has_protected (hdr->frame_control)) +ieee80211_has_protected (hdr->frame_control)) { +skb_put (msdu,IEEE80211_CCMP_MIC_LEN ); buf_len +=IEEE80211_CCMP_MIC_LEN ; + } buf_len =min_t (u32, buf_len,WMI_TLV_MGMT_TX_FRAME_MAX_LEN ); buf_len =round_up (buf_len,4 );
Signature · 7 lines
2.20.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Sasha Levin
maintainerPATCH 17/219 regmap: debugfs: Fix memory leak in regmap_debugfs_init
In reply to Sasha LevinFrom: Daniel Baluta <[email protected]>
[ Upstream commit 2899872b627e99b7586fe3b6c9f861da1b4d5072 ]
As detected by kmemleak running on i.MX6ULL board:
nreferenced object 0xd8366600 (size 64):
comm "swapper/0", pid 1, jiffies 4294937370 (age 933.220s) hex dump (first 32 bytes):
64 75 6d 6d 79 2d 69 6f 6d 75 78 63 2d 67 70 72 dummy-iomuxc-gpr
40 32 30 65 34 30 30 30 00 e3 f3 ab fe d1 1b dd @20e4000........
backtrace:
[<b0402aec>] kasprintf+0x2c/0x54
[<a6fbad2c>] regmap_debugfs_init+0x7c/0x31c
[<9c8d91fa>] __regmap_init+0xb5c/0xcf4
[<5b1c3d2a>] of_syscon_register+0x164/0x2c4
[<596a5d80>] syscon_node_to_regmap+0x64/0x90
[<49bd597b>] imx6ul_init_machine+0x34/0xa0
[<250a4dac>] customize_machine+0x1c/0x30
[<2d19fdaf>] do_one_initcall+0x7c/0x398
[<e6084469>] kernel_init_freeable+0x328/0x448
[<168c9101>] kernel_init+0x8/0x114
[<913268aa>] ret_from_fork+0x14/0x20
[<ce7b131a>] 0x0Root cause is that map->debugfs_name is allocated using kasprintf and then the pointer is lost by assigning it other memory address.
--- drivers/base/regmap/regmap-debugfs.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/base/regmap/regmap-debugfs.c +2 -0
@@ -565,6 +565,8 @@ void regmap_debugfs_init(struct regmap *map, const char *name) }if (!strcmp (name,"dummy" )) { +kfree (map->debugfs_name); + map->debugfs_name =kasprintf (GFP_KERNEL ,"dummy%d" , dummy_index); name = map->debugfs_name;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 18/219 batman-adv: fix for leaked TVLV handler.
In reply to Sasha LevinFrom: Jeremy Sowden <[email protected]>
[ Upstream commit 17f78dd1bd624a4dd78ed5db3284a63ee807fcc3 ]
A handler for BATADV_TVLV_ROAM was being registered when the translation-table was initialized, but not unregistered when the translation-table was freed. Unregister it.
--- net/batman-adv/translation-table.c | 2 ++ 1 file changed, 2 insertions(+)
net/batman-adv/translation-table.c +2 -0
@@ -3826,6 +3826,8 @@ static void batadv_tt_purge(struct work_struct *work)*/ void batadv_tt_free (struct batadv_priv *bat_priv) { +batadv_tvlv_handler_unregister (bat_priv,BATADV_TVLV_ROAM ,1 ); +batadv_tvlv_container_unregister (bat_priv,BATADV_TVLV_TT ,1 );batadv_tvlv_handler_unregister (bat_priv,BATADV_TVLV_TT ,1 );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 19/219 media: dvb: usb: fix use after free in dvb_usb_device_exit
In reply to Sasha LevinFrom: Oliver Neukum <[email protected]>
[ Upstream commit 6cf97230cd5f36b7665099083272595c55d72be7 ]
dvb_usb_device_exit() frees and uses the device name in that order. Fix by storing the name in a buffer before freeing it.
--- drivers/media/usb/dvb-usb/dvb-usb-init.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/media/usb/dvb-usb/dvb-usb-init.c +5 -2
@@ -287,12 +287,15 @@ EXPORT_SYMBOL(dvb_usb_device_init);void dvb_usb_device_exit (struct usb_interface *intf) {struct dvb_usb_device *d =usb_get_intfdata (intf); -const char *name ="generic DVB-USB module" ; +const char *default_name ="generic DVB-USB module" ; +char name[40 ];usb_set_intfdata (intf,NULL );if (d !=NULL && d->desc !=NULL ) { - name = d->desc->name; +strscpy (name, d->desc->name,sizeof (name));dvb_usb_exit (d); + }else { +strscpy (name, default_name,sizeof (name)); }info ("%s successfully deinitialized and disconnected." , name);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 20/219 media: spi: IR LED: add missing of table registration
In reply to Sasha LevinFrom: Daniel Gomez <[email protected]>
[ Upstream commit 24e4cf770371df6ad49ed873f21618d9878f64c8 ]
MODULE_DEVICE_TABLE(of, <of_match_table> should be called to complete DT OF mathing mechanism and register it.
Before this patch:
modinfo drivers/media/rc/ir-spi.ko | grep alias
After this patch:
modinfo drivers/media/rc/ir-spi.ko | grep alias
alias: of:N*T*Cir-spi-ledC* alias: of:N*T*Cir-spi-led
--- drivers/media/rc/ir-spi.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/rc/ir-spi.c +1 -0
@@ -161,6 +161,7 @@ static const struct of_device_id ir_spi_of_match[] = { { .compatible = "ir-spi-led" }, {}, }; +MODULE_DEVICE_TABLE (of, ir_spi_of_match);static struct spi_driver ir_spi_driver = { .probe = ir_spi_probe,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 21/219 crypto: talitos - fix skcipher failure due to wrong output IV
In reply to Sasha LevinFrom: Christophe Leroy <[email protected]>
[ Upstream commit 3e03e792865ae48b8cfc69a0b4d65f02f467389f ]
Selftests report the following:
[ 2.984845] alg: skcipher: cbc-aes-talitos encryption test failed (wrong output IV) on test vector 0, cfg="in-place" [ 2.995377] 00000000: 3d af ba 42 9d 9e b4 30 b4 22 da 80 2c 9f ac 41 [ 3.032673] alg: skcipher: cbc-des-talitos encryption test failed (wrong output IV) on test vector 0, cfg="in-place" [ 3.043185] 00000000: fe dc ba 98 76 54 32 10 [ 3.063238] alg: skcipher: cbc-3des-talitos encryption test failed (wrong output IV) on test vector 0, cfg="in-place" [ 3.073818] 00000000: 7d 33 88 93 0f 93 b2 42
This above dumps show that the actual output IV is indeed the input IV. This is due to the IV not being copied back into the request.
This patch fixes that.
--- drivers/crypto/talitos.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/crypto/talitos.c +4 -0
@@ -1571,11 +1571,15 @@ static void ablkcipher_done(struct device *dev, int err) {struct ablkcipher_request *areq = context; +struct crypto_ablkcipher *cipher =crypto_ablkcipher_reqtfm (areq); +struct talitos_ctx *ctx =crypto_ablkcipher_ctx (cipher); +unsigned int ivsize =crypto_ablkcipher_ivsize (cipher);struct talitos_edesc *edesc; edesc = container_of(desc, struct talitos_edesc, desc);common_nonsnoop_unmap (dev, edesc, areq); +memcpy (areq->info, ctx->iv, ivsize);kfree (edesc);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 22/219 media: ov7740: avoid invalid framesize setting
In reply to Sasha LevinFrom: Akinobu Mita <[email protected]>
[ Upstream commit 6e4ab830ac6d6a0d7cd7f87dc5d6536369bf24a8 ]
If the requested framesize by VIDIOC_SUBDEV_S_FMT is larger than supported framesizes, it causes an out of bounds array access and the resulting framesize is unexpected.
Avoid out of bounds array access and select the default framesize.
--- drivers/media/i2c/ov7740.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/media/i2c/ov7740.c +5 -1
@@ -761,7 +761,11 @@ static int ov7740_try_fmt_internal(struct v4l2_subdev *sd, fsize++; } - +if (i >=ARRAY_SIZE (ov7740_framesizes)) { + fsize = &ov7740_framesizes[0 ]; + fmt->width = fsize->width; + fmt->height = fsize->height; + }if (ret_frmsize !=NULL ) *ret_frmsize = fsize;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 23/219 media: marvell-ccic: fix DMA s/g desc number calculation
In reply to Sasha LevinFrom: Lubomir Rintel <[email protected]>
[ Upstream commit 0c7aa32966dab0b8a7424e1b34c7f206817953ec ]
The commit d790b7eda953 ("[media] vb2-dma-sg: move dma_(un)map_sg here") left dma_desc_nent unset. It previously contained the number of DMA descriptors as returned from dma_map_sg().
We can now (since the commit referred to above) obtain the same value from the sg_table and drop dma_desc_nent altogether.
Tested on OLPC XO-1.75 machine. Doesn't affect the OLPC XO-1's Cafe driver, since that one doesn't do DMA.
[[email protected]: fix a checkpatch warning]
--- drivers/media/platform/marvell-ccic/mcam-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/platform/marvell-ccic/mcam-core.c +3 -2
@@ -200,7 +200,6 @@ struct mcam_vb_buffer {struct list_head queue;struct mcam_dma_desc *dma_desc;/* Descriptor virtual address */ dma_addr_t dma_desc_pa;/* Descriptor physical address */ -int dma_desc_nent;/* Number of mapped descriptors */ };static inline struct mcam_vb_buffer *vb_to_mvb (struct vb2_v4l2_buffer *vb)
@@ -608,9 +607,11 @@ static void mcam_dma_contig_done(struct mcam_camera *cam, int frame)static void mcam_sg_next_buffer (struct mcam_camera *cam) {struct mcam_vb_buffer *buf; +struct sg_table *sg_table; buf = list_first_entry(&cam->buffers, struct mcam_vb_buffer, queue);list_del_init (&buf->queue); + sg_table =vb2_dma_sg_plane_desc (&buf->vb_buf.vb2_buf,0 );/* * Very Bad Not Good Things happen if you don't clear * C1_DESC_ENA before making any descriptor changes.
@@ -618,7 +619,7 @@ static void mcam_sg_next_buffer(struct mcam_camera *cam)mcam_reg_clear_bit (cam,REG_CTRL1 ,C1_DESC_ENA );mcam_reg_write (cam,REG_DMA_DESC_Y , buf->dma_desc_pa);mcam_reg_write (cam,REG_DESC_LEN_Y , - buf->dma_desc_nent*sizeof (struct mcam_dma_desc )); + sg_table->nents *sizeof (struct mcam_dma_desc ));mcam_reg_write (cam,REG_DESC_LEN_U ,0 );mcam_reg_write (cam,REG_DESC_LEN_V ,0 );mcam_reg_set_bit (cam,REG_CTRL1 ,C1_DESC_ENA );
Signature · 1 line
2.20.1