Skip to content

Commit 33d0c9c

Browse files
committed
Merge tag 'spi-fix-v7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi fixes from Mark Brown: "There are a couple of nasty issues fixed here in the axiado and rockchip drivers. We've also got more of the fixes from Johan here, this time for the two Cadence drivers, plus a couple of other similar fixes from John and Felix" * tag 'spi-fix-v7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: spi: amlogic-spisg: initialize completion before requesting IRQ spi: axiado: replace usleep_range() with udelay() in IRQ path spi: cadence-quadspi: fix runtime pm and clock imbalance on unbind spi: cadence-quadspi: fix unclocked access on unbind spi: cadence-quadspi: fix clock imbalance on probe failure spi: cadence-quadspi: fix runtime pm disable imbalance on probe failure spi: cadence: fix clock imbalance on probe failure spi: cadence: fix unclocked access on unbind spi: rockchip: Drop unused and broken CR0 macros spi: rockchip: Read ISR, not IMR, to detect cs-inactive IRQ spi: rzv2h-rspi: Fix silent failure in clock setup error path
2 parents d8b0e2e + 8c0f9cd commit 33d0c9c

6 files changed

Lines changed: 36 additions & 28 deletions

File tree

drivers/spi/spi-amlogic-spisg.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ static int aml_spisg_probe(struct platform_device *pdev)
794794

795795
dma_set_max_seg_size(&pdev->dev, SPISG_BLOCK_MAX);
796796

797+
init_completion(&spisg->completion);
797798
ret = devm_request_irq(&pdev->dev, irq, aml_spisg_irq, 0, NULL, spisg);
798799
if (ret) {
799800
dev_err(&pdev->dev, "irq request failed\n");
@@ -806,8 +807,6 @@ static int aml_spisg_probe(struct platform_device *pdev)
806807
goto out_clk;
807808
}
808809

809-
init_completion(&spisg->completion);
810-
811810
pm_runtime_put(&spisg->pdev->dev);
812811

813812
return 0;

drivers/spi/spi-axiado.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static void ax_spi_fill_tx_fifo(struct ax_spi *xspi)
201201
* then spi control did't work thoroughly, add one byte delay
202202
*/
203203
if (ax_spi_read(xspi, AX_SPI_IVR) & AX_SPI_IVR_TFOV)
204-
usleep_range(10, 10);
204+
udelay(10);
205205
if (xspi->tx_buf)
206206
ax_spi_write_b(xspi, AX_SPI_TXFIFO, *xspi->tx_buf++);
207207
else

drivers/spi/spi-cadence-quadspi.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,14 +1860,10 @@ static int cqspi_probe(struct platform_device *pdev)
18601860
if (irq < 0)
18611861
return -ENXIO;
18621862

1863-
ret = pm_runtime_set_active(dev);
1864-
if (ret)
1865-
return ret;
1866-
18671863
ret = clk_bulk_prepare_enable(CLK_QSPI_NUM, cqspi->clks);
18681864
if (ret) {
18691865
dev_err(dev, "Cannot enable QSPI clocks.\n");
1870-
goto disable_rpm;
1866+
return ret;
18711867
}
18721868

18731869
/* Obtain QSPI reset control */
@@ -1962,10 +1958,11 @@ static int cqspi_probe(struct platform_device *pdev)
19621958
cqspi->sclk = 0;
19631959

19641960
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
1965-
pm_runtime_enable(dev);
19661961
pm_runtime_set_autosuspend_delay(dev, CQSPI_AUTOSUSPEND_TIMEOUT);
19671962
pm_runtime_use_autosuspend(dev);
19681963
pm_runtime_get_noresume(dev);
1964+
pm_runtime_set_active(dev);
1965+
pm_runtime_enable(dev);
19691966
}
19701967

19711968
host->num_chipselect = cqspi->num_chipselect;
@@ -1977,7 +1974,7 @@ static int cqspi_probe(struct platform_device *pdev)
19771974
ret = cqspi_request_mmap_dma(cqspi);
19781975
if (ret == -EPROBE_DEFER) {
19791976
dev_err_probe(&pdev->dev, ret, "Failed to request mmap DMA\n");
1980-
goto disable_controller;
1977+
goto disable_rpm;
19811978
}
19821979
}
19831980

@@ -1995,14 +1992,16 @@ static int cqspi_probe(struct platform_device *pdev)
19951992
release_dma_chan:
19961993
if (cqspi->rx_chan)
19971994
dma_release_channel(cqspi->rx_chan);
1998-
disable_controller:
1999-
cqspi_controller_enable(cqspi, 0);
2000-
disable_clks:
2001-
if (pm_runtime_get_sync(&pdev->dev) >= 0)
2002-
clk_bulk_disable_unprepare(CLK_QSPI_NUM, cqspi->clks);
20031995
disable_rpm:
2004-
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM)))
1996+
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
20051997
pm_runtime_disable(dev);
1998+
pm_runtime_set_suspended(dev);
1999+
pm_runtime_put_noidle(dev);
2000+
pm_runtime_dont_use_autosuspend(dev);
2001+
}
2002+
cqspi_controller_enable(cqspi, 0);
2003+
disable_clks:
2004+
clk_bulk_disable_unprepare(CLK_QSPI_NUM, cqspi->clks);
20062005

20072006
return ret;
20082007
}
@@ -2026,18 +2025,19 @@ static void cqspi_remove(struct platform_device *pdev)
20262025
if (cqspi->rx_chan)
20272026
dma_release_channel(cqspi->rx_chan);
20282027

