mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 05:32:00 +00:00
spi: Fixes for v6.7
A couple of fixes that came in during the merge window, one Kconfig dependency fix and another fix for a long standing issue where in the case where a sync transfer races with system suspend. -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmVONkAACgkQJNaLcl1U h9CjXAf+INeTPAMe6N9eR4IQ8Q+92h2ST1P8YlZ7Mr8BUgEieXVrnlk9CCtUqymy JBG3NmHnoQEnDfQ6AXB5dW9ALtOOwxI4PbCIRaaQ1pV5Xu6LBE/HKIvYdSUOevvx LTXeUKt60TD+75AoKYx59Eu3SVQVQr+RoK6GFxZOPh0ixgpIBq9sZ03bXBQFyXCA xvvTjqc/olMK8V35ZUjmERR+/0qi7dv9gLCuPXDcMzyaAMZRcX5IfD4WUhfmIEdD diqiYEebV3EQ0Qzl72C3gYuANVUJ3mRNpDoa2ITRtpspCk0G2ghe8nuRVCZQ/Qyq C2F8n2p9UKDMPhay6vbK6LVr/1Fi1A== =p/JY -----END PGP SIGNATURE----- Merge tag 'spi-fix-v6.7-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi Pull spi fixes from Mark Brown: "A couple of fixes that came in during the merge window: one Kconfig dependency fix and another fix for a long standing issue where a sync transfer races with system suspend" * tag 'spi-fix-v6.7-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: spi: Fix null dereference on suspend spi: spi-zynq-qspi: add spi-mem to driver kconfig dependencies
This commit is contained in:
commit
ae4f52a729
@ -1169,6 +1169,7 @@ config SPI_XTENSA_XTFPGA
|
|||||||
config SPI_ZYNQ_QSPI
|
config SPI_ZYNQ_QSPI
|
||||||
tristate "Xilinx Zynq QSPI controller"
|
tristate "Xilinx Zynq QSPI controller"
|
||||||
depends on ARCH_ZYNQ || COMPILE_TEST
|
depends on ARCH_ZYNQ || COMPILE_TEST
|
||||||
|
depends on SPI_MEM
|
||||||
help
|
help
|
||||||
This enables support for the Zynq Quad SPI controller
|
This enables support for the Zynq Quad SPI controller
|
||||||
in master mode.
|
in master mode.
|
||||||
|
@ -3317,33 +3317,52 @@ void spi_unregister_controller(struct spi_controller *ctlr)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(spi_unregister_controller);
|
EXPORT_SYMBOL_GPL(spi_unregister_controller);
|
||||||
|
|
||||||
|
static inline int __spi_check_suspended(const struct spi_controller *ctlr)
|
||||||
|
{
|
||||||
|
return ctlr->flags & SPI_CONTROLLER_SUSPENDED ? -ESHUTDOWN : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void __spi_mark_suspended(struct spi_controller *ctlr)
|
||||||
|
{
|
||||||
|
mutex_lock(&ctlr->bus_lock_mutex);
|
||||||
|
ctlr->flags |= SPI_CONTROLLER_SUSPENDED;
|
||||||
|
mutex_unlock(&ctlr->bus_lock_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void __spi_mark_resumed(struct spi_controller *ctlr)
|
||||||
|
{
|
||||||
|
mutex_lock(&ctlr->bus_lock_mutex);
|
||||||
|
ctlr->flags &= ~SPI_CONTROLLER_SUSPENDED;
|
||||||
|
mutex_unlock(&ctlr->bus_lock_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
int spi_controller_suspend(struct spi_controller *ctlr)
|
int spi_controller_suspend(struct spi_controller *ctlr)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret = 0;
|
||||||
|
|
||||||
/* Basically no-ops for non-queued controllers */
|
/* Basically no-ops for non-queued controllers */
|
||||||
if (!ctlr->queued)
|
if (ctlr->queued) {
|
||||||
return 0;
|
ret = spi_stop_queue(ctlr);
|
||||||
|
if (ret)
|
||||||
ret = spi_stop_queue(ctlr);
|
dev_err(&ctlr->dev, "queue stop failed\n");
|
||||||
if (ret)
|
}
|
||||||
dev_err(&ctlr->dev, "queue stop failed\n");
|
|
||||||
|
|
||||||
|
__spi_mark_suspended(ctlr);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(spi_controller_suspend);
|
EXPORT_SYMBOL_GPL(spi_controller_suspend);
|
||||||
|
|
||||||
int spi_controller_resume(struct spi_controller *ctlr)
|
int spi_controller_resume(struct spi_controller *ctlr)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret = 0;
|
||||||
|
|
||||||
if (!ctlr->queued)
|
__spi_mark_resumed(ctlr);
|
||||||
return 0;
|
|
||||||
|
|
||||||
ret = spi_start_queue(ctlr);
|
|
||||||
if (ret)
|
|
||||||
dev_err(&ctlr->dev, "queue restart failed\n");
|
|
||||||
|
|
||||||
|
if (ctlr->queued) {
|
||||||
|
ret = spi_start_queue(ctlr);
|
||||||
|
if (ret)
|
||||||
|
dev_err(&ctlr->dev, "queue restart failed\n");
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(spi_controller_resume);
|
EXPORT_SYMBOL_GPL(spi_controller_resume);
|
||||||
@ -4147,8 +4166,7 @@ static void __spi_transfer_message_noqueue(struct spi_controller *ctlr, struct s
|
|||||||
ctlr->cur_msg = msg;
|
ctlr->cur_msg = msg;
|
||||||
ret = __spi_pump_transfer_message(ctlr, msg, was_busy);
|
ret = __spi_pump_transfer_message(ctlr, msg, was_busy);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
dev_err(&ctlr->dev, "noqueue transfer failed\n");
|
||||||
|
|
||||||
ctlr->cur_msg = NULL;
|
ctlr->cur_msg = NULL;
|
||||||
ctlr->fallback = false;
|
ctlr->fallback = false;
|
||||||
|
|
||||||
@ -4164,7 +4182,6 @@ static void __spi_transfer_message_noqueue(struct spi_controller *ctlr, struct s
|
|||||||
spi_idle_runtime_pm(ctlr);
|
spi_idle_runtime_pm(ctlr);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
|
||||||
mutex_unlock(&ctlr->io_mutex);
|
mutex_unlock(&ctlr->io_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4187,6 +4204,11 @@ static int __spi_sync(struct spi_device *spi, struct spi_message *message)
|
|||||||
int status;
|
int status;
|
||||||
struct spi_controller *ctlr = spi->controller;
|
struct spi_controller *ctlr = spi->controller;
|
||||||
|
|
||||||
|
if (__spi_check_suspended(ctlr)) {
|
||||||
|
dev_warn_once(&spi->dev, "Attempted to sync while suspend\n");
|
||||||
|
return -ESHUTDOWN;
|
||||||
|
}
|
||||||
|
|
||||||
status = __spi_validate(spi, message);
|
status = __spi_validate(spi, message);
|
||||||
if (status != 0)
|
if (status != 0)
|
||||||
return status;
|
return status;
|
||||||
|
@ -566,6 +566,7 @@ struct spi_controller {
|
|||||||
#define SPI_CONTROLLER_MUST_RX BIT(3) /* Requires rx */
|
#define SPI_CONTROLLER_MUST_RX BIT(3) /* Requires rx */
|
||||||
#define SPI_CONTROLLER_MUST_TX BIT(4) /* Requires tx */
|
#define SPI_CONTROLLER_MUST_TX BIT(4) /* Requires tx */
|
||||||
#define SPI_CONTROLLER_GPIO_SS BIT(5) /* GPIO CS must select slave */
|
#define SPI_CONTROLLER_GPIO_SS BIT(5) /* GPIO CS must select slave */
|
||||||
|
#define SPI_CONTROLLER_SUSPENDED BIT(6) /* Currently suspended */
|
||||||
|
|
||||||
/* Flag indicating if the allocation of this struct is devres-managed */
|
/* Flag indicating if the allocation of this struct is devres-managed */
|
||||||
bool devm_allocated;
|
bool devm_allocated;
|
||||||
|
Loading…
Reference in New Issue
Block a user