Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2664121pxa; Mon, 17 Aug 2020 15:56:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwE33cAP5exY4V8GfVFsdViU68dbvSxnF74zn4QjQeuyICl2ZVeWF0ptuOaYrZ/8LERqTsA X-Received: by 2002:a17:906:24d0:: with SMTP id f16mr16824080ejb.325.1597705011395; Mon, 17 Aug 2020 15:56:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597705011; cv=none; d=google.com; s=arc-20160816; b=RNnvaGVn1gajJeSFqFgW3PNCC8AESQE4FTQ3WOhPjBaghxyP6DNM1PQ8KkAbKHnbxH qDne5RVLzoQb2AWgq0TDE7Q901tY+vImeTWa/53vt6YRgNFPJelyjfUkqkAQVhgwQX/m MCOFzZ5yG0zrjMWtuIW9HsflFk53Lw75OdE0ptASbg+OoTyBRQY4xGuHBoZCt0VW57zz jU/F080n1tsN0o1yRCxqsNjL2swc9y48JlQzHoWg3vJdFoxvWFyF/xrLl3BEMphBBcxL Tg1gfmDQnW2IG7CT/YyeFjClJoWwbiDemg2Qg/yYkwFPgy+fpQJC5rdFBEgPF+e5PJQT Dj/g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UpH2na77+HNf9cO9U1/vNt/X31Ad3HA22BZIgME9N/Q=; b=Mxokkln1Wql/cQptOZOOO/hS36fD1J2BMJ0MR4G/VZRvnlJ9Skio6kohugAqQLQHfH lnlEnyscw9LCw5ViyZaVpbAZ9MYXgXq2xgpvFIjFYvAegED0HxXo0KDuILFzDfafhlzE X4oGXNApC0/pDgdba4jsHCqgKFvtdTiGJCDHSYu75pEvGXbE7Cj/l08bfXcCX3SSfeoz ZfFEv4sdSoVVG9XXpA908/PvA5chjuWAH/aAEZusfQOlpZK55AXeROLNYP2QbOyCtFJa OdUe9g/bhuVTphYhFAye7o5c+gipWkk3ClyUD1tM88DbPF0dJrZ287795FuAAounF4Pw QNpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xTrvTOoH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b14si11648702eds.102.2020.08.17.15.56.27; Mon, 17 Aug 2020 15:56:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xTrvTOoH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732592AbgHQTnp (ORCPT + 99 others); Mon, 17 Aug 2020 15:43:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:50770 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729540AbgHQPX0 (ORCPT ); Mon, 17 Aug 2020 11:23:26 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 764AE2339E; Mon, 17 Aug 2020 15:23:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597677805; bh=4Abc2RcV96zkWCXOb26k7nxJQ2yw3b6kMzMkLIEkKJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xTrvTOoHxh35uO++C80GrPbYIkGZc8I8bqblo6MwpXmM1b1H7bdgvA6rj7VWYf8K3 VaFx7aVR+QWEBKB/0WBApd2WXY9rTwJAJadi6mFNtRSDEt2oC+u9+ioxhwzmeRGFSC frGnq+P/7p6FfKRoTJffQfd5yTnoSo/Mj4gi0Yh8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wenjing Liu , Jun Lei , Rodrigo Siqueira , Alex Deucher , Sasha Levin Subject: [PATCH 5.8 114/464] drm/amd/display: allow query ddc data over aux to be read only operation Date: Mon, 17 Aug 2020 17:11:07 +0200 Message-Id: <20200817143839.270709622@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wenjing Liu [ Upstream commit 26b4750d6cf84cb2b3f0a84c9b345e7b71886410 ] [why] Two issues: 1. Add read only operation support for query ddc data over aux. 2. Fix a bug where if read size is multiple of 16, mot of the last read transaction will not be set to 0. Signed-off-by: Wenjing Liu Reviewed-by: Jun Lei Acked-by: Rodrigo Siqueira Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- .../gpu/drm/amd/display/dc/core/dc_link_ddc.c | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c index aefd29a440b52..be8f265976b09 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c @@ -503,7 +503,7 @@ bool dal_ddc_service_query_ddc_data( uint8_t *read_buf, uint32_t read_size) { - bool ret = false; + bool success = true; uint32_t payload_size = dal_ddc_service_is_in_aux_transaction_mode(ddc) ? DEFAULT_AUX_MAX_DATA_SIZE : EDID_SEGMENT_SIZE; @@ -527,7 +527,6 @@ bool dal_ddc_service_query_ddc_data( * but we want to read 256 over i2c!!!!*/ if (dal_ddc_service_is_in_aux_transaction_mode(ddc)) { struct aux_payload payload; - bool read_available = true; payload.i2c_over_aux = true; payload.address = address; @@ -536,21 +535,26 @@ bool dal_ddc_service_query_ddc_data( if (write_size != 0) { payload.write = true; - payload.mot = false; + /* should not set mot (middle of transaction) to 0 + * if there are pending read payloads + */ + payload.mot = read_size == 0 ? false : true; payload.length = write_size; payload.data = write_buf; - ret = dal_ddc_submit_aux_command(ddc, &payload); - read_available = ret; + success = dal_ddc_submit_aux_command(ddc, &payload); } - if (read_size != 0 && read_available) { + if (read_size != 0 && success) { payload.write = false; + /* should set mot (middle of transaction) to 0 + * since it is the last payload to send + */ payload.mot = false; payload.length = read_size; payload.data = read_buf; - ret = dal_ddc_submit_aux_command(ddc, &payload); + success = dal_ddc_submit_aux_command(ddc, &payload); } } else { struct i2c_command command = {0}; @@ -573,7 +577,7 @@ bool dal_ddc_service_query_ddc_data( command.number_of_payloads = dal_ddc_i2c_payloads_get_count(&payloads); - ret = dm_helpers_submit_i2c( + success = dm_helpers_submit_i2c( ddc->ctx, ddc->link, &command); @@ -581,7 +585,7 @@ bool dal_ddc_service_query_ddc_data( dal_ddc_i2c_payloads_destroy(&payloads); } - return ret; + return success; } bool dal_ddc_submit_aux_command(struct ddc_service *ddc, @@ -598,7 +602,7 @@ bool dal_ddc_submit_aux_command(struct ddc_service *ddc, do { struct aux_payload current_payload; - bool is_end_of_payload = (retrieved + DEFAULT_AUX_MAX_DATA_SIZE) > + bool is_end_of_payload = (retrieved + DEFAULT_AUX_MAX_DATA_SIZE) >= payload->length; current_payload.address = payload->address; @@ -607,7 +611,10 @@ bool dal_ddc_submit_aux_command(struct ddc_service *ddc, current_payload.i2c_over_aux = payload->i2c_over_aux; current_payload.length = is_end_of_payload ? payload->length - retrieved : DEFAULT_AUX_MAX_DATA_SIZE; - current_payload.mot = !is_end_of_payload; + /* set mot (middle of transaction) to false + * if it is the last payload + */ + current_payload.mot = is_end_of_payload ? payload->mot:true; current_payload.reply = payload->reply; current_payload.write = payload->write; -- 2.25.1