[2/2] libcamera: pipeline: simple: Do not alloc CMA DMA-buffers for camss and ipu6/7
diff mbox series

Message ID 20261025155233.113989-2-johannes.goede@oss.qualcomm.com
State Superseded
Headers show
Series
  • [1/2] libcamera: software_isp: Add AllocCmaDmaBuffers constructor flag
Related show

Commit Message

Hans de Goede Oct. 25, 2026, 3:52 p.m. UTC
On Qualcomm platforms with the camss CSI receiver block it is not necessary
to allocate DMA-buffers from CMA and doing so may lead to starvation of
the CMA pool for other processes.

On Intel IPU6 / IPU7 there typically is no CMA memory reservation at all so
trying to use memory from there is not useful.

Reported-by: Wenmeng Liu <wenmeng.liu@oss.qualcomm.com>
Closes: https://lists.libcamera.org/pipermail/libcamera-devel/2026-September/062125.html
Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
---
 src/libcamera/pipeline/simple/simple.cpp | 25 ++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

Comments

Milan Zamazal Oct. 26, 2026, 2:46 p.m. UTC | #1
Hans de Goede <johannes.goede@oss.qualcomm.com> writes:

> On Qualcomm platforms with the camss CSI receiver block it is not necessary
> to allocate DMA-buffers from CMA and doing so may lead to starvation of
> the CMA pool for other processes.
>
> On Intel IPU6 / IPU7 there typically is no CMA memory reservation at all so
> trying to use memory from there is not useful.
>
> Reported-by: Wenmeng Liu <wenmeng.liu@oss.qualcomm.com>
> Closes: https://lists.libcamera.org/pipermail/libcamera-devel/2026-September/062125.html
> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
> ---
>  src/libcamera/pipeline/simple/simple.cpp | 25 ++++++++++++++----------
>  1 file changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
> index caab09b00..5042950cf 100644
> --- a/src/libcamera/pipeline/simple/simple.cpp
> +++ b/src/libcamera/pipeline/simple/simple.cpp
> @@ -251,20 +251,22 @@ struct SimplePipelineInfo {
>  	 * The Software ISP can't be used together with the converters.
>  	 */
>  	bool swIspEnabled;
> +	/* Flags controlling Software ISP behavior. */
> +	SoftwareIsp::SoftwareIspFlags swIspFlags;
>  };
>  
>  namespace {
>  
>  static const SimplePipelineInfo supportedDevices[] = {
> -	{ "dcmipp", {}, false },
> -	{ "imx7-csi", { { "pxp", 1 } }, true },
> -	{ "intel-ipu6", {}, true },
> -	{ "intel-ipu7", {}, true },
> -	{ "j721e-csi2rx", {}, true },
> -	{ "mtk-seninf", { { "mtk-mdp", 3 } }, false },
> -	{ "mxc-isi", {}, false },
> -	{ "qcom-camss", {}, true },
> -	{ "sun6i-csi", {}, false },
> +	{ "dcmipp", {}, false, {} },
> +	{ "imx7-csi", { { "pxp", 1 } }, true, SoftwareIsp::SoftwareIspFlag::AllocCmaDmaBuffers },
> +	{ "intel-ipu6", {}, true, {} },
> +	{ "intel-ipu7", {}, true, {} },
> +	{ "j721e-csi2rx", {}, true, SoftwareIsp::SoftwareIspFlag::AllocCmaDmaBuffers },
> +	{ "mtk-seninf", { { "mtk-mdp", 3 } }, false, {} },
> +	{ "mxc-isi", {}, false, {} },
> +	{ "qcom-camss", {}, true, {} },
> +	{ "sun6i-csi", {}, false, {} },

I can't say whether the settings here are correct but otherwise:

Reviewed-by: Milan Zamazal <mzamazal@redhat.com>

>  };
>  
>  bool isRaw(const StreamConfiguration &cfg)
> @@ -427,6 +429,7 @@ public:
>  	V4L2Subdevice *subdev(const MediaEntity *entity);
>  	std::shared_ptr<MediaDevice> converter() { return converter_; }
>  	bool swIspEnabled() const { return swIspEnabled_; }
> +	SoftwareIsp::SoftwareIspFlags swIspFlags() const { return swIspFlags_; }
>  
>  protected:
>  	int queueRequestDevice(Camera *camera, Request *request) override;
> @@ -460,6 +463,7 @@ private:
>  
>  	std::shared_ptr<MediaDevice> converter_;
>  	bool swIspEnabled_;
> +	SoftwareIsp::SoftwareIspFlags swIspFlags_;
>  };
>  
>  /* -----------------------------------------------------------------------------
> @@ -616,7 +620,7 @@ int SimpleCameraData::init()
>  	 */
>  	if (!converter_ && pipe->swIspEnabled()) {
>  		swIsp_ = std::make_unique<SoftwareIsp>(pipe, sensor_.get(),
> -						       SoftwareIsp::SoftwareIspFlag::AllocCmaDmaBuffers,
> +						       pipe->swIspFlags(),
>  						       &controlInfo_);
>  		if (!swIsp_->isValid()) {
>  			LOG(SimplePipeline, Warning)
> @@ -1883,6 +1887,7 @@ bool SimplePipelineHandler::matchDevice(std::shared_ptr<MediaDevice> media,
>  	}
>  
>  	swIspEnabled_ = info.swIspEnabled;
> +	swIspFlags_ = info.swIspFlags;
>  	const GlobalConfiguration &configuration = cameraManager()->_d()->configuration();
>  	for (const ValueNode &entry :
>  	     configuration.configuration()["pipelines"]["simple"]["supported_devices"]
Hans de Goede Oct. 26, 2026, 2:53 p.m. UTC | #2
Hi,

On 26-Oct-26 3:46 PM, Milan Zamazal wrote:
> Hans de Goede <johannes.goede@oss.qualcomm.com> writes:
> 
>> On Qualcomm platforms with the camss CSI receiver block it is not necessary
>> to allocate DMA-buffers from CMA and doing so may lead to starvation of
>> the CMA pool for other processes.
>>
>> On Intel IPU6 / IPU7 there typically is no CMA memory reservation at all so
>> trying to use memory from there is not useful.
>>
>> Reported-by: Wenmeng Liu <wenmeng.liu@oss.qualcomm.com>
>> Closes: https://lists.libcamera.org/pipermail/libcamera-devel/2026-September/062125.html
>> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
>> ---
>>  src/libcamera/pipeline/simple/simple.cpp | 25 ++++++++++++++----------
>>  1 file changed, 15 insertions(+), 10 deletions(-)
>>
>> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
>> index caab09b00..5042950cf 100644
>> --- a/src/libcamera/pipeline/simple/simple.cpp
>> +++ b/src/libcamera/pipeline/simple/simple.cpp
>> @@ -251,20 +251,22 @@ struct SimplePipelineInfo {
>>  	 * The Software ISP can't be used together with the converters.
>>  	 */
>>  	bool swIspEnabled;
>> +	/* Flags controlling Software ISP behavior. */
>> +	SoftwareIsp::SoftwareIspFlags swIspFlags;
>>  };
>>  
>>  namespace {
>>  
>>  static const SimplePipelineInfo supportedDevices[] = {
>> -	{ "dcmipp", {}, false },
>> -	{ "imx7-csi", { { "pxp", 1 } }, true },
>> -	{ "intel-ipu6", {}, true },
>> -	{ "intel-ipu7", {}, true },
>> -	{ "j721e-csi2rx", {}, true },
>> -	{ "mtk-seninf", { { "mtk-mdp", 3 } }, false },
>> -	{ "mxc-isi", {}, false },
>> -	{ "qcom-camss", {}, true },
>> -	{ "sun6i-csi", {}, false },
>> +	{ "dcmipp", {}, false, {} },
>> +	{ "imx7-csi", { { "pxp", 1 } }, true, SoftwareIsp::SoftwareIspFlag::AllocCmaDmaBuffers },
>> +	{ "intel-ipu6", {}, true, {} },
>> +	{ "intel-ipu7", {}, true, {} },
>> +	{ "j721e-csi2rx", {}, true, SoftwareIsp::SoftwareIspFlag::AllocCmaDmaBuffers },
>> +	{ "mtk-seninf", { { "mtk-mdp", 3 } }, false, {} },
>> +	{ "mxc-isi", {}, false, {} },
>> +	{ "qcom-camss", {}, true, {} },
>> +	{ "sun6i-csi", {}, false, {} },
> 
> I can't say whether the settings here are correct but otherwise:

Note I'm only changing the camss and ipu6/ipu7 settings, the rest is unchanged
from before this patch (passing empty flags for configs which have swIspEnabled = false).

> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>

Regards,

Hans



>>  };
>>  
>>  bool isRaw(const StreamConfiguration &cfg)
>> @@ -427,6 +429,7 @@ public:
>>  	V4L2Subdevice *subdev(const MediaEntity *entity);
>>  	std::shared_ptr<MediaDevice> converter() { return converter_; }
>>  	bool swIspEnabled() const { return swIspEnabled_; }
>> +	SoftwareIsp::SoftwareIspFlags swIspFlags() const { return swIspFlags_; }
>>  
>>  protected:
>>  	int queueRequestDevice(Camera *camera, Request *request) override;
>> @@ -460,6 +463,7 @@ private:
>>  
>>  	std::shared_ptr<MediaDevice> converter_;
>>  	bool swIspEnabled_;
>> +	SoftwareIsp::SoftwareIspFlags swIspFlags_;
>>  };
>>  
>>  /* -----------------------------------------------------------------------------
>> @@ -616,7 +620,7 @@ int SimpleCameraData::init()
>>  	 */
>>  	if (!converter_ && pipe->swIspEnabled()) {
>>  		swIsp_ = std::make_unique<SoftwareIsp>(pipe, sensor_.get(),
>> -						       SoftwareIsp::SoftwareIspFlag::AllocCmaDmaBuffers,
>> +						       pipe->swIspFlags(),
>>  						       &controlInfo_);
>>  		if (!swIsp_->isValid()) {
>>  			LOG(SimplePipeline, Warning)
>> @@ -1883,6 +1887,7 @@ bool SimplePipelineHandler::matchDevice(std::shared_ptr<MediaDevice> media,
>>  	}
>>  
>>  	swIspEnabled_ = info.swIspEnabled;
>> +	swIspFlags_ = info.swIspFlags;
>>  	const GlobalConfiguration &configuration = cameraManager()->_d()->configuration();
>>  	for (const ValueNode &entry :
>>  	     configuration.configuration()["pipelines"]["simple"]["supported_devices"]
>

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index caab09b00..5042950cf 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -251,20 +251,22 @@  struct SimplePipelineInfo {
 	 * The Software ISP can't be used together with the converters.
 	 */
 	bool swIspEnabled;
+	/* Flags controlling Software ISP behavior. */
+	SoftwareIsp::SoftwareIspFlags swIspFlags;
 };
 
 namespace {
 
 static const SimplePipelineInfo supportedDevices[] = {
-	{ "dcmipp", {}, false },
-	{ "imx7-csi", { { "pxp", 1 } }, true },
-	{ "intel-ipu6", {}, true },
-	{ "intel-ipu7", {}, true },
-	{ "j721e-csi2rx", {}, true },
-	{ "mtk-seninf", { { "mtk-mdp", 3 } }, false },
-	{ "mxc-isi", {}, false },
-	{ "qcom-camss", {}, true },
-	{ "sun6i-csi", {}, false },
+	{ "dcmipp", {}, false, {} },
+	{ "imx7-csi", { { "pxp", 1 } }, true, SoftwareIsp::SoftwareIspFlag::AllocCmaDmaBuffers },
+	{ "intel-ipu6", {}, true, {} },
+	{ "intel-ipu7", {}, true, {} },
+	{ "j721e-csi2rx", {}, true, SoftwareIsp::SoftwareIspFlag::AllocCmaDmaBuffers },
+	{ "mtk-seninf", { { "mtk-mdp", 3 } }, false, {} },
+	{ "mxc-isi", {}, false, {} },
+	{ "qcom-camss", {}, true, {} },
+	{ "sun6i-csi", {}, false, {} },
 };
 
 bool isRaw(const StreamConfiguration &cfg)
@@ -427,6 +429,7 @@  public:
 	V4L2Subdevice *subdev(const MediaEntity *entity);
 	std::shared_ptr<MediaDevice> converter() { return converter_; }
 	bool swIspEnabled() const { return swIspEnabled_; }
+	SoftwareIsp::SoftwareIspFlags swIspFlags() const { return swIspFlags_; }
 
 protected:
 	int queueRequestDevice(Camera *camera, Request *request) override;
@@ -460,6 +463,7 @@  private:
 
 	std::shared_ptr<MediaDevice> converter_;
 	bool swIspEnabled_;
+	SoftwareIsp::SoftwareIspFlags swIspFlags_;
 };
 
 /* -----------------------------------------------------------------------------
@@ -616,7 +620,7 @@  int SimpleCameraData::init()
 	 */
 	if (!converter_ && pipe->swIspEnabled()) {
 		swIsp_ = std::make_unique<SoftwareIsp>(pipe, sensor_.get(),
-						       SoftwareIsp::SoftwareIspFlag::AllocCmaDmaBuffers,
+						       pipe->swIspFlags(),
 						       &controlInfo_);
 		if (!swIsp_->isValid()) {
 			LOG(SimplePipeline, Warning)
@@ -1883,6 +1887,7 @@  bool SimplePipelineHandler::matchDevice(std::shared_ptr<MediaDevice> media,
 	}
 
 	swIspEnabled_ = info.swIspEnabled;
+	swIspFlags_ = info.swIspFlags;
 	const GlobalConfiguration &configuration = cameraManager()->_d()->configuration();
 	for (const ValueNode &entry :
 	     configuration.configuration()["pipelines"]["simple"]["supported_devices"]