[PATCH v4 0/2] firmware: stratix10-svc: Agilex5 SMMU DMA coherent support

adrian.ho.yin.ng@altera.com posted 2 patches 1 week, 6 days ago
drivers/firmware/stratix10-svc.c             | 250 +++++++++++++++----
include/linux/firmware/intel/stratix10-smc.h |  23 ++
2 files changed, 228 insertions(+), 45 deletions(-)
[PATCH v4 0/2] firmware: stratix10-svc: Agilex5 SMMU DMA coherent support
Posted by adrian.ho.yin.ng@altera.com 1 week, 6 days ago
From: Adrian Ng Ho Yin <adrian.ho.yin.ng@altera.com>

This series adds Agilex5 SMMU DMA coherent support in the stratix10-svc
driver.

On Agilex5 the DDR base address starts at 0x8000_0000, which is
outside the addressable range of the SDM. When SMMU is active, the
driver must allocate DMA-coherent buffers and pass IOVAs within the
SDM-accessible 0-512MB window to ATF. Agilex5 REV B introduced a
hardware SDM address remapper, but it must be bypassed so no additional
offset is applied to the IOVA, keeping the implementation consistent
across all Agilex5 revisions.

Patch 1 reports unmatched frees in stratix10_svc_free_memory() with
dev_warn() and cleans up related coding style in svc_pa_to_va(). The
list-head corruption from list_del(&svc_data_mem) was already fixed by
commit 9119ceb76e98 ("firmware: stratix10-svc: fix memory leaks and list
corruption bugs").

Patch 2 adds the DMA coherent allocation path and wires Agilex5
enablement in probe: require an IOMMU domain for intel,agilex5-svc,
bypass the SDM address remapper via INTEL_SIP_SMC_SDM_REMAPPER_CONFIG,
set the 29-bit DMA mask, select the DMA path through
stratix10_svc_pdata, register a devm cleanup for leaked buffers, and
guard err_destroy_pool against a NULL genpool.

---
changelog:
v3 -> v4:
- Squash the DMA-allocation and Agilex5 probe enablement patches into
  one commit. Building the former alone triggered -Wunused-function on
  svc_setup_dma_memory() and left use_dma_mem false (inert).
- Drop the arm64 DTS patch from this series; resend firmware patches
  only.
- Drop Signed-off-by: Dinh Nguyen from patch 1; resending with author
  Signed-off-by only.

v2 -> v3:
- Squash former patch 2 (SMC remapper defines) into the probe enablement
  patch so the defines land with their first usage.
- Rebase on socfpga_firmware_for_v7.4.
- Drop the list_del(&svc_data_mem) fix already present in 9119ceb76e98;
  keep the unmatched-free warning and style cleanup.
- Adapt of_device_id.data usage to extend stratix10_svc_pdata (shared with
  needs_psci_cpu_off) instead of casting BIT flags into .data.
- Keep kzalloc_obj()/kfree() lifetime for pmem on both gen_pool and DMA
  paths after 9119ceb76e98.

v1 -> v2:
- split original patch into smaller patches for easier review and backporting.
- Fixed the Fixes: tag in patch 3 referencing 5a0793ac66ac
- Replaced of_device_is_compatible() with of_device_id.data + of_device_get_match_data()
- Various commit message improvements
---

Adrian Ng Ho Yin (2):
  firmware: stratix10-svc: warn on unmatched free in
    stratix10_svc_free_memory
  firmware: stratix10-svc: add Agilex5 SMMU DMA coherent support

 drivers/firmware/stratix10-svc.c             | 250 +++++++++++++++----
 include/linux/firmware/intel/stratix10-smc.h |  23 ++
 2 files changed, 228 insertions(+), 45 deletions(-)

-- 
2.49.GIT
Re: [PATCH v4 0/2] firmware: stratix10-svc: Agilex5 SMMU DMA coherent support
Posted by Dinh Nguyen 1 week, 3 days ago

On 9/11/26 10:52, adrian.ho.yin.ng@altera.com wrote:
> From: Adrian Ng Ho Yin <adrian.ho.yin.ng@altera.com>
> 
> This series adds Agilex5 SMMU DMA coherent support in the stratix10-svc
> driver.
> 
> On Agilex5 the DDR base address starts at 0x8000_0000, which is
> outside the addressable range of the SDM. When SMMU is active, the
> driver must allocate DMA-coherent buffers and pass IOVAs within the
> SDM-accessible 0-512MB window to ATF. Agilex5 REV B introduced a
> hardware SDM address remapper, but it must be bypassed so no additional
> offset is applied to the IOVA, keeping the implementation consistent
> across all Agilex5 revisions.
> 
> Patch 1 reports unmatched frees in stratix10_svc_free_memory() with
> dev_warn() and cleans up related coding style in svc_pa_to_va(). The
> list-head corruption from list_del(&svc_data_mem) was already fixed by
> commit 9119ceb76e98 ("firmware: stratix10-svc: fix memory leaks and list
> corruption bugs").
> 
> Patch 2 adds the DMA coherent allocation path and wires Agilex5
> enablement in probe: require an IOMMU domain for intel,agilex5-svc,
> bypass the SDM address remapper via INTEL_SIP_SMC_SDM_REMAPPER_CONFIG,
> set the 29-bit DMA mask, select the DMA path through
> stratix10_svc_pdata, register a devm cleanup for leaked buffers, and
> guard err_destroy_pool against a NULL genpool.
> 
> ---
> changelog:
> v3 -> v4:
> - Squash the DMA-allocation and Agilex5 probe enablement patches into
>    one commit. Building the former alone triggered -Wunused-function on
>    svc_setup_dma_memory() and left use_dma_mem false (inert).
> - Drop the arm64 DTS patch from this series; resend firmware patches
>    only.
> - Drop Signed-off-by: Dinh Nguyen from patch 1; resending with author
>    Signed-off-by only.
> 
> v2 -> v3:
> - Squash former patch 2 (SMC remapper defines) into the probe enablement
>    patch so the defines land with their first usage.
> - Rebase on socfpga_firmware_for_v7.4.
> - Drop the list_del(&svc_data_mem) fix already present in 9119ceb76e98;
>    keep the unmatched-free warning and style cleanup.
> - Adapt of_device_id.data usage to extend stratix10_svc_pdata (shared with
>    needs_psci_cpu_off) instead of casting BIT flags into .data.
> - Keep kzalloc_obj()/kfree() lifetime for pmem on both gen_pool and DMA
>    paths after 9119ceb76e98.
> 
> v1 -> v2:
> - split original patch into smaller patches for easier review and backporting.
> - Fixed the Fixes: tag in patch 3 referencing 5a0793ac66ac
> - Replaced of_device_is_compatible() with of_device_id.data + of_device_get_match_data()
> - Various commit message improvements
> ---
> 
> Adrian Ng Ho Yin (2):
>    firmware: stratix10-svc: warn on unmatched free in
>      stratix10_svc_free_memory
>    firmware: stratix10-svc: add Agilex5 SMMU DMA coherent support
> 
>   drivers/firmware/stratix10-svc.c             | 250 +++++++++++++++----
>   include/linux/firmware/intel/stratix10-smc.h |  23 ++
>   2 files changed, 228 insertions(+), 45 deletions(-)
> 

Applied!

Thanks,
Dinh