Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Brendan Higgins <brendan.higgins@linux.dev>,
	David Gow <david@davidgow.net>, Rae Moar <raemoar63@gmail.com>,
	Andy Shevchenko <andy@kernel.org>,
	brgl@kernel.org, driver-core@lists.linux.dev,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	kunit-dev@googlegroups.com
Subject: Re: [PATCH v4 1/3] driver core: platform: remove software node on release()
Date: Thu, 30 Apr 2026 15:02:10 +0300	[thread overview]
Message-ID: <afNEwrHLNTA4ywrN@ashevche-desk.local> (raw)
In-Reply-To: <20260430-swnode-remove-on-dev-unreg-v4-1-01574da0aed3@oss.qualcomm.com>

On Thu, Apr 30, 2026 at 09:46:04AM +0200, Bartosz Golaszewski wrote:
> If we pass a software node to a newly created device using struct
> platform_device_info, it will not be removed when the device is
> released. This may happen when a module creating the device is removed
> or on failure in platform_device_add().
> 
> When we try to reuse that software node in a subsequent call to
> platform_device_register_full(), it will fails with -EBUSY. Add the
> missing call to device_remove_software_node() in release path.
> 
> In addition to the above change, make sure that we still function
> correctly if a software node is used as the primary firmware node as
> well as disallow using two software nodes for platform devices as
> device_add_software_node() does not handle this case correctly (in fact
> a comment inside it states that only one software node per device is
> allowed but it will not bail out if two are used so we need to handle it
> here).

...

> -	if (pdevinfo->swnode && pdevinfo->properties)
> +	/*
> +	 * Only one software node per device is allowed. Make sure we don't
> +	 * accept or create two.
> +	 */
> +	if ((pdevinfo->swnode && pdevinfo->properties) ||
> +	    (pdevinfo->swnode && is_software_node(pdevinfo->fwnode)) ||
> +	    (pdevinfo->properties && is_software_node(pdevinfo->fwnode)))
>  		return ERR_PTR(-EINVAL);

This makes me think of why we have these many ways of doing things...
Perhaps we should kill pdevinfo::properties completely?

Second thought is what about actually refusing this on the level of
device_add_software_node()? And looking at it, we have that check
there, why do we need it here then? Did we miss to check error code from
device_add_software_node() somewhere?

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-04-30 12:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-30  7:46 [PATCH v4 0/3] driver core: remove software node from platform devices on device release Bartosz Golaszewski
2026-04-30  7:46 ` [PATCH v4 1/3] driver core: platform: remove software node on release() Bartosz Golaszewski
2026-04-30 12:02   ` Andy Shevchenko [this message]
2026-04-30 12:38     ` Bartosz Golaszewski
2026-05-11  7:33       ` Bartosz Golaszewski
2026-05-11 14:00         ` Danilo Krummrich
2026-05-11 14:17           ` Bartosz Golaszewski
2026-05-11 14:31             ` Danilo Krummrich
2026-05-11 14:50               ` Bartosz Golaszewski
2026-05-11 15:04                 ` Danilo Krummrich
2026-05-11 16:08                   ` Bartosz Golaszewski
2026-04-30  7:46 ` [PATCH v4 2/3] kunit: provide kunit_software_node_register() Bartosz Golaszewski
2026-04-30  7:46 ` [PATCH v4 3/3] driver core: platform: tests: add test cases for correct swnode removal Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=afNEwrHLNTA4ywrN@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=bartosz.golaszewski@oss.qualcomm.com \
    --cc=brendan.higgins@linux.dev \
    --cc=brgl@kernel.org \
    --cc=dakr@kernel.org \
    --cc=david@davidgow.net \
    --cc=dmitry.torokhov@gmail.com \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=raemoar63@gmail.com \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox