5.19.2-rc1 review
Subsystems (12)
Greg Kroah-Hartman
maintainerPATCH 750/1157 clk: qcom: gcc-msm8939: Add missing system_mm_noc_bfdcd_clk_src
In reply to Greg Kroah-HartmanFrom: Bryan O'Donoghue <[email protected]>
[ Upstream commit dd363e2f7196278e7a30f509a0e8a841cb763b14 ]
The msm8939 has an additional higher operating point for the multi-media peripherals. The higher throughput MM componets operate off of the system-mm noc not the system noc.
system_mm_noc_bfdcd_clk_src is the source clock for the higher frequency capable system noc mm.
Maximum frequency for the MM SNOC is 400 MHz.
--- drivers/clk/qcom/gcc-msm8939.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/clk/qcom/gcc-msm8939.c +13 -0
@@ -644,6 +644,18 @@ static struct clk_rcg2 bimc_ddr_clk_src = { }, }; +static struct clk_rcg2 system_mm_noc_bfdcd_clk_src = { + .cmd_rcgr =0x2600c , + .hid_width =5 , + .parent_map = gcc_xo_gpll0_gpll6a_map, + .clkr.hw.init = &(struct clk_init_data ){ + .name ="system_mm_noc_bfdcd_clk_src" , + .parent_data = gcc_xo_gpll0_gpll6a_parent_data, + .num_parents =3 , + .ops = &clk_rcg2_ops, + }, +}; +static const struct freq_tbl ftbl_gcc_camss_ahb_clk[] = {F (40000000 ,P_GPLL0 ,10 ,1 ,2 ),F (80000000 ,P_GPLL0 ,10 ,0 ,0 ),
@@ -3623,6 +3635,7 @@ static struct clk_regmap *gcc_msm8939_clocks[] = { [GPLL2_VOTE] = &gpll2_vote, [PCNOC_BFDCD_CLK_SRC] = &pcnoc_bfdcd_clk_src.clkr, [SYSTEM_NOC_BFDCD_CLK_SRC] = &system_noc_bfdcd_clk_src.clkr, + [SYSTEM_MM_NOC_BFDCD_CLK_SRC] = &system_mm_noc_bfdcd_clk_src.clkr, [CAMSS_AHB_CLK_SRC] = &camss_ahb_clk_src.clkr, [APSS_AHB_CLK_SRC] = &apss_ahb_clk_src.clkr, [CSI0_CLK_SRC] = &csi0_clk_src.clkr,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 751/1157 clk: qcom: gcc-msm8939: Point MM peripherals to system_mm_noc clock
In reply to Greg Kroah-HartmanFrom: Bryan O'Donoghue <[email protected]>
[ Upstream commit 05eed0990927aa9634682fec58660e30f7b7ae30 ]
Qcom docs indciate the following peripherals operating from System NOC MM not from System NOC clocks.
- MDP
- VFE
- JPEGe
- Venus
Switch over the relevant parent pointers.
--- drivers/clk/qcom/gcc-msm8939.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/clk/qcom/gcc-msm8939.c +8 -8
@@ -2453,7 +2453,7 @@ static struct clk_branch gcc_camss_jpeg_axi_clk = { .hw.init = &(struct clk_init_data){ .name ="gcc_camss_jpeg_axi_clk" , .parent_data = &(const struct clk_parent_data ){ - .hw = &system_noc_bfdcd_clk_src.clkr.hw, + .hw = &system_mm_noc_bfdcd_clk_src.clkr.hw, }, .num_parents =1 , .flags =CLK_SET_RATE_PARENT ,
@@ -2657,7 +2657,7 @@ static struct clk_branch gcc_camss_vfe_axi_clk = { .hw.init = &(struct clk_init_data){ .name ="gcc_camss_vfe_axi_clk" , .parent_data = &(const struct clk_parent_data ){ - .hw = &system_noc_bfdcd_clk_src.clkr.hw, + .hw = &system_mm_noc_bfdcd_clk_src.clkr.hw, }, .num_parents =1 , .flags =CLK_SET_RATE_PARENT ,
@@ -2813,7 +2813,7 @@ static struct clk_branch gcc_mdss_axi_clk = { .hw.init = &(struct clk_init_data){ .name ="gcc_mdss_axi_clk" , .parent_data = &(const struct clk_parent_data ){ - .hw = &system_noc_bfdcd_clk_src.clkr.hw, + .hw = &system_mm_noc_bfdcd_clk_src.clkr.hw, }, .num_parents =1 , .flags =CLK_SET_RATE_PARENT ,
@@ -3205,7 +3205,7 @@ static struct clk_branch gcc_mdp_tbu_clk = { .hw.init = &(struct clk_init_data){ .name ="gcc_mdp_tbu_clk" , .parent_data = &(const struct clk_parent_data ){ - .hw = &system_noc_bfdcd_clk_src.clkr.hw, + .hw = &system_mm_noc_bfdcd_clk_src.clkr.hw, }, .num_parents =1 , .flags =CLK_SET_RATE_PARENT ,
@@ -3223,7 +3223,7 @@ static struct clk_branch gcc_venus_tbu_clk = { .hw.init = &(struct clk_init_data){ .name ="gcc_venus_tbu_clk" , .parent_data = &(const struct clk_parent_data ){ - .hw = &system_noc_bfdcd_clk_src.clkr.hw, + .hw = &system_mm_noc_bfdcd_clk_src.clkr.hw, }, .num_parents =1 , .flags =CLK_SET_RATE_PARENT ,
@@ -3241,7 +3241,7 @@ static struct clk_branch gcc_vfe_tbu_clk = { .hw.init = &(struct clk_init_data){ .name ="gcc_vfe_tbu_clk" , .parent_data = &(const struct clk_parent_data ){ - .hw = &system_noc_bfdcd_clk_src.clkr.hw, + .hw = &system_mm_noc_bfdcd_clk_src.clkr.hw, }, .num_parents =1 , .flags =CLK_SET_RATE_PARENT ,
@@ -3259,7 +3259,7 @@ static struct clk_branch gcc_jpeg_tbu_clk = { .hw.init = &(struct clk_init_data){ .name ="gcc_jpeg_tbu_clk" , .parent_data = &(const struct clk_parent_data ){ - .hw = &system_noc_bfdcd_clk_src.clkr.hw, + .hw = &system_mm_noc_bfdcd_clk_src.clkr.hw, }, .num_parents =1 , .flags =CLK_SET_RATE_PARENT ,
@@ -3496,7 +3496,7 @@ static struct clk_branch gcc_venus0_axi_clk = { .hw.init = &(struct clk_init_data){ .name ="gcc_venus0_axi_clk" , .parent_data = &(const struct clk_parent_data ){ - .hw = &system_noc_bfdcd_clk_src.clkr.hw, + .hw = &system_mm_noc_bfdcd_clk_src.clkr.hw, }, .num_parents =1 , .flags =CLK_SET_RATE_PARENT ,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 752/1157 usb: host: xhci: use snprintf() in xhci_decode_trb()
In reply to Greg Kroah-HartmanFrom: Sergey Shtylyov <[email protected]>
[ Upstream commit 1ce69c35b86038dd11d3a6115a04501c5b89a940 ]
Commit cbf286e8ef83 ("xhci: fix unsafe memory usage in xhci tracing") apparently missed one sprintf() call in xhci_decode_trb() -- replace it with the snprintf() call as well...
Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool.
--- drivers/usb/host/xhci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci.h +1 -1
@@ -2417,7 +2417,7 @@ static inline const char *xhci_decode_trb(char *str, size_t size, field3 & TRB_CYCLE ? 'C' : 'c');break ;case TRB_STOP_RING : - sprintf(str, + snprintf(str, size, "%s: slot %d sp %d ep %d flags %c", xhci_trb_type_string(type), TRB_TO_SLOT_ID(field3),
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 753/1157 RDMA/rxe: Add a responder state for atomic reply
In reply to Greg Kroah-HartmanFrom: Bob Pearson <[email protected]>
[ Upstream commit 0ed5493e430a1d887eb62b45c75dd5d6bb2dcf48 ]
Add a responder state for atomic reply similar to read reply and rename process_atomic() rxe_atomic_reply(). In preparation for merging the normal and retry atomic responder flows.
--- drivers/infiniband/sw/rxe/rxe_resp.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/infiniband/sw/rxe/rxe_resp.c +18 -6
@@ -21,6 +21,7 @@ enum resp_states {RESPST_CHK_RKEY ,RESPST_EXECUTE ,RESPST_READ_REPLY , +RESPST_ATOMIC_REPLY ,RESPST_COMPLETE ,RESPST_ACKNOWLEDGE , RESPST_CLEANUP,
@@ -55,6 +56,7 @@ static char *resp_state_name[] = { [RESPST_CHK_RKEY] = "CHK_RKEY", [RESPST_EXECUTE] = "EXECUTE", [RESPST_READ_REPLY] = "READ_REPLY", + [RESPST_ATOMIC_REPLY] = "ATOMIC_REPLY", [RESPST_COMPLETE] = "COMPLETE", [RESPST_ACKNOWLEDGE] = "ACKNOWLEDGE", [RESPST_CLEANUP] = "CLEANUP",
@@ -552,8 +554,8 @@ static enum resp_states write_data_in(struct rxe_qp *qp,/* Guarantee atomicity of atomic operations at the machine level. */ static DEFINE_SPINLOCK (atomic_ops_lock); -static enum resp_states process_atomic (struct rxe_qp *qp, -struct rxe_pkt_info *pkt) +static enum resp_states rxe_atomic_reply (struct rxe_qp *qp, +struct rxe_pkt_info *pkt) {u64 *vaddr;enum resp_states ret;
@@ -585,7 +587,16 @@ static enum resp_states process_atomic(struct rxe_qp *qp,spin_unlock_bh (&atomic_ops_lock); - ret =RESPST_NONE ; + qp->resp.msn++; + +/* next expected psn, read handles this separately */ + qp->resp.psn = (pkt->psn +1 ) &BTH_PSN_MASK ; + qp->resp.ack_psn = qp->resp.psn; + + qp->resp.opcode = pkt->opcode; + qp->resp.status =IB_WC_SUCCESS ; + + ret =RESPST_ACKNOWLEDGE ; out:return ret; }
@@ -858,9 +869,7 @@ static enum resp_states execute(struct rxe_qp *qp, struct rxe_pkt_info *pkt) qp->resp.msn++;return RESPST_READ_REPLY ; }else if (pkt->mask &RXE_ATOMIC_MASK ) { - err =process_atomic (qp, pkt); -if (err) -return err; +return RESPST_ATOMIC_REPLY ; }else {/* Unreachable */ WARN_ON_ONCE (1 );
@@ -1316,6 +1325,9 @@ int rxe_responder(void *arg)case RESPST_READ_REPLY : state =read_reply (qp, pkt);break ; +case RESPST_ATOMIC_REPLY : + state =rxe_atomic_reply (qp, pkt); +break ;case RESPST_ACKNOWLEDGE : state =acknowledge (qp, pkt);break ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 754/1157 RDMA/rxe: Fix deadlock in rxe_do_local_ops()
In reply to Greg Kroah-HartmanFrom: Bob Pearson <[email protected]>
[ Upstream commit 7cb33d1bc1ac8e51fd88928f96674d392f8e07c4 ]
When a local operation (invalidate mr, reg mr, bind mw) is finished there will be no ack packet coming from a responder to cause the wqe to be completed. This may happen anyway if a subsequent wqe performs IO. Currently if the wqe is signalled the completer tasklet is scheduled immediately but not otherwise.
This leads to a deadlock if the next wqe has the fence bit set in send flags and the operation is not signalled. This patch removes the condition that the wqe must be signalled in order to schedule the completer tasklet which is the simplest fix for this deadlock and is fairly low cost. This is the analog for local operations of always setting the ackreq bit in all last or only request packets even if the operation is not signalled.
--- drivers/infiniband/sw/rxe/rxe_req.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/infiniband/sw/rxe/rxe_req.c +5 -3
@@ -581,9 +581,11 @@ static int rxe_do_local_ops(struct rxe_qp *qp, struct rxe_send_wqe *wqe) wqe->status =IB_WC_SUCCESS ; qp->req.wqe_index =queue_next_index (qp->sq.queue, qp->req.wqe_index); -if ((wqe->wr.send_flags &IB_SEND_SIGNALED ) || - qp->sq_sig_type ==IB_SIGNAL_ALL_WR ) -rxe_run_task (&qp->comp.task,1 ); +/* There is no ack coming for local work requests +* which can lead to a deadlock. So go ahead and complete +* it now. +*/ +rxe_run_task (&qp->comp.task,1 );return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 755/1157 clk: qcom: ipq8074: fix NSS core PLL-s
In reply to Greg Kroah-HartmanFrom: Robert Marko <[email protected]>
[ Upstream commit ca41ec1b30434636c56c5600b24a8d964d359d9c ]
Like in IPQ6018 the NSS related Alpha PLL-s require initial configuration to work.
So, obtain the regmap that is required for the Alpha PLL configuration and thus utilize the qcom_cc_really_probe() as we already have the regmap. Then utilize the Alpha PLL configs from the downstream QCA 5.4 based kernel to configure them.
This fixes the UBI32 and NSS crypto PLL-s failing to get enabled by the kernel.
--- drivers/clk/qcom/gcc-ipq8074.c | 39 +++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-)
drivers/clk/qcom/gcc-ipq8074.c +38 -1
@@ -4371,6 +4371,33 @@ static struct clk_branch gcc_pcie0_axi_s_bridge_clk = { }, }; +static const struct alpha_pll_config ubi32_pll_config = { + .l =0x4e , + .config_ctl_val =0x200d4aa8 , + .config_ctl_hi_val =0x3c2 , + .main_output_mask =BIT (0 ), + .aux_output_mask =BIT (1 ), + .pre_div_val =0x0 , + .pre_div_mask =BIT (12 ), + .post_div_val =0x0 , + .post_div_mask =GENMASK (9 ,8 ), +}; + +static const struct alpha_pll_config nss_crypto_pll_config = { + .l =0x3e , + .alpha =0x0 , + .alpha_hi =0x80 , + .config_ctl_val =0x4001055b , + .main_output_mask =BIT (0 ), + .pre_div_val =0x0 , + .pre_div_mask =GENMASK (14 ,12 ), + .post_div_val =0x1 <<8 , + .post_div_mask =GENMASK (11 ,8 ), + .vco_mask =GENMASK (21 ,20 ), + .vco_val =0x0 , + .alpha_en_mask =BIT (24 ), +}; +static struct clk_hw *gcc_ipq8074_hws[] = { &gpll0_out_main_div2.hw, &gpll6_out_main_div2.hw,
@@ -4772,7 +4799,17 @@ static const struct qcom_cc_desc gcc_ipq8074_desc = {static int gcc_ipq8074_probe (struct platform_device *pdev) { -return qcom_cc_probe (pdev, &gcc_ipq8074_desc); +struct regmap *regmap; + + regmap =qcom_cc_map (pdev, &gcc_ipq8074_desc); +if (IS_ERR (regmap)) +return PTR_ERR (regmap); + +clk_alpha_pll_configure (&ubi32_pll_main, regmap, &ubi32_pll_config); +clk_alpha_pll_configure (&nss_crypto_pll_main, regmap, + &nss_crypto_pll_config); + +return qcom_cc_really_probe (pdev, &gcc_ipq8074_desc, regmap); }static struct platform_driver gcc_ipq8074_driver = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 756/1157 clk: qcom: ipq8074: SW workaround for UBI32 PLL lock
In reply to Greg Kroah-HartmanFrom: Robert Marko <[email protected]>
[ Upstream commit 3401ea2856ef84f39b75f0dc5ebcaeda81cb90ec ]
UBI32 Huayra PLL fails to lock in 5 us in some SoC silicon and thus it will cause the wait_for_pll() to timeout and thus return the error indicating that the PLL failed to lock.
This is bug in Huayra PLL HW for which SW workaround is to set bit 26 of TEST_CTL register.
This is ported from the QCA 5.4 based downstream kernel.
--- drivers/clk/qcom/gcc-ipq8074.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/clk/qcom/gcc-ipq8074.c +3 -0
@@ -4805,6 +4805,9 @@ static int gcc_ipq8074_probe(struct platform_device *pdev)if (IS_ERR (regmap))return PTR_ERR (regmap); +/* SW Workaround for UBI32 Huayra PLL */ +regmap_update_bits (regmap,0x2501c ,BIT (26 ),BIT (26 )); +clk_alpha_pll_configure (&ubi32_pll_main, regmap, &ubi32_pll_config);clk_alpha_pll_configure (&nss_crypto_pll_main, regmap, &nss_crypto_pll_config);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 757/1157 clk: qcom: ipq8074: fix NSS port frequency tables
In reply to Greg Kroah-HartmanFrom: Robert Marko <[email protected]>
[ Upstream commit 0e9e61a2815b5cd34f1b495b2d72e8127ce9b794 ]
NSS port 5 and 6 frequency tables are currently broken and are causing a wide ranges of issue like 1G not working at all on port 6 or port 5 being clocked with 312 instead of 125 MHz as UNIPHY1 gets selected.
So, update the frequency tables with the ones from the downstream QCA 5.4 based kernel which has already fixed this.
--- drivers/clk/qcom/gcc-ipq8074.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/clk/qcom/gcc-ipq8074.c +8 -0
@@ -1788,8 +1788,10 @@ static struct clk_regmap_div nss_port4_tx_div_clk_src = {static const struct freq_tbl ftbl_nss_port5_rx_clk_src[] = {F (19200000 ,P_XO ,1 ,0 ,0 ),F (25000000 ,P_UNIPHY1_RX ,12.5 ,0 ,0 ), +F (25000000 ,P_UNIPHY0_RX ,5 ,0 ,0 ),F (78125000 ,P_UNIPHY1_RX ,4 ,0 ,0 ),F (125000000 ,P_UNIPHY1_RX ,2.5 ,0 ,0 ), +F (125000000 ,P_UNIPHY0_RX ,1 ,0 ,0 ),F (156250000 ,P_UNIPHY1_RX ,2 ,0 ,0 ),F (312500000 ,P_UNIPHY1_RX ,1 ,0 ,0 ), { }
@@ -1828,8 +1830,10 @@ static struct clk_regmap_div nss_port5_rx_div_clk_src = {static const struct freq_tbl ftbl_nss_port5_tx_clk_src[] = {F (19200000 ,P_XO ,1 ,0 ,0 ),F (25000000 ,P_UNIPHY1_TX ,12.5 ,0 ,0 ), +F (25000000 ,P_UNIPHY0_TX ,5 ,0 ,0 ),F (78125000 ,P_UNIPHY1_TX ,4 ,0 ,0 ),F (125000000 ,P_UNIPHY1_TX ,2.5 ,0 ,0 ), +F (125000000 ,P_UNIPHY0_TX ,1 ,0 ,0 ),F (156250000 ,P_UNIPHY1_TX ,2 ,0 ,0 ),F (312500000 ,P_UNIPHY1_TX ,1 ,0 ,0 ), { }
@@ -1867,8 +1871,10 @@ static struct clk_regmap_div nss_port5_tx_div_clk_src = {static const struct freq_tbl ftbl_nss_port6_rx_clk_src[] = {F (19200000 ,P_XO ,1 ,0 ,0 ), +F (25000000 ,P_UNIPHY2_RX ,5 ,0 ,0 ),F (25000000 ,P_UNIPHY2_RX ,12.5 ,0 ,0 ),F (78125000 ,P_UNIPHY2_RX ,4 ,0 ,0 ), +F (125000000 ,P_UNIPHY2_RX ,1 ,0 ,0 ),F (125000000 ,P_UNIPHY2_RX ,2.5 ,0 ,0 ),F (156250000 ,P_UNIPHY2_RX ,2 ,0 ,0 ),F (312500000 ,P_UNIPHY2_RX ,1 ,0 ,0 ),
@@ -1907,8 +1913,10 @@ static struct clk_regmap_div nss_port6_rx_div_clk_src = {static const struct freq_tbl ftbl_nss_port6_tx_clk_src[] = {F (19200000 ,P_XO ,1 ,0 ,0 ), +F (25000000 ,P_UNIPHY2_TX ,5 ,0 ,0 ),F (25000000 ,P_UNIPHY2_TX ,12.5 ,0 ,0 ),F (78125000 ,P_UNIPHY2_TX ,4 ,0 ,0 ), +F (125000000 ,P_UNIPHY2_TX ,1 ,0 ,0 ),F (125000000 ,P_UNIPHY2_TX ,2.5 ,0 ,0 ),F (156250000 ,P_UNIPHY2_TX ,2 ,0 ,0 ),F (312500000 ,P_UNIPHY2_TX ,1 ,0 ,0 ),
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 758/1157 clk: qcom: ipq8074: set BRANCH_HALT_DELAY flag for UBI clocks
In reply to Greg Kroah-HartmanFrom: Robert Marko <[email protected]>
[ Upstream commit 2bd357e698207e2e65db03007e4be65bf9d6a7b3 ]
Currently, attempting to enable the UBI clocks will cause the stuck at off warning to be printed and clk_enable will fail.
[ 14.936694] gcc_ubi1_ahb_clk status stuck at 'off'
Downstream 5.4 QCA kernel has fixed this by seting the BRANCH_HALT_DELAY flag on UBI clocks, so lets do the same.
--- drivers/clk/qcom/gcc-ipq8074.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/clk/qcom/gcc-ipq8074.c +10 -0
@@ -3354,6 +3354,7 @@ static struct clk_branch gcc_nssnoc_ubi1_ahb_clk = {static struct clk_branch gcc_ubi0_ahb_clk = { .halt_reg =0x6820c , + .halt_check =BRANCH_HALT_DELAY , .clkr = { .enable_reg =0x6820c , .enable_mask =BIT (0 ),
@@ -3371,6 +3372,7 @@ static struct clk_branch gcc_ubi0_ahb_clk = {static struct clk_branch gcc_ubi0_axi_clk = { .halt_reg =0x68200 , + .halt_check =BRANCH_HALT_DELAY , .clkr = { .enable_reg =0x68200 , .enable_mask =BIT (0 ),
@@ -3388,6 +3390,7 @@ static struct clk_branch gcc_ubi0_axi_clk = {static struct clk_branch gcc_ubi0_nc_axi_clk = { .halt_reg =0x68204 , + .halt_check =BRANCH_HALT_DELAY , .clkr = { .enable_reg =0x68204 , .enable_mask =BIT (0 ),
@@ -3405,6 +3408,7 @@ static struct clk_branch gcc_ubi0_nc_axi_clk = {static struct clk_branch gcc_ubi0_core_clk = { .halt_reg =0x68210 , + .halt_check =BRANCH_HALT_DELAY , .clkr = { .enable_reg =0x68210 , .enable_mask =BIT (0 ),
@@ -3422,6 +3426,7 @@ static struct clk_branch gcc_ubi0_core_clk = {static struct clk_branch gcc_ubi0_mpt_clk = { .halt_reg =0x68208 , + .halt_check =BRANCH_HALT_DELAY , .clkr = { .enable_reg =0x68208 , .enable_mask =BIT (0 ),
@@ -3439,6 +3444,7 @@ static struct clk_branch gcc_ubi0_mpt_clk = {static struct clk_branch gcc_ubi1_ahb_clk = { .halt_reg =0x6822c , + .halt_check =BRANCH_HALT_DELAY , .clkr = { .enable_reg =0x6822c , .enable_mask =BIT (0 ),
@@ -3456,6 +3462,7 @@ static struct clk_branch gcc_ubi1_ahb_clk = {static struct clk_branch gcc_ubi1_axi_clk = { .halt_reg =0x68220 , + .halt_check =BRANCH_HALT_DELAY , .clkr = { .enable_reg =0x68220 , .enable_mask =BIT (0 ),
@@ -3473,6 +3480,7 @@ static struct clk_branch gcc_ubi1_axi_clk = {static struct clk_branch gcc_ubi1_nc_axi_clk = { .halt_reg =0x68224 , + .halt_check =BRANCH_HALT_DELAY , .clkr = { .enable_reg =0x68224 , .enable_mask =BIT (0 ),
@@ -3490,6 +3498,7 @@ static struct clk_branch gcc_ubi1_nc_axi_clk = {static struct clk_branch gcc_ubi1_core_clk = { .halt_reg =0x68230 , + .halt_check =BRANCH_HALT_DELAY , .clkr = { .enable_reg =0x68230 , .enable_mask =BIT (0 ),
@@ -3507,6 +3516,7 @@ static struct clk_branch gcc_ubi1_core_clk = {static struct clk_branch gcc_ubi1_mpt_clk = { .halt_reg =0x68228 , + .halt_check =BRANCH_HALT_DELAY , .clkr = { .enable_reg =0x68228 , .enable_mask =BIT (0 ),
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 759/1157 clk: qcom: camcc-sdm845: Fix topology around titan_top power domain
In reply to Greg Kroah-HartmanFrom: Vladimir Zapolskiy <[email protected]>
[ Upstream commit 103dd2338bbff567bce7acd00fc5a09c806b38ec ]
On SDM845 two found VFE GDSC power domains shall not be operated, if titan top is turned off, thus the former power domains will be set as subdomains by a GDSC registration routine.
--- drivers/clk/qcom/camcc-sdm845.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/clk/qcom/camcc-sdm845.c +4 -0
@@ -1534,6 +1534,8 @@ static struct clk_branch cam_cc_sys_tmr_clk = { }, }; +static struct gdsc titan_top_gdsc; +static struct gdsc bps_gdsc = { .gdscr =0x6004 , .pd = {
@@ -1567,6 +1569,7 @@ static struct gdsc ife_0_gdsc = { .name = "ife_0_gdsc", }, .flags = POLL_CFG_GDSCR, + .parent = &titan_top_gdsc.pd, .pwrsts = PWRSTS_OFF_ON, };
@@ -1576,6 +1579,7 @@ static struct gdsc ife_1_gdsc = { .name = "ife_1_gdsc", }, .flags = POLL_CFG_GDSCR, + .parent = &titan_top_gdsc.pd, .pwrsts = PWRSTS_OFF_ON, };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 760/1157 clk: qcom: camcc-sm8250: Fix topology around titan_top power domain
In reply to Greg Kroah-HartmanFrom: Vladimir Zapolskiy <[email protected]>
[ Upstream commit f8acf01a6a4f84baf05181e24bd48def4ba23f5b ]
On SM8250 two found VFE GDSC power domains shall not be operated, if titan top is turned off, thus the former power domains will be set as subdomains by a GDSC registration routine.
--- drivers/clk/qcom/camcc-sm8250.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/clk/qcom/camcc-sm8250.c +4 -0
@@ -2205,6 +2205,8 @@ static struct clk_branch cam_cc_sleep_clk = { }, }; +static struct gdsc titan_top_gdsc; +static struct gdsc bps_gdsc = { .gdscr =0x7004 , .pd = {
@@ -2238,6 +2240,7 @@ static struct gdsc ife_0_gdsc = { .name = "ife_0_gdsc", }, .flags = POLL_CFG_GDSCR, + .parent = &titan_top_gdsc.pd, .pwrsts = PWRSTS_OFF_ON, };
@@ -2247,6 +2250,7 @@ static struct gdsc ife_1_gdsc = { .name = "ife_1_gdsc", }, .flags = POLL_CFG_GDSCR, + .parent = &titan_top_gdsc.pd, .pwrsts = PWRSTS_OFF_ON, };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 761/1157 clk: qcom: clk-rcg2: Fail Duty-Cycle configuration if MND divider is not enabled.
In reply to Greg Kroah-HartmanFrom: Nikita Travkin <[email protected]>
[ Upstream commit bdafb609c3bb848d710ad9cd4debd2ee9d6a4049 ]
In cases when MND is not enabled (e.g. when only Half Integer Divider is used), setting D registers makes no effect.
Fail instead of making ineffective write.
--- drivers/clk/qcom/clk-rcg2.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/clk/qcom/clk-rcg2.c +6 -1
@@ -437,7 +437,7 @@ static int clk_rcg2_get_duty_cycle(struct clk_hw *hw, struct clk_duty *duty)static int clk_rcg2_set_duty_cycle (struct clk_hw *hw,struct clk_duty *duty) {struct clk_rcg2 *rcg =to_clk_rcg2 (hw); -u32 notn_m, n, m, d, not2d, mask, duty_per; +u32 notn_m, n, m, d, not2d, mask, duty_per, cfg;int ret;/* Duty-cycle cannot be modified for non-MND RCGs */
@@ -448,6 +448,11 @@ static int clk_rcg2_set_duty_cycle(struct clk_hw *hw, struct clk_duty *duty)regmap_read (rcg->clkr.regmap,RCG_N_OFFSET (rcg), ¬n_m);regmap_read (rcg->clkr.regmap,RCG_M_OFFSET (rcg), &m); +regmap_read (rcg->clkr.regmap,RCG_CFG_OFFSET (rcg), &cfg); + +/* Duty-cycle cannot be modified if MND divider is in bypass mode. */ +if (!(cfg &CFG_MODE_MASK )) +return -EINVAL ; n = (~(notn_m) + m) & mask;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 762/1157 clk: qcom: clk-rcg2: Make sure to not write d=0 to the NMD register
In reply to Greg Kroah-HartmanFrom: Nikita Travkin <[email protected]>
[ Upstream commit d0696770cef35a1fd16ea2167e2198c18aa6fbfe ]
Sometimes calculation of d value may result in 0 because of the rounding after integer division. This causes the following error:
[ 113.969689] camss_gp1_clk_src: rcg didn't update its configuration. [ 113.969754] WARNING: CPU: 3 PID: 35 at drivers/clk/qcom/clk-rcg2.c:122 update_config+0xc8/0xdc
Make sure that D value is never zero.
--- drivers/clk/qcom/clk-rcg2.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/clk/qcom/clk-rcg2.c +6 -3
@@ -13,6 +13,7 @@#include <linux/rational.h> #include <linux/regmap.h> #include <linux/math64.h> +#include <linux/minmax.h> #include <linux/slab.h> #include <asm/div64.h>
@@ -461,9 +462,11 @@ static int clk_rcg2_set_duty_cycle(struct clk_hw *hw, struct clk_duty *duty)/* Calculate 2d value */ d =DIV_ROUND_CLOSEST (n * duty_per *2 ,100 ); -/* Check bit widths of 2d. If D is too big reduce duty cycle. */ -if (d > mask) - d = mask; +/* +* Check bit widths of 2d. If D is too big reduce duty cycle. +* Also make sure it is never zero. +*/ + d =clamp_val (d,1 , mask);if ((d /2 ) > (n - m)) d = (n - m) *2 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 763/1157 kernfs: fix potential NULL dereference in __kernfs_remove
In reply to Greg Kroah-HartmanFrom: Yushan Zhou <[email protected]>
[ Upstream commit 72b5d5aef246a0387cefa23121dd90901c7a691a ]
When lockdep is enabled, lockdep_assert_held_write would cause potential NULL pointer dereference.
Fix the following smatch warnings:
fs/kernfs/dir.c:1353 __kernfs_remove() warn: variable dereferenced before check 'kn' (see line 1346)
--- fs/kernfs/dir.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/kernfs/dir.c +5 -2
@@ -1343,14 +1343,17 @@ static void __kernfs_remove(struct kernfs_node *kn) {struct kernfs_node *pos; +/* Short-circuit if non-root @kn has already finished removal. */ +if (!kn) +return ; +lockdep_assert_held_write (&kernfs_root (kn)->kernfs_rwsem);/* -* Short-circuit if non-root @kn has already finished removal. * This is for kernfs_remove_self() which plays with active ref * after removal. */ -if (!kn || (kn->parent &&RB_EMPTY_NODE (&kn->rb))) +if (kn->parent &&RB_EMPTY_NODE (&kn->rb))return ;pr_debug ("kernfs %s: removing\n" , kn->name);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 764/1157 mm: rmap: use the correct parameter name for DEFINE_PAGE_VMA_WALK
In reply to Greg Kroah-HartmanFrom: Yang Shi <[email protected]>
[ Upstream commit 507db7927cd181d409dd495c8384b8e14c21c600 ]
The parameter used by DEFINE_PAGE_VMA_WALK is _page not page, fix the parameter name. It didn't cause any build error, it is probably because the only caller is write_protect_page() from ksm.c, which pass in page.
--- include/linux/rmap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/rmap.h +2 -2
@@ -325,8 +325,8 @@ struct page_vma_mapped_walk {#define DEFINE_PAGE_VMA_WALK (name, _page, _vma, _address, _flags) \ struct page_vma_mapped_walk name = { \ .pfn = page_to_pfn(_page), \ - .nr_pages = compound_nr(page), \ - .pgoff = page_to_pgoff(page), \ + .nr_pages = compound_nr(_page), \ + .pgoff = page_to_pgoff(_page), \ .vma = _vma, \ .address = _address, \ .flags = _flags, \
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 765/1157 mm/migration: return errno when isolate_huge_page failed
In reply to Greg Kroah-HartmanFrom: Miaohe Lin <[email protected]>
[ Upstream commit 7ce82f4c3f3ead13a9d9498768e3b1a79975c4d8 ]
We might fail to isolate huge page due to e.g. the page is under migration which cleared HPageMigratable. We should return errno in this case rather than always return 1 which could confuse the user, i.e. the caller might think all of the memory is migrated while the hugetlb page is left behind. We make the prototype of isolate_huge_page consistent with isolate_lru_page as suggested by Huang Ying and rename isolate_huge_page to isolate_hugetlb as suggested by Muchun to improve the readability.
--- include/linux/hugetlb.h | 6 +++--- mm/gup.c | 2 +- mm/hugetlb.c | 11 +++++------ mm/memory-failure.c | 2 +- mm/memory_hotplug.c | 2 +- mm/mempolicy.c | 2 +- mm/migrate.c | 7 ++++--- 7 files changed, 16 insertions(+), 16 deletions(-)
include/linux/hugetlb.h +3 -3
@@ -170,7 +170,7 @@ bool hugetlb_reserve_pages(struct inode *inode, long from, long to, vm_flags_t vm_flags);long hugetlb_unreserve_pages (struct inode *inode,long start,long end,long freed); -bool isolate_huge_page (struct page *page,struct list_head *list); +int isolate_hugetlb (struct page *page,struct list_head *list);int get_hwpoison_huge_page (struct page *page,bool *hugetlb);int get_huge_page_for_hwpoison (unsigned long pfn,int flags);void putback_active_hugepage (struct page *page);
@@ -376,9 +376,9 @@ static inline pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr,return NULL ; } -static inline bool isolate_huge_page (struct page *page,struct list_head *list) +static inline int isolate_hugetlb (struct page *page,struct list_head *list) { -return false; +return -EBUSY ; }static inline int get_hwpoison_huge_page (struct page *page,bool *hugetlb)
mm/gup.c +1 -1
@@ -1900,7 +1900,7 @@ static long check_and_migrate_movable_pages(unsigned long nr_pages,* Try to move out any movable page before pinning the range. */ if (folio_test_hugetlb (folio)) { -if (!isolate_huge_page (&folio->page, +if (isolate_hugetlb (&folio->page, &movable_page_list)) isolation_error_count++;continue ;
mm/hugetlb.c +5 -6
@@ -2766,8 +2766,7 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page,* Fail with -EBUSY if not possible. */ spin_unlock_irq (&hugetlb_lock); -if (!isolate_huge_page (old_page, list)) - ret = -EBUSY ; + ret =isolate_hugetlb (old_page, list);spin_lock_irq (&hugetlb_lock); goto free_new; }else if (!HPageFreed (old_page)) {
@@ -2843,7 +2842,7 @@ int isolate_or_dissolve_huge_page(struct page *page, struct list_head *list)if (hstate_is_gigantic (h))return -ENOMEM ; -if (page_count (head) &&isolate_huge_page (head, list)) +if (page_count (head) && !isolate_hugetlb (head, list)) ret =0 ;else if (!page_count (head)) ret =alloc_and_dissolve_huge_page (h, head, list);
@@ -6966,15 +6965,15 @@ follow_huge_pgd(struct mm_struct *mm, unsigned long address, pgd_t *pgd, int flareturn pte_page (*(pte_t *)pgd) + ((address & ~PGDIR_MASK ) >>PAGE_SHIFT ); } -bool isolate_huge_page (struct page *page,struct list_head *list) +int isolate_hugetlb (struct page *page,struct list_head *list) { -bool ret = true; +int ret =0 ;spin_lock_irq (&hugetlb_lock);if (!PageHeadHuge (page) || !HPageMigratable (page) || !get_page_unless_zero (page)) { - ret = false; + ret = -EBUSY ; goto unlock; }ClearHPageMigratable (page);
mm/memory-failure.c +1 -1
@@ -2178,7 +2178,7 @@ static bool isolate_page(struct page *page, struct list_head *pagelist)bool lru =PageLRU (page);if (PageHuge (page)) { - isolated =isolate_huge_page (page, pagelist); + isolated = !isolate_hugetlb (page, pagelist); }else {if (lru) isolated = !isolate_lru_page (page);
mm/memory_hotplug.c +1 -1
@@ -1643,7 +1643,7 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)if (PageHuge (page)) { pfn =page_to_pfn (head) +compound_nr (head) -1 ; -isolate_huge_page (head, &source); +isolate_hugetlb (head, &source);continue ; }else if (PageTransHuge (page)) pfn =page_to_pfn (head) +thp_nr_pages (page) -1 ;
mm/mempolicy.c +1 -1
@@ -602,7 +602,7 @@ static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask,/* With MPOL_MF_MOVE, we migrate only unshared hugepage. */ if (flags & (MPOL_MF_MOVE_ALL ) || (flags &MPOL_MF_MOVE &&page_mapcount (page) ==1 )) { -if (!isolate_huge_page (page, qp->pagelist) && +if (isolate_hugetlb (page, qp->pagelist) && (flags &MPOL_MF_STRICT ))/* * Failed to isolate page but allow migrating pages
mm/migrate.c +4 -3
@@ -133,7 +133,7 @@ static void putback_movable_page(struct page *page)* * This function shall be used whenever the isolated pageset has been * built from lru, balloon, hugetlbfs page. See isolate_migratepages_range() -* and isolate_huge_page(). +* and isolate_hugetlb(). */ void putback_movable_pages (struct list_head *l) {
@@ -1633,8 +1633,9 @@ static int add_page_for_migration(struct mm_struct *mm, unsigned long addr,if (PageHuge (page)) {if (PageHead (page)) { -isolate_huge_page (page, pagelist); - err =1 ; + err =isolate_hugetlb (page, pagelist); +if (!err) + err =1 ; } }else {struct page *head;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 766/1157 mm/migration: fix potential pte_unmap on an not mapped pte
In reply to Greg Kroah-HartmanFrom: Miaohe Lin <[email protected]>
[ Upstream commit ad1ac596e8a8c4b06715dfbd89853eb73c9886b2 ]
__migration_entry_wait and migration_entry_wait_on_locked assume pte is always mapped from caller. But this is not the case when it's called from migration_entry_wait_huge and follow_huge_pmd. Add a hugetlbfs variant that calls hugetlb_migration_entry_wait(ptep == NULL) to fix this issue.
--- include/linux/swapops.h | 12 ++++++++---- mm/hugetlb.c | 4 ++-- mm/migrate.c | 23 +++++++++++++++++++---- 3 files changed, 29 insertions(+), 10 deletions(-)
include/linux/swapops.h +8 -4
@@ -244,8 +244,10 @@ extern void __migration_entry_wait(struct mm_struct *mm, pte_t *ptep, spinlock_t *ptl);extern void migration_entry_wait (struct mm_struct *mm,pmd_t *pmd,unsigned long address); -extern void migration_entry_wait_huge (struct vm_area_struct *vma, -struct mm_struct *mm,pte_t *pte); +#ifdef CONFIG_HUGETLB_PAGE +extern void __migration_entry_wait_huge (pte_t *ptep,spinlock_t *ptl); +extern void migration_entry_wait_huge (struct vm_area_struct *vma,pte_t *pte); +#endif #else static inline swp_entry_t make_readable_migration_entry (pgoff_t offset) {
@@ -271,8 +273,10 @@ static inline void __migration_entry_wait(struct mm_struct *mm, pte_t *ptep, spinlock_t *ptl) { }static inline void migration_entry_wait (struct mm_struct *mm,pmd_t *pmd,unsigned long address) { } -static inline void migration_entry_wait_huge (struct vm_area_struct *vma, -struct mm_struct *mm,pte_t *pte) { } +#ifdef CONFIG_HUGETLB_PAGE +static inline void __migration_entry_wait_huge (pte_t *ptep,spinlock_t *ptl) { } +static inline void migration_entry_wait_huge (struct vm_area_struct *vma,pte_t *pte) { } +#endif static inline int is_writable_migration_entry (swp_entry_t entry) {return 0 ;
mm/hugetlb.c +2 -2
@@ -5707,7 +5707,7 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,*/ entry =huge_ptep_get (ptep);if (unlikely (is_hugetlb_entry_migration (entry))) { -migration_entry_wait_huge (vma, mm, ptep); +migration_entry_wait_huge (vma, ptep);return 0 ; }else if (unlikely (is_hugetlb_entry_hwpoisoned (entry))) return VM_FAULT_HWPOISON_LARGE |
@@ -6933,7 +6933,7 @@ follow_huge_pmd(struct mm_struct *mm, unsigned long address, }else {if (is_hugetlb_entry_migration (pte)) {spin_unlock (ptl); -__migration_entry_wait (mm, (pte_t *)pmd, ptl); +__migration_entry_wait_huge ((pte_t *)pmd, ptl); goto retry; }/*
mm/migrate.c +19 -4
@@ -315,13 +315,28 @@ void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd,__migration_entry_wait (mm, ptep, ptl); } -void migration_entry_wait_huge (struct vm_area_struct *vma, -struct mm_struct *mm,pte_t *pte) +#ifdef CONFIG_HUGETLB_PAGE +void __migration_entry_wait_huge (pte_t *ptep,spinlock_t *ptl) { -spinlock_t *ptl =huge_pte_lockptr (hstate_vma (vma), mm, pte); -__migration_entry_wait (mm, pte, ptl); +pte_t pte; + +spin_lock (ptl); + pte =huge_ptep_get (ptep); + +if (unlikely (!is_hugetlb_entry_migration (pte))) +spin_unlock (ptl); +else +migration_entry_wait_on_locked (pte_to_swp_entry (pte),NULL , ptl); } +void migration_entry_wait_huge (struct vm_area_struct *vma,pte_t *pte) +{ +spinlock_t *ptl =huge_pte_lockptr (hstate_vma (vma), vma->vm_mm, pte); + +__migration_entry_wait_huge (pte, ptl); +} +#endif +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION void pmd_migration_entry_wait (struct mm_struct *mm,pmd_t *pmd) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 767/1157 kasan: fix zeroing vmalloc memory with HW_TAGS
In reply to Greg Kroah-HartmanFrom: Andrey Konovalov <[email protected]>
[ Upstream commit 6c2f761dad7851d8088b91063ccaea3c970efe78 ]
HW_TAGS KASAN skips zeroing page_alloc allocations backing vmalloc mappings via __GFP_SKIP_ZERO. Instead, these pages are zeroed via kasan_unpoison_vmalloc() by passing the KASAN_VMALLOC_INIT flag.
The problem is that __kasan_unpoison_vmalloc() does not zero pages when either kasan_vmalloc_enabled() or is_vmalloc_or_module_addr() fail.
Thus:
1. Change __vmalloc_node_range() to only set KASAN_VMALLOC_INIT when __GFP_SKIP_ZERO is set.
2. Change __kasan_unpoison_vmalloc() to always zero pages when the KASAN_VMALLOC_INIT flag is set.
3. Add WARN_ON() asserts to check that KASAN_VMALLOC_INIT cannot be set in other early return paths of __kasan_unpoison_vmalloc().
Also clean up the comment in __kasan_unpoison_vmalloc.
--- mm/kasan/hw_tags.c | 32 +++++++++++++++++++++++--------- mm/vmalloc.c | 10 +++++----- 2 files changed, 28 insertions(+), 14 deletions(-)
mm/kasan/hw_tags.c +23 -9
@@ -257,27 +257,37 @@ static void unpoison_vmalloc_pages(const void *addr, u8 tag) } } +static void init_vmalloc_pages (const void *start,unsigned long size) +{ +const void *addr; + +for (addr = start; addr < start + size; addr +=PAGE_SIZE ) { +struct page *page =virt_to_page (addr); + +clear_highpage_kasan_tagged (page); + } +} +void *__kasan_unpoison_vmalloc (const void *start,unsigned long size,kasan_vmalloc_flags_t flags) {u8 tag;unsigned long redzone_start, redzone_size; -if (!kasan_vmalloc_enabled ()) -return (void *)start; - -if (!is_vmalloc_or_module_addr (start)) +if (!kasan_vmalloc_enabled () || !is_vmalloc_or_module_addr (start)) { +if (flags &KASAN_VMALLOC_INIT ) +init_vmalloc_pages (start, size);return (void *)start; + }/* -* Skip unpoisoning and assigning a pointer tag for non-VM_ALLOC -* mappings as: +* Don't tag non-VM_ALLOC mappings, as: * * 1. Unlike the software KASAN modes, hardware tag-based KASAN only * supports tagging physical memory. Therefore, it can only tag a * single mapping of normal physical pages. * 2. Hardware tag-based KASAN can only tag memory mapped with special -* mapping protection bits, see arch_vmalloc_pgprot_modify(). +* mapping protection bits, see arch_vmap_pgprot_tagged(). * As non-VM_ALLOC mappings can be mapped outside of vmalloc code, * providing these bits would require tracking all non-VM_ALLOC * mappers.
@@ -289,15 +299,19 @@ void *__kasan_unpoison_vmalloc(const void *start, unsigned long size,* * For non-VM_ALLOC allocations, page_alloc memory is tagged as usual. */ -if (!(flags &KASAN_VMALLOC_VM_ALLOC )) +if (!(flags &KASAN_VMALLOC_VM_ALLOC )) { +WARN_ON (flags &KASAN_VMALLOC_INIT );return (void *)start; + }/* * Don't tag executable memory. * The kernel doesn't tolerate having the PC register tagged. */ -if (!(flags &KASAN_VMALLOC_PROT_NORMAL )) +if (!(flags &KASAN_VMALLOC_PROT_NORMAL )) { +WARN_ON (flags &KASAN_VMALLOC_INIT );return (void *)start; + } tag =kasan_random_tag (); start =set_tag (start, tag);
mm/vmalloc.c +5 -5
@@ -3168,15 +3168,15 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,/* * Mark the pages as accessible, now that they are mapped. -* The init condition should match the one in post_alloc_hook() -* (except for the should_skip_init() check) to make sure that memory -* is initialized under the same conditions regardless of the enabled -* KASAN mode. +* The condition for setting KASAN_VMALLOC_INIT should complement the +* one in post_alloc_hook() with regards to the __GFP_SKIP_ZERO check +* to make sure that memory is initialized under the same conditions. * Tag-based KASAN modes only assign tags to normal non-executable * allocations, see __kasan_unpoison_vmalloc(). */ kasan_flags |=KASAN_VMALLOC_VM_ALLOC ; -if (!want_init_on_free () &&want_init_on_alloc (gfp_mask)) +if (!want_init_on_free () &&want_init_on_alloc (gfp_mask) && + (gfp_mask & __GFP_SKIP_ZERO)) kasan_flags |=KASAN_VMALLOC_INIT ;/* KASAN_VMALLOC_PROT_NORMAL already set if required. */ area->addr =kasan_unpoison_vmalloc (area->addr, real_size, kasan_flags);
Signature · 1 line
2.35.1
Re: [PATCH 5.19 0767/1157] kasan: fix zeroing vmalloc memory with HW_TAGS
Quoted 44 lines · Greg Kroah-Hartman
From: Andrey Konovalov <[email protected]>
[ Upstream commit
6c2f761dad7851d8088b91063ccaea3c970efe78]
HW_TAGSKASAN skips zeroingpage_allocallocations backing vmalloc mappings via__GFP_SKIP_ZERO. Instead, these pages are zeroed viakasan_unpoison_vmalloc()by passing theKASAN_VMALLOC_INITflag.The problem is that
__kasan_unpoison_vmalloc()does not zero pages when eitherkasan_vmalloc_enabled()oris_vmalloc_or_module_addr()fail.Thus:
1. Change
__vmalloc_node_range()to only setKASAN_VMALLOC_INITwhen__GFP_SKIP_ZEROis set.2. Change
__kasan_unpoison_vmalloc()to always zero pages when theKASAN_VMALLOC_INITflag is set.3. Add
WARN_ON()asserts to check thatKASAN_VMALLOC_INITcannot be set in other early return paths of__kasan_unpoison_vmalloc().Also clean up the comment in
__kasan_unpoison_vmalloc.Link https://lkml.kernel.org/r/4bc503537efdc539ffc3f461c1b70162eea31cf6.1654798516.git.andreyknvl@google.com open hereFixes 23689e91fb22 ("kasan, vmalloc: add vmalloc tagging for HW_TAGS")Signed-off-by Andrey Konovalov <[email protected]>Cc Marco Elver <[email protected]>Cc Alexander Potapenko <[email protected]>Cc Dmitry Vyukov <[email protected]>Cc Andrey Ryabinin <[email protected]>Signed-off-by Andrew Morton <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- mm/kasan/hw_tags.c | 32 +++++++++++++++++++++++--------- mm/vmalloc.c | 10 +++++----- 2 files changed, 28 insertions(+), 14 deletions(-)mm/kasan/hw_tags.c +0
-0@@ -257,27 +257,37 @@ static void unpoison_vmalloc_pages(const void *addr, u8 tag) }
mm/kasan/hw_tags.c static void unpoison_vmalloc_pages(const void *addr, u8 tag) · line 267
Quoted 10 lines
mm/kasan/hw_tags.c +8
-0} +static void init_vmalloc_pages (const void *start,unsigned long size) +{ +const void *addr; + +for (addr = start; addr < start + size; addr +=PAGE_SIZE ) { +struct page *page =virt_to_page (addr); + +clear_highpage_kasan_tagged (page);
This breaks build on aarch64:
Quoted 85 lines
mm/kasan/hw_tags.c: In function 'init_vmalloc_pages':mm/kasan/hw_tags.c:267:17: error: implicit declaration of function 'clear_highpage_kasan_tagged' [-Werror=implicit-function-declaration]mm/kasan/hw_tags.c +15
-9+ } +} +void *__kasan_unpoison_vmalloc (const void *start,unsigned long size,kasan_vmalloc_flags_t flags) {u8 tag;unsigned long redzone_start, redzone_size; -if (!kasan_vmalloc_enabled ()) -return (void *)start; - -if (!is_vmalloc_or_module_addr (start)) +if (!kasan_vmalloc_enabled () || !is_vmalloc_or_module_addr (start)) { +if (flags &KASAN_VMALLOC_INIT ) +init_vmalloc_pages (start, size);return (void *)start; + }/* -* Skip unpoisoning and assigning a pointer tag for non-VM_ALLOC -* mappings as: +* Don't tag non-VM_ALLOC mappings, as: * * 1. Unlike the software KASAN modes, hardware tag-based KASAN only * supports tagging physical memory. Therefore, it can only tag a * single mapping of normal physical pages. * 2. Hardware tag-based KASAN can only tag memory mapped with special -* mapping protection bits, see arch_vmalloc_pgprot_modify(). +* mapping protection bits, see arch_vmap_pgprot_tagged(). * As non-VM_ALLOC mappings can be mapped outside of vmalloc code, * providing these bits would require tracking all non-VM_ALLOC * mappers. @@ -289,15 +299,19 @@ void *__kasan_unpoison_vmalloc(const void *start, unsigned long size,* * For non-VM_ALLOC allocations, page_alloc memory is tagged as usual. */ -if (!(flags &KASAN_VMALLOC_VM_ALLOC )) +if (!(flags &KASAN_VMALLOC_VM_ALLOC )) { +WARN_ON (flags &KASAN_VMALLOC_INIT );return (void *)start; + }/* * Don't tag executable memory. * The kernel doesn't tolerate having the PC register tagged. */ -if (!(flags &KASAN_VMALLOC_PROT_NORMAL )) +if (!(flags &KASAN_VMALLOC_PROT_NORMAL )) { +WARN_ON (flags &KASAN_VMALLOC_INIT );return (void *)start; + } tag =kasan_random_tag (); start =set_tag (start, tag);mm/vmalloc.c +5
-5@@ -3168,15 +3168,15 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,/* * Mark the pages as accessible, now that they are mapped. -* The init condition should match the one in post_alloc_hook() -* (except for the should_skip_init() check) to make sure that memory -* is initialized under the same conditions regardless of the enabled -* KASAN mode. +* The condition for setting KASAN_VMALLOC_INIT should complement the +* one in post_alloc_hook() with regards to the __GFP_SKIP_ZERO check +* to make sure that memory is initialized under the same conditions. * Tag-based KASAN modes only assign tags to normal non-executable * allocations, see __kasan_unpoison_vmalloc(). */ kasan_flags |=KASAN_VMALLOC_VM_ALLOC ; -if (!want_init_on_free () &&want_init_on_alloc (gfp_mask)) +if (!want_init_on_free () &&want_init_on_alloc (gfp_mask) && + (gfp_mask & __GFP_SKIP_ZERO)) kasan_flags |=KASAN_VMALLOC_INIT ;/* KASAN_VMALLOC_PROT_NORMAL already set if required. */ area->addr =kasan_unpoison_vmalloc (area->addr, real_size, kasan_flags);
Signature · 2 lines
js suse labs
Re: [PATCH 5.19 0767/1157] kasan: fix zeroing vmalloc memory with HW_TAGS
Quoted 49 lines · Jiri Slaby
Quoted 48 lines · Greg Kroah-Hartman
From: Andrey Konovalov <[email protected]>
[ Upstream commit
6c2f761dad7851d8088b91063ccaea3c970efe78]
HW_TAGSKASAN skips zeroingpage_allocallocations backing vmalloc mappings via __GFP_SKIP_ZERO. Instead, these pages are zeroed viakasan_unpoison_vmalloc()by passing theKASAN_VMALLOC_INITflag.The problem is that
__kasan_unpoison_vmalloc()does not zero pages when eitherkasan_vmalloc_enabled()oris_vmalloc_or_module_addr()fail.Thus:
1. Change
__vmalloc_node_range()to only setKASAN_VMALLOC_INITwhen__GFP_SKIP_ZEROis set.2. Change
__kasan_unpoison_vmalloc()to always zero pages when theKASAN_VMALLOC_INITflag is set.3. Add
WARN_ON()asserts to check thatKASAN_VMALLOC_INITcannot be set in other early return paths of__kasan_unpoison_vmalloc().Also clean up the comment in
__kasan_unpoison_vmalloc.Link https://lkml.kernel.org/r/4bc503537efdc539ffc3f461c1b70162eea31cf6.1654798516.git.andreyknvl@google.com open hereFixes 23689e91fb22 ("kasan, vmalloc: add vmalloc tagging for HW_TAGS")Signed-off-by Andrey Konovalov <[email protected]>Cc Marco Elver <[email protected]>Cc Alexander Potapenko <[email protected]>Cc Dmitry Vyukov <[email protected]>Cc Andrey Ryabinin <[email protected]>Signed-off-by Andrew Morton <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
mm/kasan/hw_tags.c| 32 +++++++++++++++++++++++--------- mm/vmalloc.c | 10 +++++-----2 files changed, 28 insertions(+), 14 deletions(-)mm/kasan/hw_tags.c +2
-0@@ -257,27 +257,37 @@ static void unpoison_vmalloc_pages(const void *addr, u8 tag) } } +static void init_vmalloc_pages (const void *start,unsigned long size) +{
Quoted 10 lines
mm/kasan/hw_tags.c static void unpoison_vmalloc_pages(const void *addr, u8 tag) · line 267
Quoted 6 lines
mm/kasan/hw_tags.c +6
-0+ const void *addr; + + for (addr = start; addr < start + size; addr += PAGE_SIZE) { + struct page *page = virt_to_page(addr); + + clear_highpage_kasan_tagged(page);This breaks build on aarch64:
Quoted 2 lines
mm/kasan/hw_tags.c: In function 'init_vmalloc_pages':mm/kasan/hw_tags.c:267:17: error: implicit declaration of function 'clear_highpage_kasan_tagged' [-Werror=implicit-function-declaration]
Which translates into: this is missing:
commit d9da8f6cf55eeca642c021912af1890002464c64
Author: Andrey Konovalov <[email protected]> Date: Thu Jun 9 20:18:46 2022 +0200
mm: introduce clear_highpage_kasan_tagged
Quoted 83 lines
Quoted 82 lines
+ }
mm/kasan/hw_tags.c +2
-0+} +void *__kasan_unpoison_vmalloc(const void *start, unsigned long size,
kasan_vmalloc_flags_tflags)
{
u8 tag;
unsigned longredzone_start,redzone_size;
- if (!kasan_vmalloc_enabled())
- return (void *)start;
-
- if (!is_vmalloc_or_module_addr(start))
+ if (!kasan_vmalloc_enabled() || !is_vmalloc_or_module_addr(start)) { + if (flags &KASAN_VMALLOC_INIT)
+init_vmalloc_pages(start, size);
return (void *)start;
+ }
/*
- * Skip unpoisoning and assigning a pointer tag for non-VM_ALLOC - * mappings as:
+ * Don't tag non-VM_ALLOC mappings, as:
*
* 1. Unlike the software KASAN modes, hardware tag-based KASAN only * supports tagging physical memory. Therefore, it can only tag a * single mapping of normal physical pages.
* 2. Hardware tag-based KASAN can only tag memory mapped with special - * mapping protection bits, seearch_vmalloc_pgprot_modify(). + * mapping protection bits, seearch_vmap_pgprot_tagged(). * As non-VM_ALLOC mappings can be mapped outside of vmalloc code, * providing these bits would require tracking all non-VM_ALLOC * mappers.mm/kasan/hw_tags.c +6
-2@@ -289,15 +299,19 @@ void *__kasan_unpoison_vmalloc(const void*start, unsigned long size, * * For non-VM_ALLOC allocations, page_alloc memory is tagged as usual. */ - if (!(flags & KASAN_VMALLOC_VM_ALLOC)) + if (!(flags & KASAN_VMALLOC_VM_ALLOC)) { + WARN_ON(flags & KASAN_VMALLOC_INIT); return (void *)start; + } /* * Don't tag executable memory. * The kernel doesn't tolerate having the PC register tagged. */ - if (!(flags & KASAN_VMALLOC_PROT_NORMAL)) + if (!(flags & KASAN_VMALLOC_PROT_NORMAL)) { + WARN_ON(flags & KASAN_VMALLOC_INIT); return (void *)start; + } tag = kasan_random_tag(); start = set_tag(start, tag);mm/vmalloc.c +0
-2@@ -3168,15 +3168,15 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, /** Mark the pages as accessible, now that they are mapped. -* The init condition should match the one in post_alloc_hook() -* (except for the should_skip_init() check) to make sure that memory
- * is initialized under the same conditions regardless of the enabled
- * KASAN mode.
+ * The condition for settingKASAN_VMALLOC_INITshould complement the
+ * one inpost_alloc_hook()with regards to the__GFP_SKIP_ZEROcheck
+ * to make sure that memory is initialized under the same conditions.
* Tag-based KASAN modes only assign tags to normal non-executable
* allocations, see__kasan_unpoison_vmalloc().
*/
kasan_flags|=KASAN_VMALLOC_VM_ALLOC;
- if (!want_init_on_free() &&want_init_on_alloc(gfp_mask))
+ if (!want_init_on_free() &&want_init_on_alloc(gfp_mask)&& + (gfp_mask&__GFP_SKIP_ZERO))
kasan_flags|=KASAN_VMALLOC_INIT;
/*KASAN_VMALLOC_PROT_NORMALalready set if required. */area->addr=kasan_unpoison_vmalloc(area->addr, real_size, kasan_flags);
Signature · 2 lines
js suse labs
Greg Kroah-Hartman
maintainerRe: [PATCH 5.19 0767/1157] kasan: fix zeroing vmalloc memory with HW_TAGS
Quoted 63 lines · Jiri Slaby
Quoted 49 lines · Jiri Slaby
Quoted 48 lines · Greg Kroah-Hartman
From: Andrey Konovalov <[email protected]>
[ Upstream commit
6c2f761dad7851d8088b91063ccaea3c970efe78]
HW_TAGSKASAN skips zeroingpage_allocallocations backing vmalloc mappings via __GFP_SKIP_ZERO. Instead, these pages are zeroed viakasan_unpoison_vmalloc()by passing theKASAN_VMALLOC_INITflag.The problem is that
__kasan_unpoison_vmalloc()does not zero pages when eitherkasan_vmalloc_enabled()oris_vmalloc_or_module_addr()fail.Thus:
1. Change
__vmalloc_node_range()to only setKASAN_VMALLOC_INITwhen__GFP_SKIP_ZEROis set.2. Change
__kasan_unpoison_vmalloc()to always zero pages when theKASAN_VMALLOC_INITflag is set.3. Add
WARN_ON()asserts to check thatKASAN_VMALLOC_INITcannot be set in other early return paths of__kasan_unpoison_vmalloc().Also clean up the comment in
__kasan_unpoison_vmalloc.Link https://lkml.kernel.org/r/4bc503537efdc539ffc3f461c1b70162eea31cf6.1654798516.git.andreyknvl@google.com open hereFixes 23689e91fb22 ("kasan, vmalloc: add vmalloc tagging for HW_TAGS")Signed-off-by Andrey Konovalov <[email protected]>Cc Marco Elver <[email protected]>Cc Alexander Potapenko <[email protected]>Cc Dmitry Vyukov <[email protected]>Cc Andrey Ryabinin <[email protected]>Signed-off-by Andrew Morton <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
mm/kasan/hw_tags.c| 32 +++++++++++++++++++++++--------- mm/vmalloc.c | 10 +++++-----2 files changed, 28 insertions(+), 14 deletions(-)mm/kasan/hw_tags.c +2
-0@@ -257,27 +257,37 @@ static void unpoison_vmalloc_pages(const void *addr, u8 tag) } } +static void init_vmalloc_pages (const void *start,unsigned long size) +{Quoted 12 lines
mm/kasan/hw_tags.c static void unpoison_vmalloc_pages(const void *addr, u8 tag) · line 267
Quoted 6 lines
mm/kasan/hw_tags.c +6
-0+ const void *addr; + + for (addr = start; addr < start + size; addr += PAGE_SIZE) { + struct page *page = virt_to_page(addr); + + clear_highpage_kasan_tagged(page);This breaks build on aarch64:
Quoted 4 lines
mm/kasan/hw_tags.c: In function 'init_vmalloc_pages':mm/kasan/hw_tags.c:267:17: error: implicit declaration of function 'clear_highpage_kasan_tagged' [-Werror=implicit-function-declaration]
Quoted 6 lines
Which translates into: this is missing:
commitd9da8f6cf55eeca642c021912af1890002464c64Author: Andrey Konovalov <[email protected]> Date: Thu Jun 9 20:18:46 2022 +0200mm: introduce
clear_highpage_kasan_tagged
Thanks, now added to both 5.18.y and 5.19.y. I'll push out some -rc2 releases with this in it so it can get some testing.
greg k-h
Greg Kroah-Hartman
maintainerPATCH 768/1157 mm/mempolicy: fix get_nodes out of bound access
In reply to Greg Kroah-HartmanFrom: Tianyu Li <[email protected]>
[ Upstream commit 000eca5d044d1ee23b4ca311793cf3fc528da6c6 ]
When user specified more nodes than supported, get_nodes will access nmask array out of bounds.
--- mm/mempolicy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/mempolicy.c +1 -1
@@ -1388,7 +1388,7 @@ static int get_nodes(nodemask_t *nodes, const unsigned long __user *nmask, unsigned long bits = min_t(unsigned long, maxnode, BITS_PER_LONG);unsigned long t; -if (get_bitmap (&t, &nmask[maxnode /BITS_PER_LONG ], bits)) +if (get_bitmap (&t, &nmask[(maxnode -1 ) /BITS_PER_LONG ], bits))return -EFAULT ;if (maxnode - bits >=MAX_NUMNODES ) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 769/1157 phy: ti: tusb1210: Dont check for write errors when powering on
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit d4a0a189b72a7c98e4256292b18b67c69fbc9343 ]
On some platforms, like Intel Merrifield, the writing values during power on may timeout:
tusb1210 dwc3.0.auto.ulpi: error -110 writing val 0x41 to reg 0x80 phy phy-dwc3.0.auto.ulpi.0: phy poweron failed --> -110 dwc3 dwc3.0.auto: error -ETIMEDOUT: failed to initialize core
dwc3: probe of dwc3.0.auto failed with error -110
which effectively fails the probe of the USB controller. Drop the check as it was before the culprit commit (see Fixes tag).
--- drivers/phy/ti/phy-tusb1210.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/phy/ti/phy-tusb1210.c +3 -2
@@ -105,8 +105,9 @@ static int tusb1210_power_on(struct phy *phy)msleep (TUSB1210_RESET_TIME_MS );/* Restore the optional eye diagram optimization value */ -return tusb1210_ulpi_write (tusb,TUSB1210_VENDOR_SPECIFIC2 , - tusb->vendor_specific2); +tusb1210_ulpi_write (tusb,TUSB1210_VENDOR_SPECIFIC2 , tusb->vendor_specific2); + +return 0 ; }static int tusb1210_power_off (struct phy *phy)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 770/1157 phy: rockchip-inno-usb2: Sync initial otg state
In reply to Greg Kroah-HartmanFrom: Peter Geis <[email protected]>
[ Upstream commit 8dc60f8da22fdbaa1fafcfb5ff6d24bc9eff56aa ]
The initial otg state for the phy defaults to device mode. The actual state isn't detected until an ID IRQ fires. Fix this by syncing the ID state during initialization.
--- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +6 -0
@@ -1162,6 +1162,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, EXTCON_USB_HOST, &rport->event_nb);if (ret)dev_err (rphy->dev,"register USB HOST notifier failed\n" ); + +if (!of_property_read_bool (rphy->dev->of_node,"extcon" )) { +/* do initial sync of usb state */ + ret =property_enabled (rphy->grf, &rport->port_cfg->utmi_id); +extcon_set_state_sync (rphy->edev,EXTCON_USB_HOST , !ret); + } } out:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 771/1157 PCI: dwc: Stop link on host_init errors and de-initialization
In reply to Greg Kroah-HartmanFrom: Serge Semin <[email protected]>
[ Upstream commit 113fa857b74c947137d845e7e635afcf6a59c43a ]
It's logically correct to undo everything that was done when an error is discovered or in the corresponding cleanup counterpart. Otherwise the host controller will be left in an undetermined state. Since the link is set up in the host_init method, deactivate it there in the cleanup-on-error block and stop the link in the antagonistic routine - dw_pcie_host_deinit(). Link deactivation is platform-specific and should be implemented in dw_pcie_ops.stop_link().
--- .../pci/controller/dwc/pcie-designware-host.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pcie-designware-host.c +14 -2
@@ -421,8 +421,14 @@ int dw_pcie_host_init(struct pcie_port *pp) bridge->sysdata = pp; ret =pci_host_probe (bridge); -if (!ret) -return 0 ; +if (ret) + goto err_stop_link; + +return 0 ; + +err_stop_link: +if (pci->ops && pci->ops->stop_link) + pci->ops->stop_link (pci); err_free_msi:if (pp->has_msi_ctrl)
@@ -433,8 +439,14 @@ EXPORT_SYMBOL_GPL(dw_pcie_host_init);void dw_pcie_host_deinit (struct pcie_port *pp) { +struct dw_pcie *pci =to_dw_pcie_from_pp (pp); +pci_stop_root_bus (pp->bridge->bus);pci_remove_root_bus (pp->bridge->bus); + +if (pci->ops && pci->ops->stop_link) + pci->ops->stop_link (pci); +if (pp->has_msi_ctrl)dw_pcie_free_msi (pp); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 772/1157 PCI: dwc: Add unroll iATU space support to dw_pcie_disable_atu()
In reply to Greg Kroah-HartmanFrom: Serge Semin <[email protected]>
[ Upstream commit d1cf738f2b65a5640234e1da90a68d3523fbed83 ]
dw_pcie_disable_atu() was introduced by f8aed6ec624f ("PCI: dwc:
designware: Add EP mode support") and supported only the viewport version of the iATU CSRs.
DW PCIe IP cores v4.80a and newer also support unrolled iATU/eDMA space. Callers of dw_pcie_disable_atu(), including pci_epc_ops.clear_bar(), pci_epc_ops.unmap_addr(), and dw_pcie_setup_rc(), don't work correctly when it is enabled.
Add dw_pcie_disable_atu() support for controllers with unrolled iATU CSRs enabled.
--- drivers/pci/controller/dwc/pcie-designware.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/pci/controller/dwc/pcie-designware.c +13 -3
@@ -491,7 +491,7 @@ int dw_pcie_prog_inbound_atu(struct dw_pcie *pci, u8 func_no, int index,void dw_pcie_disable_atu (struct dw_pcie *pci,int index,enum dw_pcie_region_type type) { -int region; +u32 region;switch (type) {case DW_PCIE_REGION_INBOUND :
@@ -504,8 +504,18 @@ void dw_pcie_disable_atu(struct dw_pcie *pci, int index,return ; } -dw_pcie_writel_dbi (pci,PCIE_ATU_VIEWPORT , region | index); -dw_pcie_writel_dbi (pci,PCIE_ATU_CR2 , ~(u32 )PCIE_ATU_ENABLE ); +if (pci->iatu_unroll_enabled) { +if (region ==PCIE_ATU_REGION_INBOUND ) { +dw_pcie_writel_ib_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL2 , + ~(u32 )PCIE_ATU_ENABLE ); + }else { +dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL2 , + ~(u32 )PCIE_ATU_ENABLE ); + } + }else { +dw_pcie_writel_dbi (pci,PCIE_ATU_VIEWPORT , region | index); +dw_pcie_writel_dbi (pci,PCIE_ATU_CR2 , ~(u32 )PCIE_ATU_ENABLE ); + } }int dw_pcie_wait_for_link (struct dw_pcie *pci)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 773/1157 PCI: dwc: Disable outbound windows only for controllers using iATU
In reply to Greg Kroah-HartmanFrom: Serge Semin <[email protected]>
[ Upstream commit d60a2e281e9de2b2f67343b2e39417ca0f4fd54e ]
Some DWC-based controllers (e.g., pcie-al.c and pci-keystone.c, identified by the fact that they override the default dw_child_pcie_ops) use their own address translation approach instead of the DWC internal ATU (iATU). For those controllers, skip disabling the iATU outbound windows.
--- drivers/pci/controller/dwc/pcie-designware-host.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/pci/controller/dwc/pcie-designware-host.c +8 -6
@@ -543,7 +543,6 @@ static struct pci_ops dw_pcie_ops = {void dw_pcie_setup_rc (struct pcie_port *pp) { -int i;u32 val, ctrl, num_ctrls;struct dw_pcie *pci =to_dw_pcie_from_pp (pp);
@@ -594,19 +593,22 @@ void dw_pcie_setup_rc(struct pcie_port *pp)PCI_COMMAND_MASTER |PCI_COMMAND_SERR ;dw_pcie_writel_dbi (pci,PCI_COMMAND , val); -/* Ensure all outbound windows are disabled so there are multiple matches */ -for (i =0 ; i < pci->num_ob_windows; i++) -dw_pcie_disable_atu (pci, i,DW_PCIE_REGION_OUTBOUND ); -/* * If the platform provides its own child bus config accesses, it means * the platform uses its own address translation component rather than * ATU, so we should not program the ATU here. */ if (pp->bridge->child_ops == &dw_child_pcie_ops) { -int atu_idx =0 ; +int i, atu_idx =0 ;struct resource_entry *entry; +/* +* Disable all outbound windows to make sure a transaction +* can't match multiple windows. +*/ +for (i =0 ; i < pci->num_ob_windows; i++) +dw_pcie_disable_atu (pci, i,DW_PCIE_REGION_OUTBOUND ); +/* Get last memory resource entry */ resource_list_for_each_entry (entry, &pp->bridge->windows) {if (resource_type (entry->res) !=IORESOURCE_MEM )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 774/1157 PCI: dwc: Set INCREASE_REGION_SIZE flag based on limit address
In reply to Greg Kroah-HartmanFrom: Serge Semin <[email protected]>
[ Upstream commit 777e7c3ab73036105e6fc4a67ed950179dbffbab ]
We program the 64-bit ATU limit address (in PCIE_ATU_LIMIT/ PCIE_ATU_UPPER_LIMIT or PCIE_ATU_UNR_LOWER_LIMIT/PCIE_ATU_UNR_UPPER_LIMIT), but in addition, the PCIE_ATU_INCREASE_REGION_SIZE bit must be set if the upper 32 bits of the limit address differ from the upper 32 bits of the base address (see [1,2]).
5b4cf0f65324 ("PCI: dwc: Add upper limit address for outbound iATU") set PCIE_ATU_INCREASE_REGION_SIZE, but only when the *size* was greater than 4GB. It did not set it when a smaller region crossed a 4GB boundary, e.g., [mem 0x0_f0000000-0x1_0fffffff].
Set PCIE_ATU_INCREASE_REGION_SIZE whenever PCIE_ATU_UPPER_LIMIT is greater than PCIE_ATU_UPPER_BASE.
[1] DesignWare Cores PCI Express Controller Databook - DWC PCIe Root Port,
v5.40a, March 2019, fig.3-36, p.175
[2] DesignWare Cores PCI Express Controller Databook - DWC PCIe Root Port,
v5.40a, March 2019, fig.3-37, p.176--- drivers/pci/controller/dwc/pcie-designware.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/pci/controller/dwc/pcie-designware.c +10 -6
@@ -287,8 +287,8 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8 func_no,dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_UPPER_TARGET ,upper_32_bits (pci_addr)); val = type |PCIE_ATU_FUNC_NUM (func_no); - val =upper_32_bits (size -1 ) ? - val |PCIE_ATU_INCREASE_REGION_SIZE : val; +if (upper_32_bits (limit_addr) >upper_32_bits (cpu_addr)) + val |=PCIE_ATU_INCREASE_REGION_SIZE ;if (pci->version ==0x490A ) val =dw_pcie_enable_ecrc (val);dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL1 , val);
@@ -315,6 +315,7 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, u64 pci_addr, u64 size) {u32 retries, val; +u64 limit_addr;if (pci->ops && pci->ops->cpu_addr_fixup) cpu_addr = pci->ops->cpu_addr_fixup (pci, cpu_addr);
@@ -325,6 +326,8 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no,return ; } + limit_addr = cpu_addr + size -1 ; +dw_pcie_writel_dbi (pci,PCIE_ATU_VIEWPORT ,PCIE_ATU_REGION_OUTBOUND | index); dw_pcie_writel_dbi(pci, PCIE_ATU_LOWER_BASE,
@@ -332,17 +335,18 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no,dw_pcie_writel_dbi (pci,PCIE_ATU_UPPER_BASE ,upper_32_bits (cpu_addr));dw_pcie_writel_dbi (pci,PCIE_ATU_LIMIT , -lower_32_bits (cpu_addr + size -1 )); +lower_32_bits (limit_addr));if (pci->version >=0x460A )dw_pcie_writel_dbi (pci,PCIE_ATU_UPPER_LIMIT , -upper_32_bits (cpu_addr + size -1 )); +upper_32_bits (limit_addr));dw_pcie_writel_dbi (pci,PCIE_ATU_LOWER_TARGET ,lower_32_bits (pci_addr));dw_pcie_writel_dbi (pci,PCIE_ATU_UPPER_TARGET ,upper_32_bits (pci_addr)); val = type |PCIE_ATU_FUNC_NUM (func_no); - val = ((upper_32_bits (size -1 )) && (pci->version >=0x460A )) ? - val |PCIE_ATU_INCREASE_REGION_SIZE : val; +if (upper_32_bits (limit_addr) >upper_32_bits (cpu_addr) && + pci->version >=0x460A ) + val |=PCIE_ATU_INCREASE_REGION_SIZE ;if (pci->version ==0x490A ) val =dw_pcie_enable_ecrc (val);dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , val);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 775/1157 PCI: dwc: Deallocate EPC memory on dw_pcie_ep_init() errors
In reply to Greg Kroah-HartmanFrom: Serge Semin <[email protected]>
[ Upstream commit 8161e9626b50892eaedbd8070ecb1586ecedb109 ]
If dw_pcie_ep_init() fails to perform any action after the EPC memory is initialized and the MSI memory region is allocated, the latter parts won't be undone thus causing a memory leak. Add a cleanup-on-error path to fix these leaks.
--- .../pci/controller/dwc/pcie-designware-ep.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pcie-designware-ep.c +16 -2
@@ -780,8 +780,9 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) ep->msi_mem =pci_epc_mem_alloc_addr (epc, &ep->msi_mem_phys, epc->mem->window.page_size);if (!ep->msi_mem) { + ret = -ENOMEM ;dev_err (dev,"Failed to reserve memory for MSI/MSI-X\n" ); -return -ENOMEM ; + goto err_exit_epc_mem; }if (ep->ops->get_features) {
@@ -790,6 +791,19 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)return 0 ; } -return dw_pcie_ep_init_complete (ep); + ret =dw_pcie_ep_init_complete (ep); +if (ret) + goto err_free_epc_mem; + +return 0 ; + +err_free_epc_mem: +pci_epc_mem_free_addr (epc, ep->msi_mem_phys, ep->msi_mem, + epc->mem->window.page_size); + +err_exit_epc_mem: +pci_epc_mem_exit (epc); + +return ret; }EXPORT_SYMBOL_GPL (dw_pcie_ep_init);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 776/1157 PCI: dwc: Always enable CDM check if "snps,enable-cdm-check" exists
In reply to Greg Kroah-HartmanFrom: Serge Semin <[email protected]>
[ Upstream commit ec7b952f453ce7eabe7e1bea584626934d44f668 ]
If the "snps,enable-cdm-check" property exists, we should enable the CDM check. But previously dw_pcie_setup() could exit before doing so if the "num-lanes" property was absent or invalid.
Move the CDM enable earlier so we do it regardless of whether "num-lanes" is present.
--- drivers/pci/controller/dwc/pcie-designware.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/pci/controller/dwc/pcie-designware.c +7 -7
@@ -740,6 +740,13 @@ void dw_pcie_setup(struct dw_pcie *pci) val |=PORT_LINK_DLL_LINK_EN ;dw_pcie_writel_dbi (pci,PCIE_PORT_LINK_CONTROL , val); +if (of_property_read_bool (np,"snps,enable-cdm-check" )) { + val =dw_pcie_readl_dbi (pci,PCIE_PL_CHK_REG_CONTROL_STATUS ); + val |=PCIE_PL_CHK_REG_CHK_REG_CONTINUOUS | +PCIE_PL_CHK_REG_CHK_REG_START ; +dw_pcie_writel_dbi (pci,PCIE_PL_CHK_REG_CONTROL_STATUS , val); + } +of_property_read_u32 (np,"num-lanes" , &pci->num_lanes);if (!pci->num_lanes) {dev_dbg (pci->dev,"Using h/w default number of lanes\n" );
@@ -786,11 +793,4 @@ void dw_pcie_setup(struct dw_pcie *pci)break ; }dw_pcie_writel_dbi (pci,PCIE_LINK_WIDTH_SPEED_CONTROL , val); - -if (of_property_read_bool (np,"snps,enable-cdm-check" )) { - val =dw_pcie_readl_dbi (pci,PCIE_PL_CHK_REG_CONTROL_STATUS ); - val |=PCIE_PL_CHK_REG_CHK_REG_CONTINUOUS | -PCIE_PL_CHK_REG_CHK_REG_START ; -dw_pcie_writel_dbi (pci,PCIE_PL_CHK_REG_CONTROL_STATUS , val); - } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 777/1157 soundwire: bus_type: fix remove and shutdown support
In reply to Greg Kroah-HartmanFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit df6407782964dc7e35ad84230abb38f46314b245 ]
The bus sdw_drv_remove() and sdw_drv_shutdown() helpers are used conditionally, if the driver provides these routines.
These helpers already test if the driver provides a .remove or .shutdown callback, so there's no harm in invoking the sdw_drv_remove() and sdw_drv_shutdown() unconditionally.
In addition, the current code is imbalanced with dev_pm_domain_attach() called from sdw_drv_probe(), but dev_pm_domain_detach() called from sdw_drv_remove() only if the driver provides a .remove callback.
--- drivers/soundwire/bus_type.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/soundwire/bus_type.c +2 -6
@@ -193,12 +193,8 @@ int __sdw_register_driver(struct sdw_driver *drv, struct module *owner) drv->driver.owner = owner; drv->driver.probe = sdw_drv_probe; - -if (drv->remove) - drv->driver.remove = sdw_drv_remove; - -if (drv->shutdown) - drv->driver.shutdown = sdw_drv_shutdown; + drv->driver.remove = sdw_drv_remove; + drv->driver.shutdown = sdw_drv_shutdown;return driver_register (&drv->driver); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 778/1157 soundwire: revisit driver bind/unbind and callbacks
In reply to Greg Kroah-HartmanFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit bd29c00edd0a5dac8b6e7332bb470cd50f92e893 ]
In the SoundWire probe, we store a pointer from the driver ops into the 'slave' structure. This can lead to kernel oopses when unbinding codec drivers, e.g. with the following sequence to remove machine driver and codec driver.
/sbin/modprobe -r snd_soc_sof_sdw/sbin/modprobe -r snd_soc_rt711
The full details can be found in the BugLink below, for reference the two following examples show different cases of driver ops/callbacks being invoked after the driver .remove().
kernel: BUG: kernel NULL pointer dereference, address: 0000000000000150 kernel: Workqueue: events cdns_update_slave_status_work [soundwire_cadence] kernel: RIP: 0010:mutex_lock+0x19/0x30 kernel: Call Trace: kernel: ? sdw_handle_slave_status+0x426/0xe00 [soundwire_bus 94ff184bf398570c3f8ff7efe9e32529f532e4ae] kernel: ? newidle_balance+0x26a/0x400 kernel: ? cdns_update_slave_status_work+0x1e9/0x200 [soundwire_cadence 1bcf98eebe5ba9833cd433323769ac923c9c6f82]
kernel: BUG: unable to handle page fault for address: ffffffffc07654c8 kernel: Workqueue: pm pm_runtime_work kernel: RIP: 0010:sdw_bus_prep_clk_stop+0x6f/0x160 [soundwire_bus] kernel: Call Trace: kernel: <TASK> kernel: sdw_cdns_clock_stop+0xb5/0x1b0 [soundwire_cadence 1bcf98eebe5ba9833cd433323769ac923c9c6f82] kernel: intel_suspend_runtime+0x5f/0x120 [soundwire_intel aca858f7c87048d3152a4a41bb68abb9b663a1dd] kernel: ? dpm_sysfs_remove+0x60/0x60
This was not detected earlier in Intel tests since the tests first remove the parent PCI device and shut down the bus. The sequence above is a corner case which keeps the bus operational but without a driver bound.
While trying to solve this kernel oopses, it became clear that the existing SoundWire bus does not deal well with the unbind case.
Commit 528be501b7d4a ("soundwire: sdw_slave: add probe_complete structure and new fields") added a 'probed' status variable and a 'probe_complete'
struct completion. This status is however not reset on remove and
likewise the 'probe complete' is not re-initialized, so the bind/unbind/bind test cases would fail. The timeout used before the 'update_status' callback was also a bad idea in hindsight, there
should really be no timing assumption as to if and when a driver is
bound to a device.
An initial draft was based on device_lock() and device_unlock() was tested. This proved too complicated, with deadlocks created during the suspend-resume sequences, which also use the same device_lock/unlock() as the bind/unbind sequences. On a CometLake device, a bad DSDT/BIOS caused spurious resumes and the use of device_lock() caused hangs during suspend. After multiple weeks or testing and painful reverse-engineering of deadlocks on different devices, we looked for alternatives that did not interfere with the device core.
A bus notifier was used successfully to keep track of DRIVER_BOUND and DRIVER_UNBIND events. This solved the bind-unbind-bind case in tests, but it can still be defeated with a theoretical corner case where the memory is freed by a .remove while the callback is in use. The notifier only helps make sure the driver callbacks are valid, but not that the memory allocated in probe remains valid while the callbacks are invoked.
This patch suggests the introduction of a new 'sdw_dev_lock' mutex protecting probe/remove and all driver callbacks. Since this mutex is 'local' to SoundWire only, it does not interfere with existing locks and does not create deadlocks. In addition, this patch removes the 'probe_complete' completion, instead we directly invoke the 'update_status' from the probe routine. That removes any sort of timing dependency and a much better support for the device/driver model, the driver could be bound before the bus started, or eons after the bus started and the hardware would be properly initialized in all cases.
--- drivers/soundwire/bus.c | 75 ++++++++++++++++++++--------------- drivers/soundwire/bus_type.c | 30 +++++++++++--- drivers/soundwire/slave.c | 3 +- drivers/soundwire/stream.c | 53 ++++++++++++++++--------- include/linux/soundwire/sdw.h | 6 +-- 5 files changed, 106 insertions(+), 61 deletions(-)
drivers/soundwire/bus.c +42 -33
@@ -7,6 +7,7 @@#include <linux/pm_runtime.h> #include <linux/soundwire/sdw_registers.h> #include <linux/soundwire/sdw.h> +#include <linux/soundwire/sdw_type.h> #include "bus.h" #include "sysfs_local.h"
@@ -842,15 +843,21 @@ static int sdw_slave_clk_stop_callback(struct sdw_slave *slave,enum sdw_clk_stop_mode mode, enum sdw_clk_stop_type type) { - int ret; + int ret = 0; -if (slave->ops && slave->ops->clk_stop) { - ret = slave->ops->clk_stop (slave, mode, type); -if (ret <0 ) -return ret; +mutex_lock (&slave->sdw_dev_lock); + +if (slave->probed) { +struct device *dev = &slave->dev; +struct sdw_driver *drv =drv_to_sdw_driver (dev->driver); + +if (drv->ops && drv->ops->clk_stop) + ret = drv->ops->clk_stop (slave, mode, type); } -return 0 ; +mutex_unlock (&slave->sdw_dev_lock); + +return ret; } static int sdw_slave_clk_stop_prepare(struct sdw_slave *slave,
@@ -1611,14 +1618,24 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave) }/* Update the Slave driver */ -if (slave_notify && slave->ops && - slave->ops->interrupt_callback) { - slave_intr.sdca_cascade = sdca_cascade; - slave_intr.control_port = clear; -memcpy (slave_intr.port, &port_status, -sizeof (slave_intr.port)); - - slave->ops->interrupt_callback (slave, &slave_intr); +if (slave_notify) { +mutex_lock (&slave->sdw_dev_lock); + +if (slave->probed) { +struct device *dev = &slave->dev; +struct sdw_driver *drv =drv_to_sdw_driver (dev->driver); + +if (drv->ops && drv->ops->interrupt_callback) { + slave_intr.sdca_cascade = sdca_cascade; + slave_intr.control_port = clear; +memcpy (slave_intr.port, &port_status, +sizeof (slave_intr.port)); + + drv->ops->interrupt_callback (slave, &slave_intr); + } + } + +mutex_unlock (&slave->sdw_dev_lock); }/* Ack interrupt */
@@ -1692,29 +1709,21 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)static int sdw_update_slave_status (struct sdw_slave *slave,enum sdw_slave_status status) { -unsigned long time; +int ret =0 ; -if (!slave->probed) { -/* -* the slave status update is typically handled in an -* interrupt thread, which can race with the driver -* probe, e.g. when a module needs to be loaded. -* -* make sure the probe is complete before updating -* status. -*/ - time =wait_for_completion_timeout (&slave->probe_complete, -msecs_to_jiffies (DEFAULT_PROBE_TIMEOUT )); -if (!time) { -dev_err (&slave->dev,"Probe not complete, timed out\n" ); -return -ETIMEDOUT ; - } +mutex_lock (&slave->sdw_dev_lock); + +if (slave->probed) { +struct device *dev = &slave->dev; +struct sdw_driver *drv =drv_to_sdw_driver (dev->driver); + +if (drv->ops && drv->ops->update_status) + ret = drv->ops->update_status (slave, status); } -if (!slave->ops || !slave->ops->update_status) -return 0 ; +mutex_unlock (&slave->sdw_dev_lock); -return slave->ops->update_status (slave, status); +return ret; }/**
drivers/soundwire/bus_type.c +25 -5
@@ -98,8 +98,6 @@ static int sdw_drv_probe(struct device *dev)if (!id)return -ENODEV ; - slave->ops = drv->ops; -/* * attach to power domain but don't turn on (last arg) */
@@ -107,19 +105,23 @@ static int sdw_drv_probe(struct device *dev)if (ret)return ret; +mutex_lock (&slave->sdw_dev_lock); + ret = drv->probe (slave, id);if (ret) { name = drv->name;if (!name) name = drv->driver.name; +mutex_unlock (&slave->sdw_dev_lock); +dev_err (dev,"Probe of %s failed: %d\n" , name, ret);dev_pm_domain_detach (dev, false);return ret; }/* device is probed so let's read the properties now */ -if (slave->ops && slave->ops->read_prop) - slave->ops->read_prop (slave); +if (drv->ops && drv->ops->read_prop) + drv->ops->read_prop (slave);/* init the sysfs as we have properties now */ ret =sdw_slave_sysfs_init (slave);
@@ -139,7 +141,19 @@ static int sdw_drv_probe(struct device *dev) slave->prop.clk_stop_timeout); slave->probed = true; -complete (&slave->probe_complete); + +/* +* if the probe happened after the bus was started, notify the codec driver +* of the current hardware status to e.g. start the initialization. +* Errors are only logged as warnings to avoid failing the probe. +*/ +if (drv->ops && drv->ops->update_status) { + ret = drv->ops->update_status (slave, slave->status); +if (ret <0 ) +dev_warn (dev,"%s: update_status failed with status %d\n" , __func__, ret); + } + +mutex_unlock (&slave->sdw_dev_lock);dev_dbg (dev,"probe complete\n" );
@@ -152,9 +166,15 @@ static int sdw_drv_remove(struct device *dev)struct sdw_driver *drv =drv_to_sdw_driver (dev->driver);int ret =0 ; +mutex_lock (&slave->sdw_dev_lock); + + slave->probed = false; +if (drv->remove) ret = drv->remove (slave); +mutex_unlock (&slave->sdw_dev_lock); +dev_pm_domain_detach (dev, false);return ret;
drivers/soundwire/slave.c +2 -1
@@ -12,6 +12,7 @@ static void sdw_slave_release(struct device *dev) {struct sdw_slave *slave =dev_to_sdw_dev (dev); +mutex_destroy (&slave->sdw_dev_lock);kfree (slave); }
@@ -58,9 +59,9 @@ int sdw_slave_add(struct sdw_bus *bus,init_completion (&slave->enumeration_complete);init_completion (&slave->initialization_complete); slave->dev_num =0 ; -init_completion (&slave->probe_complete); slave->probed = false; slave->first_interrupt_done = false; +mutex_init (&slave->sdw_dev_lock);for (i =0 ; i <SDW_MAX_PORTS ; i++)init_completion (&slave->port_ready[i]);
drivers/soundwire/stream.c +35 -18
85 lines not on this page · raw message
include/linux/soundwire/sdw.h +2 -4
@@ -646,9 +646,6 @@ struct sdw_slave_ops {* @dev_num: Current Device Number, values can be 0 or dev_num_sticky * @dev_num_sticky: one-time static Device Number assigned by Bus * @probed: boolean tracking driver state -* @probe_complete: completion utility to control potential races -* on startup between driver probe/initialization and SoundWire -* Slave state changes/implementation-defined interrupts * @enumeration_complete: completion utility to control potential races * on startup between device enumeration and read/write access to the * Slave device
@@ -663,6 +660,7 @@ struct sdw_slave_ops {* for a Slave happens for the first time after enumeration * @is_mockup_device: status flag used to squelch errors in the command/control * protocol for SoundWire mockup devices +* @sdw_dev_lock: mutex used to protect callbacks/remove races */ struct sdw_slave {struct sdw_slave_id id;
@@ -680,12 +678,12 @@ struct sdw_slave {u16 dev_num;u16 dev_num_sticky;bool probed; -struct completion probe_complete;struct completion enumeration_complete;struct completion initialization_complete;u32 unattach_request;bool first_interrupt_done;bool is_mockup_device; +struct mutex sdw_dev_lock;/* protect callbacks/remove races */ };#define dev_to_sdw_dev (_dev) container_of(_dev, struct sdw_slave, dev)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 779/1157 KVM: arm64: Dont return from void function
In reply to Greg Kroah-HartmanFrom: Quentin Perret <[email protected]>
[ Upstream commit 1c3ace2b8b3995d3213c5e2d2aca01a0577a3b0f ]
Although harmless, the return statement in kvm_unexpected_el2_exception is rather confusing as the function itself has a void return type. The C standard is also pretty clear that "A return statement with an expression shall not appear in a function whose return type is void". Given that this return statement does not seem to add any actual value, let's not pointlessly violate the standard.
Build-tested with GCC 10 and CLANG 13 for good measure, the disassembled code is identical with or without the return statement.
--- arch/arm64/kvm/hyp/nvhe/switch.c | 2 +- arch/arm64/kvm/hyp/vhe/switch.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/hyp/nvhe/switch.c +1 -1
@@ -386,5 +386,5 @@ asmlinkage void __noreturn hyp_panic_bad_stack(void) asmlinkage void kvm_unexpected_el2_exception(void) { -return __kvm_unexpected_el2_exception (); +__kvm_unexpected_el2_exception (); }
arch/arm64/kvm/hyp/vhe/switch.c +1 -1
@@ -249,5 +249,5 @@ void __noreturn hyp_panic(void) asmlinkage void kvm_unexpected_el2_exception(void) { -return __kvm_unexpected_el2_exception (); +__kvm_unexpected_el2_exception (); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 780/1157 dmaengine: sf-pdma: Add multithread support for a DMA channel
In reply to Greg Kroah-HartmanFrom: Viacheslav Mitrofanov <[email protected]>
[ Upstream commit b2cc5c465c2cb8ab697c3fd6583c614e3f6cfbcc ]
When we get a DMA channel and try to use it in multiple threads it will cause oops and hanging the system.
% echo 64 > /sys/module/dmatest/parameters/threads_per_chan % echo 10000 > /sys/module/dmatest/parameters/iterations % echo 1 > /sys/module/dmatest/parameters/run
[ 89.480664] Unable to handle kernel NULL pointer dereference at virtual
address 00000000000000a0
[ 89.488725] Oops [#1]
[ 89.494708] CPU: 2 PID: 1008 Comm: dma0chan0-copy0 Not tainted
5.17.0-rc5
[ 89.509385] epc : vchan_find_desc+0x32/0x46
[ 89.513553] ra : sf_pdma_tx_status+0xca/0xd6This happens because of data race. Each thread rewrite channels's descriptor as soon as device_prep_dma_memcpy() is called. It leads to the situation when the driver thinks that it uses right descriptor that actually is freed or substituted for other one.
With current fixes a descriptor changes its value only when it has been used. A new descriptor is acquired from vc->desc_issued queue that is already filled with descriptors that are ready to be sent. Threads have no direct access to DMA channel descriptor. Now it is just possible to queue a descriptor for further processing.
--- drivers/dma/sf-pdma/sf-pdma.c | 44 ++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 14 deletions(-)
drivers/dma/sf-pdma/sf-pdma.c +30 -14
@@ -52,16 +52,6 @@ static inline struct sf_pdma_desc *to_sf_pdma_desc(struct virt_dma_desc *vd)static struct sf_pdma_desc *sf_pdma_alloc_desc (struct sf_pdma_chan *chan) {struct sf_pdma_desc *desc; -unsigned long flags; - -spin_lock_irqsave (&chan->lock, flags); - -if (chan->desc && !chan->desc->in_use) { -spin_unlock_irqrestore (&chan->lock, flags); -return chan->desc; - } - -spin_unlock_irqrestore (&chan->lock, flags); desc =kzalloc (sizeof (*desc),GFP_NOWAIT );if (!desc)
@@ -111,7 +101,6 @@ sf_pdma_prep_dma_memcpy(struct dma_chan *dchan, dma_addr_t dest, dma_addr_t src, desc->async_tx =vchan_tx_prep (&chan->vchan, &desc->vdesc, flags);spin_lock_irqsave (&chan->vchan.lock, iflags); - chan->desc = desc;sf_pdma_fill_desc (desc, dest, src, len);spin_unlock_irqrestore (&chan->vchan.lock, iflags);
@@ -170,11 +159,17 @@ static size_t sf_pdma_desc_residue(struct sf_pdma_chan *chan,unsigned long flags;u64 residue =0 ;struct sf_pdma_desc *desc; -struct dma_async_tx_descriptor *tx; +struct dma_async_tx_descriptor *tx =NULL ;spin_lock_irqsave (&chan->vchan.lock, flags); - tx = &chan->desc->vdesc.tx; +list_for_each_entry (vd, &chan->vchan.desc_submitted, node) +if (vd->tx.cookie == cookie) + tx = &vd->tx; + +if (!tx) + goto out; +if (cookie == tx->chan->completed_cookie) goto out;
@@ -241,6 +236,19 @@ static void sf_pdma_enable_request(struct sf_pdma_chan *chan)writel (v, regs->ctrl); } +static struct sf_pdma_desc *sf_pdma_get_first_pending_desc (struct sf_pdma_chan *chan) +{ +struct virt_dma_chan *vchan = &chan->vchan; +struct virt_dma_desc *vdesc; + +if (list_empty (&vchan->desc_issued)) +return NULL ; + + vdesc = list_first_entry(&vchan->desc_issued, struct virt_dma_desc, node); + + return container_of(vdesc, struct sf_pdma_desc, vdesc); +} +static void sf_pdma_xfer_desc (struct sf_pdma_chan *chan) {struct sf_pdma_desc *desc = chan->desc;
@@ -268,8 +276,11 @@ static void sf_pdma_issue_pending(struct dma_chan *dchan)spin_lock_irqsave (&chan->vchan.lock, flags); -if (vchan_issue_pending (&chan->vchan) && chan->desc) +if (!chan->desc &&vchan_issue_pending (&chan->vchan)) { +/* vchan_issue_pending has made a check that desc in not NULL */ + chan->desc =sf_pdma_get_first_pending_desc (chan);sf_pdma_xfer_desc (chan); + }spin_unlock_irqrestore (&chan->vchan.lock, flags); }
@@ -298,6 +309,11 @@ static void sf_pdma_donebh_tasklet(struct tasklet_struct *t)spin_lock_irqsave (&chan->vchan.lock, flags);list_del (&chan->desc->vdesc.node);vchan_cookie_complete (&chan->desc->vdesc); + + chan->desc =sf_pdma_get_first_pending_desc (chan); +if (chan->desc) +sf_pdma_xfer_desc (chan); +spin_unlock_irqrestore (&chan->vchan.lock, flags); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 781/1157 PCI: endpoint: Dont stop controller when unbinding endpoint function
In reply to Greg Kroah-HartmanFrom: Shunsuke Mie <[email protected]>
[ Upstream commit 1bc2b7bfba6e2f64edf5e246f3af2967261f6c3d ]
Unbinding an endpoint function from the endpoint controller shouldn't stop the controller. This is especially a problem for multi-function endpoints where other endpoints may still be active.
Don't stop the controller when unbinding one of its endpoints. Normally the controller is stopped via configfs.
--- drivers/pci/endpoint/functions/pci-epf-test.c | 1 - 1 file changed, 1 deletion(-)
drivers/pci/endpoint/functions/pci-epf-test.c +0 -1
@@ -627,7 +627,6 @@ static void pci_epf_test_unbind(struct pci_epf *epf)cancel_delayed_work (&epf_test->cmd_handler);pci_epf_test_clean_dma_chan (epf_test); -pci_epc_stop (epc);for (bar =0 ; bar <PCI_STD_NUM_BARS ; bar++) { epf_bar = &epf->bar[bar];
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 782/1157 phy: qcom-qmp: fix the QSERDES_V5_COM_CMN_MODE register
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit 488987b2d5cade4e7680f7e81590435a848d1fa9 ]
Change QSERDES_V5_COM_CMN_MODE to be defined to 0x1a0 rather than 0x1a4. The only user of this register name (sm8450_qmp_gen4x2_pcie_serdes_tbl) should use the 0x1a0 register, as stated in the downstream dtsi tree.
--- drivers/phy/qualcomm/phy-qcom-qmp.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/phy/qualcomm/phy-qcom-qmp.h +2 -1
@@ -1116,7 +1116,8 @@#define QSERDES_V5_COM_CORE_CLK_EN 0x174#define QSERDES_V5_COM_CMN_CONFIG 0x17c#define QSERDES_V5_COM_CMN_MISC1 0x19c -#define QSERDES_V5_COM_CMN_MODE 0x1a4 +#define QSERDES_V5_COM_CMN_MODE 0x1a0 +#define QSERDES_V5_COM_CMN_MODE_CONTD 0x1a4#define QSERDES_V5_COM_VCO_DC_LEVEL_CTRL 0x1a8#define QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE1_MODE0 0x1ac#define QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE2_MODE0 0x1b0
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 783/1157 scsi: qla2xxx: Check correct variable in qla24xx_async_gffid()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 7c33e477bd883f79cccec418980cb8f7f2d50347 ]
There is a copy and paste bug here. It should check ".rsp" instead of ".req". The error message is copy and pasted as well so update that too.
--- drivers/scsi/qla2xxx/qla_gs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_gs.c +2 -2
@@ -3386,9 +3386,9 @@ int qla24xx_async_gffid(scsi_qla_host_t *vha, fc_port_t *fcport, bool wait) sp->u.iocb_cmd.u.ctarg.rsp_allocated_size, &sp->u.iocb_cmd.u.ctarg.rsp_dma, GFP_KERNEL); -if (!sp->u.iocb_cmd.u.ctarg.req) { +if (!sp->u.iocb_cmd.u.ctarg.rsp) {ql_log (ql_log_warn, vha,0xd041 , -"%s: Failed to allocate ct_sns request.\n" , +"%s: Failed to allocate ct_sns response.\n" , __func__); goto done_free_sp; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 784/1157 scsi: sd: Rework asynchronous resume support
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
[ Upstream commit 88f1669019bd62b3009a3cebf772fbaaa21b9f38 ]
For some technologies, e.g. an ATA bus, resuming can take multiple seconds. Waiting for resume to finish can cause a very noticeable delay. Hence this commit that restores the behavior from before "scsi: core: pm:
Rely on the device driver core for async power management" for most SCSI devices.
This commit introduces a behavior change: if the START command fails, do not consider this as a SCSI disk resume failure.
--- drivers/scsi/sd.c | 84 +++++++++++++++++++++++++++++++++++++---------- drivers/scsi/sd.h | 5 +++ 2 files changed, 71 insertions(+), 18 deletions(-)
drivers/scsi/sd.c +66 -18
@@ -103,6 +103,7 @@ static void sd_config_discard(struct scsi_disk *, unsigned int);static void sd_config_write_same (struct scsi_disk *);static int sd_revalidate_disk (struct gendisk *);static void sd_unlock_native_capacity (struct gendisk *disk); +static void sd_start_done_work (struct work_struct *work);static int sd_probe (struct device *);static int sd_remove (struct device *);static void sd_shutdown (struct device *);
@@ -3463,6 +3464,7 @@ static int sd_probe(struct device *dev) sdkp->max_retries =SD_MAX_RETRIES ;atomic_set (&sdkp->openers,0 );atomic_set (&sdkp->device->ioerr_cnt,0 ); +INIT_WORK (&sdkp->start_done_work, sd_start_done_work);if (!sdp->request_queue->rq_timeout) {if (sdp->type !=TYPE_MOD )
@@ -3585,12 +3587,69 @@ static void scsi_disk_release(struct device *dev)kfree (sdkp); } +/* Process sense data after a START command finished. */ +static void sd_start_done_work (struct work_struct *work) +{ +struct scsi_disk *sdkp =container_of (work,typeof (*sdkp), + start_done_work); +struct scsi_sense_hdr sshdr; +int res = sdkp->start_result; + +if (res ==0 ) +return ; + +sd_print_result (sdkp,"Start/Stop Unit failed" , res); + +if (res <0 ) +return ; + +if (scsi_normalize_sense (sdkp->start_sense_buffer, + sdkp->start_sense_len, &sshdr)) +sd_print_sense_hdr (sdkp, &sshdr); +} + +/* A START command finished. May be called from interrupt context. */ +static void sd_start_done (struct request *req,blk_status_t status) +{ +const struct scsi_cmnd *scmd =blk_mq_rq_to_pdu (req); +struct scsi_disk *sdkp =scsi_disk (req->q->disk); + + sdkp->start_result = scmd->result; +WARN_ON_ONCE (scmd->sense_len >SCSI_SENSE_BUFFERSIZE ); + sdkp->start_sense_len = scmd->sense_len; +memcpy (sdkp->start_sense_buffer, scmd->sense_buffer, +ARRAY_SIZE (sdkp->start_sense_buffer)); +WARN_ON_ONCE (!schedule_work (&sdkp->start_done_work)); +} + +/* Submit a START command asynchronously. */ +static int sd_submit_start (struct scsi_disk *sdkp,u8 cmd[],u8 cmd_len) +{ +struct scsi_device *sdev = sdkp->device; +struct request_queue *q = sdev->request_queue; +struct request *req; +struct scsi_cmnd *scmd; + + req =scsi_alloc_request (q,REQ_OP_DRV_IN ,BLK_MQ_REQ_PM ); +if (IS_ERR (req)) +return PTR_ERR (req); + + scmd =blk_mq_rq_to_pdu (req); + scmd->cmd_len = cmd_len; +memcpy (scmd->cmnd, cmd, cmd_len); + scmd->allowed = sdkp->max_retries; + req->timeout =SD_TIMEOUT ; + req->rq_flags |=RQF_PM |RQF_QUIET ; + req->end_io = sd_start_done; +blk_execute_rq_nowait (req,/*at_head=*/ true); + +return 0 ; +} +static int sd_start_stop_device (struct scsi_disk *sdkp,int start) {unsigned char cmd[6 ] = {START_STOP };/* START_VALID */ -struct scsi_sense_hdr sshdr;struct scsi_device *sdp = sdkp->device; -int res;if (start) cmd[4 ] |=1 ;/* START */
@@ -3601,23 +3660,10 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)if (!scsi_device_online (sdp))return -ENODEV ; - res =scsi_execute (sdp, cmd,DMA_NONE ,NULL ,0 ,NULL , &sshdr, -SD_TIMEOUT , sdkp->max_retries,0 ,RQF_PM ,NULL ); -if (res) { -sd_print_result (sdkp,"Start/Stop Unit failed" , res); -if (res >0 &&scsi_sense_valid (&sshdr)) { -sd_print_sense_hdr (sdkp, &sshdr); -/* 0x3a is medium not present */ -if (sshdr.asc ==0x3a ) - res =0 ; - } - } +/* Wait until processing of sense data has finished. */ +flush_work (&sdkp->start_done_work); -/* SCSI error codes must not go to the generic layer */ -if (res) -return -EIO ; - -return 0 ; +return sd_submit_start (sdkp, cmd,sizeof (cmd)); }/*
@@ -3644,6 +3690,8 @@ static void sd_shutdown(struct device *dev)sd_printk (KERN_NOTICE , sdkp,"Stopping disk\n" );sd_start_stop_device (sdkp,0 ); } + +flush_work (&sdkp->start_done_work); }static int sd_suspend_common (struct device *dev,bool ignore_stop_errors)
drivers/scsi/sd.h +5 -0
@@ -150,6 +150,11 @@ struct scsi_disk { unsigned urswrz : 1; unsigned security : 1; unsigned ignore_medium_access_errors : 1; + +int start_result; +u32 start_sense_len; +u8 start_sense_buffer[SCSI_SENSE_BUFFERSIZE ]; +struct work_struct start_done_work; };#define to_scsi_disk (obj) container_of(obj, struct scsi_disk, disk_dev)
Signature · 1 line
2.35.1
Re: [PATCH 5.19 0784/1157] scsi: sd: Rework asynchronous resume support
Quoted 10 lines · Greg Kroah-Hartman
From: Bart Van Assche <[email protected]>
[ Upstream commit
88f1669019bd62b3009a3cebf772fbaaa21b9f38]For some technologies, e.g. an ATA bus, resuming can take multiple seconds. Waiting for resume to finish can cause a very noticeable delay. Hence this commit that restores the behavior from before "scsi: core: pm:
Rely on the device driver core for async power management" for most SCSI devices.
Quoted 6 lines
This commit introduces a behavior change: if the START command fails, do not consider this as a SCSI disk resume failure.
Fixes a19a93e4c6a9 ("scsi: core: pm: Rely on the device driver core for async power management")
Hi Greg,
It has been reported that this patch causes a regression, namely disks not coming back after a resume. That issue is worse than the issue fixed by this patch - eliminating a delay. Please drop this patch from the stable tree.
A revert of this patch has been posted on the linux-scsi mailing list. See also https://lore.kernel.org/linux-scsi/[email protected]/.
Thanks,
Bart.
Greg Kroah-Hartman
maintainerRe: [PATCH 5.19 0784/1157] scsi: sd: Rework asynchronous resume support
Quoted 18 lines · Bart Van Assche
Quoted 10 lines · Greg Kroah-Hartman
From: Bart Van Assche <[email protected]>
[ Upstream commit
88f1669019bd62b3009a3cebf772fbaaa21b9f38]For some technologies, e.g. an ATA bus, resuming can take multiple seconds. Waiting for resume to finish can cause a very noticeable delay. Hence this commit that restores the behavior from before "scsi: core: pm:
Rely on the device driver core for async power management" for most SCSI devices.Quoted 6 lines
This commit introduces a behavior change: if the START command fails, do not consider this as a SCSI disk resume failure.
Fixes a19a93e4c6a9 ("scsi: core: pm: Rely on the device driver core for async power management")
Quoted 8 lines
Hi Greg,
It has been reported that this patch causes a regression, namely disks not coming back after a resume. That issue is worse than the issue fixed by this patch - eliminating a delay. Please drop this patch from the stable tree.
A revert of this patch has been posted on the linux-scsi mailing list. See also https://lore.kernel.org/linux-scsi/[email protected]/.
Now dropped from the queue, thanks.
greg k-h
Greg Kroah-Hartman
maintainerPATCH 785/1157 scsi: lpfc: Revert RSCN_MEMENTO workaround for misbehaved configuration
In reply to Greg Kroah-HartmanFrom: James Smart <[email protected]>
[ Upstream commit ffc566411aded3c12c63e1310fb23830e9608c59 ]
The RSCN_MEMENTO logic was to workaround a target that does not register both FCP and NVMe FC4 types at the same time. This caused the configuration to not produce a second RSCN for the NVMe FC4 type registration in a timely manner. The intention of the RSCN_MEMENTO flag was to always signal to try NVMe PRLI.
However, there are other FCP-only target arrays in correctly behaved configurations that reject the NVMe PRLI followed by a LOGO leading to never rediscovering the target after an issue_lip (as LOGO causes a repeat of PLOGI/PRLIs).
Revert the RSCN_MEMENTO patch as it is causing correctly behaved configs to fail while it exists only to succeed on a misbehaved config.
--- drivers/scsi/lpfc/lpfc.h | 1 - drivers/scsi/lpfc/lpfc_els.c | 8 ++------ drivers/scsi/lpfc/lpfc_hbadisc.c | 3 +-- 3 files changed, 3 insertions(+), 9 deletions(-)
drivers/scsi/lpfc/lpfc.h +0 -1
@@ -604,7 +604,6 @@ struct lpfc_vport {#define FC_VFI_REGISTERED 0x800000/* VFI is registered */ #define FC_FDISC_COMPLETED 0x1000000/* FDISC completed */ #define FC_DISC_DELAYED 0x2000000/* Delay NPort discovery */ -#define FC_RSCN_MEMENTO 0x4000000/* RSCN cmd processed */ uint32_t ct_flags;#define FC_CT_RFF_ID 0x1/* RFF_ID accepted by switch */
drivers/scsi/lpfc/lpfc_els.c +2 -6
@@ -1886,7 +1886,6 @@ lpfc_end_rscn(struct lpfc_vport *vport)else {spin_lock_irq (shost->host_lock); vport->fc_flag &= ~FC_RSCN_MODE ; - vport->fc_flag |=FC_RSCN_MEMENTO ;spin_unlock_irq (shost->host_lock); } }
@@ -2434,14 +2433,13 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,u32 local_nlp_type, elscmd;/* -* If discovery was kicked off from RSCN mode, -* the FC4 types supported from a +* If we are in RSCN mode, the FC4 types supported from a * previous GFT_ID command may not be accurate. So, if we * are a NVME Initiator, always look for the possibility of * the remote NPort beng a NVME Target. */ if (phba->sli_rev ==LPFC_SLI_REV4 && - vport->fc_flag & (FC_RSCN_MODE |FC_RSCN_MEMENTO ) && + vport->fc_flag &FC_RSCN_MODE && vport->nvmei_support) ndlp->nlp_fc4_type |=NLP_FC4_NVME ; local_nlp_type = ndlp->nlp_fc4_type;
@@ -7915,7 +7913,6 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,if ((rscn_cnt <FC_MAX_HOLD_RSCN ) && !(vport->fc_flag &FC_RSCN_DISCOVERY )) { vport->fc_flag |=FC_RSCN_MODE ; - vport->fc_flag &= ~FC_RSCN_MEMENTO ;spin_unlock_irq (shost->host_lock);if (rscn_cnt) { cmd = vport->fc_rscn_id_list[rscn_cnt-1 ]->virt;
@@ -7965,7 +7962,6 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,spin_lock_irq (shost->host_lock); vport->fc_flag |=FC_RSCN_MODE ; - vport->fc_flag &= ~FC_RSCN_MEMENTO ;spin_unlock_irq (shost->host_lock); vport->fc_rscn_id_list[vport->fc_rscn_id_cnt++] = pcmd;/* Indicate we are done walking fc_rscn_id_list on this vport */
drivers/scsi/lpfc/lpfc_hbadisc.c +1 -2
@@ -1354,8 +1354,7 @@ lpfc_linkup_port(struct lpfc_vport *vport)spin_lock_irq (shost->host_lock); vport->fc_flag &= ~(FC_PT2PT |FC_PT2PT_PLOGI |FC_ABORT_DISCOVERY | -FC_RSCN_MEMENTO |FC_RSCN_MODE | -FC_NLP_MORE |FC_RSCN_DISCOVERY ); +FC_RSCN_MODE |FC_NLP_MORE |FC_RSCN_DISCOVERY ); vport->fc_flag |=FC_NDISC_ACTIVE ; vport->fc_ns_retry =0 ;spin_unlock_irq (shost->host_lock);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 786/1157 intel_th: Fix a resource leak in an error handling path
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 086c28ab7c5699256aced0049aae9c42f1410313 ]
If an error occurs after calling 'pci_alloc_irq_vectors()', 'pci_free_irq_vectors()' must be called as already done in the remove function.
--- drivers/hwtracing/intel_th/pci.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/hwtracing/intel_th/pci.c +8 -2
@@ -100,8 +100,10 @@ static int intel_th_pci_probe(struct pci_dev *pdev, } th =intel_th_alloc (&pdev->dev, drvdata, resource, r); -if (IS_ERR (th)) -return PTR_ERR (th); +if (IS_ERR (th)) { + err =PTR_ERR (th); + goto err_free_irq; + } th->activate = intel_th_pci_activate; th->deactivate = intel_th_pci_deactivate;
@@ -109,6 +111,10 @@ static int intel_th_pci_probe(struct pci_dev *pdev,pci_set_master (pdev);return 0 ; + +err_free_irq: +pci_free_irq_vectors (pdev); +return err; }static void intel_th_pci_remove (struct pci_dev *pdev)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 787/1157 intel_th: msu-sink: Potential dereference of null pointer
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 82f76a4a720791d889de775b5f7541d601efc8bd ]
The return value of dma_alloc_coherent() needs to be checked. To avoid use of null pointer in sg_set_buf() in case of the failure of alloc.
--- drivers/hwtracing/intel_th/msu-sink.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hwtracing/intel_th/msu-sink.c +3 -0
@@ -71,6 +71,9 @@ static int msu_sink_alloc_window(void *data, struct sg_table **sgt, size_t size) block =dma_alloc_coherent (priv->dev->parent->parent,PAGE_SIZE , &sg_dma_address (sg_ptr),GFP_KERNEL ); +if (!block) +return -ENOMEM ; +sg_set_buf (sg_ptr, block,PAGE_SIZE ); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 788/1157 intel_th: msu: Fix vmalloced buffers
In reply to Greg Kroah-HartmanFrom: Alexander Shishkin <[email protected]>
[ Upstream commit ac12ad3ccf6d386e64a9d6a890595a2509d24edd ]
After commit f5ff79fddf0e ("dma-mapping: remove CONFIG_DMA_REMAP") there's a chance of DMA buffer getting allocated via vmalloc(), which messes up the mmapping code:
Quoted 5 lines
RIP: msc_mmap_fault [intel_th_msu] Call Trace: <TASK> __do_fault do_fault
...
Fix this by accounting for vmalloc possibility.
--- drivers/hwtracing/intel_th/msu.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/hwtracing/intel_th/msu.c +12 -2
@@ -1067,6 +1067,16 @@ msc_buffer_set_uc(struct msc *msc) {}static inline void msc_buffer_set_wb (struct msc *msc) {}#endif /* CONFIG_X86 */ +static struct page *msc_sg_page (struct scatterlist *sg) +{ +void *addr =sg_virt (sg); + +if (is_vmalloc_addr (addr)) +return vmalloc_to_page (addr); + +return sg_page (sg); +} +/** * msc_buffer_win_alloc() - alloc a window for a multiblock mode * @msc: MSC device
@@ -1137,7 +1147,7 @@ static void __msc_buffer_win_free(struct msc *msc, struct msc_window *win)int i;for_each_sg (win->sgt->sgl, sg, win->nr_segs, i) { -struct page *page =sg_page (sg); +struct page *page =msc_sg_page (sg); page->mapping =NULL ; dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE,
@@ -1401,7 +1411,7 @@ static struct page *msc_buffer_get_page(struct msc *msc, unsigned long pgoff) pgoff -= win->pgoff;for_each_sg (win->sgt->sgl, sg, win->nr_segs, blk) { -struct page *page =sg_page (sg); +struct page *page =msc_sg_page (sg);size_t pgsz =PFN_DOWN (sg->length);if (pgoff < pgsz)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 789/1157 binder: fix redefinition of seq_file attributes
In reply to Greg Kroah-HartmanFrom: Carlos Llamas <[email protected]>
[ Upstream commit b7e241bbff24f9e106bf616408fd58bcedc44bae ]
The patchset in [1] exported some definitions to binder_internal.h in order to make the debugfs entries such as 'stats' and 'transaction_log' available in a binderfs instance. However, the DEFINE_SHOW_ATTRIBUTE macro expands into a static function/variable pair, which in turn get redefined each time a source file includes this internal header.
This problem was made evident after a report from the kernel test robot <[email protected]> where several W=1 build warnings are seen in downstream kernels. See the following example:
include/../drivers/android/binder_internal.h:111:23: warning: 'binder_stats_fops' defined but not used [-Wunused-const-variable=]
111 | DEFINE_SHOW_ATTRIBUTE(binder_stats);
| ^~~~~~~~~~~~
include/linux/seq_file.h:174:37: note: in definition of macro 'DEFINE_SHOW_ATTRIBUTE'
174 | static const struct file_operations __name ## _fops = { \
| ^~~~~~This patch fixes the above issues by moving back the definitions into binder.c and instead creates an array of the debugfs entries which is more convenient to share with binderfs and iterate through.
[1] https://lore.kernel.org/all/[email protected]/
--- drivers/android/binder.c | 114 +++++++++++++++++++++--------- drivers/android/binder_internal.h | 46 +++--------- drivers/android/binderfs.c | 47 +++--------- 3 files changed, 100 insertions(+), 107 deletions(-)
drivers/android/binder.c +79 -35
@@ -197,8 +197,32 @@ static inline void binder_stats_created(enum binder_stat_types type)atomic_inc (&binder_stats.obj_created[type]); } -struct binder_transaction_log binder_transaction_log; -struct binder_transaction_log binder_transaction_log_failed; +struct binder_transaction_log_entry { +int debug_id; +int debug_id_done; +int call_type; +int from_proc; +int from_thread; +int target_handle; +int to_proc; +int to_thread; +int to_node; +int data_size; +int offsets_size; +int return_error_line; +uint32_t return_error; +uint32_t return_error_param; +char context_name[BINDERFS_MAX_NAME +1 ]; +}; + +struct binder_transaction_log { +atomic_t cur; +bool full; +struct binder_transaction_log_entry entry[32 ]; +}; + +static struct binder_transaction_log binder_transaction_log; +static struct binder_transaction_log binder_transaction_log_failed;static struct binder_transaction_log_entry *binder_transaction_log_add (struct binder_transaction_log *log)
@@ -6197,8 +6221,7 @@ static void print_binder_proc_stats(struct seq_file *m,print_binder_stats (m," " , &proc->stats); } - -int binder_state_show (struct seq_file *m,void *unused) +static int state_show (struct seq_file *m,void *unused) {struct binder_proc *proc;struct binder_node *node;
@@ -6237,7 +6260,7 @@ int binder_state_show(struct seq_file *m, void *unused)return 0 ; } -int binder_stats_show (struct seq_file *m,void *unused) +static int stats_show (struct seq_file *m,void *unused) {struct binder_proc *proc;
@@ -6253,7 +6276,7 @@ int binder_stats_show(struct seq_file *m, void *unused)return 0 ; } -int binder_transactions_show (struct seq_file *m,void *unused) +static int transactions_show (struct seq_file *m,void *unused) {struct binder_proc *proc;
@@ -6309,7 +6332,7 @@ static void print_binder_transaction_log_entry(struct seq_file *m, "\n" : " (incomplete)\n"); } -int binder_transaction_log_show (struct seq_file *m,void *unused) +static int transaction_log_show (struct seq_file *m,void *unused) {struct binder_transaction_log *log = m->private;unsigned int log_cur =atomic_read (&log->cur);
@@ -6341,6 +6364,45 @@ const struct file_operations binder_fops = { .release = binder_release, }; +DEFINE_SHOW_ATTRIBUTE (state); +DEFINE_SHOW_ATTRIBUTE (stats); +DEFINE_SHOW_ATTRIBUTE (transactions); +DEFINE_SHOW_ATTRIBUTE (transaction_log); + +const struct binder_debugfs_entry binder_debugfs_entries[] = { + { + .name ="state" , + .mode =0444 , + .fops = &state_fops, + .data =NULL , + }, + { + .name ="stats" , + .mode =0444 , + .fops = &stats_fops, + .data =NULL , + }, + { + .name ="transactions" , + .mode =0444 , + .fops = &transactions_fops, + .data =NULL , + }, + { + .name ="transaction_log" , + .mode =0444 , + .fops = &transaction_log_fops, + .data = &binder_transaction_log, + }, + { + .name ="failed_transaction_log" , + .mode =0444 , + .fops = &transaction_log_fops, + .data = &binder_transaction_log_failed, + }, + {}/* terminator */ +}; +static int __init init_binder_device (const char *name) {int ret;
@@ -6386,36 +6448,18 @@ static int __init binder_init(void)atomic_set (&binder_transaction_log_failed.cur, ~0U ); binder_debugfs_dir_entry_root =debugfs_create_dir ("binder" ,NULL ); -if (binder_debugfs_dir_entry_root) +if (binder_debugfs_dir_entry_root) { +const struct binder_debugfs_entry *db_entry; + +binder_for_each_debugfs_entry (db_entry) +debugfs_create_file (db_entry->name, + db_entry->mode, + binder_debugfs_dir_entry_root, + db_entry->data, + db_entry->fops); + binder_debugfs_dir_entry_proc =debugfs_create_dir ("proc" , binder_debugfs_dir_entry_root); - -if (binder_debugfs_dir_entry_root) { -debugfs_create_file ("state" , -0444 , - binder_debugfs_dir_entry_root, -NULL , - &binder_state_fops); -debugfs_create_file ("stats" , -0444 , - binder_debugfs_dir_entry_root, -NULL , - &binder_stats_fops); -debugfs_create_file ("transactions" , -0444 , - binder_debugfs_dir_entry_root, -NULL , - &binder_transactions_fops); -debugfs_create_file ("transaction_log" , -0444 , - binder_debugfs_dir_entry_root, - &binder_transaction_log, - &binder_transaction_log_fops); -debugfs_create_file ("failed_transaction_log" , -0444 , - binder_debugfs_dir_entry_root, - &binder_transaction_log_failed, - &binder_transaction_log_fops); } if (!IS_ENABLED(CONFIG_ANDROID_BINDERFS) &&
drivers/android/binder_internal.h +11 -35
58 lines not on this page · raw message
drivers/android/binderfs.c +10 -37
59 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 790/1157 staging: rtl8192u: Fix sleep in atomic context bug in dm_fsync_timer_callback
In reply to Greg Kroah-HartmanFrom: Duoming Zhou <[email protected]>
[ Upstream commit 6a0c054930d554ad8f8044ef1fc856d9da391c81 ]
There are sleep in atomic context bugs when dm_fsync_timer_callback is executing. The root cause is that the memory allocation functions with GFP_KERNEL or GFP_NOIO parameters are called in dm_fsync_timer_callback which is a timer handler. The call paths that could trigger bugs are shown below:
(interrupt context)dm_fsync_timer_callback
write_nic_byte
kzalloc(sizeof(data), GFP_KERNEL); //may sleep usb_control_msg
kmalloc(.., GFP_NOIO); //may sleep
write_nic_dword
kzalloc(sizeof(data), GFP_KERNEL); //may sleep usb_control_msg
kmalloc(.., GFP_NOIO); //may sleep
This patch uses delayed work to replace timer and moves the operations that may sleep into the delayed work in order to mitigate bugs.
--- drivers/staging/rtl8192u/r8192U.h | 2 +- drivers/staging/rtl8192u/r8192U_dm.c | 38 +++++++++++++--------------- drivers/staging/rtl8192u/r8192U_dm.h | 2 +- 3 files changed, 20 insertions(+), 22 deletions(-)
drivers/staging/rtl8192u/r8192U.h +1 -1
@@ -1013,7 +1013,7 @@ typedef struct r8192_priv {bool bis_any_nonbepkts;bool bcurrent_turbo_EDCA;bool bis_cur_rdlstate; -struct timer_list fsync_timer; +struct delayed_work fsync_work;bool bfsync_processing;/* 500ms Fsync timer is active or not */ u32 rate_record;u32 rateCountDiffRecord;
drivers/staging/rtl8192u/r8192U_dm.c +18 -20
@@ -2578,19 +2578,20 @@ static void dm_init_fsync(struct net_device *dev) priv->ieee80211->fsync_seconddiff_ratethreshold =200 ; priv->ieee80211->fsync_state = Default_Fsync; priv->framesyncMonitor =1 ;/* current default 0xc38 monitor on */ -timer_setup (&priv->fsync_timer, dm_fsync_timer_callback,0 ); +INIT_DELAYED_WORK (&priv->fsync_work, dm_fsync_work_callback); }static void dm_deInit_fsync (struct net_device *dev) {struct r8192_priv *priv =ieee80211_priv (dev); -del_timer_sync (&priv->fsync_timer); +cancel_delayed_work_sync (&priv->fsync_work); } -void dm_fsync_timer_callback (struct timer_list *t) +void dm_fsync_work_callback (struct work_struct *work) { -struct r8192_priv *priv =from_timer (priv, t, fsync_timer); +struct r8192_priv *priv = + container_of(work, struct r8192_priv, fsync_work.work);struct net_device *dev = priv->ieee80211->dev;u32 rate_index, rate_count =0 , rate_count_diff =0 ;bool bSwitchFromCountDiff = false;
@@ -2657,17 +2658,16 @@ void dm_fsync_timer_callback(struct timer_list *t) } }if (bDoubleTimeInterval) { -if (timer_pending (&priv->fsync_timer)) -del_timer_sync (&priv->fsync_timer); - priv->fsync_timer.expires = jiffies + -msecs_to_jiffies (priv->ieee80211->fsync_time_interval*priv->ieee80211->fsync_multiple_timeinterval); -add_timer (&priv->fsync_timer); +cancel_delayed_work_sync (&priv->fsync_work); +schedule_delayed_work (&priv->fsync_work, +msecs_to_jiffies (priv + ->ieee80211->fsync_time_interval * + priv->ieee80211->fsync_multiple_timeinterval)); }else { -if (timer_pending (&priv->fsync_timer)) -del_timer_sync (&priv->fsync_timer); - priv->fsync_timer.expires = jiffies + -msecs_to_jiffies (priv->ieee80211->fsync_time_interval); -add_timer (&priv->fsync_timer); +cancel_delayed_work_sync (&priv->fsync_work); +schedule_delayed_work (&priv->fsync_work, +msecs_to_jiffies (priv + ->ieee80211->fsync_time_interval)); } }else {/* Let Register return to default value; */
@@ -2695,7 +2695,7 @@ static void dm_EndSWFsync(struct net_device *dev)struct r8192_priv *priv =ieee80211_priv (dev);RT_TRACE (COMP_HALDM ,"%s\n" , __func__); -del_timer_sync (&(priv->fsync_timer)); +cancel_delayed_work_sync (&priv->fsync_work);/* Let Register return to default value; */ if (priv->bswitch_fsync) {
@@ -2736,11 +2736,9 @@ static void dm_StartSWFsync(struct net_device *dev)if (priv->ieee80211->fsync_rate_bitmap & rateBitmap) priv->rate_record += priv->stats.received_rate_histogram[1 ][rateIndex]; } -if (timer_pending (&priv->fsync_timer)) -del_timer_sync (&priv->fsync_timer); - priv->fsync_timer.expires = jiffies + -msecs_to_jiffies (priv->ieee80211->fsync_time_interval); -add_timer (&priv->fsync_timer); +cancel_delayed_work_sync (&priv->fsync_work); +schedule_delayed_work (&priv->fsync_work, +msecs_to_jiffies (priv->ieee80211->fsync_time_interval));write_nic_dword (dev, rOFDM0_RxDetector2,0x465c12cd ); }
drivers/staging/rtl8192u/r8192U_dm.h +1 -1
@@ -166,7 +166,7 @@ void dm_force_tx_fw_info(struct net_device *dev,void dm_init_edca_turbo (struct net_device *dev);void dm_rf_operation_test_callback (unsigned long data);void dm_rf_pathcheck_workitemcallback (struct work_struct *work); -void dm_fsync_timer_callback (struct timer_list *t); +void dm_fsync_work_callback (struct work_struct *work);void dm_cck_txpower_adjust (struct net_device *dev,bool binch14);void dm_shadow_init (struct net_device *dev);void dm_initialize_txpower_tracking (struct net_device *dev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 791/1157 rtla/utils: Use calloc and check the potential memory allocation failure
In reply to Greg Kroah-HartmanFrom: jianchunfu <[email protected]>
[ Upstream commit b5f37a0b6f667f5c72340ca9dcd7703f261cb981 ]
Replace malloc with calloc and add memory allocating check of mon_cpus before used.
--- tools/tracing/rtla/src/utils.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/tracing/rtla/src/utils.c +3 -2
@@ -106,8 +106,9 @@ int parse_cpu_list(char *cpu_list, char **monitored_cpus) nr_cpus =sysconf (_SC_NPROCESSORS_CONF); - mon_cpus =malloc (nr_cpus *sizeof (char )); -memset (mon_cpus,0 , (nr_cpus *sizeof (char ))); + mon_cpus =calloc (nr_cpus,sizeof (char )); +if (!mon_cpus) + goto err;for (p = cpu_list; *p; ) { cpu =atoi (p);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 792/1157 habanalabs: fix double unlock on error in map_device_va()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit a43a9f67774adbd575d10ec88824016fbe034777 ]
If hl_mmu_prefetch_cache_range() fails then this code calls mutex_unlock(&ctx->mmu_lock) when it's no longer holding the mutex.
--- drivers/misc/habanalabs/common/memory.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/misc/habanalabs/common/memory.c +2 -4
@@ -1245,16 +1245,16 @@ static int map_device_va(struct hl_ctx *ctx, struct hl_mem_in *args, u64 *device rc =map_phys_pg_pack (ctx, ret_vaddr, phys_pg_pack);if (rc) {dev_err (hdev->dev,"mapping page pack failed for handle %u\n" , handle); +mutex_unlock (&ctx->mmu_lock); goto map_err; } rc =hl_mmu_invalidate_cache_range (hdev, false, *vm_type |MMU_OP_SKIP_LOW_CACHE_INV , ctx->asid, ret_vaddr, phys_pg_pack->total_size); +mutex_unlock (&ctx->mmu_lock);if (rc) goto map_err; -mutex_unlock (&ctx->mmu_lock); -/* * prefetch is done upon user's request. it is performed in WQ as and so can * be outside the MMU lock. the operation itself is already protected by the mmu lock
@@ -1283,8 +1283,6 @@ static int map_device_va(struct hl_ctx *ctx, struct hl_mem_in *args, u64 *devicereturn rc; map_err: -mutex_unlock (&ctx->mmu_lock); -if (add_va_block (hdev, va_range, ret_vaddr, ret_vaddr + phys_pg_pack->total_size -1 )) dev_warn(hdev->dev,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 793/1157 dt-bindings: mmc: sdhci-msm: Fix issues in yaml bindings
In reply to Greg Kroah-HartmanFrom: Bhupesh Sharma <[email protected]>
[ Upstream commit 8574adf5222d786b747022c6edcbcdddf409a139 ]
Rob pointed some remaining issues in the sdhci-msm yaml bindings (via [1]).
Fix the same by first using the 'mmc-controller.yaml' as 'ref' and thereafter also fix the issues reported by 'make dtbs_check' check.
[1]. https://lore.kernel.org/linux-arm-msm/[email protected]/
--- .../devicetree/bindings/mmc/sdhci-msm.yaml | 52 ++++++++++++++++--- 1 file changed, 44 insertions(+), 8 deletions(-)
Documentation/devicetree/bindings/mmc/sdhci-msm.yaml +44 -8
@@ -17,6 +17,9 @@ description: properties: compatible: oneOf: + - enum: + - qcom,sdhci-msm-v4 + deprecated: true - items: - enum: - qcom,apq8084-sdhci
@@ -27,6 +30,9 @@ properties: - qcom,msm8992-sdhci - qcom,msm8994-sdhci - qcom,msm8996-sdhci + - const: qcom,sdhci-msm-v4 # for sdcc versions less than 5.0 + - items: + - enum: - qcom,qcs404-sdhci - qcom,sc7180-sdhci - qcom,sc7280-sdhci
@@ -38,12 +44,7 @@ properties: - qcom,sm6350-sdhci - qcom,sm8150-sdhci - qcom,sm8250-sdhci - - enum: - - qcom,sdhci-msm-v4 # for sdcc versions less than 5.0 - - qcom,sdhci-msm-v5 # for sdcc version 5.0 - - items: - - const: qcom,sdhci-msm-v4 # Deprecated (only for backward compatibility) - # for sdcc versions less than 5.0 + - const: qcom,sdhci-msm-v5 # for sdcc version 5.0 reg: minItems: 1
@@ -53,6 +54,28 @@ properties: - description: CQE register map - description: Inline Crypto Engine register map + reg-names: + minItems: 1 + maxItems: 4 + oneOf: + - items: + - const: hc_mem + - items: + - const: hc_mem + - const: core_mem + - items: + - const: hc_mem + - const: cqe_mem + - items: + - const: hc_mem + - const: cqe_mem + - const: ice_mem + - items: + - const: hc_mem + - const: core_mem + - const: cqe_mem + - const: ice_mem + clocks: minItems: 3 items:
@@ -121,6 +144,16 @@ properties: description: A phandle to sdhci power domain node maxItems: 1 + mmc-ddr-1_8v: true + + mmc-hs200-1_8v: true + + mmc-hs400-1_8v: true + + bus-width: true + + max-frequency: true + patternProperties: '^opp-table(-[a-z0-9]+)?$': if:
@@ -140,7 +173,10 @@ required: - clock-names - interrupts -additionalProperties: true +allOf: + - $ref: mmc-controller.yaml# + +unevaluatedProperties: false examples: - |
@@ -149,7 +185,7 @@ examples: #include <dt-bindings/clock/qcom,rpmh.h> #include <dt-bindings/power/qcom-rpmpd.h> - sdhc_2: sdhci@8804000 { + sdhc_2: mmc@8804000 { compatible = "qcom,sm8250-sdhci", "qcom,sdhci-msm-v5"; reg = <0 0x08804000 0 0x1000>;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 794/1157 mmc: sdhci-of-esdhc: Fix refcount leak in esdhc_signal_voltage_switch
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit b5899a3e2f783a27b268e38d37f9b24c71bddf45 ]
of_find_matching_node() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() to avoid refcount leak. of_node_put() checks null pointer.
--- drivers/mmc/host/sdhci-of-esdhc.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/host/sdhci-of-esdhc.c +1 -0
@@ -904,6 +904,7 @@ static int esdhc_signal_voltage_switch(struct mmc_host *mmc, scfg_node =of_find_matching_node (NULL , scfg_device_ids);if (scfg_node) scfg_base =of_iomap (scfg_node,0 ); +of_node_put (scfg_node);if (scfg_base) { sdhciovselcr =SDHCIOVSELCR_TGLEN |SDHCIOVSELCR_VSELVAL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 795/1157 mmc: mxcmmc: Silence a clang warning
In reply to Greg Kroah-HartmanFrom: Fabio Estevam <[email protected]>
[ Upstream commit 7dc65e3c0ef4b746a583b7c58f99873fddf5ccfa ]
Change the of_device_get_match_data() cast to (uintptr_t) to silence the following clang warning:
drivers/mmc/host/mxcmmc.c:1028:18: warning: cast to smaller integer type 'enum mxcmci_type' from 'const void *' [-Wvoid-pointer-to-enum-cast]
--- drivers/mmc/host/mxcmmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/mxcmmc.c +1 -1
@@ -1025,7 +1025,7 @@ static int mxcmci_probe(struct platform_device *pdev) mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; mmc->max_seg_size = mmc->max_req_size; - host->devtype = (enum mxcmci_type )of_device_get_match_data (&pdev->dev); + host->devtype = (uintptr_t )of_device_get_match_data (&pdev->dev);/* adjust max_segs after devtype detection */ if (!is_mpc512x_mmc (host))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 796/1157 mmc: renesas_sdhi: Get the reset handle early in the probe
In reply to Greg Kroah-HartmanFrom: Lad Prabhakar <[email protected]>
[ Upstream commit 0dac1e498f8130fdacfdd5289e3a7ac87ec1b9ad ]
In case of devm_reset_control_get_optional_exclusive() failure we returned directly instead of jumping to the error path to roll back initialization.
This patch moves devm_reset_control_get_optional_exclusive() early in the probe so that we have the reset handle prior to initialization of the hardware.
--- drivers/mmc/host/renesas_sdhi_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/host/renesas_sdhi_core.c +4 -4
@@ -938,6 +938,10 @@ int renesas_sdhi_probe(struct platform_device *pdev,if (IS_ERR (priv->clk_cd))return dev_err_probe (&pdev->dev,PTR_ERR (priv->clk_cd),"cannot get cd clock" ); + priv->rstc =devm_reset_control_get_optional_exclusive (&pdev->dev,NULL ); +if (IS_ERR (priv->rstc)) +return PTR_ERR (priv->rstc); + priv->pinctrl =devm_pinctrl_get (&pdev->dev);if (!IS_ERR (priv->pinctrl)) { priv->pins_default = pinctrl_lookup_state(priv->pinctrl,
@@ -1030,10 +1034,6 @@ int renesas_sdhi_probe(struct platform_device *pdev,if (ret) goto efree; - priv->rstc =devm_reset_control_get_optional_exclusive (&pdev->dev,NULL ); -if (IS_ERR (priv->rstc)) -return PTR_ERR (priv->rstc); - ver =sd_ctrl_read16 (host,CTL_VERSION );/* GEN2_SDR104 is first known SDHI to use 32bit block count */ if (ver <SDHI_VER_GEN2_SDR104 && mmc_data->max_blk_count >U16_MAX )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 797/1157 memstick/ms_block: Fix some incorrect memory allocation
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 2e531bc3e0d86362fcd8a577b3278d9ef3cc2ba0 ]
Some functions of the bitmap API take advantage of the fact that a bitmap is an array of long.
So, to make sure this assertion is correct, allocate bitmaps with bitmap_zalloc() instead of kzalloc()+hand-computed number of bytes.
While at it, also use bitmap_free() instead of kfree() to keep the semantic.
--- drivers/memstick/core/ms_block.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/memstick/core/ms_block.c +5 -5
@@ -1341,17 +1341,17 @@ static int msb_ftl_initialize(struct msb_data *msb) msb->zone_count = msb->block_count /MS_BLOCKS_IN_ZONE ; msb->logical_block_count = msb->zone_count *496 -2 ; - msb->used_blocks_bitmap =kzalloc (msb->block_count /8 ,GFP_KERNEL ); - msb->erased_blocks_bitmap =kzalloc (msb->block_count /8 ,GFP_KERNEL ); + msb->used_blocks_bitmap =bitmap_zalloc (msb->block_count,GFP_KERNEL ); + msb->erased_blocks_bitmap =bitmap_zalloc (msb->block_count,GFP_KERNEL ); msb->lba_to_pba_table =kmalloc_array (msb->logical_block_count,sizeof (u16),GFP_KERNEL );if (!msb->used_blocks_bitmap || !msb->lba_to_pba_table || !msb->erased_blocks_bitmap) { -kfree (msb->used_blocks_bitmap); +bitmap_free (msb->used_blocks_bitmap); +bitmap_free (msb->erased_blocks_bitmap);kfree (msb->lba_to_pba_table); -kfree (msb->erased_blocks_bitmap);return -ENOMEM ; }
@@ -1946,7 +1946,7 @@ static DEFINE_MUTEX(msb_disk_lock); /* protects against races in open/release */static void msb_data_clear (struct msb_data *msb) {kfree (msb->boot_page); -kfree (msb->used_blocks_bitmap); +bitmap_free (msb->used_blocks_bitmap);kfree (msb->lba_to_pba_table);kfree (msb->cache); msb->card =NULL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 798/1157 memstick/ms_block: Fix a memory leak
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 54eb7a55be6779c4d0c25eaf5056498a28595049 ]
'erased_blocks_bitmap' is never freed. As it is allocated at the same time as 'used_blocks_bitmap', it is likely that it should be freed also at the same time.
Add the corresponding bitmap_free() in msb_data_clear().
--- drivers/memstick/core/ms_block.c | 1 + 1 file changed, 1 insertion(+)
drivers/memstick/core/ms_block.c +1 -0
@@ -1947,6 +1947,7 @@ static void msb_data_clear(struct msb_data *msb) {kfree (msb->boot_page);bitmap_free (msb->used_blocks_bitmap); +bitmap_free (msb->erased_blocks_bitmap);kfree (msb->lba_to_pba_table);kfree (msb->cache); msb->card =NULL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 799/1157 mmc: sdhci-of-at91: fix set_uhs_signaling rewriting of MC1R
In reply to Greg Kroah-HartmanFrom: Eugen Hristev <[email protected]>
[ Upstream commit 5987e6ded29d52e42fc7b06aa575c60a25eee38e ]
In set_uhs_signaling, the DDR bit is being set by fully writing the MC1R register.
This can lead to accidental erase of certain bits in this register. Avoid this by doing a read-modify-write operation.
--- drivers/mmc/host/sdhci-of-at91.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-of-at91.c +7 -2
@@ -100,8 +100,13 @@ static void sdhci_at91_set_clock(struct sdhci_host *host, unsigned int clock)static void sdhci_at91_set_uhs_signaling (struct sdhci_host *host,unsigned int timing) { -if (timing ==MMC_TIMING_MMC_DDR52 ) -sdhci_writeb (host,SDMMC_MC1R_DDR ,SDMMC_MC1R ); +u8 mc1r; + +if (timing ==MMC_TIMING_MMC_DDR52 ) { + mc1r =sdhci_readb (host,SDMMC_MC1R ); + mc1r |=SDMMC_MC1R_DDR ; +sdhci_writeb (host, mc1r,SDMMC_MC1R ); + }sdhci_set_uhs_signaling (host, timing); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 800/1157 of: device: Fix missing of_node_put() in of_dma_set_restricted_buffer
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit d17e37c41b7ed38459957a5d2968ba61516fd5c2 ]
We should use of_node_put() for the reference 'node' returned by of_parse_phandle() which will increase the refcount.
--- drivers/of/device.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/of/device.c +4 -1
@@ -81,8 +81,11 @@ of_dma_set_restricted_buffer(struct device *dev, struct device_node *np)* restricted-dma-pool region is allowed. */ if (of_device_is_compatible (node,"restricted-dma-pool" ) && -of_device_is_available (node)) +of_device_is_available (node)) { +of_node_put (node);break ; + } +of_node_put (node); }/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 801/1157 mmc: block: Add single read for 4k sector cards
In reply to Greg Kroah-HartmanFrom: Christian Loehle <[email protected]>
[ Upstream commit b3fa3e6dccc465969721b8bd2824213bd235efeb ]
Cards with 4k native sector size may only be read 4k-aligned, accommodate for this in the single read recovery and use it.
--- drivers/mmc/core/block.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/mmc/core/block.c +14 -14
@@ -176,7 +176,7 @@ static inline int mmc_blk_part_switch(struct mmc_card *card, unsigned int part_type);static void mmc_blk_rw_rq_prep (struct mmc_queue_req *mqrq,struct mmc_card *card, -int disable_multi, +int recovery_mode,struct mmc_queue *mq);static void mmc_blk_hsq_req_done (struct mmc_request *mrq);
@@ -1302,7 +1302,7 @@ static void mmc_blk_eval_resp_error(struct mmc_blk_request *brq) }static void mmc_blk_data_prep (struct mmc_queue *mq,struct mmc_queue_req *mqrq, -int disable_multi,bool *do_rel_wr_p, +int recovery_mode,bool *do_rel_wr_p,bool *do_data_tag_p) {struct mmc_blk_data *md = mq->blkdata;
@@ -1368,12 +1368,12 @@ static void mmc_blk_data_prep(struct mmc_queue *mq, struct mmc_queue_req *mqrq, brq->data.blocks--;/* -* After a read error, we redo the request one sector +* After a read error, we redo the request one (native) sector * at a time in order to accurately determine which * sectors can be read successfully. */ -if (disable_multi) - brq->data.blocks =1 ; +if (recovery_mode) + brq->data.blocks =queue_physical_block_size (mq->queue) >>9 ;/* * Some controllers have HW issues while operating
@@ -1590,7 +1590,7 @@ static int mmc_blk_cqe_issue_rw_rq(struct mmc_queue *mq, struct request *req)static void mmc_blk_rw_rq_prep (struct mmc_queue_req *mqrq,struct mmc_card *card, -int disable_multi, +int recovery_mode,struct mmc_queue *mq) {u32 readcmd, writecmd;
@@ -1599,7 +1599,7 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,struct mmc_blk_data *md = mq->blkdata;bool do_rel_wr, do_data_tag; -mmc_blk_data_prep (mq, mqrq, disable_multi, &do_rel_wr, &do_data_tag); +mmc_blk_data_prep (mq, mqrq, recovery_mode, &do_rel_wr, &do_data_tag); brq->mrq.cmd = &brq->cmd;
@@ -1690,7 +1690,7 @@ static int mmc_blk_fix_state(struct mmc_card *card, struct request *req)#define MMC_READ_SINGLE_RETRIES 2 -/* Single sector read during recovery */ +/* Single (native) sector read during recovery */ static void mmc_blk_read_single (struct mmc_queue *mq,struct request *req) {struct mmc_queue_req *mqrq =req_to_mmc_queue_req (req);
@@ -1698,6 +1698,7 @@ static void mmc_blk_read_single(struct mmc_queue *mq, struct request *req)struct mmc_card *card = mq->card;struct mmc_host *host = card->host;blk_status_t error =BLK_STS_OK ; +size_t bytes_per_read =queue_physical_block_size (mq->queue); do { u32 status;
@@ -1732,13 +1733,13 @@ static void mmc_blk_read_single(struct mmc_queue *mq, struct request *req)else error =BLK_STS_OK ; - }while (blk_update_request (req, error,512 )); + }while (blk_update_request (req, error, bytes_per_read));return ; error_exit: mrq->data->bytes_xfered =0 ; -blk_update_request (req,BLK_STS_IOERR ,512 ); +blk_update_request (req,BLK_STS_IOERR , bytes_per_read);/* Let it try the remaining request again */ if (mqrq->retries >MMC_MAX_RETRIES -1 ) mqrq->retries =MMC_MAX_RETRIES -1 ;
@@ -1879,10 +1880,9 @@ static void mmc_blk_mq_rw_recovery(struct mmc_queue *mq, struct request *req)return ; } -/* FIXME: Missing single sector read for large sector size */ -if (!mmc_large_sector (card) &&rq_data_dir (req) ==READ && - brq->data.blocks >1 ) { -/* Read one sector at a time */ +if (rq_data_dir (req) ==READ && brq->data.blocks > +queue_physical_block_size (mq->queue) >>9 ) { +/* Read one (native) sector at a time */ mmc_blk_read_single (mq, req);return ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 802/1157 KVM: s390: pv: leak the topmost page table when destroy fails
In reply to Greg Kroah-HartmanFrom: Claudio Imbrenda <[email protected]>
[ Upstream commit faa2f72cb3569256480c5540d242c84e99965160 ]
Each secure guest must have a unique ASCE (address space control element); we must avoid that new guests use the same page for their ASCE, to avoid errors.
Since the ASCE mostly consists of the address of the topmost page table (plus some flags), we must not return that memory to the pool unless the ASCE is no longer in use.
Only a successful Destroy Secure Configuration UVC will make the ASCE reusable again.
If the Destroy Configuration UVC fails, the ASCE cannot be reused for a secure guest (either for the ASCE or for other memory areas). To avoid a collision, it must not be used again. This is a permanent error and the page becomes in practice unusable, so we set it aside and leak it. On failure we already leak other memory that belongs to the ultravisor (i.e. the variable and base storage for a guest) and not leaking the topmost page table was an oversight.
This error (and thus the leakage) should not happen unless the hardware is broken or KVM has some unknown serious bug.
Message-Id: <[email protected]>
--- arch/s390/include/asm/gmap.h | 2 + arch/s390/kvm/pv.c | 9 ++-- arch/s390/mm/gmap.c | 86 ++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 3 deletions(-)
arch/s390/include/asm/gmap.h +2 -0
@@ -148,4 +148,6 @@ void gmap_sync_dirty_log_pmd(struct gmap *gmap, unsigned long dirty_bitmap[4], unsigned long gaddr, unsigned long vmaddr);int gmap_mark_unmergeable (void );void s390_reset_acc (struct mm_struct *mm); +void s390_unlist_old_asce (struct gmap *gmap); +int s390_replace_asce (struct gmap *gmap);#endif /* _ASM_S390_GMAP_H */
arch/s390/kvm/pv.c +6 -3
@@ -161,10 +161,13 @@ int kvm_s390_pv_deinit_vm(struct kvm *kvm, u16 *rc, u16 *rrc)atomic_set (&kvm->mm->context.is_protected,0 );KVM_UV_EVENT (kvm,3 ,"PROTVIRT DESTROY VM: rc %x rrc %x" , *rc, *rrc);WARN_ONCE (cc,"protvirt destroy vm failed rc %x rrc %x" , *rc, *rrc); -/* Inteded memory leak on "impossible" error */ -if (!cc) +/* Intended memory leak on "impossible" error */ +if (!cc) {kvm_s390_pv_dealloc_vm (kvm); -return cc ? -EIO :0 ; +return 0 ; + } +s390_replace_asce (kvm->arch.gmap); +return -EIO ; }int kvm_s390_pv_init_vm (struct kvm *kvm,u16 *rc,u16 *rrc)
arch/s390/mm/gmap.c +86 -0
89 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 803/1157 PCI/portdrv: Dont disable AER reporting in get_port_device_capability()
In reply to Greg Kroah-HartmanFrom: Stefan Roese <[email protected]>
[ Upstream commit 8795e182b02dc87e343c79e73af6b8b7f9c5e635 ]
AER reporting is currently disabled in the DevCtl registers of all non Root Port PCIe devices on systems using pcie_ports_native || host->native_aer, disabling AER completely in such systems. This is because 2bd50dd800b5 ("PCI: PCIe: Disable PCIe port services during port initialization"), added a call to pci_disable_pcie_error_reporting() *after* the AER setup was completed for the PCIe device tree.
Here a longer analysis about the current status of AER enabling / disabling upon bootup provided by Bjorn:
pcie_portdrv_probe
pcie_port_device_register
get_port_device_capability
pci_disable_pcie_error_reporting
clear CERE NFERE FERE URRE # <-- disable for RP USP DSP
pcie_device_init
device_register # new AER service device
aer_probe
aer_enable_rootport # RP only
set_downstream_devices_error_reporting
set_device_error_reporting # self (RP)
if (RP || USP || DSP)
pci_enable_pcie_error_reporting
set CERE NFERE FERE URRE # <-- enable for RP
pci_walk_bus
set_device_error_reporting
if (RP || USP || DSP)
pci_enable_pcie_error_reporting
set CERE NFERE FERE URRE # <-- enable for USP DSP
In a typical Root Port -> Endpoint hierarchy, the above:
- Disables Error Reporting for the Root Port,
- Enables Error Reporting for the Root Port,
- Does NOT enable Error Reporting for the Endpoint because it is not a Root Port or Switch Port.
In a deeper Root Port -> Upstream Switch Port -> Downstream Switch Port -> Endpoint hierarchy:
- Disables Error Reporting for the Root Port,
- Enables Error Reporting for the Root Port,
- Enables Error Reporting for both Switch Ports,
- Does NOT enable Error Reporting for the Endpoint because it is not a Root Port or Switch Port,
- Disables Error Reporting for the Switch Ports when pcie_portdrv_probe() claims them. AER does not re-enable it because these are not Root Ports.
Remove this call to pci_disable_pcie_error_reporting() from get_port_device_capability(), leaving the already enabled AER configuration intact. With this change, AER is enabled in the Root Port and the PCIe switch upstream and downstream ports. Only the PCIe Endpoints don't have AER enabled yet. A follow-up patch will take care of this Endpoint enabling.
--- drivers/pci/pcie/portdrv_core.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/pci/pcie/portdrv_core.c +1 -8
@@ -222,15 +222,8 @@ static int get_port_device_capability(struct pci_dev *dev)#ifdef CONFIG_PCIEAER if (dev->aer_cap &&pci_aer_available () && - (pcie_ports_native || host->native_aer)) { + (pcie_ports_native || host->native_aer)) services |=PCIE_PORT_SERVICE_AER ; - -/* -* Disable AER on this port in case it's been enabled by the -* BIOS (the AER service driver will enable it when necessary). -*/ -pci_disable_pcie_error_reporting (dev); - }#endif /* Root Ports and Root Complex Event Collectors may generate PMEs */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 804/1157 PCI: qcom: Set up rev 2.1.0 PARF_PHY before enabling clocks
In reply to Greg Kroah-HartmanFrom: Christian Marangi <[email protected]>
[ Upstream commit 38f897ae3d44900f627cad708a15db498ce2ca31 ]
We currently enable clocks BEFORE we write to PARF_PHY_CTRL reg to enable clocks and resets. This causes the driver to never set to a ready state with the error 'Phy link never came up'.
This is caused by the PHY clock getting enabled before setting the required bits in the PARF regs.
A workaround for this was set but with this new discovery we can drop the workaround and use a proper solution to the problem by just enabling the clock only AFTER the PARF_PHY_CTRL bit is set.
This correctly sets up the PCIe link and makes it usable even when a bootloader leaves the PCIe link in an undefined state.
--- drivers/pci/controller/dwc/pcie-qcom.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/pci/controller/dwc/pcie-qcom.c +4 -6
@@ -337,8 +337,6 @@ static int qcom_pcie_init_2_1_0(struct qcom_pcie *pcie)reset_control_assert (res->ext_reset);reset_control_assert (res->phy_reset); -writel (1 , pcie->parf +PCIE20_PARF_PHY_CTRL ); - ret =regulator_bulk_enable (ARRAY_SIZE (res->supplies), res->supplies);if (ret <0 ) {dev_err (dev,"cannot enable regulators\n" );
@@ -381,15 +379,15 @@ static int qcom_pcie_init_2_1_0(struct qcom_pcie *pcie) goto err_deassert_axi; } - ret =clk_bulk_prepare_enable (ARRAY_SIZE (res->clks), res->clks); -if (ret) - goto err_clks; -/* enable PCIe clocks and resets */ val =readl (pcie->parf +PCIE20_PARF_PHY_CTRL ); val &= ~BIT (0 );writel (val, pcie->parf +PCIE20_PARF_PHY_CTRL ); + ret =clk_bulk_prepare_enable (ARRAY_SIZE (res->clks), res->clks); +if (ret) + goto err_clks; +if (of_device_is_compatible (node,"qcom,pcie-ipq8064" ) ||of_device_is_compatible (node,"qcom,pcie-ipq8064-v2" )) { writel(PCS_DEEMPH_TX_DEEMPH_GEN1(24) |
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 805/1157 scsi: smartpqi: Fix DMA direction for RAID requests
In reply to Greg Kroah-HartmanFrom: Mahesh Rajashekhara <[email protected]>
[ Upstream commit 69695aeaa6621bc49cdd7a8e5a8d1042461e496e ]
Correct a SOP READ and WRITE DMA flags for some requests.
This update corrects DMA direction issues with SCSI commands removed from the controller's internal lookup table.
Currently, SCSI READ BLOCK LIMITS (0x5) was removed from the controller lookup table and exposed a DMA direction flag issue.
SCSI READ BLOCK LIMITS was recently removed from our controller lookup table so the controller uses the respective IU flag field to set the DMA data direction. Since the DMA direction is incorrect the FW never completes the request causing a hang.
Some SCSI commands which use SCSI READ BLOCK LIMITS
* sg_map
* mt -f /dev/stX status
After updating controller firmware, users may notice their tape units failing. This patch resolves the issue.
Also, the AIO path DMA direction is correct.
The DMA direction flag is a day-one bug with no reported BZ.
--- drivers/scsi/smartpqi/smartpqi_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +2 -2
@@ -5484,10 +5484,10 @@ static int pqi_raid_submit_scsi_cmd_with_io_request( }switch (scmd->sc_data_direction) { -case DMA_TO_DEVICE : +case DMA_FROM_DEVICE : request->data_direction =SOP_READ_FLAG ;break ; -case DMA_FROM_DEVICE : +case DMA_TO_DEVICE : request->data_direction =SOP_WRITE_FLAG ;break ;case DMA_NONE :
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 806/1157 xtensa: iss/network: provide release() callback
In reply to Greg Kroah-HartmanFrom: Max Filippov <[email protected]>
[ Upstream commit 8864fb8359682912ee99235db7db916733a1fd7b ]
Provide release() callback for the platform device embedded into struct iss_net_private and registered in the iss_net_configure so that platform_device_unregister could be called for it.
--- arch/xtensa/platforms/iss/network.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/xtensa/platforms/iss/network.c +10 -0
@@ -472,6 +472,15 @@ static const struct net_device_ops iss_netdev_ops = { .ndo_set_rx_mode = iss_net_set_multicast_list, }; +static void iss_net_pdev_release (struct device *dev) +{ +struct platform_device *pdev =to_platform_device (dev); +struct iss_net_private *lp = + container_of(pdev, struct iss_net_private, pdev); + +free_netdev (lp->dev); +} +static int iss_net_configure (int index,char *init) {struct net_device *dev;
@@ -527,6 +536,7 @@ static int iss_net_configure(int index, char *init) lp->pdev.id = index; lp->pdev.name =DRIVER_NAME ; + lp->pdev.dev.release = iss_net_pdev_release;platform_device_register (&lp->pdev);SET_NETDEV_DEV (dev, &lp->pdev.dev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 807/1157 xtensa: iss: fix handling error cases in iss_net_configure()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 628ccfc8f5f79dd548319408fcc53949fe97b258 ]
The 'pdev' and 'netdev' need to be released in error cases of iss_net_configure().
Change the return type of iss_net_configure() to void, because it's not used.
--- arch/xtensa/platforms/iss/network.c | 32 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 17 deletions(-)
arch/xtensa/platforms/iss/network.c +15 -17
@@ -481,16 +481,15 @@ static void iss_net_pdev_release(struct device *dev)free_netdev (lp->dev); } -static int iss_net_configure (int index,char *init) +static void iss_net_configure (int index,char *init) {struct net_device *dev;struct iss_net_private *lp; -int err; dev =alloc_etherdev (sizeof (*lp));if (dev ==NULL ) {pr_err ("eth_configure: failed to allocate device\n" ); -return 1 ; +return ; }/* Initialize private element. */
@@ -518,7 +517,7 @@ static int iss_net_configure(int index, char *init)if (!tuntap_probe (lp, index, init)) {pr_err ("%s: invalid arguments. Skipping device!\n" , dev->name); - goto errout; + goto err_free_netdev; }pr_info ("Netdevice %d (%pM)\n" , index, dev->dev_addr);
@@ -526,7 +525,8 @@ static int iss_net_configure(int index, char *init)/* sysfs register */ if (!driver_registered) { -platform_driver_register (&iss_net_driver); +if (platform_driver_register (&iss_net_driver)) + goto err_free_netdev; driver_registered =1 ; }
@@ -537,7 +537,8 @@ static int iss_net_configure(int index, char *init) lp->pdev.id = index; lp->pdev.name =DRIVER_NAME ; lp->pdev.dev.release = iss_net_pdev_release; -platform_device_register (&lp->pdev); +if (platform_device_register (&lp->pdev)) + goto err_free_netdev;SET_NETDEV_DEV (dev, &lp->pdev.dev); dev->netdev_ops = &iss_netdev_ops;
@@ -546,23 +547,20 @@ static int iss_net_configure(int index, char *init) dev->irq =-1 ;rtnl_lock (); - err =register_netdevice (dev); -rtnl_unlock (); - -if (err) { +if (register_netdevice (dev)) { +rtnl_unlock ();pr_err ("%s: error registering net device!\n" , dev->name); -/* XXX: should we call ->remove() here? */ -free_netdev (dev); -return 1 ; +platform_device_unregister (&lp->pdev); +return ; } +rtnl_unlock ();timer_setup (&lp->tl, iss_net_user_timer_expire,0 ); -return 0 ; +return ; -errout: -/* FIXME: unregister; free, etc.. */ -return -EIO ; +err_free_netdev: +free_netdev (dev); }/* ------------------------------------------------------------------------- */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 808/1157 usb: gadget: udc: amd5536 depends on HAS_DMA
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 8097cf2fb3b2205257f1c76f4808e3398d66b6d9 ]
USB_AMD5536UDC should depend on HAS_DMA since it selects USB_SNP_CORE, which depends on HAS_DMA and since 'select' does not follow any dependency chains.
Fixes this kconfig warning:
WARNING: unmet direct dependencies detected for USB_SNP_CORE
Depends on [n]: USB_SUPPORT [=y] && USB_GADGET [=y] && (USB_AMD5536UDC [=y] || USB_SNP_UDC_PLAT [=n]) && HAS_DMA [=n] Selected by [y]:
- USB_AMD5536UDC [=y] && USB_SUPPORT [=y] && USB_GADGET [=y] && USB_PCI [=y]
--- drivers/usb/gadget/udc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/Kconfig +1 -1
@@ -311,7 +311,7 @@ source "drivers/usb/gadget/udc/bdc/Kconfig" config USB_AMD5536UDC tristate "AMD5536 UDC" - depends on USB_PCI + depends on USB_PCI && HAS_DMA select USB_SNP_CORE help The AMD5536 UDC is part of the AMD Geode CS5536, an x86 southbridge.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 809/1157 usb: aspeed-vhub: Fix refcount leak bug in ast_vhub_init_desc()
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 220fafb4ed04187e9c17be4152da5a7f2ffbdd8c ]
We should call of_node_put() for the reference returned by of_get_child_by_name() which has increased the refcount.
--- drivers/usb/gadget/udc/aspeed-vhub/hub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/gadget/udc/aspeed-vhub/hub.c +3 -1
@@ -1059,8 +1059,10 @@ static int ast_vhub_init_desc(struct ast_vhub *vhub)/* Initialize vhub String Descriptors. */ INIT_LIST_HEAD (&vhub->vhub_str_desc); desc_np =of_get_child_by_name (vhub_np,"vhub-strings" ); -if (desc_np) +if (desc_np) { ret =ast_vhub_of_parse_str_desc (vhub, desc_np); +of_node_put (desc_np); + }else ret =ast_vhub_str_alloc_add (vhub, &ast_vhub_strings);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 810/1157 usb: dwc3: core: Deprecate GCTL.CORESOFTRESET
In reply to Greg Kroah-HartmanFrom: Thinh Nguyen <[email protected]>
[ Upstream commit afbd04e66e5d16ca3c7ea2e3c56eca25558eacf3 ]
Synopsys IP DWC_usb32 and DWC_usb31 version 1.90a and above deprecated GCTL.CORESOFTRESET. The DRD mode switching flow is updated to remove the GCTL soft reset. Add version checks to prevent using deprecated setting in mode switching flow.
--- drivers/usb/dwc3/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +2 -1
@@ -159,7 +159,8 @@ static void __dwc3_set_mode(struct work_struct *work) }/* For DRD host or device mode only */ -if (dwc->desired_dr_role !=DWC3_GCTL_PRTCAP_OTG ) { + if ((DWC3_IP_IS(DWC3) || DWC3_VER_IS_PRIOR(DWC31, 190A)) && + dwc->desired_dr_role !=DWC3_GCTL_PRTCAP_OTG ) { reg =dwc3_readl (dwc->regs,DWC3_GCTL ); reg |=DWC3_GCTL_CORESOFTRESET ;dwc3_writel (dwc->regs,DWC3_GCTL , reg);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 811/1157 usb: dwc3: core: Do not perform GCTL_CORE_SOFTRESET during bootup
In reply to Greg Kroah-HartmanFrom: Rohith Kollalsi <[email protected]>
[ Upstream commit 07903626d98853e605fe63e5ce149f1b7314bbea ]
According to the programming guide, it is recommended to perform a GCTL_CORE_SOFTRESET only when switching the mode from device to host or host to device. However, it is found that during bootup when __dwc3_set_mode() is called for the first time, GCTL_CORESOFTRESET is done with suspendable bit(BIT 17) of DWC3_GUSB3PIPECTL set. This some times leads to issues like controller going into bad state and controller registers reading value zero. Until GCTL_CORESOFTRESET is done and run/stop bit is set core initialization is not complete. Setting suspendable bit of DWC3_GUSB3PIPECTL and then performing GCTL_CORESOFTRESET is therefore not recommended. Avoid this by only performing the reset if current_dr_role is set, that is, when doing subsequent role switching.
--- drivers/usb/dwc3/core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/usb/dwc3/core.c +7 -3
@@ -158,9 +158,13 @@ static void __dwc3_set_mode(struct work_struct *work)break ; } -/* For DRD host or device mode only */ - if ((DWC3_IP_IS(DWC3) || DWC3_VER_IS_PRIOR(DWC31, 190A)) && - dwc->desired_dr_role !=DWC3_GCTL_PRTCAP_OTG ) { +/* +* When current_dr_role is not set, there's no role switching. +* Only perform GCTL.CoreSoftReset when there's DRD role switching. +*/ +if (dwc->current_dr_role && ((DWC3_IP_IS (DWC3 ) || + DWC3_VER_IS_PRIOR(DWC31, 190A)) && + dwc->desired_dr_role !=DWC3_GCTL_PRTCAP_OTG )) { reg =dwc3_readl (dwc->regs,DWC3_GCTL ); reg |=DWC3_GCTL_CORESOFTRESET ;dwc3_writel (dwc->regs,DWC3_GCTL , reg);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 812/1157 usb: dwc3: qcom: fix missing optional irq warnings
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 69bb3520db7cecbccc9e497fc568fa5465c9d43f ]
Not all platforms have all of the four currently supported wakeup interrupts so use the optional irq helpers when looking up interrupts to avoid printing error messages when an optional interrupt is not found:
dwc3-qcom a6f8800.usb: error -ENXIO: IRQ hs_phy_irq not found
--- drivers/usb/dwc3/dwc3-qcom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +2 -2
@@ -443,9 +443,9 @@ static int dwc3_qcom_get_irq(struct platform_device *pdev,int ret;if (np) - ret =platform_get_irq_byname (pdev_irq, name); + ret =platform_get_irq_byname_optional (pdev_irq, name);else - ret =platform_get_irq (pdev_irq, num); + ret =platform_get_irq_optional (pdev_irq, num);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 813/1157 eeprom: idt_89hpesx: uninitialized data in idt_dbgfs_csr_write()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 71d46f1ff2212ced4852c7e77c5176382a1bdcec ]
The simple_write_to_buffer() function will return positive/success if it is able to write a single byte anywhere within the buffer. However that potentially leaves a lot of the buffer uninitialized.
In this code it's better to return 0 if the offset is non-zero. This code is not written to support partial writes. And then return -EFAULT if the buffer is not completely initialized.
--- drivers/misc/eeprom/idt_89hpesx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/misc/eeprom/idt_89hpesx.c +6 -2
@@ -909,14 +909,18 @@ static ssize_t idt_dbgfs_csr_write(struct file *filep, const char __user *ubuf,u32 csraddr, csrval;char *buf; +if (*offp) +return 0 ; +/* Copy data from User-space */ buf =kmalloc (count +1 ,GFP_KERNEL );if (!buf)return -ENOMEM ; - ret =simple_write_to_buffer (buf, count, offp, ubuf, count); -if (ret <0 ) +if (copy_from_user (buf, ubuf, count)) { + ret = -EFAULT ; goto free_buf; + } buf[count] =0 ;/* Find position of colon in the buffer */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 814/1157 phy: stm32: fix error return in stm32_usbphyc_phy_init
In reply to Greg Kroah-HartmanFrom: Fabrice Gasnier <[email protected]>
[ Upstream commit 32b378a9179ae4db61cfc5d502717214e6cd1e1c ]
Error code is overridden, in case the PLL doesn't lock. So, the USB initialization can continue. This leads to a platform freeze. This can be avoided by returning proper error code to avoid USB probe freezing the platform. It also displays proper errors in log.
--- drivers/phy/st/phy-stm32-usbphyc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/phy/st/phy-stm32-usbphyc.c +3 -1
@@ -358,7 +358,9 @@ static int stm32_usbphyc_phy_init(struct phy *phy)return 0 ; pll_disable: -return stm32_usbphyc_pll_disable (usbphyc); +stm32_usbphyc_pll_disable (usbphyc); + +return ret; }static int stm32_usbphyc_phy_exit (struct phy *phy)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 815/1157 phy: rockchip-inno-usb2: Ignore OTG IRQs in host mode
In reply to Greg Kroah-HartmanFrom: Samuel Holland <[email protected]>
[ Upstream commit fd7d47484125c7d04578de9294faa7fec6e5df0a ]
When the OTG port is fixed to host mode, the driver does not request its IRQs, nor does it enable those IRQs in hardware. Similarly, the driver should ignore the OTG port IRQs when handling the shared interrupt.
Otherwise, it would update the extcon based on an ID pin which may be in an undefined state, or try to queue a uninitialized work item.
--- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +3 -1
@@ -978,7 +978,9 @@ static irqreturn_t rockchip_usb2phy_irq(int irq, void *data)switch (rport->port_id) {case USB2PHY_PORT_OTG : - ret |=rockchip_usb2phy_otg_mux_irq (irq, rport); +if (rport->mode !=USB_DR_MODE_HOST && + rport->mode !=USB_DR_MODE_UNKNOWN ) + ret |=rockchip_usb2phy_otg_mux_irq (irq, rport);break ;case USB2PHY_PORT_HOST : ret |=rockchip_usb2phy_linestate_irq (irq, rport);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 816/1157 interconnect: imx: fix max_node_id
In reply to Greg Kroah-HartmanFrom: Peng Fan <[email protected]>
[ Upstream commit bd734481e172b4827af09c9ab06c51d2ab7201e6 ]
max_node_id not equal to the ARRAY_SIZE of node array, need increase 1, otherwise xlate will fail for the last entry. And rename max_node_id to num_nodes to reflect the reality.
--- drivers/interconnect/imx/imx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/interconnect/imx/imx.c +4 -4
@@ -234,16 +234,16 @@ int imx_icc_register(struct platform_device *pdev,struct device *dev = &pdev->dev;struct icc_onecell_data *data;struct icc_provider *provider; -int max_node_id; +int num_nodes;int ret;/* icc_onecell_data is indexed by node_id, unlike nodes param */ - max_node_id =get_max_node_id (nodes, nodes_count); - data =devm_kzalloc (dev,struct_size (data, nodes, max_node_id), + num_nodes =get_max_node_id (nodes, nodes_count) +1 ; + data =devm_kzalloc (dev,struct_size (data, nodes, num_nodes),GFP_KERNEL );if (!data)return -ENOMEM ; - data->num_nodes = max_node_id; + data->num_nodes = num_nodes; provider =devm_kzalloc (dev,sizeof (*provider),GFP_KERNEL );if (!provider)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 817/1157 KVM: arm64: Fix hypervisor address symbolization
In reply to Greg Kroah-HartmanFrom: Kalesh Singh <[email protected]>
[ Upstream commit ed6313a93fd11d2015ad17046f3c418bf6a8dab1 ]
With CONFIG_RANDOMIZE_BASE=y vmlinux addresses will resolve incorrectly from kallsyms. Fix this by adding the KASLR offset before printing the symbols.
--- arch/arm64/kvm/handle_exit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/handle_exit.c +2 -2
@@ -347,10 +347,10 @@ void __noreturn __cold nvhe_hyp_panic_handler(u64 esr, u64 spsr,kvm_err ("nVHE hyp BUG at: %s:%u!\n" , file, line); else kvm_err("nVHE hyp BUG at: [<%016llx>] %pB!\n", panic_addr, - (void *)panic_addr); + (void *)(panic_addr + kaslr_offset())); }else {kvm_err ("nVHE hyp panic at: [<%016llx>] %pB!\n" , panic_addr, - (void *)panic_addr); + (void *)(panic_addr +kaslr_offset ())); }/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 818/1157 um: random: Dont initialise hwrng struct with zero
In reply to Greg Kroah-HartmanFrom: Christopher Obbard <[email protected]>
[ Upstream commit 9e70cbd11b03889c92462cf52edb2bd023c798fa ]
Initialising the hwrng struct with zeros causes a
compile-time sparse warning:
$ ARCH=um make -j10 W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ... CHECK arch/um/drivers/random.c arch/um/drivers/random.c:31:31: sparse: warning: Using plain integer as NULL pointer
Fix the warning by not initialising the hwrng struct with zeros as it is initialised anyway during module init.
--- arch/um/drivers/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/um/drivers/random.c +1 -1
@@ -28,7 +28,7 @@* protects against a module being loaded twice at the same time. */ static int random_fd =-1 ; -static struct hwrng hwrng = {0 , }; +static struct hwrng hwrng;static DECLARE_COMPLETION (have_data);static int rng_dev_read (struct hwrng *rng,void *buf,size_t max,bool block)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 819/1157 mm: percpu: use kmemleak_ignore_phys() instead of kmemleak_free()
In reply to Greg Kroah-HartmanFrom: Patrick Wang <[email protected]>
[ Upstream commit a317ebccaa3609917a2c021af870cf3fa607ab0c ]
Kmemleak recently added a rbtree to store the objects allocted with physical address. Those objects can't be freed with kmemleak_free().
According to the comments, percpu allocations are tracked by kmemleak separately. Kmemleak_free() was used to avoid the unnecessary tracking. If kmemleak_free() fails, those objects would be scanned by kmemleak, which is unnecessary but shouldn't lead to other effects.
Use kmemleak_ignore_phys() instead of kmemleak_free() for those objects.
--- mm/percpu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/percpu.c +3 -3
@@ -3104,7 +3104,7 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size, goto out_free_areas; }/* kmemleak tracks the percpu allocations separately */ -kmemleak_free (ptr); +kmemleak_ignore_phys (__pa (ptr)); areas[group] = ptr; base =min (ptr, base);
@@ -3304,7 +3304,7 @@ int __init pcpu_page_first_chunk(size_t reserved_size, pcpu_fc_cpu_to_node_fn_t goto enomem; }/* kmemleak tracks the percpu allocations separately */ -kmemleak_free (ptr); +kmemleak_ignore_phys (__pa (ptr)); pages[j++] =virt_to_page (ptr); } }
@@ -3417,7 +3417,7 @@ void __init setup_per_cpu_areas(void)if (!ai || !fc)panic ("Failed to allocate memory for percpu areas." );/* kmemleak tracks the percpu allocations separately */ -kmemleak_free (fc); +kmemleak_ignore_phys (__pa (fc)); ai->dyn_size = unit_size; ai->unit_size = unit_size;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 820/1157 RDMA/irdma: Fix a window for use-after-free
In reply to Greg Kroah-HartmanFrom: Mustafa Ismail <[email protected]>
[ Upstream commit 8ecef7890b3aea78c8bbb501a4b5b8134367b821 ]
During a destroy CQ an interrupt may cause processing of a CQE after CQ resources are freed by irdma_cq_free_rsrc(). Fix this by moving the call to irdma_cq_free_rsrc() after the irdma_sc_cleanup_ceqes(), which is called under the cq_lock.
--- drivers/infiniband/hw/irdma/verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/irdma/verbs.c +1 -1
@@ -1776,11 +1776,11 @@ static int irdma_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)spin_unlock_irqrestore (&iwcq->lock, flags);irdma_cq_wq_destroy (iwdev->rf, cq); -irdma_cq_free_rsrc (iwdev->rf, iwcq);spin_lock_irqsave (&iwceq->ce_lock, flags);irdma_sc_cleanup_ceqes (cq, ceq);spin_unlock_irqrestore (&iwceq->ce_lock, flags); +irdma_cq_free_rsrc (iwdev->rf, iwcq);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 821/1157 RDMA/irdma: Fix VLAN connection with wildcard address
In reply to Greg Kroah-HartmanFrom: Mustafa Ismail <[email protected]>
[ Upstream commit 82ab2b52654c43ba24a3f6603fec40874cc5a7e5 ]
When an application listens on a wildcard address, and there are VLAN and non-VLAN IP addresses, iWARP connection establishemnt can fail if the listen node VLAN ID does not match.
Fix this by checking the vlan_id only if not a wildcard listen node.
--- drivers/infiniband/hw/irdma/cm.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/infiniband/hw/irdma/cm.c +6 -5
@@ -1477,12 +1477,13 @@ irdma_find_listener(struct irdma_cm_core *cm_core, u32 *dst_addr, u16 dst_port, list_for_each_entry (listen_node, &cm_core->listen_list, list) {memcpy (listen_addr, listen_node->loc_addr,sizeof (listen_addr)); listen_port = listen_node->loc_port; +if (listen_port != dst_port || + !(listener_state & listen_node->listener_state)) +continue ;/* compare node pair, return node handle if a match */ -if ((!memcmp (listen_addr, dst_addr,sizeof (listen_addr)) || - !memcmp (listen_addr, ip_zero,sizeof (listen_addr))) && - listen_port == dst_port && - vlan_id == listen_node->vlan_id && - (listener_state & listen_node->listener_state)) { +if (!memcmp (listen_addr, ip_zero,sizeof (listen_addr)) || + (!memcmp (listen_addr, dst_addr,sizeof (listen_addr)) && + vlan_id == listen_node->vlan_id)) {refcount_inc (&listen_node->refcnt);spin_unlock_irqrestore (&cm_core->listen_list_lock, flags);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 822/1157 RDMA/irdma: Fix setting of QP context err_rq_idx_valid field
In reply to Greg Kroah-HartmanFrom: Mustafa Ismail <[email protected]>
[ Upstream commit 3a844596ed71b7c12ac602f6f6b7b0f17e4d6a90 ]
Setting err_rq_idx_valid field in QP context when the AE source of the AEQE is not associated with an RQ causes the firmware flush to fail.
Set err_rq_idx_valid field in QP context only if it is associated with an RQ. Additionally, cleanup the redundant setting of this field in irdma_process_aeq.
--- drivers/infiniband/hw/irdma/hw.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/infiniband/hw/irdma/hw.c +4 -11
@@ -257,10 +257,6 @@ static void irdma_process_aeq(struct irdma_pci_f *rf) iwqp->last_aeq = info->ae_id;spin_unlock_irqrestore (&iwqp->lock, flags); ctx_info = &iwqp->ctx_info; -if (rdma_protocol_roce (&iwqp->iwdev->ibdev,1 )) - ctx_info->roce_info->err_rq_idx_valid = true; -else - ctx_info->iwarp_info->err_rq_idx_valid = true; }else {if (info->ae_id !=IRDMA_AE_CQ_OPERATION_ERROR )continue ;
@@ -370,16 +366,12 @@ static void irdma_process_aeq(struct irdma_pci_f *rf)case IRDMA_AE_LCE_FUNCTION_CATASTROPHIC :case IRDMA_AE_LCE_CQ_CATASTROPHIC :case IRDMA_AE_UDA_XMIT_DGRAM_TOO_LONG : -if (rdma_protocol_roce (&iwdev->ibdev,1 )) - ctx_info->roce_info->err_rq_idx_valid = false; -else - ctx_info->iwarp_info->err_rq_idx_valid = false; - fallthrough;default :ibdev_err (&iwdev->ibdev,"abnormal ae_id = 0x%x bool qp=%d qp_id = %d\n" , info->ae_id, info->qp, info->qp_cq_id);if (rdma_protocol_roce (&iwdev->ibdev,1 )) { -if (!info->sq && ctx_info->roce_info->err_rq_idx_valid) { + ctx_info->roce_info->err_rq_idx_valid = info->rq; +if (info->rq) { ctx_info->roce_info->err_rq_idx = info->wqe_idx;irdma_sc_qp_setctx_roce (&iwqp->sc_qp, iwqp->host_ctx.va, ctx_info);
@@ -388,7 +380,8 @@ static void irdma_process_aeq(struct irdma_pci_f *rf)irdma_cm_disconn (iwqp);break ; } -if (!info->sq && ctx_info->iwarp_info->err_rq_idx_valid) { + ctx_info->iwarp_info->err_rq_idx_valid = info->rq; +if (info->rq) { ctx_info->iwarp_info->err_rq_idx = info->wqe_idx; ctx_info->tcp_info_valid = false; ctx_info->iwarp_info_valid = true;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 823/1157 RDMA/rtrs-srv: Fix modinfo output for stringify
In reply to Greg Kroah-HartmanFrom: Jack Wang <[email protected]>
[ Upstream commit ed6e53820ee4f68ed927de17e5675ff2a07a47e2 ]
stringify works with define, not enum.
--- drivers/infiniband/ulp/rtrs/rtrs-pri.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-pri.h +11 -10
@@ -23,6 +23,17 @@#define RTRS_PROTO_VER_STRING __stringify(RTRS_PROTO_VER_MAJOR) "." \ __stringify(RTRS_PROTO_VER_MINOR) +/* +* Max IB immediate data size is 2^28 (MAX_IMM_PAYL_BITS) +* and the minimum chunk size is 4096 (2^12). +* So the maximum sess_queue_depth is 65536 (2^16) in theory. +* But mempool_create, create_qp and ib_post_send fail with +* "cannot allocate memory" error if sess_queue_depth is too big. +* Therefore the pratical max value of sess_queue_depth is +* somewhere between 1 and 65534 and it depends on the system. +*/ +#define MAX_SESS_QUEUE_DEPTH 65535 +enum rtrs_imm_const {MAX_IMM_TYPE_BITS =4 ,MAX_IMM_TYPE_MASK = ((1 <<MAX_IMM_TYPE_BITS ) -1 ),
@@ -46,16 +57,6 @@ enum {MAX_PATHS_NUM =128 , -/* -* Max IB immediate data size is 2^28 (MAX_IMM_PAYL_BITS) -* and the minimum chunk size is 4096 (2^12). -* So the maximum sess_queue_depth is 65536 (2^16) in theory. -* But mempool_create, create_qp and ib_post_send fail with -* "cannot allocate memory" error if sess_queue_depth is too big. -* Therefore the pratical max value of sess_queue_depth is -* somewhere between 1 and 65534 and it depends on the system. -*/ -MAX_SESS_QUEUE_DEPTH =65535 ,MIN_CHUNK_SIZE =8192 , RTRS_HB_INTERVAL_MS = 5000,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 824/1157 RDMA/rtrs-clt: Replace list_next_or_null_rr_rcu with an inline function
In reply to Greg Kroah-HartmanFrom: Md Haris Iqbal <[email protected]>
[ Upstream commit c14adff285ad1bb8eefc5d8fc202ceb1f7e3a2f1 ]
removes list_next_or_null_rr_rcu macro to fix below warnings. That macro is used only twice.
CHECK:MACRO_ARG_REUSE: Macro argument reuse 'head' - possible side-effects? CHECK:MACRO_ARG_REUSE: Macro argument reuse 'ptr' - possible side-effects? CHECK:MACRO_ARG_REUSE: Macro argument reuse 'memb' - possible side-effects?
Replaces that macro with an inline function.
--- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 35 ++++++++++++-------------- 1 file changed, 16 insertions(+), 19 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-clt.c +16 -19
@@ -740,25 +740,25 @@ struct path_it {struct rtrs_clt_path *(*next_path)(struct path_it *it); }; -/** -* list_next_or_null_rr_rcu - get next list element in round-robin fashion. +/* +* rtrs_clt_get_next_path_or_null - get clt path from the list or return NULL * @head: the head for the list. -* @ptr: the list head to take the next element from. -* @type: the type of the struct this is embedded in. -* @memb: the name of the list_head within the struct. +* @clt_path: The element to take the next clt_path from. * -* Next element returned in round-robin fashion, i.e. head will be skipped, +* Next clt path returned in round-robin fashion, i.e. head will be skipped, * but if list is observed as empty, NULL will be returned. * -* This primitive may safely run concurrently with the _rcu list-mutation +* This function may safely run concurrently with the _rcu list-mutation * primitives such as list_add_rcu() as long as it's guarded by rcu_read_lock(). */ -#define list_next_or_null_rr_rcu (head, ptr, type, memb) \ -({ \ - list_next_or_null_rcu(head, ptr, type, memb) ?: \ - list_next_or_null_rcu(head, READ_ONCE((ptr)->next), \ - type, memb); \ -}) +static inline struct rtrs_clt_path * +rtrs_clt_get_next_path_or_null (struct list_head *head,struct rtrs_clt_path *clt_path) +{ +return list_next_or_null_rcu (head, &clt_path->s.entry,typeof (*clt_path), s.entry) ?: +list_next_or_null_rcu (head, +READ_ONCE ((&clt_path->s.entry)->next), +typeof (*clt_path), s.entry); +}/** * get_next_path_rr() - Returns path in round-robin fashion.
@@ -789,10 +789,8 @@ static struct rtrs_clt_path *get_next_path_rr(struct path_it *it) path =list_first_or_null_rcu (&clt->paths_list,typeof (*path), s.entry); else - path =list_next_or_null_rr_rcu (&clt->paths_list, - &path->s.entry, -typeof (*path), - s.entry); + path =rtrs_clt_get_next_path_or_null (&clt->paths_list, path); +rcu_assign_pointer (*ppcpu_path, path);return path;
@@ -2277,8 +2275,7 @@ static void rtrs_clt_remove_path_from_arr(struct rtrs_clt_path *clt_path)* removed. If @sess is the last element, then @next is NULL. */ rcu_read_lock (); - next =list_next_or_null_rr_rcu (&clt->paths_list, &clt_path->s.entry, -typeof (*next), s.entry); + next =rtrs_clt_get_next_path_or_null (&clt->paths_list, clt_path);rcu_read_unlock ();/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 825/1157 RDMA/qedr: Fix potential memory leak in __qedr_alloc_mr()
In reply to Greg Kroah-HartmanFrom: Jianglei Nie <[email protected]>
[ Upstream commit b3236a64ddd125a455ef5b5316c1b9051b732974 ]
__qedr_alloc_mr() allocates a memory chunk for "mr->info.pbl_table" with init_mr_info(). When rdma_alloc_tid() and rdma_register_tid() fail, "mr" is released while "mr->info.pbl_table" is not released, which will lead to a memory leak.
We should release the "mr->info.pbl_table" with qedr_free_pbl() when error occurs to fix the memory leak.
--- drivers/infiniband/hw/qedr/verbs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/infiniband/hw/qedr/verbs.c +5 -3
@@ -3084,7 +3084,7 @@ static struct qedr_mr *__qedr_alloc_mr(struct ib_pd *ibpd,else DP_ERR (dev,"roce alloc tid returned error %d\n" , rc); - goto err0; + goto err1; }/* Index only, 18 bit long, lkey = itid << 8 | key */
@@ -3108,7 +3108,7 @@ static struct qedr_mr *__qedr_alloc_mr(struct ib_pd *ibpd, rc = dev->ops->rdma_register_tid (dev->rdma_ctx, &mr->hw_mr);if (rc) {DP_ERR (dev,"roce register tid returned an error %d\n" , rc); - goto err1; + goto err2; } mr->ibmr.lkey = mr->hw_mr.itid <<8 | mr->hw_mr.key;
@@ -3117,8 +3117,10 @@ static struct qedr_mr *__qedr_alloc_mr(struct ib_pd *ibpd,DP_DEBUG (dev,QEDR_MSG_MR ,"alloc frmr: %x\n" , mr->ibmr.lkey);return mr; -err1: +err2: dev->ops->rdma_free_tid (dev->rdma_ctx, mr->hw_mr.itid); +err1: +qedr_free_pbl (dev, &mr->info.pbl_info, mr->info.pbl_table); err0:kfree (mr);return ERR_PTR (rc);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 826/1157 RDMA/hns: Fix incorrect clearing of interrupt status register
In reply to Greg Kroah-HartmanFrom: Haoyue Xu <[email protected]>
[ Upstream commit ecb4db5c3590aa956b4b2c352081a5b632d1f9f9 ]
The driver will clear all the interrupts in the same area when the driver handles the interrupt of type AEQ overflow. It should only set the interrupt status bit of type AEQ overflow.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +2 -2
@@ -6000,8 +6000,8 @@ static irqreturn_t hns_roce_v2_msix_interrupt_abn(int irq, void *dev_id)dev_err (dev,"AEQ overflow!\n" ); - int_st |=1 <<HNS_ROCE_V2_VF_INT_ST_AEQ_OVERFLOW_S ; -roce_write (hr_dev,ROCEE_VF_ABN_INT_ST_REG , int_st); +roce_write (hr_dev,ROCEE_VF_ABN_INT_ST_REG , +1 <<HNS_ROCE_V2_VF_INT_ST_AEQ_OVERFLOW_S );/* Set reset level for reset_event() */ if (ops->set_default_reset_request)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 827/1157 RDMA/siw: Fix duplicated reported IW_CM_EVENT_CONNECT_REPLY event
In reply to Greg Kroah-HartmanFrom: Cheng Xu <[email protected]>
[ Upstream commit 3056fc6c32e613b760422b94c7617ac9a24a4721 ]
If siw_recv_mpa_rr returns -EAGAIN, it means that the MPA reply hasn't been received completely, and should not report IW_CM_EVENT_CONNECT_REPLY in this case. This may trigger a call trace in iw_cm. A simple way to trigger this:
server: ib_send_lat
client: ib_send_lat -R <server_ip>
The call trace looks like this:
kernel BUG at drivers/infiniband/core/iwcm.c:894! invalid opcode: 0000 [#1] PREEMPT SMP NOPTI <...>
Workqueue: iw_cm_wq cm_work_handler [iw_cm] Call Trace: <TASK> cm_work_handler+0x1dd/0x370 [iw_cm] process_one_work+0x1e2/0x3b0 worker_thread+0x49/0x2e0 ? rescuer_thread+0x370/0x370 kthread+0xe5/0x110 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x1f/0x30 </TASK>
--- drivers/infiniband/sw/siw/siw_cm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/infiniband/sw/siw/siw_cm.c +4 -3
@@ -725,11 +725,11 @@ static int siw_proc_mpareply(struct siw_cep *cep)enum mpa_v2_ctrl mpa_p2p_mode =MPA_V2_RDMA_NO_RTR ; rv =siw_recv_mpa_rr (cep); -if (rv != -EAGAIN ) -siw_cancel_mpatimer (cep);if (rv) goto out_err; +siw_cancel_mpatimer (cep); + rep = &cep->mpa.hdr;if (__mpa_rr_revision (rep->params.bits) >MPA_REVISION_2 ) {
@@ -895,7 +895,8 @@ static int siw_proc_mpareply(struct siw_cep *cep) } out_err: -siw_cm_upcall (cep,IW_CM_EVENT_CONNECT_REPLY , -EINVAL ); +if (rv != -EAGAIN ) +siw_cm_upcall (cep,IW_CM_EVENT_CONNECT_REPLY , -EINVAL );return rv; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 828/1157 RDMA/rxe: Fix BUG: KASAN: null-ptr-deref in rxe_qp_do_cleanup
In reply to Greg Kroah-HartmanFrom: Zhu Yanjun <[email protected]>
[ Upstream commit 37da51efe6eaa0560f46803c8c436a48a2084da7 ]
The function rxe_create_qp calls rxe_qp_from_init. If some error occurs, the error handler of function rxe_qp_from_init will set both scq and rcq to NULL.
Then rxe_create_qp calls rxe_put to handle qp. In the end, rxe_qp_do_cleanup is called by rxe_put. rxe_qp_do_cleanup directly accesses scq and rcq before checking them. This will cause null-ptr-deref error.
The call graph is as below:
rxe_create_qp {
...
rxe_qp_from_init {
...
err1:
...
qp->rcq = NULL; <---rcq is set to NULL
qp->scq = NULL; <---scq is set to NULL
...}
qp_init:
rxe_put{
...
rxe_qp_do_cleanup {
...
atomic_dec(&qp->scq->num_wq); <--- scq is accessed
...
atomic_dec(&qp->rcq->num_wq); <--- rcq is accessed
}
}--- drivers/infiniband/sw/rxe/rxe_qp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/infiniband/sw/rxe/rxe_qp.c +6 -4
@@ -804,13 +804,15 @@ static void rxe_qp_do_cleanup(struct work_struct *work)if (qp->rq.queue)rxe_queue_cleanup (qp->rq.queue); -atomic_dec (&qp->scq->num_wq); -if (qp->scq) +if (qp->scq) { +atomic_dec (&qp->scq->num_wq);rxe_put (qp->scq); + } -atomic_dec (&qp->rcq->num_wq); -if (qp->rcq) +if (qp->rcq) { +atomic_dec (&qp->rcq->num_wq);rxe_put (qp->rcq); + }if (qp->pd)rxe_put (qp->pd);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 829/1157 iio: cros: Register FIFO callback after sensor is registered
In reply to Greg Kroah-HartmanFrom: Gwendal Grignou <[email protected]>
[ Upstream commit 0b4ae3f6d1210c11f9baf159009c7227eacf90f2 ]
Instead of registering callback to process sensor events right at initialization time, wait for the sensor to be register in the iio subsystem.
Events can come at probe time (in case the kernel rebooted abruptly without switching the sensor off for instance), and be sent to IIO core before the sensor is fully registered.
--- drivers/iio/accel/cros_ec_accel_legacy.c | 4 +- .../cros_ec_sensors/cros_ec_lid_angle.c | 4 +- .../common/cros_ec_sensors/cros_ec_sensors.c | 6 +- .../cros_ec_sensors/cros_ec_sensors_core.c | 58 ++++++++++++++----- drivers/iio/light/cros_ec_light_prox.c | 6 +- drivers/iio/pressure/cros_ec_baro.c | 6 +- .../linux/iio/common/cros_ec_sensors_core.h | 7 ++- 7 files changed, 60 insertions(+), 31 deletions(-)
drivers/iio/accel/cros_ec_accel_legacy.c +2 -2
@@ -215,7 +215,7 @@ static int cros_ec_accel_legacy_probe(struct platform_device *pdev)return -ENOMEM ; ret =cros_ec_sensors_core_init (pdev, indio_dev, true, - cros_ec_sensors_capture,NULL ); + cros_ec_sensors_capture);if (ret)return ret;
@@ -235,7 +235,7 @@ static int cros_ec_accel_legacy_probe(struct platform_device *pdev) state->sign[CROS_EC_SENSOR_Z ] =-1 ; } -return devm_iio_device_register (dev, indio_dev); +return cros_ec_sensors_core_register (dev, indio_dev,NULL ); }static struct platform_driver cros_ec_accel_platform_driver = {
drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c +2 -2
@@ -97,7 +97,7 @@ static int cros_ec_lid_angle_probe(struct platform_device *pdev)if (!indio_dev)return -ENOMEM ; - ret =cros_ec_sensors_core_init (pdev, indio_dev, false,NULL ,NULL ); + ret =cros_ec_sensors_core_init (pdev, indio_dev, false,NULL );if (ret)return ret;
@@ -113,7 +113,7 @@ static int cros_ec_lid_angle_probe(struct platform_device *pdev)if (ret)return ret; -return devm_iio_device_register (dev, indio_dev); +return cros_ec_sensors_core_register (dev, indio_dev,NULL ); }static const struct platform_device_id cros_ec_lid_angle_ids[] = {
drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c +3 -3
@@ -235,8 +235,7 @@ static int cros_ec_sensors_probe(struct platform_device *pdev)return -ENOMEM ; ret =cros_ec_sensors_core_init (pdev, indio_dev, true, - cros_ec_sensors_capture, - cros_ec_sensors_push_data); + cros_ec_sensors_capture);if (ret)return ret;
@@ -297,7 +296,8 @@ static int cros_ec_sensors_probe(struct platform_device *pdev)else state->core.read_ec_sensors_data = cros_ec_sensors_read_cmd; -return devm_iio_device_register (dev, indio_dev); +return cros_ec_sensors_core_register (dev, indio_dev, + cros_ec_sensors_push_data); }static const struct platform_device_id cros_ec_sensors_ids[] = {
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +42 -16
86 lines not on this page · raw message
drivers/iio/light/cros_ec_light_prox.c +3 -3
@@ -181,8 +181,7 @@ static int cros_ec_light_prox_probe(struct platform_device *pdev)return -ENOMEM ; ret =cros_ec_sensors_core_init (pdev, indio_dev, true, - cros_ec_sensors_capture, - cros_ec_sensors_push_data); + cros_ec_sensors_capture);if (ret)return ret;
@@ -240,7 +239,8 @@ static int cros_ec_light_prox_probe(struct platform_device *pdev) state->core.read_ec_sensors_data = cros_ec_sensors_read_cmd; -return devm_iio_device_register (dev, indio_dev); +return cros_ec_sensors_core_register (dev, indio_dev, + cros_ec_sensors_push_data); }static const struct platform_device_id cros_ec_light_prox_ids[] = {
drivers/iio/pressure/cros_ec_baro.c +3 -3
@@ -138,8 +138,7 @@ static int cros_ec_baro_probe(struct platform_device *pdev)return -ENOMEM ; ret =cros_ec_sensors_core_init (pdev, indio_dev, true, - cros_ec_sensors_capture, - cros_ec_sensors_push_data); + cros_ec_sensors_capture);if (ret)return ret;
@@ -186,7 +185,8 @@ static int cros_ec_baro_probe(struct platform_device *pdev) state->core.read_ec_sensors_data = cros_ec_sensors_read_cmd; -return devm_iio_device_register (dev, indio_dev); +return cros_ec_sensors_core_register (dev, indio_dev, + cros_ec_sensors_push_data); }static const struct platform_device_id cros_ec_baro_ids[] = {
include/linux/iio/common/cros_ec_sensors_core.h +5 -2
@@ -95,8 +95,11 @@ int cros_ec_sensors_read_cmd(struct iio_dev *indio_dev, unsigned long scan_mask,struct platform_device ;int cros_ec_sensors_core_init (struct platform_device *pdev,struct iio_dev *indio_dev,bool physical_device, -cros_ec_sensors_capture_t trigger_capture, -cros_ec_sensorhub_push_data_cb_t push_data); +cros_ec_sensors_capture_t trigger_capture); + +int cros_ec_sensors_core_register (struct device *dev, +struct iio_dev *indio_dev, +cros_ec_sensorhub_push_data_cb_t push_data);irqreturn_t cros_ec_sensors_capture (int irq,void *p); int cros_ec_sensors_push_data(struct iio_dev *indio_dev,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 830/1157 clk: qcom: Drop mmcx gdsc supply for dispcc and videocc
In reply to Greg Kroah-HartmanFrom: Abel Vesa <[email protected]>
[ Upstream commit b1ec8b53c9ae5fae33d60e9638d39ca5346b941b ]
Both dispcc and videocc use mmcx power domain now. Lets drop the supply mmcx from every gdsc.
--- drivers/clk/qcom/dispcc-sm8250.c | 1 - drivers/clk/qcom/videocc-sm8250.c | 4 ---- 2 files changed, 5 deletions(-)
drivers/clk/qcom/dispcc-sm8250.c +0 -1
@@ -1134,7 +1134,6 @@ static struct gdsc mdss_gdsc = { }, .pwrsts = PWRSTS_OFF_ON, .flags = HW_CTRL, - .supply = "mmcx", };static struct clk_regmap *disp_cc_sm8250_clocks[] = {
drivers/clk/qcom/videocc-sm8250.c +0 -4
@@ -277,7 +277,6 @@ static struct gdsc mvs0c_gdsc = { }, .flags = 0, .pwrsts = PWRSTS_OFF_ON, - .supply = "mmcx", };static struct gdsc mvs1c_gdsc = {
@@ -287,7 +286,6 @@ static struct gdsc mvs1c_gdsc = { }, .flags = 0, .pwrsts = PWRSTS_OFF_ON, - .supply = "mmcx", };static struct gdsc mvs0_gdsc = {
@@ -297,7 +295,6 @@ static struct gdsc mvs0_gdsc = { }, .flags = HW_CTRL, .pwrsts = PWRSTS_OFF_ON, - .supply = "mmcx", };static struct gdsc mvs1_gdsc = {
@@ -307,7 +304,6 @@ static struct gdsc mvs1_gdsc = { }, .flags = HW_CTRL, .pwrsts = PWRSTS_OFF_ON, - .supply = "mmcx", };static struct clk_regmap *video_cc_sm8250_clocks[] = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 831/1157 clk: qcom: gdsc: Bump parent usage count when GDSC is found enabled
In reply to Greg Kroah-HartmanFrom: Bjorn Andersson <[email protected]>
[ Upstream commit 41fff779d7948147f2440c4bb134cdf8b45b22d7 ]
When a GDSC is found to be enabled at boot the pm_runtime state will be unbalanced as the GDSC is later turned off. Fix this by increasing the usage counter on the power-domain, in line with how we handled the regulator state.
--- drivers/clk/qcom/gdsc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/clk/qcom/gdsc.c +8 -0
@@ -420,6 +420,14 @@ static int gdsc_init(struct gdsc *sc)return ret; } +/* ...and the power-domain */ + ret =gdsc_pm_runtime_get (sc); +if (ret) { +if (sc->rsupply) +regulator_disable (sc->rsupply); +return ret; + } +/* * Votable GDSCs can be ON due to Vote from other masters. * If a Votable GDSC is ON, make sure we have a Vote.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 832/1157 clk: qcom: gcc-msm8939: Fix weird field spacing in ftbl_gcc_camss_cci_clk
In reply to Greg Kroah-HartmanFrom: Bryan O'Donoghue <[email protected]>
[ Upstream commit 2bc308ebc453ba22f3f120f777b9ac48f973ee80 ]
Adding a new item to this frequency table I see the existing indentation is incorrect.
--- drivers/clk/qcom/gcc-msm8939.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/gcc-msm8939.c +1 -1
@@ -1014,7 +1014,7 @@ static struct clk_rcg2 blsp1_uart2_apps_clk_src = { };static const struct freq_tbl ftbl_gcc_camss_cci_clk[] = { -F (19200000 ,P_XO ,1 ,0 ,0 ), +F (19200000 ,P_XO ,1 ,0 ,0 ), { } };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 833/1157 RDMA/hfi1: fix potential memory leak in setup_base_ctxt()
In reply to Greg Kroah-HartmanFrom: Jianglei Nie <[email protected]>
[ Upstream commit aa2a1df3a2c85f855af7d54466ac10bd48645d63 ]
setup_base_ctxt() allocates a memory chunk for uctxt->groups with hfi1_alloc_ctxt_rcv_groups(). When init_user_ctxt() fails, uctxt->groups is not released, which will lead to a memory leak.
We should release the uctxt->groups with hfi1_free_ctxt_rcv_groups() when init_user_ctxt() fails.
--- drivers/infiniband/hw/hfi1/file_ops.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/hfi1/file_ops.c +3 -1
@@ -1179,8 +1179,10 @@ static int setup_base_ctxt(struct hfi1_filedata *fd, goto done; ret =init_user_ctxt (fd, uctxt); -if (ret) +if (ret) { +hfi1_free_ctxt_rcv_groups (uctxt); goto done; + }user_init (uctxt);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 834/1157 gpio: gpiolib-of: Fix refcount bugs in of_mm_gpiochip_add_data()
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 5d07a692f9562f9c06e62cce369e9dd108173a0f ]
We should use of_node_get() when a new reference of device_node is created. It is noted that the old reference stored in 'mm_gc->gc.of_node' should also be decreased.
This patch is based on the fact that there is a call site in function 'qe_add_gpiochips()' of src file 'drivers\soc\fsl\qe\gpio.c'. In this function, of_mm_gpiochip_add_data() is contained in an iteration of for_each_compatible_node() which will automatically increase and decrease the refcount. So we need additional of_node_get() for the reference escape in of_mm_gpiochip_add_data().
--- drivers/gpio/gpiolib-of.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpio/gpiolib-of.c +3 -1
@@ -860,7 +860,8 @@ int of_mm_gpiochip_add_data(struct device_node *np,if (mm_gc->save_regs) mm_gc->save_regs (mm_gc); - mm_gc->gc.of_node = np; +of_node_put (mm_gc->gc.of_node); + mm_gc->gc.of_node =of_node_get (np); ret =gpiochip_add_data (gc, data);if (ret)
@@ -868,6 +869,7 @@ int of_mm_gpiochip_add_data(struct device_node *np,return 0 ; err2: +of_node_put (np);iounmap (mm_gc->regs); err1:kfree (gc->label);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 835/1157 iio: adc: max1027: unlock on error path in max1027_read_single_value()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 06ee60eb507f00fb3643876ec05318c63332dc88 ]
If max1027_wait_eoc() fails then call iio_device_release_direct_mode() before returning.
--- drivers/iio/adc/max1027.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/adc/max1027.c +3 -3
@@ -349,8 +349,7 @@ static int max1027_read_single_value(struct iio_dev *indio_dev,if (ret <0 ) {dev_err (&indio_dev->dev,"Failed to configure conversion register\n" ); -iio_device_release_direct_mode (indio_dev); -return ret; + goto release; }/*
@@ -360,11 +359,12 @@ static int max1027_read_single_value(struct iio_dev *indio_dev,*/ ret =max1027_wait_eoc (indio_dev);if (ret) -return ret; + goto release;/* Read result */ ret =spi_read (st->spi, st->buffer, (chan->type ==IIO_TEMP ) ?4 :2 ); +release:iio_device_release_direct_mode (indio_dev);if (ret <0 )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 836/1157 HID: mcp2221: prevent a buffer overflow in mcp_smbus_write()
In reply to Greg Kroah-HartmanFrom: Harshit Mogalapalli <[email protected]>
[ Upstream commit 62ac2473553a00229e67bdf3cb023b62cf7f5a9a ]
Smatch Warning:drivers/hid/hid-mcp2221.c:388 mcp_smbus_write() error: __memcpy() '&mcp->txbuf[5]' too small (59 vs 255) drivers/hid/hid-mcp2221.c:388 mcp_smbus_write() error: __memcpy() 'buf' too small (34 vs 255)
The 'len' variable can take a value between 0-255 as it can come from data->block[0] and it is user data. So add an bound check to prevent a buffer overflow in memcpy().
--- drivers/hid/hid-mcp2221.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hid/hid-mcp2221.c +3 -0
@@ -385,6 +385,9 @@ static int mcp_smbus_write(struct mcp2221 *mcp, u16 addr, data_len =7 ;break ;default : +if (len >I2C_SMBUS_BLOCK_MAX ) +return -EINVAL ; +memcpy (&mcp->txbuf[5 ], buf, len); data_len = len +5 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 837/1157 HID: amd_sfh: Add NULL check for hid device
In reply to Greg Kroah-HartmanFrom: Basavaraj Natikar <[email protected]>
[ Upstream commit 06aa2a43c307cf4096f422dcb575e5d2913e528f ]
On removal of hid device during SFH set report may cause NULL pointer exception. Hence add NULL check for hid device before accessing.
--- drivers/hid/amd-sfh-hid/amd_sfh_hid.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/hid/amd-sfh-hid/amd_sfh_hid.c +8 -4
@@ -101,11 +101,15 @@ static int amdtp_wait_for_response(struct hid_device *hid)void amdtp_hid_wakeup (struct hid_device *hid) { -struct amdtp_hid_data *hid_data = hid->driver_data; -struct amdtp_cl_data *cli_data = hid_data->cli_data; +struct amdtp_hid_data *hid_data; +struct amdtp_cl_data *cli_data; - cli_data->request_done[cli_data->cur_hid_dev] = true; -wake_up_interruptible (&hid_data->hid_wait); +if (hid) { + hid_data = hid->driver_data; + cli_data = hid_data->cli_data; + cli_data->request_done[cli_data->cur_hid_dev] = true; +wake_up_interruptible (&hid_data->hid_wait); + } }static struct hid_ll_driver amdtp_hid_ll_driver = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 838/1157 dmaengine: imx-dma: Cast of_device_get_match_data() with (uintptr_t)
In reply to Greg Kroah-HartmanFrom: Fabio Estevam <[email protected]>
[ Upstream commit c3266ee185b59e5aab3e0f982e5b7f95d31555a7 ]
Change the of_device_get_match_data() cast to (uintptr_t) to silence the following clang warning:
drivers/dma/imx-dma.c:1048:20: warning: cast to smaller integer type 'enum imx_dma_type' from 'const void *' [-Wvoid-pointer-to-enum-cast]
--- drivers/dma/imx-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/imx-dma.c +1 -1
@@ -1047,7 +1047,7 @@ static int __init imxdma_probe(struct platform_device *pdev)return -ENOMEM ; imxdma->dev = &pdev->dev; - imxdma->devtype = (enum imx_dma_type )of_device_get_match_data (&pdev->dev); + imxdma->devtype = (uintptr_t )of_device_get_match_data (&pdev->dev); res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); imxdma->base =devm_ioremap_resource (&pdev->dev, res);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 839/1157 scripts/gdb: fix lx-dmesg on 32 bits arch
In reply to Greg Kroah-HartmanFrom: Antonio Borneo <[email protected]>
[ Upstream commit e3c8d33e0d62175c31ca7ab7ab01b18f0b6318d3 ]
The type atomic_long_t can have size 4 or 8 bytes, depending on CONFIG_64BIT; it's only content, the field 'counter', is either an int or a s64 value.
Current code incorrectly uses the fixed size utils.read_u64() to read the field 'counter' inside atomic_long_t.
On 32 bits architectures reading the last element 'tail_id' of the struct prb_desc_ring:
struct prb_desc_ring {
...
atomic_long_t tail_id;
};causes the utils.read_u64() to access outside the boundary of the struct and the gdb command 'lx-dmesg' exits with error:
Python Exception <class 'IndexError'>: index out of range Error occurred in Python: index out of range
Query the really used atomic_long_t counter type size.
--- scripts/gdb/linux/dmesg.py | 9 +++------ scripts/gdb/linux/utils.py | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 8 deletions(-)
scripts/gdb/linux/dmesg.py +3 -6
@@ -22,7 +22,6 @@ prb_desc_type = utils.CachedType("struct prb_desc") prb_desc_ring_type = utils.CachedType("struct prb_desc_ring") prb_data_ring_type = utils.CachedType("struct prb_data_ring") printk_ringbuffer_type = utils.CachedType("struct printk_ringbuffer") -atomic_long_type = utils.CachedType("atomic_long_t") class LxDmesg(gdb.Command): """Print Linux kernel log buffer."""
@@ -68,8 +67,6 @@ class LxDmesg(gdb.Command): off = prb_data_ring_type.get_type()['data'].bitpos // 8 text_data_addr = utils.read_ulong(text_data_ring, off) - counter_off = atomic_long_type.get_type()['counter'].bitpos // 8 - sv_off = prb_desc_type.get_type()['state_var'].bitpos // 8 off = prb_desc_type.get_type()['text_blk_lpos'].bitpos // 8
@@ -89,9 +86,9 @@ class LxDmesg(gdb.Command): # read in tail and head descriptor ids off = prb_desc_ring_type.get_type()['tail_id'].bitpos // 8 - tail_id = utils.read_u64(desc_ring, off + counter_off) + tail_id = utils.read_atomic_long(desc_ring, off) off = prb_desc_ring_type.get_type()['head_id'].bitpos // 8 - head_id = utils.read_u64(desc_ring, off + counter_off) + head_id = utils.read_atomic_long(desc_ring, off) did = tail_id while True:
@@ -102,7 +99,7 @@ class LxDmesg(gdb.Command): desc = utils.read_memoryview(inf, desc_addr + desc_off, desc_sz).tobytes() # skip non-committed record - state = 3 & (utils.read_u64(desc, sv_off + counter_off) >> desc_flags_shift) + state = 3 & (utils.read_atomic_long(desc, sv_off) >> desc_flags_shift) if state != desc_committed and state != desc_finalized: if did == head_id: break
scripts/gdb/linux/utils.py +12 -2
@@ -35,13 +35,12 @@ class CachedType: long_type = CachedType("long") - +atomic_long_type = CachedType("atomic_long_t") def get_long_type(): global long_type return long_type.get_type() - def offset_of(typeobj, field): element = gdb.Value(0).cast(typeobj) return int(str(element[field].address).split()[0], 16)
@@ -129,6 +128,17 @@ def read_ulong(buffer, offset): else: return read_u32(buffer, offset) +atomic_long_counter_offset = atomic_long_type.get_type()['counter'].bitpos +atomic_long_counter_sizeof = atomic_long_type.get_type()['counter'].type.sizeof + +def read_atomic_long(buffer, offset): + global atomic_long_counter_offset + global atomic_long_counter_sizeof + + if atomic_long_counter_sizeof == 8: + return read_u64(buffer, offset + atomic_long_counter_offset) + else: + return read_u32(buffer, offset + atomic_long_counter_offset) target_arch = None
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 840/1157 RDMA/rxe: Fix mw bind to allow any consumer key portion
In reply to Greg Kroah-HartmanFrom: Bob Pearson <[email protected]>
[ Upstream commit 1603f89935ec86d40a7667e1250392626976ccc2 ]
The current implementation of rxe_check_bind_mw() in rxe_mw.c is incorrect since it requires the new key portion provided by the mw consumer to be different than the previous key portion. This is not required by the IBA. Remove the test.
--- drivers/infiniband/sw/rxe/rxe_mw.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/infiniband/sw/rxe/rxe_mw.c +0 -7
@@ -48,8 +48,6 @@ int rxe_dealloc_mw(struct ib_mw *ibmw)static int rxe_check_bind_mw (struct rxe_qp *qp,struct rxe_send_wqe *wqe,struct rxe_mw *mw,struct rxe_mr *mr) { -u32 key = wqe->wr.wr.mw.rkey &0xff ; -if (mw->ibmw.type ==IB_MW_TYPE_1 ) {if (unlikely (mw->state !=RXE_MW_STATE_VALID )) { pr_err_once(
@@ -87,11 +85,6 @@ static int rxe_check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, } } -if (unlikely (key == (mw->rkey &0xff ))) { -pr_err_once ("attempt to bind MW with same key\n" ); -return -EINVAL ; - } -/* remaining checks only apply to a nonzero MR */ if (!mr)return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 841/1157 mmc: core: quirks: Add of_node_put() when breaking out of loop
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 883c1d6fa4368a63cae2d6ae2d9c91141c60e233 ]
In mmc_fixup_of_compatible_match(), we should call of_node_put() when breaking out of for_each_child_of_node() which will increase and decrease the refcount during one iteration.
--- drivers/mmc/core/quirks.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/core/quirks.h +3 -1
@@ -163,8 +163,10 @@ static inline bool mmc_fixup_of_compatible_match(struct mmc_card *card,struct device_node *np;for_each_child_of_node (mmc_dev (card->host)->of_node, np) { -if (of_device_is_compatible (np, compatible)) +if (of_device_is_compatible (np, compatible)) { +of_node_put (np);return true; + } }return false;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 842/1157 mmc: cavium-octeon: Add of_node_put() when breaking out of loop
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 19bbb49acf8d7a03cb83e05624363741a4c3ec6f ]
In octeon_mmc_probe(), we should call of_node_put() when breaking out of for_each_child_of_node() which has increased and decreased the refcount during each iteration.
--- drivers/mmc/host/cavium-octeon.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/host/cavium-octeon.c +1 -0
@@ -277,6 +277,7 @@ static int octeon_mmc_probe(struct platform_device *pdev)if (ret) {dev_err (&pdev->dev,"Error populating slots\n" );octeon_mmc_set_shared_power (host,0 ); +of_node_put (cn); goto error; } i++;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 843/1157 mmc: cavium-thunderx: Add of_node_put() when breaking out of loop
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 7ee480795e41db314f2c445c65ed854a5d6e8e32 ]
In thunder_mmc_probe(), we should call of_node_put() when breaking out of for_each_child_of_node() which has increased and decreased the refcount during each iteration.
--- drivers/mmc/host/cavium-thunderx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/host/cavium-thunderx.c +3 -1
@@ -142,8 +142,10 @@ static int thunder_mmc_probe(struct pci_dev *pdev,continue ; ret =cvm_mmc_of_slot_probe (&host->slot_pdev[i]->dev, host); -if (ret) +if (ret) { +of_node_put (child_node); goto error; + } } i++; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 844/1157 HID: alps: Declare U1_UNICORN_LEGACY support
In reply to Greg Kroah-HartmanFrom: Artem Borisov <[email protected]>
[ Upstream commit 1117d182c5d72abd7eb8b7d5e7b8c3373181c3ab ]
U1_UNICORN_LEGACY id was added to the driver, but was not declared in the device id table, making it impossible to use.
--- drivers/hid/hid-alps.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hid/hid-alps.c +2 -0
@@ -830,6 +830,8 @@ static const struct hid_device_id alps_id[] = { USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1_DUAL) }, { HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1) }, + { HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, + USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1_UNICORN_LEGACY) }, { HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_T4_BTNLESS) }, { }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 845/1157 RDMA/rxe: For invalidate compare according to set keys in mr
In reply to Greg Kroah-HartmanFrom: Md Haris Iqbal <[email protected]>
[ Upstream commit 174e7b137042f19b5ce88beb4fc0ff4ec6b0c72a ]
The 'rkey' input can be an lkey or rkey, and in rxe the lkey or rkey have the same value, including the variant bits.
So, if mr->rkey is set, compare the invalidate key with it, otherwise compare with the mr->lkey.
Since we already did a lookup on the non-varient bits to get this far, the check's only purpose is to confirm that the wqe has the correct variant bits.
--- drivers/infiniband/sw/rxe/rxe_loc.h | 2 +- drivers/infiniband/sw/rxe/rxe_mr.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/infiniband/sw/rxe/rxe_loc.h +1 -1
@@ -77,7 +77,7 @@ struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key, enum rxe_mr_lookup_type type);int mr_check_range (struct rxe_mr *mr,u64 iova,size_t length);int advance_dma_data (struct rxe_dma_info *dma,unsigned int length); -int rxe_invalidate_mr (struct rxe_qp *qp,u32 rkey); +int rxe_invalidate_mr (struct rxe_qp *qp,u32 key);int rxe_reg_fast_mr (struct rxe_qp *qp,struct rxe_send_wqe *wqe);int rxe_mr_set_page (struct ib_mr *ibmr,u64 addr);int rxe_dereg_mr (struct ib_mr *ibmr,struct ib_udata *udata);
drivers/infiniband/sw/rxe/rxe_mr.c +6 -6
@@ -576,22 +576,22 @@ struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key,return mr; } -int rxe_invalidate_mr (struct rxe_qp *qp,u32 rkey) +int rxe_invalidate_mr (struct rxe_qp *qp,u32 key) {struct rxe_dev *rxe =to_rdev (qp->ibqp.device);struct rxe_mr *mr;int ret; - mr =rxe_pool_get_index (&rxe->mr_pool, rkey >>8 ); + mr =rxe_pool_get_index (&rxe->mr_pool, key >>8 );if (!mr) { -pr_err ("%s: No MR for rkey %#x\n" , __func__, rkey); +pr_err ("%s: No MR for key %#x\n" , __func__, key); ret = -EINVAL ; goto err; } -if (rkey != mr->rkey) { -pr_err ("%s: rkey (%#x) doesn't match mr->rkey (%#x)\n" , - __func__, rkey, mr->rkey); +if (mr->rkey ? (key != mr->rkey) : (key != mr->lkey)) { +pr_err ("%s: wr key (%#x) doesn't match mr key (%#x)\n" , + __func__, key, (mr->rkey ? mr->rkey : mr->lkey)); ret = -EINVAL ; goto err_drop_ref; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 846/1157 RDMA/rxe: Fix rnr retry behavior
In reply to Greg Kroah-HartmanFrom: Bob Pearson <[email protected]>
[ Upstream commit 445fd4f4fb76d513de6b05b08b3a4d0bb980fc80 ]
Currently the completer tasklet when retransmit timer or the rnr timer fires the same flag (qp->req.need_retry) is set so that if either timer fires it will attempt to perform a retry flow on the send queue. This has the effect of responding to an RNR NAK at the first retransmit timer event which might not allow the requested rnr timeout.
This patch adds a new flag (qp->req.wait_for_rnr_timer) which, if set, prevents a retry flow until the rnr nak timer fires.
This patch fixes rnr retry errors which can be observed by running the pyverbs test_rdmacm_async_traffic_external_qp multiple times. With this patch applied they do not occur.
--- drivers/infiniband/sw/rxe/rxe_comp.c | 8 +++++++- drivers/infiniband/sw/rxe/rxe_qp.c | 1 + drivers/infiniband/sw/rxe/rxe_req.c | 15 +++++++++++++-- drivers/infiniband/sw/rxe/rxe_verbs.h | 1 + 4 files changed, 22 insertions(+), 3 deletions(-)
drivers/infiniband/sw/rxe/rxe_comp.c +7 -1
@@ -114,6 +114,8 @@ void retransmit_timer(struct timer_list *t) {struct rxe_qp *qp =from_timer (qp, t, retrans_timer); +pr_debug ("%s: fired for qp#%d\n" , __func__, qp->elem.index); +if (qp->valid) { qp->comp.timeout =1 ;rxe_run_task (&qp->comp.task,1 );
@@ -730,11 +732,15 @@ int rxe_completer(void *arg)break ;case COMPST_RNR_RETRY : +/* we come here if we received an RNR NAK */ if (qp->comp.rnr_retry >0 ) {if (qp->comp.rnr_retry !=7 ) qp->comp.rnr_retry--; - qp->req.need_retry =1 ; +/* don't start a retry flow until the +* rnr timer has fired +*/ + qp->req.wait_for_rnr_timer =1 ;pr_debug ("qp#%d set rnr nak timer\n" ,qp_num (qp)); mod_timer(&qp->rnr_nak_timer,
drivers/infiniband/sw/rxe/rxe_qp.c +1 -0
@@ -507,6 +507,7 @@ static void rxe_qp_reset(struct rxe_qp *qp)atomic_set (&qp->ssn,0 ); qp->req.opcode =-1 ; qp->req.need_retry =0 ; + qp->req.wait_for_rnr_timer =0 ; qp->req.noack_pkts =0 ; qp->resp.msn =0 ; qp->resp.opcode =-1 ;
drivers/infiniband/sw/rxe/rxe_req.c +13 -2
@@ -101,7 +101,11 @@ void rnr_nak_timer(struct timer_list *t) {struct rxe_qp *qp =from_timer (qp, t, rnr_nak_timer); -pr_debug ("qp#%d rnr nak timer fired\n" ,qp_num (qp)); +pr_debug ("%s: fired for qp#%d\n" , __func__,qp_num (qp)); + +/* request a send queue retry */ + qp->req.need_retry =1 ; + qp->req.wait_for_rnr_timer =0 ;rxe_run_task (&qp->req.task,1 ); }
@@ -622,10 +626,17 @@ int rxe_requester(void *arg) qp->req.need_rd_atomic =0 ; qp->req.wait_psn =0 ; qp->req.need_retry =0 ; + qp->req.wait_for_rnr_timer =0 ; goto exit; } -if (unlikely (qp->req.need_retry)) { +/* we come here if the retransmot timer has fired +* or if the rnr timer has fired. If the retransmit +* timer fires while we are processing an RNR NAK wait +* until the rnr timer has fired before starting the +* retry flow +*/ +if (unlikely (qp->req.need_retry && !qp->req.wait_for_rnr_timer)) {req_retry (qp); qp->req.need_retry =0 ; }
drivers/infiniband/sw/rxe/rxe_verbs.h +1 -0
@@ -124,6 +124,7 @@ struct rxe_req_info {int need_rd_atomic;int wait_psn;int need_retry; +int wait_for_rnr_timer;int noack_pkts;struct rxe_task task; };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 847/1157 PCI: tegra194: Fix Root Port interrupt handling
In reply to Greg Kroah-HartmanFrom: Vidya Sagar <[email protected]>
[ Upstream commit 6646e99bcec627e866bc84365af37942c72b4b76 ]
As part of Root Port interrupt handling, level-0 register is read first and based on the bits set in that, corresponding level-1 registers are read for further interrupt processing. Since both these values are currently read into the same 'val' variable, checking level-0 bits the second time around is happening on the 'val' variable value of level-1 register contents instead of freshly reading the level-0 value again.
Fix by using different variables to store level-0 and level-1 registers contents.
--- drivers/pci/controller/dwc/pcie-tegra194.c | 46 +++++++++++----------- 1 file changed, 22 insertions(+), 24 deletions(-)
drivers/pci/controller/dwc/pcie-tegra194.c +22 -24
@@ -350,15 +350,14 @@ static irqreturn_t tegra_pcie_rp_irq_handler(int irq, void *arg)struct tegra194_pcie *pcie = arg;struct dw_pcie *pci = &pcie->pci;struct pcie_port *pp = &pci->pp; -u32 val, tmp; +u32 val, status_l0, status_l1;u16 val_w; - val =appl_readl (pcie,APPL_INTR_STATUS_L0 ); -if (val &APPL_INTR_STATUS_L0_LINK_STATE_INT ) { - val =appl_readl (pcie,APPL_INTR_STATUS_L1_0_0 ); -if (val &APPL_INTR_STATUS_L1_0_0_LINK_REQ_RST_NOT_CHGED ) { -appl_writel (pcie, val,APPL_INTR_STATUS_L1_0_0 ); - + status_l0 =appl_readl (pcie,APPL_INTR_STATUS_L0 ); +if (status_l0 &APPL_INTR_STATUS_L0_LINK_STATE_INT ) { + status_l1 =appl_readl (pcie,APPL_INTR_STATUS_L1_0_0 ); +appl_writel (pcie, status_l1,APPL_INTR_STATUS_L1_0_0 ); +if (status_l1 &APPL_INTR_STATUS_L1_0_0_LINK_REQ_RST_NOT_CHGED ) {/* SBR & Surprise Link Down WAR */ val =appl_readl (pcie,APPL_CAR_RESET_OVRD ); val &= ~APPL_CAR_RESET_OVRD_CYA_OVERRIDE_CORE_RST_N ;
@@ -374,15 +373,15 @@ static irqreturn_t tegra_pcie_rp_irq_handler(int irq, void *arg) } } -if (val &APPL_INTR_STATUS_L0_INT_INT ) { - val =appl_readl (pcie,APPL_INTR_STATUS_L1_8_0 ); -if (val &APPL_INTR_STATUS_L1_8_0_AUTO_BW_INT_STS ) { +if (status_l0 &APPL_INTR_STATUS_L0_INT_INT ) { + status_l1 =appl_readl (pcie,APPL_INTR_STATUS_L1_8_0 ); +if (status_l1 &APPL_INTR_STATUS_L1_8_0_AUTO_BW_INT_STS ) {appl_writel (pcie,APPL_INTR_STATUS_L1_8_0_AUTO_BW_INT_STS ,APPL_INTR_STATUS_L1_8_0 );apply_bad_link_workaround (pp); } -if (val &APPL_INTR_STATUS_L1_8_0_BW_MGT_INT_STS ) { +if (status_l1 &APPL_INTR_STATUS_L1_8_0_BW_MGT_INT_STS ) {appl_writel (pcie,APPL_INTR_STATUS_L1_8_0_BW_MGT_INT_STS ,APPL_INTR_STATUS_L1_8_0 );
@@ -394,25 +393,24 @@ static irqreturn_t tegra_pcie_rp_irq_handler(int irq, void *arg) } } - val =appl_readl (pcie,APPL_INTR_STATUS_L0 ); -if (val &APPL_INTR_STATUS_L0_CDM_REG_CHK_INT ) { - val =appl_readl (pcie,APPL_INTR_STATUS_L1_18 ); - tmp =dw_pcie_readl_dbi (pci,PCIE_PL_CHK_REG_CONTROL_STATUS ); -if (val &APPL_INTR_STATUS_L1_18_CDM_REG_CHK_CMPLT ) { +if (status_l0 &APPL_INTR_STATUS_L0_CDM_REG_CHK_INT ) { + status_l1 =appl_readl (pcie,APPL_INTR_STATUS_L1_18 ); + val =dw_pcie_readl_dbi (pci,PCIE_PL_CHK_REG_CONTROL_STATUS ); +if (status_l1 &APPL_INTR_STATUS_L1_18_CDM_REG_CHK_CMPLT ) {dev_info (pci->dev,"CDM check complete\n" ); - tmp |=PCIE_PL_CHK_REG_CHK_REG_COMPLETE ; + val |=PCIE_PL_CHK_REG_CHK_REG_COMPLETE ; } -if (val &APPL_INTR_STATUS_L1_18_CDM_REG_CHK_CMP_ERR ) { +if (status_l1 &APPL_INTR_STATUS_L1_18_CDM_REG_CHK_CMP_ERR ) {dev_err (pci->dev,"CDM comparison mismatch\n" ); - tmp |=PCIE_PL_CHK_REG_CHK_REG_COMPARISON_ERROR ; + val |=PCIE_PL_CHK_REG_CHK_REG_COMPARISON_ERROR ; } -if (val &APPL_INTR_STATUS_L1_18_CDM_REG_CHK_LOGIC_ERR ) { +if (status_l1 &APPL_INTR_STATUS_L1_18_CDM_REG_CHK_LOGIC_ERR ) {dev_err (pci->dev,"CDM Logic error\n" ); - tmp |=PCIE_PL_CHK_REG_CHK_REG_LOGIC_ERROR ; + val |=PCIE_PL_CHK_REG_CHK_REG_LOGIC_ERROR ; } -dw_pcie_writel_dbi (pci,PCIE_PL_CHK_REG_CONTROL_STATUS , tmp); - tmp =dw_pcie_readl_dbi (pci,PCIE_PL_CHK_REG_ERR_ADDR ); -dev_err (pci->dev,"CDM Error Address Offset = 0x%08X\n" , tmp); +dw_pcie_writel_dbi (pci,PCIE_PL_CHK_REG_CONTROL_STATUS , val); + val =dw_pcie_readl_dbi (pci,PCIE_PL_CHK_REG_ERR_ADDR ); +dev_err (pci->dev,"CDM Error Address Offset = 0x%08X\n" , val); }return IRQ_HANDLED ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 848/1157 PCI: tegra194: Fix link up retry sequence
In reply to Greg Kroah-HartmanFrom: Vidya Sagar <[email protected]>
[ Upstream commit e05fd6ae77c3e2cc0dba283005d24b6d56d2b1fa ]
Add the missing DLF capability offset while clearing DL_FEATURE_EXCHANGE_EN bit during link up retry.
--- drivers/pci/controller/dwc/pcie-tegra194.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-tegra194.c +1 -1
@@ -976,7 +976,7 @@ static int tegra194_pcie_start_link(struct dw_pcie *pci) offset =dw_pcie_find_ext_capability (pci,PCI_EXT_CAP_ID_DLF ); val =dw_pcie_readl_dbi (pci, offset +PCI_DLF_CAP ); val &= ~PCI_DLF_EXCHANGE_ENABLE ; -dw_pcie_writel_dbi (pci, offset, val); +dw_pcie_writel_dbi (pci, offset +PCI_DLF_CAP , val);tegra194_pcie_host_init (pp);dw_pcie_setup_rc (pp);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 849/1157 HID: amd_sfh: Handle condition of "no sensors"
In reply to Greg Kroah-HartmanFrom: Basavaraj Natikar <[email protected]>
[ Upstream commit 5d4d0f15657535f6a122ab26d47230b5c2b944af ]
Add a check for num_hid_devices to handle special case the situation of "no sensors".
--- drivers/hid/amd-sfh-hid/amd_sfh_client.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hid/amd-sfh-hid/amd_sfh_client.c +2 -0
@@ -173,6 +173,8 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) dev = &privdata->pdev->dev; cl_data->num_hid_devices =amd_mp2_get_sensor_num (privdata, &cl_data->sensor_idx[0 ]); +if (cl_data->num_hid_devices ==0 ) +return -ENODEV ;INIT_DELAYED_WORK (&cl_data->work, amd_sfh_work);INIT_DELAYED_WORK (&cl_data->work_buffer, amd_sfh_work_buffer);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 850/1157 USB: serial: fix tty-port initialized comments
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 688ee1d1785c1359f9040f615dd8e6054962bce2 ]
Fix up the tty-port initialized comments which got truncated and obfuscated when replacing the old ASYNCB_INITIALIZED flag.
--- drivers/usb/serial/sierra.c | 3 ++- drivers/usb/serial/usb-serial.c | 2 +- drivers/usb/serial/usb_wwan.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-)
drivers/usb/serial/sierra.c +2 -1
@@ -737,7 +737,8 @@ static void sierra_close(struct usb_serial_port *port)/* * Need to take susp_lock to make sure port is not already being -* resumed, but no need to hold it due to initialized +* resumed, but no need to hold it due to the tty-port initialized +* flag. */ spin_lock_irq (&intfdata->susp_lock);if (--intfdata->open_ports ==0 )
drivers/usb/serial/usb-serial.c +1 -1
@@ -295,7 +295,7 @@ static int serial_open(struct tty_struct *tty, struct file *filp)* * Shut down a USB serial port. Serialized against activate by the * tport mutex and kept to matching open/close pairs -* of calls by the initialized flag. +* of calls by the tty-port initialized flag. * * Not called if tty is console. */
drivers/usb/serial/usb_wwan.c +2 -1
@@ -388,7 +388,8 @@ void usb_wwan_close(struct usb_serial_port *port)/* * Need to take susp_lock to make sure port is not already being -* resumed, but no need to hold it due to initialized +* resumed, but no need to hold it due to the tty-port initialized +* flag. */ spin_lock_irq (&intfdata->susp_lock);if (--intfdata->open_ports ==0 )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 851/1157 usb: xhci_plat_remove: avoid NULL dereference
In reply to Greg Kroah-HartmanFrom: Alexey Sheplyakov <[email protected]>
[ Upstream commit d7de14d74d6551f0d097430f9893ce82ad17e5b8 ]
Since commit 4736ebd7fcaff1eb8481c140ba494962847d6e0a ("usb: host:
xhci-plat: omit shared hcd if either root hub has no ports") xhci->shared_hcd can be NULL, which causes the following Oops on reboot:
[ 710.124450] systemd-shutdown[1]: Rebooting. [ 710.298861] xhci-hcd xhci-hcd.2.auto: remove, state 4 [ 710.304217] usb usb3: USB disconnect, device number 1 [ 710.317441] xhci-hcd xhci-hcd.2.auto: USB bus 3 deregistered [ 710.323280] xhci-hcd xhci-hcd.2.auto: remove, state 1 [ 710.328401] usb usb2: USB disconnect, device number 1 [ 710.333515] usb 2-3: USB disconnect, device number 2 [ 710.467649] xhci-hcd xhci-hcd.2.auto: USB bus 2 deregistered [ 710.475450] Unable to handle kernel NULL pointer dereference at virtual address 00000000000003b8 [ 710.484425] Mem abort info: [ 710.487265] ESR = 0x0000000096000004 [ 710.491060] EC = 0x25: DABT (current EL), IL = 32 bits [ 710.496427] SET = 0, FnV = 0 [ 710.499525] EA = 0, S1PTW = 0 [ 710.502716] FSC = 0x04: level 0 translation fault [ 710.507648] Data abort info: [ 710.510577] ISV = 0, ISS = 0x00000004 [ 710.514462] CM = 0, WnR = 0 [ 710.517480] user pgtable: 4k pages, 48-bit VAs, pgdp=00000008b0050000 [ 710.523976] [00000000000003b8] pgd=0000000000000000, p4d=0000000000000000 [ 710.530961] Internal error: Oops: 96000004 [#1] PREEMPT SMP [ 710.536551] Modules linked in: rfkill input_leds snd_soc_simple_card snd_soc_simple_card_utils snd_soc_nau8822 designware_i2s snd_soc_core dw_hdmi_ahb_audio snd_pcm_dmaengine arm_ccn panfrost ac97_bus gpu_sched snd_pcm at24 fuse configfs sdhci_of_dwcmshc sdhci_pltfm sdhci nvme led_class mmc_core nvme_core bt1_pvt polynomial tp_serio snd_seq_midi snd_seq_midi_event snd_seq snd_timer snd_rawmidi snd_seq_device snd soundcore efivarfs ipv6 [ 710.575286] CPU: 7 PID: 1 Comm: systemd-shutdow Not tainted 5.19.0-rc7-00043-gfd8619f4fd54 #1 [ 710.583822] Hardware name: T-Platforms TF307-MB/BM1BM1-A, BIOS 5.6 07/06/2022 [ 710.590972] pstate: 40000005 (nZcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 710.597949] pc : usb_remove_hcd+0x34/0x1e4 [ 710.602067] lr : xhci_plat_remove+0x74/0x140 [ 710.606351] sp : ffff800009f3b7c0 [ 710.609674] x29: ffff800009f3b7c0 x28: ffff000800960040 x27: 0000000000000000 [ 710.616833] x26: ffff800008dc22a0 x25: 0000000000000000 x24: 0000000000000000 [ 710.623992] x23: 0000000000000000 x22: ffff000805465810 x21: ffff000805465800 [ 710.631149] x20: ffff000800f80000 x19: 0000000000000000 x18: ffffffffffffffff [ 710.638307] x17: ffff000805096000 x16: ffff00080633b800 x15: ffff000806537a1c [ 710.645465] x14: 0000000000000001 x13: 0000000000000000 x12: ffff00080378d6f0 [ 710.652621] x11: ffff00080041a900 x10: ffff800009b204e8 x9 : ffff8000088abaa4 [ 710.659779] x8 : ffff000800960040 x7 : ffff800009409000 x6 : 0000000000000001 [ 710.666936] x5 : ffff800009241000 x4 : ffff800009241440 x3 : 0000000000000000 [ 710.674094] x2 : ffff000800960040 x1 : ffff000800960040 x0 : 0000000000000000 [ 710.681251] Call trace: [ 710.683704] usb_remove_hcd+0x34/0x1e4 [ 710.687467] xhci_plat_remove+0x74/0x140 [ 710.691400] platform_remove+0x34/0x70 [ 710.695165] device_remove+0x54/0x90 [ 710.698753] device_release_driver_internal+0x200/0x270 [ 710.703992] device_release_driver+0x24/0x30 [ 710.708273] bus_remove_device+0xe0/0x16c [ 710.712293] device_del+0x178/0x390 [ 710.715797] platform_device_del.part.0+0x24/0x90 [ 710.720514] platform_device_unregister+0x30/0x50 [ 710.725232] dwc3_host_exit+0x20/0x30 [ 710.728907] dwc3_remove+0x174/0x1b0 [ 710.732494] platform_remove+0x34/0x70 [ 710.736254] device_remove+0x54/0x90 [ 710.739840] device_release_driver_internal+0x200/0x270 [ 710.745078] device_release_driver+0x24/0x30 [ 710.749359] bus_remove_device+0xe0/0x16c [ 710.753380] device_del+0x178/0x390 [ 710.756881] platform_device_del.part.0+0x24/0x90 [ 710.761598] platform_device_unregister+0x30/0x50 [ 710.766314] of_platform_device_destroy+0xe8/0x100 [ 710.771119] device_for_each_child_reverse+0x70/0xc0 [ 710.776099] of_platform_depopulate+0x48/0x90 [ 710.780468] __dwc3_of_simple_teardown+0x28/0xe0 [ 710.785099] dwc3_of_simple_shutdown+0x20/0x30 [ 710.789555] platform_shutdown+0x30/0x40 [ 710.793490] device_shutdown+0x138/0x32c [ 710.797425] __do_sys_reboot+0x1c4/0x2ac [ 710.801362] __arm64_sys_reboot+0x30/0x40 [ 710.805383] invoke_syscall+0x50/0x120 [ 710.809146] el0_svc_common.constprop.0+0x68/0x124 [ 710.813950] do_el0_svc+0x3c/0xcc [ 710.817275] el0_svc+0x60/0x12c [ 710.820428] el0t_64_sync_handler+0xc0/0x13c [ 710.824710] el0t_64_sync+0x18c/0x190 [ 710.828386] Code: a9025bf5 f942c420 f9001fe0 d2800000 (b943ba62) [ 710.834498] ---[ end trace 0000000000000000 ]--- [ 710.875958] pstore: crypto_comp_compress failed, ret = -22! [ 710.895047] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b [ 710.902757] Kernel Offset: disabled [ 710.906255] CPU features: 0x800,00004811,00001082 [ 710.910971] Memory Limit: none [ 710.927474] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---
To avoid the problem check for NULL in usb_remove_hcd.
--- drivers/usb/core/hcd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/core/hcd.c +7 -1
@@ -3037,9 +3037,15 @@ EXPORT_SYMBOL_GPL(usb_add_hcd);*/ void usb_remove_hcd (struct usb_hcd *hcd) { -struct usb_device *rhdev = hcd->self.root_hub; +struct usb_device *rhdev;bool rh_registered; +if (!hcd) { +pr_debug ("%s: hcd is NULL\n" , __func__); +return ; + } + rhdev = hcd->self.root_hub; +dev_info (hcd->self.controller,"remove, state %x\n" , hcd->state);usb_get_dev (rhdev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 852/1157 usb: cdns3: change place of priv_ep assignment in cdns3_gadget_ep_dequeue(), cdns3_gadget_ep_enable()
In reply to Greg Kroah-HartmanFrom: Andrey Strachuk <[email protected]>
[ Upstream commit c3ffc9c4ca44bfe9562166793d133e1fb0630ea6 ]
If 'ep' is NULL, result of ep_to_cdns3_ep(ep) is invalid pointer and its dereference with priv_ep->cdns3_dev may cause panic.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/usb/cdns3/cdns3-gadget.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/usb/cdns3/cdns3-gadget.c +6 -3
@@ -2285,14 +2285,15 @@ static int cdns3_gadget_ep_enable(struct usb_ep *ep,int val; priv_ep =ep_to_cdns3_ep (ep); - priv_dev = priv_ep->cdns3_dev; - comp_desc = priv_ep->endpoint.comp_desc;if (!ep || !desc || desc->bDescriptorType !=USB_DT_ENDPOINT ) {dev_dbg (priv_dev->dev,"usbss: invalid parameters\n" );return -EINVAL ; } + comp_desc = priv_ep->endpoint.comp_desc; + priv_dev = priv_ep->cdns3_dev; +if (!desc->wMaxPacketSize) {dev_err (priv_dev->dev,"usbss: missing wMaxPacketSize\n" );return -EINVAL ;
@@ -2600,7 +2601,7 @@ int cdns3_gadget_ep_dequeue(struct usb_ep *ep, struct usb_request *request) {struct cdns3_endpoint *priv_ep =ep_to_cdns3_ep (ep); -struct cdns3_device *priv_dev = priv_ep->cdns3_dev; +struct cdns3_device *priv_dev;struct usb_request *req, *req_temp;struct cdns3_request *priv_req;struct cdns3_trb *link_trb;
@@ -2611,6 +2612,8 @@ int cdns3_gadget_ep_dequeue(struct usb_ep *ep,if (!ep || !request || !ep->desc)return -EINVAL ; + priv_dev = priv_ep->cdns3_dev; +spin_lock_irqsave (&priv_dev->lock, flags); priv_req =to_cdns3_request (request);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 853/1157 mtd: spi-nor: fix spi_nor_spimem_setup_op() call in spi_nor_erase_{sector,chip}()
In reply to Greg Kroah-HartmanFrom: Patrice Chotard <[email protected]>
[ Upstream commit f8cd9f632f4415b1e8838bdca8ab42cfb37a6584 ]
For erase operations, reg_proto must be used as indicated in struct spi_nor description in spi-nor.h.
This issue was found when DT property spi-tx-bus-width is set to 4. In this case the spi_mem_op->addr.buswidth is set to 4 for erase command which is not correct.
Tested on stm32mp157c-ev1 board with mx66l51235f spi-nor.
--- drivers/mtd/spi-nor/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/spi-nor/core.c +3 -3
@@ -177,7 +177,7 @@ int spi_nor_controller_ops_write_reg(struct spi_nor *nor, u8 opcode,static int spi_nor_controller_ops_erase (struct spi_nor *nor,loff_t offs) { -if (spi_nor_protocol_is_dtr (nor->write_proto)) +if (spi_nor_protocol_is_dtr (nor->reg_proto))return -EOPNOTSUPP ;return nor->controller_ops->erase (nor, offs);
@@ -972,7 +972,7 @@ static int spi_nor_erase_chip(struct spi_nor *nor)if (nor->spimem) {struct spi_mem_op op =SPI_NOR_CHIP_ERASE_OP ; -spi_nor_spimem_setup_op (nor, &op, nor->write_proto); +spi_nor_spimem_setup_op (nor, &op, nor->reg_proto); ret =spi_mem_exec_op (nor->spimem, &op); }else {
@@ -1115,7 +1115,7 @@ int spi_nor_erase_sector(struct spi_nor *nor, u32 addr)SPI_NOR_SECTOR_ERASE_OP (nor->erase_opcode, nor->addr_width, addr); -spi_nor_spimem_setup_op (nor, &op, nor->write_proto); +spi_nor_spimem_setup_op (nor, &op, nor->reg_proto);return spi_mem_exec_op (nor->spimem, &op); }else if (nor->controller_ops->erase) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 854/1157 staging: fbtft: core: set smem_len before fb_deferred_io_init call
In reply to Greg Kroah-HartmanFrom: Peter Suti <[email protected]>
[ Upstream commit 81e878887ff82a7dd42f22951391069a5d520627 ]
The fbtft_framebuffer_alloc() calls fb_deferred_io_init() before initializing info->fix.smem_len. It is set to zero by the framebuffer_alloc() function. It will trigger a WARN_ON() at the start of fb_deferred_io_init() and the function will not do anything.
--- drivers/staging/fbtft/fbtft-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/fbtft/fbtft-core.c +1 -1
@@ -655,7 +655,6 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, fbdefio->delay =HZ / fps; fbdefio->sort_pagereflist = true; fbdefio->deferred_io = fbtft_deferred_io; -fb_deferred_io_init (info);snprintf (info->fix.id,sizeof (info->fix.id),"%s" , dev->driver->name); info->fix.type =FB_TYPE_PACKED_PIXELS ;
@@ -666,6 +665,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, info->fix.line_length = width * bpp /8 ; info->fix.accel =FB_ACCEL_NONE ; info->fix.smem_len = vmem_size; +fb_deferred_io_init (info); info->var.rotate = pdata->rotate; info->var.xres = width;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 855/1157 KVM: nVMX: Set UMIP bit CR4_FIXED1 MSR when emulating UMIP
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
[ Upstream commit a910b5ab6b250a88fff1866bf708642d83317466 ]
Make UMIP an "allowed-1" bit CR4_FIXED1 MSR when KVM is emulating UMIP. KVM emulates UMIP for both L1 and L2, and so should enumerate that L2 is allowed to have CR4.UMIP=1. Not setting the bit doesn't immediately break nVMX, as KVM does set/clear the bit in CR4_FIXED1 in response to a guest CPUID update, i.e. KVM will correctly (dis)allow nested VM-Entry based on whether or not UMIP is exposed to L1. That said, KVM should enumerate the bit as being allowed from time zero, e.g. userspace will see the wrong value if the MSR is read before CPUID is written.
Message-Id: <[email protected]>
--- arch/x86/kvm/vmx/nested.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kvm/vmx/nested.c +3 -0
@@ -6786,6 +6786,9 @@ void nested_vmx_setup_ctls_msrs(struct nested_vmx_msrs *msrs, u32 ept_caps)rdmsrl (MSR_IA32_VMX_CR0_FIXED1 , msrs->cr0_fixed1);rdmsrl (MSR_IA32_VMX_CR4_FIXED1 , msrs->cr4_fixed1); +if (vmx_umip_emulated ()) + msrs->cr4_fixed1 |=X86_CR4_UMIP ; + msrs->vmcs_enum =nested_vmx_calc_vmcs_enum_msr (); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 856/1157 tools/power/x86/intel-speed-select: Fix off by one check
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit d9f74d98bbec978edbf860f729b531281ba0d8ff ]
Change > MAX_DIE_PER_PACKAGE to >= MAX_DIE_PER_PACKAGE to prevent accessing one element beyond the end of the array.
--- tools/power/x86/intel-speed-select/isst-daemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/power/x86/intel-speed-select/isst-daemon.c +1 -1
@@ -41,7 +41,7 @@ void process_level_change(int cpu)time_t tm;int ret; -if (pkg_id >=MAX_PACKAGE_COUNT || die_id >MAX_DIE_PER_PACKAGE ) { +if (pkg_id >=MAX_PACKAGE_COUNT || die_id >=MAX_DIE_PER_PACKAGE ) {debug_printf ("Invalid package/die info for cpu:%d\n" , cpu);return ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 857/1157 platform/x86: pmc_atom: Match all Lex BayTrail boards with critclk_systems DMI table
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit c9d959fc32a5f9312282817052d8986614f2dc08 ]
The critclk_systems[] DMI match table already contains 2 Lex BayTrail boards and patches were just submitted to add 3 more entries for the following models: 3I380NX, 3I380A, 3I380CW.
Looking at: https://www.lex.com.tw/products/embedded-ipc-board/
we can see that Lex BayTrail makes many embedded boards with multiple ethernet boards and none of their products are battery powered so we don't need to worry (too much) about power consumption when suspended.
Add a new DMI match which simply matches all Lex BayTrail boards and drop the 2 existing board specific quirks.
--- drivers/platform/x86/pmc_atom.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/platform/x86/pmc_atom.c +7 -12
@@ -389,21 +389,16 @@ static const struct dmi_system_id critclk_systems[] = { }, }, { -/* pmc_plt_clk0 - 3 are used for the 4 ethernet controllers */ - .ident = "Lex 3I380D", +/* +* Lex System / Lex Computech Co. makes a lot of Bay Trail +* based embedded boards which often come with multiple +* ethernet controllers using multiple pmc_plt_clks. See: +* https://www.lex.com.tw/products/embedded-ipc-board/ +*/ + .ident = "Lex BayTrail", .callback = dmi_callback, .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Lex BayTrail"), - DMI_MATCH(DMI_PRODUCT_NAME, "3I380D"), - }, - }, - { -/* pmc_plt_clk* - are used for ethernet controllers */ - .ident ="Lex 2I385SW" , - .callback = dmi_callback, - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Lex BayTrail" ), - DMI_MATCH(DMI_PRODUCT_NAME, "2I385SW"), }, }, {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 858/1157 platform/mellanox: mlxreg-lc: Fix error flow and extend verbosity
In reply to Greg Kroah-HartmanFrom: Vadim Pasternak <[email protected]>
[ Upstream commit b4b830a34d8046633231b7fe87f6f2cb6240dc9f ]
Fix error flow:
- Clean-up client object in case of probing failure.
- Prevent running remove routine in case of probing failure. Probing and removing are invoked by hotplug events raised upon line card insertion and removing. If probing procedure failed all data is cleared and there is nothing to do in remove routine.
--- drivers/platform/mellanox/mlxreg-lc.c | 82 ++++++++++++++++++++------- 1 file changed, 63 insertions(+), 19 deletions(-)
drivers/platform/mellanox/mlxreg-lc.c +63 -19
@@ -716,8 +716,12 @@ mlxreg_lc_config_init(struct mlxreg_lc *mlxreg_lc, void *regmap,switch (regval) {case MLXREG_LC_SN4800_C16 : err =mlxreg_lc_sn4800_c16_config_init (mlxreg_lc, regmap, data); -if (err) +if (err) { +dev_err (dev,"Failed to config client %s at bus %d at addr 0x%02x\n" , + data->hpdev.brdinfo->type, data->hpdev.nr, + data->hpdev.brdinfo->addr);return err; + }break ;default :return -ENODEV ;
@@ -730,8 +734,11 @@ mlxreg_lc_config_init(struct mlxreg_lc *mlxreg_lc, void *regmap, mlxreg_lc->mux =platform_device_register_resndata (dev,"i2c-mux-mlxcpld" , data->hpdev.nr,NULL ,0 , mlxreg_lc->mux_data,sizeof (*mlxreg_lc->mux_data)); -if (IS_ERR (mlxreg_lc->mux)) +if (IS_ERR (mlxreg_lc->mux)) { +dev_err (dev,"Failed to create mux infra for client %s at bus %d at addr 0x%02x\n" , + data->hpdev.brdinfo->type, data->hpdev.nr, data->hpdev.brdinfo->addr);return PTR_ERR (mlxreg_lc->mux); + }/* Register IO access driver. */ if (mlxreg_lc->io_data) {
@@ -740,6 +747,9 @@ mlxreg_lc_config_init(struct mlxreg_lc *mlxreg_lc, void *regmap,platform_device_register_resndata (dev,"mlxreg-io" , data->hpdev.nr,NULL ,0 , mlxreg_lc->io_data,sizeof (*mlxreg_lc->io_data));if (IS_ERR (mlxreg_lc->io_regs)) { +dev_err (dev,"Failed to create regio for client %s at bus %d at addr 0x%02x\n" , + data->hpdev.brdinfo->type, data->hpdev.nr, + data->hpdev.brdinfo->addr); err =PTR_ERR (mlxreg_lc->io_regs); goto fail_register_io; }
@@ -753,6 +763,9 @@ mlxreg_lc_config_init(struct mlxreg_lc *mlxreg_lc, void *regmap, mlxreg_lc->led_data, sizeof(*mlxreg_lc->led_data));if (IS_ERR (mlxreg_lc->led)) { +dev_err (dev,"Failed to create LED objects for client %s at bus %d at addr 0x%02x\n" , + data->hpdev.brdinfo->type, data->hpdev.nr, + data->hpdev.brdinfo->addr); err =PTR_ERR (mlxreg_lc->led); goto fail_register_led; }
@@ -809,7 +822,8 @@ static int mlxreg_lc_probe(struct platform_device *pdev)if (!data->hpdev.adapter) {dev_err (&pdev->dev,"Failed to get adapter for bus %d\n" , data->hpdev.nr); -return -EFAULT ; + err = -EFAULT ; + goto i2c_get_adapter_fail; }/* Create device at the top of line card I2C tree.*/
@@ -818,32 +832,40 @@ static int mlxreg_lc_probe(struct platform_device *pdev)if (IS_ERR (data->hpdev.client)) {dev_err (&pdev->dev,"Failed to create client %s at bus %d at addr 0x%02x\n" , data->hpdev.brdinfo->type, data->hpdev.nr, data->hpdev.brdinfo->addr); - -i2c_put_adapter (data->hpdev.adapter); - data->hpdev.adapter =NULL ; -return PTR_ERR (data->hpdev.client); + err =PTR_ERR (data->hpdev.client); + goto i2c_new_device_fail; } regmap =devm_regmap_init_i2c (data->hpdev.client, &mlxreg_lc_regmap_conf);if (IS_ERR (regmap)) { +dev_err (&pdev->dev,"Failed to create regmap for client %s at bus %d at addr 0x%02x\n" , + data->hpdev.brdinfo->type, data->hpdev.nr, data->hpdev.brdinfo->addr); err =PTR_ERR (regmap); - goto mlxreg_lc_probe_fail; + goto devm_regmap_init_i2c_fail; }/* Set default registers. */ for (i =0 ; i < mlxreg_lc_regmap_conf.num_reg_defaults; i++) { err =regmap_write (regmap, mlxreg_lc_regmap_default[i].reg, mlxreg_lc_regmap_default[i].def); -if (err) - goto mlxreg_lc_probe_fail; +if (err) { +dev_err (&pdev->dev,"Failed to set default regmap %d for client %s at bus %d at addr 0x%02x\n" , + i, data->hpdev.brdinfo->type, data->hpdev.nr, + data->hpdev.brdinfo->addr); + goto regmap_write_fail; + } }/* Sync registers with hardware. */ regcache_mark_dirty (regmap); err =regcache_sync (regmap); -if (err) - goto mlxreg_lc_probe_fail; +if (err) { +dev_err (&pdev->dev,"Failed to sync regmap for client %s at bus %d at addr 0x%02x\n" , + data->hpdev.brdinfo->type, data->hpdev.nr, data->hpdev.brdinfo->addr); + err =PTR_ERR (regmap); + goto regcache_sync_fail; + } par_pdata = data->hpdev.brdinfo->platform_data; mlxreg_lc->par_regmap = par_pdata->regmap;
@@ -854,12 +876,27 @@ static int mlxreg_lc_probe(struct platform_device *pdev)/* Configure line card. */ err =mlxreg_lc_config_init (mlxreg_lc, regmap, data);if (err) - goto mlxreg_lc_probe_fail; + goto mlxreg_lc_config_init_fail;return err; -mlxreg_lc_probe_fail: +mlxreg_lc_config_init_fail: +regcache_sync_fail: +regmap_write_fail: +devm_regmap_init_i2c_fail: +if (data->hpdev.client) { +i2c_unregister_device (data->hpdev.client); + data->hpdev.client =NULL ; + } +i2c_new_device_fail:i2c_put_adapter (data->hpdev.adapter); + data->hpdev.adapter =NULL ; +i2c_get_adapter_fail: +/* Clear event notification callback and handle. */ +if (data->notifier) { + data->notifier->user_handler =NULL ; + data->notifier->handle =NULL ; + }return err; }
@@ -868,11 +905,18 @@ static int mlxreg_lc_remove(struct platform_device *pdev)struct mlxreg_core_data *data =dev_get_platdata (&pdev->dev);struct mlxreg_lc *mlxreg_lc =platform_get_drvdata (pdev); -/* Clear event notification callback. */ -if (data->notifier) { - data->notifier->user_handler =NULL ; - data->notifier->handle =NULL ; - } +/* +* Probing and removing are invoked by hotplug events raised upon line card insertion and +* removing. If probing procedure fails all data is cleared. However, hotplug event still +* will be raised on line card removing and activate removing procedure. In this case there +* is nothing to remove. +*/ +if (!data->notifier || !data->notifier->handle) +return 0 ; + +/* Clear event notification callback and handle. */ + data->notifier->user_handler =NULL ; + data->notifier->handle =NULL ;/* Destroy static I2C device feeding by main power. */ mlxreg_lc_destroy_static_devices(mlxreg_lc, mlxreg_lc->main_devs,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 859/1157 platform/olpc: Fix uninitialized data in debugfs write
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 40ec787e1adf302c11668d4cc69838f4d584187d ]
The call to:
size = simple_write_to_buffer(cmdbuf, sizeof(cmdbuf), ppos, buf, size);
will succeed if at least one byte is written to the "cmdbuf" buffer. The "*ppos" value controls which byte is written. Another problem is that this code does not check for errors so it's possible for the entire buffer to be uninitialized.
Inintialize the struct to zero to prevent reading uninitialized stack data.
Debugfs is normally only writable by root so the impact of this bug is very minimal.
--- drivers/platform/olpc/olpc-ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/olpc/olpc-ec.c +1 -1
@@ -264,7 +264,7 @@ static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf,int i, m;unsigned char ec_cmd[EC_MAX_CMD_ARGS ];unsigned int ec_cmd_int[EC_MAX_CMD_ARGS ]; -char cmdbuf[64 ]; +char cmdbuf[64 ] ="" ;int ec_cmd_bytes;mutex_lock (&ec_dbgfs_lock);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 860/1157 RDMA/srpt: Duplicate port name members
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
[ Upstream commit b03b1ae2a3125d4475452e4f19f5d3a6e910ff6e ]
Prepare for decoupling the lifetimes of struct srpt_port and struct srpt_port_id by duplicating the port name into struct srpt_port.
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 9 ++++++--- drivers/infiniband/ulp/srpt/ib_srpt.h | 10 +++++++--- 2 files changed, 13 insertions(+), 6 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +6 -3
@@ -566,14 +566,17 @@ static int srpt_refresh_port(struct srpt_port *sport)return ret; sport->port_guid_id.wwn.priv = sport; -srpt_format_guid (sport->port_guid_id.name, -sizeof (sport->port_guid_id.name), +srpt_format_guid (sport->guid_name,ARRAY_SIZE (sport->guid_name), &sport->gid.global.interface_id); +memcpy (sport->port_guid_id.name, sport->guid_name, +ARRAY_SIZE (sport->guid_name)); sport->port_gid_id.wwn.priv = sport; -snprintf (sport->port_gid_id.name,sizeof (sport->port_gid_id.name), +snprintf (sport->gid_name,ARRAY_SIZE (sport->gid_name),"0x%016llx%016llx" ,be64_to_cpu (sport->gid.global.subnet_prefix),be64_to_cpu (sport->gid.global.interface_id)); +memcpy (sport->port_gid_id.name, sport->gid_name, +ARRAY_SIZE (sport->gid_name));if (rdma_protocol_iwarp (sport->sdev->device, sport->port))return 0 ;
drivers/infiniband/ulp/srpt/ib_srpt.h +7 -3
@@ -376,7 +376,7 @@ struct srpt_tpg { };/** -* struct srpt_port_id - information about an RDMA port name +* struct srpt_port_id - LIO RDMA port information * @mutex: Protects @tpg_list changes. * @tpg_list: TPGs associated with the RDMA port name. * @wwn: WWN associated with the RDMA port name.
@@ -402,8 +402,10 @@ struct srpt_port_id {* @lid: cached value of the port's lid. * @gid: cached value of the port's gid. * @work: work structure for refreshing the aforementioned cached values. -* @port_guid_id: target port GUID -* @port_gid_id: target port GID +* @guid_name: port name in GUID format. +* @port_guid_id: LIO target port information for the port name in GUID format. +* @gid_name: port name in GID format. +* @port_gid_id: LIO target port information for the port name in GID format. * @port_attrib: Port attributes that can be accessed through configfs. * @refcount: Number of objects associated with this port. * @freed_channels: Completion that will be signaled once @refcount becomes 0.
@@ -419,7 +421,9 @@ struct srpt_port {u32 lid;union ib_gid gid;struct work_struct work; +char guid_name[64 ];struct srpt_port_id port_guid_id; +char gid_name[64 ];struct srpt_port_id port_gid_id;struct srpt_port_attrib port_attrib;atomic_t refcount;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 861/1157 RDMA/srpt: Introduce a reference count in struct srpt_device
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
[ Upstream commit aa7dfbb41b5a60ab90e244d6f586b8cb5c791c3e ]
This will be used to keep struct srpt_device around as long as either the RDMA port exists or a LIO target port is associated with the struct srpt_device.
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 17 +++++++++++++++-- drivers/infiniband/ulp/srpt/ib_srpt.h | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +15 -2
@@ -3104,6 +3104,18 @@ static int srpt_use_srq(struct srpt_device *sdev, bool use_srq)return ret; } +static void srpt_free_sdev (struct kref *refcnt) +{ +struct srpt_device *sdev =container_of (refcnt,typeof (*sdev), refcnt); + +kfree (sdev); +} + +static void srpt_sdev_put (struct srpt_device *sdev) +{ +kref_put (&sdev->refcnt, srpt_free_sdev); +} +/** * srpt_add_one - InfiniBand device addition callback function * @device: Describes a HCA.
@@ -3122,6 +3134,7 @@ static int srpt_add_one(struct ib_device *device)if (!sdev)return -ENOMEM ; +kref_init (&sdev->refcnt); sdev->device = device;mutex_init (&sdev->sdev_mutex);
@@ -3217,7 +3230,7 @@ static int srpt_add_one(struct ib_device *device)srpt_free_srq (sdev);ib_dealloc_pd (sdev->pd); free_dev: -kfree (sdev); +srpt_sdev_put (sdev);pr_info ("%s(%s) failed.\n" , __func__,dev_name (&device->dev));return ret; }
@@ -3261,7 +3274,7 @@ static void srpt_remove_one(struct ib_device *device, void *client_data)ib_dealloc_pd (sdev->pd); -kfree (sdev); +srpt_sdev_put (sdev); }static struct ib_client srpt_client = {
drivers/infiniband/ulp/srpt/ib_srpt.h +2 -0
@@ -434,6 +434,7 @@ struct srpt_port {/** * struct srpt_device - information associated by SRPT with a single HCA +* @refcnt: Reference count for this device. * @device: Backpointer to the struct ib_device managed by the IB core. * @pd: IB protection domain. * @lkey: L_Key (local key) with write access to all local memory.
@@ -449,6 +450,7 @@ struct srpt_port {* @port: Information about the ports owned by this HCA. */ struct srpt_device { +struct kref refcnt;struct ib_device *device;struct ib_pd *pd;u32 lkey;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 862/1157 RDMA/srpt: Fix a use-after-free
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
[ Upstream commit b5605148e6ce36bb21020d49010b617693933128 ]
Change the LIO port members inside struct srpt_port from regular members into pointers. Allocate the LIO port data structures from inside srpt_make_tport() and free these from inside srpt_make_tport(). Keep struct srpt_device as long as either an RDMA port or a LIO target port is associated with it. This patch decouples the lifetime of struct srpt_port (controlled by the RDMA core) and struct srpt_port_id (controlled by LIO). This patch fixes the following KASAN complaint:
BUG: KASAN: use-after-free in srpt_enable_tpg+0x31/0x70 [ib_srpt] Read of size 8 at addr ffff888141cc34b8 by task check/5093 Call Trace: <TASK> show_stack+0x4e/0x53 dump_stack_lvl+0x51/0x66 print_address_description.constprop.0.cold+0xea/0x41e print_report.cold+0x90/0x205 kasan_report+0xb9/0xf0 __asan_load8+0x69/0x90 srpt_enable_tpg+0x31/0x70 [ib_srpt] target_fabric_tpg_base_enable_store+0xe2/0x140 [target_core_mod] configfs_write_iter+0x18b/0x210 new_sync_write+0x1f2/0x2f0 vfs_write+0x3e3/0x540 ksys_write+0xbb/0x140 __x64_sys_write+0x42/0x50 do_syscall_64+0x34/0x80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 </TASK>
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 130 ++++++++++++++++++-------- drivers/infiniband/ulp/srpt/ib_srpt.h | 10 +- 2 files changed, 94 insertions(+), 46 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +89 -41
@@ -565,18 +565,12 @@ static int srpt_refresh_port(struct srpt_port *sport)if (ret)return ret; - sport->port_guid_id.wwn.priv = sport;srpt_format_guid (sport->guid_name,ARRAY_SIZE (sport->guid_name), &sport->gid.global.interface_id); -memcpy (sport->port_guid_id.name, sport->guid_name, -ARRAY_SIZE (sport->guid_name)); - sport->port_gid_id.wwn.priv = sport;snprintf (sport->gid_name,ARRAY_SIZE (sport->gid_name),"0x%016llx%016llx" ,be64_to_cpu (sport->gid.global.subnet_prefix),be64_to_cpu (sport->gid.global.interface_id)); -memcpy (sport->port_gid_id.name, sport->gid_name, -ARRAY_SIZE (sport->gid_name));if (rdma_protocol_iwarp (sport->sdev->device, sport->port))return 0 ;
@@ -2317,31 +2311,35 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev, tag_num = ch->rq_size; tag_size =1 ;/* ib_srpt does not use se_sess->sess_cmd_map */ -mutex_lock (&sport->port_guid_id.mutex); -list_for_each_entry (stpg, &sport->port_guid_id.tpg_list, entry) { -if (!IS_ERR_OR_NULL (ch->sess)) -break ; - ch->sess =target_setup_session (&stpg->tpg, tag_num, +if (sport->guid_id) { +mutex_lock (&sport->guid_id->mutex); +list_for_each_entry (stpg, &sport->guid_id->tpg_list, entry) { +if (!IS_ERR_OR_NULL (ch->sess)) +break ; + ch->sess =target_setup_session (&stpg->tpg, tag_num, tag_size,TARGET_PROT_NORMAL , ch->sess_name, ch,NULL ); + } +mutex_unlock (&sport->guid_id->mutex); } -mutex_unlock (&sport->port_guid_id.mutex); -mutex_lock (&sport->port_gid_id.mutex); -list_for_each_entry (stpg, &sport->port_gid_id.tpg_list, entry) { -if (!IS_ERR_OR_NULL (ch->sess)) -break ; - ch->sess =target_setup_session (&stpg->tpg, tag_num, +if (sport->gid_id) { +mutex_lock (&sport->gid_id->mutex); +list_for_each_entry (stpg, &sport->gid_id->tpg_list, entry) { +if (!IS_ERR_OR_NULL (ch->sess)) +break ; + ch->sess =target_setup_session (&stpg->tpg, tag_num, tag_size,TARGET_PROT_NORMAL , i_port_id, ch,NULL ); -if (!IS_ERR_OR_NULL (ch->sess)) -break ; -/* Retry without leading "0x" */ - ch->sess =target_setup_session (&stpg->tpg, tag_num, +if (!IS_ERR_OR_NULL (ch->sess)) +break ; +/* Retry without leading "0x" */ + ch->sess =target_setup_session (&stpg->tpg, tag_num, tag_size,TARGET_PROT_NORMAL , i_port_id +2 , ch,NULL ); + } +mutex_unlock (&sport->gid_id->mutex); } -mutex_unlock (&sport->port_gid_id.mutex);if (IS_ERR_OR_NULL (ch->sess)) {WARN_ON_ONCE (ch->sess ==NULL );
@@ -2986,7 +2984,12 @@ static int srpt_release_sport(struct srpt_port *sport)return 0 ; } -static struct se_wwn *__srpt_lookup_wwn (const char *name) +struct port_and_port_id { +struct srpt_port *sport; +struct srpt_port_id **port_id; +}; + +static struct port_and_port_id __srpt_lookup_port (const char *name) {struct ib_device *dev;struct srpt_device *sdev;
@@ -3001,25 +3004,38 @@ static struct se_wwn *__srpt_lookup_wwn(const char *name)for (i =0 ; i < dev->phys_port_cnt; i++) { sport = &sdev->port[i]; -if (strcmp (sport->port_guid_id.name, name) ==0 ) -return &sport->port_guid_id.wwn; -if (strcmp (sport->port_gid_id.name, name) ==0 ) -return &sport->port_gid_id.wwn; +if (strcmp (sport->guid_name, name) ==0 ) { +kref_get (&sdev->refcnt); +return (struct port_and_port_id ){ + sport, &sport->guid_id}; + } +if (strcmp (sport->gid_name, name) ==0 ) { +kref_get (&sdev->refcnt); +return (struct port_and_port_id ){ + sport, &sport->gid_id}; + } } } -return NULL ; +return (struct port_and_port_id ){}; } -static struct se_wwn *srpt_lookup_wwn (const char *name) +/** +* srpt_lookup_port() - Look up an RDMA port by name +* @name: ASCII port name +* +* Increments the RDMA port reference count if an RDMA port pointer is returned. +* The caller must drop that reference count by calling srpt_port_put_ref(). +*/ +static struct port_and_port_id srpt_lookup_port (const char *name) { -struct se_wwn *wwn; +struct port_and_port_id papi;spin_lock (&srpt_dev_lock); - wwn =__srpt_lookup_wwn (name); + papi =__srpt_lookup_port (name);spin_unlock (&srpt_dev_lock); -return wwn; +return papi; }static void srpt_free_srq (struct srpt_device *sdev)
@@ -3198,10 +3214,6 @@ static int srpt_add_one(struct ib_device *device) sport->port_attrib.srp_sq_size =DEF_SRPT_SQ_SIZE ; sport->port_attrib.use_srq = false;INIT_WORK (&sport->work, srpt_refresh_port_work); -mutex_init (&sport->port_guid_id.mutex); -INIT_LIST_HEAD (&sport->port_guid_id.tpg_list); -mutex_init (&sport->port_gid_id.mutex); -INIT_LIST_HEAD (&sport->port_gid_id.tpg_list); ret =srpt_refresh_port (sport);if (ret) {
@@ -3302,10 +3314,10 @@ static struct srpt_port_id *srpt_wwn_to_sport_id(struct se_wwn *wwn) {struct srpt_port *sport = wwn->priv; -if (wwn == &sport->port_guid_id.wwn) -return &sport->port_guid_id; -if (wwn == &sport->port_gid_id.wwn) -return &sport->port_gid_id; +if (sport->guid_id && &sport->guid_id->wwn == wwn) +return sport->guid_id; +if (sport->gid_id && &sport->gid_id->wwn == wwn) +return sport->gid_id;WARN_ON_ONCE (true);return NULL ; }
@@ -3790,7 +3802,31 @@ static struct se_wwn *srpt_make_tport(struct target_fabric_configfs *tf,struct config_group *group, const char *name) { - return srpt_lookup_wwn(name) ? : ERR_PTR(-EINVAL); + struct port_and_port_id papi = srpt_lookup_port(name); +struct srpt_port *sport = papi.sport; +struct srpt_port_id *port_id; + +if (!papi.port_id) +return ERR_PTR (-EINVAL ); +if (*papi.port_id) { +/* Attempt to create a directory that already exists. */ +WARN_ON_ONCE (true); +return &(*papi.port_id)->wwn; + } + port_id =kzalloc (sizeof (*port_id),GFP_KERNEL ); +if (!port_id) { +srpt_sdev_put (sport->sdev); +return ERR_PTR (-ENOMEM ); + } +mutex_init (&port_id->mutex); +INIT_LIST_HEAD (&port_id->tpg_list); + port_id->wwn.priv = sport; +memcpy (port_id->name, port_id == sport->guid_id ? sport->guid_name : + sport->gid_name,ARRAY_SIZE (port_id->name)); + + *papi.port_id = port_id; + +return &port_id->wwn; }/**
@@ -3799,6 +3835,18 @@ static struct se_wwn *srpt_make_tport(struct target_fabric_configfs *tf,*/ static void srpt_drop_tport (struct se_wwn *wwn) { +struct srpt_port_id *port_id =container_of (wwn,typeof (*port_id), wwn); +struct srpt_port *sport = wwn->priv; + +if (sport->guid_id == port_id) + sport->guid_id =NULL ; +else if (sport->gid_id == port_id) + sport->gid_id =NULL ; +else +WARN_ON_ONCE (true); + +srpt_sdev_put (sport->sdev); +kfree (port_id); }static ssize_t srpt_wwn_version_show (struct config_item *item,char *buf)
drivers/infiniband/ulp/srpt/ib_srpt.h +5 -5
@@ -393,7 +393,7 @@ struct srpt_port_id { };/** -* struct srpt_port - information associated by SRPT with a single IB port +* struct srpt_port - SRPT RDMA port information * @sdev: backpointer to the HCA information. * @mad_agent: per-port management datagram processing information. * @enabled: Whether or not this target port is enabled.
@@ -403,9 +403,9 @@ struct srpt_port_id {* @gid: cached value of the port's gid. * @work: work structure for refreshing the aforementioned cached values. * @guid_name: port name in GUID format. -* @port_guid_id: LIO target port information for the port name in GUID format. +* @guid_id: LIO target port information for the port name in GUID format. * @gid_name: port name in GID format. -* @port_gid_id: LIO target port information for the port name in GID format. +* @gid_id: LIO target port information for the port name in GID format. * @port_attrib: Port attributes that can be accessed through configfs. * @refcount: Number of objects associated with this port. * @freed_channels: Completion that will be signaled once @refcount becomes 0.
@@ -422,9 +422,9 @@ struct srpt_port {union ib_gid gid;struct work_struct work;char guid_name[64 ]; -struct srpt_port_id port_guid_id; +struct srpt_port_id *guid_id;char gid_name[64 ]; -struct srpt_port_id port_gid_id; +struct srpt_port_id *gid_id;struct srpt_port_attrib port_attrib;atomic_t refcount;struct completion *freed_channels;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 863/1157 android: binder: stop saving a pointer to the VMA
In reply to Greg Kroah-HartmanFrom: Liam R. Howlett <[email protected]>
[ Upstream commit a43cfc87caaf46710c8027a8c23b8a55f1078f19 ]
Do not record a pointer to a VMA outside of the mmap_lock for later use. This is unsafe and there are a number of failure paths *after* the recorded VMA pointer may be freed during setup. There is no callback to the driver to clear the saved pointer from generic mm code. Furthermore, the VMA pointer may become stale if any number of VMA operations end up freeing the VMA so saving it was fragile to being with.
Instead, change the binder_alloc struct to record the start address of the VMA and use vma_lookup() to get the vma when needed. Add lockdep mmap_lock checks on updates to the vma pointer to ensure the lock is held and depend on that lock for synchronization of readers and writers - which was already the case anyways, so the smp_wmb()/smp_rmb() was not necessary.
--- drivers/android/binder_alloc.c | 30 ++++++++++++------------- drivers/android/binder_alloc.h | 2 +- drivers/android/binder_alloc_selftest.c | 2 +- 3 files changed, 16 insertions(+), 18 deletions(-)
drivers/android/binder_alloc.c +14 -16
@@ -213,7 +213,7 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate,if (mm) {mmap_read_lock (mm); - vma = alloc->vma; + vma =vma_lookup (mm, alloc->vma_addr); }if (!vma && need_mm) {
@@ -313,16 +313,15 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate,static inline void binder_alloc_set_vma (struct binder_alloc *alloc,struct vm_area_struct *vma) { -if (vma) +unsigned long vm_start =0 ; + +if (vma) { + vm_start = vma->vm_start; alloc->vma_vm_mm = vma->vm_mm; -/* -* If we see alloc->vma is not NULL, buffer data structures set up -* completely. Look at smp_rmb side binder_alloc_get_vma. -* We also want to guarantee new alloc->vma_vm_mm is always visible -* if alloc->vma is set. -*/ -smp_wmb (); - alloc->vma = vma; + } + +mmap_assert_write_locked (alloc->vma_vm_mm); + alloc->vma_addr = vm_start; } static inline struct vm_area_struct *binder_alloc_get_vma(
@@ -330,11 +329,9 @@ static inline struct vm_area_struct *binder_alloc_get_vma( {struct vm_area_struct *vma =NULL ; -if (alloc->vma) { -/* Look at description in binder_alloc_set_vma */ -smp_rmb (); - vma = alloc->vma; - } +if (alloc->vma_addr) + vma =vma_lookup (alloc->vma_vm_mm, alloc->vma_addr); +return vma; }
@@ -817,7 +814,8 @@ void binder_alloc_deferred_release(struct binder_alloc *alloc) buffers =0 ;mutex_lock (&alloc->mutex); -BUG_ON (alloc->vma); +BUG_ON (alloc->vma_addr && +vma_lookup (alloc->vma_vm_mm, alloc->vma_addr));while ((n =rb_first (&alloc->allocated_buffers))) { buffer = rb_entry(n, struct binder_buffer, rb_node);
drivers/android/binder_alloc.h +1 -1
@@ -100,7 +100,7 @@ struct binder_lru_page {*/ struct binder_alloc {struct mutex mutex; -struct vm_area_struct *vma; +unsigned long vma_addr;struct mm_struct *vma_vm_mm;void __user *buffer;struct list_head buffers;
drivers/android/binder_alloc_selftest.c +1 -1
@@ -287,7 +287,7 @@ void binder_selftest_alloc(struct binder_alloc *alloc)if (!binder_selftest_run)return ;mutex_lock (&binder_selftest_lock); -if (!binder_selftest_run || !alloc->vma) +if (!binder_selftest_run || !alloc->vma_addr) goto done;pr_info ("STARTED\n" );binder_selftest_alloc_offset (alloc, end_offset,0 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 864/1157 mm/mmap.c: fix missing call to vm_unacct_memory in mmap_region
In reply to Greg Kroah-HartmanFrom: Miaohe Lin <[email protected]>
[ Upstream commit 7f82f922319ede486540e8746769865b9508d2c2 ]
Since the beginning, charged is set to 0 to avoid calling vm_unacct_memory twice because vm_unacct_memory will be called by above unmap_region. But since commit 4f74d2c8e827 ("vm: remove 'nr_accounted' calculations from the unmap_vmas() interfaces"), unmap_region doesn't call vm_unacct_memory anymore. So charged shouldn't be set to 0 now otherwise the calling to paired vm_unacct_memory will be missed and leads to imbalanced account.
--- mm/mmap.c | 1 - 1 file changed, 1 deletion(-)
mm/mmap.c +0 -1
@@ -1894,7 +1894,6 @@ unsigned long mmap_region(struct file *file, unsigned long addr,/* Undo any partial mapping done by a device driver. */ unmap_region (mm, vma, prev, vma->vm_start, vma->vm_end); - charged =0 ;if (vm_flags &VM_SHARED )mapping_unmap_writable (file->f_mapping); free_vma:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 865/1157 selftests/vm: fix errno handling in mrelease_test
In reply to Greg Kroah-HartmanFrom: Adam Sindelar <[email protected]>
[ Upstream commit 3b8e7f5c42d1aa44f71fd219717c80e34101361e ]
mrelease_test should return KSFT_SKIP when process_mrelease is not defined, but due to a perror call consuming the errno, it returns KSFT_FAIL.
This patch decides the exit code before calling perror.
--- tools/testing/selftests/vm/mrelease_test.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
tools/testing/selftests/vm/mrelease_test.c +11 -5
@@ -62,19 +62,22 @@ static int alloc_noexit(unsigned long nr_pages, int pipefd)/* The process_mrelease calls in this test are expected to fail */ static void run_negative_tests (int pidfd) { +int res;/* Test invalid flags. Expect to fail with EINVAL error code. */ if (!syscall (__NR_process_mrelease, pidfd, (unsigned int )-1 ) || errno !=EINVAL ) { + res = (errno ==ENOSYS ?KSFT_SKIP :KSFT_FAIL );perror ("process_mrelease with wrong flags" ); -exit (errno ==ENOSYS ?KSFT_SKIP :KSFT_FAIL ); +exit (res); }/* * Test reaping while process is alive with no pending SIGKILL. * Expect to fail with EINVAL error code. */ if (!syscall (__NR_process_mrelease, pidfd,0 ) || errno !=EINVAL ) { + res = (errno ==ENOSYS ?KSFT_SKIP :KSFT_FAIL );perror ("process_mrelease on a live process" ); -exit (errno ==ENOSYS ?KSFT_SKIP :KSFT_FAIL ); +exit (res); } }
@@ -100,8 +103,9 @@ int main(void)/* Test a wrong pidfd */ if (!syscall (__NR_process_mrelease,-1 ,0 ) || errno !=EBADF ) { + res = (errno ==ENOSYS ?KSFT_SKIP :KSFT_FAIL );perror ("process_mrelease with wrong pidfd" ); -exit (errno ==ENOSYS ?KSFT_SKIP :KSFT_FAIL ); +exit (res); }/* Start the test with 1MB child memory allocation */
@@ -156,8 +160,9 @@ int main(void)run_negative_tests (pidfd);if (kill (pid,SIGKILL )) { + res = (errno ==ENOSYS ?KSFT_SKIP :KSFT_FAIL );perror ("kill" ); -exit (errno ==ENOSYS ?KSFT_SKIP :KSFT_FAIL ); +exit (res); } success = (syscall (__NR_process_mrelease, pidfd,0 ) ==0 );
@@ -172,9 +177,10 @@ int main(void)if (errno ==ESRCH ) { retry = (size <=MAX_SIZE_MB ); }else { + res = (errno ==ENOSYS ?KSFT_SKIP :KSFT_FAIL );perror ("process_mrelease" );waitpid (pid,NULL ,0 ); -exit (errno ==ENOSYS ?KSFT_SKIP :KSFT_FAIL ); +exit (res); } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 866/1157 tools/testing/selftests/vm/hugetlb-madvise.c: silence uninitialized variable warning
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 3d5367a0426da61c7cb616cc85b6239467e261dd ]
This code just reads from memory without caring about the data itself. However static checkers complain that "tmp" is never properly initialized. Initialize it to zero and change the name to "dummy" to show that we don't care about the value stored in it.
--- tools/testing/selftests/vm/hugetlb-madvise.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/vm/hugetlb-madvise.c +3 -2
@@ -89,10 +89,11 @@ void write_fault_pages(void *addr, unsigned long nr_pages)void read_fault_pages (void *addr,unsigned long nr_pages) { -unsigned long i, tmp; +unsigned long dummy =0 ; +unsigned long i;for (i =0 ; i < nr_pages; i++) - tmp += *((unsigned long *)(addr + (i * huge_page_size))); + dummy += *((unsigned long *)(addr + (i * huge_page_size))); }int main (int argc,char **argv)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 867/1157 selftest/vm: uninitialized variable in main()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 360b420dbded8ad5b70a41de98e77354dd9e7d36 ]
Initialize "length" to zero by default.
--- tools/testing/selftests/vm/hugepage-mremap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/vm/hugepage-mremap.c +1 -1
@@ -107,7 +107,7 @@ static void register_region_with_uffd(char *addr, size_t len)int main (int argc,char *argv[]) { -size_t length; +size_t length =0 ;if (argc !=2 && argc !=3 ) {printf ("Usage: %s [length_in_MB] <hugetlb_file>\n" , argv[0 ]);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 868/1157 rtla: Fix Makefile when called from -C tools/
In reply to Greg Kroah-HartmanFrom: Daniel Bristot de Oliveira <[email protected]>
[ Upstream commit c7d8a598c5b1e21a0957f5dec2ef4139d2d1a23a ]
Sedat Dilek reported an error on rtla Makefile when running:
$ make -C tools/ clean
[...]
make[2]: Entering directory
'/home/dileks/src/linux-kernel/git/tools/tracing/rtla'
[...]
'/home/dileks/src/linux-kernel/git/Documentation/tools/rtla'
/bin/sh: 1: test: rtla-make[2]:: unexpected operator <------ The problem
rm: cannot remove '/home/dileks/src/linux-kernel/git': Is a directory
make[2]: *** [Makefile:120: clean] Error 1
make[2]: Leaving directoryThis occurred because the rtla calls kernel's Makefile to get the version in silence mode, e.g.,
$ make -sC ../../.. kernelversion
5.19.0-rc4But the -s is being ignored when rtla's makefile is called indirectly, so the output looks like this:
$ make -C ../../.. kernelversion
make: Entering directory '/root/linux'
5.19.0-rc4
make: Leaving directory '/root/linux'Using 'grep -v make' avoids this problem, e.g.,
$ make -C ../../.. kernelversion | grep -v make
5.19.0-rc4Thus, add | grep -v make.
--- tools/tracing/rtla/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/tracing/rtla/Makefile +1 -1
@@ -1,6 +1,6 @@ NAME := rtla # Follow the kernel version -VERSION := $(shell cat VERSION 2> /dev/null || make -sC ../../.. kernelversion) +VERSION := $(shell cat VERSION 2> /dev/null || make -sC ../../.. kernelversion | grep -v make) # From libtracefs: # Makefiles suck: This macro sets a default value of $(2) for the
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 869/1157 rtla: Fix double free
In reply to Greg Kroah-HartmanFrom: Andreas Schwab <[email protected]>
[ Upstream commit 4f753c3be52c1d930afc0fe3169baa605dbaf611 ]
Avoid double free by making trace_instance_destroy indempotent. When trace_instance_init fails, it calls trace_instance_destroy, but its only caller osnoise_destroy_tool calls it again.
--- tools/tracing/rtla/src/trace.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/tracing/rtla/src/trace.c +7 -2
@@ -134,13 +134,18 @@ void trace_instance_destroy(struct trace_instance *trace)if (trace->inst) {disable_tracer (trace->inst);destroy_instance (trace->inst); + trace->inst =NULL ; } -if (trace->seq) +if (trace->seq) {free (trace->seq); + trace->seq =NULL ; + } -if (trace->tep) +if (trace->tep) {tep_free (trace->tep); + trace->tep =NULL ; + } }/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 870/1157 virtio: replace restricted mem access flag with callback
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
[ Upstream commit a603002eea8213eec5211be5a85db8340aea06d0 ]
Instead of having a global flag to require restricted memory access for all virtio devices, introduce a callback which can select that requirement on a per-device basis.
For convenience add a common function returning always true, which can be used for use cases like SEV.
Per default use a callback always returning false.
As the callback needs to be set in early init code already, add a virtio anchor which is builtin in case virtio is enabled.
--- arch/s390/mm/init.c | 4 ++-- arch/x86/mm/mem_encrypt_amd.c | 4 ++-- drivers/virtio/Kconfig | 4 ++++ drivers/virtio/Makefile | 1 + drivers/virtio/virtio.c | 4 ++-- drivers/virtio/virtio_anchor.c | 18 ++++++++++++++++++ include/linux/platform-feature.h | 6 +----- include/linux/virtio_anchor.h | 19 +++++++++++++++++++ include/xen/xen.h | 4 ++-- 9 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 drivers/virtio/virtio_anchor.c create mode 100644 include/linux/virtio_anchor.h
arch/s390/mm/init.c +2 -2
@@ -31,7 +31,6 @@#include <linux/cma.h> #include <linux/gfp.h> #include <linux/dma-direct.h> -#include <linux/platform-feature.h> #include <asm/processor.h> #include <linux/uaccess.h> #include <asm/pgalloc.h>
@@ -48,6 +47,7 @@#include <asm/kasan.h> #include <asm/dma-mapping.h> #include <asm/uv.h> +#include <linux/virtio_anchor.h> #include <linux/virtio_config.h> pgd_t swapper_pg_dir[PTRS_PER_PGD] __section(".bss..swapper_pg_dir");
@@ -175,7 +175,7 @@ static void pv_init(void)if (!is_prot_virt_guest ())return ; -platform_set (PLATFORM_VIRTIO_RESTRICTED_MEM_ACCESS ); +virtio_set_mem_acc_cb (virtio_require_restricted_mem_acc);/* make sure bounce buffers are shared */ swiotlb_init (true,SWIOTLB_FORCE |SWIOTLB_VERBOSE );
arch/x86/mm/mem_encrypt_amd.c +2 -2
@@ -20,8 +20,8 @@#include <linux/bitops.h> #include <linux/dma-mapping.h> #include <linux/virtio_config.h> +#include <linux/virtio_anchor.h> #include <linux/cc_platform.h> -#include <linux/platform-feature.h> #include <asm/tlbflush.h> #include <asm/fixmap.h>
@@ -245,7 +245,7 @@ void __init sev_setup_arch(void)swiotlb_adjust_size (size);/* Set restricted memory access for virtio. */ -platform_set (PLATFORM_VIRTIO_RESTRICTED_MEM_ACCESS ); +virtio_set_mem_acc_cb (virtio_require_restricted_mem_acc); }static unsigned long pg_level_to_pfn (int level,pte_t *kpte,pgprot_t *ret_prot)
drivers/virtio/Kconfig +4 -0
@@ -1,6 +1,10 @@ # SPDX-License-Identifier: GPL-2.0-only +config VIRTIO_ANCHOR + bool + config VIRTIO tristate + select VIRTIO_ANCHOR help This option is selected by any driver which implements the virtio bus, such as CONFIG_VIRTIO_PCI, CONFIG_VIRTIO_MMIO, CONFIG_RPMSG
drivers/virtio/Makefile +1 -0
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_VIRTIO) += virtio.o virtio_ring.o +obj-$(CONFIG_VIRTIO_ANCHOR) += virtio_anchor.o obj-$(CONFIG_VIRTIO_PCI_LIB) += virtio_pci_modern_dev.o obj-$(CONFIG_VIRTIO_PCI_LIB_LEGACY) += virtio_pci_legacy_dev.o obj-$(CONFIG_VIRTIO_MMIO) += virtio_mmio.o
drivers/virtio/virtio.c +2 -2
@@ -2,10 +2,10 @@#include <linux/virtio.h> #include <linux/spinlock.h> #include <linux/virtio_config.h> +#include <linux/virtio_anchor.h> #include <linux/module.h> #include <linux/idr.h> #include <linux/of.h> -#include <linux/platform-feature.h> #include <uapi/linux/virtio_ids.h> /* Unique numbering for virtio devices. */
@@ -174,7 +174,7 @@ static int virtio_features_ok(struct virtio_device *dev)might_sleep (); -if (platform_has (PLATFORM_VIRTIO_RESTRICTED_MEM_ACCESS )) { +if (virtio_check_mem_acc_cb (dev)) {if (!virtio_has_feature (dev,VIRTIO_F_VERSION_1 )) {dev_warn (&dev->dev,"device must provide VIRTIO_F_VERSION_1\n" );
drivers/virtio/virtio_anchor.c new file +18 -0
@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include <linux/virtio.h> +#include <linux/virtio_anchor.h> + +bool virtio_require_restricted_mem_acc (struct virtio_device *dev) +{ +return true; +} +EXPORT_SYMBOL_GPL (virtio_require_restricted_mem_acc); + +static bool virtio_no_restricted_mem_acc (struct virtio_device *dev) +{ +return false; +} + +bool (*virtio_check_mem_acc_cb)(struct virtio_device *dev) = + virtio_no_restricted_mem_acc; +EXPORT_SYMBOL_GPL (virtio_check_mem_acc_cb);
include/linux/platform-feature.h +1 -5
@@ -6,11 +6,7 @@#include <asm/platform-feature.h> /* The platform features are starting with the architecture specific ones. */ - -/* Used to enable platform specific DMA handling for virtio devices. */ -#define PLATFORM_VIRTIO_RESTRICTED_MEM_ACCESS (0 + PLATFORM_ARCH_FEAT_N) - -#define PLATFORM_FEAT_N (1 + PLATFORM_ARCH_FEAT_N) +#define PLATFORM_FEAT_N (0 + PLATFORM_ARCH_FEAT_N)void platform_set (unsigned int feature);void platform_clear (unsigned int feature);
include/linux/virtio_anchor.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_VIRTIO_ANCHOR_H +#define _LINUX_VIRTIO_ANCHOR_H + +#ifdef CONFIG_VIRTIO_ANCHOR +struct virtio_device ; + +bool virtio_require_restricted_mem_acc (struct virtio_device *dev); +extern bool (*virtio_check_mem_acc_cb)(struct virtio_device *dev); + +static inline void virtio_set_mem_acc_cb (bool (*func)(struct virtio_device *)) +{ + virtio_check_mem_acc_cb = func; +} +#else +#define virtio_set_mem_acc_cb (func) do { } while (0) +#endif + +#endif /* _LINUX_VIRTIO_ANCHOR_H */
include/xen/xen.h +2 -2
@@ -52,12 +52,12 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,extern u64 xen_saved_max_mem_size;#endif -#include <linux/platform-feature.h> +#include <linux/virtio_anchor.h> static inline void xen_set_restricted_virtio_memory_access (void ) {if (IS_ENABLED (CONFIG_XEN_VIRTIO ) &&xen_domain ()) -platform_set (PLATFORM_VIRTIO_RESTRICTED_MEM_ACCESS ); +virtio_set_mem_acc_cb (virtio_require_restricted_mem_acc); }#ifdef CONFIG_XEN_UNPOPULATED_ALLOC
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 871/1157 xen: dont require virtio with grants for non-PV guests
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
[ Upstream commit 251e90e7e346a23742b90e2c4db19d322e071d99 ]
Commit fa1f57421e0b ("xen/virtio: Enable restricted memory access using Xen grant mappings") introduced a new requirement for using virtio
devices: the backend now needs to support the VIRTIO_F_ACCESS_PLATFORM feature.
This is an undue requirement for non-PV guests, as those can be operated with existing backends without any problem, as long as those backends are running in dom0.
Per default allow virtio devices without grant support for non-PV guests.
On Arm require VIRTIO_F_ACCESS_PLATFORM for devices having been listed in the device tree to use grants.
Add a new config item to always force use of grants for virtio.
--- arch/arm/xen/enlighten.c | 4 +++- arch/x86/xen/enlighten_hvm.c | 4 +++- arch/x86/xen/enlighten_pv.c | 5 ++++- drivers/xen/Kconfig | 9 +++++++++ drivers/xen/grant-dma-ops.c | 10 ++++++++++ include/xen/xen-ops.h | 9 +++++++++ include/xen/xen.h | 8 -------- 7 files changed, 38 insertions(+), 11 deletions(-)
arch/arm/xen/enlighten.c +3 -1
@@ -34,6 +34,7 @@#include <linux/timekeeping.h> #include <linux/timekeeper_internal.h> #include <linux/acpi.h> +#include <linux/virtio_anchor.h> #include <linux/mm.h>
@@ -443,7 +444,8 @@ static int __init xen_guest_init(void)if (!xen_domain ())return 0 ; -xen_set_restricted_virtio_memory_access (); +if (IS_ENABLED (CONFIG_XEN_VIRTIO )) +virtio_set_mem_acc_cb (xen_virtio_mem_acc);if (!acpi_disabled)xen_acpi_guest_init ();
arch/x86/xen/enlighten_hvm.c +3 -1
@@ -4,6 +4,7 @@#include <linux/cpu.h> #include <linux/kexec.h> #include <linux/memblock.h> +#include <linux/virtio_anchor.h> #include <xen/features.h> #include <xen/events.h>
@@ -195,7 +196,8 @@ static void __init xen_hvm_guest_init(void)if (xen_pv_domain ())return ; -xen_set_restricted_virtio_memory_access (); +if (IS_ENABLED (CONFIG_XEN_VIRTIO_FORCE_GRANT )) +virtio_set_mem_acc_cb (virtio_require_restricted_mem_acc);init_hvm_pv_info ();
arch/x86/xen/enlighten_pv.c +4 -1
@@ -31,6 +31,7 @@#include <linux/gfp.h> #include <linux/edd.h> #include <linux/reboot.h> +#include <linux/virtio_anchor.h> #include <xen/xen.h> #include <xen/events.h>
@@ -109,7 +110,9 @@ static DEFINE_PER_CPU(struct tls_descs, shadow_tls_desc);static void __init xen_pv_init_platform (void ) { -xen_set_restricted_virtio_memory_access (); +/* PV guests can't operate virtio devices without grants. */ +if (IS_ENABLED (CONFIG_XEN_VIRTIO )) +virtio_set_mem_acc_cb (virtio_require_restricted_mem_acc);populate_extra_pte (fix_to_virt (FIX_PARAVIRT_BOOTMAP ));
drivers/xen/Kconfig +9 -0
@@ -355,4 +355,13 @@ config XEN_VIRTIO If in doubt, say n. +config XEN_VIRTIO_FORCE_GRANT + bool "Require Xen virtio support to use grants" + depends on XEN_VIRTIO + help + Require virtio for Xen guests to use grant mappings. + This will avoid the need to give the backend the right to map all + of the guest memory. This will need support on the backend side + (e.g. qemu or kernel, depending on the virtio device types used). + endmenu
drivers/xen/grant-dma-ops.c +10 -0
@@ -12,6 +12,8 @@#include <linux/of.h> #include <linux/pfn.h> #include <linux/xarray.h> +#include <linux/virtio_anchor.h> +#include <linux/virtio.h> #include <xen/xen.h> #include <xen/xen-ops.h> #include <xen/grant_table.h>
@@ -287,6 +289,14 @@ bool xen_is_grant_dma_device(struct device *dev)return has_iommu; } +bool xen_virtio_mem_acc (struct virtio_device *dev) +{ +if (IS_ENABLED (CONFIG_XEN_VIRTIO_FORCE_GRANT )) +return true; + +return xen_is_grant_dma_device (dev->dev.parent); +} +void xen_grant_setup_dma_ops (struct device *dev) {struct xen_grant_dma_data *data;
include/xen/xen-ops.h +9 -0
@@ -5,6 +5,7 @@#include <linux/percpu.h> #include <linux/notifier.h> #include <linux/efi.h> +#include <linux/virtio_anchor.h> #include <xen/features.h> #include <asm/xen/interface.h> #include <xen/interface/vcpu.h>
@@ -217,6 +218,7 @@ static inline void xen_preemptible_hcall_end(void) { }#ifdef CONFIG_XEN_GRANT_DMA_OPS void xen_grant_setup_dma_ops (struct device *dev);bool xen_is_grant_dma_device (struct device *dev); +bool xen_virtio_mem_acc (struct virtio_device *dev);#else static inline void xen_grant_setup_dma_ops (struct device *dev) {
@@ -225,6 +227,13 @@ static inline bool xen_is_grant_dma_device(struct device *dev) {return false; } + +struct virtio_device ; + +static inline bool xen_virtio_mem_acc (struct virtio_device *dev) +{ +return false; +}#endif /* CONFIG_XEN_GRANT_DMA_OPS */ #endif /* INCLUDE_XEN_OPS_H */
include/xen/xen.h +0 -8
@@ -52,14 +52,6 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,extern u64 xen_saved_max_mem_size;#endif -#include <linux/virtio_anchor.h> - -static inline void xen_set_restricted_virtio_memory_access (void ) -{ -if (IS_ENABLED (CONFIG_XEN_VIRTIO ) &&xen_domain ()) -virtio_set_mem_acc_cb (virtio_require_restricted_mem_acc); -} -#ifdef CONFIG_XEN_UNPOPULATED_ALLOC int xen_alloc_unpopulated_pages (unsigned int nr_pages,struct page **pages);void xen_free_unpopulated_pages (unsigned int nr_pages,struct page **pages);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 872/1157 selftests: kvm: set rax before vmcall
In reply to Greg Kroah-HartmanFrom: Andrei Vagin <[email protected]>
[ Upstream commit 281106f938d3daaea6f8b6723a8217a2a1ef6936 ]
kvm_hypercall has to place the hypercall number in rax.
Trace events show that kvm_pv_test doesn't work properly:
kvm_pv_test-53132: kvm_hypercall: nr 0x0 a0 0x0 a1 0x0 a2 0x0 a3 0x0
kvm_pv_test-53132: kvm_hypercall: nr 0x0 a0 0x0 a1 0x0 a2 0x0 a3 0x0
kvm_pv_test-53132: kvm_hypercall: nr 0x0 a0 0x0 a1 0x0 a2 0x0 a3 0x0With this change, it starts working as expected:
kvm_pv_test-54285: kvm_hypercall: nr 0x5 a0 0x0 a1 0x0 a2 0x0 a3 0x0
kvm_pv_test-54285: kvm_hypercall: nr 0xa a0 0x0 a1 0x0 a2 0x0 a3 0x0
kvm_pv_test-54285: kvm_hypercall: nr 0xb a0 0x0 a1 0x0 a2 0x0 a3 0x0Message-Id: <[email protected]>
--- tools/testing/selftests/kvm/lib/x86_64/processor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/lib/x86_64/processor.c +1 -1
@@ -1422,7 +1422,7 @@ uint64_t kvm_hypercall(uint64_t nr, uint64_t a0, uint64_t a1, uint64_t a2, asmvolatile ("vmcall" :"=a" (r) - :"b" (a0),"c" (a1),"d" (a2),"S" (a3)); + :"a" (nr),"b" (a0),"c" (a1),"d" (a2),"S" (a3));return r; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 873/1157 of/fdt: declared return type does not match actual return type
In reply to Greg Kroah-HartmanFrom: Xu Qiang <[email protected]>
[ Upstream commit 7913145afa51bbed9eaf8e5b4ee55fa9884a71e5 ]
The commit 649cab56de8e (“of: properly check for error returned by fdt_get_name()”) changed the return value type from bool to int, but forgot to change the return value simultaneously.
populate_node was only called in unflatten_dt_nodes, and returns with values greater than or equal to 0 were discarded without further processing. Considering that return 0 usually indicates success, return 0 instead of return true.
--- drivers/of/fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/of/fdt.c +1 -1
@@ -246,7 +246,7 @@ static int populate_node(const void *blob, } *pnp = np; -return true; +return 0 ; }static void reverse_nodes (struct device_node *parent)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 874/1157 RDMA/mlx5: Add missing check for return value in get namespace flow
In reply to Greg Kroah-HartmanFrom: Maor Gottlieb <[email protected]>
[ Upstream commit c9776457bd5eaad4ce4ecb17af8d8f3cc6957c0b ]
Add missing check for return value when calling to mlx5_ib_ft_type_to_namespace, even though it can't really fail in this specific call.
--- drivers/infiniband/hw/mlx5/fs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx5/fs.c +2 -4
@@ -2050,12 +2050,10 @@ static int mlx5_ib_matcher_ns(struct uverbs_attr_bundle *attrs,if (err)return err; -if (flags) { -mlx5_ib_ft_type_to_namespace ( +if (flags) +return mlx5_ib_ft_type_to_namespace (MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_TX , &obj->ns_type); -return 0 ; - } } obj->ns_type =MLX5_FLOW_NAMESPACE_BYPASS ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 875/1157 RDMA/rxe: Fix error unwind in rxe_create_qp()
In reply to Greg Kroah-HartmanFrom: Zhu Yanjun <[email protected]>
[ Upstream commit fd5382c5805c4bcb50fd25b7246247d3f7114733 ]
In the function rxe_create_qp(), rxe_qp_from_init() is called to initialize qp, internally things like the spin locks are not setup until rxe_qp_init_req().
If an error occures before this point then the unwind will call rxe_cleanup() and eventually to rxe_qp_do_cleanup()/rxe_cleanup_task() which will oops when trying to access the uninitialized spinlock.
Move the spinlock initializations earlier before any failures.
--- drivers/infiniband/sw/rxe/rxe_qp.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/infiniband/sw/rxe/rxe_qp.c +8 -4
@@ -174,6 +174,14 @@ static void rxe_qp_init_misc(struct rxe_dev *rxe, struct rxe_qp *qp,spin_lock_init (&qp->state_lock); +spin_lock_init (&qp->req.task.state_lock); +spin_lock_init (&qp->resp.task.state_lock); +spin_lock_init (&qp->comp.task.state_lock); + +spin_lock_init (&qp->sq.sq_lock); +spin_lock_init (&qp->rq.producer_lock); +spin_lock_init (&qp->rq.consumer_lock); +atomic_set (&qp->ssn,0 );atomic_set (&qp->skb_out,0 ); }
@@ -233,7 +241,6 @@ static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp, qp->req.opcode =-1 ; qp->comp.opcode =-1 ; -spin_lock_init (&qp->sq.sq_lock);skb_queue_head_init (&qp->req_pkts); rxe_init_task(rxe, &qp->req.task, qp,
@@ -284,9 +291,6 @@ static int rxe_qp_init_resp(struct rxe_dev *rxe, struct rxe_qp *qp, } } -spin_lock_init (&qp->rq.producer_lock); -spin_lock_init (&qp->rq.consumer_lock); -skb_queue_head_init (&qp->resp_pkts); rxe_init_task(rxe, &qp->resp.task, qp,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 876/1157 block/rnbd-srv: Set keep_id to true after mutex_trylock
In reply to Greg Kroah-HartmanFrom: Md Haris Iqbal <[email protected]>
[ Upstream commit 4bc14f3101364877dd59085f39e068a2a7ec9f2d ]
After setting keep_id if the mutex trylock fails, the keep_id stays set for the rest of the sess_dev lifetime.
Therefore, set keep_id to true after mutex_trylock succeeds, so that a failure of trylock does'nt touch keep_id.
--- drivers/block/rnbd/rnbd-srv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/rnbd/rnbd-srv.c +2 -1
@@ -323,10 +323,11 @@ void rnbd_srv_sess_dev_force_close(struct rnbd_srv_sess_dev *sess_dev, {struct rnbd_srv_session *sess = sess_dev->sess; - sess_dev->keep_id = true;/* It is already started to close by client's close message. */ if (!mutex_trylock (&sess->lock))return ; + + sess_dev->keep_id = true;/* first remove sysfs itself to avoid deadlock */ sysfs_remove_file_self (&sess_dev->kobj, &attr->attr);rnbd_srv_destroy_dev_session_sysfs (sess_dev);
Signature · 1 line
2.35.1