Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp623654pxa; Fri, 14 Aug 2020 13:12:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKF5uJFWmLY/zho9Wp0UpQGk/Do9W2+6UJaXRlVmI+ONVY1gO1arPxrsP/VKx8MIg/6lVQ X-Received: by 2002:a17:906:ca5a:: with SMTP id jx26mr3880663ejb.62.1597435947180; Fri, 14 Aug 2020 13:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597435947; cv=none; d=google.com; s=arc-20160816; b=MUBusFa5vD2OhVJ248WDMYnsp3Pm++hZrs5GyJDvoXDT8TitpRK33sAO3RVvOjGqIX clLncNuJWh06EdiMbZ2iycvAq9MugUSabhppirG0jpFPIGUWpwjgG3qRI7y/K2vBlNN+ B+kXlrURfOpKZZ/BSPq/atiB/cxmnkrB1VLpm5aGmdVofZiFt9TgzTdjD1qNjbTk7eyD z9o9/EbOMKLBEmULwnzj0WicWYIMaIPoHLR2M6exbv2c1nVJ0xVv7Cs0NiIITy8hh7ho lricTKU/oz2aHg9zeNTBUerxaB6dZjDlSFKAbn5sOIBMf+we4T/qst//0L+do0BpUtQc kntA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Gh/neF9ziJj56PStHE/QUZcQmekSoXrkmgunMbnXSWg=; b=EmsHA1hO/ZjPBxkRf+ItI/16dw4zD9ckytG61aIA/R5ssZc7lfUk7BiP5toW9Qb1T2 q807d8pLAVP2zpXM4VAuyfRZhNAsZP0YQyc0/Bw23+Z8HavctORBKH7+qIRkEL0PLxtv SoVNUiMW06g59nyxY/pggw13v+Xa7GtK6wfijLXh4n9LCVNCYVL/2ntwCY6hXzVOlFUp 39eQewqh2DSS+82tEhYg5HVACkLkHxW51oUzT2sd7KMe2vqMH29pz9Mjd2G7Y6Zd6F5K iTABexE/iQakluT0G8+g5kTdakLWpSxsd91G4Dusak0s7x+kdn1x9WnahHyHahJSxozi ORAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nsEdusix; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lz17si5917715ejb.521.2020.08.14.13.11.48; Fri, 14 Aug 2020 13:12:27 -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=@google.com header.s=20161025 header.b=nsEdusix; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728148AbgHNTWv (ORCPT + 99 others); Fri, 14 Aug 2020 15:22:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726196AbgHNTWu (ORCPT ); Fri, 14 Aug 2020 15:22:50 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CC5BC061385 for ; Fri, 14 Aug 2020 12:22:50 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id c16so11029476ejx.12 for ; Fri, 14 Aug 2020 12:22:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Gh/neF9ziJj56PStHE/QUZcQmekSoXrkmgunMbnXSWg=; b=nsEdusixWGWlqqcRwywxuEcnS0tRoDLUZ5AHp1gy4TV6NF4nPagOWT2h656wgfLODg duAPjQ237NbgC/fxEmuEbnPx2xPn/BpCCaKavmn0akmuPquJgdZvYiyrua4MY+g3eQW9 TgsTdAyoD3Ifs0tuNk8n6z0uL+4msbqxuTVzCABiJfXTLm0IWrK7qzfln3p0iz3rL97V L71AVTtHP8h6QhfIaYwh/6WSvmA8szEmbdFBnVykMukugE7Rop7nMJqLeEtjiG52MRh5 gY64O7S08lc/qMuIYBW/j79Fj52HP/BSAroHBmF2cUR95qpT8pOMrrSYigygRC8CTKgo bmUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Gh/neF9ziJj56PStHE/QUZcQmekSoXrkmgunMbnXSWg=; b=hftVA3VJTOVNUoL/jY5SJSaZWHH3m+v7vXuaeox5cMTuRY8doGbICXXkizaQ5uNa2p e5ae29u4TQuR5iK/tYDLKN23QPa/9rL+cP3Amh1UdLeIjomvIy1I/YYh44WP/r32eL6P sMDYmNNUUR48qRA3ydyTWiOQERGRnOsaFZLm+7bx7T24Xqgs7l/XIe7tM9w0d4Nx5Y4D Fo9z7kjrMSI+J0aELwwE5ASktwrQdn/hXKjynVtQRDuyikyfeXLXBhXEWc69HjVAMKc6 cGi42CYSULd8jYLV6w2sFEyv15kZzOE6m9xDGpCeIlLWelIlY6hMeD/is4+2+YswM+zT fuFA== X-Gm-Message-State: AOAM532115zhZkT5XAKNm2iDc8ZHWr+Vg4HR9ZXWMlVCE8I7UO0/Vv1l QUkqnu6zjHbTD+aZO57j0fqCtSAjxOyXSAzJrSa8eg== X-Received: by 2002:a17:906:4994:: with SMTP id p20mr3575441eju.299.1597432968735; Fri, 14 Aug 2020 12:22:48 -0700 (PDT) MIME-Version: 1.0 References: <20200813012125.GV1665100@dtor-ws> In-Reply-To: <20200813012125.GV1665100@dtor-ws> From: Raul Rangel Date: Fri, 14 Aug 2020 13:22:37 -0600 Message-ID: Subject: Re: PS/2 + i8042 intermixing commands To: Dmitry Torokhov Cc: linux-input@vger.kernel.org, linux-kernel , "S, Shirish" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for clarifying Dmitry. I'll get a patch pushed up next week. On Wed, Aug 12, 2020 at 7:21 PM Dmitry Torokhov wrote: > > 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