From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751545AbdBCPxM (ORCPT ); Fri, 3 Feb 2017 10:53:12 -0500 Received: from mail-eopbgr00050.outbound.protection.outlook.com ([40.107.0.50]:47612 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751461AbdBCPxK (ORCPT ); Fri, 3 Feb 2017 10:53:10 -0500 From: Laurentiu Tudor To: Stuart Yoder , "gregkh@linuxfoundation.org" CC: "devel@driverdev.osuosl.org" , "arnd@arndb.de" , Ruxandra Ioana Radulescu , "Roy Pledge" , "linux-kernel@vger.kernel.org" , "agraf@suse.de" , "Catalin Horghidan" , Leo Li Subject: Re: [PATCH 3/9] staging: fsl-mc: add device release callback Thread-Topic: [PATCH 3/9] staging: fsl-mc: add device release callback Thread-Index: AdJ9sMNezK1x6+sdQsOghepgXnO3DwAhNTkA Date: Fri, 3 Feb 2017 15:53:01 +0000 Message-ID: <5894A75C.9050505@nxp.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=laurentiu.tudor@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [192.88.146.1] x-microsoft-exchange-diagnostics: 1;VI1PR0401MB2637;7:b07bkGWsdLPYHwUUAM0S/0uLAZbwMLUqKrRA+mDwBJESQOAoxIWqy7LAUmGu6UPwJetsh3UBvqnnlySR2Z53bnbqg/g5RGWRf8KiVkwz6/8zMAJ1cl1bzxRyZ9X+D5R1DXpXFeiep3H33pWLB2KhgcQYI2Lx//pkBEbD9n4t9lLEKfde8PoPlubbmMThZxMoyxaMyEkUrXNeKoBKuWDu6PzUcL4+LTX/1n2VFOGhNKCd8C7W6X7KJ9sAdPNJtZjg8RfR5qIHISL2NqhMymREryQKpQeL76OXfwIqG6S2ipqGgVBnDuYWyyvexqiqFtER1vb77RyhiyfgmFQPlIwKK/WSi7GtZrgn4L2mQN82ag5jm7yBH1bgngpxwjR0Ymz9q5D9YeZVMyEcyN1U7N0hNs+S8GLuyfeQE4RJUKMrPiXCPqUSqmen7JKDdTj96IHzGXV9+u7fAK9oPbSyecX0wvK+w3CX7hUIX0KnVKW3RMJZyijZBjdFMu1g+zCiUfy4ijXb3JUCGf62l3huynBi+w== x-forefront-antispam-report: SFV:SKI;SCL:-1SFV:NSPM;SFS:(10009020)(979002)(6009001)(7916002)(39850400002)(39840400002)(39410400002)(39860400002)(39450400003)(13464003)(189002)(377454003)(24454002)(199003)(189998001)(5001770100001)(97736004)(2906002)(4326007)(102836003)(33656002)(66066001)(2900100001)(59896002)(3280700002)(86362001)(36756003)(6116002)(3846002)(92566002)(6486002)(229853002)(77096006)(38730400001)(6506006)(25786008)(6512007)(54906002)(6436002)(2501003)(3660700001)(99286003)(68736007)(101416001)(81156014)(50986999)(5660300001)(53936002)(7736002)(122556002)(76176999)(87266999)(54356999)(53546003)(81166006)(305945005)(8936002)(2950100002)(80316001)(105586002)(6246003)(106356001)(65816999)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0401MB2637;H:VI1PR0401MB1856.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; x-ms-office365-filtering-correlation-id: 9db8f192-d9d1-427b-29c0-08d44c4cbb9d x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081);SRVR:VI1PR0401MB2637; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(185117386973197); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(20161123558025)(20161123564025)(20161123560025)(20161123562025)(20161123555025)(6072148);SRVR:VI1PR0401MB2637;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0401MB2637; x-forefront-prvs: 02070414A1 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="Windows-1252" Content-ID: MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Feb 2017 15:53:01.3896 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2637 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v13FrLBD002512 On 02/03/2017 02:02 AM, Stuart Yoder wrote: > >> -----Original Message----- >> From: upstream-release-bounces@linux.freescale.net [mailto:upstream-release- >> bounces@linux.freescale.net] On Behalf Of laurentiu.tudor@nxp.com >> Sent: Wednesday, February 01, 2017 5:43 AM >> To: gregkh@linuxfoundation.org >> Cc: devel@driverdev.osuosl.org; arnd@arndb.de; Ruxandra Ioana Radulescu ; >> Roy Pledge ; linux-kernel@vger.kernel.org; agraf@suse.de; Catalin Horghidan >> ; Leo Li ; Stuart Yoder ; >> Laurentiu Tudor >> Subject: [upstream-release] [PATCH 3/9] staging: fsl-mc: add device release callback >> >> From: Laurentiu Tudor >> >> When hot unplugging a mc-bus device the kernel displays >> this pertinent message, followed by a stack dump: >> "Device 'foo.N' does not have a release() function, >> it is broken and must be fixed." >> Add the required callback to fix. >> >> Signed-off-by: Laurentiu Tudor >> --- >> drivers/staging/fsl-mc/bus/fsl-mc-bus.c | 17 +++++++++++++++++ >> 1 file changed, 17 insertions(+) >> >> diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c >> index 7c6a43b..6601bde 100644 >> --- a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c >> +++ b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c >> @@ -419,6 +419,22 @@ bool fsl_mc_is_root_dprc(struct device *dev) >> return dev == root_dprc_dev; >> } >> >> +static void fsl_mc_device_release(struct device *dev) >> +{ >> + struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); >> + struct fsl_mc_bus *mc_bus = NULL; >> + >> + kfree(mc_dev->regions); >> + >> + if (strcmp(mc_dev->obj_desc.type, "dprc") == 0) >> + mc_bus = to_fsl_mc_bus(mc_dev); >> + >> + if (mc_bus) >> + devm_kfree(mc_dev->dev.parent, mc_bus); >> + else >> + kmem_cache_free(mc_dev_cache, mc_dev); >> +} >> + >> /** >> * Add a newly discovered fsl-mc device to be visible in Linux >> */ >> @@ -460,6 +476,7 @@ int fsl_mc_device_add(struct dprc_obj_desc *obj_desc, >> device_initialize(&mc_dev->dev); >> mc_dev->dev.parent = parent_dev; >> mc_dev->dev.bus = &fsl_mc_bus_type; >> + mc_dev->dev.release = fsl_mc_device_release; >> dev_set_name(&mc_dev->dev, "%s.%d", obj_desc->type, obj_desc->id); >> >> if (strcmp(obj_desc->type, "dprc") == 0) { >> -- > > With this patch applied, you still have this: > > void fsl_mc_device_remove(struct fsl_mc_device *mc_dev) > { > struct fsl_mc_bus *mc_bus = NULL; > > kfree(mc_dev->regions); > > /* > * The device-specific remove callback will get invoked by device_del() > */ > device_del(&mc_dev->dev); > put_device(&mc_dev->dev); > > if (strcmp(mc_dev->obj_desc.type, "dprc") == 0) > mc_bus = to_fsl_mc_bus(mc_dev); > > if (mc_bus) > devm_kfree(mc_dev->dev.parent, mc_bus); > else > kmem_cache_free(mc_dev_cache, mc_dev); > } > > ...i.e. you are doing the same thing in 2 places. You > need to remove the kfree/devm_kfree/ kmem_cache_free, > here, no? > Right, thanks for spotting. I started working on a v2 of the series. --- Best Regards, Laurentiu