From patchwork Fri Jun 7 13:25:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Wentong" X-Patchwork-Id: 802503 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 624A4194093 for ; Fri, 7 Jun 2024 13:04:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717765446; cv=none; b=otv19ksEBYmSvTxNVdARFtqdmi5UGPBdZbnoq7eLaDAlbiZYq7TI54QrJGuObcqSmhNKQFwnsrwtIPgTIrMyPILSh6MEVp55B0RML98zZh7AzmfAAa8oTybhsMCO6c3A/1drhvI6G2e1FsAdoOQJlk2BTcBusKcyMKPUAdq8HjQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717765446; c=relaxed/simple; bh=QDUG6/wAPAJT68+sgD4iatys55dg2O76vtEDxrInv04=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SAjGFDuiYC3IpeOsnF2HQSqMjXy2z2nd0+7QneV7DO9whZ38M8B9sylelSaCyGi9nF+wwGOaM5RT0pgnU8PpVoyZ36B7XKaLIaIw7lOrylvP3nj3NZuzQO2xRJsyGEaZskBf9mOwPbrUd0HLWoMikCIn6wC2mMj7uL+O/tTwlUg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=VhfSF8O+; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="VhfSF8O+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717765444; x=1749301444; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QDUG6/wAPAJT68+sgD4iatys55dg2O76vtEDxrInv04=; b=VhfSF8O+QEyO7iG+86McSk7aLHs92RS7vTaj0kCAUUuYAZtY+Sv+oFZ6 i2RjLE+0z8GvzzGjRvilc7NVBCfK76RM3E17v00+1GX83mu5NE0SC3Y/D 8fXgctHWKRuM/EeIc/VE4uyusiGjD8nL+e1hA4C5GOs+ZR8XBUU6iaZoR 2GjzWdIptfRxM6dTl0Liyue0x2BkmNtp+M85G3Cgmf9Cyin8Jk9IObUJ5 F2bn6lTEHf+ILlKKqrLnTrBi05KgElvOLi76TpCVdDJCh8qc4lb0GY131 XsVI4h76leW3NKhOV5fjii8t7UhtItJKF6tWO3jSVjO1gGKIL+GbCH3d4 Q==; X-CSE-ConnectionGUID: 8q5IWjVRTGuZmDbfArP6ag== X-CSE-MsgGUID: L+4m61JLS1asEaOF0MhWlQ== X-IronPort-AV: E=McAfee;i="6600,9927,11096"; a="18311925" X-IronPort-AV: E=Sophos;i="6.08,221,1712646000"; d="scan'208";a="18311925" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2024 06:04:04 -0700 X-CSE-ConnectionGUID: Npc5tfVyToqyFDorjuC1Gg== X-CSE-MsgGUID: qQU1Ti/2Qkmn/j47IL+iEw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,221,1712646000"; d="scan'208";a="42734182" Received: from wentongw-optiplex-8070.sh.intel.com ([10.239.154.12]) by fmviesa005.fm.intel.com with ESMTP; 07 Jun 2024 06:04:02 -0700 From: Wentong Wu To: sakari.ailus@linux.intel.com, linux-media@vger.kernel.org Cc: hao.yao@intel.com, Wentong Wu , Jason Chen Subject: [PATCH v2 1/3] media: ivsc: csi: don't count privacy on as error Date: Fri, 7 Jun 2024 21:25:45 +0800 Message-Id: <20240607132547.2820515-2-wentong.wu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240607132547.2820515-1-wentong.wu@intel.com> References: <20240607132547.2820515-1-wentong.wu@intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Prior to the ongoing command privacy is on, it would return -1 to indicate the current privacy status, and the ongoing command would be well executed by firmware as well, so this is not error. This patch changes its behavior to notify privacy on directly by V4L2 privacy control instead of reporting error. Fixes: 29006e196a56 ("media: pci: intel: ivsc: Add CSI submodule") Reported-by: Hao Yao Signed-off-by: Wentong Wu Tested-by: Jason Chen --- drivers/media/pci/intel/ivsc/mei_csi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/media/pci/intel/ivsc/mei_csi.c b/drivers/media/pci/intel/ivsc/mei_csi.c index 89b582a221ab..05c0acb78939 100644 --- a/drivers/media/pci/intel/ivsc/mei_csi.c +++ b/drivers/media/pci/intel/ivsc/mei_csi.c @@ -190,7 +190,11 @@ static int mei_csi_send(struct mei_csi *csi, u8 *buf, size_t len) /* command response status */ ret = csi->cmd_response.status; - if (ret) { + if (ret == -1) { + /* notify privacy on instead of reporting error */ + ret = 0; + v4l2_ctrl_s_ctrl(csi->privacy_ctrl, 1); + } else if (ret) { ret = -EINVAL; goto out; } From patchwork Fri Jun 7 13:25:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Wentong" X-Patchwork-Id: 802759 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 7568A18732D for ; Fri, 7 Jun 2024 13:04:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717765449; cv=none; b=Z+A8V3ylEi1+T0z13LAvniWLJuh6uQnnVQGyEeoouFzd90WOQSUhAaHxxoy8JGXTcReGq5uZD+wbp+kEjOVhtB7ReN7+vAcLWb6r9Mib4aSTWIoAnI0TB3I83XiM+T6w0/DVW6oC9wx7WKm9fu/aMF9T7pS4qgGIhRcZVF3QULE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717765449; c=relaxed/simple; bh=SWUBLicWCoe659rktqHrfB3VErb9y/ffAhDsr1AcIxw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G/KdJWr27M6kULdrLRi21HUsGyfvgeYFXC19NqIN0pCzJVWQVcvmetDR5UakCRQfT0cTUNIT8G4S9dMEANE+py93XgblybxsJG7Hg9prdz5DW9epvx7fHjQhVkZOS5X7RM6LRMfjxCfeiQYi1zjgkVn2IkME1+psomrrQ/QJpbQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=OxaVoM9I; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="OxaVoM9I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717765447; x=1749301447; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SWUBLicWCoe659rktqHrfB3VErb9y/ffAhDsr1AcIxw=; b=OxaVoM9IafIQC8AMVYdO6XLzB0aSd+EtZdiuvhmgEYws/MPNYsmfcbcV OrEaiq2MirnOLnXJHD4swgRiSQPY9B2sC9YzzygxGBeZUq+19V4IijDAI lRCPspGHiQLnuFaXZ7r3hFjTu2NuwWo5t61Dp3ANoDwqwVhzXC38Hvmgf 08m98iDPvXeQeqgO27PD+Ewrpp7Ic4vL8Qimk3FywEMPFhoSktCPUR6XK Ci4HNbn1x7TmVJNkHdvLaiHhLmyNlaVsB+0jmvQbmEBRRn1XCxsTZH0Fn lzXyW7/uZhsn8PNzBYi67KgOrwcGr9AOOUoWPwdC/2OA0MkIc7fyvG9uP A==; X-CSE-ConnectionGUID: hNERS0XqTXCj6NtW3IYzFQ== X-CSE-MsgGUID: g0XReb3QTBemhICSB+OJUQ== X-IronPort-AV: E=McAfee;i="6600,9927,11096"; a="18311929" X-IronPort-AV: E=Sophos;i="6.08,221,1712646000"; d="scan'208";a="18311929" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2024 06:04:07 -0700 X-CSE-ConnectionGUID: UtnhCg0ISASI5xhpVb5UCA== X-CSE-MsgGUID: 7o0eNtnKQhqQ2bUST4pHxw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,221,1712646000"; d="scan'208";a="42734243" Received: from wentongw-optiplex-8070.sh.intel.com ([10.239.154.12]) by fmviesa005.fm.intel.com with ESMTP; 07 Jun 2024 06:04:05 -0700 From: Wentong Wu To: sakari.ailus@linux.intel.com, linux-media@vger.kernel.org Cc: hao.yao@intel.com, Wentong Wu , Jason Chen Subject: [PATCH v2 2/3] media: ivsc: csi: add separate lock for v4l2 control handler Date: Fri, 7 Jun 2024 21:25:46 +0800 Message-Id: <20240607132547.2820515-3-wentong.wu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240607132547.2820515-1-wentong.wu@intel.com> References: <20240607132547.2820515-1-wentong.wu@intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There're possibilities that privacy status change notification happens in the middle of the ongoing mei command which already takes the command lock, but v4l2_ctrl_s_ctrl() would also need the same lock prior to this patch, so this may results in circular locking problem. This patch adds one dedicated lock for v4l2 control handler to avoid described issue. Reported-by: Hao Yao Signed-off-by: Wentong Wu Tested-by: Jason Chen --- drivers/media/pci/intel/ivsc/mei_csi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/media/pci/intel/ivsc/mei_csi.c b/drivers/media/pci/intel/ivsc/mei_csi.c index 05c0acb78939..a46a012b301f 100644 --- a/drivers/media/pci/intel/ivsc/mei_csi.c +++ b/drivers/media/pci/intel/ivsc/mei_csi.c @@ -126,6 +126,8 @@ struct mei_csi { struct v4l2_ctrl_handler ctrl_handler; struct v4l2_ctrl *freq_ctrl; struct v4l2_ctrl *privacy_ctrl; + /* lock for v4l2 controls */ + struct mutex ctrl_lock; unsigned int remote_pad; /* start streaming or not */ int streaming; @@ -563,11 +565,13 @@ static int mei_csi_init_controls(struct mei_csi *csi) u32 max; int ret; + mutex_init(&csi->ctrl_lock); + ret = v4l2_ctrl_handler_init(&csi->ctrl_handler, 2); if (ret) return ret; - csi->ctrl_handler.lock = &csi->lock; + csi->ctrl_handler.lock = &csi->ctrl_lock; max = ARRAY_SIZE(link_freq_menu_items) - 1; csi->freq_ctrl = v4l2_ctrl_new_int_menu(&csi->ctrl_handler, @@ -756,6 +760,7 @@ static int mei_csi_probe(struct mei_cl_device *cldev, err_ctrl_handler: v4l2_ctrl_handler_free(&csi->ctrl_handler); + mutex_destroy(&csi->ctrl_lock); v4l2_async_nf_unregister(&csi->notifier); v4l2_async_nf_cleanup(&csi->notifier); @@ -775,6 +780,7 @@ static void mei_csi_remove(struct mei_cl_device *cldev) v4l2_async_nf_unregister(&csi->notifier); v4l2_async_nf_cleanup(&csi->notifier); v4l2_ctrl_handler_free(&csi->ctrl_handler); + mutex_destroy(&csi->ctrl_lock); v4l2_async_unregister_subdev(&csi->subdev); v4l2_subdev_cleanup(&csi->subdev); media_entity_cleanup(&csi->subdev.entity); From patchwork Fri Jun 7 13:25:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Wentong" X-Patchwork-Id: 802502 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 1D4D818732D for ; Fri, 7 Jun 2024 13:04:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717765452; cv=none; b=ATAAs25HYabo99nzcJouKII18CuTxDl0YOKNjeZduxl1AKFJqj7g2NsYbG47oSnkDg5zf1aaYoYdq6xBBGCSaNWaMm2jccXT5RKLB7G/OvLHT0dvfLGhfzLlshRLudYv0cLKtF1OI1+xE8zI1RgWrTacfSb4Bzz19nSuT4JlYJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717765452; c=relaxed/simple; bh=iCQLYmprlaAQWpAMxh9Mc/US0SNHlFGe+GDZ0+wbjM8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lyqzamiyVBE4qARisXvJ9C/YqvQAmAvsVcV28LHHhQ4ZLu1Ak5mLYiJHGOxQWsgxJKowkUyxcE+ButMlTRPP25T+p5hmvjNgFVNqdXC+jvr8plDrNU8Qa8PdqdOaH1jrs9xbeGrXyVS81Rq8ZeZVqUDXNu1wRR7zFNO3bMzsBQA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Ie1j7Fkh; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Ie1j7Fkh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717765451; x=1749301451; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iCQLYmprlaAQWpAMxh9Mc/US0SNHlFGe+GDZ0+wbjM8=; b=Ie1j7FkhzWnS0m7EBe0kAJID1Ly7xkqWga5PfUKtD05SfKUOT2MVw56o UlpjaQjEmWoomx6nS2TApZR1HkRAN1gwUfm+cinbaWi+i14TcPUI+inmG EbqeQ1WvoMhFlJws8jkvOdQZETO6snVGu2EO9JL/d+aDHOHfgzzds9Itv dYtHZ9309Zw2NfXyIr503Cj27b3vJNSwKHeKzyRj+4y266GiYR9pE9Ix8 H32cED2Y6uNbky2cgPpNPeM4VqdbaFmme/YjhWBj+TWw/mc6d1fT4tC8S uZy3KKRUlnpJbMGdIOaRMUT6/kwLfgEwSWMwOB9XvBGllLSIODQMHUVDm A==; X-CSE-ConnectionGUID: Pswy8zc9QBWrrqmZnyt5vQ== X-CSE-MsgGUID: Vs1iPX7UQZKVRNnYFv+tFA== X-IronPort-AV: E=McAfee;i="6600,9927,11096"; a="18311944" X-IronPort-AV: E=Sophos;i="6.08,221,1712646000"; d="scan'208";a="18311944" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2024 06:04:11 -0700 X-CSE-ConnectionGUID: SX76SQMMTj2UhISYtQlAWQ== X-CSE-MsgGUID: z+oyKIeASfaAw8YNZ9QrJg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,221,1712646000"; d="scan'208";a="42734311" Received: from wentongw-optiplex-8070.sh.intel.com ([10.239.154.12]) by fmviesa005.fm.intel.com with ESMTP; 07 Jun 2024 06:04:09 -0700 From: Wentong Wu To: sakari.ailus@linux.intel.com, linux-media@vger.kernel.org Cc: hao.yao@intel.com, Wentong Wu , Jason Chen Subject: [PATCH v2 3/3] media: ivsc: csi: remove privacy status in struct mei_csi Date: Fri, 7 Jun 2024 21:25:47 +0800 Message-Id: <20240607132547.2820515-4-wentong.wu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240607132547.2820515-1-wentong.wu@intel.com> References: <20240607132547.2820515-1-wentong.wu@intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The privacy status is maintained by privacy_ctrl, on which all of the privacy status changes will go through, so there is no point in maintaining one more element any more. Reported-by: Hao Yao Signed-off-by: Wentong Wu Tested-by: Jason Chen --- drivers/media/pci/intel/ivsc/mei_csi.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/media/pci/intel/ivsc/mei_csi.c b/drivers/media/pci/intel/ivsc/mei_csi.c index a46a012b301f..bff0176fc8f1 100644 --- a/drivers/media/pci/intel/ivsc/mei_csi.c +++ b/drivers/media/pci/intel/ivsc/mei_csi.c @@ -138,9 +138,6 @@ struct mei_csi { u32 nr_of_lanes; /* frequency of the CSI-2 link */ u64 link_freq; - - /* privacy status */ - enum ivsc_privacy_status status; }; static const struct v4l2_mbus_framefmt mei_csi_format_mbus_default = { @@ -271,10 +268,9 @@ static void mei_csi_rx(struct mei_cl_device *cldev) switch (notif.cmd_id) { case CSI_PRIVACY_NOTIF: - if (notif.cont.cont < CSI_PRIVACY_MAX) { - csi->status = notif.cont.cont; - v4l2_ctrl_s_ctrl(csi->privacy_ctrl, csi->status); - } + if (notif.cont.cont < CSI_PRIVACY_MAX) + v4l2_ctrl_s_ctrl(csi->privacy_ctrl, + notif.cont.cont == CSI_PRIVACY_ON); break; case CSI_SET_OWNER: case CSI_SET_CONF: