Linux CXL
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: alejandro.lucero-palau@amd.com
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH v31 4/5] sfc: obtain and map cxl range using devm_cxl_probe_mem
Date: Tue, 30 Jun 2026 15:04:53 +0000	[thread overview]
Message-ID: <20260630150454.0784E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260630151346.31201-5-alejandro.lucero-palau@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Inverted teardown order unmaps write-combining memory and cleans up devm CXL resources after the PCI device is disabled.
--

commit 8a6ea64dcd83c4ec06b3116375770f0f9dce6ca6
Author: Alejandro Lucero <alucerop@amd.com>
Subject: sfc: obtain and map cxl range using devm_cxl_probe_mem

This commit uses the core CXL API to safely obtain and map the CXL range
linked to an HDM committed by the BIOS. The mapped range is used as the ctpio
buffer.

> diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c
> index 61cbb6cfc3602..3806cd3dd7f48 100644
> --- a/drivers/net/ethernet/sfc/efx.c
> +++ b/drivers/net/ethernet/sfc/efx.c
> @@ -984,6 +984,7 @@ static void efx_pci_remove(struct pci_dev *pci_dev)
>  	efx_fini_io(efx);
>  
>  	probe_data = container_of(efx, struct efx_probe_data, efx);
> +	efx_cxl_exit(probe_data);

[Severity: High]
Does this sequence unmap the Write-Combining memory after the PCI device is
disabled?

In efx_pci_remove(), efx_fini_io() is called first, which calls
pci_disable_device(). Then efx_cxl_exit() calls iounmap() on the ctpio_cxl
mapping.

If a CPU write-combining buffer flush occurs during iounmap() on a disabled
device, could it trigger a fatal PCIe error (Master Abort) and a kernel panic?

Also, since devm_cxl_probe_mem() and devm_cxl_dev_state_create() are used
during initialization, devres will clean up these resources after
efx_pci_remove() returns. Does this mean the devm cleanup also accesses the
device after it has been disabled?

>  
>  	pci_dbg(efx->pci_dev, "shutdown successful\n");
>  

[ ... ]

> @@ -1242,6 +1243,7 @@ static int efx_pci_probe(struct pci_dev *pci_dev,
>  	return 0;
>  
>   fail3:
> +	efx_cxl_exit(probe_data);
>  	efx_fini_io(efx);

[Severity: High]
Does this error path cause devm-managed CXL resources to be cleaned up on a
disabled device?

While efx_cxl_exit() correctly unmaps the region before efx_fini_io()
disables the device here, the devm-managed resources (like the CXL accel
memdev) will be destroyed by devres after efx_pci_probe() returns.

By the time devres runs, efx_fini_io() has already called pci_disable_device(),
so the devm cleanup will happen with the PCI device already disabled.

>   fail2:
>  	efx_fini_struct(efx);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260630151346.31201-1-alejandro.lucero-palau@amd.com?part=4

  reply	other threads:[~2026-06-30 15:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30 15:13 [PATCH v31 0/5] Type2 device basic support alejandro.lucero-palau
2026-06-30 15:13 ` [PATCH v31 1/5] sfc: add cxl support alejandro.lucero-palau
2026-06-30 15:13 ` [PATCH v31 2/5] sfc: Map cxl regs alejandro.lucero-palau
2026-06-30 14:39   ` sashiko-bot
2026-06-30 15:13 ` [PATCH v31 3/5] sfc: Initialize cxl dpa alejandro.lucero-palau
2026-06-30 14:52   ` sashiko-bot
2026-06-30 15:13 ` [PATCH v31 4/5] sfc: obtain and map cxl range using devm_cxl_probe_mem alejandro.lucero-palau
2026-06-30 15:04   ` sashiko-bot [this message]
2026-06-30 15:13 ` [PATCH v31 5/5] sfc: support pio mapping based on cxl alejandro.lucero-palau
2026-06-30 15: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=20260630150454.0784E1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alejandro.lucero-palau@amd.com \
    --cc=linux-cxl@vger.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