From: Sasha Levin Date: Thu, 20 Aug 2020 04:04:00 +0000 (-0400) Subject: Fixes for 4.14 X-Git-Tag: v4.14.194~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4a74cf80514e8b1b4bce4eb279d9158c5c8fa45b;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.14 Signed-off-by: Sasha Levin --- diff --git a/queue-4.14/alsa-echoaudio-fix-potential-oops-in-snd_echo_resume.patch b/queue-4.14/alsa-echoaudio-fix-potential-oops-in-snd_echo_resume.patch new file mode 100644 index 00000000000..adae131102b --- /dev/null +++ b/queue-4.14/alsa-echoaudio-fix-potential-oops-in-snd_echo_resume.patch @@ -0,0 +1,45 @@ +From eb9bf37e74f379b1b0a9fac47fe0928a1c346f63 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 13 Aug 2020 15:46:30 +0800 +Subject: ALSA: echoaudio: Fix potential Oops in snd_echo_resume() + +From: Dinghao Liu + +[ Upstream commit 5a25de6df789cc805a9b8ba7ab5deef5067af47e ] + +Freeing chip on error may lead to an Oops at the next time +the system goes to resume. Fix this by removing all +snd_echo_free() calls on error. + +Fixes: 47b5d028fdce8 ("ALSA: Echoaudio - Add suspend support #2") +Signed-off-by: Dinghao Liu +Link: https://lore.kernel.org/r/20200813074632.17022-1-dinghao.liu@zju.edu.cn +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/pci/echoaudio/echoaudio.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c +index e1f0bcd45c378..b58a098a7270d 100644 +--- a/sound/pci/echoaudio/echoaudio.c ++++ b/sound/pci/echoaudio/echoaudio.c +@@ -2215,7 +2215,6 @@ static int snd_echo_resume(struct device *dev) + if (err < 0) { + kfree(commpage_bak); + dev_err(dev, "resume init_hw err=%d\n", err); +- snd_echo_free(chip); + return err; + } + +@@ -2242,7 +2241,6 @@ static int snd_echo_resume(struct device *dev) + if (request_irq(pci->irq, snd_echo_interrupt, IRQF_SHARED, + KBUILD_MODNAME, chip)) { + dev_err(chip->card->dev, "cannot grab irq\n"); +- snd_echo_free(chip); + return -EBUSY; + } + chip->irq = pci->irq; +-- +2.25.1 + diff --git a/queue-4.14/clk-clk-atlas6-fix-return-value-check-in-atlas6_clk_.patch b/queue-4.14/clk-clk-atlas6-fix-return-value-check-in-atlas6_clk_.patch new file mode 100644 index 00000000000..b8a500a1801 --- /dev/null +++ b/queue-4.14/clk-clk-atlas6-fix-return-value-check-in-atlas6_clk_.patch @@ -0,0 +1,39 @@ +From 562188d08b5d96716c1b4f6d98ec2c8d546858c0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 13 Jul 2020 03:21:43 +0000 +Subject: clk: clk-atlas6: fix return value check in atlas6_clk_init() + +From: Xu Wang + +[ Upstream commit 12b90b40854a8461a02ef19f6f4474cc88d64b66 ] + +In case of error, the function clk_register() returns ERR_PTR() +and never returns NULL. The NULL test in the return value check +should be replaced with IS_ERR(). + +Signed-off-by: Xu Wang +Link: https://lore.kernel.org/r/20200713032143.21362-1-vulab@iscas.ac.cn +Acked-by: Barry Song +Fixes: 7bf21bc81f28 ("clk: sirf: re-arch to make the codes support both prima2 and atlas6") +Signed-off-by: Stephen Boyd +Signed-off-by: Sasha Levin +--- + drivers/clk/sirf/clk-atlas6.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/clk/sirf/clk-atlas6.c b/drivers/clk/sirf/clk-atlas6.c +index 665fa681b2e1e..1e6bdf22c3b64 100644 +--- a/drivers/clk/sirf/clk-atlas6.c ++++ b/drivers/clk/sirf/clk-atlas6.c +@@ -136,7 +136,7 @@ static void __init atlas6_clk_init(struct device_node *np) + + for (i = pll1; i < maxclk; i++) { + atlas6_clks[i] = clk_register(NULL, atlas6_clk_hw_array[i]); +- BUG_ON(!atlas6_clks[i]); ++ BUG_ON(IS_ERR(atlas6_clks[i])); + } + clk_register_clkdev(atlas6_clks[cpu], NULL, "cpu"); + clk_register_clkdev(atlas6_clks[io], NULL, "io"); +-- +2.25.1 + diff --git a/queue-4.14/dm-rq-don-t-call-blk_mq_queue_stopped-in-dm_stop_que.patch b/queue-4.14/dm-rq-don-t-call-blk_mq_queue_stopped-in-dm_stop_que.patch new file mode 100644 index 00000000000..bfa15a49cc0 --- /dev/null +++ b/queue-4.14/dm-rq-don-t-call-blk_mq_queue_stopped-in-dm_stop_que.patch @@ -0,0 +1,45 @@ +From 99e4f30a7d0e06673d482df42fb8e2cc972cdbb3 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 19 Jun 2020 16:42:14 +0800 +Subject: dm rq: don't call blk_mq_queue_stopped() in dm_stop_queue() + +From: Ming Lei + +[ Upstream commit e766668c6cd49d741cfb49eaeb38998ba34d27bc ] + +dm_stop_queue() only uses blk_mq_quiesce_queue() so it doesn't +formally stop the blk-mq queue; therefore there is no point making the +blk_mq_queue_stopped() check -- it will never be stopped. + +In addition, even though dm_stop_queue() actually tries to quiesce hw +queues via blk_mq_quiesce_queue(), checking with blk_queue_quiesced() +to avoid unnecessary queue quiesce isn't reliable because: the +QUEUE_FLAG_QUIESCED flag is set before synchronize_rcu() and +dm_stop_queue() may be called when synchronize_rcu() from another +blk_mq_quiesce_queue() is in-progress. + +Fixes: 7b17c2f7292ba ("dm: Fix a race condition related to stopping and starting queues") +Signed-off-by: Ming Lei +Signed-off-by: Mike Snitzer +Signed-off-by: Sasha Levin +--- + drivers/md/dm-rq.c | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c +index eadfcfd106fff..cac8ec16e6031 100644 +--- a/drivers/md/dm-rq.c ++++ b/drivers/md/dm-rq.c +@@ -95,9 +95,6 @@ static void dm_old_stop_queue(struct request_queue *q) + + static void dm_mq_stop_queue(struct request_queue *q) + { +- if (blk_mq_queue_stopped(q)) +- return; +- + blk_mq_quiesce_queue(q); + } + +-- +2.25.1 + diff --git a/queue-4.14/drm-vmwgfx-fix-two-list_for_each-loop-exit-tests.patch b/queue-4.14/drm-vmwgfx-fix-two-list_for_each-loop-exit-tests.patch new file mode 100644 index 00000000000..c7b7ba74087 --- /dev/null +++ b/queue-4.14/drm-vmwgfx-fix-two-list_for_each-loop-exit-tests.patch @@ -0,0 +1,62 @@ +From f74edd14c6d8f37bc4b4feea013f6837f93e738c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 26 Jun 2020 13:39:59 +0300 +Subject: drm/vmwgfx: Fix two list_for_each loop exit tests + +From: Dan Carpenter + +[ Upstream commit 4437c1152ce0e57ab8f401aa696ea6291cc07ab1 ] + +These if statements are supposed to be true if we ended the +list_for_each_entry() loops without hitting a break statement but they +don't work. + +In the first loop, we increment "i" after the "if (i == unit)" condition +so we don't necessarily know that "i" is not equal to unit at the end of +the loop. + +In the second loop we exit when mode is not pointing to a valid +drm_display_mode struct so it doesn't make sense to check "mode->type". + +Fixes: a278724aa23c ("drm/vmwgfx: Implement fbdev on kms v2") +Signed-off-by: Dan Carpenter +Reviewed-by: Roland Scheidegger +Signed-off-by: Roland Scheidegger +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +index 11f1c30ead548..848c9d009be2a 100644 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +@@ -2707,7 +2707,7 @@ int vmw_kms_fbdev_init_data(struct vmw_private *dev_priv, + ++i; + } + +- if (i != unit) { ++ if (&con->head == &dev_priv->dev->mode_config.connector_list) { + DRM_ERROR("Could not find initial display unit.\n"); + return -EINVAL; + } +@@ -2729,13 +2729,13 @@ int vmw_kms_fbdev_init_data(struct vmw_private *dev_priv, + break; + } + +- if (mode->type & DRM_MODE_TYPE_PREFERRED) +- *p_mode = mode; +- else { ++ if (&mode->head == &con->modes) { + WARN_ONCE(true, "Could not find initial preferred mode.\n"); + *p_mode = list_first_entry(&con->modes, + struct drm_display_mode, + head); ++ } else { ++ *p_mode = mode; + } + + return 0; +-- +2.25.1 + diff --git a/queue-4.14/drm-vmwgfx-use-correct-vmw_legacy_display_unit-point.patch b/queue-4.14/drm-vmwgfx-use-correct-vmw_legacy_display_unit-point.patch new file mode 100644 index 00000000000..56b290f2580 --- /dev/null +++ b/queue-4.14/drm-vmwgfx-use-correct-vmw_legacy_display_unit-point.patch @@ -0,0 +1,54 @@ +From 9d994b73764b1fd5530f87a352763ac8e6dedaee Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 26 Jun 2020 13:34:37 +0300 +Subject: drm/vmwgfx: Use correct vmw_legacy_display_unit pointer + +From: Dan Carpenter + +[ Upstream commit 1d2c0c565bc0da25f5e899a862fb58e612b222df ] + +The "entry" pointer is an offset from the list head and it doesn't +point to a valid vmw_legacy_display_unit struct. Presumably the +intent was to point to the last entry. + +Also the "i++" wasn't used so I have removed that as well. + +Fixes: d7e1958dbe4a ("drm/vmwgfx: Support older hardware.") +Signed-off-by: Dan Carpenter +Reviewed-by: Roland Scheidegger +Signed-off-by: Roland Scheidegger +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c +index 3824595fece12..39f4ad0dab8db 100644 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c +@@ -79,7 +79,7 @@ static int vmw_ldu_commit_list(struct vmw_private *dev_priv) + struct vmw_legacy_display_unit *entry; + struct drm_framebuffer *fb = NULL; + struct drm_crtc *crtc = NULL; +- int i = 0; ++ int i; + + /* If there is no display topology the host just assumes + * that the guest will set the same layout as the host. +@@ -90,12 +90,11 @@ static int vmw_ldu_commit_list(struct vmw_private *dev_priv) + crtc = &entry->base.crtc; + w = max(w, crtc->x + crtc->mode.hdisplay); + h = max(h, crtc->y + crtc->mode.vdisplay); +- i++; + } + + if (crtc == NULL) + return 0; +- fb = entry->base.crtc.primary->state->fb; ++ fb = crtc->primary->state->fb; + + return vmw_kms_write_svga(dev_priv, w, h, fb->pitches[0], + fb->format->cpp[0] * 8, +-- +2.25.1 + diff --git a/queue-4.14/fs-ufs-avoid-potential-u32-multiplication-overflow.patch b/queue-4.14/fs-ufs-avoid-potential-u32-multiplication-overflow.patch new file mode 100644 index 00000000000..e700152008c --- /dev/null +++ b/queue-4.14/fs-ufs-avoid-potential-u32-multiplication-overflow.patch @@ -0,0 +1,44 @@ +From def5e288b6bc0064c3c64173a0d2d28d9e40421d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 11 Aug 2020 18:35:53 -0700 +Subject: fs/ufs: avoid potential u32 multiplication overflow + +From: Colin Ian King + +[ Upstream commit 88b2e9b06381551b707d980627ad0591191f7a2d ] + +The 64 bit ino is being compared to the product of two u32 values, +however, the multiplication is being performed using a 32 bit multiply so +there is a potential of an overflow. To be fully safe, cast uspi->s_ncg +to a u64 to ensure a 64 bit multiplication occurs to avoid any chance of +overflow. + +Fixes: f3e2a520f5fb ("ufs: NFS support") +Signed-off-by: Colin Ian King +Signed-off-by: Andrew Morton +Cc: Evgeniy Dushistov +Cc: Alexey Dobriyan +Link: http://lkml.kernel.org/r/20200715170355.1081713-1-colin.king@canonical.com +Addresses-Coverity: ("Unintentional integer overflow") +Signed-off-by: Linus Torvalds +Signed-off-by: Sasha Levin +--- + fs/ufs/super.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/fs/ufs/super.c b/fs/ufs/super.c +index 6440003f8ddc6..e3f3a0df60276 100644 +--- a/fs/ufs/super.c ++++ b/fs/ufs/super.c +@@ -99,7 +99,7 @@ static struct inode *ufs_nfs_get_inode(struct super_block *sb, u64 ino, u32 gene + struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; + struct inode *inode; + +- if (ino < UFS_ROOTINO || ino > uspi->s_ncg * uspi->s_ipg) ++ if (ino < UFS_ROOTINO || ino > (u64)uspi->s_ncg * uspi->s_ipg) + return ERR_PTR(-ESTALE); + + inode = ufs_iget(sb, ino); +-- +2.25.1 + diff --git a/queue-4.14/gpu-ipu-v3-image-convert-combine-rotate-no-rotate-ir.patch b/queue-4.14/gpu-ipu-v3-image-convert-combine-rotate-no-rotate-ir.patch new file mode 100644 index 00000000000..1debcb60b9d --- /dev/null +++ b/queue-4.14/gpu-ipu-v3-image-convert-combine-rotate-no-rotate-ir.patch @@ -0,0 +1,118 @@ +From f6701c744f833cb4f971f29aed9d65bef02dae51 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 17 Jun 2020 15:40:37 -0700 +Subject: gpu: ipu-v3: image-convert: Combine rotate/no-rotate irq handlers + +From: Steve Longerbeam + +[ Upstream commit 0f6245f42ce9b7e4d20f2cda8d5f12b55a44d7d1 ] + +Combine the rotate_irq() and norotate_irq() handlers into a single +eof_irq() handler. + +Signed-off-by: Steve Longerbeam +Signed-off-by: Philipp Zabel +Signed-off-by: Sasha Levin +--- + drivers/gpu/ipu-v3/ipu-image-convert.c | 58 +++++++++----------------- + 1 file changed, 20 insertions(+), 38 deletions(-) + +diff --git a/drivers/gpu/ipu-v3/ipu-image-convert.c b/drivers/gpu/ipu-v3/ipu-image-convert.c +index a5e33d58e02f7..d2f9e65522676 100644 +--- a/drivers/gpu/ipu-v3/ipu-image-convert.c ++++ b/drivers/gpu/ipu-v3/ipu-image-convert.c +@@ -992,9 +992,10 @@ static irqreturn_t do_irq(struct ipu_image_convert_run *run) + return IRQ_WAKE_THREAD; + } + +-static irqreturn_t norotate_irq(int irq, void *data) ++static irqreturn_t eof_irq(int irq, void *data) + { + struct ipu_image_convert_chan *chan = data; ++ struct ipu_image_convert_priv *priv = chan->priv; + struct ipu_image_convert_ctx *ctx; + struct ipu_image_convert_run *run; + unsigned long flags; +@@ -1011,45 +1012,26 @@ static irqreturn_t norotate_irq(int irq, void *data) + + ctx = run->ctx; + +- if (ipu_rot_mode_is_irt(ctx->rot_mode)) { +- /* this is a rotation operation, just ignore */ +- spin_unlock_irqrestore(&chan->irqlock, flags); +- return IRQ_HANDLED; +- } +- +- ret = do_irq(run); +-out: +- spin_unlock_irqrestore(&chan->irqlock, flags); +- return ret; +-} +- +-static irqreturn_t rotate_irq(int irq, void *data) +-{ +- struct ipu_image_convert_chan *chan = data; +- struct ipu_image_convert_priv *priv = chan->priv; +- struct ipu_image_convert_ctx *ctx; +- struct ipu_image_convert_run *run; +- unsigned long flags; +- irqreturn_t ret; +- +- spin_lock_irqsave(&chan->irqlock, flags); +- +- /* get current run and its context */ +- run = chan->current_run; +- if (!run) { ++ if (irq == chan->out_eof_irq) { ++ if (ipu_rot_mode_is_irt(ctx->rot_mode)) { ++ /* this is a rotation op, just ignore */ ++ ret = IRQ_HANDLED; ++ goto out; ++ } ++ } else if (irq == chan->rot_out_eof_irq) { ++ if (!ipu_rot_mode_is_irt(ctx->rot_mode)) { ++ /* this was NOT a rotation op, shouldn't happen */ ++ dev_err(priv->ipu->dev, ++ "Unexpected rotation interrupt\n"); ++ ret = IRQ_HANDLED; ++ goto out; ++ } ++ } else { ++ dev_err(priv->ipu->dev, "Received unknown irq %d\n", irq); + ret = IRQ_NONE; + goto out; + } + +- ctx = run->ctx; +- +- if (!ipu_rot_mode_is_irt(ctx->rot_mode)) { +- /* this was NOT a rotation operation, shouldn't happen */ +- dev_err(priv->ipu->dev, "Unexpected rotation interrupt\n"); +- spin_unlock_irqrestore(&chan->irqlock, flags); +- return IRQ_HANDLED; +- } +- + ret = do_irq(run); + out: + spin_unlock_irqrestore(&chan->irqlock, flags); +@@ -1142,7 +1124,7 @@ static int get_ipu_resources(struct ipu_image_convert_chan *chan) + chan->out_chan, + IPU_IRQ_EOF); + +- ret = request_threaded_irq(chan->out_eof_irq, norotate_irq, do_bh, ++ ret = request_threaded_irq(chan->out_eof_irq, eof_irq, do_bh, + 0, "ipu-ic", chan); + if (ret < 0) { + dev_err(priv->ipu->dev, "could not acquire irq %d\n", +@@ -1155,7 +1137,7 @@ static int get_ipu_resources(struct ipu_image_convert_chan *chan) + chan->rotation_out_chan, + IPU_IRQ_EOF); + +- ret = request_threaded_irq(chan->rot_out_eof_irq, rotate_irq, do_bh, ++ ret = request_threaded_irq(chan->rot_out_eof_irq, eof_irq, do_bh, + 0, "ipu-ic", chan); + if (ret < 0) { + dev_err(priv->ipu->dev, "could not acquire irq %d\n", +-- +2.25.1 + diff --git a/queue-4.14/i2c-rcar-avoid-race-when-unregistering-slave.patch b/queue-4.14/i2c-rcar-avoid-race-when-unregistering-slave.patch new file mode 100644 index 00000000000..3ecd8f39b9c --- /dev/null +++ b/queue-4.14/i2c-rcar-avoid-race-when-unregistering-slave.patch @@ -0,0 +1,56 @@ +From 9475951fb26476f3067d77fe1c528936ff69b09e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 26 Jul 2020 18:16:06 +0200 +Subject: i2c: rcar: avoid race when unregistering slave +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Wolfram Sang + +[ Upstream commit c7c9e914f9a0478fba4dc6f227cfd69cf84a4063 ] + +Due to the lockless design of the driver, it is theoretically possible +to access a NULL pointer, if a slave interrupt was running while we were +unregistering the slave. To make this rock solid, disable the interrupt +for a short time while we are clearing the interrupt_enable register. +This patch is purely based on code inspection. The OOPS is super-hard to +trigger because clearing SAR (the address) makes interrupts even more +unlikely to happen as well. While here, reinit SCR to SDBS because this +bit should always be set according to documentation. There is no effect, +though, because the interface is disabled. + +Fixes: 7b814d852af6 ("i2c: rcar: avoid race when unregistering slave client") +Signed-off-by: Wolfram Sang +Reviewed-by: Niklas Söderlund +Signed-off-by: Wolfram Sang +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-rcar.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c +index 07305304712e1..ed0f068109785 100644 +--- a/drivers/i2c/busses/i2c-rcar.c ++++ b/drivers/i2c/busses/i2c-rcar.c +@@ -815,12 +815,14 @@ static int rcar_unreg_slave(struct i2c_client *slave) + + WARN_ON(!priv->slave); + +- /* disable irqs and ensure none is running before clearing ptr */ ++ /* ensure no irq is running before clearing ptr */ ++ disable_irq(priv->irq); + rcar_i2c_write(priv, ICSIER, 0); +- rcar_i2c_write(priv, ICSCR, 0); ++ rcar_i2c_write(priv, ICSSR, 0); ++ enable_irq(priv->irq); ++ rcar_i2c_write(priv, ICSCR, SDBS); + rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */ + +- synchronize_irq(priv->irq); + priv->slave = NULL; + + pm_runtime_put(rcar_i2c_priv_to_dev(priv)); +-- +2.25.1 + diff --git a/queue-4.14/i2c-rcar-slave-only-send-stop-event-when-we-have-bee.patch b/queue-4.14/i2c-rcar-slave-only-send-stop-event-when-we-have-bee.patch new file mode 100644 index 00000000000..97c6d963fd5 --- /dev/null +++ b/queue-4.14/i2c-rcar-slave-only-send-stop-event-when-we-have-bee.patch @@ -0,0 +1,55 @@ +From 4f2a9010e19741cfac2d3bb7553d3e174923369c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 29 Jun 2020 17:38:07 +0200 +Subject: i2c: rcar: slave: only send STOP event when we have been addressed + +From: Wolfram Sang + +[ Upstream commit 314139f9f0abdba61ed9a8463bbcb0bf900ac5a2 ] + +When the SSR interrupt is activated, it will detect every STOP condition +on the bus, not only the ones after we have been addressed. So, enable +this interrupt only after we have been addressed, and disable it +otherwise. + +Fixes: de20d1857dd6 ("i2c: rcar: add slave support") +Signed-off-by: Wolfram Sang +Signed-off-by: Wolfram Sang +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-rcar.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c +index db9ca8e926ca7..07305304712e1 100644 +--- a/drivers/i2c/busses/i2c-rcar.c ++++ b/drivers/i2c/busses/i2c-rcar.c +@@ -538,13 +538,14 @@ static bool rcar_i2c_slave_irq(struct rcar_i2c_priv *priv) + rcar_i2c_write(priv, ICSIER, SDR | SSR | SAR); + } + +- rcar_i2c_write(priv, ICSSR, ~SAR & 0xff); ++ /* Clear SSR, too, because of old STOPs to other clients than us */ ++ rcar_i2c_write(priv, ICSSR, ~(SAR | SSR) & 0xff); + } + + /* master sent stop */ + if (ssr_filtered & SSR) { + i2c_slave_event(priv->slave, I2C_SLAVE_STOP, &value); +- rcar_i2c_write(priv, ICSIER, SAR | SSR); ++ rcar_i2c_write(priv, ICSIER, SAR); + rcar_i2c_write(priv, ICSSR, ~SSR & 0xff); + } + +@@ -802,7 +803,7 @@ static int rcar_reg_slave(struct i2c_client *slave) + priv->slave = slave; + rcar_i2c_write(priv, ICSAR, slave->addr); + rcar_i2c_write(priv, ICSSR, 0); +- rcar_i2c_write(priv, ICSIER, SAR | SSR); ++ rcar_i2c_write(priv, ICSIER, SAR); + rcar_i2c_write(priv, ICSCR, SIE | SDBS); + + return 0; +-- +2.25.1 + diff --git a/queue-4.14/input-sentelic-fix-error-return-when-fsp_reg_write-f.patch b/queue-4.14/input-sentelic-fix-error-return-when-fsp_reg_write-f.patch new file mode 100644 index 00000000000..2b7f7209e18 --- /dev/null +++ b/queue-4.14/input-sentelic-fix-error-return-when-fsp_reg_write-f.patch @@ -0,0 +1,39 @@ +From 4a5dd0660ff7155b1ee0ff2307fff91bf6bade45 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 6 Aug 2020 15:35:34 -0700 +Subject: Input: sentelic - fix error return when fsp_reg_write fails + +From: Colin Ian King + +[ Upstream commit ea38f06e0291986eb93beb6d61fd413607a30ca4 ] + +Currently when the call to fsp_reg_write fails -EIO is not being returned +because the count is being returned instead of the return value in retval. +Fix this by returning the value in retval instead of count. + +Addresses-Coverity: ("Unused value") +Fixes: fc69f4a6af49 ("Input: add new driver for Sentelic Finger Sensing Pad") +Signed-off-by: Colin Ian King +Link: https://lore.kernel.org/r/20200603141218.131663-1-colin.king@canonical.com +Signed-off-by: Dmitry Torokhov +Signed-off-by: Sasha Levin +--- + drivers/input/mouse/sentelic.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/input/mouse/sentelic.c b/drivers/input/mouse/sentelic.c +index 11c32ac8234b2..779d0b9341c0d 100644 +--- a/drivers/input/mouse/sentelic.c ++++ b/drivers/input/mouse/sentelic.c +@@ -454,7 +454,7 @@ static ssize_t fsp_attr_set_setreg(struct psmouse *psmouse, void *data, + + fsp_reg_write_enable(psmouse, false); + +- return count; ++ return retval; + } + + PSMOUSE_DEFINE_WO_ATTR(setreg, S_IWUSR, NULL, fsp_attr_set_setreg); +-- +2.25.1 + diff --git a/queue-4.14/iommu-omap-check-for-failure-of-a-call-to-omap_iommu.patch b/queue-4.14/iommu-omap-check-for-failure-of-a-call-to-omap_iommu.patch new file mode 100644 index 00000000000..3cecbc3bffb --- /dev/null +++ b/queue-4.14/iommu-omap-check-for-failure-of-a-call-to-omap_iommu.patch @@ -0,0 +1,43 @@ +From 63a7070cfeac800d4143c46d2e29699ab3ec006f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 14 Jul 2020 20:22:11 +0100 +Subject: iommu/omap: Check for failure of a call to omap_iommu_dump_ctx + +From: Colin Ian King + +[ Upstream commit dee9d154f40c58d02f69acdaa5cfd1eae6ebc28b ] + +It is possible for the call to omap_iommu_dump_ctx to return +a negative error number, so check for the failure and return +the error number rather than pass the negative value to +simple_read_from_buffer. + +Fixes: 14e0e6796a0d ("OMAP: iommu: add initial debugfs support") +Signed-off-by: Colin Ian King +Link: https://lore.kernel.org/r/20200714192211.744776-1-colin.king@canonical.com +Addresses-Coverity: ("Improper use of negative value") +Signed-off-by: Joerg Roedel +Signed-off-by: Sasha Levin +--- + drivers/iommu/omap-iommu-debug.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/iommu/omap-iommu-debug.c b/drivers/iommu/omap-iommu-debug.c +index 505548aafeff2..cec33e90e3998 100644 +--- a/drivers/iommu/omap-iommu-debug.c ++++ b/drivers/iommu/omap-iommu-debug.c +@@ -101,8 +101,11 @@ static ssize_t debug_read_regs(struct file *file, char __user *userbuf, + mutex_lock(&iommu_debug_lock); + + bytes = omap_iommu_dump_ctx(obj, p, count); ++ if (bytes < 0) ++ goto err; + bytes = simple_read_from_buffer(userbuf, count, ppos, buf, bytes); + ++err: + mutex_unlock(&iommu_debug_lock); + kfree(buf); + +-- +2.25.1 + diff --git a/queue-4.14/iommu-vt-d-enforce-pasid-devtlb-field-mask.patch b/queue-4.14/iommu-vt-d-enforce-pasid-devtlb-field-mask.patch new file mode 100644 index 00000000000..314ccfecffb --- /dev/null +++ b/queue-4.14/iommu-vt-d-enforce-pasid-devtlb-field-mask.patch @@ -0,0 +1,40 @@ +From 7fef84392cb82bdda3e5130d7710e91d331b53a7 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 24 Jul 2020 09:49:14 +0800 +Subject: iommu/vt-d: Enforce PASID devTLB field mask + +From: Liu Yi L + +[ Upstream commit 5f77d6ca5ca74e4b4a5e2e010f7ff50c45dea326 ] + +Set proper masks to avoid invalid input spillover to reserved bits. + +Signed-off-by: Liu Yi L +Signed-off-by: Jacob Pan +Signed-off-by: Lu Baolu +Reviewed-by: Eric Auger +Link: https://lore.kernel.org/r/20200724014925.15523-2-baolu.lu@linux.intel.com +Signed-off-by: Joerg Roedel +Signed-off-by: Sasha Levin +--- + include/linux/intel-iommu.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h +index 4def15c32a018..d2364ba99f6ce 100644 +--- a/include/linux/intel-iommu.h ++++ b/include/linux/intel-iommu.h +@@ -304,8 +304,8 @@ enum { + + #define QI_DEV_EIOTLB_ADDR(a) ((u64)(a) & VTD_PAGE_MASK) + #define QI_DEV_EIOTLB_SIZE (((u64)1) << 11) +-#define QI_DEV_EIOTLB_GLOB(g) ((u64)g) +-#define QI_DEV_EIOTLB_PASID(p) (((u64)p) << 32) ++#define QI_DEV_EIOTLB_GLOB(g) ((u64)(g) & 0x1) ++#define QI_DEV_EIOTLB_PASID(p) ((u64)((p) & 0xfffff) << 32) + #define QI_DEV_EIOTLB_SID(sid) ((u64)((sid) & 0xffff) << 16) + #define QI_DEV_EIOTLB_QDEP(qd) ((u64)((qd) & 0x1f) << 4) + #define QI_DEV_EIOTLB_PFSID(pfsid) (((u64)(pfsid & 0xf) << 12) | \ +-- +2.25.1 + diff --git a/queue-4.14/mfd-arizona-ensure-32k-clock-is-put-on-driver-unbind.patch b/queue-4.14/mfd-arizona-ensure-32k-clock-is-put-on-driver-unbind.patch new file mode 100644 index 00000000000..287cc8fbb1a --- /dev/null +++ b/queue-4.14/mfd-arizona-ensure-32k-clock-is-put-on-driver-unbind.patch @@ -0,0 +1,65 @@ +From 0930ab5a1592aa382ded8f64926e33d3e42f4214 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 15 Jun 2020 14:53:21 +0100 +Subject: mfd: arizona: Ensure 32k clock is put on driver unbind and error + +From: Charles Keepax + +[ Upstream commit ddff6c45b21d0437ce0c85f8ac35d7b5480513d7 ] + +Whilst it doesn't matter if the internal 32k clock register settings +are cleaned up on exit, as the part will be turned off losing any +settings, hence the driver hasn't historially bothered. The external +clock should however be cleaned up, as it could cause clocks to be +left on, and will at best generate a warning on unbind. + +Add clean up on both the probe error path and unbind for the 32k +clock. + +Fixes: cdd8da8cc66b ("mfd: arizona: Add gating of external MCLKn clocks") +Signed-off-by: Charles Keepax +Signed-off-by: Lee Jones +Signed-off-by: Sasha Levin +--- + drivers/mfd/arizona-core.c | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c +index ad8a5296c50ba..9aa33141e7f14 100644 +--- a/drivers/mfd/arizona-core.c ++++ b/drivers/mfd/arizona-core.c +@@ -1528,6 +1528,15 @@ int arizona_dev_init(struct arizona *arizona) + arizona_irq_exit(arizona); + err_pm: + pm_runtime_disable(arizona->dev); ++ ++ switch (arizona->pdata.clk32k_src) { ++ case ARIZONA_32KZ_MCLK1: ++ case ARIZONA_32KZ_MCLK2: ++ arizona_clk32k_disable(arizona); ++ break; ++ default: ++ break; ++ } + err_reset: + arizona_enable_reset(arizona); + regulator_disable(arizona->dcvdd); +@@ -1550,6 +1559,15 @@ int arizona_dev_exit(struct arizona *arizona) + regulator_disable(arizona->dcvdd); + regulator_put(arizona->dcvdd); + ++ switch (arizona->pdata.clk32k_src) { ++ case ARIZONA_32KZ_MCLK1: ++ case ARIZONA_32KZ_MCLK2: ++ arizona_clk32k_disable(arizona); ++ break; ++ default: ++ break; ++ } ++ + mfd_remove_devices(arizona->dev); + arizona_free_irq(arizona, ARIZONA_IRQ_UNDERCLOCKED, arizona); + arizona_free_irq(arizona, ARIZONA_IRQ_OVERCLOCKED, arizona); +-- +2.25.1 + diff --git a/queue-4.14/mfd-dln2-run-event-handler-loop-under-spinlock.patch b/queue-4.14/mfd-dln2-run-event-handler-loop-under-spinlock.patch new file mode 100644 index 00000000000..4e39d16b415 --- /dev/null +++ b/queue-4.14/mfd-dln2-run-event-handler-loop-under-spinlock.patch @@ -0,0 +1,68 @@ +From 5b9c83f9da6cfba441ba9def9935bbab2507594d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 23 Jul 2020 16:02:46 +0300 +Subject: mfd: dln2: Run event handler loop under spinlock + +From: Andy Shevchenko + +[ Upstream commit 3d858942250820b9adc35f963a257481d6d4c81d ] + +The event handler loop must be run with interrupts disabled. +Otherwise we will have a warning: + +[ 1970.785649] irq 31 handler lineevent_irq_handler+0x0/0x20 enabled interrupts +[ 1970.792739] WARNING: CPU: 0 PID: 0 at kernel/irq/handle.c:159 __handle_irq_event_percpu+0x162/0x170 +[ 1970.860732] RIP: 0010:__handle_irq_event_percpu+0x162/0x170 +... +[ 1970.946994] Call Trace: +[ 1970.949446] +[ 1970.951471] handle_irq_event_percpu+0x2c/0x80 +[ 1970.955921] handle_irq_event+0x23/0x43 +[ 1970.959766] handle_simple_irq+0x57/0x70 +[ 1970.963695] generic_handle_irq+0x42/0x50 +[ 1970.967717] dln2_rx+0xc1/0x210 [dln2] +[ 1970.971479] ? usb_hcd_unmap_urb_for_dma+0xa6/0x1c0 +[ 1970.976362] __usb_hcd_giveback_urb+0x77/0xe0 +[ 1970.980727] usb_giveback_urb_bh+0x8e/0xe0 +[ 1970.984837] tasklet_action_common.isra.0+0x4a/0xe0 +... + +Recently xHCI driver switched to tasklets in the commit 36dc01657b49 +("usb: host: xhci: Support running urb giveback in tasklet context"). + +The handle_irq_event_* functions are expected to be called with interrupts +disabled and they rightfully complain here because we run in tasklet context +with interrupts enabled. + +Use a event spinlock to protect event handler from being interrupted. + +Note, that there are only two users of this GPIO and ADC drivers and both of +them are using generic_handle_irq() which makes above happen. + +Fixes: 338a12814297 ("mfd: Add support for Diolan DLN-2 devices") +Signed-off-by: Andy Shevchenko +Signed-off-by: Lee Jones +Signed-off-by: Sasha Levin +--- + drivers/mfd/dln2.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c +index 672831d5ee32e..97a69cd6f1278 100644 +--- a/drivers/mfd/dln2.c ++++ b/drivers/mfd/dln2.c +@@ -294,7 +294,11 @@ static void dln2_rx(struct urb *urb) + len = urb->actual_length - sizeof(struct dln2_header); + + if (handle == DLN2_HANDLE_EVENT) { ++ unsigned long flags; ++ ++ spin_lock_irqsave(&dln2->event_cb_lock, flags); + dln2_run_event_callbacks(dln2, id, echo, data, len); ++ spin_unlock_irqrestore(&dln2->event_cb_lock, flags); + } else { + /* URB will be re-submitted in _dln2_transfer (free_rx_slot) */ + if (dln2_transfer_complete(dln2, urb, handle, echo)) +-- +2.25.1 + diff --git a/queue-4.14/net-qcom-emac-add-missed-clk_disable_unprepare-in-er.patch b/queue-4.14/net-qcom-emac-add-missed-clk_disable_unprepare-in-er.patch new file mode 100644 index 00000000000..0dd4a270fc5 --- /dev/null +++ b/queue-4.14/net-qcom-emac-add-missed-clk_disable_unprepare-in-er.patch @@ -0,0 +1,58 @@ +From b749ee2b181060b414d4b3b0484c1bf2c82f4dff Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 10 Aug 2020 10:57:05 +0800 +Subject: net: qcom/emac: add missed clk_disable_unprepare in error path of + emac_clks_phase1_init + +From: Wang Hai + +[ Upstream commit 50caa777a3a24d7027748e96265728ce748b41ef ] + +Fix the missing clk_disable_unprepare() before return +from emac_clks_phase1_init() in the error handling case. + +Fixes: b9b17debc69d ("net: emac: emac gigabit ethernet controller driver") +Reported-by: Hulk Robot +Signed-off-by: Wang Hai +Acked-by: Timur Tabi +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/qualcomm/emac/emac.c | 17 ++++++++++++++--- + 1 file changed, 14 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/ethernet/qualcomm/emac/emac.c b/drivers/net/ethernet/qualcomm/emac/emac.c +index 759543512117c..5ab83751a471f 100644 +--- a/drivers/net/ethernet/qualcomm/emac/emac.c ++++ b/drivers/net/ethernet/qualcomm/emac/emac.c +@@ -493,13 +493,24 @@ static int emac_clks_phase1_init(struct platform_device *pdev, + + ret = clk_prepare_enable(adpt->clk[EMAC_CLK_CFG_AHB]); + if (ret) +- return ret; ++ goto disable_clk_axi; + + ret = clk_set_rate(adpt->clk[EMAC_CLK_HIGH_SPEED], 19200000); + if (ret) +- return ret; ++ goto disable_clk_cfg_ahb; ++ ++ ret = clk_prepare_enable(adpt->clk[EMAC_CLK_HIGH_SPEED]); ++ if (ret) ++ goto disable_clk_cfg_ahb; + +- return clk_prepare_enable(adpt->clk[EMAC_CLK_HIGH_SPEED]); ++ return 0; ++ ++disable_clk_cfg_ahb: ++ clk_disable_unprepare(adpt->clk[EMAC_CLK_CFG_AHB]); ++disable_clk_axi: ++ clk_disable_unprepare(adpt->clk[EMAC_CLK_AXI]); ++ ++ return ret; + } + + /* Enable clocks; needs emac_clks_phase1_init to be called before */ +-- +2.25.1 + diff --git a/queue-4.14/nfs-fix-getxattr-kernel-panic-and-memory-overflow.patch b/queue-4.14/nfs-fix-getxattr-kernel-panic-and-memory-overflow.patch new file mode 100644 index 00000000000..d31cd435255 --- /dev/null +++ b/queue-4.14/nfs-fix-getxattr-kernel-panic-and-memory-overflow.patch @@ -0,0 +1,55 @@ +From 5b3b5f8869f730f63307c0acd44c2385877cdae4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 5 Aug 2020 12:23:19 -0500 +Subject: nfs: Fix getxattr kernel panic and memory overflow + +From: Jeffrey Mitchell + +[ Upstream commit b4487b93545214a9db8cbf32e86411677b0cca21 ] + +Move the buffer size check to decode_attr_security_label() before memcpy() +Only call memcpy() if the buffer is large enough + +Fixes: aa9c2669626c ("NFS: Client implementation of Labeled-NFS") +Signed-off-by: Jeffrey Mitchell +[Trond: clean up duplicate test of label->len != 0] +Signed-off-by: Trond Myklebust +Signed-off-by: Sasha Levin +--- + fs/nfs/nfs4proc.c | 2 -- + fs/nfs/nfs4xdr.c | 6 +++++- + 2 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c +index a19bbcfab7c5e..4cfb84119e017 100644 +--- a/fs/nfs/nfs4proc.c ++++ b/fs/nfs/nfs4proc.c +@@ -5323,8 +5323,6 @@ static int _nfs4_get_security_label(struct inode *inode, void *buf, + return ret; + if (!(fattr.valid & NFS_ATTR_FATTR_V4_SECURITY_LABEL)) + return -ENOENT; +- if (buflen < label.len) +- return -ERANGE; + return 0; + } + +diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c +index 0b2d051990e99..3cd04c98da6bc 100644 +--- a/fs/nfs/nfs4xdr.c ++++ b/fs/nfs/nfs4xdr.c +@@ -4258,7 +4258,11 @@ static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap, + goto out_overflow; + if (len < NFS4_MAXLABELLEN) { + if (label) { +- memcpy(label->label, p, len); ++ if (label->len) { ++ if (label->len < len) ++ return -ERANGE; ++ memcpy(label->label, p, len); ++ } + label->len = len; + label->pi = pi; + label->lfs = lfs; +-- +2.25.1 + diff --git a/queue-4.14/perf-bench-mem-always-memset-source-before-memcpy.patch b/queue-4.14/perf-bench-mem-always-memset-source-before-memcpy.patch new file mode 100644 index 00000000000..387355803fe --- /dev/null +++ b/queue-4.14/perf-bench-mem-always-memset-source-before-memcpy.patch @@ -0,0 +1,105 @@ +From e871fe93689588f74120d01596c6bc30ced00986 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 10 Aug 2020 15:34:04 +0200 +Subject: perf bench mem: Always memset source before memcpy + +From: Vincent Whitchurch + +[ Upstream commit 1beaef29c34154ccdcb3f1ae557f6883eda18840 ] + +For memcpy, the source pages are memset to zero only when --cycles is +used. This leads to wildly different results with or without --cycles, +since all sources pages are likely to be mapped to the same zero page +without explicit writes. + +Before this fix: + +$ export cmd="./perf stat -e LLC-loads -- ./perf bench \ + mem memcpy -s 1024MB -l 100 -f default" +$ $cmd + + 2,935,826 LLC-loads + 3.821677452 seconds time elapsed + +$ $cmd --cycles + + 217,533,436 LLC-loads + 8.616725985 seconds time elapsed + +After this fix: + +$ $cmd + + 214,459,686 LLC-loads + 8.674301124 seconds time elapsed + +$ $cmd --cycles + + 214,758,651 LLC-loads + 8.644480006 seconds time elapsed + +Fixes: 47b5757bac03c338 ("perf bench mem: Move boilerplate memory allocation to the infrastructure") +Signed-off-by: Vincent Whitchurch +Cc: Alexander Shishkin +Cc: Jiri Olsa +Cc: Mark Rutland +Cc: Namhyung Kim +Cc: Peter Zijlstra +Cc: kernel@axis.com +Link: http://lore.kernel.org/lkml/20200810133404.30829-1-vincent.whitchurch@axis.com +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Sasha Levin +--- + tools/perf/bench/mem-functions.c | 21 +++++++++++---------- + 1 file changed, 11 insertions(+), 10 deletions(-) + +diff --git a/tools/perf/bench/mem-functions.c b/tools/perf/bench/mem-functions.c +index 0251dd348124a..4864fc67d01b5 100644 +--- a/tools/perf/bench/mem-functions.c ++++ b/tools/perf/bench/mem-functions.c +@@ -222,12 +222,8 @@ static int bench_mem_common(int argc, const char **argv, struct bench_mem_info * + return 0; + } + +-static u64 do_memcpy_cycles(const struct function *r, size_t size, void *src, void *dst) ++static void memcpy_prefault(memcpy_t fn, size_t size, void *src, void *dst) + { +- u64 cycle_start = 0ULL, cycle_end = 0ULL; +- memcpy_t fn = r->fn.memcpy; +- int i; +- + /* Make sure to always prefault zero pages even if MMAP_THRESH is crossed: */ + memset(src, 0, size); + +@@ -236,6 +232,15 @@ static u64 do_memcpy_cycles(const struct function *r, size_t size, void *src, vo + * to not measure page fault overhead: + */ + fn(dst, src, size); ++} ++ ++static u64 do_memcpy_cycles(const struct function *r, size_t size, void *src, void *dst) ++{ ++ u64 cycle_start = 0ULL, cycle_end = 0ULL; ++ memcpy_t fn = r->fn.memcpy; ++ int i; ++ ++ memcpy_prefault(fn, size, src, dst); + + cycle_start = get_cycles(); + for (i = 0; i < nr_loops; ++i) +@@ -251,11 +256,7 @@ static double do_memcpy_gettimeofday(const struct function *r, size_t size, void + memcpy_t fn = r->fn.memcpy; + int i; + +- /* +- * We prefault the freshly allocated memory range here, +- * to not measure page fault overhead: +- */ +- fn(dst, src, size); ++ memcpy_prefault(fn, size, src, dst); + + BUG_ON(gettimeofday(&tv_start, NULL)); + for (i = 0; i < nr_loops; ++i) +-- +2.25.1 + diff --git a/queue-4.14/pwm-bcm-iproc-handle-clk_get_rate-return.patch b/queue-4.14/pwm-bcm-iproc-handle-clk_get_rate-return.patch new file mode 100644 index 00000000000..6eefe6f53d8 --- /dev/null +++ b/queue-4.14/pwm-bcm-iproc-handle-clk_get_rate-return.patch @@ -0,0 +1,55 @@ +From 7e8934c969a666a88fd99664063d9ec7fb5bd8d9 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 17 Jul 2020 21:46:06 -0700 +Subject: pwm: bcm-iproc: handle clk_get_rate() return +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Rayagonda Kokatanur + +[ Upstream commit 6ced5ff0be8e94871ba846dfbddf69d21363f3d7 ] + +Handle clk_get_rate() returning 0 to avoid possible division by zero. + +Fixes: daa5abc41c80 ("pwm: Add support for Broadcom iProc PWM controller") +Signed-off-by: Rayagonda Kokatanur +Signed-off-by: Scott Branden +Reviewed-by: Ray Jui +Reviewed-by: Uwe Kleine-König +Signed-off-by: Thierry Reding +Signed-off-by: Sasha Levin +--- + drivers/pwm/pwm-bcm-iproc.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/drivers/pwm/pwm-bcm-iproc.c b/drivers/pwm/pwm-bcm-iproc.c +index 31b01035d0ab3..8cfba3614e601 100644 +--- a/drivers/pwm/pwm-bcm-iproc.c ++++ b/drivers/pwm/pwm-bcm-iproc.c +@@ -85,8 +85,6 @@ static void iproc_pwmc_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + u64 tmp, multi, rate; + u32 value, prescale; + +- rate = clk_get_rate(ip->clk); +- + value = readl(ip->base + IPROC_PWM_CTRL_OFFSET); + + if (value & BIT(IPROC_PWM_CTRL_EN_SHIFT(pwm->hwpwm))) +@@ -99,6 +97,13 @@ static void iproc_pwmc_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + else + state->polarity = PWM_POLARITY_INVERSED; + ++ rate = clk_get_rate(ip->clk); ++ if (rate == 0) { ++ state->period = 0; ++ state->duty_cycle = 0; ++ return; ++ } ++ + value = readl(ip->base + IPROC_PWM_PRESCALE_OFFSET); + prescale = value >> IPROC_PWM_PRESCALE_SHIFT(pwm->hwpwm); + prescale &= IPROC_PWM_PRESCALE_MAX; +-- +2.25.1 + diff --git a/queue-4.14/rdma-ipoib-return-void-from-ipoib_ib_dev_stop.patch b/queue-4.14/rdma-ipoib-return-void-from-ipoib_ib_dev_stop.patch new file mode 100644 index 00000000000..876ccabdaa7 --- /dev/null +++ b/queue-4.14/rdma-ipoib-return-void-from-ipoib_ib_dev_stop.patch @@ -0,0 +1,59 @@ +From 599e46311117ecac5798e1a9dd5fbac104c5462f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 23 Jun 2020 13:52:36 +0300 +Subject: RDMA/ipoib: Return void from ipoib_ib_dev_stop() + +From: Kamal Heib + +[ Upstream commit 95a5631f6c9f3045f26245e6045244652204dfdb ] + +The return value from ipoib_ib_dev_stop() is always 0 - change it to be +void. + +Link: https://lore.kernel.org/r/20200623105236.18683-1-kamalheib1@gmail.com +Signed-off-by: Kamal Heib +Signed-off-by: Jason Gunthorpe +Signed-off-by: Sasha Levin +--- + drivers/infiniband/ulp/ipoib/ipoib.h | 2 +- + drivers/infiniband/ulp/ipoib/ipoib_ib.c | 4 +--- + 2 files changed, 2 insertions(+), 4 deletions(-) + +diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h +index 4a5c7a07a6315..268e23ba4a636 100644 +--- a/drivers/infiniband/ulp/ipoib/ipoib.h ++++ b/drivers/infiniband/ulp/ipoib/ipoib.h +@@ -509,7 +509,7 @@ void ipoib_ib_dev_cleanup(struct net_device *dev); + + int ipoib_ib_dev_open_default(struct net_device *dev); + int ipoib_ib_dev_open(struct net_device *dev); +-int ipoib_ib_dev_stop(struct net_device *dev); ++void ipoib_ib_dev_stop(struct net_device *dev); + void ipoib_ib_dev_up(struct net_device *dev); + void ipoib_ib_dev_down(struct net_device *dev); + int ipoib_ib_dev_stop_default(struct net_device *dev); +diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c +index d77e8e2ae05f2..8e1f48fe6f2e7 100644 +--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c ++++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c +@@ -809,7 +809,7 @@ int ipoib_ib_dev_stop_default(struct net_device *dev) + return 0; + } + +-int ipoib_ib_dev_stop(struct net_device *dev) ++void ipoib_ib_dev_stop(struct net_device *dev) + { + struct ipoib_dev_priv *priv = ipoib_priv(dev); + +@@ -817,8 +817,6 @@ int ipoib_ib_dev_stop(struct net_device *dev) + + clear_bit(IPOIB_FLAG_INITIALIZED, &priv->flags); + ipoib_flush_ah(dev); +- +- return 0; + } + + void ipoib_ib_tx_timer_func(unsigned long ctx) +-- +2.25.1 + diff --git a/queue-4.14/series b/queue-4.14/series index 7edf0e651f9..72f6d59e85e 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -192,3 +192,29 @@ watchdog-f71808e_wdt-clear-watchdog-timeout-occurred-flag.patch pseries-fix-64-bit-logical-memory-block-panic.patch perf-intel-pt-fix-fup-packet-state.patch drm-imx-imx-ldb-disable-both-channels-for-split-mode-in-enc-disable.patch +mfd-arizona-ensure-32k-clock-is-put-on-driver-unbind.patch +rdma-ipoib-return-void-from-ipoib_ib_dev_stop.patch +usb-serial-ftdi_sio-make-process-packet-buffer-unsig.patch +usb-serial-ftdi_sio-clean-up-receive-processing.patch +usb-serial-ftdi_sio-fix-break-and-sysrq-handling.patch +gpu-ipu-v3-image-convert-combine-rotate-no-rotate-ir.patch +dm-rq-don-t-call-blk_mq_queue_stopped-in-dm_stop_que.patch +iommu-omap-check-for-failure-of-a-call-to-omap_iommu.patch +iommu-vt-d-enforce-pasid-devtlb-field-mask.patch +i2c-rcar-slave-only-send-stop-event-when-we-have-bee.patch +clk-clk-atlas6-fix-return-value-check-in-atlas6_clk_.patch +pwm-bcm-iproc-handle-clk_get_rate-return.patch +tools-build-feature-use-cc-and-cxx-from-parent.patch +i2c-rcar-avoid-race-when-unregistering-slave.patch +input-sentelic-fix-error-return-when-fsp_reg_write-f.patch +drm-vmwgfx-use-correct-vmw_legacy_display_unit-point.patch +drm-vmwgfx-fix-two-list_for_each-loop-exit-tests.patch +net-qcom-emac-add-missed-clk_disable_unprepare-in-er.patch +nfs-fix-getxattr-kernel-panic-and-memory-overflow.patch +fs-ufs-avoid-potential-u32-multiplication-overflow.patch +test_kmod-avoid-potential-double-free-in-trigger_con.patch +mfd-dln2-run-event-handler-loop-under-spinlock.patch +alsa-echoaudio-fix-potential-oops-in-snd_echo_resume.patch +perf-bench-mem-always-memset-source-before-memcpy.patch +tools-build-feature-quote-cc-and-cxx-for-their-argum.patch +sh-landisk-add-missing-initialization-of-sh_io_port_.patch diff --git a/queue-4.14/sh-landisk-add-missing-initialization-of-sh_io_port_.patch b/queue-4.14/sh-landisk-add-missing-initialization-of-sh_io_port_.patch new file mode 100644 index 00000000000..896f3e13f05 --- /dev/null +++ b/queue-4.14/sh-landisk-add-missing-initialization-of-sh_io_port_.patch @@ -0,0 +1,45 @@ +From ff7eb55b3dcaf9c46fd9e671ac90ca6d62431a94 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 14 Aug 2020 14:42:45 +0200 +Subject: sh: landisk: Add missing initialization of sh_io_port_base + +From: Geert Uytterhoeven + +[ Upstream commit 0c64a0dce51faa9c706fdf1f957d6f19878f4b81 ] + +The Landisk setup code maps the CF IDE area using ioremap_prot(), and +passes the resulting virtual addresses to the pata_platform driver, +disguising them as I/O port addresses. Hence the pata_platform driver +translates them again using ioport_map(). +As CONFIG_GENERIC_IOMAP=n, and CONFIG_HAS_IOPORT_MAP=y, the +SuperH-specific mapping code in arch/sh/kernel/ioport.c translates +I/O port addresses to virtual addresses by adding sh_io_port_base, which +defaults to -1, thus breaking the assumption of an identity mapping. + +Fix this by setting sh_io_port_base to zero. + +Fixes: 37b7a97884ba64bf ("sh: machvec IO death.") +Signed-off-by: Geert Uytterhoeven +Signed-off-by: Rich Felker +Signed-off-by: Sasha Levin +--- + arch/sh/boards/mach-landisk/setup.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/arch/sh/boards/mach-landisk/setup.c b/arch/sh/boards/mach-landisk/setup.c +index f1147caebacf0..af69fb7fef7c7 100644 +--- a/arch/sh/boards/mach-landisk/setup.c ++++ b/arch/sh/boards/mach-landisk/setup.c +@@ -85,6 +85,9 @@ device_initcall(landisk_devices_setup); + + static void __init landisk_setup(char **cmdline_p) + { ++ /* I/O port identity mapping */ ++ __set_io_port_base(0); ++ + /* LED ON */ + __raw_writeb(__raw_readb(PA_LED) | 0x03, PA_LED); + +-- +2.25.1 + diff --git a/queue-4.14/test_kmod-avoid-potential-double-free-in-trigger_con.patch b/queue-4.14/test_kmod-avoid-potential-double-free-in-trigger_con.patch new file mode 100644 index 00000000000..0dc0c387b25 --- /dev/null +++ b/queue-4.14/test_kmod-avoid-potential-double-free-in-trigger_con.patch @@ -0,0 +1,65 @@ +From 9ecdd8acd249860ad8566575e776c90324a9b32a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 11 Aug 2020 18:36:16 -0700 +Subject: test_kmod: avoid potential double free in trigger_config_run_type() + +From: Tiezhu Yang + +[ Upstream commit 0776d1231bec0c7ab43baf440a3f5ef5f49dd795 ] + +Reset the member "test_fs" of the test configuration after a call of the +function "kfree_const" to a null pointer so that a double memory release +will not be performed. + +Fixes: d9c6a72d6fa2 ("kmod: add test driver to stress test the module loader") +Signed-off-by: Tiezhu Yang +Signed-off-by: Luis Chamberlain +Signed-off-by: Andrew Morton +Acked-by: Luis Chamberlain +Cc: Alexei Starovoitov +Cc: Al Viro +Cc: Christian Brauner +Cc: Chuck Lever +Cc: David Howells +Cc: David S. Miller +Cc: Greg Kroah-Hartman +Cc: Jakub Kicinski +Cc: James Morris +Cc: Jarkko Sakkinen +Cc: J. Bruce Fields +Cc: Jens Axboe +Cc: Josh Triplett +Cc: Kees Cook +Cc: Lars Ellenberg +Cc: Nikolay Aleksandrov +Cc: Philipp Reisner +Cc: Roopa Prabhu +Cc: "Serge E. Hallyn" +Cc: Sergei Trofimovich +Cc: Sergey Kvachonok +Cc: Shuah Khan +Cc: Tony Vroon +Cc: Christoph Hellwig +Link: http://lkml.kernel.org/r/20200610154923.27510-4-mcgrof@kernel.org +Signed-off-by: Linus Torvalds +Signed-off-by: Sasha Levin +--- + lib/test_kmod.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/test_kmod.c b/lib/test_kmod.c +index cf619795a1822..c0ce0156d54bb 100644 +--- a/lib/test_kmod.c ++++ b/lib/test_kmod.c +@@ -747,7 +747,7 @@ static int trigger_config_run_type(struct kmod_test_device *test_dev, + break; + case TEST_KMOD_FS_TYPE: + kfree_const(config->test_fs); +- config->test_driver = NULL; ++ config->test_fs = NULL; + copied = config_copy_test_fs(config, test_str, + strlen(test_str)); + break; +-- +2.25.1 + diff --git a/queue-4.14/tools-build-feature-quote-cc-and-cxx-for-their-argum.patch b/queue-4.14/tools-build-feature-quote-cc-and-cxx-for-their-argum.patch new file mode 100644 index 00000000000..7328a2f63b1 --- /dev/null +++ b/queue-4.14/tools-build-feature-quote-cc-and-cxx-for-their-argum.patch @@ -0,0 +1,93 @@ +From e5e1e57bb43e16c92cd23f82f6c472b833b398c1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 12 Aug 2020 17:15:17 -0500 +Subject: tools build feature: Quote CC and CXX for their arguments +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Daniel Díaz + +[ Upstream commit fa5c893181ed2ca2f96552f50073786d2cfce6c0 ] + +When using a cross-compilation environment, such as OpenEmbedded, +the CC an CXX variables are set to something more than just a +command: there are arguments (such as --sysroot) that need to be +passed on to the compiler so that the right set of headers and +libraries are used. + +For the particular case that our systems detected, CC is set to +the following: + + export CC="aarch64-linaro-linux-gcc --sysroot=/oe/build/tmp/work/machine/perf/1.0-r9/recipe-sysroot" + +Without quotes, detection is as follows: + + Auto-detecting system features: + ... dwarf: [ OFF ] + ... dwarf_getlocations: [ OFF ] + ... glibc: [ OFF ] + ... gtk2: [ OFF ] + ... libbfd: [ OFF ] + ... libcap: [ OFF ] + ... libelf: [ OFF ] + ... libnuma: [ OFF ] + ... numa_num_possible_cpus: [ OFF ] + ... libperl: [ OFF ] + ... libpython: [ OFF ] + ... libcrypto: [ OFF ] + ... libunwind: [ OFF ] + ... libdw-dwarf-unwind: [ OFF ] + ... zlib: [ OFF ] + ... lzma: [ OFF ] + ... get_cpuid: [ OFF ] + ... bpf: [ OFF ] + ... libaio: [ OFF ] + ... libzstd: [ OFF ] + ... disassembler-four-args: [ OFF ] + + Makefile.config:414: *** No gnu/libc-version.h found, please install glibc-dev[el]. Stop. + Makefile.perf:230: recipe for target 'sub-make' failed + make[1]: *** [sub-make] Error 2 + Makefile:69: recipe for target 'all' failed + make: *** [all] Error 2 + +With CC and CXX quoted, some of those features are now detected. + +Fixes: e3232c2f39ac ("tools build feature: Use CC and CXX from parent") +Signed-off-by: Daniel Díaz +Reviewed-by: Thomas Hebb +Cc: Alexei Starovoitov +Cc: Andrii Nakryiko +Cc: Daniel Borkmann +Cc: Jiri Olsa +Cc: John Fastabend +Cc: KP Singh +Cc: Martin KaFai Lau +Cc: Namhyung Kim +Cc: Song Liu +Cc: Stephane Eranian +Cc: Yonghong Song +Link: http://lore.kernel.org/lkml/20200812221518.2869003-1-daniel.diaz@linaro.org +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Sasha Levin +--- + tools/build/Makefile.feature | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature +index a2389f0c0b1c0..79427b09590c5 100644 +--- a/tools/build/Makefile.feature ++++ b/tools/build/Makefile.feature +@@ -7,7 +7,7 @@ endif + + feature_check = $(eval $(feature_check_code)) + define feature_check_code +- feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CC=$(CC) CXX=$(CXX) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0) ++ feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CC="$(CC)" CXX="$(CXX)" CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0) + endef + + feature_set = $(eval $(feature_set_code)) +-- +2.25.1 + diff --git a/queue-4.14/tools-build-feature-use-cc-and-cxx-from-parent.patch b/queue-4.14/tools-build-feature-use-cc-and-cxx-from-parent.patch new file mode 100644 index 00000000000..f71bb6749a4 --- /dev/null +++ b/queue-4.14/tools-build-feature-use-cc-and-cxx-from-parent.patch @@ -0,0 +1,91 @@ +From 455c1cf067416e63b3b35e862dfe93b8dc796ab7 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 26 Jul 2020 21:08:14 -0700 +Subject: tools build feature: Use CC and CXX from parent + +From: Thomas Hebb + +[ Upstream commit e3232c2f39acafd5a29128425bc30b9884642cfa ] + +commit c8c188679ccf ("tools build: Use the same CC for feature detection +and actual build") changed these assignments from unconditional (:=) to +conditional (?=) so that they wouldn't clobber values from the +environment. However, conditional assignment does not work properly for +variables that Make implicitly sets, among which are CC and CXX. To +quote tools/scripts/Makefile.include, which handles this properly: + + # Makefiles suck: This macro sets a default value of $(2) for the + # variable named by $(1), unless the variable has been set by + # environment or command line. This is necessary for CC and AR + # because make sets default values, so the simpler ?= approach + # won't work as expected. + +In other words, the conditional assignments will not run even if the +variables are not overridden in the environment; Make will set CC to +"cc" and CXX to "g++" when it starts[1], meaning the variables are not +empty by the time the conditional assignments are evaluated. This breaks +cross-compilation when CROSS_COMPILE is set but CC isn't, since "cc" +gets used for feature detection instead of the cross compiler (and +likewise for CXX). + +To fix the issue, just pass down the values of CC and CXX computed by +the parent Makefile, which gets included by the Makefile that actually +builds whatever we're detecting features for and so is guaranteed to +have good values. This is a better solution anyway, since it means we +aren't trying to replicate the logic of the parent build system and so +don't risk it getting out of sync. + +Leave PKG_CONFIG alone, since 1) there's no common logic to compute it +in Makefile.include, and 2) it's not an implicit variable, so +conditional assignment works properly. + +[1] https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html + +Fixes: c8c188679ccf ("tools build: Use the same CC for feature detection and actual build") +Signed-off-by: Thomas Hebb +Acked-by: Jiri Olsa +Cc: David Carrillo-Cisneros +Cc: Ian Rogers +Cc: Igor Lubashev +Cc: Namhyung Kim +Cc: Quentin Monnet +Cc: Song Liu +Cc: Stephane Eranian +Cc: thomas hebb +Link: http://lore.kernel.org/lkml/0a6e69d1736b0fa231a648f50b0cce5d8a6734ef.1595822871.git.tommyhebb@gmail.com +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Sasha Levin +--- + tools/build/Makefile.feature | 2 +- + tools/build/feature/Makefile | 2 -- + 2 files changed, 1 insertion(+), 3 deletions(-) + +diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature +index c71a05b9c984f..a2389f0c0b1c0 100644 +--- a/tools/build/Makefile.feature ++++ b/tools/build/Makefile.feature +@@ -7,7 +7,7 @@ endif + + feature_check = $(eval $(feature_check_code)) + define feature_check_code +- feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0) ++ feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CC=$(CC) CXX=$(CXX) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0) + endef + + feature_set = $(eval $(feature_set_code)) +diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile +index 96982640fbf88..26316749e594a 100644 +--- a/tools/build/feature/Makefile ++++ b/tools/build/feature/Makefile +@@ -55,8 +55,6 @@ FILES= \ + + FILES := $(addprefix $(OUTPUT),$(FILES)) + +-CC ?= $(CROSS_COMPILE)gcc +-CXX ?= $(CROSS_COMPILE)g++ + PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config + LLVM_CONFIG ?= llvm-config + +-- +2.25.1 + diff --git a/queue-4.14/usb-serial-ftdi_sio-clean-up-receive-processing.patch b/queue-4.14/usb-serial-ftdi_sio-clean-up-receive-processing.patch new file mode 100644 index 00000000000..b1f977629c1 --- /dev/null +++ b/queue-4.14/usb-serial-ftdi_sio-clean-up-receive-processing.patch @@ -0,0 +1,75 @@ +From 7467d51bcaa9da0f37588fb19cadb6c8c76c26d4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 8 Jul 2020 14:49:52 +0200 +Subject: USB: serial: ftdi_sio: clean up receive processing + +From: Johan Hovold + +[ Upstream commit ce054039ba5e47b75a3be02a00274e52b06a6456 ] + +Clean up receive processing by dropping the character pointer and +keeping the length argument unchanged throughout the function. + +Also make it more apparent that sysrq processing can consume a +characters by adding an explicit continue. + +Reviewed-by: Greg Kroah-Hartman +Signed-off-by: Johan Hovold +Signed-off-by: Sasha Levin +--- + drivers/usb/serial/ftdi_sio.c | 19 +++++++++---------- + 1 file changed, 9 insertions(+), 10 deletions(-) + +diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c +index 4959fcac5e030..8abb30c797d30 100644 +--- a/drivers/usb/serial/ftdi_sio.c ++++ b/drivers/usb/serial/ftdi_sio.c +@@ -2045,7 +2045,6 @@ static int ftdi_process_packet(struct usb_serial_port *port, + struct ftdi_private *priv, unsigned char *buf, int len) + { + unsigned char status; +- unsigned char *ch; + int i; + char flag; + +@@ -2088,8 +2087,7 @@ static int ftdi_process_packet(struct usb_serial_port *port, + else + priv->transmit_empty = 0; + +- len -= 2; +- if (!len) ++ if (len == 2) + return 0; /* status only */ + + /* +@@ -2118,19 +2116,20 @@ static int ftdi_process_packet(struct usb_serial_port *port, + } + } + +- port->icount.rx += len; +- ch = buf + 2; ++ port->icount.rx += len - 2; + + if (port->port.console && port->sysrq) { +- for (i = 0; i < len; i++, ch++) { +- if (!usb_serial_handle_sysrq_char(port, *ch)) +- tty_insert_flip_char(&port->port, *ch, flag); ++ for (i = 2; i < len; i++) { ++ if (usb_serial_handle_sysrq_char(port, buf[i])) ++ continue; ++ tty_insert_flip_char(&port->port, buf[i], flag); + } + } else { +- tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len); ++ tty_insert_flip_string_fixed_flag(&port->port, buf + 2, flag, ++ len - 2); + } + +- return len; ++ return len - 2; + } + + static void ftdi_process_read_urb(struct urb *urb) +-- +2.25.1 + diff --git a/queue-4.14/usb-serial-ftdi_sio-fix-break-and-sysrq-handling.patch b/queue-4.14/usb-serial-ftdi_sio-fix-break-and-sysrq-handling.patch new file mode 100644 index 00000000000..a34b8f2c068 --- /dev/null +++ b/queue-4.14/usb-serial-ftdi_sio-fix-break-and-sysrq-handling.patch @@ -0,0 +1,87 @@ +From 4965e3b95521b5704752fd5a08a02d3acbc2ec91 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 8 Jul 2020 14:49:53 +0200 +Subject: USB: serial: ftdi_sio: fix break and sysrq handling + +From: Johan Hovold + +[ Upstream commit 733fff67941dad64b8a630450b8372b1873edc41 ] + +Only the last NUL in a packet should be flagged as a break character, +for example, to avoid dropping unrelated characters when IGNBRK is set. + +Also make sysrq work by consuming the break character instead of having +it immediately cancel the sysrq request, and by not processing it +prematurely to avoid triggering a sysrq based on an unrelated character +received in the same packet (which was received *before* the break). + +Note that the break flag can be left set also for a packet received +immediately following a break and that and an ending NUL in such a +packet will continue to be reported as a break as there's no good way to +tell it apart from an actual break. + +Tested on FT232R and FT232H. + +Fixes: 72fda3ca6fc1 ("USB: serial: ftd_sio: implement sysrq handling on break") +Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") +Reviewed-by: Greg Kroah-Hartman +Signed-off-by: Johan Hovold +Signed-off-by: Sasha Levin +--- + drivers/usb/serial/ftdi_sio.c | 24 +++++++++++++++++------- + 1 file changed, 17 insertions(+), 7 deletions(-) + +diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c +index 8abb30c797d30..0574bf03b3171 100644 +--- a/drivers/usb/serial/ftdi_sio.c ++++ b/drivers/usb/serial/ftdi_sio.c +@@ -2045,6 +2045,7 @@ static int ftdi_process_packet(struct usb_serial_port *port, + struct ftdi_private *priv, unsigned char *buf, int len) + { + unsigned char status; ++ bool brkint = false; + int i; + char flag; + +@@ -2096,13 +2097,17 @@ static int ftdi_process_packet(struct usb_serial_port *port, + */ + flag = TTY_NORMAL; + if (buf[1] & FTDI_RS_ERR_MASK) { +- /* Break takes precedence over parity, which takes precedence +- * over framing errors */ +- if (buf[1] & FTDI_RS_BI) { +- flag = TTY_BREAK; ++ /* ++ * Break takes precedence over parity, which takes precedence ++ * over framing errors. Note that break is only associated ++ * with the last character in the buffer and only when it's a ++ * NUL. ++ */ ++ if (buf[1] & FTDI_RS_BI && buf[len - 1] == '\0') { + port->icount.brk++; +- usb_serial_handle_break(port); +- } else if (buf[1] & FTDI_RS_PE) { ++ brkint = true; ++ } ++ if (buf[1] & FTDI_RS_PE) { + flag = TTY_PARITY; + port->icount.parity++; + } else if (buf[1] & FTDI_RS_FE) { +@@ -2118,8 +2123,13 @@ static int ftdi_process_packet(struct usb_serial_port *port, + + port->icount.rx += len - 2; + +- if (port->port.console && port->sysrq) { ++ if (brkint || (port->port.console && port->sysrq)) { + for (i = 2; i < len; i++) { ++ if (brkint && i == len - 1) { ++ if (usb_serial_handle_break(port)) ++ return len - 3; ++ flag = TTY_BREAK; ++ } + if (usb_serial_handle_sysrq_char(port, buf[i])) + continue; + tty_insert_flip_char(&port->port, buf[i], flag); +-- +2.25.1 + diff --git a/queue-4.14/usb-serial-ftdi_sio-make-process-packet-buffer-unsig.patch b/queue-4.14/usb-serial-ftdi_sio-make-process-packet-buffer-unsig.patch new file mode 100644 index 00000000000..df0208ad0ae --- /dev/null +++ b/queue-4.14/usb-serial-ftdi_sio-make-process-packet-buffer-unsig.patch @@ -0,0 +1,96 @@ +From fcc3a7f29cccd5cc1dba26ac972f16b3876c6f11 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 8 Jul 2020 14:49:51 +0200 +Subject: USB: serial: ftdi_sio: make process-packet buffer unsigned + +From: Johan Hovold + +[ Upstream commit ab4cc4ef6724ea588e835fc1e764c4b4407a70b7 ] + +Use an unsigned type for the process-packet buffer argument and give it +a more apt name. + +Reviewed-by: Greg Kroah-Hartman +Signed-off-by: Johan Hovold +Signed-off-by: Sasha Levin +--- + drivers/usb/serial/ftdi_sio.c | 22 +++++++++++----------- + 1 file changed, 11 insertions(+), 11 deletions(-) + +diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c +index a962065227c48..4959fcac5e030 100644 +--- a/drivers/usb/serial/ftdi_sio.c ++++ b/drivers/usb/serial/ftdi_sio.c +@@ -2042,12 +2042,12 @@ static int ftdi_prepare_write_buffer(struct usb_serial_port *port, + #define FTDI_RS_ERR_MASK (FTDI_RS_BI | FTDI_RS_PE | FTDI_RS_FE | FTDI_RS_OE) + + static int ftdi_process_packet(struct usb_serial_port *port, +- struct ftdi_private *priv, char *packet, int len) ++ struct ftdi_private *priv, unsigned char *buf, int len) + { ++ unsigned char status; ++ unsigned char *ch; + int i; +- char status; + char flag; +- char *ch; + + if (len < 2) { + dev_dbg(&port->dev, "malformed packet\n"); +@@ -2057,7 +2057,7 @@ static int ftdi_process_packet(struct usb_serial_port *port, + /* Compare new line status to the old one, signal if different/ + N.B. packet may be processed more than once, but differences + are only processed once. */ +- status = packet[0] & FTDI_STATUS_B0_MASK; ++ status = buf[0] & FTDI_STATUS_B0_MASK; + if (status != priv->prev_status) { + char diff_status = status ^ priv->prev_status; + +@@ -2083,7 +2083,7 @@ static int ftdi_process_packet(struct usb_serial_port *port, + } + + /* save if the transmitter is empty or not */ +- if (packet[1] & FTDI_RS_TEMT) ++ if (buf[1] & FTDI_RS_TEMT) + priv->transmit_empty = 1; + else + priv->transmit_empty = 0; +@@ -2097,29 +2097,29 @@ static int ftdi_process_packet(struct usb_serial_port *port, + * data payload to avoid over-reporting. + */ + flag = TTY_NORMAL; +- if (packet[1] & FTDI_RS_ERR_MASK) { ++ if (buf[1] & FTDI_RS_ERR_MASK) { + /* Break takes precedence over parity, which takes precedence + * over framing errors */ +- if (packet[1] & FTDI_RS_BI) { ++ if (buf[1] & FTDI_RS_BI) { + flag = TTY_BREAK; + port->icount.brk++; + usb_serial_handle_break(port); +- } else if (packet[1] & FTDI_RS_PE) { ++ } else if (buf[1] & FTDI_RS_PE) { + flag = TTY_PARITY; + port->icount.parity++; +- } else if (packet[1] & FTDI_RS_FE) { ++ } else if (buf[1] & FTDI_RS_FE) { + flag = TTY_FRAME; + port->icount.frame++; + } + /* Overrun is special, not associated with a char */ +- if (packet[1] & FTDI_RS_OE) { ++ if (buf[1] & FTDI_RS_OE) { + port->icount.overrun++; + tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); + } + } + + port->icount.rx += len; +- ch = packet + 2; ++ ch = buf + 2; + + if (port->port.console && port->sysrq) { + for (i = 0; i < len; i++, ch++) { +-- +2.25.1 +