Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp120426ybi; Fri, 26 Jul 2019 07:05:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqw2BFWr/29Lv5Hjs30a/+3IdnHPYdUYANR1OKlfDKT/oLtXmjykMIxgywucp8xNcUlpkYfQ X-Received: by 2002:a62:e710:: with SMTP id s16mr23134842pfh.183.1564149928675; Fri, 26 Jul 2019 07:05:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564149928; cv=none; d=google.com; s=arc-20160816; b=OEj3TfWmQCr0c1h2kiyHE+UMmGgjdRvWGZa3497zZJAZCeaw2blqV3+K6Hiqna4+XK wxZWk5UgweobK0QweNpiVQ45R09TrYYmwxppwclhxlBSt5gO3NFLn3AdP8FHht7vxp4g d36e2e1pvnNrbaFfRHYG+eWL9x2cyMreKV7FCUaTmnm4hbHP8AiD4tlyfhlCezvHNiZd Y7/pWrCk8vkFgtG2o4qKUgVF1xjMoxoAsE4YlnHraqv+rB2tP56utVik17abr3QQA50K 0+dCqoH02yutYqHeABqOdyCvaThq6wdqm+9NjnvcYI2SJAySvZdEdeQ9urP9mm3mhL1v ReaQ== 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=MvxZrABPK/che8S8Bn4lOpMa/XhKt09NJYGIxT6dkT4=; b=qZpzdeBgrXakaOw/S7ZxfLta1aVDlqogRGFFBQMhstaksUuKt0p3aXegXYf44JKgPa 6EpzAu4VL9IvT41/lvH0uIuaFAkqR46t3Me5+HSAT1Xj6KBhEeuOjJ0KQsqfuixEwcTh lZygEsjcADM3m1Ycdgkvs1BL3+Yu28x/rZhyPGxa0XgM8UTH68QfKkFq8ebmrwDYh7Sa aqpkX0LOq70i2NY5b0LEBEumtNfNg+qb1GMsDANtisDzAfl+fY4lzo6g1ThwSJVmBtV/ dasNhlj4XbWIbj3BRVCkfmeHaVJjSg6YG6SEd/Al5CCHN/4sBCfAS0hIuirAAjxU6MNG mEng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mOFvSAqx; 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 i1si24957509pfr.203.2019.07.26.07.05.13; Fri, 26 Jul 2019 07:05:28 -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=mOFvSAqx; 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 S2387521AbfGZOBZ (ORCPT + 99 others); Fri, 26 Jul 2019 10:01:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:42332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388797AbfGZOBW (ORCPT ); Fri, 26 Jul 2019 10:01:22 -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 5712420659; Fri, 26 Jul 2019 14:01:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564149681; bh=FVYNxjJLl/W5Dert07lPwnlV/q5+htxqU2YZhMN4tVA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mOFvSAqxJtYLjDKCpiywPR/Hj9HyVEoup//WBMEY/mfHLkp6x8koAmiOwLlmv5j9g d7eEUcC+sk7AlJo5/EO6o57O26KLm1D/D101VmY6rnW5jBO60Mh5FdXduz7Lu320y9 0eMqTheDx3jighRHdszCAdnWVz/haxkmtwIMqmMA= Date: Fri, 26 Jul 2019 16:01:18 +0200 From: Greg KH To: "Chang, Junxiao" Cc: "linux-kernel@vger.kernel.org" , "rafael@kernel.org" , "Li, Lili" Subject: Re: [PATCH] platform: release resource itself instead of resource tree Message-ID: <20190726140118.GA23143@kroah.com> References: <1556173458-9318-1-git-send-email-junxiao.chang@intel.com> <20190725133850.GB11115@kroah.com> <840F6BCBBBA89F46BAD0D7D6EF39E6E350F5072A@SHSMSX107.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <840F6BCBBBA89F46BAD0D7D6EF39E6E350F5072A@SHSMSX107.ccr.corp.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 A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail? A: No. Q: Should I include quotations after my reply? http://daringfireball.net/2007/07/on_top On Fri, Jul 26, 2019 at 10:24:22AM +0000, Chang, Junxiao wrote: > Hi Greg, > > Thank you for looking at it. > > Below example is simplified description. Our detail problem is: > 1. ACPI driver registers a MEM resource during bootup; > 2. Our PUNIT(Intel CPU power management module) platform device reads ACPI driver's resource, and registers same MEM resource; > 3. According to current resource management logic, if two resources are same, later registered resource will be parent. That is, PUNIT platform device's resource will be ACPI driver resource's parent. > 4. PUNIT kernel module is removed, its resource will be removed. If we use original API "release_resource", ACPI driver's resource will be released as well because it is PUNIT device's child; Why did you remove this module? That never happens unless you do it "by hand", and as root. Just don't do this if it causes problems in your system, right? Anyway, if you create a child reference you should always clean up all of your children before removing yourself from memory. So try fixing that up first. > 5. Next time PUNIT platform device kernel module is inserted, it might read wrong ACPI MEM resource because it has been released in step 4. > > How should we handle this case? :) Don't unload kernel modules unless you know what you are doing :) Seriously, you are creating a dependancy here that you are not expressing in your module reference count, and you are not properly cleaning up after yourself when removing your devices. Just delete your child devices when unloading yourself and you should be fine, right? > We should not register same MEM resource in step 2? Or, make change in > resource management logic, if two resources are same, later registered > resource should be child instead of parent? I don't know how your resource management logic works, try working with the developers who wrote that. But as you describe it, it is not correct at least when you try to clean things up. thanks, greg k-h