From patchwork Fri Oct 4 14:34:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihail Atanassov X-Patchwork-Id: 11174691 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 B491913BD for ; Fri, 4 Oct 2019 14:34:53 +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 9B806222C4 for ; Fri, 4 Oct 2019 14:34:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B806222C4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.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 6C03A6EBB8; Fri, 4 Oct 2019 14:34:52 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10067.outbound.protection.outlook.com [40.107.1.67]) by gabe.freedesktop.org (Postfix) with ESMTPS id 990B06EBB5 for ; Fri, 4 Oct 2019 14:34:50 +0000 (UTC) Received: from VI1PR0801CA0082.eurprd08.prod.outlook.com (2603:10a6:800:7d::26) by DB7PR08MB4587.eurprd08.prod.outlook.com (2603:10a6:10:30::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.20; Fri, 4 Oct 2019 14:34:47 +0000 Received: from VE1EUR03FT037.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::207) by VI1PR0801CA0082.outlook.office365.com (2603:10a6:800:7d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.20 via Frontend Transport; Fri, 4 Oct 2019 14:34:47 +0000 Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT037.mail.protection.outlook.com (10.152.19.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Fri, 4 Oct 2019 14:34:45 +0000 Received: ("Tessian outbound 0cf06bf5c60e:v33"); Fri, 04 Oct 2019 14:34:45 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7d279d107cd0a66c X-CR-MTA-TID: 64aa7808 Received: from f3d1354be0af.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.4.55]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id B1CC4576-DB53-4375-8097-66DA055768B4.1; Fri, 04 Oct 2019 14:34:39 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02lp2055.outbound.protection.outlook.com [104.47.4.55]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f3d1354be0af.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 04 Oct 2019 14:34:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iLEk20M19ajPf8Eb5spizCSEPkGKxxgB/VTC9OjWNZ7y/xubWyfyd7QKoJuXAfRGumU1YscWq0qUFBu8fmTqEgdCRzZag2dp6pYSXHkD1H7CyPW2dyUgse3bIa1Ei67YkE3gNAsEX6lfc+cmpNAF0GnAutcp67os0tQ82uLkSW+cT8wgZX7TaOfMChYynNw9trw+PSF7jNDwoo+/+LtVV0CHGGsOcDaxbkuW0xuk+F62oPo7UiBp/bzLIB09Sk77aUjffuJtMcFTIu8TEpR3QXitkWgCM1eh7Lwjx6OwCRShOPZoJu+EOXZ5fqJBhkZEuHH4asOkcxq5G/9UPD+3sQ== 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=zc4lele6dIwjU4c6a3L+IzKflQgRbWkIRbEL8ZX6qzA=; b=O3jKOZS75GTyBRYqgZLMR1Q3/Ju63+m6/8JC88N0RkK0UIsiHcLXlyaKAFYFHOgmMUInqDLSXwtquGHxqq/JDzdJ2g9AKL64TSXCEX9B7imR+CefrJK1dmXaiKdtGtnAKzn8IrMT3YBrKpbk00yMTMAP3ZoZrR0McAxK05NYJMMSgufn9OW2cLo9z5KOf1CvevU7jrsW9REt3y/A+sauXUTasZa05VW2oLk7A8QbGMI3ijTrFP6efnpI8XLet1d4p1LBa5OPA7bxEDHpchebaQvsh+MONovPWz99dnaASoWTzAtQNOjfDuHDf4t7Ivxs4+O00UajnQWL1lfUYKZ6Zw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from VI1PR08MB4078.eurprd08.prod.outlook.com (20.178.127.92) by VI1PR08MB4288.eurprd08.prod.outlook.com (20.179.25.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.20; Fri, 4 Oct 2019 14:34:37 +0000 Received: from VI1PR08MB4078.eurprd08.prod.outlook.com ([fe80::7d25:d1f2:e3eb:868b]) by VI1PR08MB4078.eurprd08.prod.outlook.com ([fe80::7d25:d1f2:e3eb:868b%6]) with mapi id 15.20.2305.023; Fri, 4 Oct 2019 14:34:37 +0000 From: Mihail Atanassov To: "dri-devel@lists.freedesktop.org" Subject: [PATCH 1/3] drm/komeda: Consolidate struct komeda_drv allocations Thread-Topic: [PATCH 1/3] drm/komeda: Consolidate struct komeda_drv allocations Thread-Index: AQHVesDZif8RFMaQBUOH/Gc/fEStZw== Date: Fri, 4 Oct 2019 14:34:37 +0000 Message-ID: <20191004143418.53039-2-mihail.atanassov@arm.com> References: <20191004143418.53039-1-mihail.atanassov@arm.com> In-Reply-To: <20191004143418.53039-1-mihail.atanassov@arm.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [217.140.106.52] x-clientproxiedby: LNXP265CA0001.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::13) To VI1PR08MB4078.eurprd08.prod.outlook.com (2603:10a6:803:e5::28) x-mailer: git-send-email 2.23.0 Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Mihail.Atanassov@arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 9e5582b9-1da4-43b9-dc18-08d748d80062 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VI1PR08MB4288:|VI1PR08MB4288:|DB7PR08MB4587: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:185;OLM:185; x-forefront-prvs: 018093A9B5 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(396003)(346002)(39860400002)(366004)(376002)(136003)(199004)(189003)(1076003)(66066001)(14454004)(66556008)(102836004)(2906002)(5660300002)(478600001)(36756003)(76176011)(26005)(50226002)(3846002)(2501003)(6116002)(11346002)(66446008)(386003)(186003)(64756008)(6506007)(66476007)(8936002)(66946007)(5024004)(14444005)(2616005)(4326008)(256004)(44832011)(81166006)(6512007)(99286004)(486006)(6436002)(5640700003)(8676002)(6486002)(86362001)(25786009)(71190400001)(476003)(6916009)(7736002)(305945005)(71200400001)(446003)(2351001)(54906003)(316002)(52116002)(81156014); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB4288; H:VI1PR08MB4078.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 5+c4P3D84usX9SQ0peKaoAbt8WogtBHW2uWJjQV10LzLibcmru/8t1xY0Zy6N60TEka3TtEZiVadgFR4/gHw0WVdrMC3CS0vY52FLz/g+gZxz+es2dy3qjn/wAx5iKIhj4IKT/1VHXcZL6CaRZCGYT+1gVes2KQPgfzStzC++JdwwoRNb60UMPZbm63U4vku7R4Uz3iKxGibSjmRp6I8J2u5/2Y9fzXSi5Iyr4OLUVnovghKVRLZN/HQaSx2iSqp1fXEFy1qqgJT/arehcvOHN+p5bpoYGbjCER8hRk+tGNQK0WduR+T4ML6rcB6YCuOvb0E7ZjFn5W7OYr7CA5YmW8CXVO/YzY42Rcb6V3VCkJcc3zNlaB+jwTcJ2F+gKtxoDCBZAPDMGM4X2a9wSqaVbKR2REnzZrKVm9NaDvM4Xg= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4288 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Mihail.Atanassov@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT037.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(346002)(396003)(136003)(376002)(199004)(189003)(5660300002)(86362001)(186003)(25786009)(2501003)(23756003)(6512007)(22756006)(36906005)(36756003)(316002)(54906003)(70586007)(70206006)(50226002)(478600001)(26826003)(50466002)(81166006)(81156014)(2616005)(76130400001)(63350400001)(336012)(476003)(126002)(11346002)(446003)(486006)(8936002)(8746002)(2906002)(14454004)(5640700003)(7736002)(26005)(2351001)(76176011)(107886003)(102836004)(305945005)(47776003)(6916009)(66066001)(6486002)(4326008)(1076003)(14444005)(5024004)(99286004)(8676002)(6506007)(386003)(6116002)(356004)(3846002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR08MB4587; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:TempError; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; A:1; MX:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: bde6a659-115a-4591-14f4-08d748d7fb71 NoDisclaimer: True X-Forefront-PRVS: 018093A9B5 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fRAJSu4jPFY5N39TwnKfo/4uYgQ/qMp6WYYkyzf3Vpecq9N8JiuVd2lwRx2LP8t6Lrm0aznG+1GYySiMs2l+/KTQPMLsSOGzb8oTiQ/NiYlz2fbfUwAsy7uxQ50oYeX3aqWwtXInbB/f2ZdWTeSPSwOsq/YWXKDH3wFGv3UtPH39h5i1NGWtuZZ1iinYJGPFtRW4Ojw7SQQCcJtutEk606N+xZ5VUPRjJ9+GOnaYacw1s3R3yYv7lLaDDrchMqOU3rzJDJHwF6h3RktJ2kEDUposZwU8o9F5YPlPEF0Yc9Zz3W67u0KSvHpF+dkKDyWrI2PgWWyW7nCL+TRKBLH4avw34qf9dJXgZAllCH1gyl0mugYKiY3WSqVxY29u9T+3rkju2vgByPUWfZXB7d//ld4jB7v9w1cM/3EtMMGH4Cw= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2019 14:34:45.1438 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9e5582b9-1da4-43b9-dc18-08d748d80062 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB4587 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zc4lele6dIwjU4c6a3L+IzKflQgRbWkIRbEL8ZX6qzA=; b=9JZlXfB7LJbzJvQaa8xLU84rrHTSOS+STRcYPB6o/20ReacSF/2J9dGyUPKqye51F4M7fm+s8QhYnCZLLfH+KXAMU2Y+wbzJ+ukTwXFN7YaV91axFg1dII+8fOObkG25lxnU7ccrnQz/AuDETBwFrqbtDkS+JTmk6WzN81llQy4= X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zc4lele6dIwjU4c6a3L+IzKflQgRbWkIRbEL8ZX6qzA=; b=9JZlXfB7LJbzJvQaa8xLU84rrHTSOS+STRcYPB6o/20ReacSF/2J9dGyUPKqye51F4M7fm+s8QhYnCZLLfH+KXAMU2Y+wbzJ+ukTwXFN7YaV91axFg1dII+8fOObkG25lxnU7ccrnQz/AuDETBwFrqbtDkS+JTmk6WzN81llQy4= X-Mailman-Original-Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.freedesktop.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.freedesktop.org; dmarc=none action=none header.from=arm.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: Mihail Atanassov , David Airlie , Liviu Dudau , Russell King , Maxime Ripard , "linux-kernel@vger.kernel.org" , "james qian wang \(Arm Technology China\)" , nd , Sean Paul Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" struct komeda_drv has two pointer members only, and both it and its members get allocated separately. Since both members' types are in scope, there's not a lot to gain by keeping the indirection around. To avoid double-free issues, provide a barebones ->release() hook for the driver. Signed-off-by: Mihail Atanassov --- .../gpu/drm/arm/display/komeda/komeda_dev.c | 21 ++++------- .../gpu/drm/arm/display/komeda/komeda_dev.h | 4 +-- .../gpu/drm/arm/display/komeda/komeda_drv.c | 36 +++++++++---------- .../gpu/drm/arm/display/komeda/komeda_kms.c | 26 ++++++++------ .../gpu/drm/arm/display/komeda/komeda_kms.h | 4 +-- 5 files changed, 42 insertions(+), 49 deletions(-) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c index 937a6d4c4865..c84f978cacc3 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c @@ -179,28 +179,23 @@ static int komeda_parse_dt(struct device *dev, struct komeda_dev *mdev) return ret; } -struct komeda_dev *komeda_dev_create(struct device *dev) +int komeda_dev_init(struct komeda_dev *mdev, struct device *dev) { struct platform_device *pdev = to_platform_device(dev); const struct komeda_product_data *product; - struct komeda_dev *mdev; struct resource *io_res; int err = 0; product = of_device_get_match_data(dev); if (!product) - return ERR_PTR(-ENODEV); + return -ENODEV; io_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!io_res) { DRM_ERROR("No registers defined.\n"); - return ERR_PTR(-ENODEV); + return -ENODEV; } - mdev = devm_kzalloc(dev, sizeof(*mdev), GFP_KERNEL); - if (!mdev) - return ERR_PTR(-ENOMEM); - mutex_init(&mdev->lock); mdev->dev = dev; @@ -284,16 +279,16 @@ struct komeda_dev *komeda_dev_create(struct device *dev) komeda_debugfs_init(mdev); #endif - return mdev; + return 0; disable_clk: clk_disable_unprepare(mdev->aclk); err_cleanup: - komeda_dev_destroy(mdev); - return ERR_PTR(err); + komeda_dev_fini(mdev); + return err; } -void komeda_dev_destroy(struct komeda_dev *mdev) +void komeda_dev_fini(struct komeda_dev *mdev) { struct device *dev = mdev->dev; const struct komeda_dev_funcs *funcs = mdev->funcs; @@ -335,8 +330,6 @@ void komeda_dev_destroy(struct komeda_dev *mdev) devm_clk_put(dev, mdev->aclk); mdev->aclk = NULL; } - - devm_kfree(dev, mdev); } int komeda_dev_resume(struct komeda_dev *mdev) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.h b/drivers/gpu/drm/arm/display/komeda/komeda_dev.h index 414200233b64..e392b8ffc372 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.h @@ -213,8 +213,8 @@ komeda_product_match(struct komeda_dev *mdev, u32 target) const struct komeda_dev_funcs * d71_identify(u32 __iomem *reg, struct komeda_chip_info *chip); -struct komeda_dev *komeda_dev_create(struct device *dev); -void komeda_dev_destroy(struct komeda_dev *mdev); +int komeda_dev_init(struct komeda_dev *mdev, struct device *dev); +void komeda_dev_fini(struct komeda_dev *mdev); struct komeda_dev *dev_to_mdev(struct device *dev); diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c index d6c2222c5d33..660181bdc008 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c @@ -14,15 +14,15 @@ #include "komeda_kms.h" struct komeda_drv { - struct komeda_dev *mdev; - struct komeda_kms_dev *kms; + struct komeda_dev mdev; + struct komeda_kms_dev kms; }; struct komeda_dev *dev_to_mdev(struct device *dev) { struct komeda_drv *mdrv = dev_get_drvdata(dev); - return mdrv ? mdrv->mdev : NULL; + return mdrv ? &mdrv->mdev : NULL; } static void komeda_unbind(struct device *dev) @@ -32,8 +32,8 @@ static void komeda_unbind(struct device *dev) if (!mdrv) return; - komeda_kms_detach(mdrv->kms); - komeda_dev_destroy(mdrv->mdev); + komeda_kms_fini(mdrv->kms); + komeda_dev_fini(mdrv->mdev); dev_set_drvdata(dev, NULL); devm_kfree(dev, mdrv); @@ -48,24 +48,20 @@ static int komeda_bind(struct device *dev) if (!mdrv) return -ENOMEM; - mdrv->mdev = komeda_dev_create(dev); - if (IS_ERR(mdrv->mdev)) { - err = PTR_ERR(mdrv->mdev); + err = komeda_dev_init(&mdrv->mdev, dev); + if (err) goto free_mdrv; - } - mdrv->kms = komeda_kms_attach(mdrv->mdev); - if (IS_ERR(mdrv->kms)) { - err = PTR_ERR(mdrv->kms); - goto destroy_mdev; - } + err = komeda_kms_init(&mdrv->kms, &mdrv->mdev); + if (err) + goto fini_mdev; dev_set_drvdata(dev, mdrv); return 0; -destroy_mdev: - komeda_dev_destroy(mdrv->mdev); +fini_mdev: + komeda_dev_fini(&mdrv->mdev); free_mdrv: devm_kfree(dev, mdrv); @@ -140,12 +136,12 @@ MODULE_DEVICE_TABLE(of, komeda_of_match); static int __maybe_unused komeda_pm_suspend(struct device *dev) { struct komeda_drv *mdrv = dev_get_drvdata(dev); - struct drm_device *drm = &mdrv->kms->base; + struct drm_device *drm = &mdrv->kms.base; int res; res = drm_mode_config_helper_suspend(drm); - komeda_dev_suspend(mdrv->mdev); + komeda_dev_suspend(&mdrv->mdev); return res; } @@ -153,9 +149,9 @@ static int __maybe_unused komeda_pm_suspend(struct device *dev) static int __maybe_unused komeda_pm_resume(struct device *dev) { struct komeda_drv *mdrv = dev_get_drvdata(dev); - struct drm_device *drm = &mdrv->kms->base; + struct drm_device *drm = &mdrv->kms.base; - komeda_dev_resume(mdrv->mdev); + komeda_dev_resume(&mdrv->mdev); return drm_mode_config_helper_resume(drm); } diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c index d49772de93e0..03dcf1d7688f 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c @@ -23,6 +23,15 @@ DEFINE_DRM_GEM_CMA_FOPS(komeda_cma_fops); +static void komeda_kms_release(struct drm_device *dev) +{ + drm_dev_fini(dev); + /* + * No need to kfree(dev) since we're stored in an aggregate struct + * that's managed separately. + */ +} + static int komeda_gem_cma_dumb_create(struct drm_file *file, struct drm_device *dev, struct drm_mode_create_dumb *args) @@ -60,6 +69,7 @@ static irqreturn_t komeda_kms_irq_handler(int irq, void *data) static struct drm_driver komeda_kms_driver = { .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC, .lastclose = drm_fb_helper_lastclose, + .release = komeda_kms_release, .gem_free_object_unlocked = drm_gem_cma_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, .dumb_create = komeda_gem_cma_dumb_create, @@ -257,19 +267,15 @@ static void komeda_kms_mode_config_init(struct komeda_kms_dev *kms, config->helper_private = &komeda_mode_config_helpers; } -struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev) +int komeda_kms_init(struct komeda_kms_dev *kms, struct komeda_dev *mdev) { - struct komeda_kms_dev *kms = kzalloc(sizeof(*kms), GFP_KERNEL); struct drm_device *drm; int err; - if (!kms) - return ERR_PTR(-ENOMEM); - drm = &kms->base; err = drm_dev_init(drm, &komeda_kms_driver, mdev->dev); if (err) - goto free_kms; + return err; drm->dev_private = mdev; @@ -319,7 +325,7 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev) if (err) goto free_interrupts; - return kms; + return 0; free_interrupts: drm_kms_helper_poll_fini(drm); @@ -332,12 +338,10 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev) komeda_kms_cleanup_private_objs(kms); drm->dev_private = NULL; drm_dev_put(drm); -free_kms: - kfree(kms); - return ERR_PTR(err); + return err; } -void komeda_kms_detach(struct komeda_kms_dev *kms) +void komeda_kms_fini(struct komeda_kms_dev *kms) { struct drm_device *drm = &kms->base; struct komeda_dev *mdev = drm->dev_private; diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h index 45c498e15e7a..e81ceb298034 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h @@ -181,7 +181,7 @@ void komeda_kms_cleanup_private_objs(struct komeda_kms_dev *kms); void komeda_crtc_handle_event(struct komeda_crtc *kcrtc, struct komeda_events *evts); -struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev); -void komeda_kms_detach(struct komeda_kms_dev *kms); +int komeda_kms_init(struct komeda_kms_dev *kms, struct komeda_dev *mdev); +void komeda_kms_fini(struct komeda_kms_dev *kms); #endif /*_KOMEDA_KMS_H_*/ From patchwork Fri Oct 4 14:34:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihail Atanassov X-Patchwork-Id: 11174693 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 8222313BD for ; Fri, 4 Oct 2019 14:34:56 +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 699FC215EA for ; Fri, 4 Oct 2019 14:34:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 699FC215EA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.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 69EC26EBB7; Fri, 4 Oct 2019 14:34:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80045.outbound.protection.outlook.com [40.107.8.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6D1066EBB9 for ; Fri, 4 Oct 2019 14:34:52 +0000 (UTC) Received: from VI1PR08CA0197.eurprd08.prod.outlook.com (2603:10a6:800:d2::27) by DBBPR08MB4554.eurprd08.prod.outlook.com (2603:10a6:10:d1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.20; Fri, 4 Oct 2019 14:34:49 +0000 Received: from AM5EUR03FT007.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::203) by VI1PR08CA0197.outlook.office365.com (2603:10a6:800:d2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.18 via Frontend Transport; Fri, 4 Oct 2019 14:34:49 +0000 Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT007.mail.protection.outlook.com (10.152.16.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Fri, 4 Oct 2019 14:34:47 +0000 Received: ("Tessian outbound 3fba803f6da3:v33"); Fri, 04 Oct 2019 14:34:47 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0798540fbde5b4ef X-CR-MTA-TID: 64aa7808 Received: from e28735ce9d3a.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.0.55]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 14D801F9-9CE1-413F-9B1E-3C7D8327D8A5.1; Fri, 04 Oct 2019 14:34:42 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01lp2055.outbound.protection.outlook.com [104.47.0.55]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e28735ce9d3a.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 04 Oct 2019 14:34:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Eoh65+Yw/SOSHXFMB0nANtTj7X7phw/0a7R+UGIul1Y3voyG1q1ItIfNhasUQH+Z3tjOAejREGt3HdR6lvvEC5dbDJTyL/SCDfjKXH651XDBfHhykOvPeJf7E4SIlYJdWKqQDS5ZBhhOwTp2g7d8uS3JLpNAZTMOaZfz58KemUkfLs2bCo/ug2NQ6VGHJryRVxrqEp+o/8z1sjzaBzUh/vCjDLQ/pK0KvHfEFhG26b5r8UhWNUgc9ot91D1vsx5UPdIDiSOwtERUI4NAgRAkB3SKbZlRtuabrtjVmCeIo2M40T7rNPdFh4ojIXzgUat36NTv/BsBWJGrt7ED5ss/3A== 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=MK4ZcTaWUSRAjX0xe8+6lEgAOWI0bkyan77WyvE7Nwo=; b=huCNw23ZqbBUP1lLa9cpb/ARdt/lRKwtvRXsElOd5cV3ZaIGPojsh6TDG6dyNybFh0ojUiP46EWKG+eDv+8YXmhRRvfUaFvdtJ3/FBntieAFwOqfFtwdytYOBCodrSLaZN8jkPlofvNfZkmS6I2EITkve7GVOgH7kJeYDvJigqdXIw4xNwhWb0dRFiZ22uaedAuJBJiEpOmmznw1NteX6lE1pnDrkBKW8vszVzf/xSH6sFyk3ifZ/PxDtlrq/NsDnkJ6aEZMAfLIHEPCKULOQbpaJpXPGr74KmKtlncMfFwgI+iOGBLInWPCDq1EWwWCYXv0WEbbqePO422kZsOcXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from VI1PR08MB4078.eurprd08.prod.outlook.com (20.178.127.92) by VI1PR08MB4288.eurprd08.prod.outlook.com (20.179.25.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.20; Fri, 4 Oct 2019 14:34:39 +0000 Received: from VI1PR08MB4078.eurprd08.prod.outlook.com ([fe80::7d25:d1f2:e3eb:868b]) by VI1PR08MB4078.eurprd08.prod.outlook.com ([fe80::7d25:d1f2:e3eb:868b%6]) with mapi id 15.20.2305.023; Fri, 4 Oct 2019 14:34:39 +0000 From: Mihail Atanassov To: "dri-devel@lists.freedesktop.org" Subject: [PATCH 2/3] drm/komeda: Memory manage struct komeda_drv in probe/remove Thread-Topic: [PATCH 2/3] drm/komeda: Memory manage struct komeda_drv in probe/remove Thread-Index: AQHVesDatT7fIDs+C0WcvAQ2c1lXGQ== Date: Fri, 4 Oct 2019 14:34:39 +0000 Message-ID: <20191004143418.53039-3-mihail.atanassov@arm.com> References: <20191004143418.53039-1-mihail.atanassov@arm.com> In-Reply-To: <20191004143418.53039-1-mihail.atanassov@arm.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [217.140.106.52] x-clientproxiedby: LNXP265CA0001.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::13) To VI1PR08MB4078.eurprd08.prod.outlook.com (2603:10a6:803:e5::28) x-mailer: git-send-email 2.23.0 Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Mihail.Atanassov@arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 7e80022c-8d33-4009-83ec-08d748d801f8 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VI1PR08MB4288:|VI1PR08MB4288:|DBBPR08MB4554: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:296;OLM:296; x-forefront-prvs: 018093A9B5 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(396003)(346002)(39860400002)(366004)(376002)(136003)(199004)(189003)(1076003)(66066001)(14454004)(66556008)(102836004)(2906002)(5660300002)(478600001)(36756003)(76176011)(26005)(50226002)(3846002)(2501003)(6116002)(11346002)(66446008)(386003)(186003)(64756008)(6506007)(66476007)(8936002)(66946007)(2616005)(4326008)(256004)(44832011)(81166006)(6512007)(99286004)(486006)(6436002)(5640700003)(8676002)(6486002)(86362001)(25786009)(71190400001)(476003)(6916009)(7736002)(305945005)(71200400001)(446003)(2351001)(54906003)(316002)(52116002)(81156014); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB4288; H:VI1PR08MB4078.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: b5k7dmFBQ7V2Gg0Eey0+UbOOxONeoXqgpT9bskVPXBKYyGlTf6AOjsutW+4i0dA9AM2RB9vbzcj6Kss4zMaSaqRfhYV+/Pt2Ir+0yfqD2hAv14nTx2Rw0upHV0PMY9AwL6YjzgbjD13F28yiiBJflgIvKdeGhh0YctHag3xnXHWLugYW6MK7ZTx0a+LGD73VUMC9kCbrurz/fAQGZfQXMqpdbAn/H0QZYKFHq3kFCNO5MqCMFkOKXYdqGTkHGwPU19EAVyvg4QM1cIMnBtdnVDlk8gBmHofmTiJ67d88PBjZ2vOcnJwFl8vy5Kkbp04VefXz5Qyzhwirn5B9hSO3L8trJioPffQH8+IY6P8BUdN7bV0IbVNHkDT/QY5avgLWfGOsQhhXf8DiNKi6ABWltURNuFPzqO/AOh9h1D3Eb7g= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4288 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Mihail.Atanassov@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT007.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(136003)(376002)(39860400002)(396003)(346002)(199004)(189003)(76176011)(99286004)(2501003)(476003)(478600001)(54906003)(50226002)(2616005)(2351001)(6486002)(76130400001)(86362001)(36756003)(36906005)(102836004)(66066001)(5640700003)(1076003)(6506007)(386003)(486006)(6512007)(47776003)(23756003)(356004)(316002)(186003)(4326008)(336012)(25786009)(8936002)(6116002)(7736002)(3846002)(8746002)(70586007)(70206006)(50466002)(6916009)(305945005)(22756006)(107886003)(26005)(26826003)(81166006)(81156014)(126002)(446003)(63350400001)(14454004)(11346002)(2906002)(8676002)(5660300002); DIR:OUT; SFP:1101; SCL:1; SRVR:DBBPR08MB4554; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:TempError; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; A:1; MX:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 8d42af8c-9711-46bb-beec-08d748d7fcc7 NoDisclaimer: True X-Forefront-PRVS: 018093A9B5 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xHBnrrU4DsOTLLROaR0c+nAx2hXV07YbnJaPjb3rYGnRD7A9/Cn1dDtlB0HHYL80aNQrV+ykvgSSQyJb2YpTzhT8qQlr99hscumgg+C0FSDJE9NUpObcg7B0ZmTrFHXT5XzYQfstj4BAvzoBYuoX3O56Fu3O6p0IdvLR5+Cl//CYYmdyk9BHm0q+1vz9XlPa4vqN4WV0BzwY5mL0UO3LKE8enbhdb8ooNj4Gd7kDs9dEHEYDtOHbKynBMUSsQzh0T1GADZBB13+WC1Z5exmAmrCewIfH28gU4ye0q4SbOg9wt+Q8r+RxB893PAYeutKV8gXtolZsDls4kHzVTFrn5/Ej0Bmmnw02JjekJbh4wG8j5fX4OaOEs7t4XHIp7sAJSt7T610ksfE+HXFjM9+mTk0ERx2Vkr0bT27MhpgWqks= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2019 14:34:47.8803 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e80022c-8d33-4009-83ec-08d748d801f8 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4554 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MK4ZcTaWUSRAjX0xe8+6lEgAOWI0bkyan77WyvE7Nwo=; b=PbGcC81UIqnELOaGaoq5oTb9ucYR3XFbFBAuz7SnVXkVisFMTqMTGEjPFn4TD6CAP0JUV0v9Dpqyvhq4iqfykfJb87uOTy6Tyt6axXq76+ZQUerRGss+tpseBuOh0VFQKUKdnRmc9dYTXbU2HEGrbum5v7iHkyW+8rL3b6YQhN0= X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MK4ZcTaWUSRAjX0xe8+6lEgAOWI0bkyan77WyvE7Nwo=; b=PbGcC81UIqnELOaGaoq5oTb9ucYR3XFbFBAuz7SnVXkVisFMTqMTGEjPFn4TD6CAP0JUV0v9Dpqyvhq4iqfykfJb87uOTy6Tyt6axXq76+ZQUerRGss+tpseBuOh0VFQKUKdnRmc9dYTXbU2HEGrbum5v7iHkyW+8rL3b6YQhN0= X-Mailman-Original-Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.freedesktop.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.freedesktop.org; dmarc=none action=none header.from=arm.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: Mihail Atanassov , David Airlie , Liviu Dudau , Russell King , Maxime Ripard , "linux-kernel@vger.kernel.org" , "james qian wang \(Arm Technology China\)" , nd , Sean Paul Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Some fields of komeda_drv members will be useful very early in probe code, so make sure an instance is available. Signed-off-by: Mihail Atanassov --- .../gpu/drm/arm/display/komeda/komeda_drv.c | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c index 660181bdc008..9ed25ffe0e22 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c @@ -32,22 +32,15 @@ static void komeda_unbind(struct device *dev) if (!mdrv) return; - komeda_kms_fini(mdrv->kms); - komeda_dev_fini(mdrv->mdev); - - dev_set_drvdata(dev, NULL); - devm_kfree(dev, mdrv); + komeda_kms_fini(&mdrv->kms); + komeda_dev_fini(&mdrv->mdev); } static int komeda_bind(struct device *dev) { - struct komeda_drv *mdrv; + struct komeda_drv *mdrv = dev_get_drvdata(dev); int err; - mdrv = devm_kzalloc(dev, sizeof(*mdrv), GFP_KERNEL); - if (!mdrv) - return -ENOMEM; - err = komeda_dev_init(&mdrv->mdev, dev); if (err) goto free_mdrv; @@ -56,8 +49,6 @@ static int komeda_bind(struct device *dev) if (err) goto fini_mdev; - dev_set_drvdata(dev, mdrv); - return 0; fini_mdev: @@ -97,10 +88,15 @@ static int komeda_platform_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct component_match *match = NULL; struct device_node *child; + struct komeda_drv *mdrv; if (!dev->of_node) return -ENODEV; + mdrv = devm_kzalloc(dev, sizeof(*mdrv), GFP_KERNEL); + if (!mdrv) + return -ENOMEM; + for_each_available_child_of_node(dev->of_node, child) { if (of_node_cmp(child->name, "pipeline") != 0) continue; @@ -110,12 +106,20 @@ static int komeda_platform_probe(struct platform_device *pdev) komeda_add_slave(dev, &match, child, KOMEDA_OF_PORT_OUTPUT, 1); } + dev_set_drvdata(dev, mdrv); + return component_master_add_with_match(dev, &komeda_master_ops, match); } static int komeda_platform_remove(struct platform_device *pdev) { - component_master_del(&pdev->dev, &komeda_master_ops); + struct device *dev = &pdev->dev; + struct komeda_drv *mdrv = dev_get_drvdata(dev); + + component_master_del(dev, &komeda_master_ops); + + dev_set_drvdata(dev, NULL); + devm_kfree(dev, mdrv); return 0; } From patchwork Fri Oct 4 14:34:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihail Atanassov X-Patchwork-Id: 11174697 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 6E40C76 for ; Fri, 4 Oct 2019 14:35:00 +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 511BD215EA for ; Fri, 4 Oct 2019 14:35:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 511BD215EA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.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 4C4326EBBB; Fri, 4 Oct 2019 14:34:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00044.outbound.protection.outlook.com [40.107.0.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4D9646EBBB for ; Fri, 4 Oct 2019 14:34:55 +0000 (UTC) Received: from VI1PR08CA0216.eurprd08.prod.outlook.com (2603:10a6:802:15::25) by AM5PR0802MB2401.eurprd08.prod.outlook.com (2603:10a6:203:9d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.20; Fri, 4 Oct 2019 14:34:51 +0000 Received: from VE1EUR03FT052.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::209) by VI1PR08CA0216.outlook.office365.com (2603:10a6:802:15::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2327.23 via Frontend Transport; Fri, 4 Oct 2019 14:34:51 +0000 Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT052.mail.protection.outlook.com (10.152.19.173) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Fri, 4 Oct 2019 14:34:49 +0000 Received: ("Tessian outbound 851a1162fca7:v33"); Fri, 04 Oct 2019 14:34:49 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 1f8cbc9fb4748bd1 X-CR-MTA-TID: 64aa7808 Received: from 393823e7005a.1 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.4.54]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 5BD2E0D3-AC41-4050-AAB7-AC1F822AAA42.1; Fri, 04 Oct 2019 14:34:44 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02lp2054.outbound.protection.outlook.com [104.47.4.54]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 393823e7005a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 04 Oct 2019 14:34:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N6fW52EVlPO89VZ0t54WyPEOjt4ipnaN3NU3HJ8B/rIQ7Yo6hRRUUwat7MyPE55rlGIwFfTHCcUTFONBiCHohtVqbGOzu+AQ6o1Qm7GAj4J4zTqDMQS14d5tPJn3QC6bkszDq2Lq4X4jxXydv5XG6Pz/lT4R0UrxI1rW1U5fsffzOPTXWFTR2cdOsJSAU/nRvHe0OHp/K1lIEDFjgsJyQHejp+YBLD936hiBFKyzJeGECaQKxQnAbxDPxJ3T4gx+y3KcxzDOoCms8HLD9DQ+DuLSvEhlBqZTsPfsV8Y9FTbTw9wHvTdpiPHe21Tvq7pxtsm64ErIOmciEURLxowYgg== 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=mNdHO3i6gvnroogALjLGcMFWCn+EzncaOt64/SWnjVg=; b=SrQ60GCjcgLJWZLO1KRMp61dUD4TMspft5I/AJihjQ+IQfOC8XtJIunEZbzx6zUYyEIwGOBakjyAniETH4yUFaXUQuRhd7+TMU2AaSZA+MrXR3JlQqmBri4zzvkPcVEgTtxkjp6FHpod2TMYPCBejfGbvgHBTOboj44BIYe0zNjp78mvZ0vaY2+HmmWPlTQAxaHMXVUWJtxbIL2SzQ7f8GFqQkiS8Kp0hbk/GFuvkSK0mvxZmtu3f98w0q9qooavIU/6k9Ywpvrfk5X+Lcbmdb0ItCwehDi+bx9ik0LDnpwrE0mweHyoFyLIcvxAycWQDJTW8Xl2hqy29qhjQ+iuRA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from VI1PR08MB4078.eurprd08.prod.outlook.com (20.178.127.92) by VI1PR08MB3791.eurprd08.prod.outlook.com (20.178.15.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.20; Fri, 4 Oct 2019 14:34:42 +0000 Received: from VI1PR08MB4078.eurprd08.prod.outlook.com ([fe80::7d25:d1f2:e3eb:868b]) by VI1PR08MB4078.eurprd08.prod.outlook.com ([fe80::7d25:d1f2:e3eb:868b%6]) with mapi id 15.20.2305.023; Fri, 4 Oct 2019 14:34:42 +0000 From: Mihail Atanassov To: "dri-devel@lists.freedesktop.org" Subject: [RFC PATCH 3/3] drm/komeda: Allow non-component drm_bridge only endpoints Thread-Topic: [RFC PATCH 3/3] drm/komeda: Allow non-component drm_bridge only endpoints Thread-Index: AQHVesDbPaY1L1VuWkStjJCfY/hwXQ== Date: Fri, 4 Oct 2019 14:34:42 +0000 Message-ID: <20191004143418.53039-4-mihail.atanassov@arm.com> References: <20191004143418.53039-1-mihail.atanassov@arm.com> In-Reply-To: <20191004143418.53039-1-mihail.atanassov@arm.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [217.140.106.52] x-clientproxiedby: LNXP265CA0001.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::13) To VI1PR08MB4078.eurprd08.prod.outlook.com (2603:10a6:803:e5::28) x-mailer: git-send-email 2.23.0 Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Mihail.Atanassov@arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: d796e427-5269-4da5-5bc7-08d748d80300 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VI1PR08MB3791:|VI1PR08MB3791:|AM5PR0802MB2401: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:421;OLM:421; x-forefront-prvs: 018093A9B5 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(366004)(376002)(396003)(346002)(39860400002)(136003)(189003)(199004)(66066001)(2906002)(36756003)(66946007)(316002)(71200400001)(71190400001)(6512007)(54906003)(256004)(5024004)(14444005)(3846002)(6116002)(5640700003)(6436002)(1076003)(476003)(486006)(7736002)(81166006)(81156014)(44832011)(6486002)(52116002)(8676002)(26005)(386003)(6506007)(2501003)(25786009)(50226002)(86362001)(2616005)(305945005)(478600001)(76176011)(11346002)(446003)(186003)(8936002)(4326008)(6916009)(5660300002)(2351001)(14454004)(66556008)(99286004)(64756008)(66476007)(66446008)(102836004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB3791; H:VI1PR08MB4078.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ixU5OnmONMifDDPRNUhG+1LvhCR4KYL+uezm6Q/bOaJtELic6B4E0RjZ2fmFpYmJ1vzMS8G1SJpw50TAFZBASee3mOKywy7nu91OFp76TabqX5M9OTPNllhC/aqYWvJuc8E36mCTCJW6Leg9UgHGPB9dU8/SBNot0/FMGbmiW+K3JsnYHyRII78rtnA+bDG6b0Xq+tlQECqeIhJF6phjKDOVqS0xiG6NCKO9nFk2z54pSDU8yq0SXJoNodCNKNQfJwWZCmeo3AnhuXXVTf2AEoe7pFpQUNvovp+zWJJU5IHUnRGWg0O+MdSyBAuO9bBLY/498AYMBGTMWvYOh8AW98uoM+rxbFv21SWFfMU+HwmNdO/7Gf8wptC3CHqAdHyp1dI2Nubv21Nx8EGPQhbGhtK4UYNm+BQwSE/WUA+1KGQ= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3791 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Mihail.Atanassov@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT052.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(396003)(346002)(136003)(376002)(199004)(189003)(66066001)(25786009)(446003)(5640700003)(8746002)(2616005)(486006)(6916009)(6486002)(126002)(476003)(36906005)(54906003)(47776003)(22756006)(305945005)(7736002)(5660300002)(316002)(11346002)(76176011)(86362001)(70586007)(70206006)(76130400001)(50226002)(8936002)(2351001)(6512007)(4326008)(14444005)(5024004)(50466002)(356004)(8676002)(3846002)(36756003)(81156014)(81166006)(2501003)(2906002)(386003)(63350400001)(23756003)(6116002)(99286004)(6506007)(14454004)(1076003)(186003)(478600001)(26005)(336012)(102836004)(26826003)(107886003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0802MB2401; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:TempError; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; A:1; MX:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 1b96fdd2-3b6d-4d12-7262-08d748d7fe4e NoDisclaimer: True X-Forefront-PRVS: 018093A9B5 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OappirnqM+GMNS0KNaAPJ2zVFd5NCrXxUJat1dTNxRsQhTM571LMeld6tEE3l1wKNps2imByfUbhT+Y3qHEFOFODNWPwSzWoKQ24JHTCZa297B8WJ766t07d4fIuS+IbfpVDx1NazUvSNtTY68G201TIoIdwS1gNM7/kDjQ3O4tOXyIdD04/LNMl5cQe1v5FfNzjOEe1p0BkJQw5iRxCN1jOQAk1mcqANauK3PcZTs63Q4PNejOdz1TFwfStzAcWR7BlH+IcH/fpO6sloBniKI1V2r82WmmhCKKsnCHEXYFDi+C0NuubMB14I4PA2p9AQMFg6XqJ/gsy35frePFK7Y5JdABm66gBOnWpgjpxqdJjGknH7HK0dgMdHDi8w7J6pOCFGsyJY/8PNWvbZhfcXOsJf4EoURGfjrtg3XrKpyM= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2019 14:34:49.5094 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d796e427-5269-4da5-5bc7-08d748d80300 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2401 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mNdHO3i6gvnroogALjLGcMFWCn+EzncaOt64/SWnjVg=; b=FNxTreWfT8Q6cX75Ijk/pTB5ag4ENU6AATTMEscN7lTCKYf3hQR5WWcT+4B5ginZ4jyBObFrJtkEY5SwzMGyhColr6U1mCGp8gevSAq0cH+HT29HVWt+RtIYvQniyXACDsrL7parjfi76F37XZBvHA+4sm0ooV/TpMg+IYcM/WU= X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mNdHO3i6gvnroogALjLGcMFWCn+EzncaOt64/SWnjVg=; b=FNxTreWfT8Q6cX75Ijk/pTB5ag4ENU6AATTMEscN7lTCKYf3hQR5WWcT+4B5ginZ4jyBObFrJtkEY5SwzMGyhColr6U1mCGp8gevSAq0cH+HT29HVWt+RtIYvQniyXACDsrL7parjfi76F37XZBvHA+4sm0ooV/TpMg+IYcM/WU= X-Mailman-Original-Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.freedesktop.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.freedesktop.org; dmarc=none action=none header.from=arm.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: Mihail Atanassov , David Airlie , Liviu Dudau , Russell King , Maxime Ripard , "linux-kernel@vger.kernel.org" , "james qian wang \(Arm Technology China\)" , nd , Sean Paul Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To support transmitters other than the tda998x, we need to allow non-component framework bridges to be attached to a dummy drm_encoder in our driver. For the existing supported encoder (tda998x), keep the behaviour as-is, since there's no way to unbind if a drm_bridge module goes away under our feet. Signed-off-by: Mihail Atanassov Signed-off-by: Russell King Tested-by: Mihail Atanassov --- .../gpu/drm/arm/display/komeda/komeda_dev.h | 5 + .../gpu/drm/arm/display/komeda/komeda_drv.c | 58 ++++++-- .../gpu/drm/arm/display/komeda/komeda_kms.c | 133 +++++++++++++++++- .../gpu/drm/arm/display/komeda/komeda_kms.h | 5 + 4 files changed, 187 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.h b/drivers/gpu/drm/arm/display/komeda/komeda_dev.h index e392b8ffc372..64d2902e2e0c 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.h @@ -176,6 +176,11 @@ struct komeda_dev { /** @irq: irq number */ int irq; + /** @has_components: + * + * if true, use the component framework to bind/unbind driver + */ + bool has_components; /** @lock: used to protect dpmode */ struct mutex lock; diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c index 9ed25ffe0e22..34cfc6a4c3e4 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include "komeda_dev.h" #include "komeda_kms.h" @@ -69,18 +71,35 @@ static int compare_of(struct device *dev, void *data) return dev->of_node == data; } -static void komeda_add_slave(struct device *master, - struct component_match **match, - struct device_node *np, - u32 port, u32 endpoint) +static int komeda_add_slave(struct device *master, + struct komeda_drv *mdrv, + struct component_match **match, + struct device_node *np, + u32 port, u32 endpoint) { struct device_node *remote; + struct drm_bridge *bridge; + int ret = 0; remote = of_graph_get_remote_node(np, port, endpoint); - if (remote) { + if (!remote) + return 0; + + if (komeda_remote_device_is_component(np, port, endpoint)) { + mdrv->mdev.has_components = true; drm_of_component_match_add(master, match, compare_of, remote); - of_node_put(remote); + goto exit; + } + + bridge = of_drm_find_bridge(remote); + if (!bridge) { + ret = -EPROBE_DEFER; + goto exit; } + +exit: + of_node_put(remote); + return ret; } static int komeda_platform_probe(struct platform_device *pdev) @@ -89,6 +108,7 @@ static int komeda_platform_probe(struct platform_device *pdev) struct component_match *match = NULL; struct device_node *child; struct komeda_drv *mdrv; + int ret; if (!dev->of_node) return -ENODEV; @@ -101,14 +121,27 @@ static int komeda_platform_probe(struct platform_device *pdev) if (of_node_cmp(child->name, "pipeline") != 0) continue; - /* add connector */ - komeda_add_slave(dev, &match, child, KOMEDA_OF_PORT_OUTPUT, 0); - komeda_add_slave(dev, &match, child, KOMEDA_OF_PORT_OUTPUT, 1); + /* attach any remote devices if present */ + ret = komeda_add_slave(dev, mdrv, &match, child, + KOMEDA_OF_PORT_OUTPUT, 0); + if (ret) + goto free_mdrv; + ret = komeda_add_slave(dev, mdrv, &match, child, + KOMEDA_OF_PORT_OUTPUT, 1); + if (ret) + goto free_mdrv; } dev_set_drvdata(dev, mdrv); - return component_master_add_with_match(dev, &komeda_master_ops, match); + return mdrv->mdev.has_components + ? component_master_add_with_match( + dev, &komeda_master_ops, match) + : komeda_bind(dev); + +free_mdrv: + devm_kfree(dev, mdrv); + return ret; } static int komeda_platform_remove(struct platform_device *pdev) @@ -116,7 +149,10 @@ static int komeda_platform_remove(struct platform_device *pdev) struct device *dev = &pdev->dev; struct komeda_drv *mdrv = dev_get_drvdata(dev); - component_master_del(dev, &komeda_master_ops); + if (mdrv->mdev.has_components) + component_master_del(dev, &komeda_master_ops); + else + komeda_unbind(dev); dev_set_drvdata(dev, NULL); devm_kfree(dev, mdrv); diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c index 03dcf1d7688f..6eb52d1b20a0 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c @@ -6,6 +6,7 @@ */ #include #include +#include #include #include @@ -14,6 +15,8 @@ #include #include #include +#include +#include #include #include @@ -267,6 +270,130 @@ static void komeda_kms_mode_config_init(struct komeda_kms_dev *kms, config->helper_private = &komeda_mode_config_helpers; } +static void komeda_encoder_destroy(struct drm_encoder *encoder) +{ + drm_encoder_cleanup(encoder); +} + +static const struct drm_encoder_funcs komeda_dummy_enc_funcs = { + .destroy = komeda_encoder_destroy, +}; + +bool komeda_remote_device_is_component(struct device_node *local, + u32 port, u32 endpoint) +{ + struct device_node *remote; + char const * const component_devices[] = { + "nxp,tda998x", + }; + int i; + bool ret = false; + + remote = of_graph_get_remote_node(local, port, endpoint); + if (!remote) + return false; + + /* Coprocessor endpoints are always component based. */ + if (port != KOMEDA_OF_PORT_OUTPUT) { + ret = true; + goto exit; + } + + for (i = 0; i < ARRAY_SIZE(component_devices); ++i) { + if (of_device_is_compatible(remote, component_devices[i])) { + ret = true; + goto exit; + } + } + +exit: + of_node_put(remote); + return ret; +} + +static int komeda_encoder_attach_bridge(struct komeda_dev *mdev, + struct komeda_kms_dev *kms, + struct drm_encoder *encoder, + struct device_node *np) +{ + struct device_node *remote; + struct drm_bridge *bridge; + u32 crtcs = 0; + int ret = 0; + + if (komeda_remote_device_is_component(np, KOMEDA_OF_PORT_OUTPUT, 0)) + return 0; + + remote = of_graph_get_remote_node(np, KOMEDA_OF_PORT_OUTPUT, 0); + if (!remote) + return 0; + + bridge = of_drm_find_bridge(remote); + if (!bridge) { + ret = -EINVAL; + goto exit; + } + + crtcs = drm_of_find_possible_crtcs(&kms->base, remote); + + encoder->possible_crtcs = crtcs ? crtcs : 1; + + ret = drm_encoder_init(&kms->base, encoder, + &komeda_dummy_enc_funcs, DRM_MODE_ENCODER_TMDS, + NULL); + if (ret) + goto exit; + + ret = drm_bridge_attach(encoder, bridge, NULL); + if (ret) + goto exit; + +exit: + of_node_put(remote); + return ret; +} + +static int komeda_encoder_attach_bridges(struct komeda_kms_dev *kms, + struct komeda_dev *mdev) +{ + int i, err; + + for (i = 0; i < kms->n_crtcs; i++) { + err = komeda_encoder_attach_bridge( + mdev, kms, + &kms->encoders[i], mdev->pipelines[i]->of_node); + if (err) + return err; + } + + return 0; +} + +static int komeda_kms_attach_external(struct komeda_kms_dev *kms, + struct komeda_dev *mdev) +{ + int err; + + if (mdev->has_components) { + err = component_bind_all(mdev->dev, kms); + if (err) + return err; + } + + err = komeda_encoder_attach_bridges(kms, mdev); + if (err) + return err; + + return 0; +} + +static void komeda_kms_detach_external(struct komeda_dev *mdev, + struct drm_device *drm) +{ + if (mdev->has_components) + component_unbind_all(mdev->dev, drm); +} + int komeda_kms_init(struct komeda_kms_dev *kms, struct komeda_dev *mdev) { struct drm_device *drm; @@ -301,7 +428,7 @@ int komeda_kms_init(struct komeda_kms_dev *kms, struct komeda_dev *mdev) if (err) goto cleanup_mode_config; - err = component_bind_all(mdev->dev, kms); + err = komeda_kms_attach_external(kms, mdev); if (err) goto cleanup_mode_config; @@ -332,7 +459,7 @@ int komeda_kms_init(struct komeda_kms_dev *kms, struct komeda_dev *mdev) drm->irq_enabled = false; mdev->funcs->disable_irq(mdev); free_component_binding: - component_unbind_all(mdev->dev, drm); + komeda_kms_detach_external(mdev, drm); cleanup_mode_config: drm_mode_config_cleanup(drm); komeda_kms_cleanup_private_objs(kms); @@ -351,7 +478,7 @@ void komeda_kms_fini(struct komeda_kms_dev *kms) drm_atomic_helper_shutdown(drm); drm->irq_enabled = false; mdev->funcs->disable_irq(mdev); - component_unbind_all(mdev->dev, drm); + komeda_kms_detach_external(mdev, drm); drm_mode_config_cleanup(drm); komeda_kms_cleanup_private_objs(kms); drm->dev_private = NULL; diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h index e81ceb298034..c2856e19d092 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -123,6 +124,7 @@ struct komeda_kms_dev { int n_crtcs; /** @crtcs: crtcs list */ struct komeda_crtc crtcs[KOMEDA_MAX_PIPELINES]; + struct drm_encoder encoders[KOMEDA_MAX_PIPELINES]; }; #define to_kplane(p) container_of(p, struct komeda_plane, base) @@ -184,4 +186,7 @@ void komeda_crtc_handle_event(struct komeda_crtc *kcrtc, int komeda_kms_init(struct komeda_kms_dev *kms, struct komeda_dev *mdev); void komeda_kms_fini(struct komeda_kms_dev *kms); +bool komeda_remote_device_is_component(struct device_node *local, + u32 port, u32 endpoint); + #endif /*_KOMEDA_KMS_H_*/