Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8897022ybi; Thu, 6 Jun 2019 23:12:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyM2tE7cRTTguELoffzQVQiTyGcUuMZ1KdJJt4PvYHPJ2Run6VtcPcGcD6bClugSzIfyRQs X-Received: by 2002:aa7:90d3:: with SMTP id k19mr55341464pfk.1.1559887961331; Thu, 06 Jun 2019 23:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559887961; cv=none; d=google.com; s=arc-20160816; b=tFbnbYbI/Dg5TNJSe/OZthsU7wLWIJVh+da1r6Yu7FcOn0xgVYs61/yxS6IVi6IGTl 64JJE/k7oE8zQS1yGnbe9jq8EKnFWAsaaja9IpZg4z3Mp3ZwGpOkdeOZL/PzhhlWYJlm 0xAJTnY0nVwr7k2guxQcVJZunJKkLGBp+1YbaRam/5Z/REY3C0znzvZmZKv67tJ+Lqgl JHtCnOLYOdLDwPrq9HqDqy/910i59ho7Xx5R/JMjkJhgTJW/zyaXOpLRqrB94f5aBP6X XmxEsXNNgLiqh7IZOptkx8rAAY4HM/xpL0xUUFF5OMVTlQG0eDV9qqylqCXuBbB6tegs fyvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:cc:to:subject:dkim-signature:dkim-filter; bh=+uR4qgy3oYGxG+0KpS+F/2Aej6rAjh5RXeKhbh9N708=; b=ZXBM7mWEo+EY3xNb8F5R3mD0An0lwi3dvqdykHkGJoGXnsGeKVjaXUsV6OzTP/ZFPR pGVALliqiw0TnZ5zAbg6xc+MRd/95DCRDPY5DLR2wqwBo9uNTCKQMRYWj7cgN2L32tB/ ldrtbx2YEVhNJPQiDjy11Lt6FEkSTnH+/LwQsIqujpEBHXGhHpKuvpjIaKdSK03asZuu I2HgE0b+TRHthDuGcr87+O+w4Gn/xlZpPwsttZsa/orPlzBjGheohxzoIqksGWI18hDs g2O3hylU5GsQh2tQh8cY1/TLSKaF3WBgmO56hnIQtElru2/ffJHlU+NJ46+gapCl2XM7 +7/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=t0CBwA4D; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d92si1042010pld.262.2019.06.06.23.12.25; Thu, 06 Jun 2019 23:12:41 -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; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=t0CBwA4D; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727064AbfFGGK5 (ORCPT + 99 others); Fri, 7 Jun 2019 02:10:57 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:35286 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726292AbfFGGK5 (ORCPT ); Fri, 7 Jun 2019 02:10:57 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190607061055euoutp01d59da50263a5ddc739b4d37468a0c76b~l1b1y4cdS2879028790euoutp01o for ; Fri, 7 Jun 2019 06:10:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190607061055euoutp01d59da50263a5ddc739b4d37468a0c76b~l1b1y4cdS2879028790euoutp01o DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1559887855; bh=+uR4qgy3oYGxG+0KpS+F/2Aej6rAjh5RXeKhbh9N708=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=t0CBwA4DqmDAGphyKeL4lji26zHP4IZJ54cNVOhqVx0LJsUN/pohoqo/Njd/lL0DT 00e9Q08Agn7X09NNvLABtLfaTlt+X4QNj/s7ycdjUcmjtoL3X6h1Be0DnG0WefeHee 956TRaMdMyswH1PRgJqIwCi+Ihp3Q8OAOeDGqxFg= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190607061054eucas1p131b508aac74138e2cbf72f6431562bdd~l1b0yNpKW0324403244eucas1p1J; Fri, 7 Jun 2019 06:10:54 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 45.35.04325.EEFF9FC5; Fri, 7 Jun 2019 07:10:54 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20190607061053eucas1p230b6bcfdf9fc1c35f966dda20a76fdd5~l1bzwq0f30856808568eucas1p2U; Fri, 7 Jun 2019 06:10:53 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20190607061053eusmtrp23fac0fbb5cffd1e0022737b402e1a61a~l1bzg2FxW1706517065eusmtrp2L; Fri, 7 Jun 2019 06:10:53 +0000 (GMT) X-AuditID: cbfec7f5-b8fff700000010e5-79-5cf9ffee5131 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id FF.A5.04140.DEFF9FC5; Fri, 7 Jun 2019 07:10:53 +0100 (BST) Received: from [106.120.51.74] (unknown [106.120.51.74]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20190607061052eusmtip19fc68647439cbb0ce77d31ed7cd81e83~l1by4bHMK2554825548eusmtip1a; Fri, 7 Jun 2019 06:10:52 +0000 (GMT) Subject: Re: [PATCH v4 09/15] drm/bridge: tc358767: Use reported AUX transfer size To: Andrey Smirnov , dri-devel@lists.freedesktop.org Cc: Laurent Pinchart , Tomi Valkeinen , Andrey Gusakov , Philipp Zabel , Cory Tusar , Chris Healy , Lucas Stach , linux-kernel@vger.kernel.org From: Andrzej Hajda Message-ID: <136db777-5d62-642b-a359-b06ade4518b8@samsung.com> Date: Fri, 7 Jun 2019 08:10:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190607044550.13361-10-andrew.smirnov@gmail.com> Content-Transfer-Encoding: 8bit Content-Language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA01SbUhTYRjtvfdu9zo3u27ansyKhhQFmX0Ql7Iv8cf9JRJBZgO76kVXOmXz swKHRi4ttQ8Nt0JXhqGlZmpOREhpM8RSjHILNyn/JNgkkzKcy+0a+e+c85zzvs95eSlcbhdF UBptHq/TclkqsYTosS292/vdt6SO8ZZJmTLjMaZ00CBifn8YIpjX/XaM+bDoETPTDx0Yc+N2 E8lM9D0QM1OuYYJpb3CKT0rY6VofxlpNUyRrNtaLWHelHWOrvTGsffIVxi50bmPf1Y5iiVSy JDadz9IU8Lp9xy9IMj1dFiy3fkvRJ88bwoDmwitQEAX0ITDecmIVSELJ6acIPi7UIIH8RHC3 7ppIIAurk5dtq4QKRMa79wp6M4IXFi8pkDkEjWU25D9XQZ+B9iaP2I/D6ET4UWoV+004PYJB ed9n3D8Q07vB+9IRMMno4zDfUxfQCToKHrfMBvRwOgnctg6R4AmFt/UzhB8H0SdgZNpO+jFO b4eybjMuYCU4ZxoChYB2kWCeGkdC03jo/z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wzmH7GCLEmlhVX5h5ilOBgVhLhLbvwI0aINyWxsiq1KD++qDQntfgQ oynQcxOZpUST84GpJK8k3tDU0NzC0tDc2NzYzEJJnLdD4GCMkEB6YklqdmpqQWoRTB8TB6dU A2Og2b0wH3k7ryuNW/MN1rN+Wt7/5t2W+qa397Knq8iXqH51vmE4d9FNoeo7ymcYSneqZfDb 7lt3ZNl6zX+NyqXLDl6wcv7mumbZ03uPBSWWa3M4sK/5UCmcUf9rWZ2ey7PHlhcy+Q/u3e76 oCh0LavojgkC1rLffipun/2qOu95q+2zdfGBFcVKLMUZiYZazEXFiQBN/buq7QIAAA== X-CMS-MailID: 20190607061053eucas1p230b6bcfdf9fc1c35f966dda20a76fdd5 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20190607044641epcas1p429ad931d59b2c1c083f41c29d86d1a12 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190607044641epcas1p429ad931d59b2c1c083f41c29d86d1a12 References: <20190607044550.13361-1-andrew.smirnov@gmail.com> <20190607044550.13361-10-andrew.smirnov@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Andrzej Hajda  -- Regards Andrzej > Cc: Andrzej Hajda > Cc: Laurent Pinchart > Cc: Tomi Valkeinen > Cc: Andrey Gusakov > Cc: Philipp Zabel > Cc: Cory Tusar > Cc: Chris Healy > Cc: Lucas Stach > Cc: dri-devel@lists.freedesktop.org > Cc: linux-kernel@vger.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: