Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A54C21254B for ; Tue, 30 Dec 2025 10:52:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767091942; cv=none; b=TmJyPODfxJCQRHm0rfmE0yRh6EAUWH3tvS+jC/swCY+xqCy6r66lMpAfdYYhxQ6OeTrNleuWIws3M8P343KH0ykUjzZIhEiQU6NOCM8XPa9GplYOsenzPzo2h1TFPKSpHZ+/K7jLWJjBVWNyjeIc4ACWbv/xguJsCZn9PZv0OkQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767091942; c=relaxed/simple; bh=0U+WRwMcIku8TKMGPl19rhckCfREHU4LkFf0GXSAhjo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QvDtmOgd9CBlpQZ3u4hhbuH6wn1//jiFK5xOIPR8pciXoz8AK9tw1RRfY1H1aZRtDbjqfj0HA2FgaDTTxR8K5GZsUjBzXjxu1JNdzoXXao6xuYUO5UIkOHYWn54X8nk4oP0HUnzxKjJGzhaL4bulIdccih2os84didcVLkr3UsI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FB089ytG; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FB089ytG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1767091941; x=1798627941; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0U+WRwMcIku8TKMGPl19rhckCfREHU4LkFf0GXSAhjo=; b=FB089ytG7FD3HIMzWwfwpJjR7bdcl2Oblmoxb6KIwcvghyASZp20c9EZ dq4bAO3wZG+y5Sr1dWYk6sfcVZgMhVXFOz8pNX9kN93ZekTiMTLxhxuWM Tfal54WqXn/spTf/7ZXJ4zGxkXr54ZmTgD8fKXe+1W6KARnwGDtmddfzx XIY/b8cHk8Z/b4Rt55GY9cmLujZ62mJSiqAj3HaF4tIOUuwop+00bxDxo L0nP08cNGOCC2a7TBCwKIyKgujh+deGM6w/K4ArGODL+J3lrSaav6n8/H dFRSBsHkSA6bEewlo4/UQtS9gn2s2AVV88HfTaY8bIsS2HdO7iJD1E6sw w==; X-CSE-ConnectionGUID: qARTzycYSxaOnza8CSIdCQ== X-CSE-MsgGUID: rEZVGMplSiCo+WxAu0/ztQ== X-IronPort-AV: E=McAfee;i="6800,10657,11656"; a="94148719" X-IronPort-AV: E=Sophos;i="6.21,188,1763452800"; d="scan'208";a="94148719" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Dec 2025 02:52:17 -0800 X-CSE-ConnectionGUID: y3mRZBotQpSvPq3hHE3WhA== X-CSE-MsgGUID: i7lS4KcdSQKQNTgftWYuZQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,188,1763452800"; d="scan'208";a="201186894" Received: from egrumbac-mobl6.ger.corp.intel.com (HELO kekkonen.fi.intel.com) ([10.245.245.96]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Dec 2025 02:52:15 -0800 Received: from punajuuri.localdomain (unknown [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 7DCF8121D82; Tue, 30 Dec 2025 12:52:23 +0200 (EET) Received: from sailus by punajuuri.localdomain with local (Exim 4.98.2) (envelope-from ) id 1vaXKw-0000000FQXx-0hVT; Tue, 30 Dec 2025 12:52:22 +0200 Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo From: Sakari Ailus To: linux-media@vger.kernel.org Cc: bingbu.cao@linux.intel.com, tian.shu.qiu@intel.com, antti.laakso@linux.intel.com, mehdi.djait@linux.intel.com Subject: [PATCH v2 01/13] media: ipu6: Ensure stream_mutex is acquired when dealing with node list Date: Tue, 30 Dec 2025 12:52:10 +0200 Message-ID: <20251230105222.3676928-2-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251230105222.3676928-1-sakari.ailus@linux.intel.com> References: <20251230105222.3676928-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The ipu6 isys driver maintains the list of video buffer queues related to a stream (in ipu6 context streams on the same CSI-2 virtual channel) and this list is modified through VIDIOC_STREAMON and VIDIOC_STREAMOFF IOCTLs. Ensure the common mutex is acquired when accessing the linked list, i.e. the isys device context's stream_mutex. Add a lockdep assert to ipu6_isys_get_buffer_list() and switch to guard() while at it as the error handling becomes more simple this way. Signed-off-by: Sakari Ailus --- drivers/media/pci/intel/ipu6/ipu6-isys-queue.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-queue.c b/drivers/media/pci/intel/ipu6/ipu6-isys-queue.c index aa2cf7287477..8f05987cdb4e 100644 --- a/drivers/media/pci/intel/ipu6/ipu6-isys-queue.c +++ b/drivers/media/pci/intel/ipu6/ipu6-isys-queue.c @@ -3,6 +3,7 @@ * Copyright (C) 2013--2024 Intel Corporation */ #include +#include #include #include #include @@ -201,6 +202,8 @@ static int buffer_list_get(struct ipu6_isys_stream *stream, unsigned long flags; unsigned long buf_flag = IPU6_ISYS_BUFFER_LIST_FL_INCOMING; + lockdep_assert_held(&stream->mutex); + bl->nbufs = 0; INIT_LIST_HEAD(&bl->head); @@ -294,9 +297,8 @@ static int ipu6_isys_stream_start(struct ipu6_isys_video *av, struct ipu6_isys_buffer_list __bl; int ret; - mutex_lock(&stream->isys->stream_mutex); + guard(mutex)(&stream->isys->stream_mutex); ret = ipu6_isys_video_set_streaming(av, 1, bl); - mutex_unlock(&stream->isys->stream_mutex); if (ret) goto out_requeue; @@ -637,10 +639,10 @@ static void stop_streaming(struct vb2_queue *q) mutex_lock(&av->isys->stream_mutex); if (stream->nr_streaming == stream->nr_queues && stream->streaming) ipu6_isys_video_set_streaming(av, 0, NULL); + list_del(&aq->node); mutex_unlock(&av->isys->stream_mutex); stream->nr_streaming--; - list_del(&aq->node); stream->streaming = 0; mutex_unlock(&stream->mutex); -- 2.47.3