Commit Graph

18 Commits

Author SHA1 Message Date
Greg Kroah-Hartman c29930ef83 FSI changes for v5.18
* Improvements in SCOM and OCC drivers for error handling and retries
 
  * Addition of tracepoints for initialisation path
 
  * API for setting long running SBE FIFO operations
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEE+nHMAt9PCBDH63wBa3ZZB4FHcJ4FAmITXCIACgkQa3ZZB4FH
 cJ6tRQ//eBrtmh0pkfccNMw1tqGqPJAqsANxBwTBFlG02MD7YhUH6VEyULdp2V8O
 icwweLcUwM5Q6d6mDSCTEWxRDyLDsQ3lIBCq/j6DLCOZ3gaFAm7bwdl24p59lK51
 DNkNB4quAhsc1eXQ3hmALXEUZ1QRLSrbw4+utYPhaiyCU/8LORqaelmip52HBVK5
 8WDsOs/Vj7o+Yiu6dNtYfRTkjH3AHyMCgPjSI6tZ1sUZGGeyBTWywDNcbX7wIVAn
 wuf+4G+v5XtY7uqmnvMRmhoUU01FvdJ573/UGLyQ5qlZIN6C6i2q5shyvUP839FC
 8GNeRJJFABq0qB9nMK2S9hhGvaFG8AhcWMNvT+/IRPa9p4wyvwClwzqeeScATDWg
 762bQSl9NOrkGtggh3GDDH5hywQeFuboPhiNfCp9Y0Hw6Ng+OBx1Z9BzxuqayFQi
 N1hsd+AC/K8qkcYiayV4euCbA2rinSzUZOYWCHlaPrqG78wACgcI2YWrwmz1prBH
 y4aSibeehcXIvHseQQnLHUzLWfZiRr1UsEGA94lva2NnjUADiO/Wty9F2gI/i7zv
 X+VP77/9s14EGrx8w4SunPn24i67xEoHMFzwuzr69HuT32w/CKLX52UqUdPCjecF
 TbdEJDAwQH/Pml/t+rBfN4ntHhkoMRDhvbM7yovUJ6Y3gcDTMDY=
 =kOpN
 -----END PGP SIGNATURE-----

Merge tag 'fsi-for-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/joel/fsi into char-misc-next

Joel writes:

FSI changes for v5.18

 * Improvements in SCOM and OCC drivers for error handling and retries

 * Addition of tracepoints for initialisation path

 * API for setting long running SBE FIFO operations

* tag 'fsi-for-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/joel/fsi:
  fsi: Add trace events in initialization path
  fsi: sbefifo: Implement FSI_SBEFIFO_READ_TIMEOUT_SECONDS ioctl
  fsi: sbefifo: Use specified value of start of response timeout
  fsi: occ: Improve response status checking
  fsi: scom: Remove retries in indirect scoms
  fsi: scom: Fix error handling
2022-02-21 17:47:42 +01:00
Eddie James f2af60bb7c fsi: Add trace events in initialization path
Add definitions for trace events to show the scanning flow.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Link: https://lore.kernel.org/r/20220207161640.35605-1-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-02-21 19:38:54 +10:30
Christophe JAILLET 83ba7e895d fsi: Aspeed: Fix a potential double free
A struct device can never be devm_alloc()'ed.
Here, it is embedded in "struct fsi_master", and "struct fsi_master" is
embedded in "struct fsi_master_aspeed".

Since "struct device" is embedded, the data structure embedding it must be
released with the release function, as is already done here.

So use kzalloc() instead of devm_kzalloc() when allocating "aspeed" and
update all error handling branches accordingly.

This prevent a potential double free().

This also fix another issue if opb_readl() fails. Instead of a direct
return, it now jumps in the error handling path.

Fixes: 606397d67f ("fsi: Add ast2600 master driver")
Suggested-by: Greg KH <gregkh@linuxfoundation.org>
Suggested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/2c123f8b0a40dc1a061fae982169fe030b4f47e6.1641765339.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-02-04 16:45:39 +01:00
Eddie James 1e2233d4f3 fsi: Aspeed: Reduce poll timeout
The lengthy timeout previously used sometimes resulted in
scheduling problems, detailed below. Therefore reduce the timeout
to 500us. This timeout selection is supported by the benchmarks
collected below with various clock dividers. This is purely the time
spent polling (reported by ktime_get()).

