Commit graph

717 commits

Author SHA1 Message Date
Linus Torvalds
0262163136 spi: Updates for v6.17
This release is almost entirely driver work, mostly new drivers with the
 usual smattering of per driver updates anf fixes, with only trivial
 changes in the core.  Highlights include:
 
  - Quite a bit of maintainence work on the STM32 and Qualcomm drivers.
  - Usage of the newly added devm_dma_request_chan() in the ateml driver,
    pulling in the relevant dmaengine change.
  - Cleanups of our usage of the PM autosuspend functions, this pulls in
    some PM core changes on a shared tag.
  - Support for ADI sigma-delta triggers, Amlogic SPISG, Mediatek MT6991
    and MT8196, Renesas RZ/V2H(P) and SOPHGO SG2042.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmiHa5MACgkQJNaLcl1U
 h9DSlAf/YyxtmieKVcrWN9vsfNM6tHWOxLshxoIpkWoab5uVdoLsHQSQzzB76Taz
 mBeJAaf0ipLV9b6b9Cl2rZEwWJPg+l3o3KXAbQSQ7bMV/4vUhsFDkXO/nnPd6EmK
 ta20i7UpuRKvW55MrzbkJ0+bU1kTVrMxDBR/CJQuF0U+TOUaytpIsZ54nfJ5facq
 W4bMNwzpqcxoyk5iR1xQxsu4phPkcL6tQ1XF3MlcTOEOmLxPXNPZX+WDoRYEAuCo
 8M6+YyFMFlEgeQGplDhPb3O/KCTdQOhOGXSs0UpeiVVXV6Ozl23GG47wPC79HWRV
 +pAPQ8FfUnNDHw0IAaHc9WyF+FVhKQ==
 =yjWy
 -----END PGP SIGNATURE-----

Merge tag 'spi-v6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi

Pull spi updates from Mark Brown:
 "This release is almost entirely driver work, mostly new drivers with
  the usual smattering of per driver updates anf fixes, with only
  trivial changes in the core. Highlights include:

   - Quite a bit of maintainence work on the STM32 and Qualcomm drivers

   - Usage of the newly added devm_dma_request_chan() in the ateml
     driver, pulling in the relevant dmaengine change

   - Cleanups of our usage of the PM autosuspend functions, this pulls
     in some PM core changes on a shared tag

   - Support for ADI sigma-delta triggers, Amlogic SPISG, Mediatek
     MT6991 and MT8196, Renesas RZ/V2H(P) and SOPHGO SG2042"

* tag 'spi-v6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (62 commits)
  spi: SPISG: Fix less than zero comparison on a u32 variable
  spi: intel: Allow writeable MTD partition with module param
  spi: Add driver for the RZ/V2H(P) RSPI IP
  spi: dt-bindings: Document the RZ/V2H(P) RSPI
  MAINTAINERS: Add an entry for Amlogic spi driver
  spi: Add Amlogic SPISG driver
  spi: dt-bindings: Add binding document of Amlogic SPISG controller
  spi: spi-sg2044-nor: Add SPI-NOR controller for SG2042
  spi: spi-sg2044-nor: Add configurable chip_info
  spi: dt-bindings: spi-sg2044-nor: Change SOPHGO SG2042
  spi: spi-qpic-snand: simplify bad block marker duplication
  spi: spidev: Add an entry for the ABB spi sensors
  dt-bindings: trivial-devices: Document ABB sensors
  spi: stm32-ospi: Fix NULL vs IS_ERR() bug in stm32_ospi_get_resources()
  spi: gpio: Use explicit 'unsigned int' for parameter types
  spi: dt-bindings: spi-mux: Drop "spi-max-frequency" as required
  spi: st: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
  spi: rspi: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
  spi: sh-msiof: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
  spi: xilinx: Fix block comment style and minor cleanups
  ...
2025-07-28 23:03:09 -07:00
Linus Torvalds
53edfecef6 Power management updates for 6.17-rc1
- Fix two initialization ordering issues in the cpufreq core and a
    governor initialization error path in it, and clean it up (Lifeng
    Zheng)
 
  - Add Granite Rapids support in no-HWP mode to the intel_pstate cpufreq
    driver (Li RongQing)
 
  - Make intel_pstate always use HWP_DESIRED_PERF when operating in the
    passive mode (Rafael Wysocki)
 
  - Allow building the tegra124 cpufreq driver as a module (Aaron Kling)
 
  - Do minor cleanups for Rust cpufreq and cpumask APIs and fix MAINTAINERS
    entry for cpu.rs (Abhinav Ananthu, Ritvik Gupta, Lukas Bulwahn)
 
  - Clean up assorted cpufreq drivers (Arnd Bergmann, Dan Carpenter,
    Krzysztof Kozlowski, Sven Peter, Svyatoslav Ryhel, Lifeng Zheng)
 
  - Add the NEED_UPDATE_LIMITS flag to the CPPC cpufreq driver (Prashant
    Malani)
 
  - Fix minimum performance state label error in the amd-pstate driver
    documentation (Shouye Liu)
 
  - Add the CPUFREQ_GOV_STRICT_TARGET flag to the userspace cpufreq
    governor and explain HW coordination influence on it in the
    documentation (Shashank Balaji)
 
  - Fix opencoded for_each_cpu() in idle_state_valid() in the DT cpuidle
    driver (Yury Norov)
 
  - Remove info about non-existing QoS interfaces from the PM QoS
    documentation (Ulf Hansson)
 
  - Use c_* types via kernel prelude in Rust for OPP (Abhinav Ananthu)
 
  - Add HiSilicon uncore frequency scaling driver to devfreq (Jie Zhan)
 
  - Allow devfreq drivers to add custom sysfs ABIs (Jie Zhan)
 
  - Simplify the sun8i-a33-mbus devfreq driver by using more devm
    functions (Uwe Kleine-König)
 
  - Fix an index typo in trans_stat() in devfreq (Chanwoo Choi)
 
  - Check devfreq governor before using governor->name (Lifeng Zheng)
 
  - Remove a redundant devfreq_get_freq_range() call from
    devfreq_add_device() (Lifeng Zheng)
 
  - Limit max_freq with scaling_min_freq in devfreq (Lifeng Zheng)
 
  - Replace sscanf() with kstrtoul() in set_freq_store() (Lifeng Zheng)
 
  - Extend the asynchronous suspend and resume of devices to handle
    suppliers like parents and consumers like children (Rafael Wysocki)
 
  - Make pm_runtime_force_resume() work for drivers that set the
    DPM_FLAG_SMART_SUSPEND flag and allow PCI drivers and drivers that
    collaborate with the general ACPI PM domain to set it (Rafael
    Wysocki)
 
  - Add kernel parameter to disable asynchronous suspend/resume of
    devices (Tudor Ambarus)
 
  - Drop redundant might_sleep() calls from some functions in the device
    suspend/resume core code (Zhongqiu Han)
 
  - Fix the handling of monitors connected right before waking up the
    system from sleep (tuhaowen)
 
  - Clean up MAINTAINERS entries for suspend and hibernation (Rafael
    Wysocki)
 
  - Fix error code path in the KEXEC_JUMP flow and drop a redundant
    pm_restore_gfp_mask() call from it (Rafael Wysocki)
 
  - Rearrange suspend/resume error handling in the core device suspend
    and resume code (Rafael Wysocki)
 
  - Fix up white space that does not follow coding style in the
    hibernation core code (Darshan Rathod)
 
  - Document return values of suspend-related API functions in the
    runtime PM framework (Sakari Ailus)
 
  - Mark last busy stamp in multiple autosuspend-related functions in the
    runtime PM framework and update its documentation (Sakari Ailus)
 
  - Take active children into account in pm_runtime_get_if_in_use() for
    consistency (Rafael Wysocki)
 
  - Fix NULL pointer dereference in get_pd_power_uw() in the dtpm_cpu
    power capping driver (Sivan Zohar-Kotzer)
 
  - Add support for the Bartlett Lake platform to the Intel RAPL power
    capping driver (Qiao Wei)
 
  - Add PL4 support for Panther Lake to the intel_rapl_msr power capping
    driver (Zhang Rui)
 
  - Update contact information in the PM ABI docs and maintainer
    information in the power domains DT binding (Rafael Wysocki)
 
  - Update PM header inclusions to follow the IWYU (Include What You Use)
    principle (Andy Shevchenko)
 
  - Add flags to specify power on attach/detach for PM domains, make the
    driver core detach PM domains in device_unbind_cleanup(), and drop
    the dev_pm_domain_detach() call from the platform bus type (Claudiu
    Beznea)
 
  - Improve Python binding's Makefile for cpupower (John B. Wyatt IV)
 
  - Fix printing of CORE, CPU fields in cpupower-monitor (Gautham Shenoy)
 -----BEGIN PGP SIGNATURE-----
 
 iQFGBAABCAAwFiEEcM8Aw/RY0dgsiRUR7l+9nS/U47UFAmh/wC4SHHJqd0Byand5
 c29ja2kubmV0AAoJEO5fvZ0v1OO1O6MIAJtfclAleksv+PzbEyC+yk72zKinJg35
 WJUk4Kz1yMOqAPazbpXRXt1tuxqyB3HWeixnTFyZbz+bbhZjYJ0lvpWGkdsFaS0i
 NSbILSpHNGtOrP6s6hVKTBmLAdAzdWYWMQizlWgGrkhOiN5BnQzL7pAi2aGqu9KS
 tGqnIg/3QwBAvnxijgpkm7qozOUMPJ9dzSvxMaFeB6JH7SNbTOODVFtsoD+mbJlH
 YVMMWxih8b4MRJgAo4N2bL1Glp/Qnwg4ACawnQokt8Rknbtwku57QF9YwTbubr36
 Ok7qbNnUSx0h9KtMQQNogLLkFreTJkbGknVWEwaWWhXNeW9l4cr6MWo=
 =xVF9
 -----END PGP SIGNATURE-----

