diff --git a/src/ipa/libipa/algorithm.cpp b/src/ipa/libipa/algorithm.cpp
index 757ce3519652..20ead51bf7e0 100644
--- a/src/ipa/libipa/algorithm.cpp
+++ b/src/ipa/libipa/algorithm.cpp
@@ -16,6 +16,28 @@ namespace libcamera {
 
 namespace ipa {
 
+std::ostream &operator<<(std::basic_ostream<char> &out, libcamera::ipa::AlgorithmStep step)
+{
+	switch (step) {
+	case AlgorithmStep::Init:
+		out << "Init";
+		break;
+	case AlgorithmStep::Configure:
+		out << "Configure";
+		break;
+	case AlgorithmStep::Queue:
+		out << "Queue";
+		break;
+	case AlgorithmStep::Prepare:
+		out << "Prepare";
+		break;
+	case AlgorithmStep::Process:
+		out << "Process";
+		break;
+	}
+	return out;
+}
+
 /**
  * \class Algorithm
  * \brief The base class for all IPA algorithms
diff --git a/src/ipa/libipa/algorithm.h b/src/ipa/libipa/algorithm.h
index b47765700317..97d7130a789d 100644
--- a/src/ipa/libipa/algorithm.h
+++ b/src/ipa/libipa/algorithm.h
@@ -7,6 +7,7 @@
 #pragma once
 
 #include <memory>
+#include <set>
 #include <stdint.h>
 #include <string>
 
@@ -18,6 +19,48 @@ class ValueNode;
 
 namespace ipa {
 
+enum class AlgorithmStep {
+	Init = 0,
+	Configure,
+	Queue,
+	Prepare,
+	Process
+};
+
+std::ostream &operator<<(std::basic_ostream<char> &out, libcamera::ipa::AlgorithmStep step);
+
+const std::array<AlgorithmStep, 5> kAlgorithmAllSteps = {
+	AlgorithmStep::Init,
+	AlgorithmStep::Configure,
+	AlgorithmStep::Queue,
+	AlgorithmStep::Prepare,
+	AlgorithmStep::Process
+};
+
+struct AlgorithmDependency {
+	enum Type {
+		/* Step on target needs to come first */
+		Before = 0x01,
+		/* Target must exist */
+		Exist = 0x02
+	};
+
+	std::string target;
+	AlgorithmStep step;
+	unsigned type = 0;
+
+	bool operator<(const AlgorithmDependency &other) const
+	{
+		return (target < other.target) ||
+		       ((target == other.target) &&
+			((step < other.step) ||
+			 ((step == other.step) &&
+			  (type < other.type))));
+	}
+};
+
+const std::set<AlgorithmDependency> kNoDependencies = {};
+
 template<typename _Module>
 class AlgorithmFactoryBase;
 
@@ -63,6 +106,11 @@ public:
 	{
 	}
 
+	virtual const std::set<AlgorithmDependency> &dependencies() const
+	{
+		return kNoDependencies;
+	}
+
 	const std::string &name() const
 	{
 		return name_;
diff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h
index 5644458bdf3d..cb2176dc37a6 100644
--- a/src/ipa/libipa/module.h
+++ b/src/ipa/libipa/module.h
@@ -7,8 +7,10 @@
 
 #pragma once
 
+#include <cerrno>
 #include <list>
 #include <memory>
+#include <set>
 #include <string>
 #include <vector>
 
@@ -35,6 +37,7 @@ public:
 	using Config = _Config;
 	using Params = _Params;
 	using Stats = _Stats;
+	using AlgorithmT = Algorithm<Module>;
 
 	virtual ~Module() {}
 
@@ -43,25 +46,76 @@ public:
 		return algorithms_;
 	}
 
