Compare
5b0a459f990be2faba33229fd93f10f23745fab2..8980bc573ae2d2b9d86d76aeb86c76e1597070bf
spi: tegra114: assert CS GPIO for every transfer in a message
The driver provides its own transfer_one_message() and therefore drives
the chip-select GPIO itself rather than through the SPI core. The GPIO is
asserted only in the is_first_of_msg path of
tegra_spi_setup_transfer_one(), but tegra_spi_transfer_end() deasserts it
whenever a transfer has cs_change set. For a multi-transfer message whose
earlier transfers request cs_change -- for example a register read that
sends the address in one transfer and clocks the data back in the next --
the CS GPIO is released after the first transfer and never re-asserted,
so the remaining transfers are clocked with chip-select inactive and the
peripheral never drives the bus.
This was observed with an ADIS16470 IMU (adis16475 driver), whose
register read is a two-transfer, cs_change-framed exchange: a logic
analyzer showed the data frame clocked with CS high, and the driver read
0 while the device drove 0x4056 on the wire.
Re-assert the CS GPIO for every transfer so that multi-transfer messages
keep chip-select active across the whole message. gpiod_set_value() is
idempotent and polarity-aware, so this is a no-op for the first transfer
and for messages that keep CS asserted throughout.
Fixes: 63c1440596ff ("spi: tegra114: add support for gpio based CS")
Signed-off-by: Carlos Jones Jr <carlosjr.jones@analog.com>
Link: https://patch.msgid.link/20261002085540.1625-1-carlosjr.jones@analog.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Carlos Jones Jr <carlosjr.jones@analog.com> · 2026-10-02 08:55 UTC · committed by Mark Brown
3 files changed,
+10
−6
- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
- drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c
- drivers/spi/spi-tegra114.c
modified drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
| @@ -2065,15 +2065,14 @@ static int amdgpu_ttm_buffer_entity_init(struct amdgpu_gtt_mgr *mgr, | |||
| 2065 | 2065 | int i, r, num_pages; | |
| 2066 | 2066 | const u64 GTT_MAX_PAGES = (AMDGPU_GTT_MAX_TRANSFER_SIZE >> PAGE_SHIFT); | |
| 2067 | 2067 | ||
| 2068 | - | if (ARRAY_SIZE(entity->gart_window_offs) < num_gart_windows) | |
| 2069 | - | return -EINVAL; | |
| 2070 | - | ||
| 2071 | 2068 | r = drm_sched_entity_init(&entity->base, prio, scheds, num_schedulers, NULL); | |
| 2072 | 2069 | if (r) | |
| 2073 | 2070 | return r; | |
| 2074 | 2071 | ||
| 2075 | 2072 | mutex_init(&entity->lock); | |
| 2076 | 2073 | ||
| 2074 | + | if (ARRAY_SIZE(entity->gart_window_offs) < num_gart_windows) | |
| 2075 | + | return -EINVAL; | |
| 2077 | 2076 | if (num_gart_windows == 0) | |
| 2078 | 2077 | return 0; | |
| 2079 | 2078 | ||
| @@ -2081,7 +2080,6 @@ static int amdgpu_ttm_buffer_entity_init(struct amdgpu_gtt_mgr *mgr, | |||
| 2081 | 2080 | r = amdgpu_gtt_mgr_alloc_entries(mgr, &entity->gart_node, num_pages, | |
| 2082 | 2081 | DRM_MM_INSERT_BEST); | |
| 2083 | 2082 | if (r) { | |
| 2084 | - | mutex_destroy(&entity->lock); | |
| 2085 | 2083 | drm_sched_entity_destroy(&entity->base); | |
| 2086 | 2084 | return r; | |
| 2087 | 2085 | } | |
| @@ -2099,7 +2097,6 @@ static void amdgpu_ttm_buffer_entity_fini(struct amdgpu_gtt_mgr *mgr, | |||
| 2099 | 2097 | struct amdgpu_ttm_buffer_entity *entity) | |
| 2100 | 2098 | { | |
| 2101 | 2099 | amdgpu_gtt_mgr_free_entries(mgr, &entity->gart_node); | |
| 2102 | - | mutex_destroy(&entity->lock); | |
| 2103 | 2100 | drm_sched_entity_destroy(&entity->base); | |
| 2104 | 2101 | } | |
| 2105 | 2102 | ||
modified drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c
| @@ -288,7 +288,7 @@ static int uvd_v3_1_fw_validate(struct amdgpu_device *adev) | |||
| 288 | 288 | int i; | |
| 289 | 289 | uint32_t keysel = adev->uvd.keyselect; | |
| 290 | 290 | ||
| 291 | - | if (RREG32(mmUVD_FW_START)) { | |
| 291 | + | if (RREG32(mmUVD_FW_START) & UVD_FW_STATUS__PASS_MASK) { | |
| 292 | 292 | dev_dbg(adev->dev, "UVD keyselect already set: 0x%x (on CPU: 0x%x)\n", | |
| 293 | 293 | RREG32(mmUVD_FW_START), adev->uvd.keyselect); | |
| 294 | 294 | return 0; | |
modified drivers/spi/spi-tegra114.c
| @@ -859,6 +859,13 @@ static u32 tegra_spi_setup_transfer_one(struct spi_device *spi, | |||
| 859 | 859 | command1 |= SPI_BIT_LENGTH(bits_per_word - 1); | |
| 860 | 860 | } | |
| 861 | 861 | ||
| 862 | + | /* | |
| 863 | + | * Re-assert the CS GPIO for every transfer: transfer_end() drops it | |
| 864 | + | * on cs_change, and the assert above only covers is_first_of_msg. | |
| 865 | + | */ | |
| 866 | + | if (spi_get_csgpiod(spi, 0)) | |
| 867 | + | gpiod_set_value(spi_get_csgpiod(spi, 0), 1); | |
| 868 | + | ||
| 862 | 869 | return command1; | |
| 863 | 870 | } | |
| 864 | 871 | ||