In message: [PATCH][linux-yocto linux-yocto/v5.10/standard/nxp-sdk-5.10/nxp-s32g2xx] s32-gen1: spi-fsl-qspi: use devm_ioremap instead of ioremap_cache on 15/02/2022 [email protected] wrote:
> From: Quanyang Wang <[email protected]> > > In the document "S32G2 Reference Manual" Section 38.1.4, it says that > "QuadSPI AHB region 00000000h-1FFFFFFF is non-cacheable". So we > shouldn't use ioremap_cache to map this region since the system will > consider this region as normal cacheable memory. Let's use devm_ioremap > instead of ioremap_cache to avoid the calltrace as following: > > Internal error: synchronous external abort: 96000210 [#1] PREEMPT SMP > Modules linked in: > CPU: 1 PID: 346 Comm: mtd_debug Not tainted 5.10.41-rt42 #46 > Hardware name: Freescale S32G274A (DT) > pstate: 20000005 (nzCv daif -PAN -UAO -TCO BTYPE=--) > pc : __memcpy_fromio+0x48/0x98 > lr : s32gen1_exec_op+0xfc/0x288 > sp : ffffffc01132b750 > x29: ffffffc01132b750 x28: ffffffc01132be30 > x27: 00000055a7dfd2a0 x26: 0000000000000000 > x25: 00000000030f00cc x24: ffffffc01105d000 > x23: 0000000000000000 x22: ffffff8800bec600 > x21: ffffff88036c5100 x20: ffffffc01132bb00 > x19: ffffff8800be8600 x18: 0000000000000000 > x17: 0000000000000000 x16: 0000000000000000 > x15: 0000000000000000 x14: 0000000000000000 > x13: 0000000000000001 x12: 0000000000000108 > x11: 00000000000000ee x10: 0000000000000004 > x9 : 0000000000000000 x8 : 000000007b08765a > x7 : 00287fe501ca1225 x6 : 0000000000000010 > x5 : 0000000034f0ba34 x4 : ffffffc014000000 > x3 : ffffff8804730f10 x2 : 0000000000000010 > x1 : ffffffc014000000 x0 : ffffff8804730f00 > Call trace: > __memcpy_fromio+0x48/0x98 > spi_mem_exec_op+0x36c/0x3a0 > spi_mem_no_dirmap_read+0x98/0xb0 > spi_mem_dirmap_read+0xb8/0x140 > spi_nor_read_data+0x114/0x180 > spi_nor_read+0x94/0x110 > mtd_read_oob_std+0x78/0x88 > mtd_read_oob+0x7c/0x138 > mtd_read+0x48/0x78 > mtdchar_read+0x114/0x2a0 > vfs_read+0xac/0x1a0 > ksys_read+0x6c/0x100 > __arm64_sys_read+0x1c/0x28 > el0_svc_common.constprop.0+0x78/0x1a0 > do_el0_svc+0x24/0x90 > el0_svc+0x14/0x20 > el0_sync_handler+0xb0/0xb8 > el0_sync+0x180/0x1c0 > Code: aa0103e4 927df0c6 910020c6 8b060003 (f9400085) > > Furthermore, revert "s32-gen1: spi-fsl-qspi: Map AHB buffer at first > read from QSPI" to unify the code with other SOCs. > > Signed-off-by: Quanyang Wang <[email protected]> > --- > Hi Bruce, > > Would you please help merge this patch to the branches: > linux-yocto v5.10/standard/nxp-sdk-5.10/nxp-s32g2xx > linux-yocto v5.10/standard/preempt-rt/nxp-sdk-5.10/nxp-s32g2xx merged. Bruce > > Thanks, > Quanyang > --- > drivers/spi/s32gen1-qspi.c | 11 ----------- > drivers/spi/spi-fsl-qspi.c | 15 +++++---------- > 2 files changed, 5 insertions(+), 21 deletions(-) > > diff --git a/drivers/spi/s32gen1-qspi.c b/drivers/spi/s32gen1-qspi.c > index 12608915a22e..2d456045cbd0 100644 > --- a/drivers/spi/s32gen1-qspi.c > +++ b/drivers/spi/s32gen1-qspi.c > @@ -6,8 +6,6 @@ > #include <linux/mtd/spi-nor.h> > #include <linux/types.h> > #include <linux/mm.h> > -#include <linux/cache.h> > -#include <asm/cacheflush.h> > #include <linux/ktime.h> > #include <linux/math64.h> > #include <asm/div64.h> > @@ -1018,21 +1016,12 @@ static int qspi_read_mem(struct fsl_qspi *q, > u64 mb_int, mb_frac; > u32 us_passed, rem; > > - if (!q->ahb_addr) { > - q->ahb_addr = ioremap_cache(QUADSPI_AHB_BASE, > - q->devtype_data->ahb_buf_size); > - if (!q->ahb_addr) > - return -ENOMEM; > - } > - > while (qspi_readl(q, base + QUADSPI_SR) & QUADSPI_SR_BUSY_MASK) > ; > mcr_reg = clear_fifos(q); > qspi_writel(q, lut_cfg << QUADSPI_BFGENCR_SEQID_SHIFT, > base + QUADSPI_BFGENCR); > > - __inval_dcache_area((void __force *)q->ahb_addr + op->addr.val, > op->data.nbytes); > - > /* Read out the data directly from the AHB buffer. */ > ktime_get_ts64(&start); > memcpy_fromio(op->data.buf.in, q->ahb_addr + op->addr.val, > diff --git a/drivers/spi/spi-fsl-qspi.c b/drivers/spi/spi-fsl-qspi.c > index fc9e1efb566d..bc8959823654 100644 > --- a/drivers/spi/spi-fsl-qspi.c > +++ b/drivers/spi/spi-fsl-qspi.c > @@ -743,13 +743,11 @@ static int fsl_qspi_probe(struct platform_device *pdev) > "QuadSPI-memory"); > q->memmap_phy = res->start; > /* Since there are 4 cs, map size required is 4 times ahb_buf_size */ > - if (!is_s32gen1_qspi(q)) { > - q->ahb_addr = devm_ioremap(dev, q->memmap_phy, > - (q->devtype_data->ahb_buf_size * 4)); > - if (!q->ahb_addr) { > - ret = -ENOMEM; > - goto err_put_ctrl; > - } > + q->ahb_addr = devm_ioremap(dev, q->memmap_phy, > + (q->devtype_data->ahb_buf_size * 4)); > + if (!q->ahb_addr) { > + ret = -ENOMEM; > + goto err_put_ctrl; > } > > /* find the clocks */ > @@ -840,9 +838,6 @@ static int fsl_qspi_remove(struct platform_device *pdev) > { > struct fsl_qspi *q = platform_get_drvdata(pdev); > > - if (q->ahb_addr) > - iounmap(q->ahb_addr); > - > /* disable the hardware */ > qspi_writel(q, QUADSPI_MCR_MDIS_MASK, q->iobase + QUADSPI_MCR); > qspi_writel(q, 0x0, q->iobase + QUADSPI_RSER); > -- > 2.25.1 >
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#10953): https://lists.yoctoproject.org/g/linux-yocto/message/10953 Mute This Topic: https://lists.yoctoproject.org/mt/89156119/21656 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
