From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Thor Thayer <thor.thayer@linux.intel.com>,
Boris Brezillon <boris.brezillon@bootlin.com>,
Sasha Levin <sashal@kernel.org>,
linux-mtd@lists.infradead.org
Subject: [PATCH AUTOSEL 4.14 22/35] mtd: spi-nor: Fix Cadence QSPI page fault kernel panic
Date: Thu, 29 Nov 2018 01:00:56 -0500 [thread overview]
Message-ID: <20181129060110.159878-22-sashal@kernel.org> (raw)
In-Reply-To: <20181129060110.159878-1-sashal@kernel.org>
From: Thor Thayer <thor.thayer@linux.intel.com>
[ Upstream commit a6a66f80c85e8e20573ca03fabf32445954a88d5 ]
The current Cadence QSPI driver caused a kernel panic sporadically
when writing to QSPI. The problem was caused by writing more bytes
than needed because the QSPI operated on 4 bytes at a time.
<snip>
[ 11.202044] Unable to handle kernel paging request at virtual address bffd3000
[ 11.209254] pgd = e463054d
[ 11.211948] [bffd3000] *pgd=2fffb811, *pte=00000000, *ppte=00000000
[ 11.218202] Internal error: Oops: 7 [#1] SMP ARM
[ 11.222797] Modules linked in:
[ 11.225844] CPU: 1 PID: 1317 Comm: systemd-hwdb Not tainted 4.17.7-d0c45cd44a8f
[ 11.235796] Hardware name: Altera SOCFPGA Arria10
[ 11.240487] PC is at __raw_writesl+0x70/0xd4
[ 11.244741] LR is at cqspi_write+0x1a0/0x2cc
</snip>
On a page boundary limit the number of bytes copied from the tx buffer
to remain within the page.
This patch uses a temporary buffer to hold the 4 bytes to write and then
copies only the bytes required from the tx buffer.
Reported-by: Adrian Amborzewicz <adrian.ambrozewicz@intel.com>
Signed-off-by: Thor Thayer <thor.thayer@linux.intel.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/mtd/spi-nor/cadence-quadspi.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c b/drivers/mtd/spi-nor/cadence-quadspi.c
index 8d89204b90d2..f22dd34f4f83 100644
--- a/drivers/mtd/spi-nor/cadence-quadspi.c
+++ b/drivers/mtd/spi-nor/cadence-quadspi.c
@@ -625,9 +625,23 @@ static int cqspi_indirect_write_execute(struct spi_nor *nor,
reg_base + CQSPI_REG_INDIRECTWR);
while (remaining > 0) {
+ size_t write_words, mod_bytes;
+
write_bytes = remaining > page_size ? page_size : remaining;
- iowrite32_rep(cqspi->ahb_base, txbuf,
- DIV_ROUND_UP(write_bytes, 4));
+ write_words = write_bytes / 4;
+ mod_bytes = write_bytes % 4;
+ /* Write 4 bytes at a time then single bytes. */
+ if (write_words) {
+ iowrite32_rep(cqspi->ahb_base, txbuf, write_words);
+ txbuf += (write_words * 4);
+ }
+ if (mod_bytes) {
+ unsigned int temp = 0xFFFFFFFF;
+
+ memcpy(&temp, txbuf, mod_bytes);
+ iowrite32(temp, cqspi->ahb_base);
+ txbuf += mod_bytes;
+ }
ret = wait_for_completion_timeout(&cqspi->transfer_complete,
msecs_to_jiffies
@@ -638,7 +652,6 @@ static int cqspi_indirect_write_execute(struct spi_nor *nor,
goto failwr;
}
- txbuf += write_bytes;
remaining -= write_bytes;
if (remaining > 0)
--
2.17.1
next prev parent reply other threads:[~2018-11-29 6:02 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-29 6:00 [PATCH AUTOSEL 4.14 01/35] media: omap3isp: Unregister media device as first Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 02/35] iommu/vt-d: Fix NULL pointer dereference in prq_event_thread() Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 03/35] brcmutil: really fix decoding channel info for 160 MHz bandwidth Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 04/35] iommu/ipmmu-vmsa: Fix crash on early domain free Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 05/35] can: rcar_can: Fix erroneous registration Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 06/35] test_firmware: fix error return getting clobbered Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 07/35] HID: input: Ignore battery reported by Symbol DS4308 Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 08/35] batman-adv: Use explicit tvlv padding for ELP packets Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 09/35] batman-adv: Expand merged fragment buffer for full packet Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 10/35] amd/iommu: Fix Guest Virtual APIC Log Tail Address Register Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 11/35] bnx2x: Assign unique DMAE channel number for FW DMAE transactions Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 12/35] qed: Fix PTT leak in qed_drain() Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 13/35] qed: Fix reading wrong value in loop condition Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 14/35] Revert "usb: gadget: ffs: Fix BUG when userland exits with submitted AIO transfers" Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 15/35] net/mlx4_core: Zero out lkey field in SW2HW_MPT fw command Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 16/35] net/mlx4_core: Fix uninitialized variable compilation warning Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 17/35] net/mlx4: Fix UBSAN warning of signed integer overflow Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 18/35] gpio: mockup: fix indicated direction Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 19/35] mtd: rawnand: qcom: Namespace prefix some commands Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 20/35] exec: make de_thread() freezable Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 21/35] HID: multitouch: Add pointstick support for Cirque Touchpad Sasha Levin
2018-11-29 6:00 ` Sasha Levin [this message]
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 23/35] qed: Fix bitmap_weight() check Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 24/35] qed: Fix QM getters to always return a valid pq Sasha Levin
2018-11-29 6:00 ` [PATCH AUTOSEL 4.14 25/35] iomap: sub-block dio needs to zeroout beyond EOF Sasha Levin
2018-11-29 12:14 ` Dave Chinner
2018-11-29 12:47 ` Greg KH
2018-11-29 22:40 ` Dave Chinner
2018-11-30 8:22 ` Greg KH
2018-11-30 10:14 ` Sasha Levin
2018-11-30 20:35 ` Darrick J. Wong
2018-11-30 21:50 ` Dave Chinner
2018-12-01 7:49 ` Sasha Levin
2018-12-01 9:09 ` XFS patches for stable Amir Goldstein
2018-12-02 15:25 ` Sasha Levin
2018-12-02 16:10 ` Christoph Hellwig
2018-12-02 20:08 ` Greg KH
2018-12-03 14:41 ` Richard Weinberger
2018-12-03 16:56 ` Sasha Levin
2018-12-02 23:23 ` [PATCH AUTOSEL 4.14 25/35] iomap: sub-block dio needs to zeroout beyond EOF Dave Chinner
2018-12-03 7:11 ` Amir Goldstein
2018-12-03 9:22 ` Sasha Levin
2018-12-03 21:23 ` Thomas Backlund
2018-12-04 7:28 ` Greg KH
2018-12-04 8:12 ` Sasha Levin
2018-12-28 8:06 ` Pavel Machek
2018-12-29 23:35 ` Dave Chinner
2018-11-30 21:45 ` Dave Chinner
2018-12-02 20:11 ` Greg KH
2018-11-29 6:01 ` [PATCH AUTOSEL 4.14 26/35] net: faraday: ftmac100: remove netif_running(netdev) check before disabling interrupts Sasha Levin
2018-11-29 6:01 ` [PATCH AUTOSEL 4.14 27/35] iommu/vt-d: Use memunmap to free memremap Sasha Levin
2018-11-29 6:01 ` [PATCH AUTOSEL 4.14 28/35] flexfiles: use per-mirror specified stateid for IO Sasha Levin
2018-11-29 6:01 ` [PATCH AUTOSEL 4.14 29/35] net: thunderx: set xdp_prog to NULL if bpf_prog_add fails Sasha Levin
2018-11-29 6:01 ` [PATCH AUTOSEL 4.14 30/35] ibmvnic: Fix RX queue buffer cleanup Sasha Levin
2018-11-29 6:01 ` [PATCH AUTOSEL 4.14 31/35] virtio-net: disable guest csum during XDP set Sasha Levin
2018-11-29 6:01 ` [PATCH AUTOSEL 4.14 32/35] virtio-net: fail XDP set if guest csum is negotiated Sasha Levin
2018-11-29 6:01 ` [PATCH AUTOSEL 4.14 33/35] team: no need to do team_notify_peers or team_mcast_rejoin when disabling port Sasha Levin
2018-11-29 6:01 ` [PATCH AUTOSEL 4.14 34/35] net: amd: add missing of_node_put() Sasha Levin
2018-11-29 6:01 ` [PATCH AUTOSEL 4.14 35/35] net: thunderx: set tso_hdrs pointer to NULL in nicvf_free_snd_queue 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=20181129060110.159878-22-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=boris.brezillon@bootlin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=stable@vger.kernel.org \
--cc=thor.thayer@linux.intel.com \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).