From patchwork Fri Apr 4 19:58:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 3940611 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7CD0CBFF02 for ; Fri, 4 Apr 2014 19:58:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 974B5203B6 for ; Fri, 4 Apr 2014 19:58:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 948C220396 for ; Fri, 4 Apr 2014 19:58:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 90AF36EDF0; Fri, 4 Apr 2014 12:58:46 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qa0-f46.google.com (mail-qa0-f46.google.com [209.85.216.46]) by gabe.freedesktop.org (Postfix) with ESMTP id 369636E09E for ; Fri, 4 Apr 2014 12:58:45 -0700 (PDT) Received: by mail-qa0-f46.google.com with SMTP id dc16so396478qab.19 for ; Fri, 04 Apr 2014 12:58:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=s5dpdJz/N1VwksVyi2AXnqqZI5PShmL0mcMg6ZfSzsg=; b=EbY1LTvuhxkDZLUxlDIxcHvqiniRuozk4hJPtIj1boKI/lKS+n6W0drPibrwAuvbO7 KeecBmt50qJ390rtELSulpYrI74ewIn4D1K6AkBjk6e2vw15gHzY181nk5m884hpOd6o frdSz4hkdS1aFgM9jV0Sq5YU82Aza/ehnlF4Wy4zLMNhxWaJ4l/0LBVg4XDV3f+P4Nls YHCT3mOdlJeKE7W/VnEKzoN0BY/rCvUvovIPtM/kKDAAACTHhhFNfvg8ewd1JZQwXcTq GhjDKnwy3F0JnEGUzvtQnFr7R5O0pOGUwB7cI/GNvb5PMnNk+C5TzLSxnDA0IYhJbPHd VwfA== X-Received: by 10.224.114.130 with SMTP id e2mr16628539qaq.53.1396641524777; Fri, 04 Apr 2014 12:58:44 -0700 (PDT) Received: from localhost.localdomain (static-74-96-105-49.washdc.fios.verizon.net. [74.96.105.49]) by mx.google.com with ESMTPSA id z8sm18106968qaw.17.2014.04.04.12.58.44 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Fri, 04 Apr 2014 12:58:44 -0700 (PDT) From: Alex Deucher To: dri-devel@lists.freedesktop.org, jani.nikula@linux.intel.com, ville.syrjala@linux.intel.com, treding@nvidia.com Subject: [PATCH 1/4] drm/radeon/dp: handle zero sized i2c over aux transactions Date: Fri, 4 Apr 2014 15:58:36 -0400 Message-Id: <1396641519-18529-2-git-send-email-alexander.deucher@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1396641519-18529-1-git-send-email-alexander.deucher@amd.com> References: <1396641519-18529-1-git-send-email-alexander.deucher@amd.com> Cc: Alex Deucher X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Needed for proper i2c over aux handling for certain monitors and configurations (e.g., dp bridges or adapters). Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/atombios_dp.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c index 8b0ab17..e914008 100644 --- a/drivers/gpu/drm/radeon/atombios_dp.c +++ b/drivers/gpu/drm/radeon/atombios_dp.c @@ -143,6 +143,7 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan, } #define HEADER_SIZE 4 +#define BARE_ADDRESS_SIZE 3 static ssize_t radeon_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) @@ -160,13 +161,16 @@ radeon_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) tx_buf[0] = msg->address & 0xff; tx_buf[1] = msg->address >> 8; tx_buf[2] = msg->request << 4; - tx_buf[3] = msg->size - 1; + tx_buf[3] = msg->size ? (msg->size - 1) : 0; switch (msg->request & ~DP_AUX_I2C_MOT) { case DP_AUX_NATIVE_WRITE: case DP_AUX_I2C_WRITE: tx_size = HEADER_SIZE + msg->size; - tx_buf[3] |= tx_size << 4; + if (msg->size == 0) + tx_buf[3] |= BARE_ADDRESS_SIZE << 4; + else + tx_buf[3] |= tx_size << 4; memcpy(tx_buf + HEADER_SIZE, msg->buffer, msg->size); ret = radeon_process_aux_ch(chan, tx_buf, tx_size, NULL, 0, delay, &ack); @@ -177,7 +181,10 @@ radeon_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) case DP_AUX_NATIVE_READ: case DP_AUX_I2C_READ: tx_size = HEADER_SIZE; - tx_buf[3] |= tx_size << 4; + if (msg->size == 0) + tx_buf[3] |= BARE_ADDRESS_SIZE << 4; + else + tx_buf[3] |= tx_size << 4; ret = radeon_process_aux_ch(chan, tx_buf, tx_size, msg->buffer, msg->size, delay, &ack); break; @@ -186,7 +193,7 @@ radeon_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) break; } - if (ret > 0) + if (ret >= 0) msg->reply = ack >> 4; return ret;