Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754222AbdFWWWw (ORCPT ); Fri, 23 Jun 2017 18:22:52 -0400 Received: from mail-pg0-f50.google.com ([74.125.83.50]:36118 "EHLO mail-pg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753306AbdFWWWu (ORCPT ); Fri, 23 Jun 2017 18:22:50 -0400 Subject: Re: [PATCH RESEND 13/13] platform/chrome: cros_ec_lightbar - Avoid I2C xfer to EC during suspend To: Enric Balletbo i Serra , olof@lixom.net, bleung@chromium.org, linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, Jeffery Yu , Guenter Roeck References: <20170516161319.13257-1-enric.balletbo@collabora.com> <20170516161319.13257-14-enric.balletbo@collabora.com> From: Benson Leung Organization: Google Message-ID: <62f4fd24-3c4f-0e68-656b-699a028f760d@google.com> Date: Fri, 23 Jun 2017 15:22:46 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <20170516161319.13257-14-enric.balletbo@collabora.com> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="xeS6LTcsK6l2jRXP5NFtBFR6Wriht4AvB" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6008 Lines: 185 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --xeS6LTcsK6l2jRXP5NFtBFR6Wriht4AvB Content-Type: multipart/mixed; boundary="mbkiIev3epejvBwr45S1sjQjepJnB1M4u"; protected-headers="v1" From: Benson Leung To: Enric Balletbo i Serra , olof@lixom.net, bleung@chromium.org, linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, Jeffery Yu , Guenter Roeck Message-ID: <62f4fd24-3c4f-0e68-656b-699a028f760d@google.com> Subject: Re: [PATCH RESEND 13/13] platform/chrome: cros_ec_lightbar - Avoid I2C xfer to EC during suspend References: <20170516161319.13257-1-enric.balletbo@collabora.com> <20170516161319.13257-14-enric.balletbo@collabora.com> In-Reply-To: <20170516161319.13257-14-enric.balletbo@collabora.com> --mbkiIev3epejvBwr45S1sjQjepJnB1M4u Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Hi Enric, On 05/16/2017 09:13 AM, Enric Balletbo i Serra wrote: > From: Jeffery Yu >=20 > A Mutex lock in cros_ec_cmd_xfer which may be held by frozen > Userspace thread during system suspending. So should not > call this routine in suspend thread. >=20 > Signed-off-by: Jeffery Yu > Signed-off-by: Guenter Roeck > Signed-off-by: Enric Balletbo i Serra Signed-off-by: Benson Leung Applied. > --- > drivers/platform/chrome/cros_ec_dev.c | 12 ++++-------- > drivers/platform/chrome/cros_ec_lightbar.c | 13 +++++++++---- > 2 files changed, 13 insertions(+), 12 deletions(-) >=20 > diff --git a/drivers/platform/chrome/cros_ec_dev.c b/drivers/platform/c= hrome/cros_ec_dev.c > index 7c26223..b9bf086 100644 > --- a/drivers/platform/chrome/cros_ec_dev.c > +++ b/drivers/platform/chrome/cros_ec_dev.c > @@ -437,8 +437,7 @@ static int ec_device_probe(struct platform_device *= pdev) > cros_ec_sensors_register(ec); > =20 > /* Take control of the lightbar from the EC. */ > - if (ec_has_lightbar(ec)) > - lb_manual_suspend_ctrl(ec, 1); > + lb_manual_suspend_ctrl(ec, 1); > =20 > return 0; > =20 > @@ -452,8 +451,7 @@ static int ec_device_remove(struct platform_device = *pdev) > struct cros_ec_dev *ec =3D dev_get_drvdata(&pdev->dev); > =20 > /* Let the EC take over the lightbar again. */ > - if (ec_has_lightbar(ec)) > - lb_manual_suspend_ctrl(ec, 0); > + lb_manual_suspend_ctrl(ec, 0); > =20 > cros_ec_debugfs_remove(ec); > =20 > @@ -472,8 +470,7 @@ static int ec_device_suspend(struct device *dev) > { > struct cros_ec_dev *ec =3D dev_get_drvdata(dev); > =20 > - if (ec_has_lightbar(ec)) > - lb_suspend(ec); > + lb_suspend(ec); > =20 > return 0; > } > @@ -482,8 +479,7 @@ static int ec_device_resume(struct device *dev) > { > struct cros_ec_dev *ec =3D dev_get_drvdata(dev); > =20 > - if (ec_has_lightbar(ec)) > - lb_resume(ec); > + lb_resume(ec); > =20 > return 0; > } > diff --git a/drivers/platform/chrome/cros_ec_lightbar.c b/drivers/platf= orm/chrome/cros_ec_lightbar.c > index e570c1e..fd2b047 100644 > --- a/drivers/platform/chrome/cros_ec_lightbar.c > +++ b/drivers/platform/chrome/cros_ec_lightbar.c > @@ -43,6 +43,7 @@ static unsigned long lb_interval_jiffies =3D 50 * HZ = / 1000; > * If this is true, we won't do anything during suspend/resume. > */ > static bool userspace_control; > +static struct cros_ec_dev *ec_with_lightbar; > =20 > static ssize_t interval_msec_show(struct device *dev, > struct device_attribute *attr, char *buf) > @@ -384,6 +385,9 @@ int lb_manual_suspend_ctrl(struct cros_ec_dev *ec, = uint8_t enable) > struct cros_ec_command *msg; > int ret; > =20 > + if (ec !=3D ec_with_lightbar) > + return 0; > + > msg =3D alloc_lightbar_cmd_msg(ec); > if (!msg) > return -ENOMEM; > @@ -413,7 +417,7 @@ int lb_manual_suspend_ctrl(struct cros_ec_dev *ec, = uint8_t enable) > =20 > int lb_suspend(struct cros_ec_dev *ec) > { > - if (userspace_control) > + if (userspace_control || ec !=3D ec_with_lightbar) > return 0; > =20 > return lb_send_empty_cmd(ec, LIGHTBAR_CMD_SUSPEND); > @@ -421,7 +425,7 @@ int lb_suspend(struct cros_ec_dev *ec) > =20 > int lb_resume(struct cros_ec_dev *ec) > { > - if (userspace_control) > + if (userspace_control || ec !=3D ec_with_lightbar) > return 0; > =20 > return lb_send_empty_cmd(ec, LIGHTBAR_CMD_RESUME); > @@ -606,9 +610,10 @@ static umode_t cros_ec_lightbar_attrs_are_visible(= struct kobject *kobj, > return 0; > =20 > /* Only instantiate this stuff if the EC has a lightbar */ > - if (ec_has_lightbar(ec)) > + if (ec_has_lightbar(ec)) { > + ec_with_lightbar =3D ec; > return a->mode; > - > + } > return 0; > } > =20 >=20 --=20 Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. bleung@google.com Chromium OS Project bleung@chromium.org --mbkiIev3epejvBwr45S1sjQjepJnB1M4u-- --xeS6LTcsK6l2jRXP5NFtBFR6Wriht4AvB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBCgAGBQJZTZS2AAoJEB8J9XsKL+ZYiu4QAIDG5poIuHoBuunq6KJ/f91/ 7/+Dyb00NKzovqpsdaMDk7HCMTrhpIU3UkqMIEEEGGcn8PH7mrZRmYFUbH6y2Na1 wbvEVR4Vo/Se/RrhxFhHtPRKzF2W7qlSByFqvxyn7/FkJd3ZxcXcs0xQuLD9jtKO aEHgQ/eRtJoKUjvCCxeIWVoIb38QSwDZcXMa2Hm6U3zrskeUVElOVCyxKUzCJJPT d+XGSkV7Q4v9epZbsTCH7UCmF2Lv4MQ5k8g9fQU+W/Lq3kRTmKNmUCU+h3Tj4DwD h0sG4wYNRoFeJURVuVRc4+H50DZmnhLnCrgHtwjB8zQiI+YoC5BOUm/y8prNpRdp a2/DHiG6J04EDHpwNOSQcSUguuHnNAhm12ReIJbfYGFWiU2r7yPx2VAA4JehqrG1 fzlEb1UyyjZBcd6JcYgwPkNhnE5DszEQYfClvi/K32zpbEbSg/ANgNJVOOB723km YiWBUL1QojOBvIi0QM8YQzzWdLhExf7XWLZuCcxYMX8BEDZ6+ZSd4447EMEmebyT zAmCAa6LLAcjXRDbH4QMUy7X5vhNSOGSnd56yPDtxhJfpGiYjdiIfTTYH3Qv07qS 2cFOHZvrMz7DNrb5f0mW5WIUnvEPS0L4Awu2HhBjjfcm/LNA2L9wvXwbKJPTJJWH MywP4dKQ3gUda8FFwgaF =AP7h -----END PGP SIGNATURE----- --xeS6LTcsK6l2jRXP5NFtBFR6Wriht4AvB--