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 branch 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c fixes from Wolfram Sang:
"A set of driver bugfixes and an improvement for a core helper"

* 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
i2c: i2c-designware-platdrv: Always use a dynamic adapter number
i2c: i2c-designware-platdrv: Cleanup setting of the adapter number
i2c: add extra check to safe DMA buffer helper
i2c: i2c-stm32f7: Fix SDADEL minimum formula
i2c: rcar: explain the lockless design
i2c: rcar: fix concurrency issue related to ICDMAER
i2c: sis630: correct format strings
i2c: mediatek: modify threshold passed to i2c_get_dma_safe_msg_buf()

+29 -16
+3 -4
drivers/i2c/busses/i2c-designware-platdrv.c
··· 86 86 struct i2c_timings *t = &dev->timings; 87 87 u32 ss_ht = 0, fp_ht = 0, hs_ht = 0, fs_ht = 0; 88 88 89 - dev->adapter.nr = -1; 90 89 dev->tx_fifo_depth = 32; 91 90 dev->rx_fifo_depth = 32; 92 91 ··· 218 219 dev->mode = DW_IC_SLAVE; 219 220 } 220 221 221 - static void dw_i2c_set_fifo_size(struct dw_i2c_dev *dev, int id) 222 + static void dw_i2c_set_fifo_size(struct dw_i2c_dev *dev) 222 223 { 223 224 u32 param, tx_fifo_depth, rx_fifo_depth; 224 225 ··· 232 233 if (!dev->tx_fifo_depth) { 233 234 dev->tx_fifo_depth = tx_fifo_depth; 234 235 dev->rx_fifo_depth = rx_fifo_depth; 235 - dev->adapter.nr = id; 236 236 } else if (tx_fifo_depth >= 2) { 237 237 dev->tx_fifo_depth = min_t(u32, dev->tx_fifo_depth, 238 238 tx_fifo_depth); ··· 356 358 div_u64(clk_khz * t->sda_hold_ns + 500000, 1000000); 357 359 } 358 360 359 - dw_i2c_set_fifo_size(dev, pdev->id); 361 + dw_i2c_set_fifo_size(dev); 360 362 361 363 adap = &dev->adapter; 362 364 adap->owner = THIS_MODULE; 363 365 adap->class = I2C_CLASS_DEPRECATED; 364 366 ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev)); 365 367 adap->dev.of_node = pdev->dev.of_node; 368 + adap->nr = -1; 366 369 367 370 dev_pm_set_driver_flags(&pdev->dev, 368 371 DPM_FLAG_SMART_PREPARE |
+4 -4
drivers/i2c/busses/i2c-mt65xx.c
··· 503 503 writel(I2C_DMA_INT_FLAG_NONE, i2c->pdmabase + OFFSET_INT_FLAG); 504 504 writel(I2C_DMA_CON_RX, i2c->pdmabase + OFFSET_CON); 505 505 506 - dma_rd_buf = i2c_get_dma_safe_msg_buf(msgs, 0); 506 + dma_rd_buf = i2c_get_dma_safe_msg_buf(msgs, 1); 507 507 if (!dma_rd_buf) 508 508 return -ENOMEM; 509 509 ··· 526 526 writel(I2C_DMA_INT_FLAG_NONE, i2c->pdmabase + OFFSET_INT_FLAG); 527 527 writel(I2C_DMA_CON_TX, i2c->pdmabase + OFFSET_CON); 528 528 529 - dma_wr_buf = i2c_get_dma_safe_msg_buf(msgs, 0); 529 + dma_wr_buf = i2c_get_dma_safe_msg_buf(msgs, 1); 530 530 if (!dma_wr_buf) 531 531 return -ENOMEM; 532 532 ··· 549 549 writel(I2C_DMA_CLR_FLAG, i2c->pdmabase + OFFSET_INT_FLAG); 550 550 writel(I2C_DMA_CLR_FLAG, i2c->pdmabase + OFFSET_CON); 551 551 552 - dma_wr_buf = i2c_get_dma_safe_msg_buf(msgs, 0); 552 + dma_wr_buf = i2c_get_dma_safe_msg_buf(msgs, 1); 553 553 if (!dma_wr_buf) 554 554 return -ENOMEM; 555 555 ··· 561 561 return -ENOMEM; 562 562 } 563 563 564 - dma_rd_buf = i2c_get_dma_safe_msg_buf((msgs + 1), 0); 564 + dma_rd_buf = i2c_get_dma_safe_msg_buf((msgs + 1), 1); 565 565 if (!dma_rd_buf) { 566 566 dma_unmap_single(i2c->dev, wpaddr, 567 567 msgs->len, DMA_TO_DEVICE);
+12 -3
drivers/i2c/busses/i2c-rcar.c
··· 363 363 struct dma_chan *chan = priv->dma_direction == DMA_FROM_DEVICE 364 364 ? priv->dma_rx : priv->dma_tx; 365 365 366 - /* Disable DMA Master Received/Transmitted */ 367 - rcar_i2c_write(priv, ICDMAER, 0); 368 - 369 366 dma_unmap_single(chan->device->dev, sg_dma_address(&priv->sg), 370 367 sg_dma_len(&priv->sg), priv->dma_direction); 371 368 ··· 372 375 priv->flags |= ID_P_NO_RXDMA; 373 376 374 377 priv->dma_direction = DMA_NONE; 378 + 379 + /* Disable DMA Master Received/Transmitted, must be last! */ 380 + rcar_i2c_write(priv, ICDMAER, 0); 375 381 } 376 382 377 383 static void rcar_i2c_cleanup_dma(struct rcar_i2c_priv *priv) ··· 611 611 return true; 612 612 } 613 613 614 + /* 615 + * This driver has a lock-free design because there are IP cores (at least 616 + * R-Car Gen2) which have an inherent race condition in their hardware design. 617 + * There, we need to clear RCAR_BUS_MASK_DATA bits as soon as possible after 618 + * the interrupt was generated, otherwise an unwanted repeated message gets 619 + * generated. It turned out that taking a spinlock at the beginning of the ISR 620 + * was already causing repeated messages. Thus, this driver was converted to 621 + * the now lockless behaviour. Please keep this in mind when hacking the driver. 622 + */ 614 623 static irqreturn_t rcar_i2c_irq(int irq, void *ptr) 615 624 { 616 625 struct rcar_i2c_priv *priv = ptr;
+2 -2
drivers/i2c/busses/i2c-sis630.c
··· 478 478 if (!request_region(smbus_base + SMB_STS, SIS630_SMB_IOREGION, 479 479 sis630_driver.name)) { 480 480 dev_err(&sis630_dev->dev, 481 - "I/O Region 0x%04hx-0x%04hx for SMBus already in use.\n", 481 + "I/O Region 0x%04x-0x%04x for SMBus already in use.\n", 482 482 smbus_base + SMB_STS, 483 483 smbus_base + SMB_STS + SIS630_SMB_IOREGION - 1); 484 484 retval = -EBUSY; ··· 528 528 sis630_adapter.dev.parent = &dev->dev; 529 529 530 530 snprintf(sis630_adapter.name, sizeof(sis630_adapter.name), 531 - "SMBus SIS630 adapter at %04hx", smbus_base + SMB_STS); 531 + "SMBus SIS630 adapter at %04x", smbus_base + SMB_STS); 532 532 533 533 return i2c_add_adapter(&sis630_adapter); 534 534 }
+1 -1
drivers/i2c/busses/i2c-stm32f7.c
··· 432 432 STM32F7_I2C_ANALOG_FILTER_DELAY_MAX : 0); 433 433 dnf_delay = setup->dnf * i2cclk; 434 434 435 - sdadel_min = setup->fall_time - i2c_specs[setup->speed].hddat_min - 435 + sdadel_min = i2c_specs[setup->speed].hddat_min + setup->fall_time - 436 436 af_delay_min - (setup->dnf + 3) * i2cclk; 437 437 438 438 sdadel_max = i2c_specs[setup->speed].vddat_max - setup->rise_time -
+7 -2
drivers/i2c/i2c-core-base.c
··· 2258 2258 /** 2259 2259 * i2c_get_dma_safe_msg_buf() - get a DMA safe buffer for the given i2c_msg 2260 2260 * @msg: the message to be checked 2261 - * @threshold: the minimum number of bytes for which using DMA makes sense 2261 + * @threshold: the minimum number of bytes for which using DMA makes sense. 2262 + * Should at least be 1. 2262 2263 * 2263 2264 * Return: NULL if a DMA safe buffer was not obtained. Use msg->buf with PIO. 2264 2265 * Or a valid pointer to be used with DMA. After use, release it by ··· 2269 2268 */ 2270 2269 u8 *i2c_get_dma_safe_msg_buf(struct i2c_msg *msg, unsigned int threshold) 2271 2270 { 2272 - if (msg->len < threshold) 2271 + /* also skip 0-length msgs for bogus thresholds of 0 */ 2272 + if (!threshold) 2273 + pr_debug("DMA buffer for addr=0x%02x with length 0 is bogus\n", 2274 + msg->addr); 2275 + if (msg->len < threshold || msg->len == 0) 2273 2276 return NULL; 2274 2277 2275 2278 if (msg->flags & I2C_M_DMA_SAFE)