From patchwork Fri Apr 12 16:05:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Li X-Patchwork-Id: 10898679 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 473A117E6 for ; Fri, 12 Apr 2019 16:05:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D26828E96 for ; Fri, 12 Apr 2019 16:05:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2186D28EA1; Fri, 12 Apr 2019 16:05:50 +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,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 BBC2128E96 for ; Fri, 12 Apr 2019 16:05:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BAA03899B0; Fri, 12 Apr 2019 16:05:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-eopbgr740042.outbound.protection.outlook.com [40.107.74.42]) by gabe.freedesktop.org (Postfix) with ESMTPS id 02B85899B0; Fri, 12 Apr 2019 16:05:48 +0000 (UTC) Received: from DM3PR12CA0057.namprd12.prod.outlook.com (2603:10b6:0:56::25) by MN2PR12MB3469.namprd12.prod.outlook.com (2603:10b6:208:ca::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1792.16; Fri, 12 Apr 2019 16:05:45 +0000 Received: from BY2NAM03FT041.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::209) by DM3PR12CA0057.outlook.office365.com (2603:10b6:0:56::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1792.15 via Frontend Transport; Fri, 12 Apr 2019 16:05:45 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV02.amd.com (165.204.84.17) by BY2NAM03FT041.mail.protection.outlook.com (10.152.85.246) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1771.16 via Frontend Transport; Fri, 12 Apr 2019 16:05:45 +0000 Received: from SATLEXDAG04.amd.com (10.181.40.9) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server (TLS) id 14.3.389.1; Fri, 12 Apr 2019 11:05:44 -0500 Received: from leodev.amd.com (10.180.168.240) by satlexdag04.amd.com (10.181.40.9) with Microsoft SMTP Server id 14.3.389.1; Fri, 12 Apr 2019 12:05:43 -0400 From: To: , Subject: [PATCH 1/2] drm/dp_aux: Use non-cyclic idr, add suffix option for aux device Date: Fri, 12 Apr 2019 12:05:30 -0400 Message-ID: <1555085131-8716-2-git-send-email-sunpeng.li@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1555085131-8716-1-git-send-email-sunpeng.li@amd.com> References: <1555085131-8716-1-git-send-email-sunpeng.li@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)(346002)(39860400002)(136003)(396003)(376002)(2980300002)(428003)(189003)(199004)(2876002)(6666004)(356004)(5660300002)(486006)(2906002)(68736007)(81166006)(81156014)(8676002)(50466002)(86362001)(50226002)(48376002)(8936002)(305945005)(336012)(186003)(77096007)(26005)(53416004)(110136005)(446003)(426003)(11346002)(126002)(476003)(2616005)(316002)(53936002)(16586007)(97736004)(7696005)(51416003)(76176011)(86152003)(47776003)(36756003)(4326008)(106466001)(72206003)(14444005)(54906003)(105586002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR12MB3469; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 00bc1fb1-ee85-4a00-aed1-08d6bf60b8a3 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600139)(711020)(4605104)(2017052603328); SRVR:MN2PR12MB3469; X-MS-TrafficTypeDiagnostic: MN2PR12MB3469: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 0005B05917 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: Us6vgS3hInFNh4Zhk2Gs+VpzyBKvHac7YaHhRu7spwTTwAnOTRCsegkEAUB1dzL82871K0Mu5Zx8T39qY85wJgC/uBCkSwJPSerI6FYGoHWOwmUoghSJCzTzEyq5rzAo4+cLLkHHkPMbTVmQ+fApHe9Q57qzrdq43ZG8Mf3FT3T+3MknNXLewaOC3focDsZQUAhq+FtT7e3qC83r/NVVvoUK7FqInOcIGS/5AZRNgy1yrvUW2xr2rsMXGxFzzO77qI/FXHtb/VFerUpaSO4bmDEb0fBfyzDmuk014vIZYmNBc3F86Jwcs+Z1mcKMZJFNNNQnEVbrxm74L2kqOQ7srcgxyxUY6DunDliIFUyb3Ldj3XkWjwftEgsaQFefDi5ykGnbFsDSZKfB3/PL5vAYzt8eR38eDp93QH6U5aGNEWQ= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2019 16:05:45.3092 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 00bc1fb1-ee85-4a00-aed1-08d6bf60b8a3 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=[SATLEXCHOV02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3469 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=us8DtpekqnhG2Jnpw7oe2B42SX0EfIa9YIkGh2J/JCI=; b=qxzAnLz6hsBo2L4FrmcOviyya6Mz28dx32yfV66wO7wvz6wHyB21iRzIdtRVUI8yFmg8BcSG/vMArTIjJb9jwj44cKeCbYuwM8kAqcaAciNoUDdnFeEKLGRm9XiDPk367WRFRjc1xXGZihFn2RrYbimnpqSArf7rPa5s5/y1qY4= 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: Leo Li , jerry.zuo@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Leo Li In preparation for adding aux devices for DP MST: 1. A non-cyclic idr is used for the device minor version. That way, hotplug cycling MST devices won't needlessly increment the minor version index. 2. A suffix option is added to the aux device file name. It can be used to identify the corresponding MST device. Signed-off-by: Leo Li --- drivers/gpu/drm/drm_crtc_helper_internal.h | 5 +++-- drivers/gpu/drm/drm_dp_aux_dev.c | 8 ++++---- drivers/gpu/drm/drm_dp_helper.c | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc_helper_internal.h b/drivers/gpu/drm/drm_crtc_helper_internal.h index b5ac158..9f0907b 100644 --- a/drivers/gpu/drm/drm_crtc_helper_internal.h +++ b/drivers/gpu/drm/drm_crtc_helper_internal.h @@ -46,7 +46,7 @@ static inline int drm_fb_helper_modinit(void) #ifdef CONFIG_DRM_DP_AUX_CHARDEV int drm_dp_aux_dev_init(void); void drm_dp_aux_dev_exit(void); -int drm_dp_aux_register_devnode(struct drm_dp_aux *aux); +int drm_dp_aux_register_devnode(struct drm_dp_aux *aux, const char *suffix); void drm_dp_aux_unregister_devnode(struct drm_dp_aux *aux); #else static inline int drm_dp_aux_dev_init(void) @@ -58,7 +58,8 @@ static inline void drm_dp_aux_dev_exit(void) { } -static inline int drm_dp_aux_register_devnode(struct drm_dp_aux *aux) +static inline int drm_dp_aux_register_devnode(struct drm_dp_aux *aux, + const char *suffix) { return 0; } diff --git a/drivers/gpu/drm/drm_dp_aux_dev.c b/drivers/gpu/drm/drm_dp_aux_dev.c index 0e4f25d..2310a67 100644 --- a/drivers/gpu/drm/drm_dp_aux_dev.c +++ b/drivers/gpu/drm/drm_dp_aux_dev.c @@ -80,8 +80,7 @@ static struct drm_dp_aux_dev *alloc_drm_dp_aux_dev(struct drm_dp_aux *aux) kref_init(&aux_dev->refcount); mutex_lock(&aux_idr_mutex); - index = idr_alloc_cyclic(&aux_idr, aux_dev, 0, DRM_AUX_MINORS, - GFP_KERNEL); + index = idr_alloc(&aux_idr, aux_dev, 0, DRM_AUX_MINORS, GFP_KERNEL); mutex_unlock(&aux_idr_mutex); if (index < 0) { kfree(aux_dev); @@ -290,7 +289,7 @@ void drm_dp_aux_unregister_devnode(struct drm_dp_aux *aux) kref_put(&aux_dev->refcount, release_drm_dp_aux_dev); } -int drm_dp_aux_register_devnode(struct drm_dp_aux *aux) +int drm_dp_aux_register_devnode(struct drm_dp_aux *aux, const char *suffix) { struct drm_dp_aux_dev *aux_dev; int res; @@ -301,7 +300,8 @@ int drm_dp_aux_register_devnode(struct drm_dp_aux *aux) aux_dev->dev = device_create(drm_dp_aux_dev_class, aux->dev, MKDEV(drm_dev_major, aux_dev->index), NULL, - "drm_dp_aux%d", aux_dev->index); + "drm_dp_aux%d%s", aux_dev->index, + suffix ? suffix : ""); if (IS_ERR(aux_dev->dev)) { res = PTR_ERR(aux_dev->dev); aux_dev->dev = NULL; diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c index e2266ac..13f1005 100644 --- a/drivers/gpu/drm/drm_dp_helper.c +++ b/drivers/gpu/drm/drm_dp_helper.c @@ -1143,7 +1143,7 @@ int drm_dp_aux_register(struct drm_dp_aux *aux) strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(aux->dev), sizeof(aux->ddc.name)); - ret = drm_dp_aux_register_devnode(aux); + ret = drm_dp_aux_register_devnode(aux, NULL); if (ret) return ret; From patchwork Fri Apr 12 16:05:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Leo Li X-Patchwork-Id: 10898681 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 0EEFE922 for ; Fri, 12 Apr 2019 16:05:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFD3A28AD6 for ; Fri, 12 Apr 2019 16:05:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFBCD28E97; Fri, 12 Apr 2019 16:05:58 +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,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 3B53E28AD6 for ; Fri, 12 Apr 2019 16:05:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 357AF89A08; Fri, 12 Apr 2019 16:05:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-eopbgr810044.outbound.protection.outlook.com [40.107.81.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id A6CC589A08; Fri, 12 Apr 2019 16:05:52 +0000 (UTC) Received: from DM3PR12CA0102.namprd12.prod.outlook.com (2603:10b6:0:55::22) by MN2PR12MB3471.namprd12.prod.outlook.com (2603:10b6:208:c8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1792.18; Fri, 12 Apr 2019 16:05:50 +0000 Received: from BY2NAM03FT009.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::204) by DM3PR12CA0102.outlook.office365.com (2603:10b6:0:55::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1792.16 via Frontend Transport; Fri, 12 Apr 2019 16:05:50 +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 BY2NAM03FT009.mail.protection.outlook.com (10.152.84.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1771.16 via Frontend Transport; Fri, 12 Apr 2019 16:05:49 +0000 Received: from SATLEXDAG04.amd.com (10.181.40.9) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server (TLS) id 14.3.389.1; Fri, 12 Apr 2019 11:05:48 -0500 Received: from leodev.amd.com (10.180.168.240) by satlexdag04.amd.com (10.181.40.9) with Microsoft SMTP Server id 14.3.389.1; Fri, 12 Apr 2019 12:05:47 -0400 From: To: , Subject: [PATCH 2/2] drm/dp_mst: Register aux-dev nodes for MST ports Date: Fri, 12 Apr 2019 12:05:31 -0400 Message-ID: <1555085131-8716-3-git-send-email-sunpeng.li@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1555085131-8716-1-git-send-email-sunpeng.li@amd.com> References: <1555085131-8716-1-git-send-email-sunpeng.li@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)(979002)(376002)(346002)(39860400002)(396003)(136003)(2980300002)(428003)(199004)(189003)(5820100001)(426003)(486006)(2616005)(336012)(2876002)(11346002)(126002)(446003)(476003)(5660300002)(72206003)(53936002)(68736007)(8936002)(86362001)(53416004)(186003)(36756003)(66574012)(478600001)(105586002)(77096007)(106466001)(305945005)(356004)(6666004)(26005)(97736004)(76176011)(23676004)(81156014)(81166006)(8676002)(86152003)(7696005)(47776003)(4326008)(14444005)(2906002)(110136005)(316002)(54906003)(50466002)(2870700001)(50226002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR12MB3471; 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: 94b1b48c-1522-4b84-1047-08d6bf60bb37 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600139)(711020)(4605104)(2017052603328); SRVR:MN2PR12MB3471; X-MS-TrafficTypeDiagnostic: MN2PR12MB3471: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 0005B05917 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: aO6ao8mHhi6De0XHcGbGLxXS0/1qV3Up3FNUb5PiUt3UAjDlBLfUD442Wt3iG1T7B5coDJfIm9ts6YbUm6V8dWIkzVBT/XhL3tnEHnzcwe2DSF5KjV2W+f8kMF1Xd1JRlCKapjTxIoRWnv0yOHjBYR8WJ3LDnMmc8Yt1FhH+qhLmGGmq+ubchqWtCbgxk1ACgeyK4yCGsYa7AC84EzSl5UiXZocD8I8uNz9isHRSwvaCurolREnGSyyWdNK57UcSNHp+OMt1C1m7jpdaXy64040WsWWGkDiZz3EcBuvHJu2skozJ9dChMgQBCoNZQxk54vuQzA9wY55DMHCfxAmB5N5aUGyYqQDBh7DiKDbQi8We6qBYZEKXKIIrXN+QX75mZ3sKxdHm0MLHRaScgNUAhFTnuRXUr7PeeFtcyVqMl1w= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2019 16:05:49.6466 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 94b1b48c-1522-4b84-1047-08d6bf60bb37 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: MN2PR12MB3471 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IlNrHtQxhdPMHMjY5Tk7BEwfE53Fsncr9q//8GnYxHw=; b=veV3wr1sZQocssGD29zFhfk8/rcSD29BkvZD9bdl/G7aaeD/D8P+oUL9W7UQTnaiDHaIQgXRR+2PONNtjbWTpfLHIaiswxZpAdOVsQFFO2Ywnh6WMrvL64KrusTHOZGe8nn9yB4fXA/RikGrHvPx4V6f7wLZE5C0cNt1kRk3F5g= 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: Leo Li , jerry.zuo@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Ville Syrjälä Expose AUX devices for MST ports, similar to how they are exposed for SST. The registered device will have it's MST port path appended in order to identify it. i.e. /dev/drm_dp_aux4_mst:0-2-1 So for a MST topology like so: +---------+ | ASIC | +---------+ Conn-0| | +----v----+ +----| MST HUB |----+ | +---------+ | | | |Port-1 Port-2| +-----v-----+ +-----v-----+ | MST | | SST | | Display | | Display | +-----------+ +-----------+ |Port-1 x The list of AUX device names will look like: AUX Device Name | MST Device ----------------------+---------------------------------- drm_dp_aux0 | MST Hub drm_dp_aux1_mst:0-1-1 | MST Display's disconnected DP out drm_dp_aux2_mst:0-1 | MST Display drm_dp_aux3_mst:0-2 | SST Display Note that aux devices are only created for Physical Ports. Logical Ports are left out, since they are internally connected within the MST device (not connected to a DP RX or TX). Leo Li: * Add missing drm_crtc_helper_internal.h include * Fix hard-coded offset and size in drm_dp_send_dpcd_read() * Only create aux devices for physical ports. Signed-off-by: Ville Syrjälä Signed-off-by: Leo Li --- drivers/gpu/drm/drm_dp_aux_dev.c | 13 +++- drivers/gpu/drm/drm_dp_mst_topology.c | 109 ++++++++++++++++++++++++++++++---- include/drm/drm_dp_helper.h | 4 ++ include/drm/drm_dp_mst_helper.h | 6 ++ 4 files changed, 117 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_aux_dev.c b/drivers/gpu/drm/drm_dp_aux_dev.c index 2310a67..f1241d1 100644 --- a/drivers/gpu/drm/drm_dp_aux_dev.c +++ b/drivers/gpu/drm/drm_dp_aux_dev.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -160,7 +161,11 @@ static ssize_t auxdev_read_iter(struct kiocb *iocb, struct iov_iter *to) break; } - res = drm_dp_dpcd_read(aux_dev->aux, pos, buf, todo); + 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); + if (res <= 0) break; @@ -207,7 +212,11 @@ static ssize_t auxdev_write_iter(struct kiocb *iocb, struct iov_iter *from) break; } - res = drm_dp_dpcd_write(aux_dev->aux, pos, buf, todo); + 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); + if (res <= 0) break; diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index 2ab16c9..d5282db 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -35,6 +35,8 @@ #include #include +#include "drm_crtc_helper_internal.h" + /** * DOC: dp mst helper * @@ -52,6 +54,9 @@ static int drm_dp_dpcd_write_payload(struct drm_dp_mst_topology_mgr *mgr, int id, struct drm_dp_payload *payload); +static int drm_dp_send_dpcd_read(struct drm_dp_mst_topology_mgr *mgr, + struct drm_dp_mst_port *port, + int offset, int size, u8 *bytes); static int drm_dp_send_dpcd_write(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, int offset, int size, u8 *bytes); @@ -941,6 +946,8 @@ static void drm_dp_destroy_port(struct kref *kref) struct drm_dp_mst_topology_mgr *mgr = port->mgr; if (!port->input) { + drm_dp_aux_unregister_devnode(&port->aux); + port->vcpi.num_slots = 0; kfree(port->cached_edid); @@ -1095,6 +1102,46 @@ static bool drm_dp_port_setup_pdt(struct drm_dp_mst_port *port) return send_link; } +/** + * drm_dp_mst_dpcd_read() - read a series of bytes from the DPCD via sideband + * @aux: Fake sideband AUX CH + * @offset: address of the (first) register to read + * @buffer: buffer to store the register values + * @size: number of bytes in @buffer + * + * Performs the same functionality for remote devices via + * sideband messaging as drm_dp_dpcd_read() does for local + * devices via actual AUX CH. + */ +ssize_t drm_dp_mst_dpcd_read(struct drm_dp_aux *aux, + unsigned int offset, void *buffer, size_t size) +{ + struct drm_dp_mst_port *port = container_of(aux, struct drm_dp_mst_port, aux); + + return drm_dp_send_dpcd_read(port->mgr, port, + offset, size, buffer); +} + +/** + * drm_dp_mst_dpcd_write() - write a series of bytes to the DPCD via sideband + * @aux: Fake sideband AUX CH + * @offset: address of the (first) register to write + * @buffer: buffer containing the values to write + * @size: number of bytes in @buffer + * + * Performs the same functionality for remote devices via + * sideband messaging as drm_dp_dpcd_write() does for local + * devices via actual AUX CH. + */ +ssize_t drm_dp_mst_dpcd_write(struct drm_dp_aux *aux, + unsigned int offset, void *buffer, size_t size) +{ + struct drm_dp_mst_port *port = container_of(aux, struct drm_dp_mst_port, aux); + + return drm_dp_send_dpcd_write(port->mgr, port, + offset, size, buffer); +} + static void drm_dp_check_mstb_guid(struct drm_dp_mst_branch *mstb, u8 *guid) { int ret; @@ -1158,6 +1205,7 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb, port->mgr = mstb->mgr; port->aux.name = "DPMST"; port->aux.dev = dev->dev; + port->aux.is_remote = true; created = true; } else { old_pdt = port->pdt; @@ -1188,7 +1236,7 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb, drm_dp_send_enum_path_resources(mstb->mgr, mstb, port); } else { port->available_pbn = 0; - } + } } if (old_pdt != port->pdt && !port->input) { @@ -1220,6 +1268,14 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb, drm_connector_set_tile_property(port->connector); } (*mstb->mgr->cbs->register_connector)(port->connector); + + /* Prepend an '_' in front to suffix the aux device filename */ + memmove(proppath + 1, proppath, sizeof(proppath) - 1); + proppath[0] = '_'; + + /* Only create aux devices for physical ports with a TX or RX*/ + if (port->port_num < DP_MST_LOGICAL_PORT_0) + drm_dp_aux_register_devnode(&port->aux, proppath); } out: @@ -1404,7 +1460,6 @@ static bool drm_dp_validate_guid(struct drm_dp_mst_topology_mgr *mgr, return false; } -#if 0 static int build_dpcd_read(struct drm_dp_sideband_msg_tx *msg, u8 port_num, u32 offset, u8 num_bytes) { struct drm_dp_sideband_msg_req_body req; @@ -1417,7 +1472,6 @@ static int build_dpcd_read(struct drm_dp_sideband_msg_tx *msg, u8 port_num, u32 return 0; } -#endif static int drm_dp_send_sideband_msg(struct drm_dp_mst_topology_mgr *mgr, bool up, u8 *msg, int len) @@ -1994,26 +2048,55 @@ int drm_dp_update_payload_part2(struct drm_dp_mst_topology_mgr *mgr) } EXPORT_SYMBOL(drm_dp_update_payload_part2); -#if 0 /* unused as of yet */ static int drm_dp_send_dpcd_read(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, - int offset, int size) + int offset, int size, u8 *bytes) { int len; + int ret = 0; struct drm_dp_sideband_msg_tx *txmsg; + struct drm_dp_mst_branch *mstb; + + mstb = drm_dp_get_validated_mstb_ref(mgr, port->parent); + if (!mstb) + return -EINVAL; txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL); - if (!txmsg) - return -ENOMEM; + if (!txmsg) { + ret = -ENOMEM; + goto fail_put; + } - len = build_dpcd_read(txmsg, port->port_num, 0, 8); + len = build_dpcd_read(txmsg, port->port_num, offset, size); txmsg->dst = port->parent; drm_dp_queue_down_tx(mgr, txmsg); - return 0; + ret = drm_dp_mst_wait_tx_reply(mstb, txmsg); + if (ret < 0) + goto fail_free; + + /* DPCD read should never be NACKed */ + if (WARN_ON_ONCE(txmsg->reply.reply_type == 1)) { + ret = -EIO; + goto fail_free; + } + + if (txmsg->reply.u.remote_dpcd_read_ack.num_bytes != size) { + ret = -EPROTO; + goto fail_free; + } + + ret = min_t(size_t, txmsg->reply.u.remote_dpcd_read_ack.num_bytes, size); + memcpy(bytes, txmsg->reply.u.remote_dpcd_read_ack.bytes, ret); + +fail_free: + kfree(txmsg); +fail_put: + drm_dp_put_mst_branch_device(mstb); + + return ret; } -#endif static int drm_dp_send_dpcd_write(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, @@ -2041,9 +2124,9 @@ static int drm_dp_send_dpcd_write(struct drm_dp_mst_topology_mgr *mgr, ret = drm_dp_mst_wait_tx_reply(mstb, txmsg); if (ret > 0) { - if (txmsg->reply.reply_type == 1) { - ret = -EINVAL; - } else + if (txmsg->reply.reply_type == 1) + ret = -EIO; + else ret = 0; } kfree(txmsg); diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h index 509667e..6dea76a 100644 --- a/include/drm/drm_dp_helper.h +++ b/include/drm/drm_dp_helper.h @@ -1265,6 +1265,10 @@ struct drm_dp_aux { * @cec: struct containing fields used for CEC-Tunneling-over-AUX. */ struct drm_dp_aux_cec cec; + /** + * @is_remote: Is this "AUX CH" actually using sideband messaging. + */ + bool is_remote; }; ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset, diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h index 371cc28..30f8c11 100644 --- a/include/drm/drm_dp_mst_helper.h +++ b/include/drm/drm_dp_mst_helper.h @@ -615,6 +615,12 @@ void drm_dp_mst_dump_topology(struct seq_file *m, void drm_dp_mst_topology_mgr_suspend(struct drm_dp_mst_topology_mgr *mgr); int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr); + +ssize_t drm_dp_mst_dpcd_read(struct drm_dp_aux *aux, + unsigned int offset, void *buffer, size_t size); +ssize_t drm_dp_mst_dpcd_write(struct drm_dp_aux *aux, + unsigned int offset, void *buffer, size_t size); + struct drm_dp_mst_topology_state *drm_atomic_get_mst_topology_state(struct drm_atomic_state *state, struct drm_dp_mst_topology_mgr *mgr); int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state,