Merge tag 'pm-6.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management updates from Rafael Wysocki:
 "As is tradition, cpufreq is the part with the largest number of
  updates that include core fixes and cleanups as well as updates of
  several assorted drivers, but there are also quite a few updates
  related to system sleep, mostly focused on asynchronous suspend and
  resume of devices and on making the integration of system suspend
  and resume with runtime PM easier.

  Runtime PM is also updated to allow some code duplication in drivers
  to be eliminated going forward and to work more consistently overall
  in some cases.

  Apart from that, there are some driver core updates related to PM
  domains that should help to address ordering issues with devm_ cleanup
  routines relying on PM domains, some assorted devfreq updates
  including core fixes and cleanups, tooling updates, and documentation
  and MAINTAINERS updates.

  Specifics:

   - Fix two initialization ordering issues in the cpufreq core and a
     governor initialization error path in it, and clean it up (Lifeng
     Zheng)

   - Add Granite Rapids support in no-HWP mode to the intel_pstate
     cpufreq driver (Li RongQing)

   - Make intel_pstate always use HWP_DESIRED_PERF when operating in the
     passive mode (Rafael Wysocki)

   - Allow building the tegra124 cpufreq driver as a module (Aaron
     Kling)

   - Do minor cleanups for Rust cpufreq and cpumask APIs and fix
     MAINTAINERS entry for cpu.rs (Abhinav Ananthu, Ritvik Gupta, Lukas
     Bulwahn)

   - Clean up assorted cpufreq drivers (Arnd Bergmann, Dan Carpenter,
     Krzysztof Kozlowski, Sven Peter, Svyatoslav Ryhel, Lifeng Zheng)

   - Add the NEED_UPDATE_LIMITS flag to the CPPC cpufreq driver
     (Prashant Malani)

   - Fix minimum performance state label error in the amd-pstate driver
     documentation (Shouye Liu)

   - Add the CPUFREQ_GOV_STRICT_TARGET flag to the userspace cpufreq
     governor and explain HW coordination influence on it in the
     documentation (Shashank Balaji)

   - Fix opencoded for_each_cpu() in idle_state_valid() in the DT
     cpuidle driver (Yury Norov)

   - Remove info about non-existing QoS interfaces from the PM QoS
     documentation (Ulf Hansson)

   - Use c_* types via kernel prelude in Rust for OPP (Abhinav Ananthu)

   - Add HiSilicon uncore frequency scaling driver to devfreq (Jie Zhan)

   - Allow devfreq drivers to add custom sysfs ABIs (Jie Zhan)

   - Simplify the sun8i-a33-mbus devfreq driver by using more devm
     functions (Uwe Kleine-König)

   - Fix an index typo in trans_stat() in devfreq (Chanwoo Choi)

   - Check devfreq governor before using governor->name (Lifeng Zheng)

   - Remove a redundant devfreq_get_freq_range() call from
     devfreq_add_device() (Lifeng Zheng)

   - Limit max_freq with scaling_min_freq in devfreq (Lifeng Zheng)

   - Replace sscanf() with kstrtoul() in set_freq_store() (Lifeng Zheng)

   - Extend the asynchronous suspend and resume of devices to handle
     suppliers like parents and consumers like children (Rafael Wysocki)

   - Make pm_runtime_force_resume() work for drivers that set the
     DPM_FLAG_SMART_SUSPEND flag and allow PCI drivers and drivers that
     collaborate with the general ACPI PM domain to set it (Rafael
     Wysocki)

   - Add kernel parameter to disable asynchronous suspend/resume of
     devices (Tudor Ambarus)

   - Drop redundant might_sleep() calls from some functions in the
     device suspend/resume core code (Zhongqiu Han)

   - Fix the handling of monitors connected right before waking up the
     system from sleep (tuhaowen)

   - Clean up MAINTAINERS entries for suspend and hibernation (Rafael
     Wysocki)

   - Fix error code path in the KEXEC_JUMP flow and drop a redundant
     pm_restore_gfp_mask() call from it (Rafael Wysocki)

   - Rearrange suspend/resume error handling in the core device suspend
     and resume code (Rafael Wysocki)

   - Fix up white space that does not follow coding style in the
     hibernation core code (Darshan Rathod)

   - Document return values of suspend-related API functions in the
     runtime PM framework (Sakari Ailus)

   - Mark last busy stamp in multiple autosuspend-related functions in
     the runtime PM framework and update its documentation (Sakari
     Ailus)

   - Take active children into account in pm_runtime_get_if_in_use() for
     consistency (Rafael Wysocki)

   - Fix NULL pointer dereference in get_pd_power_uw() in the dtpm_cpu
     power capping driver (Sivan Zohar-Kotzer)

   - Add support for the Bartlett Lake platform to the Intel RAPL power
     capping driver (Qiao Wei)

   - Add PL4 support for Panther Lake to the intel_rapl_msr power
     capping driver (Zhang Rui)

   - Update contact information in the PM ABI docs and maintainer
     information in the power domains DT binding (Rafael Wysocki)

   - Update PM header inclusions to follow the IWYU (Include What You
     Use) principle (Andy Shevchenko)

   - Add flags to specify power on attach/detach for PM domains, make
     the driver core detach PM domains in device_unbind_cleanup(), and
     drop the dev_pm_domain_detach() call from the platform bus type
     (Claudiu Beznea)

   - Improve Python binding's Makefile for cpupower (John B. Wyatt IV)

   - Fix printing of CORE, CPU fields in cpupower-monitor (Gautham
     Shenoy)"

