Skip to content

Commit 32226e8

Browse files
Finn Thainmpe
authored andcommitted
macintosh/adb-iop: Implement idle -> sending state transition
In the present algorithm, the 'idle' state transition does not take place until there's a bus timeout. Once idle, the driver does not automatically proceed with the next request. Change the algorithm so that queued ADB requests will be sent as soon as the driver becomes idle. This is to take place after the current IOP message is completed. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Tested-by: Stan Johnson <userm57@yahoo.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/dedcdfc62f43e85cc4c2a8d211a7e2fec7bc7c1a.1590880623.git.fthain@telegraphics.com.au
1 parent 56b732e commit 32226e8

1 file changed

Lines changed: 24 additions & 19 deletions

File tree

‎drivers/macintosh/adb-iop.c‎

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,19 @@ struct adb_driver adb_iop_driver = {
5454
.reset_bus = adb_iop_reset_bus
5555
};
5656

57-
static void adb_iop_end_req(struct adb_request *req, int state)
57+
static void adb_iop_done(void)
5858
{
59+
struct adb_request *req = current_req;
60+
61+
adb_iop_state = idle;
62+
5963
req->complete = 1;
6064
current_req = req->next;
6165
if (req->done)
6266
(*req->done)(req);
63-
adb_iop_state = state;
67+
68+
if (adb_iop_state == idle)
69+
adb_iop_start();
6470
}
6571

6672
/*
@@ -94,37 +100,36 @@ static void adb_iop_complete(struct iop_msg *msg)
94100
static void adb_iop_listen(struct iop_msg *msg)
95101
{
96102
struct adb_iopmsg *amsg = (struct adb_iopmsg *)msg->message;
97-
struct adb_request *req;
98103
unsigned long flags;
104+
bool req_done = false;
99105

100106
local_irq_save(flags);
101107

102-
req = current_req;
103-
104108
/* Handle a timeout. Timeout packets seem to occur even after
105109
* we've gotten a valid reply to a TALK, presumably because of
106110
* autopolling.
107111
*/
108112

109-
if (amsg->flags & ADB_IOP_TIMEOUT) {
110-
msg->reply[0] = ADB_IOP_TIMEOUT | ADB_IOP_AUTOPOLL;
111-
msg->reply[1] = 0;
112-
msg->reply[2] = 0;
113-
if (req && (adb_iop_state != idle)) {
114-
adb_iop_end_req(req, idle);
115-
}
116-
} else {
117-
if ((adb_iop_state == awaiting_reply) &&
118-
(amsg->flags & ADB_IOP_EXPLICIT)) {
113+
if (amsg->flags & ADB_IOP_EXPLICIT) {
114+
if (adb_iop_state == awaiting_reply) {
115+
struct adb_request *req = current_req;
116+
119117
req->reply_len = amsg->count + 1;
120118
memcpy(req->reply, &amsg->cmd, req->reply_len);
121-
} else {
122-
adb_input(&amsg->cmd, amsg->count + 1,
123-
amsg->flags & ADB_IOP_AUTOPOLL);
119+
120+
req_done = true;
124121
}
125-
memcpy(msg->reply, msg->message, IOP_MSG_LEN);
122+
} else if (!(amsg->flags & ADB_IOP_TIMEOUT)) {
123+
adb_input(&amsg->cmd, amsg->count + 1,
124+
amsg->flags & ADB_IOP_AUTOPOLL);
126125
}
126+
127+
msg->reply[0] = ADB_IOP_AUTOPOLL;
127128
iop_complete_message(msg);
129+
130+
if (req_done)
131+
adb_iop_done();
132+
128133
local_irq_restore(flags);
129134
}
130135

0 commit comments

Comments
 (0)