From patchwork Wed Jun 12 08:32:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10991273 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9611E14E5 for ; Thu, 13 Jun 2019 07:28:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84D9E204C1 for ; Thu, 13 Jun 2019 07:28:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78F692887B; Thu, 13 Jun 2019 07:28:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0FC41204C1 for ; Thu, 13 Jun 2019 07:28:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BA3148932D; Thu, 13 Jun 2019 07:28:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by gabe.freedesktop.org (Postfix) with ESMTPS id 607468945B for ; Wed, 12 Jun 2019 08:33:20 +0000 (UTC) Received: by mail-pl1-x643.google.com with SMTP id e5so6323667pls.13 for ; Wed, 12 Jun 2019 01:33:20 -0700 (PDT) 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=0YhRw4hEvpmSGYGOKHYPQ23PiOFrqYfjvT/vGeo0Ytk=; b=pe0nsjSSzLyqVu5XIRynQJY2LfI2IihF6njJIqJP4/gDHR0yehgPVJrEUnfpiWCLqP uVYSrJvOBtanfyxnZLRjgHfG7llVCw4tkE+K6M/V1guQ5kfSkt7S7nwOltNWQsbelF6m sYP/qm9vvlBjqP1LBNUd+XzTYUx4G578Z42c0sxYpOnhx2hSoFq/ejQlpvvSP1HD11M5 q50FI0EaSMGg6/hlHhcFuQSTf7Rb2YZGy1/NjfhrkDAYxPedWKClg9l/oBJajAEOt452 F7LkXyi7WBXt7t7LkS6k5rls4pmBvWlknQls8D5Di1v4LIdoQ9U5YDrKgxR2MVr2p2Bo 2r2A== X-Gm-Message-State: APjAAAWiNfBNxLDfoweZD7MfCsuvgE4/mA3H1uldUX60DeuAFzkCxWG2 kbtMCgt71MpDXjplyPHYzJWAFn9J8Hs= X-Google-Smtp-Source: APXvYqxNd+3bddyt8ZF2XKgqmfXEeaJ0OBYolrQrsl39gZ2dsWVHqX3VJMTCzuS8x8EdNCUpWLX7jw== X-Received: by 2002:a17:902:a5ca:: with SMTP id t10mr74835974plq.98.1560328399576; Wed, 12 Jun 2019 01:33:19 -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 d21sm18845991pfr.162.2019.06.12.01.33.18 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 12 Jun 2019 01:33:18 -0700 (PDT) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Subject: [PATCH v5 09/15] drm/bridge: tc358767: Use reported AUX transfer size Date: Wed, 12 Jun 2019 01:32:46 -0700 Message-Id: <20190612083252.15321-10-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190612083252.15321-1-andrew.smirnov@gmail.com> References: <20190612083252.15321-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 13 Jun 2019 07:27:23 +0000 X-Mailman-Original-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=0YhRw4hEvpmSGYGOKHYPQ23PiOFrqYfjvT/vGeo0Ytk=; b=B5ArIorW4kXUtotbiOSJZwDJYP7HvorMRv9fSyfiWmdqxHC5e7OoAMMhuSlWXUYaT2 FJ6IZz+9qUuMMMiwovhnQb/UC3cX+04PT2knYH+20j2RdRDWyb7DR+FIFx+ArvPTEUW2 P92YS+6ZTDAzx63s4O99vsGjmY8UxCxVEPqB6okZDv2d1fE5kue4VbbZCqe5WNAPsiYR 4iTcYNskJZTGLhXpyo3hhiTTSO9qv/hUxCQSOd+gKMLwnmf/CefIpWbMk/Wyk+++zYTO Ie8gtPMsPJ3Zu6nPO10sebfZ/yNZJJFZqXkFeX880K/lznxNmBX6X17A8JSwvgHqN2n3 Crpw== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cory Tusar , Andrey Smirnov , Andrey Gusakov , linux-kernel@vger.kernel.org, Tomi Valkeinen , Laurent Pinchart , Chris Healy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 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: