Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp284760img; Thu, 21 Mar 2019 20:31:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzoAQ0cMd5CvNI++Rm+MwtSCIfY5CtYcyhR6TgAuefXo3DJ8roP3EpSYzQXn+60jYnzizwR X-Received: by 2002:a63:1060:: with SMTP id 32mr6771074pgq.126.1553225483460; Thu, 21 Mar 2019 20:31:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553225483; cv=none; d=google.com; s=arc-20160816; b=nUxVi/BPiSUPLxliJ2cEiIg8FPmQ0XSw0O79XInMaC8iJNPa5SATi6rQT/4vDqz8WG JbpqMUu9oMxqH5m8md1m9h3DlPoCBMgzkwg6Zr2Tog5g2uD7Vifrf81FLh3r4G3jvvK5 zU+7FXXyuXiJ7WnBBuhhvEd6wvZ1yP6V5sDvTr/jCvUq3g0V1JVC6FHAeW1YyofNlCE6 nKvQapbYpLqob2TPQNIyez8AblajuqAGLxUBd+5BqlZNyqmtJOjNYob5ZgysJI+W3cDv NicEHfd5mwizyq8SLVIgdhNULDWjl3K3kZhu+kL8g430zVsf1P47umWM2WiuSkq+QmZZ 3cQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=INRHOGy/wyO5pYqIz/meaocRgOP5THaNDqBF/skxbt4=; b=dkl7O6XrZW6TQFePB7MnXsrMrwKFXG1fWl9fw1AQ4qm/WN7lsjqnhWg1RUDfQKSOG3 h+T3ymPn3vFdFwx1zo8gegWHxhsQEiMIBMLouEzoExh9/vW60+GddMSqKdZ/WpeJHK2v OQOl6pPEBuS8Zpuy2l2aMEot1ChkBuga6nyvFAwaqf+faKvAgac2FwN6Tavl7M3czFb+ NhHqnqbrYh6kT7asuGGWvlTAYQH+PCP9LJe3lLKFtTzLn6lMWcaTjV0sJaVnnemY+z1d KqqRHpLEuzH+IgNtBkdw00LXAchRaJodd7vJWLQ1QQPOGtt5x5CkrkP25iCywo6wJ8Em zE8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Yq0k8Pei; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e9si6224964plb.99.2019.03.21.20.31.08; Thu, 21 Mar 2019 20:31:23 -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=@gmail.com header.s=20161025 header.b=Yq0k8Pei; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727820AbfCVDaF (ORCPT + 99 others); Thu, 21 Mar 2019 23:30:05 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34742 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727707AbfCVD31 (ORCPT ); Thu, 21 Mar 2019 23:29:27 -0400 Received: by mail-pf1-f196.google.com with SMTP id v64so547813pfb.1 for ; Thu, 21 Mar 2019 20:29:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=INRHOGy/wyO5pYqIz/meaocRgOP5THaNDqBF/skxbt4=; b=Yq0k8PeiQl3yK/RRqk7tB5Tpq9qP39QD/K7vz5XiXmREuzE1jjheXMwsDzj3UnAB4R tbA0rW/cLjNP7uLbzFH0sJ6ed4UqGfmPiXZ/Q8Xq8cvvwrZaH3aMST6qsod5XyFefp7c D+PwVn9hv7Vvmub0TGfZfRhXvYXe0TIBPhHdtQLlj0dfkHshQ799o7WbbSs4bZB6TGkC ajGAm8Eyq5QMESZuTqTjP9hGDALze1DcsdG7zdvtfp3OdnXVxoz0EHyG6/+o7MnfJ4ub oeY9yiXnziM7Ob5Ea3YgB6NcraTnYNZRx5KA55TpLyfuNmPhKNCtx3P6wSbWyl2ThoU0 4UhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=INRHOGy/wyO5pYqIz/meaocRgOP5THaNDqBF/skxbt4=; b=Zjv7mRkwSoSs4LdlyTurlEAuqxjWIQwXNRQGVQNM1MwxKN6GWGshiabjNSCWZndo4H NcIhdG6i5WhdK8uufrqaewXd2VHYpz5Y4SbF2Ot3uz3WKFvvYSPkT2NEEWn7C/KgrkKM Tx6/UMtGwy1Q26hGUXmVkkM+j2Zq1YE566YT4k7eWL3TCvILgkUz482ctT9NgIDJ9HT5 0wV1FziDjl+vsX6OXjfIKetMNkYd5TlFzRskXLALMPtxOVdJxEAKqmiQ1mi02iG57ytz 6jHVV1t3n0sXYQYHu5PnyYOfkjaRKP1SIb6AgFLeb8LzUOkaCR4GSuaHR+NKfE75bwCC kIfg== X-Gm-Message-State: APjAAAV5wj0ZCLPNiJWl6+Pb4hbzDggnSgD6SDuY1714jhNJ5Enyt8bq jAQcTyCKy2+FBqk9TyEx11E= X-Received: by 2002:a65:43c7:: with SMTP id n7mr6796715pgp.173.1553225366880; Thu, 21 Mar 2019 20:29:26 -0700 (PDT) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id o76sm16154476pfa.156.2019.03.21.20.29.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2019 20:29:26 -0700 (PDT) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Cc: Andrey Smirnov , Archit Taneja , Andrzej Hajda , Laurent Pinchart , Tomi Valkeinen , Andrey Gusakov , Philipp Zabel , Chris Healy , Lucas Stach , linux-kernel@vger.kernel.org Subject: [PATCH v2 09/15] drm/bridge: tc358767: Use reported AUX transfer size Date: Thu, 21 Mar 2019 20:28:55 -0700 Message-Id: <20190322032901.12045-10-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190322032901.12045-1-andrew.smirnov@gmail.com> References: <20190322032901.12045-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Archit Taneja Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Tomi Valkeinen Cc: Andrey Gusakov Cc: Philipp Zabel 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 8adaac5ca271..7e4607c6907f 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -144,10 +144,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 */ @@ -284,29 +284,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) { @@ -360,6 +337,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) @@ -397,10 +375,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: -- 2.20.1