Compare
a2eae9f4fa1b07f8e6e61b48931228da051943f0..4eac392e48fc0ddc6d5ac10d57aac7245c17d0d9
spi: spi-fsl-lpspi: pass struct fsl_lpspi_data instead of struct spi_controller if possible
Instead of passing a spi_controller pointer to functions and using spi_controller_get_devdata() to get the struct fsl_lpspi_data pointer, directly pass a struct fsl_lpspi_data pointer. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://patch.msgid.link/20261009-spi-fsl-lpspi-more-cleanups-v1-1-2d4549d5205e@pengutronix.de Signed-off-by: Mark Brown <broonie@kernel.org>
Marc Kleine-Budde <mkl@pengutronix.de> · 2026-10-09 10:16 UTC · committed by Mark Brown
6 files changed,
+21
−72
- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
- drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c
- drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c
- drivers/spi/spi-fsl-lpspi.c
- drivers/spi/spi-imx.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/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c
| @@ -89,7 +89,6 @@ static const struct smu_feature_bits smu_v14_0_2_dpm_features = { | |||
| 89 | 89 | #define PP_OD_FEATURE_FAN_TARGET_TEMPERATURE 9 | |
| 90 | 90 | #define PP_OD_FEATURE_FAN_MINIMUM_PWM 10 | |
| 91 | 91 | #define PP_OD_FEATURE_FAN_ZERO_RPM_ENABLE 11 | |
| 92 | - | #define PP_OD_FEATURE_FAN_ZERO_RPM_STOP_TEMP 12 | |
| 93 | 92 | ||
| 94 | 93 | static struct cmn2asic_msg_mapping smu_v14_0_2_message_map[SMU_MSG_MAX_COUNT] = { | |
| 95 | 94 | MSG_MAP(TestMessage, PPSMC_MSG_TestMessage, 1), | |
| @@ -1021,10 +1020,6 @@ static void smu_v14_0_2_get_od_setting_limits(struct smu_context *smu, | |||
| 1021 | 1020 | od_min_setting = overdrive_lowerlimits->FanZeroRpmEnable; | |
| 1022 | 1021 | od_max_setting = overdrive_upperlimits->FanZeroRpmEnable; | |
| 1023 | 1022 | break; | |
| 1024 | - | case PP_OD_FEATURE_FAN_ZERO_RPM_STOP_TEMP: | |
| 1025 | - | od_min_setting = pptable->SkuTable.MsgLimits.FanStopTempMin; | |
| 1026 | - | od_max_setting = pptable->SkuTable.MsgLimits.FanStopTempMax; | |
| 1027 | - | break; | |
| 1028 | 1023 | default: | |
| 1029 | 1024 | od_min_setting = od_max_setting = INT_MAX; | |
| 1030 | 1025 | break; | |
| @@ -1249,24 +1244,6 @@ static int smu_v14_0_2_emit_clk_levels(struct smu_context *smu, | |||
| 1249 | 1244 | min_value, max_value); | |
| 1250 | 1245 | break; | |
| 1251 | 1246 | ||
| 1252 | - | case SMU_OD_FAN_ZERO_RPM_STOP_TEMP: | |
| 1253 | - | if (!smu_v14_0_2_is_od_feature_supported(smu, | |
| 1254 | - | PP_OD_FEATURE_ZERO_FAN_BIT)) | |
| 1255 | - | break; | |
| 1256 | - | ||
| 1257 | - | size += sysfs_emit_at(buf, size, "FAN_ZERO_RPM_STOP_TEMPERATURE:\n"); | |
| 1258 | - | size += sysfs_emit_at(buf, size, "%d\n", | |
| 1259 | - | (int)od_table->OverDriveTable.FanZeroRpmStopTemp); | |
| 1260 | - | ||
| 1261 | - | size += sysfs_emit_at(buf, size, "%s:\n", "OD_RANGE"); | |
| 1262 | - | smu_v14_0_2_get_od_setting_limits(smu, | |
| 1263 | - | PP_OD_FEATURE_FAN_ZERO_RPM_STOP_TEMP, | |
| 1264 | - | &min_value, | |
| 1265 | - | &max_value); | |
| 1266 | - | size += sysfs_emit_at(buf, size, "ZERO_RPM_STOP_TEMPERATURE: %u %u\n", | |
| 1267 | - | min_value, max_value); | |
| 1268 | - | break; | |
| 1269 | - | ||
| 1270 | 1247 | case SMU_OD_RANGE: | |
| 1271 | 1248 | if (!smu_v14_0_2_is_od_feature_supported(smu, PP_OD_FEATURE_GFXCLK_BIT) && | |
| 1272 | 1249 | !smu_v14_0_2_is_od_feature_supported(smu, PP_OD_FEATURE_UCLK_BIT) && | |
| @@ -2334,9 +2311,7 @@ static void smu_v14_0_2_set_supported_od_feature_mask(struct smu_context *smu) | |||
| 2334 | 2311 | OD_OPS_SUPPORT_FAN_MINIMUM_PWM_RETRIEVE | | |
| 2335 | 2312 | OD_OPS_SUPPORT_FAN_MINIMUM_PWM_SET | | |
| 2336 | 2313 | OD_OPS_SUPPORT_FAN_ZERO_RPM_ENABLE_RETRIEVE | | |
| 2337 | - | OD_OPS_SUPPORT_FAN_ZERO_RPM_ENABLE_SET | | |
| 2338 | - | OD_OPS_SUPPORT_FAN_ZERO_RPM_STOP_TEMP_RETRIEVE | | |
| 2339 | - | OD_OPS_SUPPORT_FAN_ZERO_RPM_STOP_TEMP_SET; | |
| 2314 | + | OD_OPS_SUPPORT_FAN_ZERO_RPM_ENABLE_SET; | |
| 2340 | 2315 | } | |
| 2341 | 2316 | ||
| 2342 | 2317 | static int smu_v14_0_2_get_overdrive_table(struct smu_context *smu, | |
| @@ -2417,8 +2392,6 @@ static int smu_v14_0_2_set_default_od_settings(struct smu_context *smu) | |||
| 2417 | 2392 | user_od_table_bak.OverDriveTable.FanMinimumPwm; | |
| 2418 | 2393 | user_od_table->OverDriveTable.FanZeroRpmEnable = | |
| 2419 | 2394 | user_od_table_bak.OverDriveTable.FanZeroRpmEnable; | |
| 2420 | - | user_od_table->OverDriveTable.FanZeroRpmStopTemp = | |
| 2421 | - | user_od_table_bak.OverDriveTable.FanZeroRpmStopTemp; | |
| 2422 | 2395 | } | |
| 2423 | 2396 | ||
| 2424 | 2397 | smu_v14_0_2_set_supported_od_feature_mask(smu); | |
| @@ -2473,11 +2446,6 @@ static int smu_v14_0_2_od_restore_table_single(struct smu_context *smu, long inp | |||
| 2473 | 2446 | boot_overdrive_table->OverDriveTable.FanZeroRpmEnable; | |
| 2474 | 2447 | od_table->OverDriveTable.FeatureCtrlMask |= BIT(PP_OD_FEATURE_ZERO_FAN_BIT); | |
| 2475 | 2448 | break; | |
| 2476 | - | case PP_OD_EDIT_FAN_ZERO_RPM_STOP_TEMP: | |
| 2477 | - | od_table->OverDriveTable.FanZeroRpmStopTemp = | |
| 2478 | - | boot_overdrive_table->OverDriveTable.FanZeroRpmStopTemp; | |
| 2479 | - | od_table->OverDriveTable.FeatureCtrlMask |= BIT(PP_OD_FEATURE_ZERO_FAN_BIT); | |
| 2480 | - | break; | |
| 2481 | 2449 | case PP_OD_EDIT_ACOUSTIC_LIMIT: | |
| 2482 | 2450 | od_table->OverDriveTable.AcousticLimitRpmThreshold = | |
| 2483 | 2451 | boot_overdrive_table->OverDriveTable.AcousticLimitRpmThreshold; | |
| @@ -2784,27 +2752,6 @@ static int smu_v14_0_2_od_edit_dpm_table(struct smu_context *smu, | |||
| 2784 | 2752 | od_table->OverDriveTable.FeatureCtrlMask |= BIT(PP_OD_FEATURE_ZERO_FAN_BIT); | |
| 2785 | 2753 | break; | |
| 2786 | 2754 | ||
| 2787 | - | case PP_OD_EDIT_FAN_ZERO_RPM_STOP_TEMP: | |
| 2788 | - | if (!smu_v14_0_2_is_od_feature_supported(smu, PP_OD_FEATURE_ZERO_FAN_BIT)) { | |
| 2789 | - | dev_warn(adev->dev, "Zero RPM setting not supported!\n"); | |
| 2790 | - | return -ENOTSUPP; | |
| 2791 | - | } | |
| 2792 | - | ||
| 2793 | - | smu_v14_0_2_get_od_setting_limits(smu, | |
| 2794 | - | PP_OD_FEATURE_FAN_ZERO_RPM_STOP_TEMP, | |
| 2795 | - | &minimum, | |
| 2796 | - | &maximum); | |
| 2797 | - | if (input[0] < minimum || | |
| 2798 | - | input[0] > maximum) { | |
| 2799 | - | dev_info(adev->dev, "zero RPM stop temperature setting(%ld) must be within [%d, %d]!\n", | |
| 2800 | - | input[0], minimum, maximum); | |
| 2801 | - | return -EINVAL; | |
| 2802 | - | } | |
| 2803 | - | ||
| 2804 | - | od_table->OverDriveTable.FanZeroRpmStopTemp = input[0]; | |
| 2805 | - | od_table->OverDriveTable.FeatureCtrlMask |= BIT(PP_OD_FEATURE_ZERO_FAN_BIT); | |
| 2806 | - | break; | |
| 2807 | - | ||
| 2808 | 2755 | case PP_OD_RESTORE_DEFAULT_TABLE: | |
| 2809 | 2756 | if (size == 1) { | |
| 2810 | 2757 | ret = smu_v14_0_2_od_restore_table_single(smu, input[0]); | |
modified drivers/spi/spi-fsl-lpspi.c
| @@ -550,11 +550,8 @@ static int fsl_lpspi_target_abort(struct spi_controller *controller) | |||
| 550 | 550 | return 0; | |
| 551 | 551 | } | |
| 552 | 552 | ||
| 553 | - | static int fsl_lpspi_wait_for_completion(struct spi_controller *controller) | |
| 553 | + | static int fsl_lpspi_wait_for_completion(struct fsl_lpspi_data *fsl_lpspi) | |
| 554 | 554 | { | |
| 555 | - | struct fsl_lpspi_data *fsl_lpspi = | |
| 556 | - | spi_controller_get_devdata(controller); | |
| 557 | - | ||
| 558 | 555 | if (fsl_lpspi->is_target) { | |
| 559 | 556 | if (wait_for_completion_interruptible(&fsl_lpspi->xfer_done) || | |
| 560 | 557 | fsl_lpspi->target_aborted) { | |
| @@ -758,11 +755,9 @@ err: | |||
| 758 | 755 | return ret; | |
| 759 | 756 | } | |
| 760 | 757 | ||
| 761 | - | static int fsl_lpspi_pio_transfer(struct spi_controller *controller, | |
| 758 | + | static int fsl_lpspi_pio_transfer(struct fsl_lpspi_data *fsl_lpspi, | |
| 762 | 759 | struct spi_transfer *t) | |
| 763 | 760 | { | |
| 764 | - | struct fsl_lpspi_data *fsl_lpspi = | |
| 765 | - | spi_controller_get_devdata(controller); | |
| 766 | 761 | int ret; | |
| 767 | 762 | ||
| 768 | 763 | fsl_lpspi->tx_buf = t->tx_buf; | |
| @@ -774,7 +769,7 @@ static int fsl_lpspi_pio_transfer(struct spi_controller *controller, | |||
| 774 | 769 | ||
| 775 | 770 | fsl_lpspi_write_tx_fifo(fsl_lpspi); | |
| 776 | 771 | ||
| 777 | - | ret = fsl_lpspi_wait_for_completion(controller); | |
| 772 | + | ret = fsl_lpspi_wait_for_completion(fsl_lpspi); | |
| 778 | 773 | ||
| 779 | 774 | fsl_lpspi_reset(fsl_lpspi); | |
| 780 | 775 | ||
| @@ -803,7 +798,7 @@ static int fsl_lpspi_transfer_one(struct spi_controller *controller, | |||
| 803 | 798 | if (fsl_lpspi->usedma) | |
| 804 | 799 | ret = fsl_lpspi_dma_transfer(controller, fsl_lpspi, t); | |
| 805 | 800 | else | |
| 806 | - | ret = fsl_lpspi_pio_transfer(controller, t); | |
| 801 | + | ret = fsl_lpspi_pio_transfer(fsl_lpspi, t); | |
| 807 | 802 | if (ret < 0) | |
| 808 | 803 | return ret; | |
| 809 | 804 | ||
modified drivers/spi/spi-imx.c
| @@ -1578,11 +1578,13 @@ static int spi_imx_dma_tx_data_handle(struct spi_imx_data *spi_imx, | |||
| 1578 | 1578 | dma_data->dma_len = ALIGN(dma_data->data_len, BYTES_PER_32BITS_WORD); | |
| 1579 | 1579 | } | |
| 1580 | 1580 | ||
| 1581 | - | dma_data->dma_tx_buf = kzalloc(dma_data->dma_len, GFP_KERNEL); | |
| 1581 | + | dma_data->dma_tx_buf = kzalloc(DMA_CACHE_ALIGNED_LEN(dma_data->dma_len), | |
| 1582 | + | GFP_KERNEL); | |
| 1582 | 1583 | if (!dma_data->dma_tx_buf) | |
| 1583 | 1584 | return -ENOMEM; | |
| 1584 | 1585 | ||
| 1585 | - | dma_data->dma_rx_buf = kzalloc(dma_data->dma_len, GFP_KERNEL); | |
| 1586 | + | dma_data->dma_rx_buf = kzalloc(DMA_CACHE_ALIGNED_LEN(dma_data->dma_len), | |
| 1587 | + | GFP_KERNEL); | |
| 1586 | 1588 | if (!dma_data->dma_rx_buf) { | |
| 1587 | 1589 | kfree(dma_data->dma_tx_buf); | |
| 1588 | 1590 | return -ENOMEM; | |
| @@ -1920,7 +1922,8 @@ static int spi_imx_dma_package_transfer(struct spi_imx_data *spi_imx, | |||
| 1920 | 1922 | ||
| 1921 | 1923 | /* Trim the DMA RX buffer and copy the actual data to rx_buf */ | |
| 1922 | 1924 | dma_sync_single_for_cpu(controller->dma_rx->device->dev, dma_data->dma_rx_addr, | |
| 1923 | - | dma_data->dma_len, DMA_FROM_DEVICE); | |
| 1925 | + | DMA_CACHE_ALIGNED_LEN(dma_data->dma_len), | |
| 1926 | + | DMA_FROM_DEVICE); | |
| 1924 | 1927 | spi_imx_dma_rx_data_handle(spi_imx, dma_data, transfer->rx_buf + spi_imx->rx_offset, | |
| 1925 | 1928 | word_delay); | |
| 1926 | 1929 | spi_imx->rx_offset += dma_data->data_len; | |
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 | ||