5.18.18-rc1 review
Subsystems (12)
Greg Kroah-Hartman
maintainerPATCH 767/1095 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 768/1095 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 769/1095 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
@@ -3083,7 +3083,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 */
@@ -3107,7 +3107,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;
@@ -3116,8 +3116,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 770/1095 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
@@ -6125,8 +6125,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 771/1095 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 772/1095 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 773/1095 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 774/1095 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 775/1095 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 776/1095 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 777/1095 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
@@ -861,7 +861,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)
@@ -869,6 +870,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 778/1095 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 779/1095 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 780/1095 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
@@ -100,11 +100,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 781/1095 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 782/1095 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 783/1095 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
@@ -69,8 +69,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(
@@ -108,11 +106,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 784/1095 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 785/1095 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 786/1095 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 787/1095 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 788/1095 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 789/1095 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 );
@@ -729,11 +731,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
@@ -513,6 +513,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
@@ -103,7 +103,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 ); }
@@ -626,10 +630,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
@@ -123,6 +123,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 790/1095 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
@@ -352,15 +352,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 ;
@@ -376,15 +375,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 );
@@ -396,25 +395,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 791/1095 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
@@ -978,7 +978,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 792/1095 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
@@ -155,6 +155,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 793/1095 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 794/1095 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
@@ -2281,14 +2281,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 ;
@@ -2596,7 +2597,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;
@@ -2607,6 +2608,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 795/1095 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);
@@ -976,7 +976,7 @@ static int spi_nor_erase_chip(struct spi_nor *nor)SPI_MEM_OP_NO_DUMMY , SPI_MEM_OP_NO_DATA); -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 {
@@ -1121,7 +1121,7 @@ int spi_nor_erase_sector(struct spi_nor *nor, u32 addr)SPI_MEM_OP_NO_DUMMY , SPI_MEM_OP_NO_DATA); -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 796/1095 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
@@ -656,7 +656,6 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, fbdefio->delay =HZ / fps; fbdefio->sort_pagelist = 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 ;
@@ -667,6 +666,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 797/1095 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
@@ -6790,6 +6790,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 798/1095 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 799/1095 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
@@ -402,21 +402,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 800/1095 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 801/1095 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 802/1095 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 803/1095 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 804/1095 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 805/1095 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 806/1095 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
@@ -1882,7 +1882,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 807/1095 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 808/1095 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 809/1095 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 810/1095 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 811/1095 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
@@ -1423,7 +1423,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 812/1095 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 813/1095 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
@@ -2265,12 +2265,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 814/1095 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
@@ -186,6 +186,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 ); }
@@ -245,7 +253,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,
@@ -296,9 +303,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 815/1095 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
Greg Kroah-Hartman
maintainerPATCH 816/1095 null_blk: fix ida error handling in null_add_dev()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit ee452a8d984f94fa8e894f003a52e776e4572881 ]
There needs to be some error checking if ida_simple_get() fails. Also call ida_free() if there are errors later.
--- drivers/block/null_blk/main.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/block/null_blk/main.c +11 -3
@@ -2044,8 +2044,13 @@ static int null_add_dev(struct nullb_device *dev)blk_queue_flag_clear (QUEUE_FLAG_ADD_RANDOM , nullb->q);mutex_lock (&lock); - nullb->index =ida_simple_get (&nullb_indexes,0 ,0 ,GFP_KERNEL ); - dev->index = nullb->index; + rv =ida_simple_get (&nullb_indexes,0 ,0 ,GFP_KERNEL ); +if (rv <0 ) { +mutex_unlock (&lock); + goto out_cleanup_zone; + } + nullb->index = rv; + dev->index = rv;mutex_unlock (&lock);blk_queue_logical_block_size (nullb->q, dev->blocksize);
@@ -2065,13 +2070,16 @@ static int null_add_dev(struct nullb_device *dev) rv =null_gendisk_register (nullb);if (rv) - goto out_cleanup_zone; + goto out_ida_free;mutex_lock (&lock);list_add_tail (&nullb->list, &nullb_list);mutex_unlock (&lock);return 0 ; + +out_ida_free: +ida_free (&nullb_indexes, nullb->index); out_cleanup_zone:null_free_zoned_dev (dev); out_cleanup_disk:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 817/1095 nvme: use command_id instead of req->tag in trace_nvme_complete_rq()
In reply to Greg Kroah-HartmanFrom: Bean Huo <[email protected]>
[ Upstream commit 679c54f2de672b7d79d02f8c4ad483ff6dd8ce2e ]
Use command_id instead of req->tag in trace_nvme_complete_rq(), because of commit e7006de6c238 ("nvme: code command_id with a genctr for use authentication after release"), cmd->common.command_id is set to ((genctl & 0xf)< 12 | req->tag), no longer req->tag, which makes cid in trace_nvme_complete_rq and trace_nvme_setup_cmd are not the same.
--- drivers/nvme/host/trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/trace.h +1 -1
@@ -98,7 +98,7 @@ TRACE_EVENT(nvme_complete_rq,TP_fast_assign ( __entry->ctrl_id = nvme_req(req)->ctrl->instance; __entry->qid =nvme_req_qid (req); - __entry->cid = req->tag; + __entry->cid =nvme_req (req)->cmd->common.command_id; __entry->result =le64_to_cpu (nvme_req (req)->result.u64); __entry->retries =nvme_req (req)->retries; __entry->flags =nvme_req (req)->flags;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 818/1095 nvme: define compat_ioctl again to unbreak 32-bit userspace.
In reply to Greg Kroah-HartmanFrom: Nick Bowler <[email protected]>
[ Upstream commit a25d4261582cf00dad884c194d21084836663d3d ]
Commit 89b3d6e60550 ("nvme: simplify the compat ioctl handling") removed the initialization of compat_ioctl from the nvme block_device_operations structures.
Presumably the expectation was that 32-bit ioctls would be directed through the regular handler but this is not the case: failing to assign .compat_ioctl actually means that the compat case is disabled entirely, and any attempt to submit nvme ioctls from 32-bit userspace fails outright with -ENOTTY.
For example:
% smartctl -x /dev/nvme0n1
[...]
Read NVMe Identify Controller failed: NVME_IOCTL_ADMIN_CMD: Inappropriate ioctl for device
The blkdev_compat_ptr_ioctl helper can be used to direct compat calls through the main ioctl handler and makes things work again.
--- drivers/nvme/host/core.c | 1 + drivers/nvme/host/multipath.c | 1 + 2 files changed, 2 insertions(+)
drivers/nvme/host/core.c +1 -0
@@ -2093,6 +2093,7 @@ static int nvme_report_zones(struct gendisk *disk, sector_t sector,static const struct block_device_operations nvme_bdev_ops = { .owner =THIS_MODULE , .ioctl = nvme_ioctl, + .compat_ioctl = blkdev_compat_ptr_ioctl, .open = nvme_open, .release = nvme_release, .getgeo = nvme_getgeo,
drivers/nvme/host/multipath.c +1 -0
@@ -408,6 +408,7 @@ const struct block_device_operations nvme_ns_head_ops = { .open = nvme_ns_head_open, .release = nvme_ns_head_release, .ioctl = nvme_ns_head_ioctl, + .compat_ioctl = blkdev_compat_ptr_ioctl, .getgeo = nvme_getgeo, .report_zones = nvme_ns_head_report_zones, .pr_ops = &nvme_pr_ops,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 819/1095 nvme: catch -ENODEV from nvme_revalidate_zones again
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit e06b425bc835ead08b9fd935bf5e47eef473e7a0 ]
nvme_revalidate_zones can also return -ENODEV if e.g. zone sizes aren't constant or not a power of two. In that case we should jump to marking the gendisk hidden and only support pass through.
--- drivers/nvme/host/core.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/nvme/host/core.c +7 -6
@@ -1897,8 +1897,10 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)if (ns->head->ids.csi ==NVME_CSI_ZNS ) { ret =nvme_update_zone_info (ns, lbaf); -if (ret) - goto out_unfreeze; +if (ret) { +blk_mq_unfreeze_queue (ns->disk->queue); + goto out; + } } set_disk_ro(ns->disk, (id->nsattr & NVME_NS_ATTR_RO) ||
@@ -1909,7 +1911,7 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)if (blk_queue_is_zoned (ns->queue)) { ret =nvme_revalidate_zones (ns);if (ret && !nvme_first_scan (ns->disk)) -return ret; + goto out; }if (nvme_ns_head_multipath (ns->head)) {
@@ -1924,9 +1926,9 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)disk_update_readahead (ns->head->disk);blk_mq_unfreeze_queue (ns->head->disk->queue); } -return 0 ; -out_unfreeze: + ret =0 ; +out:/* * If probing fails due an unsupported feature, hide the block device, * but still allow other access.
@@ -1936,7 +1938,6 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)set_bit (NVME_NS_READY , &ns->flags); ret =0 ; } -blk_mq_unfreeze_queue (ns->disk->queue);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 820/1095 block/bio: remove duplicate append pages code
In reply to Greg Kroah-HartmanFrom: Keith Busch <[email protected]>
[ Upstream commit c58c0074c54c2e2bb3bb0d5a4d8896bb660cc8bc ]
The getting pages setup for zone append and normal IO are identical. Use common code for each.
--- block/bio.c | 102 ++++++++++++++++++++++------------------------------ 1 file changed, 42 insertions(+), 60 deletions(-)
block/bio.c +42 -60
@@ -1129,6 +1129,37 @@ static void bio_put_pages(struct page **pages, size_t size, size_t off)put_page (pages[i]); } +static int bio_iov_add_page (struct bio *bio,struct page *page, +unsigned int len,unsigned int offset) +{ +bool same_page = false; + +if (!__bio_try_merge_page (bio, page, len, offset, &same_page)) { +if (WARN_ON_ONCE (bio_full (bio, len))) +return -EINVAL ; +__bio_add_page (bio, page, len, offset); +return 0 ; + } + +if (same_page) +put_page (page); +return 0 ; +} + +static int bio_iov_add_zone_append_page (struct bio *bio,struct page *page, +unsigned int len,unsigned int offset) +{ +struct request_queue *q =bdev_get_queue (bio->bi_bdev); +bool same_page = false; + +if (bio_add_hw_page (q, bio, page, len, offset, +queue_max_zone_append_sectors (q), &same_page) != len) +return -EINVAL ; +if (same_page) +put_page (page); +return 0 ; +} +#define PAGE_PTRS_PER_BVEC (sizeof(struct bio_vec) / sizeof(struct page *))/**
@@ -1147,7 +1178,6 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)unsigned short entries_left = bio->bi_max_vecs - bio->bi_vcnt;struct bio_vec *bv = bio->bi_io_vec + bio->bi_vcnt;struct page **pages = (struct page **)bv; -bool same_page = false;ssize_t size, left;unsigned len, i;size_t offset;
@@ -1156,7 +1186,7 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)* Move page array up in the allocated memory for the bio vecs as far as * possible so that we can start filling biovecs from the beginning * without overwriting the temporary page array. -*/ +*/ BUILD_BUG_ON (PAGE_PTRS_PER_BVEC <2 ); pages += entries_left * (PAGE_PTRS_PER_BVEC -1 );
@@ -1166,18 +1196,18 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)for (left = size, i =0 ; left >0 ; left -= len, i++) {struct page *page = pages[i]; +int ret; len =min_t (size_t,PAGE_SIZE - offset, left); +if (bio_op (bio) ==REQ_OP_ZONE_APPEND ) + ret =bio_iov_add_zone_append_page (bio, page, len, + offset); +else + ret =bio_iov_add_page (bio, page, len, offset); -if (__bio_try_merge_page (bio, page, len, offset, &same_page)) { -if (same_page) -put_page (page); - }else { -if (WARN_ON_ONCE (bio_full (bio, len))) { -bio_put_pages (pages + i, left, offset); -return -EINVAL ; - } -__bio_add_page (bio, page, len, offset); +if (ret) { +bio_put_pages (pages + i, left, offset); +return ret; } offset =0 ; }
@@ -1186,51 +1216,6 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)return 0 ; } -static int __bio_iov_append_get_pages (struct bio *bio,struct iov_iter *iter) -{ -unsigned short nr_pages = bio->bi_max_vecs - bio->bi_vcnt; -unsigned short entries_left = bio->bi_max_vecs - bio->bi_vcnt; -struct request_queue *q =bdev_get_queue (bio->bi_bdev); -unsigned int max_append_sectors =queue_max_zone_append_sectors (q); -struct bio_vec *bv = bio->bi_io_vec + bio->bi_vcnt; -struct page **pages = (struct page **)bv; -ssize_t size, left; -unsigned len, i; -size_t offset; -int ret =0 ; - -/* -* Move page array up in the allocated memory for the bio vecs as far as -* possible so that we can start filling biovecs from the beginning -* without overwriting the temporary page array. -*/ -BUILD_BUG_ON (PAGE_PTRS_PER_BVEC <2 ); - pages += entries_left * (PAGE_PTRS_PER_BVEC -1 ); - - size =iov_iter_get_pages (iter, pages,LONG_MAX , nr_pages, &offset); -if (unlikely (size <=0 )) -return size ? size : -EFAULT ; - -for (left = size, i =0 ; left >0 ; left -= len, i++) { -struct page *page = pages[i]; -bool same_page = false; - - len =min_t (size_t,PAGE_SIZE - offset, left); -if (bio_add_hw_page (q, bio, page, len, offset, - max_append_sectors, &same_page) != len) { -bio_put_pages (pages + i, left, offset); - ret = -EINVAL ; -break ; - } -if (same_page) -put_page (page); - offset =0 ; - } - -iov_iter_advance (iter, size - left); -return ret; -} -/** * bio_iov_iter_get_pages - add user or kernel pages to a bio * @bio: bio to add pages to
@@ -1265,10 +1250,7 @@ int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) }do { -if (bio_op (bio) ==REQ_OP_ZONE_APPEND ) - ret =__bio_iov_append_get_pages (bio, iter); -else - ret =__bio_iov_iter_get_pages (bio, iter); + ret =__bio_iov_iter_get_pages (bio, iter); }while (!ret &&iov_iter_count (iter) && !bio_full (bio,0 ));/* don't account direct I/O as memory stall */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 821/1095 block: ensure iov_iter advances for added pages
In reply to Greg Kroah-HartmanFrom: Keith Busch <[email protected]>
[ Upstream commit 325347d965e7ccf5424a05398807a6d801846612 ]
There are cases where a bio may not accept additional pages, and the iov needs to advance to the last data length that was accepted. The zone append used to handle this correctly, but was inadvertently broken when the setup was made common with the normal r/w case.
--- block/bio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
block/bio.c +4 -4
@@ -1181,6 +1181,7 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)ssize_t size, left;unsigned len, i;size_t offset; +int ret =0 ;/* * Move page array up in the allocated memory for the bio vecs as far as
@@ -1196,7 +1197,6 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)for (left = size, i =0 ; left >0 ; left -= len, i++) {struct page *page = pages[i]; -int ret; len =min_t (size_t,PAGE_SIZE - offset, left);if (bio_op (bio) ==REQ_OP_ZONE_APPEND )
@@ -1207,13 +1207,13 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)if (ret) {bio_put_pages (pages + i, left, offset); -return ret; +break ; } offset =0 ; } -iov_iter_advance (iter, size); -return 0 ; +iov_iter_advance (iter, size - left); +return ret; }/**
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 822/1095 jbd2: fix outstanding credits assert in jbd2_journal_commit_transaction()
In reply to Greg Kroah-HartmanFrom: Zhang Yi <[email protected]>
[ Upstream commit a89573ce4ad32f19f43ec669771726817e185be0 ]
We catch an assert problem in jbd2_journal_commit_transaction() when doing fsstress and request falut injection tests. The problem is happened in a race condition between jbd2_journal_commit_transaction() and ext4_end_io_end(). Firstly, ext4_writepages() writeback dirty pages and start reserved handle, and then the journal was aborted due to some previous metadata IO error, jbd2_journal_abort() start to commit current running transaction, the committing procedure could be raced by ext4_end_io_end() and lead to subtract j_reserved_credits twice from commit_transaction->t_outstanding_credits, finally the t_outstanding_credits is mistakenly smaller than t_nr_buffers and trigger assert.
kjournald2 kworker
jbd2_journal_commit_transaction()
write_unlock(&journal->j_state_lock); atomic_sub(j_reserved_credits, t_outstanding_credits); //sub once
jbd2_journal_start_reserved()
start_this_handle() //detect aborted journal
jbd2_journal_free_reserved() //get running transaction
read_lock(&journal->j_state_lock)
__jbd2_journal_unreserve_handle()
atomic_sub(j_reserved_credits, t_outstanding_credits);
//sub again
read_unlock(&journal->j_state_lock); journal->j_running_transaction = NULL; J_ASSERT(t_nr_buffers <= t_outstanding_credits) //bomb!!!
Fix this issue by using journal->j_state_lock to protect the subtraction in jbd2_journal_commit_transaction().
--- fs/jbd2/commit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jbd2/commit.c +1 -1
@@ -551,13 +551,13 @@ void jbd2_journal_commit_transaction(journal_t *journal)*/ jbd2_journal_switch_revoke_table (journal); +write_lock (&journal->j_state_lock);/* * Reserved credits cannot be claimed anymore, free them */ atomic_sub (atomic_read (&journal->j_reserved_credits), &commit_transaction->t_outstanding_credits); -write_lock (&journal->j_state_lock);trace_jbd2_commit_flushing (journal, commit_transaction); stats.run.rs_flushing = jiffies; stats.run.rs_locked = jbd2_time_diff(stats.run.rs_locked,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 823/1095 ext4: recover csum seed of tmp_inode after migrating to extents
In reply to Greg Kroah-HartmanFrom: Li Lingfeng <[email protected]>
[ Upstream commit 07ea7a617d6b278fb7acedb5cbe1a81ce2de7d0c ]
When migrating to extents, the checksum seed of temporary inode need to be replaced by inode's, otherwise the inode checksums will be incorrect when swapping the inodes data.
However, the temporary inode can not match it's checksum to itself since it has lost it's own checksum seed.
mkfs.ext4 -F /dev/sdc
mount /dev/sdc /mnt/sdcxfs_io -fc "pwrite 4k 4k" -c "fsync" /mnt/sdc/testfile chattr -e /mnt/sdc/testfile
chattr +e /mnt/sdc/testfile
umount /dev/sdc
fsck -fn /dev/sdc
========
...
Pass 1: Checking inodes, blocks, and sizes
Inode 13 passes checks, but checksum does not match inode. Fix? no
...
========
The fix is simple, save the checksum seed of temporary inode, and recover it after migrating to extents.
--- fs/ext4/migrate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext4/migrate.c +3 -1
@@ -417,7 +417,7 @@ int ext4_ext_migrate(struct inode *inode)struct inode *tmp_inode =NULL ;struct migrate_struct lb;unsigned long max_entries; -__u32 goal; +__u32 goal, tmp_csum_seed;uid_t owner[2 ];/*
@@ -465,6 +465,7 @@ int ext4_ext_migrate(struct inode *inode)* the migration. */ ei =EXT4_I (inode); + tmp_csum_seed =EXT4_I (tmp_inode)->i_csum_seed;EXT4_I (tmp_inode)->i_csum_seed = ei->i_csum_seed;i_size_write (tmp_inode,i_size_read (inode));/*
@@ -575,6 +576,7 @@ int ext4_ext_migrate(struct inode *inode)* the inode is not visible to user space. */ tmp_inode->i_blocks =0 ; +EXT4_I (tmp_inode)->i_csum_seed = tmp_csum_seed;/* Reset the extent details */ ext4_ext_tree_init (handle, tmp_inode);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 824/1095 jbd2: fix assertion jh->b_frozen_data == NULL failure when journal aborted
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
[ Upstream commit 4a734f0869f970b8a9b65062ea40b09a5da9dba8 ]
Following process will fail assertion 'jh->b_frozen_data == NULL' in jbd2_journal_dirty_metadata():
jbd2_journal_commit_transaction
unlink(dir/a)
jh->b_transaction = trans1
jh->b_jlist = BJ_Metadata
journal->j_running_transaction = NULL
trans1->t_state = T_COMMITunlink(dir/b)
handle->h_trans = trans2
do_get_write_access
jh->b_modified = 0
jh->b_frozen_data = frozen_buffer
jh->b_next_transaction = trans2
jbd2_journal_dirty_metadata
is_handle_aborted
is_journal_aborted // return false
--> jbd2 abort <--
while (commit_transaction->t_buffers)
if (is_journal_aborted)
jbd2_journal_refile_buffer
__jbd2_journal_refile_buffer
WRITE_ONCE(jh->b_transaction,
jh->b_next_transaction)
WRITE_ONCE(jh->b_next_transaction, NULL)
__jbd2_journal_file_buffer(jh, BJ_Reserved)
J_ASSERT_JH(jh, jh->b_frozen_data == NULL) // assertion failure !The reproducer (See detail in [Link]) reports:
------------[ cut here ]------------ kernel BUG at fs/jbd2/transaction.c:1629! invalid opcode: 0000 [#1] PREEMPT SMP CPU: 2 PID: 584 Comm: unlink Tainted: G W 5.19.0-rc6-00115-g4a57a8400075-dirty #697 RIP: 0010:jbd2_journal_dirty_metadata+0x3c5/0x470 RSP: 0018:ffffc90000be7ce0 EFLAGS: 00010202 Call Trace: <TASK> __ext4_handle_dirty_metadata+0xa0/0x290 ext4_handle_dirty_dirblock+0x10c/0x1d0 ext4_delete_entry+0x104/0x200 __ext4_unlink+0x22b/0x360 ext4_unlink+0x275/0x390 vfs_unlink+0x20b/0x4c0 do_unlinkat+0x42f/0x4c0 __x64_sys_unlink+0x37/0x50 do_syscall_64+0x35/0x80
After journal aborting, __jbd2_journal_refile_buffer() is executed with holding @jh->b_state_lock, we can fix it by moving 'is_handle_aborted()' into the area protected by @jh->b_state_lock.
--- fs/jbd2/transaction.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
fs/jbd2/transaction.c +12 -2
@@ -1486,8 +1486,6 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)struct journal_head *jh;int ret =0 ; -if (is_handle_aborted (handle)) -return -EROFS ;if (!buffer_jbd (bh))return -EUCLEAN ;
@@ -1534,6 +1532,18 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) journal = transaction->t_journal;spin_lock (&jh->b_state_lock); +if (is_handle_aborted (handle)) { +/* +* Check journal aborting with @jh->b_state_lock locked, +* since 'jh->b_transaction' could be replaced with +* 'jh->b_next_transaction' during old transaction +* committing if journal aborted, which may fail +* assertion on 'jh->b_frozen_data == NULL'. +*/ + ret = -EROFS ; + goto out_unlock_bh; + } +if (jh->b_modified ==0 ) {/* * This buffer's got modified and becoming part
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 825/1095 usb: cdns3: Dont use priv_dev uninitialized in cdns3_gadget_ep_enable()
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 78acd4ca433425e6dd4032cfc2156c60e34931f2 ]
Clang warns:
drivers/usb/cdns3/cdns3-gadget.c:2290:11: error: variable 'priv_dev' is uninitialized when used here [-Werror,-Wuninitialized]
dev_dbg(priv_dev->dev, "usbss: invalid parameters\n");
^~~~~~~~
include/linux/dev_printk.h:155:18: note: expanded from macro 'dev_dbg'
dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
^~~
include/linux/dynamic_debug.h:167:7: note: expanded from macro 'dynamic_dev_dbg'
dev, fmt, ##__VA_ARGS__)
^~~
include/linux/dynamic_debug.h:152:56: note: expanded from macro '_dynamic_func_call'
__dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__)
^~~~~~~~~~~
include/linux/dynamic_debug.h:134:15: note: expanded from macro '__dynamic_func_call'
func(&id, ##__VA_ARGS__); \
^~~~~~~~~~~
drivers/usb/cdns3/cdns3-gadget.c:2278:31: note: initialize the variable 'priv_dev' to silence this warning
struct cdns3_device *priv_dev;
^
= NULL1 error generated.
The priv_dev assignment was moved below the if statement to avoid potentially dereferencing ep before it was checked but priv_dev is used in the dev_dbg() call.
To fix this, move the priv_dev and comp_desc assignments back to their original spot and hoist the ep check above those assignments with a call to pr_debug() instead of dev_dbg().
--- drivers/usb/cdns3/cdns3-gadget.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/usb/cdns3/cdns3-gadget.c +8 -4
@@ -2280,16 +2280,20 @@ static int cdns3_gadget_ep_enable(struct usb_ep *ep,int ret =0 ;int val; +if (!ep) { +pr_debug ("usbss: ep not configured?\n" ); +return -EINVAL ; + } + 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 ) { +if (!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 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 826/1095 opp: Fix error check in dev_pm_opp_attach_genpd()
In reply to Greg Kroah-HartmanFrom: Tang Bin <[email protected]>
[ Upstream commit 4ea9496cbc959eb5c78f3e379199aca9ef4e386b ]
dev_pm_domain_attach_by_name() may return NULL in some cases, so IS_ERR() doesn't meet the requirements. Thus fix it.
--- drivers/opp/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/opp/core.c +2 -2
@@ -2413,8 +2413,8 @@ struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, } virt_dev =dev_pm_domain_attach_by_name (dev, *name); -if (IS_ERR (virt_dev)) { - ret =PTR_ERR (virt_dev); +if (IS_ERR_OR_NULL (virt_dev)) { + ret =PTR_ERR (virt_dev) ? : -ENODEV ;dev_err (dev,"Couldn't attach to pm_domain: %d\n" , ret); goto err; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 827/1095 ASoC: cros_ec_codec: Fix refcount leak in cros_ec_codec_platform_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 0a034d93ee929a9ea89f3fa5f1d8492435b9ee6e ]
of_parse_phandle() 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.
--- sound/soc/codecs/cros_ec_codec.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/codecs/cros_ec_codec.c +1 -0
@@ -994,6 +994,7 @@ static int cros_ec_codec_platform_probe(struct platform_device *pdev)dev_dbg (dev,"ap_shm_phys_addr=%#llx len=%#x\n" , priv->ap_shm_phys_addr, priv->ap_shm_len); } +of_node_put (node); }#endif
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 828/1095 ASoC: samsung: Fix error handling in aries_audio_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 3e2649c5e8643bea0867bb1dd970fedadb0eb7f3 ]
of_get_child_by_name() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. This function is missing of_node_put(cpu) in the error path. Fix this by goto out label. of_node_put() will check NULL pointer.
--- sound/soc/samsung/aries_wm8994.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
sound/soc/samsung/aries_wm8994.c +4 -2
@@ -628,8 +628,10 @@ static int aries_audio_probe(struct platform_device *pdev)return -EINVAL ; codec =of_get_child_by_name (dev->of_node,"codec" ); -if (!codec) -return -EINVAL ; +if (!codec) { + ret = -EINVAL ; + goto out; + }for_each_card_prelinks (card, i, dai_link) { dai_link->codecs->of_node = of_parse_phandle(codec,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 829/1095 ASoC: imx-audmux: Silence a clang warning
In reply to Greg Kroah-HartmanFrom: Fabio Estevam <[email protected]>
[ Upstream commit 2f4a8171da06609bb6a063630ed546ee3d93dad7 ]
Change the of_device_get_match_data() cast to (uintptr_t) to silence the following clang warning:
sound/soc/fsl/imx-audmux.c:301:16: warning: cast to smaller integer type 'enum imx_audmux_type' from 'const void *' [-Wvoid-pointer-to-enum-cast]
--- sound/soc/fsl/imx-audmux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/fsl/imx-audmux.c +1 -1
@@ -298,7 +298,7 @@ static int imx_audmux_probe(struct platform_device *pdev) audmux_clk =NULL ; } - audmux_type = (enum imx_audmux_type )of_device_get_match_data (&pdev->dev); + audmux_type = (uintptr_t )of_device_get_match_data (&pdev->dev);switch (audmux_type) {case IMX31_AUDMUX :
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 830/1095 ASoC: mediatek: mt8173: Fix refcount leak in mt8173_rt5650_rt5676_dev_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit ae4f11c1ed2d67192fdf3d89db719ee439827c11 ]
of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Fix missing of_node_put() in error paths.
--- sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c +7 -3
@@ -256,14 +256,16 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev)if (!mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S ].codecs[0 ].of_node) {dev_err (&pdev->dev,"Property 'audio-codec' missing or invalid\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto put_node; } mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S ].codecs[1 ].of_node =of_parse_phandle (pdev->dev.of_node,"mediatek,audio-codec" ,1 );if (!mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S ].codecs[1 ].of_node) {dev_err (&pdev->dev,"Property 'audio-codec' missing or invalid\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto put_node; } mt8173_rt5650_rt5676_codec_conf[0 ].dlc.of_node = mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S ].codecs[1 ].of_node;
@@ -276,13 +278,15 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev)if (!mt8173_rt5650_rt5676_dais[DAI_LINK_HDMI_I2S ].codecs->of_node) {dev_err (&pdev->dev,"Property 'audio-codec' missing or invalid\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto put_node; } card->dev = &pdev->dev; ret =devm_snd_soc_register_card (&pdev->dev, card); +put_node:of_node_put (platform_node);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 831/1095 ASoC: mt6797-mt6351: Fix refcount leak in mt6797_mt6351_dev_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 7472eb8d7dd12b6b9b1a4f4527719cc9c7f5965f ]
of_parse_phandle() 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.
--- sound/soc/mediatek/mt6797/mt6797-mt6351.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/soc/mediatek/mt6797/mt6797-mt6351.c +5 -1
@@ -217,7 +217,8 @@ static int mt6797_mt6351_dev_probe(struct platform_device *pdev)if (!codec_node) {dev_err (&pdev->dev,"Property 'audio-codec' missing or invalid\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto put_platform_node; }for_each_card_prelinks (card, i, dai_link) {if (dai_link->codecs->name)
@@ -230,6 +231,9 @@ static int mt6797_mt6351_dev_probe(struct platform_device *pdev)dev_err (&pdev->dev,"%s snd_soc_register_card fail %d\n" , __func__, ret); +of_node_put (codec_node); +put_platform_node: +of_node_put (platform_node);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 832/1095 ASoC: codecs: da7210: add check for i2c_add_driver
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 82fa8f581a954ddeec1602bed9f8b4a09d100e6e ]
As i2c_add_driver could return error if fails, it should be better to check the return value.
However, if the CONFIG_I2C and CONFIG_SPI_MASTER are both true, the return value of i2c_add_driver will be covered by spi_register_driver.
Therefore, it is necessary to add check and return error if fails.
--- sound/soc/codecs/da7210.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/codecs/da7210.c +2 -0
@@ -1336,6 +1336,8 @@ static int __init da7210_modinit(void)int ret =0 ;#if IS_ENABLED (CONFIG_I2C ) ret =i2c_add_driver (&da7210_i2c_driver); +if (ret) +return ret;#endif #if defined(CONFIG_SPI_MASTER ) ret =spi_register_driver (&da7210_spi_driver);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 833/1095 ASoC: mediatek: mt8173-rt5650: Fix refcount leak in mt8173_rt5650_dev_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit efe2178d1a32492f99e7f1f2568eea5c88a85729 ]
of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Fix refcount leak in some error paths.
--- sound/soc/mediatek/mt8173/mt8173-rt5650.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
sound/soc/mediatek/mt8173/mt8173-rt5650.c +6 -3
@@ -280,7 +280,8 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)if (!mt8173_rt5650_dais[DAI_LINK_CODEC_I2S ].codecs[0 ].of_node) {dev_err (&pdev->dev,"Property 'audio-codec' missing or invalid\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto put_platform_node; } mt8173_rt5650_dais[DAI_LINK_CODEC_I2S ].codecs[1 ].of_node = mt8173_rt5650_dais[DAI_LINK_CODEC_I2S ].codecs[0 ].of_node;
@@ -293,7 +294,7 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)dev_err (&pdev->dev,"%s codec_capture_dai name fail %d\n" , __func__, ret); -return ret; + goto put_platform_node; } mt8173_rt5650_dais[DAI_LINK_CODEC_I2S ].codecs[1 ].dai_name = codec_capture_dai;
@@ -315,12 +316,14 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)if (!mt8173_rt5650_dais[DAI_LINK_HDMI_I2S ].codecs->of_node) {dev_err (&pdev->dev,"Property 'audio-codec' missing or invalid\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto put_platform_node; } card->dev = &pdev->dev; ret =devm_snd_soc_register_card (&pdev->dev, card); +put_platform_node:of_node_put (platform_node);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 834/1095 serial: pic32: free up irq names correctly
In reply to Greg Kroah-HartmanFrom: Jiri Slaby <[email protected]>
[ Upstream commit fe36fa18ca77ca3ca9f90aab6cf39031416e432b ]
struct pic32_sport contains built-up names for irqs. These are freed only in error path of pic32_uart_startup(). And even there, the freeing happens before free_irq().
So fix this by:
* moving frees after free_irq(), and
* add frees to pic32_uart_shutdown() -- the opposite of pic32_uart_startup().
--- drivers/tty/serial/pic32_uart.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/tty/serial/pic32_uart.c +6 -3
@@ -493,14 +493,14 @@ static int pic32_uart_startup(struct uart_port *port)return 0 ; out_t: -kfree (sport->irq_tx_name);free_irq (sport->irq_tx, port); +kfree (sport->irq_tx_name); out_r: -kfree (sport->irq_rx_name);free_irq (sport->irq_rx, port); +kfree (sport->irq_rx_name); out_f: -kfree (sport->irq_fault_name);free_irq (sport->irq_fault, port); +kfree (sport->irq_fault_name); out_done:return ret; }
@@ -519,8 +519,11 @@ static void pic32_uart_shutdown(struct uart_port *port)/* free all 3 interrupts for this UART */ free_irq (sport->irq_fault, port); +kfree (sport->irq_fault_name);free_irq (sport->irq_tx, port); +kfree (sport->irq_tx_name);free_irq (sport->irq_rx, port); +kfree (sport->irq_rx_name); }/* serial core request to change current uart setting */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 835/1095 serial: pic32: fix missing clk_disable_unprepare() on error in pic32_uart_startup()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 6f3cdf2bf1ba9b70de6c2921a415951a0d59873b ]
Fix the missing clk_disable_unprepare() before return from pic32_uart_startup() in the error handling case.
--- drivers/tty/serial/pic32_uart.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/tty/serial/pic32_uart.c +3 -1
@@ -427,7 +427,7 @@ static int pic32_uart_startup(struct uart_port *port)if (!sport->irq_fault_name) {dev_err (port->dev,"%s: kasprintf err!" , __func__); ret = -ENOMEM ; - goto out_done; + goto out_disable_clk; }irq_set_status_flags (sport->irq_fault,IRQ_NOAUTOEN ); ret = request_irq(sport->irq_fault, pic32_uart_fault_interrupt,
@@ -501,6 +501,8 @@ static int pic32_uart_startup(struct uart_port *port) out_f:free_irq (sport->irq_fault, port);kfree (sport->irq_fault_name); +out_disable_clk: +clk_disable_unprepare (sport->clk); out_done:return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 836/1095 serial: 8250: Export ICR access helpers for internal use
In reply to Greg Kroah-HartmanFrom: Maciej W. Rozycki <[email protected]>
[ Upstream commit cb5a40e3143bc64437858b337273fd63cc42e9c2 ]
Make ICR access helpers available outside 8250_port.c, however retain them as ordinary static functions so as not to regress code generation.
This is because serial_icr_write' is currently automatically inlined by GCC, however serial_icr_read' is not. Making them both static inline would grow code produced, e.g.:
$ i386-linux-gnu-size --format=gnu 8250_port-{old,new}.o
text data bss total filename
15065 3378 0 18443 8250_port-old.o
15289 3378 0 18667 8250_port-new.oand:
$ riscv64-linux-gnu-size --format=gnu 8250_port-{old,new}.o
text data bss total filename
16980 5306 0 22286 8250_port-old.o
17124 5306 0 22430 8250_port-new.owhile making them external would needlessly add a new module interface and lose the benefit from `serial_icr_write' getting inlined outside 8250_port.o.
--- drivers/tty/serial/8250/8250.h | 22 ++++++++++++++++++++++ drivers/tty/serial/8250/8250_port.c | 21 --------------------- 2 files changed, 22 insertions(+), 21 deletions(-)
drivers/tty/serial/8250/8250.h +22 -0
@@ -120,6 +120,28 @@ static inline void serial_out(struct uart_8250_port *up, int offset, int value) up->port.serial_out (&up->port, offset, value); } +/* +* For the 16C950 +*/ +static void serial_icr_write (struct uart_8250_port *up,int offset,int value) +{ +serial_out (up,UART_SCR , offset); +serial_out (up,UART_ICR , value); +} + +static unsigned int __maybe_unused serial_icr_read (struct uart_8250_port *up, +int offset) +{ +unsigned int value; + +serial_icr_write (up,UART_ACR , up->acr |UART_ACR_ICRRD ); +serial_out (up,UART_SCR , offset); + value =serial_in (up,UART_ICR ); +serial_icr_write (up,UART_ACR , up->acr); + +return value; +} +void serial8250_clear_and_reinit_fifos (struct uart_8250_port *p);static inline int serial_dl_read (struct uart_8250_port *up)
drivers/tty/serial/8250/8250_port.c +0 -21
@@ -537,27 +537,6 @@ serial_port_out_sync(struct uart_port *p, int offset, int value) } } -/* -* For the 16C950 -*/ -static void serial_icr_write (struct uart_8250_port *up,int offset,int value) -{ -serial_out (up,UART_SCR , offset); -serial_out (up,UART_ICR , value); -} - -static unsigned int serial_icr_read (struct uart_8250_port *up,int offset) -{ -unsigned int value; - -serial_icr_write (up,UART_ACR , up->acr |UART_ACR_ICRRD ); -serial_out (up,UART_SCR , offset); - value =serial_in (up,UART_ICR ); -serial_icr_write (up,UART_ACR , up->acr); - -return value; -} -/* * FIFO support. */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 837/1095 ASoC: SOF: make ctx_store and ctx_restore as optional
In reply to Greg Kroah-HartmanFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit 03f69725749f453b9a4d454a92805f8eb5f095c2 ]
Commit 657774acd00f ("ASoC: SOF: Make sof_suspend/resume IPC agnostic") did not marked ctx_store and ctx_restore as Optional.
--- sound/soc/sof/sof-priv.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/sof/sof-priv.h +2 -2
@@ -364,8 +364,8 @@ struct snd_sof_ipc_msg {/** * struct sof_ipc_pm_ops - IPC-specific PM ops -* @ctx_save: Function pointer for context save -* @ctx_restore: Function pointer for context restore +* @ctx_save: Optional function pointer for context save +* @ctx_restore: Optional function pointer for context restore */ struct sof_ipc_pm_ops {int (*ctx_save)(struct snd_sof_dev *sdev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 838/1095 ASoC: codecs: msm8916-wcd-digital: move gains from SX_TLV to S8_TLV
In reply to Greg Kroah-HartmanFrom: Srinivas Kandagatla <[email protected]>
[ Upstream commit 5babb012c847beb6c8c7108fd78f650b7a2c6054 ]
move all the digital gains form using SX_TLV to S8_TLV, these gains are actually 8 bit gains with 7th signed bit and ranges from -84dB to +40dB
rest of the Qualcomm wcd codecs uses these properly.
--- sound/soc/codecs/msm8916-wcd-digital.c | 46 +++++++++++++------------- 1 file changed, 23 insertions(+), 23 deletions(-)
sound/soc/codecs/msm8916-wcd-digital.c +23 -23
@@ -328,8 +328,8 @@ static const struct snd_kcontrol_new rx1_mix2_inp1_mux = SOC_DAPM_ENUM(static const struct snd_kcontrol_new rx2_mix2_inp1_mux =SOC_DAPM_ENUM ("RX2 MIX2 INP1 Mux" , rx2_mix2_inp1_chain_enum); -/* Digital Gain control -38.4 dB to +38.4 dB in 0.3 dB steps */ -static const DECLARE_TLV_DB_SCALE(digital_gain, -3840, 30, 0); +/* Digital Gain control -84 dB to +40 dB in 1 dB steps */ +static const DECLARE_TLV_DB_SCALE(digital_gain, -8400, 100, -8400);/* Cutoff Freq for High Pass Filter at -3dB */ static const char *const hpf_cutoff_text[] = {
@@ -510,15 +510,15 @@ static int wcd_iir_filter_info(struct snd_kcontrol *kcontrol,static const struct snd_kcontrol_new msm8916_wcd_digital_snd_controls[] = {SOC_SINGLE_S8_TLV ("RX1 Digital Volume" ,LPASS_CDC_RX1_VOL_CTL_B2_CTL , --128 ,127 , digital_gain), +-84 ,40 , digital_gain),SOC_SINGLE_S8_TLV ("RX2 Digital Volume" ,LPASS_CDC_RX2_VOL_CTL_B2_CTL , --128 ,127 , digital_gain), +-84 ,40 , digital_gain),SOC_SINGLE_S8_TLV ("RX3 Digital Volume" ,LPASS_CDC_RX3_VOL_CTL_B2_CTL , --128 ,127 , digital_gain), +-84 ,40 , digital_gain),SOC_SINGLE_S8_TLV ("TX1 Digital Volume" ,LPASS_CDC_TX1_VOL_CTL_GAIN , --128 ,127 , digital_gain), +-84 ,40 , digital_gain),SOC_SINGLE_S8_TLV ("TX2 Digital Volume" ,LPASS_CDC_TX2_VOL_CTL_GAIN , --128 ,127 , digital_gain), +-84 ,40 , digital_gain),SOC_ENUM ("TX1 HPF Cutoff" , tx1_hpf_cutoff_enum),SOC_ENUM ("TX2 HPF Cutoff" , tx2_hpf_cutoff_enum),SOC_SINGLE ("TX1 HPF Switch" ,LPASS_CDC_TX1_MUX_CTL ,3 ,1 ,0 ),
@@ -553,22 +553,22 @@ static const struct snd_kcontrol_new msm8916_wcd_digital_snd_controls[] = {WCD_IIR_FILTER_CTL ("IIR2 Band3" ,IIR2 ,BAND3 ),WCD_IIR_FILTER_CTL ("IIR2 Band4" ,IIR2 ,BAND4 ),WCD_IIR_FILTER_CTL ("IIR2 Band5" ,IIR2 ,BAND5 ), -SOC_SINGLE_SX_TLV ("IIR1 INP1 Volume" ,LPASS_CDC_IIR1_GAIN_B1_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("IIR1 INP2 Volume" ,LPASS_CDC_IIR1_GAIN_B2_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("IIR1 INP3 Volume" ,LPASS_CDC_IIR1_GAIN_B3_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("IIR1 INP4 Volume" ,LPASS_CDC_IIR1_GAIN_B4_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("IIR2 INP1 Volume" ,LPASS_CDC_IIR2_GAIN_B1_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("IIR2 INP2 Volume" ,LPASS_CDC_IIR2_GAIN_B2_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("IIR2 INP3 Volume" ,LPASS_CDC_IIR2_GAIN_B3_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("IIR2 INP4 Volume" ,LPASS_CDC_IIR2_GAIN_B4_CTL , - 0, -84, 40, digital_gain), +SOC_SINGLE_S8_TLV ("IIR1 INP1 Volume" ,LPASS_CDC_IIR1_GAIN_B1_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("IIR1 INP2 Volume" ,LPASS_CDC_IIR1_GAIN_B2_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("IIR1 INP3 Volume" ,LPASS_CDC_IIR1_GAIN_B3_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("IIR1 INP4 Volume" ,LPASS_CDC_IIR1_GAIN_B4_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("IIR2 INP1 Volume" ,LPASS_CDC_IIR2_GAIN_B1_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("IIR2 INP2 Volume" ,LPASS_CDC_IIR2_GAIN_B2_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("IIR2 INP3 Volume" ,LPASS_CDC_IIR2_GAIN_B3_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("IIR2 INP4 Volume" ,LPASS_CDC_IIR2_GAIN_B4_CTL , + -84, 40, digital_gain), };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 839/1095 ASoC: codecs: wcd9335: move gains from SX_TLV to S8_TLV
In reply to Greg Kroah-HartmanFrom: Srinivas Kandagatla <[email protected]>
[ Upstream commit 2fbe0953732e06b471cdedbf6f615b84235580d8 ]
move all the digital gains form using SX_TLV to S8_TLV, these gains are actually 8 bit gains with 7th signed bit and ranges from -84dB to +40dB
rest of the Qualcomm wcd codecs uses these properly.
--- sound/soc/codecs/wcd9335.c | 81 +++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 45 deletions(-)
sound/soc/codecs/wcd9335.c +36 -45
@@ -2259,51 +2259,42 @@ static int wcd9335_rx_hph_mode_put(struct snd_kcontrol *kc,static const struct snd_kcontrol_new wcd9335_snd_controls[] = {/* -84dB min - 40dB max */ -SOC_SINGLE_SX_TLV ("RX0 Digital Volume" ,WCD9335_CDC_RX0_RX_VOL_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX1 Digital Volume" ,WCD9335_CDC_RX1_RX_VOL_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX2 Digital Volume" ,WCD9335_CDC_RX2_RX_VOL_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX3 Digital Volume" ,WCD9335_CDC_RX3_RX_VOL_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX4 Digital Volume" ,WCD9335_CDC_RX4_RX_VOL_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX5 Digital Volume" ,WCD9335_CDC_RX5_RX_VOL_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX6 Digital Volume" ,WCD9335_CDC_RX6_RX_VOL_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX7 Digital Volume" ,WCD9335_CDC_RX7_RX_VOL_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX8 Digital Volume" ,WCD9335_CDC_RX8_RX_VOL_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX0 Mix Digital Volume" , -WCD9335_CDC_RX0_RX_VOL_MIX_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX1 Mix Digital Volume" , -WCD9335_CDC_RX1_RX_VOL_MIX_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX2 Mix Digital Volume" , -WCD9335_CDC_RX2_RX_VOL_MIX_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX3 Mix Digital Volume" , -WCD9335_CDC_RX3_RX_VOL_MIX_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX4 Mix Digital Volume" , -WCD9335_CDC_RX4_RX_VOL_MIX_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX5 Mix Digital Volume" , -WCD9335_CDC_RX5_RX_VOL_MIX_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX6 Mix Digital Volume" , -WCD9335_CDC_RX6_RX_VOL_MIX_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX7 Mix Digital Volume" , -WCD9335_CDC_RX7_RX_VOL_MIX_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX8 Mix Digital Volume" , -WCD9335_CDC_RX8_RX_VOL_MIX_CTL , -0 ,-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX0 Digital Volume" ,WCD9335_CDC_RX0_RX_VOL_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX1 Digital Volume" ,WCD9335_CDC_RX1_RX_VOL_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX2 Digital Volume" ,WCD9335_CDC_RX2_RX_VOL_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX3 Digital Volume" ,WCD9335_CDC_RX3_RX_VOL_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX4 Digital Volume" ,WCD9335_CDC_RX4_RX_VOL_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX5 Digital Volume" ,WCD9335_CDC_RX5_RX_VOL_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX6 Digital Volume" ,WCD9335_CDC_RX6_RX_VOL_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX7 Digital Volume" ,WCD9335_CDC_RX7_RX_VOL_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX8 Digital Volume" ,WCD9335_CDC_RX8_RX_VOL_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX0 Mix Digital Volume" ,WCD9335_CDC_RX0_RX_VOL_MIX_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX1 Mix Digital Volume" ,WCD9335_CDC_RX1_RX_VOL_MIX_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX2 Mix Digital Volume" ,WCD9335_CDC_RX2_RX_VOL_MIX_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX3 Mix Digital Volume" ,WCD9335_CDC_RX3_RX_VOL_MIX_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX4 Mix Digital Volume" ,WCD9335_CDC_RX4_RX_VOL_MIX_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX5 Mix Digital Volume" ,WCD9335_CDC_RX5_RX_VOL_MIX_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX6 Mix Digital Volume" ,WCD9335_CDC_RX6_RX_VOL_MIX_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX7 Mix Digital Volume" ,WCD9335_CDC_RX7_RX_VOL_MIX_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX8 Mix Digital Volume" ,WCD9335_CDC_RX8_RX_VOL_MIX_CTL , +-84 ,40 , digital_gain),SOC_ENUM ("RX INT0_1 HPF cut off" , cf_int0_1_enum),SOC_ENUM ("RX INT0_2 HPF cut off" , cf_int0_2_enum),SOC_ENUM ("RX INT1_1 HPF cut off" , cf_int1_1_enum),
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 840/1095 rpmsg: char: Add mutex protection for rpmsg_eptdev_open()
In reply to Greg Kroah-HartmanFrom: Shengjiu Wang <[email protected]>
[ Upstream commit abe13e9a561d6b3e82b21362c0d6dd3ecd8a5b13 ]
There is no mutex protection for rpmsg_eptdev_open(), especially for eptdev->ept read and write operation. It may cause issues when multiple instances call rpmsg_eptdev_open() in parallel,the return state may be success or EBUSY.
--- drivers/rpmsg/rpmsg_char.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/rpmsg/rpmsg_char.c +6 -1
@@ -120,8 +120,11 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp)struct rpmsg_device *rpdev = eptdev->rpdev;struct device *dev = &eptdev->dev; -if (eptdev->ept) +mutex_lock (&eptdev->ept_lock); +if (eptdev->ept) { +mutex_unlock (&eptdev->ept_lock);return -EBUSY ; + }get_device (dev);
@@ -137,11 +140,13 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp)if (!ept) {dev_err (dev,"failed to open %s\n" , eptdev->chinfo.name);put_device (dev); +mutex_unlock (&eptdev->ept_lock);return -EINVAL ; } eptdev->ept = ept; filp->private_data = eptdev; +mutex_unlock (&eptdev->ept_lock);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 841/1095 rpmsg: mtk_rpmsg: Fix circular locking dependency
In reply to Greg Kroah-HartmanFrom: AngeloGioacchino Del Regno <[email protected]>
[ Upstream commit 353d9214682e65c55cdffad8c82139a3321c5f13 ]
During execution of the worker that's used to register rpmsg devices we are safely locking the channels mutex but, when creating a new endpoint for such devices, we are registering a IPI on the SCP, which then makes the SCP to trigger an interrupt, lock its own mutex and in turn register more subdevices.
This creates a circular locking dependency situation, as the mtk_rpmsg channels_lock will then depend on the SCP IPI lock.
[ 15.447736] ======================================================
[ 15.460158] WARNING: possible circular locking dependency detected
[ 15.460161] 5.17.0-next-20220324+ #399 Not tainted
[ 15.460165] ------------------------------------------------------
[ 15.460166] kworker/0:3/155 is trying to acquire lock:
[ 15.460170] ffff5b4d0eaf1308 (&scp->ipi_desc[i].lock){+.+.}-{4:4}, at: scp_ipi_lock+0x34/0x50 [mtk_scp_ipi]
[ 15.504958]
[] but task is already holding lock:
[ 15.504960] ffff5b4d0e8f1918 (&mtk_subdev->channels_lock){+.+.}-{4:4}, at: mtk_register_device_work_function+0x50/0x1cc [mtk_rpmsg]
[ 15.504978][] which lock already depends on the new lock.
[ 15.504980]
[] the existing dependency chain (in reverse order) is:
[ 15.504982]
[] -> #1 (&mtk_subdev->channels_lock){+.+.}-{4:4}:
[ 15.504990] lock_acquire+0x68/0x84
[ 15.504999] __mutex_lock+0xa4/0x3e0
[ 15.505007] mutex_lock_nested+0x40/0x70
[ 15.505012] mtk_rpmsg_ns_cb+0xe4/0x134 [mtk_rpmsg]
[ 15.641684] mtk_rpmsg_ipi_handler+0x38/0x64 [mtk_rpmsg]
[ 15.641693] scp_ipi_handler+0xbc/0x180 [mtk_scp]
[ 15.663905] mt8192_scp_irq_handler+0x44/0xa4 [mtk_scp]
[ 15.663915] scp_irq_handler+0x6c/0xa0 [mtk_scp]
[ 15.685779] irq_thread_fn+0x34/0xa0
[ 15.685785] irq_thread+0x18c/0x240
[ 15.685789] kthread+0x104/0x110
[ 15.709579] ret_from_fork+0x10/0x20
[ 15.709586]
[] -> #0 (&scp->ipi_desc[i].lock){+.+.}-{4:4}:
[ 15.731271] __lock_acquire+0x11e4/0x1910
[ 15.740367] lock_acquire.part.0+0xd8/0x220
[ 15.749813] lock_acquire+0x68/0x84
[ 15.757861] __mutex_lock+0xa4/0x3e0
[ 15.766084] mutex_lock_nested+0x40/0x70
[ 15.775006] scp_ipi_lock+0x34/0x50 [mtk_scp_ipi]
[ 15.785503] scp_ipi_register+0x40/0xa4 [mtk_scp_ipi]
[ 15.796697] scp_register_ipi+0x1c/0x30 [mtk_scp]
[ 15.807194] mtk_rpmsg_create_ept+0xa0/0x108 [mtk_rpmsg]
[ 15.818912] rpmsg_create_ept+0x44/0x60
[ 15.827660] cros_ec_rpmsg_probe+0x15c/0x1f0
[ 15.837282] rpmsg_dev_probe+0x128/0x1d0
[ 15.846203] really_probe.part.0+0xa4/0x2a0
[ 15.855649] __driver_probe_device+0xa0/0x150
[ 15.865443] driver_probe_device+0x48/0x150
[ 15.877157] __device_attach_driver+0xc0/0x12c
[ 15.889359] bus_for_each_drv+0x80/0xe0
[ 15.900330] __device_attach+0xe4/0x190
[ 15.911303] device_initial_probe+0x1c/0x2c
[ 15.922969] bus_probe_device+0xa8/0xb0
[ 15.933927] device_add+0x3a8/0x8a0
[ 15.944193] device_register+0x28/0x40
[ 15.954970] rpmsg_register_device+0x5c/0xa0
[ 15.966782] mtk_register_device_work_function+0x148/0x1cc [mtk_rpmsg]
[ 15.983146] process_one_work+0x294/0x664
[ 15.994458] worker_thread+0x7c/0x45c
[ 16.005069] kthread+0x104/0x110
[ 16.014789] ret_from_fork+0x10/0x20
[ 16.025201][] other info that might help us debug this:
[ 16.047769] Possible unsafe locking scenario:
[ 16.063942] CPU0 CPU1 [ 16.075166] ---- ---- [ 16.086376] lock(&mtk_subdev->channels_lock); [ 16.097592] lock(&scp->ipi_desc[i].lock); [ 16.113188] lock(&mtk_subdev->channels_lock); [ 16.129482] lock(&scp->ipi_desc[i].lock); [ 16.140020]
[] *** DEADLOCK ***
[ 16.158282] 4 locks held by kworker/0:3/155:
[ 16.168978] #0: ffff5b4d00008748 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work+0x1fc/0x664
[ 16.190017] #1: ffff80000953bdc8 ((work_completion)(&mtk_subdev->register_work)){+.+.}-{0:0}, at: process_one_work+0x1fc/0x664
[ 16.215269] #2: ffff5b4d0e8f1918 (&mtk_subdev->channels_lock){+.+.}-{4:4}, at: mtk_register_device_work_function+0x50/0x1cc [mtk_rpmsg]
[ 16.242131] #3: ffff5b4d05964190 (&dev->mutex){....}-{4:4}, at: __device_attach+0x44/0x190To solve this, simply unlock the channels_lock mutex before calling mtk_rpmsg_register_device() and relock it right after, as safety is still ensured by the locking mechanism that happens right after through SCP.
--- drivers/rpmsg/mtk_rpmsg.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/rpmsg/mtk_rpmsg.c +2 -0
@@ -234,7 +234,9 @@ static void mtk_register_device_work_function(struct work_struct *register_work)if (info->registered)continue ; +mutex_unlock (&subdev->channels_lock); ret =mtk_rpmsg_register_device (subdev, &info->info); +mutex_lock (&subdev->channels_lock);if (ret) {dev_err (&pdev->dev,"Can't create rpmsg_device\n" );continue ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 842/1095 remoteproc: k3-r5: Fix refcount leak in k3_r5_cluster_of_init
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit fa220c05d282e7479abe08b54e3bdffd06c25e97 ]
Every iteration of for_each_available_child_of_node() decrements the reference count of the previous node.
When breaking early from a for_each_available_child_of_node() loop, we need to explicitly call of_node_put() on the child node. Add missing of_node_put() to avoid refcount leak.
--- drivers/remoteproc/ti_k3_r5_remoteproc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/remoteproc/ti_k3_r5_remoteproc.c +2 -0
@@ -1655,6 +1655,7 @@ static int k3_r5_cluster_of_init(struct platform_device *pdev)if (!cpdev) { ret = -ENODEV ;dev_err (dev,"could not get R5 core platform device\n" ); +of_node_put (child); goto fail; }
@@ -1663,6 +1664,7 @@ static int k3_r5_cluster_of_init(struct platform_device *pdev)dev_err (dev,"k3_r5_core_of_init failed, ret = %d\n" , ret);put_device (&cpdev->dev); +of_node_put (child); goto fail; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 843/1095 selftests/livepatch: better synchronize test_klp_callbacks_busy
In reply to Greg Kroah-HartmanFrom: Joe Lawrence <[email protected]>
[ Upstream commit 55eb9a6c8bf3e2099863118ef53e02d9f44f85a8 ]
The test_klp_callbacks_busy module conditionally blocks a future livepatch transition by busy waiting inside its workqueue function, busymod_work_func(). After scheduling this work, a test livepatch is loaded, introducing the transition under test.
Both events are marked in the kernel log for later verification, but there is no synchronization to ensure that busymod_work_func() logs its function entry message before subsequent selftest commands log their own messages. This can lead to a rare test failure due to unexpected ordering like:
# --- expected # +++ result # @@ -1,7 +1,7 @@
# % modprobe test_klp_callbacks_busy block_transition=Y
# test_klp_callbacks_busy: test_klp_callbacks_busy_init
# -test_klp_callbacks_busy: busymod_work_func enter
# % modprobe test_klp_callbacks_demo
# +test_klp_callbacks_busy: busymod_work_func enter
# livepatch: enabling patch 'test_klp_callbacks_demo' # livepatch: 'test_klp_callbacks_demo': initializing patching transition # test_klp_callbacks_demo: pre_patch_callback: vmlinux
Force the module init function to wait until busymod_work_func() has started (and logged its message), before exiting to the next selftest steps.
--- lib/livepatch/test_klp_callbacks_busy.c | 8 ++++++++ 1 file changed, 8 insertions(+)
lib/livepatch/test_klp_callbacks_busy.c +8 -0
@@ -16,10 +16,12 @@ MODULE_PARM_DESC(block_transition, "blocstatic void busymod_work_func (struct work_struct *work); static DECLARE_WORK(work, busymod_work_func); +static DECLARE_COMPLETION (busymod_work_started);static void busymod_work_func (struct work_struct *work) {pr_info ("%s enter\n" , __func__); +complete (&busymod_work_started);while (READ_ONCE (block_transition)) {/*
@@ -37,6 +39,12 @@ static int test_klp_callbacks_busy_init(pr_info ("%s\n" , __func__);schedule_work (&work); +/* +* To synchronize kernel messages, hold the init function from +* exiting until the work function's entry message has printed. +*/ +wait_for_completion (&busymod_work_started); +if (!block_transition) {/* * Serialize output: print all messages from the work
Greg Kroah-Hartman
maintainerPATCH 844/1095 profiling: fix shift too large makes kernel panic
In reply to Greg Kroah-HartmanFrom: Chen Zhongjin <[email protected]>
[ Upstream commit 0fe6ee8f123a4dfb529a5aff07536bb481f34043 ]
2d186afd04d6 ("profiling: fix shift-out-of-bounds bugs") limits shift value by [0, BITS_PER_LONG -1], which means [0, 63].
However, syzbot found that the max shift value should be the bit number of (_etext - _stext). If shift is outside of this, the "buffer_bytes" will be zero and will cause kzalloc(0). Then the kernel panics due to dereferencing the returned pointer 16.
This can be easily reproduced by passing a large number like 60 to enable profiling and then run readprofile.
LOGS:
BUG: kernel NULL pointer dereference, address: 0000000000000010 #PF: supervisor write access in kernel mode #PF: error_code(0x0002) - not-present page PGD 6148067 P4D 6148067 PUD 6142067 PMD 0 PREEMPT SMP CPU: 4 PID: 184 Comm: readprofile Not tainted 5.18.0+ #162 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014 RIP: 0010:read_profile+0x104/0x220 RSP: 0018:ffffc900006fbe80 EFLAGS: 00000202 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 RDX: ffff888006150000 RSI: 0000000000000001 RDI: ffffffff82aba4a0 RBP: 000000000188bb60 R08: 0000000000000010 R09: ffff888006151000 R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff82aba4a0 R13: 0000000000000000 R14: ffffc900006fbf08 R15: 0000000000020c30 FS: 000000000188a8c0(0000) GS:ffff88803ed00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000010 CR3: 0000000006144000 CR4: 00000000000006e0 Call Trace: <TASK> proc_reg_read+0x56/0x70 vfs_read+0x9a/0x1b0 ksys_read+0xa1/0xe0 ? fpregs_assert_state_consistent+0x1e/0x40 do_syscall_64+0x3a/0x80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 RIP: 0033:0x4d4b4e RSP: 002b:00007ffebb668d58 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 000000000188a8a0 RCX: 00000000004d4b4e RDX: 0000000000000400 RSI: 000000000188bb60 RDI: 0000000000000003 RBP: 0000000000000003 R08: 000000000000006e R09: 0000000000000000 R10: 0000000000000041 R11: 0000000000000246 R12: 000000000188bb60 R13: 0000000000000400 R14: 0000000000000000 R15: 000000000188bb60 </TASK> Modules linked in: CR2: 0000000000000010 Killed ---[ end trace 0000000000000000 ]---
Check prof_len in profile_init() to prevent it be zero.
--- kernel/profile.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/profile.c +7 -0
@@ -109,6 +109,13 @@ int __ref profile_init(void)/* only text is profiled */ prof_len = (_etext - _stext) >> prof_shift; + +if (!prof_len) { +pr_warn ("profiling shift: %u too large\n" , prof_shift); + prof_on =0 ; +return -EINVAL ; + } + buffer_bytes = prof_len*sizeof (atomic_t);if (!alloc_cpumask_var (&prof_cpu_mask,GFP_KERNEL ))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 845/1095 remoteproc: imx_rproc: Fix refcount leak in imx_rproc_addr_init
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 61afafe8b938bc74841cf4b1a73dd08b9d287c5a ]
of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not needed anymore. This function has two paths missing of_node_put().
--- drivers/remoteproc/imx_rproc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/remoteproc/imx_rproc.c +4 -3
@@ -562,16 +562,17 @@ static int imx_rproc_addr_init(struct imx_rproc *priv, node =of_parse_phandle (np,"memory-region" , a);/* Not map vdevbuffer, vdevring region */ -if (!strncmp (node->name,"vdev" ,strlen ("vdev" ))) +if (!strncmp (node->name,"vdev" ,strlen ("vdev" ))) { +of_node_put (node);continue ; + } err =of_address_to_resource (node,0 , &res); +of_node_put (node);if (err) {dev_err (dev,"unable to resolve memory region\n" );return err; } -of_node_put (node); -if (b >=IMX_RPROC_MEM_MAX )break ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 846/1095 selftests/powerpc: Skip energy_scale_info test on older firmware
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
[ Upstream commit 4228a996b072d36f3baafb4afdc2d2d66d2cbadf ]
Older machines don't have the firmware feature that enables the code this test is testing. Skip the test if the sysfs directory doesn't exist. Also use the FAIL_IF() macro to provide more verbose error reporting if an error is encountered.
--- .../powerpc/papr_attributes/attr_test.c | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-)
tools/testing/selftests/powerpc/papr_attributes/attr_test.c +18 -12
@@ -7,6 +7,7 @@* Copyright 2022, Pratik Rajesh Sampat, IBM Corp. */ +#include <errno.h> #include <stdio.h> #include <string.h> #include <dirent.h>
@@ -32,7 +33,7 @@ enum type { NUM_VAL }; -int value_type (int id) +static int value_type (int id) {int val_type;
@@ -54,15 +55,21 @@ int value_type(int id)return val_type; } -int verify_energy_info (void ) +static int verify_energy_info (void ) {const char *path ="/sys/firmware/papr/energy_scale_info" ;struct dirent *entry;struct stat s;DIR *dirp; -if (stat (path, &s) || !S_ISDIR (s.st_mode)) -return -1 ; + errno =0 ; +if (stat (path, &s)) { +SKIP_IF (errno ==ENOENT ); +FAIL_IF (errno); + } + +FAIL_IF (!S_ISDIR (s.st_mode)); + dirp =opendir (path);while ((entry =readdir (dirp)) !=NULL ) {
@@ -76,25 +83,24 @@ int verify_energy_info(void) id =atoi (entry->d_name); attr_type =value_type (id); -if (attr_type ==INVALID ) -return -1 ; +FAIL_IF (attr_type ==INVALID );/* Check if the files exist and have data in them */ sprintf (file_name,"%s/%d/desc" , path, id); f =fopen (file_name,"r" ); -if (!f ||fgetc (f) ==EOF ) -return -1 ; +FAIL_IF (!f); +FAIL_IF (fgetc (f) ==EOF );sprintf (file_name,"%s/%d/value" , path, id); f =fopen (file_name,"r" ); -if (!f ||fgetc (f) ==EOF ) -return -1 ; +FAIL_IF (!f); +FAIL_IF (fgetc (f) ==EOF );if (attr_type ==STR_VAL ) {sprintf (file_name,"%s/%d/value_desc" , path, id); f =fopen (file_name,"r" ); -if (!f ||fgetc (f) ==EOF ) -return -1 ; +FAIL_IF (!f); +FAIL_IF (fgetc (f) ==EOF ); } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 847/1095 ASoC: samsung: h1940_uda1380: include proepr GPIO consumer header
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit bd10b0dafdcf0ec1677cad70101e1f97b9e28f2e ]
h1940_uda1380 uses gpiod*/GPIOD* so it should include GPIO consumer header.
--- sound/soc/samsung/h1940_uda1380.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/samsung/h1940_uda1380.c +1 -1
@@ -8,7 +8,7 @@// Based on version from Arnaud Patard <[email protected]> #include <linux/types.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/module.h> #include <sound/soc.h>
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 848/1095 powerpc/perf: Optimize clearing the pending PMI and remove WARN_ON for PMI check in power_pmu_disable
In reply to Greg Kroah-HartmanFrom: Athira Rajeev <[email protected]>
[ Upstream commit 890005a7d98f7452cfe86dcfb2aeeb7df01132ce ]
commit 2c9ac51b850d ("powerpc/perf: Fix PMU callbacks to clear pending PMI before resetting an overflown PMC") added a new function "pmi_irq_pending" in hw_irq.h. This function is to check if there is a PMI marked as pending in Paca (PACA_IRQ_PMI).This is used in power_pmu_disable in a WARN_ON. The intention here is to provide a warning if there is PMI pending, but no counter is found overflown.
During some of the perf runs, below warning is hit:
WARNING: CPU: 36 PID: 0 at arch/powerpc/perf/core-book3s.c:1332 power_pmu_disable+0x25c/0x2c0 Modules linked in: -----
NIP [c000000000141c3c] power_pmu_disable+0x25c/0x2c0 LR [c000000000141c8c] power_pmu_disable+0x2ac/0x2c0
Call Trace: [c000000baffcfb90] [c000000000141c8c] power_pmu_disable+0x2ac/0x2c0 (unreliable) [c000000baffcfc10] [c0000000003e2f8c] perf_pmu_disable+0x4c/0x60 [c000000baffcfc30] [c0000000003e3344] group_sched_out.part.124+0x44/0x100 [c000000baffcfc80] [c0000000003e353c] __perf_event_disable+0x13c/0x240 [c000000baffcfcd0] [c0000000003dd334] event_function+0xc4/0x140 [c000000baffcfd20] [c0000000003d855c] remote_function+0x7c/0xa0 [c000000baffcfd50] [c00000000026c394] flush_smp_call_function_queue+0xd4/0x300 [c000000baffcfde0] [c000000000065b24] smp_ipi_demux_relaxed+0xa4/0x100 [c000000baffcfe20] [c0000000000cb2b0] xive_muxed_ipi_action+0x20/0x40 [c000000baffcfe40] [c000000000207c3c] __handle_irq_event_percpu+0x8c/0x250 [c000000baffcfee0] [c000000000207e2c] handle_irq_event_percpu+0x2c/0xa0 [c000000baffcff10] [c000000000210a04] handle_percpu_irq+0x84/0xc0 [c000000baffcff40] [c000000000205f14] generic_handle_irq+0x54/0x80 [c000000baffcff60] [c000000000015740] __do_irq+0x90/0x1d0 [c000000baffcff90] [c000000000016990] __do_IRQ+0xc0/0x140 [c0000009732f3940] [c000000bafceaca8] 0xc000000bafceaca8 [c0000009732f39d0] [c000000000016b78] do_IRQ+0x168/0x1c0 [c0000009732f3a00] [c0000000000090c8] hardware_interrupt_common_virt+0x218/0x220
This means that there is no PMC overflown among the active events in the PMU, but there is a PMU pending in Paca. The function "any_pmc_overflown" checks the PMCs on active events in cpuhw->n_events. Code snippet:
<<>>
if (any_pmc_overflown(cpuhw))
clear_pmi_irq_pending();
else
WARN_ON(pmi_irq_pending());
<<>>
Here the PMC overflown is not from active event. Example: When we do perf record, default cycles and instructions will be running on PMC6 and PMC5 respectively. It could happen that overflowed event is currently not active and pending PMI is for the inactive event. Debug logs from trace_printk:
<<>>any_pmc_overflown: idx is 5: pmc value is 0xd9apower_pmu_disable: PMC1: 0x0, PMC2: 0x0, PMC3: 0x0, PMC4: 0x0, PMC5: 0xd9a, PMC6: 0x80002011 <<>>
Here active PMC (from idx) is PMC5 , but overflown PMC is PMC6(0x80002011). When we handle PMI interrupt for such cases, if the PMC overflown is from inactive event, it will be ignored. Reference commit:
commit bc09c219b2e6 ("powerpc/perf: Fix finding overflowed PMC in interrupt")
Patch addresses two changes:
1) Fix 1 : Removal of warning ( WARN_ON(pmi_irq_pending()); ) We were printing warning if no PMC is found overflown among active PMU events, but PMI pending in PACA. But this could happen in cases where PMC overflown is not in active PMC. An inactive event could have caused the overflow. Hence the warning is not needed. To know pending PMI is from an inactive event, we need to loop through all PMC's which will cause more SPR reads via mfspr and increase in context switch. Also in existing function: perf_event_interrupt, already we ignore PMI's overflown when it is from an inactive PMC.
2) Fix 2: optimization in clearing pending PMI.
Currently we check for any active PMC overflown before clearing PMI pending in Paca. This is causing additional SPR read also. From point 1, we know that if PMI pending in Paca from inactive cases, that is going to be ignored during replay. Hence if there is pending PMI in Paca, just clear it irrespective of PMC overflown or not.
In summary, remove the any_pmc_overflown check entirely in power_pmu_disable. ie If there is a pending PMI in Paca, clear it, since we are in pmu_disable. There could be cases where PMI is pending because of inactive PMC ( which later when replayed also will get ignored ), so WARN_ON could give false warning. Hence removing it.
--- arch/powerpc/perf/core-book3s.c | 35 ++++++++++++++------------------- 1 file changed, 15 insertions(+), 20 deletions(-)
arch/powerpc/perf/core-book3s.c +15 -20
@@ -1349,27 +1349,22 @@ static void power_pmu_disable(struct pmu *pmu)* a PMI happens during interrupt replay and perf counter * values are cleared by PMU callbacks before replay. * -* If any PMC corresponding to the active PMU events are -* overflown, disable the interrupt by clearing the paca -* bit for PMI since we are disabling the PMU now. -* Otherwise provide a warning if there is PMI pending, but -* no counter is found overflown. +* Disable the interrupt by clearing the paca bit for PMI +* since we are disabling the PMU now. Otherwise provide a +* warning if there is PMI pending, but no counter is found +* overflown. +* +* Since power_pmu_disable runs under local_irq_save, it +* could happen that code hits a PMC overflow without PMI +* pending in paca. Hence only clear PMI pending if it was +* set. +* +* If a PMI is pending, then MSR[EE] must be disabled (because +* the masked PMI handler disabling EE). So it is safe to +* call clear_pmi_irq_pending(). */ -if (any_pmc_overflown (cpuhw)) { -/* -* Since power_pmu_disable runs under local_irq_save, it -* could happen that code hits a PMC overflow without PMI -* pending in paca. Hence only clear PMI pending if it was -* set. -* -* If a PMI is pending, then MSR[EE] must be disabled (because -* the masked PMI handler disabling EE). So it is safe to -* call clear_pmi_irq_pending(). -*/ -if (pmi_irq_pending ()) -clear_pmi_irq_pending (); - }else -WARN_ON (pmi_irq_pending ()); +if (pmi_irq_pending ()) +clear_pmi_irq_pending (); val = mmcra = cpuhw->mmcr.mmcra;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 849/1095 ASoC: samsung: change gpiod_speaker_power and rx1950_audio from global to static variables
In reply to Greg Kroah-HartmanFrom: Tom Rix <[email protected]>
[ Upstream commit d2294461b90e0c5b3bbfaaf2c8baff4fd3e2bb13 ]
sparse reportssound/soc/samsung/rx1950_uda1380.c:131:18: warning: symbol 'gpiod_speaker_power' was not declared. Should it be static? sound/soc/samsung/rx1950_uda1380.c:231:24: warning: symbol 'rx1950_audio' was not declared. Should it be static?
Both gpiod_speaker_power and rx1950_audio are only used in rx1950_uda1380.c, so their storage class specifiers should be static.
--- sound/soc/samsung/rx1950_uda1380.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/samsung/rx1950_uda1380.c +2 -2
@@ -128,7 +128,7 @@ static int rx1950_startup(struct snd_pcm_substream *substream) &hw_rates); } -struct gpio_desc *gpiod_speaker_power; +static struct gpio_desc *gpiod_speaker_power;static int rx1950_spk_power (struct snd_soc_dapm_widget *w,struct snd_kcontrol *kcontrol,int event)
@@ -227,7 +227,7 @@ static int rx1950_probe(struct platform_device *pdev)return devm_snd_soc_register_card (dev, &rx1950_asoc); } -struct platform_driver rx1950_audio = { +static struct platform_driver rx1950_audio = { .driver = { .name ="rx1950-audio" , .pm = &snd_soc_pm_ops,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 850/1095 ASoC: codecs: wsa881x: handle timeouts in resume path
In reply to Greg Kroah-HartmanFrom: Srinivas Kandagatla <[email protected]>
[ Upstream commit cf6af24b54903f9f70c29b3e5b19cb72cc862d60 ]
Currently we do not check if SoundWire slave initialization timeout expired before continuing to access its registers.
Its possible that the registers are not accessible if timeout is expired. Handle this by returning timeout in resume path.
--- sound/soc/codecs/wsa881x.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
sound/soc/codecs/wsa881x.c +8 -2
@@ -1174,11 +1174,17 @@ static int __maybe_unused wsa881x_runtime_resume(struct device *dev)struct sdw_slave *slave =dev_to_sdw_dev (dev);struct regmap *regmap =dev_get_regmap (dev,NULL );struct wsa881x_priv *wsa881x =dev_get_drvdata (dev); +unsigned long time;gpiod_direction_output (wsa881x->sd_n,1 ); -wait_for_completion_timeout (&slave->initialization_complete, -msecs_to_jiffies (WSA881X_PROBE_TIMEOUT )); + time =wait_for_completion_timeout (&slave->initialization_complete, +msecs_to_jiffies (WSA881X_PROBE_TIMEOUT )); +if (!time) { +dev_err (dev,"Initialization not complete, timed out\n" ); +gpiod_direction_output (wsa881x->sd_n,0 ); +return -ETIMEDOUT ; + }regcache_cache_only (regmap, false);regcache_sync (regmap);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 851/1095 net/mlx5: Expose mlx5_sriov_blocking_notifier_register / unregister APIs
In reply to Greg Kroah-HartmanFrom: Yishai Hadas <[email protected]>
[ Upstream commit 846e437387e74c44ddc9f3eeec472fd37ca3cdb9 ]
Expose mlx5_sriov_blocking_notifier_register / unregister APIs to let a VF register to be notified for its enablement / disablement by the PF.
Upon VF probe it will call mlx5_sriov_blocking_notifier_register() with its notifier block and upon VF remove it will call mlx5_sriov_blocking_notifier_unregister() to drop its registration.
This can give a VF the ability to clean some resources upon disable before that the command interface goes down and on the other hand sets some stuff before that it's enabled.
This may be used by a VF which is migration capable in few cases.(e.g. PF load/unload upon an health recovery).
--- .../net/ethernet/mellanox/mlx5/core/sriov.c | 65 ++++++++++++++++++- include/linux/mlx5/driver.h | 12 ++++ 2 files changed, 76 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/sriov.c +64 -1
@@ -87,6 +87,11 @@ static int mlx5_device_enable_sriov(struct mlx5_core_dev *dev, int num_vfs) enable_vfs_hca: num_msix_count =mlx5_get_default_msix_vec_count (dev, num_vfs);for (vf =0 ; vf < num_vfs; vf++) { +/* Notify the VF before its enablement to let it set +* some stuff. +*/ +blocking_notifier_call_chain (&sriov->vfs_ctx[vf].notifier, +MLX5_PF_NOTIFY_ENABLE_VF , dev); err =mlx5_core_enable_hca (dev, vf +1 );if (err) {mlx5_core_warn (dev,"failed to enable VF %d (%d)\n" , vf, err);
@@ -127,6 +132,11 @@ mlx5_device_disable_sriov(struct mlx5_core_dev *dev, int num_vfs, bool clear_vf)for (vf = num_vfs -1 ; vf >=0 ; vf--) {if (!sriov->vfs_ctx[vf].enabled)continue ; +/* Notify the VF before its disablement to let it clean +* some resources. +*/ +blocking_notifier_call_chain (&sriov->vfs_ctx[vf].notifier, +MLX5_PF_NOTIFY_DISABLE_VF , dev); err =mlx5_core_disable_hca (dev, vf +1 );if (err) {mlx5_core_warn (dev,"failed to disable VF %d\n" , vf);
@@ -257,7 +267,7 @@ int mlx5_sriov_init(struct mlx5_core_dev *dev) {struct mlx5_core_sriov *sriov = &dev->priv.sriov;struct pci_dev *pdev = dev->pdev; -int total_vfs; +int total_vfs, i;if (!mlx5_core_is_pf (dev))return 0 ;
@@ -269,6 +279,9 @@ int mlx5_sriov_init(struct mlx5_core_dev *dev)if (!sriov->vfs_ctx)return -ENOMEM ; +for (i =0 ; i < total_vfs; i++) +BLOCKING_INIT_NOTIFIER_HEAD (&sriov->vfs_ctx[i].notifier); +return 0 ; }
@@ -281,3 +294,53 @@ void mlx5_sriov_cleanup(struct mlx5_core_dev *dev)kfree (sriov->vfs_ctx); } + +/** +* mlx5_sriov_blocking_notifier_unregister - Unregister a VF from +* a notification block chain. +* +* @mdev: The mlx5 core device. +* @vf_id: The VF id. +* @nb: The notifier block to be unregistered. +*/ +void mlx5_sriov_blocking_notifier_unregister (struct mlx5_core_dev *mdev, +int vf_id, +struct notifier_block *nb) +{ +struct mlx5_vf_context *vfs_ctx; +struct mlx5_core_sriov *sriov; + + sriov = &mdev->priv.sriov; +if (WARN_ON (vf_id <0 || vf_id >= sriov->num_vfs)) +return ; + + vfs_ctx = &sriov->vfs_ctx[vf_id]; +blocking_notifier_chain_unregister (&vfs_ctx->notifier, nb); +} +EXPORT_SYMBOL (mlx5_sriov_blocking_notifier_unregister); + +/** +* mlx5_sriov_blocking_notifier_register - Register a VF notification +* block chain. +* +* @mdev: The mlx5 core device. +* @vf_id: The VF id. +* @nb: The notifier block to be called upon the VF events. +* +* Returns 0 on success or an error code. +*/ +int mlx5_sriov_blocking_notifier_register (struct mlx5_core_dev *mdev, +int vf_id, +struct notifier_block *nb) +{ +struct mlx5_vf_context *vfs_ctx; +struct mlx5_core_sriov *sriov; + + sriov = &mdev->priv.sriov; +if (vf_id <0 || vf_id >= sriov->num_vfs) +return -EINVAL ; + + vfs_ctx = &sriov->vfs_ctx[vf_id]; +return blocking_notifier_chain_register (&vfs_ctx->notifier, nb); +} +EXPORT_SYMBOL (mlx5_sriov_blocking_notifier_register);
include/linux/mlx5/driver.h +12 -0
@@ -445,6 +445,11 @@ struct mlx5_qp_table {struct radix_tree_root tree; }; +enum { +MLX5_PF_NOTIFY_DISABLE_VF , +MLX5_PF_NOTIFY_ENABLE_VF , +}; +struct mlx5_vf_context {int enabled;u64 port_guid;
@@ -455,6 +460,7 @@ struct mlx5_vf_context { u8 port_guid_valid:1; u8 node_guid_valid:1;enum port_state_policy policy; +struct blocking_notifier_head notifier; };struct mlx5_core_sriov {
@@ -1155,6 +1161,12 @@ int mlx5_dm_sw_icm_dealloc(struct mlx5_core_dev *dev, enum mlx5_sw_icm_type typestruct mlx5_core_dev *mlx5_vf_get_core_dev (struct pci_dev *pdev);void mlx5_vf_put_core_dev (struct mlx5_core_dev *mdev); +int mlx5_sriov_blocking_notifier_register (struct mlx5_core_dev *mdev, +int vf_id, +struct notifier_block *nb); +void mlx5_sriov_blocking_notifier_unregister (struct mlx5_core_dev *mdev, +int vf_id, +struct notifier_block *nb);#ifdef CONFIG_MLX5_CORE_IPOIB struct net_device *mlx5_rdma_netdev_alloc(struct mlx5_core_dev *mdev, struct ib_device *ibdev,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 852/1095 vfio/pci: Have all VFIO PCI drivers store the vfio_pci_core_device in drvdata
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 91be0bd6c6cf21328017e990d3ceeb00f03821fd ]
Having a consistent pointer in the drvdata will allow the next patch to make use of the drvdata from some of the core code helpers.
Use a WARN_ON inside vfio_pci_core_register_device() to detect drivers that miss this.
--- drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 15 +++++++++++---- drivers/vfio/pci/mlx5/main.c | 15 +++++++++++---- drivers/vfio/pci/vfio_pci.c | 2 +- drivers/vfio/pci/vfio_pci_core.c | 4 ++++ 4 files changed, 27 insertions(+), 9 deletions(-)
drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +11 -4
@@ -337,6 +337,14 @@ static int vf_qm_cache_wb(struct hisi_qm *qm)return 0 ; } +static struct hisi_acc_vf_core_device *hssi_acc_drvdata (struct pci_dev *pdev) +{ +struct vfio_pci_core_device *core_device =dev_get_drvdata (&pdev->dev); + + return container_of(core_device, struct hisi_acc_vf_core_device, + core_device); +} +static void vf_qm_fun_reset (struct hisi_acc_vf_core_device *hisi_acc_vdev,struct hisi_qm *qm) {
@@ -962,7 +970,7 @@ hisi_acc_vfio_pci_get_device_state(struct vfio_device *vdev,static void hisi_acc_vf_pci_aer_reset_done (struct pci_dev *pdev) { -struct hisi_acc_vf_core_device *hisi_acc_vdev =dev_get_drvdata (&pdev->dev); +struct hisi_acc_vf_core_device *hisi_acc_vdev =hssi_acc_drvdata (pdev);if (hisi_acc_vdev->core_device.vdev.migration_flags !=VFIO_MIGRATION_STOP_COPY )
@@ -1274,11 +1282,10 @@ static int hisi_acc_vfio_pci_probe(struct pci_dev *pdev, const struct pci_device &hisi_acc_vfio_pci_ops); } +dev_set_drvdata (&pdev->dev, &hisi_acc_vdev->core_device); ret =vfio_pci_core_register_device (&hisi_acc_vdev->core_device);if (ret) goto out_free; - -dev_set_drvdata (&pdev->dev, hisi_acc_vdev);return 0 ; out_free:
@@ -1289,7 +1296,7 @@ static int hisi_acc_vfio_pci_probe(struct pci_dev *pdev, const struct pci_devicestatic void hisi_acc_vfio_pci_remove (struct pci_dev *pdev) { -struct hisi_acc_vf_core_device *hisi_acc_vdev =dev_get_drvdata (&pdev->dev); +struct hisi_acc_vf_core_device *hisi_acc_vdev =hssi_acc_drvdata (pdev);vfio_pci_core_unregister_device (&hisi_acc_vdev->core_device);vfio_pci_core_uninit_device (&hisi_acc_vdev->core_device);
drivers/vfio/pci/mlx5/main.c +11 -4
@@ -39,6 +39,14 @@ struct mlx5vf_pci_core_device {struct mlx5_vf_migration_file *saving_migf; }; +static struct mlx5vf_pci_core_device *mlx5vf_drvdata (struct pci_dev *pdev) +{ +struct vfio_pci_core_device *core_device =dev_get_drvdata (&pdev->dev); + + return container_of(core_device, struct mlx5vf_pci_core_device, + core_device); +} +static struct page *mlx5vf_get_migration_page (struct mlx5_vf_migration_file *migf,unsigned long offset)
@@ -505,7 +513,7 @@ static int mlx5vf_pci_get_device_state(struct vfio_device *vdev,static void mlx5vf_pci_aer_reset_done (struct pci_dev *pdev) { -struct mlx5vf_pci_core_device *mvdev =dev_get_drvdata (&pdev->dev); +struct mlx5vf_pci_core_device *mvdev =mlx5vf_drvdata (pdev);if (!mvdev->migrate_cap)return ;
@@ -614,11 +622,10 @@ static int mlx5vf_pci_probe(struct pci_dev *pdev, } } +dev_set_drvdata (&pdev->dev, &mvdev->core_device); ret =vfio_pci_core_register_device (&mvdev->core_device);if (ret) goto out_free; - -dev_set_drvdata (&pdev->dev, mvdev);return 0 ; out_free:
@@ -629,7 +636,7 @@ static int mlx5vf_pci_probe(struct pci_dev *pdev,static void mlx5vf_pci_remove (struct pci_dev *pdev) { -struct mlx5vf_pci_core_device *mvdev =dev_get_drvdata (&pdev->dev); +struct mlx5vf_pci_core_device *mvdev =mlx5vf_drvdata (pdev);vfio_pci_core_unregister_device (&mvdev->core_device);vfio_pci_core_uninit_device (&mvdev->core_device);
drivers/vfio/pci/vfio_pci.c +1 -1
@@ -151,10 +151,10 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)return -ENOMEM ;vfio_pci_core_init_device (vdev, pdev, &vfio_pci_ops); +dev_set_drvdata (&pdev->dev, vdev); ret =vfio_pci_core_register_device (vdev);if (ret) goto out_free; -dev_set_drvdata (&pdev->dev, vdev);return 0 ; out_free:
drivers/vfio/pci/vfio_pci_core.c +4 -0
@@ -1821,6 +1821,10 @@ int vfio_pci_core_register_device(struct vfio_pci_core_device *vdev)struct pci_dev *pdev = vdev->pdev;int ret; +/* Drivers must set the vfio_pci_core_device to their drvdata */ +if (WARN_ON (vdev !=dev_get_drvdata (&vdev->pdev->dev))) +return -EINVAL ; +if (pdev->hdr_type !=PCI_HEADER_TYPE_NORMAL )return -EINVAL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 853/1095 net/ice: fix initializing the bitmap in the switch code
In reply to Greg Kroah-HartmanFrom: Alexander Lobakin <[email protected]>
[ Upstream commit 2f7ee2a72ccec8b85a05c4644d7ec9f40c1c50c8 ]
Kbuild spotted the following bug during the testing of one of the optimizations:
In file included from include/linux/cpumask.h:12,
[...]
from drivers/net/ethernet/intel/ice/ice_switch.c:4:drivers/net/ethernet/intel/ice/ice_switch.c: In function 'ice_find_free_recp_res_idx.constprop':include/linux/bitmap.h:447:22: warning: 'possible_idx[0]' is used uninitialized [-Wuninitialized]
447 | *map |= GENMASK(start + nbits - 1, start);
| ^~In file included from drivers/net/ethernet/intel/ice/ice.h:7,
from drivers/net/ethernet/intel/ice/ice_lib.h:7,
from drivers/net/ethernet/intel/ice/ice_switch.c:4:drivers/net/ethernet/intel/ice/ice_switch.c:4929:24: note: 'possible_idx[0]' was declared here
4929 | DECLARE_BITMAP(possible_idx, ICE_MAX_FV_WORDS);
| ^~~~~~~~~~~~include/linux/types.h:11:23: note: in definition of macro 'DECLARE_BITMAP'
11 | unsigned long name[BITS_TO_LONGS(bits)]
| ^~~~
%ICE_MAX_FV_WORDS is 48, so bitmap_set() here was initializing only 48 bits, leaving a junk in the rest 16.
It was previously hidden due to that filling 48 bits makes bitmap_set() call external __bitmap_set(), but after making it use plain bit arithmetics on small bitmaps, compilers started seeing the issue. It was still working because those 16 weren't used anywhere anyhow.
bitmap_{clear,set}() are not really intended to initialize bitmaps, rather to modify already initialized ones, as they don't do anything past the passed number of bits. The correct function to do this in that particular case is bitmap_fill(), so use it here. It will do *possible_idx = ~0UL instead of *possible_idx |= GENMASK(47, 0), not leaving anything in an undefined state.
--- drivers/net/ethernet/intel/ice/ice_switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_switch.c +1 -1
@@ -4874,7 +4874,7 @@ ice_find_free_recp_res_idx(struct ice_hw *hw, const unsigned long *profiles,bitmap_zero (recipes,ICE_MAX_NUM_RECIPES );bitmap_zero (used_idx,ICE_MAX_FV_WORDS ); -bitmap_set (possible_idx,0 ,ICE_MAX_FV_WORDS ); +bitmap_fill (possible_idx,ICE_MAX_FV_WORDS );/* For each profile we are going to associate the recipe with, add the * recipes that are associated with that profile. This will give us
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 854/1095 tty: n_gsm: fix user open not possible at responder until initiator open
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit ac77f0077c3265197d378158c85a55eee6d21508 ]
After setting up the control channel on both sides the responder side may want to open a virtual tty to listen on until the initiator starts an application on a user channel. The current implementation allows the open() but no other operation, like termios. These fail with EINVAL. The responder sided application has no means to detect an open by the initiator sided application this way. And the initiator sided applications usually expect the responder sided application to listen on the user channel upon open.
Set the user channel into half-open state on responder side once a user application opens the virtual tty to allow IO operations on it. Furthermore, keep the user channel constipated until the initiator side opens it to give the responder sided application the chance to detect the new connection and to avoid data loss if the responder sided application starts sending before the user channel is open.
--- drivers/tty/n_gsm.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)
drivers/tty/n_gsm.c +29 -2
@@ -1510,6 +1510,8 @@ static void gsm_dlci_close(struct gsm_dlci *dlci)if (debug &8 )pr_debug ("DLCI %d goes closed.\n" , dlci->addr); dlci->state =DLCI_CLOSED ; +/* Prevent us from sending data before the link is up again */ + dlci->constipated = true;if (dlci->addr !=0 ) {tty_port_tty_hangup (&dlci->port, false);spin_lock_irqsave (&dlci->lock, flags);
@@ -1539,6 +1541,7 @@ static void gsm_dlci_open(struct gsm_dlci *dlci)del_timer (&dlci->t1);/* This will let a tty open continue */ dlci->state =DLCI_OPEN ; + dlci->constipated = false;if (debug &8 )pr_debug ("DLCI %d goes open.\n" , dlci->addr);/* Send current modem state */
@@ -1619,6 +1622,25 @@ static void gsm_dlci_begin_open(struct gsm_dlci *dlci)mod_timer (&dlci->t1, jiffies + gsm->t1 *HZ /100 ); } +/** +* gsm_dlci_set_opening - change state to opening +* @dlci: DLCI to open +* +* Change internal state to wait for DLCI open from initiator side. +* We set off timers and responses upon reception of an SABM. +*/ +static void gsm_dlci_set_opening (struct gsm_dlci *dlci) +{ +switch (dlci->state) { +case DLCI_CLOSED : +case DLCI_CLOSING : + dlci->state =DLCI_OPENING ; +break ; +default : +break ; + } +} +/** * gsm_dlci_begin_close - start channel open procedure * @dlci: DLCI to open
@@ -1762,10 +1784,13 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr) dlci->addr = addr; dlci->adaption = gsm->adaption; dlci->state =DLCI_CLOSED ; -if (addr) +if (addr) { dlci->data = gsm_dlci_data; -else +/* Prevent us from sending data before the link is up */ + dlci->constipated = true; + }else { dlci->data = gsm_dlci_command; + } gsm->dlci[addr] = dlci;return dlci; }
@@ -3178,6 +3203,8 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)/* Start sending off SABM messages */ if (gsm->initiator)gsm_dlci_begin_open (dlci); +else +gsm_dlci_set_opening (dlci);/* And wait for virtual carrier */ return tty_port_block_til_ready (port, tty, filp); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 855/1095 tty: n_gsm: fix tty registration before control channel open
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit 01aecd917114577c423f07cec0d186ad007d76fc ]
The current implementation registers/deregisters the user ttys at mux attach/detach. That means that the user devices are available before any control channel is open. However, user channel initialization requires an open control channel. Furthermore, the user is not informed if the mux restarts due to configuration changes.
Put the registration/deregistration procedure into separate function to improve readability.
Move registration to mux activation and deregistration to mux cleanup to keep the user devices only open as long as a control channel exists. The user will be informed via the device driver if the mux was reconfigured in a way that required a mux re-activation.
This makes it necessary to add T2 initialization to gsmld_open() for the ldisc open code path (not the reconfiguration code path) to avoid deletion of an uninitialized T2 at mux cleanup.
--- drivers/tty/n_gsm.c | 117 ++++++++++++++++++++++++++++++-------------- 1 file changed, 79 insertions(+), 38 deletions(-)
drivers/tty/n_gsm.c +79 -38
@@ -235,6 +235,7 @@ struct gsm_mux {struct gsm_dlci *dlci[NUM_DLCI ];int old_c_iflag;/* termios c_iflag value before attach */ bool constipated;/* Asked by remote to shut up */ +bool has_devices;/* Devices were registered */ spinlock_t tx_lock;unsigned int tx_bytes;/* TX data outstanding */
@@ -463,6 +464,68 @@ static void gsm_hex_dump_bytes(const char *fname, const u8 *data,kfree (prefix); } +/** +* gsm_register_devices - register all tty devices for a given mux index +* +* @driver: the tty driver that describes the tty devices +* @index: the mux number is used to calculate the minor numbers of the +* ttys for this mux and may differ from the position in the +* mux array. +*/ +static int gsm_register_devices (struct tty_driver *driver,unsigned int index) +{ +struct device *dev; +int i; +unsigned int base; + +if (!driver || index >=MAX_MUX ) +return -EINVAL ; + + base = index *NUM_DLCI ;/* first minor for this index */ +for (i =1 ; i <NUM_DLCI ; i++) { +/* Don't register device 0 - this is the control channel +* and not a usable tty interface +*/ + dev =tty_register_device (gsm_tty_driver, base + i,NULL ); +if (IS_ERR (dev)) { +if (debug &8 ) +pr_info ("%s failed to register device minor %u" , + __func__, base + i); +for (i--; i >=1 ; i--) +tty_unregister_device (gsm_tty_driver, base + i); +return PTR_ERR (dev); + } + } + +return 0 ; +} + +/** +* gsm_unregister_devices - unregister all tty devices for a given mux index +* +* @driver: the tty driver that describes the tty devices +* @index: the mux number is used to calculate the minor numbers of the +* ttys for this mux and may differ from the position in the +* mux array. +*/ +static void gsm_unregister_devices (struct tty_driver *driver, +unsigned int index) +{ +int i; +unsigned int base; + +if (!driver || index >=MAX_MUX ) +return ; + + base = index *NUM_DLCI ;/* first minor for this index */ +for (i =1 ; i <NUM_DLCI ; i++) { +/* Don't unregister device 0 - this is the control +* channel and not a usable tty interface +*/ +tty_unregister_device (gsm_tty_driver, base + i); + } +} +/** * gsm_print_packet - display a frame for debug * @hdr: header to print before decode
@@ -2208,6 +2271,10 @@ static void gsm_cleanup_mux(struct gsm_mux *gsm, bool disc)del_timer_sync (&gsm->t2_timer);/* Free up any link layer users and finally the control channel */ +if (gsm->has_devices) { +gsm_unregister_devices (gsm_tty_driver, gsm->num); + gsm->has_devices = false; + }for (i =NUM_DLCI -1 ; i >=0 ; i--)if (gsm->dlci[i])gsm_dlci_release (gsm->dlci[i]);
@@ -2231,6 +2298,7 @@ static void gsm_cleanup_mux(struct gsm_mux *gsm, bool disc)static int gsm_activate_mux (struct gsm_mux *gsm) {struct gsm_dlci *dlci; +int ret;timer_setup (&gsm->t2_timer, gsm_control_retransmit,0 );init_waitqueue_head (&gsm->event);
@@ -2242,9 +2310,14 @@ static int gsm_activate_mux(struct gsm_mux *gsm)else gsm->receive = gsm1_receive; + ret =gsm_register_devices (gsm_tty_driver, gsm->num); +if (ret) +return ret; + dlci =gsm_dlci_alloc (gsm,0 );if (dlci ==NULL )return -ENOMEM ; + gsm->has_devices = true; gsm->dead = false;/* Tty opens are now permissible */ return 0 ; }
@@ -2504,39 +2577,14 @@ static int gsmld_output(struct gsm_mux *gsm, u8 *data, int len)* will need moving to an ioctl path. */ -static int gsmld_attach_gsm (struct tty_struct *tty,struct gsm_mux *gsm) +static void gsmld_attach_gsm (struct tty_struct *tty,struct gsm_mux *gsm) { -unsigned int base; -int ret, i; - gsm->tty =tty_kref_get (tty);/* Turn off tty XON/XOFF handling to handle it explicitly. */ gsm->old_c_iflag = tty->termios.c_iflag; tty->termios.c_iflag &= (IXON |IXOFF ); - ret =gsm_activate_mux (gsm); -if (ret !=0 ) -tty_kref_put (gsm->tty); -else { -/* Don't register device 0 - this is the control channel and not -a usable tty interface */ - base =mux_num_to_base (gsm);/* Base for this MUX */ -for (i =1 ; i <NUM_DLCI ; i++) { -struct device *dev; - - dev =tty_register_device (gsm_tty_driver, - base + i,NULL ); -if (IS_ERR (dev)) { -for (i--; i >=1 ; i--) -tty_unregister_device (gsm_tty_driver, - base + i); -return PTR_ERR (dev); - } - } - } -return ret; } -/** * gsmld_detach_gsm - stop doing 0710 mux * @tty: tty attached to the mux
@@ -2547,12 +2595,7 @@ static int gsmld_attach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)static void gsmld_detach_gsm (struct tty_struct *tty,struct gsm_mux *gsm) { -unsigned int base =mux_num_to_base (gsm);/* Base for this MUX */ -int i; -WARN_ON (tty != gsm->tty); -for (i =1 ; i <NUM_DLCI ; i++) -tty_unregister_device (gsm_tty_driver, base + i);/* Restore tty XON/XOFF handling. */ gsm->tty->termios.c_iflag = gsm->old_c_iflag;tty_kref_put (gsm->tty);
@@ -2644,7 +2687,6 @@ static void gsmld_close(struct tty_struct *tty)static int gsmld_open (struct tty_struct *tty) {struct gsm_mux *gsm; -int ret;if (tty->ops->write ==NULL )return -EINVAL ;
@@ -2660,12 +2702,11 @@ static int gsmld_open(struct tty_struct *tty)/* Attach the initial passive connection */ gsm->encoding =1 ; - ret =gsmld_attach_gsm (tty, gsm); -if (ret !=0 ) { -gsm_cleanup_mux (gsm, false); -mux_put (gsm); - } -return ret; +gsmld_attach_gsm (tty, gsm); + +timer_setup (&gsm->t2_timer, gsm_control_retransmit,0 ); + +return 0 ; }/**
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 856/1095 tty: n_gsm: fix wrong queuing behavior in gsm_dlci_data_output()
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit 556fc8ac06513cced381588d6d58c184d95cc4fe ]
1) The function drains the fifo for the given user tty/DLCI without considering 'TX_THRESH_HI' and different to gsm_dlci_data_output_framed(), which moves only one packet from the user side to the internal transmission queue. We can only handle one packet at a time here if we want to allow DLCI priority handling in gsm_dlci_data_sweep() to avoid link starvation.
2) Furthermore, the additional header octet from convergence layer type 2 is not counted against MTU. It is part of the UI/UIH frame message which needs to be limited to MTU. Hence, it is wrong not to consider this octet.
3) Finally, the waiting user tty is not informed about freed space in its send queue.
Take at most one packet worth of data out of the DLCI fifo to fix 1). Limit the max user data size per packet to MTU - 1 in case of convergence layer type 2 to leave space for the control signal octet which is added in the later part of the function. This fixes 2).
Add tty_port_tty_wakeup() to wake up the user tty if new write space has been made available to fix 3).
--- drivers/tty/n_gsm.c | 74 +++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 32 deletions(-)
drivers/tty/n_gsm.c +42 -32
@@ -886,41 +886,51 @@ static int gsm_dlci_data_output(struct gsm_mux *gsm, struct gsm_dlci *dlci) {struct gsm_msg *msg;u8 *dp; -int len, total_size, size; -int h = dlci->adaption -1 ; +int h, len, size; - total_size =0 ; -while (1 ) { - len =kfifo_len (&dlci->fifo); -if (len ==0 ) -return total_size; - -/* MTU/MRU count only the data bits */ -if (len > gsm->mtu) - len = gsm->mtu; - - size = len + h; - - msg =gsm_data_alloc (gsm, dlci->addr, size, gsm->ftype); -/* FIXME: need a timer or something to kick this so it can't -get stuck with no work outstanding and no buffer free */ -if (msg ==NULL ) -return -ENOMEM ; - dp = msg->data; -switch (dlci->adaption) { -case 1 :/* Unstructured */ -break ; -case 2 :/* Unstructed with modem bits. -Always one byte as we never send inline break data */ - *dp++ = (gsm_encode_modem (dlci) <<1 ) |EA ; -break ; - } -WARN_ON (kfifo_out_locked (&dlci->fifo, dp , len, &dlci->lock) != len); -__gsm_data_queue (dlci, msg); - total_size += size; +/* for modem bits without break data */ + h = ((dlci->adaption ==1 ) ?0 :1 ); + + len =kfifo_len (&dlci->fifo); +if (len ==0 ) +return 0 ; + +/* MTU/MRU count only the data bits but watch adaption mode */ +if ((len + h) > gsm->mtu) + len = gsm->mtu - h; + + size = len + h; + + msg =gsm_data_alloc (gsm, dlci->addr, size, gsm->ftype); +/* FIXME: need a timer or something to kick this so it can't +* get stuck with no work outstanding and no buffer free +*/ +if (!msg) +return -ENOMEM ; + dp = msg->data; +switch (dlci->adaption) { +case 1 :/* Unstructured */ +break ; +case 2 :/* Unstructured with modem bits. +* Always one byte as we never send inline break data +*/ + *dp++ = (gsm_encode_modem (dlci) <<1 ) |EA ; +break ; +default : +pr_err ("%s: unsupported adaption %d\n" , __func__, + dlci->adaption); +break ; } + +WARN_ON (len !=kfifo_out_locked (&dlci->fifo, dp, len, + &dlci->lock)); + +/* Notify upper layer about available send space. */ +tty_port_tty_wakeup (&dlci->port); + +__gsm_data_queue (dlci, msg);/* Bytes of data we used up */ -return total_size; +return size; }/**
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 857/1095 tty: n_gsm: fix missing timer to handle stalled links
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit c568f7086c6e771c77aad13d727c70ef70e07243 ]
The current implementation does not handle the situation that no data is in the internal queue and needs to be sent out while the user tty fifo is full.
Add a timer that moves more data from user tty down to the internal queue which is then serialized on the ldisc. This timer is triggered if no data was moved from a user tty to the internal queue within 10 * T1.
--- drivers/tty/n_gsm.c | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-)
drivers/tty/n_gsm.c +35 -8
@@ -244,6 +244,7 @@ struct gsm_mux {struct list_head tx_list;/* Pending data packets */ /* Control messages */ +struct timer_list kick_timer;/* Kick TX queuing on timeout */ struct timer_list t2_timer;/* Retransmit timer for commands */ int cretries;/* Command retry counter */ struct gsm_control *pending_cmd;/* Our current pending command */
@@ -850,6 +851,7 @@ static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)list_add_tail (&msg->list, &gsm->tx_list); gsm->tx_bytes += msg->len;gsm_data_kick (gsm, dlci); +mod_timer (&gsm->kick_timer, jiffies +10 * gsm->t1 *HZ /100 ); }/**
@@ -902,9 +904,6 @@ static int gsm_dlci_data_output(struct gsm_mux *gsm, struct gsm_dlci *dlci) size = len + h; msg =gsm_data_alloc (gsm, dlci->addr, size, gsm->ftype); -/* FIXME: need a timer or something to kick this so it can't -* get stuck with no work outstanding and no buffer free -*/ if (!msg)return -ENOMEM ; dp = msg->data;
@@ -981,9 +980,6 @@ static int gsm_dlci_data_output_framed(struct gsm_mux *gsm, size = len + overhead; msg =gsm_data_alloc (gsm, dlci->addr, size, gsm->ftype); - -/* FIXME: need a timer or something to kick this so it can't -get stuck with no work outstanding and no buffer free */ if (msg ==NULL ) {skb_queue_tail (&dlci->skb_list, dlci->skb); dlci->skb =NULL ;
@@ -1079,9 +1075,9 @@ static int gsm_dlci_modem_output(struct gsm_mux *gsm, struct gsm_dlci *dlci,* renegotiate DLCI priorities with optional stuff. Needs optimising. */ -static void gsm_dlci_data_sweep (struct gsm_mux *gsm) +static int gsm_dlci_data_sweep (struct gsm_mux *gsm) { -int len; +int len, ret =0 ;/* Priority ordering: We should do priority with RR of the groups */ int i =1 ;
@@ -1104,7 +1100,11 @@ static void gsm_dlci_data_sweep(struct gsm_mux *gsm)/* DLCI empty - try the next */ if (len ==0 ) i++; +else + ret++; } + +return ret; }/**
@@ -1823,6 +1823,30 @@ static void gsm_dlci_command(struct gsm_dlci *dlci, const u8 *data, int len) } } +/** +* gsm_kick_timer - transmit if possible +* @t: timer contained in our gsm object +* +* Transmit data from DLCIs if the queue is empty. We can't rely on +* a tty wakeup except when we filled the pipe so we need to fire off +* new data ourselves in other cases. +*/ +static void gsm_kick_timer (struct timer_list *t) +{ +struct gsm_mux *gsm =from_timer (gsm, t, kick_timer); +unsigned long flags; +int sent =0 ; + +spin_lock_irqsave (&gsm->tx_lock, flags); +/* If we have nothing running then we need to fire up */ +if (gsm->tx_bytes <TX_THRESH_LO ) + sent =gsm_dlci_data_sweep (gsm); +spin_unlock_irqrestore (&gsm->tx_lock, flags); + +if (sent && debug &4 ) +pr_info ("%s TX queue stalled\n" , __func__); +} +/* * Allocate/Free DLCI channels */
@@ -2278,6 +2302,7 @@ static void gsm_cleanup_mux(struct gsm_mux *gsm, bool disc) }/* Finish outstanding timers, making sure they are done */ +del_timer_sync (&gsm->kick_timer);del_timer_sync (&gsm->t2_timer);/* Free up any link layer users and finally the control channel */
@@ -2310,6 +2335,7 @@ static int gsm_activate_mux(struct gsm_mux *gsm)struct gsm_dlci *dlci;int ret; +timer_setup (&gsm->kick_timer, gsm_kick_timer,0 );timer_setup (&gsm->t2_timer, gsm_control_retransmit,0 );init_waitqueue_head (&gsm->event);spin_lock_init (&gsm->control_lock);
@@ -2714,6 +2740,7 @@ static int gsmld_open(struct tty_struct *tty)gsmld_attach_gsm (tty, gsm); +timer_setup (&gsm->kick_timer, gsm_kick_timer,0 );timer_setup (&gsm->t2_timer, gsm_control_retransmit,0 );return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 858/1095 tty: n_gsm: fix non flow control frames during mux flow off
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit bec0224816d19abe4fe503586d16d51890540615 ]
n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010.
See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1516
The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to
the newer 27.010 here. Chapter 5.4.6.3.6 states that FCoff stops the
transmission on all channels except the control channel. This is already
implemented in gsm_data_kick(). However, chapter 5.4.8.1 explains that this
shall result in the same behavior as software flow control on the ldisc in
advanced option mode. That means only flow control frames shall be sent
during flow off. The current implementation does not consider this case.
Change gsm_data_kick() to send only flow control frames if constipated to abide the standard. gsm_read_ea_val() and gsm_is_flow_ctrl_msg() are introduced as helper functions for this.
It is planned to use gsm_read_ea_val() in later code cleanups for other functions, too.
--- drivers/tty/n_gsm.c | 54 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-)
drivers/tty/n_gsm.c +53 -1
@@ -421,6 +421,27 @@ static int gsm_read_ea(unsigned int *val, u8 c)return c &EA ; } +/** +* gsm_read_ea_val - read a value until EA +* @val: variable holding value +* @data: buffer of data +* @dlen: length of data +* +* Processes an EA value. Updates the passed variable and +* returns the processed data length. +*/ +static unsigned int gsm_read_ea_val (unsigned int *val,const u8 *data,int dlen) +{ +unsigned int len =0 ; + +for (; dlen >0 ; dlen--) { + len++; +if (gsm_read_ea (val, *data++)) +break ; + } +return len; +} +/** * gsm_encode_modem - encode modem data bits * @dlci: DLCI to encode from
@@ -746,6 +767,37 @@ static struct gsm_msg *gsm_data_alloc(struct gsm_mux *gsm, u8 addr, int len,return m; } +/** +* gsm_is_flow_ctrl_msg - checks if flow control message +* @msg: message to check +* +* Returns true if the given message is a flow control command of the +* control channel. False is returned in any other case. +*/ +static bool gsm_is_flow_ctrl_msg (struct gsm_msg *msg) +{ +unsigned int cmd; + +if (msg->addr >0 ) +return false; + +switch (msg->ctrl & ~PF ) { +case UI : +case UIH : + cmd =0 ; +if (gsm_read_ea_val (&cmd, msg->data +2 , msg->len -2 ) <1 ) +break ; +switch (cmd & ~PF ) { +case CMD_FCOFF : +case CMD_FCON : +return true; + } +break ; + } + +return false; +} +/** * gsm_data_kick - poke the queue * @gsm: GSM Mux
@@ -765,7 +817,7 @@ static void gsm_data_kick(struct gsm_mux *gsm, struct gsm_dlci *dlci)int len;list_for_each_entry_safe (msg, nmsg, &gsm->tx_list, list) { -if (gsm->constipated && msg->addr) +if (gsm->constipated && !gsm_is_flow_ctrl_msg (msg))continue ;if (gsm->encoding !=0 ) { gsm->txframe[0 ] =GSM1_SOF ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 859/1095 tty: n_gsm: fix packet re-transmission without open control channel
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit 4fae831b3a71fc5a44cc5c7d0b8c1267ee7659f5 ]
In the current implementation control packets are re-transmitted even if the control channel closed down during T2. This is wrong. Check whether the control channel is open before re-transmitting any packets. Note that control channel open/close is handled by T1 and not T2 and remains unaffected by this.
--- drivers/tty/n_gsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/n_gsm.c +1 -1
@@ -1532,7 +1532,7 @@ static void gsm_control_retransmit(struct timer_list *t)spin_lock_irqsave (&gsm->control_lock, flags); ctrl = gsm->pending_cmd;if (ctrl) { -if (gsm->cretries ==0 ) { +if (gsm->cretries ==0 || !gsm->dlci[0 ] || gsm->dlci[0 ]->dead) { gsm->pending_cmd =NULL ; ctrl->error = -ETIMEDOUT ; ctrl->done =1 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 860/1095 tty: n_gsm: fix race condition in gsmld_write()
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit 32dd59f96924f45e33bc79854f7a00679c0fa28e ]
The function may be used by the user directly and also by the n_gsm internal functions. They can lead into a race condition which results in interleaved frames if both are writing at the same time. The receiving side is not able to decode those interleaved frames correctly.
Add a lock around the low side tty write to avoid race conditions and frame interleaving between user originated writes and n_gsm writes.
--- drivers/tty/n_gsm.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
drivers/tty/n_gsm.c +17 -4
@@ -2863,11 +2863,24 @@ static ssize_t gsmld_read(struct tty_struct *tty, struct file *file,static ssize_t gsmld_write (struct tty_struct *tty,struct file *file,const unsigned char *buf,size_t nr) { -int space =tty_write_room (tty); +struct gsm_mux *gsm = tty->disc_data; +unsigned long flags; +int space; +int ret; + +if (!gsm) +return -ENODEV ; + + ret = -ENOBUFS ; +spin_lock_irqsave (&gsm->tx_lock, flags); + space =tty_write_room (tty);if (space >= nr) -return tty->ops->write (tty, buf, nr); -set_bit (TTY_DO_WRITE_WAKEUP , &tty->flags); -return -ENOBUFS ; + ret = tty->ops->write (tty, buf, nr); +else +set_bit (TTY_DO_WRITE_WAKEUP , &tty->flags); +spin_unlock_irqrestore (&gsm->tx_lock, flags); + +return ret; }/**
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 861/1095 tty: n_gsm: fix deadlock and link starvation in outgoing data path
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit 0af021678d5d30c31f5a6b631f404ead3575212a ]
The current implementation queues up new control and user packets as needed and processes this queue down to the ldisc in the same code path. That means that the upper and the lower layer are hard coupled in the code. Due to this deadlocks can happen as seen below while transmitting data, especially during ldisc congestion. Furthermore, the data channels starve the control channel on high transmission load on the ldisc.
Introduce an additional control channel data queue to prevent timeouts and link hangups during ldisc congestion. This is being processed before the user channel data queue in gsm_data_kick(), i.e. with the highest priority. Put the queue to ldisc data path into a workqueue and trigger it whenever new data has been put into the transmission queue. Change gsm_dlci_data_sweep() accordingly to fill up the transmission queue until TX_THRESH_HI. This solves the locking issue, keeps latency low and provides good performance on high data load.
Note that now all packets from a DLCI are removed from the internal queue if the associated DLCI was closed. This ensures that no data is sent by the introduced write task to an already closed DLCI.
BUG: spinlock recursion on CPU#0, test_v24_loop/124 lock: serial8250_ports+0x3a8/0x7500, .magic: dead4ead, .owner: test_v24_loop/124, .owner_cpu: 0 CPU: 0 PID: 124 Comm: test_v24_loop Tainted: G O 5.18.0-rc2 #3 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 Call Trace: <IRQ> dump_stack_lvl+0x34/0x44 do_raw_spin_lock+0x76/0xa0 _raw_spin_lock_irqsave+0x72/0x80 uart_write_room+0x3b/0xc0 gsm_data_kick+0x14b/0x240 [n_gsm] gsmld_write_wakeup+0x35/0x70 [n_gsm] tty_wakeup+0x53/0x60 tty_port_default_wakeup+0x1b/0x30 serial8250_tx_chars+0x12f/0x220 serial8250_handle_irq.part.0+0xfe/0x150 serial8250_default_handle_irq+0x48/0x80 serial8250_interrupt+0x56/0xa0 __handle_irq_event_percpu+0x78/0x1f0 handle_irq_event+0x34/0x70 handle_fasteoi_irq+0x90/0x1e0 __common_interrupt+0x69/0x100 common_interrupt+0x48/0xc0 asm_common_interrupt+0x1e/0x40 RIP: 0010:__do_softirq+0x83/0x34e Code: 2a 0a ff 0f b7 ed c7 44 24 10 0a 00 00 00 48 c7 c7 51 2a 64 82 e8 2d
e2 d5 ff 65 66 c7 05 83 af 1e 7e 00 00 fb b8 ff ff ff ff <49> c7 c2 40 61 80 82 0f bc c5 41 89 c4 41 83 c4 01 0f 84 e6 00 00
RSP: 0018:ffffc90000003f98 EFLAGS: 00000286
RAX: 00000000ffffffff RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff82642a51 RDI: ffffffff825bb5e7
RBP: 0000000000000200 R08: 00000008de3271a8 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000030 R14: 0000000000000000 R15: 0000000000000000
? __do_softirq+0x73/0x34e irq_exit_rcu+0xb5/0x100 common_interrupt+0xa4/0xc0 </IRQ> <TASK> asm_common_interrupt+0x1e/0x40 RIP: 0010:_raw_spin_unlock_irqrestore+0x2e/0x50 Code: 00 55 48 89 fd 48 83 c7 18 53 48 89 f3 48 8b 74 24 10 e8 85 28 36 ff
48 89 ef e8 cd 58 36 ff 80 e7 02 74 01 fb bf 01 00 00 00 <e8> 3d 97 33 ff 65 8b 05 96 23 2b 7e 85 c0 74 03 5b 5d c3 0f 1f 44
RSP: 0018:ffffc9000020fd08 EFLAGS: 00000202
RAX: 0000000000000000 RBX: 0000000000000246 RCX: 0000000000000000
RDX: 0000000000000004 RSI: ffffffff8257fd74 RDI: 0000000000000001
RBP: ffff8880057de3a0 R08: 00000008de233000 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000100 R14: 0000000000000202 R15: ffff8880057df0b8
? _raw_spin_unlock_irqrestore+0x23/0x50 gsmtty_write+0x65/0x80 [n_gsm] n_tty_write+0x33f/0x530 ? swake_up_all+0xe0/0xe0 file_tty_write.constprop.0+0x1b1/0x320 ? n_tty_flush_buffer+0xb0/0xb0 new_sync_write+0x10c/0x190 vfs_write+0x282/0x310 ksys_write+0x68/0xe0 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7f3e5e35c15c Code: 8b 7c 24 08 89 c5 e8 c5 ff ff ff 89 ef 89 44 24 08 e8 58 bc 02 00 8b
44 24 08 48 83 c4 10 5d c3 48 63 ff b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 76 10 48 8b 15 fd fc 05 00 f7 d8 64 89 02 48 83
RSP: 002b:00007ffcee77cd18 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007ffcee77cd70 RCX: 00007f3e5e35c15c
RDX: 0000000000000100 RSI: 00007ffcee77cd90 RDI: 0000000000000003
RBP: 0000000000000100 R08: 0000000000000000 R09: 7efefefefefefeff
R10: 00007f3e5e3bddeb R11: 0000000000000246 R12: 00007ffcee77ce8f
R13: 0000000000000001 R14: 000056214404e010 R15: 00007ffcee77cd90
</TASK>
--- drivers/tty/n_gsm.c | 407 ++++++++++++++++++++++++++++++-------------- 1 file changed, 279 insertions(+), 128 deletions(-)
drivers/tty/n_gsm.c +279 -128
@@ -5,6 +5,14 @@* * * THIS IS A DEVELOPMENT SNAPSHOT IT IS NOT A FINAL RELEASE * * +* Outgoing path: +* tty -> DLCI fifo -> scheduler -> GSM MUX data queue ---o-> ldisc +* control message -> GSM MUX control queue --´ +* +* Incoming path: +* ldisc -> gsm_queue() -o--> tty +* `-> gsm_control_response() +* * TO DO: * Mostly done: ioctls for setting modes/timing * Partly done: hooks so you can pull off frames to non tty devs
@@ -210,6 +218,9 @@ struct gsm_mux {/* Events on the GSM channel */ wait_queue_head_t event; +/* ldisc send work */ +struct work_struct tx_work; +/* Bits for GSM mode decoding */ /* Framing Layer */
@@ -241,7 +252,8 @@ struct gsm_mux {unsigned int tx_bytes;/* TX data outstanding */ #define TX_THRESH_HI 8192#define TX_THRESH_LO 2048 -struct list_head tx_list;/* Pending data packets */ +struct list_head tx_ctrl_list;/* Pending control packets */ +struct list_head tx_data_list;/* Pending data packets */ /* Control messages */ struct timer_list kick_timer;/* Kick TX queuing on timeout */
@@ -371,6 +383,11 @@ static const u8 gsm_fcs8[256] = {static int gsmld_output (struct gsm_mux *gsm,u8 *data,int len);static int gsm_modem_update (struct gsm_dlci *dlci,u8 brk); +static struct gsm_msg *gsm_data_alloc (struct gsm_mux *gsm,u8 addr,int len, +u8 ctrl); +static int gsm_send_packet (struct gsm_mux *gsm,struct gsm_msg *msg); +static void gsmld_write_trigger (struct gsm_mux *gsm); +static void gsmld_write_task (struct work_struct *work);/** * gsm_fcs_add - update FCS
@@ -655,57 +672,73 @@ static int gsm_stuff_frame(const u8 *input, u8 *output, int len)* @cr: command/response bit seen as initiator * @control: control byte including PF bit * -* Format up and transmit a control frame. These do not go via the -* queueing logic as they should be transmitted ahead of data when -* they are needed. -* -* FIXME: Lock versus data TX path +* Format up and transmit a control frame. These should be transmitted +* ahead of data when they are needed. */ - -static void gsm_send (struct gsm_mux *gsm,int addr,int cr,int control) +static int gsm_send (struct gsm_mux *gsm,int addr,int cr,int control) { -int len; -u8 cbuf[10 ]; -u8 ibuf[3 ]; +struct gsm_msg *msg; +u8 *dp;int ocr; +unsigned long flags; + + msg =gsm_data_alloc (gsm, addr,0 , control); +if (!msg) +return -ENOMEM ;/* toggle C/R coding if not initiator */ ocr = cr ^ (gsm->initiator ?0 :1 ); -switch (gsm->encoding) { -case 0 : - cbuf[0 ] =GSM0_SOF ; - cbuf[1 ] = (addr <<2 ) | (ocr <<1 ) |EA ; - cbuf[2 ] = control; - cbuf[3 ] =EA ;/* Length of data = 0 */ - cbuf[4 ] =0xFF -gsm_fcs_add_block (INIT_FCS , cbuf +1 ,3 ); - cbuf[5 ] =GSM0_SOF ; - len =6 ; -break ; -case 1 : -case 2 : -/* Control frame + packing (but not frame stuffing) in mode 1 */ - ibuf[0 ] = (addr <<2 ) | (ocr <<1 ) |EA ; - ibuf[1 ] = control; - ibuf[2 ] =0xFF -gsm_fcs_add_block (INIT_FCS , ibuf,2 ); -/* Stuffing may double the size worst case */ - len =gsm_stuff_frame (ibuf, cbuf +1 ,3 ); -/* Now add the SOF markers */ - cbuf[0 ] =GSM1_SOF ; - cbuf[len +1 ] =GSM1_SOF ; -/* FIXME: we can omit the lead one in many cases */ - len +=2 ; -break ; -default : -WARN_ON (1 ); -return ; - } -gsmld_output (gsm, cbuf, len); -if (!gsm->initiator) { - cr = cr & gsm->initiator; - control = control & ~PF ; + msg->data -=3 ; + dp = msg->data; + *dp++ = (addr <<2 ) | (ocr <<1 ) |EA ; + *dp++ = control; + +if (gsm->encoding ==0 ) + *dp++ =EA ;/* Length of data = 0 */ + + *dp =0xFF -gsm_fcs_add_block (INIT_FCS , msg->data, dp - msg->data); + msg->len = (dp - msg->data) +1 ; + +gsm_print_packet ("Q->" , addr, cr, control,NULL ,0 ); + +spin_lock_irqsave (&gsm->tx_lock, flags); +list_add_tail (&msg->list, &gsm->tx_ctrl_list); + gsm->tx_bytes += msg->len; +spin_unlock_irqrestore (&gsm->tx_lock, flags); +gsmld_write_trigger (gsm); + +return 0 ; +} + +/** +* gsm_dlci_clear_queues - remove outstanding data for a DLCI +* @gsm: mux +* @dlci: clear for this DLCI +* +* Clears the data queues for a given DLCI. +*/ +static void gsm_dlci_clear_queues (struct gsm_mux *gsm,struct gsm_dlci *dlci) +{ +struct gsm_msg *msg, *nmsg; +int addr = dlci->addr; +unsigned long flags; + +/* Clear DLCI write fifo first */ +spin_lock_irqsave (&dlci->lock, flags); +kfifo_reset (&dlci->fifo); +spin_unlock_irqrestore (&dlci->lock, flags); + +/* Clear data packets in MUX write queue */ +spin_lock_irqsave (&gsm->tx_lock, flags); +list_for_each_entry_safe (msg, nmsg, &gsm->tx_data_list, list) { +if (msg->addr != addr) +continue ; + gsm->tx_bytes -= msg->len; +list_del (&msg->list); +kfree (msg); } -gsm_print_packet ("-->" , addr, cr, control,NULL ,0 ); +spin_unlock_irqrestore (&gsm->tx_lock, flags); }/**
@@ -767,6 +800,45 @@ static struct gsm_msg *gsm_data_alloc(struct gsm_mux *gsm, u8 addr, int len,return m; } +/** +* gsm_send_packet - sends a single packet +* @gsm: GSM Mux +* @msg: packet to send +* +* The given packet is encoded and sent out. No memory is freed. +* The caller must hold the gsm tx lock. +*/ +static int gsm_send_packet (struct gsm_mux *gsm,struct gsm_msg *msg) +{ +int len, ret; + + +if (gsm->encoding ==0 ) { + gsm->txframe[0 ] =GSM0_SOF ; +memcpy (gsm->txframe +1 , msg->data, msg->len); + gsm->txframe[msg->len +1 ] =GSM0_SOF ; + len = msg->len +2 ; + }else { + gsm->txframe[0 ] =GSM1_SOF ; + len =gsm_stuff_frame (msg->data, gsm->txframe +1 , msg->len); + gsm->txframe[len +1 ] =GSM1_SOF ; + len +=2 ; + } + +if (debug &4 ) +gsm_hex_dump_bytes (__func__, gsm->txframe, len); +gsm_print_packet ("-->" , msg->addr, gsm->initiator, msg->ctrl, msg->data, + msg->len); + + ret =gsmld_output (gsm, gsm->txframe, len); +if (ret <=0 ) +return ret; +/* FIXME: Can eliminate one SOF in many more cases */ + gsm->tx_bytes -= msg->len; + +return 0 ; +} +/** * gsm_is_flow_ctrl_msg - checks if flow control message * @msg: message to check
@@ -799,59 +871,81 @@ static bool gsm_is_flow_ctrl_msg(struct gsm_msg *msg) }/** -* gsm_data_kick - poke the queue +* gsm_data_kick - poke the queue * @gsm: GSM Mux -* @dlci: DLCI sending the data * * The tty device has called us to indicate that room has appeared in -* the transmit queue. Ram more data into the pipe if we have any +* the transmit queue. Ram more data into the pipe if we have any. * If we have been flow-stopped by a CMD_FCOFF, then we can only -* send messages on DLCI0 until CMD_FCON -* -* FIXME: lock against link layer control transmissions +* send messages on DLCI0 until CMD_FCON. The caller must hold +* the gsm tx lock. */ - -static void gsm_data_kick (struct gsm_mux *gsm,struct gsm_dlci *dlci) +static int gsm_data_kick (struct gsm_mux *gsm) {struct gsm_msg *msg, *nmsg; -int len; +struct gsm_dlci *dlci; +int ret; -list_for_each_entry_safe (msg, nmsg, &gsm->tx_list, list) { +clear_bit (TTY_DO_WRITE_WAKEUP , &gsm->tty->flags); + +/* Serialize control messages and control channel messages first */ +list_for_each_entry_safe (msg, nmsg, &gsm->tx_ctrl_list, list) {if (gsm->constipated && !gsm_is_flow_ctrl_msg (msg)) +return -EAGAIN ; + ret =gsm_send_packet (gsm, msg); +switch (ret) { +case -ENOSPC : +return -ENOSPC ; +case -ENODEV : +/* ldisc not open */ + gsm->tx_bytes -= msg->len; +list_del (&msg->list); +kfree (msg);continue ; -if (gsm->encoding !=0 ) { - gsm->txframe[0 ] =GSM1_SOF ; - len =gsm_stuff_frame (msg->data, - gsm->txframe +1 , msg->len); - gsm->txframe[len +1 ] =GSM1_SOF ; - len +=2 ; - }else { - gsm->txframe[0 ] =GSM0_SOF ; -memcpy (gsm->txframe +1 , msg->data, msg->len); - gsm->txframe[msg->len +1 ] =GSM0_SOF ; - len = msg->len +2 ; - } - -if (debug &4 ) -gsm_hex_dump_bytes (__func__, gsm->txframe, len); -if (gsmld_output (gsm, gsm->txframe, len) <=0 ) +default : +if (ret >=0 ) { +list_del (&msg->list); +kfree (msg); + }break ; -/* FIXME: Can eliminate one SOF in many more cases */ - gsm->tx_bytes -= msg->len; - -list_del (&msg->list); -kfree (msg); + } + } -if (dlci) { -tty_port_tty_wakeup (&dlci->port); - }else { -int i =0 ; +if (gsm->constipated) +return -EAGAIN ; -for (i =0 ; i <NUM_DLCI ; i++) -if (gsm->dlci[i]) -tty_port_tty_wakeup (&gsm->dlci[i]->port); +/* Serialize other channels */ +if (list_empty (&gsm->tx_data_list)) +return 0 ; +list_for_each_entry_safe (msg, nmsg, &gsm->tx_data_list, list) { + dlci = gsm->dlci[msg->addr]; +/* Send only messages for DLCIs with valid state */ +if (dlci->state !=DLCI_OPEN ) { + gsm->tx_bytes -= msg->len; +list_del (&msg->list); +kfree (msg); +continue ; + } + ret =gsm_send_packet (gsm, msg); +switch (ret) { +case -ENOSPC : +return -ENOSPC ; +case -ENODEV : +/* ldisc not open */ + gsm->tx_bytes -= msg->len; +list_del (&msg->list); +kfree (msg); +continue ; +default : +if (ret >=0 ) { +list_del (&msg->list); +kfree (msg); + } +break ; } } + +return 1 ; }/**
@@ -900,9 +994,21 @@ static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg) msg->data = dp;/* Add to the actual output queue */ -list_add_tail (&msg->list, &gsm->tx_list); +switch (msg->ctrl & ~PF ) { +case UI : +case UIH : +if (msg->addr >0 ) { +list_add_tail (&msg->list, &gsm->tx_data_list); +break ; + } + fallthrough; +default : +list_add_tail (&msg->list, &gsm->tx_ctrl_list); +break ; + } gsm->tx_bytes += msg->len; -gsm_data_kick (gsm, dlci); + +gsmld_write_trigger (gsm);mod_timer (&gsm->kick_timer, jiffies +10 * gsm->t1 *HZ /100 ); }
@@ -1129,32 +1235,39 @@ static int gsm_dlci_modem_output(struct gsm_mux *gsm, struct gsm_dlci *dlci,static int gsm_dlci_data_sweep (struct gsm_mux *gsm) { -int len, ret =0 ;/* Priority ordering: We should do priority with RR of the groups */ -int i =1 ; - -while (i <NUM_DLCI ) { -struct gsm_dlci *dlci; +int i, len, ret =0 ; +bool sent; +struct gsm_dlci *dlci; -if (gsm->tx_bytes >TX_THRESH_HI ) -break ; - dlci = gsm->dlci[i]; -if (dlci ==NULL || dlci->constipated) { - i++; -continue ; +while (gsm->tx_bytes <TX_THRESH_HI ) { +for (sent = false, i =1 ; i <NUM_DLCI ; i++) { + dlci = gsm->dlci[i]; +/* skip unused or blocked channel */ +if (!dlci || dlci->constipated) +continue ; +/* skip channels with invalid state */ +if (dlci->state !=DLCI_OPEN ) +continue ; +/* count the sent data per adaption */ +if (dlci->adaption <3 && !dlci->net) + len =gsm_dlci_data_output (gsm, dlci); +else + len =gsm_dlci_data_output_framed (gsm, dlci); +/* on error exit */ +if (len <0 ) +return ret; +if (len >0 ) { + ret++; + sent = true; +/* The lower DLCs can starve the higher DLCs! */ +break ; + } +/* try next */ } -if (dlci->adaption <3 && !dlci->net) - len =gsm_dlci_data_output (gsm, dlci); -else - len =gsm_dlci_data_output_framed (gsm, dlci); -if (len <0 ) +if (!sent)break ; -/* DLCI empty - try the next */ -if (len ==0 ) - i++; -else - ret++; - } + };return ret; }
@@ -1402,7 +1515,6 @@ static void gsm_control_message(struct gsm_mux *gsm, unsigned int command, const u8 *data, int clen) {u8 buf[1 ]; -unsigned long flags;switch (command) {case CMD_CLD : {
@@ -1424,9 +1536,7 @@ static void gsm_control_message(struct gsm_mux *gsm, unsigned int command, gsm->constipated = false;gsm_control_reply (gsm,CMD_FCON ,NULL ,0 );/* Kick the link in case it is idling */ -spin_lock_irqsave (&gsm->tx_lock, flags); -gsm_data_kick (gsm,NULL ); -spin_unlock_irqrestore (&gsm->tx_lock, flags); +gsmld_write_trigger (gsm);break ;case CMD_FCOFF :/* Modem wants us to STFU */
@@ -1629,8 +1739,6 @@ static int gsm_control_wait(struct gsm_mux *gsm, struct gsm_control *control)static void gsm_dlci_close (struct gsm_dlci *dlci) { -unsigned long flags; -del_timer (&dlci->t1);if (debug &8 )pr_debug ("DLCI %d goes closed.\n" , dlci->addr);
@@ -1639,17 +1747,16 @@ static void gsm_dlci_close(struct gsm_dlci *dlci) dlci->constipated = true;if (dlci->addr !=0 ) {tty_port_tty_hangup (&dlci->port, false); -spin_lock_irqsave (&dlci->lock, flags); -kfifo_reset (&dlci->fifo); -spin_unlock_irqrestore (&dlci->lock, flags); +gsm_dlci_clear_queues (dlci->gsm, dlci);/* Ensure that gsmtty_open() can return. */ tty_port_set_initialized (&dlci->port,0 );wake_up_interruptible (&dlci->port.open_wait); }else dlci->gsm->dead = true; -wake_up (&dlci->gsm->event);/* A DLCI 0 close is a MUX termination so we need to kick that back to userspace somehow */ +gsm_dlci_data_kick (dlci); +wake_up (&dlci->gsm->event); }/**
@@ -1672,6 +1779,7 @@ static void gsm_dlci_open(struct gsm_dlci *dlci)/* Send current modem state */ if (dlci->addr)gsm_modem_update (dlci,0 ); +gsm_dlci_data_kick (dlci);wake_up (&dlci->gsm->event); }
@@ -2226,7 +2334,7 @@ static void gsm1_receive(struct gsm_mux *gsm, unsigned char c) }else if ((c &ISO_IEC_646_MASK ) ==XOFF ) { gsm->constipated = false;/* Kick the link in case it is idling */ -gsm_data_kick (gsm,NULL ); +gsmld_write_trigger (gsm);return ; }if (c ==GSM1_SOF ) {
@@ -2357,6 +2465,9 @@ static void gsm_cleanup_mux(struct gsm_mux *gsm, bool disc)del_timer_sync (&gsm->kick_timer);del_timer_sync (&gsm->t2_timer); +/* Finish writing to ldisc */ +flush_work (&gsm->tx_work); +/* Free up any link layer users and finally the control channel */ if (gsm->has_devices) {gsm_unregister_devices (gsm_tty_driver, gsm->num);
@@ -2368,9 +2479,12 @@ static void gsm_cleanup_mux(struct gsm_mux *gsm, bool disc)mutex_unlock (&gsm->mutex);/* Now wipe the queues */ tty_ldisc_flush (gsm->tty); -list_for_each_entry_safe (txq, ntxq, &gsm->tx_list, list) +list_for_each_entry_safe (txq, ntxq, &gsm->tx_ctrl_list, list) +kfree (txq); +INIT_LIST_HEAD (&gsm->tx_ctrl_list); +list_for_each_entry_safe (txq, ntxq, &gsm->tx_data_list, list)kfree (txq); -INIT_LIST_HEAD (&gsm->tx_list); +INIT_LIST_HEAD (&gsm->tx_data_list); }/**
@@ -2389,6 +2503,7 @@ static int gsm_activate_mux(struct gsm_mux *gsm)timer_setup (&gsm->kick_timer, gsm_kick_timer,0 );timer_setup (&gsm->t2_timer, gsm_control_retransmit,0 ); +INIT_WORK (&gsm->tx_work, gsmld_write_task);init_waitqueue_head (&gsm->event);spin_lock_init (&gsm->control_lock);spin_lock_init (&gsm->tx_lock);
@@ -2498,7 +2613,8 @@ static struct gsm_mux *gsm_alloc_mux(void)spin_lock_init (&gsm->lock);mutex_init (&gsm->mutex);kref_init (&gsm->ref); -INIT_LIST_HEAD (&gsm->tx_list); +INIT_LIST_HEAD (&gsm->tx_ctrl_list); +INIT_LIST_HEAD (&gsm->tx_data_list); gsm->t1 =T1 ; gsm->t2 =T2 ;
@@ -2655,6 +2771,47 @@ static int gsmld_output(struct gsm_mux *gsm, u8 *data, int len)return gsm->tty->ops->write (gsm->tty, data, len); } + +/** +* gsmld_write_trigger - schedule ldisc write task +* @gsm: our mux +*/ +static void gsmld_write_trigger (struct gsm_mux *gsm) +{ +if (!gsm || !gsm->dlci[0 ] || gsm->dlci[0 ]->dead) +return ; +schedule_work (&gsm->tx_work); +} + + +/** +* gsmld_write_task - ldisc write task +* @work: our tx write work +* +* Writes out data to the ldisc if possible. We are doing this here to +* avoid dead-locking. This returns if no space or data is left for output. +*/ +static void gsmld_write_task (struct work_struct *work) +{ + struct gsm_mux *gsm = container_of(work, struct gsm_mux, tx_work); +unsigned long flags; +int i, ret; + +/* All outstanding control channel and control messages and one data +* frame is sent. +*/ + ret = -ENODEV ; +spin_lock_irqsave (&gsm->tx_lock, flags); +if (gsm->tty) + ret =gsm_data_kick (gsm); +spin_unlock_irqrestore (&gsm->tx_lock, flags); + +if (ret >=0 ) +for (i =0 ; i <NUM_DLCI ; i++) +if (gsm->dlci[i]) +tty_port_tty_wakeup (&gsm->dlci[i]->port); +} +/** * gsmld_attach_gsm - mode set up * @tty: our tty structure
@@ -2794,6 +2951,7 @@ static int gsmld_open(struct tty_struct *tty)timer_setup (&gsm->kick_timer, gsm_kick_timer,0 );timer_setup (&gsm->t2_timer, gsm_control_retransmit,0 ); +INIT_WORK (&gsm->tx_work, gsmld_write_task);return 0 ; }
@@ -2810,16 +2968,9 @@ static int gsmld_open(struct tty_struct *tty)static void gsmld_write_wakeup (struct tty_struct *tty) {struct gsm_mux *gsm = tty->disc_data; -unsigned long flags;/* Queue poll */ -clear_bit (TTY_DO_WRITE_WAKEUP , &tty->flags); -spin_lock_irqsave (&gsm->tx_lock, flags); -gsm_data_kick (gsm,NULL ); -if (gsm->tx_bytes <TX_THRESH_LO ) { -gsm_dlci_data_sweep (gsm); - } -spin_unlock_irqrestore (&gsm->tx_lock, flags); +gsmld_write_trigger (gsm); }/**
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 862/1095 tty: n_gsm: fix resource allocation order in gsm_activate_mux()
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit 7349660438603ed19282e75949561406531785a5 ]
Within gsm_activate_mux() all timers and locks are initiated before the actual resource for the control channel is allocated. This can lead to race conditions.
Allocate the control channel DLCI object first to avoid race conditions.
--- drivers/tty/n_gsm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/tty/n_gsm.c +4 -3
@@ -2501,6 +2501,10 @@ static int gsm_activate_mux(struct gsm_mux *gsm)struct gsm_dlci *dlci;int ret; + dlci =gsm_dlci_alloc (gsm,0 ); +if (dlci ==NULL ) +return -ENOMEM ; +timer_setup (&gsm->kick_timer, gsm_kick_timer,0 );timer_setup (&gsm->t2_timer, gsm_control_retransmit,0 );INIT_WORK (&gsm->tx_work, gsmld_write_task);
@@ -2517,9 +2521,6 @@ static int gsm_activate_mux(struct gsm_mux *gsm)if (ret)return ret; - dlci =gsm_dlci_alloc (gsm,0 ); -if (dlci ==NULL ) -return -ENOMEM ; gsm->has_devices = true; gsm->dead = false;/* Tty opens are now permissible */ return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 863/1095 ASoC: qcom: Fix missing of_node_put() in asoc_qcom_lpass_cpu_platform_probe()
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit f507c0c67dac57d2bcd5dcae4b6139b0305d8957 ]
We should call of_node_put() for the reference 'dsp_of_node' returned by of_parse_phandle() which will increase the refcount.
--- sound/soc/qcom/lpass-cpu.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/qcom/lpass-cpu.c +1 -0
@@ -1090,6 +1090,7 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev) dsp_of_node =of_parse_phandle (pdev->dev.of_node,"qcom,adsp" ,0 );if (dsp_of_node) {dev_err (dev,"DSP exists and holds audio resources\n" ); +of_node_put (dsp_of_node);return -EBUSY ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 864/1095 MIPS: Loongson64: Fix section mismatch warning
In reply to Greg Kroah-HartmanFrom: Tiezhu Yang <[email protected]>
[ Upstream commit 08472f6ebdc23334ad11dcd761d2d52c32897793 ]
prom_init_numa_memory() is annotated __init and not used by any module, thus don't export it.
Remove not needed EXPORT_SYMBOL for prom_init_numa_memory() to fix the following section mismatch warning:
LD vmlinux.o
MODPOST vmlinux.symvers
WARNING: modpost: vmlinux.o(___ksymtab+prom_init_numa_memory+0x0): Section mismatch in reference from the variable __ksymtab_prom_init_numa_memory to the function .init.text:prom_init_numa_memory() The symbol prom_init_numa_memory is exported and annotated __init
Fix this by removing the __init annotation of prom_init_numa_memory or drop the export.
This is build on Linux 5.19-rc4.
--- arch/mips/loongson64/numa.c | 1 - 1 file changed, 1 deletion(-)
arch/mips/loongson64/numa.c +0 -1
@@ -196,7 +196,6 @@ void __init prom_init_numa_memory(void)pr_info ("CP0_PageGrain: CP0 5.1 (0x%x)\n" ,read_c0_pagegrain ());prom_meminit (); } -EXPORT_SYMBOL (prom_init_numa_memory);pg_data_t *__init arch_alloc_nodedata (int nid) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 865/1095 ASoC: imx-card: Fix DSD/PDM mclk frequency
In reply to Greg Kroah-HartmanFrom: Shengjiu Wang <[email protected]>
[ Upstream commit c0fabd12a8570cb932f13d9388f3d887ad44369b ]
The DSD/PDM rate not only DSD64/128/256/512, which are the multiple rate of 44.1kHz, but also support the multiple rate of 8kHz, so can't force all mclk frequency to be 22579200Hz, need to assign the frequency according to rate.
--- sound/soc/fsl/imx-card.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
sound/soc/fsl/imx-card.c +11 -3
@@ -17,6 +17,9 @@#include "fsl_sai.h" +#define IMX_CARD_MCLK_22P5792MHZ 22579200 +#define IMX_CARD_MCLK_24P576MHZ 24576000 +enum codec_type {CODEC_DUMMY =0 ,CODEC_AK5558 =1 ,
@@ -353,9 +356,14 @@ static int imx_aif_hw_params(struct snd_pcm_substream *substream, mclk_freq =akcodec_get_mclk_rate (substream, params, slots, slot_width); else mclk_freq =params_rate (params) * slots * slot_width; -/* Use the maximum freq from DSD512 (512*44100 = 22579200) */ -if (format_is_dsd (params)) - mclk_freq =22579200 ; + +if (format_is_dsd (params)) { +/* Use the maximum freq from DSD512 (512*44100 = 22579200) */ +if (!(params_rate (params) %11025 )) + mclk_freq =IMX_CARD_MCLK_22P5792MHZ ; +else + mclk_freq =IMX_CARD_MCLK_24P576MHZ ; + } ret =snd_soc_dai_set_sysclk (cpu_dai, link_data->cpu_sysclk_id, mclk_freq,SND_SOC_CLOCK_OUT );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 866/1095 remoteproc: qcom: wcnss: Fix handling of IRQs
In reply to Greg Kroah-HartmanFrom: Sireesh Kodali <[email protected]>
[ Upstream commit bed0adac1ded4cb486ba19a3a7e730fbd9a1c9c6 ]
The wcnss_get_irq function is expected to return a value > 0 in the event that an IRQ is succssfully obtained, but it instead returns 0. This causes the stop and ready IRQs to never actually be used despite being defined in the device-tree. This patch fixes that.
--- drivers/remoteproc/qcom_wcnss.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/remoteproc/qcom_wcnss.c +8 -2
@@ -467,6 +467,7 @@ static int wcnss_request_irq(struct qcom_wcnss *wcnss, irq_handler_t thread_fn) {int ret; +int irq_number; ret =platform_get_irq_byname (pdev, name);if (ret <0 && optional) {
@@ -477,14 +478,19 @@ static int wcnss_request_irq(struct qcom_wcnss *wcnss,return ret; } + irq_number = ret; + ret =devm_request_threaded_irq (&pdev->dev, ret,NULL , thread_fn,IRQF_TRIGGER_RISING |IRQF_ONESHOT ,"wcnss" , wcnss); -if (ret) +if (ret) {dev_err (&pdev->dev,"request %s IRQ failed\n" , name); +return ret; + } -return ret; +/* Return the IRQ number if the IRQ was successfully acquired */ +return irq_number; }static int wcnss_alloc_memory_region (struct qcom_wcnss *wcnss)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 867/1095 vfio/ccw: Fix FSM state if mdev probe fails
In reply to Greg Kroah-HartmanFrom: Eric Farman <[email protected]>
[ Upstream commit f6c876d67e956de8d69349b0ee43bc7277c09e5c ]
The FSM is in STANDBY state when arriving in vfio_ccw_mdev_probe(), and this routine converts it to IDLE as part of its processing. The error exit sets it to IDLE (again) but clears the private->mdev pointer.
The FSM should of course be managing the state itself, but the correct thing for vfio_ccw_mdev_probe() to do would be to put the state back the way it found it.
The corresponding check of private->mdev in vfio_ccw_sch_io_todo() can be removed, since the distinction is unnecessary at this point.
--- drivers/s390/cio/vfio_ccw_drv.c | 5 +++-- drivers/s390/cio/vfio_ccw_ops.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/s390/cio/vfio_ccw_drv.c +3 -2
@@ -107,9 +107,10 @@ static void vfio_ccw_sch_io_todo(struct work_struct *work)/* * Reset to IDLE only if processing of a channel program * has finished. Do not overwrite a possible processing -* state if the final interrupt was for HSCH or CSCH. +* state if the interrupt was unsolicited, or if the final +* interrupt was for HSCH or CSCH. */ -if (private->mdev && cp_is_finished) +if (cp_is_finished) private->state =VFIO_CCW_STATE_IDLE ;if (private->io_trigger)
drivers/s390/cio/vfio_ccw_ops.c +1 -1
@@ -146,7 +146,7 @@ static int vfio_ccw_mdev_probe(struct mdev_device *mdev)vfio_uninit_group_dev (&private->vdev);atomic_inc (&private->avail); private->mdev =NULL ; - private->state =VFIO_CCW_STATE_IDLE ; + private->state =VFIO_CCW_STATE_STANDBY ;return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 868/1095 vfio/ccw: Do not change FSM state in subchannel event
In reply to Greg Kroah-HartmanFrom: Eric Farman <[email protected]>
[ Upstream commit cffcc109fd682075dee79bade3d60a07152a8fd1 ]
The routine vfio_ccw_sch_event() is tasked with handling subchannel events, specifically machine checks, on behalf of vfio-ccw. It correctly calls cio_update_schib(), and if that fails (meaning the subchannel is gone) it makes an FSM event call to mark the subchannel Not Operational.
If that worked, however, then it decides that if the FSM state was already Not Operational (implying the subchannel just came back), then it should simply change the FSM to partially- or fully-open.
Remove this trickery, since a subchannel returning will require more probing than simply "oh all is well again" to ensure it works correctly.
--- drivers/s390/cio/vfio_ccw_drv.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/s390/cio/vfio_ccw_drv.c +3 -11
@@ -302,19 +302,11 @@ static int vfio_ccw_sch_event(struct subchannel *sch, int process)if (work_pending (&sch->todo_work)) goto out_unlock; -if (cio_update_schib (sch)) { -vfio_ccw_fsm_event (private,VFIO_CCW_EVENT_NOT_OPER ); - rc =0 ; - goto out_unlock; - } - - private =dev_get_drvdata (&sch->dev); -if (private->state ==VFIO_CCW_STATE_NOT_OPER ) { - private->state = private->mdev ?VFIO_CCW_STATE_IDLE : -VFIO_CCW_STATE_STANDBY ; - } rc =0 ; +if (cio_update_schib (sch)) +vfio_ccw_fsm_event (private,VFIO_CCW_EVENT_NOT_OPER ); + out_unlock:spin_unlock_irqrestore (sch->lock, flags);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 869/1095 ASoC: audio-graph-card2.c: use of_property_read_u32() for rate
In reply to Greg Kroah-HartmanFrom: Kuninori Morimoto <[email protected]>
[ Upstream commit 817a62108dfacebd548e38451bf0e7eee023e97f ]
Audio Graph Card2 is using of_get_property(), but it should use of_property_read_u32() to getting rate. Otherwise the setting will be strange value. This patch fixup it.
--- sound/soc/generic/audio-graph-card2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/soc/generic/audio-graph-card2.c +3 -2
@@ -856,7 +856,7 @@ int audio_graph2_link_c2c(struct asoc_simple_priv *priv,struct device_node *port0, *port1, *ports;struct device_node *codec0_port, *codec1_port;struct device_node *ep0, *ep1; -u32 val; +u32 val =0 ;int ret = -EINVAL ;/*
@@ -880,7 +880,8 @@ int audio_graph2_link_c2c(struct asoc_simple_priv *priv, ports =of_get_parent (port0); port1 =of_get_next_child (ports, lnk); -if (!of_get_property (ports,"rate" , &val)) { +of_property_read_u32 (ports,"rate" , &val); +if (!val) {struct device *dev =simple_priv_to_dev (priv);dev_err (dev,"Codec2Codec needs rate settings\n" );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 870/1095 serial: 8250_fsl: Dont report FE, PE and OE twice
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 9d3aaceb73acadf134596a2f8db9c451c1332d3d ]
Some Freescale 8250 implementations have the problem that a single long break results in one irq per character frame time. The code in fsl8250_handle_irq() that is supposed to handle that uses the BI bit in lsr_saved_flags to detect such a situation and then skip the second received character. However it also stores other error bits and so after a single frame error the character received in the next irq handling is passed to the upper layer with a frame error, too.
So after a spike on the data line (which is correctly recognized as a frame error) the following valid character is thrown away, because the driver reports a frame error for that one, too.
To weaken this problem restrict saving LSR to only the BI bit.
Note however that the handling is still broken:
- lsr_saved_flags is updated using orig_lsr which is the LSR content for the first received char, but there might be more in the FIFO, so a character is thrown away that is received later and not necessarily the one following the break.
- The doubled break might be the 2nd and 3rd char in the FIFO, so the workaround doesn't catch these, because serial8250_rx_chars() doesn't handle the workaround.
- lsr_saved_flags might have set UART_LSR_BI at the entry of fsl8250_handle_irq() which doesn't originate from fsl8250_handle_irq()'s "up->lsr_saved_flags |= orig_lsr & UART_LSR_BI;" but from e.g. from serial8250_tx_empty().
- For a long or a short break this isn't about two characters, but more or only a single one.
--- drivers/tty/serial/8250/8250_fsl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/8250/8250_fsl.c +1 -1
@@ -77,7 +77,7 @@ int fsl8250_handle_irq(struct uart_port *port)if ((lsr &UART_LSR_THRE ) && (up->ier &UART_IER_THRI ))serial8250_tx_chars (up); - up->lsr_saved_flags = orig_lsr; + up->lsr_saved_flags |= orig_lsr &UART_LSR_BI ;uart_unlock_and_check_sysrq_irqrestore (&up->port, flags);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 871/1095 tty: n_gsm: fix wrong T1 retry count handling
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit f30e10caa80aa1f35508bc17fc302dbbde9a833c ]
n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010.
See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1516
The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to
the newer 27.010 here. Chapter 5.7.3 states that the valid range for the
maximum number of retransmissions (N2) is from 0 to 255 (both including).gsm_dlci_t1() handles this number incorrectly by performing N2 - 1
retransmission attempts. Setting N2 to zero results in more than 255
retransmission attempts.
Fix gsm_dlci_t1() to comply with 3GPP 27.010.
--- drivers/tty/n_gsm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/n_gsm.c +2 -2
@@ -1805,8 +1805,8 @@ static void gsm_dlci_t1(struct timer_list *t)switch (dlci->state) {case DLCI_OPENING : - dlci->retries--;if (dlci->retries) { + dlci->retries--;gsm_command (dlci->gsm, dlci->addr,SABM |PF );mod_timer (&dlci->t1, jiffies + gsm->t1 *HZ /100 ); }else if (!dlci->addr && gsm->control == (DM |PF )) {
@@ -1821,8 +1821,8 @@ static void gsm_dlci_t1(struct timer_list *t)break ;case DLCI_CLOSING : - dlci->retries--;if (dlci->retries) { + dlci->retries--;gsm_command (dlci->gsm, dlci->addr,DISC |PF );mod_timer (&dlci->t1, jiffies + gsm->t1 *HZ /100 ); }else
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 872/1095 tty: n_gsm: fix DM command
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit 18a948c7d90995d127785e308fa7b701df4c499f ]
n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010.
See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1516
The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to
the newer 27.010 here. Chapter 5.3.3 defines the DM response. There exists
no DM command. However, the current implementation incorrectly sends DM as
command in case of unexpected UIH frames in gsm_queue().
Correct this behavior by always sending DM as response.
--- drivers/tty/n_gsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/n_gsm.c +1 -1
@@ -2211,7 +2211,7 @@ static void gsm_queue(struct gsm_mux *gsm) goto invalid;#endif if (dlci ==NULL || dlci->state !=DLCI_OPEN ) { -gsm_command (gsm, address,DM |PF ); +gsm_response (gsm, address,DM |PF );return ; } dlci->data (dlci, gsm->buf, gsm->len);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 873/1095 tty: n_gsm: fix flow control handling in tx path
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit 59ff0680ecbfec742b1e0381e7cc46b41eb06647 ]
The current implementation constipates all transmission paths during flow control except for flow control frames. However, these may not be located at the beginning of the transmission queue of the control channel. Ensure that flow control frames in the transmission queue for the control channel are always handled even if constipated by skipping through other messages.
--- drivers/tty/n_gsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/n_gsm.c +1 -1
@@ -891,7 +891,7 @@ static int gsm_data_kick(struct gsm_mux *gsm)/* Serialize control messages and control channel messages first */ list_for_each_entry_safe (msg, nmsg, &gsm->tx_ctrl_list, list) {if (gsm->constipated && !gsm_is_flow_ctrl_msg (msg)) -return -EAGAIN ; +continue ; ret =gsm_send_packet (gsm, msg);switch (ret) {case -ENOSPC :
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 874/1095 tty: n_gsm: fix missing corner cases in gsmld_poll()
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit 7e5b4322cde067e1d0f1bf8f490e93f664a7c843 ]
gsmld_poll() currently fails to handle the following corner cases correctly:
- remote party closed the associated tty
Add the missing checks and map those to EPOLLHUP. Reorder the checks to group them by their reaction.
--- drivers/tty/n_gsm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/tty/n_gsm.c +5 -2
@@ -3057,12 +3057,15 @@ static __poll_t gsmld_poll(struct tty_struct *tty, struct file *file,poll_wait (file, &tty->read_wait, wait);poll_wait (file, &tty->write_wait, wait); + +if (gsm->dead) + mask |=EPOLLHUP ;if (tty_hung_up_p (file)) mask |=EPOLLHUP ; +if (test_bit (TTY_OTHER_CLOSED , &tty->flags)) + mask |=EPOLLHUP ;if (!tty_is_writelocked (tty) &&tty_write_room (tty) >0 ) mask |=EPOLLOUT |EPOLLWRNORM ; -if (gsm->dead) - mask |=EPOLLHUP ;return mask; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 875/1095 MIPS: vdso: Utilize __pa() for gic_pfn
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit 8baa65126e19af5ee9f3c07e7bb53da41c39e4b1 ]
The GIC user offset is mapped into every process' virtual address and is therefore part of the hot-path of arch_setup_additional_pages(). Utilize __pa() such that we are more optimal even when CONFIG_DEBUG_VIRTUAL is enabled, and while at it utilize PFN_DOWN() instead of open-coding the right shift by PAGE_SHIFT.
--- arch/mips/kernel/vdso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/vdso.c +1 -1
@@ -159,7 +159,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)/* Map GIC user page. */ if (gic_size) { gic_base = (unsigned long )mips_gic_base +MIPS_GIC_USER_OFS ; - gic_pfn =virt_to_phys ((void *)gic_base) >>PAGE_SHIFT ; + gic_pfn =PFN_DOWN (__pa (gic_base)); ret =io_remap_pfn_range (vma, base, gic_pfn, gic_size,pgprot_noncached (vma->vm_page_prot));
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 876/1095 ASoC: SOF: mediatek: fix mt8195 StatvectorSel wrong setting
In reply to Greg Kroah-HartmanFrom: YC Hung <[email protected]>
[ Upstream commit 99bad468846f7a255dcfc95454401c83ae02e89b ]
Fix StatVectorSel wrong setting.
--- sound/soc/sof/mediatek/mt8195/mt8195-loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sof/mediatek/mt8195/mt8195-loader.c +1 -1
@@ -21,7 +21,7 @@ void sof_hifixdsp_boot_sequence(struct snd_sof_dev *sdev, u32 boot_addr)/* pull high StatVectorSel to use AltResetVec (set bit4 to 1) */ snd_sof_dsp_update_bits (sdev,DSP_REG_BAR ,DSP_RESET_SW , -DSP_RESET_SW ,DSP_RESET_SW ); +STATVECTOR_SEL ,STATVECTOR_SEL );/* toggle DReset & BReset */ /* pull high DReset & BReset */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 877/1095 swiotlb: fail map correctly with failed io_tlb_default_mem
In reply to Greg Kroah-HartmanFrom: Robin Murphy <[email protected]>
[ Upstream commit c51ba246cb172c9e947dc6fb8868a1eaf0b2a913 ]
In the failure case of trying to use a buffer which we'd previously failed to allocate, the "!mem" condition is no longer sufficient since io_tlb_default_mem became static and assigned by default. Update the condition to work as intended per the rest of that conversion.
--- kernel/dma/swiotlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/dma/swiotlb.c +1 -1
@@ -588,7 +588,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *dev, phys_addr_t orig_addr,int index;phys_addr_t tlb_addr; -if (!mem) +if (!mem || !mem->nslabs)panic ("Can not allocate SWIOTLB buffer earlier and can't now provide you with the DMA bounce buffer" );if (cc_platform_has (CC_ATTR_MEM_ENCRYPT ))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 878/1095 ASoC: SOF: ipc3-topology: Prevent double freeing of ipc_control_data via load_bytes
In reply to Greg Kroah-HartmanFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit d5bd47f3ca124058a8e87eae4508afeda2132611 ]
We have sanity checks for byte controls and if any of the fail the locally allocated scontrol->ipc_control_data is freed up, but not set to NULL.
On a rollback path of the error the higher level code will also try to free the scontrol->ipc_control_data which will eventually going to lead to memory corruption as double freeing memory is not a good thing.
--- sound/soc/sof/ipc3-topology.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/sof/ipc3-topology.c +1 -0
@@ -1629,6 +1629,7 @@ static int sof_ipc3_control_load_bytes(struct snd_sof_dev *sdev, struct snd_sof_return 0 ; err:kfree (scontrol->ipc_control_data); + scontrol->ipc_control_data =NULL ;return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 879/1095 ASoc: audio-graph-card2: Fix refcount leak bug in __graph_get_type()
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit eda26893dabfc6da7a1e1ff5f8628ed9faab3ab9 ]
We should call of_node_put() for the reference before its replacement as it returned by of_get_parent() which has increased the refcount. Besides, we should also call of_node_put() before return.
--- sound/soc/generic/audio-graph-card2.c | 35 +++++++++++++++++++-------- 1 file changed, 25 insertions(+), 10 deletions(-)
sound/soc/generic/audio-graph-card2.c +25 -10
@@ -229,7 +229,8 @@ enum graph_type {static enum graph_type __graph_get_type (struct device_node *lnk) { -struct device_node *np; +struct device_node *np, *parent_np; +enum graph_type ret;/* * target {
@@ -240,19 +241,33 @@ static enum graph_type __graph_get_type(struct device_node *lnk)* }; */ np =of_get_parent (lnk); -if (of_node_name_eq (np,"ports" )) - np =of_get_parent (np); +if (of_node_name_eq (np,"ports" )) { + parent_np =of_get_parent (np); +of_node_put (np); + np = parent_np; + } -if (of_node_name_eq (np,GRAPH_NODENAME_MULTI )) -return GRAPH_MULTI ; +if (of_node_name_eq (np,GRAPH_NODENAME_MULTI )) { + ret =GRAPH_MULTI ; + goto out_put; + } -if (of_node_name_eq (np,GRAPH_NODENAME_DPCM )) -return GRAPH_DPCM ; +if (of_node_name_eq (np,GRAPH_NODENAME_DPCM )) { + ret =GRAPH_DPCM ; + goto out_put; + } -if (of_node_name_eq (np,GRAPH_NODENAME_C2C )) -return GRAPH_C2C ; +if (of_node_name_eq (np,GRAPH_NODENAME_C2C )) { + ret =GRAPH_C2C ; + goto out_put; + } + + ret =GRAPH_NORMAL ; + +out_put: +of_node_put (np); +return ret; -return GRAPH_NORMAL ; } static enum graph_type graph_get_type(struct asoc_simple_priv *priv,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 880/1095 ASoC: mt6359: Fix refcount leak bug
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit a8d5df69e2ec702d979f7d04ed519caf8691a032 ]
In mt6359_parse_dt() and mt6359_accdet_parse_dt(), we should call of_node_put() for the reference returned by of_get_child_by_name() which has increased the refcount.
--- sound/soc/codecs/mt6359-accdet.c | 1 + sound/soc/codecs/mt6359.c | 1 + 2 files changed, 2 insertions(+)
sound/soc/codecs/mt6359-accdet.c +1 -0
@@ -675,6 +675,7 @@ static int mt6359_accdet_parse_dt(struct mt6359_accdet *priv) sizeof(struct three_key_threshold)); } +of_node_put (node);dev_warn (priv->dev,"accdet caps=%x\n" , priv->caps);return 0 ;
sound/soc/codecs/mt6359.c +1 -0
@@ -2780,6 +2780,7 @@ static int mt6359_parse_dt(struct mt6359_priv *priv) ret =of_property_read_u32 (np,"mediatek,mic-type-2" , &priv->mux_select[MUX_MIC_TYPE_2 ]); +of_node_put (np);if (ret) { dev_info(priv->dev, "%s() failed to read mic-type-2, use default (%d)\n",
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 881/1095 serial: 8250_bcm7271: Save/restore RTS in suspend/resume
In reply to Greg Kroah-HartmanFrom: Doug Berger <[email protected]>
[ Upstream commit 3182efd036c1b955403d131258234896cbd9fbeb ]
Commit 9cabe26e65a8 ("serial: 8250_bcm7271: UART errors after resuming from S2") prevented an early enabling of RTS during resume, but it did not actively restore the RTS state after resume.
--- drivers/tty/serial/8250/8250_bcm7271.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/tty/serial/8250/8250_bcm7271.c +18 -6
@@ -1139,16 +1139,19 @@ static int __maybe_unused brcmuart_suspend(struct device *dev)struct brcmuart_priv *priv =dev_get_drvdata (dev);struct uart_8250_port *up =serial8250_get_port (priv->line);struct uart_port *port = &up->port; - -serial8250_suspend_port (priv->line); -clk_disable_unprepare (priv->baud_mux_clk); +unsigned long flags;/* * This will prevent resume from enabling RTS before the -* baud rate has been resored. +* baud rate has been restored. */ +spin_lock_irqsave (&port->lock, flags); priv->saved_mctrl = port->mctrl; - port->mctrl =0 ; + port->mctrl &= ~TIOCM_RTS ; +spin_unlock_irqrestore (&port->lock, flags); + +serial8250_suspend_port (priv->line); +clk_disable_unprepare (priv->baud_mux_clk);return 0 ; }
@@ -1158,6 +1161,7 @@ static int __maybe_unused brcmuart_resume(struct device *dev)struct brcmuart_priv *priv =dev_get_drvdata (dev);struct uart_8250_port *up =serial8250_get_port (priv->line);struct uart_port *port = &up->port; +unsigned long flags;int ret; ret =clk_prepare_enable (priv->baud_mux_clk);
@@ -1180,7 +1184,15 @@ static int __maybe_unused brcmuart_resume(struct device *dev)start_rx_dma (serial8250_get_port (priv->line)); }serial8250_resume_port (priv->line); - port->mctrl = priv->saved_mctrl; + +if (priv->saved_mctrl &TIOCM_RTS ) { +/* Restore RTS */ +spin_lock_irqsave (&port->lock, flags); + port->mctrl |=TIOCM_RTS ; + port->ops->set_mctrl (port, port->mctrl); +spin_unlock_irqrestore (&port->lock, flags); + } +return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 882/1095 iommu/exynos: Handle failed IOMMU device registration properly
In reply to Greg Kroah-HartmanFrom: Sam Protsenko <[email protected]>
[ Upstream commit fce398d2d02c0a9a2bedf7c7201b123e153e8963 ]
If iommu_device_register() fails in exynos_sysmmu_probe(), the previous calls have to be cleaned up. In this case, the iommu_device_sysfs_add() should be cleaned up, by calling its remove counterpart call.
--- drivers/iommu/exynos-iommu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iommu/exynos-iommu.c +5 -1
@@ -630,7 +630,7 @@ static int exynos_sysmmu_probe(struct platform_device *pdev) ret =iommu_device_register (&data->iommu, &exynos_iommu_ops, dev);if (ret) -return ret; + goto err_iommu_register;platform_set_drvdata (pdev, data);
@@ -657,6 +657,10 @@ static int exynos_sysmmu_probe(struct platform_device *pdev)pm_runtime_enable (dev);return 0 ; + +err_iommu_register: +iommu_device_sysfs_remove (&data->iommu); +return ret; }static int __maybe_unused exynos_sysmmu_suspend (struct device *dev)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 883/1095 9p: Drop kref usage
In reply to Greg Kroah-HartmanFrom: Kent Overstreet <[email protected]>
[ Upstream commit 6cda12864cb0f99810a5809e11e3ee5b102c9a47 ]
An upcoming patch is going to require passing the client through p9_req_put() -> p9_req_free(), but that's awkward with the kref indirection - so this patch switches to using refcount_t directly.
--- include/net/9p/client.h | 6 +++--- net/9p/client.c | 19 ++++++++----------- 2 files changed, 11 insertions(+), 14 deletions(-)
include/net/9p/client.h +3 -3
@@ -76,7 +76,7 @@ enum p9_req_status_t {struct p9_req_t {int status;int t_err; -struct kref refcount; +refcount_t refcount;wait_queue_head_t wq;struct p9_fcall tc;struct p9_fcall rc;
@@ -227,12 +227,12 @@ struct p9_req_t *p9_tag_lookup(struct p9_client *c, u16 tag);static inline void p9_req_get (struct p9_req_t *r) { -kref_get (&r->refcount); +refcount_inc (&r->refcount); }static inline int p9_req_try_get (struct p9_req_t *r) { -return kref_get_unless_zero (&r->refcount); +return refcount_inc_not_zero (&r->refcount); }int p9_req_put (struct p9_req_t *r);
net/9p/client.c +8 -11
@@ -305,7 +305,7 @@ p9_tag_alloc(struct p9_client *c, int8_t type, unsigned int max_size)* callback), so p9_client_cb eats the second ref there * as the pointer is duplicated directly by virtqueue_add_sgs() */ -refcount_set (&req->refcount.refcount,2 ); +refcount_set (&req->refcount,2 );return req;
@@ -370,18 +370,15 @@ static int p9_tag_remove(struct p9_client *c, struct p9_req_t *r)return p9_req_put (r); } -static void p9_req_free (struct kref *ref) -{ - struct p9_req_t *r = container_of(ref, struct p9_req_t, refcount); - -p9_fcall_fini (&r->tc); -p9_fcall_fini (&r->rc); -kmem_cache_free (p9_req_cache, r); -} -int p9_req_put (struct p9_req_t *r) { -return kref_put (&r->refcount, p9_req_free); +if (refcount_dec_and_test (&r->refcount)) { +p9_fcall_fini (&r->tc); +p9_fcall_fini (&r->rc); +kmem_cache_free (p9_req_cache, r); +return 1 ; + } +return 0 ; }EXPORT_SYMBOL (p9_req_put);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 884/1095 9p: Add client parameter to p9_req_put()
In reply to Greg Kroah-HartmanFrom: Kent Overstreet <[email protected]>
[ Upstream commit 8b11ff098af42b1fa57fc817daadd53c8b244a0c ]
This is to aid in adding mempools, in the next patch.
--- include/net/9p/client.h | 2 +- net/9p/client.c | 12 ++++++------ net/9p/trans_fd.c | 12 ++++++------ net/9p/trans_rdma.c | 2 +- net/9p/trans_virtio.c | 4 ++-- net/9p/trans_xen.c | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-)
include/net/9p/client.h +1 -1
@@ -235,7 +235,7 @@ static inline int p9_req_try_get(struct p9_req_t *r)return refcount_inc_not_zero (&r->refcount); } -int p9_req_put (struct p9_req_t *r); +int p9_req_put (struct p9_client *c,struct p9_req_t *r);void p9_client_cb (struct p9_client *c,struct p9_req_t *req,int status);
net/9p/client.c +6 -6
@@ -341,7 +341,7 @@ struct p9_req_t *p9_tag_lookup(struct p9_client *c, u16 tag)if (!p9_req_try_get (req)) goto again;if (req->tc.tag != tag) { -p9_req_put (req); +p9_req_put (c, req); goto again; } }
@@ -367,10 +367,10 @@ static int p9_tag_remove(struct p9_client *c, struct p9_req_t *r)spin_lock_irqsave (&c->lock, flags);idr_remove (&c->reqs, tag);spin_unlock_irqrestore (&c->lock, flags); -return p9_req_put (r); +return p9_req_put (c, r); } -int p9_req_put (struct p9_req_t *r) +int p9_req_put (struct p9_client *c,struct p9_req_t *r) {if (refcount_dec_and_test (&r->refcount)) {p9_fcall_fini (&r->tc);
@@ -423,7 +423,7 @@ void p9_client_cb(struct p9_client *c, struct p9_req_t *req, int status)wake_up (&req->wq);p9_debug (P9_DEBUG_MUX ,"wakeup: %d\n" , req->tc.tag); -p9_req_put (req); +p9_req_put (c, req); }EXPORT_SYMBOL (p9_client_cb);
@@ -706,7 +706,7 @@ static struct p9_req_t *p9_client_prepare_req(struct p9_client *c, reterr:p9_tag_remove (c, req);/* We have to put also the 2nd reference as it won't be used */ -p9_req_put (req); +p9_req_put (c, req);return ERR_PTR (err); }
@@ -743,7 +743,7 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...) err = c->trans_mod->request (c, req);if (err <0 ) {/* write won't happen */ -p9_req_put (req); +p9_req_put (c, req);if (err != -ERESTARTSYS && err != -EFAULT ) c->status = Disconnected; goto recalc_sigpending;
net/9p/trans_fd.c +6 -6
@@ -378,7 +378,7 @@ static void p9_read_work(struct work_struct *work) m->rc.sdata =NULL ; m->rc.offset =0 ; m->rc.capacity =0 ; -p9_req_put (m->rreq); +p9_req_put (m->client, m->rreq); m->rreq =NULL ; }
@@ -492,7 +492,7 @@ static void p9_write_work(struct work_struct *work) m->wpos += err;if (m->wpos == m->wsize) { m->wpos = m->wsize =0 ; -p9_req_put (m->wreq); +p9_req_put (m->client, m->wreq); m->wreq =NULL ; }
@@ -695,7 +695,7 @@ static int p9_fd_cancel(struct p9_client *client, struct p9_req_t *req)if (req->status ==REQ_STATUS_UNSENT ) {list_del (&req->req_list); req->status =REQ_STATUS_FLSHD ; -p9_req_put (req); +p9_req_put (client, req); ret =0 ; }spin_unlock (&client->lock);
@@ -722,7 +722,7 @@ static int p9_fd_cancelled(struct p9_client *client, struct p9_req_t *req)list_del (&req->req_list); req->status =REQ_STATUS_FLSHD ;spin_unlock (&client->lock); -p9_req_put (req); +p9_req_put (client, req);return 0 ; }
@@ -883,12 +883,12 @@ static void p9_conn_destroy(struct p9_conn *m)p9_mux_poll_stop (m);cancel_work_sync (&m->rq);if (m->rreq) { -p9_req_put (m->rreq); +p9_req_put (m->client, m->rreq); m->rreq =NULL ; }cancel_work_sync (&m->wq);if (m->wreq) { -p9_req_put (m->wreq); +p9_req_put (m->client, m->wreq); m->wreq =NULL ; }
net/9p/trans_rdma.c +1 -1
@@ -350,7 +350,7 @@ send_done(struct ib_cq *cq, struct ib_wc *wc) c->busa, c->req->tc.size, DMA_TO_DEVICE);up (&rdma->sq_sem); -p9_req_put (c->req); +p9_req_put (client, c->req);kfree (c); }
net/9p/trans_virtio.c +2 -2
@@ -199,7 +199,7 @@ static int p9_virtio_cancel(struct p9_client *client, struct p9_req_t *req)/* Reply won't come, so drop req ref */ static int p9_virtio_cancelled (struct p9_client *client,struct p9_req_t *req) { -p9_req_put (req); +p9_req_put (client, req);return 0 ; }
@@ -523,7 +523,7 @@ p9_virtio_zc_request(struct p9_client *client, struct p9_req_t *req,kvfree (out_pages);if (!kicked) {/* reply won't come */ -p9_req_put (req); +p9_req_put (client, req); }return err; }
net/9p/trans_xen.c +1 -1
@@ -163,7 +163,7 @@ static int p9_xen_request(struct p9_client *client, struct p9_req_t *p9_req) ring->intf->out_prod = prod;spin_unlock_irqrestore (&ring->lock, flags);notify_remote_via_irq (ring->irq); -p9_req_put (p9_req); +p9_req_put (client, p9_req);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 885/1095 net: 9p: fix refcount leak in p9_read_work() error handling
In reply to Greg Kroah-HartmanFrom: Hangyu Hua <[email protected]>
[ Upstream commit 4ac7573e1f9333073fa8d303acc941c9b7ab7f61 ]
p9_req_put need to be called when m->rreq->rc.sdata is NULL to avoid temporary refcount leak.
--- net/9p/trans_fd.c | 1 + 1 file changed, 1 insertion(+)
net/9p/trans_fd.c +1 -0
@@ -343,6 +343,7 @@ static void p9_read_work(struct work_struct *work)p9_debug (P9_DEBUG_ERROR ,"No recv fcall for tag %d (req %p), disconnecting!\n" , m->rc.tag, m->rreq); +p9_req_put (m->client, m->rreq); m->rreq =NULL ; err = -EIO ; goto error;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 886/1095 MIPS: Fixed __debug_virt_addr_valid()
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit 8a2b456665d1e797123669581524cbb095fb003b ]
It is permissible for kernel code to call virt_to_phys() against virtual addresses that are in KSEG0 or KSEG1 and we need to be dealing with both types. Rewrite the test condition to ensure that the kernel virtual addresses are above PAGE_OFFSET which they must be, and below KSEG2 where the non-linear mapping starts.
For EVA, there is not much that we can do given the linear address range that is offered, so just return any virtual address as being valid.
Finally, when HIGHMEM is not enabled, all virtual addresses are assumed to be valid as well.
--- arch/mips/mm/physaddr.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
arch/mips/mm/physaddr.c +4 -10
@@ -5,6 +5,7 @@#include <linux/mmdebug.h> #include <linux/mm.h> +#include <asm/addrspace.h> #include <asm/sections.h> #include <asm/io.h> #include <asm/page.h>
@@ -12,15 +13,6 @@static inline bool __debug_virt_addr_valid (unsigned long x) { -/* high_memory does not get immediately defined, and there -* are early callers of __pa() against PAGE_OFFSET -*/ -if (!high_memory && x >=PAGE_OFFSET ) -return true; - -if (high_memory && x >=PAGE_OFFSET && x < (unsigned long )high_memory) -return true; -/* * MAX_DMA_ADDRESS is a virtual address that may not correspond to an * actual physical address. Enough code relies on
@@ -30,7 +22,9 @@ static inline bool __debug_virt_addr_valid(unsigned long x)if (x ==MAX_DMA_ADDRESS )return true; -return false; +return x >=PAGE_OFFSET && (KSEGX (x) <KSEG2 || +IS_ENABLED (CONFIG_EVA ) || + !IS_ENABLED (CONFIG_HIGHMEM )); }phys_addr_t __virt_to_phys (volatile const void *x)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 887/1095 rpmsg: qcom_smd: Fix refcount leak in qcom_smd_parse_edge
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 65382585f067d4256ba087934f30f85c9b6984de ]
of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when done.
--- drivers/rpmsg/qcom_smd.c | 1 + 1 file changed, 1 insertion(+)
drivers/rpmsg/qcom_smd.c +1 -0
@@ -1383,6 +1383,7 @@ static int qcom_smd_parse_edge(struct device *dev, } edge->ipc_regmap =syscon_node_to_regmap (syscon_np); +of_node_put (syscon_np);if (IS_ERR (edge->ipc_regmap)) { ret =PTR_ERR (edge->ipc_regmap); goto put_node;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 888/1095 kfifo: fix kfifo_to_user() return type
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 045ed31e23aea840648c290dbde04797064960db ]
The kfifo_to_user() macro is supposed to return zero for success or negative error codes. Unfortunately, there is a signedness bug so it returns unsigned int. This only affects callers which try to save the result in ssize_t and as far as I can see the only place which does that is line6_hwdep_read().
TL;DR: s/_uint/_int/.
--- include/linux/kfifo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/kfifo.h +1 -1
@@ -688,7 +688,7 @@ __kfifo_uint_must_check_helper( \* writer, you don't need extra locking to use these macro. */ #define kfifo_to_user (fifo, to, len, copied) \ -__kfifo_uint_must_check_helper( \ +__kfifo_int_must_check_helper( \ ({ \ typeof((fifo) + 1) __tmp = (fifo); \ void __user *__to = (to); \
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 889/1095 lib/smp_processor_id: fix imbalanced instrumentation_end() call
In reply to Greg Kroah-HartmanFrom: Tetsuo Handa <[email protected]>
[ Upstream commit bd27acaac24e4b252ee28dddcabaee80456d0faf ]
Currently instrumentation_end() won't be called if printk_ratelimit() returned false.
--- lib/smp_processor_id.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/smp_processor_id.c +1 -1
@@ -47,9 +47,9 @@ unsigned int check_preemption_disabled(const char *what1, const char *what2)printk ("caller is %pS\n" ,__builtin_return_address (0 ));dump_stack (); -instrumentation_end (); out_enable: +instrumentation_end ();preempt_enable_no_resched_notrace (); out:return this_cpu;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 890/1095 proc: fix a dentry lock race between release_task and lookup
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
[ Upstream commit d919a1e79bac890421537cf02ae773007bf55e6b ]
Commit 7bc3e6e55acf06 ("proc: Use a list of inodes to flush from proc") moved proc_flush_task() behind __exit_signal(). Then, process systemd can take long period high cpu usage during releasing task in following concurrent processes:
systemd pskernel_waitid stat(/proc/tgid)
do_wait filename_lookup
wait_consider_task lookup_fast
release_task
__exit_signal
__unhash_process
detach_pid
__change_pid // remove task->pid_links
d_revalidate -> pid_revalidate // 0
d_invalidate(/proc/tgid)
shrink_dcache_parent(/proc/tgid)
d_walk(/proc/tgid)
spin_lock_nested(/proc/tgid/fd)
// iterating opened fd
proc_flush_pid |
d_invalidate (/proc/tgid/fd) |
shrink_dcache_parent(/proc/tgid/fd) |
shrink_dentry_list(subdirs) ↓
shrink_lock_dentry(/proc/tgid/fd) --> race on dentry lockFunction d_invalidate() will remove dentry from hash firstly, but why does proc_flush_pid() process dentry '/proc/tgid/fd' before dentry '/proc/tgid'? That's because proc_pid_make_inode() adds proc inode in reverse order by invoking hlist_add_head_rcu(). But proc should not add any inodes under '/proc/tgid' except '/proc/tgid/task/pid', fix it by adding inode into 'pid->inodes' only if the inode is /proc/tgid or /proc/tgid/task/pid.
Performance regression:
Create 200 tasks, each task open one file for 50,000 times. Kill all tasks when opened files exceed 10,000,000 (cat /proc/sys/fs/file-nr).
Before fix:
$ time killall -wq aa real 4m40.946s # During this period, we can see 'ps' and 'systemd' taking high cpu usage.
After fix:
$ time killall -wq aa real 1m20.732s # During this period, we can see 'systemd' taking high cpu usage.
--- fs/proc/base.c | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-)
fs/proc/base.c +38 -8
@@ -1885,7 +1885,7 @@ void proc_pid_evict_inode(struct proc_inode *ei)put_pid (pid); } -struct inode *proc_pid_make_inode (struct super_block * sb, +struct inode *proc_pid_make_inode (struct super_block *sb,struct task_struct *task,umode_t mode) {struct inode * inode;
@@ -1914,11 +1914,6 @@ struct inode *proc_pid_make_inode(struct super_block * sb,/* Let the pid remember us for quick removal */ ei->pid = pid; -if (S_ISDIR (mode)) { -spin_lock (&pid->lock); -hlist_add_head_rcu (&ei->sibling_inodes, &pid->inodes); -spin_unlock (&pid->lock); - }task_dump_owner (task,0 , &inode->i_uid, &inode->i_gid);security_task_to_inode (task, inode);
@@ -1931,6 +1926,39 @@ struct inode *proc_pid_make_inode(struct super_block * sb,return NULL ; } +/* +* Generating an inode and adding it into @pid->inodes, so that task will +* invalidate inode's dentry before being released. +* +* This helper is used for creating dir-type entries under '/proc' and +* '/proc/<tgid>/task'. Other entries(eg. fd, stat) under '/proc/<tgid>' +* can be released by invalidating '/proc/<tgid>' dentry. +* In theory, dentries under '/proc/<tgid>/task' can also be released by +* invalidating '/proc/<tgid>' dentry, we reserve it to handle single +* thread exiting situation: Any one of threads should invalidate its +* '/proc/<tgid>/task/<pid>' dentry before released. +*/ +static struct inode *proc_pid_make_base_inode (struct super_block *sb, +struct task_struct *task,umode_t mode) +{ +struct inode *inode; +struct proc_inode *ei; +struct pid *pid; + + inode =proc_pid_make_inode (sb, task, mode); +if (!inode) +return NULL ; + +/* Let proc_flush_pid find this directory inode */ + ei =PROC_I (inode); + pid = ei->pid; +spin_lock (&pid->lock); +hlist_add_head_rcu (&ei->sibling_inodes, &pid->inodes); +spin_unlock (&pid->lock); + +return inode; +} +int pid_getattr (struct user_namespace *mnt_userns,const struct path *path,struct kstat *stat,u32 request_mask,unsigned int query_flags) {
@@ -3350,7 +3378,8 @@ static struct dentry *proc_pid_instantiate(struct dentry * dentry, {struct inode *inode; - inode =proc_pid_make_inode (dentry->d_sb, task,S_IFDIR |S_IRUGO |S_IXUGO ); + inode =proc_pid_make_base_inode (dentry->d_sb, task, +S_IFDIR |S_IRUGO |S_IXUGO );if (!inode)return ERR_PTR (-ENOENT );
@@ -3649,7 +3678,8 @@ static struct dentry *proc_task_instantiate(struct dentry *dentry, struct task_struct *task, const void *ptr) { struct inode *inode; - inode =proc_pid_make_inode (dentry->d_sb, task,S_IFDIR |S_IRUGO |S_IXUGO ); + inode =proc_pid_make_base_inode (dentry->d_sb, task, +S_IFDIR |S_IRUGO |S_IXUGO );if (!inode)return ERR_PTR (-ENOENT );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 891/1095 remoteproc: qcom: pas: Check if coredump is enabled
In reply to Greg Kroah-HartmanFrom: Siddharth Gupta <[email protected]>
[ Upstream commit 7b6ece968fca4ec9e42d34caff7e06dc84c45717 ]
Client drivers need to check if coredump is enabled for the rproc before continuing with coredump generation. This change adds a check in the PAS driver.
--- drivers/remoteproc/qcom_q6v5_pas.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/remoteproc/qcom_q6v5_pas.c +3 -0
@@ -87,6 +87,9 @@ static void adsp_minidump(struct rproc *rproc) {struct qcom_adsp *adsp = rproc->priv; +if (rproc->dump_conf ==RPROC_COREDUMP_DISABLED ) +return ; +qcom_minidump (rproc, adsp->minidump_id); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 892/1095 remoteproc: sysmon: Wait for SSCTL service to come up
In reply to Greg Kroah-HartmanFrom: Sibi Sankar <[email protected]>
[ Upstream commit 47c04e00eff86a81cd357c3feed04c86089bcb85 ]
The SSCTL service comes up after a finite time when the remote Q6 comes out of reset. Any graceful shutdowns requested during this period will be a NOP and abrupt tearing down of the glink channel might lead to pending transactions on the remote Q6 side and will ultimately lead to a fatal error. Fix this by waiting for the SSCTL service when a graceful shutdown is requested.
--- drivers/remoteproc/qcom_sysmon.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/remoteproc/qcom_sysmon.c +10 -0
@@ -41,6 +41,7 @@ struct qcom_sysmon {struct completion comp;struct completion ind_comp;struct completion shutdown_comp; +struct completion ssctl_comp;struct mutex lock;bool ssr_ack;
@@ -445,6 +446,8 @@ static int ssctl_new_server(struct qmi_handle *qmi, struct qmi_service *svc) svc->priv = sysmon; +complete (&sysmon->ssctl_comp); +return 0 ; }
@@ -501,6 +504,7 @@ static int sysmon_start(struct rproc_subdev *subdev) .ssr_event = SSCTL_SSR_EVENT_AFTER_POWERUP }; +reinit_completion (&sysmon->ssctl_comp);mutex_lock (&sysmon->state_lock); sysmon->state =SSCTL_SSR_EVENT_AFTER_POWERUP ;blocking_notifier_call_chain (&sysmon_notifiers,0 , (void *)&event);
@@ -545,6 +549,11 @@ static void sysmon_stop(struct rproc_subdev *subdev, bool crashed)if (crashed)return ; +if (sysmon->ssctl_instance) { +if (!wait_for_completion_timeout (&sysmon->ssctl_comp,HZ /2 )) +dev_err (sysmon->dev,"timeout waiting for ssctl service\n" ); + } +if (sysmon->ssctl_version) sysmon->shutdown_acked =ssctl_request_shutdown (sysmon);else if (sysmon->ept)
@@ -631,6 +640,7 @@ struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc,init_completion (&sysmon->comp);init_completion (&sysmon->ind_comp);init_completion (&sysmon->shutdown_comp); +init_completion (&sysmon->ssctl_comp);mutex_init (&sysmon->lock);mutex_init (&sysmon->state_lock);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 893/1095 mfd: t7l66xb: Drop platform disable callback
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 128ac294e1b437cb8a7f2ff8ede1cde9082bddbe ]
None of the in-tree instantiations of struct t7l66xb_platform_data provides a disable callback. So better don't dereference this function pointer unconditionally. As there is no user, drop it completely instead of calling it conditional.
This is a preparation for making platform remove callbacks return void.
--- drivers/mfd/t7l66xb.c | 6 +----- include/linux/mfd/t7l66xb.h | 1 - 2 files changed, 1 insertion(+), 6 deletions(-)
drivers/mfd/t7l66xb.c +1 -5
@@ -397,11 +397,8 @@ static int t7l66xb_probe(struct platform_device *dev)static int t7l66xb_remove (struct platform_device *dev) { -struct t7l66xb_platform_data *pdata =dev_get_platdata (&dev->dev);struct t7l66xb *t7l66xb =platform_get_drvdata (dev); -int ret; - ret = pdata->disable (dev);clk_disable_unprepare (t7l66xb->clk48m);clk_put (t7l66xb->clk48m);clk_disable_unprepare (t7l66xb->clk32k);
@@ -412,8 +409,7 @@ static int t7l66xb_remove(struct platform_device *dev)mfd_remove_devices (&dev->dev);kfree (t7l66xb); -return ret; - +return 0 ; }static struct platform_driver t7l66xb_platform_driver = {
include/linux/mfd/t7l66xb.h +0 -1
@@ -12,7 +12,6 @@struct t7l66xb_platform_data {int (*enable)(struct platform_device *dev); -int (*disable)(struct platform_device *dev);int (*suspend)(struct platform_device *dev);int (*resume)(struct platform_device *dev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 894/1095 mfd: max77620: Fix refcount leak in max77620_initialise_fps
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 1520669c8255bd637c6b248b2be910e2688d38dd ]
of_get_child_by_name() 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.
--- drivers/mfd/max77620.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mfd/max77620.c +2 -0
@@ -419,9 +419,11 @@ static int max77620_initialise_fps(struct max77620_chip *chip) ret =max77620_config_fps (chip, fps_child);if (ret <0 ) {of_node_put (fps_child); +of_node_put (fps_np);return ret; } } +of_node_put (fps_np); config = chip->enable_global_lpm ?MAX77620_ONOFFCNFG2_SLP_LPM_MSK :0 ; ret = regmap_update_bits(chip->rmap, MAX77620_REG_ONOFFCNFG2,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 895/1095 iommu/arm-smmu: qcom_iommu: Add of_node_put() when breaking out of loop
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit a91eb6803c1c715738682fece095145cbd68fe0b ]
In qcom_iommu_has_secure_context(), we should call of_node_put() for the reference 'child' when breaking out of for_each_child_of_node() which will automatically increase and decrease the refcount.
--- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iommu/arm/arm-smmu/qcom_iommu.c +5 -2
@@ -750,9 +750,12 @@ static bool qcom_iommu_has_secure_context(struct qcom_iommu_dev *qcom_iommu) {struct device_node *child; -for_each_child_of_node (qcom_iommu->dev->of_node, child) -if (of_device_is_compatible (child,"qcom,msm-iommu-v1-sec" )) +for_each_child_of_node (qcom_iommu->dev->of_node, child) { +if (of_device_is_compatible (child,"qcom,msm-iommu-v1-sec" )) { +of_node_put (child);return true; + } + }return false; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 896/1095 perf tools: Fix dso_id inode generation comparison
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
[ Upstream commit 68566a7cf56bf3148797c218ed45a9de078ef47c ]
Synthesized MMAP events have zero ino_generation, so do not compare them to DSOs with a real ino_generation otherwise we end up with a DSO without a build id.
--- tools/perf/util/dsos.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
tools/perf/util/dsos.c +13 -2
@@ -23,8 +23,19 @@ static int __dso_id__cmp(struct dso_id *a, struct dso_id *b)if (a->ino > b->ino)return -1 ;if (a->ino < b->ino)return 1 ; -if (a->ino_generation > b->ino_generation)return -1 ; -if (a->ino_generation < b->ino_generation)return 1 ; +/* +* Synthesized MMAP events have zero ino_generation, avoid comparing +* them with MMAP events with actual ino_generation. +* +* I found it harmful because the mismatch resulted in a new +* dso that did not have a build ID whereas the original dso did have a +* build ID. The build ID was essential because the object was not found +* otherwise. - Adrian +*/ +if (a->ino_generation && b->ino_generation) { +if (a->ino_generation > b->ino_generation)return -1 ; +if (a->ino_generation < b->ino_generation)return 1 ; + }return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 897/1095 riscv: spinwait: Fix hartid variable type
In reply to Greg Kroah-HartmanFrom: Sunil V L <[email protected]>
[ Upstream commit c029e487e7c00e5594a4ae946952605db34e359b ]
The hartid variable is of type int but compared with ULONG_MAX(INVALID_HARTID). This issue is fixed by changing the hartid variable type to unsigned long.
--- arch/riscv/kernel/cpu_ops_spinwait.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/kernel/cpu_ops_spinwait.c +2 -2
@@ -20,7 +20,7 @@ void *__cpu_spinwait_task_pointer[NR_CPUS] __section(".data");static void cpu_update_secondary_bootdata (unsigned int cpuid,struct task_struct *tidle) { -int hartid =cpuid_to_hartid_map (cpuid); +unsigned long hartid =cpuid_to_hartid_map (cpuid);/* * The hartid must be less than NR_CPUS to avoid out-of-bound access
@@ -29,7 +29,7 @@ static void cpu_update_secondary_bootdata(unsigned int cpuid,* spinwait booting is not the recommended approach for any platforms * booting Linux in S-mode and can be disabled in the future. */ -if (hartid ==INVALID_HARTID || hartid >=NR_CPUS ) +if (hartid ==INVALID_HARTID || hartid >= (unsigned long )NR_CPUS )return ;/* Make sure tidle is updated */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 898/1095 s390/crash: fix incorrect number of bytes to copy to user space
In reply to Greg Kroah-HartmanFrom: Alexander Gordeev <[email protected]>
[ Upstream commit f6749da17a34eb08c9665f072ce7c812ff68aad2 ]
The number of bytes in a chunk is correctly calculated, but instead the total number of bytes is passed to copy_to_user_real() function.
--- arch/s390/kernel/crash_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/crash_dump.c +1 -1
@@ -199,7 +199,7 @@ static int copy_oldmem_user(void __user *dst, unsigned long src, size_t count) }else { len = count; } - rc =copy_to_user_real (dst, src, count); + rc =copy_to_user_real (dst, src, len);if (rc)return rc; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 899/1095 s390/zcore: fix race when reading from hardware system area
In reply to Greg Kroah-HartmanFrom: Alexander Gordeev <[email protected]>
[ Upstream commit 9ffed254d938c9e99eb7761c7f739294c84e0367 ]
Memory buffer used for reading out data from hardware system area is not protected against concurrent access.
--- drivers/s390/char/zcore.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/s390/char/zcore.c +10 -1
@@ -50,6 +50,7 @@ static struct dentry *zcore_reipl_file;static struct dentry *zcore_hsa_file;static struct ipl_parameter_block *zcore_ipl_block; +static DEFINE_MUTEX (hsa_buf_mutex);static char hsa_buf[PAGE_SIZE ]__aligned(PAGE_SIZE) ;/*
@@ -66,19 +67,24 @@ int memcpy_hsa_user(void __user *dest, unsigned long src, size_t count)if (!hsa_available)return -ENODATA ; +mutex_lock (&hsa_buf_mutex);while (count) {if (sclp_sdias_copy (hsa_buf, src /PAGE_SIZE +2 ,1 )) {TRACE ("sclp_sdias_copy() failed\n" ); +mutex_unlock (&hsa_buf_mutex);return -EIO ; } offset = src %PAGE_SIZE ; bytes =min (PAGE_SIZE - offset, count); -if (copy_to_user (dest, hsa_buf + offset, bytes)) +if (copy_to_user (dest, hsa_buf + offset, bytes)) { +mutex_unlock (&hsa_buf_mutex);return -EFAULT ; + } src += bytes; dest += bytes; count -= bytes; } +mutex_unlock (&hsa_buf_mutex);return 0 ; }
@@ -96,9 +102,11 @@ int memcpy_hsa_kernel(void *dest, unsigned long src, size_t count)if (!hsa_available)return -ENODATA ; +mutex_lock (&hsa_buf_mutex);while (count) {if (sclp_sdias_copy (hsa_buf, src /PAGE_SIZE +2 ,1 )) {TRACE ("sclp_sdias_copy() failed\n" ); +mutex_unlock (&hsa_buf_mutex);return -EIO ; } offset = src %PAGE_SIZE ;
@@ -108,6 +116,7 @@ int memcpy_hsa_kernel(void *dest, unsigned long src, size_t count) dest += bytes; count -= bytes; } +mutex_unlock (&hsa_buf_mutex);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 900/1095 ASoC: fsl_asrc: force cast the asrc_format type
In reply to Greg Kroah-HartmanFrom: Shengjiu Wang <[email protected]>
[ Upstream commit c49932726de24405d45516b3f8ad2735714fdf05 ]
Fix sparse warning:sound/soc/fsl/fsl_asrc.c:1177:60: sparse: warning: incorrect type in argument 3 (different base types)sound/soc/fsl/fsl_asrc.c:1177:60: sparse: expected unsigned int [usertype] *out_valuesound/soc/fsl/fsl_asrc.c:1177:60: sparse: got restricted snd_pcm_format_t *sound/soc/fsl/fsl_asrc.c:1200:47: sparse: warning: restricted snd_pcm_format_t degrades to integer
--- sound/soc/fsl/fsl_asrc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
sound/soc/fsl/fsl_asrc.c +4 -2
@@ -1066,6 +1066,7 @@ static int fsl_asrc_probe(struct platform_device *pdev)struct resource *res;void __iomem *regs;int irq, ret, i; +u32 asrc_fmt =0 ;u32 map_idx;char tmp[16 ];u32 width;
@@ -1174,7 +1175,8 @@ static int fsl_asrc_probe(struct platform_device *pdev)return ret; } - ret =of_property_read_u32 (np,"fsl,asrc-format" , &asrc->asrc_format); + ret =of_property_read_u32 (np,"fsl,asrc-format" , &asrc_fmt); + asrc->asrc_format = (__force snd_pcm_format_t )asrc_fmt;if (ret) { ret =of_property_read_u32 (np,"fsl,asrc-width" , &width);if (ret) {
@@ -1197,7 +1199,7 @@ static int fsl_asrc_probe(struct platform_device *pdev) } } -if (!(FSL_ASRC_FORMATS & (1ULL << asrc->asrc_format))) { +if (!(FSL_ASRC_FORMATS &pcm_format_to_bits (asrc->asrc_format))) {dev_warn (&pdev->dev,"unsupported width, use default S24_LE\n" ); asrc->asrc_format =SNDRV_PCM_FORMAT_S24_LE ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 901/1095 ASoC: fsl-asoc-card: force cast the asrc_format type
In reply to Greg Kroah-HartmanFrom: Shengjiu Wang <[email protected]>
[ Upstream commit 6c7b077dad62178c33f9a3ae17f90d6b0bf6e2e5 ]
Fix sparse warning:sound/soc/fsl/fsl-asoc-card.c:833:45: sparse: warning: incorrect type in argument 3 (different base types)sound/soc/fsl/fsl-asoc-card.c:833:45: sparse: expected unsigned int [usertype] *out_valuesound/soc/fsl/fsl-asoc-card.c:833:45: sparse: got restricted snd_pcm_format_t *
--- sound/soc/fsl/fsl-asoc-card.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/soc/fsl/fsl-asoc-card.c +3 -2
@@ -537,6 +537,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)struct device *codec_dev =NULL ;const char *codec_dai_name;const char *codec_dev_name; +u32 asrc_fmt =0 ;u32 width;int ret;
@@ -829,8 +830,8 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) goto asrc_fail; } - ret =of_property_read_u32 (asrc_np,"fsl,asrc-format" , - &priv->asrc_format); + ret =of_property_read_u32 (asrc_np,"fsl,asrc-format" , &asrc_fmt); + priv->asrc_format = (__force snd_pcm_format_t )asrc_fmt;if (ret) {/* Fallback to old binding; translate to asrc_format */ ret = of_property_read_u32(asrc_np, "fsl,asrc-width",
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 902/1095 ASoC: fsl_easrc: use snd_pcm_format_t type for sample_format
In reply to Greg Kroah-HartmanFrom: Shengjiu Wang <[email protected]>
[ Upstream commit de27216cf2d645c2fd14e513707bdcd54e5b1de4 ]
Fix sparse warning:sound/soc/fsl/fsl_easrc.c:562:33: sparse: warning: restricted snd_pcm_format_t degrades to integer sound/soc/fsl/fsl_easrc.c:563:34: sparse: warning: restricted snd_pcm_format_t degrades to integer sound/soc/fsl/fsl_easrc.c:565:38: sparse: warning: restricted snd_pcm_format_t degrades to integer sound/soc/fsl/fsl_easrc.c:566:39: sparse: warning: restricted snd_pcm_format_t degrades to integer sound/soc/fsl/fsl_easrc.c:608:33: sparse: warning: restricted snd_pcm_format_t degrades to integer sound/soc/fsl/fsl_easrc.c:609:34: sparse: warning: restricted snd_pcm_format_t degrades to integer sound/soc/fsl/fsl_easrc.c:615:40: sparse: warning: restricted snd_pcm_format_t degrades to integer sound/soc/fsl/fsl_easrc.c:616:41: sparse: warning: restricted snd_pcm_format_t degrades to integer
sound/soc/fsl/fsl_easrc.c:1465:51: sparse: warning: incorrect type in assignment (different base types)sound/soc/fsl/fsl_easrc.c:1465:51: sparse: expected unsigned int sample_formatsound/soc/fsl/fsl_easrc.c:1465:51: sparse: got restricted snd_pcm_format_t [usertype] formatsound/soc/fsl/fsl_easrc.c:1467:52: sparse: warning: incorrect type in assignment (different base types)sound/soc/fsl/fsl_easrc.c:1467:52: sparse: expected unsigned int sample_formatsound/soc/fsl/fsl_easrc.c:1467:52: sparse: got restricted snd_pcm_format_t [usertype] asrc_formatsound/soc/fsl/fsl_easrc.c:1470:52: sparse: warning: incorrect type in assignment (different base types)sound/soc/fsl/fsl_easrc.c:1470:52: sparse: expected unsigned int sample_formatsound/soc/fsl/fsl_easrc.c:1470:52: sparse: got restricted snd_pcm_format_t [usertype] formatsound/soc/fsl/fsl_easrc.c:1472:51: sparse: warning: incorrect type in assignment (different base types)sound/soc/fsl/fsl_easrc.c:1472:51: sparse: expected unsigned int sample_formatsound/soc/fsl/fsl_easrc.c:1472:51: sparse: got restricted snd_pcm_format_t [usertype] asrc_formatsound/soc/fsl/fsl_easrc.c:1484:41: sparse: warning: incorrect type in argument 2 (different base types)sound/soc/fsl/fsl_easrc.c:1484:41: sparse: expected restricted snd_pcm_format_t [usertype] *in_raw_formatsound/soc/fsl/fsl_easrc.c:1484:41: sparse: got unsigned int *sound/soc/fsl/fsl_easrc.c:1485:41: sparse: warning: incorrect type in argument 3 (different base types)sound/soc/fsl/fsl_easrc.c:1485:41: sparse: expected restricted snd_pcm_format_t [usertype] *out_raw_formatsound/soc/fsl/fsl_easrc.c:1485:41: sparse: got unsigned int *sound/soc/fsl/fsl_easrc.c:1937:60: sparse: warning: incorrect type in argument 3 (different base types)sound/soc/fsl/fsl_easrc.c:1937:60: sparse: expected unsigned int [usertype] *out_valuesound/soc/fsl/fsl_easrc.c:1937:60: sparse: got restricted snd_pcm_format_t *sound/soc/fsl/fsl_easrc.c:1943:49: sparse: warning: restricted snd_pcm_format_t degrades to integer
--- sound/soc/fsl/fsl_easrc.c | 9 ++++++--- sound/soc/fsl/fsl_easrc.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-)
sound/soc/fsl/fsl_easrc.c +6 -3
@@ -476,7 +476,8 @@ static int fsl_easrc_prefilter_config(struct fsl_asrc *easrc,struct fsl_asrc_pair *ctx;struct device *dev;u32 inrate, outrate, offset =0 ; -u32 in_s_rate, out_s_rate, in_s_fmt, out_s_fmt; +u32 in_s_rate, out_s_rate; +snd_pcm_format_t in_s_fmt, out_s_fmt;int ret, i;if (!easrc)
@@ -1873,6 +1874,7 @@ static int fsl_easrc_probe(struct platform_device *pdev)struct resource *res;struct device_node *np;void __iomem *regs; +u32 asrc_fmt =0 ;int ret, irq; easrc =devm_kzalloc (dev,sizeof (*easrc),GFP_KERNEL );
@@ -1933,13 +1935,14 @@ static int fsl_easrc_probe(struct platform_device *pdev)return ret; } - ret =of_property_read_u32 (np,"fsl,asrc-format" , &easrc->asrc_format); + ret =of_property_read_u32 (np,"fsl,asrc-format" , &asrc_fmt); + easrc->asrc_format = (__force snd_pcm_format_t )asrc_fmt;if (ret) {dev_err (dev,"failed to asrc format\n" );return ret; } -if (!(FSL_EASRC_FORMATS & (1ULL << easrc->asrc_format))) { +if (!(FSL_EASRC_FORMATS & (pcm_format_to_bits (easrc->asrc_format)))) {dev_warn (dev,"unsupported format, switching to S24_LE\n" ); easrc->asrc_format =SNDRV_PCM_FORMAT_S24_LE ; }
sound/soc/fsl/fsl_easrc.h +1 -1
@@ -569,7 +569,7 @@ struct fsl_easrc_io_params {unsigned int access_len;unsigned int fifo_wtmk;unsigned int sample_rate; -unsigned int sample_format; +snd_pcm_format_t sample_format;unsigned int norm_rate; };
Signature · 1 line
2.35.1