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 few driver fixes for the I2C subsystem"

* 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
i2c: stm32f7: remove warning when compiling with W=1
i2c: stm32f7: fix a race in slave mode with arbitration loss irq
i2c: stm32f7: fix first byte to send in slave mode
i2c: mt65xx: fix NULL ptr dereference
i2c: aspeed: fix master pending state handling

+48 -29
+34 -20
drivers/i2c/busses/i2c-aspeed.c
··· 108 108 #define ASPEED_I2CD_S_TX_CMD BIT(2) 109 109 #define ASPEED_I2CD_M_TX_CMD BIT(1) 110 110 #define ASPEED_I2CD_M_START_CMD BIT(0) 111 + #define ASPEED_I2CD_MASTER_CMDS_MASK \ 112 + (ASPEED_I2CD_M_STOP_CMD | \ 113 + ASPEED_I2CD_M_S_RX_CMD_LAST | \ 114 + ASPEED_I2CD_M_RX_CMD | \ 115 + ASPEED_I2CD_M_TX_CMD | \ 116 + ASPEED_I2CD_M_START_CMD) 111 117 112 118 /* 0x18 : I2CD Slave Device Address Register */ 113 119 #define ASPEED_I2CD_DEV_ADDR_MASK GENMASK(6, 0) ··· 342 336 struct i2c_msg *msg = &bus->msgs[bus->msgs_index]; 343 337 u8 slave_addr = i2c_8bit_addr_from_msg(msg); 344 338 345 - bus->master_state = ASPEED_I2C_MASTER_START; 346 - 347 339 #if IS_ENABLED(CONFIG_I2C_SLAVE) 348 340 /* 349 341 * If it's requested in the middle of a slave session, set the master 350 342 * state to 'pending' then H/W will continue handling this master 351 343 * command when the bus comes back to the idle state. 352 344 */ 353 - if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE) 345 + if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE) { 354 346 bus->master_state = ASPEED_I2C_MASTER_PENDING; 347 + return; 348 + } 355 349 #endif /* CONFIG_I2C_SLAVE */ 356 350 351 + bus->master_state = ASPEED_I2C_MASTER_START; 357 352 bus->buf_index = 0; 358 353 359 354 if (msg->flags & I2C_M_RD) { ··· 429 422 } 430 423 } 431 424 432 - #if IS_ENABLED(CONFIG_I2C_SLAVE) 433 - /* 434 - * A pending master command will be started by H/W when the bus comes 435 - * back to idle state after completing a slave operation so change the 436 - * master state from 'pending' to 'start' at here if slave is inactive. 437 - */ 438 - if (bus->master_state == ASPEED_I2C_MASTER_PENDING) { 439 - if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE) 440 - goto out_no_complete; 441 - 442 - bus->master_state = ASPEED_I2C_MASTER_START; 443 - } 444 - #endif /* CONFIG_I2C_SLAVE */ 445 - 446 425 /* Master is not currently active, irq was for someone else. */ 447 426 if (bus->master_state == ASPEED_I2C_MASTER_INACTIVE || 448 427 bus->master_state == ASPEED_I2C_MASTER_PENDING) ··· 455 462 #if IS_ENABLED(CONFIG_I2C_SLAVE) 456 463 /* 457 464 * If a peer master starts a xfer immediately after it queues a 458 - * master command, change its state to 'pending' then H/W will 459 - * continue the queued master xfer just after completing the 460 - * slave mode session. 465 + * master command, clear the queued master command and change 466 + * its state to 'pending'. To simplify handling of pending 467 + * cases, it uses S/W solution instead of H/W command queue 468 + * handling. 461 469 */ 462 470 if (unlikely(irq_status & ASPEED_I2CD_INTR_SLAVE_MATCH)) { 471 + writel(readl(bus->base + ASPEED_I2C_CMD_REG) & 472 + ~ASPEED_I2CD_MASTER_CMDS_MASK, 473 + bus->base + ASPEED_I2C_CMD_REG); 463 474 bus->master_state = ASPEED_I2C_MASTER_PENDING; 464 475 dev_dbg(bus->dev, 465 476 "master goes pending due to a slave start\n"); ··· 626 629 irq_handled |= aspeed_i2c_master_irq(bus, 627 630 irq_remaining); 628 631 } 632 + 633 + /* 634 + * Start a pending master command at here if a slave operation is 635 + * completed. 636 + */ 637 + if (bus->master_state == ASPEED_I2C_MASTER_PENDING && 638 + bus->slave_state == ASPEED_I2C_SLAVE_INACTIVE) 639 + aspeed_i2c_do_start(bus); 629 640 #else 630 641 irq_handled = aspeed_i2c_master_irq(bus, irq_remaining); 631 642 #endif /* CONFIG_I2C_SLAVE */ ··· 695 690 (readl(bus->base + ASPEED_I2C_CMD_REG) & 696 691 ASPEED_I2CD_BUS_BUSY_STS)) 697 692 aspeed_i2c_recover_bus(bus); 693 + 694 + /* 695 + * If timed out and the state is still pending, drop the pending 696 + * master command. 697 + */ 698 + spin_lock_irqsave(&bus->lock, flags); 699 + if (bus->master_state == ASPEED_I2C_MASTER_PENDING) 700 + bus->master_state = ASPEED_I2C_MASTER_INACTIVE; 701 + spin_unlock_irqrestore(&bus->lock, flags); 698 702 699 703 return -ETIMEDOUT; 700 704 }
+1 -1
drivers/i2c/busses/i2c-mt65xx.c
··· 875 875 876 876 static u32 mtk_i2c_functionality(struct i2c_adapter *adap) 877 877 { 878 - if (adap->quirks->flags & I2C_AQ_NO_ZERO_LEN) 878 + if (i2c_check_quirks(adap, I2C_AQ_NO_ZERO_LEN)) 879 879 return I2C_FUNC_I2C | 880 880 (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK); 881 881 else
+13 -8
drivers/i2c/busses/i2c-stm32f7.c
··· 305 305 struct regmap *regmap; 306 306 }; 307 307 308 - /** 308 + /* 309 309 * All these values are coming from I2C Specification, Version 6.0, 4th of 310 310 * April 2014. 311 311 * ··· 1192 1192 STM32F7_I2C_CR1_TXIE; 1193 1193 stm32f7_i2c_set_bits(base + STM32F7_I2C_CR1, mask); 1194 1194 1195 + /* Write 1st data byte */ 1196 + writel_relaxed(value, base + STM32F7_I2C_TXDR); 1195 1197 } else { 1196 1198 /* Notify i2c slave that new write transfer is starting */ 1197 1199 i2c_slave_event(slave, I2C_SLAVE_WRITE_REQUESTED, &value); ··· 1503 1501 void __iomem *base = i2c_dev->base; 1504 1502 struct device *dev = i2c_dev->dev; 1505 1503 struct stm32_i2c_dma *dma = i2c_dev->dma; 1506 - u32 mask, status; 1504 + u32 status; 1507 1505 1508 1506 status = readl_relaxed(i2c_dev->base + STM32F7_I2C_ISR); 1509 1507 ··· 1528 1526 f7_msg->result = -EINVAL; 1529 1527 } 1530 1528 1531 - /* Disable interrupts */ 1532 - if (stm32f7_i2c_is_slave_registered(i2c_dev)) 1533 - mask = STM32F7_I2C_XFER_IRQ_MASK; 1534 - else 1535 - mask = STM32F7_I2C_ALL_IRQ_MASK; 1536 - stm32f7_i2c_disable_irq(i2c_dev, mask); 1529 + if (!i2c_dev->slave_running) { 1530 + u32 mask; 1531 + /* Disable interrupts */ 1532 + if (stm32f7_i2c_is_slave_registered(i2c_dev)) 1533 + mask = STM32F7_I2C_XFER_IRQ_MASK; 1534 + else 1535 + mask = STM32F7_I2C_ALL_IRQ_MASK; 1536 + stm32f7_i2c_disable_irq(i2c_dev, mask); 1537 + } 1537 1538 1538 1539 /* Disable dma */ 1539 1540 if (i2c_dev->use_dma) {