All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Manivannan Sadhasivam via B4 Relay"
	<devnull+manivannan.sadhasivam.oss.qualcomm.com@kernel.org>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v2 2/9] power: sequencing: pcie-m2: Allow creating serdev for multiple PCI devices
Date: Thu, 07 May 2026 23:28:27 +0000	[thread overview]
Message-ID: <20260507232828.14D87C2BCB2@smtp.kernel.org> (raw)
In-Reply-To: <20260507-pwrseq-m2-bt-v2-2-1740bd478539@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Logic flaw prevents tracking multiple PCI devices, defeating the core purpose of the patch.
- [High] Lockless check of `serdev_ctrl->serdev` introduces a data race during concurrent device additions.
--

commit c7f58507c704ae72da8e4afb0e0855215048187d
Author: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>

power: sequencing: pcie-m2: Allow creating serdev for multiple PCI devices

This patch introduces a list to track multiple PCI devices per M.2 slot
by creating a 'pwrseq_pci_dev' for each device requiring a serdev. It
replaces the single serdev reference with this list to scale the driver.

> diff --git a/drivers/power/sequencing/pwrseq-pcie-m2.c b/drivers/power/sequencing/pwrseq-pcie-m2.c
> index b2ed336fd5ad9..469e130330faa 100644
> --- a/drivers/power/sequencing/pwrseq-pcie-m2.c
> +++ b/drivers/power/sequencing/pwrseq-pcie-m2.c

[ ... ]

> @@ -248,17 +259,23 @@ static int pwrseq_pcie_m2_create_serdev(struct pwrseq_pcie_m2_ctx *ctx)
>  		return 0;
>  	}

Since the intent is to track multiple PCI devices per M.2 slot, does this
existing early bailout:

	if (serdev_ctrl->serdev) {
		serdev_controller_put(serdev_ctrl);
		return 0;
	}

prevent adding subsequent PCI devices to the ctx->pci_devices list?

If serdev_ctrl->serdev is already set by the first device, won't this return
0 without allocating pwrseq_pci_dev, leaving the list with only one device?

Additionally, is it possible for two PCI devices to trigger the
BUS_NOTIFY_ADD_DEVICE notifier concurrently?

If both threads observe serdev_ctrl->serdev as NULL without synchronization,
could they both proceed to allocate and call serdev_device_add()? This could
overwrite the ctrl->serdev pointer locklessly.

If the slower thread ultimately fails device_add() due to a sysfs name
collision, it could execute ctrl->serdev = NULL in its error path. Would this
corrupt the serdev controller state and silently orphan the serdev that was
successfully registered by the first thread?

>  
> -	ctx->serdev = serdev_device_alloc(serdev_ctrl);
> -	if (!ctx->serdev) {
> +	pci_dev = kzalloc(sizeof(*pci_dev), GFP_KERNEL);
> +	if (!pci_dev) {
>  		ret = -ENOMEM;
>  		goto err_put_ctrl;
>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260507-pwrseq-m2-bt-v2-0-1740bd478539@oss.qualcomm.com?part=2

  reply	other threads:[~2026-05-07 23:28 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-07 16:06 [PATCH v2 0/9] Fixes/improvements for the PCI M.2 power sequencing driver Manivannan Sadhasivam
2026-05-07 16:06 ` Manivannan Sadhasivam via B4 Relay
2026-05-07 16:06 ` [PATCH v2 1/9] power: sequencing: pcie-m2: Fix inconsistent function prefixes Manivannan Sadhasivam
2026-05-07 16:06   ` Manivannan Sadhasivam via B4 Relay
2026-05-07 18:51   ` Fixes/improvements for the PCI M.2 power sequencing driver bluez.test.bot
2026-05-07 16:06 ` [PATCH v2 2/9] power: sequencing: pcie-m2: Allow creating serdev for multiple PCI devices Manivannan Sadhasivam
2026-05-07 16:06   ` Manivannan Sadhasivam via B4 Relay
2026-05-07 23:28   ` sashiko-bot [this message]
2026-05-07 16:06 ` [PATCH v2 3/9] power: sequencing: pcie-m2: Improve PCI device ID check Manivannan Sadhasivam
2026-05-07 16:06   ` Manivannan Sadhasivam via B4 Relay
2026-05-07 16:06 ` [PATCH v2 4/9] power: sequencing: pcie-m2: Create serdev for PCI devices present before probe Manivannan Sadhasivam
2026-05-07 16:06   ` Manivannan Sadhasivam via B4 Relay
2026-05-07 23:54   ` sashiko-bot
2026-05-11 11:45   ` Bartosz Golaszewski
2026-05-07 16:06 ` [PATCH v2 5/9] power: sequencing: pcie-m2: Create BT node based on the pci_device_id[] table Manivannan Sadhasivam
2026-05-07 16:06   ` Manivannan Sadhasivam via B4 Relay
2026-05-07 16:06 ` [PATCH v2 6/9] Bluetooth: hci_qca: Add M.2 Bluetooth device support using pwrseq Manivannan Sadhasivam
2026-05-07 16:06   ` Manivannan Sadhasivam via B4 Relay
2026-05-08  0:44   ` sashiko-bot
2026-05-07 16:06 ` [PATCH v2 7/9] Bluetooth: hci_qca: Rename 'power_ctrl_enabled' to 'bt_en_available' Manivannan Sadhasivam
2026-05-07 16:06   ` Manivannan Sadhasivam via B4 Relay
2026-05-08  0:53   ` sashiko-bot
2026-05-11 11:34   ` Bartosz Golaszewski
2026-05-07 16:06 ` [PATCH v2 8/9] power: sequencing: Add an API to return the pwrseq device's 'dev' pointer Manivannan Sadhasivam
2026-05-07 16:06   ` Manivannan Sadhasivam via B4 Relay
2026-05-08  1:16   ` sashiko-bot
2026-05-11 11:34   ` Bartosz Golaszewski
2026-05-07 16:06 ` [PATCH v2 9/9] Bluetooth: hci_qca: Set 'bt_en_available' based on W_DISABLE2# presence in M.2 connector Manivannan Sadhasivam
2026-05-07 16:06   ` Manivannan Sadhasivam via B4 Relay
2026-05-08  2:06   ` sashiko-bot
2026-05-11 11:36   ` Bartosz Golaszewski
2026-05-08 12:49 ` [PATCH v2 0/9] Fixes/improvements for the PCI M.2 power sequencing driver Wei Deng

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=20260507232828.14D87C2BCB2@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=devnull+manivannan.sadhasivam.oss.qualcomm.com@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.