Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kaustabh Chakraborty" <kauschluss@disroot.org>
Cc: krzk+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org,
	conor+dt@kernel.org
Subject: Re: [PATCH v7 05/10] mfd: sec: set DMA coherent mask
Date: Fri, 15 May 2026 22:24:00 +0000	[thread overview]
Message-ID: <20260515222400.CDDB7C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260516-s2mu005-pmic-v7-5-73f9702fb461@disroot.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Shared dma_mask pointer across MFD child devices causes a data race and violates DMA API contracts.
--

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

mfd: sec: set DMA coherent mask

This commit manually sets the coherent DMA mask to 0 and points the device's
dma_mask to it. This is intended to suppress "DMA mask not set" warnings
for sub-devices, as the device does not use DMA for communication.

> diff --git a/drivers/mfd/sec-common.c b/drivers/mfd/sec-common.c
> index 22f6c74eb6c0e..fe92bc4a3dd26 100644
> --- a/drivers/mfd/sec-common.c
> +++ b/drivers/mfd/sec-common.c
> @@ -221,6 +221,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;

When the MFD core adds child devices via mfd_add_device(), it copies the
parent's dma_mask pointer to the child devices:

    pdev->dev.dma_mask = parent->dma_mask;

Because sub-devices for this PMIC probe asynchronously, they can concurrently
execute platform_dma_configure(), which eventually calls of_dma_configure_id()
and performs a lockless read-modify-write:

    *dev->dma_mask &= mask;

Since all child devices share the same dma_mask pointer referencing the
parent's coherent_dma_mask, does this cause an unsynchronized data race on
the parent's memory?

Additionally, sharing a single dma_mask pointer across multiple devices breaks
the driver model. If any child device were to legitimately call dma_set_mask(),
wouldn't it silently overwrite the DMA mask for all sibling devices?

Finally, manually modifying device structures to fake an invalid mask of 0
bypasses DMA subsystem validation. Helpers like dma_coerce_mask_and_coherent()
explicitly reject a mask of 0. Is manually assigning 0 here the recommended way
to suppress the warning?

> +
>  	pm_runtime_set_active(sec_pmic->dev);
>  
>  	switch (sec_pmic->device_type) {

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260516-s2mu005-pmic-v7-0-73f9702fb461@disroot.org?part=5

  reply	other threads:[~2026-05-15 22:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-15 21:38 [PATCH v7 00/10] Support for Samsung S2MU005 PMIC and its sub-devices Kaustabh Chakraborty
2026-05-15 21:38 ` [PATCH v7 01/10] dt-bindings: leds: document Samsung S2M series PMIC flash LED device Kaustabh Chakraborty
2026-05-15 21:38 ` [PATCH v7 02/10] dt-bindings: extcon: document Samsung S2M series PMIC extcon device Kaustabh Chakraborty
2026-05-15 21:38 ` [PATCH v7 03/10] dt-bindings: mfd: add documentation for S2MU005 PMIC Kaustabh Chakraborty
2026-05-15 21:38 ` [PATCH v7 04/10] mfd: sec: add support " Kaustabh Chakraborty
2026-05-15 22:25   ` sashiko-bot
2026-05-15 21:38 ` [PATCH v7 05/10] mfd: sec: set DMA coherent mask Kaustabh Chakraborty
2026-05-15 22:24   ` sashiko-bot [this message]
2026-05-15 21:38 ` [PATCH v7 06/10] leds: flash: add support for Samsung S2M series PMIC flash LED device Kaustabh Chakraborty
2026-05-15 22:15   ` sashiko-bot
2026-05-15 21:38 ` [PATCH v7 07/10] leds: rgb: add support for Samsung S2M series PMIC RGB " Kaustabh Chakraborty
2026-05-15 22:10   ` sashiko-bot
2026-05-15 21:38 ` [PATCH v7 08/10] Documentation: leds: document pattern behavior of Samsung S2M series PMIC RGB LEDs Kaustabh Chakraborty
2026-05-15 21:38 ` [PATCH v7 09/10] extcon: add support for Samsung S2M series PMIC extcon devices Kaustabh Chakraborty
2026-05-15 22:10   ` sashiko-bot
2026-05-15 21:38 ` [PATCH v7 10/10] power: supply: add support for Samsung S2M series PMIC charger device Kaustabh Chakraborty
2026-05-15 22:22   ` 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=20260515222400.CDDB7C2BCB0@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox