spi_qmsi_ss: add device_busy_set() to avoid re-enter deep sleep

When CONFIG_SYS_POWER_DEEP_SLEEP is enabled, spi_qmsi_ss will
keep entering deep sleep because it needs to wait until the
current transfer completes, which blocks the current thread.
The system keeps entering deep sleep again and again and the
transfer will never complete.

Add device_busy_set() to spi_qmsi_ss driver to indicate that
the device is busy and block the system from entering deep
sleep during transaction.

Jira: ZEP-1488

Change-Id: I5a4456933249def93eaa529b30b99d730af74482
Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
This commit is contained in:
Qiu Peiyang 2016-12-20 09:04:24 +08:00 committed by Anas Nashif
commit b549e0fbca

View file

@ -169,6 +169,8 @@ static int ss_spi_qmsi_transceive(struct device *dev,
pending_transfers[spi_id].dev = dev; pending_transfers[spi_id].dev = dev;
k_sem_give(&context->sem); k_sem_give(&context->sem);
device_busy_set(dev);
xfer = &pending_transfers[spi_id].xfer; xfer = &pending_transfers[spi_id].xfer;
xfer->rx = rx_buf; xfer->rx = rx_buf;
@ -206,6 +208,7 @@ static int ss_spi_qmsi_transceive(struct device *dev,
rc = qm_ss_spi_set_config(spi_id, cfg); rc = qm_ss_spi_set_config(spi_id, cfg);
if (rc != 0) { if (rc != 0) {
device_busy_clear(dev);
return -EINVAL; return -EINVAL;
} }
@ -218,11 +221,13 @@ static int ss_spi_qmsi_transceive(struct device *dev,
#ifdef CONFIG_SPI_SS_CS_GPIO #ifdef CONFIG_SPI_SS_CS_GPIO
spi_control_cs(dev, false); spi_control_cs(dev, false);
#endif #endif
device_busy_clear(dev);
return -EIO; return -EIO;
} }
k_sem_take(&context->device_sync_sem, K_FOREVER); k_sem_take(&context->device_sync_sem, K_FOREVER);
device_busy_clear(dev);
return context->rc ? -EIO : 0; return context->rc ? -EIO : 0;
} }