Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10938442ybi; Thu, 25 Jul 2019 07:20:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpHG7I/mc5wv5Jx4B7sPUFcPOD9I6myiSJfPRt8DwgyvzE9EmNKBYYM2aPTMXoFb+FAXm5 X-Received: by 2002:a17:902:e512:: with SMTP id ck18mr86567475plb.53.1564064439429; Thu, 25 Jul 2019 07:20:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564064439; cv=none; d=google.com; s=arc-20160816; b=OzvwSxtbcqX+G/CE1VjQnY4OeB3vN/AYGwHbAuiLemH5RGW7RyX2/piQcn3Bwgk4yV mKcG+kwqzB/09mmVJuLMbboqrT+CxEaAxFmRoA/AHGMX8LdPqrH2D8FFxmtcZS0+FRTp qLyXSpk4rgHO7Ar9te6D4/V8bTh9IJUznw6QPMjJSU7KeLEs1Ju/DJMaS4M+0XKQgqYQ dyTnqn9lse9z/S3peWGsjHtxZbcK8OGeIS6c0cUoVusCrsRG3YQXrWRucuHjQduFOrrr TZgnXZ70sOUOtob1MFQuogY2fT468p+lvV3B95Npy6O9QYFFknuWRwQ+RCgVj4nRtgfI CfMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=3jsXiSyd82D9s7oD48YknnfMAO/DOTvl19K2R9LavQ0=; b=xSmfUNIj5IwOjuI7Mm0hDvVxMoXyDO2M/TZ2CfK819l5RKz5t5TSku5ndTKmDMUpj7 xoQ4vMIqgVuLQeDF9W0tng7YK3f87RQBJeKwDdPW81GlXryZ/FopcMSxh0k/x1230CuG yymcKyYnyPfme6Q6jhKJaWeYINAb77Pry20lM/2CJJHEU/tbhr6AU6iWP8UwMdAG83Cf Evrdw87T0woda8YdYS68HB+LTg56cJf8VsCwZ0r2+69siu2T6H0y2dXsf8tbZ6MwKhha 1ycHmWm9DkGb0h2KT1M948eErpd01dp7AmXzYX7xiZewvvuy+XSGSN5WQZrEVDhNON2r dyLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YOxSG8MN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bj5si15415722plb.227.2019.07.25.07.20.24; Thu, 25 Jul 2019 07:20:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YOxSG8MN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389430AbfGYNiy (ORCPT + 99 others); Thu, 25 Jul 2019 09:38:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:47440 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387959AbfGYNix (ORCPT ); Thu, 25 Jul 2019 09:38:53 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 791B92238C; Thu, 25 Jul 2019 13:38:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564061933; bh=jlsOsLLZzXiGnKWyHRln4ewYE4NqswfShzMVdsaJ5nM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YOxSG8MN51AA/XDSj9b/sEo4PEpqypukfdcgUkrd8+BG/egBOOQlspkazTPJLMnpu tqpdLl2QV1lDHi+uW19iEd80z5iMPSAEJnJs20zyqTiPFo6s6/s901fRwAoBV1Rh2P bBBFWV86uWwo0cJ7aLh4s2xTJ+XUtXQk7DHyyvkw= Date: Thu, 25 Jul 2019 15:38:50 +0200 From: Greg KH To: junxiao.chang@intel.com Cc: linux-kernel@vger.kernel.org, rafael@kernel.org, lili.li@intel.com Subject: Re: [PATCH] platform: release resource itself instead of resource tree Message-ID: <20190725133850.GB11115@kroah.com> References: <1556173458-9318-1-git-send-email-junxiao.chang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1556173458-9318-1-git-send-email-junxiao.chang@intel.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 25, 2019 at 02:24:18PM +0800, junxiao.chang@intel.com wrote: > From: Junxiao Chang > > When platform device is deleted or there is error in adding > device, platform device resources should be released. Currently > API release_resource is used to release platform device resources. > However, this API releases not only platform resource itself but > also its child resources. It might release resources which are > still in use. Calling remove_resource only releases current > resource itself, not resource tree, it moves its child resources > to up level. But shouldn't the parent device not get removed until all of the children are removed? What is causing this "inversion" to happen? > > For example, platform device 1 and device 2 are registered, then only > device 1 is unregistered in below code: > > ... > // Register platform test device 1, resource 0xfed1a000 ~ 0xfed1afff > pdev1 = platform_device_register_full(&pdevinfo1); > > // Register platform test device 2, resource 0xfed1a200 ~ 0xfed1a2ff > pdev2 = platform_device_register_full(&pdevinfo2); > > // Now platform device 2 resource should be device 1 resource's child > > // Unregister device 1 only > platform_device_unregister(pdev1); > ... Don't do that. :) You created this mess of platform devices, so you need to keep track of them. > Platform device 2 resource will be released as well because its > parent resource(device 1's resource) is released, this is not expected. > If using API remove_resource, device 2 resource will not be released. > > This change fixed an intel pmc platform device resource issue when > intel pmc ipc kernel module is inserted/removed for twice. Why not fix that kernel module instead? It seems like that is the real problem here, not a driver core issue. thanks, greg k-h