Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp889151ybl; Fri, 9 Aug 2019 15:47:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/FkaqksbegrBr4c+OcG6OJ4BT11Aohx3ZUl6j1YXOj2Mpj8jkJvAQlZhEdSoPHG8keSPv X-Received: by 2002:a17:902:7448:: with SMTP id e8mr21271667plt.85.1565390846796; Fri, 09 Aug 2019 15:47:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565390846; cv=none; d=google.com; s=arc-20160816; b=nWsNuejudlPA1OBjl7r5UVCO++RRc4l+myxBZRhQa6lVZFE+ksnMhdiDk4QvgrEGHd S2QVaX7foscTOB6oCTgey8rhhXG6q3NmOpsVqv/IWMVGk6ggA5mNty2/ypTMly5iT3Qh 4xV9Oyi9oqx8Di5+VxZ7kWWw5Cm7CiWYWUMKDDLdjba0eiDerj281mTGS8b3MVjAhgVM XH1yx7ry5+nyuBF3wv3Tg5BIekFmUvZqp6zYY0e3+Ws9L2QcRTeGUHU7xN4MCX4P2DBd JFt2mPUG8rjXWPahum6XhEub+57vEjG7FrL6pJNDGxUIKPx+hdGunD3VETYTHXqeE0BT SocA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=1p81AB5H9qAkQ7oKXv/MOS/Ji9SglTShb5Ura3jIvoI=; b=SbYpFCXcQ0Yqk7LUzz2w8Nf7D0FEnUME0LxG+UXnYYkTfsyw1D6oDUwKXB1EsPfsnY QekpGEjVCgIHnC2+wUR7vJkj6Jm5FKp5vRn/+Tk8AzdH+EX6zGF3d2YJt24rM5vKWXR4 TDPZpROcKa6Q3zdo8LQwK+yHTOtQzgr1bF2zIv6WndQNxsKbi5AoarP/PXwTVYa/2pIk 3y1SASvMHcGaj4qz+gnYuCZx/fqN9Uo749WlKP1Vb/TkVIpbJzttKDNrEKlSQOkSS2ah rj5F2JVOG6KIRTAQ4nXkCTJKmQIip3JusTUPF1WcXaedI0TGiG4n4GiEtYfif63B9lnv ravQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=ExyKgXkb; 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 d13si56597767pgu.268.2019.08.09.15.47.11; Fri, 09 Aug 2019 15:47:26 -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=@linux-foundation.org header.s=google header.b=ExyKgXkb; 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 S1726475AbfHIWqT (ORCPT + 99 others); Fri, 9 Aug 2019 18:46:19 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:43017 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726137AbfHIWqT (ORCPT ); Fri, 9 Aug 2019 18:46:19 -0400 Received: by mail-lf1-f65.google.com with SMTP id c19so70609829lfm.10 for ; Fri, 09 Aug 2019 15:46:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1p81AB5H9qAkQ7oKXv/MOS/Ji9SglTShb5Ura3jIvoI=; b=ExyKgXkb/BGoNFg8m4OqIIXIlDmsmOJafAq7Bjan8ZmSwacpffwVH2GN6TnrJSxo2h pHsH9vYN7ejqSahUyY6p5X32G9bUFSvKCB4kFbng3x8FCMX/44gZS1FkYdunY1ss+guV vsAd1IZPy8LBDclYbvqOCO/UmVj8WlvHfETaM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1p81AB5H9qAkQ7oKXv/MOS/Ji9SglTShb5Ura3jIvoI=; b=X9I8Rah4P63exU5GENQyH3mCOZzHHQoZH8xrs0am6vVyDK/CeL47ewv3zygKmGViKr e/UFvHEI93Ld1qz7XYbcF4EfC2RD3OsrOcvJN7aKZxSWvxisSCvJa5ZkXFXbuXcNeKk3 TPyDWcLNW2IZuaT+e8H5tnJfEhfpTlG9Pjx22JnXd05KABFSfNk1sVHRz8qrCJz0In5M frjxEt6dy2m0wJizJ79YlfYjTMqBN39dQ+L8w1pwhDYp7NY+Vzkhk7cxGg0dDGU612mu c23+lL0H5Liy0JazEnGhz8eWBX6FeA0NY9BaUipKQWEP+yJltxp0vU1/383KvYRBundy BPnA== X-Gm-Message-State: APjAAAU9/kj9iz3T7EvASYp7SYrxdeG9lzTKW6moH7F9jDhT0/FQhMD5 rQc7vlxi+p3nLmlyi0EE9zN1SLTRpis= X-Received: by 2002:a19:6753:: with SMTP id e19mr13953848lfj.187.1565390776492; Fri, 09 Aug 2019 15:46:16 -0700 (PDT) Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com. [209.85.167.49]) by smtp.gmail.com with ESMTPSA id g5sm19845377ljj.69.2019.08.09.15.46.15 for (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Fri, 09 Aug 2019 15:46:15 -0700 (PDT) Received: by mail-lf1-f49.google.com with SMTP id x3so16830510lfn.6 for ; Fri, 09 Aug 2019 15:46:15 -0700 (PDT) X-Received: by 2002:ac2:5c42:: with SMTP id s2mr14345185lfp.61.1565390774837; Fri, 09 Aug 2019 15:46:14 -0700 (PDT) MIME-Version: 1.0 References: <1565278859475.1962@mentor.com> <1565358624103.3694@mentor.com> <20190809223831.fk4uyrzscr366syr@master> In-Reply-To: <20190809223831.fk4uyrzscr366syr@master> From: Linus Torvalds Date: Fri, 9 Aug 2019 15:45:59 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Resend [PATCH] kernel/resource.c: invalidate parent when freed resource has childs To: Wei Yang Cc: "Schmid, Carsten" , "bp@suse.de" , "dan.j.williams@intel.com" , "mingo@kernel.org" , "dave.hansen@linux.intel.com" , "linux-kernel@vger.kernel.org" , "bhelgaas@google.com" , "osalvador@suse.de" , "rdunlap@infradead.org" , "richardw.yang@linux.intel.com" , "gregkh@linuxfoundation.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 9, 2019 at 3:38 PM Wei Yang wrote: > > In theory, child may have siblings. Would it be possible to have several > devices under xhci-hcd? I'm less interested in the xhci-hcd case - which I certainly *hope* is fixed already? - than in "if this happens somewhere else". So if we do want to remove the parent (which may be a good idea with a warning), and want to make sure that the children are really removed from the resource hierarchy, we should do somethiing like static bool detach_children(struct resource *res) { res = res->child; if (!res) return false; do { res->parent = NULL; res = res->sibling; } while (res); return true; } and then we could write the __release_region() warning as /* You should not release a resource that has children */ WARN_ON_ONCE(detach_children(res)); or something? NOTE! The above is entirely untested, and written purely in my mail reader. It might be seriously buggy, including not compiling, or doing odd things. See it more as a "maybe something like this" code snippet example than any kind of final form. Linus