lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <cece2c1d-6e9b-d850-5321-31fae15cadb7@collabora.com>
Date:   Mon, 3 Oct 2022 13:38:45 +0200
From:   AngeloGioacchino Del Regno 
        <angelogioacchino.delregno@...labora.com>
To:     Pin-yen Lin <treapking@...omium.org>,
        Andrzej Hajda <andrzej.hajda@...el.com>,
        Neil Armstrong <narmstrong@...libre.com>,
        Robert Foss <robert.foss@...aro.org>,
        Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
        Jonas Karlman <jonas@...boo.se>,
        Jernej Skrabec <jernej.skrabec@...il.com>,
        David Airlie <airlied@...ux.ie>,
        Daniel Vetter <daniel@...ll.ch>
Cc:     linux-kernel@...r.kernel.org, Hermes Wu <hermes.wu@....com.tw>,
        Allen Chen <allen.chen@....com.tw>,
        Hsin-Yi Wang <hsinyi@...omium.org>,
        dri-devel@...ts.freedesktop.org
Subject: Re: [PATCH v2 1/2] drm/bridge: it6505: Adapt runtime power management
 framework

Il 03/10/22 07:03, Pin-yen Lin ha scritto:
> Use pm_runtime_(get|put)_sync to control the bridge power, and add
> SET_SYSTEM_SLEEP_PM_OPS with pm_runtime_force_(suspend|resume) to it6505
> driver. Without SET_SYSTEM_SLEEP_PM_OPS, the bridge will be powered on
> unnecessarily when no external display is connected.
> 
> Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver")
> Signed-off-by: Pin-yen Lin <treapking@...omium.org>
> 
> ---
> 
> Changes in v2:
> - Handle the error from pm_runtime_get_sync in it6505_extcon_work
> 
>   drivers/gpu/drm/bridge/ite-it6505.c | 33 +++++++++++++++++++++--------
>   1 file changed, 24 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
> index 2bb957cffd94..685d8e750b12 100644
> --- a/drivers/gpu/drm/bridge/ite-it6505.c
> +++ b/drivers/gpu/drm/bridge/ite-it6505.c
> @@ -421,6 +421,7 @@ struct it6505 {
>   	struct notifier_block event_nb;
>   	struct extcon_dev *extcon;
>   	struct work_struct extcon_wq;
> +	int extcon_state;
>   	enum drm_connector_status connector_status;
>   	enum link_train_status link_state;
>   	struct work_struct link_works;
> @@ -2685,31 +2686,42 @@ static void it6505_extcon_work(struct work_struct *work)
>   {
>   	struct it6505 *it6505 = container_of(work, struct it6505, extcon_wq);
>   	struct device *dev = &it6505->client->dev;
> -	int state = extcon_get_state(it6505->extcon, EXTCON_DISP_DP);
> -	unsigned int pwroffretry = 0;
> +	int state, ret;
>   
>   	if (it6505->enable_drv_hold)
>   		return;
>   
>   	mutex_lock(&it6505->extcon_lock);
>   
> +	state = extcon_get_state(it6505->extcon, EXTCON_DISP_DP);
>   	DRM_DEV_DEBUG_DRIVER(dev, "EXTCON_DISP_DP = 0x%02x", state);
> +
> +	if (state == it6505->extcon_state)
> +		goto unlock;

Even if it's unlikely for anything bad to happen, please add error handling,
or we might end up with unbalanced pm_runtime calls.

	if (state == it6505->extcon_state || unlikely(state < 0))
		goto unlock;
	it6505->extcon_state = state;
	if (state) {
		....
	} else {
		....
	}

Regards,
Angelo

Powered by blists - more mailing lists