Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1800183ybt; Sat, 27 Jun 2020 21:34:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxYrfS1xHM9VPW8Dn7FkU00tO1cbaT2M0gC615H4OL2598vzrM0GmYIw5Gebu4V93X0ihy X-Received: by 2002:a17:906:6686:: with SMTP id z6mr8646564ejo.258.1593318854911; Sat, 27 Jun 2020 21:34:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593318854; cv=none; d=google.com; s=arc-20160816; b=wlKDqmQUFz0KjGK9hvr54n5VCBUjUkcMfLtBmhXdiDQCU9LkEyE9UW878XWV0vgUsS 9w1WTRqjGSeR0jPdJRJY7BijNaE7uc5c2HKeFeg9H05t3aGXSPVHRWskq/Bp/4mvqCgH M73fUTqBvatC8YifCQJ473GtGym4hUbEWAlk8WiL6ajg5DECluYaUKcNx0KnVZUfoFX6 g0azcLLYoILev1sn9e4ZbFoUcpejaX7+dycgiqY3NOqEa/WIuH8OIxLMzP7YmVhZ8Pu7 I+LEylxEMP0dwkwT9LJXTQzzTOxeCX2UN3surASossmiGwpUttIU04lRTQ3PTcAxeNCv Y72A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:from:references:in-reply-to :message-id:cc:to; bh=QmPaa8aj2rtPmDpx7/eji43NUKHdjMsFArW7JfQsjYQ=; b=bQAJ3XPZTKGslg4Yk+K2fPBCMmH4OhVG1sxRNSM2sVje9gK8T85gIg/9vWlBPyDLtY HyT1lTACwJ6XH20YQxBRgFI0eajTjJ7j6wGEyOwUBGjFTQe0TVOV3Avqth14XXWC/tzz 41p7/zchR5fd8QFax6dZblXTZPCqAoRT5cdO0eB3/7yzmaabO+YW0P6TgOGV0mlGLS9T FlzjQYix993pnJZ4aTDi35Ton204m5IlV1MoV3URnwrn/kAnMTOFcci/nvduZSH7yttp VdhfniCt+0/m5VRBGZQ/Ph1TJMDQ1W/LV+QsG0Pj+F46xp65JgW2VhKDBSa6vK1r8Whe IHiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n9si1395014edo.13.2020.06.27.21.33.51; Sat, 27 Jun 2020 21:34:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726010AbgF1EcU (ORCPT + 99 others); Sun, 28 Jun 2020 00:32:20 -0400 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:34318 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726072AbgF1Ebr (ORCPT ); Sun, 28 Jun 2020 00:31:47 -0400 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id 9C4E32970B; Sun, 28 Jun 2020 00:31:44 -0400 (EDT) To: Benjamin Herrenschmidt Cc: Joshua Thompson , Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Laurent Vivier , Mark Cave-Ayland , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Message-Id: <754cddfa045e5bfa53e5da199831de02e7d2f27f.1593318192.git.fthain@telegraphics.com.au> In-Reply-To: References: From: Finn Thain Subject: [PATCH 5/9] macintosh/via-macii: Handle poll replies correctly Date: Sun, 28 Jun 2020 14:23:12 +1000 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Userspace applications may use /dev/adb to send Talk requests. Such requests always have req->reply_expected == 1. The same is true of Talk requests sent by the kernel, except for poll requests queued internally by the via-macii driver. Those requests have req->reply_expected == 0. Consequently, poll reply packets get treated like autopoll reply packets. (It doesn't make sense to try to distinguish them.) Always enter 'reading' state after a poll request, so that the reply gets collected and passed to adb_input(), and none go missing. All Talk replies passed to adb_input() come from polling or autopolling, so call adb_input() with the autopoll parameter set to 1. Fixes: d95fd5fce88f0 ("m68k: Mac II ADB fixes") # v5.0+ Tested-by: Stan Johnson Signed-off-by: Finn Thain --- drivers/macintosh/via-macii.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/macintosh/via-macii.c b/drivers/macintosh/via-macii.c index d29c87943ca46..8d5ef77b4a435 100644 --- a/drivers/macintosh/via-macii.c +++ b/drivers/macintosh/via-macii.c @@ -463,6 +463,21 @@ static irqreturn_t macii_interrupt(int irq, void *arg) via[ACR] &= ~SR_OUT; x = via[SR]; + } else if ((req->data[1] & OP_MASK) == TALK) { + macii_state = reading; + + reading_reply = 0; + reply_ptr = reply_buf; + *reply_ptr = req->data[1]; + reply_len = 1; + + via[ACR] &= ~SR_OUT; + x = via[SR]; + + req->complete = 1; + current_req = req->next; + if (req->done) + (*req->done)(req); } else { macii_state = idle; @@ -510,8 +525,9 @@ static irqreturn_t macii_interrupt(int irq, void *arg) current_req = req->next; if (req->done) (*req->done)(req); - } else if (reply_len && autopoll_devs) { - adb_input(reply_buf, reply_len, 0); + } else if (reply_len && autopoll_devs && + reply_buf[0] == last_poll_cmd) { + adb_input(reply_buf, reply_len, 1); } break; } -- 2.26.2