linux/drivers/macintosh
Finn Thain 2c9cfbadfa macintosh/adb-iop: Always wait for reply message from IOP
A recent patch incorrectly altered the adb-iop state machine behaviour
and introduced a regression that can appear intermittently as a
malfunctioning ADB input device. This seems to be caused when reply
packets from different ADB commands become mixed up, especially during
the adb bus scan. Fix this by unconditionally entering the awaiting_reply
state after sending an explicit command, even when the ADB command won't
generate a reply from the ADB device.

It turns out that the IOP always generates reply messages, even when the
ADB command does not produce a reply packet (e.g. ADB Listen command).
So it's not really the ADB reply packets that are being mixed up, it's the
IOP messages that enclose them. The bug goes like this:

  1. CPU sends a message to the IOP, expecting no response because this
     message contains an ADB Listen command. The ADB command is now
     considered complete.

  2. CPU sends a second message to the IOP, this time expecting a
     response because this message contains an ADB Talk command. This
     ADB command needs a reply before it can be completed.

  3. adb-iop driver receives an IOP message and assumes that it relates
     to the Talk command. It's actually an empty one (with flags ==
     ADB_IOP_EXPLICIT|ADB_IOP_TIMEOUT) for the previous command. The
     Talk command is now considered complete but it gets the wrong reply
     data.

  4. adb-iop driver gets another IOP response message, which contains
     the actual reply data for the Talk command, but this is dropped
     (the driver is no longer in awaiting_reply state).

Cc: Joshua Thompson <funaho@jurai.org>
Fixes: e2954e5f72 ("macintosh/adb-iop: Implement sending -> idle state transition")
Tested-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Link: https://lore.kernel.org/r/0f0a25855391e7eaa53a50f651aea0124e8525dd.1605847196.git.fthain@telegraphics.com.au
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
2020-12-07 10:48:15 +01:00
..
ams macintosh/ams-input: switch to using input device polling mode 2020-05-28 23:24:32 +10:00
adb-iop.c macintosh/adb-iop: Always wait for reply message from IOP 2020-12-07 10:48:15 +01:00
adb.c macintosh/adb: Replace HTTP links with HTTPS ones 2020-07-22 00:01:23 +10:00
adbhid.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
ans-lcd.c misc: cleanup minor number definitions in c file into miscdevice.h 2020-03-18 12:27:03 +01:00
ans-lcd.h misc: cleanup minor number definitions in c file into miscdevice.h 2020-03-18 12:27:03 +01:00
apm_emu.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 118 2019-05-24 17:39:02 +02:00
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
mac_hid.c sysctl: pass kernel pointers to ->proc_handler 2020-04-27 02:07:40 -04:00
macio_asic.c dma-mapping: make support for dma ops optional 2020-07-19 09:29:23 +02:00
macio_sysfs.c macintosh: Use device_type helpers to access the node type 2018-11-26 22:33:37 +11:00
macio-adb.c mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
Makefile macintosh/via-pmu: Replace via-pmu68k driver with via-pmu driver 2018-07-31 19:56:42 +10:00
mediabay.c mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
rack-meter.c rackmeter: Use vtime aware kcpustat accessor 2019-11-21 07:59:00 +01:00
smu.c powerpc updates for 5.10 2020-10-16 12:21:15 -07:00
therm_adt746x.c macintosh/therm_adt746x: Replace HTTP links with HTTPS ones 2020-07-22 00:01:24 +10:00
therm_windtunnel.c macintosh: convert to i2c_new_scanned_device 2020-03-26 12:36:20 +01:00
via-cuda.c macintosh/via-cuda: Don't rely on Cuda to end a transfer 2019-01-22 10:21:45 +01:00
via-macii.c macintosh/via-macii: Clarify definition of macii_init() 2020-07-26 23:34:25 +10:00
via-pmu-backlight.c backlight: Fix old-style function definition 2018-01-21 23:37:44 +11:00
via-pmu-event.c
via-pmu-event.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
via-pmu-led.c powerpc: use the new LED disk activity trigger 2016-06-27 08:58:40 +02:00
via-pmu.c mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
windfarm_ad7417_sensor.c macintosh: windfarm: fix MODINFO regression 2020-03-10 12:30:59 +01:00
windfarm_core.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 246 2019-06-19 17:09:08 +02:00
windfarm_cpufreq_clamp.c cpufreq: Use per-policy frequency QoS 2019-10-21 02:05:21 +02:00
windfarm_fcu_controls.c macintosh: windfarm: fix MODINFO regression 2020-03-10 12:30:59 +01:00
windfarm_lm75_sensor.c macintosh: windfarm: remove detatch debug containing spelling mistakes 2020-09-02 11:00:17 +10:00
windfarm_lm87_sensor.c macintosh: windfarm: remove detatch debug containing spelling mistakes 2020-09-02 11:00:17 +10:00
windfarm_max6690_sensor.c macintosh: windfarm: fix MODINFO regression 2020-03-10 12:30:59 +01:00
windfarm_mpu.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 246 2019-06-19 17:09:08 +02:00
windfarm_pid.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 246 2019-06-19 17:09:08 +02:00
windfarm_pid.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 246 2019-06-19 17:09:08 +02:00
windfarm_pm72.c macintosh: Use pr_warn instead of pr_warning 2019-10-18 15:00:22 +02:00
windfarm_pm81.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 246 2019-06-19 17:09:08 +02:00
windfarm_pm91.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 246 2019-06-19 17:09:08 +02:00
windfarm_pm112.c drivers/macintosh: Fix memleak in windfarm_pm112 driver 2020-05-15 11:58:56 +10:00
windfarm_pm121.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 246 2019-06-19 17:09:08 +02:00
windfarm_rm31.c macintosh: Use pr_warn instead of pr_warning 2019-10-18 15:00:22 +02:00
windfarm_smu_controls.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 246 2019-06-19 17:09:08 +02:00
windfarm_smu_sat.c macintosh: windfarm: use for_each_child_of_node() macro 2020-09-15 22:13:39 +10:00
windfarm_smu_sensors.c macintosh: smu_sensors: use for_each_child_of_node() macro 2020-09-18 19:59:44 +10:00
windfarm.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 246 2019-06-19 17:09:08 +02:00