Commit Graph

5890 Commits

Author SHA1 Message Date
Ivan Vecera 2a52fbc685 spi: Introduce spi_get_device_match_data() helper
JIRA: https://issues.redhat.com/browse/RHEL-105063

commit aea672d054a21782ed8450c75febb6ba3c208ca4
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date:   Thu Oct 20 22:54:21 2022 +0300

    spi: Introduce spi_get_device_match_data() helper

    The proposed spi_get_device_match_data() helper is for retrieving
    a driver data associated with the ID in an ID table. First, it tries
    to get driver data of the device enumerated by firmware interface
    (usually Device Tree or ACPI). If none is found it falls back to
    the SPI ID table matching.

    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Link: https://lore.kernel.org/r/20221020195421.10482-1-andriy.shevchenko@linux.intel.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2025-08-12 11:45:36 +02:00
David Arcari b1c3805e34 spi: pxa2xx: Add MTP-S, ARL-H, LNL-M support
JIRA: https://issues.redhat.com/browse/RHEL-78311
Upstream Status: RHEL-only

RHEL is missing the following upstream commit:

07c337927e06 ("spi: pxa2xx: Remove no more neededPCI ID table")

as well as additional predecessor commits, so in order to support Meteor
Lake PCH-S, ARL-H, and LNL-M we need to add some of the entries
from upstream 72d4a1683741 into the pxa2xx_spi_pci_compound_match table
in spi-pxa2xx.c.

Signed-off-by: David Arcari <darcari@redhat.com>
2025-02-07 12:15:12 -05:00
CKI Backport Bot 778e78fb4b spi: nxp-fspi: fix the KASAN report out-of-bounds bug
JIRA: https://issues.redhat.com/browse/RHEL-60743
CVE: CVE-2024-46853

commit 2a8787c1cdc7be24fdd8953ecd1a8743a1006235
Author: Han Xu <han.xu@nxp.com>
Date:   Wed Sep 11 16:11:45 2024 -0500

    spi: nxp-fspi: fix the KASAN report out-of-bounds bug

    Change the memcpy length to fix the out-of-bounds issue when writing the
    data that is not 4 byte aligned to TX FIFO.

    To reproduce the issue, write 3 bytes data to NOR chip.

    dd if=3b of=/dev/mtd0
    [   36.926103] ==================================================================
    [   36.933409] BUG: KASAN: slab-out-of-bounds in nxp_fspi_exec_op+0x26ec/0x2838
    [   36.940514] Read of size 4 at addr ffff00081037c2a0 by task dd/455
    [   36.946721]
    [   36.948235] CPU: 3 UID: 0 PID: 455 Comm: dd Not tainted 6.11.0-rc5-gc7b0e37c8434 #1070
    [   36.956185] Hardware name: Freescale i.MX8QM MEK (DT)
    [   36.961260] Call trace:
    [   36.963723]  dump_backtrace+0x90/0xe8
    [   36.967414]  show_stack+0x18/0x24
    [   36.970749]  dump_stack_lvl+0x78/0x90
    [   36.974451]  print_report+0x114/0x5cc
    [   36.978151]  kasan_report+0xa4/0xf0
    [   36.981670]  __asan_report_load_n_noabort+0x1c/0x28
    [   36.986587]  nxp_fspi_exec_op+0x26ec/0x2838
    [   36.990800]  spi_mem_exec_op+0x8ec/0xd30
    [   36.994762]  spi_mem_no_dirmap_read+0x190/0x1e0
    [   36.999323]  spi_mem_dirmap_write+0x238/0x32c
    [   37.003710]  spi_nor_write_data+0x220/0x374
    [   37.007932]  spi_nor_write+0x110/0x2e8
    [   37.011711]  mtd_write_oob_std+0x154/0x1f0
    [   37.015838]  mtd_write_oob+0x104/0x1d0
    [   37.019617]  mtd_write+0xb8/0x12c
    [   37.022953]  mtdchar_write+0x224/0x47c
    [   37.026732]  vfs_write+0x1e4/0x8c8
    [   37.030163]  ksys_write+0xec/0x1d0
    [   37.033586]  __arm64_sys_write+0x6c/0x9c
    [   37.037539]  invoke_syscall+0x6c/0x258
    [   37.041327]  el0_svc_common.constprop.0+0x160/0x22c
    [   37.046244]  do_el0_svc+0x44/0x5c
    [   37.049589]  el0_svc+0x38/0x78
    [   37.052681]  el0t_64_sync_handler+0x13c/0x158
    [   37.057077]  el0t_64_sync+0x190/0x194
    [   37.060775]
    [   37.062274] Allocated by task 455:
    [   37.065701]  kasan_save_stack+0x2c/0x54
    [   37.069570]  kasan_save_track+0x20/0x3c
    [   37.073438]  kasan_save_alloc_info+0x40/0x54
    [   37.077736]  __kasan_kmalloc+0xa0/0xb8
    [   37.081515]  __kmalloc_noprof+0x158/0x2f8
    [   37.085563]  mtd_kmalloc_up_to+0x120/0x154
    [   37.089690]  mtdchar_write+0x130/0x47c
    [   37.093469]  vfs_write+0x1e4/0x8c8
    [   37.096901]  ksys_write+0xec/0x1d0
    [   37.100332]  __arm64_sys_write+0x6c/0x9c
    [   37.104287]  invoke_syscall+0x6c/0x258
    [   37.108064]  el0_svc_common.constprop.0+0x160/0x22c
    [   37.112972]  do_el0_svc+0x44/0x5c
    [   37.116319]  el0_svc+0x38/0x78
    [   37.119401]  el0t_64_sync_handler+0x13c/0x158
    [   37.123788]  el0t_64_sync+0x190/0x194
    [   37.127474]
    [   37.128977] The buggy address belongs to the object at ffff00081037c2a0
    [   37.128977]  which belongs to the cache kmalloc-8 of size 8
    [   37.141177] The buggy address is located 0 bytes inside of
    [   37.141177]  allocated 3-byte region [ffff00081037c2a0, ffff00081037c2a3)
    [   37.153465]
    [   37.154971] The buggy address belongs to the physical page:
    [   37.160559] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x89037c
    [   37.168596] flags: 0xbfffe0000000000(node=0|zone=2|lastcpupid=0x1ffff)
    [   37.175149] page_type: 0xfdffffff(slab)
    [   37.179021] raw: 0bfffe0000000000 ffff000800002500 dead000000000122 0000000000000000
    [   37.186788] raw: 0000000000000000 0000000080800080 00000001fdffffff 0000000000000000
    [   37.194553] page dumped because: kasan: bad access detected
    [   37.200144]
    [   37.201647] Memory state around the buggy address:
    [   37.206460]  ffff00081037c180: fa fc fc fc fa fc fc fc fa fc fc fc fa fc fc fc
    [   37.213701]  ffff00081037c200: fa fc fc fc 05 fc fc fc 03 fc fc fc 02 fc fc fc
    [   37.220946] >ffff00081037c280: 06 fc fc fc 03 fc fc fc fc fc fc fc fc fc fc fc
    [   37.228186]                                ^
    [   37.232473]  ffff00081037c300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
    [   37.239718]  ffff00081037c380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
    [   37.246962] ==================================================================
    [   37.254394] Disabling lock debugging due to kernel taint
    0+1 records in
    0+1 records out
    3 bytes copied, 0.335911 s, 0.0 kB/s

    Fixes: a5356aef6a ("spi: spi-mem: Add driver for NXP FlexSPI controller")
    Cc: stable@kernel.org
    Signed-off-by: Han Xu <han.xu@nxp.com>
    Link: https://patch.msgid.link/20240911211146.3337068-1-han.xu@nxp.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com>
