Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 992fc597 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "spi: spi-geni-qcom: Calculate transfer timeout dynamically"

parents c1586982 146de6ec
Loading
Loading
Loading
Loading
+20 −10
Original line number Diff line number Diff line
@@ -167,6 +167,7 @@ struct spi_geni_master {
	u32 miso_sampling_ctrl_val;
	int set_cs_sb_delay; /*SB PIPE Delay */
	int set_pre_cmd_dly; /*Pre command Delay */
	bool use_fixed_timeout;
};

static struct spi_master *get_spi_master(struct device *dev)
@@ -1265,7 +1266,7 @@ static int spi_geni_transfer_one(struct spi_master *spi,
{
	int ret = 0;
	struct spi_geni_master *mas = spi_master_get_devdata(spi);
	unsigned long timeout;
	unsigned long timeout, xfer_timeout;

	if ((xfer->tx_buf == NULL) && (xfer->rx_buf == NULL)) {
		dev_err(mas->dev, "Invalid xfer both tx rx are NULL\n");
@@ -1278,6 +1279,15 @@ static int spi_geni_transfer_one(struct spi_master *spi,
		return -EINVAL;
	}

	if (mas->use_fixed_timeout)
		xfer_timeout = msecs_to_jiffies(SPI_XFER_TIMEOUT_MS);
	else
		xfer_timeout =
			100 * msecs_to_jiffies(DIV_ROUND_UP(xfer->len * 8,
				DIV_ROUND_UP(xfer->speed_hz, MSEC_PER_SEC)));
	GENI_SE_DBG(mas->ipc, false, mas->dev,
			"current xfer_timeout:%lu ms.\n", xfer_timeout);

	if (mas->cur_xfer_mode != GSI_DMA) {
		reinit_completion(&mas->xfer_done);
		ret = setup_fifo_xfer(xfer, mas, slv->mode, spi);
@@ -1289,7 +1299,8 @@ static int spi_geni_transfer_one(struct spi_master *spi,
		}

		timeout = wait_for_completion_timeout(&mas->xfer_done,
					msecs_to_jiffies(SPI_XFER_TIMEOUT_MS));
				xfer_timeout);

		if (!timeout) {
			GENI_SE_ERR(mas->ipc, true, mas->dev,
				"Xfer[len %d tx %pK rx %pK n %d] timed out.\n",
@@ -1329,10 +1340,8 @@ static int spi_geni_transfer_one(struct spi_master *spi,
			int i;

			for (i = 0 ; i < mas->num_tx_eot; i++) {
				timeout =
				wait_for_completion_timeout(
					&mas->tx_cb,
					msecs_to_jiffies(SPI_XFER_TIMEOUT_MS));
				timeout = wait_for_completion_timeout(
					&mas->tx_cb, xfer_timeout);
				if (timeout <= 0) {
					GENI_SE_ERR(mas->ipc, true, mas->dev,
					"Tx[%d] timeout%lu\n", i, timeout);
@@ -1341,10 +1350,8 @@ static int spi_geni_transfer_one(struct spi_master *spi,
				}
			}
			for (i = 0 ; i < mas->num_rx_eot; i++) {
				timeout =
				wait_for_completion_timeout(
					&mas->rx_cb,
					msecs_to_jiffies(SPI_XFER_TIMEOUT_MS));
				timeout = wait_for_completion_timeout(
					&mas->rx_cb, xfer_timeout);
				if (timeout <= 0) {
					GENI_SE_ERR(mas->ipc, true, mas->dev,
					 "Rx[%d] timeout%lu\n", i, timeout);
@@ -1680,6 +1687,9 @@ static int spi_geni_probe(struct platform_device *pdev)
		of_property_read_bool(pdev->dev.of_node,
				"qcom,shared_ee");

	geni_mas->use_fixed_timeout =
		of_property_read_bool(pdev->dev.of_node,
				"qcom,use-fixed-timeout");
	geni_mas->set_miso_sampling = of_property_read_bool(pdev->dev.of_node,
				"qcom,set-miso-sampling");
	if (geni_mas->set_miso_sampling) {