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

Configure Feed

Select the types of activity you want to include in your feed.

Merge existing fixes from spi/for-5.11

+82 -6
+80 -4
drivers/spi/spi-geni-qcom.c
··· 83 83 spinlock_t lock; 84 84 int irq; 85 85 bool cs_flag; 86 + bool abort_failed; 86 87 }; 87 88 88 89 static int get_spi_clk_cfg(unsigned int speed_hz, ··· 142 141 spin_unlock_irq(&mas->lock); 143 142 144 143 time_left = wait_for_completion_timeout(&mas->abort_done, HZ); 145 - if (!time_left) 144 + if (!time_left) { 146 145 dev_err(mas->dev, "Failed to cancel/abort m_cmd\n"); 146 + 147 + /* 148 + * No need for a lock since SPI core has a lock and we never 149 + * access this from an interrupt. 150 + */ 151 + mas->abort_failed = true; 152 + } 153 + } 154 + 155 + static bool spi_geni_is_abort_still_pending(struct spi_geni_master *mas) 156 + { 157 + struct geni_se *se = &mas->se; 158 + u32 m_irq, m_irq_en; 159 + 160 + if (!mas->abort_failed) 161 + return false; 162 + 163 + /* 164 + * The only known case where a transfer times out and then a cancel 165 + * times out then an abort times out is if something is blocking our 166 + * interrupt handler from running. Avoid starting any new transfers 167 + * until that sorts itself out. 168 + */ 169 + spin_lock_irq(&mas->lock); 170 + m_irq = readl(se->base + SE_GENI_M_IRQ_STATUS); 171 + m_irq_en = readl(se->base + SE_GENI_M_IRQ_EN); 172 + spin_unlock_irq(&mas->lock); 173 + 174 + if (m_irq & m_irq_en) { 175 + dev_err(mas->dev, "Interrupts pending after abort: %#010x\n", 176 + m_irq & m_irq_en); 177 + return true; 178 + } 179 + 180 + /* 181 + * If we're here the problem resolved itself so no need to check more 182 + * on future transfers. 183 + */ 184 + mas->abort_failed = false; 185 + 186 + return false; 147 187 } 148 188 149 189 static void spi_geni_set_cs(struct spi_device *slv, bool set_flag) ··· 200 158 if (set_flag == mas->cs_flag) 201 159 return; 202 160 203 - mas->cs_flag = set_flag; 204 - 205 161 pm_runtime_get_sync(mas->dev); 162 + 163 + if (spi_geni_is_abort_still_pending(mas)) { 164 + dev_err(mas->dev, "Can't set chip select\n"); 165 + goto exit; 166 + } 167 + 206 168 spin_lock_irq(&mas->lock); 169 + if (mas->cur_xfer) { 170 + dev_err(mas->dev, "Can't set CS when prev xfer running\n"); 171 + spin_unlock_irq(&mas->lock); 172 + goto exit; 173 + } 174 + 175 + mas->cs_flag = set_flag; 207 176 reinit_completion(&mas->cs_done); 208 177 if (set_flag) 209 178 geni_se_setup_m_cmd(se, SPI_CS_ASSERT, 0); ··· 223 170 spin_unlock_irq(&mas->lock); 224 171 225 172 time_left = wait_for_completion_timeout(&mas->cs_done, HZ); 226 - if (!time_left) 173 + if (!time_left) { 174 + dev_warn(mas->dev, "Timeout setting chip select\n"); 227 175 handle_fifo_timeout(spi, NULL); 176 + } 228 177 178 + exit: 229 179 pm_runtime_put(mas->dev); 230 180 } 231 181 ··· 336 280 int ret; 337 281 struct spi_geni_master *mas = spi_master_get_devdata(spi); 338 282 283 + if (spi_geni_is_abort_still_pending(mas)) 284 + return -EBUSY; 285 + 339 286 ret = setup_fifo_params(spi_msg->spi, spi); 340 287 if (ret) 341 288 dev_err(mas->dev, "Couldn't select mode %d\n", ret); ··· 413 354 unsigned int bytes_per_fifo_word = geni_byte_per_fifo_word(mas); 414 355 unsigned int i = 0; 415 356 357 + /* Stop the watermark IRQ if nothing to send */ 358 + if (!mas->cur_xfer) { 359 + writel(0, se->base + SE_GENI_TX_WATERMARK_REG); 360 + return false; 361 + } 362 + 416 363 max_bytes = (mas->tx_fifo_depth - mas->tx_wm) * bytes_per_fifo_word; 417 364 if (mas->tx_rem_bytes < max_bytes) 418 365 max_bytes = mas->tx_rem_bytes; ··· 461 396 if (rx_last_byte_valid && rx_last_byte_valid < 4) 462 397 rx_bytes -= bytes_per_fifo_word - rx_last_byte_valid; 463 398 } 399 + 400 + /* Clear out the FIFO and bail if nowhere to put it */ 401 + if (!mas->cur_xfer) { 402 + for (i = 0; i < DIV_ROUND_UP(rx_bytes, bytes_per_fifo_word); i++) 403 + readl(se->base + SE_GENI_RX_FIFOn); 404 + return; 405 + } 406 + 464 407 if (mas->rx_rem_bytes < rx_bytes) 465 408 rx_bytes = mas->rx_rem_bytes; 466 409 ··· 567 494 struct spi_transfer *xfer) 568 495 { 569 496 struct spi_geni_master *mas = spi_master_get_devdata(spi); 497 + 498 + if (spi_geni_is_abort_still_pending(mas)) 499 + return -EBUSY; 570 500 571 501 /* Terminate and return success for 0 byte length transfer */ 572 502 if (!xfer->len)
+2 -2
drivers/spi/spi-stm32.c
··· 493 493 494 494 /* align packet size with data registers access */ 495 495 if (spi->cur_bpw > 8) 496 - fthlv -= (fthlv % 2); /* multiple of 2 */ 496 + fthlv += (fthlv % 2) ? 1 : 0; 497 497 else 498 - fthlv -= (fthlv % 4); /* multiple of 4 */ 498 + fthlv += (fthlv % 4) ? (4 - (fthlv % 4)) : 0; 499 499 500 500 if (!fthlv) 501 501 fthlv = 1;