2024-09-27 19:18:14 +00:00
Lucas Zampieri a12e9ba4e0 Merge: spi: lpspi: Avoid potential use-after-free in probe()
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4648

JIRA: https://issues.redhat.com/browse/RHEL-33234
CVE: CVE-2024-26866
Omitted-fix: 6c6871cdaef9 ("spi: Merge spi_controller.{slave,target}_abort()")
             This fix would be nice to have, but isn't necessary at the moment, as RHEL doesn't enable
             CONFIG_SPI_SLAVE and therefore this fix would have no runtime effect.

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>

Approved-by: Brian Masney <bmasney@redhat.com>
Approved-by: Eric Chanudet <echanude@redhat.com>
Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com>

Merged-by: Lucas Zampieri <lzampier@redhat.com>
2024-08-06 14:25:03 +00:00
Lucas Zampieri 811e21caf2 Merge: spi: fix null pointer dereference within spi_sync
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4649

JIRA: https://issues.redhat.com/browse/RHEL-39777
CVE: CVE-2024-36930

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>

Approved-by: Brian Masney <bmasney@redhat.com>
Approved-by: Eric Chanudet <echanude@redhat.com>
Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com>

Merged-by: Lucas Zampieri <lzampier@redhat.com>
2024-07-16 19:46:41 +00:00
Lucas Zampieri a5ce8459b7 Merge: spi: Fix null dereference on suspend
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4651

JIRA: https://issues.redhat.com/browse/RHEL-38218
CVE: CVE-2023-52749

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>

Approved-by: Brian Masney <bmasney@redhat.com>
Approved-by: Eric Chanudet <echanude@redhat.com>
Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com>

Merged-by: Lucas Zampieri <lzampier@redhat.com>
2024-07-16 19:45:53 +00:00
Jaroslav Kysela 3414f5b2e8 spi: tegra114: Remove unnecessary NULL-pointer checks
JIRA: https://issues.redhat.com/browse/RHEL-27515

commit 373c36bf7914e3198ac2654dede499f340c52950
Author: Alexander Danilenko <al.b.danilenko@gmail.com>
Date: Tue Aug 15 12:20:58 2023 +0300

    spi: tegra114: Remove unnecessary NULL-pointer checks

    cs_setup, cs_hold and cs_inactive points to fields of spi_device struct,
    so there is no sense in checking them for NULL.

    Found by Linux Verification Center (linuxtesting.org) with SVACE.

    Fixes: 04e6bb0d6bb1 ("spi: modify set_cs_timing parameter")
    Signed-off-by: Alexander Danilenko <al.b.danilenko@gmail.com>
    Link: https://lore.kernel.org/r/20230815092058.4083-1-al.b.danilenko@gmail.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
2024-07-08 20:53:44 +02:00
Jaroslav Kysela 44b0fced74 spi: Add APIs in spi core to set/get spi->chip_select and spi->cs_gpiod
JIRA: https://issues.redhat.com/browse/RHEL-27515

Omitted-fix: 4ae08845db4c1f759b8382bc7527ab8249230e7f
	     mfd: tps6594: Use spi_get_chipselect() API to access spi->chip_select

commit 303feb3cc06ac0665d0ee9c1414941200e60e8a3
Author: Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com>
Date: Fri Jan 20 00:23:30 2023 +0530

    spi: Add APIs in spi core to set/get spi->chip_select and spi->cs_gpiod

    Supporting multi-cs in spi core and spi controller drivers would require
    the chip_select & cs_gpiod members of struct spi_device to be an array.
    But changing the type of these members to array would break the spi driver
    functionality. To make the transition smoother introduced four new APIs to
    get/set the spi->chip_select & spi->cs_gpiod and replaced all
    spi->chip_select and spi->cs_gpiod references in spi core with the API
    calls.
    While adding multi-cs support in further patches the chip_select & cs_gpiod
    members of the spi_device structure would be converted to arrays & the
    "idx" parameter of the APIs would be used as array index i.e.,
    spi->chip_select[idx] & spi->cs_gpiod[idx] respectively.

    Suggested-by: Lars-Peter Clausen <lars@metafoo.de>
    Signed-off-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com>
    Reviewed-by: Michal Simek <michal.simek@amd.com>
    Link: https://lore.kernel.org/r/20230119185342.2093323-2-amit.kumar-mahapatra@amd.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
2024-07-08 20:53:44 +02:00
Jaroslav Kysela 035e9abef2 spi: Reintroduce spi_set_cs_timing()
JIRA: https://issues.redhat.com/browse/RHEL-27515

Omitted-fix: f6c911f3308c1cfb97ae1da6654080d7104e2df2
             spi: dt-bindings: Introduce spi-cs-setup-ns property
             not used in RHEL
Omitted-fix: 33a2fde5f77bd744b8bd0c694bc173cc968e55a5
             spi: Introduce spi-cs-setup-ns property
             not used in RHEL
Omitted-fix: f732646d0ccd22f42ed7de5e59c0abb7a848e034
             spi: atmel-quadspi: Add support for configuring CS timing
             not used in RHEL

commit 684a47847ae639689e7b823251975348a8e5434f
Author: Tudor Ambarus <tudor.ambarus@microchip.com>
Date: Thu Nov 17 12:52:44 2022 +0200

    spi: Reintroduce spi_set_cs_timing()

    commit 4ccf359849 ("spi: remove spi_set_cs_timing()"), removed the
    method as noboby used it. Nobody used it probably because some SPI
    controllers use some default large cs-setup time that covers the usual
    cs-setup time required by the spi devices. There are though SPI controllers
    that have a smaller granularity for the cs-setup time and their default
    value can't fulfill the spi device requirements. That's the case for the
    at91 QSPI IPs where the default cs-setup time is half of the QSPI clock
    period. This was observed when using an sst26vf064b SPI NOR flash which
    needs a spi-cs-setup-ns = <7>; in order to be operated close to its maximum
    104 MHz frequency.

    Call spi_set_cs_timing() in spi_setup() just before calling spi_set_cs(),
    as the latter needs the CS timings already set.
    If spi->controller->set_cs_timing is not set, the method will return 0.
    There's no functional impact expected for the existing drivers. Even if the
    spi-mt65xx.c and spi-tegra114.c drivers set the set_cs_timing method,
    there's no user for them as of now. The only tested user of this support
    will be a SPI NOR flash that comunicates with the Atmel QSPI controller for
    which the support follows in the next patches.

    One will notice that this support is a bit different from the one that was
    removed in commit 4ccf359849 ("spi: remove spi_set_cs_timing()"),
    because this patch adapts to the changes done after the removal: the move
    of the cs delays to the spi device, the retirement of the lelgacy GPIO
    handling. The mutex handling was removed from spi_set_cs_timing() because
    we now always call spi_set_cs_timing() in spi_setup(), which already
    handles the spi->controller->io_mutex, so use the mutex handling from
    spi_setup().

    Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
    Link: https://lore.kernel.org/r/20221117105249.115649-4-tudor.ambarus@microchip.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
2024-07-08 20:53:43 +02:00
Jaroslav Kysela e0c6022ad3 spi: mediatek: support tick_delay without enhance_timing
JIRA: https://issues.redhat.com/browse/RHEL-27515

Omitted-fix: da40a352db2bae470a3eea038cc53454c24e67f3
	     spi: Add compatible for MT7986
Omitted-fix: 7e963fb2a33ce488e65258ab5be38a4855923033
	     spi: mediatek: add ipm design support for MT7986

