From patchwork Tue Dec 3 14:35:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lipski, Mikita" X-Patchwork-Id: 11271413 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 15937138C for ; Tue, 3 Dec 2019 14:36:02 +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 F22FE20659 for ; Tue, 3 Dec 2019 14:36:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F22FE20659 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 64E346E794; Tue, 3 Dec 2019 14:35:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-eopbgr760071.outbound.protection.outlook.com [40.107.76.71]) by gabe.freedesktop.org (Postfix) with ESMTPS id 54BF56E794; Tue, 3 Dec 2019 14:35:45 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OeYTHjeEtwmX24R027dm4NzxqlOU6o8ePUTwFsMfnNlaBMVhf8kD17SwSt5MXUSgQc+MTxIBdJp5NuY/6WDimV4/Q1BsedrLaLDtBaaX0y7mvDpnVlo1qQXlx20ABc+oRTP0Vxe1WFebRywUMFiN+Hw4EYYeaqspc41IXB7sWNqappaBkBWGnD/m58hU/TMv3RcWLRAuGvQe6Jg7Ko/ANbVz9L/N+nHZxT/bxwfGV7c7bzzLi6804NC4u1EqLU+KgyEQeeFCvWuuHcw9MoId/vheAs++3GDwIYZrd59omcyV3LPAt2GvSi8jSL7E+r0SCuqQ4PTqll4PSD/Ip5bq+A== 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=LkXIeU5cUmVLADhdjOnrIFma4xF0glStBcMFDZqZfY4=; b=P8P4/50vD29WCyBpEMKDrO1aYD+F5KqeaxySF9v+l+xUknw/P87bppEVjjl0N1nAzjJpEMCISWzDJ8XS4TnfoRdzr9lQxXHDegSlaqD7Vlj0XMZ6LB8IaYwCenkeDi+qoT3a3FMUI/Dr7p5/+vROsaChB/1nfTQ49OUMEcdhpTDqDcxoQxS8meOqQhRwlFmuJayOH8Iqhgmi66WJvJGmt/pFYlyUOQmiz1mmLYLdzwX6kw7WvVCLwLKSISCo+SZJSKOh+NvRIGvOjb/KQNK5zJRGxNuBIt4Mf28gKp0pDWQtQwHtLks8n+2dFHomYrRPSsujFgwHECmhB3Xmb1hdbg== 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 DM6PR12CA0027.namprd12.prod.outlook.com (2603:10b6:5:1c0::40) by BN8PR12MB3537.namprd12.prod.outlook.com (2603:10b6:408:6d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2495.22; Tue, 3 Dec 2019 14:35:43 +0000 Received: from DM6NAM11FT054.eop-nam11.prod.protection.outlook.com (2a01:111:f400:7eaa::202) by DM6PR12CA0027.outlook.office365.com (2603:10b6:5:1c0::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2495.18 via Frontend Transport; Tue, 3 Dec 2019 14:35:43 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXMB02.amd.com (165.204.84.17) by DM6NAM11FT054.mail.protection.outlook.com (10.13.173.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2451.23 via Frontend Transport; Tue, 3 Dec 2019 14:35:43 +0000 Received: from SATLEXMB01.amd.com (10.181.40.142) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 3 Dec 2019 08:35:42 -0600 Received: from mlipski-pc.amd.com (10.180.168.240) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Tue, 3 Dec 2019 08:35:41 -0600 From: To: Subject: [PATCH v8 03/17] drm/dp_mst: Add MST support to DP DPCD R/W functions Date: Tue, 3 Dec 2019 09:35:16 -0500 Message-ID: <20191203143530.27262-4-mikita.lipski@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191203143530.27262-1-mikita.lipski@amd.com> References: <20191203143530.27262-1-mikita.lipski@amd.com> 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)(376002)(136003)(346002)(39860400002)(428003)(189003)(199004)(336012)(450100002)(305945005)(54906003)(2351001)(81166006)(8676002)(16586007)(5660300002)(70586007)(70206006)(81156014)(426003)(50466002)(446003)(11346002)(36756003)(8936002)(48376002)(316002)(2616005)(50226002)(478600001)(1076003)(6916009)(26005)(86362001)(53416004)(2876002)(2906002)(356004)(51416003)(6666004)(14444005)(4326008)(76176011)(186003)(7696005)(16060500001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN8PR12MB3537; H:SATLEXMB02.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 12678698-0106-4dfe-4593-08d777fe13bb X-MS-TrafficTypeDiagnostic: BN8PR12MB3537: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-Forefront-PRVS: 02408926C4 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uZ9m6boa1kxhEj2h6QG0KpB4TcggCRGKzfu32tRdVgfkUCWVlbve+zWUULv8iAK12qe538GuP4Am4Sto0JGji4/4o28JOfEYTxhrmpErTOE1hCtIMmsHLlm/3dgbkb17InxK03NZLWLoSFw361lxW4S1t3Et9jHx1wm1r2V2l8+tTmS02uaggKvE6NnBZ93QmHR1f+RALI8qX21POvjUhnXVRQORovlN+jdqDKt7iBntfh8hFa+j5rs0j5ESzqzVJ4GvSHSVs/qd2y1FhtfyLWTz+F9eYj6BoPKSP5VdclFauZ0IermbJYLcM7pl9t5yFlL5rx7Ia2+KKQhMiceUwyiL1yiMKa+Y7yO5jaYcY7/onjGF0nNoID4XCsIpJXkM/ngzTV6nDNWJkQQnyuPZGXGcbMnoeLAxT64dhz9mEUML2GkSFuDxyEnn61h0SJ/O X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2019 14:35:43.1812 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 12678698-0106-4dfe-4593-08d777fe13bb 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=[SATLEXMB02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3537 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=LkXIeU5cUmVLADhdjOnrIFma4xF0glStBcMFDZqZfY4=; b=YBb9dl8AL3B2l2XUBcBDuyeIVGVuN/QsA9g3rkO5gs8id7zqS0sjyPaxoE07hEK8tbUhB8VSABEZDLj7DvINHEw1jIX8JtcXAvKm5difPHmSS4jjuitKrCej1bPv4RNeBw2HJqkMkIfS+rUdTK3oyBnCkAdtE67O+rWCDSEVfMw= 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 , Mikita Lipski , 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 v4: Fix calling wrong function on DPCD write v5: delete deprecated include of drmP.h Reviewed-by: Lyude Paul Reviewed-by: Harry Wentland Signed-off-by: David Francis Signed-off-by: Mikita Lipski --- 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 0cfb386754c3..2510717d5a08 100644 --- a/drivers/gpu/drm/drm_dp_aux_dev.c +++ b/drivers/gpu/drm/drm_dp_aux_dev.c @@ -163,11 +163,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; @@ -215,11 +211,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_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 2c7870aef469..2faef8bd911f 100644 --- a/drivers/gpu/drm/drm_dp_helper.c +++ b/drivers/gpu/drm/drm_dp_helper.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "drm_crtc_helper_internal.h" @@ -266,7 +267,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 @@ -295,13 +296,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); @@ -311,7 +317,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 @@ -328,8 +334,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; }