div  1: max:150us avg:  2us
div  2: max:155us avg:  3us
div  4: max:149us avg:  7us
div  8: max:153us avg: 13us
div 16: max:197us avg: 21us
div 32: max:181us avg: 50us
div 64: max:262us avg:100us

Jan 22 01:27:21 rain27bmc kernel: rcu: INFO: rcu_sched self-detected stall on CPU
Jan 22 01:27:21 rain27bmc kernel: rcu:         0-....: (2099 ticks this GP) idle=0ca/1/0x40000002 softirq=349573/349573 fqs=1048
Jan 22 01:27:21 rain27bmc kernel:         (t=2100 jiffies g=841149 q=7163)
Jan 22 01:27:21 rain27bmc kernel: NMI backtrace for cpu 0
Jan 22 01:27:21 rain27bmc kernel: CPU: 0 PID: 5959 Comm: ibm-read-vpd Not tainted 5.8.17-a9b4ea8 #1
Jan 22 01:27:21 rain27bmc kernel: Hardware name: Generic DT based system
Jan 22 01:27:21 rain27bmc kernel: Backtrace:
Jan 22 01:27:25 rain27bmc kernel: [<8010d92c>] (dump_backtrace) from [<8010db80>] (show_stack+0x20/0x24)
...
Jan 22 01:27:25 rain27bmc kernel: [<8010130c>] (gic_handle_irq) from [<80100b0c>] (__irq_svc+0x6c/0x90)
Jan 22 01:27:25 rain27bmc kernel: Exception stack(0xb79159b0 to 0xb79159f8)
Jan 22 01:27:25 rain27bmc kernel: 59a0:                                     9e88e5d5 00000559 00000559 00000018
Jan 22 01:27:25 rain27bmc kernel: 59c0: 00000000 9f217c55 00000003 00000559 a0201c00 bfa4d048 bfa4d000 b7915a44
Jan 22 01:27:25 rain27bmc kernel: 59e0: 40e88f8a b7915a00 3254e553 80734924 80030113 ffffffff
Jan 22 01:27:25 rain27bmc kernel:  r9:b7914000 r8:a0201c00 r7:b79159e4 r6:ffffffff r5:80030113 r4:80734924
Jan 22 01:27:25 rain27bmc kernel: [<807348b4>] (__opb_read) from [<80734d98>] (aspeed_master_read+0xbc/0xcc)
Jan 22 01:27:25 rain27bmc kernel:  r10:00000004 r9:00000002 r8:80734cdc r7:bd33fa40 r6:00000004 r5:bd33f840
Jan 22 01:27:25 rain27bmc kernel:  r4:00201c00
Jan 22 01:27:25 rain27bmc kernel: [<80734cdc>] (aspeed_master_read) from [<807320f0>] (fsi_master_read+0x6c/0x1bc)
...

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20210211194846.35475-1-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-06-04 15:00:01 +09:30
Yangtao Li a3469912f4 fsi: aspeed: convert to devm_platform_ioremap_resource
Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
Link: https://lore.kernel.org/r/20191228190631.26777-1-tiny.windzz@gmail.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-06-04 14:34:09 +09:30
Joel Stanley 4134cb9165 fsi: aspeed: Emit fewer barriers in opb operations
When setting up a read or write to the OPB memory space, we must perform
five or six AHB writes. The ordering of these up until the trigger write
does not matter, so use writel_relaxed.

The generated code goes from (Debian GCC 10.2.1-6):

        mov     r8, r3
        mcr     15, 0, sl, cr7, cr10, {4}
        str     sl, [r6, #20]
        mcr     15, 0, sl, cr7, cr10, {4}
        str     r3, [r6, #24]
        mcr     15, 0, sl, cr7, cr10, {4}
        str     r1, [r6, #28]
        mcr     15, 0, sl, cr7, cr10, {4}
        str     r2, [r6, #32]
        mcr     15, 0, sl, cr7, cr10, {4}
        mov     r1, #1
        str     r1, [r6, #64]   ; 0x40
        mcr     15, 0, sl, cr7, cr10, {4}
        str     r1, [r6, #4]

to this:

        str     r3, [r7, #20]
        str     r2, [r7, #24]
        str     r1, [r7, #28]
        str     r3, [r7, #64]
        mov     r8, #0
        mcr     15, 0, r8, cr7, cr10, {4}
        str     r3, [r7, #4]

Signed-off-by: Joel Stanley <joel@jms.id.au>
Acked-by: Jeremy Kerr <jk@ozlabs.org>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
Tested-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20210223041737.171274-1-joel@jms.id.au
Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-06-04 14:18:17 +09:30
Zou Wei 19a5217812 fsi: Add missing MODULE_DEVICE_TABLE
This patch adds missing MODULE_DEVICE_TABLE definition which generates
correct modalias for automatic loading of this driver when it is built
as an external module.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zou Wei <zou_wei@huawei.com>
Link: https://lore.kernel.org/r/1620896249-52769-1-git-send-email-zou_wei@huawei.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-06-04 14:10:45 +09:30
Eddie James dfd7f2c1c5 fsi: Aspeed: Add mutex to protect HW access
There is nothing to prevent multiple commands being executed
simultaneously. Add a mutex to prevent this.

Fixes: 606397d67f ("fsi: Add ast2600 master driver")
Reviewed-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Milton Miller <miltonm@us.ibm.com>
Signed-off-by: Eddie James <eajames@linux.ibm.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/20201120004929.185239-1-joel@jms.id.au
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-12-09 19:52:25 +01:00
Joel Stanley 4a851d714e fsi: aspeed: Support CFAM reset GPIO
Systems have a line for restting the remote CFAM. This is not part of
the FSI master, but is associated with it, so it makes sense to include
it in the master driver.

This exposes a sysfs interface to reset the cfam, abstracting away the
direction and polarity of the GPIO, as well as the timing of the reset
pulse. Userspace will be blocked until the reset pulse is finished.

The reset is hard coded to be in the range of (900, 1000) us. It was
observed with a scope to regularly be just over 1ms.

If the device tree property is not preset the driver will silently
continue.

Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
Link: https://lore.kernel.org/r/20200728025527.174503-6-joel@jms.id.au
Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-09-10 12:26:43 +09:30
Joel Stanley add6895188 fsi: aspeed: Add module param for bus divisor
For testing and hardware debugging a user may wish to override the
divisor at runtime. By setting fsi_master_aspeed.bus_div=N, the divisor
will be set to N, if 0 < N <= 0x3ff.

This is a module parameter and not a device tree option as it will only
need to be set when testing or debugging.

Reviewed-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20200728025527.174503-5-joel@jms.id.au
Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-09-10 12:23:19 +09:30
Joel Stanley 4a80c2017b fsi: aspeed: Run the bus at maximum speed
Testing of Tacoma has shown that the ASPEED master can be run at maximum
speed.

The exception is when wired externally with a cable, in which case we
use a divisor of two to ensure reliable operation.

Reviewed-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20200728025527.174503-4-joel@jms.id.au
Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-09-10 12:23:17 +09:30
Joel Stanley f369a29bdd fsi: aspeed: Support cabled FSI
Some FSI capable systems have internal FSI signals, and some have
external cabled FSI. Software can detect which machine this is by
reading a jumper GPIO, and also control which pins the signals are
routed to through a mux GPIO.

This attempts to find the GPIOs at probe time. If they are not present
in the device tree the driver will not error and continue as before.

The mux GPIO is owned by the FSI driver to ensure it is not modified at
runtime. The routing jumper obtained as non-exclusive to allow other
software to inspect it's state.

Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
Link: https://lore.kernel.org/r/20200728025527.174503-3-joel@jms.id.au
Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-09-10 12:23:14 +09:30
Eddie James a1d5ce111a fsi: master: Remove link enable read-back
Both the Aspeed and hub masters read back the link enable register
after enabling the link, but this is unnecessary, so remove it.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-09-10 12:22:49 +09:30
Eddie James 04635a30dd fsi: master: Add boolean parameter to link_enable function
Add the ability to disable a link with a boolean parameter to the
link_enable function. This is necessary so that the master can disable
links that it isn't using; for example, links to slaves that fail
initialization.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-09-10 12:22:47 +09:30
Eddie James 6e0ef7d2ce fsi: aspeed: Enable 23-bit addressing
In order to access more than the second hub link, 23-bit addressing is
required. The core provides the highest two bits of address as the slave
ID to the master.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Acked-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-09-10 12:22:46 +09:30
Andrew Jeffery 5e50229956 fsi: aspeed: Fix OPB0 byte order register values
The data byte order selection registers in the APB2OPB primarily expose some
internal plumbing necessary to get correct write accesses onto the OPB.
OPB write cycles require "data mirroring" across the 32-bit data bus to
support variable data width slaves that don't implement "byte enables".
For slaves that do implement byte enables the master can signal which
bytes on the data bus the slave should consider valid.

The data mirroring behaviour is specified by the following table:

    +-----------------+----------+-----------------------------------+
    |                 |          |          32-bit Data Bus          |
    +---------+-------+----------+---------+---------+-------+-------+
    |         |       |          |         |         |       |       |
    |   ABus  | Mn_BE |  Request |   Dbus  |   Dbus  |  Dbus |  Dbus |
    | (30:31) | (0:3) | Transfer |   0:7   |   8:15  | 16:23 | 24:31 |
    |         |       |   Size   |  byte0  |  byte1  | byte2 | byte3 |
    +---------+-------+----------+---------+---------+-------+-------+
    |    00   |  1111 | fullword |  byte0  |  byte1  | byte2 | byte3 |
    +---------+-------+----------+---------+---------+-------+-------+
    |    00   |  1110 | halfword |  byte0  |  byte1  | byte2 |       |
    +---------+-------+----------+---------+---------+-------+-------+
    |    01   |  0111 |   byte   | _byte1_ |  byte1  | byte2 | byte3 |
    +---------+-------+----------+---------+---------+-------+-------+
    |    00   |  1100 | halfword |  byte0  |  byte1  |       |       |
    +---------+-------+----------+---------+---------+-------+-------+
    |    01   |  0110 |   byte   | _byte1_ |  byte1  | byte2 |       |
    +---------+-------+----------+---------+---------+-------+-------+
    |    10   |  0011 | halfword | _byte2_ | _byte3_ | byte2 | byte3 |
    +---------+-------+----------+---------+---------+-------+-------+
    |    00   |  1000 |   byte   |  byte0  |         |       |       |
    +---------+-------+----------+---------+---------+-------+-------+
    |    01   |  0100 |   byte   | _byte1_ |  byte1  |       |       |
    +---------+-------+----------+---------+---------+-------+-------+
    |    10   |  0010 |   byte   | _byte2_ |         | byte2 |       |
    +---------+-------+----------+---------+---------+-------+-------+
    |    11   |  0001 |   byte   | _byte3_ | _byte3_ |       | byte3 |
    +---------+-------+----------+---------+---------+-------+-------+

Mirrored data values are highlighted by underscores in the Dbus columns.
The values in the ABus and Request Transfer Size columns correspond to
values in the field names listed in the write data order select register
descriptions.

Similar configuration registers are exposed for reads which enables the
secondary purpose of configuring hardware endian conversions. It appears the
data bus byte order is switched around in hardware so set the registers such
that we can access the correct values for all widths. The values were
determined by experimentation on hardware against fixed CFAM register
values to configure the read data order, then in combination with the
table above and the register layout documentation in the AST2600
datasheet performing write/read cycles to configure the write data order
registers.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Acked-by: Alistair Popple <alistair@popple.id.au>
Link: https://lore.kernel.org/r/20191108051945.7109-12-joel@jms.id.au
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-11-08 11:28:21 +01:00
Joel Stanley 913b73730e fsi: aspeed: Add trace points
These trace points help with debugging the FSI master. They show the low
level reads, writes and error states of the master.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/20191108051945.7109-11-joel@jms.id.au
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-11-08 11:28:20 +01:00
Joel Stanley 606397d67f fsi: Add ast2600 master driver
The ast2600 BMC has a pair of FSI masters in it, behind an AHB to OPB
bridge.

The master driver supports reads and writes of full words, half word and
byte accesses to remote CFAMs. It can perform very basic error recovery
through resetting of the FSI port when an error is detected, and the
issuing of breaks and terms.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Acked-by: Alistair Popple <alistair@popple.id.au>
--
v2:
 - remove debugging
 - squash in fixes
Link: https://lore.kernel.org/r/20191108051945.7109-10-joel@jms.id.au
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-11-08 11:28:20 +01:00