commit 03b1be379dcee2e9c866c2a455a1a4a9581b3efd
Author: Leilk Liu <leilk.liu@mediatek.com>
Date: Tue Mar 15 11:24:06 2022 +0800

    spi: mediatek: support tick_delay without enhance_timing

    this patch support tick_delay bit[31:30] without enhance_timing feature.

    Fixes: f84d866ab43f("spi: mediatek: add tick_delay support")
    Signed-off-by: Leilk Liu <leilk.liu@mediatek.com>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Link: https://lore.kernel.org/r/20220315032411.2826-2-leilk.liu@mediatek.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
2024-07-08 20:53:43 +02:00
Jaroslav Kysela f10238ec58 spi: modify set_cs_timing parameter
JIRA: https://issues.redhat.com/browse/RHEL-27515

Omitted-fix: 3672bb820f3292b6f035469f863c020317a3dd28
	     spi: mediatek: skip delays if they are 0

commit 04e6bb0d6bb127bac929fb35edd2dd01613c9520
Author: Mason Zhang <Mason.Zhang@mediatek.com>
Date: Wed Aug 4 21:37:47 2021 +0800

    spi: modify set_cs_timing parameter

    This patch modified set_cs_timing parameter, no need pass in spi_delay
    to set_cs_timing callback.
    By the way, we modified the mediatek and tegra114 spi driver to fix build err.
    In mediatek spi driver, We have support set absolute time not clk_count,
    and call this function in prepare_message not user's API.

    Signed-off-by: Mason Zhang <Mason.Zhang@mediatek.com>
    Link: https://lore.kernel.org/r/20210804133746.6742-1-Mason.Zhang@mediatek.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
2024-07-08 20:53:43 +02:00
Jaroslav Kysela 56687194e7 spi: mediatek: add tick_delay support
JIRA: https://issues.redhat.com/browse/RHEL-27515

Omitted-fix: 03b1be379dcee2e9c866c2a455a1a4a9581b3efd
	     spi: mediatek: support tick_delay without enhance_timing

commit f84d866ab43fcc27b417c86357d6534f157a3d89
Author: Mason Zhang <Mason.Zhang@mediatek.com>
Date: Tue Jul 13 19:40:49 2021 +0800

    spi: mediatek: add tick_delay support

    This patch support tick_delay setting, some users need use
    high-speed spi speed, which can use tick_delay to tuning spi clk timing.

    Signed-off-by: Mason Zhang <Mason.Zhang@mediatek.com>
    Link: https://lore.kernel.org/r/20210713114048.29509-1-mason.zhang@mediatek.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
2024-07-08 20:53:43 +02:00
Andrew Halaney dc14f5bee2 spi: fsl-lpspi: use 'time_left' variable with wait_for_completion_timeout()
JIRA: https://issues.redhat.com/browse/RHEL-33234

commit eef51e99f7b9ecc903a3a9ad9e7ca84dc35c3f52
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>
Date:   Tue Apr 30 13:41:34 2024 +0200

    spi: fsl-lpspi: use 'time_left' variable with wait_for_completion_timeout()

    There is a confusing pattern in the kernel to use a variable named 'timeout' to
    store the result of wait_for_completion_timeout() causing patterns like:

            timeout = wait_for_completion_timeout(...)
            if (!timeout) return -ETIMEDOUT;

    with all kinds of permutations. Use 'time_left' as a variable to make the code
    self explaining.

    Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Link: https://lore.kernel.org/r/20240430114142.28551-3-wsa+renesas@sang-engineering.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-07-05 08:50:54 -05:00
Andrew Halaney 77868f0184 spi: spi-fsl-lpspi: remove redundant spi_controller_put call
JIRA: https://issues.redhat.com/browse/RHEL-33234

commit bff892acf79cec531da6cb21c50980a584ce1476
Author: Carlos Song <carlos.song@nxp.com>
Date:   Wed Apr 3 16:40:29 2024 +0800

    spi: spi-fsl-lpspi: remove redundant spi_controller_put call

    devm_spi_alloc_controller will allocate an SPI controller and
    automatically release a reference on it when dev is unbound from
    its driver. It doesn't need to call spi_controller_put explicitly
    to put the reference when lpspi driver failed initialization.

    Fixes: 2ae0ab0143fc ("spi: lpspi: Avoid potential use-after-free in probe()")
    Signed-off-by: Carlos Song <carlos.song@nxp.com>
    Reviewed-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
    Link: https://msgid.link/r/20240403084029.2000544-1-carlos.song@nxp.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-07-05 08:50:54 -05:00
Andrew Halaney 042f6c4c40 spi: lpspi: Avoid potential use-after-free in probe()
JIRA: https://issues.redhat.com/browse/RHEL-33234
CVE: CVE-2024-26866

commit 2ae0ab0143fcc06190713ed81a6486ed0ad3c861
Author: Alexander Sverdlin <alexander.sverdlin@siemens.com>
Date:   Tue Mar 12 12:20:48 2024 +0100

    spi: lpspi: Avoid potential use-after-free in probe()

    fsl_lpspi_probe() is allocating/disposing memory manually with
    spi_alloc_host()/spi_alloc_target(), but uses
    devm_spi_register_controller(). In case of error after the latter call the
    memory will be explicitly freed in the probe function by
    spi_controller_put() call, but used afterwards by "devm" management outside
    probe() (spi_unregister_controller() <- devm_spi_unregister() below).

    Unable to handle kernel NULL pointer dereference at virtual address 0000000000000070
    ...
    Call trace:
     kernfs_find_ns
     kernfs_find_and_get_ns
     sysfs_remove_group
     sysfs_remove_groups
     device_remove_attrs
     device_del
     spi_unregister_controller
     devm_spi_unregister
     release_nodes
     devres_release_all
     really_probe
     driver_probe_device
     __device_attach_driver
     bus_for_each_drv
     __device_attach
     device_initial_probe
     bus_probe_device
     deferred_probe_work_func
     process_one_work
     worker_thread
     kthread
     ret_from_fork

    Fixes: 5314987de5 ("spi: imx: add lpspi bus driver")
    Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
    Link: https://msgid.link/r/20240312112050.2503643-1-alexander.sverdlin@siemens.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-07-05 08:50:54 -05:00
Andrew Halaney cc5e3da1f8 spi: fsl-lpspi: switch to use modern name
JIRA: https://issues.redhat.com/browse/RHEL-33234

commit 2e2af40b57ad4464eb6c3bffa1fd500551a32c4a
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Mon Aug 7 20:40:53 2023 +0800

    spi: fsl-lpspi: switch to use modern name

    Change legacy name master/target to modern name host/target

    No functional changed.

    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Link: https://lore.kernel.org/r/20230807124105.3429709-9-yangyingliang@huawei.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-07-05 08:50:54 -05:00
Andrew Halaney cd4324e1d7 spi: spi-fsl-lpspi: Read chip-select amount from hardware for i.MX93
JIRA: https://issues.redhat.com/browse/RHEL-33234

commit f46b06e62c86a688ebe691b004f3056818c8ed15
Author: Alexander Stein <alexander.stein@ew.tq-group.com>
Date:   Mon Jul 17 10:59:34 2023 +0200

    spi: spi-fsl-lpspi: Read chip-select amount from hardware for i.MX93

    PARAM.PCSNUM register on i.MX93 indicates the number of supported
    (hw) chip-selects. LPSPI4 has 3 while others have only 2.
    Still allow overwriting from DT.

    Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
    Link: https://lore.kernel.org/r/20230717085934.409476-3-alexander.stein@ew.tq-group.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-07-05 08:50:54 -05:00
