From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-media@vger.kernel.org
Cc: Antti Laakso <antti.laakso@linux.intel.com>,
sarang.sapre@intel.com, daxing.li@intel.com,
ong.hock.yu@intel.com
Subject: [PATCH v4 38/45] media: ipu6: Make fw mapping function reusable
Date: Mon, 7 Sep 2026 14:29:57 +0300 [thread overview]
Message-ID: <20260907113004.2489993-39-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <20260907113004.2489993-1-sakari.ailus@linux.intel.com>
From: Antti Laakso <antti.laakso@linux.intel.com>
Make ipu6_map_fw_region reusable as for ipu7 we want to map other
buffers too, not only firmware. Also add DMA data direction and mapping
attributes as arguments as these are different for ipu7.
Signed-off-by: Antti Laakso <antti.laakso@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/pci/intel/ipu6/ipu6-buttress.c | 40 ++++++++++----------
drivers/media/pci/intel/ipu6/ipu6-buttress.h | 10 ++---
drivers/media/pci/intel/ipu6/ipu6-isys.c | 7 ++--
drivers/media/pci/intel/ipu6/ipu6.c | 8 ++--
4 files changed, 33 insertions(+), 32 deletions(-)
diff --git a/drivers/media/pci/intel/ipu6/ipu6-buttress.c b/drivers/media/pci/intel/ipu6/ipu6-buttress.c
index 13fd7a083b25..74db0a37561e 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-buttress.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-buttress.c
@@ -676,55 +676,55 @@ int ipu6_buttress_reset_authentication(struct ipu6_device *isp)
return 0;
}
-int ipu6_buttress_map_fw_image(struct ipu6_bus_device *sys,
- const struct firmware *fw, struct sg_table *sgt)
+int ipu6_map_fw_region(struct ipu6_bus_device *sys, const void *data,
+ size_t size, enum dma_data_direction dir,
+ unsigned long attrs)
{
- bool is_vmalloc = is_vmalloc_addr(fw->data);
+ bool is_vmalloc = is_vmalloc_addr(data);
struct pci_dev *pdev = sys->isp->pdev;
+ struct sg_table *sgt = &sys->fw_sgt;
struct page **pages;
- const void *addr;
unsigned long n_pages;
unsigned int i;
int ret;
- if (!is_vmalloc && !virt_addr_valid(fw->data))
+ if (!is_vmalloc && !virt_addr_valid(data))
return -EDOM;
- n_pages = PFN_UP(fw->size);
+ n_pages = PFN_UP(size);
pages = kmalloc_objs(*pages, n_pages);
if (!pages)
return -ENOMEM;
- addr = fw->data;
for (i = 0; i < n_pages; i++) {
struct page *p = is_vmalloc ?
- vmalloc_to_page(addr) : virt_to_page(addr);
+ vmalloc_to_page(data) : virt_to_page(data);
if (!p) {
ret = -ENOMEM;
goto out;
}
pages[i] = p;
- addr += PAGE_SIZE;
+ data += PAGE_SIZE;
}
- ret = sg_alloc_table_from_pages(sgt, pages, n_pages, 0, fw->size,
+ ret = sg_alloc_table_from_pages(sgt, pages, n_pages, 0, size,
GFP_KERNEL);
if (ret) {
ret = -ENOMEM;
goto out;
}
- ret = dma_map_sgtable(&pdev->dev, sgt, DMA_TO_DEVICE, 0);
+ ret = dma_map_sgtable(&pdev->dev, sgt, dir, 0);
if (ret) {
sg_free_table(sgt);
goto out;
}
- ret = ipu6_dma_map_sgtable(sys, sgt, DMA_TO_DEVICE, 0);
+ ret = ipu6_dma_map_sgtable(sys, sgt, dir, attrs);
if (ret) {
- dma_unmap_sgtable(&pdev->dev, sgt, DMA_TO_DEVICE, 0);
+ dma_unmap_sgtable(&pdev->dev, sgt, dir, 0);
sg_free_table(sgt);
goto out;
}
@@ -736,18 +736,18 @@ int ipu6_buttress_map_fw_image(struct ipu6_bus_device *sys,
return ret;
}
-EXPORT_SYMBOL_NS_GPL(ipu6_buttress_map_fw_image, "INTEL_IPU6");
+EXPORT_SYMBOL_NS_GPL(ipu6_map_fw_region, "INTEL_IPU6");
-void ipu6_buttress_unmap_fw_image(struct ipu6_bus_device *sys,
- struct sg_table *sgt)
+void ipu6_unmap_fw_region(struct ipu6_bus_device *sys,
+ enum dma_data_direction dir)
{
struct pci_dev *pdev = sys->isp->pdev;
- ipu6_dma_unmap_sgtable(sys, sgt, DMA_TO_DEVICE, 0);
- dma_unmap_sgtable(&pdev->dev, sgt, DMA_TO_DEVICE, 0);
- sg_free_table(sgt);
+ ipu6_dma_unmap_sgtable(sys, &sys->fw_sgt, dir, 0);
+ dma_unmap_sgtable(&pdev->dev, &sys->fw_sgt, dir, 0);
+ sg_free_table(&sys->fw_sgt);
}
-EXPORT_SYMBOL_NS_GPL(ipu6_buttress_unmap_fw_image, "INTEL_IPU6");
+EXPORT_SYMBOL_NS_GPL(ipu6_unmap_fw_region, "INTEL_IPU6");
int ipu6_buttress_authenticate(struct ipu6_device *isp)
{
diff --git a/drivers/media/pci/intel/ipu6/ipu6-buttress.h b/drivers/media/pci/intel/ipu6/ipu6-buttress.h
index 47a49e961945..79d8f5893686 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-buttress.h
+++ b/drivers/media/pci/intel/ipu6/ipu6-buttress.h
@@ -84,11 +84,11 @@ struct ipu6_ipc_buttress_bulk_msg {
};
int ipu6_buttress_ipc_reset(struct ipu6_device *isp);
-int ipu6_buttress_map_fw_image(struct ipu6_bus_device *sys,
- const struct firmware *fw,
- struct sg_table *sgt);
-void ipu6_buttress_unmap_fw_image(struct ipu6_bus_device *sys,
- struct sg_table *sgt);
+int ipu6_map_fw_region(struct ipu6_bus_device *sys, const void *data,
+ size_t size, enum dma_data_direction dir,
+ unsigned long attrs);
+void ipu6_unmap_fw_region(struct ipu6_bus_device *sys,
+ enum dma_data_direction dir);
int ipu6_buttress_power(struct device *dev,
const struct ipu6_buttress_ctrl *ctrl, bool on);
bool ipu6_buttress_get_secure_mode(struct ipu6_device *isp);
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys.c b/drivers/media/pci/intel/ipu6/ipu6-isys.c
index 5a3ba5007249..459121e6c1cb 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys.c
@@ -1042,7 +1042,8 @@ static int isys_probe(struct auxiliary_device *auxdev,
if (!isp->secure_mode) {
fw = isp->cpd_fw;
- ret = ipu6_buttress_map_fw_image(adev, fw, &adev->fw_sgt);
+ ret = ipu6_map_fw_region(adev, fw->data, fw->size,
+ DMA_TO_DEVICE, 0);
if (ret)
goto release_firmware;
@@ -1082,7 +1083,7 @@ static int isys_probe(struct auxiliary_device *auxdev,
ipu6_cpd_free_pkg_dir(adev);
remove_shared_buffer:
if (!isp->secure_mode)
- ipu6_buttress_unmap_fw_image(adev, &adev->fw_sgt);
+ ipu6_unmap_fw_region(adev, DMA_TO_DEVICE);
release_firmware:
if (!isp->secure_mode)
release_firmware(adev->fw);
@@ -1112,7 +1113,7 @@ static void isys_remove(struct auxiliary_device *auxdev)
if (!isp->secure_mode) {
ipu6_cpd_free_pkg_dir(adev);
- ipu6_buttress_unmap_fw_image(adev, &adev->fw_sgt);
+ ipu6_unmap_fw_region(adev, DMA_TO_DEVICE);
release_firmware(adev->fw);
}
diff --git a/drivers/media/pci/intel/ipu6/ipu6.c b/drivers/media/pci/intel/ipu6/ipu6.c
index 428ad046e239..af5581da7149 100644
--- a/drivers/media/pci/intel/ipu6/ipu6.c
+++ b/drivers/media/pci/intel/ipu6/ipu6.c
@@ -624,8 +624,8 @@ static int ipu6_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto out_ipu6_rpm_put;
}
- ret = ipu6_buttress_map_fw_image(isp->psys, isp->cpd_fw,
- &isp->psys->fw_sgt);
+ ret = ipu6_map_fw_region(isp->psys, isp->cpd_fw->data,
+ isp->cpd_fw->size, DMA_TO_DEVICE, 0);
if (ret) {
dev_err_probe(&isp->pdev->dev, ret, "failed to map fw image\n");
goto out_ipu6_rpm_put;
@@ -679,7 +679,7 @@ static int ipu6_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
out_ipu6_bus_del_devices:
if (!IS_ERR_OR_NULL(isp->psys)) {
ipu6_cpd_free_pkg_dir(isp->psys);
- ipu6_buttress_unmap_fw_image(isp->psys, &isp->psys->fw_sgt);
+ ipu6_unmap_fw_region(isp->psys, DMA_TO_DEVICE);
}
if (!IS_ERR_OR_NULL(isp->psys) && !IS_ERR_OR_NULL(isp->psys->mmu))
ipu6_mmu_cleanup(isp->psys->mmu);
@@ -702,7 +702,7 @@ static void ipu6_pci_remove(struct pci_dev *pdev)
devm_free_irq(&pdev->dev, pdev->irq, isp);
ipu6_cpd_free_pkg_dir(isp->psys);
- ipu6_buttress_unmap_fw_image(isp->psys, &isp->psys->fw_sgt);
+ ipu6_unmap_fw_region(isp->psys, DMA_TO_DEVICE);
ipu6_buttress_exit(isp);
ipu6_bus_del_devices(pdev);
--
2.47.3
next prev parent reply other threads:[~2026-09-07 11:30 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 11:29 [PATCH v4 00/45] media: ipu6: Add support for ipu7 hardware Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 01/45] media: ipu6: Add helpers for IPU runtime variation Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 02/45] media: ipu6: Rename pointer to firmware context Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 03/45] media: ipu6: Rename buttress_ipc pointer Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 04/45] media: ipu6: Remove duplicate warnings in cpd validation Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 05/45] media: ipu6: Remove unused ipu6 firmware struct Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 06/45] media: ipu6: Cleanup ipu6_mmu_init() Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 07/45] media: ipu6: Simplify firmware com arguments Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 08/45] media: ipu6: Add helper to identify ipu7 Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 09/45] media: ipu6: Prepare buttress for ipu7 support Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 10/45] media: ipu6: Use single struct for registers Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 11/45] media: ipu6: Rename IPU subsys ID Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 12/45] media: ipu6: Add ipu7 buttress support Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 13/45] media: ipu6: Prepare mmu driver for hw variation Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 14/45] media: ipu6: Add ipu7 mmu support Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 15/45] media: ipu6: Add ipu7 cpd handling Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 16/45] media: ipu6: Add check for pkg_dir before freeing Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 17/45] media: ipu6: Rename isys fw msg union Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 18/45] media: ipu6: Move isys isr handlers to fw file Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 19/45] media: ipu6: Move hw specific buffer handling down Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 20/45] media: ipu6: Isolate hw specific buffer handling Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 21/45] media: ipu6: Add isys firmware ops Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 22/45] media: ipu6: Add ipu7 fw start/stop functionality Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 23/45] media: ipu6: Add ipu7 fw com methods Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 24/45] media: ipu6: Add ipu7 fw isys ops Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 25/45] media: ipu6: Add ipu7 csi2 register definitions Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 26/45] media: ipu6: Add ipu7 isr handler Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 27/45] media: ipu6: Add ipu7 csi phy driver Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 28/45] media: ipu6: Split ipu6 csi2 stream enable/disable Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 29/45] media: ipu6: Add support for ipu7 csi2 receiver Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 30/45] media: ipu6: Parse bus type for ipu7 Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 31/45] media: ipu6: Enable ipu7 isys interrupts Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 32/45] media: ipu6: Skip watermark configuration for ipu7 Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 33/45] media: ipu6: The SPC init is valid only for ipu6 Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 34/45] media: ipu6: The VC arbitration mechanism is ipu6 only Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 35/45] media: ipu6: Move buttress mem alloc out from probe Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 36/45] media: ipu6: Read correct SKU ID for ipu7 Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 37/45] media: ipu6: Add support for fixed iova region Sakari Ailus
2026-09-07 11:29 ` Sakari Ailus [this message]
2026-09-07 11:29 ` [PATCH v4 39/45] media: ipu6: Move isys fw mapping to pci_probe Sakari Ailus
2026-09-07 11:29 ` [PATCH v4 40/45] media: ipu6: Map ipu7 firmware Sakari Ailus
2026-09-07 11:30 ` [PATCH v4 41/45] media: ipu6: Set model name for ipu7 Sakari Ailus
2026-09-07 11:30 ` [PATCH v4 42/45] media: ipu6: Add ipu7.5 buttress support Sakari Ailus
2026-09-07 11:30 ` [PATCH v4 43/45] media: ipu6: Add ipu7.5 mmu initialization data Sakari Ailus
2026-09-07 11:30 ` [PATCH v4 44/45] media: ipu6: Enable support for IPU 7 and IPU 7.5 Sakari Ailus
2026-09-07 11:30 ` [PATCH v4 45/45] staging: media: ipu7: Update TODO file Sakari Ailus
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=20260907113004.2489993-39-sakari.ailus@linux.intel.com \
--to=sakari.ailus@linux.intel.com \
--cc=antti.laakso@linux.intel.com \
--cc=daxing.li@intel.com \
--cc=linux-media@vger.kernel.org \
--cc=ong.hock.yu@intel.com \
--cc=sarang.sapre@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.