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;