Andrew Halaney f31d0cc6f1 spi: spi-fsl-lpspi: Move controller initialization further down
JIRA: https://issues.redhat.com/browse/RHEL-33234
Conflicts: Due to missing SPI wide
           90366cd60133a ("spi: Get rid of old SPI_MASTER_MUST_TX & SPI_MASTER_MUST_RX")
           the older names are still used, and show as a conflict in the
           removed code. The newly added code use the newer names, in
           effect partially applying the above commit for this driver

commit dfc07ee62c03eaaaf806fccc50bd52fcbc9f828f
Author: Alexander Stein <alexander.stein@ew.tq-group.com>
Date:   Mon Jul 17 10:59:33 2023 +0200

    spi: spi-fsl-lpspi: Move controller initialization further down

    This is a preparation for reading number of chip-selects from hardware.
    This needs IO resources mapped and peripheral clocking enabled.
    No functional changes intended.

    Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
    Link: https://lore.kernel.org/r/20230717085934.409476-2-alexander.stein@ew.tq-group.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-07-05 08:50:54 -05:00
Andrew Halaney e48b55db41 spi: spi-fsl-lpspi: Remove num_cs from device struct
JIRA: https://issues.redhat.com/browse/RHEL-33234

commit a55265eeedafee12d9743196ce5bb43266509c31
Author: Alexander Stein <alexander.stein@ew.tq-group.com>
Date:   Wed Jul 5 11:01:43 2023 +0200

    spi: spi-fsl-lpspi: Remove num_cs from device struct

    This is only used during probe() call, so there is no need to store it
    longer than that.

    Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
    Link: https://lore.kernel.org/r/20230705090145.1354663-1-alexander.stein@ew.tq-group.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-07-05 08:50:54 -05:00
Andrew Halaney b7180bec19 spi: spi-fsl-lpspi: downgrade log level for pio mode
JIRA: https://issues.redhat.com/browse/RHEL-33234

commit d5786c88cacbb859f465e8e93c26154585c1008d
Author: Alexander Stein <alexander.stein@ew.tq-group.com>
Date:   Wed May 31 09:28:49 2023 +0200

    spi: spi-fsl-lpspi: downgrade log level for pio mode

    Having no DMA is not an error. The simplest reason is not having it
    configured. SPI will still be usable, so raise a warning instead to
    get still some attention.

    Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
    Link: https://lore.kernel.org/r/20230531072850.739021-1-alexander.stein@ew.tq-group.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-07-05 08:50:54 -05:00
Andrew Halaney eb2624ec8b spi: lpspi: disable lpspi module irq in DMA mode
JIRA: https://issues.redhat.com/browse/RHEL-33234

commit 9728fb3ce11729aa8c276825ddf504edeb00611d
Author: Clark Wang <xiaoning.wang@nxp.com>
Date:   Fri May 5 14:35:57 2023 +0800

    spi: lpspi: disable lpspi module irq in DMA mode

    When all bits of IER are set to 0, we still can observe the lpspi irq events
    when using DMA mode to transfer data.

    So disable irq to avoid the too much irq events.

    Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
    Link: https://lore.kernel.org/r/20230505063557.3962220-1-xiaoning.wang@nxp.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-07-05 08:50:54 -05:00
Andrew Halaney b31db7ae5c spi: lpspi: run transfer speed_hz sanity check
JIRA: https://issues.redhat.com/browse/RHEL-33234

commit f571d9132e0657b4aae40a8ffe758224d1f41047
Author: Clark Wang <xiaoning.wang@nxp.com>
Date:   Fri May 5 14:41:59 2023 +0800

    spi: lpspi: run transfer speed_hz sanity check

    Avoid config.speed_hz is 0 when it is a divisor.

    Signed-off-by: Han Xu <han.xu@nxp.com
    Signed-off-by: Clark Wang <xiaoning.wang@nxp.com
    Link: https://lore.kernel.org/r/20230505064159.3964473-1-xiaoning.wang@nxp.com
    Signed-off-by: Mark Brown <broonie@kernel.org

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-07-05 08:50:54 -05:00
Andrew Halaney d9c40d097c spi: fsl-lpspi: Convert to platform remove callback returning void
JIRA: https://issues.redhat.com/browse/RHEL-33234

commit edd49c898751838009940fe38a7ad4c1d23224df
Author: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date:   Fri Mar 3 18:19:40 2023 +0100

    spi: fsl-lpspi: Convert to platform remove callback returning void

    The .remove() callback for a platform driver returns an int which makes
    many driver authors wrongly assume it's possible to do error handling by
    returning an error code. However the value returned is (mostly) ignored
    and this typically results in resource leaks. To improve here there is a
    quest to make the remove callback return void. In the first step of this
    quest all drivers are converted to .remove_new() which already returns
    void.

    Trivially convert this driver from always returning zero in the remove
    callback to the void returning variant.

    Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Link: https://lore.kernel.org/r/20230303172041.2103336-27-u.kleine-koenig@pengutronix.de
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-07-05 08:50:53 -05:00
Andrew Halaney 876cb9d72e spi: spi-fsl-lpspi: support multiple cs for lpspi
JIRA: https://issues.redhat.com/browse/RHEL-33234

commit 5f947746f0089529c85654704643f158b420ff92
Author: Han Xu <han.xu@nxp.com>
Date:   Tue Dec 6 16:54:09 2022 -0600

    spi: spi-fsl-lpspi: support multiple cs for lpspi

    support to get chip select number from DT file.

    Signed-off-by: Han Xu <han.xu@nxp.com>
    Link: https://lore.kernel.org/r/20221206225410.604482-1-han.xu@nxp.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-07-05 08:50:53 -05:00
Andrew Halaney a00a572d5f spi: introduce new helpers with using modern naming
JIRA: https://issues.redhat.com/browse/RHEL-33234

commit b8d3b056a78dcc941fd1a117697ab2b956c2953f
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Tue Oct 11 17:22:04 2022 +0800

    spi: introduce new helpers with using modern naming

    For using modern names host/target to instead of all the legacy names,
    I think it takes 3 steps:
      - step1: introduce new helpers with modern naming.
      - step2: switch to use these new helpers in all drivers.
      - step3: remove all legacy helpers and update all legacy names.

    This patch is for step1, it introduces new helpers with host/target
    naming for drivers using.

    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Link: https://lore.kernel.org/r/20221011092204.950288-1-yangyingliang@huawei.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-07-05 08:50:53 -05:00
Andrew Halaney 1d4e3a6f38 spi: Fix null dereference on suspend
JIRA: https://issues.redhat.com/browse/RHEL-38218
CVE: CVE-2023-52749
Conflicts: Due to missing commit
           82238d2cbd99e ("spi: Rename SPI_MASTER_GPIO_SS to SPI_CONTROLLER_GPIO_SS")
           some context diffs were introduced. That commit touches too
           much of SPI, let's take that as part of a subsystem upgrade
           but not for this one patch.

commit bef4a48f4ef798c4feddf045d49e53c8a97d5e37
Author: Mark Hasemeyer <markhas@chromium.org>
Date:   Tue Nov 7 14:47:43 2023 -0700

    spi: Fix null dereference on suspend

    A race condition exists where a synchronous (noqueue) transfer can be
    active during a system suspend. This can cause a null pointer
    dereference exception to occur when the system resumes.

    Example order of events leading to the exception:
    1. spi_sync() calls __spi_transfer_message_noqueue() which sets
       ctlr->cur_msg
    2. Spi transfer begins via spi_transfer_one_message()
    3. System is suspended interrupting the transfer context
    4. System is resumed
    6. spi_controller_resume() calls spi_start_queue() which resets cur_msg
       to NULL
    7. Spi transfer context resumes and spi_finalize_current_message() is
       called which dereferences cur_msg (which is now NULL)

    Wait for synchronous transfers to complete before suspending by
    acquiring the bus mutex and setting/checking a suspend flag.

    Signed-off-by: Mark Hasemeyer <markhas@chromium.org>
    Link: https://lore.kernel.org/r/20231107144743.v1.1.I7987f05f61901f567f7661763646cb7d7919b528@changeid
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Cc: stable@kernel.org

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-07-03 12:31:25 -05:00
Andrew Halaney 91821f508c spi: fix null pointer dereference within spi_sync
JIRA: https://issues.redhat.com/browse/RHEL-39777
CVE: CVE-2024-36930

