Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp955224pxa; Wed, 12 Aug 2020 18:23:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0sS2THsJ0yB+jfYSvKJ5qJNCjZzhce9sBZQwce9P1oCHtO36yzwf0DUBi0BICrNYQgIgA X-Received: by 2002:a17:906:2a14:: with SMTP id j20mr2015021eje.376.1597281825723; Wed, 12 Aug 2020 18:23:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597281825; cv=none; d=google.com; s=arc-20160816; b=ChfJiHO/c7SH13Fnu/FPpSqvA6fVX//s7U6gux33vFpkA4J2Bd4Ts6LS4C2RU1fBeO bB+hhbc9pdY9IwP+m4+tWRn4R6Z1uyTQ1xm9o0en+q3HFjoO0++LjA2l3bpYmORiGNIz 2V3ID+h/7D/g7r255KSTBoDYTvu3q6XVsvyngrm3tLgqplLaxoeJmTAe9rqWH+EsYGWZ mgom25ueCKbEvuUTNfxqSjfK+jy1qmZ78X3i6lKsY7+S5uef6/SpkjjAsbBIPyEJp5Yi XsGKjUneHEe/hFdAzMtNHCU9Fwz/uSvvVIbMMGg2Jochdf/hpXiWHulnmTvL+notpPUv tPdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=lQIgWLskafx/ldXdduKgobildOhYZxik0ZHwho1Zfoo=; b=YGnxggu3lBNA5apOh0T2GOw2Tan30zfWrU+B1+XmUaBbdfsKptsiEDfoCFiVKTSmm2 3mAaid5VnNZXN5/8gRJBQC1W00hoaiAmXuNXduL2z/2NDkA4mRxXCYukTi6h25nxiTXR 1FXtHYXnEtP2+B0VJcmv8hdxiFD5Is4jY8hDQzkpURr2VWbAxzB1T8Q1LC8B5RNn1+Lf BF6+1bgHRu0wr/SmjXXkVV3s2/O8euDv7JVbX1oR0KUVaAl1gOEtalo4bmCriOkyO3O8 HhYd+RxYSCJYp0Xk39PCWRNXmlw8w07M/r/sNd4YI6xME4b6M1yaeaWqyD2ArLJQAYy2 n58Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="mGN4/7qa"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f12si2809941edx.142.2020.08.12.18.23.23; Wed, 12 Aug 2020 18:23:45 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="mGN4/7qa"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726605AbgHMBVa (ORCPT + 99 others); Wed, 12 Aug 2020 21:21:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726554AbgHMBV3 (ORCPT ); Wed, 12 Aug 2020 21:21:29 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77C06C061383; Wed, 12 Aug 2020 18:21:29 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id x6so1972825pgx.12; Wed, 12 Aug 2020 18:21:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=lQIgWLskafx/ldXdduKgobildOhYZxik0ZHwho1Zfoo=; b=mGN4/7qavgQWwG5YfUkeYeG0wYOtcBkAYp2bPdv6B36KhbQa9wrpecPbkjDWFoOW9L JeE25dc4lsSrciIgNBYihQti5o9VWJxedN3krMCF85tLA7O96PgOvMkeen5dNdfXc7n3 j2PSPmE5MwIE3VKLLwZowwQtUX73oolFxjkmk4y2XXmvbOfELNdK/++VPg4E4mHz2Fed qE51NDmggB+4+meJqc5PNTqDKFly23rsPUviIIr27sdvHwCqh61BgJx2F44kH3YjS10d 6bjf91qQeNf2vXIxXZfR8FG1mDbxUpIObEy3qkI1UxDWQTo/JhgYQeNx6yql7PO0U8kB zNXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=lQIgWLskafx/ldXdduKgobildOhYZxik0ZHwho1Zfoo=; b=eLaA+VOkCvL+mAV30/AdWAAIXexBM6SVR/zD1HYUeHbv32tHeJcoy3MlqSZmiUMoNO yrLyJLgT3lHCu82NfSXiyJxtWig1c3TclXj2lRo5HVEwClZS7TP7w5gEgJhrjcvNzjBw 0tl3RiEeJLVfYAJujkTtPOOpetaJTQiT4rNAhQ/658JxCUfBI2TByXD3K5/2XjG9XrDp OC2lXSzCR9ZAl4F38O954Wl8D+3qOawVlYvVGVAO57LNvgqRqqPfnOw7yQwE/A29kxXB JP6Den9eTSeiN8Mit0NBVQLmdPRFWYJSoZGAmqbXtuOb94uZHztKqserLZotqEMo9OsG bDAg== X-Gm-Message-State: AOAM530VbIoJpKh+wJKov6dKfe7lvPfcpqhD3sg/z57Es2DHoY2W2XNp 2XejcG6DUa7icStej7YRsJQ= X-Received: by 2002:a62:7c09:: with SMTP id x9mr2004878pfc.229.1597281688701; Wed, 12 Aug 2020 18:21:28 -0700 (PDT) Received: from dtor-ws ([2620:15c:202:201:a6ae:11ff:fe11:fcc3]) by smtp.gmail.com with ESMTPSA id m22sm3346397pja.36.2020.08.12.18.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2020 18:21:27 -0700 (PDT) Date: Wed, 12 Aug 2020 18:21:25 -0700 From: Dmitry Torokhov To: Raul Rangel Cc: linux-input@vger.kernel.org, linux-kernel , "S, Shirish" Subject: Re: PS/2 + i8042 intermixing commands Message-ID: <20200813012125.GV1665100@dtor-ws> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 06, 2020 at 09:28:41AM -0600, Raul Rangel wrote: > > > > <- atkbd_event_work->atkbd_set_leds > > [KB recv data: 0xed] # CMD 10 > > <- Wait, where is the data? > > > > <- Continuation of i8042_port_close? > > [KB recv cmd: 0x60] # CMD #14 > > [KB recv data: 0x43] > > [KB eaten by STATE_WRITE_CMD_BYTE: 0x43] > > [KB set CTR_RAM(0x00)=0x43 (old:0x41)] > > [AUX IRQ enable] > > > > <- Here is the data! > > [KB recv data: 0x00] # CMD 10 (data) > > [KB Unsupported i8042 data 0x00] > > [KB recv data: 0x00] <- Did the host retry? > > [KB Unsupported i8042 data 0x00] > > > > <- atkbd_event_work->atkbd_set_repeat_rate > > [KB recv data: 0xf3] # CMD #11 > > [KB recv data: 0x00] > > [KB eaten by STATE_SETREP: 0x00] > > > > [KB recv cmd: 0xd4] # CMD #15 > > [KB recv data: 0xf2] > > [STATE_SEND_TO_MOUSE: 0xf2] > > As you can see CMD #10 starts between #13 and #14, and then completes > after #14. Is this expected behavior? > > I'm not quite sure if #13 and #14 are coming from i8042_port_close. I > don't have a function trace available, but it seems to fit. > > I found this comment: > /* > * Writers to AUX and KBD ports as well as users issuing i8042_command > * directly should acquire i8042_mutex (by means of calling > * i8042_lock_chip() and i8042_unlock_ship() helpers) to ensure that > * they do not disturb each other (unfortunately in many i8042 > * implementations write to one of the ports will immediately abort > * command that is being processed by another port). > */ > static DEFINE_MUTEX(i8042_mutex); > > Does that not mean that i8042_port_close, i8042_enable_kbd_port, > i8042_enable_aux_port, + any other function that calls i8042_command > should be taking the lock before calling i8042_command? Yeah, I think this is right. When I added the mutex it was because 2 deices were clashing with each other and I did not consider that closing port in the i8042 driver itself may also disturb in-flight command. Thanks. -- Dmitry