Re: [PATCH] ata: libahci: fix panic when accessing ports beyond MMIO region

Damien Le Moal
2026-04-24T11:15:30Z

On 4/24/26 20:07, Niklas Cassel wrote:
> On Fri, Apr 24, 2026 at 03:16:56PM +0800, 李佑鸿 wrote:
>> At 2026-04-24 10:43:11, "Damien Le Moal" <dlemoal@kernel.org> wrote:
>>>
>>> What I am surprised of here is that we even see that device on the PCI bus at
>>> all when it is disabled in the BIOs. If that device is disabled, why are we even
>>> seeing it by scanning the PCI ports ? The adapter should simply not be visible
>>> at all.
>
> I agree.
> E.g. both AMD and Intel make sure that the AHCI controller PCI device does
> not show up on the PCI bus if you disable it using the BIOS.
>
> It would have been nice if the Phytium BIOS also worked like that.
>
>
>> 3. **BAR Size Mismatch**: `CAP.NP` indicates more ports than physically fit in the BAR
>> - If CAP claims 32 ports but BAR is only 4KB, this is physically impossible
>> - 32 ports require at least 0x1100 bytes (0x100 + 32 * 0x80)
>
> The reason why I did not suggest failing the probe() originally, was because
> 李佑鸿 sent a patch with a Fixes tag, so I assumed that he considered it a
> regression, and wanted the hardware to continue working, even though it was
> marked as disabled in BIOS, because that is how it was before the commit in
> the Fixes tag was introduced.
>
> That said, I fully agree that I think it is better to modify the AHCI driver
> to fail the probe() for this AHCI controller when it has not been properly
> initialized (because it is marked as disabled in BIOS).
>
> I prefer option 3.
> Look at CAP.NP and look at the BAR size, if it is too small, just fail the
> probe().

Sounds good (and a lot safer) to me.

>
>
> Kind regards,
> Niklas

--
Damien Le Moal
Western Digital Research