qemu-patch-raspberry4/hw/i2c
Corey Minyard 0fa758c3a0 i2c: Fix SMBus read transactions to avoid double events
Change 2293c27fad (i2c: implement broadcast write) added broadcast
capability to the I2C bus, but it broke SMBus read transactions.
An SMBus read transaction does two i2c_start_transaction() calls
without an intervening i2c_end_transfer() call.  This will
result in i2c_start_transfer() adding the same device to the
current_devs list twice, and then the ->event() for the same
device gets called twice in the second call to i2c_start_transfer(),
resulting in the smbus code getting confused.

Note that this happens even with pure I2C devices when simulating
SMBus over I2C.

This fix only scans the bus if the current set of devices is empty.
This means that the current set of devices stays fixed until
i2c_end_transfer() is called, which is really what you want.

This also deletes the empty check from the top of i2c_end_transfer().
It's unnecessary, and it prevents the broadcast variable from being
set to false at the end of the transaction if no devices were on
the bus.

Cc: KONRAD Frederic <fred.konrad@greensocs.com>
Cc: Alistair Francis <alistair.francis@xilinx.com>
Cc: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Cc: Kwon <hyun.kwon@xilinx.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: KONRAD Frederic <fred.konrad@greensocs.com>
Tested-by: KONRAD Frederic <fred.konrad@greensocs.com>
Message-id: 1470153614-6657-1-git-send-email-minyard@acm.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-10-24 16:26:55 +01:00
..
aspeed_i2c.c i2c: add aspeed i2c controller 2016-06-06 16:59:29 +01:00
bitbang_i2c.c hw/i2c: QOM'ify bitbang_i2c.c 2016-06-14 15:59:13 +01:00
bitbang_i2c.h i2c: Rename i2c_bus to I2CBus 2014-02-14 16:22:31 +01:00
core.c i2c: Fix SMBus read transactions to avoid double events 2016-10-24 16:26:55 +01:00
exynos4210_i2c.c hw/i2c: QOM'ify exynos4210_i2c.c 2016-06-14 15:59:13 +01:00
i2c-ddc.c hw/i2c-ddc.c: Implement DDC I2C slave 2016-06-14 15:59:15 +01:00
imx_i2c.c hw: explicitly include qemu/log.h 2016-05-19 16:42:29 +02:00
Makefile.objs hw/i2c-ddc.c: Implement DDC I2C slave 2016-06-14 15:59:15 +01:00
omap_i2c.c hw/i2c: QOM'ify omap_i2c.c 2016-06-14 15:59:13 +01:00
pm_smbus.c x86: Clean up includes 2016-01-29 15:07:22 +00:00
smbus.c hw: Clean up includes 2016-01-29 15:07:25 +00:00
smbus_eeprom.c hw: Clean up includes 2016-01-29 15:07:25 +00:00
smbus_ich9.c ICH9 SMB: make TYPE_ICH9_SMB_DEVICE macro public 2016-06-29 14:03:46 +02:00
versatile_i2c.c hw/i2c: QOM'ify versatile_i2c.c 2016-06-14 15:59:13 +01:00