cip-dev.lists.cip-project.org archive mirror
 help / color / mirror / Atom feed
From: "Lad Prabhakar" <prabhakar.mahadev-lad.rj@bp.renesas.com>
To: cip-dev@lists.cip-project.org,
	Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>,
	Pavel Machek <pavel@denx.de>
Cc: Biju Das <biju.das.jz@bp.renesas.com>
Subject: [cip-dev] [PATCH 4.19.y-cip 20/40] media: i2c: imx219: take lock in imx219_enum_mbus_code/frame_size
Date: Tue,  9 Mar 2021 16:36:36 +0000	[thread overview]
Message-ID: <20210309163656.20944-21-prabhakar.mahadev-lad.rj@bp.renesas.com> (raw)
In-Reply-To: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com>

[-- Attachment #1: Type: text/plain, Size: 4658 bytes --]

From: Hans Verkuil <hverkuil-cisco@xs4all.nl>

commit 81015221a269e0d9bf6dbc3fda099b09a876ebb7 upstream.

These two functions did not take the imx219->mutex lock, but
imx219_get_format_code checks that a lock is taken, so it issues
a warning:

[    8.738717] WARNING: CPU: 2 PID: 60 at drivers/media/i2c/imx219.c:653 imx219_get_format_code+0xac/0xc0
[    8.748113] Modules linked in:
[    8.751214] CPU: 2 PID: 60 Comm: kworker/2:1 Tainted: G        W         5.8.0-rc1-arm64 #148
[    8.759821] Hardware name: NVIDIA Jetson TX1 Developer Kit (DT)
[    8.765806] Workqueue: events deferred_probe_work_func
[    8.771003] pstate: 60000005 (nZCv daif -PAN -UAO BTYPE=--)
[    8.776635] pc : imx219_get_format_code+0xac/0xc0
[    8.781390] lr : imx219_get_format_code+0xa8/0xc0
[    8.786143] sp : ffff800012a538f0
[    8.789495] x29: ffff800012a538f0 x28: ffff800012838e90
[    8.794867] x27: ffff0000f28c5800 x26: ffff800011161c68
[    8.800237] x25: ffff0000f2a5a3f8 x24: 0000000000000018
[    8.805605] x23: ffff0000f284ef18 x22: ffff0000f2a5a080
[    8.810974] x21: ffff0000f284ff00 x20: ffff0000f2a5a080
[    8.816343] x19: 000000000000300f x18: 00000000ffffffff
[    8.821712] x17: ffff800011c77268 x16: 00000000000040d7
[    8.827081] x15: 00000000000040d8 x14: 0000000000000000
[    8.832451] x13: 00000000000040d4 x12: ffff800011d19300
[    8.837819] x11: 00000000000208c0 x10: 0000000000000004
[    8.843188] x9 : 000000003baa2ecd x8 : 000000008b3f9c73
[    8.848558] x7 : 0000000000000008 x6 : 0000000000000034
[    8.853929] x5 : 0000000000000000 x4 : 0000000000000001
[    8.859297] x3 : ffff800010a2a8a8 x2 : ffff0000f84a8000
[    8.864666] x1 : 0000000000000000 x0 : 0000000000000000
[    8.870034] Call trace:
[    8.872515]  imx219_get_format_code+0xac/0xc0
[    8.876921]  imx219_enum_mbus_code+0x38/0x60
[    8.881241]  call_enum_mbus_code+0x50/0x70
[    8.885387]  tegra_vi_graph_notify_complete+0x290/0x5e8
[    8.890670]  v4l2_async_notifier_try_complete.part.0+0x48/0x68
[    8.896563]  v4l2_async_register_subdev+0x100/0x1c0
[    8.901497]  v4l2_async_register_subdev_sensor_common+0x70/0xf0
[    8.907477]  imx219_probe+0x590/0x728
[    8.911184]  i2c_device_probe+0xe4/0x2b0
[    8.915151]  really_probe+0xd8/0x330
[    8.918768]  driver_probe_device+0x58/0xb8
[    8.922909]  __device_attach_driver+0x84/0xc8
[    8.927315]  bus_for_each_drv+0x78/0xc8
[    8.931193]  __device_attach+0xe4/0x140
[    8.935072]  device_initial_probe+0x14/0x20
[    8.939301]  bus_probe_device+0x9c/0xa8
[    8.943179]  deferred_probe_work_func+0x74/0xb0
[    8.947759]  process_one_work+0x2c4/0x740
[    8.951813]  worker_thread+0x4c/0x430
[    8.955518]  kthread+0x158/0x178
[    8.958786]  ret_from_fork+0x10/0x1c
[    8.962401] irq event stamp: 63536
[    8.965846] hardirqs last  enabled at (63535): [<ffff800010082398>] el1_irq+0xd8/0x180
[    8.973846] hardirqs last disabled at (63536): [<ffff8000100a6484>] do_debug_exception+0x16c/0x258
[    8.982895] softirqs last  enabled at (63534): [<ffff800010080d4c>] _stext+0x54c/0x594
[    8.990896] softirqs last disabled at (63525): [<ffff8000100c8350>] irq_exit+0x100/0x138
[    8.999066] ---[ end trace ebfbcd84b75ef921 ]---
[    9.004354] ------------[ cut here ]------------

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/media/i2c/imx219.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 386717fb2b99..a2829c7012aa 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -811,7 +811,9 @@ static int imx219_enum_mbus_code(struct v4l2_subdev *sd,
 	if (code->index >= (ARRAY_SIZE(codes) / 4))
 		return -EINVAL;
 
+	mutex_lock(&imx219->mutex);
 	code->code = imx219_get_format_code(imx219, codes[code->index * 4]);
+	mutex_unlock(&imx219->mutex);
 
 	return 0;
 }
@@ -821,11 +823,15 @@ static int imx219_enum_frame_size(struct v4l2_subdev *sd,
 				  struct v4l2_subdev_frame_size_enum *fse)
 {
 	struct imx219 *imx219 = to_imx219(sd);
+	u32 code;
 
 	if (fse->index >= ARRAY_SIZE(supported_modes))
 		return -EINVAL;
 
-	if (fse->code != imx219_get_format_code(imx219, fse->code))
+	mutex_lock(&imx219->mutex);
+	code = imx219_get_format_code(imx219, fse->code);
+	mutex_unlock(&imx219->mutex);
+	if (fse->code != code)
 		return -EINVAL;
 
 	fse->min_width = supported_modes[fse->index].width;
-- 
2.17.1


[-- Attachment #2: Type: text/plain, Size: 428 bytes --]


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#6236): https://lists.cip-project.org/g/cip-dev/message/6236
Mute This Topic: https://lists.cip-project.org/mt/81205367/4520388
Group Owner: cip-dev+owner@lists.cip-project.org
Unsubscribe: https://lists.cip-project.org/g/cip-dev/leave/8129055/4520388/727948398/xyzzy [cip-dev@archiver.kernel.org]
-=-=-=-=-=-=-=-=-=-=-=-


  parent reply	other threads:[~2021-03-09 16:37 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-09 16:36 [cip-dev] [PATCH 4.19.y-cip 00/40] Renesas RZ/G2{E,H,M,N} add VIN, CSI2 support Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 01/40] media: ov5645: Remove unneeded regulator_set_voltage() Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 02/40] media: device property: Add a function to test is a fwnode is a graph endpoint Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 03/40] media: v4l2-async: Accept endpoints and devices for fwnode matching Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 04/40] media: v4l2-async: Pass notifier pointer to match functions Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 05/40] media: v4l2-async: Log message in case of heterogeneous fwnode match Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 06/40] media: v4l: ctrl: Provide unlocked variant of v4l2_ctrl_grab Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 07/40] media: rcar-vin: fix wrong return value in rvin_set_channel_routing() Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 08/40] media: rcar-csi2: Update V3M and E3 start procedure Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 09/40] media: rcar-vin: Invalidate pipeline if conversion is not possible on input formats Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 10/40] media: rcar-vin: Add support for MEDIA_BUS_FMT_SRGGB8_1X8 format Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 11/40] media: rcar-csi2: " Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 12/40] media: dt-bindings: media: i2c: Add IMX219 CMOS sensor binding Lad Prabhakar
