Compare

70db8dea2aac43dd4f9a7ec2365d8c950efaa07d..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

Browse files
6 files changed, +27 −102
modified drivers/gpu/drm/i915/display/intel_cx0_phy.c
@@ -2342,14 +2342,12 @@ static void intel_c10pll_dump_hw_state(struct drm_printer *p,
2342 2342 static bool is_arrowlake_s_by_host_bridge(void)
2343 2343 {
2344 2344 struct pci_dev *pdev = NULL;
2345 - while ((pdev = pci_get_class(PCI_CLASS_BRIDGE_HOST << 8, pdev))) {
2346 - if (IS_ARROWLAKE_S_BY_HOST_BRIDGE_ID(pdev->device)) {
2347 - pci_dev_put(pdev);
2348 - return true;
2349 - }
2350 - }
2345 + u16 host_bridge_pci_dev_id;
2351 2346
2352 - return false;
2347 + while ((pdev = pci_get_class(PCI_CLASS_BRIDGE_HOST << 8, pdev)))
2348 + host_bridge_pci_dev_id = pdev->device;
2349 +
2350 + return pdev && IS_ARROWLAKE_S_BY_HOST_BRIDGE_ID(host_bridge_pci_dev_id);
2353 2351 }
2354 2352
2355 2353 static u16 intel_c20_hdmi_tmds_tx_cgf_1(struct intel_display *display)
modified drivers/gpu/drm/i915/display/intel_dmc.c
@@ -1023,55 +1023,6 @@ static void dmc_set_fw_offset(struct intel_dmc *dmc,
1023 1023 }
1024 1024 }
1025 1025
1026 - /*
1027 - * Check if the load address is within the valid range for the given DMC ID.
1028 - */
1029 - static bool dmc_load_addr_sanity_check(struct intel_dmc *dmc,
1030 - u32 start_addr, u32 payload_size,
1031 - int header_ver, enum intel_dmc_id dmc_id)
1032 - {
1033 - u32 start_range, end_range, end_addr;
1034 -
1035 - if (header_ver != 3)
1036 - return true;
1037 -
1038 - switch (dmc_id) {
1039 - case DMC_FW_MAIN:
1040 - start_range = DMC_MAIN_PROGRAM_BASE_START;
1041 - end_range = DMC_MAIN_PROGRAM_BASE_END;
1042 - break;
1043 - case DMC_FW_PIPEA:
1044 - start_range = DMC_PIPEA_PROGRAM_BASE_START;
1045 - end_range = DMC_PIPEA_PROGRAM_BASE_END;
1046 - break;
1047 - case DMC_FW_PIPEB:
1048 - start_range = DMC_PIPEB_PROGRAM_BASE_START;
1049 - end_range = DMC_PIPEB_PROGRAM_BASE_END;
1050 - break;
1051 - case DMC_FW_PIPEC:
1052 - start_range = DMC_PIPEC_PROGRAM_BASE_START;
1053 - end_range = DMC_PIPEC_PROGRAM_BASE_END;
1054 - break;
1055 - case DMC_FW_PIPED:
1056 - start_range = DMC_PIPED_PROGRAM_BASE_START;
1057 - end_range = DMC_PIPED_PROGRAM_BASE_END;
1058 - break;
1059 - default:
1060 - MISSING_CASE(dmc_id);
1061 - return false;
1062 - }
1063 -
1064 - if (payload_size == 0)
1065 - end_addr = start_addr;
1066 - else if (check_add_overflow(start_addr, payload_size - 1, &end_addr))
1067 - return false;
1068 -
1069 - if (start_addr < start_range || end_addr > end_range)
1070 - return false;
1071 -
1072 - return true;
1073 - }
1074 -
1075 1026 static bool dmc_mmio_addr_sanity_check(struct intel_dmc *dmc,
1076 1027 const u32 *mmioaddr, u32 mmio_count,
1077 1028 int header_ver, enum intel_dmc_id dmc_id)
@@ -1169,7 +1120,7 @@ static u32 parse_dmc_fw_header(struct intel_dmc *dmc,
1169 1120 }
1170 1121
1171 1122 /* Cache the dmc header info. */
1172 - if (!mmio_count || mmio_count > mmio_count_max) {
1123 + if (mmio_count > mmio_count_max) {
1173 1124 drm_err(display->drm, "DMC firmware has wrong mmio count %u\n", mmio_count);
1174 1125 return 0;
1175 1126 }
@@ -1215,21 +1166,13 @@ static u32 parse_dmc_fw_header(struct intel_dmc *dmc,
1215 1166 disable_dmc_evt(display, dmc_id, dmc_info->mmioaddr[i],
1216 1167 dmc_info->mmiodata[i]) ? " (disabling)" : "");
1217 1168 }
1169 + dmc_info->mmio_count = mmio_count;
1170 + dmc_info->start_mmioaddr = start_mmioaddr;
1218 1171
1219 1172 rem_size -= header_len_bytes;
1220 1173
1221 1174 /* fw_size is in dwords, so multiplied by 4 to convert into bytes. */
1222 - if (check_mul_overflow(dmc_header->fw_size, 4u, &payload_size)) {
1223 - drm_err(display->drm, "DMC fw_size too large (%u dwords)\n",
1224 - dmc_header->fw_size);
1225 - return 0;
1226 - }
1227 -
1228 - if (!payload_size) {
1229 - drm_err(display->drm, "DMC firmware has empty payload\n");
1230 - return 0;
1231 - }
1232 -
1175 + payload_size = dmc_header->fw_size * 4;
1233 1176 if (rem_size < payload_size)
1234 1177 goto error_truncated;
1235 1178
@@ -1237,21 +1180,12 @@ static u32 parse_dmc_fw_header(struct intel_dmc *dmc,
1237 1180 drm_err(display->drm, "DMC FW too big (%u bytes)\n", payload_size);
1238 1181 return 0;
1239 1182 }
1240 -
1241 - if (!dmc_load_addr_sanity_check(dmc, start_mmioaddr, payload_size,
1242 - dmc_header->header_ver, dmc_id)) {
1243 - drm_err(display->drm, "DMC %d: firmware has wrong load address\n", dmc_id);
1244 - return 0;
1245 - }
1183 + dmc_info->dmc_fw_size = dmc_header->fw_size;
1246 1184
1247 1185 dmc_info->payload = kmalloc(payload_size, GFP_KERNEL);
1248 1186 if (!dmc_info->payload)
1249 1187 return 0;
1250 1188
1251 - dmc_info->mmio_count = mmio_count;
1252 - dmc_info->start_mmioaddr = start_mmioaddr;
1253 - dmc_info->dmc_fw_size = dmc_header->fw_size;
1254 -
1255 1189 payload = (u8 *)(dmc_header) + header_len_bytes;
1256 1190 memcpy(dmc_info->payload, payload, payload_size);
1257 1191
modified drivers/gpu/drm/i915/display/intel_dmc_regs.h
@@ -521,18 +521,6 @@ enum pipedmc_event_id {
521 521 #define TGL_PIPE_MMIO_END(dmc_id) _PICK_EVEN(((dmc_id) - 1), _TGL_PIPEA_MMIO_END,\
522 522 _TGL_PIPEB_MMIO_END)
523 523
524 - /* For DMC header version v3*/
525 - #define DMC_MAIN_PROGRAM_BASE_START 0x80000
526 - #define DMC_MAIN_PROGRAM_BASE_END 0x86fff
527 - #define DMC_PIPEA_PROGRAM_BASE_START 0x90000
528 - #define DMC_PIPEA_PROGRAM_BASE_END 0x96fff
529 - #define DMC_PIPEB_PROGRAM_BASE_START 0x98000
530 - #define DMC_PIPEB_PROGRAM_BASE_END 0x9efff
531 - #define DMC_PIPEC_PROGRAM_BASE_START 0x52000
532 - #define DMC_PIPEC_PROGRAM_BASE_END 0x53fff
533 - #define DMC_PIPED_PROGRAM_BASE_START 0x59000
534 - #define DMC_PIPED_PROGRAM_BASE_END 0x5afff
535 -
536 524 #define SKL_DMC_DC3_DC5_COUNT _MMIO(0x80030)
537 525 #define SKL_DMC_DC5_DC6_COUNT _MMIO(0x8002C)
538 526 #define BXT_DMC_DC3_DC5_COUNT _MMIO(0x80038)
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