+	const std::vector<Algorithm<Module> *> &algorithmsOrderedForStep(AlgorithmStep step) const
+	{
+		return algorithmsOrderedForStep_.at(step);
+	}
+
 	int createAlgorithms(Context &context, const ValueNode &algorithms)
 	{
 		const auto &list = algorithms.asList();
+		std::map<AlgorithmT *, const ValueNode *> dataMap;
+
+		utils::ScopeExitActions actions;
+
+		actions += [this]() {
+			clearAlgorithms();
+		};
 
 		for (const auto &[i, algo] : utils::enumerate(list)) {
 			if (!algo.isDictionary()) {
 				LOG(IPAModuleAlgo, Error)
 					<< "Invalid tuning data syntax for algorithm " << i;
-				algorithms_.clear();
 				return -EINVAL;
 			}
 
-			int ret = createAlgorithm(context, algo);
+			const auto &[name, algoData] = *algo.asDict().begin();
+			/*
+			 * Optionally, algorithms can be disabled via the tuning file
+			 * by including enabled: false as a parameter within the
+			 * algorithm tuning data. This is not an error, so we return 0.
+			 */
+			if (!algoData["enabled"].get<bool>(true)) {
+				LOG(IPAModuleAlgo, Info)
+					<< "Algorithm '" << name << "' disabled via tuning file";
+				return 0;
+			}
+
+			std::unique_ptr<Algorithm<Module>> instance = createAlgorithm(name);
+			if (!instance) {
+				LOG(IPAModuleAlgo, Error)
+					<< "Algorithm '" << name << "' not found";
+				return -EINVAL;
+			}
+
+			algorithms_.push_back(std::move(instance));
+
+			LOG(IPAModuleAlgo, Debug)
+				<< "Instantiated algorithm '" << name << "'";
+
+			dataMap[algorithms_.back().get()] = &algoData;
+		}
+
+		for (auto step : kAlgorithmAllSteps) {
+			std::vector<AlgorithmT *> algos;
+			int ret = createOrderedList(algos, step);
+			if (ret)
+				return ret;
+
+			algorithmsOrderedForStep_[step] = std::move(algos);
+		}
+
+		for (const auto &a : algorithmsOrderedForStep(AlgorithmStep::Init)) {
+			int ret = a->init(context, *dataMap[a]);
 			if (ret) {
-				algorithms_.clear();
+				LOG(IPAModuleAlgo, Error)
+					<< "Algorithm failed to initialize";
 				return ret;
 			}
 		}
 
+		actions.release();
+
 		return 0;
 	}
 
@@ -71,42 +125,101 @@ public:
 	}
 
 private:
-	int createAlgorithm(Context &context, const ValueNode &data)
+	int createOrderedList(std::vector<Algorithm<Module> *> &orderedList,
+			      AlgorithmStep step)
 	{
-		const auto &[name, algoData] = *data.asDict().begin();
+		using Algo = Algorithm<Module>;
+		std::set<Algo *> handledAlgorithms;
 
-		/*
-		 * Optionally, algorithms can be disabled via the tuning file
-		 * by including enabled: false as a parameter within the
-		 * algorithm tuning data. This is not an error, so we return 0.
-		 */
-		if (!algoData["enabled"].get<bool>(true)) {
-			LOG(IPAModuleAlgo, Info)
-				<< "Algorithm '" << name << "' disabled via tuning file";
-			return 0;
+		orderedList.clear();
+
+		for (const auto &a : algorithms()) {
+			std::vector<std::string> resolutionStack;
+			int ret = addToOrderedList(a.get(), orderedList,
+						   resolutionStack,
+						   step);
+			if (ret)
+				return ret;
 		}
 
-		std::unique_ptr<Algorithm<Module>> algo = createAlgorithm(name);
-		if (!algo) {
-			LOG(IPAModuleAlgo, Error)
-				<< "Algorithm '" << name << "' not found";
-			return -EINVAL;
-		}
-
-		int ret = algo->init(context, algoData);
-		if (ret) {
-			LOG(IPAModuleAlgo, Error)
-				<< "Algorithm '" << name << "' failed to initialize";
-			return ret;
-		}
-
-		LOG(IPAModuleAlgo, Debug)
-			<< "Instantiated algorithm '" << name << "'";
-
-		algorithms_.push_back(std::move(algo));
 		return 0;
 	}
 
+	int addToOrderedList(Algorithm<Module> *algo,
+			     std::vector<Algorithm<Module> *> &orderedList,
+			     std::vector<std::string> &resolutionStack,
+			     AlgorithmStep step)
+	{
+		/* nothing to do if it was added already due to dependency resolution */
+		if (std::find(orderedList.begin(), orderedList.end(), algo) != orderedList.end())
+			return 0;
+
+		auto &deps = algo->dependencies();
+
+		/* First add the dependent ones */
+		for (auto &dep : deps) {
+			if (dep.step != step)
+				continue;
+
+			if (!(dep.type & (AlgorithmDependency::Exist | AlgorithmDependency::Before))) {
+				LOG(IPAModuleAlgo, Error)
+					<< "Unknown dependency flags '"
+					<< dep.type
+					<< "' on dependency '" << dep.target;
+				return -EINVAL;
+			}
+
+			if (std::find(resolutionStack.begin(), resolutionStack.end(), dep.target) != resolutionStack.end()) {
+				LOG(IPAModuleAlgo, Info)
+					<< "Circular dependency detected: "
+					<< dep.target;
+				return -EINVAL;
+			}
+
+			/* Find the target */
+			auto iter = std::find_if(algorithms_.begin(), algorithms_.end(),
+						 [&](auto &a) { return a->name() == dep.target; });
+			if (iter == algorithms_.end()) {
+				if (dep.type & AlgorithmDependency::Exist) {
+					LOG(IPAModuleAlgo, Error)
+						<< "Algorithm '" << dep.target
+						<< "' is listed as dependency but not instantiated";
+					return -EINVAL;
+				}
+
+				if (dep.type & AlgorithmDependency::Before) {
+					LOG(IPAModuleAlgo, Debug)
+						<< "Algorithm '" << dep.target
+						<< "' is listed as optional dependency but not instantiated";
+					continue;
+				}
+
+				ASSERT(false);
+			}
+
+			Algorithm<Module> *dependency = iter->get();
+			if (std::find(orderedList.begin(), orderedList.end(), dependency) == orderedList.end()) {
+				resolutionStack.push_back(dep.target);
+				int ret = addToOrderedList(dependency,
+							   orderedList,
+							   resolutionStack,
+							   step);
+				if (ret)
+					return ret;
+			}
+		}
+
+		orderedList.push_back(algo);
+		LOG(IPAModuleAlgo, Debug) << "Step " << step << " add algo " << algo->name();
+		return 0;
+	}
+
+	void clearAlgorithms()
+	{
+		algorithmsOrderedForStep_.clear();
+		algorithms_.clear();
+	}
+
 	static std::unique_ptr<Algorithm<Module>> createAlgorithm(const std::string &name)
 	{
 		for (const AlgorithmFactoryBase<Module> *factory : factories()) {
@@ -129,6 +242,7 @@ private:
 	}
 
 	std::list<std::unique_ptr<Algorithm<Module>>> algorithms_;
+	std::map<AlgorithmStep, std::vector<AlgorithmT *>> algorithmsOrderedForStep_;
 };
 
 } /* namespace ipa */
diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp
index cefaf40aee63..add2e45cfa36 100644
--- a/src/ipa/rkisp1/rkisp1.cpp
+++ b/src/ipa/rkisp1/rkisp1.cpp
@@ -30,6 +30,7 @@
 
 #include "algorithms/algorithm.h"
 #include "libipa/agc.h"
+#include "libipa/algorithm.h"
 
 #include "ipa_context.h"
 #include "params.h"
@@ -237,8 +238,8 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig,
 			return format.colourEncoding == PixelFormatInfo::ColourEncodingRAW;
 		});
 
-	for (const auto &a : algorithms()) {
-		Algorithm *algo = static_cast<Algorithm *>(a.get());
+	for (const auto &a : algorithmsOrderedForStep(AlgorithmStep::Configure)) {
+		Algorithm *algo = static_cast<Algorithm *>(a);
 
 		/* Disable algorithms that don't support raw formats. */
 		algo->disabled_ = context_.configuration.raw && !algo->supportsRaw_;
@@ -290,8 +291,8 @@ void IPARkISP1::queueRequest(const uint32_t frame, const ControlList &controls)
 	IPAFrameContext &frameContext = context_.frameContexts.alloc(frame);
 	context_.debugMetadata.enableByControl(controls);
 
-	for (const auto &a : algorithms()) {
-		Algorithm *algo = static_cast<Algorithm *>(a.get());
+	for (const auto &a : algorithmsOrderedForStep(AlgorithmStep::Queue)) {
+		Algorithm *algo = static_cast<Algorithm *>(a);
 		if (algo->disabled_)
 			continue;
 		algo->queueRequest(context_, frame, frameContext, controls);
@@ -305,8 +306,9 @@ void IPARkISP1::computeParams(const uint32_t frame, const uint32_t bufferId)
 	RkISP1Params params(context_.configuration.paramFormat,
 			    mappedBuffers_.at(bufferId).planes()[0]);
 
-	for (const auto &algo : algorithms())
+	for (const auto &algo : algorithmsOrderedForStep(AlgorithmStep::Prepare)) {
 		algo->prepare(context_, frame, frameContext, &params);
+	}
 
 	paramsComputed.emit(frame, params.bytesused());
 }
@@ -330,8 +332,8 @@ void IPARkISP1::processStats(const uint32_t frame, const uint32_t bufferId,
 
 	ControlList metadata(controls::controls);
 
-	for (const auto &a : algorithms()) {
-		Algorithm *algo = static_cast<Algorithm *>(a.get());
+	for (const auto &a : algorithmsOrderedForStep(AlgorithmStep::Process)) {
+		Algorithm *algo = static_cast<Algorithm *>(a);
 		if (algo->disabled_)
 			continue;
 		algo->process(context_, frame, frameContext, stats, metadata);
