Re: [PATCH linux-next v2 1/1] spi: imx: dynamic burst length adjust for PIO mode

From: Leonard Crestez
Date: Wed May 17 2017 - 13:33:32 EST


On Mon, 2017-05-01 at 03:31 -0700, jiada_wang@xxxxxxxxxx wrote:
> From: Jiada Wang <jiada_wang@xxxxxxxxxx>
>
> previously burst length (BURST_LENGTH) is always set to equal
> to bits_per_word, causes a 10us gap between each word in
> transfer, which significantly affects performance.
>
> This patch uses 32 bits transfer to simulate lower bits transfer,
> and adjusts burst length runtimely to use biggeest burst length
> as possible to reduce the gaps in transfer for PIO mode.
>
> Signed-off-by: Jiada Wang <jiada_wang@xxxxxxxxxx>
> ---
> Âdrivers/spi/spi-imx.c | 157 +++++++++++++++++++++++++++++++++++++++++++++++---
> Â1 file changed, 149 insertions(+), 8 deletions(-)

This patch made it's way to linux-next and broke boot on imx6dl-
sabreauto and imx6sl-evk boards (but others work). The crashes look
like this:

[ÂÂÂÂ1.442384] spi_imx 2008000.ecspi: dma setup error -19, use pio
[ÂÂÂÂ1.452930] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[ÂÂÂÂ1.461320] pgd = c0004000
[ÂÂÂÂ1.464078] [00000000] *pgd=00000000
[ÂÂÂÂ1.467821] Internal error: Oops: 5 [#1] SMP ARM
[ÂÂÂÂ1.472464] Modules linked in:
[ÂÂÂÂ1.475558] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.12.0-rc1-00001-g8d4a6ca #90
[ÂÂÂÂ1.483234] Hardware name: Freescale i.MX6 SoloLite (Device Tree)
[ÂÂÂÂ1.489349] task: ef058000 task.stack: ef054000
[ÂÂÂÂ1.493926] PC is at spi_imx_transfer+0x2d8/0x364
[ÂÂÂÂ1.498659] LR is at spi_bitbang_transfer_one+0x80/0xa0
[ÂÂÂÂ1.503910] pc : [<c05f6264>]ÂÂÂÂlr : [<c05f3440>]ÂÂÂÂpsr: 20000013
[ÂÂÂÂ1.503910] sp : ef0558b0ÂÂip : ef0558e0ÂÂfp : ef0558dc
[ÂÂÂÂ1.515412] r10: ee938a98ÂÂr9 : ef340c28ÂÂr8 : ee938800
[ÂÂÂÂ1.520658] r7 : ee938800ÂÂr6 : ef340800ÂÂr5 : ef055aacÂÂr4 : ef340ce0
[ÂÂÂÂ1.527206] r3 : 00000001ÂÂr2 : fffffffcÂÂr1 : 00000000ÂÂr0 : ee938800
[ÂÂÂÂ1.533757] Flags: nzCvÂÂIRQs onÂÂFIQs onÂÂMode SVC_32ÂÂISA ARMÂÂSegment none
[ÂÂÂÂ1.540913] Control: 10c5387dÂÂTable: 8000404aÂÂDAC: 00000051
[ÂÂÂÂ1.546680] Process swapper/0 (pid: 1, stack limit = 0xef054210)
[ÂÂÂÂ1.552709] Stack: (0xef0558b0 to 0xef056000)
[ÂÂÂÂ1.557093] 58a0:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂc05f5cfc c05f587c 00000000 ef055aac
[ÂÂÂÂ1.565301] 58c0: ef340800 ef340ce0 ee938800 ef340c28 ef055904 ef0558e0 c05f3440 c05f5f98
[ÂÂÂÂ1.573509] 58e0: ee938800 ef055aac ef340800 ef055a38 00000000 ef340c28 ef055944 ef055908
[ÂÂÂÂ1.581714] 5900: c05f21c0 c05f33cc ee938800 00000000 ef05592c ef055920 c0496c3c 00000000
[ÂÂÂÂ1.589920] 5920: ef340800 ef055a38 00000000 00000000 ee938a98 00000000 ef055984 ef055948
[ÂÂÂÂ1.598126] 5940: c05f28c8 c05f2118 ef055a38 ef340800 ef05596c ef340a80 c016d518 ef055990
[ÂÂÂÂ1.606332] 5960: ee938800 ef055a38 ef340800 ef340c28 ee938a98 00000000 ef055a14 ef055988
[ÂÂÂÂ1.614537] 5980: c05f2bf0 c05f24e0 ef340ac4 60000013 00000000 00000000 dead4ead ffffffff
[ÂÂÂÂ1.622743] 59a0: ffffffff c1669b70 00000000 00000000 c0be1d7c ef0559b4 ef0559b4 00000000
[ÂÂÂÂ1.630948] 59c0: 00000000 dead4ead ffffffff ffffffff c1669b70 00000000 00000000 c0be1d7c
[ÂÂÂÂ1.639153] 59e0: ef0559b4 ef0559b4 ee938800 ee938800 ef055a38 ef055a38 00000006 c1669b3c
[ÂÂÂÂ1.647359] 5a00: ee938800 ef055b27 ef055a2c ef055a18 c05f2c34 c05f2a30 ef0c8bc1 ef0c8bc0
[ÂÂÂÂ1.655565] 5a20: ef055b14 ef055a30 c05f2d20 c05f2c10 ef055a54 ef055b4a ef055aa4 ef055ae0
[ÂÂÂÂ1.663770] 5a40: ee938800 00000000 c05f0640 ef055990 00000007 00000001 ffffff8d ef055a5c
[ÂÂÂÂ1.671975] 5a60: ef055a5c 00000000 ef055a68 ef055a68 ef0c8bc0 00000000 00000001 00000000
[ÂÂÂÂ1.680179] 5a80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000802
[ÂÂÂÂ1.688384] 5aa0: 01312d00 ef055ae0 ef055a38 00000000 ef0c8bc1 00000006 00000000 00000000
[ÂÂÂÂ1.696588] 5ac0: 00000000 00000000 00000000 00000000 00000000 00000000 00000810 01312d00
[ÂÂÂÂ1.704794] 5ae0: ef055a38 ef055aa4 ef058000 c05c298c ee938800 ee938a70 ee938800 ef341018
[ÂÂÂÂ1.712999] 5b00: ef7e6f0c c0a669a4 ef055b3c ef055b18 c05c29c4 c05f2c58 00000006 00000000
[ÂÂÂÂ1.721206] 5b20: ef055b4c 9f055b30 c05c298c c0a669a4 ef055b74 ef055b40 c05d4970 c05c2998
[ÂÂÂÂ1.729412] 5b40: ef055b5c ef055b50 c016d518 c016d320 ef055b74 ef341018 c0a669a4 ee938a70
[ÂÂÂÂ1.737617] 5b60: ee938800 00000000 ef055bb4 ef055b78 c05d5634 c05d4954 ef341010 ef341050
[ÂÂÂÂ1.745822] 5b80: 00000000 ef341018 00000000 ef341010 ee938a70 00000000 ef341018 00000000
[ÂÂÂÂ1.754027] 5ba0: 00000000 00000000 ef055be4 ef055bb8 c05c2f88 c05d5300 c0e3ed44 00000000
[ÂÂÂÂ1.762232] 5bc0: 00000000 ee938800 c0e3ed34 00000000 c0e3ed44 00000000 ef055c04 ef055be8
[ÂÂÂÂ1.770437] 5be0: c05f0070 c05c2e78 ee938800 c166767c 00000000 c0e3ed44 ef055c2c ef055c08
[ÂÂÂÂ1.778643] 5c00: c053ed28 c05efff8 c0e3ed44 ef055c78 ee938800 00000001 00000000 c1667638
[ÂÂÂÂ1.786848] 5c20: ef055c4c ef055c30 c053ef1c c053eacc 00000000 ef055c78 c053ee7c 00000001
[ÂÂÂÂ1.795055] 5c40: ef055c74 ef055c50 c053d050 c053ee88 ef0c0ed4 ee8adfd4 ee938800 ee938800
[ÂÂÂÂ1.803261] 5c60: ee938834 c0e403a4 ef055c9c ef055c78 c053e998 c053cff0 ee938800 00000001
[ÂÂÂÂ1.811466] 5c80: ee938808 ee938800 c0e403a4 00000000 ef055cac ef055ca0 c053ef9c c053e8ec
[ÂÂÂÂ1.819671] 5ca0: ef055ccc ef055cb0 c053df88 c053ef94 ee938808 ef340800 ee938800 00000000
[ÂÂÂÂ1.827877] 5cc0: ef055d0c ef055cd0 c053c0ec c053df04 c05f07d8 c0450bd8 00000000 ee938800
[ÂÂÂÂ1.836083] 5ce0: ef055d0c ee938800 ef340800 00000000 ef0f5010 00000000 ef340800 00000000
[ÂÂÂÂ1.844288] 5d00: ef055d2c ef055d10 c05f1044 c053bd28 ef7e6f0c ef7e6f5c ee938800 00000001
[ÂÂÂÂ1.852493] 5d20: ef055d74 ef055d30 c05f18f0 c05f0fb8 00000000 c04289b8 ef055d64 ef0f5010
[ÂÂÂÂ1.860699] 5d40: c040f6f4 01312d00 ef055d74 ef340800 ef340ce0 ef340a60 ffffffed ef0f5010
[ÂÂÂÂ1.868905] 5d60: ef0f5000 ee8d4f80 ef055d8c ef055d78 c05f3508 c05f14b8 ef340ce0 ef340800
[ÂÂÂÂ1.877111] 5d80: ef055ddc ef055d90 c05f6700 c05f346c 00000000 ef0c5840 ef340ce0 00000002
[ÂÂÂÂ1.885316] 5da0: c1667638 ef0f5010 00000000 00000000 c0e40ccc ef0f5010 fffffffe c0e40ccc
[ÂÂÂÂ1.893522] 5dc0: fffffdfb 00000000 00000000 c0d00618 ef055dfc ef055de0 c05409cc c05f6394
[ÂÂÂÂ1.901728] 5de0: ef0f5010 c166767c 00000000 c0e40ccc ef055e24 ef055e00 c053ed28 c0540980
[ÂÂÂÂ1.909934] 5e00: ef0f5010 c0e40ccc ef0f5044 00000000 00000000 c0d5f858 ef055e44 ef055e28
[ÂÂÂÂ1.918139] 5e20: c053ee78 c053eacc 00000000 c0e40ccc c053edb0 00000000 ef055e6c ef055e48
[ÂÂÂÂ1.926345] 5e40: c053cf8c c053edbc ef009aa4 ef0bbcd0 ef009ad4 c0e40ccc ee8d7300 c0e3b068
[ÂÂÂÂ1.934551] 5e60: ef055e7c ef055e70 c053e680 c053cf24 ef055ea4 ef055e80 c053e1a4 c053e66c
[ÂÂÂÂ1.942756] 5e80: c0c4a470 ef055e90 c0e40ccc ffffe000 c0d5f850 c0cdd42c ef055ebc ef055ea8
[ÂÂÂÂ1.950963] 5ea0: c053f814 c053e0ac c0d47a14 ffffe000 ef055ecc ef055ec0 c054091c c053f7a0
[ÂÂÂÂ1.959168] 5ec0: ef055edc ef055ed0 c0d47a2c c05408f0 ef055f4c ef055ee0 c0101934 c0d47a20
[ÂÂÂÂ1.967374] 5ee0: c0d00634 c04157f0 c0cde600 000000ef ef055f4c ef055f00 c0147468 c0d00624
[ÂÂÂÂ1.975578] 5f00: 00000000 00000006 00000006 00000000 c0cdd42c c0c53d64 efffcc3a efffcc42
[ÂÂÂÂ1.983784] 5f20: c0e179e4 00000006 c0e7c000 c0d70ee8 c0e7c000 c0d5f850 c0cdd42c 000000ef
[ÂÂÂÂ1.991990] 5f40: ef055f94 ef055f50 c0d00e74 c01018fc 00000006 00000006 00000000 c0d00618
[ÂÂÂÂ2.000194] 5f60: 96fb16ef 00000007 c09af0d8 00000000 c09af0d8 00000000 00000000 00000000
[ÂÂÂÂ2.008401] 5f80: 00000000 00000000 ef055fac ef055f98 c09af0e8 c0d00d54 00000000 c09af0d8
[ÂÂÂÂ2.016605] 5fa0: 00000000 ef055fb0 c0107d30 c09af0e4 00000000 00000000 00000000 00000000
[ÂÂÂÂ2.024810] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ÂÂÂÂ2.033015] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 def4d473 a64cea87
[ÂÂÂÂ2.041206] Backtrace:
[ÂÂÂÂ2.043707] [<c05f5f8c>] (spi_imx_transfer) from [<c05f3440>] (spi_bitbang_transfer_one+0x80/0xa0)
[ÂÂÂÂ2.052699]ÂÂr9:ef340c28 r8:ee938800 r7:ef340ce0 r6:ef340800 r5:ef055aac r4:00000000
[ÂÂÂÂ2.060479] [<c05f33c0>] (spi_bitbang_transfer_one) from [<c05f21c0>] (spi_transfer_one_message+0xb4/0x3c8)
[ÂÂÂÂ2.070251]ÂÂr9:ef340c28 r8:00000000 r7:ef055a38 r6:ef340800 r5:ef055aac r4:ee938800
[ÂÂÂÂ2.078029] [<c05f210c>] (spi_transfer_one_message) from [<c05f28c8>] (__spi_pump_messages+0x3f4/0x534)
[ÂÂÂÂ2.087452]ÂÂr10:00000000 r9:ee938a98 r8:00000000 r7:00000000 r6:ef055a38 r5:ef340800
[ÂÂÂÂ2.095301]ÂÂr4:00000000
[ÂÂÂÂ2.097869] [<c05f24d4>] (__spi_pump_messages) from [<c05f2bf0>] (__spi_sync+0x1cc/0x1e0)
[ÂÂÂÂ2.106079]ÂÂr10:00000000 r9:ee938a98 r8:ef340c28 r7:ef340800 r6:ef055a38 r5:ee938800
[ÂÂÂÂ2.113927]ÂÂr4:ef055990
[ÂÂÂÂ2.116492] [<c05f2a24>] (__spi_sync) from [<c05f2c34>] (spi_sync+0x30/0x48)
[ÂÂÂÂ2.123570]ÂÂr10:ef055b27 r9:ee938800 r8:c1669b3c r7:00000006 r6:ef055a38 r5:ef055a38
[ÂÂÂÂ2.131418]ÂÂr4:ee938800
[ÂÂÂÂ2.133985] [<c05f2c04>] (spi_sync) from [<c05f2d20>] (spi_write_then_read+0xd4/0x184)
[ÂÂÂÂ2.141924]ÂÂr5:ef0c8bc0 r4:ef0c8bc1
[ÂÂÂÂ2.145534] [<c05f2c4c>] (spi_write_then_read) from [<c05c29c4>] (m25p80_read_reg+0x38/0x70)
[ÂÂÂÂ2.154002]ÂÂr10:c0a669a4 r9:ef7e6f0c r8:ef341018 r7:ee938800 r6:ee938a70 r5:ee938800
[ÂÂÂÂ2.161851]ÂÂr4:c05c298c
[ÂÂÂÂ2.164415] [<c05c298c>] (m25p80_read_reg) from [<c05d4970>] (spi_nor_read_id+0x28/0xc0)
[ÂÂÂÂ2.172527]ÂÂr5:c0a669a4 r4:c05c298c
[ÂÂÂÂ2.176132] [<c05d4948>] (spi_nor_read_id) from [<c05d5634>] (spi_nor_scan+0x340/0x8f8)
[ÂÂÂÂ2.184164]ÂÂr8:00000000 r7:ee938800 r6:ee938a70 r5:c0a669a4 r4:ef341018
[ÂÂÂÂ2.190894] [<c05d52f4>] (spi_nor_scan) from [<c05c2f88>] (m25p_probe+0x11c/0x168)
[ÂÂÂÂ2.198494]ÂÂr10:00000000 r9:00000000 r8:00000000 r7:ef341018 r6:00000000 r5:ee938a70
[ÂÂÂÂ2.206342]ÂÂr4:ef341010
[ÂÂÂÂ2.208907] [<c05c2e6c>] (m25p_probe) from [<c05f0070>] (spi_drv_probe+0x84/0xb4)
[ÂÂÂÂ2.216418]ÂÂr8:00000000 r7:c0e3ed44 r6:00000000 r5:c0e3ed34 r4:ee938800
[ÂÂÂÂ2.223162] [<c05effec>] (spi_drv_probe) from [<c053ed28>] (driver_probe_device+0x268/0x2f0)
[ÂÂÂÂ2.231626]ÂÂr7:c0e3ed44 r6:00000000 r5:c166767c r4:ee938800
[ÂÂÂÂ2.237321] [<c053eac0>] (driver_probe_device) from [<c053ef1c>] (__device_attach_driver+0xa0/0xd4)
[ÂÂÂÂ2.246396]ÂÂr9:c1667638 r8:00000000 r7:00000001 r6:ee938800 r5:ef055c78 r4:c0e3ed44
[ÂÂÂÂ2.254174] [<c053ee7c>] (__device_attach_driver) from [<c053d050>] (bus_for_each_drv+0x6c/0xa0)
[ÂÂÂÂ2.262984]ÂÂr7:00000001 r6:c053ee7c r5:ef055c78 r4:00000000
[ÂÂÂÂ2.268675] [<c053cfe4>] (bus_for_each_drv) from [<c053e998>] (__device_attach+0xb8/0x120)
[ÂÂÂÂ2.276963]ÂÂr6:c0e403a4 r5:ee938834 r4:ee938800
[ÂÂÂÂ2.281614] [<c053e8e0>] (__device_attach) from [<c053ef9c>] (device_initial_probe+0x14/0x18)
[ÂÂÂÂ2.290164]ÂÂr7:00000000 r6:c0e403a4 r5:ee938800 r4:ee938808
[ÂÂÂÂ2.295857] [<c053ef88>] (device_initial_probe) from [<c053df88>] (bus_probe_device+0x90/0x98)
[ÂÂÂÂ2.304501] [<c053def8>] (bus_probe_device) from [<c053c0ec>] (device_add+0x3d0/0x584)
[ÂÂÂÂ2.312443]ÂÂr7:00000000 r6:ee938800 r5:ef340800 r4:ee938808
[ÂÂÂÂ2.318134] [<c053bd1c>] (device_add) from [<c05f1044>] (spi_add_device+0x98/0x13c)
[ÂÂÂÂ2.325821]ÂÂr10:00000000 r9:ef340800 r8:00000000 r7:ef0f5010 r6:00000000 r5:ef340800
[ÂÂÂÂ2.333669]ÂÂr4:ee938800
[ÂÂÂÂ2.336235] [<c05f0fac>] (spi_add_device) from [<c05f18f0>] (spi_register_master+0x444/0x7a4)
[ÂÂÂÂ2.344786]ÂÂr7:00000001 r6:ee938800 r5:ef7e6f5c r4:ef7e6f0c
[ÂÂÂÂ2.350478] [<c05f14ac>] (spi_register_master) from [<c05f3508>] (spi_bitbang_start+0xa8/0x12c)
[ÂÂÂÂ2.359207]ÂÂr10:ee8d4f80 r9:ef0f5000 r8:ef0f5010 r7:ffffffed r6:ef340a60 r5:ef340ce0
[ÂÂÂÂ2.367055]ÂÂr4:ef340800
[ÂÂÂÂ2.369623] [<c05f3460>] (spi_bitbang_start) from [<c05f6700>] (spi_imx_probe+0x378/0x604)
[ÂÂÂÂ2.377909]ÂÂr5:ef340800 r4:ef340ce0
[ÂÂÂÂ2.381518] [<c05f6388>] (spi_imx_probe) from [<c05409cc>] (platform_drv_probe+0x58/0xb8)
[ÂÂÂÂ2.389727]ÂÂr10:c0d00618 r9:00000000 r8:00000000 r7:fffffdfb r6:c0e40ccc r5:fffffffe
[ÂÂÂÂ2.397574]ÂÂr4:ef0f5010
[ÂÂÂÂ2.400140] [<c0540974>] (platform_drv_probe) from [<c053ed28>] (driver_probe_device+0x268/0x2f0)
[ÂÂÂÂ2.409037]ÂÂr7:c0e40ccc r6:00000000 r5:c166767c r4:ef0f5010
[ÂÂÂÂ2.414730] [<c053eac0>] (driver_probe_device) from [<c053ee78>] (__driver_attach+0xc8/0xcc)
[ÂÂÂÂ2.423197]ÂÂr9:c0d5f858 r8:00000000 r7:00000000 r6:ef0f5044 r5:c0e40ccc r4:ef0f5010
[ÂÂÂÂ2.430973] [<c053edb0>] (__driver_attach) from [<c053cf8c>] (bus_for_each_dev+0x74/0xa8)
[ÂÂÂÂ2.439175]ÂÂr7:00000000 r6:c053edb0 r5:c0e40ccc r4:00000000
[ÂÂÂÂ2.444867] [<c053cf18>] (bus_for_each_dev) from [<c053e680>] (driver_attach+0x20/0x28)
[ÂÂÂÂ2.452894]ÂÂr6:c0e3b068 r5:ee8d7300 r4:c0e40ccc
[ÂÂÂÂ2.457544] [<c053e660>] (driver_attach) from [<c053e1a4>] (bus_add_driver+0x104/0x214)
[ÂÂÂÂ2.465582] [<c053e0a0>] (bus_add_driver) from [<c053f814>] (driver_register+0x80/0xfc)
[ÂÂÂÂ2.473611]ÂÂr7:c0cdd42c r6:c0d5f850 r5:ffffe000 r4:c0e40ccc
[ÂÂÂÂ2.479302] [<c053f794>] (driver_register) from [<c054091c>] (__platform_driver_register+0x38/0x4c)
[ÂÂÂÂ2.488369]ÂÂr5:ffffe000 r4:c0d47a14
[ÂÂÂÂ2.491984] [<c05408e4>] (__platform_driver_register) from [<c0d47a2c>] (spi_imx_driver_init+0x18/0x20)
[ÂÂÂÂ2.501412] [<c0d47a14>] (spi_imx_driver_init) from [<c0101934>] (do_one_initcall+0x44/0x178)
[ÂÂÂÂ2.509977] [<c01018f0>] (do_one_initcall) from [<c0d00e74>] (kernel_init_freeable+0x12c/0x1ec)
[ÂÂÂÂ2.518704]ÂÂr8:000000ef r7:c0cdd42c r6:c0d5f850 r5:c0e7c000 r4:c0d70ee8
[ÂÂÂÂ2.525441] [<c0d00d48>] (kernel_init_freeable) from [<c09af0e8>] (kernel_init+0x10/0x118)
[ÂÂÂÂ2.533735]ÂÂr10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:c09af0d8
[ÂÂÂÂ2.541582]ÂÂr4:00000000
[ÂÂÂÂ2.544153] [<c09af0d8>] (kernel_init) from [<c0107d30>] (ret_from_fork+0x14/0x24)
[ÂÂÂÂ2.551745]ÂÂr5:c09af0d8 r4:00000000
[ÂÂÂÂ2.555349] Code: e1b03123 0affff6a e2422004 e3a01000 (e5923004)
[ÂÂÂÂ2.561619] ---[ end trace 5e472bb4310ae461 ]---
[ÂÂÂÂ2.566504] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
[ÂÂÂÂ2.566504]
[ÂÂÂÂ2.575695] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
[ÂÂÂÂ2.575695]
[ÂÂÂÂ2.604346] random: fast init done

This is at commit 8d4a6cad7adb3ddac32cd52635f20e11de11a658 from
broonie/spi/topic/imx which has no other patches on top of v4.12-rc1.

>From a very brief investigation it seems this is not handling correctly
the cases where spi_transfer->rx_buf or tx_buf are NULL?

--
Regards,
Leonard