Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6401358ybi; Wed, 5 Jun 2019 00:08:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzquh5Jyrkoi8yWteDvRMGttSYSPdgZIMrMIEL6/yqR92sQy9HDu7QmvuxFlqYMxaiH4ge5 X-Received: by 2002:a17:90a:b105:: with SMTP id z5mr42349782pjq.76.1559718487626; Wed, 05 Jun 2019 00:08:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559718487; cv=none; d=google.com; s=arc-20160816; b=R/7/gUsLsIkLzR8LNTWodcyLDOztxkaazENGY/abfESkD3GNhCX+Sx2kXYb3hzfMuI Jq9EuCIOHKJTlH1nhUJhcnK7m250oMSu+bTMqSRWu1Mso3rfqtooAMi4vesqpuZ/NgJA cV/8lgN8YNSH4PDXZJEtcO/hdIwJaCa8Bjda9uDlVdLmFAnQIweN65/RdfyWNqlcdK9o tPljpp7FrFwb2H3ftxVbYOSSHiZHysGq52OzPNs4c3H72hT+kDOFW6TIuC1LcY/bMsER yFIDX38rFjDLL3F5YhQgQHLS4ODQ+vIzKa4fbgp8yZliAqdqay2nlpo4sFtNqnakI4MC OXiQ== 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=QQDXy+HnUfgnkG61CQzmVPka5AA3kE5ajdtEw9kTzGA=; b=0wljD3rdIlLYp5fdgqBxHc6eXKCUOejRWG+WWDqgWL+Lo6EUcInCh0mhnsx3x4AYqp 14+KtTGiO0ErrjPeGoDfOn55vLaedCMZ60Q3cI2rqQKerWR/fK+nfyv3JqgCQgIeWwiS ltZmrkoi0SeqvRmH/lDnazG4NppZ6zqqdlAcKC3Zjg1ZkSqJox6v2am7S/NAEKGXMCGh nGYBj7EzXDEM476dfmdZbXC0pDyb3H4jXzCWdBxS5D2ZdgyAQLl7QqfKCN5aTOYkTEem qOm3rR296owhKEcSzibiGdt6L+bX7VWs+YpomKc3HlZMYYqJi/wXtqkqEGVg93VQ9vU6 v89w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="OVPIYke/"; 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 o188si25155252pgo.489.2019.06.05.00.07.50; Wed, 05 Jun 2019 00:08:07 -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="OVPIYke/"; 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 S1726820AbfFEHFk (ORCPT + 99 others); Wed, 5 Jun 2019 03:05:40 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:39282 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726777AbfFEHFg (ORCPT ); Wed, 5 Jun 2019 03:05:36 -0400 Received: by mail-pg1-f195.google.com with SMTP id 196so11881194pgc.6 for ; Wed, 05 Jun 2019 00:05:36 -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=QQDXy+HnUfgnkG61CQzmVPka5AA3kE5ajdtEw9kTzGA=; b=OVPIYke/b/AIKAzyPux8I7yZ7ovCGIn+2LxvLJt9s/ISoCcFERqZq3sO3IP56UsOKN 32Kv5LyNimcOqysNm/VvAy1lvohHuI9wnd1Ag9QdqzJbxy4G1msJDx/z+r6t3UOMKZTS byGyg1/N40tuVrl/IgqUahQXHjQ/JYxZU9EV1yz5iY7AjUJt0qvnpfstKDNZKCIFaVcK Mr078IyHi3Q50uvBDFu4F4rZeXw19PjqtoSxByzV4NxEKEwBlF/hIj3tIzAQTglMjYQW O8lW0mBBRysyn4RW4RtgTV1ihhMPC2wLQtfdSZlDiN5gDhF/nNrePEL4PConR1Fagd5D Dd6A== 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=QQDXy+HnUfgnkG61CQzmVPka5AA3kE5ajdtEw9kTzGA=; b=XNkILTYZnryeuJaeUUwuQqI8bV8Rn+TjV9SNcTtOwvUMW0qJ3ufaec8wYx8eUtV/sZ Lx7ayHpNoAo8o/ufvlAkoJuxXhZN2qGQVAAfbkuvMHQcHdOodKqJAp3hdkGgcpfwCLJv rI3O4Xd5EabW0LzOg6WrFk18bh87rpUhROqPWbPo1bLAG7R8yefq3r2zkLQVUWZilUZp Yue/k8NxwaTf5T+oxdk/GG7qOYmEhvbUCns90kTleF/1iOlKh+J0RW8RAHB+wVX7YKP4 IA8QlSyj7De9fPf70ky7Dflz3AK5IBj8IOs2eWI4wgZXK9NL2BqDELUWdNL+uWljjsWf C4OQ== X-Gm-Message-State: APjAAAX6LJlC3T1+N0ZN2KRs+hfHR6nYbNnnRvdEuylg/e1x5ChtO+bN PGyKS96A3E2DsXEtvHmpyCQ= X-Received: by 2002:a63:6111:: with SMTP id v17mr2444359pgb.206.1559718335807; Wed, 05 Jun 2019 00:05:35 -0700 (PDT) Received: from localhost.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id d132sm6527348pfd.61.2019.06.05.00.05.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jun 2019 00:05:35 -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 , Cory Tusar , Chris Healy , Lucas Stach , linux-kernel@vger.kernel.org Subject: [PATCH v3 09/15] drm/bridge: tc358767: Use reported AUX transfer size Date: Wed, 5 Jun 2019 00:05:01 -0700 Message-Id: <20190605070507.11417-10-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190605070507.11417-1-andrew.smirnov@gmail.com> References: <20190605070507.11417-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: 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 0125e2f7e076..90ec33caacbc 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) { @@ -376,6 +353,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) @@ -413,10 +391,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.21.0