5.16.3-rc1 review
Subsystems (9)
Greg Kroah-Hartman
maintainerPATCH 254/1039 ath10k: Fix the MTU size on QCA9377 SDIO
In reply to Greg Kroah-HartmanFrom: Fabio Estevam <[email protected]>
[ Upstream commit 09b8cd69edcf2be04a781e1781e98e52a775c9ad ]
On an imx6dl-pico-pi board with a QCA9377 SDIO chip, simply trying to connect via ssh to another machine causes:
[ 55.824159] ath10k_sdio mmc1:0001:1: failed to transmit packet, dropping: -12 [ 55.832169] ath10k_sdio mmc1:0001:1: failed to submit frame: -12 [ 55.838529] ath10k_sdio mmc1:0001:1: failed to push frame: -12 [ 55.905863] ath10k_sdio mmc1:0001:1: failed to transmit packet, dropping: -12 [ 55.913650] ath10k_sdio mmc1:0001:1: failed to submit frame: -12 [ 55.919887] ath10k_sdio mmc1:0001:1: failed to push frame: -12
, leading to an ssh connection failure.
One user inspected the size of frames on Wireshark and reported the followig:
"I was able to narrow the issue down to the mtu. If I set the mtu for the wlan0 device to 1486 instead of 1500, the issue does not happen.
The size of frames that I see on Wireshark is exactly 1500 after setting it to 1486."
Clearing the HI_ACS_FLAGS_ALT_DATA_CREDIT_SIZE avoids the problem and the ssh command works successfully after that.
Introduce a 'credit_size_workaround' field to ath10k_hw_params for the QCA9377 SDIO, so that the HI_ACS_FLAGS_ALT_DATA_CREDIT_SIZE is not set in this case.
Tested with QCA9377 SDIO with firmware WLAN.TF.1.1.1-00061-QCATFSWPZ-1.
--- drivers/net/wireless/ath/ath10k/core.c | 19 ++++++++++++++++++- drivers/net/wireless/ath/ath10k/hw.h | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/core.c +18 -1
@@ -89,6 +89,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .rri_on_ddr = false, .hw_filter_reset_required = true, .fw_diag_ce_download = false, + .credit_size_workaround = false, .tx_stats_over_pktlog = true, .dynamic_sar_support = false, },
@@ -124,6 +125,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .rri_on_ddr = false, .hw_filter_reset_required = true, .fw_diag_ce_download = false, + .credit_size_workaround = false, .tx_stats_over_pktlog = true, .dynamic_sar_support = false, },
@@ -160,6 +162,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .rri_on_ddr = false, .hw_filter_reset_required = true, .fw_diag_ce_download = false, + .credit_size_workaround = false, .tx_stats_over_pktlog = false, .dynamic_sar_support = false, },
@@ -190,6 +193,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .num_wds_entries = 0x20, .uart_pin_workaround = true, .tx_stats_over_pktlog = false, + .credit_size_workaround = false, .bmi_large_size_download = true, .supports_peer_stats_info = true, .dynamic_sar_support = true,
@@ -226,6 +230,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .rri_on_ddr = false, .hw_filter_reset_required = true, .fw_diag_ce_download = false, + .credit_size_workaround = false, .tx_stats_over_pktlog = false, .dynamic_sar_support = false, },
@@ -261,6 +266,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .rri_on_ddr = false, .hw_filter_reset_required = true, .fw_diag_ce_download = false, + .credit_size_workaround = false, .tx_stats_over_pktlog = false, .dynamic_sar_support = false, },
@@ -296,6 +302,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .rri_on_ddr = false, .hw_filter_reset_required = true, .fw_diag_ce_download = false, + .credit_size_workaround = false, .tx_stats_over_pktlog = false, .dynamic_sar_support = false, },
@@ -334,6 +341,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .rri_on_ddr = false, .hw_filter_reset_required = true, .fw_diag_ce_download = true, + .credit_size_workaround = false, .tx_stats_over_pktlog = false, .supports_peer_stats_info = true, .dynamic_sar_support = true,
@@ -376,6 +384,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .rri_on_ddr = false, .hw_filter_reset_required = true, .fw_diag_ce_download = false, + .credit_size_workaround = false, .tx_stats_over_pktlog = false, .dynamic_sar_support = false, },
@@ -424,6 +433,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .rri_on_ddr = false, .hw_filter_reset_required = true, .fw_diag_ce_download = false, + .credit_size_workaround = false, .tx_stats_over_pktlog = false, .dynamic_sar_support = false, },
@@ -469,6 +479,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .rri_on_ddr = false, .hw_filter_reset_required = true, .fw_diag_ce_download = false, + .credit_size_workaround = false, .tx_stats_over_pktlog = false, .dynamic_sar_support = false, },
@@ -504,6 +515,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .rri_on_ddr = false, .hw_filter_reset_required = true, .fw_diag_ce_download = false, + .credit_size_workaround = false, .tx_stats_over_pktlog = false, .dynamic_sar_support = false, },
@@ -541,6 +553,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .rri_on_ddr = false, .hw_filter_reset_required = true, .fw_diag_ce_download = true, + .credit_size_workaround = false, .tx_stats_over_pktlog = false, .dynamic_sar_support = false, },
@@ -570,6 +583,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .ast_skid_limit = 0x10, .num_wds_entries = 0x20, .uart_pin_workaround = true, + .credit_size_workaround = true, .dynamic_sar_support = false, }, {
@@ -611,6 +625,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .rri_on_ddr = false, .hw_filter_reset_required = true, .fw_diag_ce_download = false, + .credit_size_workaround = false, .tx_stats_over_pktlog = false, .dynamic_sar_support = false, },
@@ -639,6 +654,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .rri_on_ddr = true, .hw_filter_reset_required = false, .fw_diag_ce_download = false, + .credit_size_workaround = false, .tx_stats_over_pktlog = false, .dynamic_sar_support = true, },
@@ -714,6 +730,7 @@ static void ath10k_send_suspend_complete(struct ath10k *ar)static int ath10k_init_sdio (struct ath10k *ar,enum ath10k_firmware_mode mode) { +bool mtu_workaround = ar->hw_params.credit_size_workaround;int ret;u32 param =0 ;
@@ -731,7 +748,7 @@ static int ath10k_init_sdio(struct ath10k *ar, enum ath10k_firmware_mode mode) param |=HI_ACS_FLAGS_SDIO_REDUCE_TX_COMPL_SET ; -if (mode ==ATH10K_FIRMWARE_MODE_NORMAL ) +if (mode ==ATH10K_FIRMWARE_MODE_NORMAL && !mtu_workaround) param |=HI_ACS_FLAGS_ALT_DATA_CREDIT_SIZE ;else param &= ~HI_ACS_FLAGS_ALT_DATA_CREDIT_SIZE ;
drivers/net/wireless/ath/ath10k/hw.h +3 -0
@@ -618,6 +618,9 @@ struct ath10k_hw_params {*/ bool uart_pin_workaround; +/* Workaround for the credit size calculation */ +bool credit_size_workaround; +/* tx stats support over pktlog */ bool tx_stats_over_pktlog;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 255/1039 ath11k: Fix QMI file type enum value
In reply to Greg Kroah-HartmanFrom: Seevalamuthu Mariappan <[email protected]>
[ Upstream commit 18ae1ab04525507ae5528245a6df004cacd0d39a ]
bdf_type for caldata in QMI_WLANFW_BDF_DOWNLOAD_REQ_V01 is wrongly sent as 1. But, expected bdf_type value for caldata and EEPROM is 2 and 3 respectively. It leads to firmware crash. Fix ath11k_qmi_file_type enum values.
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.5.0.1-01100-QCAHKSWPL_SILICONZ-1
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.4.0.1-00192-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/qmi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/qmi.h +1 -1
@@ -41,7 +41,7 @@ struct ath11k_base;enum ath11k_qmi_file_type {ATH11K_QMI_FILE_TYPE_BDF_GOLDEN , -ATH11K_QMI_FILE_TYPE_CALDATA , +ATH11K_QMI_FILE_TYPE_CALDATA =2 ,ATH11K_QMI_FILE_TYPE_EEPROM ,ATH11K_QMI_MAX_FILE_TYPE , };
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 256/1039 Bluetooth: MGMT: Use hci_dev_test_and_{set,clear}_flag
In reply to Greg Kroah-HartmanFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 6f59f991b4e735323f099ac6490e725ae8c750a5 ]
This make use of hci_dev_test_and_{set,clear}_flag instead of doing 2 operations in a row.
--- net/bluetooth/mgmt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
net/bluetooth/mgmt.c +7 -7
@@ -3969,10 +3969,10 @@ static int set_zero_key_func(struct sock *sk, struct hci_dev *hdev,#endif if (hdev &&use_ll_privacy (hdev) && !hdev_is_powered (hdev)) { -bool changed =hci_dev_test_flag (hdev,HCI_ENABLE_LL_PRIVACY ); - -hci_dev_clear_flag (hdev,HCI_ENABLE_LL_PRIVACY ); +bool changed; + changed =hci_dev_test_and_clear_flag (hdev, +HCI_ENABLE_LL_PRIVACY );if (changed)exp_ll_privacy_feature_changed (false, hdev, sk); }
@@ -4067,15 +4067,15 @@ static int set_rpa_resolution_func(struct sock *sk, struct hci_dev *hdev, val = !!cp->param[0 ];if (val) { - changed = !hci_dev_test_flag (hdev,HCI_ENABLE_LL_PRIVACY ); -hci_dev_set_flag (hdev,HCI_ENABLE_LL_PRIVACY ); + changed = !hci_dev_test_and_set_flag (hdev, +HCI_ENABLE_LL_PRIVACY );hci_dev_clear_flag (hdev,HCI_ADVERTISING );/* Enable LL privacy + supported settings changed */ flags =BIT (0 ) |BIT (1 ); }else { - changed =hci_dev_test_flag (hdev,HCI_ENABLE_LL_PRIVACY ); -hci_dev_clear_flag (hdev,HCI_ENABLE_LL_PRIVACY ); + changed =hci_dev_test_and_clear_flag (hdev, +HCI_ENABLE_LL_PRIVACY );/* Disable LL privacy + supported settings changed */ flags =BIT (1 );
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 257/1039 Bluetooth: btusb: Handle download_firmware failure cases
In reply to Greg Kroah-HartmanFrom: Mark Chen <[email protected]>
[ Upstream commit 00c0ee9850b7b0cb7c40b8daba806ae2245e59d4 ]
For Mediatek chipset, it can not enabled if there are something wrong in btmtk_setup_firmware_79xx(). Thus, the process must be terminated and returned error code.
--- drivers/bluetooth/btusb.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/bluetooth/btusb.c +4 -0
@@ -2895,6 +2895,10 @@ static int btusb_mtk_setup(struct hci_dev *hdev)"mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin" , dev_id & 0xffff, (fw_version & 0xff) + 1); err =btusb_mtk_setup_firmware_79xx (hdev, fw_bin_name); +if (err <0 ) { +bt_dev_err (hdev,"Failed to set up firmware (%d)" , err); +return err; + }/* It's Device EndPoint Reset Option Register */ btusb_mtk_uhw_reg_write (data,MTK_EP_RST_OPT ,MTK_EP_RST_IN_OUT_OPT );
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 258/1039 drm/amd/display: Fix bug in debugfs crc_win_update entry
In reply to Greg Kroah-HartmanFrom: Wayne Lin <[email protected]>
[ Upstream commit 4bef85d4c9491415b7931407b07f24841c1e0390 ]
[Why]crc_rd_wrk shouldn't be null in crc_win_update_set(). Current programming logic is inconsistent in crc_win_update_set().
[How]
Initially, return if crc_rd_wrk is NULL. Later on, we can use member of crc_rd_wrk safely.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +4 -1
@@ -2909,10 +2909,13 @@ static int crc_win_update_set(void *data, u64 val)struct amdgpu_device *adev =drm_to_adev (new_crtc->dev);struct crc_rd_work *crc_rd_wrk = adev->dm.crc_rd_wrk; +if (!crc_rd_wrk) +return 0 ; +if (val) {spin_lock_irq (&adev_to_drm (adev)->event_lock);spin_lock_irq (&crc_rd_wrk->crc_rd_work_lock); -if (crc_rd_wrk && crc_rd_wrk->crtc) { +if (crc_rd_wrk->crtc) { old_crtc = crc_rd_wrk->crtc; old_acrtc =to_amdgpu_crtc (old_crtc); }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 259/1039 drm/amd/display: Fix out of bounds access on DNC31 stream encoder regs
In reply to Greg Kroah-HartmanFrom: Nicholas Kazlauskas <[email protected]>
[ Upstream commit d374d3b493215d637b9e7be12a93f22caf4c1f97 ]
[Why]
During dcn31_stream_encoder_create, if PHYC/D get remapped to F/G on B0 then we'll index 5 or 6 into a array of length 5 - leading to an access violation on some configs during device creation.
[How]
Software won't be touching PHYF/PHYG directly, so just extend the array to cover all possible engine IDs.
Even if it does by try to access one of these registers by accident the offset will be 0 and we'll get a warning during the access.
--- drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c +2 -1
@@ -493,7 +493,8 @@ static const struct dcn31_apg_mask apg_mask = { SE_DCN3_REG_LIST(id)\ } -static const struct dcn10_stream_enc_registers stream_enc_regs[] = { +/* Some encoders won't be initialized here - but they're logical, not physical. */ +static const struct dcn10_stream_enc_registers stream_enc_regs[ENGINE_ID_COUNT ] = {stream_enc_regs (0 ),stream_enc_regs (1 ),stream_enc_regs (2 ),
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 260/1039 drm/msm/gpu: Dont allow zero fence_id
In reply to Greg Kroah-HartmanFrom: Rob Clark <[email protected]>
[ Upstream commit ca3ffcbeb0c866d9b0cb38eaa2bd4416597b5966 ]
Elsewhere we treat zero as "no fence" and __msm_gem_submit_destroy() skips removal from fence_idr. We could alternately change this to use negative values for "no fence" but I think it is more clear to not allow zero as a valid fence_id.
--- drivers/gpu/drm/msm/msm_gem_submit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_gem_submit.c +1 -1
@@ -881,7 +881,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,* to the underlying fence. */ submit->fence_id =idr_alloc_cyclic (&queue->fence_idr, - submit->user_fence,0 ,INT_MAX ,GFP_KERNEL ); + submit->user_fence,1 ,INT_MAX ,GFP_KERNEL );if (submit->fence_id <0 ) { ret = submit->fence_id =0 ; submit->fence_id =0 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 261/1039 drm/msm/dp: displayPort driver need algorithm rational
In reply to Greg Kroah-HartmanFrom: Jackie Liu <[email protected]>
[ Upstream commit 53d22794711ad630f40d59dd726bd260d77d585f ]
Let's select RATIONAL with dp driver. avoid like:
[...]
x86_64-linux-gnu-ld: drivers/gpu/drm/msm/dp/dp_catalog.o: in function `dp_catalog_ctrl_config_msa':
dp_catalog.c:(.text+0x57e): undefined reference to `rational_best_approximation'
--- drivers/gpu/drm/msm/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/msm/Kconfig +1 -0
@@ -65,6 +65,7 @@ config DRM_MSM_HDMI_HDCP config DRM_MSM_DP bool "Enable DisplayPort support in MSM DRM driver" depends on DRM_MSM + select RATIONAL default y help Compile in support for DP driver in MSM DRM driver. DP external
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 262/1039 rcu/exp: Mark current CPU as exp-QS in IPI loop second pass
In reply to Greg Kroah-HartmanFrom: Frederic Weisbecker <[email protected]>
[ Upstream commit 81f6d49cce2d2fe507e3fddcc4a6db021d9c2e7b ]
Expedited RCU grace periods invoke sync_rcu_exp_select_node_cpus(), which takes two passes over the leaf rcu_node structure's CPUs. The first pass gathers up the current CPU and CPUs that are in dynticks idle mode. The workqueue will report a quiescent state on their behalf later. The second pass sends IPIs to the rest of the CPUs, but excludes the current CPU, incorrectly assuming it has been included in the first pass's list of CPUs.
Unfortunately the current CPU may have changed between the first and second pass, due to the fact that the various rcu_node structures' ->lock fields have been dropped, thus momentarily enabling preemption. This means that if the second pass's CPU was not on the first pass's list, it will be ignored completely. There will be no IPI sent to it, and there will be no reporting of quiescent states on its behalf. Unfortunately, the expedited grace period will nevertheless be waiting for that CPU to report a quiescent state, but with that CPU having no reason to believe that such a report is needed.
The result will be an expedited grace period stall.
Fix this by no longer excluding the current CPU from consideration during the second pass.
--- kernel/rcu/tree_exp.h | 1 + 1 file changed, 1 insertion(+)
kernel/rcu/tree_exp.h +1 -0
@@ -387,6 +387,7 @@ retry_ipi:continue ; }if (get_cpu () == cpu) { + mask_ofl_test |= mask;put_cpu ();continue ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 263/1039 wcn36xx: Fix max channels retrieval
In reply to Greg Kroah-HartmanFrom: Loic Poulain <[email protected]>
[ Upstream commit 09cab4308bf9b8076ee4a3c56015daf9ef9cb23e ]
Kernel test robot reported:drivers/net/wireless/ath/wcn36xx/smd.c:943:33:
sparse: sparse: cast truncates bits from constant value (780 becomes 80)
The 'channels' field is not a simple u8 array but an array of channel_params. Using sizeof for retrieving the max number of channels is then wrong.
In practice, it was not an issue, because the sizeof returned value is 780, which is truncated in min_t (u8) to 80, which is the value we expect...
Fix that properly using ARRAY_SIZE instead of sizeof.
--- drivers/net/wireless/ath/wcn36xx/smd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/wcn36xx/smd.c +1 -1
@@ -944,7 +944,7 @@ int wcn36xx_smd_update_channel_list(struct wcn36xx *wcn, struct cfg80211_scan_reINIT_HAL_MSG ((*msg_body),WCN36XX_HAL_UPDATE_CHANNEL_LIST_REQ ); - msg_body->num_channel =min_t (u8, req->n_channels,sizeof (msg_body->channels)); + msg_body->num_channel =min_t (u8, req->n_channels,ARRAY_SIZE (msg_body->channels));for (i =0 ; i < msg_body->num_channel; i++) {struct wcn36xx_hal_channel_param *param = &msg_body->channels[i];u32 min_power =WCN36XX_HAL_DEFAULT_MIN_POWER ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 264/1039 drm/msm/dsi: fix initialization in the bonded DSI case
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit 92cb1bedde9dba78d802fe2510949743a2581aed ]
Commit 739b4e7756d3 ("drm/msm/dsi: Fix an error code in msm_dsi_modeset_init()") changed msm_dsi_modeset_init() to return an error code in case msm_dsi_manager_validate_current_config() returns false. However this is not an error case, but a slave DSI of the bonded DSI link. In this case msm_dsi_modeset_init() should return 0, but just skip connector and bridge initialization.
To reduce possible confusion, drop the msm_dsi_manager_validate_current_config() function, and specif 'bonded && !master' condition directly in the msm_dsi_modeset_init().
--- drivers/gpu/drm/msm/dsi/dsi.c | 10 +++++++--- drivers/gpu/drm/msm/dsi/dsi.h | 1 - drivers/gpu/drm/msm/dsi/dsi_manager.c | 17 ----------------- 3 files changed, 7 insertions(+), 21 deletions(-)
drivers/gpu/drm/msm/dsi/dsi.c +7 -3
@@ -215,9 +215,13 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev, goto fail; } -if (!msm_dsi_manager_validate_current_config (msm_dsi->id)) { - ret = -EINVAL ; - goto fail; +if (msm_dsi_is_bonded_dsi (msm_dsi) && + !msm_dsi_is_master_dsi (msm_dsi)) { +/* +* Do not return an eror here, +* Just skip creating encoder/connector for the slave-DSI. +*/ +return 0 ; } msm_dsi->encoder = encoder;
drivers/gpu/drm/msm/dsi/dsi.h +0 -1
@@ -82,7 +82,6 @@ int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);bool msm_dsi_manager_cmd_xfer_trigger (int id,u32 dma_base,u32 len);int msm_dsi_manager_register (struct msm_dsi *msm_dsi);void msm_dsi_manager_unregister (struct msm_dsi *msm_dsi); -bool msm_dsi_manager_validate_current_config (u8 id);void msm_dsi_manager_tpg_enable (void );/* msm dsi */
drivers/gpu/drm/msm/dsi/dsi_manager.c +0 -17
@@ -649,23 +649,6 @@ fail:return ERR_PTR (ret); } -bool msm_dsi_manager_validate_current_config (u8 id) -{ -bool is_bonded_dsi =IS_BONDED_DSI (); - -/* -* For bonded DSI, we only have one drm panel. For this -* use case, we register only one bridge/connector. -* Skip bridge/connector initialisation if it is -* slave-DSI for bonded DSI configuration. -*/ -if (is_bonded_dsi && !IS_MASTER_DSI_LINK (id)) { -DBG ("Skip bridge registration for slave DSI->id: %d\n" , id); -return false; - } -return true; -} -/* initialize bridge */ struct drm_bridge *msm_dsi_manager_bridge_init (u8 id) {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 265/1039 mwifiex: Fix possible ABBA deadlock
In reply to Greg Kroah-HartmanFrom: Brian Norris <[email protected]>
[ Upstream commit 1b8bb8919ef81bfc8873d223b9361f1685f2106d ]
Quoting Jia-Ju Bai <[email protected]>:
mwifiex_dequeue_tx_packet()
spin_lock_bh(&priv->wmm.ra_list_spinlock); --> Line 1432 (Lock A)
mwifiex_send_addba()
spin_lock_bh(&priv->sta_list_spinlock); --> Line 608 (Lock B) mwifiex_process_sta_tx_pause()
spin_lock_bh(&priv->sta_list_spinlock); --> Line 398 (Lock B)
mwifiex_update_ralist_tx_pause()
spin_lock_bh(&priv->wmm.ra_list_spinlock); --> Line 941 (Lock A)Similar report for mwifiex_process_uap_tx_pause().
While the locking expectations in this driver are a bit unclear, the Fixed commit only intended to protect the sta_ptr, so we can drop the lock as soon as we're done with it.
IIUC, this deadlock cannot actually happen, because command event processing (which calls mwifiex_process_sta_tx_pause()) is sequentialized with TX packet processing (e.g., mwifiex_dequeue_tx_packet()) via the main loop (mwifiex_main_process()). But it's good not to leave this potential issue lurking.
--- drivers/net/wireless/marvell/mwifiex/sta_event.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/wireless/marvell/mwifiex/sta_event.c +6 -2
@@ -365,10 +365,12 @@ static void mwifiex_process_uap_tx_pause(struct mwifiex_private *priv, sta_ptr =mwifiex_get_sta_entry (priv, tp->peermac);if (sta_ptr && sta_ptr->tx_pause != tp->tx_pause) { sta_ptr->tx_pause = tp->tx_pause; +spin_unlock_bh (&priv->sta_list_spinlock);mwifiex_update_ralist_tx_pause (priv, tp->peermac, tp->tx_pause); + }else { +spin_unlock_bh (&priv->sta_list_spinlock); } -spin_unlock_bh (&priv->sta_list_spinlock); } }
@@ -400,11 +402,13 @@ static void mwifiex_process_sta_tx_pause(struct mwifiex_private *priv, sta_ptr =mwifiex_get_sta_entry (priv, tp->peermac);if (sta_ptr && sta_ptr->tx_pause != tp->tx_pause) { sta_ptr->tx_pause = tp->tx_pause; +spin_unlock_bh (&priv->sta_list_spinlock);mwifiex_update_ralist_tx_pause (priv, tp->peermac, tp->tx_pause); + }else { +spin_unlock_bh (&priv->sta_list_spinlock); } -spin_unlock_bh (&priv->sta_list_spinlock); } } }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 266/1039 xfrm: fix a small bug in xfrm_sa_len()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 7770a39d7c63faec6c4f33666d49a8cb664d0482 ]
copy_user_offload() will actually push a struct struct xfrm_user_offload, which is different than (struct xfrm_state *)->xso
(struct xfrm_state_offload)
--- net/xfrm/xfrm_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/xfrm/xfrm_user.c +1 -1
@@ -3058,7 +3058,7 @@ static inline unsigned int xfrm_sa_len(struct xfrm_state *x)if (x->props.extra_flags) l +=nla_total_size (sizeof (x->props.extra_flags));if (x->xso.dev) - l +=nla_total_size (sizeof (x->xso)); + l +=nla_total_size (sizeof (struct xfrm_user_offload ));if (x->props.smark.v | x->props.smark.m) { l +=nla_total_size (sizeof (x->props.smark.v)); l +=nla_total_size (sizeof (x->props.smark.m));
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 267/1039 x86/uaccess: Move variable into switch case statement
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit 61646ca83d3889696f2772edaff122dd96a2935e ]
When building with automatic stack variable initialization, GCC 12 complains about variables defined outside of switch case statements. Move the variable into the case that uses it, which silences the warning:
./arch/x86/include/asm/uaccess.h:317:23: warning: statement will never be executed [-Wswitch-unreachable]
317 | unsigned char x_u8__; \
| ^~~~~~
--- arch/x86/include/asm/uaccess.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/include/asm/uaccess.h +3 -2
@@ -314,11 +314,12 @@ do { \ do { \ __chk_user_ptr(ptr); \ switch (size) { \ - unsigned char x_u8__; \ - case 1: \ + case 1: { \ + unsigned char x_u8__; \ __get_user_asm(x_u8__, ptr, "b", "=q", label); \ (x) = x_u8__; \ break; \ + } \ case 2: \ __get_user_asm(x, ptr, "w", "=r", label); \ break; \
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 268/1039 libbpf: Add "bool skipped" to struct bpf_map
In reply to Greg Kroah-HartmanFrom: Shuyi Cheng <[email protected]>
[ Upstream commit 229fae38d0fc0d6ff58d57cbeb1432da55e58d4f ]
Fix error: "failed to pin map: Bad file descriptor, path:/sys/fs/bpf/_rodata_str1_1."
In the old kernel, the global data map will not be created, see [0]. So we should skip the pinning of the global data map to avoid bpf_object__pin_maps returning error. Therefore, when the map is not created, we mark “map->skipped" as true and then check during relocation and during pinning.
--- tools/lib/bpf/libbpf.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
tools/lib/bpf/libbpf.c +8 -3
@@ -400,6 +400,7 @@ struct bpf_map {char *pin_path;bool pinned;bool reused; +bool skipped;__u64 map_extra; };
@@ -5003,8 +5004,10 @@ bpf_object__create_maps(struct bpf_object *obj)* kernels. */ if (bpf_map__is_internal (map) && - !kernel_supports (obj,FEAT_GLOBAL_DATA )) + !kernel_supports (obj,FEAT_GLOBAL_DATA )) { + map->skipped = true;continue ; + } retried = false; retry:
@@ -5607,8 +5610,7 @@ bpf_object__relocate_data(struct bpf_object *obj, struct bpf_program *prog) }else {const struct bpf_map *map = &obj->maps[relo->map_idx]; -if (bpf_map__is_internal (map) && - !kernel_supports (obj,FEAT_GLOBAL_DATA )) { +if (map->skipped) {pr_warn ("prog '%s': relo #%d: kernel doesn't support global data\n" , prog->name, i);return -ENOTSUP ;
@@ -7733,6 +7735,9 @@ int bpf_object__pin_maps(struct bpf_object *obj, const char *path)char *pin_path =NULL ;char buf[PATH_MAX ]; +if (map->skipped) +continue ; +if (path) {int len;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 269/1039 selftests: clone3: clone3: add case CLONE3_ARGS_NO_TEST
In reply to Greg Kroah-HartmanFrom: Anders Roxell <[email protected]>
[ Upstream commit a531b0c23c0fc68ad758cc31a74cf612a4dafeb0 ]
Building selftests/clone3 with clang warns about enumeration not handled in switch case:
clone3.c:54:10: warning: enumeration value 'CLONE3_ARGS_NO_TEST' not handled in switch [-Wswitch]
switch (test_mode) {
^Add the missing switch case with a comment.
--- tools/testing/selftests/clone3/clone3.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/testing/selftests/clone3/clone3.c +6 -0
@@ -52,6 +52,12 @@ static int call_clone3(uint64_t flags, size_t size, enum test_mode test_mode) size =sizeof (struct __clone_args );switch (test_mode) { +case CLONE3_ARGS_NO_TEST : +/* +* Uses default 'flags' and 'SIGCHLD' +* assignment. +*/ +break ;case CLONE3_ARGS_ALL_0 : args.flags =0 ; args.exit_signal =0 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 270/1039 selftests: harness: avoid false negatives if test has no ASSERTs
In reply to Greg Kroah-HartmanFrom: Jakub Kicinski <[email protected]>
[ Upstream commit 3abedf4646fdc0036fcb8ebbc3b600667167fafe ]
Test can fail either immediately when ASSERT() failed or at the end if one or more EXPECT() was not met. The exact return code is decided based on the number of successful ASSERT()s.
If test has no ASSERT()s, however, the return code will be 0, as if the test did not fail. Start counting ASSERT()s from 1.
--- tools/testing/selftests/kselftest_harness.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kselftest_harness.h +1 -1
@@ -969,7 +969,7 @@ void __run_test(struct __fixture_metadata *f, t->passed =1 ; t->skip =0 ; t->trigger =0 ; - t->step =0 ; + t->step =1 ; t->no_print =0 ;memset (t->results->reason,0 ,sizeof (t->results->reason));
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 271/1039 crypto: stm32/cryp - fix CTR counter carry
In reply to Greg Kroah-HartmanFrom: Nicolas Toromanoff <[email protected]>
[ Upstream commit 41c76690b0990efacd15d35cfb4e77318cd80ebb ]
STM32 CRYP hardware doesn't manage CTR counter bigger than max U32, as a workaround, at each block the current IV is saved, if the saved IV lower u32 is 0xFFFFFFFF, the full IV is manually incremented, and set in hardware.
--- drivers/crypto/stm32/stm32-cryp.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/crypto/stm32/stm32-cryp.c +13 -14
@@ -163,7 +163,7 @@ struct stm32_cryp {struct scatter_walk in_walk;struct scatter_walk out_walk; -u32 last_ctr[4 ]; +__be32 last_ctr[4 ];u32 gcm_ctr; };
@@ -1217,27 +1217,26 @@ static void stm32_cryp_check_ctr_counter(struct stm32_cryp *cryp) {u32 cr; -if (unlikely (cryp->last_ctr[3 ] ==0xFFFFFFFF )) { - cryp->last_ctr[3 ] =0 ; - cryp->last_ctr[2 ]++; -if (!cryp->last_ctr[2 ]) { - cryp->last_ctr[1 ]++; -if (!cryp->last_ctr[1 ]) - cryp->last_ctr[0 ]++; - } +if (unlikely (cryp->last_ctr[3 ] ==cpu_to_be32 (0xFFFFFFFF ))) { +/* +* In this case, we need to increment manually the ctr counter, +* as HW doesn't handle the U32 carry. +*/ +crypto_inc ((u8 *)cryp->last_ctr,sizeof (cryp->last_ctr)); cr =stm32_cryp_read (cryp,CRYP_CR );stm32_cryp_write (cryp,CRYP_CR , cr & ~CR_CRYPEN ); -stm32_cryp_hw_write_iv (cryp, (__be32 *)cryp->last_ctr); +stm32_cryp_hw_write_iv (cryp, cryp->last_ctr);stm32_cryp_write (cryp,CRYP_CR , cr); } - cryp->last_ctr[0 ] =stm32_cryp_read (cryp,CRYP_IV0LR ); - cryp->last_ctr[1 ] =stm32_cryp_read (cryp,CRYP_IV0RR ); - cryp->last_ctr[2 ] =stm32_cryp_read (cryp,CRYP_IV1LR ); - cryp->last_ctr[3 ] =stm32_cryp_read (cryp,CRYP_IV1RR ); +/* The IV registers are BE */ + cryp->last_ctr[0 ] =cpu_to_be32 (stm32_cryp_read (cryp,CRYP_IV0LR )); + cryp->last_ctr[1 ] =cpu_to_be32 (stm32_cryp_read (cryp,CRYP_IV0RR )); + cryp->last_ctr[2 ] =cpu_to_be32 (stm32_cryp_read (cryp,CRYP_IV1LR )); + cryp->last_ctr[3 ] =cpu_to_be32 (stm32_cryp_read (cryp,CRYP_IV1RR )); }static bool stm32_cryp_irq_read_data (struct stm32_cryp *cryp)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 272/1039 crypto: stm32/cryp - fix xts and race condition in crypto_engine requests
In reply to Greg Kroah-HartmanFrom: Nicolas Toromanoff <[email protected]>
[ Upstream commit d703c7a994ee34b7fa89baf21631fca0aa9f17fc ]
Don't erase key:
If key is erased before the crypto_finalize_.*_request() call, some pending process will run with a key={ 0 }.
Moreover if the key is reset at end of request, it breaks xts chaining mode, as for last xts block (in case input len is not a multiple of block) a new AES request is started without calling again set_key().
--- drivers/crypto/stm32/stm32-cryp.c | 2 -- 1 file changed, 2 deletions(-)
drivers/crypto/stm32/stm32-cryp.c +0 -2
@@ -674,8 +674,6 @@ static void stm32_cryp_finish_req(struct stm32_cryp *cryp, int err)else crypto_finalize_skcipher_request (cryp->engine, cryp->req, err); - -memset (cryp->ctx->key,0 , cryp->ctx->keylen); }static int stm32_cryp_cpu_start (struct stm32_cryp *cryp)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 273/1039 crypto: stm32/cryp - check early input data
In reply to Greg Kroah-HartmanFrom: Nicolas Toromanoff <[email protected]>
[ Upstream commit 39e6e699c7fb92bdb2617b596ca4a4ea35c5d2a7 ]
Some auto tests failed because driver wasn't returning the expected error with some input size/iv value/tag size.
Now:
Return 0 early for empty buffer. (We don't need to start the engine for an empty input buffer).
Accept any valid authsize for gcm(aes).
Return -EINVAL if iv for ccm(aes) is invalid.
Return -EINVAL if buffer size is a not a multiple of algorithm block size.
--- drivers/crypto/stm32/stm32-cryp.c | 114 +++++++++++++++++++++++++++++- 1 file changed, 113 insertions(+), 1 deletion(-)
drivers/crypto/stm32/stm32-cryp.c +113 -1
@@ -799,7 +799,20 @@ static int stm32_cryp_aes_aead_setkey(struct crypto_aead *tfm, const u8 *key,static int stm32_cryp_aes_gcm_setauthsize (struct crypto_aead *tfm,unsigned int authsize) { -return authsize ==AES_BLOCK_SIZE ?0 : -EINVAL ; +switch (authsize) { +case 4 : +case 8 : +case 12 : +case 13 : +case 14 : +case 15 : +case 16 : +break ; +default : +return -EINVAL ; + } + +return 0 ; } static int stm32_cryp_aes_ccm_setauthsize(struct crypto_aead *tfm,
@@ -823,31 +836,61 @@ static int stm32_cryp_aes_ccm_setauthsize(struct crypto_aead *tfm,static int stm32_cryp_aes_ecb_encrypt (struct skcipher_request *req) { +if (req->cryptlen %AES_BLOCK_SIZE ) +return -EINVAL ; + +if (req->cryptlen ==0 ) +return 0 ; +return stm32_cryp_crypt (req,FLG_AES |FLG_ECB |FLG_ENCRYPT ); }static int stm32_cryp_aes_ecb_decrypt (struct skcipher_request *req) { +if (req->cryptlen %AES_BLOCK_SIZE ) +return -EINVAL ; + +if (req->cryptlen ==0 ) +return 0 ; +return stm32_cryp_crypt (req,FLG_AES |FLG_ECB ); }static int stm32_cryp_aes_cbc_encrypt (struct skcipher_request *req) { +if (req->cryptlen %AES_BLOCK_SIZE ) +return -EINVAL ; + +if (req->cryptlen ==0 ) +return 0 ; +return stm32_cryp_crypt (req,FLG_AES |FLG_CBC |FLG_ENCRYPT ); }static int stm32_cryp_aes_cbc_decrypt (struct skcipher_request *req) { +if (req->cryptlen %AES_BLOCK_SIZE ) +return -EINVAL ; + +if (req->cryptlen ==0 ) +return 0 ; +return stm32_cryp_crypt (req,FLG_AES |FLG_CBC ); }static int stm32_cryp_aes_ctr_encrypt (struct skcipher_request *req) { +if (req->cryptlen ==0 ) +return 0 ; +return stm32_cryp_crypt (req,FLG_AES |FLG_CTR |FLG_ENCRYPT ); }static int stm32_cryp_aes_ctr_decrypt (struct skcipher_request *req) { +if (req->cryptlen ==0 ) +return 0 ; +return stm32_cryp_crypt (req,FLG_AES |FLG_CTR ); }
@@ -861,53 +904,122 @@ static int stm32_cryp_aes_gcm_decrypt(struct aead_request *req)return stm32_cryp_aead_crypt (req,FLG_AES |FLG_GCM ); } +static inline int crypto_ccm_check_iv (const u8 *iv) +{ +/* 2 <= L <= 8, so 1 <= L' <= 7. */ +if (iv[0 ] <1 || iv[0 ] >7 ) +return -EINVAL ; + +return 0 ; +} +static int stm32_cryp_aes_ccm_encrypt (struct aead_request *req) { +int err; + + err =crypto_ccm_check_iv (req->iv); +if (err) +return err; +return stm32_cryp_aead_crypt (req,FLG_AES |FLG_CCM |FLG_ENCRYPT ); }static int stm32_cryp_aes_ccm_decrypt (struct aead_request *req) { +int err; + + err =crypto_ccm_check_iv (req->iv); +if (err) +return err; +return stm32_cryp_aead_crypt (req,FLG_AES |FLG_CCM ); }static int stm32_cryp_des_ecb_encrypt (struct skcipher_request *req) { +if (req->cryptlen %DES_BLOCK_SIZE ) +return -EINVAL ; + +if (req->cryptlen ==0 ) +return 0 ; +return stm32_cryp_crypt (req,FLG_DES |FLG_ECB |FLG_ENCRYPT ); }static int stm32_cryp_des_ecb_decrypt (struct skcipher_request *req) { +if (req->cryptlen %DES_BLOCK_SIZE ) +return -EINVAL ; + +if (req->cryptlen ==0 ) +return 0 ; +return stm32_cryp_crypt (req,FLG_DES |FLG_ECB ); }static int stm32_cryp_des_cbc_encrypt (struct skcipher_request *req) { +if (req->cryptlen %DES_BLOCK_SIZE ) +return -EINVAL ; + +if (req->cryptlen ==0 ) +return 0 ; +return stm32_cryp_crypt (req,FLG_DES |FLG_CBC |FLG_ENCRYPT ); }static int stm32_cryp_des_cbc_decrypt (struct skcipher_request *req) { +if (req->cryptlen %DES_BLOCK_SIZE ) +return -EINVAL ; + +if (req->cryptlen ==0 ) +return 0 ; +return stm32_cryp_crypt (req,FLG_DES |FLG_CBC ); }static int stm32_cryp_tdes_ecb_encrypt (struct skcipher_request *req) { +if (req->cryptlen %DES_BLOCK_SIZE ) +return -EINVAL ; + +if (req->cryptlen ==0 ) +return 0 ; +return stm32_cryp_crypt (req,FLG_TDES |FLG_ECB |FLG_ENCRYPT ); }static int stm32_cryp_tdes_ecb_decrypt (struct skcipher_request *req) { +if (req->cryptlen %DES_BLOCK_SIZE ) +return -EINVAL ; + +if (req->cryptlen ==0 ) +return 0 ; +return stm32_cryp_crypt (req,FLG_TDES |FLG_ECB ); }static int stm32_cryp_tdes_cbc_encrypt (struct skcipher_request *req) { +if (req->cryptlen %DES_BLOCK_SIZE ) +return -EINVAL ; + +if (req->cryptlen ==0 ) +return 0 ; +return stm32_cryp_crypt (req,FLG_TDES |FLG_CBC |FLG_ENCRYPT ); }static int stm32_cryp_tdes_cbc_decrypt (struct skcipher_request *req) { +if (req->cryptlen %DES_BLOCK_SIZE ) +return -EINVAL ; + +if (req->cryptlen ==0 ) +return 0 ; +return stm32_cryp_crypt (req,FLG_TDES |FLG_CBC ); }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 274/1039 crypto: stm32/cryp - fix double pm exit
In reply to Greg Kroah-HartmanFrom: Nicolas Toromanoff <[email protected]>
[ Upstream commit 6c12e742785bf9333faf60bfb96575bdd763448e ]
Delete extraneous lines in probe error handling code: pm was disabled twice.
--- drivers/crypto/stm32/stm32-cryp.c | 2 -- 1 file changed, 2 deletions(-)
drivers/crypto/stm32/stm32-cryp.c +0 -2
@@ -2134,8 +2134,6 @@ err_engine1:list_del (&cryp->list);spin_unlock (&cryp_list.lock); -pm_runtime_disable (dev); -pm_runtime_put_noidle (dev);pm_runtime_disable (dev);pm_runtime_put_noidle (dev);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 275/1039 crypto: stm32/cryp - fix lrw chaining mode
In reply to Greg Kroah-HartmanFrom: Nicolas Toromanoff <[email protected]>
[ Upstream commit fa97dc2d48b476ea98199d808d3248d285987e99 ]
This fixes the lrw autotest if lrw uses the CRYP as the AES block cipher provider (as ecb(aes)). At end of request, CRYP should not update the IV in case of ECB chaining mode. Indeed the ECB chaining mode never uses the IV, but the software LRW chaining mode uses the IV field as a counter and due to the (unexpected) update done by CRYP while the AES block process, the counter get a wrong value when the IV overflow.
--- drivers/crypto/stm32/stm32-cryp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/stm32/stm32-cryp.c +1 -1
@@ -644,7 +644,7 @@ static void stm32_cryp_finish_req(struct stm32_cryp *cryp, int err)/* Phase 4 : output tag */ err =stm32_cryp_read_auth_tag (cryp); -if (!err && (!(is_gcm (cryp) ||is_ccm (cryp)))) +if (!err && (!(is_gcm (cryp) ||is_ccm (cryp) ||is_ecb (cryp))))stm32_cryp_get_iv (cryp);if (cryp->sgs_copied) {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 276/1039 crypto: stm32/cryp - fix bugs and crash in tests
In reply to Greg Kroah-HartmanFrom: Nicolas Toromanoff <[email protected]>
[ Upstream commit 4b898d5cfa4d9a0ad5bc82cb5eafdc092394c6a9 ]
Extra crypto manager auto test were crashing or failling due to 2 reasons:
- block in a dead loop (dues to issues in cipher end process management)
- crash due to read/write unmapped memory (this crash was also reported when using openssl afalg engine)
Rework interrupt management, interrupts are masked as soon as they are no more used: if input buffer is fully consumed, "Input FIFO not full" interrupt is masked and if output buffer is full, "Output FIFO not empty" interrupt is masked.
And crypto request finish when input *and* outpout buffer are fully read/write.
About the crash due to unmapped memory, using scatterwalk_copychunks() that will map and copy each block fix the issue.
Using this api and copying full block will also fix unaligned data access, avoid early copy of in/out buffer, and make useless the extra alignment constraint.
--- drivers/crypto/stm32/stm32-cryp.c | 790 +++++++++--------------------- 1 file changed, 243 insertions(+), 547 deletions(-)
drivers/crypto/stm32/stm32-cryp.c +243 -547
@@ -37,7 +37,6 @@/* Mode mask = bits [15..0] */ #define FLG_MODE_MASK GENMASK(15, 0)/* Bit [31..16] status */ -#define FLG_CCM_PADDED_WA BIT(16)/* Registers */ #define CRYP_CR 0x00000000
@@ -105,8 +104,6 @@/* Misc */ #define AES_BLOCK_32 (AES_BLOCK_SIZE / sizeof(u32))#define GCM_CTR_INIT 2 -#define _walked_in (cryp->in_walk.offset - cryp->in_sg->offset) -#define _walked_out (cryp->out_walk.offset - cryp->out_sg->offset)#define CRYP_AUTOSUSPEND_DELAY 50struct stm32_cryp_caps {
@@ -144,21 +141,11 @@ struct stm32_cryp {size_t authsize;size_t hw_blocksize; -size_t total_in; -size_t total_in_save; -size_t total_out; -size_t total_out_save; +size_t payload_in; +size_t header_in; +size_t payload_out; -struct scatterlist *in_sg;struct scatterlist *out_sg; -struct scatterlist *out_sg_save; - -struct scatterlist in_sgl; -struct scatterlist out_sgl; -bool sgs_copied; - -int in_sg_len; -int out_sg_len;struct scatter_walk in_walk;struct scatter_walk out_walk;
@@ -262,6 +249,7 @@ static inline int stm32_cryp_wait_output(struct stm32_cryp *cryp) }static int stm32_cryp_read_auth_tag (struct stm32_cryp *cryp); +static void stm32_cryp_finish_req (struct stm32_cryp *cryp,int err);static struct stm32_cryp *stm32_cryp_find_dev (struct stm32_cryp_ctx *ctx) {
@@ -283,103 +271,6 @@ static struct stm32_cryp *stm32_cryp_find_dev(struct stm32_cryp_ctx *ctx)return cryp; } -static int stm32_cryp_check_aligned (struct scatterlist *sg,size_t total, -size_t align) -{ -int len =0 ; - -if (!total) -return 0 ; - -if (!IS_ALIGNED (total, align)) -return -EINVAL ; - -while (sg) { -if (!IS_ALIGNED (sg->offset,sizeof (u32))) -return -EINVAL ; - -if (!IS_ALIGNED (sg->length, align)) -return -EINVAL ; - - len += sg->length; - sg =sg_next (sg); - } - -if (len != total) -return -EINVAL ; - -return 0 ; -} - -static int stm32_cryp_check_io_aligned (struct stm32_cryp *cryp) -{ -int ret; - - ret =stm32_cryp_check_aligned (cryp->in_sg, cryp->total_in, - cryp->hw_blocksize); -if (ret) -return ret; - - ret =stm32_cryp_check_aligned (cryp->out_sg, cryp->total_out, - cryp->hw_blocksize); - -return ret; -} - -static void sg_copy_buf (void *buf,struct scatterlist *sg, -unsigned int start,unsigned int nbytes,int out) -{ -struct scatter_walk walk; - -if (!nbytes) -return ; - -scatterwalk_start (&walk, sg); -scatterwalk_advance (&walk, start); -scatterwalk_copychunks (buf, &walk, nbytes, out); -scatterwalk_done (&walk, out,0 ); -} - -static int stm32_cryp_copy_sgs (struct stm32_cryp *cryp) -{ -void *buf_in, *buf_out; -int pages, total_in, total_out; - -if (!stm32_cryp_check_io_aligned (cryp)) { - cryp->sgs_copied =0 ; -return 0 ; - } - - total_in =ALIGN (cryp->total_in, cryp->hw_blocksize); - pages = total_in ?get_order (total_in) :1 ; - buf_in = (void *)__get_free_pages (GFP_ATOMIC , pages); - - total_out =ALIGN (cryp->total_out, cryp->hw_blocksize); - pages = total_out ?get_order (total_out) :1 ; - buf_out = (void *)__get_free_pages (GFP_ATOMIC , pages); - -if (!buf_in || !buf_out) { -dev_err (cryp->dev,"Can't allocate pages when unaligned\n" ); - cryp->sgs_copied =0 ; -return -EFAULT ; - } - -sg_copy_buf (buf_in, cryp->in_sg,0 , cryp->total_in,0 ); - -sg_init_one (&cryp->in_sgl, buf_in, total_in); - cryp->in_sg = &cryp->in_sgl; - cryp->in_sg_len =1 ; - -sg_init_one (&cryp->out_sgl, buf_out, total_out); - cryp->out_sg_save = cryp->out_sg; - cryp->out_sg = &cryp->out_sgl; - cryp->out_sg_len =1 ; - - cryp->sgs_copied =1 ; - -return 0 ; -} -static void stm32_cryp_hw_write_iv (struct stm32_cryp *cryp,__be32 *iv) {if (!iv)
@@ -481,16 +372,99 @@ static int stm32_cryp_gcm_init(struct stm32_cryp *cryp, u32 cfg)/* Wait for end of processing */ ret =stm32_cryp_wait_enable (cryp); -if (ret) +if (ret) {dev_err (cryp->dev,"Timeout (gcm init)\n" ); +return ret; + } -return ret; +/* Prepare next phase */ +if (cryp->areq->assoclen) { + cfg |=CR_PH_HEADER ; +stm32_cryp_write (cryp,CRYP_CR , cfg); + }else if (stm32_cryp_get_input_text_len (cryp)) { + cfg |=CR_PH_PAYLOAD ; +stm32_cryp_write (cryp,CRYP_CR , cfg); + } + +return 0 ; +} + +static void stm32_crypt_gcmccm_end_header (struct stm32_cryp *cryp) +{ +u32 cfg; +int err; + +/* Check if whole header written */ +if (!cryp->header_in) { +/* Wait for completion */ + err =stm32_cryp_wait_busy (cryp); +if (err) { +dev_err (cryp->dev,"Timeout (gcm/ccm header)\n" ); +stm32_cryp_write (cryp,CRYP_IMSCR ,0 ); +stm32_cryp_finish_req (cryp, err); +return ; + } + +if (stm32_cryp_get_input_text_len (cryp)) { +/* Phase 3 : payload */ + cfg =stm32_cryp_read (cryp,CRYP_CR ); + cfg &= ~CR_CRYPEN ; +stm32_cryp_write (cryp,CRYP_CR , cfg); + + cfg &= ~CR_PH_MASK ; + cfg |=CR_PH_PAYLOAD |CR_CRYPEN ; +stm32_cryp_write (cryp,CRYP_CR , cfg); + }else { +/* +* Phase 4 : tag. +* Nothing to read, nothing to write, caller have to +* end request +*/ + } + } +} + +static void stm32_cryp_write_ccm_first_header (struct stm32_cryp *cryp) +{ +unsigned int i; +size_t written; +size_t len; +u32 alen = cryp->areq->assoclen; +u32 block[AES_BLOCK_32 ] = {0 }; +u8 *b8 = (u8 *)block; + +if (alen <=65280 ) { +/* Write first u32 of B1 */ + b8[0 ] = (alen >>8 ) &0xFF ; + b8[1 ] = alen &0xFF ; + len =2 ; + }else { +/* Build the two first u32 of B1 */ + b8[0 ] =0xFF ; + b8[1 ] =0xFE ; + b8[2 ] = (alen &0xFF000000 ) >>24 ; + b8[3 ] = (alen &0x00FF0000 ) >>16 ; + b8[4 ] = (alen &0x0000FF00 ) >>8 ; + b8[5 ] = alen &0x000000FF ; + len =6 ; + } + + written =min_t (size_t,AES_BLOCK_SIZE - len, alen); + +scatterwalk_copychunks ((char *)block + len, &cryp->in_walk, written,0 ); +for (i =0 ; i <AES_BLOCK_32 ; i++) +stm32_cryp_write (cryp,CRYP_DIN , block[i]); + + cryp->header_in -= written; + +stm32_crypt_gcmccm_end_header (cryp); }static int stm32_cryp_ccm_init (struct stm32_cryp *cryp,u32 cfg) {int ret; -u8 iv[AES_BLOCK_SIZE ], b0[AES_BLOCK_SIZE ]; +u32 iv_32[AES_BLOCK_32 ], b0_32[AES_BLOCK_32 ]; +u8 *iv = (u8 *)iv_32, *b0 = (u8 *)b0_32;__be32 *bd;u32 *d;unsigned int i, textlen;
@@ -531,17 +505,30 @@ static int stm32_cryp_ccm_init(struct stm32_cryp *cryp, u32 cfg)/* Wait for end of processing */ ret =stm32_cryp_wait_enable (cryp); -if (ret) +if (ret) {dev_err (cryp->dev,"Timeout (ccm init)\n" ); +return ret; + } -return ret; +/* Prepare next phase */ +if (cryp->areq->assoclen) { + cfg |=CR_PH_HEADER |CR_CRYPEN ; +stm32_cryp_write (cryp,CRYP_CR , cfg); + +/* Write first (special) block (may move to next phase [payload]) */ +stm32_cryp_write_ccm_first_header (cryp); + }else if (stm32_cryp_get_input_text_len (cryp)) { + cfg |=CR_PH_PAYLOAD ; +stm32_cryp_write (cryp,CRYP_CR , cfg); + } + +return 0 ; }static int stm32_cryp_hw_init (struct stm32_cryp *cryp) {int ret;u32 cfg, hw_mode; -pm_runtime_resume_and_get (cryp->dev);/* Disable interrupt */
@@ -605,16 +592,6 @@ static int stm32_cryp_hw_init(struct stm32_cryp *cryp)if (ret)return ret; -/* Phase 2 : header (authenticated data) */ -if (cryp->areq->assoclen) { - cfg |=CR_PH_HEADER ; - }else if (stm32_cryp_get_input_text_len (cryp)) { - cfg |=CR_PH_PAYLOAD ; -stm32_cryp_write (cryp,CRYP_CR , cfg); - }else { - cfg |=CR_PH_INIT ; - } -break ;case CR_DES_CBC :
@@ -633,8 +610,6 @@ static int stm32_cryp_hw_init(struct stm32_cryp *cryp)stm32_cryp_write (cryp,CRYP_CR , cfg); - cryp->flags &= ~FLG_CCM_PADDED_WA ; -return 0 ; }
@@ -647,25 +622,6 @@ static void stm32_cryp_finish_req(struct stm32_cryp *cryp, int err)if (!err && (!(is_gcm (cryp) ||is_ccm (cryp) ||is_ecb (cryp))))stm32_cryp_get_iv (cryp); -if (cryp->sgs_copied) { -void *buf_in, *buf_out; -int pages, len; - - buf_in =sg_virt (&cryp->in_sgl); - buf_out =sg_virt (&cryp->out_sgl); - -sg_copy_buf (buf_out, cryp->out_sg_save,0 , - cryp->total_out_save,1 ); - - len =ALIGN (cryp->total_in_save, cryp->hw_blocksize); - pages = len ?get_order (len) :1 ; -free_pages ((unsigned long )buf_in, pages); - - len =ALIGN (cryp->total_out_save, cryp->hw_blocksize); - pages = len ?get_order (len) :1 ; -free_pages ((unsigned long )buf_out, pages); - } -pm_runtime_mark_last_busy (cryp->dev);pm_runtime_put_autosuspend (cryp->dev);
@@ -1029,6 +985,7 @@ static int stm32_cryp_prepare_req(struct skcipher_request *req,struct stm32_cryp_ctx *ctx;struct stm32_cryp *cryp;struct stm32_cryp_reqctx *rctx; +struct scatterlist *in_sg;int ret;if (!req && !areq)
@@ -1054,76 +1011,55 @@ static int stm32_cryp_prepare_req(struct skcipher_request *req,if (req) { cryp->req = req; cryp->areq =NULL ; - cryp->total_in = req->cryptlen; - cryp->total_out = cryp->total_in; + cryp->header_in =0 ; + cryp->payload_in = req->cryptlen; + cryp->payload_out = req->cryptlen; + cryp->authsize =0 ; }else {/* * Length of input and output data: * Encryption case: -* INPUT = AssocData || PlainText +* INPUT = AssocData || PlainText * <- assoclen -> <- cryptlen -> -* <------- total_in -----------> * -* OUTPUT = AssocData || CipherText || AuthTag -* <- assoclen -> <- cryptlen -> <- authsize -> -* <---------------- total_out -----------------> +* OUTPUT = AssocData || CipherText || AuthTag +* <- assoclen -> <-- cryptlen --> <- authsize -> * * Decryption case: -* INPUT = AssocData || CipherText || AuthTag -* <- assoclen -> <--------- cryptlen ---------> -* <- authsize -> -* <---------------- total_in ------------------> +* INPUT = AssocData || CipherTex || AuthTag +* <- assoclen ---> <---------- cryptlen ----------> * -* OUTPUT = AssocData || PlainText -* <- assoclen -> <- crypten - authsize -> -* <---------- total_out -----------------> +* OUTPUT = AssocData || PlainText +* <- assoclen -> <- cryptlen - authsize -> */ cryp->areq = areq; cryp->req =NULL ; cryp->authsize =crypto_aead_authsize (crypto_aead_reqtfm (areq)); - cryp->total_in = areq->assoclen + areq->cryptlen; -if (is_encrypt (cryp)) -/* Append auth tag to output */ - cryp->total_out = cryp->total_in + cryp->authsize; -else -/* No auth tag in output */ - cryp->total_out = cryp->total_in - cryp->authsize; +if (is_encrypt (cryp)) { + cryp->payload_in = areq->cryptlen; + cryp->header_in = areq->assoclen; + cryp->payload_out = areq->cryptlen; + }else { + cryp->payload_in = areq->cryptlen - cryp->authsize; + cryp->header_in = areq->assoclen; + cryp->payload_out = cryp->payload_in; + } } - cryp->total_in_save = cryp->total_in; - cryp->total_out_save = cryp->total_out; + in_sg = req ? req->src : areq->src; +scatterwalk_start (&cryp->in_walk, in_sg); - cryp->in_sg = req ? req->src : areq->src; cryp->out_sg = req ? req->dst : areq->dst; - cryp->out_sg_save = cryp->out_sg; - - cryp->in_sg_len =sg_nents_for_len (cryp->in_sg, cryp->total_in); -if (cryp->in_sg_len <0 ) { -dev_err (cryp->dev,"Cannot get in_sg_len\n" ); - ret = cryp->in_sg_len; -return ret; - } - - cryp->out_sg_len =sg_nents_for_len (cryp->out_sg, cryp->total_out); -if (cryp->out_sg_len <0 ) { -dev_err (cryp->dev,"Cannot get out_sg_len\n" ); - ret = cryp->out_sg_len; -return ret; - } - - ret =stm32_cryp_copy_sgs (cryp); -if (ret) -return ret; - -scatterwalk_start (&cryp->in_walk, cryp->in_sg);scatterwalk_start (&cryp->out_walk, cryp->out_sg);if (is_gcm (cryp) ||is_ccm (cryp)) {/* In output, jump after assoc data */ -scatterwalk_advance (&cryp->out_walk, cryp->areq->assoclen); - cryp->total_out -= cryp->areq->assoclen; +scatterwalk_copychunks (NULL , &cryp->out_walk, cryp->areq->assoclen,2 ); } +if (is_ctr (cryp)) +memset (cryp->last_ctr,0 ,sizeof (cryp->last_ctr)); + ret =stm32_cryp_hw_init (cryp);return ret; }
@@ -1171,8 +1107,7 @@ static int stm32_cryp_aead_one_req(struct crypto_engine *engine, void *areq)if (!cryp)return -ENODEV ; -if (unlikely (!cryp->areq->assoclen && - !stm32_cryp_get_input_text_len (cryp))) { +if (unlikely (!cryp->payload_in && !cryp->header_in)) {/* No input data to process: get tag and finish */ stm32_cryp_finish_req (cryp,0 );return 0 ;
@@ -1181,43 +1116,10 @@ static int stm32_cryp_aead_one_req(struct crypto_engine *engine, void *areq)return stm32_cryp_cpu_start (cryp); } -static u32 *stm32_cryp_next_out (struct stm32_cryp *cryp,u32 *dst, -unsigned int n) -{ -scatterwalk_advance (&cryp->out_walk, n); - -if (unlikely (cryp->out_sg->length == _walked_out)) { - cryp->out_sg =sg_next (cryp->out_sg); -if (cryp->out_sg) { -scatterwalk_start (&cryp->out_walk, cryp->out_sg); -return (sg_virt (cryp->out_sg) + _walked_out); - } - } - -return (u32 *)((u8 *)dst + n); -} - -static u32 *stm32_cryp_next_in (struct stm32_cryp *cryp,u32 *src, -unsigned int n) -{ -scatterwalk_advance (&cryp->in_walk, n); - -if (unlikely (cryp->in_sg->length == _walked_in)) { - cryp->in_sg =sg_next (cryp->in_sg); -if (cryp->in_sg) { -scatterwalk_start (&cryp->in_walk, cryp->in_sg); -return (sg_virt (cryp->in_sg) + _walked_in); - } - } - -return (u32 *)((u8 *)src + n); -} -static int stm32_cryp_read_auth_tag (struct stm32_cryp *cryp) { -u32 cfg, size_bit, *dst, d32; -u8 *d8; -unsigned int i, j; +u32 cfg, size_bit; +unsigned int i;int ret =0 ;/* Update Config */
@@ -1240,7 +1142,7 @@ static int stm32_cryp_read_auth_tag(struct stm32_cryp *cryp)stm32_cryp_write (cryp,CRYP_DIN , size_bit); size_bit =is_encrypt (cryp) ? cryp->areq->cryptlen : - cryp->areq->cryptlen -AES_BLOCK_SIZE ; + cryp->areq->cryptlen - cryp->authsize; size_bit *=8 ;if (cryp->caps->swap_final) size_bit = (__force u32 )cpu_to_be32 (size_bit);
@@ -1249,11 +1151,9 @@ static int stm32_cryp_read_auth_tag(struct stm32_cryp *cryp)stm32_cryp_write (cryp,CRYP_DIN , size_bit); }else {/* CCM: write CTR0 */ -u8 iv[AES_BLOCK_SIZE ]; -u32 *iv32 = (u32 *)iv; -__be32 *biv; - - biv = (void *)iv; +u32 iv32[AES_BLOCK_32 ]; +u8 *iv = (u8 *)iv32; +__be32 *biv = (__be32 *)iv32;memcpy (iv, cryp->areq->iv,AES_BLOCK_SIZE );memset (iv +AES_BLOCK_SIZE -1 - iv[0 ],0 , iv[0 ] +1 );
@@ -1275,39 +1175,18 @@ static int stm32_cryp_read_auth_tag(struct stm32_cryp *cryp) }if (is_encrypt (cryp)) { +u32 out_tag[AES_BLOCK_32 ]; +/* Get and write tag */ - dst =sg_virt (cryp->out_sg) + _walked_out; +for (i =0 ; i <AES_BLOCK_32 ; i++) + out_tag[i] =stm32_cryp_read (cryp,CRYP_DOUT ); -for (i =0 ; i <AES_BLOCK_32 ; i++) { -if (cryp->total_out >=sizeof (u32)) { -/* Read a full u32 */ - *dst =stm32_cryp_read (cryp,CRYP_DOUT ); - - dst =stm32_cryp_next_out (cryp, dst, -sizeof (u32)); - cryp->total_out -=sizeof (u32); - }else if (!cryp->total_out) { -/* Empty fifo out (data from input padding) */ -stm32_cryp_read (cryp,CRYP_DOUT ); - }else { -/* Read less than an u32 */ - d32 =stm32_cryp_read (cryp,CRYP_DOUT ); - d8 = (u8 *)&d32; - -for (j =0 ; j < cryp->total_out; j++) { - *((u8 *)dst) = *(d8++); - dst =stm32_cryp_next_out (cryp, dst,1 ); - } - cryp->total_out =0 ; - } - } +scatterwalk_copychunks (out_tag, &cryp->out_walk, cryp->authsize,1 ); }else {/* Get and check tag */ u32 in_tag[AES_BLOCK_32 ], out_tag[AES_BLOCK_32 ]; -scatterwalk_map_and_copy (in_tag, cryp->in_sg, - cryp->total_in_save - cryp->authsize, - cryp->authsize,0 ); +scatterwalk_copychunks (in_tag, &cryp->in_walk, cryp->authsize,0 );for (i =0 ; i <AES_BLOCK_32 ; i++) out_tag[i] =stm32_cryp_read (cryp,CRYP_DOUT );
@@ -1349,92 +1228,37 @@ static void stm32_cryp_check_ctr_counter(struct stm32_cryp *cryp) cryp->last_ctr[3 ] =cpu_to_be32 (stm32_cryp_read (cryp,CRYP_IV1RR )); } -static bool stm32_cryp_irq_read_data (struct stm32_cryp *cryp) +static void stm32_cryp_irq_read_data (struct stm32_cryp *cryp) { -unsigned int i, j; -u32 d32, *dst; -u8 *d8; -size_t tag_size; - -/* Do no read tag now (if any) */ -if (is_encrypt (cryp) && (is_gcm (cryp) ||is_ccm (cryp))) - tag_size = cryp->authsize; -else - tag_size =0 ; - - dst =sg_virt (cryp->out_sg) + _walked_out; - -for (i =0 ; i < cryp->hw_blocksize /sizeof (u32); i++) { -if (likely (cryp->total_out - tag_size >=sizeof (u32))) { -/* Read a full u32 */ - *dst =stm32_cryp_read (cryp,CRYP_DOUT ); +unsigned int i; +u32 block[AES_BLOCK_32 ]; - dst =stm32_cryp_next_out (cryp, dst,sizeof (u32)); - cryp->total_out -=sizeof (u32); - }else if (cryp->total_out == tag_size) { -/* Empty fifo out (data from input padding) */ - d32 =stm32_cryp_read (cryp,CRYP_DOUT ); - }else { -/* Read less than an u32 */ - d32 =stm32_cryp_read (cryp,CRYP_DOUT ); - d8 = (u8 *)&d32; - -for (j =0 ; j < cryp->total_out - tag_size; j++) { - *((u8 *)dst) = *(d8++); - dst =stm32_cryp_next_out (cryp, dst,1 ); - } - cryp->total_out = tag_size; - } - } +for (i =0 ; i < cryp->hw_blocksize /sizeof (u32); i++) + block[i] =stm32_cryp_read (cryp,CRYP_DOUT ); -return !(cryp->total_out - tag_size) || !cryp->total_in; +scatterwalk_copychunks (block, &cryp->out_walk,min_t (size_t, cryp->hw_blocksize, + cryp->payload_out),1 ); + cryp->payload_out -=min_t (size_t, cryp->hw_blocksize, + cryp->payload_out); }static void stm32_cryp_irq_write_block (struct stm32_cryp *cryp) { -unsigned int i, j; -u32 *src; -u8 d8[4 ]; -size_t tag_size; - -/* Do no write tag (if any) */ -if (is_decrypt (cryp) && (is_gcm (cryp) ||is_ccm (cryp))) - tag_size = cryp->authsize; -else - tag_size =0 ; - - src =sg_virt (cryp->in_sg) + _walked_in; +unsigned int i; +u32 block[AES_BLOCK_32 ] = {0 }; -for (i =0 ; i < cryp->hw_blocksize /sizeof (u32); i++) { -if (likely (cryp->total_in - tag_size >=sizeof (u32))) { -/* Write a full u32 */ -stm32_cryp_write (cryp,CRYP_DIN , *src); +scatterwalk_copychunks (block, &cryp->in_walk,min_t (size_t, cryp->hw_blocksize, + cryp->payload_in),0 ); +for (i =0 ; i < cryp->hw_blocksize /sizeof (u32); i++) +stm32_cryp_write (cryp,CRYP_DIN , block[i]); - src =stm32_cryp_next_in (cryp, src,sizeof (u32)); - cryp->total_in -=sizeof (u32); - }else if (cryp->total_in == tag_size) { -/* Write padding data */ -stm32_cryp_write (cryp,CRYP_DIN ,0 ); - }else { -/* Write less than an u32 */ -memset (d8,0 ,sizeof (u32)); -for (j =0 ; j < cryp->total_in - tag_size; j++) { - d8[j] = *((u8 *)src); - src =stm32_cryp_next_in (cryp, src,1 ); - } - -stm32_cryp_write (cryp,CRYP_DIN , *(u32 *)d8); - cryp->total_in = tag_size; - } - } + cryp->payload_in -=min_t (size_t, cryp->hw_blocksize, cryp->payload_in); }static void stm32_cryp_irq_write_gcm_padded_data (struct stm32_cryp *cryp) {int err; -u32 cfg, tmp[AES_BLOCK_32 ]; -size_t total_in_ori = cryp->total_in; -struct scatterlist *out_sg_ori = cryp->out_sg; +u32 cfg, block[AES_BLOCK_32 ] = {0 };unsigned int i;/* 'Special workaround' procedure described in the datasheet */
@@ -1459,18 +1283,25 @@ static void stm32_cryp_irq_write_gcm_padded_data(struct stm32_cryp *cryp)/* b) pad and write the last block */ stm32_cryp_irq_write_block (cryp); - cryp->total_in = total_in_ori; +/* wait end of process */ err =stm32_cryp_wait_output (cryp);if (err) { -dev_err (cryp->dev,"Timeout (write gcm header)\n" ); +dev_err (cryp->dev,"Timeout (write gcm last data)\n" );return stm32_cryp_finish_req (cryp, err); }/* c) get and store encrypted data */ -stm32_cryp_irq_read_data (cryp); -scatterwalk_map_and_copy (tmp, out_sg_ori, - cryp->total_in_save - total_in_ori, - total_in_ori,0 ); +/* +* Same code as stm32_cryp_irq_read_data(), but we want to store +* block value +*/ +for (i =0 ; i < cryp->hw_blocksize /sizeof (u32); i++) + block[i] =stm32_cryp_read (cryp,CRYP_DOUT ); + +scatterwalk_copychunks (block, &cryp->out_walk,min_t (size_t, cryp->hw_blocksize, + cryp->payload_out),1 ); + cryp->payload_out -=min_t (size_t, cryp->hw_blocksize, + cryp->payload_out);/* d) change mode back to AES GCM */ cfg &= ~CR_ALGO_MASK ;
@@ -1483,19 +1314,13 @@ static void stm32_cryp_irq_write_gcm_padded_data(struct stm32_cryp *cryp)stm32_cryp_write (cryp,CRYP_CR , cfg);/* f) write padded data */ -for (i =0 ; i <AES_BLOCK_32 ; i++) { -if (cryp->total_in) -stm32_cryp_write (cryp,CRYP_DIN , tmp[i]); -else -stm32_cryp_write (cryp,CRYP_DIN ,0 ); - - cryp->total_in -=min_t (size_t,sizeof (u32), cryp->total_in); - } +for (i =0 ; i <AES_BLOCK_32 ; i++) +stm32_cryp_write (cryp,CRYP_DIN , block[i]);/* g) Empty fifo out */ err =stm32_cryp_wait_output (cryp);if (err) { -dev_err (cryp->dev,"Timeout (write gcm header)\n" ); +dev_err (cryp->dev,"Timeout (write gcm padded data)\n" );return stm32_cryp_finish_req (cryp, err); }
@@ -1508,16 +1333,14 @@ static void stm32_cryp_irq_write_gcm_padded_data(struct stm32_cryp *cryp)static void stm32_cryp_irq_set_npblb (struct stm32_cryp *cryp) { -u32 cfg, payload_bytes; +u32 cfg;/* disable ip, set NPBLB and reneable ip */ cfg =stm32_cryp_read (cryp,CRYP_CR ); cfg &= ~CR_CRYPEN ;stm32_cryp_write (cryp,CRYP_CR , cfg); - payload_bytes =is_decrypt (cryp) ? cryp->total_in - cryp->authsize : - cryp->total_in; - cfg |= (cryp->hw_blocksize - payload_bytes) <<CR_NBPBL_SHIFT ; + cfg |= (cryp->hw_blocksize - cryp->payload_in) <<CR_NBPBL_SHIFT ; cfg |=CR_CRYPEN ;stm32_cryp_write (cryp,CRYP_CR , cfg); }
@@ -1526,13 +1349,11 @@ static void stm32_cryp_irq_write_ccm_padded_data(struct stm32_cryp *cryp) {int err =0 ;u32 cfg, iv1tmp; -u32 cstmp1[AES_BLOCK_32 ], cstmp2[AES_BLOCK_32 ], tmp[AES_BLOCK_32 ]; -size_t last_total_out, total_in_ori = cryp->total_in; -struct scatterlist *out_sg_ori = cryp->out_sg; +u32 cstmp1[AES_BLOCK_32 ], cstmp2[AES_BLOCK_32 ]; +u32 block[AES_BLOCK_32 ] = {0 };unsigned int i;/* 'Special workaround' procedure described in the datasheet */ - cryp->flags |=FLG_CCM_PADDED_WA ;/* a) disable ip */ stm32_cryp_write (cryp,CRYP_IMSCR ,0 );
@@ -1562,7 +1383,7 @@ static void stm32_cryp_irq_write_ccm_padded_data(struct stm32_cryp *cryp)/* b) pad and write the last block */ stm32_cryp_irq_write_block (cryp); - cryp->total_in = total_in_ori; +/* wait end of process */ err =stm32_cryp_wait_output (cryp);if (err) {dev_err (cryp->dev,"Timeout (wite ccm padded data)\n" );
@@ -1570,13 +1391,16 @@ static void stm32_cryp_irq_write_ccm_padded_data(struct stm32_cryp *cryp) }/* c) get and store decrypted data */ - last_total_out = cryp->total_out; -stm32_cryp_irq_read_data (cryp); +/* +* Same code as stm32_cryp_irq_read_data(), but we want to store +* block value +*/ +for (i =0 ; i < cryp->hw_blocksize /sizeof (u32); i++) + block[i] =stm32_cryp_read (cryp,CRYP_DOUT ); -memset (tmp,0 ,sizeof (tmp)); -scatterwalk_map_and_copy (tmp, out_sg_ori, - cryp->total_out_save - last_total_out, - last_total_out,0 ); +scatterwalk_copychunks (block, &cryp->out_walk,min_t (size_t, cryp->hw_blocksize, + cryp->payload_out),1 ); + cryp->payload_out -=min_t (size_t, cryp->hw_blocksize, cryp->payload_out);/* d) Load again CRYP_CSGCMCCMxR */ for (i =0 ; i <ARRAY_SIZE (cstmp2); i++)
@@ -1593,10 +1417,10 @@ static void stm32_cryp_irq_write_ccm_padded_data(struct stm32_cryp *cryp)stm32_cryp_write (cryp,CRYP_CR , cfg);/* g) XOR and write padded data */ -for (i =0 ; i <ARRAY_SIZE (tmp); i++) { - tmp[i] ^= cstmp1[i]; - tmp[i] ^= cstmp2[i]; -stm32_cryp_write (cryp,CRYP_DIN , tmp[i]); +for (i =0 ; i <ARRAY_SIZE (block); i++) { + block[i] ^= cstmp1[i]; + block[i] ^= cstmp2[i]; +stm32_cryp_write (cryp,CRYP_DIN , block[i]); }/* h) wait for completion */
@@ -1610,30 +1434,34 @@ static void stm32_cryp_irq_write_ccm_padded_data(struct stm32_cryp *cryp)static void stm32_cryp_irq_write_data (struct stm32_cryp *cryp) { -if (unlikely (!cryp->total_in)) { +if (unlikely (!cryp->payload_in)) {dev_warn (cryp->dev,"No more data to process\n" );return ; } -if (unlikely (cryp->total_in <AES_BLOCK_SIZE && +if (unlikely (cryp->payload_in <AES_BLOCK_SIZE && (stm32_cryp_get_hw_mode (cryp) ==CR_AES_GCM ) &&is_encrypt (cryp))) {/* Padding for AES GCM encryption */ -if (cryp->caps->padding_wa) +if (cryp->caps->padding_wa) {/* Special case 1 */ -return stm32_cryp_irq_write_gcm_padded_data (cryp); +stm32_cryp_irq_write_gcm_padded_data (cryp); +return ; + }/* Setting padding bytes (NBBLB) */ stm32_cryp_irq_set_npblb (cryp); } -if (unlikely ((cryp->total_in - cryp->authsize <AES_BLOCK_SIZE ) && +if (unlikely ((cryp->payload_in <AES_BLOCK_SIZE ) && (stm32_cryp_get_hw_mode (cryp) ==CR_AES_CCM ) &&is_decrypt (cryp))) {/* Padding for AES CCM decryption */ -if (cryp->caps->padding_wa) +if (cryp->caps->padding_wa) {/* Special case 2 */ -return stm32_cryp_irq_write_ccm_padded_data (cryp); +stm32_cryp_irq_write_ccm_padded_data (cryp); +return ; + }/* Setting padding bytes (NBBLB) */ stm32_cryp_irq_set_npblb (cryp);
@@ -1645,192 +1473,60 @@ static void stm32_cryp_irq_write_data(struct stm32_cryp *cryp)stm32_cryp_irq_write_block (cryp); } -static void stm32_cryp_irq_write_gcm_header (struct stm32_cryp *cryp) +static void stm32_cryp_irq_write_gcmccm_header (struct stm32_cryp *cryp) { -int err; -unsigned int i, j; -u32 cfg, *src; - - src =sg_virt (cryp->in_sg) + _walked_in; - -for (i =0 ; i <AES_BLOCK_32 ; i++) { -stm32_cryp_write (cryp,CRYP_DIN , *src); - - src =stm32_cryp_next_in (cryp, src,sizeof (u32)); - cryp->total_in -=min_t (size_t,sizeof (u32), cryp->total_in); - -/* Check if whole header written */ -if ((cryp->total_in_save - cryp->total_in) == - cryp->areq->assoclen) { -/* Write padding if needed */ -for (j = i +1 ; j <AES_BLOCK_32 ; j++) -stm32_cryp_write (cryp,CRYP_DIN ,0 ); - -/* Wait for completion */ - err =stm32_cryp_wait_busy (cryp); -if (err) { -dev_err (cryp->dev,"Timeout (gcm header)\n" ); -return stm32_cryp_finish_req (cryp, err); - } - -if (stm32_cryp_get_input_text_len (cryp)) { -/* Phase 3 : payload */ - cfg =stm32_cryp_read (cryp,CRYP_CR ); - cfg &= ~CR_CRYPEN ; -stm32_cryp_write (cryp,CRYP_CR , cfg); - - cfg &= ~CR_PH_MASK ; - cfg |=CR_PH_PAYLOAD ; - cfg |=CR_CRYPEN ; -stm32_cryp_write (cryp,CRYP_CR , cfg); - }else { -/* Phase 4 : tag */ -stm32_cryp_write (cryp,CRYP_IMSCR ,0 ); -stm32_cryp_finish_req (cryp,0 ); - } - -break ; - } - -if (!cryp->total_in) -break ; - } -} +unsigned int i; +u32 block[AES_BLOCK_32 ] = {0 }; +size_t written; -static void stm32_cryp_irq_write_ccm_header (struct stm32_cryp *cryp) -{ -int err; -unsigned int i =0 , j, k; -u32 alen, cfg, *src; -u8 d8[4 ]; - - src =sg_virt (cryp->in_sg) + _walked_in; - alen = cryp->areq->assoclen; - -if (!_walked_in) { -if (cryp->areq->assoclen <=65280 ) { -/* Write first u32 of B1 */ - d8[0 ] = (alen >>8 ) &0xFF ; - d8[1 ] = alen &0xFF ; - d8[2 ] = *((u8 *)src); - src =stm32_cryp_next_in (cryp, src,1 ); - d8[3 ] = *((u8 *)src); - src =stm32_cryp_next_in (cryp, src,1 ); - -stm32_cryp_write (cryp,CRYP_DIN , *(u32 *)d8); - i++; - - cryp->total_in -=min_t (size_t,2 , cryp->total_in); - }else { -/* Build the two first u32 of B1 */ - d8[0 ] =0xFF ; - d8[1 ] =0xFE ; - d8[2 ] = alen &0xFF000000 ; - d8[3 ] = alen &0x00FF0000 ; - -stm32_cryp_write (cryp,CRYP_DIN , *(u32 *)d8); - i++; - - d8[0 ] = alen &0x0000FF00 ; - d8[1 ] = alen &0x000000FF ; - d8[2 ] = *((u8 *)src); - src =stm32_cryp_next_in (cryp, src,1 ); - d8[3 ] = *((u8 *)src); - src =stm32_cryp_next_in (cryp, src,1 ); - -stm32_cryp_write (cryp,CRYP_DIN , *(u32 *)d8); - i++; - - cryp->total_in -=min_t (size_t,2 , cryp->total_in); - } - } + written =min_t (size_t,AES_BLOCK_SIZE , cryp->header_in); -/* Write next u32 */ -for (; i <AES_BLOCK_32 ; i++) { -/* Build an u32 */ -memset (d8,0 ,sizeof (u32)); -for (k =0 ; k <sizeof (u32); k++) { - d8[k] = *((u8 *)src); - src =stm32_cryp_next_in (cryp, src,1 ); - - cryp->total_in -=min_t (size_t,1 , cryp->total_in); -if ((cryp->total_in_save - cryp->total_in) == alen) -break ; - } +scatterwalk_copychunks (block, &cryp->in_walk, written,0 ); +for (i =0 ; i <AES_BLOCK_32 ; i++) +stm32_cryp_write (cryp,CRYP_DIN , block[i]); -stm32_cryp_write (cryp,CRYP_DIN , *(u32 *)d8); - -if ((cryp->total_in_save - cryp->total_in) == alen) { -/* Write padding if needed */ -for (j = i +1 ; j <AES_BLOCK_32 ; j++) -stm32_cryp_write (cryp,CRYP_DIN ,0 ); - -/* Wait for completion */ - err =stm32_cryp_wait_busy (cryp); -if (err) { -dev_err (cryp->dev,"Timeout (ccm header)\n" ); -return stm32_cryp_finish_req (cryp, err); - } - -if (stm32_cryp_get_input_text_len (cryp)) { -/* Phase 3 : payload */ - cfg =stm32_cryp_read (cryp,CRYP_CR ); - cfg &= ~CR_CRYPEN ; -stm32_cryp_write (cryp,CRYP_CR , cfg); - - cfg &= ~CR_PH_MASK ; - cfg |=CR_PH_PAYLOAD ; - cfg |=CR_CRYPEN ; -stm32_cryp_write (cryp,CRYP_CR , cfg); - }else { -/* Phase 4 : tag */ -stm32_cryp_write (cryp,CRYP_IMSCR ,0 ); -stm32_cryp_finish_req (cryp,0 ); - } + cryp->header_in -= written; -break ; - } - } +stm32_crypt_gcmccm_end_header (cryp); }static irqreturn_t stm32_cryp_irq_thread (int irq,void *arg) {struct stm32_cryp *cryp = arg;u32 ph; +u32 it_mask =stm32_cryp_read (cryp,CRYP_IMSCR );if (cryp->irq_status &MISR_OUT )/* Output FIFO IRQ: read data */ -if (unlikely (stm32_cryp_irq_read_data (cryp))) { -/* All bytes processed, finish */ -stm32_cryp_write (cryp,CRYP_IMSCR ,0 ); -stm32_cryp_finish_req (cryp,0 ); -return IRQ_HANDLED ; - } +stm32_cryp_irq_read_data (cryp);if (cryp->irq_status &MISR_IN ) { -if (is_gcm (cryp)) { - ph =stm32_cryp_read (cryp,CRYP_CR ) &CR_PH_MASK ; -if (unlikely (ph ==CR_PH_HEADER )) -/* Write Header */ -stm32_cryp_irq_write_gcm_header (cryp); -else -/* Input FIFO IRQ: write data */ -stm32_cryp_irq_write_data (cryp); - cryp->gcm_ctr++; - }else if (is_ccm (cryp)) { +if (is_gcm (cryp) ||is_ccm (cryp)) { ph =stm32_cryp_read (cryp,CRYP_CR ) &CR_PH_MASK ;if (unlikely (ph ==CR_PH_HEADER ))/* Write Header */ -stm32_cryp_irq_write_ccm_header (cryp); +stm32_cryp_irq_write_gcmccm_header (cryp);else /* Input FIFO IRQ: write data */ stm32_cryp_irq_write_data (cryp); +if (is_gcm (cryp)) + cryp->gcm_ctr++; }else {/* Input FIFO IRQ: write data */ stm32_cryp_irq_write_data (cryp); } } +/* Mask useless interrupts */ +if (!cryp->payload_in && !cryp->header_in) + it_mask &= ~IMSCR_IN ; +if (!cryp->payload_out) + it_mask &= ~IMSCR_OUT ; +stm32_cryp_write (cryp,CRYP_IMSCR , it_mask); + +if (!cryp->payload_in && !cryp->header_in && !cryp->payload_out) +stm32_cryp_finish_req (cryp,0 ); +return IRQ_HANDLED ; }
@@ -1851,7 +1547,7 @@ static struct skcipher_alg crypto_algs[] = { .base.cra_flags = CRYPTO_ALG_ASYNC, .base.cra_blocksize = AES_BLOCK_SIZE, .base.cra_ctxsize = sizeof(struct stm32_cryp_ctx), - .base.cra_alignmask = 0xf, + .base.cra_alignmask = 0, .base.cra_module = THIS_MODULE, .init = stm32_cryp_init_tfm,
@@ -1868,7 +1564,7 @@ static struct skcipher_alg crypto_algs[] = { .base.cra_flags = CRYPTO_ALG_ASYNC, .base.cra_blocksize = AES_BLOCK_SIZE, .base.cra_ctxsize = sizeof(struct stm32_cryp_ctx), - .base.cra_alignmask = 0xf, + .base.cra_alignmask = 0, .base.cra_module = THIS_MODULE, .init = stm32_cryp_init_tfm,
@@ -1886,7 +1582,7 @@ static struct skcipher_alg crypto_algs[] = { .base.cra_flags = CRYPTO_ALG_ASYNC, .base.cra_blocksize = 1, .base.cra_ctxsize = sizeof(struct stm32_cryp_ctx), - .base.cra_alignmask = 0xf, + .base.cra_alignmask = 0, .base.cra_module = THIS_MODULE, .init = stm32_cryp_init_tfm,
@@ -1904,7 +1600,7 @@ static struct skcipher_alg crypto_algs[] = { .base.cra_flags = CRYPTO_ALG_ASYNC, .base.cra_blocksize = DES_BLOCK_SIZE, .base.cra_ctxsize = sizeof(struct stm32_cryp_ctx), - .base.cra_alignmask = 0xf, + .base.cra_alignmask = 0, .base.cra_module = THIS_MODULE, .init = stm32_cryp_init_tfm,
@@ -1921,7 +1617,7 @@ static struct skcipher_alg crypto_algs[] = { .base.cra_flags = CRYPTO_ALG_ASYNC, .base.cra_blocksize = DES_BLOCK_SIZE, .base.cra_ctxsize = sizeof(struct stm32_cryp_ctx), - .base.cra_alignmask = 0xf, + .base.cra_alignmask = 0, .base.cra_module = THIS_MODULE, .init = stm32_cryp_init_tfm,
@@ -1939,7 +1635,7 @@ static struct skcipher_alg crypto_algs[] = { .base.cra_flags = CRYPTO_ALG_ASYNC, .base.cra_blocksize = DES_BLOCK_SIZE, .base.cra_ctxsize = sizeof(struct stm32_cryp_ctx), - .base.cra_alignmask = 0xf, + .base.cra_alignmask = 0, .base.cra_module = THIS_MODULE, .init = stm32_cryp_init_tfm,
@@ -1956,7 +1652,7 @@ static struct skcipher_alg crypto_algs[] = { .base.cra_flags = CRYPTO_ALG_ASYNC, .base.cra_blocksize = DES_BLOCK_SIZE, .base.cra_ctxsize = sizeof(struct stm32_cryp_ctx), - .base.cra_alignmask = 0xf, + .base.cra_alignmask = 0, .base.cra_module = THIS_MODULE, .init = stm32_cryp_init_tfm,
@@ -1986,7 +1682,7 @@ static struct aead_alg aead_algs[] = { .cra_flags = CRYPTO_ALG_ASYNC, .cra_blocksize = 1, .cra_ctxsize = sizeof(struct stm32_cryp_ctx), - .cra_alignmask = 0xf, + .cra_alignmask = 0, .cra_module = THIS_MODULE, }, },
@@ -2006,7 +1702,7 @@ static struct aead_alg aead_algs[] = { .cra_flags = CRYPTO_ALG_ASYNC, .cra_blocksize = 1, .cra_ctxsize = sizeof(struct stm32_cryp_ctx), - .cra_alignmask = 0xf, + .cra_alignmask = 0, .cra_module = THIS_MODULE, }, },
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 277/1039 crypto: stm32 - Revert broken pm_runtime_resume_and_get changes
In reply to Greg Kroah-HartmanFrom: Herbert Xu <[email protected]>
[ Upstream commit 3d6b661330a7954d8136df98160d525eb04dcd6a ]
We should not call pm_runtime_resume_and_get where the reference count is expected to be incremented unconditionally. This patch reverts these calls to the original unconditional get_sync call.
--- drivers/crypto/stm32/stm32-cryp.c | 3 ++- drivers/crypto/stm32/stm32-hash.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/crypto/stm32/stm32-cryp.c +2 -1
@@ -529,7 +529,8 @@ static int stm32_cryp_hw_init(struct stm32_cryp *cryp) {int ret;u32 cfg, hw_mode; -pm_runtime_resume_and_get (cryp->dev); + +pm_runtime_get_sync (cryp->dev);/* Disable interrupt */ stm32_cryp_write (cryp,CRYP_IMSCR ,0 );
drivers/crypto/stm32/stm32-hash.c +3 -3
@@ -813,7 +813,7 @@ static void stm32_hash_finish_req(struct ahash_request *req, int err)static int stm32_hash_hw_init (struct stm32_hash_dev *hdev,struct stm32_hash_request_ctx *rctx) { -pm_runtime_resume_and_get (hdev->dev); +pm_runtime_get_sync (hdev->dev);if (!(HASH_FLAGS_INIT & hdev->flags)) {stm32_hash_write (hdev,HASH_CR ,HASH_CR_INIT );
@@ -962,7 +962,7 @@ static int stm32_hash_export(struct ahash_request *req, void *out)u32 *preg;unsigned int i; -pm_runtime_resume_and_get (hdev->dev); +pm_runtime_get_sync (hdev->dev);while ((stm32_hash_read (hdev,HASH_SR ) &HASH_SR_BUSY ))cpu_relax ();
@@ -1000,7 +1000,7 @@ static int stm32_hash_import(struct ahash_request *req, const void *in) preg = rctx->hw_context; -pm_runtime_resume_and_get (hdev->dev); +pm_runtime_get_sync (hdev->dev);stm32_hash_write (hdev,HASH_IMR , *preg++);stm32_hash_write (hdev,HASH_STR , *preg++);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 278/1039 crypto: hisilicon/qm - fix incorrect return value of hisi_qm_resume()
In reply to Greg Kroah-HartmanFrom: Weili Qian <[email protected]>
[ Upstream commit 3f9dd4c802b96626e869b2d29c8e401dabadd23e ]
When hisi_qm_resume() returns 0, it indicates that the device has started successfully. If the device fails to start, hisi_qm_resume() needs to return the actual error code to the caller instead of 0.
--- drivers/crypto/hisilicon/qm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/hisilicon/qm.c +1 -1
@@ -6038,7 +6038,7 @@ int hisi_qm_resume(struct device *dev)if (ret)pci_err (pdev,"failed to start qm(%d)\n" , ret); -return 0 ; +return ret; }EXPORT_SYMBOL_GPL (hisi_qm_resume);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 279/1039 libbpf: Fix gen_loader assumption on number of programs.
In reply to Greg Kroah-HartmanFrom: Alexei Starovoitov <[email protected]>
[ Upstream commit 259172bb6514758ce3be1610c500b51a9f44212a ]
libbpf's obj->nr_programs includes static and global functions. That number could be higher than the actual number of bpf programs going be loaded by gen_loader. Passing larger nr_programs to bpf_gen__init() doesn't hurt. Those exra stack slots will stay as zero. bpf_gen__finish() needs to check that actual number of progs that gen_loader saw is less than or equal to obj->nr_programs.
--- tools/lib/bpf/gen_loader.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/lib/bpf/gen_loader.c +3 -2
@@ -371,8 +371,9 @@ int bpf_gen__finish(struct bpf_gen *gen, int nr_progs, int nr_maps) {int i; -if (nr_progs != gen->nr_progs || nr_maps != gen->nr_maps) { -pr_warn ("progs/maps mismatch\n" ); +if (nr_progs < gen->nr_progs || nr_maps != gen->nr_maps) { +pr_warn ("nr_progs %d/%d nr_maps %d/%d mismatch\n" , + nr_progs, gen->nr_progs, nr_maps, gen->nr_maps); gen->error = -EFAULT ;return gen->error; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 280/1039 ath11k: Fix deleting uninitialized kernel timer during fragment cache flush
In reply to Greg Kroah-HartmanFrom: Rameshkumar Sundaram <[email protected]>
[ Upstream commit ba53ee7f7f38cf0592b8be1dcdabaf8f7535f8c1 ]
frag_timer will be created & initialized for stations when they associate and will be deleted during every key installation while flushing old fragments.
For AP interface self peer will be created and Group keys will be installed for this peer, but there will be no real Station entry & hence frag_timer won't be created and initialized, deleting such uninitialized kernel timers causes below warnings and backtraces printed with CONFIG_DEBUG_OBJECTS_TIMERS enabled.
[ 177.828008] ODEBUG: assert_init not available (active state 0) object type: timer_list hint: 0x0 [ 177.836833] WARNING: CPU: 3 PID: 188 at lib/debugobjects.c:508 debug_print_object+0xb0/0xf0 [ 177.845185] Modules linked in: ath11k_pci ath11k qmi_helpers qrtr_mhi qrtr ns mhi [ 177.852679] CPU: 3 PID: 188 Comm: hostapd Not tainted 5.14.0-rc3-32919-g4034139e1838-dirty #14 [ 177.865805] pstate: 60000005 (nZCv daif -PAN -UAO -TCO BTYPE=--) [ 177.871804] pc : debug_print_object+0xb0/0xf0 [ 177.876155] lr : debug_print_object+0xb0/0xf0 [ 177.880505] sp : ffffffc01169b5a0 [ 177.883810] x29: ffffffc01169b5a0 x28: ffffff80081c2320 x27: ffffff80081c4078 [ 177.890942] x26: ffffff8003fe8f28 x25: ffffff8003de9890 x24: ffffffc01134d738 [ 177.898075] x23: ffffffc010948f20 x22: ffffffc010b2d2e0 x21: ffffffc01169b628 [ 177.905206] x20: ffffffc01134d700 x19: ffffffc010c80d98 x18: 00000000000003f6 [ 177.912339] x17: 203a657079742074 x16: 63656a626f202930 x15: 0000000000000152 [ 177.919471] x14: 0000000000000152 x13: 00000000ffffffea x12: ffffffc010d732e0 [ 177.926603] x11: 0000000000000003 x10: ffffffc010d432a0 x9 : ffffffc010d432f8 [ 177.933735] x8 : 000000000002ffe8 x7 : c0000000ffffdfff x6 : 0000000000000001 [ 177.940866] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 00000000ffffffff [ 177.947997] x2 : ffffffc010c93240 x1 : ffffff80023624c0 x0 : 0000000000000054 [ 177.955130] Call trace: [ 177.957567] debug_print_object+0xb0/0xf0 [ 177.961570] debug_object_assert_init+0x124/0x178 [ 177.966269] try_to_del_timer_sync+0x1c/0x70 [ 177.970536] del_timer_sync+0x30/0x50 [ 177.974192] ath11k_peer_frags_flush+0x34/0x68 [ath11k] [ 177.979439] ath11k_mac_op_set_key+0x1e4/0x338 [ath11k] [ 177.984673] ieee80211_key_enable_hw_accel+0xc8/0x3d0 [ 177.989722] ieee80211_key_replace+0x360/0x740 [ 177.994160] ieee80211_key_link+0x16c/0x210 [ 177.998337] ieee80211_add_key+0x138/0x338 [ 178.002426] nl80211_new_key+0xfc/0x258 [ 178.006257] genl_family_rcv_msg_doit.isra.17+0xd8/0x120 [ 178.011565] genl_rcv_msg+0xd8/0x1c8 [ 178.015134] netlink_rcv_skb+0x38/0xf8 [ 178.018877] genl_rcv+0x34/0x48 [ 178.022012] netlink_unicast+0x174/0x230 [ 178.025928] netlink_sendmsg+0x188/0x388 [ 178.029845] ____sys_sendmsg+0x218/0x250 [ 178.033763] ___sys_sendmsg+0x68/0x90 [ 178.037418] __sys_sendmsg+0x44/0x88 [ 178.040988] __arm64_sys_sendmsg+0x20/0x28 [ 178.045077] invoke_syscall.constprop.5+0x54/0xe0 [ 178.049776] do_el0_svc+0x74/0xc0 [ 178.053084] el0_svc+0x10/0x18 [ 178.056133] el0t_64_sync_handler+0x88/0xb0 [ 178.060310] el0t_64_sync+0x148/0x14c [ 178.063966] ---[ end trace 8a5cf0bf9d34a058 ]---
Add changes to not to delete frag timer for peers during group key installation.
Tested on: IPQ8074 hw2.0 AHB WLAN.HK.2.5.0.1-01092-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/mac.c +1 -1
@@ -3452,7 +3452,7 @@ static int ath11k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,/* flush the fragments cache during key (re)install to * ensure all frags in the new frag list belong to the same key. */ -if (peer && cmd ==SET_KEY ) +if (peer && sta && cmd ==SET_KEY )ath11k_peer_frags_flush (ar, peer);spin_unlock_bh (&ab->base_lock);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 281/1039 spi: Fix incorrect cs_setup delay handling
In reply to Greg Kroah-HartmanFrom: Hector Martin <[email protected]>
[ Upstream commit 95c07247399536f83b89dc60cfe7b279d17e69f6 ]
Move the cs_setup delay to the end of spi_set_cs.
Quoted 1 line
From
include/linux/spi/spi.h:
* @cs_setup: delay to be introduced by the controller after CS is asserted
The cs_setup delay needs to happen *after* CS is asserted, that is, at the end of spi_set_cs, not at the beginning. Otherwise we're just delaying before the SPI transaction starts at all, which isn't very useful.
No drivers use this right now, but that is likely to change soon with an upcoming Apple SPI HID transport driver.
--- drivers/spi/spi.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/spi/spi.c +6 -7
@@ -947,12 +947,9 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force) spi->controller->last_cs_enable = enable; spi->controller->last_cs_mode_high = spi->mode &SPI_CS_HIGH ; -if (spi->cs_gpiod ||gpio_is_valid (spi->cs_gpio) || - !spi->controller->set_cs_timing) { -if (activate) -spi_delay_exec (&spi->cs_setup,NULL ); -else -spi_delay_exec (&spi->cs_hold,NULL ); +if ((spi->cs_gpiod ||gpio_is_valid (spi->cs_gpio) || + !spi->controller->set_cs_timing) && !activate) { +spi_delay_exec (&spi->cs_hold,NULL ); }if (spi->mode &SPI_CS_HIGH )
@@ -994,7 +991,9 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)if (spi->cs_gpiod ||gpio_is_valid (spi->cs_gpio) || !spi->controller->set_cs_timing) { -if (!activate) +if (activate) +spi_delay_exec (&spi->cs_setup,NULL ); +else spi_delay_exec (&spi->cs_inactive,NULL ); } }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 282/1039 kunit: tool: fix --json output for skipped tests
In reply to Greg Kroah-HartmanFrom: Daniel Latypov <[email protected]>
[ Upstream commit 9a6bb30a8830bb868b09629f0b9ad5d2b5fbb2f9 ]
Currently, KUnit will report SKIPPED tests as having failed if one uses --json.
Add the missing if statement to set the appropriate status ("SKIP"). See https://api.kernelci.org/schema-test-case.html:
"status": {
"type": "string",
"description": "The status of the execution of this test case",
"enum": ["PASS", "FAIL", "SKIP", "ERROR"],
"default": "PASS" },
with this, we now can properly produce all four of the statuses.
--- tools/testing/kunit/kunit_json.py | 2 ++ tools/testing/kunit/kunit_tool_test.py | 6 ++++++ 2 files changed, 8 insertions(+)
tools/testing/kunit/kunit_json.py +2 -0
@@ -30,6 +30,8 @@ def _get_group_json(test: Test, def_config: str, test_case = {"name": subtest.name, "status": "FAIL"} if subtest.status == TestStatus.SUCCESS: test_case["status"] = "PASS" + elif subtest.status == TestStatus.SKIPPED: + test_case["status"] = "SKIP" elif subtest.status == TestStatus.TEST_CRASHED: test_case["status"] = "ERROR" test_cases.append(test_case)
tools/testing/kunit/kunit_tool_test.py +6 -0
@@ -383,6 +383,12 @@ class KUnitJsonTest(unittest.TestCase): {'name': 'example_simple_test', 'status': 'ERROR'}, result["sub_groups"][1]["test_cases"][0]) + def test_skipped_test_json(self): + result = self._json_for('test_skip_tests.log') + self.assertEqual( + {'name': 'example_skip_test', 'status': 'SKIP'}, + result["sub_groups"][1]["test_cases"][1]) + def test_no_tests_json(self): result = self._json_for('test_is_test_passed-no_tests_run_with_header.log') self.assertEqual(0, len(result['sub_groups']))
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 283/1039 ARM: dts: gemini: NAS4220-B: fis-index-block with 128 KiB sectors
In reply to Greg Kroah-HartmanFrom: Christian Lamparter <[email protected]>
[ Upstream commit 4754eab7e5a78bdefe7a960c5c260c95ebbb5fa6 ]
Steven Maddox reported in the OpenWrt bugzilla, that his RaidSonic IB-NAS4220-B was no longer booting with the new OpenWrt 21.02 (uses linux 5.10's device-tree). However, it was working with the previous OpenWrt 19.07 series (uses 4.14).
|[ 5.548038] No RedBoot partition table detected in 30000000.flash |[ 5.618553] Searching for RedBoot partition table in 30000000.flash at offset 0x0 |[ 5.739093] No RedBoot partition table detected in 30000000.flash |... |[ 7.039504] Waiting for root device /dev/mtdblock3...
The provided bootlog shows that the RedBoot partition parser was looking for the partition table "at offset 0x0". Which is strange since the comment in the device-tree says it should be at 0xfe0000.
Further digging on the internet led to a review site that took some useful PCB pictures of their review unit back in February 2009. Their picture shows a Spansion S29GL128N11TFI01 flash chip.
Quoted 1 line
From Spansion's Datasheet:
"S29GL128N: One hundred twenty-eight 64 Kword (128 Kbyte) sectors" Steven also provided a "cat /sys/class/mtd/mtd0/erasesize" from his
unit: "131072".
With the 128 KiB Sector/Erasesize in mind. This patch changes the fis-index-block property to (0xfe0000 / 0x20000) = 0x7f.
Bugzilla: https://bugs.openwrt.org/index.php?do=details&task_id=4137
--- arch/arm/boot/dts/gemini-nas4220b.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/gemini-nas4220b.dts +1 -1
@@ -84,7 +84,7 @@ partitions { compatible = "redboot-fis"; /* Eraseblock at 0xfe0000 */ - fis-index-block = <0x1fc>; + fis-index-block = <0x7f>; }; };
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 284/1039 perf/arm-cmn: Fix CPU hotplug unregistration
In reply to Greg Kroah-HartmanFrom: Robin Murphy <[email protected]>
[ Upstream commit 56c7c6eaf3eb8ac1ec40d56096c0f2b27250da5f ]
Attempting to migrate the PMU context after we've unregistered the PMU device, or especially if we never successfully registered it in the first place, is a woefully bad idea. It's also fundamentally pointless anyway. Make sure to unregister an instance from the hotplug handler *without* invoking the teardown callback.
--- drivers/perf/arm-cmn.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/perf/arm-cmn.c +3 -2
@@ -1561,7 +1561,8 @@ static int arm_cmn_probe(struct platform_device *pdev) err =perf_pmu_register (&cmn->pmu, name,-1 );if (err) -cpuhp_state_remove_instance (arm_cmn_hp_state, &cmn->cpuhp_node); +cpuhp_state_remove_instance_nocalls (arm_cmn_hp_state, &cmn->cpuhp_node); +return err; }
@@ -1572,7 +1573,7 @@ static int arm_cmn_remove(struct platform_device *pdev)writel_relaxed (0 , cmn->dtc[0 ].base +CMN_DT_DTC_CTL );perf_pmu_unregister (&cmn->pmu); -cpuhp_state_remove_instance (arm_cmn_hp_state, &cmn->cpuhp_node); +cpuhp_state_remove_instance_nocalls (arm_cmn_hp_state, &cmn->cpuhp_node);return 0 ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 285/1039 media: dw2102: Fix use after free
In reply to Greg Kroah-HartmanFrom: Anton Vasilyev <[email protected]>
[ Upstream commit 589a9f0eb799f77de2c09583bf5bad221fa5d685 ]
dvb_usb_device_init stores parts of properties at d->props and d->desc and uses it on dvb_usb_device_exit. Free of properties on module probe leads to use after free.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204597
The patch makes properties static instead of allocated on heap to prevent memleak and use after free.
Also fixes s421_properties.devices initialization to have 2 element instead of 6 copied from p7500_properties.
--- drivers/media/usb/dvb-usb/dw2102.c | 338 ++++++++++++++++++----------- 1 file changed, 215 insertions(+), 123 deletions(-)
drivers/media/usb/dvb-usb/dw2102.c +215 -123
@@ -2150,46 +2150,153 @@ static struct dvb_usb_device_properties s6x0_properties = { } }; -static const struct dvb_usb_device_description d1100 = { -"Prof 1100 USB " , - {&dw2102_table[PROF_1100 ],NULL }, - {NULL }, -}; +static struct dvb_usb_device_properties p1100_properties = { + .caps =DVB_USB_IS_AN_I2C_ADAPTER , + .usb_ctrl =DEVICE_SPECIFIC , + .size_of_priv =sizeof (struct dw2102_state ), + .firmware =P1100_FIRMWARE , + .no_reconnect =1 , -static const struct dvb_usb_device_description d660 = { -"TeVii S660 USB" , - {&dw2102_table[TEVII_S660 ],NULL }, - {NULL }, -}; + .i2c_algo = &s6x0_i2c_algo, + .rc.core = { + .rc_interval =150 , + .rc_codes =RC_MAP_TBS_NEC , + .module_name ="dw2102" , + .allowed_protos =RC_PROTO_BIT_NEC , + .rc_query = prof_rc_query, + }, -static const struct dvb_usb_device_description d480_1 = { -"TeVii S480.1 USB" , - {&dw2102_table[TEVII_S480_1 ],NULL }, - {NULL }, + .generic_bulk_ctrl_endpoint =0x81 , + .num_adapters =1 , + .download_firmware = dw2102_load_firmware, + .read_mac_address = s6x0_read_mac_address, + .adapter = { + { + .num_frontends =1 , + .fe = {{ + .frontend_attach = stv0288_frontend_attach, + .stream = { + .type =USB_BULK , + .count =8 , + .endpoint =0x82 , + .u = { + .bulk = { + .buffersize =4096 , + } + } + }, + } }, + } + }, + .num_device_descs =1 , + .devices = { + {"Prof 1100 USB " , + {&dw2102_table[PROF_1100 ],NULL }, + {NULL }, + }, + } }; -static const struct dvb_usb_device_description d480_2 = { -"TeVii S480.2 USB" , - {&dw2102_table[TEVII_S480_2 ],NULL }, - {NULL }, -}; +static struct dvb_usb_device_properties s660_properties = { + .caps =DVB_USB_IS_AN_I2C_ADAPTER , + .usb_ctrl =DEVICE_SPECIFIC , + .size_of_priv =sizeof (struct dw2102_state ), + .firmware =S660_FIRMWARE , + .no_reconnect =1 , -static const struct dvb_usb_device_description d7500 = { -"Prof 7500 USB DVB-S2" , - {&dw2102_table[PROF_7500 ],NULL }, - {NULL }, -}; + .i2c_algo = &s6x0_i2c_algo, + .rc.core = { + .rc_interval =150 , + .rc_codes =RC_MAP_TEVII_NEC , + .module_name ="dw2102" , + .allowed_protos =RC_PROTO_BIT_NEC , + .rc_query = dw2102_rc_query, + }, -static const struct dvb_usb_device_description d421 = { -"TeVii S421 PCI" , - {&dw2102_table[TEVII_S421 ],NULL }, - {NULL }, + .generic_bulk_ctrl_endpoint =0x81 , + .num_adapters =1 , + .download_firmware = dw2102_load_firmware, + .read_mac_address = s6x0_read_mac_address, + .adapter = { + { + .num_frontends =1 , + .fe = {{ + .frontend_attach = ds3000_frontend_attach, + .stream = { + .type =USB_BULK , + .count =8 , + .endpoint =0x82 , + .u = { + .bulk = { + .buffersize =4096 , + } + } + }, + } }, + } + }, + .num_device_descs =3 , + .devices = { + {"TeVii S660 USB" , + {&dw2102_table[TEVII_S660 ],NULL }, + {NULL }, + }, + {"TeVii S480.1 USB" , + {&dw2102_table[TEVII_S480_1 ],NULL }, + {NULL }, + }, + {"TeVii S480.2 USB" , + {&dw2102_table[TEVII_S480_2 ],NULL }, + {NULL }, + }, + } }; -static const struct dvb_usb_device_description d632 = { -"TeVii S632 USB" , - {&dw2102_table[TEVII_S632 ],NULL }, - {NULL }, +static struct dvb_usb_device_properties p7500_properties = { + .caps =DVB_USB_IS_AN_I2C_ADAPTER , + .usb_ctrl =DEVICE_SPECIFIC , + .size_of_priv =sizeof (struct dw2102_state ), + .firmware =P7500_FIRMWARE , + .no_reconnect =1 , + + .i2c_algo = &s6x0_i2c_algo, + .rc.core = { + .rc_interval =150 , + .rc_codes =RC_MAP_TBS_NEC , + .module_name ="dw2102" , + .allowed_protos =RC_PROTO_BIT_NEC , + .rc_query = prof_rc_query, + }, + + .generic_bulk_ctrl_endpoint =0x81 , + .num_adapters =1 , + .download_firmware = dw2102_load_firmware, + .read_mac_address = s6x0_read_mac_address, + .adapter = { + { + .num_frontends =1 , + .fe = {{ + .frontend_attach = prof_7500_frontend_attach, + .stream = { + .type =USB_BULK , + .count =8 , + .endpoint =0x82 , + .u = { + .bulk = { + .buffersize =4096 , + } + } + }, + } }, + } + }, + .num_device_descs =1 , + .devices = { + {"Prof 7500 USB DVB-S2" , + {&dw2102_table[PROF_7500 ],NULL }, + {NULL }, + }, + } };static struct dvb_usb_device_properties su3000_properties = {
@@ -2273,6 +2380,59 @@ static struct dvb_usb_device_properties su3000_properties = { } }; +static struct dvb_usb_device_properties s421_properties = { + .caps =DVB_USB_IS_AN_I2C_ADAPTER , + .usb_ctrl =DEVICE_SPECIFIC , + .size_of_priv =sizeof (struct dw2102_state ), + .power_ctrl = su3000_power_ctrl, + .num_adapters =1 , + .identify_state = su3000_identify_state, + .i2c_algo = &su3000_i2c_algo, + + .rc.core = { + .rc_interval =150 , + .rc_codes =RC_MAP_SU3000 , + .module_name ="dw2102" , + .allowed_protos =RC_PROTO_BIT_RC5 , + .rc_query = su3000_rc_query, + }, + + .read_mac_address = su3000_read_mac_address, + + .generic_bulk_ctrl_endpoint =0x01 , + + .adapter = { + { + .num_frontends =1 , + .fe = {{ + .streaming_ctrl = su3000_streaming_ctrl, + .frontend_attach = m88rs2000_frontend_attach, + .stream = { + .type =USB_BULK , + .count =8 , + .endpoint =0x82 , + .u = { + .bulk = { + .buffersize =4096 , + } + } + } + } }, + } + }, + .num_device_descs =2 , + .devices = { + {"TeVii S421 PCI" , + { &dw2102_table[TEVII_S421 ],NULL }, + {NULL }, + }, + {"TeVii S632 USB" , + { &dw2102_table[TEVII_S632 ],NULL }, + {NULL }, + }, + } +}; +static struct dvb_usb_device_properties t220_properties = { .caps =DVB_USB_IS_AN_I2C_ADAPTER , .usb_ctrl =DEVICE_SPECIFIC ,
@@ -2390,101 +2550,33 @@ static struct dvb_usb_device_properties tt_s2_4600_properties = {static int dw2102_probe (struct usb_interface *intf,const struct usb_device_id *id) { -int retval = -ENOMEM ; -struct dvb_usb_device_properties *p1100; -struct dvb_usb_device_properties *s660; -struct dvb_usb_device_properties *p7500; -struct dvb_usb_device_properties *s421; - - p1100 =kmemdup (&s6x0_properties, -sizeof (struct dvb_usb_device_properties ),GFP_KERNEL ); -if (!p1100) - goto err0; - -/* copy default structure */ -/* fill only different fields */ - p1100->firmware =P1100_FIRMWARE ; - p1100->devices[0 ] = d1100; - p1100->rc.core.rc_query = prof_rc_query; - p1100->rc.core.rc_codes =RC_MAP_TBS_NEC ; - p1100->adapter->fe[0 ].frontend_attach = stv0288_frontend_attach; - - s660 =kmemdup (&s6x0_properties, -sizeof (struct dvb_usb_device_properties ),GFP_KERNEL ); -if (!s660) - goto err1; - - s660->firmware =S660_FIRMWARE ; - s660->num_device_descs =3 ; - s660->devices[0 ] = d660; - s660->devices[1 ] = d480_1; - s660->devices[2 ] = d480_2; - s660->adapter->fe[0 ].frontend_attach = ds3000_frontend_attach; - - p7500 =kmemdup (&s6x0_properties, -sizeof (struct dvb_usb_device_properties ),GFP_KERNEL ); -if (!p7500) - goto err2; - - p7500->firmware =P7500_FIRMWARE ; - p7500->devices[0 ] = d7500; - p7500->rc.core.rc_query = prof_rc_query; - p7500->rc.core.rc_codes =RC_MAP_TBS_NEC ; - p7500->adapter->fe[0 ].frontend_attach = prof_7500_frontend_attach; - - - s421 =kmemdup (&su3000_properties, -sizeof (struct dvb_usb_device_properties ),GFP_KERNEL ); -if (!s421) - goto err3; - - s421->num_device_descs =2 ; - s421->devices[0 ] = d421; - s421->devices[1 ] = d632; - s421->adapter->fe[0 ].frontend_attach = m88rs2000_frontend_attach; - -if (0 ==dvb_usb_device_init (intf, &dw2102_properties, -THIS_MODULE ,NULL , adapter_nr) || -0 ==dvb_usb_device_init (intf, &dw2104_properties, -THIS_MODULE ,NULL , adapter_nr) || -0 ==dvb_usb_device_init (intf, &dw3101_properties, -THIS_MODULE ,NULL , adapter_nr) || -0 ==dvb_usb_device_init (intf, &s6x0_properties, -THIS_MODULE ,NULL , adapter_nr) || -0 ==dvb_usb_device_init (intf, p1100, -THIS_MODULE ,NULL , adapter_nr) || -0 ==dvb_usb_device_init (intf, s660, -THIS_MODULE ,NULL , adapter_nr) || -0 ==dvb_usb_device_init (intf, p7500, -THIS_MODULE ,NULL , adapter_nr) || -0 ==dvb_usb_device_init (intf, s421, -THIS_MODULE ,NULL , adapter_nr) || -0 ==dvb_usb_device_init (intf, &su3000_properties, -THIS_MODULE ,NULL , adapter_nr) || -0 ==dvb_usb_device_init (intf, &t220_properties, -THIS_MODULE ,NULL , adapter_nr) || -0 ==dvb_usb_device_init (intf, &tt_s2_4600_properties, -THIS_MODULE ,NULL , adapter_nr)) { - -/* clean up copied properties */ -kfree (s421); -kfree (p7500); -kfree (s660); -kfree (p1100); +if (!(dvb_usb_device_init (intf, &dw2102_properties, +THIS_MODULE ,NULL , adapter_nr) && +dvb_usb_device_init (intf, &dw2104_properties, +THIS_MODULE ,NULL , adapter_nr) && +dvb_usb_device_init (intf, &dw3101_properties, +THIS_MODULE ,NULL , adapter_nr) && +dvb_usb_device_init (intf, &s6x0_properties, +THIS_MODULE ,NULL , adapter_nr) && +dvb_usb_device_init (intf, &p1100_properties, +THIS_MODULE ,NULL , adapter_nr) && +dvb_usb_device_init (intf, &s660_properties, +THIS_MODULE ,NULL , adapter_nr) && +dvb_usb_device_init (intf, &p7500_properties, +THIS_MODULE ,NULL , adapter_nr) && +dvb_usb_device_init (intf, &s421_properties, +THIS_MODULE ,NULL , adapter_nr) && +dvb_usb_device_init (intf, &su3000_properties, +THIS_MODULE ,NULL , adapter_nr) && +dvb_usb_device_init (intf, &t220_properties, +THIS_MODULE ,NULL , adapter_nr) && +dvb_usb_device_init (intf, &tt_s2_4600_properties, +THIS_MODULE ,NULL , adapter_nr))) {return 0 ; } - retval = -ENODEV ; -kfree (s421); -err3: -kfree (p7500); -err2: -kfree (s660); -err1: -kfree (p1100); -err0: -return retval; +return -ENODEV ; }static void dw2102_disconnect (struct usb_interface *intf)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 286/1039 media: msi001: fix possible null-ptr-deref in msi001_probe()
In reply to Greg Kroah-HartmanFrom: Wang Hai <[email protected]>
[ Upstream commit 3d5831a40d3464eea158180eb12cbd81c5edfb6a ]
I got a null-ptr-deref report:
BUG: kernel NULL pointer dereference, address: 0000000000000060 ... RIP: 0010:v4l2_ctrl_auto_cluster+0x57/0x270 ... Call Trace: msi001_probe+0x13b/0x24b [msi001] spi_probe+0xeb/0x130
...
do_syscall_64+0x35/0xb0
In msi001_probe(), if the creation of control for bandwidth_auto fails, there will be a null-ptr-deref issue when it is used in v4l2_ctrl_auto_cluster().
Check dev->hdl.error before v4l2_ctrl_auto_cluster() to fix this bug.
--- drivers/media/tuners/msi001.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/media/tuners/msi001.c +7 -0
@@ -442,6 +442,13 @@ static int msi001_probe(struct spi_device *spi) V4L2_CID_RF_TUNER_BANDWIDTH_AUTO, 0, 1, 1, 1); dev->bandwidth =v4l2_ctrl_new_std (&dev->hdl, &msi001_ctrl_ops,V4L2_CID_RF_TUNER_BANDWIDTH ,200000 ,8000000 ,1 ,200000 ); +if (dev->hdl.error) { + ret = dev->hdl.error; +dev_err (&spi->dev,"Could not initialize controls\n" ); +/* control init failed, free handler */ + goto err_ctrl_handler_free; + } +v4l2_ctrl_auto_cluster (2 , &dev->bandwidth_auto,0 , false); dev->lna_gain =v4l2_ctrl_new_std (&dev->hdl, &msi001_ctrl_ops,V4L2_CID_RF_TUNER_LNA_GAIN ,0 ,1 ,1 ,1 );
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 287/1039 media: coda/imx-vdoa: Handle dma_set_coherent_mask error codes
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 43f0633f89947df57fe0b5025bdd741768007708 ]
The return value of dma_set_coherent_mask() is not always 0. To catch the exception in case that dma is not support the mask.
--- drivers/media/platform/coda/imx-vdoa.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/media/platform/coda/imx-vdoa.c +5 -1
@@ -287,7 +287,11 @@ static int vdoa_probe(struct platform_device *pdev)struct resource *res;int ret; -dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + ret =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) { +dev_err (&pdev->dev,"DMA enable failed\n" ); +return ret; + } vdoa =devm_kzalloc (&pdev->dev,sizeof (*vdoa),GFP_KERNEL );if (!vdoa)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 288/1039 ath11k: Fix a NULL pointer dereference in ath11k_mac_op_hw_scan()
In reply to Greg Kroah-HartmanFrom: Zhou Qingyang <[email protected]>
[ Upstream commit eccd25136386a04ebf46a64f3a34e8e0fab6d9e1 ]
In ath11k_mac_op_hw_scan(), the return value of kzalloc() is directly used in memcpy(), which may lead to a NULL pointer dereference on failure of kzalloc().
Fix this bug by adding a check of arg.extraie.ptr.
This bug was found by a static analyzer. The analysis employs differential checking to identify inconsistent security operations (e.g., checks or kfrees) between two code paths and confirms that the inconsistent operations are not recovered in the current function or the callers, so they constitute bugs.
Note that, as a bug found by static analysis, it can be a false positive or hard to trigger. Multiple researchers have cross-reviewed the bug.
Builds with CONFIG_ATH11K=m show no new warnings, and our static analyzer no longer warns about this code.
--- drivers/net/wireless/ath/ath11k/mac.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath11k/mac.c +5 -2
@@ -3241,9 +3241,12 @@ static int ath11k_mac_op_hw_scan(struct ieee80211_hw *hw, arg.scan_id =ATH11K_SCAN_ID ;if (req->ie_len) { + arg.extraie.ptr =kmemdup (req->ie, req->ie_len,GFP_KERNEL ); +if (!arg.extraie.ptr) { + ret = -ENOMEM ; + goto exit; + } arg.extraie.len = req->ie_len; - arg.extraie.ptr =kzalloc (req->ie_len,GFP_KERNEL ); -memcpy (arg.extraie.ptr, req->ie, req->ie_len); }if (req->n_ssids) {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 289/1039 net: dsa: hellcreek: Fix insertion of static FDB entries
In reply to Greg Kroah-HartmanFrom: Kurt Kanzenbach <[email protected]>
[ Upstream commit 4db4c3ea56978086ca367a355e440de17d534827 ]
The insertion of static FDB entries ignores the pass_blocked bit. That bit is evaluated with regards to STP. Add the missing functionality.
--- drivers/net/dsa/hirschmann/hellcreek.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/dsa/hirschmann/hellcreek.c +5 -2
@@ -710,8 +710,9 @@ static int __hellcreek_fdb_add(struct hellcreek *hellcreek,u16 meta =0 ;dev_dbg (hellcreek->dev,"Add static FDB entry: MAC=%pM, MASK=0x%02x, " -"OBT=%d, REPRIO_EN=%d, PRIO=%d\n" , entry->mac, entry->portmask, - entry->is_obt, entry->reprio_en, entry->reprio_tc); +"OBT=%d, PASS_BLOCKED=%d, REPRIO_EN=%d, PRIO=%d\n" , entry->mac, + entry->portmask, entry->is_obt, entry->pass_blocked, + entry->reprio_en, entry->reprio_tc);/* Add mac address */ hellcreek_write (hellcreek, entry->mac[1 ] | (entry->mac[0 ] <<8 ),HR_FDBWDH );
@@ -722,6 +723,8 @@ static int __hellcreek_fdb_add(struct hellcreek *hellcreek, meta |= entry->portmask <<HR_FDBWRM0_PORTMASK_SHIFT ;if (entry->is_obt) meta |=HR_FDBWRM0_OBT ; +if (entry->pass_blocked) + meta |=HR_FDBWRM0_PASS_BLOCKED ;if (entry->reprio_en) { meta |=HR_FDBWRM0_REPRIO_EN ; meta |= entry->reprio_tc <<HR_FDBWRM0_REPRIO_TC_SHIFT ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 290/1039 net: dsa: hellcreek: Add STP forwarding rule
In reply to Greg Kroah-HartmanFrom: Kurt Kanzenbach <[email protected]>
[ Upstream commit b7ade35eb53a2455f737a623c24e4b24455b2271 ]
Treat STP as management traffic. STP traffic is designated for the CPU port only. In addition, STP traffic has to pass blocked ports.
--- drivers/net/dsa/hirschmann/hellcreek.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/net/dsa/hirschmann/hellcreek.c +14 -0
@@ -1074,6 +1074,17 @@ static int hellcreek_setup_fdb(struct hellcreek *hellcreek) .reprio_tc = 6, /* TC: 6 as per IEEE 802.1AS */ .reprio_en = 1, }; +static struct hellcreek_fdb_entry stp = { +/* MAC: 01-80-C2-00-00-00 */ + .mac = {0x01 ,0x80 ,0xc2 ,0x00 ,0x00 ,0x00 }, + .portmask =0x03 ,/* Management ports */ + .age =0 , + .is_obt =0 , + .pass_blocked =1 , + .is_static =1 , + .reprio_tc =6 , + .reprio_en =1 , + };int ret;mutex_lock (&hellcreek->reg_lock);
@@ -1081,6 +1092,9 @@ static int hellcreek_setup_fdb(struct hellcreek *hellcreek)if (ret) goto out; ret =__hellcreek_fdb_add (hellcreek, &p2p); +if (ret) + goto out; + ret =__hellcreek_fdb_add (hellcreek, &stp); out:mutex_unlock (&hellcreek->reg_lock);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 291/1039 net: dsa: hellcreek: Allow PTP P2P measurements on blocked ports
In reply to Greg Kroah-HartmanFrom: Kurt Kanzenbach <[email protected]>
[ Upstream commit cad1798d2d0811ded37d1e946c6796102e58013b ]
Allow PTP peer delay measurements on blocked ports by STP. In case of topology changes the PTP stack can directly start with the correct delays.
--- drivers/net/dsa/hirschmann/hellcreek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/hirschmann/hellcreek.c +1 -1
@@ -1069,7 +1069,7 @@ static int hellcreek_setup_fdb(struct hellcreek *hellcreek) .portmask = 0x03, /* Management ports */ .age = 0, .is_obt = 0, - .pass_blocked = 0, + .pass_blocked = 1, .is_static = 1, .reprio_tc = 6, /* TC: 6 as per IEEE 802.1AS */ .reprio_en = 1,
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 292/1039 net: dsa: hellcreek: Add missing PTP via UDP rules
In reply to Greg Kroah-HartmanFrom: Kurt Kanzenbach <[email protected]>
[ Upstream commit 6cf01e451599da630ff1af529d61c5e4db4550ab ]
The switch supports PTP for UDP transport too. Therefore, add the missing static FDB entries to ensure correct forwarding of these packets.
--- drivers/net/dsa/hirschmann/hellcreek.c | 64 ++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 4 deletions(-)
drivers/net/dsa/hirschmann/hellcreek.c +60 -4
@@ -1052,7 +1052,7 @@ static void hellcreek_setup_tc_identity_mapping(struct hellcreek *hellcreek)static int hellcreek_setup_fdb (struct hellcreek *hellcreek) { -static struct hellcreek_fdb_entry ptp = { +static struct hellcreek_fdb_entry l2_ptp = {/* MAC: 01-1B-19-00-00-00 */ .mac = {0x01 ,0x1b ,0x19 ,0x00 ,0x00 ,0x00 }, .portmask =0x03 ,/* Management ports */
@@ -1063,7 +1063,29 @@ static int hellcreek_setup_fdb(struct hellcreek *hellcreek) .reprio_tc = 6, /* TC: 6 as per IEEE 802.1AS */ .reprio_en = 1, }; -static struct hellcreek_fdb_entry p2p = { +static struct hellcreek_fdb_entry udp4_ptp = { +/* MAC: 01-00-5E-00-01-81 */ + .mac = {0x01 ,0x00 ,0x5e ,0x00 ,0x01 ,0x81 }, + .portmask =0x03 ,/* Management ports */ + .age =0 , + .is_obt =0 , + .pass_blocked =0 , + .is_static =1 , + .reprio_tc =6 , + .reprio_en =1 , + }; +static struct hellcreek_fdb_entry udp6_ptp = { +/* MAC: 33-33-00-00-01-81 */ + .mac = {0x33 ,0x33 ,0x00 ,0x00 ,0x01 ,0x81 }, + .portmask =0x03 ,/* Management ports */ + .age =0 , + .is_obt =0 , + .pass_blocked =0 , + .is_static =1 , + .reprio_tc =6 , + .reprio_en =1 , + }; +static struct hellcreek_fdb_entry l2_p2p = {/* MAC: 01-80-C2-00-00-0E */ .mac = {0x01 ,0x80 ,0xc2 ,0x00 ,0x00 ,0x0e }, .portmask =0x03 ,/* Management ports */
@@ -1074,6 +1096,28 @@ static int hellcreek_setup_fdb(struct hellcreek *hellcreek) .reprio_tc = 6, /* TC: 6 as per IEEE 802.1AS */ .reprio_en = 1, }; +static struct hellcreek_fdb_entry udp4_p2p = { +/* MAC: 01-00-5E-00-00-6B */ + .mac = {0x01 ,0x00 ,0x5e ,0x00 ,0x00 ,0x6b }, + .portmask =0x03 ,/* Management ports */ + .age =0 , + .is_obt =0 , + .pass_blocked =1 , + .is_static =1 , + .reprio_tc =6 , + .reprio_en =1 , + }; +static struct hellcreek_fdb_entry udp6_p2p = { +/* MAC: 33-33-00-00-00-6B */ + .mac = {0x33 ,0x33 ,0x00 ,0x00 ,0x00 ,0x6b }, + .portmask =0x03 ,/* Management ports */ + .age =0 , + .is_obt =0 , + .pass_blocked =1 , + .is_static =1 , + .reprio_tc =6 , + .reprio_en =1 , + };static struct hellcreek_fdb_entry stp = {/* MAC: 01-80-C2-00-00-00 */ .mac = {0x01 ,0x80 ,0xc2 ,0x00 ,0x00 ,0x00 },
@@ -1088,10 +1132,22 @@ static int hellcreek_setup_fdb(struct hellcreek *hellcreek)int ret;mutex_lock (&hellcreek->reg_lock); - ret =__hellcreek_fdb_add (hellcreek, &ptp); + ret =__hellcreek_fdb_add (hellcreek, &l2_ptp); +if (ret) + goto out; + ret =__hellcreek_fdb_add (hellcreek, &udp4_ptp); +if (ret) + goto out; + ret =__hellcreek_fdb_add (hellcreek, &udp6_ptp); +if (ret) + goto out; + ret =__hellcreek_fdb_add (hellcreek, &l2_p2p); +if (ret) + goto out; + ret =__hellcreek_fdb_add (hellcreek, &udp4_p2p);if (ret) goto out; - ret =__hellcreek_fdb_add (hellcreek, &p2p); + ret =__hellcreek_fdb_add (hellcreek, &udp6_p2p);if (ret) goto out; ret =__hellcreek_fdb_add (hellcreek, &stp);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 293/1039 arm64: dts: qcom: c630: Fix soundcard setup
In reply to Greg Kroah-HartmanFrom: Srinivas Kandagatla <[email protected]>
[ Upstream commit c02b360ca67ebeb9de07b47b2fe53f964c2561d1 ]
Currently Soundcard has 1 rx device for headset and SoundWire Speaker Playback.
This setup has issues, ex if we try to play on headset the audio stream is also sent to SoundWire Speakers and we will hear sound in both headsets and speakers.
Make a separate device for Speakers and Headset so that the streams are different and handled properly.
--- .../boot/dts/qcom/sdm850-lenovo-yoga-c630.dts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+)
arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts +27 -0
@@ -523,6 +523,10 @@ dai@1 { reg = <1>; }; + + dai@2 { + reg = <2>; + }; }; &sound {
@@ -535,6 +539,7 @@ "SpkrLeft IN", "SPK1 OUT", "SpkrRight IN", "SPK2 OUT", "MM_DL1", "MultiMedia1 Playback", + "MM_DL3", "MultiMedia3 Playback", "MultiMedia2 Capture", "MM_UL2"; mm1-dai-link {
@@ -551,6 +556,13 @@ }; }; + mm3-dai-link { + link-name = "MultiMedia3"; + cpu { + sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA3>; + }; + }; + slim-dai-link { link-name = "SLIM Playback"; cpu {
@@ -580,6 +592,21 @@ sound-dai = <&wcd9340 1>; }; }; + + slim-wcd-dai-link { + link-name = "SLIM WCD Playback"; + cpu { + sound-dai = <&q6afedai SLIMBUS_1_RX>; + }; + + platform { + sound-dai = <&q6routing>; + }; + + codec { + sound-dai = <&wcd9340 2>; + }; + }; }; &tlmm {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 294/1039 arm64: dts: qcom: ipq6018: Fix gpio-ranges property
In reply to Greg Kroah-HartmanFrom: Baruch Siach <[email protected]>
[ Upstream commit 72cb4c48a46a7cfa58eb5842c0d3672ddd5bd9ad ]
There must be three parameters in gpio-ranges property. Fixes this not very helpful error message:
OF: /soc/pinctrl@1000000: (null) = 3 found 3
--- arch/arm64/boot/dts/qcom/ipq6018.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/ipq6018.dtsi +1 -1
@@ -220,7 +220,7 @@ interrupts = <GIC_SPI 208 IRQ_TYPE_LEVEL_HIGH>; gpio-controller; #gpio-cells = <2>; - gpio-ranges = <&tlmm 0 80>; + gpio-ranges = <&tlmm 0 0 80>; interrupt-controller; #interrupt-cells = <2>;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 295/1039 drm/msm/dpu: fix safe status debugfs file
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit f31b0e24d31e18b4503eeaf0032baeacc0beaff6 ]
Make safe_status debugfs fs file actually return safe status rather than danger status data.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +2 -2
@@ -73,8 +73,8 @@ static int _dpu_danger_signal_status(struct seq_file *s, &status); }else {seq_puts (s,"\nSafe signal status:\n" ); -if (kms->hw_mdp->ops.get_danger_status) - kms->hw_mdp->ops.get_danger_status (kms->hw_mdp, +if (kms->hw_mdp->ops.get_safe_status) + kms->hw_mdp->ops.get_safe_status (kms->hw_mdp, &status); }pm_runtime_put_sync (&kms->pdev->dev);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 296/1039 drm/bridge: ti-sn65dsi86: Set max register for regmap
In reply to Greg Kroah-HartmanFrom: Stephen Boyd <[email protected]>
[ Upstream commit 0b665d4af35837f0a0ae63135b84a3c187c1db3b ]
Set the maximum register to 0xff so we can dump the registers for this device in debugfs.
--- drivers/gpu/drm/bridge/ti-sn65dsi86.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/bridge/ti-sn65dsi86.c +1 -0
@@ -188,6 +188,7 @@ static const struct regmap_config ti_sn65dsi86_regmap_config = { .val_bits = 8, .volatile_table = &ti_sn_bridge_volatile_table, .cache_type = REGCACHE_NONE, + .max_register = 0xFF, }; static void ti_sn65dsi86_write_u16(struct ti_sn65dsi86 *pdata,
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 297/1039 gpu: host1x: select CONFIG_DMA_SHARED_BUFFER
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 6c7a388b62366f0de9936db3c1921d7f4e0011bc ]
Linking fails when dma-buf is disabled:
ld.lld: error: undefined symbol: dma_fence_release
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
referenced by
fence.c
gpu/host1x/fence.o:(host1x_syncpt_fence_enable_signaling) in archivedrivers/built-in.a
referenced byfence.c
gpu/host1x/fence.o:(host1x_fence_signal) in archivedrivers/built-in.a
referenced byfence.c
gpu/host1x/fence.o:(do_fence_timeout) in archivedrivers/built-in.a
--- drivers/gpu/host1x/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/host1x/Kconfig +1 -0
@@ -2,6 +2,7 @@ config TEGRA_HOST1X tristate "NVIDIA Tegra host1x driver" depends on ARCH_TEGRA || (ARM && COMPILE_TEST) + select DMA_SHARED_BUFFER select IOMMU_IOVA help Driver for the NVIDIA Tegra host1x hardware.
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 298/1039 drm/tegra: gr2d: Explicitly control module reset
In reply to Greg Kroah-HartmanFrom: Thierry Reding <[email protected]>
[ Upstream commit 271fca025a6d43f1c18a48543c5aaf31a31e4694 ]
As of commit 4782c0a5dd88 ("clk: tegra: Don't deassert reset on enabling clocks"), module resets are no longer automatically deasserted when the module clock is enabled. To make sure that the gr2d module continues to work, we need to explicitly control the module reset.
--- drivers/gpu/drm/tegra/gr2d.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-)
drivers/gpu/drm/tegra/gr2d.c +31 -2
@@ -4,9 +4,11 @@*/ #include <linux/clk.h> +#include <linux/delay.h> #include <linux/iommu.h> #include <linux/module.h> #include <linux/of_device.h> +#include <linux/reset.h> #include "drm.h" #include "gem.h"
@@ -19,6 +21,7 @@ struct gr2d_soc {struct gr2d {struct tegra_drm_client client;struct host1x_channel *channel; +struct reset_control *rst;struct clk *clk;const struct gr2d_soc *soc;
@@ -208,6 +211,12 @@ static int gr2d_probe(struct platform_device *pdev)if (!syncpts)return -ENOMEM ; + gr2d->rst =devm_reset_control_get (dev,NULL ); +if (IS_ERR (gr2d->rst)) { +dev_err (dev,"cannot get reset\n" ); +return PTR_ERR (gr2d->rst); + } + gr2d->clk =devm_clk_get (dev,NULL );if (IS_ERR (gr2d->clk)) {dev_err (dev,"cannot get clock\n" );
@@ -220,6 +229,14 @@ static int gr2d_probe(struct platform_device *pdev)return err; } +usleep_range (2000 ,4000 ); + + err =reset_control_deassert (gr2d->rst); +if (err <0 ) { +dev_err (dev,"failed to deassert reset: %d\n" , err); + goto disable_clk; + } +INIT_LIST_HEAD (&gr2d->client.base.list); gr2d->client.base.ops = &gr2d_client_ops; gr2d->client.base.dev = dev;
@@ -234,8 +251,7 @@ static int gr2d_probe(struct platform_device *pdev) err =host1x_client_register (&gr2d->client.base);if (err <0 ) {dev_err (dev,"failed to register host1x client: %d\n" , err); -clk_disable_unprepare (gr2d->clk); -return err; + goto assert_rst; }/* initialize address register map */
@@ -245,6 +261,13 @@ static int gr2d_probe(struct platform_device *pdev)platform_set_drvdata (pdev, gr2d);return 0 ; + +assert_rst: + (void )reset_control_assert (gr2d->rst); +disable_clk: +clk_disable_unprepare (gr2d->clk); + +return err; }static int gr2d_remove (struct platform_device *pdev)
@@ -259,6 +282,12 @@ static int gr2d_remove(struct platform_device *pdev)return err; } + err =reset_control_assert (gr2d->rst); +if (err <0 ) +dev_err (&pdev->dev,"failed to assert reset: %d\n" , err); + +usleep_range (2000 ,4000 ); +clk_disable_unprepare (gr2d->clk);return 0 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 299/1039 drm/tegra: vic: Fix DMA API misuse
In reply to Greg Kroah-HartmanFrom: Robin Murphy <[email protected]>
[ Upstream commit 5566174cb10a5167d59b0793871cab7990b149b8 ]
Upon failure, dma_alloc_coherent() returns NULL. If that does happen, passing some uninitialised stack contents to dma_mapping_error() - which belongs to a different API in the first place - has precious little chance of detecting it.
Also include the correct header, because the fragile transitive inclusion currently providing it is going to break soon.
--- drivers/gpu/drm/tegra/vic.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/tegra/vic.c +3 -4
@@ -5,6 +5,7 @@#include <linux/clk.h> #include <linux/delay.h> +#include <linux/dma-mapping.h> #include <linux/host1x.h> #include <linux/iommu.h> #include <linux/module.h>
@@ -232,10 +233,8 @@ static int vic_load_firmware(struct vic *vic)if (!client->group) { virt =dma_alloc_coherent (vic->dev, size, &iova,GFP_KERNEL ); - - err =dma_mapping_error (vic->dev, iova); -if (err <0 ) -return err; +if (!virt) +return -ENOMEM ; }else { virt =tegra_drm_alloc (tegra, size, &iova); }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 300/1039 media: hantro: Fix probe func error path
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
[ Upstream commit 37af43b250fda6162005d47bf7c959c70d52b107 ]
If clocks for some reason couldn't be enabled, probe function returns immediately, without disabling PM. This obviously leaves PM ref counters unbalanced.
Fix that by jumping to appropriate error path, so effects of PM functions are reversed.
--- drivers/staging/media/hantro/hantro_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/media/hantro/hantro_drv.c +2 -1
@@ -960,7 +960,7 @@ static int hantro_probe(struct platform_device *pdev) ret =clk_bulk_prepare (vpu->variant->num_clocks, vpu->clocks);if (ret) {dev_err (&pdev->dev,"Failed to prepare clocks\n" ); -return ret; + goto err_pm_disable; } ret =v4l2_device_register (&pdev->dev, &vpu->v4l2_dev);
@@ -1016,6 +1016,7 @@ err_v4l2_unreg:v4l2_device_unregister (&vpu->v4l2_dev); err_clk_unprepare:clk_bulk_unprepare (vpu->variant->num_clocks, vpu->clocks); +err_pm_disable:pm_runtime_dont_use_autosuspend (vpu->dev);pm_runtime_disable (vpu->dev);return ret;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 301/1039 xfrm: interface with if_id 0 should return error
In reply to Greg Kroah-HartmanFrom: Antony Antony <[email protected]>
[ Upstream commit 8dce43919566f06e865f7e8949f5c10d8c2493f5 ]
xfrm interface if_id = 0 would cause xfrm policy lookup errors since Commit 9f8550e4bd9d.
Now explicitly fail to create an xfrm interface when if_id = 0
With this commit:
ip link add ipsec0 type xfrm dev lo if_id 0
Error: if_id must be non zero.
v1->v2 change:
- add Fixes: tag
--- net/xfrm/xfrm_interface.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
net/xfrm/xfrm_interface.c +12 -2
@@ -637,11 +637,16 @@ static int xfrmi_newlink(struct net *src_net, struct net_device *dev, struct netlink_ext_ack *extack) {struct net *net =dev_net (dev); -struct xfrm_if_parms p; +struct xfrm_if_parms p = {};struct xfrm_if *xi;int err;xfrmi_netlink_parms (data, &p); +if (!p.if_id) { +NL_SET_ERR_MSG (extack,"if_id must be non zero" ); +return -EINVAL ; + } + xi =xfrmi_locate (net, &p);if (xi)return -EEXIST ;
@@ -666,7 +671,12 @@ static int xfrmi_changelink(struct net_device *dev, struct nlattr *tb[], {struct xfrm_if *xi =netdev_priv (dev);struct net *net = xi->net; -struct xfrm_if_parms p; +struct xfrm_if_parms p = {}; + +if (!p.if_id) { +NL_SET_ERR_MSG (extack,"if_id must be non zero" ); +return -EINVAL ; + }xfrmi_netlink_parms (data, &p); xi =xfrmi_locate (net, &p);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 302/1039 xfrm: state and policy should fail if XFRMA_IF_ID 0
In reply to Greg Kroah-HartmanFrom: Antony Antony <[email protected]>
[ Upstream commit 68ac0f3810e76a853b5f7b90601a05c3048b8b54 ]
xfrm ineterface does not allow xfrm if_id = 0
fail to create or update xfrm state and policy.
With this commit:
ip xfrm policy add src 192.0.2.1 dst 192.0.2.2 dir out if_id 0 RTNETLINK answers: Invalid argument
ip xfrm state add src 192.0.2.1 dst 192.0.2.2 proto esp spi 1 \
reqid 1 mode tunnel aead 'rfc4106(gcm(aes))' \
0x1111111111111111111111111111111111111111 96 if_id 0RTNETLINK answers: Invalid argument
v1->v2 change:
- add Fixes: tag
--- net/xfrm/xfrm_user.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
net/xfrm/xfrm_user.c +18 -3
@@ -621,8 +621,13 @@ static struct xfrm_state *xfrm_state_construct(struct net *net,xfrm_smark_init (attrs, &x->props.smark); -if (attrs[XFRMA_IF_ID ]) +if (attrs[XFRMA_IF_ID ]) { x->if_id =nla_get_u32 (attrs[XFRMA_IF_ID ]); +if (!x->if_id) { + err = -EINVAL ; + goto error; + } + } err =__xfrm_init_state (x, false, attrs[XFRMA_OFFLOAD_DEV ]);if (err)
@@ -1413,8 +1418,13 @@ static int xfrm_alloc_userspi(struct sk_buff *skb, struct nlmsghdr *nlh, mark =xfrm_mark_get (attrs, &m); -if (attrs[XFRMA_IF_ID ]) +if (attrs[XFRMA_IF_ID ]) { if_id =nla_get_u32 (attrs[XFRMA_IF_ID ]); +if (!if_id) { + err = -EINVAL ; + goto out_noput; + } + }if (p->info.seq) { x =xfrm_find_acq_byseq (net, mark, p->info.seq);
@@ -1727,8 +1737,13 @@ static struct xfrm_policy *xfrm_policy_construct(struct net *net, struct xfrm_usxfrm_mark_get (attrs, &xp->mark); -if (attrs[XFRMA_IF_ID ]) +if (attrs[XFRMA_IF_ID ]) { xp->if_id =nla_get_u32 (attrs[XFRMA_IF_ID ]); +if (!xp->if_id) { + err = -EINVAL ; + goto error; + } + }return xp; error:
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 303/1039 ARM: 9159/1: decompressor: Avoid UNPREDICTABLE NOP encoding
In reply to Greg Kroah-HartmanFrom: Andre Przywara <[email protected]>
[ Upstream commit a92882a4d270fbcc021ee6848de5e48b7f0d27f3 ]
In the decompressor's head.S we need to start with an instruction that is some kind of NOP, but also mimics as the PE/COFF header, when the kernel is linked as an UEFI application. The clever solution here is "tstne r0, #0x4d000", which in the worst case just clobbers the condition flags, and bears the magic "MZ" signature in the lowest 16 bits.
However the encoding used (0x13105a4d) is actually not valid, since bits [15:12] are supposed to be 0 (written as "(0)" in the ARM ARM). Violating this is UNPREDICTABLE, and *can* trigger an UNDEFINED exception. Common Cortex cores seem to ignore those bits, but QEMU chooses to trap, so the code goes fishing because of a missing exception handler at this point. We are just saved by the fact that commonly (with -kernel or when running from U-Boot) the "Z" bit is set, so the instruction is never executed. See [0] for more details.
To make things more robust and avoid UNPREDICTABLE behaviour in the kernel code, lets replace this with a "two-instruction NOP":
The first instruction is an exclusive OR, the effect of which the second instruction reverts. This does not leave any trace, neither in a register nor in the condition flags. Also it's a perfectly valid encoding. Kudos to Peter Maydell for coming up with this gem.
[0] https://lore.kernel.org/qemu-devel/YTPIdbUCmwagL5%[email protected]/T/
--- arch/arm/boot/compressed/efi-header.S | 22 ++++++++++++++-------- arch/arm/boot/compressed/head.S | 3 ++- 2 files changed, 16 insertions(+), 9 deletions(-)
arch/arm/boot/compressed/efi-header.S +14 -8
@@ -9,16 +9,22 @@ #include <linux/sizes.h> .macro __nop -#ifdef CONFIG_EFI_STUB - @ This is almost but not quite a NOP, since it does clobber the - @ condition flags. But it is the best we can do for EFI, since - @ PE/COFF expects the magic string "MZ" at offset 0, while the - @ ARM/Linux boot protocol expects an executable instruction - @ there. - .inst MZ_MAGIC | (0x1310 << 16) @ tstne r0, #0x4d000 -#else AR_CLASS( mov r0, r0 ) M_CLASS( nop.w ) + .endm + + .macro __initial_nops +#ifdef CONFIG_EFI_STUB + @ This is a two-instruction NOP, which happens to bear the + @ PE/COFF signature "MZ" in the first two bytes, so the kernel + @ is accepted as an EFI binary. Booting via the UEFI stub + @ will not execute those instructions, but the ARM/Linux + @ boot protocol does, so we need some NOPs here. + .inst MZ_MAGIC | (0xe225 << 16) @ eor r5, r5, 0x4d000 + eor r5, r5, 0x4d000 @ undo previous insn +#else + __nop + __nop #endif .endm
arch/arm/boot/compressed/head.S +2 -1
@@ -203,7 +203,8 @@ start: * were patching the initial instructions of the kernel, i.e * had started to exploit this "patch area". */ - .rept 7 + __initial_nops + .rept 5 __nop .endr #ifndef CONFIG_THUMB2_KERNEL
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 304/1039 usb: ftdi-elan: fix memory leak on device disconnect
In reply to Greg Kroah-HartmanFrom: Wei Yongjun <[email protected]>
[ Upstream commit 1646566b5e0c556f779180a8514e521ac735de1e ]
'ftdi' is alloced when probe device, but not free on device disconnect, this cause a memory leak as follows:
unreferenced object 0xffff88800d584000 (size 8400):
comm "kworker/0:2", pid 3809, jiffies 4295453055 (age 13.784s) hex dump (first 32 bytes):
00 40 58 0d 80 88 ff ff 00 40 58 0d 80 88 ff ff .@X......@X.....
00 00 00 00 00 00 00 00 00 00 00 00 ad 4e ad de .............N..
backtrace:
[<000000000d47f947>] kmalloc_order_trace+0x19/0x110 mm/slab_common.c:960
[<000000008548ac68>] ftdi_elan_probe+0x8c/0x880 drivers/usb/misc/ftdi-elan.c:2647
[<000000007f73e422>] usb_probe_interface+0x31b/0x800 drivers/usb/core/driver.c:396
[<00000000fe8d07fc>] really_probe+0x299/0xc30 drivers/base/dd.c:517
[<0000000005da7d32>] __driver_probe_device+0x357/0x500 drivers/base/dd.c:751
[<000000003c2c9579>] driver_probe_device+0x4e/0x140 drivers/base/dd.c:781Fix it by freeing 'ftdi' after nobody use it.
--- drivers/usb/misc/ftdi-elan.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/misc/ftdi-elan.c +1 -0
@@ -202,6 +202,7 @@ static void ftdi_elan_delete(struct kref *kref)mutex_unlock (&ftdi_module_lock);kfree (ftdi->bulk_in_buffer); ftdi->bulk_in_buffer =NULL ; +kfree (ftdi); }static void ftdi_elan_put_kref (struct usb_ftdi *ftdi)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 305/1039 arm64: dts: marvell: cn9130: add GPIO and SPI aliases
In reply to Greg Kroah-HartmanFrom: Robert Marko <[email protected]>
[ Upstream commit effd42600b987c1e95f946b14fefc1c7639e7439 ]
CN9130 has one CP115 built in, which like the CP110 has 2 GPIO and 2 SPI controllers built-in.
However, unlike the Armada 7k and 8k the SoC DTSI doesn't add the required aliases as both the Orion SPI driver and MVEBU GPIO drivers require the aliases to be present.
So add the required aliases for GPIO and SPI controllers.
--- arch/arm64/boot/dts/marvell/cn9130.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/marvell/cn9130.dtsi +7 -0
@@ -11,6 +11,13 @@ model = "Marvell Armada CN9130 SoC"; compatible = "marvell,cn9130", "marvell,armada-ap807-quad", "marvell,armada-ap807"; + + aliases { + gpio1 = &cp0_gpio1; + gpio2 = &cp0_gpio2; + spi1 = &cp0_spi0; + spi2 = &cp0_spi1; + }; }; /*
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 306/1039 arm64: dts: marvell: cn9130: enable CP0 GPIO controllers
In reply to Greg Kroah-HartmanFrom: Robert Marko <[email protected]>
[ Upstream commit 0734f8311ce72c9041e5142769eff2083889c172 ]
CN9130 has a built-in CP115 which has 2 GPIO controllers, but unlike in Armada 7k and 8k both are left disabled by the SoC DTSI.
This first of all makes no sense as they are always present due to being SoC built-in and its an issue as boards like CN9130-CRB use the CPO GPIO2 pins for regulators and SD card support without enabling them first.
So, enable both of them like Armada 7k and 8k do.
--- arch/arm64/boot/dts/marvell/cn9130.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm64/boot/dts/marvell/cn9130.dtsi +8 -0
@@ -42,3 +42,11 @@ #undef CP11X_PCIE0_BASE #undef CP11X_PCIE1_BASE #undef CP11X_PCIE2_BASE + +&cp0_gpio1 { + status = "okay"; +}; + +&cp0_gpio2 { + status = "okay"; +};
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 307/1039 ARM: dts: armada-38x: Add generic compatible to UART nodes
In reply to Greg Kroah-HartmanFrom: Marek Behún <[email protected]>
[ Upstream commit 62480772263ab6b52e758f2346c70a526abd1d28 ]
Add generic compatible string "ns16550a" to serial port nodes of Armada 38x.
This makes it possible to use earlycon.
--- arch/arm/boot/dts/armada-38x.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/boot/dts/armada-38x.dtsi +2 -2
@@ -168,7 +168,7 @@ }; uart0: serial@12000 { - compatible = "marvell,armada-38x-uart"; + compatible = "marvell,armada-38x-uart", "ns16550a"; reg = <0x12000 0x100>; reg-shift = <2>; interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>;
@@ -178,7 +178,7 @@ }; uart1: serial@12100 { - compatible = "marvell,armada-38x-uart"; + compatible = "marvell,armada-38x-uart", "ns16550a"; reg = <0x12100 0x100>; reg-shift = <2>; interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 308/1039 mt76: mt7921: drop offload_flags overwritten
In reply to Greg Kroah-HartmanFrom: Sean Wang <[email protected]>
[ Upstream commit 2363b6a646b65a207345b9a9024dff0eff3fec44 ]
offload_flags have to be dropped for mt7921 because mt76.omac_idx 0 would always run as station mode that would cause Tx encapsulation setting is not applied to mac80211.
Also, drop IEEE80211_OFFLOAD_ENCAP_4ADDR too because it is not really being supported.
--- drivers/net/wireless/mediatek/mt76/mt7921/main.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/main.c +0 -6
@@ -318,12 +318,6 @@ static int mt7921_add_interface(struct ieee80211_hw *hw, mtxq->wcid = &mvif->sta.wcid; } -if (vif->type !=NL80211_IFTYPE_AP && - (!mvif->mt76.omac_idx || mvif->mt76.omac_idx >3 )) - vif->offload_flags =0 ; - - vif->offload_flags |=IEEE80211_OFFLOAD_ENCAP_4ADDR ; - out:mt7921_mutex_release (dev);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 309/1039 mt76: mt7921: fix MT7921E reset failure
In reply to Greg Kroah-HartmanFrom: Sean Wang <[email protected]>
[ Upstream commit 0efaf31dec572d3aac4316c6d952e06d1c33adc4 ]
There is a missing mt7921e_driver_own in the MT7921E reset procedure since the mt7921 mcu.c has been refactored for MT7921S, that will result in MT7921E reset failure, so add it back now.
--- drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h | 1 + drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c | 4 ++++ drivers/net/wireless/mediatek/mt76/mt7921/pci_mcu.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +1 -0
@@ -446,6 +446,7 @@ int mt7921_mcu_restart(struct mt76_dev *dev);void mt7921e_queue_rx_skb (struct mt76_dev *mdev,enum mt76_rxq_id q,struct sk_buff *skb); +int mt7921e_driver_own (struct mt7921_dev *dev);int mt7921e_mac_reset (struct mt7921_dev *dev);int mt7921e_mcu_init (struct mt7921_dev *dev);int mt7921s_wfsys_reset (struct mt7921_dev *dev);
drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c +4 -0
@@ -321,6 +321,10 @@ int mt7921e_mac_reset(struct mt7921_dev *dev) MT_INT_MCU_CMD);mt76_wr (dev,MT_PCIE_MAC_INT_ENABLE ,0xff ); + err =mt7921e_driver_own (dev); +if (err) +return err; + err =mt7921_run_firmware (dev);if (err) goto out;
drivers/net/wireless/mediatek/mt76/mt7921/pci_mcu.c +1 -1
@@ -4,7 +4,7 @@#include "mt7921.h" #include "mcu.h" -static int mt7921e_driver_own (struct mt7921_dev *dev) +int mt7921e_driver_own (struct mt7921_dev *dev) {u32 reg =mt7921_reg_map_l1 (dev,MT_TOP_LPCR_HOST_BAND0 );
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 310/1039 mt76: debugfs: fix queue reporting for mt76-usb
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit eae7df016c30468e09481a75b1339f0ab5ece222 ]
Fix number of rx-queued frames reported by mt76_usb driver.
--- drivers/net/wireless/mediatek/mt76/debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/debugfs.c +1 -1
@@ -82,7 +82,7 @@ static int mt76_rx_queues_read(struct seq_file *s, void *data) queued =mt76_is_usb (dev) ? q->ndesc - q->queued : q->queued;seq_printf (s," %9d | %9d | %9d | %9d |\n" , - i, q->queued, q->head, q->tail); + i, queued, q->head, q->tail); }return 0 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 311/1039 mt76: fix possible OOB issue in mt76_calculate_default_rate
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit d4f3d1c4d3c2bcce76a96a6562170664b25112f0 ]
Cap max offset value to ARRAY_SIZE(mt76_rates) - 1 in mt76_calculate_default_rate routine in order to avoid possible Out Of Bound accesses.
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +4 -3
@@ -1494,7 +1494,6 @@ EXPORT_SYMBOL_GPL(mt76_init_queue);u16 mt76_calculate_default_rate (struct mt76_phy *phy,int rateidx) {int offset =0 ; -struct ieee80211_rate *rate;if (phy->chandef.chan->band !=NL80211_BAND_2GHZ ) offset =4 ;
@@ -1503,9 +1502,11 @@ u16 mt76_calculate_default_rate(struct mt76_phy *phy, int rateidx)if (rateidx <0 ) rateidx =0 ; - rate = &mt76_rates[offset + rateidx]; + rateidx += offset; +if (rateidx >=ARRAY_SIZE (mt76_rates)) + rateidx = offset; -return rate->hw_value; +return mt76_rates[rateidx].hw_value; }EXPORT_SYMBOL_GPL (mt76_calculate_default_rate);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 312/1039 mt76: mt7921: fix possible NULL pointer dereference in mt7921_mac_write_txwi
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit ec2ebc1c5a5ce49538fa78108c53eaf722eee908 ]
Fix a possible NULL pointer deference issue in mt7921_mac_write_txwi routine if vif is NULL.
--- drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7921/mac.c +1 -1
@@ -903,7 +903,7 @@ void mt7921_mac_write_txwi(struct mt7921_dev *dev, __le32 *txwi,mt7921_mac_write_txwi_80211 (dev, txwi, skb, key);if (txwi[2 ] &cpu_to_le32 (MT_TXD2_FIX_RATE )) { -int rateidx =ffs (vif->bss_conf.basic_rates) -1 ; +int rateidx = vif ?ffs (vif->bss_conf.basic_rates) -1 :0 ;u16 rate, mode;/* hardware won't add HTC for mgmt/ctrl frame */
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 313/1039 mt76: mt7921: move mt76_connac_mcu_set_hif_suspend to bus-related files
In reply to Greg Kroah-HartmanFrom: Sean Wang <[email protected]>
[ Upstream commit 6906aa93eb93d54a42ce1902f00d6ea04ecb039b ]
This is a preliminary patch for the following patch ("mt76: mt7921s: fix the device cannot sleep deeply in suspend).
mt76_connac_mcu_set_hif_suspend eventually would be handled in each bus-level suspend/resume handler in either mt7921/sdio.c or mt7921/pci.c depending on what type of the bus the device is running on. We can move mt76_connac_mcu_set_hif_suspend to bus-related files to simplify the logic.
--- .../net/wireless/mediatek/mt76/mt7921/main.c | 13 ++----------- .../net/wireless/mediatek/mt76/mt7921/pci.c | 18 +++++------------- .../net/wireless/mediatek/mt76/mt7921/sdio.c | 18 +++++------------- 3 files changed, 12 insertions(+), 37 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/main.c +2 -11
@@ -1232,7 +1232,6 @@ static int mt7921_suspend(struct ieee80211_hw *hw, {struct mt7921_dev *dev =mt7921_hw_dev (hw);struct mt7921_phy *phy =mt7921_hw_phy (hw); -int err;cancel_delayed_work_sync (&phy->scan_work);cancel_delayed_work_sync (&phy->mt76->mac_work);
@@ -1250,25 +1249,18 @@ static int mt7921_suspend(struct ieee80211_hw *hw, mt76_connac_mcu_set_suspend_iter, &dev->mphy); - err =mt76_connac_mcu_set_hif_suspend (&dev->mt76, true); -mt7921_mutex_release (dev); -return err; +return 0 ; }static int mt7921_resume (struct ieee80211_hw *hw) {struct mt7921_dev *dev =mt7921_hw_dev (hw);struct mt7921_phy *phy =mt7921_hw_phy (hw); -int err;mt7921_mutex_acquire (dev); - err =mt76_connac_mcu_set_hif_suspend (&dev->mt76, false); -if (err <0 ) - goto out; -set_bit (MT76_STATE_RUNNING , &phy->mt76->state);clear_bit (MT76_STATE_SUSPEND , &phy->mt76->state); ieee80211_iterate_active_interfaces(hw,
@@ -1278,11 +1270,10 @@ static int mt7921_resume(struct ieee80211_hw *hw)ieee80211_queue_delayed_work (hw, &phy->mt76->mac_work,MT7921_WATCHDOG_TIME ); -out:mt7921_mutex_release (dev); -return err; +return 0 ; }static void mt7921_set_wakeup (struct ieee80211_hw *hw,bool enabled)
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +5 -13
@@ -235,7 +235,6 @@ static int mt7921_pci_suspend(struct pci_dev *pdev, pm_message_t state)struct mt76_dev *mdev =pci_get_drvdata (pdev); struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);struct mt76_connac_pm *pm = &dev->pm; -bool hif_suspend;int i, err; pm->suspended = true;
@@ -246,12 +245,9 @@ static int mt7921_pci_suspend(struct pci_dev *pdev, pm_message_t state)if (err <0 ) goto restore_suspend; - hif_suspend = !test_bit (MT76_STATE_SUSPEND , &dev->mphy.state); -if (hif_suspend) { - err =mt76_connac_mcu_set_hif_suspend (mdev, true); -if (err) - goto restore_suspend; - } + err =mt76_connac_mcu_set_hif_suspend (mdev, true); +if (err) + goto restore_suspend;/* always enable deep sleep during suspend to reduce * power consumption
@@ -302,8 +298,7 @@ restore_napi:if (!pm->ds_enable)mt76_connac_mcu_set_deep_sleep (&dev->mt76, false); -if (hif_suspend) -mt76_connac_mcu_set_hif_suspend (mdev, false); +mt76_connac_mcu_set_hif_suspend (mdev, false); restore_suspend: pm->suspended = false;
@@ -356,10 +351,7 @@ static int mt7921_pci_resume(struct pci_dev *pdev)if (!pm->ds_enable)mt76_connac_mcu_set_deep_sleep (&dev->mt76, false); -if (!test_bit (MT76_STATE_SUSPEND , &dev->mphy.state)) - err =mt76_connac_mcu_set_hif_suspend (mdev, false); - - return err; + return mt76_connac_mcu_set_hif_suspend(mdev, false); }#endif /* CONFIG_PM */
drivers/net/wireless/mediatek/mt76/mt7921/sdio.c +5 -13
@@ -203,7 +203,6 @@ static int mt7921s_suspend(struct device *__dev)struct mt7921_dev *dev =sdio_get_drvdata (func);struct mt76_connac_pm *pm = &dev->pm;struct mt76_dev *mdev = &dev->mt76; -bool hif_suspend;int err; pm->suspended = true;
@@ -214,12 +213,9 @@ static int mt7921s_suspend(struct device *__dev)if (err <0 ) goto restore_suspend; - hif_suspend = !test_bit (MT76_STATE_SUSPEND , &dev->mphy.state); -if (hif_suspend) { - err =mt76_connac_mcu_set_hif_suspend (mdev, true); -if (err) - goto restore_suspend; - } + err =mt76_connac_mcu_set_hif_suspend (mdev, true); +if (err) + goto restore_suspend;/* always enable deep sleep during suspend to reduce * power consumption
@@ -253,8 +249,7 @@ restore_worker:if (!pm->ds_enable)mt76_connac_mcu_set_deep_sleep (mdev, false); -if (hif_suspend) -mt76_connac_mcu_set_hif_suspend (mdev, false); +mt76_connac_mcu_set_hif_suspend (mdev, false); restore_suspend: pm->suspended = false;
@@ -285,10 +280,7 @@ static int mt7921s_resume(struct device *__dev)if (!pm->ds_enable)mt76_connac_mcu_set_deep_sleep (mdev, false); -if (!test_bit (MT76_STATE_SUSPEND , &dev->mphy.state)) - err =mt76_connac_mcu_set_hif_suspend (mdev, false); - -return err; +return mt76_connac_mcu_set_hif_suspend (mdev, false); }static const struct dev_pm_ops mt7921s_pm_ops = {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 314/1039 mt76: mt7921s: fix the device cannot sleep deeply in suspend
In reply to Greg Kroah-HartmanFrom: Sean Wang <[email protected]>
[ Upstream commit 5ad4faca7690a88b4529238c757b6b8ead8056ec ]
According to the MT7921S firmware, the cmd MCU_UNI_CMD_HIF_CTRL have to be last MCU command to execute in suspend handler and all data traffic have to be stopped before the cmd MCU_UNI_CMD_HIF_CTRL starts as well in order that mt7921 can successfully fall into the deep sleep mode.
Where we reuse the flag MT76_STATE_SUSPEND and avoid creating another global flag to stop all of the traffic onto the SDIO bus.
--- .../wireless/mediatek/mt76/mt76_connac_mcu.c | 2 +- .../net/wireless/mediatek/mt76/mt7921/main.c | 3 -- .../net/wireless/mediatek/mt76/mt7921/sdio.c | 34 ++++++++++++------- drivers/net/wireless/mediatek/mt76/sdio.c | 3 +- .../net/wireless/mediatek/mt76/sdio_txrx.c | 3 +- 5 files changed, 27 insertions(+), 18 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +1 -1
@@ -2461,7 +2461,7 @@ void mt76_connac_mcu_set_suspend_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) {struct mt76_phy *phy = priv; -bool suspend =test_bit (MT76_STATE_SUSPEND , &phy->state); +bool suspend = !test_bit (MT76_STATE_RUNNING , &phy->state);struct ieee80211_hw *hw = phy->hw;struct cfg80211_wowlan *wowlan = hw->wiphy->wowlan_config;int i;
drivers/net/wireless/mediatek/mt76/mt7921/main.c +0 -3
@@ -1242,8 +1242,6 @@ static int mt7921_suspend(struct ieee80211_hw *hw,mt7921_mutex_acquire (dev);clear_bit (MT76_STATE_RUNNING , &phy->mt76->state); - -set_bit (MT76_STATE_SUSPEND , &phy->mt76->state); ieee80211_iterate_active_interfaces(hw, IEEE80211_IFACE_ITER_RESUME_ALL, mt76_connac_mcu_set_suspend_iter,
@@ -1262,7 +1260,6 @@ static int mt7921_resume(struct ieee80211_hw *hw)mt7921_mutex_acquire (dev);set_bit (MT76_STATE_RUNNING , &phy->mt76->state); -clear_bit (MT76_STATE_SUSPEND , &phy->mt76->state); ieee80211_iterate_active_interfaces(hw, IEEE80211_IFACE_ITER_RESUME_ALL, mt76_connac_mcu_set_suspend_iter,
drivers/net/wireless/mediatek/mt76/mt7921/sdio.c +22 -12
@@ -206,6 +206,8 @@ static int mt7921s_suspend(struct device *__dev)int err; pm->suspended = true; +set_bit (MT76_STATE_SUSPEND , &mdev->phy.state); +cancel_delayed_work_sync (&pm->ps_work);cancel_work_sync (&pm->wake_work);
@@ -213,10 +215,6 @@ static int mt7921s_suspend(struct device *__dev)if (err <0 ) goto restore_suspend; - err =mt76_connac_mcu_set_hif_suspend (mdev, true); -if (err) - goto restore_suspend; -/* always enable deep sleep during suspend to reduce * power consumption */
@@ -224,34 +222,45 @@ static int mt7921s_suspend(struct device *__dev)mt76_txq_schedule_all (&dev->mphy);mt76_worker_disable (&mdev->tx_worker); -mt76_worker_disable (&mdev->sdio.txrx_worker);mt76_worker_disable (&mdev->sdio.status_worker); -mt76_worker_disable (&mdev->sdio.net_worker);cancel_work_sync (&mdev->sdio.stat_work);clear_bit (MT76_READING_STATS , &dev->mphy.state); -mt76_tx_status_check (mdev, true); - err =mt7921_mcu_fw_pmctrl (dev); +mt76_worker_schedule (&mdev->sdio.txrx_worker); +wait_event_timeout (dev->mt76.sdio.wait, +mt76s_txqs_empty (&dev->mt76),5 *HZ ); + +/* It is supposed that SDIO bus is idle at the point */ + err =mt76_connac_mcu_set_hif_suspend (mdev, true);if (err) goto restore_worker; +mt76_worker_disable (&mdev->sdio.txrx_worker); +mt76_worker_disable (&mdev->sdio.net_worker); + + err =mt7921_mcu_fw_pmctrl (dev); +if (err) + goto restore_txrx_worker; +sdio_set_host_pm_flags (func,MMC_PM_KEEP_POWER );return 0 ; +restore_txrx_worker: +mt76_worker_enable (&mdev->sdio.net_worker); +mt76_worker_enable (&mdev->sdio.txrx_worker); +mt76_connac_mcu_set_hif_suspend (mdev, false); + restore_worker:mt76_worker_enable (&mdev->tx_worker); -mt76_worker_enable (&mdev->sdio.txrx_worker);mt76_worker_enable (&mdev->sdio.status_worker); -mt76_worker_enable (&mdev->sdio.net_worker);if (!pm->ds_enable)mt76_connac_mcu_set_deep_sleep (mdev, false); -mt76_connac_mcu_set_hif_suspend (mdev, false); - restore_suspend: +clear_bit (MT76_STATE_SUSPEND , &mdev->phy.state); pm->suspended = false;return err;
@@ -266,6 +275,7 @@ static int mt7921s_resume(struct device *__dev)int err; pm->suspended = false; +clear_bit (MT76_STATE_SUSPEND , &mdev->phy.state); err =mt7921_mcu_drv_pmctrl (dev);if (err <0 )
drivers/net/wireless/mediatek/mt76/sdio.c +2 -1
@@ -479,7 +479,8 @@ static void mt76s_status_worker(struct mt76_worker *w) resched = true;if (dev->drv->tx_status_data && - !test_and_set_bit (MT76_READING_STATS , &dev->phy.state)) + !test_and_set_bit (MT76_READING_STATS , &dev->phy.state) && + !test_bit (MT76_STATE_SUSPEND , &dev->phy.state))queue_work (dev->wq, &dev->sdio.stat_work); }while (nframes >0 );
drivers/net/wireless/mediatek/mt76/sdio_txrx.c +2 -1
@@ -317,7 +317,8 @@ void mt76s_txrx_worker(struct mt76_sdio *sdio)if (ret >0 ) nframes += ret; -if (test_bit (MT76_MCU_RESET , &dev->phy.state)) { +if (test_bit (MT76_MCU_RESET , &dev->phy.state) || +test_bit (MT76_STATE_SUSPEND , &dev->phy.state)) {if (!mt76s_txqs_empty (dev))continue ;else
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 315/1039 mt76: mt7921: use correct iftype data on 6GHz cap init
In reply to Greg Kroah-HartmanFrom: Shayne Chen <[email protected]>
[ Upstream commit 00ff52346d74c38787ff8b4acde8c5671d9b7fe2 ]
Set 6GHz cap to iftype data which is matched to the type of current interface.
--- drivers/net/wireless/mediatek/mt76/mt7921/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7921/main.c +1 -1
@@ -166,7 +166,7 @@ mt7921_init_he_caps(struct mt7921_phy *phy, enum nl80211_band band,if (vht_cap->cap &IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN ) cap |=IEEE80211_HE_6GHZ_CAP_RX_ANTPAT_CONS ; - data->he_6ghz_capa.capa =cpu_to_le16 (cap); + data[idx].he_6ghz_capa.capa =cpu_to_le16 (cap); } idx++; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 316/1039 mt76: mt7921s: fix possible kernel crash due to invalid Rx count
In reply to Greg Kroah-HartmanFrom: Sean Wang <[email protected]>
[ Upstream commit 2b7f3574ca9a7ff4a6b4ec1ae4dfdfde481ac80b ]
Return the proper error code when out-of-range the Rx aggregation count are reported from the hardware that would create the unreasonable extreme large Rx buffer.
[ 100.873810] show_stack+0x20/0x2c [ 100.873823] dump_stack+0xc4/0x140 [ 100.873839] bad_page+0x110/0x114 [ 100.873854] check_new_pages+0xf8/0xfc [ 100.873869] rmqueue+0x5a0/0x640 [ 100.873884] get_page_from_freelist+0x124/0x20c [ 100.873898] __alloc_pages_nodemask+0x114/0x2a4 [ 100.873918] mt76s_rx_run_queue+0xd4/0x2e4 [mt76_sdio 8280a88a0c8c9cf203f16e194f99ac293bdbb2f5] [ 100.873938] mt76s_rx_handler+0xd4/0x2a0 [mt76_sdio 8280a88a0c8c9cf203f16e194f99ac293bdbb2f5] [ 100.873957] mt76s_txrx_worker+0xac/0x17c [mt76_sdio 8280a88a0c8c9cf203f16e194f99ac293bdbb2f5] [ 100.873977] mt7921s_txrx_worker+0x5c/0xd8 [mt7921s d0bdbc018082dbc8dc1407614be3c2e7bd64423b] [ 100.874003] __mt76_worker_fn+0xe8/0x170 [mt76 b80af3483a8f9d48e916c12d8dbfaa0d3cd15337] [ 100.874018] kthread+0x148/0x3ac [ 100.874032] ret_from_fork+0x10/0x30 [ 100.874067] Kernel Offset: 0x1fe2000000 from 0xffffffc010000000 [ 100.874079] PHYS_OFFSET: 0xffffffe800000000 [ 100.874090] CPU features: 0x0240002,2188200c
--- drivers/net/wireless/mediatek/mt76/mt7921/sdio.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/sdio.c +4 -0
@@ -62,6 +62,10 @@ static int mt7921s_parse_intr(struct mt76_dev *dev, struct mt76s_intr *intr)if (err <0 )return err; +if (irq_data->rx.num[0 ] >16 || + irq_data->rx.num[1 ] >128 ) +return -EINVAL ; + intr->isr = irq_data->isr; intr->rec_mb = irq_data->rec_mb; intr->tx.wtqcr = irq_data->tx.wtqcr;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 317/1039 mt76: connac: fix last_chan configuration in mt76_connac_mcu_rate_txpower_band
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit 73c7c0443685d8d152c3451e7305a2c2bc47b32e ]
last_ch configuration must not be dependent on the current configured band but it is defined by hw capabilities since the fw always expects the following order:
- 2GHz
- 5GHz
- 6GHz
--- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +5 -5
@@ -2008,12 +2008,12 @@ mt76_connac_mcu_rate_txpower_band(struct mt76_phy *phy, } batch_size =DIV_ROUND_UP (n_chan, batch_len); -if (!phy->cap.has_5ghz) - last_ch = chan_list_2ghz[n_chan -1 ]; -else if (phy->cap.has_6ghz) - last_ch = chan_list_6ghz[n_chan -1 ]; +if (phy->cap.has_6ghz) + last_ch = chan_list_6ghz[ARRAY_SIZE (chan_list_6ghz) -1 ]; +else if (phy->cap.has_5ghz) + last_ch = chan_list_5ghz[ARRAY_SIZE (chan_list_5ghz) -1 ];else - last_ch = chan_list_5ghz[n_chan -1 ]; + last_ch = chan_list_2ghz[ARRAY_SIZE (chan_list_2ghz) -1 ];for (i =0 ; i < batch_size; i++) {struct mt76_connac_tx_power_limit_tlv tx_power_tlv = {};
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 318/1039 mt76: mt7921: fix possible resume failure
In reply to Greg Kroah-HartmanFrom: Sean Wang <[email protected]>
[ Upstream commit 5375001bb4ce22801bf3bb566cc3e67d2d3a5dc0 ]
Fix the possible resume failure due to mt76_connac_mcu_set_hif_suspend timeout.
That is because clearing the flag pm->suspended too early opened up a race window, where mt7921_poll_tx/rx scheduled a ps_work to put the device in doze mode, that is unexpected for the device is being resumed from the suspend state and would make the remaining MCU comamnds in resume handler failed to execute.
--- drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +7 -2
@@ -313,7 +313,6 @@ static int mt7921_pci_resume(struct pci_dev *pdev)struct mt76_connac_pm *pm = &dev->pm;int i, err; - pm->suspended = false; err =pci_set_power_state (pdev,PCI_D0 );if (err)return err;
@@ -351,7 +350,13 @@ static int mt7921_pci_resume(struct pci_dev *pdev)if (!pm->ds_enable)mt76_connac_mcu_set_deep_sleep (&dev->mt76, false); - return mt76_connac_mcu_set_hif_suspend(mdev, false); + err =mt76_connac_mcu_set_hif_suspend (mdev, false); +if (err) +return err; + + pm->suspended = false; + + return err; }#endif /* CONFIG_PM */
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 319/1039 mt76: connac: introduce MCU_EXT macros
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit e6d2070d9d64aad04c12424865cfd9684ba64bea ]
Introduce MCU_EXT_CMD and MCU_EXT_QUERY macros in mt76_connac module. This is a preliminary patch to reuse mt76_connac module in mt7915 driver.
--- .../net/wireless/mediatek/mt76/mt7615/main.c | 4 +- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 154 ++++++++---------- .../wireless/mediatek/mt76/mt7615/testmode.c | 4 +- .../wireless/mediatek/mt76/mt76_connac_mcu.c | 4 +- .../wireless/mediatek/mt76/mt76_connac_mcu.h | 16 +- .../net/wireless/mediatek/mt76/mt7921/main.c | 4 +- .../net/wireless/mediatek/mt76/mt7921/mcu.c | 76 +++------ 7 files changed, 113 insertions(+), 149 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/main.c +2 -2
@@ -73,7 +73,7 @@ static int mt7615_start(struct ieee80211_hw *hw) goto out; } - ret =mt7615_mcu_set_chan_info (phy,MCU_EXT_CMD_SET_RX_PATH ); + ret =mt7615_mcu_set_chan_info (phy,MCU_EXT_CMD (SET_RX_PATH ));if (ret) goto out;
@@ -331,7 +331,7 @@ int mt7615_set_channel(struct mt7615_phy *phy) goto out; } - ret =mt7615_mcu_set_chan_info (phy,MCU_EXT_CMD_CHANNEL_SWITCH ); + ret =mt7615_mcu_set_chan_info (phy,MCU_EXT_CMD (CHANNEL_SWITCH ));if (ret) goto out;
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +66 -88
396 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7615/testmode.c +2 -2
@@ -91,7 +91,7 @@ mt7615_tm_set_tx_power(struct mt7615_phy *phy) }return mt76_mcu_skb_send_msg (&dev->mt76, skb, -MCU_EXT_CMD_SET_TX_POWER_CTRL , false); +MCU_EXT_CMD (SET_TX_POWER_CTRL ), false); } static void
@@ -229,7 +229,7 @@ mt7615_tm_set_tx_frames(struct mt7615_phy *phy, bool en)struct ieee80211_tx_info *info;struct sk_buff *skb = phy->mt76->test.tx_skb; -mt7615_mcu_set_chan_info (phy,MCU_EXT_CMD_SET_RX_PATH ); +mt7615_mcu_set_chan_info (phy,MCU_EXT_CMD (SET_RX_PATH ));mt7615_tm_set_tx_antenna (phy, en);mt7615_tm_set_rx_enable (dev, !en);if (!en || !skb)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +2 -2
@@ -176,7 +176,7 @@ int mt76_connac_mcu_set_mac_enable(struct mt76_dev *dev, int band, bool enable, .band = band, }; -return mt76_mcu_send_msg (dev,MCU_EXT_CMD_MAC_INIT_CTRL , &req_mac, +return mt76_mcu_send_msg (dev,MCU_EXT_CMD (MAC_INIT_CTRL ), &req_mac,sizeof (req_mac), true); }EXPORT_SYMBOL_GPL (mt76_connac_mcu_set_mac_enable);
@@ -218,7 +218,7 @@ int mt76_connac_mcu_set_rts_thresh(struct mt76_dev *dev, u32 val, u8 band) .pkt_thresh = cpu_to_le32(0x2), }; -return mt76_mcu_send_msg (dev,MCU_EXT_CMD_PROTECT_CTRL , &req, +return mt76_mcu_send_msg (dev,MCU_EXT_CMD (PROTECT_CTRL ), &req,sizeof (req), true); }EXPORT_SYMBOL_GPL (mt76_connac_mcu_set_rts_thresh);
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +12 -4
@@ -499,11 +499,19 @@ enum {#define MCU_FW_PREFIX BIT(31)#define MCU_UNI_PREFIX BIT(30)#define MCU_CE_PREFIX BIT(29) -#define MCU_QUERY_PREFIX BIT(28)#define MCU_CMD_MASK ~(MCU_FW_PREFIX | MCU_UNI_PREFIX | \ - MCU_CE_PREFIX | MCU_QUERY_PREFIX) + MCU_CE_PREFIX) -#define MCU_QUERY_MASK BIT(16) +#define __MCU_CMD_FIELD_ID GENMASK(7, 0) +#define __MCU_CMD_FIELD_EXT_ID GENMASK(15, 8) +#define __MCU_CMD_FIELD_QUERY BIT(16) + +#define MCU_CMD (_t) FIELD_PREP(__MCU_CMD_FIELD_ID, \ + MCU_CMD_##_t) +#define MCU_EXT_CMD (_t) (MCU_CMD(EXT_CID) | \ + FIELD_PREP(__MCU_CMD_FIELD_EXT_ID, \ + MCU_EXT_CMD_##_t)) +#define MCU_EXT_QUERY (_t) (MCU_EXT_CMD(_t) | __MCU_CMD_FIELD_QUERY)enum {MCU_EXT_CMD_EFUSE_ACCESS =0x01 ,
@@ -575,7 +583,7 @@ enum {MCU_CMD_GET_NIC_CAPAB =MCU_CE_PREFIX |0x8a ,MCU_CMD_SET_MU_EDCA_PARMS =MCU_CE_PREFIX |0xb0 ,MCU_CMD_REG_WRITE =MCU_CE_PREFIX |0xc0 , -MCU_CMD_REG_READ =MCU_CE_PREFIX |MCU_QUERY_MASK |0xc0 , +MCU_CMD_REG_READ =MCU_CE_PREFIX | __MCU_CMD_FIELD_QUERY |0xc0 ,MCU_CMD_CHIP_CONFIG =MCU_CE_PREFIX |0xca ,MCU_CMD_FWLOG_2_HOST =MCU_CE_PREFIX |0xc5 , MCU_CMD_GET_WTBL = MCU_CE_PREFIX | 0xcd,
drivers/net/wireless/mediatek/mt76/mt7921/main.c +2 -2
@@ -221,7 +221,7 @@ int __mt7921_start(struct mt7921_phy *phy)if (err)return err; - err =mt7921_mcu_set_chan_info (phy,MCU_EXT_CMD_SET_RX_PATH ); + err =mt7921_mcu_set_chan_info (phy,MCU_EXT_CMD (SET_RX_PATH ));if (err)return err;
@@ -363,7 +363,7 @@ static int mt7921_set_channel(struct mt7921_phy *phy)mt76_set_channel (phy->mt76); - ret =mt7921_mcu_set_chan_info (phy,MCU_EXT_CMD_CHANNEL_SWITCH ); + ret =mt7921_mcu_set_chan_info (phy,MCU_EXT_CMD (CHANNEL_SWITCH ));if (ret) goto out;
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +27 -49
141 lines not on this page · raw message
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 320/1039 mt76: connac: align MCU_EXT definitions with 7915 driver
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit 9d8d136cf0b6d5578442f38ea9eefdf67cc84fc4 ]
Align MCU_EXT and MCU_FW definitions between mt76_connac and mt7915 driver. This is a preliminary patch to reuse mt76_connac in mt7915 driver.
--- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 16 ++++++------- .../wireless/mediatek/mt76/mt76_connac_mcu.h | 24 +++++++++++++++++-- .../net/wireless/mediatek/mt76/mt7921/mcu.c | 2 +- 3 files changed, 31 insertions(+), 11 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +8 -8
@@ -176,7 +176,7 @@ int mt7615_mcu_parse_response(struct mt76_dev *mdev, int cmd,if (cmd ==MCU_CMD_PATCH_SEM_CONTROL ) {skb_pull (skb,sizeof (*rxd) -4 ); ret = *skb->data; - }else if (cmd ==MCU_EXT_CMD (GET_TEMP )) { + }else if (cmd ==MCU_EXT_CMD (THERMAL_CTRL )) {skb_pull (skb,sizeof (*rxd)); ret =le32_to_cpu (*(__le32 *)skb->data); }else if (cmd ==MCU_EXT_QUERY (RF_REG_ACCESS )) {
@@ -2095,8 +2095,8 @@ int mt7615_mcu_set_fcc5_lpn(struct mt7615_dev *dev, int val) .min_lpn = cpu_to_le16(val), }; -return mt76_mcu_send_msg (&dev->mt76,MCU_EXT_CMD (SET_RDD_TH ), &req, -sizeof (req), true); +return mt76_mcu_send_msg (&dev->mt76,MCU_EXT_CMD (SET_RADAR_TH ), + &req,sizeof (req), true); } int mt7615_mcu_set_pulse_th(struct mt7615_dev *dev,
@@ -2124,8 +2124,8 @@ int mt7615_mcu_set_pulse_th(struct mt7615_dev *dev,#undef __req_field }; -return mt76_mcu_send_msg (&dev->mt76,MCU_EXT_CMD (SET_RDD_TH ), &req, -sizeof (req), true); +return mt76_mcu_send_msg (&dev->mt76,MCU_EXT_CMD (SET_RADAR_TH ), + &req,sizeof (req), true); } int mt7615_mcu_set_radar_th(struct mt7615_dev *dev, int index,
@@ -2171,8 +2171,8 @@ int mt7615_mcu_set_radar_th(struct mt7615_dev *dev, int index,#undef __req_field_u32 }; -return mt76_mcu_send_msg (&dev->mt76,MCU_EXT_CMD (SET_RDD_TH ), &req, -sizeof (req), true); +return mt76_mcu_send_msg (&dev->mt76,MCU_EXT_CMD (SET_RADAR_TH ), + &req,sizeof (req), true); }int mt7615_mcu_rdd_send_pattern (struct mt7615_dev *dev)
@@ -2372,7 +2372,7 @@ int mt7615_mcu_get_temperature(struct mt7615_dev *dev)u8 rsv[3 ]; } req = {}; -return mt76_mcu_send_msg (&dev->mt76,MCU_EXT_CMD (GET_TEMP ), +return mt76_mcu_send_msg (&dev->mt76,MCU_EXT_CMD (THERMAL_CTRL ), &req,sizeof (req), true); }
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +22 -2
@@ -516,17 +516,21 @@ enum {enum {MCU_EXT_CMD_EFUSE_ACCESS =0x01 ,MCU_EXT_CMD_RF_REG_ACCESS =0x02 , +MCU_EXT_CMD_RF_TEST =0x04 ,MCU_EXT_CMD_PM_STATE_CTRL =0x07 ,MCU_EXT_CMD_CHANNEL_SWITCH =0x08 ,MCU_EXT_CMD_SET_TX_POWER_CTRL =0x11 ,MCU_EXT_CMD_FW_LOG_2_HOST =0x13 , +MCU_EXT_CMD_TXBF_ACTION =0x1e ,MCU_EXT_CMD_EFUSE_BUFFER_MODE =0x21 , +MCU_EXT_CMD_THERMAL_PROT =0x23 ,MCU_EXT_CMD_STA_REC_UPDATE =0x25 ,MCU_EXT_CMD_BSS_INFO_UPDATE =0x26 ,MCU_EXT_CMD_EDCA_UPDATE =0x27 ,MCU_EXT_CMD_DEV_INFO_UPDATE =0x2A , -MCU_EXT_CMD_GET_TEMP =0x2c , +MCU_EXT_CMD_THERMAL_CTRL =0x2c ,MCU_EXT_CMD_WTBL_UPDATE =0x32 , +MCU_EXT_CMD_SET_DRR_CTRL =0x36 ,MCU_EXT_CMD_SET_RDD_CTRL =0x3a ,MCU_EXT_CMD_ATE_CTRL =0x3d ,MCU_EXT_CMD_PROTECT_CTRL =0x3e ,
@@ -535,13 +539,28 @@ enum {MCU_EXT_CMD_RX_HDR_TRANS =0x47 ,MCU_EXT_CMD_MUAR_UPDATE =0x48 ,MCU_EXT_CMD_BCN_OFFLOAD =0x49 , +MCU_EXT_CMD_RX_AIRTIME_CTRL =0x4a ,MCU_EXT_CMD_SET_RX_PATH =0x4e , +MCU_EXT_CMD_EFUSE_FREE_BLOCK =0x4f ,MCU_EXT_CMD_TX_POWER_FEATURE_CTRL =0x58 ,MCU_EXT_CMD_RXDCOC_CAL =0x59 , +MCU_EXT_CMD_GET_MIB_INFO =0x5a ,MCU_EXT_CMD_TXDPD_CAL =0x60 ,MCU_EXT_CMD_CAL_CACHE =0x67 , -MCU_EXT_CMD_SET_RDD_TH =0x7c , +MCU_EXT_CMD_SET_RADAR_TH =0x7c ,MCU_EXT_CMD_SET_RDD_PATTERN =0x7d , +MCU_EXT_CMD_MWDS_SUPPORT =0x80 , +MCU_EXT_CMD_SET_SER_TRIGGER =0x81 , +MCU_EXT_CMD_SCS_CTRL =0x82 , +MCU_EXT_CMD_TWT_AGRT_UPDATE =0x94 , +MCU_EXT_CMD_FW_DBG_CTRL =0x95 , +MCU_EXT_CMD_OFFCH_SCAN_CTRL =0x9a , +MCU_EXT_CMD_SET_RDD_TH =0x9d , +MCU_EXT_CMD_MURU_CTRL =0x9f , +MCU_EXT_CMD_SET_SPR =0xa8 , +MCU_EXT_CMD_GROUP_PRE_CAL_INFO =0xab , +MCU_EXT_CMD_DPD_PRE_CAL_INFO =0xac , + MCU_EXT_CMD_PHY_STAT_INFO = 0xad, }; enum {
@@ -561,6 +580,7 @@ enum {MCU_CMD_PATCH_START_REQ =MCU_FW_PREFIX |0x05 ,MCU_CMD_PATCH_FINISH_REQ =MCU_FW_PREFIX |0x07 ,MCU_CMD_PATCH_SEM_CONTROL =MCU_FW_PREFIX |0x10 , +MCU_CMD_WA_PARAM =0xc4 ,MCU_CMD_EXT_CID =0xed ,MCU_CMD_FW_SCATTER =MCU_FW_PREFIX |0xee , MCU_CMD_RESTART_DL_REQ = MCU_FW_PREFIX | 0xef,
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +1 -1
@@ -182,7 +182,7 @@ int mt7921_mcu_parse_response(struct mt76_dev *mdev, int cmd,if (cmd ==MCU_CMD_PATCH_SEM_CONTROL ) {skb_pull (skb,sizeof (*rxd) -4 ); ret = *skb->data; - }else if (cmd ==MCU_EXT_CMD (GET_TEMP )) { + }else if (cmd ==MCU_EXT_CMD (THERMAL_CTRL )) {skb_pull (skb,sizeof (*rxd) +4 ); ret =le32_to_cpu (*(__le32 *)skb->data); }else if (cmd ==MCU_EXT_CMD (EFUSE_ACCESS )) {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 321/1039 mt76: connac: remove MCU_FW_PREFIX bit
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit 7159eb828d21ad8fb3c1c1782a286a658ba6bf66 ]
Get rid of MCU_FW_PREFIX bit since it is no longer used
--- .../wireless/mediatek/mt76/mt76_connac_mcu.h | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +9 -11
@@ -496,11 +496,9 @@ enum {#define MCU_CMD_UNI_EXT_ACK (MCU_CMD_ACK | MCU_CMD_UNI | \ MCU_CMD_QUERY) -#define MCU_FW_PREFIX BIT(31)#define MCU_UNI_PREFIX BIT(30)#define MCU_CE_PREFIX BIT(29) -#define MCU_CMD_MASK ~(MCU_FW_PREFIX | MCU_UNI_PREFIX | \ - MCU_CE_PREFIX) +#define MCU_CMD_MASK ~(MCU_UNI_PREFIX | MCU_CE_PREFIX)#define __MCU_CMD_FIELD_ID GENMASK(7, 0)#define __MCU_CMD_FIELD_EXT_ID GENMASK(15, 8)
@@ -573,17 +571,17 @@ enum { };enum { -MCU_CMD_TARGET_ADDRESS_LEN_REQ =MCU_FW_PREFIX |0x01 , -MCU_CMD_FW_START_REQ =MCU_FW_PREFIX |0x02 , +MCU_CMD_TARGET_ADDRESS_LEN_REQ =0x01 , +MCU_CMD_FW_START_REQ =0x02 ,MCU_CMD_INIT_ACCESS_REG =0x3 , -MCU_CMD_NIC_POWER_CTRL =MCU_FW_PREFIX |0x4 , -MCU_CMD_PATCH_START_REQ =MCU_FW_PREFIX |0x05 , -MCU_CMD_PATCH_FINISH_REQ =MCU_FW_PREFIX |0x07 , -MCU_CMD_PATCH_SEM_CONTROL =MCU_FW_PREFIX |0x10 , +MCU_CMD_NIC_POWER_CTRL =0x4 , +MCU_CMD_PATCH_START_REQ =0x05 , +MCU_CMD_PATCH_FINISH_REQ =0x07 , +MCU_CMD_PATCH_SEM_CONTROL =0x10 ,MCU_CMD_WA_PARAM =0xc4 ,MCU_CMD_EXT_CID =0xed , -MCU_CMD_FW_SCATTER =MCU_FW_PREFIX |0xee , -MCU_CMD_RESTART_DL_REQ =MCU_FW_PREFIX |0xef , +MCU_CMD_FW_SCATTER =0xee , +MCU_CMD_RESTART_DL_REQ =0xef , };/* offload mcu commands */
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 322/1039 mt76: connac: introduce MCU_UNI_CMD macro
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit 5472240245793c13e9986c61dd34c697296deed4 ]
Similar to MCU_EXT_CMD, introduce MCU_UNI_CMD for unified commands
--- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 26 +++++------ .../wireless/mediatek/mt76/mt76_connac_mcu.c | 44 ++++++++++--------- .../wireless/mediatek/mt76/mt76_connac_mcu.h | 19 ++++---- .../net/wireless/mediatek/mt76/mt7921/main.c | 2 +- .../net/wireless/mediatek/mt76/mt7921/mcu.c | 36 +++++++-------- 5 files changed, 64 insertions(+), 63 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +13 -13
@@ -103,7 +103,7 @@ void mt7615_mcu_fill_msg(struct mt7615_dev *dev, struct sk_buff *skb,if (wait_seq) *wait_seq = seq; - txd_len = cmd &MCU_UNI_PREFIX ?sizeof (*uni_txd) :sizeof (*mcu_txd); + txd_len = cmd & __MCU_CMD_FIELD_UNI ?sizeof (*uni_txd) :sizeof (*mcu_txd); txd = (__le32 *)skb_push (skb, txd_len);if (cmd !=MCU_CMD_FW_SCATTER ) {
@@ -124,7 +124,7 @@ void mt7615_mcu_fill_msg(struct mt7615_dev *dev, struct sk_buff *skb,FIELD_PREP (MT_TXD1_PKT_FMT , pkt_fmt); txd[1 ] =cpu_to_le32 (val); -if (cmd &MCU_UNI_PREFIX ) { +if (cmd & __MCU_CMD_FIELD_UNI) { uni_txd = (struct mt7615_uni_txd *)txd; uni_txd->len =cpu_to_le16 (skb->len -sizeof (uni_txd->txd)); uni_txd->option =MCU_CMD_UNI_EXT_ACK ;
@@ -182,12 +182,12 @@ int mt7615_mcu_parse_response(struct mt76_dev *mdev, int cmd, }else if (cmd ==MCU_EXT_QUERY (RF_REG_ACCESS )) {skb_pull (skb,sizeof (*rxd)); ret =le32_to_cpu (*(__le32 *)&skb->data[8 ]); - }else if (cmd ==MCU_UNI_CMD_DEV_INFO_UPDATE || - cmd ==MCU_UNI_CMD_BSS_INFO_UPDATE || - cmd ==MCU_UNI_CMD_STA_REC_UPDATE || - cmd ==MCU_UNI_CMD_HIF_CTRL || - cmd ==MCU_UNI_CMD_OFFLOAD || - cmd ==MCU_UNI_CMD_SUSPEND ) { + }else if (cmd ==MCU_UNI_CMD (DEV_INFO_UPDATE ) || + cmd ==MCU_UNI_CMD (BSS_INFO_UPDATE ) || + cmd ==MCU_UNI_CMD (STA_REC_UPDATE ) || + cmd ==MCU_UNI_CMD (HIF_CTRL ) || + cmd ==MCU_UNI_CMD (OFFLOAD ) || + cmd ==MCU_UNI_CMD (SUSPEND )) {struct mt7615_mcu_uni_event *event;skb_pull (skb,sizeof (*rxd));
@@ -1263,7 +1263,7 @@ mt7615_mcu_uni_add_beacon_offload(struct mt7615_dev *dev,dev_kfree_skb (skb); out: -return mt76_mcu_send_msg (&dev->mt76,MCU_UNI_CMD_BSS_INFO_UPDATE , +return mt76_mcu_send_msg (&dev->mt76,MCU_UNI_CMD (BSS_INFO_UPDATE ), &req,sizeof (req), true); }
@@ -1292,7 +1292,7 @@ mt7615_mcu_uni_add_sta(struct mt7615_phy *phy, struct ieee80211_vif *vif, struct ieee80211_sta *sta, bool enable) {return __mt7615_mcu_add_sta (phy->mt76, vif, sta, enable, -MCU_UNI_CMD_STA_REC_UPDATE , true); +MCU_UNI_CMD (STA_REC_UPDATE ), true); } static int
@@ -1326,7 +1326,7 @@ mt7615_mcu_uni_rx_ba(struct mt7615_dev *dev,mt76_connac_mcu_sta_ba_tlv (skb, params, enable, false); err =mt76_mcu_skb_send_msg (&dev->mt76, skb, -MCU_UNI_CMD_STA_REC_UPDATE , true); +MCU_UNI_CMD (STA_REC_UPDATE ), true);if (err <0 || !enable)return err;
@@ -1347,7 +1347,7 @@ mt7615_mcu_uni_rx_ba(struct mt7615_dev *dev, sta_wtbl, wtbl_hdr);return mt76_mcu_skb_send_msg (&dev->mt76, skb, -MCU_UNI_CMD_STA_REC_UPDATE , true); +MCU_UNI_CMD (STA_REC_UPDATE ), true); } static int
@@ -1359,7 +1359,7 @@ mt7615_mcu_sta_uni_update_hdr_trans(struct mt7615_dev *dev,return mt76_connac_mcu_sta_update_hdr_trans (&dev->mt76, vif, &msta->wcid, -MCU_UNI_CMD_STA_REC_UPDATE ); +MCU_UNI_CMD (STA_REC_UPDATE )); }static const struct mt7615_mcu_ops uni_update_ops = {
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +23 -21
134 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +11 -8
@@ -496,13 +496,13 @@ enum {#define MCU_CMD_UNI_EXT_ACK (MCU_CMD_ACK | MCU_CMD_UNI | \ MCU_CMD_QUERY) -#define MCU_UNI_PREFIX BIT(30)#define MCU_CE_PREFIX BIT(29) -#define MCU_CMD_MASK ~(MCU_UNI_PREFIX | MCU_CE_PREFIX) +#define MCU_CMD_MASK ~(MCU_CE_PREFIX)#define __MCU_CMD_FIELD_ID GENMASK(7, 0)#define __MCU_CMD_FIELD_EXT_ID GENMASK(15, 8)#define __MCU_CMD_FIELD_QUERY BIT(16) +#define __MCU_CMD_FIELD_UNI BIT(17)#define MCU_CMD (_t) FIELD_PREP(__MCU_CMD_FIELD_ID, \ MCU_CMD_##_t)
@@ -510,6 +510,9 @@ enum { FIELD_PREP(__MCU_CMD_FIELD_EXT_ID, \ MCU_EXT_CMD_##_t))#define MCU_EXT_QUERY (_t) (MCU_EXT_CMD(_t) | __MCU_CMD_FIELD_QUERY) +#define MCU_UNI_CMD (_t) (__MCU_CMD_FIELD_UNI | \ + FIELD_PREP(__MCU_CMD_FIELD_ID, \ + MCU_UNI_CMD_##_t))enum {MCU_EXT_CMD_EFUSE_ACCESS =0x01 ,
@@ -562,12 +565,12 @@ enum { };enum { -MCU_UNI_CMD_DEV_INFO_UPDATE =MCU_UNI_PREFIX |0x01 , -MCU_UNI_CMD_BSS_INFO_UPDATE =MCU_UNI_PREFIX |0x02 , -MCU_UNI_CMD_STA_REC_UPDATE =MCU_UNI_PREFIX |0x03 , -MCU_UNI_CMD_SUSPEND =MCU_UNI_PREFIX |0x05 , -MCU_UNI_CMD_OFFLOAD =MCU_UNI_PREFIX |0x06 , -MCU_UNI_CMD_HIF_CTRL =MCU_UNI_PREFIX |0x07 , +MCU_UNI_CMD_DEV_INFO_UPDATE =0x01 , +MCU_UNI_CMD_BSS_INFO_UPDATE =0x02 , +MCU_UNI_CMD_STA_REC_UPDATE =0x03 , +MCU_UNI_CMD_SUSPEND =0x05 , +MCU_UNI_CMD_OFFLOAD =0x06 , +MCU_UNI_CMD_HIF_CTRL =0x07 , };enum {
drivers/net/wireless/mediatek/mt76/mt7921/main.c +1 -1
@@ -1316,7 +1316,7 @@ static void mt7921_sta_set_decap_offload(struct ieee80211_hw *hw,clear_bit (MT_WCID_FLAG_HDR_TRANS , &msta->wcid.flags);mt76_connac_mcu_sta_update_hdr_trans (&dev->mt76, vif, &msta->wcid, -MCU_UNI_CMD_STA_REC_UPDATE ); +MCU_UNI_CMD (STA_REC_UPDATE )); } static int mt7921_set_sar_specs(struct ieee80211_hw *hw,
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +16 -20
@@ -187,12 +187,12 @@ int mt7921_mcu_parse_response(struct mt76_dev *mdev, int cmd, ret =le32_to_cpu (*(__le32 *)skb->data); }else if (cmd ==MCU_EXT_CMD (EFUSE_ACCESS )) { ret =mt7921_mcu_parse_eeprom (mdev, skb); - }else if (cmd ==MCU_UNI_CMD_DEV_INFO_UPDATE || - cmd ==MCU_UNI_CMD_BSS_INFO_UPDATE || - cmd ==MCU_UNI_CMD_STA_REC_UPDATE || - cmd ==MCU_UNI_CMD_HIF_CTRL || - cmd ==MCU_UNI_CMD_OFFLOAD || - cmd ==MCU_UNI_CMD_SUSPEND ) { + }else if (cmd ==MCU_UNI_CMD (DEV_INFO_UPDATE ) || + cmd ==MCU_UNI_CMD (BSS_INFO_UPDATE ) || + cmd ==MCU_UNI_CMD (STA_REC_UPDATE ) || + cmd ==MCU_UNI_CMD (HIF_CTRL ) || + cmd ==MCU_UNI_CMD (OFFLOAD ) || + cmd ==MCU_UNI_CMD (SUSPEND )) {struct mt7921_mcu_uni_event *event;skb_pull (skb,sizeof (*rxd));
@@ -226,16 +226,12 @@ int mt7921_mcu_fill_message(struct mt76_dev *mdev, struct sk_buff *skb,u32 val;u8 seq; -switch (cmd) { -case MCU_UNI_CMD_HIF_CTRL : -case MCU_UNI_CMD_SUSPEND : -case MCU_UNI_CMD_OFFLOAD : +if (cmd ==MCU_UNI_CMD (HIF_CTRL ) || + cmd ==MCU_UNI_CMD (SUSPEND ) || + cmd ==MCU_UNI_CMD (OFFLOAD )) mdev->mcu.timeout =HZ /3 ; -break ; -default : +else mdev->mcu.timeout =3 *HZ ; -break ; - } seq = ++dev->mt76.mcu.msg_seq &0xf ;if (!seq)
@@ -244,7 +240,7 @@ int mt7921_mcu_fill_message(struct mt76_dev *mdev, struct sk_buff *skb,if (cmd ==MCU_CMD_FW_SCATTER ) goto exit; - txd_len = cmd &MCU_UNI_PREFIX ?sizeof (*uni_txd) :sizeof (*mcu_txd); + txd_len = cmd & __MCU_CMD_FIELD_UNI ?sizeof (*uni_txd) :sizeof (*mcu_txd); txd = (__le32 *)skb_push (skb, txd_len); val = FIELD_PREP(MT_TXD0_TX_BYTES, skb->len) |
@@ -256,7 +252,7 @@ int mt7921_mcu_fill_message(struct mt76_dev *mdev, struct sk_buff *skb,FIELD_PREP (MT_TXD1_HDR_FORMAT ,MT_HDR_FORMAT_CMD ); txd[1 ] =cpu_to_le32 (val); -if (cmd &MCU_UNI_PREFIX ) { +if (cmd & __MCU_CMD_FIELD_UNI) { uni_txd = (struct mt7921_uni_txd *)txd; uni_txd->len =cpu_to_le16 (skb->len -sizeof (uni_txd->txd)); uni_txd->option =MCU_CMD_UNI_EXT_ACK ;
@@ -544,7 +540,7 @@ int mt7921_mcu_add_key(struct mt7921_dev *dev, struct ieee80211_vif *vif,return ret;return mt76_mcu_skb_send_msg (&dev->mt76, skb, -MCU_UNI_CMD_STA_REC_UPDATE , true); +MCU_UNI_CMD (STA_REC_UPDATE ), true); } int mt7921_mcu_uni_tx_ba(struct mt7921_dev *dev,
@@ -1132,7 +1128,7 @@ int mt7921_mcu_uni_bss_ps(struct mt7921_dev *dev, struct ieee80211_vif *vif)if (vif->type !=NL80211_IFTYPE_STATION )return -EOPNOTSUPP ; -return mt76_mcu_send_msg (&dev->mt76,MCU_UNI_CMD_BSS_INFO_UPDATE , +return mt76_mcu_send_msg (&dev->mt76,MCU_UNI_CMD (BSS_INFO_UPDATE ), &ps_req,sizeof (ps_req), true); }
@@ -1168,7 +1164,7 @@ mt7921_mcu_uni_bss_bcnft(struct mt7921_dev *dev, struct ieee80211_vif *vif,if (vif->type !=NL80211_IFTYPE_STATION )return 0 ; -return mt76_mcu_send_msg (&dev->mt76,MCU_UNI_CMD_BSS_INFO_UPDATE , +return mt76_mcu_send_msg (&dev->mt76,MCU_UNI_CMD (BSS_INFO_UPDATE ), &bcnft_req,sizeof (bcnft_req), true); }
@@ -1223,7 +1219,7 @@ int mt7921_mcu_sta_update(struct mt7921_dev *dev, struct ieee80211_sta *sta, .sta = sta, .vif = vif, .enable = enable, - .cmd = MCU_UNI_CMD_STA_REC_UPDATE, + .cmd = MCU_UNI_CMD(STA_REC_UPDATE), .state = state, .offload_fw = true, .rcpi = to_rcpi(rssi),
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 323/1039 mt76: mt7921s: fix suspend error with enlarging mcu timeout value
In reply to Greg Kroah-HartmanFrom: Sean Wang <[email protected]>
[ Upstream commit 1bb42a354d8ca2888c7c2fcbf0add410176a33dc ]
Fix the false positive suspend error that may occur on mt7921s with enlarging mcu timeout value.
The reason why we have to enlarge mcu timeout from HZ / 3 to HZ is we should consider the additional overhead caused by running concurrently with btmtksdio (a MT7921 bluetooth SDIO driver) that would compete for the same SDIO bus in process context to complete the suspend procedure.
--- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +1 -1
@@ -229,7 +229,7 @@ int mt7921_mcu_fill_message(struct mt76_dev *mdev, struct sk_buff *skb,if (cmd ==MCU_UNI_CMD (HIF_CTRL ) || cmd ==MCU_UNI_CMD (SUSPEND ) || cmd ==MCU_UNI_CMD (OFFLOAD )) - mdev->mcu.timeout =HZ /3 ; + mdev->mcu.timeout =HZ ;else mdev->mcu.timeout =3 *HZ ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 324/1039 wilc1000: fix double free error in probe()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 4894edacfa93d7046bec4fc61fc402ac6a2ac9e8 ]
Smatch complains that there is a double free in probe:
drivers/net/wireless/microchip/wilc1000/spi.c:186 wilc_bus_probe() error: double free of 'spi_priv' drivers/net/wireless/microchip/wilc1000/sdio.c:163 wilc_sdio_probe() error: double free of 'sdio_priv'
The problem is that wilc_netdev_cleanup() function frees "wilc->bus_data". That's confusing and a layering violation. Leave the frees in probe(), delete the free in wilc_netdev_cleanup(), and add some new frees to the remove() functions.
--- drivers/net/wireless/microchip/wilc1000/netdev.c | 1 - drivers/net/wireless/microchip/wilc1000/sdio.c | 2 ++ drivers/net/wireless/microchip/wilc1000/spi.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-)
drivers/net/wireless/microchip/wilc1000/netdev.c +0 -1
@@ -905,7 +905,6 @@ void wilc_netdev_cleanup(struct wilc *wilc)wilc_wlan_cfg_deinit (wilc);wlan_deinit_locks (wilc); -kfree (wilc->bus_data);wiphy_unregister (wilc->wiphy);wiphy_free (wilc->wiphy); }
drivers/net/wireless/microchip/wilc1000/sdio.c +2 -0
@@ -167,9 +167,11 @@ free:static void wilc_sdio_remove (struct sdio_func *func) {struct wilc *wilc =sdio_get_drvdata (func); +struct wilc_sdio *sdio_priv = wilc->bus_data;clk_disable_unprepare (wilc->rtc_clk);wilc_netdev_cleanup (wilc); +kfree (sdio_priv); }static int wilc_sdio_reset (struct wilc *wilc)
drivers/net/wireless/microchip/wilc1000/spi.c +2 -0
@@ -190,9 +190,11 @@ free:static int wilc_bus_remove (struct spi_device *spi) {struct wilc *wilc =spi_get_drvdata (spi); +struct wilc_spi *spi_priv = wilc->bus_data;clk_disable_unprepare (wilc->rtc_clk);wilc_netdev_cleanup (wilc); +kfree (spi_priv);return 0 ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 325/1039 rtw88: add quirk to disable pci caps on HP 250 G7 Notebook PC
In reply to Greg Kroah-HartmanFrom: Ping-Ke Shih <[email protected]>
[ Upstream commit c81edb8dddaa36c4defa26240cc19127f147283f ]
8821CE causes random freezes on HP 250 G7 Notebook PC. Add a quirk to disable pci ASPM capability.
--- drivers/net/wireless/realtek/rtw88/pci.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/wireless/realtek/rtw88/pci.c +9 -0
@@ -1738,6 +1738,15 @@ static const struct dmi_system_id rtw88_pci_quirks[] = { }, .driver_data = (void *)BIT(QUIRK_DIS_PCI_CAP_ASPM), }, + { + .callback = disable_pci_caps, + .ident = "HP HP 250 G7 Notebook PC", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "HP"), + DMI_MATCH(DMI_PRODUCT_NAME, "HP 250 G7 Notebook PC"), + }, + .driver_data = (void *)BIT(QUIRK_DIS_PCI_CAP_ASPM), + }, {} };
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 326/1039 rtw88: Disable PCIe ASPM while doing NAPI poll on 8821CE
In reply to Greg Kroah-HartmanFrom: Kai-Heng Feng <[email protected]>
[ Upstream commit 24f5e38a13b5ae2b6105cda8bb47c19108e62a9a ]
Many Intel based platforms face system random freeze after commit 9e2fd29864c5 ("rtw88: add napi support").
The commit itself shouldn't be the culprit. My guess is that the 8821CE only leaves ASPM L1 for a short period when IRQ is raised. Since IRQ is masked during NAPI polling, the PCIe link stays at L1 and makes RX DMA extremely slow. Eventually the RX ring becomes messed up:
[ 1133.194697] rtw_8821ce 0000:02:00.0: pci bus timeout, check dma status
Since the 8821CE hardware may fail to leave ASPM L1, manually do it in the driver to resolve the issue.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215131
--- drivers/net/wireless/realtek/rtw88/pci.c | 70 +++++++----------------- drivers/net/wireless/realtek/rtw88/pci.h | 2 + 2 files changed, 21 insertions(+), 51 deletions(-)
drivers/net/wireless/realtek/rtw88/pci.c +19 -51
@@ -2,7 +2,6 @@/* Copyright(c) 2018-2019 Realtek Corporation */ -#include <linux/dmi.h> #include <linux/module.h> #include <linux/pci.h> #include "main.h"
@@ -1409,7 +1408,11 @@ static void rtw_pci_link_ps(struct rtw_dev *rtwdev, bool enter)* throughput. This is probably because the ASPM behavior slightly * varies from different SOC. */ -if (rtwpci->link_ctrl &PCI_EXP_LNKCTL_ASPM_L1 ) +if (!(rtwpci->link_ctrl &PCI_EXP_LNKCTL_ASPM_L1 )) +return ; + +if ((enter &&atomic_dec_if_positive (&rtwpci->link_usage) ==0 ) || + (!enter &&atomic_inc_return (&rtwpci->link_usage) ==1 ))rtw_pci_aspm_set (rtwdev, enter); }
@@ -1658,6 +1661,9 @@ static int rtw_pci_napi_poll(struct napi_struct *napi, int budget) priv);int work_done =0 ; +if (rtwpci->rx_no_aspm) +rtw_pci_link_ps (rtwdev, false); +while (work_done < budget) {u32 work_done_once;
@@ -1681,6 +1687,8 @@ static int rtw_pci_napi_poll(struct napi_struct *napi, int budget)if (rtw_pci_get_hw_rx_ring_nr (rtwdev, rtwpci))napi_schedule (napi); } +if (rtwpci->rx_no_aspm) +rtw_pci_link_ps (rtwdev, true);return work_done; }
@@ -1702,59 +1710,13 @@ static void rtw_pci_napi_deinit(struct rtw_dev *rtwdev)netif_napi_del (&rtwpci->napi); } -enum rtw88_quirk_dis_pci_caps { -QUIRK_DIS_PCI_CAP_MSI , -QUIRK_DIS_PCI_CAP_ASPM , -}; - -static int disable_pci_caps (const struct dmi_system_id *dmi) -{ -uintptr_t dis_caps = (uintptr_t )dmi->driver_data; - -if (dis_caps &BIT (QUIRK_DIS_PCI_CAP_MSI )) - rtw_disable_msi = true; -if (dis_caps &BIT (QUIRK_DIS_PCI_CAP_ASPM )) - rtw_pci_disable_aspm = true; - -return 1 ; -} - -static const struct dmi_system_id rtw88_pci_quirks[] = { - { - .callback = disable_pci_caps, - .ident ="Protempo Ltd L116HTN6SPW" , - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Protempo Ltd" ), -DMI_MATCH (DMI_PRODUCT_NAME ,"L116HTN6SPW" ), - }, - .driver_data = (void *)BIT (QUIRK_DIS_PCI_CAP_ASPM ), - }, - { - .callback = disable_pci_caps, - .ident ="HP HP Pavilion Laptop 14-ce0xxx" , - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"HP" ), -DMI_MATCH (DMI_PRODUCT_NAME ,"HP Pavilion Laptop 14-ce0xxx" ), - }, - .driver_data = (void *)BIT (QUIRK_DIS_PCI_CAP_ASPM ), - }, - { - .callback = disable_pci_caps, - .ident ="HP HP 250 G7 Notebook PC" , - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"HP" ), -DMI_MATCH (DMI_PRODUCT_NAME ,"HP 250 G7 Notebook PC" ), - }, - .driver_data = (void *)BIT (QUIRK_DIS_PCI_CAP_ASPM ), - }, - {} -}; -int rtw_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) { +struct pci_dev *bridge =pci_upstream_bridge (pdev);struct ieee80211_hw *hw;struct rtw_dev *rtwdev; +struct rtw_pci *rtwpci;int drv_data_size;int ret;
@@ -1772,6 +1734,9 @@ int rtw_pci_probe(struct pci_dev *pdev, rtwdev->hci.ops = &rtw_pci_ops; rtwdev->hci.type =RTW_HCI_TYPE_PCIE ; + rtwpci = (struct rtw_pci *)rtwdev->priv; +atomic_set (&rtwpci->link_usage,1 ); + ret =rtw_core_init (rtwdev);if (ret) goto err_release_hw;
@@ -1800,7 +1765,10 @@ int rtw_pci_probe(struct pci_dev *pdev, goto err_destroy_pci; } -dmi_check_system (rtw88_pci_quirks); +/* Disable PCIe ASPM L1 while doing NAPI poll for 8821CE */ +if (pdev->device ==0xc821 && bridge->vendor ==PCI_VENDOR_ID_INTEL ) + rtwpci->rx_no_aspm = true; +rtw_pci_phy_cfg (rtwdev); ret =rtw_register_hw (rtwdev, hw);
drivers/net/wireless/realtek/rtw88/pci.h +2 -0
@@ -223,6 +223,8 @@ struct rtw_pci {struct rtw_pci_tx_ring tx_rings[RTK_MAX_TX_QUEUE_NUM ];struct rtw_pci_rx_ring rx_rings[RTK_MAX_RX_QUEUE_NUM ];u16 link_ctrl; +atomic_t link_usage; +bool rx_no_aspm;DECLARE_BITMAP (flags,NUM_OF_RTW_PCI_FLAGS );void __iomem *mmap;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 327/1039 iwlwifi: mvm: fix 32-bit build in FTM
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 8b0f92549f2c2458200935c12a2e2a6e80234cf5 ]
On a 32-bit build, the division here needs to be done using do_div(), otherwise the compiler will try to call a function that doesn't exist, thus failing to build.
--- drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c +2 -1
@@ -1066,7 +1066,8 @@ static void iwl_mvm_ftm_rtt_smoothing(struct iwl_mvm *mvm, overshoot =IWL_MVM_FTM_INITIATOR_SMOOTH_OVERSHOOT ; alpha =IWL_MVM_FTM_INITIATOR_SMOOTH_ALPHA ; - rtt_avg = (alpha * rtt + (100 - alpha) * resp->rtt_avg) /100 ; + rtt_avg = alpha * rtt + (100 - alpha) * resp->rtt_avg; +do_div (rtt_avg,100 ); IWL_DEBUG_INFO(mvm, "%pM: prev rtt_avg=%lld, new rtt_avg=%lld, rtt=%lld\n",
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 328/1039 iwlwifi: dont pass actual WGDS revision number in table_revision
In reply to Greg Kroah-HartmanFrom: Luca Coelho <[email protected]>
[ Upstream commit ac9952f6954216be72a8bde210e1ef2c949d8ee0 ]
The FW API for PER_CHAIN_LIMIT_OFFSET_CMD is misleading. The element name is table_rev, but it shouldn't actually contain the table revision number, but whether we should use the South Korea scheme or not.
Fix the driver so that we only set this value to either 0 or 1. It will only be 1 (meaning South Korea) if the ACPI WGDS table revision is 1.
--- .../net/wireless/intel/iwlwifi/fw/api/power.h | 8 ++++---- drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 9 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/api/power.h +4 -4
@@ -419,7 +419,7 @@ struct iwl_geo_tx_power_profiles_cmd_v1 {* struct iwl_geo_tx_power_profile_cmd_v2 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd. * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation * @table: offset profile per band. -* @table_revision: BIOS table revision. +* @table_revision: 0 for not-South Korea, 1 for South Korea (the name is misleading) */ struct iwl_geo_tx_power_profiles_cmd_v2 {__le32 ops;
@@ -431,7 +431,7 @@ struct iwl_geo_tx_power_profiles_cmd_v2 {* struct iwl_geo_tx_power_profile_cmd_v3 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd. * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation * @table: offset profile per band. -* @table_revision: BIOS table revision. +* @table_revision: 0 for not-South Korea, 1 for South Korea (the name is misleading) */ struct iwl_geo_tx_power_profiles_cmd_v3 {__le32 ops;
@@ -443,7 +443,7 @@ struct iwl_geo_tx_power_profiles_cmd_v3 {* struct iwl_geo_tx_power_profile_cmd_v4 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd. * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation * @table: offset profile per band. -* @table_revision: BIOS table revision. +* @table_revision: 0 for not-South Korea, 1 for South Korea (the name is misleading) */ struct iwl_geo_tx_power_profiles_cmd_v4 {__le32 ops;
@@ -455,7 +455,7 @@ struct iwl_geo_tx_power_profiles_cmd_v4 {* struct iwl_geo_tx_power_profile_cmd_v5 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd. * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation * @table: offset profile per band. -* @table_revision: BIOS table revision. +* @table_revision: 0 for not-South Korea, 1 for South Korea (the name is misleading) */ struct iwl_geo_tx_power_profiles_cmd_v5 {__le32 ops;
drivers/net/wireless/intel/iwlwifi/mvm/fw.c +13 -5
@@ -820,6 +820,7 @@ static int iwl_mvm_sar_geo_init(struct iwl_mvm *mvm)u16 len;u32 n_bands;u32 n_profiles; +u32 sk =0 ;int ret; u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, PHY_OPS_GROUP, PER_CHAIN_LIMIT_OFFSET_CMD,
@@ -879,19 +880,26 @@ static int iwl_mvm_sar_geo_init(struct iwl_mvm *mvm)if (ret)return 0 ; +/* Only set to South Korea if the table revision is 1 */ +if (mvm->fwrt.geo_rev ==1 ) + sk =1 ; +/* -* Set the revision on versions that contain it. +* Set the table_revision to South Korea (1) or not (0). The +* element name is misleading, as it doesn't contain the table +* revision number, but whether the South Korea variation +* should be used. * This must be done after calling iwl_sar_geo_init(). */ if (cmd_ver ==5 ) - cmd.v5.table_revision =cpu_to_le32 (mvm->fwrt.geo_rev); + cmd.v5.table_revision =cpu_to_le32 (sk);else if (cmd_ver ==4 ) - cmd.v4.table_revision =cpu_to_le32 (mvm->fwrt.geo_rev); + cmd.v4.table_revision =cpu_to_le32 (sk);else if (cmd_ver ==3 ) - cmd.v3.table_revision =cpu_to_le32 (mvm->fwrt.geo_rev); + cmd.v3.table_revision =cpu_to_le32 (sk);else if (fw_has_api (&mvm->fwrt.fw->ucode_capa,IWL_UCODE_TLV_API_SAR_TABLE_VER )) - cmd.v2.table_revision =cpu_to_le32 (mvm->fwrt.geo_rev); + cmd.v2.table_revision =cpu_to_le32 (sk); return iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(PHY_OPS_GROUP,
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 329/1039 iwlwifi: mvm: test roc running status bits before removing the sta
In reply to Greg Kroah-HartmanFrom: Nathan Errera <[email protected]>
[ Upstream commit 998e1aba6e5eb35370eaf30ccc1823426ec11f90 ]
In some cases the sta is being removed twice since we do not test the roc aux running before removing it. Start looking at the bit before removing the sta.
--- .../net/wireless/intel/iwlwifi/mvm/time-event.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/time-event.c +12 -3
@@ -49,14 +49,13 @@ void iwl_mvm_roc_done_wk(struct work_struct *wk) struct iwl_mvm *mvm = container_of(wk, struct iwl_mvm, roc_done_wk);/* -* Clear the ROC_RUNNING /ROC_AUX_RUNNING status bit. +* Clear the ROC_RUNNING status bit. * This will cause the TX path to drop offchannel transmissions. * That would also be done by mac80211, but it is racy, in particular * in the case that the time event actually completed in the firmware * (which is handled in iwl_mvm_te_handle_notif). */ clear_bit (IWL_MVM_STATUS_ROC_RUNNING , &mvm->status); -clear_bit (IWL_MVM_STATUS_ROC_AUX_RUNNING , &mvm->status);synchronize_net ();
@@ -82,9 +81,19 @@ void iwl_mvm_roc_done_wk(struct work_struct *wk) mvmvif =iwl_mvm_vif_from_mac80211 (mvm->p2p_device_vif);iwl_mvm_flush_sta (mvm, &mvmvif->bcast_sta, true); } - }else { + } + +/* +* Clear the ROC_AUX_RUNNING status bit. +* This will cause the TX path to drop offchannel transmissions. +* That would also be done by mac80211, but it is racy, in particular +* in the case that the time event actually completed in the firmware +* (which is handled in iwl_mvm_te_handle_notif). +*/ +if (test_and_clear_bit (IWL_MVM_STATUS_ROC_AUX_RUNNING , &mvm->status)) {/* do the same in case of hot spot 2.0 */ iwl_mvm_flush_sta (mvm, &mvm->aux_sta, true); +/* In newer version of this command an aux station is added only * in cases of dedicated tx queue and need to be removed in end * of use */
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 330/1039 iwlwifi: mvm: perform 6GHz passive scan after suspend
In reply to Greg Kroah-HartmanFrom: Avraham Stern <[email protected]>
[ Upstream commit f4745cbb17572209a7fa27a6796ed70e7ada860b ]
The 6GHz passive scan is performed only once every 50 minutes. However, in case of suspend/resume, the regulatory information is reset, so 6GHz channels may become disabled.
Fix it by performing a 6GHz passive scan within 60 seconds after suspend/resume even if the 50 minutes timeout did not expire yet.
--- drivers/net/wireless/intel/iwlwifi/mvm/scan.c | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/scan.c +9 -12
@@ -1924,22 +1924,19 @@ static void iwl_mvm_scan_6ghz_passive_scan(struct iwl_mvm *mvm, }/* -* 6GHz passive scan is allowed while associated in a defined time -* interval following HW reset or resume flow +* 6GHz passive scan is allowed in a defined time interval following HW +* reset or resume flow, or while not associated and a large interval +* has passed since the last 6GHz passive scan. */ -if (vif->bss_conf.assoc && +if ((vif->bss_conf.assoc || +time_after (mvm->last_6ghz_passive_scan_jiffies + + (IWL_MVM_6GHZ_PASSIVE_SCAN_TIMEOUT *HZ ), jiffies)) && (time_before (mvm->last_reset_or_resume_time_jiffies + (IWL_MVM_6GHZ_PASSIVE_SCAN_ASSOC_TIMEOUT *HZ ), jiffies))) { -IWL_DEBUG_SCAN (mvm,"6GHz passive scan: associated\n" ); -return ; - } - -/* No need for 6GHz passive scan if not enough time elapsed */ -if (time_after (mvm->last_6ghz_passive_scan_jiffies + - (IWL_MVM_6GHZ_PASSIVE_SCAN_TIMEOUT *HZ ), jiffies)) { -IWL_DEBUG_SCAN (mvm, -"6GHz passive scan: timeout did not expire\n" ); +IWL_DEBUG_SCAN (mvm,"6GHz passive scan: %s\n" , + vif->bss_conf.assoc ?"associated" : +"timeout did not expire" );return ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 331/1039 iwlwifi: mvm: set protected flag only for NDP ranging
In reply to Greg Kroah-HartmanFrom: Avraham Stern <[email protected]>
[ Upstream commit 6bb2ea37c02db98cb677f978cfcb833ca608c5eb ]
Don't use protected ranging negotiation for FTM ranging as responders that support only FTM ranging don't expect the FTM request to be protected.
--- drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c +1 -1
@@ -511,7 +511,7 @@ iwl_mvm_ftm_put_target(struct iwl_mvm *mvm, struct ieee80211_vif *vif,rcu_read_lock (); sta =rcu_dereference (mvm->fw_id_to_mac_id[mvmvif->ap_sta_id]); -if (sta->mfp) +if (sta->mfp && (peer->ftm.trigger_based || peer->ftm.non_trigger_based))FTM_PUT_FLAG (PMF );rcu_read_unlock ();
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 332/1039 mmc: meson-mx-sdhc: add IRQ check
In reply to Greg Kroah-HartmanFrom: Sergey Shtylyov <[email protected]>
[ Upstream commit 77bed755e0f06135faccdd3948863703f9a6e640 ]
The driver neglects to check the result of platform_get_irq()'s call and blithely passes the negative error codes to devm_request_threaded_irq() (which takes *unsigned* IRQ #), causing it to fail with -EINVAL, overriding an original error code. Stop calling devm_request_threaded_irq() with the invalid IRQ #s.
--- drivers/mmc/host/meson-mx-sdhc-mmc.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/mmc/host/meson-mx-sdhc-mmc.c +5 -0
@@ -854,6 +854,11 @@ static int meson_mx_sdhc_probe(struct platform_device *pdev) goto err_disable_pclk; irq =platform_get_irq (pdev,0 ); +if (irq <0 ) { + ret = irq; + goto err_disable_pclk; + } + ret =devm_request_threaded_irq (dev, irq, meson_mx_sdhc_irq, meson_mx_sdhc_irq_thread,IRQF_ONESHOT ,NULL , host);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 333/1039 mmc: meson-mx-sdio: add IRQ check
In reply to Greg Kroah-HartmanFrom: Sergey Shtylyov <[email protected]>
[ Upstream commit 8fc9a77bc64e1f23d07953439817d8402ac9706f ]
The driver neglects to check the result of platform_get_irq()'s call and blithely passes the negative error codes to devm_request_threaded_irq() (which takes *unsigned* IRQ #), causing it to fail with -EINVAL, overriding an original error code. Stop calling devm_request_threaded_irq() with the invalid IRQ #s.
--- drivers/mmc/host/meson-mx-sdio.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/mmc/host/meson-mx-sdio.c +5 -0
@@ -662,6 +662,11 @@ static int meson_mx_mmc_probe(struct platform_device *pdev) } irq =platform_get_irq (pdev,0 ); +if (irq <0 ) { + ret = irq; + goto error_free_mmc; + } + ret = devm_request_threaded_irq(host->controller_dev, irq, meson_mx_mmc_irq, meson_mx_mmc_irq_thread, IRQF_ONESHOT,
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 334/1039 block: fix error unwinding in device_add_disk
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 99d8690aae4b2f0d1d90075de355ac087f820a66 ]
One device_add is called disk->ev will be freed by disk_release, so we should free it twice. Fix this by allocating disk->ev after device_add so that the extra local unwinding can be removed entirely.
Based on an earlier patch from Tetsuo Handa.
--- block/genhd.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
block/genhd.c +6 -7
@@ -437,10 +437,6 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk, disk->flags |=GENHD_FL_EXT_DEVT ; } - ret =disk_alloc_events (disk); -if (ret) - goto out_free_ext_minor; -/* delay uevents, until we scanned partition table */ dev_set_uevent_suppress (ddev,1 );
@@ -451,7 +447,12 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk, ddev->devt =MKDEV (disk->major, disk->first_minor); ret =device_add (ddev);if (ret) - goto out_disk_release_events; + goto out_free_ext_minor; + + ret =disk_alloc_events (disk); +if (ret) + goto out_device_del; +if (!sysfs_deprecated) { ret =sysfs_create_link (block_depr, &ddev->kobj,kobject_name (&ddev->kobj));
@@ -539,8 +540,6 @@ out_del_block_link:sysfs_remove_link (block_depr,dev_name (ddev)); out_device_del:device_del (ddev); -out_disk_release_events: -disk_release_events (disk); out_free_ext_minor:if (disk->major ==BLOCK_EXT_MAJOR )blk_free_ext_minor (disk->first_minor);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 335/1039 selinux: fix potential memleak in selinux_add_opt()
In reply to Greg Kroah-HartmanFrom: Bernard Zhao <[email protected]>
[ Upstream commit 2e08df3c7c4e4e74e3dd5104c100f0bf6288aaa8 ]
This patch try to fix potential memleak in error branch.
--- security/selinux/hooks.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
security/selinux/hooks.c +10 -2
@@ -988,18 +988,22 @@ out:static int selinux_add_opt (int token,const char *s,void **mnt_opts) {struct selinux_mnt_opts *opts = *mnt_opts; +bool is_alloc_opts = false;if (token == Opt_seclabel)/* eaten and completely ignored */ return 0 ; +if (!s) +return -ENOMEM ; +if (!opts) { opts =kzalloc (sizeof (struct selinux_mnt_opts ),GFP_KERNEL );if (!opts)return -ENOMEM ; *mnt_opts = opts; + is_alloc_opts = true; } -if (!s) -return -ENOMEM ; +switch (token) {case Opt_context:if (opts->context || opts->defcontext)
@@ -1024,6 +1028,10 @@ static int selinux_add_opt(int token, const char *s, void **mnt_opts) }return 0 ; Einval: +if (is_alloc_opts) { +kfree (opts); + *mnt_opts =NULL ; + }pr_warn (SEL_MOUNT_FAIL_MSG );return -EINVAL ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 336/1039 um: fix ndelay/udelay defines
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 5f8539e2ff962e25b57742ca7106456403abbc94 ]
Many places in the kernel use 'udelay' as an identifier, and are broken with the current "#define udelay um_udelay". Fix this by adding an argument to the macro, and do the same to 'ndelay' as well, just in case.
--- arch/um/include/asm/delay.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/um/include/asm/delay.h +2 -2
@@ -14,7 +14,7 @@ static inline void um_ndelay(unsigned long nsecs)ndelay (nsecs); }#undef ndelay -#define ndelay um_ndelay +#define ndelay (n) um_ndelay(n)static inline void um_udelay (unsigned long usecs) {
@@ -26,5 +26,5 @@ static inline void um_udelay(unsigned long usecs) udelay(usecs); }#undef udelay -#define udelay um_udelay +#define udelay (n) um_udelay(n)#endif /* __UM_DELAY_H */
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 337/1039 um: rename set_signals() to um_set_signals()
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit bbe33504d4a7fdab9011211e55e262c869b3f6cc ]
Rename set_signals() as there's at least one driver that uses the same name and can now be built on UM due to PCI support, and thus we can get symbol conflicts.
Also rename set_signals_trace() to be consistent.
--- arch/um/include/asm/irqflags.h | 4 ++-- arch/um/include/shared/longjmp.h | 2 +- arch/um/include/shared/os.h | 4 ++-- arch/um/kernel/ksyms.c | 2 +- arch/um/os-Linux/sigio.c | 6 +++--- arch/um/os-Linux/signal.c | 8 ++++---- 6 files changed, 13 insertions(+), 13 deletions(-)
arch/um/include/asm/irqflags.h +2 -2
@@ -3,7 +3,7 @@#define __UM_IRQFLAGS_Hextern int signals_enabled; -int set_signals (int enable); +int um_set_signals (int enable);void block_signals (void );void unblock_signals (void );
@@ -16,7 +16,7 @@ static inline unsigned long arch_local_save_flags(void)#define arch_local_irq_restore arch_local_irq_restorestatic inline void arch_local_irq_restore (unsigned long flags) { -set_signals (flags); +um_set_signals (flags); }#define arch_local_irq_enable arch_local_irq_enable
arch/um/include/shared/longjmp.h +1 -1
@@ -18,7 +18,7 @@ extern void longjmp(jmp_buf, int); enable = *(volatile int *)&signals_enabled; \ n =setjmp (*buf); \if (n !=0 ) \ -set_signals_trace (enable); \ +um_set_signals_trace (enable); \ n; })#endif
arch/um/include/shared/os.h +2 -2
@@ -238,8 +238,8 @@ extern void send_sigio_to_self(void);extern int change_sig (int signal,int on);extern void block_signals (void );extern void unblock_signals (void ); -extern int set_signals (int enable); -extern int set_signals_trace (int enable); +extern int um_set_signals (int enable); +extern int um_set_signals_trace (int enable);extern int os_is_signal_stack (void );extern void deliver_alarm (void );extern void register_pm_wake_signal (void );
arch/um/kernel/ksyms.c +1 -1
@@ -6,7 +6,7 @@#include <linux/module.h> #include <os.h> -EXPORT_SYMBOL (set_signals); +EXPORT_SYMBOL (um_set_signals);EXPORT_SYMBOL (signals_enabled);EXPORT_SYMBOL (os_stat_fd);
arch/um/os-Linux/sigio.c +3 -3
@@ -132,7 +132,7 @@ static void update_thread(void)int n;char c; - flags =set_signals_trace (0 ); + flags =um_set_signals_trace (0 );CATCH_EINTR (n =write (sigio_private[0 ], &c,sizeof (c)));if (n !=sizeof (c)) { printk(UM_KERN_ERR "update_thread : write failed, err = %d\n",
@@ -147,7 +147,7 @@ static void update_thread(void) goto fail; } -set_signals_trace (flags); +um_set_signals_trace (flags);return ; fail:/* Critical section start */
@@ -161,7 +161,7 @@ static void update_thread(void)close (write_sigio_fds[0 ]);close (write_sigio_fds[1 ]);/* Critical section end */ -set_signals_trace (flags); +um_set_signals_trace (flags); }int __add_sigio_fd (int fd)
arch/um/os-Linux/signal.c +4 -4
@@ -94,7 +94,7 @@ void sig_handler(int sig, struct siginfo *si, mcontext_t *mc)sig_handler_common (sig, si, mc); -set_signals_trace (enabled); +um_set_signals_trace (enabled); }static void timer_real_alarm_handler (mcontext_t *mc)
@@ -126,7 +126,7 @@ void timer_alarm_handler(int sig, struct siginfo *unused_si, mcontext_t *mc) signals_active &= ~SIGALRM_MASK ; -set_signals_trace (enabled); +um_set_signals_trace (enabled); }void deliver_alarm (void ) {
@@ -348,7 +348,7 @@ void unblock_signals(void) } } -int set_signals (int enable) +int um_set_signals (int enable) {int ret;if (signals_enabled == enable)
@@ -362,7 +362,7 @@ int set_signals(int enable)return ret; } -int set_signals_trace (int enable) +int um_set_signals_trace (int enable) {int ret;if (signals_enabled == enable)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 338/1039 um: virt-pci: Fix 32-bit compile
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit d73820df6437b5d0a57be53faf39db46a0264b3a ]
There were a few 32-bit compile warnings that of course turned into errors with -Werror, fix the 32-bit build.
--- arch/um/drivers/virt-pci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/um/drivers/virt-pci.c +4 -4
@@ -181,15 +181,15 @@ static unsigned long um_pci_cfgspace_read(void *priv, unsigned int offset,/* buf->data is maximum size - we may only use parts of it */ struct um_pci_message_buffer *buf;u8 *data; -unsigned long ret = ~0ULL ; +unsigned long ret =ULONG_MAX ;if (!dev) -return ~0ULL ; +return ULONG_MAX ; buf =get_cpu_var (um_pci_msg_bufs); data = buf->data; -memset (data,0xff ,sizeof (data)); +memset (buf->data,0xff ,sizeof (buf->data));switch (size) {case 1 :
@@ -304,7 +304,7 @@ static unsigned long um_pci_bar_read(void *priv, unsigned int offset,/* buf->data is maximum size - we may only use parts of it */ struct um_pci_message_buffer *buf;u8 *data; -unsigned long ret = ~0ULL ; +unsigned long ret =ULONG_MAX ; buf =get_cpu_var (um_pci_msg_bufs); data = buf->data;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 339/1039 lib/logic_iomem: Fix 32-bit build
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 4e84139e14af5ea60772cc4f33d7059aec76e0eb ]
On a 32-bit build, the (unsigned long long) casts throw warnings (or errors) due to being to a different integer size. Cast to uintptr_t first (with the __force for sparse) and then further to get the consistent print on 32 and 64-bit.
--- lib/logic_iomem.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
lib/logic_iomem.c +7 -6
@@ -79,7 +79,7 @@ static void __iomem *real_ioremap(phys_addr_t offset, size_t size)static void real_iounmap (void __iomem *addr) {WARN (1 ,"invalid iounmap for addr 0x%llx\n" , - (unsigned long long __force )addr); + (unsigned long long )(uintptr_t __force )addr); }#endif /* CONFIG_LOGIC_IOMEM_FALLBACK */
@@ -173,7 +173,7 @@ EXPORT_SYMBOL(iounmap); static u##sz real_raw_read ## op(const volatile void __iomem *addr) \ { \ WARN(1, "Invalid read" #op " at address %llx\n", \ - (unsigned long long __force)addr); \ + (unsigned long long)(uintptr_t __force)addr); \ return (u ## sz)~0ULL; \ } \ \
@@ -181,7 +181,8 @@ static void real_raw_write ## op(u ## sz val, \ volatile void __iomem *addr) \ { \ WARN(1, "Invalid writeq" #op " of 0x%llx at address %llx\n", \ - (unsigned long long )val, (unsigned long long __force )addr);\ + (unsigned long long)val, \ + (unsigned long long)(uintptr_t __force)addr);\ } \MAKE_FALLBACK (b,8 );
@@ -194,14 +195,14 @@ MAKE_FALLBACK(q, 64);static void real_memset_io (volatile void __iomem *addr,int value,size_t size) {WARN (1 ,"Invalid memset_io at address 0x%llx\n" , - (unsigned long long __force )addr); + (unsigned long long )(uintptr_t __force )addr); }static void real_memcpy_fromio (void *buffer,const volatile void __iomem *addr,size_t size) {WARN (1 ,"Invalid memcpy_fromio at address 0x%llx\n" , - (unsigned long long __force )addr); + (unsigned long long )(uintptr_t __force )addr);memset (buffer,0xff , size); }
@@ -210,7 +211,7 @@ static void real_memcpy_toio(volatile void __iomem *addr, const void *buffer, size_t size) {WARN (1 ,"Invalid memcpy_toio at address 0x%llx\n" , - (unsigned long long __force )addr); + (unsigned long long )(uintptr_t __force )addr); }#endif /* CONFIG_LOGIC_IOMEM_FALLBACK */
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 340/1039 lib/logic_iomem: Fix operation on 32-bit
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 4e8a5edac5010820e7c5303fc96f5a262e096bb6 ]
On 32-bit, the first entry might be at 0/NULL, but that's strange and leads to issues, e.g. where we check "if (ret)". Use a IOREMAP_BIAS/IOREMAP_MASK of 0x80000000UL to avoid this. This then requires reducing the number of areas (via MAX_AREAS), but we still have 128 areas, which is enough.
--- lib/logic_iomem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/logic_iomem.c +3 -3
@@ -21,15 +21,15 @@ struct logic_iomem_area {#define AREA_SHIFT 24#define MAX_AREA_SIZE (1 << AREA_SHIFT) -#define MAX_AREAS ((1ULL<<32) / MAX_AREA_SIZE) +#define MAX_AREAS ((1U << 31) / MAX_AREA_SIZE)#define AREA_BITS ((MAX_AREAS - 1) << AREA_SHIFT)#define AREA_MASK (MAX_AREA_SIZE - 1)#ifdef CONFIG_64BIT #define IOREMAP_BIAS 0xDEAD000000000000UL#define IOREMAP_MASK 0xFFFFFFFF00000000UL#else -#define IOREMAP_BIAS 0 -#define IOREMAP_MASK 0 +#define IOREMAP_BIAS 0x80000000UL +#define IOREMAP_MASK 0x80000000UL#endif static DEFINE_MUTEX (regions_mtx);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 341/1039 um: virtio_uml: Fix time-travel external time propagation
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 85e73968a040c642fd38f6cba5b73b61f5d0f052 ]
When creating an external event, the current time needs to be propagated to other participants of a simulation. This is done in the places here where we kick a virtq etc.
However, it must be done for _all_ external events, and that includes making the initial socket connection and later closing it. Call time_travel_propagate_time() to do this before making or closing the socket connection.
Apparently, at least for the initial connection creation, due to the remote side in my use cases using microseconds (rather than nanoseconds), this wasn't a problem yet; only started failing between 5.14-rc1 and 5.15-rc1 (didn't test others much), or possibly depending on the configuration, where more delays happen before the virtio devices are initialized.
--- arch/um/drivers/virtio_uml.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/um/drivers/virtio_uml.c +4 -0
@@ -1090,6 +1090,8 @@ static void virtio_uml_release_dev(struct device *d) container_of(d, struct virtio_device, dev);struct virtio_uml_device *vu_dev =to_virtio_uml_device (vdev); +time_travel_propagate_time (); +/* might not have been opened due to not negotiating the feature */ if (vu_dev->req_fd >=0 ) {um_free_irq (vu_dev->irq, vu_dev);
@@ -1136,6 +1138,8 @@ static int virtio_uml_probe(struct platform_device *pdev) vu_dev->pdev = pdev; vu_dev->req_fd =-1 ; +time_travel_propagate_time (); +do { rc =os_connect_socket (pdata->socket_path); }while (rc == -EINTR );
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 342/1039 Bluetooth: L2CAP: Fix using wrong mode
In reply to Greg Kroah-HartmanFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 30d57722732d9736554f85f75f9d7ad5402d192e ]
If user has a set to use SOCK_STREAM the socket would default to L2CAP_MODE_ERTM which later needs to be adjusted if the destination address is LE which doesn't support such mode.
--- net/bluetooth/l2cap_sock.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
net/bluetooth/l2cap_sock.c +10 -2
@@ -161,7 +161,11 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)break ; } -if (chan->psm &&bdaddr_type_is_le (chan->src_type)) +/* Use L2CAP_MODE_LE_FLOWCTL (CoC) in case of LE address and +* L2CAP_MODE_EXT_FLOWCTL (ECRED) has not been set. +*/ +if (chan->psm &&bdaddr_type_is_le (chan->src_type) && + chan->mode !=L2CAP_MODE_EXT_FLOWCTL ) chan->mode =L2CAP_MODE_LE_FLOWCTL ; chan->state =BT_BOUND ;
@@ -255,7 +259,11 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr,return -EINVAL ; } -if (chan->psm &&bdaddr_type_is_le (chan->src_type) && !chan->mode) +/* Use L2CAP_MODE_LE_FLOWCTL (CoC) in case of LE address and +* L2CAP_MODE_EXT_FLOWCTL (ECRED) has not been set. +*/ +if (chan->psm &&bdaddr_type_is_le (chan->src_type) && + chan->mode !=L2CAP_MODE_EXT_FLOWCTL ) chan->mode =L2CAP_MODE_LE_FLOWCTL ;l2cap_sock_init_pid (sk);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 343/1039 bpftool: Enable line buffering for stdout
In reply to Greg Kroah-HartmanFrom: Paul Chaignon <[email protected]>
[ Upstream commit 1a1a0b0364ad291bd8e509da104ac8b5b1afec5d ]
The output of bpftool prog tracelog is currently buffered, which is inconvenient when piping the output into other commands. A simple tracelog | grep will typically not display anything. This patch fixes it by enabling line buffering on stdout for the whole bpftool binary.
--- tools/bpf/bpftool/main.c | 2 ++ 1 file changed, 2 insertions(+)
tools/bpf/bpftool/main.c +2 -0
@@ -400,6 +400,8 @@ int main(int argc, char **argv) };int opt, ret; +setlinebuf (stdout); + last_do_help = do_help; pretty_output = false; json_output = false;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 344/1039 backlight: qcom-wled: Validate enabled string indices in DT
In reply to Greg Kroah-HartmanFrom: Marijn Suijten <[email protected]>
[ Upstream commit c05b21ebc5bce3ecc78c2c71afd76d92c790a2ac ]
The strings passed in DT may possibly cause out-of-bounds register accesses and should be validated before use.
--- drivers/video/backlight/qcom-wled.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/video/backlight/qcom-wled.c +17 -1
@@ -1528,12 +1528,28 @@ static int wled_configure(struct wled *wled) string_len =of_property_count_elems_of_size (dev->of_node,"qcom,enabled-strings" ,sizeof (u32)); -if (string_len >0 ) +if (string_len >0 ) { +if (string_len > wled->max_string_count) { +dev_err (dev,"Cannot have more than %d strings\n" , + wled->max_string_count); +return -EINVAL ; + } +of_property_read_u32_array (dev->of_node,"qcom,enabled-strings" , wled->cfg.enabled_strings,sizeof (u32)); +for (i =0 ; i < string_len; ++i) { +if (wled->cfg.enabled_strings[i] >= wled->max_string_count) { +dev_err (dev, +"qcom,enabled-strings index %d at %d is out of bounds\n" , + wled->cfg.enabled_strings[i], i); +return -EINVAL ; + } + } + } +return 0 ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 345/1039 backlight: qcom-wled: Pass number of elements to read to read_u32_array
In reply to Greg Kroah-HartmanFrom: Marijn Suijten <[email protected]>
[ Upstream commit e29e24bdabfeddbf8b1a4ecac1af439a85150438 ]
of_property_read_u32_array takes the number of elements to read as last argument. This does not always need to be 4 (sizeof(u32)) but should instead be the size of the array in DT as read just above with of_property_count_elems_of_size.
To not make such an error go unnoticed again the driver now bails accordingly when of_property_read_u32_array returns an error. Surprisingly the indentation of newlined arguments is lining up again after prepending rc = .
--- drivers/video/backlight/qcom-wled.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/video/backlight/qcom-wled.c +7 -2
@@ -1535,10 +1535,15 @@ static int wled_configure(struct wled *wled)return -EINVAL ; } -of_property_read_u32_array (dev->of_node, + rc =of_property_read_u32_array (dev->of_node,"qcom,enabled-strings" , wled->cfg.enabled_strings, -sizeof (u32)); + string_len); +if (rc) { +dev_err (dev,"Failed to read %d elements from qcom,enabled-strings: %d\n" , + string_len, rc); +return rc; + }for (i =0 ; i < string_len; ++i) {if (wled->cfg.enabled_strings[i] >= wled->max_string_count) {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 346/1039 backlight: qcom-wled: Fix off-by-one maximum with default num_strings
In reply to Greg Kroah-HartmanFrom: Marijn Suijten <[email protected]>
[ Upstream commit 5ada78b26f935f8751852dffa24f6b545b1d2517 ]
When not specifying num-strings in the DT the default is used, but +1 is added to it which turns WLED3 into 4 and WLED4/5 into 5 strings instead of 3 and 4 respectively, causing out-of-bounds reads and register read/writes. This +1 exists for a deficiency in the DT parsing code, and is simply omitted entirely - solving this oob issue - by parsing the property separately much like qcom,enabled-strings.
This also enables more stringent checks on the maximum value when qcom,enabled-strings is provided in the DT, by parsing num-strings after enabled-strings to allow it to check against (and in a subsequent patch override) the length of enabled-strings: it is invalid to set num-strings higher than that.
The DT currently utilizes it to get around an incorrect fixed read of four elements from that array (has been addressed in a prior patch) by setting a lower num-strings where desired.
--- drivers/video/backlight/qcom-wled.c | 48 ++++++++++------------------- 1 file changed, 16 insertions(+), 32 deletions(-)
drivers/video/backlight/qcom-wled.c +16 -32
@@ -1256,21 +1256,6 @@ static const struct wled_var_cfg wled5_ovp_cfg = { .size = 16, }; -static u32 wled3_num_strings_values_fn (u32 idx) -{ -return idx +1 ; -} - -static const struct wled_var_cfg wled3_num_strings_cfg = { - .fn = wled3_num_strings_values_fn, - .size =3 , -}; - -static const struct wled_var_cfg wled4_num_strings_cfg = { - .fn = wled3_num_strings_values_fn, - .size =4 , -}; -static u32 wled3_switch_freq_values_fn (u32 idx) {return 19200 / (2 * (1 + idx));
@@ -1344,11 +1329,6 @@ static int wled_configure(struct wled *wled) .val_ptr = &cfg->switch_freq, .cfg = &wled3_switch_freq_cfg, }, - { - .name = "qcom,num-strings", - .val_ptr = &cfg->num_strings, - .cfg = &wled3_num_strings_cfg, - }, }; const struct wled_u32_opts wled4_opts[] = {
@@ -1372,11 +1352,6 @@ static int wled_configure(struct wled *wled) .val_ptr = &cfg->switch_freq, .cfg = &wled3_switch_freq_cfg, }, - { - .name = "qcom,num-strings", - .val_ptr = &cfg->num_strings, - .cfg = &wled4_num_strings_cfg, - }, }; const struct wled_u32_opts wled5_opts[] = {
@@ -1400,11 +1375,6 @@ static int wled_configure(struct wled *wled) .val_ptr = &cfg->switch_freq, .cfg = &wled3_switch_freq_cfg, }, - { - .name = "qcom,num-strings", - .val_ptr = &cfg->num_strings, - .cfg = &wled4_num_strings_cfg, - }, { .name = "qcom,modulator-sel", .val_ptr = &cfg->mod_sel,
@@ -1523,8 +1493,6 @@ static int wled_configure(struct wled *wled) *bool_opts[i].val_ptr = true; } - cfg->num_strings = cfg->num_strings +1 ; - string_len =of_property_count_elems_of_size (dev->of_node,"qcom,enabled-strings" ,sizeof (u32));
@@ -1555,6 +1523,22 @@ static int wled_configure(struct wled *wled) } } + rc =of_property_read_u32 (dev->of_node,"qcom,num-strings" , &val); +if (!rc) { +if (val <1 || val > wled->max_string_count) { +dev_err (dev,"qcom,num-strings must be between 1 and %d\n" , + wled->max_string_count); +return -EINVAL ; + } + +if (string_len >0 && val > string_len) { +dev_err (dev,"qcom,num-strings exceeds qcom,enabled-strings\n" ); +return -EINVAL ; + } + + cfg->num_strings = val; + } +return 0 ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 347/1039 backlight: qcom-wled: Override default length with qcom,enabled-strings
In reply to Greg Kroah-HartmanFrom: Marijn Suijten <[email protected]>
[ Upstream commit 2b4b49602f9feca7b7a84eaa33ad9e666c8aa695 ]
The length of qcom,enabled-strings as property array is enough to determine the number of strings to be enabled, without needing to set qcom,num-strings to override the default number of strings when less than the default (which is also the maximum) is provided in DT.
This also introduces an extra warning when qcom,num-strings is set, denoting that it is not necessary to set both anymore. It is usually more concise to set just qcom,num-length when a zero-based, contiguous range of strings is needed (the majority of the cases), or to only set qcom,enabled-strings when a specific set of indices is desired.
--- drivers/video/backlight/qcom-wled.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/video/backlight/qcom-wled.c +9 -3
@@ -1521,6 +1521,8 @@ static int wled_configure(struct wled *wled)return -EINVAL ; } } + + cfg->num_strings = string_len; } rc =of_property_read_u32 (dev->of_node,"qcom,num-strings" , &val);
@@ -1531,9 +1533,13 @@ static int wled_configure(struct wled *wled)return -EINVAL ; } -if (string_len >0 && val > string_len) { -dev_err (dev,"qcom,num-strings exceeds qcom,enabled-strings\n" ); -return -EINVAL ; +if (string_len >0 ) { +dev_warn (dev,"Only one of qcom,num-strings or qcom,enabled-strings" +" should be set\n" ); +if (val > string_len) { +dev_err (dev,"qcom,num-strings exceeds qcom,enabled-strings\n" ); +return -EINVAL ; + } } cfg->num_strings = val;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 348/1039 backlight: qcom-wled: Use cpu_to_le16 macro to perform conversion
In reply to Greg Kroah-HartmanFrom: Marijn Suijten <[email protected]>
[ Upstream commit 0a139358548968b2ff308257b4fbeec7badcc3e1 ]
The kernel already provides appropriate primitives to perform endianness conversion which should be used in favour of manual bit-wrangling.
--- drivers/video/backlight/qcom-wled.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/video/backlight/qcom-wled.c +11 -12
@@ -231,14 +231,14 @@ struct wled {static int wled3_set_brightness (struct wled *wled,u16 brightness) {int rc, i; -u8 v[2 ]; +__le16 v; - v[0 ] = brightness &0xff ; - v[1 ] = (brightness >>8 ) &0xf ; + v =cpu_to_le16 (brightness &WLED3_SINK_REG_BRIGHT_MAX );for (i =0 ; i < wled->cfg.num_strings; ++i) { rc =regmap_bulk_write (wled->regmap, wled->ctrl_addr + -WLED3_SINK_REG_BRIGHT (i), v,2 ); +WLED3_SINK_REG_BRIGHT (i), + &v,sizeof (v));if (rc <0 )return rc; }
@@ -250,18 +250,18 @@ static int wled4_set_brightness(struct wled *wled, u16 brightness) {int rc, i;u16 low_limit = wled->max_brightness *4 /1000 ; -u8 v[2 ]; +__le16 v;/* WLED4's lower limit of operation is 0.4% */ if (brightness >0 && brightness < low_limit) brightness = low_limit; - v[0 ] = brightness &0xff ; - v[1 ] = (brightness >>8 ) &0xf ; + v =cpu_to_le16 (brightness &WLED3_SINK_REG_BRIGHT_MAX );for (i =0 ; i < wled->cfg.num_strings; ++i) { rc =regmap_bulk_write (wled->regmap, wled->sink_addr + -WLED4_SINK_REG_BRIGHT (i), v,2 ); +WLED4_SINK_REG_BRIGHT (i), + &v,sizeof (v));if (rc <0 )return rc; }
@@ -273,21 +273,20 @@ static int wled5_set_brightness(struct wled *wled, u16 brightness) {int rc, offset;u16 low_limit = wled->max_brightness *1 /1000 ; -u8 v[2 ]; +__le16 v;/* WLED5's lower limit is 0.1% */ if (brightness < low_limit) brightness = low_limit; - v[0 ] = brightness &0xff ; - v[1 ] = (brightness >>8 ) &0x7f ; + v =cpu_to_le16 (brightness &WLED5_SINK_REG_BRIGHT_MAX_15B ); offset = (wled->cfg.mod_sel ==MOD_A ) ?WLED5_SINK_REG_MOD_A_BRIGHTNESS_LSB :WLED5_SINK_REG_MOD_B_BRIGHTNESS_LSB ; rc =regmap_bulk_write (wled->regmap, wled->sink_addr + offset, - v,2 ); + &v,sizeof (v));return rc; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 349/1039 backlight: qcom-wled: Respect enabled-strings in set_brightness
In reply to Greg Kroah-HartmanFrom: Marijn Suijten <[email protected]>
[ Upstream commit ec961cf3241153e0f27d850f1bf0f172e7d27a21 ]
The hardware is capable of controlling any non-contiguous sequence of LEDs specified in the DT using qcom,enabled-strings as u32 array, and this also follows from the DT-bindings documentation. The numbers specified in this array represent indices of the LED strings that are to be enabled and disabled.
Its value is appropriately used to setup and enable string modules, but completely disregarded in the set_brightness paths which only iterate over the number of strings linearly.
Take an example where only string 2 is enabled with qcom,enabled_strings=<2>: this string is appropriately enabled but subsequent brightness changes would have only touched the zero'th brightness register because num_strings is 1 here. This is simply addressed by looking up the string for this index in the enabled_strings array just like the other codepaths that iterate over num_strings.
Likewise enabled_strings is now also used in the autodetection path for consistent behaviour: when a list of strings is specified in DT only those strings will be probed for autodetection, analogous to how the number of strings that need to be probed is already bound by qcom,num-strings. After all autodetection uses the set_brightness helpers to set an initial value, which could otherwise end up changing brightness on a different set of strings.
--- drivers/video/backlight/qcom-wled.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/video/backlight/qcom-wled.c +12 -10
@@ -237,7 +237,7 @@ static int wled3_set_brightness(struct wled *wled, u16 brightness)for (i =0 ; i < wled->cfg.num_strings; ++i) { rc =regmap_bulk_write (wled->regmap, wled->ctrl_addr + -WLED3_SINK_REG_BRIGHT (i), +WLED3_SINK_REG_BRIGHT (wled->cfg.enabled_strings[i]), &v,sizeof (v));if (rc <0 )return rc;
@@ -260,7 +260,7 @@ static int wled4_set_brightness(struct wled *wled, u16 brightness)for (i =0 ; i < wled->cfg.num_strings; ++i) { rc =regmap_bulk_write (wled->regmap, wled->sink_addr + -WLED4_SINK_REG_BRIGHT (i), +WLED4_SINK_REG_BRIGHT (wled->cfg.enabled_strings[i]), &v,sizeof (v));if (rc <0 )return rc;
@@ -571,7 +571,7 @@ unlock_mutex:static void wled_auto_string_detection (struct wled *wled) { -int rc =0 , i, delay_time_us; +int rc =0 , i, j, delay_time_us;u32 sink_config =0 ;u8 sink_test =0 , sink_valid =0 , val;bool fault_set;
@@ -618,14 +618,15 @@ static void wled_auto_string_detection(struct wled *wled)/* Iterate through the strings one by one */ for (i =0 ; i < wled->cfg.num_strings; i++) { - sink_test =BIT ((WLED4_SINK_REG_CURR_SINK_SHFT + i)); + j = wled->cfg.enabled_strings[i]; + sink_test =BIT ((WLED4_SINK_REG_CURR_SINK_SHFT + j));/* Enable feedback control */ rc =regmap_write (wled->regmap, wled->ctrl_addr + -WLED3_CTRL_REG_FEEDBACK_CONTROL , i +1 ); +WLED3_CTRL_REG_FEEDBACK_CONTROL , j +1 );if (rc <0 ) {dev_err (wled->dev,"Failed to enable feedback for SINK %d rc = %d\n" , - i +1 , rc); + j +1 , rc); goto failed_detect; }
@@ -634,7 +635,7 @@ static void wled_auto_string_detection(struct wled *wled) WLED4_SINK_REG_CURR_SINK, sink_test);if (rc <0 ) {dev_err (wled->dev,"Failed to configure SINK %d rc=%d\n" , - i +1 , rc); + j +1 , rc); goto failed_detect; }
@@ -661,7 +662,7 @@ static void wled_auto_string_detection(struct wled *wled)if (fault_set)dev_dbg (wled->dev,"WLED OVP fault detected with SINK %d\n" , - i +1 ); + j +1 );else sink_valid |= sink_test;
@@ -701,15 +702,16 @@ static void wled_auto_string_detection(struct wled *wled)/* Enable valid sinks */ if (wled->version ==4 ) {for (i =0 ; i < wled->cfg.num_strings; i++) { + j = wled->cfg.enabled_strings[i];if (sink_config & -BIT (WLED4_SINK_REG_CURR_SINK_SHFT + i)) +BIT (WLED4_SINK_REG_CURR_SINK_SHFT + j)) val =WLED4_SINK_REG_STR_MOD_MASK ;else /* Disable modulator_en for unused sink */ val =0 ; rc =regmap_write (wled->regmap, wled->sink_addr + -WLED4_SINK_REG_STR_MOD_EN (i), val); +WLED4_SINK_REG_STR_MOD_EN (j), val);if (rc <0 ) {dev_err (wled->dev,"Failed to configure MODULATOR_EN rc=%d\n" , rc);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 350/1039 software node: fix wrong node passed to find nargs_prop
In reply to Greg Kroah-HartmanFrom: Clément Léger <[email protected]>
[ Upstream commit c5fc5ba8b6b7bebc05e45036a33405b4c5036c2f ]
nargs_prop refers to a property located in the reference that is found within the nargs property. Use the correct reference node in call to property_entry_read_int_array() to retrieve the correct nargs value.
--- drivers/base/swnode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/swnode.c +1 -1
@@ -529,7 +529,7 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode,return -ENOENT ;if (nargs_prop) { - error =property_entry_read_int_array (swnode->node->properties, + error =property_entry_read_int_array (ref->node->properties, nargs_prop,sizeof (u32), &nargs_prop_val,1 );if (error)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 351/1039 ath11k: Fix unexpected return buffer manager error for QCA6390
In reply to Greg Kroah-HartmanFrom: Baochen Qiang <[email protected]>
[ Upstream commit 71c748b5e01e3e28838a8e26a8966fb5adb03df7 ]
We are seeing below error on QCA6390:
...
[70211.671189] ath11k_pci 0000:72:00.0: failed to parse rx error in wbm_rel ring desc -22 [70212.696154] ath11k_pci 0000:72:00.0: failed to parse rx error in wbm_rel ring desc -22 [70213.092941] ath11k_pci 0000:72:00.0: failed to parse rx error in wbm_rel ring desc -22
...
The reason is that, with commit 734223d78428 ("ath11k: change return buffer manager for QCA6390"), ath11k expects the return buffer manager (RBM) field of descriptor configured as HAL_RX_BUF_RBM_SW1_BM when parsing error frames from WBM2SW3_RELEASE ring. This is a wrong change cause the RBM field is set as HAL_RX_BUF_RBM_SW3_BM.
The same issue also applies to REO2TCL ring though we have not got any error reported.
Fix it by changing RBM from HAL_RX_BUF_RBM_SW1_BM to HAL_RX_BUF_RBM_SW3_BM for these two rings.
Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-01740-QCAHSTSWPLZ_V2_TO_X86-1
--- drivers/net/wireless/ath/ath11k/dp_rx.c | 2 +- drivers/net/wireless/ath/ath11k/hal_rx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath11k/dp_rx.c +1 -1
@@ -3800,7 +3800,7 @@ int ath11k_dp_process_rx_err(struct ath11k_base *ab, struct napi_struct *napi,ath11k_hal_rx_msdu_link_info_get (link_desc_va, &num_msdus, msdu_cookies, &rbm);if (rbm !=HAL_RX_BUF_RBM_WBM_IDLE_DESC_LIST && - rbm != ab->hw_params.hal_params->rx_buf_rbm) { + rbm !=HAL_RX_BUF_RBM_SW3_BM ) { ab->soc_stats.invalid_rbm++;ath11k_warn (ab,"invalid return buffer manager %d\n" , rbm); ath11k_dp_rx_link_desc_return(ab, desc,
drivers/net/wireless/ath/ath11k/hal_rx.c +1 -1
@@ -374,7 +374,7 @@ int ath11k_hal_wbm_desc_parse_err(struct ath11k_base *ab, void *desc, ret_buf_mgr =FIELD_GET (BUFFER_ADDR_INFO1_RET_BUF_MGR , wbm_desc->buf_addr_info.info1); -if (ret_buf_mgr != ab->hw_params.hal_params->rx_buf_rbm) { +if (ret_buf_mgr !=HAL_RX_BUF_RBM_SW3_BM ) { ab->soc_stats.invalid_rbm++;return -EINVAL ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 352/1039 mt76: mt7921: fix a possible race enabling/disabling runtime-pm
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit d430dffbe9dd30759f3c64b65bf85b0245c8d8ab ]
Fix a possible race enabling/disabling runtime-pm between mt7921_pm_set() and mt7921_poll_rx() since mt7921_pm_wake_work() always schedules rx-napi callback and it will trigger mt7921_pm_power_save_work routine putting chip to in low-power state during mt7921_pm_set processing.
--- drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c | 3 --- drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c | 12 +++++++++--- 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c +0 -3
@@ -7,9 +7,6 @@ int mt76_connac_pm_wake(struct mt76_phy *phy, struct mt76_connac_pm *pm) {struct mt76_dev *dev = phy->dev; -if (!pm->enable) -return 0 ; -if (mt76_is_usb (dev))return 0 ;
drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c +9 -3
@@ -276,7 +276,7 @@ mt7921_pm_set(void *data, u64 val)struct mt7921_dev *dev = data;struct mt76_connac_pm *pm = &dev->pm; -mt7921_mutex_acquire (dev); +mutex_lock (&dev->mt76.mutex);if (val == pm->enable) goto out;
@@ -285,7 +285,11 @@ mt7921_pm_set(void *data, u64 val) pm->stats.last_wake_event = jiffies; pm->stats.last_doze_event = jiffies; } - pm->enable = val; +/* make sure the chip is awake here and ps_work is scheduled +* just at end of the this routine. +*/ + pm->enable = false; +mt76_connac_pm_wake (&dev->mphy, pm); ieee80211_iterate_active_interfaces(mt76_hw(dev), IEEE80211_IFACE_ITER_RESUME_ALL,
@@ -293,8 +297,10 @@ mt7921_pm_set(void *data, u64 val)mt76_connac_mcu_set_deep_sleep (&dev->mt76, pm->ds_enable); + pm->enable = val; +mt76_connac_power_save_sched (&dev->mphy, pm); out: -mt7921_mutex_release (dev); +mutex_unlock (&dev->mt76.mutex);return 0 ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 353/1039 Bluetooth: hci_qca: Stop IBS timer during BT OFF
In reply to Greg Kroah-HartmanFrom: Panicker Harish <[email protected]>
[ Upstream commit df1e5c51492fd93ffc293acdcc6f00698d19fedc ]
The IBS timers are not stopped properly once BT OFF is triggered. we could see IBS commands being sent along with version command, so stopped IBS timers while Bluetooth is off.
--- drivers/bluetooth/hci_qca.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/bluetooth/hci_qca.c +3 -0
@@ -1928,6 +1928,9 @@ static int qca_power_off(struct hci_dev *hdev) hu->hdev->hw_error =NULL ; hu->hdev->cmd_timeout =NULL ; +del_timer_sync (&qca->wake_retrans_timer); +del_timer_sync (&qca->tx_idle_timer); +/* Stop sending shutdown command if soc crashes. */ if (soc_type !=QCA_ROME && qca->memdump_state ==QCA_MEMDUMP_IDLE ) {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 354/1039 x86/boot/compressed: Move CLANG_FLAGS to beginning of KBUILD_CFLAGS
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 5fe392ff9d1f7254a1fbb3f72d9893088e4d23eb ]
When cross compiling i386_defconfig on an arm64 host with clang, there are a few instances of '-Waddress-of-packed-member' and '-Wgnu-variable-sized-type-not-at-end' in arch/x86/boot/compressed/, which should both be disabled with the cc-disable-warning calls in that directory's Makefile, which indicates that cc-disable-warning is failing at the point of testing these flags.
The cc-disable-warning calls fail because at the point that the flags are tested, KBUILD_CFLAGS has '-march=i386' without $(CLANG_FLAGS), which has the '--target=' flag to tell clang what architecture it is targeting. Without the '--target=' flag, the host architecture (arm64) is used and i386 is not a valid value for '-march=' in that case. This error can be seen by adding some logging to try-run:
clang-14: error: the clang compiler does not support '-march=i386'
Invoking the compiler has to succeed prior to calling cc-option or cc-disable-warning in order to accurately test whether or not the flag is supported; if it doesn't, the requested flag can never be added to the compiler flags. Move $(CLANG_FLAGS) to the beginning of KBUILD_FLAGS so that any new flags that might be added in the future can be accurately tested.
--- arch/x86/boot/compressed/Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/boot/compressed/Makefile +5 -2
@@ -28,7 +28,11 @@ KCOV_INSTRUMENT := n targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \ vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4 vmlinux.bin.zst -KBUILD_CFLAGS := -m$(BITS) -O2 +# CLANG_FLAGS must come before any cc-disable-warning or cc-option calls in +# case of cross compiling, as it has the '--target=' flag, which is needed to +# avoid errors with '-march=i386', and future flags may depend on the target to +# be valid. +KBUILD_CFLAGS := -m$(BITS) -O2 $(CLANG_FLAGS) KBUILD_CFLAGS += -fno-strict-aliasing -fPIE KBUILD_CFLAGS += -Wundef KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
@@ -47,7 +51,6 @@ KBUILD_CFLAGS += -D__DISABLE_EXPORTS # Disable relocation relaxation in case the link is not PIE. KBUILD_CFLAGS += $(call as-option,-Wa$(comma)-mrelax-relocations=no) KBUILD_CFLAGS += -include $(srctree)/include/linux/hidden.h -KBUILD_CFLAGS += $(CLANG_FLAGS) # sev.c indirectly inludes inat-table.h which is generated during # compilation and stored in $(objtree). Add the directory to the includes so
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 355/1039 crypto: octeontx2 - prevent underflow in get_cores_bmap()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 10371b6212bb682f13247733d6b76b91b2b80f9a ]
If we're going to cap "eng_grp->g->engs_num" upper bounds then we should cap the lower bounds as well.
--- drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c +2 -1
@@ -29,7 +29,8 @@ static struct otx2_cpt_bitmap get_cores_bmap(struct device *dev,bool found = false;int i; -if (eng_grp->g->engs_num >OTX2_CPT_MAX_ENGINES ) { +if (eng_grp->g->engs_num <0 || + eng_grp->g->engs_num >OTX2_CPT_MAX_ENGINES ) {dev_err (dev,"unsupported number of engines %d on octeontx2\n" , eng_grp->g->engs_num);return bmap;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 356/1039 block: null_blk: only set set->nr_maps as 3 if active poll_queues is > 0
In reply to Greg Kroah-HartmanFrom: Ming Lei <[email protected]>
[ Upstream commit 19768f80cf23834e65482f1667ff54192d469fee ]
It isn't correct to set set->nr_maps as 3 if g_poll_queues is > 0 since we can change it via configfs for null_blk device created there, so only set it as 3 if active poll_queues is > 0.
Fixes divide zero exception reported by Shinichiro.
--- drivers/block/null_blk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/null_blk/main.c +1 -1
@@ -1891,7 +1891,7 @@ static int null_init_tag_set(struct nullb *nullb, struct blk_mq_tag_set *set)if (g_shared_tag_bitmap) set->flags |=BLK_MQ_F_TAG_HCTX_SHARED ; set->driver_data = nullb; -if (g_poll_queues) +if (poll_queues) set->nr_maps =3 ;else set->nr_maps =1 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 357/1039 regulator: qcom-labibb: OCP interrupts are not a failure while disabled
In reply to Greg Kroah-HartmanFrom: Marijn Suijten <[email protected]>
[ Upstream commit d27bb69dc83f00f86a830298c967052cded6e784 ]
Receiving the Over-Current Protection interrupt while the regulator is disabled does not count as unhandled/failure (IRQ_NONE, or 0 as it were) but a "fake event", usually due to inrush as the is regulator about to be enabled.
--- drivers/regulator/qcom-labibb-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/qcom-labibb-regulator.c +1 -1
@@ -260,7 +260,7 @@ static irqreturn_t qcom_labibb_ocp_isr(int irq, void *chip)/* If the regulator is not enabled, this is a fake event */ if (!ops->is_enabled (vreg->rdev)) -return 0 ; +return IRQ_HANDLED ;/* If we tried to recover for too many times it's not getting better */ if (vreg->ocp_irq_count >LABIBB_MAX_OCP_COUNT )
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 358/1039 hwmon: (mr75203) fix wrong power-up delay value
In reply to Greg Kroah-HartmanFrom: Arseny Demidov <[email protected]>
[ Upstream commit a8d6d4992ad9d92356619ac372906bd29687bb46 ]
In the file mr75203.c we have a macro named POWER_DELAY_CYCLE_256, the correct value should be 0x100. The register ip_tmr is expressed in units of IP clk cycles, in accordance with the datasheet. Typical power-up delays for Temperature Sensor are 256 cycles i.e. 0x100.
--- drivers/hwmon/mr75203.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/mr75203.c +1 -1
@@ -93,7 +93,7 @@#define VM_CH_REQ BIT(21)#define IP_TMR 0x05 -#define POWER_DELAY_CYCLE_256 0x80 +#define POWER_DELAY_CYCLE_256 0x100#define POWER_DELAY_CYCLE_64 0x40#define PVT_POLL_DELAY_US 20
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 359/1039 x86/mce/inject: Avoid out-of-bounds write when setting flags
In reply to Greg Kroah-HartmanFrom: Zhang Zixun <[email protected]>
[ Upstream commit de768416b203ac84e02a757b782a32efb388476f ]
A contrived zero-length write, for example, by using write(2):
... ret = write(fd, str, 0); ...
to the "flags" file causes:
BUG: KASAN: stack-out-of-bounds in flags_write Write of size 1 at addr ffff888019be7ddf by task writefile/3787 CPU: 4 PID: 3787 Comm: writefile Not tainted 5.16.0-rc7+ #12 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014
due to accessing buf one char before its start.
Prevent such out-of-bounds access.
[ bp: Productize into a proper patch. Link below is the next best
thing because the original mail didn't get archived on lore. ]
--- arch/x86/kernel/cpu/mce/inject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/mce/inject.c +1 -1
@@ -350,7 +350,7 @@ static ssize_t flags_write(struct file *filp, const char __user *ubuf,char buf[MAX_FLAG_OPT_SIZE ], *__buf;int err; -if (cnt >MAX_FLAG_OPT_SIZE ) +if (!cnt || cnt >MAX_FLAG_OPT_SIZE )return -EINVAL ;if (copy_from_user (&buf, ubuf, cnt))
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 360/1039 io_uring: remove double poll on poll update
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
[ Upstream commit e840b4baf3cfb37e2ead4f649a45bb78178677ff ]
Before updating a poll request we should remove it from poll queues, including the double poll entry.
--- fs/io_uring.c | 1 + 1 file changed, 1 insertion(+)
fs/io_uring.c +1 -0
@@ -5928,6 +5928,7 @@ static int io_poll_update(struct io_kiocb *req, unsigned int issue_flags)* update those. For multishot, if we're racing with completion, just * let completion re-add it. */ +io_poll_remove_double (preq); completing = !__io_poll_remove_one (preq, &preq->poll, false);if (completing && (preq->poll.events &EPOLLONESHOT )) { ret = -EALREADY ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 361/1039 bpf: Add missing map_get_next_key method to bloom filter map.
In reply to Greg Kroah-HartmanFrom: Haimin Zhang <[email protected]>
[ Upstream commit 3ccdcee28415c4226de05438b4d89eb5514edf73 ]
Without it, kernel crashes in map_get_next_key().
--- kernel/bpf/bloom_filter.c | 6 ++++++ 1 file changed, 6 insertions(+)
kernel/bpf/bloom_filter.c +6 -0
@@ -82,6 +82,11 @@ static int bloom_map_delete_elem(struct bpf_map *map, void *value)return -EOPNOTSUPP ; } +static int bloom_map_get_next_key (struct bpf_map *map,void *key,void *next_key) +{ +return -EOPNOTSUPP ; +} +static struct bpf_map *bloom_map_alloc (union bpf_attr *attr) {u32 bitset_bytes, bitset_mask, nr_hash_funcs, nr_bits;
@@ -192,6 +197,7 @@ const struct bpf_map_ops bloom_filter_map_ops = { .map_meta_equal = bpf_map_meta_equal, .map_alloc = bloom_map_alloc, .map_free = bloom_map_free, + .map_get_next_key = bloom_map_get_next_key, .map_push_elem = bloom_map_push_elem, .map_peek_elem = bloom_map_peek_elem, .map_pop_elem = bloom_map_pop_elem,
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 362/1039 serial: 8250_bcm7271: Propagate error codes from brcmuart_probe()
In reply to Greg Kroah-HartmanFrom: Lad Prabhakar <[email protected]>
[ Upstream commit c195438f1e84de8fa46b4f5264d12379bee6e9a1 ]
In case of failures brcmuart_probe() always returned -ENODEV, this isn't correct for example platform_get_irq_byname() may return -EPROBE_DEFER to handle such cases propagate error codes in brcmuart_probe() in case of failures.
--- drivers/tty/serial/8250/8250_bcm7271.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/tty/serial/8250/8250_bcm7271.c +8 -3
@@ -1076,14 +1076,18 @@ static int brcmuart_probe(struct platform_device *pdev) priv->rx_bufs =dma_alloc_coherent (dev, priv->rx_size, &priv->rx_addr,GFP_KERNEL ); -if (!priv->rx_bufs) +if (!priv->rx_bufs) { + ret = -EINVAL ; goto err; + } priv->tx_size =UART_XMIT_SIZE ; priv->tx_buf =dma_alloc_coherent (dev, priv->tx_size, &priv->tx_addr,GFP_KERNEL ); -if (!priv->tx_buf) +if (!priv->tx_buf) { + ret = -EINVAL ; goto err; + } } ret =serial8250_register_8250_port (&up);
@@ -1097,6 +1101,7 @@ static int brcmuart_probe(struct platform_device *pdev)if (priv->dma_enabled) { dma_irq =platform_get_irq_byname (pdev,"dma" );if (dma_irq <0 ) { + ret = dma_irq;dev_err (dev,"no IRQ resource info\n" ); goto err1; }
@@ -1116,7 +1121,7 @@ err1: err:brcmuart_free_bufs (dev, priv);brcmuart_arbitration (priv,0 ); -return -ENODEV ; +return ret; }static int brcmuart_remove (struct platform_device *pdev)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 363/1039 drm/amd/display: fix dereference before NULL check
In reply to Greg Kroah-HartmanFrom: José Expósito <[email protected]>
[ Upstream commit f28cad86ada1a7345d7bbd379bef5a8babfa791b ]
The "plane_state" pointer was access before checking if it was NULL.
Avoid a possible NULL pointer dereference by accessing the plane address after the check.
Addresses-Coverity-ID: 1493892 ("Dereference before null check")
--- drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c +2 -1
@@ -134,11 +134,12 @@ void dcn201_update_plane_addr(const struct dc *dc, struct pipe_ctx *pipe_ctx)PHYSICAL_ADDRESS_LOC addr;struct dc_plane_state *plane_state = pipe_ctx->plane_state;struct dce_hwseq *hws = dc->hwseq; -struct dc_plane_address uma = plane_state->address; +struct dc_plane_address uma;if (plane_state ==NULL )return ; + uma = plane_state->address; addr_patched =patch_address_for_sbs_tb_stereo (pipe_ctx, &addr);plane_address_in_gpu_space_to_uma (hws, &uma);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 364/1039 ACPI: scan: Create platform device for BCM4752 and LNV4752 ACPI nodes
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit f85196bdd5a50da74670250564740fc852b3c239 ]
BCM4752 and LNV4752 ACPI nodes describe a Broadcom 4752 GPS module attached to an UART of the system.
The GPS modules talk a custom protocol which only works with a closed- source Android gpsd daemon which knows this protocol.
The ACPI nodes also describe GPIOs to turn the GPS on/off these are handled by the net/rfkill/rfkill-gpio.c code. This handling predates the addition of enumeration of ACPI instantiated serdevs to the kernel and was broken by that addition, because the ACPI scan code now no longer instantiates platform_device-s for these nodes.
Rename the i2c_multi_instantiate_ids HID list to ignore_serial_bus_ids and add the BCM4752 and LNV4752 HIDs, so that rfkill-gpio gets a platform_device to bind to again; and so that a tty cdev for gpsd gets created for these.
--- drivers/acpi/scan.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/acpi/scan.c +10 -3
@@ -1695,6 +1695,7 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device) {struct list_head resource_list;bool is_serial_bus_slave = false; +static const struct acpi_device_id ignore_serial_bus_ids[] = {/* * These devices have multiple I2cSerialBus resources and an i2c-client * must be instantiated for each, each with its own i2c_device_id.
@@ -1703,11 +1704,18 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device)* drivers/platform/x86/i2c-multi-instantiate.c driver, which knows * which i2c_device_id to use for each resource. */ -static const struct acpi_device_id i2c_multi_instantiate_ids[] = { {"BSG1160", }, {"BSG2150", }, {"INT33FE", }, {"INT3515", }, + /* + * HIDs of device with an UartSerialBusV2 resource for which userspace + * expects a regular tty cdev to be created (instead of the in kernel + * serdev) and which have a kernel driver which expects a platform_dev + * such as the rfkill-gpio driver. + */ + {"BCM4752", }, + {"LNV4752", }, {} };
@@ -1721,8 +1729,7 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device) fwnode_property_present(&device->fwnode, "baud")))return true; -/* Instantiate a pdev for the i2c-multi-instantiate drv to bind to */ -if (!acpi_match_device_ids (device, i2c_multi_instantiate_ids)) +if (!acpi_match_device_ids (device, ignore_serial_bus_ids))return false;INIT_LIST_HEAD (&resource_list);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 365/1039 pcmcia: rsrc_nonstatic: Fix a NULL pointer dereference in __nonstatic_find_io_region()
In reply to Greg Kroah-HartmanFrom: Zhou Qingyang <[email protected]>
[ Upstream commit ca0fe0d7c35c97528bdf621fdca75f13157c27af ]
In __nonstatic_find_io_region(), pcmcia_make_resource() is assigned to res and used in pci_bus_alloc_resource(). There is a dereference of res in pci_bus_alloc_resource(), which could lead to a NULL pointer dereference on failure of pcmcia_make_resource().
Fix this bug by adding a check of res.
This bug was found by a static analyzer. The analysis employs differential checking to identify inconsistent security operations (e.g., checks or kfrees) between two code paths and confirms that the inconsistent operations are not recovered in the current function or the callers, so they constitute bugs.
Note that, as a bug found by static analysis, it can be a false positive or hard to trigger. Multiple researchers have cross-reviewed the bug.
Builds with CONFIG_PCCARD_NONSTATIC=y show no new warnings, and our static analyzer no longer warns about this code.
--- drivers/pcmcia/rsrc_nonstatic.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/pcmcia/rsrc_nonstatic.c +3 -0
@@ -690,6 +690,9 @@ static struct resource *__nonstatic_find_io_region(struct pcmcia_socket *s,unsigned long min = base;int ret; +if (!res) +return NULL ; + data.mask = align -1 ; data.offset = base & data.mask; data.map = &s_data->io_db;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 366/1039 pcmcia: rsrc_nonstatic: Fix a NULL pointer dereference in nonstatic_find_mem_region()
In reply to Greg Kroah-HartmanFrom: Zhou Qingyang <[email protected]>
[ Upstream commit 977d2e7c63c3d04d07ba340b39987742e3241554 ]
In nonstatic_find_mem_region(), pcmcia_make_resource() is assigned to res and used in pci_bus_alloc_resource(). There a dereference of res in pci_bus_alloc_resource(), which could lead to a NULL pointer dereference on failure of pcmcia_make_resource().
Fix this bug by adding a check of res.
This bug was found by a static analyzer. The analysis employs differential checking to identify inconsistent security operations (e.g., checks or kfrees) between two code paths and confirms that the inconsistent operations are not recovered in the current function or the callers, so they constitute bugs.
Note that, as a bug found by static analysis, it can be a false positive or hard to trigger. Multiple researchers have cross-reviewed the bug.
Builds with CONFIG_PCCARD_NONSTATIC=y show no new warnings, and our static analyzer no longer warns about this code.
--- drivers/pcmcia/rsrc_nonstatic.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/pcmcia/rsrc_nonstatic.c +3 -0
@@ -812,6 +812,9 @@ static struct resource *nonstatic_find_mem_region(u_long base, u_long num,unsigned long min, max;int ret, i, j; +if (!res) +return NULL ; + low = low || !(s->features &SS_CAP_PAGE_REGS ); data.mask = align -1 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 367/1039 power: reset: mt6397: Check for null res pointer
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 1c1348bf056dee665760a3bd1cd30b0be7554fc2 ]
The return value of platform_get_resource() needs to be checked. To avoid use of error pointer in case that there is no suitable resource.
--- drivers/power/reset/mt6323-poweroff.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/power/reset/mt6323-poweroff.c +3 -0
@@ -57,6 +57,9 @@ static int mt6323_pwrc_probe(struct platform_device *pdev)return -ENOMEM ; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) +return -EINVAL ; + pwrc->base = res->start; pwrc->regmap = mt6397_chip->regmap; pwrc->dev = &pdev->dev;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 368/1039 net/xfrm: IPsec tunnel mode fix inner_ipproto setting in sec_path
In reply to Greg Kroah-HartmanFrom: Raed Salem <[email protected]>
[ Upstream commit 45a98ef4922def8c679ca7c454403d1957fe70e7 ]
The inner_ipproto saves the inner IP protocol of the plain text packet. This allows vendor's IPsec feature making offload decision at skb's features_check and configuring hardware at ndo_start_xmit, current code implenetation did not handle the case where IPsec is used in tunnel mode.
Fix by handling the case when IPsec is used in tunnel mode by reading the protocol of the plain text packet IP protocol.
--- net/xfrm/xfrm_output.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-)
net/xfrm/xfrm_output.c +25 -5
@@ -647,10 +647,12 @@ static int xfrm_output_gso(struct net *net, struct sock *sk, struct sk_buff *skb* This requires hardware to know the inner packet type to calculate * the inner header checksum. Save inner ip protocol here to avoid * traversing the packet in the vendor's xmit code. -* If the encap type is IPIP, just save skb->inner_ipproto. Otherwise, -* get the ip protocol from the IP header. +* For IPsec tunnel mode save the ip protocol from the IP header of the +* plain text packet. Otherwise If the encap type is IPIP, just save +* skb->inner_ipproto in any other case get the ip protocol from the IP +* header. */ -static void xfrm_get_inner_ipproto (struct sk_buff *skb) +static void xfrm_get_inner_ipproto (struct sk_buff *skb,struct xfrm_state *x) {struct xfrm_offload *xo =xfrm_offload (skb);const struct ethhdr *eth;
@@ -658,6 +660,25 @@ static void xfrm_get_inner_ipproto(struct sk_buff *skb)if (!xo)return ; +if (x->outer_mode.encap ==XFRM_MODE_TUNNEL ) { +switch (x->outer_mode.family) { +case AF_INET : + xo->inner_ipproto =ip_hdr (skb)->protocol; +break ; +case AF_INET6 : + xo->inner_ipproto =ipv6_hdr (skb)->nexthdr; +break ; +default : +break ; + } + +return ; + } + +/* non-Tunnel Mode */ +if (!skb->encapsulation) +return ; +if (skb->inner_protocol_type ==ENCAP_TYPE_IPPROTO ) { xo->inner_ipproto = skb->inner_ipproto;return ;
@@ -712,8 +733,7 @@ int xfrm_output(struct sock *sk, struct sk_buff *skb) sp->xvec[sp->len++] = x;xfrm_state_hold (x); -if (skb->encapsulation) -xfrm_get_inner_ipproto (skb); +xfrm_get_inner_ipproto (skb, x); skb->encapsulation =1 ;if (skb_is_gso (skb)) {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 369/1039 net: ethernet: mtk_eth_soc: fix return values and refactor MDIO ops
In reply to Greg Kroah-HartmanFrom: Daniel Golle <[email protected]>
[ Upstream commit eda80b249df7bbc7b3dd13907343a3e59bfc57fd ]
Instead of returning -1 (-EPERM) when MDIO bus is stuck busy while writing or 0xffff if it happens while reading, return the appropriate -ETIMEDOUT. Also fix return type to int instead of u32. Refactor functions to use bitfield helpers instead of having various masking and shifting constants in the code, which also results in the register definitions in the header file being more obviously related to what is stated in the MediaTek's Reference Manual.
--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 53 ++++++++++++--------- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 16 +++++-- 2 files changed, 41 insertions(+), 28 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +30 -23
@@ -91,46 +91,53 @@ static int mtk_mdio_busy_wait(struct mtk_eth *eth) }dev_err (eth->dev,"mdio: MDIO timeout\n" ); -return -1 ; +return -ETIMEDOUT ; } -static u32 _mtk_mdio_write (struct mtk_eth *eth,u32 phy_addr, -u32 phy_register,u32 write_data) +static int _mtk_mdio_write (struct mtk_eth *eth,u32 phy_addr,u32 phy_reg, +u32 write_data) { -if (mtk_mdio_busy_wait (eth)) -return -1 ; +int ret; - write_data &=0xffff ; + ret =mtk_mdio_busy_wait (eth); +if (ret <0 ) +return ret; -mtk_w32 (eth,PHY_IAC_ACCESS |PHY_IAC_START |PHY_IAC_WRITE | - (phy_register <<PHY_IAC_REG_SHIFT ) | - (phy_addr <<PHY_IAC_ADDR_SHIFT ) | write_data, +mtk_w32 (eth,PHY_IAC_ACCESS | +PHY_IAC_START_C22 | +PHY_IAC_CMD_WRITE | +PHY_IAC_REG (phy_reg) | +PHY_IAC_ADDR (phy_addr) | +PHY_IAC_DATA (write_data),MTK_PHY_IAC ); -if (mtk_mdio_busy_wait (eth)) -return -1 ; + ret =mtk_mdio_busy_wait (eth); +if (ret <0 ) +return ret;return 0 ; } -static u32 _mtk_mdio_read (struct mtk_eth *eth,int phy_addr,int phy_reg) +static int _mtk_mdio_read (struct mtk_eth *eth,u32 phy_addr,u32 phy_reg) { -u32 d; +int ret; -if (mtk_mdio_busy_wait (eth)) -return 0xffff ; + ret =mtk_mdio_busy_wait (eth); +if (ret <0 ) +return ret; -mtk_w32 (eth,PHY_IAC_ACCESS |PHY_IAC_START |PHY_IAC_READ | - (phy_reg <<PHY_IAC_REG_SHIFT ) | - (phy_addr <<PHY_IAC_ADDR_SHIFT ), +mtk_w32 (eth,PHY_IAC_ACCESS | +PHY_IAC_START_C22 | +PHY_IAC_CMD_C22_READ | +PHY_IAC_REG (phy_reg) | +PHY_IAC_ADDR (phy_addr),MTK_PHY_IAC ); -if (mtk_mdio_busy_wait (eth)) -return 0xffff ; - - d =mtk_r32 (eth,MTK_PHY_IAC ) &0xffff ; + ret =mtk_mdio_busy_wait (eth); +if (ret <0 ) +return ret; -return d; +return mtk_r32 (eth,MTK_PHY_IAC ) &PHY_IAC_DATA_MASK ; } static int mtk_mdio_write(struct mii_bus *bus, int phy_addr,
drivers/net/ethernet/mediatek/mtk_eth_soc.h +11 -5
@@ -341,11 +341,17 @@/* PHY Indirect Access Control registers */ #define MTK_PHY_IAC 0x10004#define PHY_IAC_ACCESS BIT(31) -#define PHY_IAC_READ BIT(19) -#define PHY_IAC_WRITE BIT(18) -#define PHY_IAC_START BIT(16) -#define PHY_IAC_ADDR_SHIFT 20 -#define PHY_IAC_REG_SHIFT 25 +#define PHY_IAC_REG_MASK GENMASK(29, 25) +#define PHY_IAC_REG (x) FIELD_PREP(PHY_IAC_REG_MASK, (x)) +#define PHY_IAC_ADDR_MASK GENMASK(24, 20) +#define PHY_IAC_ADDR (x) FIELD_PREP(PHY_IAC_ADDR_MASK, (x)) +#define PHY_IAC_CMD_MASK GENMASK(19, 18) +#define PHY_IAC_CMD_WRITE FIELD_PREP(PHY_IAC_CMD_MASK, 1) +#define PHY_IAC_CMD_C22_READ FIELD_PREP(PHY_IAC_CMD_MASK, 2) +#define PHY_IAC_START_MASK GENMASK(17, 16) +#define PHY_IAC_START_C22 FIELD_PREP(PHY_IAC_START_MASK, 1) +#define PHY_IAC_DATA_MASK GENMASK(15, 0) +#define PHY_IAC_DATA (x) FIELD_PREP(PHY_IAC_DATA_MASK, (x))#define PHY_IAC_TIMEOUT HZ#define MTK_MAC_MISC 0x1000c
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 370/1039 net: dsa: fix incorrect function pointer check for MRP ring roles
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit ff91e1b68490b97c18c649b769618815eb945f11 ]
The cross-chip notifier boilerplate code meant to check the presence of ds->ops->port_mrp_add_ring_role before calling it, but checked ds->ops->port_mrp_add instead, before calling ds->ops->port_mrp_add_ring_role.
Therefore, a driver which implements one operation but not the other would trigger a NULL pointer dereference.
There isn't any such driver in DSA yet, so there is no reason to backport the change. Issue found through code inspection.
--- net/dsa/switch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/dsa/switch.c +2 -2
@@ -675,7 +675,7 @@ static int dsa_switch_mrp_add_ring_role(struct dsa_switch *ds, struct dsa_notifier_mrp_ring_role_info *info) { -if (!ds->ops->port_mrp_add) +if (!ds->ops->port_mrp_add_ring_role)return -EOPNOTSUPP ;if (ds->index == info->sw_index)
@@ -689,7 +689,7 @@ static int dsa_switch_mrp_del_ring_role(struct dsa_switch *ds, struct dsa_notifier_mrp_ring_role_info *info) { -if (!ds->ops->port_mrp_del) +if (!ds->ops->port_mrp_del_ring_role)return -EOPNOTSUPP ;if (ds->index == info->sw_index)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 371/1039 netfilter: ipt_CLUSTERIP: fix refcount leak in clusterip_tg_check()
In reply to Greg Kroah-HartmanFrom: Xin Xiong <[email protected]>
[ Upstream commit d94a69cb2cfa77294921aae9afcfb866e723a2da ]
The issue takes place in one error path of clusterip_tg_check(). When memcmp() returns nonzero, the function simply returns the error code, forgetting to decrease the reference count of a clusterip_config object, which is bumped earlier by clusterip_config_find_get(). This may incur reference count leak.
Fix this issue by decrementing the refcount of the object in specific error path.
--- net/ipv4/netfilter/ipt_CLUSTERIP.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv4/netfilter/ipt_CLUSTERIP.c +4 -1
@@ -520,8 +520,11 @@ static int clusterip_tg_check(const struct xt_tgchk_param *par)if (IS_ERR (config))return PTR_ERR (config); } - }else if (memcmp (&config->clustermac, &cipinfo->clustermac,ETH_ALEN )) + }else if (memcmp (&config->clustermac, &cipinfo->clustermac,ETH_ALEN )) { +clusterip_config_entry_put (config); +clusterip_config_put (config);return -EINVAL ; + } ret =nf_ct_netns_get (par->net, par->family);if (ret <0 ) {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 372/1039 bpf, arm64: Use emit_addr_mov_i64() for BPF_PSEUDO_FUNC
In reply to Greg Kroah-HartmanFrom: Hou Tao <[email protected]>
[ Upstream commit e4a41c2c1fa916547e63440c73a51a5eb06247af ]
The following error is reported when running "./test_progs -t for_each" under arm64:
bpf_jit: multi-func JIT bug 58 != 56
[...]
JIT doesn't support bpf-to-bpf calls
The root cause is the size of BPF_PSEUDO_FUNC instruction increases from 2 to 3 after the address of called bpf-function is settled and there are two bpf-to-bpf calls in test_pkt_access. The generated instructions are shown below:
0x48: 21 00 C0 D2 movz x1, #0x1, lsl #32 0x4c: 21 00 80 F2 movk x1, #0x1
0x48: E1 3F C0 92 movn x1, #0x1ff, lsl #32 0x4c: 41 FE A2 F2 movk x1, #0x17f2, lsl #16 0x50: 81 70 9F F2 movk x1, #0xfb84
Fixing it by using emit_addr_mov_i64() for BPF_PSEUDO_FUNC, so the size of jited image will not change.
--- arch/arm64/net/bpf_jit_comp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm64/net/bpf_jit_comp.c +4 -1
@@ -791,7 +791,10 @@ emit_cond_jmp:u64 imm64; imm64 = (u64 )insn1.imm <<32 | (u32 )imm; -emit_a64_mov_i64 (dst, imm64, ctx); +if (bpf_pseudo_func (insn)) +emit_addr_mov_i64 (dst, imm64, ctx); +else +emit_a64_mov_i64 (dst, imm64, ctx);return 1 ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 373/1039 bpf, sockmap: Fix return codes from tcp_bpf_recvmsg_parser()
In reply to Greg Kroah-HartmanFrom: John Fastabend <[email protected]>
[ Upstream commit 5b2c5540b8110eea0d67a78fb0ddb9654c58daeb ]
Applications can be confused slightly because we do not always return the same error code as expected, e.g. what the TCP stack normally returns. For example on a sock err sk->sk_err instead of returning the sock_error we return EAGAIN. This usually means the application will 'try again' instead of aborting immediately. Another example, when a shutdown event is received we should immediately abort instead of waiting for data when the user provides a timeout.
These tend to not be fatal, applications usually recover, but introduces bogus errors to the user or introduces unexpected latency. Before 'c5d2177a72a16' we fell back to the TCP stack when no data was available so we managed to catch many of the cases here, although with the extra latency cost of calling tcp_msg_wait_data() first.
To fix lets duplicate the error handling in TCP stack into tcp_bpf so that we get the same error codes.
These were found in our CI tests that run applications against sockmap and do longer lived testing, at least compared to test_sockmap that does short-lived ping/pong tests, and in some of our test clusters we deploy.
Its non-trivial to do these in a shorter form CI tests that would be appropriate for BPF selftests, but we are looking into it so we can ensure this keeps working going forward. As a preview one idea is to pull in the packetdrill testing which catches some of this.
--- net/ipv4/tcp_bpf.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
net/ipv4/tcp_bpf.c +27 -0
@@ -196,12 +196,39 @@ msg_bytes_ready:long timeo;int data; +if (sock_flag (sk,SOCK_DONE )) + goto out; + +if (sk->sk_err) { + copied =sock_error (sk); + goto out; + } + +if (sk->sk_shutdown &RCV_SHUTDOWN ) + goto out; + +if (sk->sk_state ==TCP_CLOSE ) { + copied = -ENOTCONN ; + goto out; + } + timeo =sock_rcvtimeo (sk, nonblock); +if (!timeo) { + copied = -EAGAIN ; + goto out; + } + +if (signal_pending (current)) { + copied =sock_intr_errno (timeo); + goto out; + } + data =tcp_msg_wait_data (sk, psock, timeo);if (data && !sk_psock_queue_empty (psock)) goto msg_bytes_ready; copied = -EAGAIN ; } +out:release_sock (sk);sk_psock_put (sk, psock);return copied;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 374/1039 bpf, sockmap: Fix double bpf_prog_put on error case in map_link
In reply to Greg Kroah-HartmanFrom: John Fastabend <[email protected]>
[ Upstream commit 218d747a4142f281a256687bb513a135c905867b ]
sock_map_link() is called to update a sockmap entry with a sk. But, if the sock_map_init_proto() call fails then we return an error to the map_update op against the sockmap. In the error path though we need to cleanup psock and dec the refcnt on any programs associated with the map, because we refcnt them early in the update process to ensure they are pinned for the psock. (This avoids a race where user deletes programs while also updating the map with new socks.)
In current code we do the prog refcnt dec explicitely by calling bpf_prog_put() when the program was found in the map. But, after commit '38207a5e81230' in this error path we've already done the prog to psock assignment so the programs have a reference from the psock as well. This then causes the psock tear down logic, invoked by sk_psock_put() in the error path, to similarly call bpf_prog_put on the programs there.
To be explicit this logic does the prog->psock assignment:
if (msg_*)
psock_set_prog(...)
Then the error path under the out_progs label does a similar check and dec with:
if (msg_*)
bpf_prog_put(...)
And the teardown logic sk_psock_put() does ...
psock_set_prog(msg_*, NULL)
... triggering another bpf_prog_put(...). Then KASAN gives us this splat, found by syzbot because we've created an inbalance between bpf_prog_inc and bpf_prog_put calling put twice on the program.
BUG: KASAN: vmalloc-out-of-bounds in __bpf_prog_put kernel/bpf/syscall.c:1812 [inline] BUG: KASAN: vmalloc-out-of-bounds in __bpf_prog_put kernel/bpf/syscall.c:1812 [inline] kernel/bpf/syscall.c:1829 BUG: KASAN: vmalloc-out-of-bounds in bpf_prog_put+0x8c/0x4f0 kernel/bpf/syscall.c:1829 kernel/bpf/syscall.c:1829 Read of size 8 at addr ffffc90000e76038 by task syz-executor020/3641
To fix clean up error path so it doesn't try to do the bpf_prog_put in the error path once progs are assigned then it relies on the normal psock tear down logic to do complete cleanup.
For completness we also cover the case whereh sk_psock_init_strp() fails, but this is not expected because it indicates an incorrect socket type and should be caught earlier.
--- net/core/sock_map.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
net/core/sock_map.c +13 -8
@@ -292,15 +292,23 @@ static int sock_map_link(struct bpf_map *map, struct sock *sk)if (skb_verdict)psock_set_prog (&psock->progs.skb_verdict, skb_verdict); +/* msg_* and stream_* programs references tracked in psock after this +* point. Reference dec and cleanup will occur through psock destructor +*/ ret =sock_map_init_proto (sk, psock); -if (ret <0 ) - goto out_drop; +if (ret <0 ) { +sk_psock_put (sk, psock); + goto out; + }write_lock_bh (&sk->sk_callback_lock);if (stream_parser && stream_verdict && !psock->saved_data_ready) { ret =sk_psock_init_strp (sk, psock); -if (ret) - goto out_unlock_drop; +if (ret) { +write_unlock_bh (&sk->sk_callback_lock); +sk_psock_put (sk, psock); + goto out; + }sk_psock_start_strp (sk, psock); }else if (!stream_parser && stream_verdict && !psock->saved_data_ready) {sk_psock_start_verdict (sk,psock);
@@ -309,10 +317,6 @@ static int sock_map_link(struct bpf_map *map, struct sock *sk) }write_unlock_bh (&sk->sk_callback_lock);return 0 ; -out_unlock_drop: -write_unlock_bh (&sk->sk_callback_lock); -out_drop: -sk_psock_put (sk, psock); out_progs:if (skb_verdict)bpf_prog_put (skb_verdict);
@@ -325,6 +329,7 @@ out_put_stream_parser: out_put_stream_verdict:if (stream_verdict)bpf_prog_put (stream_verdict); +out:return ret; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 375/1039 bpf: Dont promote bogus looking registers after null check.
In reply to Greg Kroah-HartmanFrom: Daniel Borkmann <[email protected]>
[ Upstream commit e60b0d12a95dcf16a63225cead4541567f5cb517 ]
If we ever get to a point again where we convert a bogus looking <ptr>_or_null typed register containing a non-zero fixed or variable offset, then lets not reset these bounds to zero since they are not and also don't promote the register to a <ptr> type, but instead leave it as <ptr>_or_null. Converting to a unknown register could be an avenue as well, but then if we run into this case it would allow to leak a kernel pointer this way.
--- kernel/bpf/verifier.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
kernel/bpf/verifier.c +6 -6
@@ -8961,15 +8961,15 @@ static void mark_ptr_or_null_reg(struct bpf_func_state *state, {if (reg_type_may_be_null (reg->type) && reg->id == id && !WARN_ON_ONCE (!reg->id)) { -/* Old offset (both fixed and variable parts) should -* have been known-zero, because we don't allow pointer -* arithmetic on pointers that might be NULL. -*/ if (WARN_ON_ONCE (reg->smin_value || reg->smax_value || !tnum_equals_const (reg->var_off,0 ) || reg->off)) { -__mark_reg_known_zero (reg); - reg->off =0 ; +/* Old offset (both fixed and variable parts) should +* have been known-zero, because we don't allow pointer +* arithmetic on pointers that might be NULL. If we +* see this happening, don't convert the register. +*/ +return ; }if (is_null) { reg->type =SCALAR_VALUE ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 376/1039 bpf: Fix verifier support for validation of async callbacks
In reply to Greg Kroah-HartmanFrom: Kris Van Hees <[email protected]>
[ Upstream commit a5bebc4f00dee47113eed48098c68e88b5ba70e8 ]
Commit bfc6bb74e4f1 ("bpf: Implement verifier support for validation of async callbacks.") added support for BPF_FUNC_timer_set_callback to
the __check_func_call() function. The test in __check_func_call() is flaweed because it can mis-interpret a regular BPF-to-BPF pseudo-call
as a BPF_FUNC_timer_set_callback callback call.
Consider the conditional in the code:
if (insn->code == (BPF_JMP | BPF_CALL) &&
insn->imm == BPF_FUNC_timer_set_callback) {The BPF_FUNC_timer_set_callback has value 170. This means that if you have a BPF program that contains a pseudo-call with an instruction delta of 170, this conditional will be found to be true by the verifier, and it will interpret the pseudo-call as a callback. This leads to a mess with the verification of the program because it makes the wrong assumptions about the nature of this call.
Solution: include an explicit check to ensure that insn->src_reg == 0. This ensures that calls cannot be mis-interpreted as an async callback call.
--- kernel/bpf/verifier.c | 1 + 1 file changed, 1 insertion(+)
kernel/bpf/verifier.c +1 -0
@@ -5965,6 +5965,7 @@ static int __check_func_call(struct bpf_verifier_env *env, struct bpf_insn *insn }if (insn->code == (BPF_JMP |BPF_CALL ) && + insn->src_reg ==0 && insn->imm == BPF_FUNC_timer_set_callback) {struct bpf_verifier_state *async_cb;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 377/1039 bpf: Fix SO_RCVBUF/SO_SNDBUF handling in _bpf_setsockopt().
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 04c350b1ae6bdb12b84009a4d0bf5ab4e621c47b ]
The commit 4057765f2dee ("sock: consistent handling of extreme SO_SNDBUF/SO_RCVBUF values") added a change to prevent underflow in setsockopt() around SO_SNDBUF/SO_RCVBUF.
This patch adds the same change to _bpf_setsockopt().
--- net/core/filter.c | 2 ++ 1 file changed, 2 insertions(+)
net/core/filter.c +2 -0
@@ -4742,12 +4742,14 @@ static int _bpf_setsockopt(struct sock *sk, int level, int optname,switch (optname) {case SO_RCVBUF : val =min_t (u32, val, sysctl_rmem_max); + val =min_t (int, val,INT_MAX /2 ); sk->sk_userlocks |=SOCK_RCVBUF_LOCK ;WRITE_ONCE (sk->sk_rcvbuf,max_t (int, val *2 ,SOCK_MIN_RCVBUF ));break ;case SO_SNDBUF : val =min_t (u32, val, sysctl_wmem_max); + val =min_t (int, val,INT_MAX /2 ); sk->sk_userlocks |=SOCK_SNDBUF_LOCK ;WRITE_ONCE (sk->sk_sndbuf,max_t (int, val *2 ,SOCK_MIN_SNDBUF ));
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 378/1039 libbpf: Use probe_name for legacy kprobe
In reply to Greg Kroah-HartmanFrom: Qiang Wang <[email protected]>
[ Upstream commit 71cff670baff5cc6a6eeb0181e2cc55579c5e1e0 ]
Fix a bug in commit 46ed5fc33db9, which wrongly used the func_name instead of probe_name to register legacy kprobe.
--- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +1 -1
@@ -9769,7 +9769,7 @@ bpf_program__attach_kprobe_opts(const struct bpf_program *prog,gen_kprobe_legacy_event_name (probe_name,sizeof (probe_name), func_name, offset); - legacy_probe =strdup (func_name); + legacy_probe =strdup (probe_name);if (!legacy_probe)return libbpf_err_ptr (-ENOMEM );
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 379/1039 netfilter: nft_payload: do not update layer 4 checksum when mangling fragments
In reply to Greg Kroah-HartmanFrom: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 4e1860a3863707e8177329c006d10f9e37e097a8 ]
IP fragments do not come with the transport header, hence skip bogus layer 4 checksum updates.
--- net/netfilter/nft_payload.c | 3 +++ 1 file changed, 3 insertions(+)
net/netfilter/nft_payload.c +3 -0
@@ -546,6 +546,9 @@ static int nft_payload_l4csum_offset(const struct nft_pktinfo *pkt, struct sk_buff *skb, unsigned int *l4csum_offset) { +if (pkt->fragoff) +return -1 ; +switch (pkt->tprot) {case IPPROTO_TCP : *l4csum_offset = offsetof(struct tcphdr , check);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 380/1039 netfilter: nft_set_pipapo: allocate pcpu scratch maps on clone
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
[ Upstream commit 23c54263efd7cb605e2f7af72717a2a951999217 ]
This is needed in case a new transaction is made that doesn't insert any new elements into an already existing set.
Else, after second 'nft -f ruleset.txt', lookups in such a set will fail because ->lookup() encounters raw_cpu_ptr(m->scratch) == NULL.
For the initial rule load, insertion of elements takes care of the allocation, but for rule reloads this isn't guaranteed: we might not have additions to the set.
--- net/netfilter/nft_set_pipapo.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/netfilter/nft_set_pipapo.c +8 -0
@@ -1290,6 +1290,11 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old)if (!new->scratch_aligned) goto out_scratch;#endif +for_each_possible_cpu (i) + *per_cpu_ptr (new->scratch, i) =NULL ; + +if (pipapo_realloc_scratch (new, old->bsize_max)) + goto out_scratch_realloc;rcu_head_init (&new->rcu);
@@ -1334,6 +1339,9 @@ out_lt:kvfree (dst->lt); dst--; } +out_scratch_realloc: +for_each_possible_cpu (i) +kfree (*per_cpu_ptr (new->scratch, i));#ifdef NFT_PIPAPO_ALIGN free_percpu (new->scratch_aligned);#endif
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 381/1039 net: fix SOF_TIMESTAMPING_BIND_PHC to work with multiple sockets
In reply to Greg Kroah-HartmanFrom: Miroslav Lichvar <[email protected]>
[ Upstream commit 007747a984ea5e895b7d8b056b24ebf431e1e71d ]
When multiple sockets using the SOF_TIMESTAMPING_BIND_PHC flag received a packet with a hardware timestamp (e.g. multiple PTP instances in different PTP domains using the UDPv4/v6 multicast or L2 transport), the timestamps received on some sockets were corrupted due to repeated conversion of the same timestamp (by the same or different vclocks).
Fix ptp_convert_timestamp() to not modify the shared skb timestamp and return the converted timestamp as a ktime_t instead. If the conversion fails, return 0 to not confuse the application with timestamps corresponding to an unexpected PHC.
--- drivers/ptp/ptp_vclock.c | 10 +++++----- include/linux/ptp_clock_kernel.h | 12 +++++++----- net/socket.c | 9 ++++++--- 3 files changed, 18 insertions(+), 13 deletions(-)
drivers/ptp/ptp_vclock.c +5 -5
@@ -185,8 +185,8 @@ out: }EXPORT_SYMBOL (ptp_get_vclocks_index); -void ptp_convert_timestamp (struct skb_shared_hwtstamps *hwtstamps, -int vclock_index) +ktime_t ptp_convert_timestamp (const struct skb_shared_hwtstamps *hwtstamps, +int vclock_index) {char name[PTP_CLOCK_NAME_LEN ] ="" ;struct ptp_vclock *vclock;
@@ -198,12 +198,12 @@ void ptp_convert_timestamp(struct skb_shared_hwtstamps *hwtstamps,snprintf (name,PTP_CLOCK_NAME_LEN ,"ptp%d" , vclock_index); dev =class_find_device_by_name (ptp_class, name);if (!dev) -return ; +return 0 ; ptp =dev_get_drvdata (dev);if (!ptp->is_virtual_clock) {put_device (dev); -return ; +return 0 ; } vclock =info_to_vclock (ptp->info);
@@ -215,7 +215,7 @@ void ptp_convert_timestamp(struct skb_shared_hwtstamps *hwtstamps,spin_unlock_irqrestore (&vclock->lock, flags);put_device (dev); - hwtstamps->hwtstamp = ns_to_ktime(ns); + return ns_to_ktime(ns); }EXPORT_SYMBOL (ptp_convert_timestamp);#endif
include/linux/ptp_clock_kernel.h +7 -5
@@ -351,15 +351,17 @@ int ptp_get_vclocks_index(int pclock_index, int **vclock_index);* * @hwtstamps: skb_shared_hwtstamps structure pointer * @vclock_index: phc index of ptp vclock. +* +* Returns converted timestamp, or 0 on error. */ -void ptp_convert_timestamp (struct skb_shared_hwtstamps *hwtstamps, -int vclock_index); +ktime_t ptp_convert_timestamp (const struct skb_shared_hwtstamps *hwtstamps, +int vclock_index);#else static inline int ptp_get_vclocks_index (int pclock_index,int **vclock_index) {return 0 ; } -static inline void ptp_convert_timestamp (struct skb_shared_hwtstamps *hwtstamps, -int vclock_index) -{ } +static inline ktime_t ptp_convert_timestamp (const struct skb_shared_hwtstamps *hwtstamps, +int vclock_index) +{return 0 ; }#endif
net/socket.c +6 -3
@@ -829,6 +829,7 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,int empty =1 , false_tstamp =0 ;struct skb_shared_hwtstamps *shhwtstamps =skb_hwtstamps (skb); +ktime_t hwtstamp;/* Race occurred between timestamp enabling and packet receiving. Fill in the current time for now. */
@@ -877,10 +878,12 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, (sk->sk_tsflags & SOF_TIMESTAMPING_RAW_HARDWARE) && !skb_is_swtx_tstamp(skb, false_tstamp)) {if (sk->sk_tsflags &SOF_TIMESTAMPING_BIND_PHC ) -ptp_convert_timestamp (shhwtstamps, sk->sk_bind_phc); + hwtstamp =ptp_convert_timestamp (shhwtstamps, + sk->sk_bind_phc); +else + hwtstamp = shhwtstamps->hwtstamp; -if (ktime_to_timespec64_cond (shhwtstamps->hwtstamp, - tss.ts +2 )) { +if (ktime_to_timespec64_cond (hwtstamp, tss.ts +2 )) { empty =0 ; if ((sk->sk_tsflags & SOF_TIMESTAMPING_OPT_PKTINFO) &&
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 382/1039 ppp: ensure minimum packet size in ppp_write()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 44073187990d5629804ce0627525f6ea5cfef171 ]
It seems pretty clear ppp layer assumed user space would always be kind to provide enough data in their write() to a ppp device.
This patch makes sure user provides at least 2 bytes.
It adds PPP_PROTO_LEN macro that could replace in net-next many occurrences of hard-coded 2 value.
I replaced only one occurrence to ease backports to stable kernels.
The bug manifests in the following report:
BUG: KMSAN: uninit-value in ppp_send_frame+0x28d/0x27c0 drivers/net/ppp/ppp_generic.c:1740 ppp_send_frame+0x28d/0x27c0 drivers/net/ppp/ppp_generic.c:1740 __ppp_xmit_process+0x23e/0x4b0 drivers/net/ppp/ppp_generic.c:1640 ppp_xmit_process+0x1fe/0x480 drivers/net/ppp/ppp_generic.c:1661 ppp_write+0x5cb/0x5e0 drivers/net/ppp/ppp_generic.c:513 do_iter_write+0xb0c/0x1500 fs/read_write.c:853 vfs_writev fs/read_write.c:924 [inline] do_writev+0x645/0xe00 fs/read_write.c:967 __do_sys_writev fs/read_write.c:1040 [inline] __se_sys_writev fs/read_write.c:1037 [inline] __x64_sys_writev+0xe5/0x120 fs/read_write.c:1037 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x54/0xd0 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x44/0xae
Uninit was created at:
slab_post_alloc_hook mm/slab.h:524 [inline] slab_alloc_node mm/slub.c:3251 [inline] __kmalloc_node_track_caller+0xe0c/0x1510 mm/slub.c:4974 kmalloc_reserve net/core/skbuff.c:354 [inline] __alloc_skb+0x545/0xf90 net/core/skbuff.c:426 alloc_skb include/linux/skbuff.h:1126 [inline] ppp_write+0x11d/0x5e0 drivers/net/ppp/ppp_generic.c:501 do_iter_write+0xb0c/0x1500 fs/read_write.c:853 vfs_writev fs/read_write.c:924 [inline] do_writev+0x645/0xe00 fs/read_write.c:967 __do_sys_writev fs/read_write.c:1040 [inline] __se_sys_writev fs/read_write.c:1037 [inline] __x64_sys_writev+0xe5/0x120 fs/read_write.c:1037 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x54/0xd0 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x44/0xae
--- drivers/net/ppp/ppp_generic.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ppp/ppp_generic.c +6 -1
@@ -69,6 +69,8 @@#define MPHDRLEN 6/* multilink protocol header length */ #define MPHDRLEN_SSN 4/* ditto with short sequence numbers */ +#define PPP_PROTO_LEN 2 +/* * An instance of /dev/ppp can be associated with either a ppp * interface unit or a ppp channel. In both cases, file->private_data
@@ -497,6 +499,9 @@ static ssize_t ppp_write(struct file *file, const char __user *buf,if (!pf)return -ENXIO ; +/* All PPP packets should start with the 2-byte protocol */ +if (count <PPP_PROTO_LEN ) +return -EINVAL ; ret = -ENOMEM ; skb =alloc_skb (count + pf->hdrlen,GFP_KERNEL );if (!skb)
@@ -1764,7 +1769,7 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb) } ++ppp->stats64.tx_packets; - ppp->stats64.tx_bytes += skb->len -2 ; + ppp->stats64.tx_bytes += skb->len -PPP_PROTO_LEN ;switch (proto) {case PPP_IP :
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 383/1039 rocker: fix a sleeping in atomic bug
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 43d012123122cc69feacab55b71369f386c19566 ]
This code is holding the &ofdpa->flow_tbl_lock spinlock so it is not allowed to sleep. That means we have to pass the OFDPA_OP_FLAG_NOWAIT flag to ofdpa_flow_tbl_del().
--- drivers/net/ethernet/rocker/rocker_ofdpa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/rocker/rocker_ofdpa.c +2 -1
@@ -2783,7 +2783,8 @@ static void ofdpa_fib4_abort(struct rocker *rocker)if (!ofdpa_port)continue ; nh->fib_nh_flags &= ~RTNH_F_OFFLOAD ; -ofdpa_flow_tbl_del (ofdpa_port,OFDPA_OP_FLAG_REMOVE , +ofdpa_flow_tbl_del (ofdpa_port, +OFDPA_OP_FLAG_REMOVE |OFDPA_OP_FLAG_NOWAIT , flow_entry); }spin_unlock_irqrestore (&ofdpa->flow_tbl_lock, flags);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 384/1039 staging: greybus: audio: Check null pointer
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 2e81948177d769106754085c3e03534e6cc1f623 ]
As the possible alloc failure of devm_kcalloc(), it could return null pointer.
Therefore, 'strings' should be checked and return NULL if alloc fails to prevent the dereference of the NULL pointer.
Also, the caller should also deal with the return value of the gb_generate_enum_strings() and return -ENOMEM if returns NULL. Moreover, because the memory allocated with devm_kzalloc() will be freed automatically when the last reference to the device is dropped, the 'gbe' in gbaudio_tplg_create_enum_kctl() and gbaudio_tplg_create_enum_ctl() do not need to free manually. But the 'control' in gbaudio_tplg_create_widget() and gbaudio_tplg_process_kcontrols() has a specially error handle to cleanup.
So it should be better to cleanup 'control' when fails.
--- drivers/staging/greybus/audio_topology.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/staging/greybus/audio_topology.c +15 -0
@@ -147,6 +147,9 @@ static const char **gb_generate_enum_strings(struct gbaudio_module_info *gb, items =le32_to_cpu (gbenum->items); strings =devm_kcalloc (gb->dev, items,sizeof (char *),GFP_KERNEL ); +if (!strings) +return NULL ; + data = gbenum->names;for (i =0 ; i < items; i++) {
@@ -655,6 +658,8 @@ static int gbaudio_tplg_create_enum_kctl(struct gbaudio_module_info *gb,/* since count=1, and reg is dummy */ gbe->items =le32_to_cpu (gb_enum->items); gbe->texts =gb_generate_enum_strings (gb, gb_enum); +if (!gbe->texts) +return -ENOMEM ;/* debug enum info */ dev_dbg(gb->dev, "Max:%d, name_length:%d\n", gbe->items,
@@ -862,6 +867,8 @@ static int gbaudio_tplg_create_enum_ctl(struct gbaudio_module_info *gb,/* since count=1, and reg is dummy */ gbe->items =le32_to_cpu (gb_enum->items); gbe->texts =gb_generate_enum_strings (gb, gb_enum); +if (!gbe->texts) +return -ENOMEM ;/* debug enum info */ dev_dbg(gb->dev, "Max:%d, name_length:%d\n", gbe->items,
@@ -1072,6 +1079,10 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module, csize +=le16_to_cpu (gbenum->names_length); control->texts = (const char *const *)gb_generate_enum_strings (module, gbenum); +if (!control->texts) { + ret = -ENOMEM ; + goto error; + } control->items =le32_to_cpu (gbenum->items); }else { csize =sizeof (struct gb_audio_control );
@@ -1181,6 +1192,10 @@ static int gbaudio_tplg_process_kcontrols(struct gbaudio_module_info *module, csize +=le16_to_cpu (gbenum->names_length); control->texts = (const char *const *)gb_generate_enum_strings (module, gbenum); +if (!control->texts) { + ret = -ENOMEM ; + goto error; + } control->items =le32_to_cpu (gbenum->items); }else { csize =sizeof (struct gb_audio_control );
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 385/1039 fsl/fman: Check for null pointer after calling devm_ioremap
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit d5a73ec96cc57cf67e51b12820fc2354e7ca46f8 ]
As the possible failure of the allocation, the devm_ioremap() may return NULL pointer.
Take tgec_initialization() as an example.
If allocation fails, the params->base_addr will be NULL pointer and will be assigned to tgec->regs in tgec_config().
Then it will cause the dereference of NULL pointer in set_mac_address(), which is called by tgec_init().
Therefore, it should be better to add the sanity check after the calling of the devm_ioremap().
--- drivers/net/ethernet/freescale/fman/mac.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
drivers/net/ethernet/freescale/fman/mac.c +16 -5
@@ -94,14 +94,17 @@ static void mac_exception(void *handle, enum fman_mac_exceptions ex) __func__, ex); } -static void set_fman_mac_params (struct mac_device *mac_dev, -struct fman_mac_params *params) +static int set_fman_mac_params (struct mac_device *mac_dev, +struct fman_mac_params *params) {struct mac_priv_s *priv = mac_dev->priv; params->base_addr = (typeof(params->base_addr))devm_ioremap (priv->dev, mac_dev->res->start,resource_size (mac_dev->res)); +if (!params->base_addr) +return -ENOMEM ; +memcpy (¶ms->addr, mac_dev->addr,sizeof (mac_dev->addr)); params->max_speed = priv->max_speed; params->phy_if = mac_dev->phy_if;
@@ -112,6 +115,8 @@ static void set_fman_mac_params(struct mac_device *mac_dev, params->event_cb = mac_exception; params->dev_id = mac_dev; params->internal_phy_node = priv->internal_phy_node; + +return 0 ; }static int tgec_initialization (struct mac_device *mac_dev)
@@ -123,7 +128,9 @@ static int tgec_initialization(struct mac_device *mac_dev) priv = mac_dev->priv; -set_fman_mac_params (mac_dev, ¶ms); + err =set_fman_mac_params (mac_dev, ¶ms); +if (err) + goto _return; mac_dev->fman_mac =tgec_config (¶ms);if (!mac_dev->fman_mac) {
@@ -169,7 +176,9 @@ static int dtsec_initialization(struct mac_device *mac_dev) priv = mac_dev->priv; -set_fman_mac_params (mac_dev, ¶ms); + err =set_fman_mac_params (mac_dev, ¶ms); +if (err) + goto _return; mac_dev->fman_mac =dtsec_config (¶ms);if (!mac_dev->fman_mac) {
@@ -218,7 +227,9 @@ static int memac_initialization(struct mac_device *mac_dev) priv = mac_dev->priv; -set_fman_mac_params (mac_dev, ¶ms); + err =set_fman_mac_params (mac_dev, ¶ms); +if (err) + goto _return;if (priv->max_speed ==SPEED_10000 ) params.phy_if =PHY_INTERFACE_MODE_XGMII ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 386/1039 Bluetooth: hci_bcm: Check for error irq
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit b38cd3b42fba66cc538edb9cf77e07881f43f8e2 ]
For the possible failure of the platform_get_irq(), the returned irq could be error number and will finally cause the failure of the request_irq().
Consider that platform_get_irq() can now in certain cases return -EPROBE_DEFER, and the consequences of letting request_irq() effectively convert that into -EINVAL, even at probe time rather than later on. So it might be better to check just now.
--- drivers/bluetooth/hci_bcm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/bluetooth/hci_bcm.c +6 -1
@@ -1188,7 +1188,12 @@ static int bcm_probe(struct platform_device *pdev)return -ENOMEM ; dev->dev = &pdev->dev; - dev->irq =platform_get_irq (pdev,0 ); + + ret =platform_get_irq (pdev,0 ); +if (ret <0 ) +return ret; + + dev->irq = ret;/* Initialize routing field to an unused value */ dev->pcm_int_params[0 ] =0xff ;
Signature · 1 line
2.34.1