From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796416033; b=mm2jXbk9hUgDCMJwIBTFdzYVWMNqjlWMV1NVo/2GrFy2e4NfUmsctU4xKd9FUvh4rP8g 0ywGcvltbmwuxgKEME8PhMi9jbA/QkbZ0US5AGTqovDjQCbKgA3/Ld6QSjcHR1ecKUbr/ ZMX2tNWb/RfpTTycnGZ4XwbPYx0B/eN1vZOt8ELeaxN/mfSeXAWlQfrnOagGcjHdzidEa mSDFqAXFfx/yEIHsYjV9AauLKNeFZoln3ylTTfGt7zOj0X92eQswZy2J9srKP5pTtUIxe tUdAt9ZRpCEO02yz+fUijKOZlDHJYhnv7lItz2ifJtKfs6idd7FZF54jO7Hjn3lB9Iw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796416033; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=2JagPfSnn3Dvf5xG8I5Mijf8UWexIkB2w1YWWEHF/Mo=; b=cZIpfl46Dyxm03Q54336FMz+3nOVauCvCVOoQ8j7QzVFFvwGN3tjSC0XWqnAKhr/801d XKub0RpqjSWoYYfRsyF1lf9OM+jAu3CpK/UVQ26nAUyyzWFApxFmXUQiQHUmDQt28aQ+B ZXA9K9CyruoTOLb8g7i+XlcKnw/h9AbiO19zHu01wBopOoLatXiCltuFE+rgOaV4mfQwF dJdo5SE6WrN1UP70Ec0AMZKlIxcJs77/7HjH7K02eo8CGFLmRGNwYDernNxfG0wYAElXf 9jzbYEK2AI6TrEgL9UVQ6PYgR0Eo/s/69f08fsyCzdjyiuovxorTJLBNCizcEcGm4xA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=mezsPE33; arc=none smtp.remote-ip=74.125.82.51 Received: from mail-dl1-f51.google.com (mail-dl1-f51.google.com [74.125.82.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63A7D606A32F for ; Fri, 4 Dec 2026 20:27:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 63A7D606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=mezsPE33 Received: by mail-dl1-f51.google.com with SMTP id a92af1059eb24-1b5adf7eacdso451496c88.1 for ; Fri, 04 Dec 2026 12:27:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796416032; x=1797020832; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=2JagPfSnn3Dvf5xG8I5Mijf8UWexIkB2w1YWWEHF/Mo=; b=mezsPE33LUuOWi7X8ySqbvAx2u5CEIeP8SkHwCzujMBGnPGx9yuLPXrrB60ItRLh+3 PK6a40DXQ8g4XrxAnY+ZEwlsW6kCMnpcpojU46PEP4A4V3hgsVq+LX2bznDGvAD+5wKb 891bFC4hyV7j6W6IJ6OAu0HA7GZps+pOW0hMssKXR10JSLIxr9BGWSO9ywBfpokXD3S/ o/7ZM/3FnM/QpOkqahwplXa4fReClt7QYesgcpSMbzGkYHci6bEHkDLTS4oPRaWsgy39 aD6x6evy+mzTH0eIX97HDf2CULduZOrcG6LG0xQzU5WfoTjxsHjV85QjnHC27LfrX6z2 Fvig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796416032; x=1797020832; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=2JagPfSnn3Dvf5xG8I5Mijf8UWexIkB2w1YWWEHF/Mo=; b=LQ3P6EgXrCGpAULZzZMzRi0+9Ikaa2V+KC0e2vn7IdDajjUNfGM7Ag0G0GPsh8hZgn ijipoQO6BE/utRD44Q6vONC2JUOHibeeO+eJguQA7wXdSYjb6pX1bQKFfGgiRaXeRJu7 peJIXpVDN7uivfzynZVL/6BADmyNxJl4kPzqzhE4wfh/hcCtnkQouqyw0iyQJC+10xjW MSDm1Y5H8N4AntY2kyJ1e7LIT1rJKLR8dQTddaS22hN7cPUhhYQn9lLRjea0tbOGvonN iLmBlYO5U7XI5L8XhzPq8YNMWPY7dOQdRsTVg6ylphYuTS9p7RYLKOopcqEeykyv5ESk dUeA== X-Forwarded-Encrypted: i=1; AL+hErH9PN8zCkjRn15zWozi94ZqUBu5/JmjhocmhYBt8RmeCdIhFcaSkYElUdhdhj4vf6+kKfzLEYowip4=@vger.kernel.org X-Gm-Message-State: APuU4Z+tycTR5TbNhSQZRhtFJ5987xaJAqDX1YpVUHukVDCG0TbIk77x 6guYG6jClUg+G7IrobYMQT2Nm4VTjw35+zuO/ZsCTHJ1PBj4n2lUXY7q X-Gm-Gg: AZFdTZegDkmQcSx4e+1Jw4ixqnG7stDuPc2NCf9Y1db3thjYBWeGgHfVzNVlBcr5I6N VPjWWLflWoGfBExapb/jtgig2QlAQAK2Rv2emz/zWLGk/716MDvnZgpmruvcLtkdCeech67bNtB ATHU7dJ/1ONoA9XnrVvgBJIOuTOHFNhZw9Mt96eKaZMIEf03EJ0CpGCAIbvqLg2k6/ERYF/K3fX GfrALqrW/ZXlls+1r0ZU1KHmgKefcENm5lYbycaDL11qlIGGaiS08xtZadgvKZXPDEoGXkH08wH /Nxvy7djeUZX0BBiBgxsj+xGMTcSbEcyUisf/V1N0Ukg0p5oVcZzWwGiE9WKZBdwuYPraZbd0nh zO02VNBkAv+GYp2x1pgK9AZdOv/XSCnfw4pyRmzRfne9br4hdNb2ETHFBQPWqzQ0SASV7bB0ZBk Ha6CZQ+n+SxHxpTRZA5NvURwc40/BXjdE7vl6X/S1Uc9cevo2XEnL45A6yiZu6wmLS1OXudt29e BzD+xxxfvwBIo4vm+3oxmscGFPsyXjIMBHxYzWe2lebIDdBMHdhhVYhZLui00f9d6fXVvak+a58 80rGIyrhKX52nXilnG8A2QM6uOl3VrlxGbpS83Q+vOI39yDZAYboEQ9hzdcuXIg3xgWMyA== X-Received: by 2002:a05:701b:4590:20b0:1b3:aee5:20c5 with SMTP id a92af1059eb24-1b5d7114170mr2564609c88.22.1796416032333; Fri, 04 Dec 2026 12:27:12 -0800 (PST) Received: from google.com ([2a00:79e0:2ebe:8:17a1:4895:5021:5d36]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5d644171bsm9482218c88.7.2026.12.04.12.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 12:27:11 -0800 (PST) Date: Fri, 4 Dec 2026 12:27:08 -0800 From: Dmitry Torokhov To: Andy Shevchenko Cc: Cesar Cibrian , Lee Jones , mfd@lists.linux.dev, Heikki Krogerus , linux-i2c@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Danilo Krummrich , Bartosz Golaszewski , Johan Hovold Subject: Re: [PATCH] mfd: core: Remove software node after unregistering platform device Message-ID: References: <20261204181605.22364-1-cesarcibrian.ai@gmail.com> <8d70cb6010e7451c7ddbbfc448abd424@gmail.com> X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Dec 04, 2026 at 10:21:00PM +0200, Andy Shevchenko wrote: > On Fri, Dec 04, 2026 at 12:12:00PM -0800, Dmitry Torokhov wrote: > > On Fri, Dec 04, 2026 at 09:47:14PM +0200, Andy Shevchenko wrote: > > > On Fri, Dec 04, 2026 at 10:16:05AM -0800, Cesar Cibrian wrote: > > > > mfd_add_device() attaches cell->swnode before calling > > > > platform_device_add(), but mfd_remove_devices_fn() calls > > > > device_remove_software_node() before platform_device_unregister(). > > > > > > > > If the child driver propagates dev_fwnode() to a sub-device (for > > > > example, i2c-designware sharing its fwnode with the i2c_adapter > > > > device on Intel LPSS), removing the software node first clears > > > > fwnode->secondary while the sub-device is still registered. When > > > > platform_device_unregister() subsequently tears down the child, > > > > software_node_notify_remove() sees dev_to_swnode() == NULL on the > > > > sub-device and skips cleanup, leaking a swnode reference and > > > > leaving a stale sysfs symlink that triggers a warning on rebind: > > > > > > > > sysfs: cannot create duplicate filename '/kernel/software_nodes/node0/i2c-0' > > > > > > > > Move device_remove_software_node() after platform_device_unregister() > > > > (device_for_each_child_reverse() holds a reference on dev throughout > > > > mfd_remove_devices_fn()). Because acpi_unbind_one() calls > > > > set_primary_fwnode(dev, NULL), which skips clearing fn->secondary > > > > when fn == dev->parent->fwnode, also clear the parent's secondary > > > > fwnode when the child shared its parent's fwnode so rebinding does > > > > not fail with -EBUSY. > > > > > > I believe it's a local hack against bigger issue which is discussed here > > > https://lore.kernel.org/lkml/20261202-swnode-shared-primary-fix-v1-0-7ff23caaa1ed@gmail.com/ > > > > > > I Cc'ed people from that thread. Meanwhile, can you test the proposed series > > > and confirm if it fixes your issue or not? > > Dmitry, thanks for chiming in! > > > My series will not fix this on its own. We still need to reorder > > software node removal so it stays intact while child devices are being > > torn down. > > > > What my series does fix is the shared_fwnode/set_secondary_fwnode() > > workaround in this patch. Once device_del() unbinds the driver first and > > tears down i2c_adapter while the secondary link is intact, > > set_primary_fwnode(&pdev->dev, NULL) sees that pdev->dev attached the > > secondary node, moves it onto pdev->dev.fwnode, and clears fn->secondary > > automatically. > > > > Also, on non-ACPI shared primary nodes where acpi_unbind_one() does not > > run, clearing dev->parent's secondary fwnode before calling > > device_remove_software_node(&pdev->dev) makes dev_to_swnode(&pdev->dev) > > return NULL and actually leaks cell->swnode's reference. > > Hmm... Does it mean that your series fixes the issue on non-ACPI cases as well? I was trying to say that I think Cesar's patch introduces a leak on non-ACPI systems... > > Cesar, based on Dmitry's answer can you apply his series and develop the > missing piece on top? > Thanks. -- Dmitry