* tag 'pm-6.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (75 commits)
  cpufreq: CPPC: Mark driver with NEED_UPDATE_LIMITS flag
  PM: docs: Use my kernel.org address in ABI docs and DT bindings
  PM: hibernate: Fix up white space that does not follow coding style
  PM: sleep: Rearrange suspend/resume error handling in the core
  Documentation: amd-pstate:fix minimum performance state label error
  PM: runtime: Take active children into account in pm_runtime_get_if_in_use()
  kexec_core: Drop redundant pm_restore_gfp_mask() call
  kexec_core: Fix error code path in the KEXEC_JUMP flow
  PM: sleep: Clean up MAINTAINERS entries for suspend and hibernation
  drivers: cpufreq: add Tegra114 support
  rust: cpumask: Replace `MaybeUninit` and `mem::zeroed` with `Opaque` APIs
  cpufreq: Exit governor when failed to start old governor
  cpufreq: Move the check of cpufreq_driver->get into cpufreq_verify_current_freq()
  cpufreq: Init policy->rwsem before it may be possibly used
  cpufreq: Initialize cpufreq-based frequency-invariance later
  cpufreq: Remove duplicate check in __cpufreq_offline()
  cpufreq: Contain scaling_cur_freq.attr in cpufreq_attrs
  cpufreq: intel_pstate: Add Granite Rapids support in no-HWP mode
  cpufreq: intel_pstate: Always use HWP_DESIRED_PERF in passive mode
  PM / devfreq: Add HiSilicon uncore frequency scaling driver
  ...
2025-07-28 20:13:36 -07:00
Mark Brown
69e536c932
spidev: introduce trivial abb sensor device
Merge series from Heiko Schocher <hs@denx.de>:

This series introduces the changes needed for trivial spi
based sensors from ABB, currently operated from userspace.
2025-07-21 15:39:07 +01:00
Cheng Ming Lin
710505212e
spi: Add check for 8-bit transfer with 8 IO mode support
The current SPI framework does not verify if the SPI device supports
8 IO mode when doing an 8-bit transfer. This patch adds a check to
ensure that if the transfer tx_nbits or rx_nbits is 8, the SPI mode must
support 8 IO. If not, an error is returned, preventing undefined behavior.

Fixes: d6a711a898 ("spi: Fix OCTAL mode support")
Cc: stable@vger.kernel.org
Signed-off-by: Cheng Ming Lin <chengminglin@mxic.com.tw>
Link: https://patch.msgid.link/20250714031023.504752-1-linchengming884@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2025-07-14 14:44:00 +01:00
Claudiu Beznea
d42c7c6fd6 PM: domains: Add flags to specify power on attach/detach
Calling dev_pm_domain_attach()/dev_pm_domain_detach() in bus driver
probe/remove functions can affect system behavior when the drivers
attached to the bus use devres-managed resources. Since devres actions
may need to access device registers, calling dev_pm_domain_detach() too
early, i.e., before these actions complete, can cause failures on some
systems. One such example is Renesas RZ/G3S SoC-based platforms.

If the device clocks are managed via PM domains, invoking
dev_pm_domain_detach() in the bus driver's remove function removes the
device's clocks from the PM domain, preventing any subsequent
pm_runtime_resume*() calls from enabling those clocks.

The second argument of dev_pm_domain_attach() specifies whether the PM
domain should be powered on during attachment. Likewise, the second
argument of dev_pm_domain_detach() indicates whether the domain should be
powered off during detachment.

Upcoming changes address the issue described above (initially for the
platform bus only) by deferring the call to dev_pm_domain_detach() until
after devres_release_all() in device_unbind_cleanup(). The detach_power_off
field in struct dev_pm_info stores the detach power off info from the
second argument of dev_pm_domain_attach().

Because there are cases where the device's PM domain power-on/off behavior
must be conditional (e.g., in i2c_device_probe()), the patch introduces
PD_FLAG_ATTACH_POWER_ON and PD_FLAG_DETACH_POWER_OFF flags to be passed
to dev_pm_domain_attach().

Finally, dev_pm_domain_attach() and its users are updated to use the newly
introduced PD_FLAG_ATTACH_POWER_ON and PD_FLAG_DETACH_POWER_OFF macros.

