Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp338945imm; Fri, 1 Jun 2018 01:40:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKoYeMr4c4QL0VKsezg2Ouqip6ySHwEUHRai27sQVKj1eXGMrUybXKWqsNHZQbtZurmntCX X-Received: by 2002:a17:902:2983:: with SMTP id h3-v6mr10314849plb.232.1527842457966; Fri, 01 Jun 2018 01:40:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527842457; cv=none; d=google.com; s=arc-20160816; b=Behbe8Ja6wzVwvO1XPoNWvs0IWd5WFu7AsFXYoO6Yz1kMbjQt31Vzd+TXmeME3CrkD bLpxUSlWAbpLFmxJVLuk0XVtZjUDcLUxdo71P7LYknvd4BhB3H1PCJM1wj9BI59hjhH8 4NYo3l/X5/ZCCh+YVVRg9zXSJiLhN6uQOI1FHmfAnZuzOhTLkHEmeWW0TqIPLfiCWRFg QFgmCoHIXp/irebtlcztIqfmC7FRhCCUUddYlVRc5Fxi87CPwB3+bvUDGAC6iX2Tl0H0 kinc9VCCsLYDGEQl1WyikyPydWZoRTGWaNWmoOhFGK7iG7HHrpTI2gf65u9i7PSZ297O KLBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=wu9AAHopbdEusWTXqGNmZqgnvXIhMNafoTHV8kXxTxs=; b=Xz3f8CJv5sahUWtGR1LrQ0BIT0XbR11UC+KfIhogsFjvTxwNCfLVRzw0a4oIkyta7f QrXpG4hInwQ+qV75jd7LuQJqbv/XPJ72YU4uNlnDYrvYawOKqfac7ImicclpXztcpAE9 Fk4D2Yf69oO0EhcLrGcm7iUgJpEV+8hwifzsepQy+CYOzEeWNNbAE6svNQkE6qnMTEGn Rk3HIQXcW8I+HICzwnh6PSrhyF7kO2j1UBKVBjkJcrg71VfGtx/FbWXXc5E6z8y+PI3K ZTxn+UDoW7ILXUXvpPc5fJHyEJ1jt8Cv5egdyLP7YhyXjm1sV6X+01PUJ/4ALPPndORl gkvg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 142-v6si14052527pga.694.2018.06.01.01.40.41; Fri, 01 Jun 2018 01:40:57 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751293AbeFAIil (ORCPT + 99 others); Fri, 1 Jun 2018 04:38:41 -0400 Received: from lb2-smtp-cloud7.xs4all.net ([194.109.24.28]:34110 "EHLO lb2-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750974AbeFAIii (ORCPT ); Fri, 1 Jun 2018 04:38:38 -0400 Received: from [192.168.2.10] ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id OfZvfwLm2xiYrOfZyfu1Jm; Fri, 01 Jun 2018 10:38:36 +0200 Subject: Re: [PATCH v7 3/6] mfd: cros-ec: Increase maximum mkbp event size To: Neil Armstrong , airlied@linux.ie, hans.verkuil@cisco.com, lee.jones@linaro.org, olof@lixom.net, seanpaul@google.com Cc: sadolfsson@google.com, felixe@google.com, bleung@google.com, darekm@google.com, marcheu@chromium.org, fparent@baylibre.com, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, eballetbo@gmail.com, Stefan Adolfsson References: <1527841154-24832-1-git-send-email-narmstrong@baylibre.com> <1527841154-24832-4-git-send-email-narmstrong@baylibre.com> From: Hans Verkuil Message-ID: Date: Fri, 1 Jun 2018 10:38:31 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1527841154-24832-4-git-send-email-narmstrong@baylibre.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfIpAKm3wS13twgFLoHbBxwwRwbhNhDO0a/Lvk3fcG7+/+SG4Pi81tfB8+89wBQwq+7Udw0afLt9Sdy7n8s4qM6PPJ9If4Tad4XliykU9wLo5W73gPvLb kW58I6WY3dw4fIKV9XYQq4o2IhIcCnGIZs9raEX7SMc1YXAUXJz1M/gzNojyHA/l3Q7pyWPJFpSDUmRC7kfqNxeQZ6xAXJfwVFRqEWWlozt0x9eXSFSQv9dp cEz6t4SubNeZhT/2VQVOs6wgKO0ujRP4Ci8vkdcTQQV29+PwynAJu1v5/3HKmTsqZ6lnsKiyNmt7OkOodIallvTbHSffZ44OrC2ExFyOVlqeKPl/H9KBP3AH +EAn9FBww/dUzOzJ0ha9yZhML3vB8Vsp2gldiy8WUT6gWFBY4QD8pVrgnSykLBdu597xO6mNT+GfQHs1LuMeL+OkgZOR1jwsgTpGq/57z7vw085QlgKU9ILP KWm4W5NhxiANHkiAqAERHxCjfPhxR441wkVL9iRVvQalBNX6CBWtXvoqc2O30brS7agOptGq+hul023C5ZBRrSYGL5g3WPPHt5vJ3Bzm6TRkuMgSh2xrvjiP zRxJ/n+Xmj9QvCsVx60n1OnaQRWaA0Ey3ceXSMQQGRedqQD9aub5EUWmlowQzCXbkbCPZ7q3SlR3RnX6GDkak6UptPUH6aOMaQBJQVOcGMCSqLyL3QHqbTB2 HjI9cauc+DZVcYzCZngKMMewjpPRLtqcZklW+MjSwFByiTI5D5/SA6KuFrfDJyVMG2Q3fZbscoA= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/01/2018 10:19 AM, Neil Armstrong wrote: > Having a 16 byte mkbp event size makes it possible to send CEC > messages from the EC to the AP directly inside the mkbp event > instead of first doing a notification and then a read. > > Signed-off-by: Stefan Adolfsson > Signed-off-by: Neil Armstrong > Tested-by: Enric Balletbo i Serra Acked-by: Hans Verkuil Regards, Hans > --- > drivers/platform/chrome/cros_ec_proto.c | 40 +++++++++++++++++++++++++-------- > include/linux/mfd/cros_ec.h | 2 +- > include/linux/mfd/cros_ec_commands.h | 19 ++++++++++++++++ > 3 files changed, 51 insertions(+), 10 deletions(-) > > diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c > index e7bbdf9..c4f6c44 100644 > --- a/drivers/platform/chrome/cros_ec_proto.c > +++ b/drivers/platform/chrome/cros_ec_proto.c > @@ -504,10 +504,31 @@ int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev, > } > EXPORT_SYMBOL(cros_ec_cmd_xfer_status); > > +static int get_next_event_xfer(struct cros_ec_device *ec_dev, > + struct cros_ec_command *msg, > + int version, uint32_t size) > +{ > + int ret; > + > + msg->version = version; > + msg->command = EC_CMD_GET_NEXT_EVENT; > + msg->insize = size; > + msg->outsize = 0; > + > + ret = cros_ec_cmd_xfer(ec_dev, msg); > + if (ret > 0) { > + ec_dev->event_size = ret - 1; > + memcpy(&ec_dev->event_data, msg->data, ec_dev->event_size); > + } > + > + return ret; > +} > + > static int get_next_event(struct cros_ec_device *ec_dev) > { > u8 buffer[sizeof(struct cros_ec_command) + sizeof(ec_dev->event_data)]; > struct cros_ec_command *msg = (struct cros_ec_command *)&buffer; > + static int cmd_version = 1; > int ret; > > if (ec_dev->suspended) { > @@ -515,18 +536,19 @@ static int get_next_event(struct cros_ec_device *ec_dev) > return -EHOSTDOWN; > } > > - msg->version = 0; > - msg->command = EC_CMD_GET_NEXT_EVENT; > - msg->insize = sizeof(ec_dev->event_data); > - msg->outsize = 0; > + if (cmd_version == 1) { > + ret = get_next_event_xfer(ec_dev, msg, cmd_version, > + sizeof(struct ec_response_get_next_event_v1)); > + if (ret < 0 || msg->result != EC_RES_INVALID_VERSION) > + return ret; > > - ret = cros_ec_cmd_xfer(ec_dev, msg); > - if (ret > 0) { > - ec_dev->event_size = ret - 1; > - memcpy(&ec_dev->event_data, msg->data, > - sizeof(ec_dev->event_data)); > + /* Fallback to version 0 for future send attempts */ > + cmd_version = 0; > } > > + ret = get_next_event_xfer(ec_dev, msg, cmd_version, > + sizeof(struct ec_response_get_next_event)); > + > return ret; > } > > diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h > index f36125e..32caef3 100644 > --- a/include/linux/mfd/cros_ec.h > +++ b/include/linux/mfd/cros_ec.h > @@ -147,7 +147,7 @@ struct cros_ec_device { > bool mkbp_event_supported; > struct blocking_notifier_head event_notifier; > > - struct ec_response_get_next_event event_data; > + struct ec_response_get_next_event_v1 event_data; > int event_size; > u32 host_event_wake_mask; > }; > diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h > index f2edd99..cc0768e 100644 > --- a/include/linux/mfd/cros_ec_commands.h > +++ b/include/linux/mfd/cros_ec_commands.h > @@ -2093,12 +2093,31 @@ union ec_response_get_next_data { > uint32_t sysrq; > } __packed; > > +union ec_response_get_next_data_v1 { > + uint8_t key_matrix[16]; > + > + /* Unaligned */ > + uint32_t host_event; > + > + uint32_t buttons; > + uint32_t switches; > + uint32_t sysrq; > + uint32_t cec_events; > + uint8_t cec_message[16]; > +} __packed; > + > struct ec_response_get_next_event { > uint8_t event_type; > /* Followed by event data if any */ > union ec_response_get_next_data data; > } __packed; > > +struct ec_response_get_next_event_v1 { > + uint8_t event_type; > + /* Followed by event data if any */ > + union ec_response_get_next_data_v1 data; > +} __packed; > + > /* Bit indices for buttons and switches.*/ > /* Buttons */ > #define EC_MKBP_POWER_BUTTON 0 >