From patchwork Mon Apr 22 23:56:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Leo Li X-Patchwork-Id: 10911731 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 5FD2214DB for ; Mon, 22 Apr 2019 23:56:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5215527FA8 for ; Mon, 22 Apr 2019 23:56:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45F6B287C3; Mon, 22 Apr 2019 23:56: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 C0DE827FA8 for ; Mon, 22 Apr 2019 23:56:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 682E4890DB; Mon, 22 Apr 2019 23:56:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0605.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe49::605]) by gabe.freedesktop.org (Postfix) with ESMTPS id 760AE890DB; Mon, 22 Apr 2019 23:56:47 +0000 (UTC) Received: from DM3PR12CA0060.namprd12.prod.outlook.com (2603:10b6:0:56::28) by BN8PR12MB2963.namprd12.prod.outlook.com (2603:10b6:408:61::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1813.16; Mon, 22 Apr 2019 23:56:45 +0000 Received: from CO1NAM03FT024.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::203) by DM3PR12CA0060.outlook.office365.com (2603:10b6:0:56::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1813.11 via Frontend Transport; Mon, 22 Apr 2019 23:56:44 +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 CO1NAM03FT024.mail.protection.outlook.com (10.152.80.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1771.16 via Frontend Transport; Mon, 22 Apr 2019 23:56:44 +0000 Received: from SATLEXDAG01.amd.com (10.181.40.3) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server (TLS) id 14.3.389.1; Mon, 22 Apr 2019 18:56:43 -0500 Received: from leodev.amd.com (10.180.168.240) by SATLEXDAG01.amd.com (10.181.40.3) with Microsoft SMTP Server id 14.3.389.1; Mon, 22 Apr 2019 19:56:42 -0400 From: To: , Subject: [PATCH 1/3] drm/dp: Use non-cyclic idr Date: Mon, 22 Apr 2019 19:56:26 -0400 Message-ID: <1555977388-14203-1-git-send-email-sunpeng.li@amd.com> X-Mailer: git-send-email 2.7.4 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)(396003)(136003)(39860400002)(376002)(346002)(2980300002)(428003)(189003)(199004)(4744005)(8676002)(70586007)(8936002)(51416003)(50226002)(70206006)(305945005)(47776003)(81166006)(81156014)(2616005)(126002)(336012)(476003)(72206003)(86362001)(486006)(4326008)(7696005)(97736004)(478600001)(426003)(53416004)(53936002)(16586007)(86152003)(5660300002)(14444005)(316002)(36756003)(186003)(54906003)(110136005)(2906002)(2876002)(26005)(356004)(48376002)(50466002)(6666004)(77096007)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:BN8PR12MB2963; 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: a9202aa8-ee12-47fd-afb1-08d6c77e2c8a X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328); SRVR:BN8PR12MB2963; X-MS-TrafficTypeDiagnostic: BN8PR12MB2963: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 00159D1518 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: xxr+51UZbQ4Tm4g1D83d0T5nsitkv4tDIDX64nIqjwSDO/txhWdQQAYtWRZP6x6P0gvg58GSV98oPz61GocN8xGaKm4Tf/95g6k6JRTJ8StvTlKn94dn/ECs3bYfIj1SABCEq73vaYKVZEiamrV1O3TyfdNR5M1eINfaO0HZD/eKBBDAqWjc6xBzmwadul7j7O8BK45vCXh/OHlvnsC09d3Z1C/cfGGLzjz3V3qBTwxwxEnxYQO3F8s+qs5oV19k4z5RGjUl4BX9vrvxo4DvoNy/TTkJxlU5nTaNu+GrymTi9TeiT8IU/xHJRGgZTxytY22n+AvhuOS1HlvbvZLTPXCNJW1N9lP4Oz8EzQPTpDJAzKSZlUPuiJKsO3NAILjPpTqORoPxnA1gf8CqbBXqAxCsjWt0KjX32daxqDN0cz4= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2019 23:56:44.4315 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9202aa8-ee12-47fd-afb1-08d6c77e2c8a 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: BN8PR12MB2963 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=1s6pR6oVk7mlw4/kcJswKJQMvwhJfCmajI2Unbg9vb8=; b=OnKVQg1o0BRSDk8zLD4txAfp23wvlBv/7ga4tDb4VdPcCTqgDhMGmMegL5g/MUr3+CMkaldKtUNpMNqS13fTwe9JUWYWi64dyKwgDu2uvE7BDiQtVD7CaCTmWNZg4xUQOJcKk1r01f9Ud+mGncy1gPIXaL40Emj9zvxZ8h2pUq8= 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, make the IDR non-cyclic. That way, hotplug cycling MST devices won't needlessly increment the minor version index. Signed-off-by: Leo Li Reviewed-by: Ville Syrjälä Reviewed-by: Lyude Paul --- drivers/gpu/drm/drm_dp_aux_dev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_aux_dev.c b/drivers/gpu/drm/drm_dp_aux_dev.c index 0e4f25d..6d84611 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); From patchwork Mon Apr 22 23:56:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Leo Li X-Patchwork-Id: 10911733 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 150AF1708 for ; Mon, 22 Apr 2019 23:56:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0987127FA8 for ; Mon, 22 Apr 2019 23:56:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1B34287C3; Mon, 22 Apr 2019 23:56:54 +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 AA81927FA8 for ; Mon, 22 Apr 2019 23:56:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8D12589256; Mon, 22 Apr 2019 23:56:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-eopbgr800078.outbound.protection.outlook.com [40.107.80.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id 19F6989256; Mon, 22 Apr 2019 23:56:52 +0000 (UTC) Received: from DM3PR12CA0044.namprd12.prod.outlook.com (2603:10b6:0:56::12) by BN8PR12MB2963.namprd12.prod.outlook.com (2603:10b6:408:61::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1813.16; Mon, 22 Apr 2019 23:56:50 +0000 Received: from CO1NAM03FT009.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::201) by DM3PR12CA0044.outlook.office365.com (2603:10b6:0:56::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1813.12 via Frontend Transport; Mon, 22 Apr 2019 23:56:50 +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 CO1NAM03FT009.mail.protection.outlook.com (10.152.80.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1771.16 via Frontend Transport; Mon, 22 Apr 2019 23:56:49 +0000 Received: from SATLEXDAG01.amd.com (10.181.40.3) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server (TLS) id 14.3.389.1; Mon, 22 Apr 2019 18:56:48 -0500 Received: from leodev.amd.com (10.180.168.240) by SATLEXDAG01.amd.com (10.181.40.3) with Microsoft SMTP Server id 14.3.389.1; Mon, 22 Apr 2019 19:56:47 -0400 From: To: , Subject: [PATCH 2/3] drm/dp_mst: Expose build_mst_prop_path() Date: Mon, 22 Apr 2019 19:56:27 -0400 Message-ID: <1555977388-14203-2-git-send-email-sunpeng.li@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1555977388-14203-1-git-send-email-sunpeng.li@amd.com> References: <1555977388-14203-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)(396003)(136003)(39860400002)(376002)(346002)(2980300002)(428003)(189003)(199004)(76176011)(8676002)(70586007)(8936002)(51416003)(50226002)(70206006)(305945005)(47776003)(81166006)(81156014)(2616005)(126002)(336012)(476003)(72206003)(446003)(86362001)(486006)(4326008)(11346002)(7696005)(97736004)(478600001)(426003)(53416004)(53936002)(16586007)(86152003)(5660300002)(14444005)(316002)(36756003)(186003)(54906003)(110136005)(2906002)(2876002)(26005)(356004)(48376002)(50466002)(6666004)(77096007)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:BN8PR12MB2963; 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: b5e98c27-8792-45d8-5e44-08d6c77e2fae X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328); SRVR:BN8PR12MB2963; X-MS-TrafficTypeDiagnostic: BN8PR12MB2963: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 00159D1518 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: B++ostm1QY9MpoYXNVo2eYKWnH724bitivcaa4J7y77Qh289HttJag1sjARzDcsuDLsnIxwr8yQKkpNYc9K0NkTOcfk8Vxk+lT0icK7eeDHE3WzTB686mCkGJ5OLNBScb94nnrIcfw2eMB2bCKBgZYbGW8/6RT1DnXxKYLL7Zq8sWfLir78U1Kp7inWAAUW1XhZe6vTwmMgKwMSaC2ZLpDpVrKz1ufNHkpWxiihPm4ppIz9CsAal/TqZXtWaFAvv2O4r0QT9jUjcBPiQCzL6U4qcBsU6/trukreQK3Vbd2UnXJTj3WMta2qfKp7Mr1/1RoN8vduJKEB2zPqcoHETmoVn+JAObGX5NJaPgeG3REGupQOv4n0XSkWfsOpWUSNfhToEOzJ93jfGefvhXUtIfTpEN9FJ7PrKSBrJOXEfJ2Y= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2019 23:56:49.6805 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b5e98c27-8792-45d8-5e44-08d6c77e2fae 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: BN8PR12MB2963 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=h4IPZtP+Tv0o3+WuCqxtXeEHQIEbsjo6E10La2IkAjo=; b=DPeVJ7QIneJYVBqxujUAX8VTN6UzsKVqpqtte1l5c4Jj/1ySGXfpWQVwLl5frRrK4Yrt8j3m/nbe/NQ1d7NPHf+wK8ivM+HTtGLAzlAzgHuaJ6BT8xzLYoBIfihxPVjXyNQyOG7as/rDeJKDO6GiutclWiihgH4+CrG2hs5rxUY= 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 To give identifiable attributes to MST DP aux devices, we can use the MST relative address. Expose this function for later use. Signed-off-by: Leo Li Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/drm_dp_mst_topology.c | 4 ++-- include/drm/drm_dp_mst_helper.h | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index 2ab16c9..86ff8e2 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -1120,7 +1120,7 @@ static void drm_dp_check_mstb_guid(struct drm_dp_mst_branch *mstb, u8 *guid) } } -static void build_mst_prop_path(const struct drm_dp_mst_branch *mstb, +void drm_dp_build_mst_prop_path(const struct drm_dp_mst_branch *mstb, int pnum, char *proppath, size_t proppath_size) @@ -1202,7 +1202,7 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb, if (created && !port->input) { char proppath[255]; - build_mst_prop_path(mstb, port->port_num, proppath, sizeof(proppath)); + drm_dp_build_mst_prop_path(mstb, port->port_num, proppath, sizeof(proppath)); port->connector = (*mstb->mgr->cbs->add_connector)(mstb->mgr, port, proppath); if (!port->connector) { /* remove it from the port list */ diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h index 371cc28..81c8d79 100644 --- a/include/drm/drm_dp_mst_helper.h +++ b/include/drm/drm_dp_mst_helper.h @@ -602,6 +602,10 @@ void drm_dp_mst_deallocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, int drm_dp_find_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr, int pbn); +void drm_dp_build_mst_prop_path(const struct drm_dp_mst_branch *mstb, + int pnum, + char *proppath, + size_t proppath_size); int drm_dp_update_payload_part1(struct drm_dp_mst_topology_mgr *mgr); From patchwork Mon Apr 22 23:56:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Leo Li X-Patchwork-Id: 10911735 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 80DB413B5 for ; Mon, 22 Apr 2019 23:57:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72C3F27FA8 for ; Mon, 22 Apr 2019 23:57:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65BB2287C3; Mon, 22 Apr 2019 23:57:04 +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 9671127FA8 for ; Mon, 22 Apr 2019 23:57:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 63679892ED; Mon, 22 Apr 2019 23:57:02 +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-eopbgr760041.outbound.protection.outlook.com [40.107.76.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1B30D892ED; Mon, 22 Apr 2019 23:57:01 +0000 (UTC) Received: from MWHPR12CA0025.namprd12.prod.outlook.com (2603:10b6:301:2::11) by BY2PR12MB0582.namprd12.prod.outlook.com (2a01:111:e400:52dd::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1813.12; Mon, 22 Apr 2019 23:56:58 +0000 Received: from CO1NAM03FT053.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::202) by MWHPR12CA0025.outlook.office365.com (2603:10b6:301:2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1813.12 via Frontend Transport; Mon, 22 Apr 2019 23:56:58 +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 CO1NAM03FT053.mail.protection.outlook.com (10.152.81.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1771.16 via Frontend Transport; Mon, 22 Apr 2019 23:56:58 +0000 Received: from SATLEXDAG01.amd.com (10.181.40.3) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server (TLS) id 14.3.389.1; Mon, 22 Apr 2019 18:56:55 -0500 Received: from leodev.amd.com (10.180.168.240) by SATLEXDAG01.amd.com (10.181.40.3) with Microsoft SMTP Server id 14.3.389.1; Mon, 22 Apr 2019 19:56:55 -0400 From: To: , Subject: [PATCH 3/3] drm/dp_mst: Register AUX devices for MST ports Date: Mon, 22 Apr 2019 19:56:28 -0400 Message-ID: <1555977388-14203-3-git-send-email-sunpeng.li@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1555977388-14203-1-git-send-email-sunpeng.li@amd.com> References: <1555977388-14203-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)(376002)(136003)(39860400002)(396003)(346002)(2980300002)(428003)(189003)(199004)(478600001)(6666004)(70586007)(4326008)(86152003)(2906002)(53416004)(110136005)(76176011)(68736007)(356004)(70206006)(7696005)(2876002)(36756003)(72206003)(23676004)(5024004)(14444005)(53936002)(2870700001)(336012)(426003)(316002)(186003)(77096007)(81156014)(8676002)(81166006)(26005)(486006)(126002)(11346002)(50226002)(66574012)(5820100001)(8936002)(97736004)(54906003)(30864003)(476003)(2616005)(5660300002)(50466002)(47776003)(305945005)(446003)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0582; 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: a25a92d8-e9ad-4237-1cec-08d6c77e34dc X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328); SRVR:BY2PR12MB0582; X-MS-TrafficTypeDiagnostic: BY2PR12MB0582: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 00159D1518 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: rZ7IYb6aHLWCx8o5ZJj2GZe+Kq+Zw9DkrxKgiQPuO397MDmRhhPL5BM2zj+VxKO/r/wLLdilRsk90+hx918hL4TwOW5ybm9mKCAxsP7imqCpH6DKyOxHhnAFbQ6Fm4ZBEFk7dAWp9AiEutUPFKdlIGfg0QXx9bwlpwN5q1JKTfYiHSzJhtu+e4tsFB2/Y+OKyUfTeomL4EpYojdkLwoV8nska3vbHA99RilKaaBrCyKS9lCfUUj1ziu8FqYcU/hHHcfhpdjiHmtVT/V0bNIfzOa/0hDoSZqpRDVouk0NeRprOL/0Mt4z6NSsVIP38ywdO53bUO86dY4ISX0SH4nFAEZtZAM+rVyhBti84bEZ3G6pKwsBrlaKmFoO7BAtgmU1thh6+yUnb3jM9QHt68df9zYMJJ8Xyfv5DMFbUQ33ASg= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2019 23:56:58.2628 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a25a92d8-e9ad-4237-1cec-08d6c77e34dc 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: BY2PR12MB0582 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=ezazqPmlpRxSzuTf1K2rdULaxZmaKfnqGRTNpNvhfJ0=; b=V2twiTN2iDvQo4xLDF9gF/mpR1CaCYgUld9OSdC6+vJDPCVtYvwo0mTFvDn5ENHwtpTObJG5c21sdNa35q0BVuPqpVrWLUom/1yxCNU2HX/p+Fny7xlziTWwKjH4jgk/9yzOoQBpMD0JAOLY1igp0tNqCEQSJDSQCJJEP5dg21k= 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ä All available downstream ports - physical and logical - are exposed for each MST device. They are listed in /dev/, following the same naming scheme as SST devices by appending an incremental ID. Additionally, a 'path' attribute is attached to the device. This is to allow udev to provide more identifiable symlinks to these devices, similar to /dev/disks. For example, adding the following udev rule: SUBSYSTEMS=="drm_dp_aux_dev", ATTR{path}=="?*", SYMLINK+="drm_dp_aux/by-path/$attr{path}" With a MST topology like so: +---------+ | ASIC | +---------+ Conn-0| | +----v----+ +----| MST HUB |----+ | +---------+ | | | |Port-1 Port-2| +-----v-----+ +-----v-----+ | MST | | SST | | Display | | Display | +-----------+ +-----------+ |Port-1 x Will create the following symlinks in 'drm_dp_aux/by-path/': AUX Device Name | MST Device ----------------------+---------------------------------- card0_sst:0 (*) | MST Hub card0_mst:0-1 | MST Display card0_mst:0-1-1 | MST Display's disconnected DP out card0_mst:0-1-8 | MST Display's internal sink card0_mst:0-2 | SST Display (*) Note that the first digit is suppose to mean 'Connector ID'. However, that's only true for 'mst:' paths. A TODO item has been left to address this. Although all downstream ports are exposed, only some will work. On certain MST displays, the upstream physical port will ACK DPCD reads. However, reads on the local logical port to the internal sink will *NAK*. i.e. reading mst:0-1 ACKs, but mst:0-1-8 NAKs. There may also be duplicates. Some displays will return the same GUID when reading DPCD from both mst:0-1 and mst:0-1-8. There are some device-dependent behavior as well. The MST hub used during testing will actually *ACK* read requests on a disconnected physical port, whereas the MST displays will NAK. In light of these discrepancies, it's simpler to expose all downstream ports - both physical and logical - and let the user decide what to use. Signed-off-by: Ville Syrjälä Signed-off-by: Leo Li --- drivers/gpu/drm/drm_dp_aux_dev.c | 53 ++++++++++++++++- drivers/gpu/drm/drm_dp_mst_topology.c | 103 +++++++++++++++++++++++++++++----- include/drm/drm_dp_helper.h | 4 ++ include/drm/drm_dp_mst_helper.h | 6 ++ 4 files changed, 151 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_aux_dev.c b/drivers/gpu/drm/drm_dp_aux_dev.c index 6d84611..4218bbf 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 @@ -114,10 +115,50 @@ static ssize_t name_show(struct device *dev, return res; } + +static int is_drm_primary_device(struct device *dev, void *data) +{ + return strstr(dev_name(dev), "card") != NULL; +} + +static ssize_t path_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct drm_dp_aux_dev *aux_dev = + drm_dp_aux_dev_get_by_minor(MINOR(dev->devt)); + struct drm_dp_aux *aux = aux_dev->aux; + struct drm_dp_mst_port *port; + struct device *card; + char temp[64]; + ssize_t res; + + card = device_find_child(dev->parent, NULL, + is_drm_primary_device); + + if (!aux->is_remote) { + /* + * TODO: AUX index does not correlate with connector ID. See if + * connector ID can be used instead. + */ + res = sprintf(buf, "%s_%s:%d\n", + dev_name(card), "sst", aux_dev->index); + return res; + } + + port = container_of(aux, struct drm_dp_mst_port, aux); + drm_dp_build_mst_prop_path(port->parent, port->port_num, + temp, sizeof(temp)); + res = sprintf(buf, "%s_%s\n", dev_name(card), temp); + + return res; +} + static DEVICE_ATTR_RO(name); +static DEVICE_ATTR_RO(path); static struct attribute *drm_dp_aux_attrs[] = { &dev_attr_name.attr, + &dev_attr_path.attr, NULL, }; ATTRIBUTE_GROUPS(drm_dp_aux); @@ -160,7 +201,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 +252,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 86ff8e2..0174527 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,8 @@ 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); + + drm_dp_aux_register_devnode(&port->aux); } out: @@ -1404,7 +1454,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 +1466,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 +2042,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 +2118,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 81c8d79..4de8256 100644 --- a/include/drm/drm_dp_mst_helper.h +++ b/include/drm/drm_dp_mst_helper.h @@ -619,6 +619,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,