Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1092336ybl; Thu, 23 Jan 2020 13:26:06 -0800 (PST) X-Google-Smtp-Source: APXvYqznNQu5VHzpP31IYYCi2YXEm2u4j2sNpD4vbtsFBRIJ018yxsCy+LLuwasNZdbNx8wYJR6G X-Received: by 2002:a9d:53c2:: with SMTP id i2mr273611oth.43.1579814766586; Thu, 23 Jan 2020 13:26:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579814766; cv=none; d=google.com; s=arc-20160816; b=Qb/ybxC6X12iPIwCQ6ohLE4rXIunJew63U3qIaNwIAiliXjrafX5NunOcftZnocLJe vBCHvSqGIvQQQJU+KqmcQntjuGpXRBr4nVG3cg1QRQcm6alXuAeWyMygnpw4c0xG87gm RiflUOdVUReN7639YWjzPDAwKkYYy6YlCI803b4cKzKzj2K0qQu9UiBOZhOrigT5z6ej DsWQky2m8BTnGjJX/5LKBjcAn+12ZbWy9KfaBUKeoK/vy/AxwX6p7vH2Id/u+Mk2Zf0D vwoKzky7YHNgzXp/gLEyPELArcmVkgR9xupgLY9XvYOIQs9+4Za5oKsNUiwa/rMPQLnQ NljQ== 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=mcbgbKXHYzFeK72nb97pWxaHY+EZyGnc0S9E+ApdXgs=; b=CnE5jzqPaTxcfYye55ivWVsFMTWHcIrIzJ5UQoMgkSNfPyNcfVukoqqWNwC+/cOga8 PdYpU2yh5ID9O4wNz5UeSxTAlILoph3VZXhvBfagGSEKrHF4cT0ifFd3IDGewIEvQcdy Si9FqCaFMWG9sd+d9Xbch1DrDCEfbf7WYdWV5D2WMcVJCVa7Bro9i96BviPBaRuKbr4V AdDLJYY8qYRj2UqsBg1xsWKtTLXet123O2fDn7ARnPrKpSc89XjGsj1JFKN4R/Rpe5Gw 3mW+LZWzbW26a+it5aBFvTEAzypEMcdNjq5604NoUmDscBR1rNJE987WsyeTyprDsZue MNEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kiQh5gmy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id t21si1847702oth.274.2020.01.23.13.25.55; Thu, 23 Jan 2020 13:26:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kiQh5gmy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1729148AbgAWVFL (ORCPT + 99 others); Thu, 23 Jan 2020 16:05:11 -0500 Received: from mail-qv1-f66.google.com ([209.85.219.66]:43652 "EHLO mail-qv1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727816AbgAWVFL (ORCPT ); Thu, 23 Jan 2020 16:05:11 -0500 Received: by mail-qv1-f66.google.com with SMTP id p2so2183708qvo.10 for ; Thu, 23 Jan 2020 13:05:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mcbgbKXHYzFeK72nb97pWxaHY+EZyGnc0S9E+ApdXgs=; b=kiQh5gmyJl9700k6zOiLXFG+rMXZHdZexdPHhc9Oo/WZkyRTatXR1udIrGkvsG66u8 q0rAB/dhh0LWPtn+GWe5a99BMC97Lurx5lQOotFfeIIYCtCGszmf0r2j0ZbYnFnfPn/1 n3l2OfAYzoYlLsKH4ck090Hf41x1DJLwZtQahzFGTxBThS3FTWwUygkzuc7W1seUZlmB 1itqYVomtcqrt0pSIN7H1+3UvpITXzxUGhFcbLvc6NUPWnPN26yTIleOEzzDYh+MrtYg 8OgG0KY7Pyqj2UnBj/Agzut5JTZpX3rWNDKl8j9vQ1/aA0W40ph/AGl9IM5w++cesls9 crMg== 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=mcbgbKXHYzFeK72nb97pWxaHY+EZyGnc0S9E+ApdXgs=; b=CV8m1WJfv5crhhYYFqaPoCbXPg/xEoT/DqxT9PzjsAumHGj3Ay1dUqaXd0a6yuX1Lp nohK1iPVwaSnB30273+UOcuimdx2lXR+TdnUicsPjVnXw4+pqnghAYe34uLBm6BgBY+V bsGnwP8NuI18+xnOgcY739rr5s1HYUMz4M31lKoLnrh6UGILL32Trm1PmtqQS1/duHGU PtYs4oKl19LV3A8roKBjSZuEyszyeuBbTtAE+phYmjUCEWi//rrKNg+N3Sljca8hqQfd Mxf+Hr+OlOnRW+tIuZtlvVfZIYXQBfhhWNGYkRKEyBiqP4MqQFsTWNuvCJHC79IM4n+4 bkUg== X-Gm-Message-State: APjAAAVawJWbeDwyQp/Pup87c3XEHQd1ibvOiVoETnEYeybR7PMe5jRu FY/lYMFcY6wgbhfP+bmR9FA7pVq5V6CehjLk6xQ= X-Received: by 2002:a0c:edb2:: with SMTP id h18mr17967337qvr.94.1579813509664; Thu, 23 Jan 2020 13:05:09 -0800 (PST) MIME-Version: 1.0 References: <20200107220640.834-1-yichengli@chromium.org> In-Reply-To: <20200107220640.834-1-yichengli@chromium.org> From: Enric Balletbo Serra Date: Thu, 23 Jan 2020 22:04:58 +0100 Message-ID: Subject: Re: [PATCH v5] platform: cros_ec: Query EC protocol version if EC transitions between RO/RW To: Yicheng Li Cc: LKML , Benson Leung , Gwendal Grignou 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 Hi Yicheng, Missatge de Yicheng Li del dia dt., 7 de gen. 2020 a les 23:10: > > RO and RW of EC may have different EC protocol version. If EC transitions > between RO and RW, but AP does not reboot (this is true for fingerprint > microcontroller / cros_fp, but not true for main ec / cros_ec), the AP > still uses the protocol version queried before transition, which can > cause problems. In the case of fingerprint microcontroller, this causes > AP to send the wrong version of EC_CMD_GET_NEXT_EVENT to RO in the > interrupt handler, which in turn prevents RO to clear the interrupt > line to AP, in an infinite loop. > > Once an EC_HOST_EVENT_INTERFACE_READY is received, we know that there > might have been a transition between RO and RW, so re-query the protocol. > > Change-Id: I49a51cc10d22a4ab9e75204a4c0c8819d5b3d282 I changed the subject to 'platform/chrome' and removed the Change-id line > Signed-off-by: Yicheng Li And added the Fabien's Tested-by tag > --- > drivers/platform/chrome/cros_ec.c | 24 +++++++++++++++++++++ > include/linux/platform_data/cros_ec_proto.h | 3 +++ Fixed a trivial conflict with current chrome-platform tree and applied for-next. Please remember to cc all the maintainers and maintain a changelog between version next time. Thanks, Enric > 2 files changed, 27 insertions(+) > > diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c > index 9b2d07422e17..38ec1fb409a5 100644 > --- a/drivers/platform/chrome/cros_ec.c > +++ b/drivers/platform/chrome/cros_ec.c > @@ -104,6 +104,23 @@ static int cros_ec_sleep_event(struct cros_ec_device *ec_dev, u8 sleep_event) > return ret; > } > > +static int cros_ec_ready_event(struct notifier_block *nb, > + unsigned long queued_during_suspend, void *_notify) > +{ > + struct cros_ec_device *ec_dev = container_of(nb, struct cros_ec_device, > + notifier_ready); > + u32 host_event = cros_ec_get_host_event(ec_dev); > + > + if (host_event & EC_HOST_EVENT_MASK(EC_HOST_EVENT_INTERFACE_READY)) { > + mutex_lock(&ec_dev->lock); > + cros_ec_query_all(ec_dev); > + mutex_unlock(&ec_dev->lock); > + return NOTIFY_OK; > + } > + > + return NOTIFY_DONE; > +} > + > /** > * cros_ec_register() - Register a new ChromeOS EC, using the provided info. > * @ec_dev: Device to register. > @@ -201,6 +218,13 @@ int cros_ec_register(struct cros_ec_device *ec_dev) > dev_dbg(ec_dev->dev, "Error %d clearing sleep event to ec", > err); > > + /* Register the notifier for EC_HOST_EVENT_INTERFACE_READY event. */ > + ec_dev->notifier_ready.notifier_call = cros_ec_ready_event; > + err = blocking_notifier_chain_register(&ec_dev->event_notifier, > + &ec_dev->notifier_ready); > + if (err) > + return err; > + > dev_info(dev, "Chrome EC device registered\n"); > > return 0; > diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h > index 0d4e4aaed37a..a1c545c464e7 100644 > --- a/include/linux/platform_data/cros_ec_proto.h > +++ b/include/linux/platform_data/cros_ec_proto.h > @@ -121,6 +121,8 @@ struct cros_ec_command { > * @event_data: Raw payload transferred with the MKBP event. > * @event_size: Size in bytes of the event data. > * @host_event_wake_mask: Mask of host events that cause wake from suspend. > + * @notifier_ready: The notifier_block to let the kernel re-query EC > + * communication protocol when the EC sends EC_HOST_EVENT_INTERFACE_READY. > * @ec: The platform_device used by the mfd driver to interface with the > * main EC. > * @pd: The platform_device used by the mfd driver to interface with the > @@ -161,6 +163,7 @@ struct cros_ec_device { > int event_size; > u32 host_event_wake_mask; > u32 last_resume_result; > + struct notifier_block notifier_ready; > > /* The platform devices used by the mfd driver */ > struct platform_device *ec; > -- > 2.21.0 >