commit 4756fa529b2f12b7cb8f21fe229b0f6f47190829
Author: Mans Rullgard <mans@mansr.com>
Date:   Tue Apr 30 19:27:05 2024 +0100

    spi: fix null pointer dereference within spi_sync

    If spi_sync() is called with the non-empty queue and the same spi_message
    is then reused, the complete callback for the message remains set while
    the context is cleared, leading to a null pointer dereference when the
    callback is invoked from spi_finalize_current_message().

    With function inlining disabled, the call stack might look like this:

      _raw_spin_lock_irqsave from complete_with_flags+0x18/0x58
      complete_with_flags from spi_complete+0x8/0xc
      spi_complete from spi_finalize_current_message+0xec/0x184
      spi_finalize_current_message from spi_transfer_one_message+0x2a8/0x474
      spi_transfer_one_message from __spi_pump_transfer_message+0x104/0x230
      __spi_pump_transfer_message from __spi_transfer_message_noqueue+0x30/0xc4
      __spi_transfer_message_noqueue from __spi_sync+0x204/0x248
      __spi_sync from spi_sync+0x24/0x3c
      spi_sync from mcp251xfd_regmap_crc_read+0x124/0x28c [mcp251xfd]
      mcp251xfd_regmap_crc_read [mcp251xfd] from _regmap_raw_read+0xf8/0x154
      _regmap_raw_read from _regmap_bus_read+0x44/0x70
      _regmap_bus_read from _regmap_read+0x60/0xd8
      _regmap_read from regmap_read+0x3c/0x5c
      regmap_read from mcp251xfd_alloc_can_err_skb+0x1c/0x54 [mcp251xfd]
      mcp251xfd_alloc_can_err_skb [mcp251xfd] from mcp251xfd_irq+0x194/0xe70 [mcp251xfd]
      mcp251xfd_irq [mcp251xfd] from irq_thread_fn+0x1c/0x78
      irq_thread_fn from irq_thread+0x118/0x1f4
      irq_thread from kthread+0xd8/0xf4
      kthread from ret_from_fork+0x14/0x28

    Fix this by also setting message->complete to NULL when the transfer is
    complete.

    Fixes: ae7d2346dc89 ("spi: Don't use the message queue if possible in spi_sync")

    Signed-off-by: Mans Rullgard <mans@mansr.com>
    Link: https://lore.kernel.org/r/20240430182705.13019-1-mans@mansr.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-07-03 12:06:12 -05:00
Rupinderjit Singh 2a8898db69 treewide: Fix probing of devices in DT overlays
JIRA: https://issues.redhat.com/browse/RHEL-22420

