public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Thierry Escande <thierry.escande@collabora.com>
Cc: Benson Leung <bleung@chromium.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] mfd: cros_ec: Prevent data transfer while device is suspended
Date: Wed, 4 Jan 2017 09:06:51 +0000	[thread overview]
Message-ID: <20170104090651.GM27589@dell> (raw)
In-Reply-To: <1481911058-28604-2-git-send-email-thierry.escande@collabora.com>

On Fri, 16 Dec 2016, Thierry Escande wrote:

> From: Joseph Lo <josephl@nvidia.com>
> 
> The cros_ec driver is still active while the device is suspended.
> Besides that, it also tries to transfer data even after the I2C host had
> been suspended. This patch uses a simple flag to prevent this.
> 
> Signed-off-by: Joseph Lo <josephl@nvidia.com>
> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
> ---
>  drivers/mfd/cros_ec.c                   | 2 ++
>  drivers/platform/chrome/cros_ec_proto.c | 5 +++++
>  include/linux/mfd/cros_ec.h             | 2 ++
>  3 files changed, 9 insertions(+)

Can this patch be taken without 3/3?

For my own reference:
  Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>

> diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c
> index abd8342..ad48633 100644
> --- a/drivers/mfd/cros_ec.c
> +++ b/drivers/mfd/cros_ec.c
> @@ -165,6 +165,7 @@ int cros_ec_suspend(struct cros_ec_device *ec_dev)
>  
>  	disable_irq(ec_dev->irq);
>  	ec_dev->was_wake_device = ec_dev->wake_enabled;
> +	ec_dev->suspended = true;
>  
>  	return 0;
>  }
> @@ -179,6 +180,7 @@ static void cros_ec_drain_events(struct cros_ec_device *ec_dev)
>  
>  int cros_ec_resume(struct cros_ec_device *ec_dev)
>  {
> +	ec_dev->suspended = false;
>  	enable_irq(ec_dev->irq);
>  
>  	/*
> diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
> index 04053fe..ed5dee7 100644
> --- a/drivers/platform/chrome/cros_ec_proto.c
> +++ b/drivers/platform/chrome/cros_ec_proto.c
> @@ -447,6 +447,11 @@ static int get_next_event(struct cros_ec_device *ec_dev)
>  	struct cros_ec_command *msg = (struct cros_ec_command *)&buffer;
>  	int ret;
>  
> +	if (ec_dev->suspended) {
> +		dev_dbg(ec_dev->dev, "Device suspended.\n");
> +		return -EHOSTDOWN;
> +	}
> +
>  	msg->version = 0;
>  	msg->command = EC_CMD_GET_NEXT_EVENT;
>  	msg->insize = sizeof(ec_dev->event_data);
> diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h
> index 76f7ef4..d585bf0 100644
> --- a/include/linux/mfd/cros_ec.h
> +++ b/include/linux/mfd/cros_ec.h
> @@ -103,6 +103,7 @@ struct cros_ec_command {
>   * @din_size: size of din buffer to allocate (zero to use static din)
>   * @dout_size: size of dout buffer to allocate (zero to use static dout)
>   * @wake_enabled: true if this device can wake the system from sleep
> + * @suspended: true if this device had been suspended
>   * @cmd_xfer: send command to EC and get response
>   *     Returns the number of bytes received if the communication succeeded, but
>   *     that doesn't mean the EC was happy with the command. The caller
> @@ -136,6 +137,7 @@ struct cros_ec_device {
>  	int din_size;
>  	int dout_size;
>  	bool wake_enabled;
> +	bool suspended;
>  	int (*cmd_xfer)(struct cros_ec_device *ec,
>  			struct cros_ec_command *msg);
>  	int (*pkt_xfer)(struct cros_ec_device *ec,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2017-01-04  9:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-16 17:57 [PATCH 0/3] mfd: cros_ec: various improvements Thierry Escande
2016-12-16 17:57 ` [PATCH 1/3] mfd: cros_ec: Prevent data transfer while device is suspended Thierry Escande
2017-01-04  9:06   ` Lee Jones [this message]
2017-01-05  8:15   ` Lee Jones
2016-12-16 17:57 ` [PATCH 2/3] mfd: cros_ec: Send suspend state notification to EC Thierry Escande
2017-01-04  9:07   ` Lee Jones
2017-01-04 14:18     ` Thierry Escande
2017-01-05  8:15   ` Lee Jones
2016-12-16 17:57 ` [PATCH 3/3] mfd: cros_ec: Add ACPI GPE handler for LID0 devices Thierry Escande
2017-01-04  9:06   ` Lee Jones
2017-01-04 17:17     ` Thierry Escande
2017-01-05  7:54       ` Lee Jones
2017-01-05 10:37         ` Thierry Escande
2017-01-05 14:43           ` Lee Jones
2017-01-05 16:39             ` Thierry Escande

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170104090651.GM27589@dell \
    --to=lee.jones@linaro.org \
    --cc=bleung@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thierry.escande@collabora.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox