From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Amelie Delaunay <amelie.delaunay@st.com>, Alain Volmat <alain.volmat@st.com>, Mark Brown <broonie@kernel.org>, Sasha Levin <sashal@kernel.org>, linux-spi@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.8 14/63] spi: stm32: fix fifo threshold level in case of short transfer Date: Mon, 24 Aug 2020 12:34:14 -0400 [thread overview] Message-ID: <20200824163504.605538-14-sashal@kernel.org> (raw) In-Reply-To: <20200824163504.605538-1-sashal@kernel.org> From: Amelie Delaunay <amelie.delaunay@st.com> [ Upstream commit 3373e9004acc0603242622b4378c64bc01d21b5f ] When transfer is shorter than half of the fifo, set the data packet size up to transfer size instead of up to half of the fifo. Check also that threshold is set at least to 1 data frame. Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Alain Volmat <alain.volmat@st.com> Link: https://lore.kernel.org/r/1597043558-29668-3-git-send-email-alain.volmat@st.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/spi/spi-stm32.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c index 814a3ec3b8ada..e5450233f3f8b 100644 --- a/drivers/spi/spi-stm32.c +++ b/drivers/spi/spi-stm32.c @@ -467,20 +467,27 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz, /** * stm32h7_spi_prepare_fthlv - Determine FIFO threshold level * @spi: pointer to the spi controller data structure + * @xfer_len: length of the message to be transferred */ -static u32 stm32h7_spi_prepare_fthlv(struct stm32_spi *spi) +static u32 stm32h7_spi_prepare_fthlv(struct stm32_spi *spi, u32 xfer_len) { - u32 fthlv, half_fifo; + u32 fthlv, half_fifo, packet; /* data packet should not exceed 1/2 of fifo space */ half_fifo = (spi->fifo_size / 2); + /* data_packet should not exceed transfer length */ + if (half_fifo > xfer_len) + packet = xfer_len; + else + packet = half_fifo; + if (spi->cur_bpw <= 8) - fthlv = half_fifo; + fthlv = packet; else if (spi->cur_bpw <= 16) - fthlv = half_fifo / 2; + fthlv = packet / 2; else - fthlv = half_fifo / 4; + fthlv = packet / 4; /* align packet size with data registers access */ if (spi->cur_bpw > 8) @@ -488,6 +495,9 @@ static u32 stm32h7_spi_prepare_fthlv(struct stm32_spi *spi) else fthlv -= (fthlv % 4); /* multiple of 4 */ + if (!fthlv) + fthlv = 1; + return fthlv; } @@ -1393,7 +1403,7 @@ static void stm32h7_spi_set_bpw(struct stm32_spi *spi) cfg1_setb |= (bpw << STM32H7_SPI_CFG1_DSIZE_SHIFT) & STM32H7_SPI_CFG1_DSIZE; - spi->cur_fthlv = stm32h7_spi_prepare_fthlv(spi); + spi->cur_fthlv = stm32h7_spi_prepare_fthlv(spi, spi->cur_xferlen); fthlv = spi->cur_fthlv - 1; cfg1_clrb |= STM32H7_SPI_CFG1_FTHLV; @@ -1588,6 +1598,8 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi *spi, spin_lock_irqsave(&spi->lock, flags); + spi->cur_xferlen = transfer->len; + if (spi->cur_bpw != transfer->bits_per_word) { spi->cur_bpw = transfer->bits_per_word; spi->cfg->set_bpw(spi); @@ -1635,8 +1647,6 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi *spi, goto out; } - spi->cur_xferlen = transfer->len; - dev_dbg(spi->dev, "transfer communication mode set to %d\n", spi->cur_comm); dev_dbg(spi->dev, -- 2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sasha Levin <sashal@kernel.org>, Amelie Delaunay <amelie.delaunay@st.com>, linux-spi@vger.kernel.org, Alain Volmat <alain.volmat@st.com>, Mark Brown <broonie@kernel.org>, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.8 14/63] spi: stm32: fix fifo threshold level in case of short transfer Date: Mon, 24 Aug 2020 12:34:14 -0400 [thread overview] Message-ID: <20200824163504.605538-14-sashal@kernel.org> (raw) In-Reply-To: <20200824163504.605538-1-sashal@kernel.org> From: Amelie Delaunay <amelie.delaunay@st.com> [ Upstream commit 3373e9004acc0603242622b4378c64bc01d21b5f ] When transfer is shorter than half of the fifo, set the data packet size up to transfer size instead of up to half of the fifo. Check also that threshold is set at least to 1 data frame. Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Alain Volmat <alain.volmat@st.com> Link: https://lore.kernel.org/r/1597043558-29668-3-git-send-email-alain.volmat@st.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/spi/spi-stm32.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c index 814a3ec3b8ada..e5450233f3f8b 100644 --- a/drivers/spi/spi-stm32.c +++ b/drivers/spi/spi-stm32.c @@ -467,20 +467,27 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz, /** * stm32h7_spi_prepare_fthlv - Determine FIFO threshold level * @spi: pointer to the spi controller data structure + * @xfer_len: length of the message to be transferred */ -static u32 stm32h7_spi_prepare_fthlv(struct stm32_spi *spi) +static u32 stm32h7_spi_prepare_fthlv(struct stm32_spi *spi, u32 xfer_len) { - u32 fthlv, half_fifo; + u32 fthlv, half_fifo, packet; /* data packet should not exceed 1/2 of fifo space */ half_fifo = (spi->fifo_size / 2); + /* data_packet should not exceed transfer length */ + if (half_fifo > xfer_len) + packet = xfer_len; + else + packet = half_fifo; + if (spi->cur_bpw <= 8) - fthlv = half_fifo; + fthlv = packet; else if (spi->cur_bpw <= 16) - fthlv = half_fifo / 2; + fthlv = packet / 2; else - fthlv = half_fifo / 4; + fthlv = packet / 4; /* align packet size with data registers access */ if (spi->cur_bpw > 8) @@ -488,6 +495,9 @@ static u32 stm32h7_spi_prepare_fthlv(struct stm32_spi *spi) else fthlv -= (fthlv % 4); /* multiple of 4 */ + if (!fthlv) + fthlv = 1; + return fthlv; } @@ -1393,7 +1403,7 @@ static void stm32h7_spi_set_bpw(struct stm32_spi *spi) cfg1_setb |= (bpw << STM32H7_SPI_CFG1_DSIZE_SHIFT) & STM32H7_SPI_CFG1_DSIZE; - spi->cur_fthlv = stm32h7_spi_prepare_fthlv(spi); + spi->cur_fthlv = stm32h7_spi_prepare_fthlv(spi, spi->cur_xferlen); fthlv = spi->cur_fthlv - 1; cfg1_clrb |= STM32H7_SPI_CFG1_FTHLV; @@ -1588,6 +1598,8 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi *spi, spin_lock_irqsave(&spi->lock, flags); + spi->cur_xferlen = transfer->len; + if (spi->cur_bpw != transfer->bits_per_word) { spi->cur_bpw = transfer->bits_per_word; spi->cfg->set_bpw(spi); @@ -1635,8 +1647,6 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi *spi, goto out; } - spi->cur_xferlen = transfer->len; - dev_dbg(spi->dev, "transfer communication mode set to %d\n", spi->cur_comm); dev_dbg(spi->dev, -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-08-24 16:39 UTC|newest] Thread overview: 109+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-08-24 16:34 [PATCH AUTOSEL 5.8 01/63] spi: stm32: clear only asserted irq flags on interrupt Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 02/63] jbd2: make sure jh have b_transaction set in refile/unfile_buffer Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 03/63] ext4: don't BUG on inconsistent journal feature Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 04/63] ext4: handle read only external journal device Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 05/63] ext4: skip non-loaded groups at cr=0/1 when scanning for good groups Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 06/63] drm/virtio: fix memory leak in virtio_gpu_cleanup_object() Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 07/63] ext4: abort the filesystem if failed to async write metadata buffer Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 08/63] jbd2: abort journal if free a async write error " Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 09/63] ext4: handle option set by mount flags correctly Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 10/63] ext4: handle error of ext4_setup_system_zone() on remount Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 11/63] ext4: correctly restore system zone info when remount fails Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 12/63] fs: prevent BUG_ON in submit_bh_wbc() Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 13/63] spi: stm32h7: fix race condition at end of transfer Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` Sasha Levin [this message] 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 14/63] spi: stm32: fix fifo threshold level in case of short transfer Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 15/63] spi: stm32: fix stm32_spi_prepare_mbr in case of odd clk_rate Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 16/63] spi: stm32: always perform registers configuration prior to transfer Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 17/63] drm/amd/powerplay: correct Vega20 cached smu feature state Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 18/63] drm/amd/powerplay: correct UVD/VCE PG state on custom pptable uploading Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 19/63] drm/amd/display: Fix LFC multiplier changing erratically Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 20/63] drm/amd/display: Switch to immediate mode for updating infopackets Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 21/63] selftests/bpf: Fix segmentation fault in test_progs Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 22/63] libbpf: Handle GCC built-in types for Arm NEON Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 23/63] netfilter: avoid ipv6 -> nf_defrag_ipv6 module dependency Sasha Levin 2020-08-24 16:34 ` [Bridge] " Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 24/63] libbpf: Prevent overriding errno when logging errors Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 25/63] tools/bpftool: Fix compilation warnings in 32-bit mode Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 26/63] selftest/bpf: " Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 27/63] selftests/bpf: Fix btf_dump test cases on 32-bit arches Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 28/63] selftests/bpf: Correct various core_reloc 64-bit assumptions Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 29/63] can: j1939: transport: j1939_xtp_rx_dat_one(): compare own packets to detect corruptions Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 30/63] dma-pool: fix coherent pool allocations for IOMMU mappings Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 31/63] dma-pool: Only allocate from CMA when in same memory zone Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 32/63] drivers/net/wan/hdlc_x25: Added needed_headroom and a skb->len check Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 33/63] ALSA: hda/realtek: Add model alc298-samsung-headphone Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 34/63] s390/cio: add cond_resched() in the slow_eval_known_fn() loop Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 35/63] ASoC: wm8994: Avoid attempts to read unreadable registers Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 36/63] ALSA: usb-audio: ignore broken processing/extension unit Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 37/63] selftests: disable rp_filter for icmp_redirect.sh Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 38/63] scsi: fcoe: Fix I/O path allocation Sasha Levin 2020-08-24 16:34 ` [Intel-wired-lan] " Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 39/63] scsi: ufs: Fix possible infinite loop in ufshcd_hold Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 40/63] scsi: ufs: Improve interrupt handling for shared interrupts Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 41/63] scsi: ufs: Clean up completed request without interrupt notification Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 42/63] scsi: scsi_debug: Fix scp is NULL errors Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 43/63] scsi: qla2xxx: Flush all sessions on zone disable Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 44/63] scsi: qla2xxx: Flush I/O " Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 45/63] scsi: qla2xxx: Indicate correct supported speeds for Mezz card Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 46/63] scsi: qla2xxx: Fix login timeout Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 47/63] scsi: qla2xxx: Check if FW supports MQ before enabling Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 48/63] scsi: qla2xxx: Fix null pointer access during disconnect from subsystem Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 49/63] Revert "scsi: qla2xxx: Fix crash on qla2x00_mailbox_command" Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 50/63] macvlan: validate setting of multiple remote source MAC addresses Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 51/63] net: gianfar: Add of_node_put() before goto statement Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 52/63] drm/amdgpu: disable gfxoff for navy_flounder Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 18:23 ` Alex Deucher 2020-08-24 18:23 ` Alex Deucher 2020-08-24 18:23 ` Alex Deucher 2020-08-30 22:41 ` Sasha Levin 2020-08-30 22:41 ` Sasha Levin 2020-08-30 22:41 ` Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 53/63] drm/amdgpu: fix NULL pointer access issue when unloading driver Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 54/63] drm/amdkfd: fix the wrong sdma instance query for renoir Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 55/63] bpf: Fix a rcu_sched stall issue with bpf task/task_file iterator Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 56/63] bpf: Avoid visit same object multiple times Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 57/63] ext4: limit the length of per-inode prealloc list Sasha Levin 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 58/63] Revert "drm/amdgpu: disable gfxoff for navy_flounder" Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 18:24 ` Alex Deucher 2020-08-24 18:24 ` Alex Deucher 2020-08-24 18:24 ` Alex Deucher 2020-08-24 16:34 ` [PATCH AUTOSEL 5.8 59/63] powerpc/perf: Fix soft lockups due to missed interrupt accounting Sasha Levin 2020-08-24 16:34 ` Sasha Levin 2020-08-24 16:35 ` [PATCH AUTOSEL 5.8 60/63] libbpf: Fix map index used in error message Sasha Levin 2020-08-24 16:35 ` [PATCH AUTOSEL 5.8 61/63] bpf: selftests: global_funcs: Check err_str before strstr Sasha Levin 2020-08-24 16:35 ` [PATCH AUTOSEL 5.8 62/63] arm64: Move handling of erratum 1418040 into C code Sasha Levin 2020-08-24 16:35 ` Sasha Levin 2020-08-24 16:35 ` [PATCH AUTOSEL 5.8 63/63] arm64: Allow booting of late CPUs affected by erratum 1418040 Sasha Levin 2020-08-24 16:35 ` Sasha Levin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200824163504.605538-14-sashal@kernel.org \ --to=sashal@kernel.org \ --cc=alain.volmat@st.com \ --cc=amelie.delaunay@st.com \ --cc=broonie@kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-spi@vger.kernel.org \ --cc=linux-stm32@st-md-mailman.stormreply.com \ --cc=stable@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.