Re: [PATCH v3 40/57] scsi: megaraid: Enable lock context analysis

[email protected] Thu, 30 Jul 2026 23:15:13 +0000
Newsgroups org.kernel.vger.linux-scsi
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(=
s) to consider:
- [Medium] Incorrect `__must_hold` annotations hide lockless execution path=
s for `reset_mutex` and defeat lock context analysis.
--

--- Patch [40]: [PATCH v3 40/57] scsi: megaraid: Enable lock context analys=
is ---
commit 40d3b019568a4b229e7033f10c3257b3f094d748
Author: Bart Van Assche <[email protected]>

scsi: megaraid: Enable lock context analysis

This commit enables lock context analysis for the megaraid driver by
setting CONTEXT_ANALYSIS to y in the Makefile.

> diff --git a/drivers/scsi/megaraid/Makefile b/drivers/scsi/megaraid/Makef=
ile
> index 12177e4cae653..9a6976a4dc22b 100644
> --- a/drivers/scsi/megaraid/Makefile
> +++ b/drivers/scsi/megaraid/Makefile
> @@ -1,4 +1,7 @@
>  # SPDX-License-Identifier: GPL-2.0
> +
> +CONTEXT_ANALYSIS :=3D y
> +

[Severity: Medium]
Will enabling context analysis here be effective given the current
annotations on the driver's lifecycle functions?

The megasas_resume() function is annotated as holding the lock:

drivers/scsi/megaraid/megaraid_sas_base.c:
    static int __maybe_unused
    megasas_resume(struct device *dev)
        __must_hold(&((struct megasas_instance *)dev_get_drvdata(dev))->res=
et_mutex)

However, the PM core invokes this resume callback without holding
reset_mutex.

Similarly, during driver probe, megasas_init_adapter_mfi() and
megasas_init_adapter_fusion() are called via the init_adapter function
pointer without reset_mutex held, but they are also annotated as
requiring it:

drivers/scsi/megaraid/megaraid_sas_fusion.c:
    static u32
    megasas_init_adapter_fusion(struct megasas_instance *instance)
        __must_hold(&instance->reset_mutex)

Could these __must_hold annotations suppress valid static analysis
warnings for these execution paths, defeating the lock context analysis
being enabled here?

>  obj-$(CONFIG_MEGARAID_MM)	+=3D megaraid_mm.o
[ ... ]

--=20
Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1785451174.gi=
[email protected]?part=3D40