From: Sasha Levin Date: Mon, 22 Mar 2021 03:05:02 +0000 (-0400) Subject: Fixes for 5.4 X-Git-Tag: v4.4.263~50 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cbe1112592a324d534beb24cb05bfe97dd1bb255;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.4 Signed-off-by: Sasha Levin --- diff --git a/queue-5.4/counter-stm32-timer-cnt-report-count-function-when-s.patch b/queue-5.4/counter-stm32-timer-cnt-report-count-function-when-s.patch new file mode 100644 index 00000000000..ecc267b3558 --- /dev/null +++ b/queue-5.4/counter-stm32-timer-cnt-report-count-function-when-s.patch @@ -0,0 +1,139 @@ +From 96d107794a09505a2c1408d0bac6f3ee95ed72c1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 26 Feb 2021 10:29:31 +0900 +Subject: counter: stm32-timer-cnt: Report count function when + SLAVE_MODE_DISABLED + +From: William Breathitt Gray + +[ Upstream commit fae6f62e6a580b663ecf42c2120a0898deae9137 ] + +When in SLAVE_MODE_DISABLED mode, the count still increases if the +counter is enabled because an internal clock is used. This patch fixes +the stm32_count_function_get() and stm32_count_function_set() functions +to properly handle this behavior. + +Fixes: ad29937e206f ("counter: Add STM32 Timer quadrature encoder") +Cc: Fabrice Gasnier +Cc: Maxime Coquelin +Cc: Alexandre Torgue +Signed-off-by: William Breathitt Gray +Reviewed-by: Fabrice Gasnier +Link: https://lore.kernel.org/r/20210226012931.161429-1-vilhelm.gray@gmail.com +Signed-off-by: Jonathan Cameron +Signed-off-by: Sasha Levin +--- + drivers/counter/stm32-timer-cnt.c | 39 ++++++++++++++++++++----------- + 1 file changed, 25 insertions(+), 14 deletions(-) + +diff --git a/drivers/counter/stm32-timer-cnt.c b/drivers/counter/stm32-timer-cnt.c +index 644ba18a72ad..c680c7abdd26 100644 +--- a/drivers/counter/stm32-timer-cnt.c ++++ b/drivers/counter/stm32-timer-cnt.c +@@ -35,13 +35,14 @@ struct stm32_timer_cnt { + * @STM32_COUNT_ENCODER_MODE_3: counts on both TI1FP1 and TI2FP2 edges + */ + enum stm32_count_function { +- STM32_COUNT_SLAVE_MODE_DISABLED = -1, ++ STM32_COUNT_SLAVE_MODE_DISABLED, + STM32_COUNT_ENCODER_MODE_1, + STM32_COUNT_ENCODER_MODE_2, + STM32_COUNT_ENCODER_MODE_3, + }; + + static enum counter_count_function stm32_count_functions[] = { ++ [STM32_COUNT_SLAVE_MODE_DISABLED] = COUNTER_COUNT_FUNCTION_INCREASE, + [STM32_COUNT_ENCODER_MODE_1] = COUNTER_COUNT_FUNCTION_QUADRATURE_X2_A, + [STM32_COUNT_ENCODER_MODE_2] = COUNTER_COUNT_FUNCTION_QUADRATURE_X2_B, + [STM32_COUNT_ENCODER_MODE_3] = COUNTER_COUNT_FUNCTION_QUADRATURE_X4, +@@ -88,6 +89,9 @@ static int stm32_count_function_get(struct counter_device *counter, + regmap_read(priv->regmap, TIM_SMCR, &smcr); + + switch (smcr & TIM_SMCR_SMS) { ++ case 0: ++ *function = STM32_COUNT_SLAVE_MODE_DISABLED; ++ return 0; + case 1: + *function = STM32_COUNT_ENCODER_MODE_1; + return 0; +@@ -97,9 +101,9 @@ static int stm32_count_function_get(struct counter_device *counter, + case 3: + *function = STM32_COUNT_ENCODER_MODE_3; + return 0; ++ default: ++ return -EINVAL; + } +- +- return -EINVAL; + } + + static int stm32_count_function_set(struct counter_device *counter, +@@ -110,6 +114,9 @@ static int stm32_count_function_set(struct counter_device *counter, + u32 cr1, sms; + + switch (function) { ++ case STM32_COUNT_SLAVE_MODE_DISABLED: ++ sms = 0; ++ break; + case STM32_COUNT_ENCODER_MODE_1: + sms = 1; + break; +@@ -120,8 +127,7 @@ static int stm32_count_function_set(struct counter_device *counter, + sms = 3; + break; + default: +- sms = 0; +- break; ++ return -EINVAL; + } + + /* Store enable status */ +@@ -269,31 +275,36 @@ static int stm32_action_get(struct counter_device *counter, + size_t function; + int err; + +- /* Default action mode (e.g. STM32_COUNT_SLAVE_MODE_DISABLED) */ +- *action = STM32_SYNAPSE_ACTION_NONE; +- + err = stm32_count_function_get(counter, count, &function); + if (err) +- return 0; ++ return err; + + switch (function) { ++ case STM32_COUNT_SLAVE_MODE_DISABLED: ++ /* counts on internal clock when CEN=1 */ ++ *action = STM32_SYNAPSE_ACTION_NONE; ++ return 0; + case STM32_COUNT_ENCODER_MODE_1: + /* counts up/down on TI1FP1 edge depending on TI2FP2 level */ + if (synapse->signal->id == count->synapses[0].signal->id) + *action = STM32_SYNAPSE_ACTION_BOTH_EDGES; +- break; ++ else ++ *action = STM32_SYNAPSE_ACTION_NONE; ++ return 0; + case STM32_COUNT_ENCODER_MODE_2: + /* counts up/down on TI2FP2 edge depending on TI1FP1 level */ + if (synapse->signal->id == count->synapses[1].signal->id) + *action = STM32_SYNAPSE_ACTION_BOTH_EDGES; +- break; ++ else ++ *action = STM32_SYNAPSE_ACTION_NONE; ++ return 0; + case STM32_COUNT_ENCODER_MODE_3: + /* counts up/down on both TI1FP1 and TI2FP2 edges */ + *action = STM32_SYNAPSE_ACTION_BOTH_EDGES; +- break; ++ return 0; ++ default: ++ return -EINVAL; + } +- +- return 0; + } + + static const struct counter_ops stm32_timer_cnt_ops = { +-- +2.30.1 + diff --git a/queue-5.4/nvme-rdma-fix-possible-hang-when-failing-to-set-io-q.patch b/queue-5.4/nvme-rdma-fix-possible-hang-when-failing-to-set-io-q.patch new file mode 100644 index 00000000000..8f39731d1bd --- /dev/null +++ b/queue-5.4/nvme-rdma-fix-possible-hang-when-failing-to-set-io-q.patch @@ -0,0 +1,46 @@ +From 52992c043a324332256525c1be1cd6b34b766048 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 15 Mar 2021 14:04:27 -0700 +Subject: nvme-rdma: fix possible hang when failing to set io queues + +From: Sagi Grimberg + +[ Upstream commit c4c6df5fc84659690d4391d1fba155cd94185295 ] + +We only setup io queues for nvme controllers, and it makes absolutely no +sense to allow a controller (re)connect without any I/O queues. If we +happen to fail setting the queue count for any reason, we should not allow +this to be a successful reconnect as I/O has no chance in going through. +Instead just fail and schedule another reconnect. + +Reported-by: Chao Leng +Fixes: 711023071960 ("nvme-rdma: add a NVMe over Fabrics RDMA host driver") +Signed-off-by: Sagi Grimberg +Reviewed-by: Chao Leng +Signed-off-by: Christoph Hellwig +Signed-off-by: Sasha Levin +--- + drivers/nvme/host/rdma.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c +index da6030010432..b8c0f75bfb7b 100644 +--- a/drivers/nvme/host/rdma.c ++++ b/drivers/nvme/host/rdma.c +@@ -666,8 +666,11 @@ static int nvme_rdma_alloc_io_queues(struct nvme_rdma_ctrl *ctrl) + return ret; + + ctrl->ctrl.queue_count = nr_io_queues + 1; +- if (ctrl->ctrl.queue_count < 2) +- return 0; ++ if (ctrl->ctrl.queue_count < 2) { ++ dev_err(ctrl->ctrl.device, ++ "unable to set any I/O queues\n"); ++ return -ENOMEM; ++ } + + dev_info(ctrl->ctrl.device, + "creating %d I/O queues.\n", nr_io_queues); +-- +2.30.1 + diff --git a/queue-5.4/series b/queue-5.4/series index bb0e26c328f..a3df0c8b7ac 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -29,3 +29,5 @@ kbuild-fix-linux-version.h-for-empty-sublevel-or-patchlevel-again.patch riscv-correct-sparsemem-configuration.patch scsi-lpfc-fix-some-error-codes-in-debugfs.patch scsi-myrs-fix-a-double-free-in-myrs_cleanup.patch +counter-stm32-timer-cnt-report-count-function-when-s.patch +nvme-rdma-fix-possible-hang-when-failing-to-set-io-q.patch