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; }