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

Merge branch 'spi-5.2' into spi-linus

+59 -13
+45 -6
drivers/spi/spi-qup.c
··· 273 273 writel_relaxed(QUP_OP_IN_SERVICE_FLAG, 274 274 controller->base + QUP_OPERATIONAL); 275 275 276 + if (!remainder) 277 + goto exit; 278 + 276 279 if (is_block_mode) { 277 280 num_words = (remainder > words_per_block) ? 278 281 words_per_block : remainder; ··· 305 302 * to refresh opflags value because MAX_INPUT_DONE_FLAG may now be 306 303 * present and this is used to determine if transaction is complete 307 304 */ 308 - *opflags = readl_relaxed(controller->base + QUP_OPERATIONAL); 309 - if (is_block_mode && *opflags & QUP_OP_MAX_INPUT_DONE_FLAG) 310 - writel_relaxed(QUP_OP_IN_SERVICE_FLAG, 311 - controller->base + QUP_OPERATIONAL); 312 - 305 + exit: 306 + if (!remainder) { 307 + *opflags = readl_relaxed(controller->base + QUP_OPERATIONAL); 308 + if (is_block_mode && *opflags & QUP_OP_MAX_INPUT_DONE_FLAG) 309 + writel_relaxed(QUP_OP_IN_SERVICE_FLAG, 310 + controller->base + QUP_OPERATIONAL); 311 + } 313 312 } 314 313 315 314 static void spi_qup_write_to_fifo(struct spi_qup *controller, u32 num_words) ··· 358 353 /* ACK by clearing service flag */ 359 354 writel_relaxed(QUP_OP_OUT_SERVICE_FLAG, 360 355 controller->base + QUP_OPERATIONAL); 356 + 357 + /* make sure the interrupt is valid */ 358 + if (!remainder) 359 + return; 361 360 362 361 if (is_block_mode) { 363 362 num_words = (remainder > words_per_block) ? ··· 576 567 return 0; 577 568 } 578 569 570 + static bool spi_qup_data_pending(struct spi_qup *controller) 571 + { 572 + unsigned int remainder_tx, remainder_rx; 573 + 574 + remainder_tx = DIV_ROUND_UP(spi_qup_len(controller) - 575 + controller->tx_bytes, controller->w_size); 576 + 577 + remainder_rx = DIV_ROUND_UP(spi_qup_len(controller) - 578 + controller->rx_bytes, controller->w_size); 579 + 580 + return remainder_tx || remainder_rx; 581 + } 582 + 579 583 static irqreturn_t spi_qup_qup_irq(int irq, void *dev_id) 580 584 { 581 585 struct spi_qup *controller = dev_id; 582 586 u32 opflags, qup_err, spi_err; 587 + unsigned long flags; 583 588 int error = 0; 584 589 585 590 qup_err = readl_relaxed(controller->base + QUP_ERROR_FLAGS); ··· 625 602 error = -EIO; 626 603 } 627 604 605 + spin_lock_irqsave(&controller->lock, flags); 606 + if (!controller->error) 607 + controller->error = error; 608 + spin_unlock_irqrestore(&controller->lock, flags); 609 + 628 610 if (spi_qup_is_dma_xfer(controller->mode)) { 629 611 writel_relaxed(opflags, controller->base + QUP_OPERATIONAL); 630 612 } else { ··· 638 610 639 611 if (opflags & QUP_OP_OUT_SERVICE_FLAG) 640 612 spi_qup_write(controller); 613 + 614 + if (!spi_qup_data_pending(controller)) 615 + complete(&controller->done); 641 616 } 642 617 643 - if ((opflags & QUP_OP_MAX_INPUT_DONE_FLAG) || error) 618 + if (error) 644 619 complete(&controller->done); 620 + 621 + if (opflags & QUP_OP_MAX_INPUT_DONE_FLAG) { 622 + if (!spi_qup_is_dma_xfer(controller->mode)) { 623 + if (spi_qup_data_pending(controller)) 624 + return IRQ_HANDLED; 625 + } 626 + complete(&controller->done); 627 + } 645 628 646 629 return IRQ_HANDLED; 647 630 }
+2 -2
drivers/spi/spi-stm32-qspi.c
··· 29 29 #define CR_SSHIFT BIT(4) 30 30 #define CR_DFM BIT(6) 31 31 #define CR_FSEL BIT(7) 32 - #define CR_FTHRES_MASK GENMASK(12, 8) 32 + #define CR_FTHRES_SHIFT 8 33 33 #define CR_TEIE BIT(16) 34 34 #define CR_TCIE BIT(17) 35 35 #define CR_FTIE BIT(18) ··· 463 463 flash->presc = presc; 464 464 465 465 mutex_lock(&qspi->lock); 466 - qspi->cr_reg = FIELD_PREP(CR_FTHRES_MASK, 3) | CR_SSHIFT | CR_EN; 466 + qspi->cr_reg = 3 << CR_FTHRES_SHIFT | CR_SSHIFT | CR_EN; 467 467 writel_relaxed(qspi->cr_reg, qspi->io_base + QSPI_CR); 468 468 469 469 /* set dcr fsize to max address */
+12 -5
drivers/spi/spi-uniphier.c
··· 328 328 struct spi_transfer *t) 329 329 { 330 330 struct uniphier_spi_priv *priv = spi_master_get_devdata(master); 331 - int status; 331 + struct device *dev = master->dev.parent; 332 + unsigned long time_left; 333 + 334 + /* Terminate and return success for 0 byte length transfer */ 335 + if (!t->len) 336 + return 0; 332 337 333 338 uniphier_spi_setup_transfer(spi, t); 334 339 ··· 343 338 344 339 uniphier_spi_irq_enable(spi, SSI_IE_RCIE | SSI_IE_RORIE); 345 340 346 - status = wait_for_completion_timeout(&priv->xfer_done, 347 - msecs_to_jiffies(SSI_TIMEOUT_MS)); 341 + time_left = wait_for_completion_timeout(&priv->xfer_done, 342 + msecs_to_jiffies(SSI_TIMEOUT_MS)); 348 343 349 344 uniphier_spi_irq_disable(spi, SSI_IE_RCIE | SSI_IE_RORIE); 350 345 351 - if (status < 0) 352 - return status; 346 + if (!time_left) { 347 + dev_err(dev, "transfer timeout.\n"); 348 + return -ETIMEDOUT; 349 + } 353 350 354 351 return priv->error; 355 352 }