commit 1a50d9403fb90cbe4dea0ec9fd0351d2ecbd8924
Author: Geert Uytterhoeven <geert+renesas@glider.be>
Date: Thu, 30 Mar 2023 15:26:13 +0200

    When loading a DT overlay that creates a device, the device is not
    probed, unless the DT overlay is unloaded and reloaded again.

    After the recent refactoring to improve fw_devlink, it no longer depends
    on the "compatible" property to identify which device tree nodes will
    become struct devices.   fw_devlink now picks up dangling consumers
    (consumers pointing to descendent device tree nodes of a device that
    aren't converted to child devices) when a device is successfully bound
    to a driver.  See __fw_devlink_pickup_dangling_consumers().

    However, during DT overlay, a device's device tree node can have
    sub-nodes added/removed without unbinding/rebinding the driver.  This
    difference in behavior between the normal device instantiation and
    probing flow vs. the DT overlay flow has a bunch of implications that
    are pointed out elsewhere[1].  One of them is that the fw_devlink logic
    to pick up dangling consumers is never exercised.

    This patch solves the fw_devlink issue by marking all DT nodes added by
    DT overlays with FWNODE_FLAG_NOT_DEVICE (fwnode that won't become
    device), and by clearing the flag when a struct device is actually
    created for the DT node.  This way, fw_devlink knows not to have
    consumers waiting on these newly added DT nodes, and to propagate the
    dependency to an ancestor DT node that has the corresponding struct
    device.

    Based on a patch by Saravana Kannan, which covered only platform and spi
    devices.

    [1] https://lore.kernel.org/r/CAGETcx_bkuFaLCiPrAWCPQz+w79ccDp6=9e881qmK=vx3hBMyg@mail.gmail.com

    Fixes: 4a032827daa89350 ("of: property: Simplify of_link_to_phandle()")
    Link: https://lore.kernel.org/r/CAGETcx_+rhHvaC_HJXGrr5_WAd2+k5f=rWYnkCZ6z5bGX-wj4w@mail.gmail.com
    Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Acked-by: Mark Brown <broonie@kernel.org>
    Acked-by: Wolfram Sang <wsa@kernel.org> # for I2C
    Acked-by: Shawn Guo <shawnguo@kernel.org>
    Acked-by: Saravana Kannan <saravanak@google.com>
    Tested-by: Ivan Bornyakov <i.bornyakov@metrotek.ru>
    Link: https://lore.kernel.org/r/e1fa546682ea4c8474ff997ab6244c5e11b6f8bc.1680182615.git.geert+renesas@glider.be
    Signed-off-by: Rob Herring <robh@kernel.org>

Signed-off-by: Rupinderjit Singh <rusingh@redhat.com>
2024-05-30 04:25:29 -04:00
Andrew Halaney bf192b194e spi: bcm63xx-hsspi: bcmbca: Replace ARCH_BCM_63XX with ARCH_BCMBCA
JIRA: https://issues.redhat.com/browse/RHEL-24205

commit 16f3c221646b39d9ad0a0cef05f14133bdf70165
Author: William Zhang <william.zhang@broadcom.com>
Date:   Wed Jul 6 23:57:58 2022 -0700

    spi: bcm63xx-hsspi: bcmbca: Replace ARCH_BCM_63XX with ARCH_BCMBCA

    Prepare for the BCM63138 ARCH_BCM_63XX migration to ARCH_BCMBCA. Make
    SPI_BCM63XX_HSSPI depending on ARCH_BCMBCA.

    Signed-off-by: William Zhang <william.zhang@broadcom.com>
    Acked-by: Florian Fainelli <f.fainelli@gmail.com>
    Acked-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-05-09 11:25:01 -04:00
Radu Rendec a551db0755 spi: sh-msiof: avoid integer overflow in constants
JIRA: https://issues.redhat.com/browse/RHEL-34056

commit 6500ad28fd5d67d5ca0fee9da73c463090842440
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>
Date:   Tue Jan 30 10:40:53 2024 +0100

    spi: sh-msiof: avoid integer overflow in constants

    cppcheck rightfully warned:

     drivers/spi/spi-sh-msiof.c:792:28: warning: Signed integer overflow for expression '7<<29'. [integerOverflow]
     sh_msiof_write(p, SIFCTR, SIFCTR_TFWM_1 | SIFCTR_RFWM_1);

    Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Link: https://msgid.link/r/20240130094053.10672-1-wsa+renesas@sang-engineering.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Radu Rendec <rrendec@redhat.com>
2024-04-25 12:10:01 -04:00
Radu Rendec a3096254cd spi: sh-msiof: add generic Gen4 binding
JIRA: https://issues.redhat.com/browse/RHEL-34056

commit ea9d001550abaf2f4c75cf4fcd936ea19f932b84
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>
Date:   Wed Aug 24 11:43:25 2022 +0200

    spi: sh-msiof: add generic Gen4 binding

    No further changes in this generation discovered yet.

    Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Link: https://lore.kernel.org/r/20220824094327.33685-3-wsa+renesas@sang-engineering.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Radu Rendec <rrendec@redhat.com>
2024-04-25 12:10:01 -04:00
Radu Rendec b2eef6ab78 spi: sh-msiof: drop unneeded MODULE_ALIAS
JIRA: https://issues.redhat.com/browse/RHEL-34056

commit 3323129a6db96b6878a260601b30651ca40caa54
Author: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Date:   Thu Sep 16 18:44:23 2021 +0200

    spi: sh-msiof: drop unneeded MODULE_ALIAS

    The MODULE_DEVICE_TABLE already creates proper alias for platform
    driver.  Having another MODULE_ALIAS causes the alias to be duplicated.

    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
    Link: https://lore.kernel.org/r/20210916164423.134603-2-krzysztof.kozlowski@canonical.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Radu Rendec <rrendec@redhat.com>
2024-04-25 12:10:01 -04:00
Radu Rendec f4fe43f25b spi: rspi: drop unneeded MODULE_ALIAS
JIRA: https://issues.redhat.com/browse/RHEL-34056

commit 98c29b35a7e3b1ef7e64a8dd05a4383ea2e2ac72
Author: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Date:   Thu Sep 16 18:44:22 2021 +0200

    spi: rspi: drop unneeded MODULE_ALIAS

    The MODULE_DEVICE_TABLE already creates proper alias for platform
    driver.  Having another MODULE_ALIAS causes the alias to be duplicated.

    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
    Link: https://lore.kernel.org/r/20210916164423.134603-1-krzysztof.kozlowski@canonical.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Radu Rendec <rrendec@redhat.com>
2024-04-25 12:10:01 -04:00
Jan Stancek 78042596b6 Merge: iommu: IOMMU and DMA-mapping API Updates for 9.4
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/3180

# Merge Request Required Information

```
Bugzilla: https://bugzilla.redhat.com/2223717
JIRA: https://issues.redhat.com/browse/RHEL-10007
JIRA: https://issues.redhat.com/browse/RHEL-10026
JIRA: https://issues.redhat.com/browse/RHEL-10042
JIRA: https://issues.redhat.com/browse/RHEL-10094
JIRA: https://issues.redhat.com/browse/RHEL-3655
JIRA: https://issues.redhat.com/browse/RHEL-800

Depends: !3244
Depends: !3245

Omitted-fix: c7bd8a1f45ba ("iommu/apple-dart: Handle DMA_FQ domains in attach_dev()")
             - Apple Dart not supported

Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

Testing: A mix of fio jobs, and various stress-ng io stressors (--hdd, --readahead, --aio, --aiol, --seek,
         --sync_file) run with strict and lazy translation modes on amd, intel, and arm systems. pgtbl_v2
         tested on AMD Genoa host

Conflicts: Should be noted in individual commits. In particular one upstream merge in 6.4, 58390c8ce1bd, had a rather
           messy merge conflict resolution set, so a number of commits have those cleanups added in here.
```

## Summary of Changes

```
        Rebase through v6.5 with a good portion of v6.6 as well (minus the
	dynamic swiotlb mempool support, per numa dma cma support, and arm
	+ mm tlb invalidate changes). For iommufd changes there are
	backports of the underlying functionality in iommufd, but I have left
	the vfio commits that will eventually make use of it for Alex.

Highlights
	* AMD GA Log Overflow refactor and PPR Log support
	* AMD v2 page table support
	* AMD v2 5 level guest page table support
	* Various cleanups and fixes
	* Sync ipmmu-vmsa in preparation for Renesas support  (config not enabled)
	* Continuation of swiotlb rework
	* Continuation of the refactor of core iommu code as part of SVA, iommufd, and pasid support work
	* Continuation of the iommufd prep work (config still not enabled)
	* Support for bounce buffer usage with non cache-line aligned kmallocs on arm64
	* Clean up of in-kernel pasid use for vt-d
	* More cleanup of BUG_ON and warning use in vt-d

        This is based on top of MR !2843 and !3158.
```

Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>

## Approved Development Ticket
All submissions to CentOS Stream must reference an approved ticket in [Red Hat Jira](https://issues.redhat.com/). Please follow the CentOS Stream [contribution documentation](https://docs.centos.org/en-US/stream-contrib/quickstart/) for how to file this ticket and have it approved.

Approved-by: John W. Linville <linville@redhat.com>
Approved-by: Tony Camuso <tcamuso@redhat.com>
Approved-by: David Arcari <darcari@redhat.com>
Approved-by: Mika Penttilä <mpenttil@redhat.com>
Approved-by: Chris von Recklinghausen <crecklin@redhat.com>
Approved-by: Eric Auger <eric.auger@redhat.com>
Approved-by: Mark Salter <msalter@redhat.com>
Approved-by: Donald Dutile <ddutile@redhat.com>

Signed-off-by: Jan Stancek <jstancek@redhat.com>
2023-11-19 15:53:34 +01:00
Jan Stancek 151f2a0ce1 Merge: update drivers/base to v6.4
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/2940

JIRA: https://issues.redhat.com/browse/RHEL-1023

Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>

Approved-by: Phil Auld <pauld@redhat.com>
Approved-by: Tony Camuso <tcamuso@redhat.com>
Approved-by: Antoine Tenart <atenart@redhat.com>
Approved-by: Jocelyn Falempe <jfalempe@redhat.com>
Approved-by: Chris von Recklinghausen <crecklin@redhat.com>
Approved-by: Prarit Bhargava <prarit@redhat.com>
Approved-by: John W. Linville <linville@redhat.com>
Approved-by: Vladis Dronov <vdronov@redhat.com>
Approved-by: Donald Dutile <ddutile@redhat.com>
Approved-by: Eric Chanudet <echanude@redhat.com>

Signed-off-by: Jan Stancek <jstancek@redhat.com>
2023-11-19 13:07:01 +01:00
Scott Weaver f4046fbdf9 Merge: soc: qcom: geni-se: Add SPI Peripheral Device mode support for GENI QuPv3
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/3278

## Summary of Changes
Add SPI device mode support for GENI based QuPv3.  Request to update Qualcomm SPI-geni driver for Qualcomm Universal Peripheral (QUP) Serial Peripheral Interface (SPI) V3. This set introduces spi slave related registers and masks

## Approved Development Ticket
JIRA: https://issues.redhat.com/browse/RHEL-14715

Signed-off-by: Shawn Doherty <sdoherty@redhat.com>

Approved-by: Lucas Karpinski <lkarpins@redhat.com>
Approved-by: Radu Rendec <rrendec@redhat.com>

Signed-off-by: Scott Weaver <scweaver@redhat.com>
2023-11-06 14:54:52 -05:00
Mark Langsdorf 094c7e2822 driver core: class: remove module * from class_create()
JIRA: https://issues.redhat.com/browse/RHEL-1023
Conflicts:
	drivers/dax/bus.c - had to remove an argument
by hand
	drivers/char/tpm/tpm-interface.c - minor context
differences

commit 1aaba11da9aa7d7d6b52a74d45b31cac118295a1
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: Fri, 17 Mar 2023 15:16:33 +0000

The module pointer in class_create() never actually did anything, and it
shouldn't have been requred to be set as a parameter even if it did
something.  So just remove it and fix up all callers of the function in
the kernel tree at the same time.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Link: https://lore.kernel.org/r/20230313181843.1207845-4-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2023-11-01 11:12:29 -05:00
Mark Langsdorf 902e0a8272 drivers: remove struct module * setting from struct class
JIRA: https://issues.redhat.com/browse/RHEL-1023
Conflicts:
	drivers/ptp/ptp_ocp.c - struct timecard_class
doesn't exist, so it wasn't possible to remove its
.owner field

commit 10a03c36b7dd7759788ebc613091d313b60f93e0
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: Fri, 17 Mar 2023 15:16:27 +0000

There is no need to manually set the owner of a struct class, as the
registering function does it automatically, so remove all of the
explicit settings from various drivers that did so as it is unneeded.

This allows us to remove this pointer entirely from this structure going
forward.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Link: https://lore.kernel.org/r/20230313181843.1207845-2-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2023-11-01 11:12:29 -05:00
Jerry Snitselaar 95cc71ad83 drivers/spi: use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN
JIRA: https://issues.redhat.com/browse/RHEL-10094
Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

commit 3cbbb41049accbf2f6f6e79f6870f39b116cd585
Author: Catalin Marinas <catalin.marinas@arm.com>
Date:   Mon Jun 12 16:31:52 2023 +0100

    drivers/spi: use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN

    ARCH_DMA_MINALIGN represents the minimum (static) alignment for safe DMA
    operations while ARCH_KMALLOC_MINALIGN is the minimum kmalloc() objects
    alignment.

    Link: https://lkml.kernel.org/r/20230612153201.554742-9-catalin.marinas@arm.com
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
    Acked-by: Mark Brown <broonie@kernel.org>
    Tested-by: Isaac J. Manjarres <isaacmanjarres@google.com>
    Cc: Alasdair Kergon <agk@redhat.com>
    Cc: Ard Biesheuvel <ardb@kernel.org>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Christoph Hellwig <hch@lst.de>
    Cc: Daniel Vetter <daniel@ffwll.ch>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Herbert Xu <herbert@gondor.apana.org.au>
    Cc: Jerry Snitselaar <jsnitsel@redhat.com>
    Cc: Joerg Roedel <joro@8bytes.org>
    Cc: Jonathan Cameron <jic23@kernel.org>
    Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Cc: Lars-Peter Clausen <lars@metafoo.de>
    Cc: Logan Gunthorpe <logang@deltatee.com>
    Cc: Marc Zyngier <maz@kernel.org>
    Cc: Mike Snitzer <snitzer@kernel.org>
    Cc: "Rafael J. Wysocki" <rafael@kernel.org>
    Cc: Robin Murphy <robin.murphy@arm.com>
    Cc: Saravana Kannan <saravanak@google.com>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: Will Deacon <will@kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 3cbbb41049accbf2f6f6e79f6870f39b116cd585)
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
2023-10-27 01:26:58 -07:00
Mika Penttilä 757c07c055 of: Rename of_modalias_node()
JIRA: https://issues.redhat.com/browse/RHEL-1349
Upstream Status: v6.4-rc1

commit 673aa1ed1c9b6710bf24e3f0957d85e2f46c77db
Author:     Miquel Raynal <miquel.raynal@bootlin.com>
AuthorDate: Tue Apr  4 18:21:16 2023 +0100
Commit:     Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CommitDate: Wed Apr  5 19:41:10 2023 +0200

    This helper does not produce a real modalias, but tries to get the
    "product" compatible part of the "vendor,product" compatibles only. It
    is far from creating a purely useful modalias string and does not seem
    to be used like that directly anyway, so let's try to give this helper a
    more meaningful name before moving there a real modalias helper (already
    existing under of/device.c).

    Also update the various documentations to refer to the strings as
    "aliases" rather than "modaliases" which has a real meaning in the Linux
    kernel.

    There is no functional change.

    Cc: Rafael J. Wysocki <rafael@kernel.org>
    Cc: Len Brown <lenb@kernel.org>
    Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
    Cc: Maxime Ripard <mripard@kernel.org>
    Cc: Thomas Zimmermann <tzimmermann@suse.de>
    Cc: Sebastian Reichel <sre@kernel.org>
    Cc: Wolfram Sang <wsa@kernel.org>
    Cc: Mark Brown <broonie@kernel.org>
    Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Reviewed-by: Rob Herring <robh@kernel.org>
    Acked-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
    Acked-by: Sebastian Reichel <sre@kernel.org>
    Link: https://lore.kernel.org/r/20230404172148.82422-9-srinivas.kandagatla@linaro.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Mika Penttilä <mpenttil@redhat.com>
2023-10-26 06:54:59 +03:00
Shawn Doherty 072c635b42 spi: spi-geni-qcom: Add SPI Device mode support for GENI based QuPv3
JIRA: https://issues.redhat.com/browse/RHEL-14715

commit d7f74cc31a89a45d4c7deaa5f759661a07a183d6
Author: Praveen Talari <quic_ptalari@quicinc.com>
Date:   Fri Jul 14 09:52:03 2023 +0530

    spi: spi-geni-qcom: Add SPI Device mode support for GENI based QuPv3

    Currently spi geni driver supports only master mode operation.

    Add spi device mode support to GENI based QuPv3.

    Signed-off-by: Praveen Talari <quic_ptalari@quicinc.com>
    Reviewed-by: Vijaya Krishna Nivarthi <quic_vnivarth@quicinc.com>
    Link: https://lore.kernel.org/r/20230714042203.14251-3-quic_ptalari@quicinc.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Shawn Doherty <sdoherty@redhat.com>
2023-10-25 14:14:57 -04:00
Shawn Doherty 4ecf8088be spi: spi-geni-qcom: enable SPI_CONTROLLER_MUST_TX for GPI DMA mode
JIRA: https://issues.redhat.com/browse/RHEL-14715

commit d10005837be83906bbd2078c3b4f9dfcbd6c95b6
Author: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Date:   Thu Jun 29 12:58:47 2023 +0300

    spi: spi-geni-qcom: enable SPI_CONTROLLER_MUST_TX for GPI DMA mode

    The GPI DMA mode requires for TX DMA to be prepared. Force SPI core to
    provide TX buffer even if the caller didn't provide one by setting the
    SPI_CONTROLLER_MUST_TX flag.

    Fixes: b59c122484ec ("spi: spi-geni-qcom: Add support for GPI dma")
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Link: https://lore.kernel.org/r/20230629095847.3648597-1-dmitry.baryshkov@linaro.org
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Shawn Doherty <sdoherty@redhat.com>
2023-10-25 14:14:53 -04:00
Shawn Doherty 577d99f34a spi: spi-geni-qcom: correctly handle -EPROBE_DEFER from dma_request_chan()
JIRA: https://issues.redhat.com/browse/RHEL-14715

commit 337207408f74a8374beacf232ec1e08742c1d98f
Author: Neil Armstrong <neil.armstrong@linaro.org>
Date:   Thu Jun 15 14:51:45 2023 +0200

    spi: spi-geni-qcom: correctly handle -EPROBE_DEFER from dma_request_chan()

    Now spi_geni_grab_gpi_chan() errors are correctly reported, the
    -EPROBE_DEFER error should be returned from probe in case the
    GPI dma driver is built as module and/or not probed yet.

    Fixes: b59c122484ec ("spi: spi-geni-qcom: Add support for GPI dma")
    Fixes: 6532582c353f ("spi: spi-geni-qcom: fix error handling in spi_geni_grab_gpi_chan()")
    Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
    Link: https://lore.kernel.org/r/20230615-topic-sm8550-upstream-fix-spi-geni-qcom-probe-v2-1-670c3d9e8c9c@linaro.org
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Shawn Doherty <sdoherty@redhat.com>
2023-10-25 14:14:51 -04:00
Mark Langsdorf 0753f4dc47 driver core: make struct bus_type.uevent() take a const *
JIRA: https://issues.redhat.com/browse/RHEL-1023
Conflicts:
	drivers/gpu/drm/drm_mipi_dsi.c - minor context
differences
	drivers/platform/x86/wmi.c - had to insert a const
in device_to_wblock()
	include/linux/hyperv.h - had to insert a const
in device_to_hv_device()
Omitted-fix: a69ea7a76d52353b17d7bedf43818c2578517e9e
	centos-9 doesn't support SuperH devices, so this
fix for the maple sub-componet of a SuperH isn't
necessary

commit 2a81ada32f0e584fc0c943e0d3a8c9f4fae411d6
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: Fri, 27 Jan 2023 13:45:52 +0000

The uevent() callback in struct bus_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.

Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230111113018.459199-16-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2023-10-23 10:35:56 -05:00
Štěpán Horáček 9a867aeb4f spi: tegra210-quad: Enable TPM wait polling
Bugzilla: https://bugzilla.redhat.com/2168368

Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

commit 967ca91a996f82219f2883e9e53d8e20df49025a
Author: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Date:   Fri Apr 21 14:43:09 2023 +0530

    spi: tegra210-quad: Enable TPM wait polling

    Trusted Platform Module requires flow control. As defined in TPM
    interface specification, client would drive MISO line at same cycle as
    last address bit on MOSI.
    Tegra234 and Tegra241 QSPI controllers have TPM wait state detection
    feature which is enabled for TPM client devices reported in SPI device
    mode bits.

    Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
    Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
    Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>
    Link: https://lore.kernel.org/r/20230421091309.2672-4-kyarlagadda@nvidia.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Štěpán Horáček <shoracek@redhat.com>
2023-08-14 11:27:16 +02:00
Štěpán Horáček 5aa0b09cf8 spi: tegra210-quad: Fix iterator outside loop
Bugzilla: https://bugzilla.redhat.com/2168368

Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

commit 2449d436681d40bc63ec2c766fd51b632270d8a7
Author: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Date:   Tue Feb 28 01:34:28 2023 +0530

    spi: tegra210-quad: Fix iterator outside loop

    Fix warn: iterator used outside loop: 'xfer'. 'xfer' variable contain
    invalid value in few conditions. Complete transfer within DATA phase
    in successful case and at the end for failed transfer.

    Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
    Link:https://lore.kernel.org/all/202210191211.46FkzKmv-lkp@intel.com/
    Fixes: 8777dd9dff40 ("spi: tegra210-quad: Fix combined sequence")

    Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
    Link: https://lore.kernel.org/r/20230227200428.45832-1-kyarlagadda@nvidia.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Štěpán Horáček <shoracek@redhat.com>
2023-08-14 11:27:16 +02:00
Štěpán Horáček eeb17cb4d0 spi: tegra210-quad: Fix validate combined sequence
Bugzilla: https://bugzilla.redhat.com/2168368

Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

commit 047ee71ae4f412d8819e39e4b08c588fa299cfc2
Author: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Date:   Fri Feb 24 22:10:34 2023 +0530

    spi: tegra210-quad: Fix validate combined sequence

    Check for non dma transfers that do not fit in FIFO has issue and skips
    combined sequence for Tegra234 & Tegra241 which does not have GPCDMA.

    Fixes: 1b8342cc4a38 ("spi: tegra210-quad: combined sequence mode")

    Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
    Link: https://lore.kernel.org/r/20230224164034.56933-1-kyarlagadda@nvidia.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Štěpán Horáček <shoracek@redhat.com>
2023-08-14 11:27:15 +02:00
Štěpán Horáček 7e9e851c43 spi: tegra210-quad: set half duplex flag
Bugzilla: https://bugzilla.redhat.com/2168368

Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

commit f7482d8285b638be87a594a30edaaf1341135c1a
Author: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Date:   Thu Feb 23 21:56:34 2023 +0530

    spi: tegra210-quad: set half duplex flag

    Tegra QSPI controller only supports half duplex transfers.
    Set half duplex constrain flag.

    Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
    Link: https://lore.kernel.org/r/20230223162635.19747-3-kyarlagadda@nvidia.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Štěpán Horáček <shoracek@redhat.com>
2023-08-14 11:27:15 +02:00
Adrien Thierry d7df574461 spi: spi-geni-qcom: Do not do DMA map/unmap inside driver, use framework instead
JIRA: https://issues.redhat.com/browse/RHEL-625

Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

commit 3a76c7ca9e77269dd10cf21465a055274cfa40c6
Author: Vijaya Krishna Nivarthi <quic_vnivarth@quicinc.com>
Date:   Wed May 17 17:48:14 2023 +0530

    spi: spi-geni-qcom: Do not do DMA map/unmap inside driver, use framework instead

    The spi geni driver in SE DMA mode, unlike GSI DMA, is not making use of
    DMA mapping functionality available in the framework.
    The driver does mapping internally which makes dma buffer fields available
    in spi_transfer struct superfluous while requiring additional members in
    spi_geni_master struct.

    Conform to the design by having framework handle map/unmap and do only
    DMA transfer in the driver; this also simplifies code a bit.

    Fixes: e5f0dfa78ac7 ("spi: spi-geni-qcom: Add support for SE DMA mode")
    Suggested-by: Douglas Anderson <dianders@chromium.org>
    Signed-off-by: Vijaya Krishna Nivarthi <quic_vnivarth@quicinc.com>
    Reviewed-by: Douglas Anderson <dianders@chromium.org>
    Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Link: https://lore.kernel.org/r/1684325894-30252-3-git-send-email-quic_vnivarth@quicinc.com
    Signed-off-by: Mark Brown <broonie@kernel.org>

Signed-off-by: Adrien Thierry <athierry@redhat.com>
2023-06-16 15:33:24 -04:00
Adrien Thierry 16e133a43c spi: spi-geni-qcom: Select FIFO mode for chip select
JIRA: https://issues.redhat.com/browse/RHEL-625

commit 4c329f5da7cfa366bacfda1328a025dd38951317
Author: Vijaya Krishna Nivarthi <quic_vnivarth@quicinc.com>
Date:   Tue May 9 15:31:36 2023 +0530

    spi: spi-geni-qcom: Select FIFO mode for chip select

    Spi geni driver switches between FIFO and DMA modes based on xfer length.
    FIFO mode relies on M_CMD_DONE_EN interrupt for completion while DMA mode
    relies on XX_DMA_DONE.
    During dynamic switching, if FIFO mode is chosen, FIFO related interrupts
    are enabled and DMA related interrupts are disabled. And viceversa.
    Chip select shares M_CMD_DONE_EN interrupt with FIFO to check completion.
    Now, if a chip select operation is preceded by a DMA xfer, M_CMD_DONE_EN
    interrupt would have been disabled and hence it will never receive one
    resulting in timeout.

    For chip select, in addition to setting the xfer mode to FIFO,
    select_mode() to FIFO so that required interrupts are enabled.

    Fixes: e5f0dfa78ac7 ("spi: spi-geni-qcom: Add support for SE DMA mode")
    Suggested-by: Praveen Talari <quic_ptalari@quicinc.com
    Signed-off-by: Vijaya Krishna Nivarthi <quic_vnivarth@quicinc.com
    Reviewed-by: Douglas Anderson <dianders@chromium.org
    Link: https://lore.kernel.org/r/1683626496-9685-1-git-send-email-quic_vnivarth@quicinc.com
    Signed-off-by: Mark Brown <broonie@kernel.org

Signed-off-by: Adrien Thierry <athierry@redhat.com>
2023-06-16 15:33:18 -04:00