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] [thread-next>] [day] [month] [year] [list]
Message-ID: <136db777-5d62-642b-a359-b06ade4518b8@samsung.com>
Date:   Fri, 7 Jun 2019 08:10:44 +0200
From:   Andrzej Hajda <a.hajda@...sung.com>
To:     Andrey Smirnov <andrew.smirnov@...il.com>,
        dri-devel@...ts.freedesktop.org
Cc:     Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
        Tomi Valkeinen <tomi.valkeinen@...com>,
        Andrey Gusakov <andrey.gusakov@...entembedded.com>,
        Philipp Zabel <p.zabel@...gutronix.de>,
        Cory Tusar <cory.tusar@....aero>,
        Chris Healy <cphealy@...il.com>,
        Lucas Stach <l.stach@...gutronix.de>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 09/15] drm/bridge: tc358767: Use reported AUX
 transfer size

On 07.06.2019 06:45, Andrey Smirnov wrote:
> Don't assume that requested data transfer size is the same as amount
> of data that was transferred. Change the code to get that information
> from DP0_AUXSTATUS instead.
>
> Since the check for AUX_BUSY in tc_aux_get_status() is pointless (it
> will always called after tc_aux_wait_busy()) and there's only one user
> of it, inline its code into tc_aux_transfer() instead of trying to
> accommodate the change above.
>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@...il.com>
Reviewed-by: Andrzej Hajda <a.hajda@...sung.com>

 --
Regards
Andrzej
> Cc: Andrzej Hajda <a.hajda@...sung.com>
> Cc: Laurent Pinchart <Laurent.pinchart@...asonboard.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@...com>
> Cc: Andrey Gusakov <andrey.gusakov@...entembedded.com>
> Cc: Philipp Zabel <p.zabel@...gutronix.de>
> Cc: Cory Tusar <cory.tusar@....aero>
> Cc: Chris Healy <cphealy@...il.com>
> Cc: Lucas Stach <l.stach@...gutronix.de>
> Cc: dri-devel@...ts.freedesktop.org
> Cc: linux-kernel@...r.kernel.org
> ---
>  drivers/gpu/drm/bridge/tc358767.c | 40 ++++++++++---------------------
>  1 file changed, 12 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
> index 8b53dc8908d3..7d0fbb12195b 100644
> --- a/drivers/gpu/drm/bridge/tc358767.c
> +++ b/drivers/gpu/drm/bridge/tc358767.c
> @@ -152,10 +152,10 @@
>  #define DP0_AUXWDATA(i)		(0x066c + (i) * 4)
>  #define DP0_AUXRDATA(i)		(0x067c + (i) * 4)
>  #define DP0_AUXSTATUS		0x068c
> -#define AUX_STATUS_MASK			0xf0
> -#define AUX_STATUS_SHIFT		4
> -#define AUX_TIMEOUT			BIT(1)
> -#define AUX_BUSY			BIT(0)
> +#define AUX_BYTES		GENMASK(15, 8)
> +#define AUX_STATUS		GENMASK(7, 4)
> +#define AUX_TIMEOUT		BIT(1)
> +#define AUX_BUSY		BIT(0)
>  #define DP0_AUXI2CADR		0x0698
>  
>  /* Link Training */
> @@ -298,29 +298,6 @@ static int tc_aux_wait_busy(struct tc_data *tc, unsigned int timeout_ms)
>  			       1000, 1000 * timeout_ms);
>  }
>  
> -static int tc_aux_get_status(struct tc_data *tc, u8 *reply)
> -{
> -	int ret;
> -	u32 value;
> -
> -	ret = regmap_read(tc->regmap, DP0_AUXSTATUS, &value);
> -	if (ret < 0)
> -		return ret;
> -
> -	if (value & AUX_BUSY) {
> -		dev_err(tc->dev, "aux busy!\n");
> -		return -EBUSY;
> -	}
> -
> -	if (value & AUX_TIMEOUT) {
> -		dev_err(tc->dev, "aux access timeout!\n");
> -		return -ETIMEDOUT;
> -	}
> -
> -	*reply = (value & AUX_STATUS_MASK) >> AUX_STATUS_SHIFT;
> -	return 0;
> -}
> -
>  static int tc_aux_write_data(struct tc_data *tc, const void *data,
>  			     size_t size)
>  {
> @@ -356,6 +333,7 @@ static ssize_t tc_aux_transfer(struct drm_dp_aux *aux,
>  	struct tc_data *tc = aux_to_tc(aux);
>  	size_t size = min_t(size_t, DP_AUX_MAX_PAYLOAD_BYTES - 1, msg->size);
>  	u8 request = msg->request & ~DP_AUX_I2C_MOT;
> +	u32 auxstatus;
>  	int ret;
>  
>  	if (size == 0)
> @@ -393,10 +371,16 @@ static ssize_t tc_aux_transfer(struct drm_dp_aux *aux,
>  	if (ret)
>  		return ret;
>  
> -	ret = tc_aux_get_status(tc, &msg->reply);
> +	ret = regmap_read(tc->regmap, DP0_AUXSTATUS, &auxstatus);
>  	if (ret)
>  		return ret;
>  
> +	if (auxstatus & AUX_TIMEOUT)
> +		return -ETIMEDOUT;
> +
> +	size = FIELD_GET(AUX_BYTES, auxstatus);
> +	msg->reply = FIELD_GET(AUX_STATUS, auxstatus);
> +
>  	switch (request) {
>  	case DP_AUX_NATIVE_READ:
>  	case DP_AUX_I2C_READ:


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