From patchwork Mon Jun 3 08:26:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Wentong" X-Patchwork-Id: 13683369 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 BABA853E31 for ; Mon, 3 Jun 2024 08:05:04 +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=1717401906; cv=none; b=f1RHMhDzjgx3xX37RDQD6AIxUf/Iuq7XMnAC8X9dOJgTnJsoKzzgT1LOgEgR7aRnV3c30+zg/xOvEDQi4kKQudcj1KaXVMEeZVWfVaoRl4UorbkLX8v7KXDK45YJdmbz7PIzu4MJ/eabH/3wFjUM8OXQz2pmlvqABaxBMou7H7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717401906; c=relaxed/simple; bh=neHAif2hPC2f8Ib3q+9GO/k4O2BoUwh6fsZqjyoxgGE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QzKGcZwI5rJP4q7zFkpTHqjj0SXiBVhHdrU4H7kyN8VgNZFbajoSmtOksBnABsXWq0CbusTpWE7BRoHPuK0aqCuenzRfxuP9o29phIxUqUDLspwEL14aRddS0t/Nc1T9kYwScUf1ZeaQVX2diDTWWe2FYwbqNriBSBJXwmrNk6g= 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=Zx4O0Ntq; arc=none smtp.client-ip=192.198.163.7 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="Zx4O0Ntq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717401904; x=1748937904; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=neHAif2hPC2f8Ib3q+9GO/k4O2BoUwh6fsZqjyoxgGE=; b=Zx4O0NtqUHwY08/IzxNfHBInXBZ1vlLjTbdnYd/JfONndmmurCBNxHFP xFrtRV6TTfxW8ut7HG8gk+O0/zDXOCiS5GlXHRtUVAE+T3X2C2nVZDgCF v728SFkVLsE+p568XjazqNSPHKGRk3x9671/4DSBLB1sr13aGvPpKHKGg 9OHI3qp9/KxQGYOM3F0u8uZ2exNur0oAtu+0wUX/CCa/ysJ6+TLtsRB1y ihdlUy/Rs9Qvn7R0E7thkm4T56ZaPRe2Azs2mWVlVetC7SLKHbbfVBclr sIGd6fv46JUFhXOUxFAAMfx6yhtHNUsuFCUTG0EQOs4qFPE7e6kwrAB+Z w==; X-CSE-ConnectionGUID: 8BqHeaBuTIGoMlXpEKS/sg== X-CSE-MsgGUID: 77V/+dbfTZCi9KsSxAQCAA== X-IronPort-AV: E=McAfee;i="6600,9927,11091"; a="39285026" X-IronPort-AV: E=Sophos;i="6.08,211,1712646000"; d="scan'208";a="39285026" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 01:05:04 -0700 X-CSE-ConnectionGUID: HOhYa/7bQ7aHXV0Ti9T08Q== X-CSE-MsgGUID: yb8z75mqSECKq3519uPOIA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,211,1712646000"; d="scan'208";a="36722118" Received: from wentongw-optiplex-8070.sh.intel.com ([10.239.154.12]) by orviesa010.jf.intel.com with ESMTP; 03 Jun 2024 01:05:03 -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 1/3] media: ivsc: csi: don't count privacy on as error Date: Mon, 3 Jun 2024 16:26:12 +0800 Message-Id: <20240603082614.1567712-2-wentong.wu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240603082614.1567712-1-wentong.wu@intel.com> References: <20240603082614.1567712-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..004ebab0b814 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, CSI_PRIVACY_ON); + } else if (ret) { ret = -EINVAL; goto out; } From patchwork Mon Jun 3 08:26:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Wentong" X-Patchwork-Id: 13683370 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 D6C2C53365 for ; Mon, 3 Jun 2024 08:05:06 +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=1717401908; cv=none; b=Q/FPMtuYHqRWukN5/R0bSAesa5M7aeoEiZ/Erx60dkQg3KghuwJv1xWAcWrM/DMD9JVieD2dAmUPWSQQjHnWJcV+5XHONs9PDuBt26878DjSu9pYGrGVtTN+Zm5dMnn1j34nc0kMhC+9IWh/bRIDQsquOC4yUow4OvBpXMBLdWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717401908; c=relaxed/simple; bh=04GAPIDZe+cnPlgu5+BSVtkVJLB/UdAQ2UPvvE/dZm0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=riFXZ0uA41+7XZilhVd/944ecp0jVc37FFWRmM4QYAgbtyvowIBkkz0cauolqumTGa8BMkw9j2/mHfXqqIR50Z2MvkwWI+zIuBJT7odtiSE4Ti3M/9Tt+VJ4HGi2PMnWCHBKpKNAIbG94iAz3N5uaJ06sEEkzVJxB+Wp/JIC9T4= 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=BNdg9J7/; arc=none smtp.client-ip=192.198.163.7 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="BNdg9J7/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717401907; x=1748937907; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=04GAPIDZe+cnPlgu5+BSVtkVJLB/UdAQ2UPvvE/dZm0=; b=BNdg9J7/UcqaMdNao4EPjHDVSxWGWY7UimfveH/CZCwSEIX9//m8bfr9 EFET1ogIkWe6V4o/2Gm+IV6AjZmHzivCU3qbeYoyvOlts7W5TpY0QTw+v wEADeCK6h/b8uid7Ug6FNqNs73MghoQuqVS1dnu5hDNKpNc5VxIMt3iZc YoVAZn3SR2PCmk0y9A9aXqd19nm1ISWy1IpFQFJKqhKjG1vnSewIF9gT2 eBmYpo5a6vo3lcHHcHsu2WAJWdpKaASsZyINYtGNOs/ouRV53l2wrHmvN erlEZrs8OK/mecHYMWr1GjdIHq/tY7eOuNDuOTItZRsOE2CU7dDUqiYA3 A==; X-CSE-ConnectionGUID: uuPQV+ZYRoav+qa0RlJr2Q== X-CSE-MsgGUID: 4Y9W/pKtQyGEho7XnhC+9w== X-IronPort-AV: E=McAfee;i="6600,9927,11091"; a="39285038" X-IronPort-AV: E=Sophos;i="6.08,211,1712646000"; d="scan'208";a="39285038" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 01:05:06 -0700 X-CSE-ConnectionGUID: yFA212NyTuOxZHszkXLk7Q== X-CSE-MsgGUID: lC+S0FDdTVejIwbXDEg5Gw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,211,1712646000"; d="scan'208";a="36722175" Received: from wentongw-optiplex-8070.sh.intel.com ([10.239.154.12]) by orviesa010.jf.intel.com with ESMTP; 03 Jun 2024 01:05:06 -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 2/3] media: ivsc: csi: add separate lock for v4l2 control handler Date: Mon, 3 Jun 2024 16:26:13 +0800 Message-Id: <20240603082614.1567712-3-wentong.wu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240603082614.1567712-1-wentong.wu@intel.com> References: <20240603082614.1567712-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 004ebab0b814..d6ba0d9efca1 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 Mon Jun 3 08:26:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Wentong" X-Patchwork-Id: 13683371 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 B4019487BF for ; Mon, 3 Jun 2024 08:05:17 +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=1717401919; cv=none; b=CZ9eC0fdtvtZSHMlH7kX0SAR/P201aSCPQ27NndnoCH45iwsxvMbqMgCHvFygGCcoeesDVAXz+IAc3nI8G/+wzUZr/6q4l+bxqinsHivdjvYE1OF+ah1+4QC74fKAMMCOq8pIkGlUIdsxkntpNFoINGQ+TeGR1yNqyE/QpEYxyM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717401919; c=relaxed/simple; bh=2wwUnJIWa/fyiUmrNrIr2z9FqDutAh7Psex4hcpKa+k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mcuO31xve6fBBTZ76nBLkK4zHM4z3FMwUwwUVOyDPK2qiQNun/2xWuDw+N6IQpyt0GJgyqGaEhcTr4hnCbt02SLOlB75O4BNBr6m9Ru5xgGSkZHNpEXxz53SVyiq6hfL5tRkJX5VYwMgKZdX0ex5whKvcR8fQMy920jo1qj56vU= 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=MzHnSHMZ; arc=none smtp.client-ip=192.198.163.7 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="MzHnSHMZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717401917; x=1748937917; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2wwUnJIWa/fyiUmrNrIr2z9FqDutAh7Psex4hcpKa+k=; b=MzHnSHMZb13ovnjIZEZtMKG5oaNzvxM03sk4M6EaAipE8Bs/9PbOyP2s E9AlB00gInuKzdfoMsi4Sd03nEYVueV1/r0tb40Ec1jgsff8ZmpHZou/l mHhAyarepZrrKhydGmId6FsPtHoBlfq5LeVa6+fczYg9V7b/fVlg35Xt6 OohEZDg+nASSTPzvXVLrlbDuVXz8FIRq19pWze13ljZBaTIJSOPsipFNW EVwhk9I+RrwrSthbnHHU4Y3adc1tzEMnMG/NcbGtDihZ+U//hxo5ijhwJ oVPb9bpkJbf7nUsJ0p8XbgZQ98Ot6anBx3zK4+TUJzV5nEKOj7mb8CLH9 A==; X-CSE-ConnectionGUID: jRC5skjJQaaWXd3deq0n4A== X-CSE-MsgGUID: n5lkZpxpSg6AO4QlKG4Q+g== X-IronPort-AV: E=McAfee;i="6600,9927,11091"; a="39285060" X-IronPort-AV: E=Sophos;i="6.08,211,1712646000"; d="scan'208";a="39285060" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 01:05:17 -0700 X-CSE-ConnectionGUID: dRUGDVsuRSOtUgG4TAHkQA== X-CSE-MsgGUID: yAhYo2MgRTSl4HkLPjpqPg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,211,1712646000"; d="scan'208";a="36722285" Received: from wentongw-optiplex-8070.sh.intel.com ([10.239.154.12]) by orviesa010.jf.intel.com with ESMTP; 03 Jun 2024 01:05:16 -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 3/3] media: ivsc: csi: remove privacy status in struct mei_csi Date: Mon, 3 Jun 2024 16:26:14 +0800 Message-Id: <20240603082614.1567712-4-wentong.wu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240603082614.1567712-1-wentong.wu@intel.com> References: <20240603082614.1567712-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 | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/media/pci/intel/ivsc/mei_csi.c b/drivers/media/pci/intel/ivsc/mei_csi.c index d6ba0d9efca1..1d1b9181a50a 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,8 @@ 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); break; case CSI_SET_OWNER: case CSI_SET_CONF: