Commit graph

185 commits

Author SHA1 Message Date
Uwe Kleine-König
b587cb7264 fsi: i2cr: Switch to use struct i2c_driver's .probe()
struct i2c_driver::probe_new is about to go away. Switch the driver to
use the probe callback with the same prototype.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/20230816171944.123705-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-08-22 15:51:33 +02:00
Yu Zhe
f04d61a379 fsi: fix some spelling mistakes in comment
Fix typos in comment.

Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
Link: https://lore.kernel.org/r/20230203083721.23455-1-yuzhe@nfschina.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2023-08-11 13:32:15 +09:30
Juerg Haefliger
3a1d7aff6e fsi: master-ast-cf: Add MODULE_FIRMWARE macro
The module loads firmware so add a MODULE_FIRMWARE macro to provide that
information via modinfo.

Fixes: 6a794a27da ("fsi: master-ast-cf: Add new FSI master using Aspeed ColdFire")
Cc: stable@vger.kernel.org # 4.19+
Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
Link: https://lore.kernel.org/r/20230628095039.26218-1-juerg.haefliger@canonical.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2023-08-11 13:32:14 +09:30
Eddie James
c0b34bed0b fsi: Add I2C Responder SCOM driver
The I2CR has the capability to directly perform SCOM operations,
circumventing the need to drive the FSI2PIB engine. Add a new
driver to perform SCOM operations through the I2CR.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20230612195657.245125-15-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2023-08-11 13:32:14 +09:30
Eddie James
53e89e3e44 fsi: Add IBM I2C Responder virtual FSI master
The I2C Responder (I2CR) is an I2C device that translates I2C commands
to CFAM or SCOM operations, effectively implementing an FSI master and
bus.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20230612195657.245125-14-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2023-08-11 13:32:14 +09:30
Eddie James
b1d3a803ac fsi: Lock mutex for master device registration
Because master device registration may cause hub master scans, or
user scans may begin before device registration has ended, so the
master scan lock must be held while registering the device.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20230809180814.151984-3-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2023-08-11 13:32:14 +09:30
Eddie James
adde0e112c fsi: Improve master indexing
Master indexing is problematic if a hub is rescanned while the
root master is being rescanned. Always allocate an index for the
FSI master, and set the device name if it hasn't already been set.
Move the call to ida_free to the bottom of master unregistration
and set the number of links to 0 in case another call to scan
comes in before the device is removed.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20230809180814.151984-2-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2023-08-11 13:31:57 +09:30
Eddie James
85f4e899de fsi: core: Switch to ida_alloc/free
ida_simple_get/remove are deprecated, so switch to ida_alloc/free.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20230612195657.245125-11-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2023-08-09 15:43:28 +09:30
Eddie James
641511bfcc fsi: core: Fix legacy minor numbering
The legacy minor numbering shifts the chip id too much,
resulting in ids that overlap with regular ids. Since there
are only 2 bits for 4 types, only shift the chip id by 2
to fit the legacy ids in their reserved space.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20230612195657.245125-10-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2023-08-09 15:43:28 +09:30
Eddie James
02c8fec05b fsi: core: Add trace events for scan and unregister
Add more trace events for the scanning and unregistration
functions for debug purposes.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/20230612195657.245125-9-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2023-08-09 15:43:28 +09:30
Eddie James
52300909f4 fsi: aspeed: Reset master errors after CFAM reset
It has been observed that sometimes the FSI master will return all 0xffs
after a CFAM has been taken out of reset, without presenting any error.
Resetting the FSI master errors resolves the issue.

Fixes: 4a851d714e ("fsi: aspeed: Support CFAM reset GPIO")
Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20230612195657.245125-8-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2023-08-09 15:43:28 +09:30
Eddie James
2f42220f35 fsi: sbefifo: Remove limits on user-specified read timeout
There's no reason to limit the user here. The way the driver is
designed, extremely large transfers require extremely long timeouts.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20230612195657.245125-7-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2023-08-09 15:43:27 +09:30
Eddie James
19c064defc fsi: sbefifo: Add configurable in-command timeout
A new use case for the SBEFIFO requires a long in-command timeout
as the SBE processes each part of the command before clearing the
upstream FIFO for the next part of the command.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20230612195657.245125-6-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2023-08-09 15:43:27 +09:30
Eddie James
d6ce872e2e fsi: sbefifo: Don't check status during probe
The status check during probe doesn't serve any purpose. Any attempt
to use the SBEFIFO will result in the same check and cleanup.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20230612195657.245125-5-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2023-08-09 15:43:27 +09:30
Eddie James
c21d322e1a fsi: Use of_match_table for bus matching if specified
Since we have two scom drivers, use the standard of matching if
the driver specifies a table so that the right devices go to the
right driver.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20230612195657.245125-4-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2023-08-09 15:43:27 +09:30
Eddie James
21930d80ed fsi: Add aliased device numbering
The I2C and SPI subsystems can use an aliased name to number the device.
Add similar support to the FSI subsystem for any device type.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20230612195657.245125-3-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2023-08-09 15:41:59 +09:30
Eddie James
d5d8dfb01e fsi: Move fsi_slave structure definition to header
Some FSI drivers may have need of the slave definition, so
move it to a header file. Also use one macro for obtaining a
pointer to the fsi_master structure.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20230612195657.245125-2-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2023-08-09 15:41:59 +09:30
Rob Herring
23ad7ec1ed fsi: Use of_property_read_reg() to parse "reg"
Use the recently added of_property_read_reg() helper to get the
untranslated "reg" address value.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20230609183056.1765183-1-robh@kernel.org
Signed-off-by: Joel Stanley <joel@jms.id.au>
2023-08-09 15:41:38 +09:30
Rob Herring
288f1acf51 fsi: Explicitly include correct DT includes
The DT of_device.h and of_platform.h date back to the separate
of_platform_bus_type before it as merged into the regular platform bus.
As part of that merge prepping Arm DT support 13 years ago, they
"temporarily" include each other. They also include platform_device.h
and of.h. As a result, there's a pretty much random mix of those include
files used throughout the tree. In order to detangle these headers and
replace the implicit includes with struct declarations, users need to
explicitly include the correct includes.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20230718205508.1790932-1-robh@kernel.org
Signed-off-by: Joel Stanley <joel@jms.id.au>
2023-08-09 15:40:11 +09:30
Greg Kroah-Hartman
a9b12f8b4e driver core: make struct device_type.devnode() take a const *
The devnode() callback in struct device_type should not be modifying the
device that is passed into it, so mark it as a const * and propagate the
function signature changes out into all relevant subsystems that use
this callback.

Cc: Jens Axboe <axboe@kernel.dk>
Cc: Alison Schofield <alison.schofield@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Ben Widawsky <bwidawsk@kernel.org>
Cc: Jeremy Kerr <jk@ozlabs.org>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Alistar Popple <alistair@popple.id.au>
Cc: Eddie James <eajames@linux.ibm.com>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jilin Yuan <yuanjilin@cdjrlc.com>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Won Chung <wonchung@google.com>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230111113018.459199-7-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-01-27 13:45:38 +01:00
Al Viro
de4eda9de2 use less confusing names for iov_iter direction initializers
READ/WRITE proved to be actively confusing - the meanings are
"data destination, as used with read(2)" and "data source, as
used with write(2)", but people keep interpreting those as
"we read data from it" and "we write data to it", i.e. exactly
the wrong way.

Call them ITER_DEST and ITER_SOURCE - at least that is harder
to misinterpret...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2022-11-25 13:01:55 -05:00
Al Viro
974c36fb82 [fsi] WRITE is "data source", not destination...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2022-11-25 13:01:20 -05:00
Jiasheng Jiang
35af9fb49b fsi: core: Check error number after calling ida_simple_get
If allocation fails, the ida_simple_get() will return error number.
So master->idx could be error number and be used in dev_set_name().
Therefore, it should be better to check it and return error if fails,
like the ida_simple_get() in __fsi_get_new_minor().

Fixes: 09aecfab93 ("drivers/fsi: Add fsi master definition")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20220111073411.614138-1-jiasheng@iscas.ac.cn
Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-09-28 21:10:57 +09:30
Eddie James
0fead4fc92 fsi: occ: Support probing the hwmon child device from dts node
There is now a need for reading devicetree properties in the OCC
hwmon driver, which isn't current supported as the FSI driver just
instantiates a basic platform device. Add support for this use case
by checking for an "occ-hwmon" node and if present, creating an
OF device from it.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20220809200701.218059-3-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-09-28 21:10:57 +09:30
Lv Ruyi
182d98e00e fsi: master-ast-cf: Fix missing of_node_put in fsi_master_acf_probe
of_parse_phandle returns node pointer with refcount incremented, use
of_node_put() on it when done.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
Link: https://lore.kernel.org/r/20220407085911.2491719-1-lv.ruyi@zte.com.cn
Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-09-28 21:10:57 +09:30
Joel Stanley
b1534a05e1 fsi: sbefifo: Add detailed debugging information
Provide more output on the timeout status, and make some vdbg calls into
dbg calls so they can be enabled at runtime.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/20220415050757.281158-1-joel@jms.id.au
Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-09-28 21:10:57 +09:30
Tom Rix
362fbc830a fsi: cleanup extern usage in function definition
Smatch reports these issues
fsi-core.c:395:12: warning: function 'fsi_slave_claim_range'
  with external linkage has definition
fsi-core.c:409:13: warning: function 'fsi_slave_release_range'
  with external linkage has definition

The storage-class-specifier extern is not needed in a
definition, so remove it.

Signed-off-by: Tom Rix <trix@redhat.com>
Link: https://lore.kernel.org/r/20220403140937.3833578-1-trix@redhat.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-09-28 21:10:57 +09:30
Eddie James
d3e1e24604 fsi: occ: Prevent use after free
Use get_device and put_device in the open and close functions to
make sure the device doesn't get freed while a file descriptor is
open.
Also, lock around the freeing of the device buffer and check the
buffer before using it in the submit function.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20220513194424.53468-1-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-09-28 21:10:57 +09:30
Eddie James
7326939faa fsi: occ: Fix checksum failure mode
Change the checksum errno to something different than the errno
used for a bad SBE message. In addition, don't set the user's
response length to the data length in this case, since it's not
SBE FFDC.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20220426154956.27205-2-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-09-27 16:57:17 +09:30
Luo Xueqin
f157555ea3 fsi: Fix typo in comment
Spelling mistake in comment.

Reported-by: k2ci <kernel-bot@kylinos.cn>
Signed-off-by: Luo Xueqin <luoxueqin@kylinos.cn>
Link: https://lore.kernel.org/r/20220705152757.27843-1-luoxueqin66@gmail.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-09-27 16:57:17 +09:30
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
Amitay Isaacs
a1dc630886 fsi: sbefifo: Implement FSI_SBEFIFO_READ_TIMEOUT_SECONDS ioctl
FSI_SBEFIFO_READ_TIMEOUT_SECONDS ioctl sets the read timeout (in
seconds) for the response received by sbefifo device from sbe.  The
timeout affects only the read operation on current sbefifo device fd.

Certain SBE operations can take long time to complete and the default
timeout of 10 seconds might not be sufficient to start receiving
response from SBE.  In such cases, allow the timeout to be set to the
maximum of 120 seconds.

The kernel does not contain the definition of the various SBE
operations, so we must expose an interface to userspace to set the
timeout for the given operation.

Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20220121053816.82253-3-joel@jms.id.au
Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-02-21 19:38:17 +10:30
Amitay Isaacs
b8d536d277 fsi: sbefifo: Use specified value of start of response timeout
For some of the chip-ops where sbe needs to collect trace information,
sbe can take a long time (>30s) to respond.  Currently these chip-ops
will timeout as the start of response timeout defaults to 10s.

Instead of default value, use specified value.  The require timeout
value will be set using ioctl.

Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20220121053816.82253-2-joel@jms.id.au
Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-02-21 19:38:17 +10:30
Eddie James
3dcf3c84f5 fsi: occ: Improve response status checking
If the driver sequence number coincidentally equals the previous
command response sequence number, the driver may proceed with
fetching the entire buffer before the OCC has processed the current
command. To be sure the correct response is obtained, check the
command type and also retry if any of the response parameters have
changed when the rest of the buffer is fetched. Also initialize the
driver with a random sequence number in order to reduce the chances
of this happening.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/20220208152235.19686-1-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-02-21 19:37:03 +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
Joel Stanley
ab1b79159a fsi: scom: Remove retries in indirect scoms
In commit f72ddbe1d7 ("fsi: scom: Remove retries") the retries were
removed from get and put scoms. That patch missed the retires in get and
put indirect scom.

For the same reason, remove them from the scom driver to allow the
caller to decide to retry.

This removes the following special case which would have caused the
retry code to return early:

 -       if ((ind_data & XSCOM_DATA_IND_COMPLETE) || (err != SCOM_PIB_BLOCKED))
 -               return 0;

I believe this case is handled.

Fixes: f72ddbe1d7 ("fsi: scom: Remove retries")
Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20211207033811.518981-3-joel@jms.id.au
Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-01-31 15:56:55 +10:30
Joel Stanley
d46fddd52d fsi: scom: Fix error handling
SCOM error handling is made complex by trying to pass around two bits of
information: the function return code, and a status parameter that
represents the CFAM error status register.

The commit f72ddbe1d7 ("fsi: scom: Remove retries") removed the
"hidden" retries in the SCOM driver, in preference of allowing the
calling code (userspace or driver) to decide how to handle a failed
SCOM. However it introduced a bug by attempting to be smart about the
return codes that were "errors" and which were ok to fall through to the
status register parsing.

We get the following errors:

 - EINVAL or ENXIO, for indirect scoms where the value is invalid
 - EINVAL, where the size or address is incorrect
 - EIO or ETIMEOUT, where FSI write failed (aspeed master)
 - EAGAIN, where the master detected a crc error (GPIO master only)
 - EBUSY, where the bus is disabled (GPIO master in external mode)

In all of these cases we should fail the SCOM read/write and return the
error.

Thanks to Dan Carpenter for the detailed bug report.