This change is preparatory.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com> # I2C
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://patch.msgid.link/20250703112708.1621607-2-claudiu.beznea.uj@bp.renesas.com
[ rjw: Changelog adjustments ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2025-07-07 20:41:20 +02:00
Sakari Ailus
2fca750160
spi: Remove redundant pm_runtime_mark_last_busy() calls
pm_runtime_put_autosuspend(), pm_runtime_put_sync_autosuspend(),
pm_runtime_autosuspend() and pm_request_autosuspend() now include a call
to pm_runtime_mark_last_busy(). Remove the now-reduntant explicit call to
pm_runtime_mark_last_busy().

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Link: https://patch.msgid.link/20250704075447.3221784-1-sakari.ailus@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2025-07-05 00:50:32 +01:00
Mark Brown
cbc9d9e108
spi: Introduce and use spi_bpw_to_bytes()
Merge series from Andy Shevchenko <andriy.shevchenko@linux.intel.com>:

Recently in the discussion with David the idea of having
a common helper popped up. The helper converts the given
bits per word to bytes. The result will always be power-of-two
(e.g. for 37 bits it returns 8 bytes) or 0 for 0 input.
More details are in the respective code comment.

This mini-series introduces it and replaces current users
under drivers/spi and we expect more (and possibly some
lurking in other subsystems).
2025-04-18 05:11:47 +01:00
Andy Shevchenko
163ddf1fea
spi: Add spi_bpw_to_bytes() helper and use it
This helper converts the given bits per word to bytes. The result
will always be power-of-two, e.g.,

    ===============    =================
    Input (in bits)    Output (in bytes)
    ===============    =================
            5                   1
            9                   2
            21                  4
            37                  8
    ===============    =================

It will return 0 for the 0 input.

There are a couple of cases in SPI that are using the same approach
and at least one more (in IIO) would benefit of it. Add a helper
for everyone.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250417152529.490582-2-andriy.shevchenko@linux.intel.com
Acked-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2025-04-17 17:30:40 +01:00
Mukesh Kumar Savaliya
88113e09ad
spi: Add support for Double Transfer Rate (DTR) mode
Introduce support for protocol drivers to specify whether a transfer
should use single or dual transfer mode. Currently, the SPI controller
cannot determine this information from the user, leading to potential
limitations in transfer capabilities.

Add a new field `dtr_mode` in the `spi_transfer` structure. The `dtr_mode`
field allows protocol drivers to indicate if Double Transfer Rate (DTR)
mode is supported for a given transfer. When `dtr_mode` is set to true,
the SPI controller will use DTR mode; otherwise, it will default to single
transfer mode.

Introduce another field `dtr_caps` to indicate if the QSPI controller is
capable of supporting DTR mode (SDR and DDR). By default, both `dtr_caps`
and `dtr_mode` will be false. These flags manage the QSPI controller's DTR
mode capabilities within the SPI framework.

The QSPI controller driver uses these flags to configure single or double
transfer rates using the controller register.

The existing spi-mem driver helps configure the DTR mode but is limited to
memory devices. There is no support available to set DTR mode for non-memory
devices, e.g., touch or any generic SPI sensor. This change is backward
compatible and doesn't break existing SPI or QSPI drivers.

Changes include:
- Addition of `dtr_mode` and `dtr_caps` fields in the `spi_transfer`
  structure.
- Documentation updates to reflect the new `dtr_mode` and `dtr_caps` fields.

Signed-off-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com>
Link: https://patch.msgid.link/20250404135427.313825-1-quic_msavaliy@quicinc.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2025-04-13 20:27:01 +01:00
Andy Shevchenko
1f1d979fbf
spi: Simplify conditionals in spi_set_cs()
First of all, the (foo && bar) || (!foo && !bar) when foo and bar
are booleans is equivalent to (foo == bar). Second, reuse variable
that holds already the calculation of the SPI CS mode to be
active-high. No functional changes intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20250331093915.4041600-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2025-04-06 23:26:08 +01:00
Linus Torvalds
47618bc875 spi: Updates for v6.15
The biggest change for SPI this release is the addition of offload
 support from David Lechner, allowing the hardware to trigger SPI
 transactions autonomously.  The initial use case is for triggering IIO
 operations but there are other applications where having the hardware
 ready to go at a minimal signal is useful for synchronising with
 external inputs (eg, interrupt handling) or reducing latency (eg, CAN
 networking).  Otherwise there's the usual fixes, improvements and
 cleanups, plus support for a bunch of new devices.
 
  - Support for offloaing support from David Lechner.
  - Support for GOcontrol1 Moduline modules, Mediatek MT7988, NXP i.MX94,
    Qualcomm SPI NAMD, Rockchip RK3562, Sophogo SG2044 and ST STM32 OSPI.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmfhbQgACgkQJNaLcl1U
 h9DQrAf6A30I4GJGwD4qWwCdsChxr0of8r3q0zIAcC53UaMqLBTdwnQT+wD4MTe8
 vnUY54Z8PYoDKaPx54YxmWh0zB4OQgxvtcJyaZ9biLWtPy3kZdhHlC5xrVQbzLc5
 ki/AW2Fsl2GQ1+5mtI3yP6awQ5HQ17gXS1q+nl2/D1njv2sI1Z1998nBkmsaNwNb
 SPmaDV5UIQkO9wENnJCbX7bRlM+FgkgYo10JFffmWCnntsaZ01NlUC+BBg9y9xAy
 padE2ucWWDqdmiHOC1z7kJU5MFGZWGSSVATLZZz3GL+vw/Oan/Mb5K2zoZh0IcD9
 QPJxNnokYtYFR/IlH/obL0EMutaoSQ==
 =vqZa
 -----END PGP SIGNATURE-----

Merge tag 'spi-v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi

Pull spi updates from Mark Brown:
 "The biggest change for SPI this release is the addition of offload
  support from David Lechner, allowing the hardware to trigger SPI
  transactions autonomously. The initial use case is for triggering IIO
  operations but there are other applications where having the hardware
  ready to go at a minimal signal is useful for synchronising with
  external inputs (eg, interrupt handling) or reducing latency (eg, CAN
  networking).

  Otherwise there's the usual fixes, improvements and cleanups, plus
  support for a bunch of new devices.

   - Support for offloading support from David Lechner

   - Support for GOcontrol1 Moduline modules, Mediatek MT7988, NXP
     i.MX94, Qualcomm SPI NAMD, Rockchip RK3562, Sophogo SG2044 and ST
     STM32 OSPI"

* tag 'spi-v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (59 commits)
  spi: spi-mem: Introduce a default ->exec_op() debug log
  spi: dt-bindings: cdns,qspi-nor: Require some peripheral properties
  spi: dt-bindings: cdns,qspi-nor: Deprecate the Cadence compatible alone
  spi: dt-bindings: cdns,qspi-nor: Be more descriptive regarding what this controller is
  spi: stm32-ospi: Include "gpio/consumer.h"
  MAINTAINERS: adjust the file entry in GOCONTROLL MODULINE MODULE SLOT
  spi: spi-qpic-snand: avoid memleak in qcom_spi_ecc_init_ctx_pipelined()
  spi: spi-mux: Fix coverity issue, unchecked return value
  spi: sophgo: fix incorrect type for ret in sg2044_spifmc_write()
  spi: sg2044-nor: fix uninitialized variable in probe
  spi: sg2044-nor: fix signedness bug in sg2044_spifmc_write()
  spi: sg2044-nor: Convert to dev_err_probe()
  spi: sg2044-nor: Fully convert to device managed resources
  dt-bindings: spi: add compatibles for mt7988
  spi: spidev: Add an entry for the gocontroll moduline module slot
  MAINTAINERS: add maintainer for the GOcontroll Moduline module slot
  dt-bindings: connector: Add the GOcontroll Moduline module slot bindings
  dt-bindings: vendor-prefixes: add GOcontroll
  spi: Use inclusive language
  spi: cadence-qspi: Improve spi memory performance
  ...
2025-03-25 19:28:14 -07:00
Miaoqian Lin
176fda56d7
spi: Fix reference count leak in slave_show()
Fix a reference count leak in slave_show() by properly putting the device
reference obtained from device_find_any_child().

Fixes: 6c364062bf ("spi: core: Add support for registering SPI slave controllers")
Fixes: c21b083798 ("spi: Use device_find_any_child() instead of custom approach")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://patch.msgid.link/20250319032305.70340-1-linmq006@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2025-03-19 12:47:50 +00:00
Andy Shevchenko
91ce208d7a
spi: Use inclusive language
Replace "master" by "[host] controller" in the SPI core code and comments.
All the similar to the "slave" by "target [device]" changes.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20250313140340.380359-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2025-03-13 14:15:54 +00:00
Mark Brown
f46eb2bfb8
spi: axi-spi-engine: add offload support
Merge series from David Lechner <dlechner@baylibre.com>:

As a recap, here is the background and end goal of this series:

The AXI SPI Engine is a SPI controller that has the ability to record a
series of SPI transactions and then play them back using a hardware
trigger. This allows operations to be performed, repeating many times,
without any CPU intervention. This is needed for achieving high data
rates (millions of samples per second) from ADCs and DACs that are
connected via a SPI bus.

The offload hardware interface consists of a trigger input and a data
output for the RX data. These are connected to other hardware external
to the SPI controller.

To record one or more transactions, commands and TX data are written
to memories in the controller (RX buffer is not used since RX data gets
streamed to an external sink). This sequence of transactions can then be
played back when the trigger input is asserted.

This series includes core SPI support along with the first SPI
controller (AXI SPI Engine) and SPI peripheral (AD7944 ADC) that use
them. This enables capturing analog data at 2 million samples per
second.

The hardware setup looks like this:

+-------------------------------+   +------------------+
|                               |   |                  |
|  SOC/FPGA                     |   |  AD7944 ADC      |
|  +---------------------+      |   |                  |
|  | AXI SPI Engine      |      |   |                  |
|  |             SPI Bus ============ SPI Bus          |
|  |                     |      |   |                  |
|  |  +---------------+  |      |   |                  |
|  |  | Offload 0     |  |      |   +------------------+
|  |  |   RX DATA OUT > > > >   |
|  |  |    TRIGGER IN < < <  v  |
|  |  +---------------+  | ^ v  |
|  +---------------------+ ^ v  |
|  | AXI PWM             | ^ v  |
|  |                 CH0 > ^ v  |
|  +---------------------+   v  |
|  | AXI DMA             |   v  |
|  |                 CH0 < < <  |
|  +---------------------+      |
|                               |
+-------------------------------+
2025-02-10 13:06:34 +00:00
David Lechner
700a281905
spi: add offload TX/RX streaming APIs
Most configuration of SPI offloads is handled opaquely using the offload
pointer that is passed to the various offload functions. However, there
are some offload features that need to be controlled on a per transfer
basis.

This patch adds a flag field to struct spi_transfer to allow specifying
such features. The first feature to be added is the ability to stream
data to/from a hardware sink/source rather than using a tx or rx buffer.
Additional flags can be added in the future as needed.

A flags field is also added to the offload struct for providers to
indicate which flags are supported. This allows for generic checking of
offload capabilities during __spi_validate() so that each offload
provider doesn't have to implement their own validation.

As a first users of this streaming capability, getter functions are
added to get a DMA channel that is directly connected to the offload.
Peripheral drivers will use this to get a DMA channel and configure it
to suit their needs.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250207-dlech-mainline-spi-engine-offload-2-v8-5-e48a489be48c@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2025-02-07 20:17:11 +00:00
Andy Shevchenko
215705db51
spi: Replace custom fsleep() implementation
_spi_transfer_delay_ns() partially reimplements what fsleep() does.
Replace that code by calling fsleep() instead.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20250205130624.716039-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2025-02-05 13:53:10 +00:00
Linus Torvalds
38f5265ed2 spi: Updates for v6.14
This is a fairly quiet release for the most part, though we do have one
 really nice improvement in the spi-mem framework which will improve
 performance for flash devices especially when built on by changes in the
 MTD subsystem which are also due to be sent this merge window.  There's
 also been some substantial work on some of the drivers, highlights
 include:
 
  - Support for per-operation bus frequency in the spi-mem framework,
    meaning speeds are no longer limited by the slowest operation.
  - ACPI support and improved power management for Rockchip SFC
    controllers.
  - Support for Atmel SAM7G5 QuadSPI and KEBA SPI controllers.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmeOY7sACgkQJNaLcl1U
 h9AA2gf/Zb0B7R5aVlW46OWTYNklvO/yu/3JmVFnd+BdRjr+0/UpnUQ8SAnsFuiK
 uX1Mw241SpngI4naqhLdR28SP6dMFyi+/5Orl2/kIzx6RSmCMbNDiw56x71KcXFl
 pPjDHRdWOTdRiOwa37/wniaP6wDoWsF4F6sI1jazZP0tc7u+QwT9Hgu+jkzUIQfS
 8eSS1W7zOHxqKVohsOb4V8ddVHGbS7EyTbm5RuMOtWP08pTIgzMdQo76WUTkRjLe
 8N0PNIbDZSSFLF//DMhTZgeD63cjPN4y7UsM1Z8jrKBtLrEzKSPy/bI/IpnLYyd2
 Wdpp2mSCGtRvBO0zU59/HOMv8jYkXw==
 =mFrM
 -----END PGP SIGNATURE-----

Merge tag 'spi-v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi

Pull spi updates from Mark Brown:
 "This is a fairly quiet release for the most part, though we do have
  one really nice improvement in the spi-mem framework which will
  improve performance for flash devices especially when built on by
  changes in the MTD subsystem which are also due to be sent this merge
  window.

  There's also been some substantial work on some of the drivers,
  highlights include:

   - Support for per-operation bus frequency in the spi-mem framework,
     meaning speeds are no longer limited by the slowest operation

   - ACPI support and improved power management for Rockchip SFC
     controllers

   - Support for Atmel SAM7G5 QuadSPI and KEBA SPI controllers"

* tag 'spi-v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (49 commits)
  spi: pxa2xx: Introduce __lpss_ssp_update_priv() helper
  spi: ti-qspi: Use syscon_regmap_lookup_by_phandle_args
  spi: amd: Fix -Wuninitialized in amd_spi_exec_mem_op()
  spi: spi-mem: Estimate the time taken by operations
  spi: spi-mem: Create macros for DTR operation
  spi: spi-mem: Reorder spi-mem macro assignments
  spi: zynqmp-gqspi: Support per spi-mem operation frequency switches
  spi: zynq-qspi: Support per spi-mem operation frequency switches
  spi: spi-ti-qspi: Support per spi-mem operation frequency switches
  spi: spi-sn-f-ospi: Support per spi-mem operation frequency switches
  spi: rockchip-sfc: Support per spi-mem operation frequency switches
  spi: nxp-fspi: Support per spi-mem operation frequency switches
  spi: mxic: Support per spi-mem operation frequency switches
  spi: mt65xx: Support per spi-mem operation frequency switches
  spi: microchip-core-qspi: Support per spi-mem operation frequency switches
  spi: fsl-qspi: Support per spi-mem operation frequency switches
  spi: dw: Support per spi-mem operation frequency switches
  spi: cadence-qspi: Support per spi-mem operation frequency switches
  spi: amlogic-spifc-a1: Support per spi-mem operation frequency switches
  spi: amd: Drop redundant check
  ...
2025-01-22 09:08:18 -08:00
Frederic Weisbecker
b04e317b52 treewide: Introduce kthread_run_worker[_on_cpu]()
kthread_create() creates a kthread without running it yet. kthread_run()
creates a kthread and runs it.

On the other hand, kthread_create_worker() creates a kthread worker and
runs it.

This difference in behaviours is confusing. Also there is no way to
create a kthread worker and affine it using kthread_bind_mask() or
kthread_affine_preferred() before starting it.

Consolidate the behaviours and introduce kthread_run_worker[_on_cpu]()
that behaves just like kthread_run(). kthread_create_worker[_on_cpu]()
will now only create a kthread worker without starting it.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
2025-01-08 18:15:03 +01:00
Andy Shevchenko
0020c9d2d5
spi: Deduplicate deferred probe checks in spi_probe()
Deduplicate deferred probe checks in spi_probe() and enable
the error message for ACPI case as well.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241208195635.1271656-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-12-09 13:14:20 +00:00
Andy Shevchenko
b6ffe0e614
spi: Unify firmware node type checks
The few functions are using different approaches on how to check for
the type of firmware node. Unify them to use a modern way of it.

With that in place it becomes obvious that no need to have independent
conditionals when they are dependent and hence the code generation can
be improved a little bit (clang-18, x86_64):

  add/remove: 0/0 grow/shrink: 2/2 up/down: 16/-46 (-30)
  Total: Before=49801, After=49771, chg -0.06%

Meanwhile no functional changes intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241208195635.1271656-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-12-09 13:14:19 +00:00
Stanislaw Gruszka
d24cfee7f6
spi: Fix acpi deferred irq probe
When probing spi device take care of deferred probe of ACPI irq gpio
similar like for OF/DT case.

>From practical standpoint this fixes issue with vsc-tp driver on
Dell XP 9340 laptop, which try to request interrupt with spi->irq
equal to -EPROBE_DEFER and fail to probe with the following error:

vsc-tp spi-INTC10D0:00: probe with driver vsc-tp failed with error -22

Suggested-by: Hans de Goede <hdegoede@redhat.com>
Fixes: 33ada67da3 ("ACPI / spi: attach GPIO IRQ from ACPI description to SPI device")
Cc: stable@vger.kernel.org
Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Alexis Lothoré <alexis.lothore@bootlin.com> # Dell XPS9320, ov01a10
Link: https://patch.msgid.link/20241122094224.226773-1-stanislaw.gruszka@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-11-26 11:29:15 +00:00
zhang jiao
b1e7828cf9
spi: Delete useless checks
Since "res" will never be null, just delete this check.

Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
Link: https://patch.msgid.link/20241112081637.40962-1-zhangjiao2@cmss.chinamobile.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-11-12 13:08:39 +00:00
Rob Herring (Arm)
270ddc2391
spi: Use of_property_present() for non-boolean properties
The use of of_property_read_bool() for non-boolean properties is
deprecated in favor of of_property_present() when testing for property
presence.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://patch.msgid.link/20241104190759.277184-2-robh@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-11-04 19:18:19 +00:00
Bartosz Golaszewski
36dbe4521a
spi: make class structs const
The two instances of struct class are only used here in functions that
take const pointers and so can too be made constant.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Link: https://patch.msgid.link/20241018122437.64275-1-brgl@bgdev.pl
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-10-18 18:44:41 +01:00
Uwe Kleine-König
eb6c65049a
spi: Provide defer reason if getting irq during probe fails
Using dev_err_probe() in spi_probe() improves the kernel output from

	spi spi0.0: deferred probe pending: (reason unknown)

to

	spi spi0.0: deferred probe pending: ad7124: Failed to get irq...

for my current quest to make a certain spi device work.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20241004094234.268301-2-u.kleine-koenig@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-10-04 13:04:05 +01:00
Yang Yingliang
0809a9ccac
spi: remove {devm_}spi_alloc_master/slave()
All the {devm_}spi_alloc_master/slave() have been replaced,
so they can be removed and replaced in doc and comment.

No functional changed.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://patch.msgid.link/20240902125947.1368-8-yangyingliang@huaweicloud.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-30 01:12:07 +02:00
Yang Yingliang
740c1c84bf
spi: remove spi_controller_is_slave() and spi_slave_abort()
spi_controller_is_slave() and spi_slave_abort() are all replaced,
so they can be removed.

No functional changed.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://patch.msgid.link/20240910022618.1397-8-yangyingliang@huaweicloud.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:41:42 +01:00
Yang Yingliang
1e0cc8d0a1
spi: switch to use spi_controller_is_target()
Switch to use modern name function spi_controller_is_target().

No functional changed.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://patch.msgid.link/20240910022618.1397-2-yangyingliang@huaweicloud.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:41:36 +01:00
Marcelo Schmitt
f58872f45c
spi: Enable controllers to extend the SPI protocol with MOSI idle configuration
The behavior of an SPI controller data output line (SDO or MOSI or COPI
(Controller Output Peripheral Input) for disambiguation) is usually not
specified when the controller is not clocking out data on SCLK edges.
However, there do exist SPI peripherals that require specific MOSI line
state when data is not being clocked out of the controller.

Conventional SPI controllers may set the MOSI line on SCLK edges then bring
it low when no data is going out or leave the line the state of the last
transfer bit. More elaborated controllers are capable to set the MOSI idle
state according to different configurable levels and thus are more suitable
for interfacing with demanding peripherals.

Add SPI mode bits to allow peripherals to request explicit MOSI idle state
when needed.

When supporting a particular MOSI idle configuration, the data output line
state is expected to remain at the configured level when the controller is
not clocking out data. When a device that needs a specific MOSI idle state
is identified, its driver should request the MOSI idle configuration by
setting the proper SPI mode bit.

Acked-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Tested-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Link: https://patch.msgid.link/9802160b5e5baed7f83ee43ac819cb757a19be55.1720810545.git.marcelo.schmitt@analog.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-07-29 01:19:51 +01:00
Linus Torvalds
c2a96b7f18 Driver core changes for 6.11-rc1
Here is the big set of driver core changes for 6.11-rc1.
 
 Lots of stuff in here, with not a huge diffstat, but apis are evolving
 which required lots of files to be touched.  Highlights of the changes
 in here are:
   - platform remove callback api final fixups (Uwe took many releases to
     get here, finally!)
   - Rust bindings for basic firmware apis and initial driver-core
     interactions.  It's not all that useful for a "write a whole driver
     in rust" type of thing, but the firmware bindings do help out the
     phy rust drivers, and the driver core bindings give a solid base on
     which others can start their work.  There is still a long way to go
     here before we have a multitude of rust drivers being added, but
     it's a great first step.
   - driver core const api changes.  This reached across all bus types,
     and there are some fix-ups for some not-common bus types that
     linux-next and 0-day testing shook out.  This work is being done to
     help make the rust bindings more safe, as well as the C code, moving
     toward the end-goal of allowing us to put driver structures into
     read-only memory.  We aren't there yet, but are getting closer.
   - minor devres cleanups and fixes found by code inspection
   - arch_topology minor changes
   - other minor driver core cleanups
 
 All of these have been in linux-next for a very long time with no
 reported problems.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCZqH+aQ8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ymoOQCfVBdLcBjEDAGh3L8qHRGMPy4rV2EAoL/r+zKm
 cJEYtJpGtWX6aAtugm9E
 =ZyJV
 -----END PGP SIGNATURE-----

Merge tag 'driver-core-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core updates from Greg KH:
 "Here is the big set of driver core changes for 6.11-rc1.

  Lots of stuff in here, with not a huge diffstat, but apis are evolving
  which required lots of files to be touched. Highlights of the changes
  in here are:

   - platform remove callback api final fixups (Uwe took many releases
     to get here, finally!)

   - Rust bindings for basic firmware apis and initial driver-core
     interactions.

     It's not all that useful for a "write a whole driver in rust" type
     of thing, but the firmware bindings do help out the phy rust
     drivers, and the driver core bindings give a solid base on which
     others can start their work.

     There is still a long way to go here before we have a multitude of
     rust drivers being added, but it's a great first step.

   - driver core const api changes.

     This reached across all bus types, and there are some fix-ups for
     some not-common bus types that linux-next and 0-day testing shook
     out.

     This work is being done to help make the rust bindings more safe,
     as well as the C code, moving toward the end-goal of allowing us to
     put driver structures into read-only memory. We aren't there yet,
     but are getting closer.

   - minor devres cleanups and fixes found by code inspection

   - arch_topology minor changes

   - other minor driver core cleanups

  All of these have been in linux-next for a very long time with no
  reported problems"

* tag 'driver-core-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (55 commits)
  ARM: sa1100: make match function take a const pointer
  sysfs/cpu: Make crash_hotplug attribute world-readable
  dio: Have dio_bus_match() callback take a const *
  zorro: make match function take a const pointer
  driver core: module: make module_[add|remove]_driver take a const *
  driver core: make driver_find_device() take a const *
  driver core: make driver_[create|remove]_file take a const *
  firmware_loader: fix soundness issue in `request_internal`
  firmware_loader: annotate doctests as `no_run`
  devres: Correct code style for functions that return a pointer type
  devres: Initialize an uninitialized struct member
  devres: Fix memory leakage caused by driver API devm_free_percpu()
  devres: Fix devm_krealloc() wasting memory
  driver core: platform: Switch to use kmemdup_array()
  driver core: have match() callback in struct bus_type take a const *
  MAINTAINERS: add Rust device abstractions to DRIVER CORE
  device: rust: improve safety comments
  MAINTAINERS: add Danilo as FIRMWARE LOADER maintainer
  MAINTAINERS: add Rust FW abstractions to FIRMWARE LOADER
  firmware: rust: improve safety comments
  ...
2024-07-25 10:42:22 -07:00
Linus Torvalds
e23dd95cfd spi: Updates for v6.11
There's some quite exciting core work in this release, we've got the
 beginnings of support for hardware initiated transfers which is itself
 independently useful for optimising fast paths in existing drivers.
 
 We also have a rework of the DMA mapping which allows finer grained
 decisions about DMA mapping messages and also helps remove some bodges
 that we'd had.
 
 Otherwise it's a fairly quiet release, a few new drivers and features
 for existing drivers, together with various cleanups and DT binding
 conversions.
 
 One regmap SPI fix made it's way in here too which I should probably
 have sent as a regmap fix instead.
 
  - Support for pre-optimising messages, reducing the overhead for
    messages that are repeatedly used (eg, reading the interrupt status
    from a device).  This will also be used for hardware initiated
    transfers in future.
  - A reworking of how DMA mapping is done, introducing a new helper and
    allowing the DMA mapping decision to be done per transfer instead of
    per message.
  - Support for Atmel SAMA7D64, Freescale LX2160A DSPI and WCH CH341A.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmaVLH0ACgkQJNaLcl1U
 h9DhHQf+KD1gVf0dF9N7Y4gf+fjFQpbf7hxpB24lpJ952/9Ke1hsM19JZDqNaTVa
 ITXIyQLr4uCtPXZ6jOd03td/6TGs9sG3VTLcRrYCG44CvhWpDgAg9Nc3KbNj95Zf
 oPWMLEG2Y2ZjGzIrbqciJ5IRF/gT4rnc2PwytmkrPYwQn6CLUCw7BM3QFFqMnyPb
 U4UA/EmLuOqtlu4z+hdL97JX/XWQfWNLzXfIlIrfJserRBexwmefN7Y2+5fica02
 OBTDyMsg82yZtqASvbsTVn4di577oCYbMnpy+0f+a74h2DDMDfspury8CbrST+Cj
 Jr7/082RuYUlUUyrR9N98EhJ9p1K+w==
 =snrv
 -----END PGP SIGNATURE-----

Merge tag 'spi-v6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi

Pull spi updates from Mark Brown:
 "There's some quite exciting core work in this release, we've got the
  beginnings of support for hardware initiated transfers which is itself
  independently useful for optimising fast paths in existing drivers.

  We also have a rework of the DMA mapping which allows finer grained
  decisions about DMA mapping messages and also helps remove some bodges
  that we'd had.

  Otherwise it's a fairly quiet release, a few new drivers and features
  for existing drivers, together with various cleanups and DT binding
  conversions.

  One regmap SPI fix made it's way in here too which I should probably
  have sent as a regmap fix instead.

  Summary:

   - Support for pre-optimising messages, reducing the overhead for
     messages that are repeatedly used (eg, reading the interrupt status
     from a device). This will also be used for hardware initiated
     transfers in future.

   - A reworking of how DMA mapping is done, introducing a new helper
     and allowing the DMA mapping decision to be done per transfer
     instead of per message.

   - Support for Atmel SAMA7D64, Freescale LX2160A DSPI and WCH CH341A"

* tag 'spi-v6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (72 commits)
  spi: dt-bindings: at91: Add sama7d65 compatible string
  spi: add ch341a usb2spi driver
  spi: dt-bindings: fsl-dspi: add compatible string 'fsl,lx2160a-dspi'
  spi: dt-bindings: fsl-dspi: add dmas and dma-names properties
  spi: spi: Remove unnecessary ‘0’ values from status
  spi: spi: Remove unnecessary ‘0’ values from rc
  spi: xcomm: fix coding style
  spi: xcomm: remove i2c_set_clientdata()
  spi: xcomm: make use of devm_spi_alloc_host()
  spi: xcomm: add gpiochip support
  spi: dt-bindings: snps,dw-apb-ssi.yaml: update compatible property
  spi: dt-bindings: fsl-dspi: Convert to yaml format
  spi: fsl-dspi: use common proptery 'spi-cs-setup(hold)-delay-ns'
  spi: axi-spi-engine: remove platform_set_drvdata()
  spi: spi-fsl-lpspi: Pass pm_ptr()
  spi: spi-imx: Pass pm_ptr()
  spi: spi-fsl-lpspi: Switch to SYSTEM_SLEEP_PM_OPS()
  spi: spi-imx: Switch to RUNTIME_PM_OPS/SYSTEM_SLEEP_PM_OPS()
  spi: add EXPORT_SYMBOL_GPL(devm_spi_optimize_message)
  spi: add devm_spi_optimize_message() helper
  ...
2024-07-15 18:03:43 -07:00
David Lechner
ca52aa4c60
spi: add defer_optimize_message controller flag
Adding spi_optimize_message() broke the spi-mux driver because it
calls spi_async() from it's transfer_one_message() callback. This
resulted in passing an incorrectly optimized message to the controller.
For example, if the underlying controller has an optimize_message()
callback, this would have not been called and can cause a crash when
the underlying controller driver tries to transfer the message.

Also, since the spi-mux driver swaps out the controller pointer by
replacing msg->spi, __spi_unoptimize_message() was being called with a
different controller than the one used in __spi_optimize_message(). This
could cause a crash when attempting to free the message resources when
__spi_unoptimize_message() is called in spi_finalize_current_message()
since it is being called with a controller that did not allocate the
resources.

This is fixed by adding a defer_optimize_message flag for controllers.
This flag causes all of the spi_[maybe_][un]optimize_message() calls to
be a no-op (other than attaching a pointer to the spi device to the
message).

This allows the spi-mux driver to pass an unmodified message to
spi_async() in spi_mux_transfer_one_message() after the spi device has
been swapped out. This causes __spi_optimize_message() and
__spi_unoptimize_message() to be called only once per message and with
the correct/same controller in each case.

Reported-by: Oleksij Rempel <o.rempel@pengutronix.de>
Closes: https://lore.kernel.org/linux-spi/Zn6HMrYG2b7epUxT@pengutronix.de/
Reported-by: Marc Kleine-Budde <mkl@pengutronix.de>
Closes: https://lore.kernel.org/linux-spi/20240628-awesome-discerning-bear-1621f9-mkl@pengutronix.de/
Fixes: 7b1d87af14 ("spi: add spi_optimize_message() APIs")
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20240708-spi-mux-fix-v1-2-6c8845193128@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-07-09 17:42:32 +01:00
David Lechner
c86a918b1b
spi: don't unoptimize message in spi_async()
Calling spi_maybe_unoptimize_message() in spi_async() is wrong because
the message is likely to be in the queue and not transferred yet. This
can corrupt the message while it is being used by the controller driver.

spi_maybe_unoptimize_message() is already called in the correct place
in spi_finalize_current_message() to balance the call to
spi_maybe_optimize_message() in spi_async().

Fixes: 7b1d87af14 ("spi: add spi_optimize_message() APIs")
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20240708-spi-mux-fix-v1-1-6c8845193128@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-07-09 17:42:31 +01:00
Li zeming
3bca1a3808
spi: spi: Remove unnecessary ‘0’ values from status
status is assigned first, so it does not need to initialize the assignment.

Signed-off-by: Li zeming <zeming@nfschina.com>
Link: https://patch.msgid.link/20240708041411.14424-1-zeming@nfschina.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-07-08 12:50:28 +01:00
Li zeming
0f2ecc3f61
spi: spi: Remove unnecessary ‘0’ values from rc
rc is assigned first, so it does not need to initialize the assignment.

Signed-off-by: Li zeming <zeming@nfschina.com>
Link: https://patch.msgid.link/20240708035320.14241-1-zeming@nfschina.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-07-08 12:50:27 +01:00
Greg Kroah-Hartman
d69d804845 driver core: have match() callback in struct bus_type take a const *
In the match() callback, the struct device_driver * should not be
changed, so change the function callback to be a const *.  This is one
step of many towards making the driver core safe to have struct
device_driver in read-only memory.

Because the match() callback is in all busses, all busses are modified
to handle this properly.  This does entail switching some container_of()
calls to container_of_const() to properly handle the constant *.

For some busses, like PCI and USB and HV, the const * is cast away in
the match callback as those busses do want to modify those structures at
this point in time (they have a local lock in the driver structure.)
That will have to be changed in the future if they wish to have their
struct device * in read-only-memory.

Cc: Rafael J. Wysocki <rafael@kernel.org>
Reviewed-by: Alex Elder <elder@kernel.org>
Acked-by: Sumit Garg <sumit.garg@linaro.org>
Link: https://lore.kernel.org/r/2024070136-wrongdoer-busily-01e8@gregkh
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-07-03 15:16:54 +02:00
Mark Brown
f01062881f
spi: add devm_spi_optimize_message() helper
Merge series from David Lechner <dlechner@baylibre.com>:

In the IIO subsystem, we are finding that it is common to call
spi_optimize_message() during driver probe since the SPI message
doesn't change for the lifetime of the driver. This patch adds a
devm_spi_optimize_message() helper to simplify this common pattern.
2024-06-25 18:49:11 +01:00
David Lechner
7e74a45c7a
spi: add EXPORT_SYMBOL_GPL(devm_spi_optimize_message)
devm_spi_optimize_message() is a public function and needs
EXPORT_SYMBOL_GPL.

Reported-by: Jonathan Cameron <jic23@kernel.org>
Closes: https://lore.kernel.org/linux-iio/20240624204424.6a91a5e4@jic23-huawei/
Fixes: d4a0055fdc ("spi: add devm_spi_optimize_message() helper")
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20240624-devm_spi_optimize_message-v2-1-58155c0180c2@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-06-24 21:25:57 +01:00
Mark Brown
17436001a6
spi: add devm_spi_optimize_message() helper
Merge series from David Lechner <dlechner@baylibre.com>:

In the IIO subsystem, we are finding that it is common to call
spi_optimize_message() during driver probe since the SPI message
doesn't change for the lifetime of the driver. This patch adds a
devm_spi_optimize_message() helper to simplify this common pattern.
2024-06-23 13:14:18 +01:00
David Lechner
d4a0055fdc
spi: add devm_spi_optimize_message() helper
This adds a new helper function devm_spi_optimize_message() that
automatically registers spi_unoptimize_message() to be called
when the device is removed.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20240621-devm_spi_optimize_message-v1-2-3f9dcba6e95e@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-06-22 12:14:33 +01:00
Mark Brown
741b31df02
spi: Merge up fixes
We need the fixes to apply new changes to the Cirrus drivers.
2024-06-20 21:09:48 +01:00
Amit Kumar Mahapatra
2c1b7bbe25
spi: Fix SPI slave probe failure
While adding a SPI device, the SPI core ensures that multiple logical CS
doesn't map to the same physical CS. For example, spi->chip_select[0] !=
spi->chip_select[1] and so forth. However, unlike the SPI master, the SPI
slave doesn't have the list of chip selects, this leads to probe failure
when the SPI controller is configured as slave. Update the
__spi_add_device() function to perform this check only if the SPI
controller is configured as master.

Fixes: 4d8ff6b099 ("spi: Add multi-cs memories support in SPI core")
Signed-off-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com>
Link: https://msgid.link/r/20240617153052.26636-1-amit.kumar-mahapatra@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-06-18 21:16:15 +01:00
Patrice Chotard
d6a711a898
spi: Fix OCTAL mode support
Add OCTAL mode support.
Issue detected using "--octal" spidev_test's option.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Link: https://msgid.link/r/20240618132951.2743935-4-patrice.chotard@foss.st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-06-18 14:48:27 +01:00
Andy Shevchenko
e289df8234
spi: Rework per message DMA mapped flag to be per transfer
The granularity of DMA mappings is transfer and moreover,
the direction is also important as it can be unidirect.

The current cur_msg_mapped flag doesn't fit well the DMA mapping
and syncing calls and we have tons of checks around on top of it.
So, instead of doing that rework the code to use per transfer per
direction flag to show if it's DMA mapped or not.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8650-QRD
Link: https://lore.kernel.org/r/20240531194723.1761567-9-andriy.shevchenko@linux.intel.com
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
Tested-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-06-10 12:49:03 +01:00
Mark Brown
22aaae4820 Linux 6.10-rc2
-----BEGIN PGP SIGNATURE-----
 
 iQFSBAABCAA8FiEEq68RxlopcLEwq+PEeb4+QwBBGIYFAmZc9egeHHRvcnZhbGRz
 QGxpbnV4LWZvdW5kYXRpb24ub3JnAAoJEHm+PkMAQRiGoLsH/0xo1TNZwNRE9Qux
 gFbJDDhxMtvWnJCSqUuhpypd7SoVVEVKiXW942gWTl97PlCEH0ov3p+0UbxnmG13
 kKJT1C/gct95L03OAfGquIjBSWh4/55o6Vz1zYTGvTFpWZo7G3ZvCDY8o9kN5/L3
 mnpC+GfzZ9ckg+2TfwlbGBQUtILHV3IipCbfDFPSrT8mS0IT67uvBlND3nI++woj
 J1znGqg1PQ6yFnFCfj4RYCiyv/jEAT0ZTyokO4rH+iQVufc3y02mokhMuqmSoE6T
 5bbHToLZIaa/QjRamN/+ltwyrhv8WlX4rJOkMibJY6w8gpukt/k6gL2Pguk4y2pf
 0FPbbC0=
 =0AGs
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmZdsDsACgkQJNaLcl1U
 h9B5bgf+K3H6WnMn+2TsKE7TBRW8D8J1FJdYDcJ5CoM/tw10YqgNHIvrZXvikLQG
 Di3jM3SIFTWn2R350PBx+z+05o3vjVKWpH1bi/EPCCfKl80vyOaMFDZYL7jRxBBl
 x3dzqsn//U13U2mdVQ0d1plxtCBqzy8v1nDq+9KNog1gjfTLFQ2Aa+++oZkoDqo4
 TJgqBAAzmynDawEhZ7WKdAb6Wb/AEyvWGgfudE+N2Qs3NZt2tbnD2KH23e8SF3ZN
 J3CiL6JPSuI2fAW8+zlZdmQRf/pEZFXxebnKc7fyDglqmzU4Pw4IIt/xIfuFMDBA
 eEPZ+gaeBV2jjPsqXb1gxD3hqCMYeQ==
 =qq1C
 -----END PGP SIGNATURE-----

spi: Merge up fixes

We need these to get the i.MX8 boards working in CI again.
2024-06-03 12:59:34 +01:00
Andy Shevchenko
9dedabe95b
spi: Assign dummy scatterlist to unidirectional transfers
Commit 8cc3bad9d9 ("spi: Remove unneded check for orig_nents")
introduced a regression: unmapped data could now be passed to the DMA
APIs, resulting in null pointer dereferences. Commit 9f788ba457 ("spi:
Don't mark message DMA mapped when no transfer in it is") and commit
da560097c0 ("spi: Check if transfer is mapped before calling DMA sync
APIs") addressed the problem, but only partially. Unidirectional
transactions will still result in null pointer dereference. To prevent
that from happening, assign a dummy scatterlist when no data is mapped,
so that the DMA API can be called and not result in a null pointer
dereference.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reported-by: Neil Armstrong <neil.armstrong@linaro.org>
Closes: https://lore.kernel.org/r/8ae675b5-fcf9-4c9b-b06a-4462f70e1322@linaro.org
Reported-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Closes: https://lore.kernel.org/all/d3679496-2e4e-4a7c-97ed-f193bd53af1d@notapiano
Closes: https://lore.kernel.org/all/4748499f-789c-45a8-b50a-2dd09f4bac8c@notapiano
Fixes: 8cc3bad9d9 ("spi: Remove unneded check for orig_nents")
Tested-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
[nfraprado: wrote the commit message]
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Link: https://msgid.link/r/20240529-dma-oops-dummy-v1-1-bb43aacfb11b@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-05-29 16:47:53 +01:00
Andy Shevchenko
a71b7845c0
spi: Refactor spi_stop_queue()
The refactoring makes code less verbose and easier to read.
Besides that the binary size is also reduced, which sounds
like a win-win case:

  add/remove: 0/1 grow/shrink: 2/2 up/down: 210/-226 (-16)
  Function                            old     new   delta
  spi_destroy_queue                    42     156    +114
  spi_controller_suspend              101     197     +96
  spi_unregister_controller           346     319     -27
  spi_register_controller            1834    1794     -40
  spi_stop_queue                      159       -    -159
  Total: Before=49230, After=49214, chg -0.03%

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://msgid.link/r/20240510204945.2581944-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-05-27 01:33:42 +01:00
Andy Shevchenko
2d19ea9e88
spi: Replace custom code with device_match_acpi_handle()
Since driver core provides a generic device_match_acpi_handle()
we may replace the custom code with it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://msgid.link/r/20240510204952.2582093-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-05-27 01:33:40 +01:00
Mark Brown
3aac9f4885
soi: Don't call DMA sync API when not needed
Merge series from Andy Shevchenko <andriy.shevchenko@linux.intel.com>:

A couple of fixes to avoid calling DMA sync API when it's not needed.
This doesn't stop from discussing if IOMMU code is doing the right thing,
i.e. dereferences SG list when orig_nents == 0, but this is a separate
story.
2024-05-23 15:16:57 +01:00
Andy Shevchenko
da560097c0
spi: Check if transfer is mapped before calling DMA sync APIs
The resent update to remove the orig_nents checks revealed
that not all DMA sync backends can cope with the unallocated
SG list, while supplying orig_nents == 0 (the commit 861370f49c
("iommu/dma: force bouncing if the size is not cacheline-aligned"),
for example, makes that happen for the IOMMU case). It means
we have to check if the buffers are DMA mapped before trying
to sync them. Re-introduce that check in a form of calling
->can_dma() in the same way as it's done in the DMA mapping loop
for the SPI transfers.

Reported-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reported-by: Neil Armstrong <neil.armstrong@linaro.org>
Closes: https://lore.kernel.org/r/8ae675b5-fcf9-4c9b-b06a-4462f70e1322@linaro.org
Closes: https://lore.kernel.org/all/d3679496-2e4e-4a7c-97ed-f193bd53af1d@notapiano
Fixes: 8cc3bad9d9 ("spi: Remove unneded check for orig_nents")
Suggested-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Tested-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://msgid.link/r/20240522171018.3362521-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-05-23 12:32:54 +01:00