2029-
cqspi_controller_enable(cqspi, 0);
2030-
2031-
20322028
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM)))
20332029
ret = pm_runtime_get_sync(&pdev->dev);
20342030

2035-
if (ret >= 0)
2031+
if (ret >= 0) {
2032+
cqspi_controller_enable(cqspi, 0);
20362033
clk_bulk_disable_unprepare(CLK_QSPI_NUM, cqspi->clks);
2034+
}
20372035

20382036
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
2039-
pm_runtime_put_sync(&pdev->dev);
20402037
pm_runtime_disable(&pdev->dev);
2038+
pm_runtime_set_suspended(&pdev->dev);
2039+
pm_runtime_put_noidle(&pdev->dev);
2040+
pm_runtime_dont_use_autosuspend(&pdev->dev);
20412041
}
20422042
}
20432043

drivers/spi/spi-cadence.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,6 @@ static int cdns_spi_probe(struct platform_device *pdev)
741741
/* Set to default valid value */
742742
ctlr->max_speed_hz = xspi->clk_rate / 4;
743743
xspi->speed_hz = ctlr->max_speed_hz;
744-
pm_runtime_put_autosuspend(&pdev->dev);
745744
} else {
746745
ctlr->mode_bits |= SPI_NO_CS;
747746
ctlr->target_abort = cdns_target_abort;
@@ -752,12 +751,17 @@ static int cdns_spi_probe(struct platform_device *pdev)
752751
goto clk_dis_all;
753752
}
754753

754+
if (!spi_controller_is_target(ctlr))
755+
pm_runtime_put_autosuspend(&pdev->dev);
756+
755757
return ret;
756758

757759
clk_dis_all:
758760
if (!spi_controller_is_target(ctlr)) {
759761
pm_runtime_disable(&pdev->dev);
760762
pm_runtime_set_suspended(&pdev->dev);
763+
pm_runtime_put_noidle(&pdev->dev);
764+
pm_runtime_dont_use_autosuspend(&pdev->dev);
761765
}
762766
remove_ctlr:
763767
spi_controller_put(ctlr);
@@ -776,16 +780,23 @@ static void cdns_spi_remove(struct platform_device *pdev)
776780
{
777781
struct spi_controller *ctlr = platform_get_drvdata(pdev);
778782
struct cdns_spi *xspi = spi_controller_get_devdata(ctlr);
783+
int ret = 0;
784+
785+
if (!spi_controller_is_target(ctlr))
786+
ret = pm_runtime_get_sync(&pdev->dev);
779787

780788
spi_controller_get(ctlr);
781789

782790
spi_unregister_controller(ctlr);
783791

784-
cdns_spi_write(xspi, CDNS_SPI_ER, CDNS_SPI_ER_DISABLE);
792+
if (ret >= 0)
793+
cdns_spi_write(xspi, CDNS_SPI_ER, CDNS_SPI_ER_DISABLE);
785794

786795
if (!spi_controller_is_target(ctlr)) {
787796
pm_runtime_disable(&pdev->dev);
788797
pm_runtime_set_suspended(&pdev->dev);
798+
pm_runtime_put_noidle(&pdev->dev);
799+
pm_runtime_dont_use_autosuspend(&pdev->dev);
789800
}
790801

791802
spi_controller_put(ctlr);

drivers/spi/spi-rockchip.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@
9898
#define CR0_FRF_MICROWIRE 0x2
9999

100100
#define CR0_XFM_OFFSET 18
101-
#define CR0_XFM_MASK (0x03 << SPI_XFM_OFFSET)
102101
#define CR0_XFM_TR 0x0
103102
#define CR0_XFM_TO 0x1
104103
#define CR0_XFM_RO 0x2
@@ -109,8 +108,6 @@
109108

110109
#define CR0_SOI_OFFSET 23
111110

112-
#define CR0_MTM_OFFSET 0x21
113-
114111
/* Bit fields in SER, 2bit */
115112
#define SER_MASK 0x3
116113

@@ -357,7 +354,8 @@ static irqreturn_t rockchip_spi_isr(int irq, void *dev_id)
357354
struct rockchip_spi *rs = spi_controller_get_devdata(ctlr);
358355

359356
/* When int_cs_inactive comes, spi target abort */
360-
if (rs->cs_inactive && readl_relaxed(rs->regs + ROCKCHIP_SPI_IMR) & INT_CS_INACTIVE) {
357+
if (rs->cs_inactive &&
358+
(readl_relaxed(rs->regs + ROCKCHIP_SPI_ISR) & INT_CS_INACTIVE)) {
361359
ctlr->target_abort(ctlr);
362360
writel_relaxed(0, rs->regs + ROCKCHIP_SPI_IMR);
363361
writel_relaxed(0xffffffff, rs->regs + ROCKCHIP_SPI_ICR);

drivers/spi/spi-rzv2h-rspi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ static u32 rzv2h_rspi_setup_clock(struct rzv2h_rspi_priv *rspi, u32 hz)
579579
rspi->info->find_pclk_rate(rspi->pclk, hz, &best_clock);
580580

581581
if (!best_clock.clk_rate)
582-
return -EINVAL;
582+
return 0;
583583

584584
ret = clk_set_rate(best_clock.clk, best_clock.clk_rate);
585585
if (ret)

0 commit comments

Comments
 (0)