Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'spi-fix-v5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi

Pull spi fixes from Mark Brown:
"A few small fixes for v5.16, one in the core for an issue with
handling of controller unregistration that was introduced with the
fixes for registering nested SPI controllers and a few more minor
device specific ones"

* tag 'spi-fix-v5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
spi: fix use-after-free of the add_lock mutex
spi: spi-geni-qcom: fix error handling in spi_geni_grab_gpi_chan()
spi: lpspi: Silence error message upon deferred probe
spi: cadence-quadspi: fix write completion support

+39 -17
+21 -3
drivers/spi/spi-cadence-quadspi.c
··· 37 37 #define CQSPI_NEEDS_WR_DELAY BIT(0) 38 38 #define CQSPI_DISABLE_DAC_MODE BIT(1) 39 39 #define CQSPI_SUPPORT_EXTERNAL_DMA BIT(2) 40 + #define CQSPI_NO_SUPPORT_WR_COMPLETION BIT(3) 40 41 41 42 /* Capabilities */ 42 43 #define CQSPI_SUPPORTS_OCTAL BIT(0) ··· 87 86 struct cqspi_flash_pdata f_pdata[CQSPI_MAX_CHIPSELECT]; 88 87 bool use_dma_read; 89 88 u32 pd_dev_id; 89 + bool wr_completion; 90 90 }; 91 91 92 92 struct cqspi_driver_platdata { ··· 998 996 * polling on the controller's side. spinand and spi-nor will take 999 997 * care of polling the status register. 1000 998 */ 1001 - reg = readl(reg_base + CQSPI_REG_WR_COMPLETION_CTRL); 1002 - reg |= CQSPI_REG_WR_DISABLE_AUTO_POLL; 1003 - writel(reg, reg_base + CQSPI_REG_WR_COMPLETION_CTRL); 999 + if (cqspi->wr_completion) { 1000 + reg = readl(reg_base + CQSPI_REG_WR_COMPLETION_CTRL); 1001 + reg |= CQSPI_REG_WR_DISABLE_AUTO_POLL; 1002 + writel(reg, reg_base + CQSPI_REG_WR_COMPLETION_CTRL); 1003 + } 1004 1004 1005 1005 reg = readl(reg_base + CQSPI_REG_SIZE); 1006 1006 reg &= ~CQSPI_REG_SIZE_ADDRESS_MASK; ··· 1740 1736 1741 1737 cqspi->master_ref_clk_hz = clk_get_rate(cqspi->clk); 1742 1738 master->max_speed_hz = cqspi->master_ref_clk_hz; 1739 + 1740 + /* write completion is supported by default */ 1741 + cqspi->wr_completion = true; 1742 + 1743 1743 ddata = of_device_get_match_data(dev); 1744 1744 if (ddata) { 1745 1745 if (ddata->quirks & CQSPI_NEEDS_WR_DELAY) ··· 1755 1747 cqspi->use_direct_mode = true; 1756 1748 if (ddata->quirks & CQSPI_SUPPORT_EXTERNAL_DMA) 1757 1749 cqspi->use_dma_read = true; 1750 + if (ddata->quirks & CQSPI_NO_SUPPORT_WR_COMPLETION) 1751 + cqspi->wr_completion = false; 1758 1752 1759 1753 if (of_device_is_compatible(pdev->dev.of_node, 1760 1754 "xlnx,versal-ospi-1.0")) ··· 1869 1859 .quirks = CQSPI_DISABLE_DAC_MODE, 1870 1860 }; 1871 1861 1862 + static const struct cqspi_driver_platdata socfpga_qspi = { 1863 + .quirks = CQSPI_NO_SUPPORT_WR_COMPLETION, 1864 + }; 1865 + 1872 1866 static const struct cqspi_driver_platdata versal_ospi = { 1873 1867 .hwcaps_mask = CQSPI_SUPPORTS_OCTAL, 1874 1868 .quirks = CQSPI_DISABLE_DAC_MODE | CQSPI_SUPPORT_EXTERNAL_DMA, ··· 1900 1886 { 1901 1887 .compatible = "xlnx,versal-ospi-1.0", 1902 1888 .data = (void *)&versal_ospi, 1889 + }, 1890 + { 1891 + .compatible = "intel,socfpga-qspi", 1892 + .data = (void *)&socfpga_qspi, 1903 1893 }, 1904 1894 { /* end of table */ } 1905 1895 };
+1 -1
drivers/spi/spi-fsl-lpspi.c
··· 912 912 913 913 ret = devm_spi_register_controller(&pdev->dev, controller); 914 914 if (ret < 0) { 915 - dev_err(&pdev->dev, "spi_register_controller error.\n"); 915 + dev_err_probe(&pdev->dev, ret, "spi_register_controller error: %i\n", ret); 916 916 goto out_pm_get; 917 917 } 918 918
+11 -7
drivers/spi/spi-geni-qcom.c
··· 491 491 int ret; 492 492 493 493 mas->tx = dma_request_chan(mas->dev, "tx"); 494 - ret = dev_err_probe(mas->dev, IS_ERR(mas->tx), "Failed to get tx DMA ch\n"); 495 - if (ret < 0) 494 + if (IS_ERR(mas->tx)) { 495 + ret = dev_err_probe(mas->dev, PTR_ERR(mas->tx), 496 + "Failed to get tx DMA ch\n"); 496 497 goto err_tx; 498 + } 497 499 498 500 mas->rx = dma_request_chan(mas->dev, "rx"); 499 - ret = dev_err_probe(mas->dev, IS_ERR(mas->rx), "Failed to get rx DMA ch\n"); 500 - if (ret < 0) 501 + if (IS_ERR(mas->rx)) { 502 + ret = dev_err_probe(mas->dev, PTR_ERR(mas->rx), 503 + "Failed to get rx DMA ch\n"); 501 504 goto err_rx; 505 + } 502 506 503 507 return 0; 504 508 505 509 err_rx: 506 - dma_release_channel(mas->tx); 507 - mas->tx = NULL; 508 - err_tx: 509 510 mas->rx = NULL; 511 + dma_release_channel(mas->tx); 512 + err_tx: 513 + mas->tx = NULL; 510 514 return ret; 511 515 } 512 516
+6 -6
drivers/spi/spi.c
··· 3099 3099 3100 3100 device_del(&ctlr->dev); 3101 3101 3102 - /* Release the last reference on the controller if its driver 3103 - * has not yet been converted to devm_spi_alloc_master/slave(). 3104 - */ 3105 - if (!ctlr->devm_allocated) 3106 - put_device(&ctlr->dev); 3107 - 3108 3102 /* free bus id */ 3109 3103 mutex_lock(&board_lock); 3110 3104 if (found == ctlr) ··· 3107 3113 3108 3114 if (IS_ENABLED(CONFIG_SPI_DYNAMIC)) 3109 3115 mutex_unlock(&ctlr->add_lock); 3116 + 3117 + /* Release the last reference on the controller if its driver 3118 + * has not yet been converted to devm_spi_alloc_master/slave(). 3119 + */ 3120 + if (!ctlr->devm_allocated) 3121 + put_device(&ctlr->dev); 3110 3122 } 3111 3123 EXPORT_SYMBOL_GPL(spi_unregister_controller); 3112 3124