From patchwork Wed Sep 18 20:26:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lipski, Mikita" X-Patchwork-Id: 11151229 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0FCF776 for ; Wed, 18 Sep 2019 20:27:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EB63C21920 for ; Wed, 18 Sep 2019 20:27:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB63C21920 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5A58F72AF3; Wed, 18 Sep 2019 20:27:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-eopbgr820075.outbound.protection.outlook.com [40.107.82.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id B149F72AF8; Wed, 18 Sep 2019 20:27:29 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KMsKz6hcvxdqwREiLl0MN5CRKU0nHKstiPLrVCERBmxymgnMgHC0a0OOfc2ft6cxj3F5wKFgS7XhIjLM8iazydZlI9AGKppTPX+NFCXVT08Ol50N4vUUumpiUFIiuO56voVY53HMFv86i1k/ckMf5K3WvkEh77qOMUw60Isy5Qs/cB55hTUUNK7IErhZ5XbXb2oAKPghp9PhziTinZeeGw5sh7Z2N4HGripj1b65g/nci9i2/aTzd407yAEOgvAoQdZY134rbuQp+pFPbIU3Vd6KUN83/o8l+dxfUInOnlaxcwgmB/N0mfkPxsVQW2tGZj/fTNBhZ/9r3AuFG3NY5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2CTGIpqzXImTeOTQD+i2qD0T6LR8r6uGNwp+nWgqSMo=; b=Q/ftBafBT1iMK4DlvYwxN4HzF7ordu5vey1giK3DXYv/m1d3AOiA2RGaku6rBQtMlX4uVYnruMpLNcQRHE4GA2HbexMbEP+WqaMe0Rea8/IFTjCrWovJMIPz030k+EYgbrGO2HOkVrJTHa3z6mfqwmMiqz22LfMVZc5Acgyw+Pn4lhxR7odogOuLhcCV6JG5a0Opt2bOMZD/iiPtk79do/VpGlLDZxveMu66tmGC4nYSb0vOww+IJ4x546td5UAbTxO90Oyxps4KCb43HCBae2ZrCG+HppGjiUfNTvES5T2S708++u9ZZUNWUMzgHPbwerifIkfO7rFq1mlgwSXyXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=permerror action=none header.from=amd.com; dkim=none (message not signed); arc=none Received: from CH2PR12CA0006.namprd12.prod.outlook.com (2603:10b6:610:57::16) by MWHPR12MB1805.namprd12.prod.outlook.com (2603:10b6:300:106::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.16; Wed, 18 Sep 2019 20:27:26 +0000 Received: from DM3NAM03FT014.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::204) by CH2PR12CA0006.outlook.office365.com (2603:10b6:610:57::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20 via Frontend Transport; Wed, 18 Sep 2019 20:27:26 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by DM3NAM03FT014.mail.protection.outlook.com (10.152.82.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2263.14 via Frontend Transport; Wed, 18 Sep 2019 20:27:26 +0000 Received: from mlipski-pc.amd.com (10.180.168.240) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.389.1; Wed, 18 Sep 2019 15:27:24 -0500 From: To: Subject: [PATCH 06/15] drm/dp_mst: Add MST support to DP DPCD R/W functions Date: Wed, 18 Sep 2019 16:26:43 -0400 Message-ID: <48e5fd874caac1d8925626bb5b91d7244b819052.1568833906.git.mikita.lipski@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(396003)(136003)(376002)(346002)(39860400002)(428003)(199004)(189003)(476003)(8936002)(48376002)(6916009)(50226002)(54906003)(81166006)(81156014)(8676002)(4326008)(5660300002)(16586007)(316002)(446003)(11346002)(2616005)(336012)(426003)(118296001)(450100002)(26005)(36756003)(14444005)(186003)(2906002)(478600001)(50466002)(47776003)(2351001)(486006)(305945005)(53416004)(7696005)(126002)(2876002)(70206006)(86362001)(70586007)(76176011)(356004)(6666004)(51416003)(16060500001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1805; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 594ad33e-cae6-44f1-5dce-08d73c769ea7 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(4618075)(2017052603328); SRVR:MWHPR12MB1805; X-MS-TrafficTypeDiagnostic: MWHPR12MB1805: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-Forefront-PRVS: 01644DCF4A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: J2j0i4ZqRJdxTJml1v7rXfyeiPiWkOzBp6eMVl6S114Fvnq1OEtlSXV5YM26Q7sy+OEjrefSR1ezcvu3PG8ZjyRd+eDfr1Cd/VdrC8gelDe07W4bUkcso3DdsIsq3pJtXDdIZkWBVMR7/f3ZLMe4ji8E7/Ty0REo84YmJPBnSth6Ydf7ZlrMOGIDYLFZma+HP0ti8RJoOdMK0GhaC/inzefLoUFjMEq9dzHC3zqz5fCnStv6Ja/EBY/zpIx8chLEFTKR7zSUWAvcl+hAi+6wTeZazxvF0jFMuNFS3thbYq5IDRI5N1fmIWNVANdejtNf+7k4lARkidFEFPRJxXf97sJF5EPMlrd9S9+X49Lo7iZleE6SmIc697B8nzzFaNnWC4vphq3v21s43NNAiLDp8hkHCxUMqXkYPzMjT4UIgdE= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2019 20:27:26.0689 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 594ad33e-cae6-44f1-5dce-08d73c769ea7 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1805 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2CTGIpqzXImTeOTQD+i2qD0T6LR8r6uGNwp+nWgqSMo=; b=xKB5dQ72MXHJtgYYtTOj1gUTytWEnG6frMVjc9zMuH8FDbRFcYkMIfgAtZLzCNonmkFrpyTk3E6YRgNzMXGdwvGPbcA5XvP7/D9M6BXCI9lVLV9+Y6ibdlyjeEWKp92Tr9euqKXvO5tAeuegJqMR0/KmqPrk7mQOMEFCAuQ+Kgk= X-Mailman-Original-Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=permerror action=none header.from=amd.com; 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: David Francis , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: David Francis Instead of having drm_dp_dpcd_read/write and drm_dp_mst_dpcd_read/write as entry points into the aux code, have drm_dp_dpcd_read/write handle both. This means that DRM drivers can make MST DPCD read/writes. v2: Fix spacing v3: Dump dpcd access on MST read/writes Reviewed-by: Lyude Paul Reviewed-by: Harry Wentland Signed-off-by: David Francis --- drivers/gpu/drm/drm_dp_aux_dev.c | 12 ++---------- drivers/gpu/drm/drm_dp_helper.c | 30 ++++++++++++++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_aux_dev.c b/drivers/gpu/drm/drm_dp_aux_dev.c index 00610bd8d6c1..0780fc358389 100644 --- a/drivers/gpu/drm/drm_dp_aux_dev.c +++ b/drivers/gpu/drm/drm_dp_aux_dev.c @@ -162,11 +162,7 @@ static ssize_t auxdev_read_iter(struct kiocb *iocb, struct iov_iter *to) break; } - if (aux_dev->aux->is_remote) - res = drm_dp_mst_dpcd_read(aux_dev->aux, pos, buf, - todo); - else - res = drm_dp_dpcd_read(aux_dev->aux, pos, buf, todo); + res = drm_dp_dpcd_read(aux_dev->aux, pos, buf, todo); if (res <= 0) break; @@ -214,11 +210,7 @@ static ssize_t auxdev_write_iter(struct kiocb *iocb, struct iov_iter *from) break; } - if (aux_dev->aux->is_remote) - res = drm_dp_mst_dpcd_write(aux_dev->aux, pos, buf, - todo); - else - res = drm_dp_dpcd_write(aux_dev->aux, pos, buf, todo); + res = drm_dp_mst_dpcd_write(aux_dev->aux, pos, buf, todo); if (res <= 0) break; diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c index 54a6414c5d96..0cbf10727bd6 100644 --- a/drivers/gpu/drm/drm_dp_helper.c +++ b/drivers/gpu/drm/drm_dp_helper.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include "drm_crtc_helper_internal.h" @@ -272,7 +273,7 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request, /** * drm_dp_dpcd_read() - read a series of bytes from the DPCD - * @aux: DisplayPort AUX channel + * @aux: DisplayPort AUX channel (SST or MST) * @offset: address of the (first) register to read * @buffer: buffer to store the register values * @size: number of bytes in @buffer @@ -301,13 +302,18 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset, * We just have to do it before any DPCD access and hope that the * monitor doesn't power down exactly after the throw away read. */ - ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, DP_DPCD_REV, buffer, - 1); - if (ret != 1) - goto out; + if (!aux->is_remote) { + ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, DP_DPCD_REV, + buffer, 1); + if (ret != 1) + goto out; + } - ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, buffer, - size); + if (aux->is_remote) + ret = drm_dp_mst_dpcd_read(aux, offset, buffer, size); + else + ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, + buffer, size); out: drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, buffer, ret); @@ -317,7 +323,7 @@ EXPORT_SYMBOL(drm_dp_dpcd_read); /** * drm_dp_dpcd_write() - write a series of bytes to the DPCD - * @aux: DisplayPort AUX channel + * @aux: DisplayPort AUX channel (SST or MST) * @offset: address of the (first) register to write * @buffer: buffer containing the values to write * @size: number of bytes in @buffer @@ -334,8 +340,12 @@ ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset, { int ret; - ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_WRITE, offset, buffer, - size); + if (aux->is_remote) + ret = drm_dp_mst_dpcd_write(aux, offset, buffer, size); + else + ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_WRITE, offset, + buffer, size); + drm_dp_dump_access(aux, DP_AUX_NATIVE_WRITE, offset, buffer, ret); return ret; }