Fixes: f72ddbe1d7 ("fsi: scom: Remove retries")
Link: https://lists.ozlabs.org/pipermail/linux-fsi/2021-November/000235.html
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20211207033811.518981-2-joel@jms.id.au
Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-01-31 15:56:55 +10:30
Eddie James
7cc2f34e1f fsi: sbefifo: Use interruptible mutex locking
Some SBE operations have extremely large responses and can require
several minutes to process the response. During this time, the device
lock must be held. If another process attempts an operation, it will
wait for the mutex for longer than the kernel hung task watchdog
allows. Therefore, use the interruptible function to lock the mutex.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/20210803213016.44739-1-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-10-22 09:54:33 +10:30
Eddie James
826280348e fsi: sbefifo: Add sysfs file indicating a timeout error
The SBEFIFO timeout error requires special handling in userspace
to do recovery operations. Add a sysfs file to indicate a timeout
error, and notify pollers when a timeout occurs.

This will be used by the openpower-occ-control application.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/20211019211749.38059-3-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-10-22 09:54:33 +10:30
Eddie James
8ec3cc9fb5 fsi: occ: Store the SBEFIFO FFDC in the user response buffer
If the SBEFIFO response indicates an error, store the response in the
user buffer and return an error. Previously, the user had no way of
obtaining the SBEFIFO FFDC.

The user's buffer now contains data in the event of a failure. No change
in the event of a successful transfer.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20211019205307.36946-3-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-10-22 09:54:32 +10:30
Eddie James
008d3825a8 fsi: occ: Use a large buffer for responses
Allocate a large buffer for each OCC to handle response data. This
removes memory allocation during an operation, and also allows for
the maximum amount of SBE FFDC.

Previously for the putsram and attn commands, only 32 words would have
been available, and for getsram, only up to the size of the transfer.
SBE FFDC might be up to 8Kb.

The SBE interface expects data to be specified in units of words (4
bytes), defined as OCC_MAX_RESP_WORDS.

This change allows the full FFDC capture to be implemented, where before
it was not available.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20211019205307.36946-2-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-10-22 09:50:55 +10:30
Eddie James
62f79f3d0e fsi: occ: Force sequence numbering per OCC
Set and increment the sequence number during the submit operation.
This prevents sequence number conflicts between different users of
the interface. A sequence number conflict may result in a user
getting an OCC response meant for a different command. Since the
sequence number is now modified, the checksum must be calculated and
set before submitting the command.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/20210721190231.117185-2-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-10-15 15:09:25 +10:30
Joachim Fenkes
9ab1428dfe fsi/sbefifo: Fix reset timeout
On BMCs with lower timer resolution than 1ms, msleep(1) will take
way longer than 1ms, so looping 10k times won't wait for 10s but
significantly longer.

Fix this by using jiffies like the rest of the code.

Fixes: 9f4a8a2d7f ("fsi/sbefifo: Add driver for the SBE FIFO")
Signed-off-by: Joachim Fenkes <fenkes@de.ibm.com>
Link: https://lore.kernel.org/r/20200724071518.430515-3-joel@jms.id.au
Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-06-04 16:06:57 +09:30
Joachim Fenkes
95152433e4 fsi/sbefifo: Clean up correct FIFO when receiving reset request from SBE
When the SBE requests a reset via the down FIFO, that is also the
FIFO we should go and reset ;)

Fixes: 9f4a8a2d7f ("fsi/sbefifo: Add driver for the SBE FIFO")
Signed-off-by: Joachim Fenkes <FENKES@de.ibm.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/20200724071518.430515-2-joel@jms.id.au
Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-06-04 15:23:40 +09:30
Zhen Lei
56e05c60f2 fsi: master-ast-cf: Remove redundant error printing in fsi_master_acf_probe()
When devm_ioremap_resource() fails, a clear enough error message will be
printed by its subfunction __devm_ioremap_resource(). The error
information contains the device name, failure cause, and possibly resource
information.

Therefore, remove the error printing here to simplify code and reduce the
binary size.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Link: https://patchwork.ozlabs.org/project/linux-fsi/patch/20210511085745.4340-1-thunder.leizhen@huawei.com/
Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-06-04 15:02:55 +09:30
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
Eddie James
614f0a50c9 fsi: occ: Log error for checksum failure
Log an error if the response checksum doesn't match the
calculated checksum.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/20210209171235.20624-3-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-06-04 14:29:57 +09:30
Eddie James
8a4659be08 fsi: occ: Don't accept response from un-initialized OCC
If the OCC is not initialized and responds as such, the driver
should continue waiting for a valid response until the timeout
expires.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Fixes: 7ed98dddb7 ("fsi: Add On-Chip Controller (OCC) driver")
Link: https://lore.kernel.org/r/20210209171235.20624-2-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-06-04 14:29:54 +09:30