All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kaustabh Chakraborty" <kauschluss@disroot.org>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org,
	krzk+dt@kernel.org
Subject: Re: [PATCH v6 05/11] mfd: sec: set DMA coherent mask
Date: Fri, 15 May 2026 11:10:27 +0000	[thread overview]
Message-ID: <20260515111028.5FD4FC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260515-s2mu005-pmic-v6-5-1979106992d4@disroot.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Setting the parent device's `dma_mask` pointer to its own `coherent_dma_mask` introduces a shared-state data race across MFD sub-devices and circumvents DMA API validation.
--

commit ed135db5f1241e8cf0252f12ff10c2221996d7ef
Author: Kaustabh Chakraborty <kauschluss@disroot.org>

mfd: sec: set DMA coherent mask

This commit manually sets the coherent_dma_mask to 0 and assigns the
dma_mask pointer to it for the SEC PMIC device. This is done to silence
warnings about missing DMA masks on sub-devices since the device does not
use DMA.

> diff --git a/drivers/mfd/sec-common.c b/drivers/mfd/sec-common.c
> index ad1c7de83a620..afc9e691bb67c 100644
> --- a/drivers/mfd/sec-common.c
> +++ b/drivers/mfd/sec-common.c
> @@ -215,6 +215,9 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
>  	if (IS_ERR(irq_data))
>  		return PTR_ERR(irq_data);
>  
> +	dev->coherent_dma_mask = 0;
> +	dev->dma_mask = &dev->coherent_dma_mask;

Does setting the dma_mask pointer to the parent's coherent_dma_mask introduce
a data race?

The MFD core in mfd_add_device() copies the parent's dma_mask pointer to all
child platform devices. Because the parent's dma_mask now points to its own
dev->coherent_dma_mask field, all child devices will share the exact same
memory pointer.

During child probe, the platform bus calls of_dma_configure_id(), which
executes an unsynchronized read-modify-write on that shared pointer:

    *dev->dma_mask &= mask;

Because sec_pmic_probe() supports devices like the S2MPS11, whose regulator
driver uses PROBE_PREFER_ASYNCHRONOUS, child devices can probe concurrently.
Will these simultaneous read-modify-writes to the parent's coherent_dma_mask
cause KCSAN warnings about data races?

Additionally, does manually mutating bus-managed device properties to simulate
a 0-bit DMA capability circumvent standard DMA API validation?

> +
>  	pm_runtime_set_active(sec_pmic->dev);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260515-s2mu005-pmic-v6-0-1979106992d4@disroot.org?part=5

  reply	other threads:[~2026-05-15 11:10 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-15 10:38 [PATCH v6 00/11] Support for Samsung S2MU005 PMIC and its sub-devices Kaustabh Chakraborty
2026-05-15 10:38 ` [PATCH v6 01/11] dt-bindings: leds: document Samsung S2M series PMIC flash LED device Kaustabh Chakraborty
2026-05-15 10:38 ` [PATCH v6 02/11] dt-bindings: extcon: document Samsung S2M series PMIC extcon device Kaustabh Chakraborty
2026-05-15 11:05   ` sashiko-bot
2026-05-15 17:15   ` Conor Dooley
2026-05-15 21:07     ` Kaustabh Chakraborty
2026-05-15 10:38 ` [PATCH v6 03/11] dt-bindings: mfd: add documentation for S2MU005 PMIC Kaustabh Chakraborty
2026-05-15 10:52   ` sashiko-bot
2026-05-15 17:14   ` Conor Dooley
2026-05-15 21:11     ` Kaustabh Chakraborty
2026-05-15 10:39 ` [PATCH v6 04/11] mfd: sec: add support " Kaustabh Chakraborty
2026-05-15 11:16   ` sashiko-bot
2026-05-15 10:39 ` [PATCH v6 05/11] mfd: sec: set DMA coherent mask Kaustabh Chakraborty
2026-05-15 11:10   ` sashiko-bot [this message]
2026-05-15 10:39 ` [PATCH v6 06/11] mfd: sec: resolve PMIC revision in S2MU005 Kaustabh Chakraborty
2026-05-15 10:39 ` [PATCH v6 07/11] leds: flash: add support for Samsung S2M series PMIC flash LED device Kaustabh Chakraborty
2026-05-15 11:05   ` sashiko-bot
2026-05-15 10:39 ` [PATCH v6 08/11] leds: rgb: add support for Samsung S2M series PMIC RGB " Kaustabh Chakraborty
2026-05-15 11:13   ` sashiko-bot
2026-05-15 10:39 ` [PATCH v6 09/11] Documentation: leds: document pattern behavior of Samsung S2M series PMIC RGB LEDs Kaustabh Chakraborty
2026-05-15 11:03   ` sashiko-bot
2026-05-15 10:39 ` [PATCH v6 10/11] extcon: add support for Samsung S2M series PMIC extcon devices Kaustabh Chakraborty
2026-05-15 11:17   ` sashiko-bot
2026-05-15 10:39 ` [PATCH v6 11/11] power: supply: add support for Samsung S2M series PMIC charger device Kaustabh Chakraborty
2026-05-15 11:20   ` sashiko-bot

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=20260515111028.5FD4FC2BCB0@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kauschluss@disroot.org \
    --cc=krzk+dt@kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@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.