2021-03-09 18:52   ` Pavel Machek
2021-03-10  8:48     ` Lad Prabhakar
2021-03-10  9:38       ` Pavel Machek
2021-03-10 10:24         ` Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 13/40] media: i2c: Add driver for Sony IMX219 sensor Lad Prabhakar
2021-03-09 20:36   ` Pavel Machek
2021-03-10  9:36     ` Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 14/40] media: i2c: imx219: Fix power sequence Lad Prabhakar
2021-03-09 19:42   ` Pavel Machek
2021-03-10  8:49     ` Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 15/40] media: i2c: imx219: Add support for RAW8 bit bayer format Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 16/40] media: i2c: imx219: Add support for cropped 640x480 resolution Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 17/40] media: i2c: imx219: Implement get_selection Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 18/40] media: i2c: imx219: Fix a bug in imx219_enum_frame_size Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 19/40] media: i2c: imx219: Selection compliance fixes Lad Prabhakar
2021-03-09 16:36 ` Lad Prabhakar [this message]
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 21/40] arm64: dts: renesas: r8a774c0-cat874: Add support for AISTARVISION MIPI Adapter V2.1 Lad Prabhakar
2021-03-09 20:39   ` Pavel Machek
2021-03-10  9:37     ` Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 22/40] media: dt-bindings: media: rcar_vin: Add r8a774a1 support Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 23/40] media: rcar-vin: Enable support for r8a774a1 Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 24/40] media: dt-bindings: media: rcar-csi2: Add r8a774a1 support Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 25/40] media: rcar-csi2: Enable support for r8a774a1 Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 26/40] arm64: dts: renesas: r8a774a1: Add VIN and CSI-2 nodes Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 27/40] media: dt-bindings: rcar-vin: Add R8A774B1 support Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 28/40] media: rcar-vin: Enable support for R8A774B1 Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 29/40] media: dt-bindings: rcar-csi2: Add R8A774B1 support Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 30/40] media: rcar-csi2: Enable support for R8A774B1 Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 31/40] arm64: dts: renesas: r8a774b1: Add VIN and CSI-2 support Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 32/40] media: dt-bindings: media: renesas,vin: Add R8A774E1 support Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 33/40] media: rcar-vin: Enable support for R8A774E1 Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 34/40] media: dt-bindings: media: renesas,csi2: Add R8A774E1 support Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 35/40] media: rcar-csi2: Enable support for R8A774E1 Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 36/40] arm64: dts: renesas: r8a774e1: Add VIN and CSI-2 nodes Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 37/40] arm64: dts: renesas: aistarvision-mipi-adapter-2.1: Add parent macro for each sensor Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 38/40] arm64: dts: renesas: Add support for MIPI Adapter V2.1 connected to HiHope RZ/G2H Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 39/40] arm64: dts: renesas: Add support for MIPI Adapter V2.1 connected to HiHope RZ/G2M Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 40/40] arm64: dts: renesas: Add support for MIPI Adapter V2.1 connected to HiHope RZ/G2N Lad Prabhakar
2021-03-09 20:48 ` [cip-dev] [PATCH 4.19.y-cip 00/40] Renesas RZ/G2{E,H,M,N} add VIN, CSI2 support Pavel Machek
2021-03-09 23:13 ` Pavel Machek
2021-03-10  8:07 ` Nobuhiro Iwamatsu
2021-03-10  9:41   ` Lad Prabhakar
2021-03-10 10:58   ` Chris Paterson
     [not found]   ` <166AF609ACF1E617.19014@lists.cip-project.org>
2021-03-22 22:11     ` Chris Paterson
2021-03-23  7:31       ` Nobuhiro Iwamatsu
2021-03-23  7:50         ` Chris Paterson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210309163656.20944-21-prabhakar.mahadev-lad.rj@bp.renesas.com \
    --to=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=cip-dev@lists.cip-project.org \
    --cc=nobuhiro1.iwamatsu@toshiba.co.jp \
    --cc=pavel@denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).