Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp997815pxb; Thu, 19 Nov 2020 20:55:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJBtzHTH1x/Eh0NosenfrKDRRkly773+5eHJgRnLc/F1XOXr44dcW5bVOK9LTmqJRSD3x6 X-Received: by 2002:a05:6402:17ac:: with SMTP id j12mr33386630edy.31.1605848145526; Thu, 19 Nov 2020 20:55:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605848145; cv=none; d=google.com; s=arc-20160816; b=Ty+zeRSylnygGXJamfb049TJgbLeJSUXKmSCu+3WvTyFcniGDI1my7judNly4IxMMj H4K/ACkHE0U2FXC+1y7Z5c0W/pKRM9yqSP2kVfbwN9jO5yvWdX1V/DPRHxkRZRrtb67b p3B9bQ7L70beCOePeJ7Dtw/I7mcLY1afUj2m6wIYoITjPnbG87jpcpvpotqsgf2f0K1z AQQ5hnlTC9Sxx119pDF5vMIb2c/BTC+hXl00smY21io5dGKHcpqZGSfaIdDOGZRSCJ/M +SnV0p4eJK2cUpQAYXImYu2HG94wwb+xh6w8kFDSEKfZqpgDvzakIOAiwI9olxFl+D8A I8xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:subject:from:message-id:cc:to; bh=ScFJ+J4U/QvZWGf0E6ztbwesWtCDV672w4rOfKQz3AU=; b=ionN5/ZTXcKJ3WTLmWgOkcrFHJYdglJqT9NTPm85det+VupfQ+OdZIuMYOWF0x2d8K EmfBTJiU4TFxnsMCu3ayY30PNIv427CyR+3HkVulc1+2ESWi2AxkPDr9j41c5SoeoZN5 MYBRyyKS6Y8Q0Xc3TJ6jWIfeWWHct7BAhGj3Z+3PzwWF/ogQkXtZy7By6ENs545BOLF6 l74rYKnyp4DH/PT7hnHcBCnF63G6/GHhlnm1S3VNLLr5KmlxBKC21rOWhptVD4EGgm94 0RhTLqpJc6nQzIslJSw47sHrZAO9Gu/XFh3ASCPc2/xpBpNIkBcCu5h0TMnEp1liEIJa cvBA== 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 cc13si1153530edb.104.2020.11.19.20.55.22; Thu, 19 Nov 2020 20:55:45 -0800 (PST) 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 S1726523AbgKTEvw (ORCPT + 99 others); Thu, 19 Nov 2020 23:51:52 -0500 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:52758 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726281AbgKTEvi (ORCPT ); Thu, 19 Nov 2020 23:51:38 -0500 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id 508152A45D; Thu, 19 Nov 2020 23:51:37 -0500 (EST) To: Benjamin Herrenschmidt , Michael Ellerman Cc: "Joshua Thompson" , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Message-Id: <0f0a25855391e7eaa53a50f651aea0124e8525dd.1605847196.git.fthain@telegraphics.com.au> From: Finn Thain Subject: [PATCH] macintosh/adb-iop: Always wait for reply message from IOP Date: Fri, 20 Nov 2020 15:39:56 +1100 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Cc: Joshua Thompson Fixes: e2954e5f727f ("macintosh/adb-iop: Implement sending -> idle state transition") Tested-by: Stan Johnson Signed-off-by: Finn Thain --- drivers/macintosh/adb-iop.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/macintosh/adb-iop.c b/drivers/macintosh/adb-iop.c index 6b26b6a2c463..0ee327249150 100644 --- a/drivers/macintosh/adb-iop.c +++ b/drivers/macintosh/adb-iop.c @@ -84,10 +84,7 @@ static void adb_iop_complete(struct iop_msg *msg) local_irq_save(flags); - if (current_req->reply_expected) - adb_iop_state = awaiting_reply; - else - adb_iop_done(); + adb_iop_state = awaiting_reply; local_irq_restore(flags); } @@ -95,8 +92,9 @@ static void adb_iop_complete(struct iop_msg *msg) /* * Listen for ADB messages from the IOP. * - * This will be called when unsolicited messages (usually replies to TALK - * commands or autopoll packets) are received. + * This will be called when unsolicited IOP messages are received. + * These IOP messages can carry ADB autopoll responses and also occur + * after explicit ADB commands. */ static void adb_iop_listen(struct iop_msg *msg) @@ -123,8 +121,10 @@ static void adb_iop_listen(struct iop_msg *msg) if (adb_iop_state == awaiting_reply) { struct adb_request *req = current_req; - req->reply_len = amsg->count + 1; - memcpy(req->reply, &amsg->cmd, req->reply_len); + if (req->reply_expected) { + req->reply_len = amsg->count + 1; + memcpy(req->reply, &amsg->cmd, req->reply_len); + } req_done = true; } -- 2.26.2