Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9092223pxu; Mon, 28 Dec 2020 06:27:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJyh5fzI3GFY40yEB7GB2dJm/ME2rJhHXRYwsJ8GRhfvxV5UjzAhD5KQ9lsMbn4IoVwTKh5P X-Received: by 2002:a50:84a9:: with SMTP id 38mr41743354edq.378.1609165621281; Mon, 28 Dec 2020 06:27:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165621; cv=none; d=google.com; s=arc-20160816; b=n9PCC+Cu0h+haJR1fYEkr4D/NSDrKLwcGKFS4P6qgkRTOtjSAHFQft6cLWf6Ozjta7 QUzrgH2ajnoBVfxlGkaegqBYexDYmZsNc2ISRGtLODsk0/3QRCvg59QneECjOvqMz8AU /iSL64ltc3Jx+qqnkse8kEm/AbykEAKKujfs5wQLg56Qtfe/qyA3hNc+R54XV0mZoBq0 B8IU+UsdPUBCjz0uHwVQLcMv50ymD+5+r6vK9+PpvyGSMZ9H9oq/SAuapkqr4peJyuSe 3zVk0cOWuOr/Vx0xBoboHtQMKrlQgw9wgUbeCF0f20p4CgjDTsN26M0xoIpZutlSEkJo hMSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OKy+0WmbHVcmCrGsMHMjSMxaRpJm0MaQONgX2zW1VCI=; b=GY6JFOB6llx5/dmE5iiXk61SHTdxSTh5rAVQNGxLP3yWaHRH7yBXWFNfd7WwgG+xk3 gBu/vIRULZjPY87F19KsVitL/Qsw8vKbJFgXMB87loJQVFGLjE7JnpVry0VOJ7XijrwB +UrSKh82KIWEs3/o9slx4O1KiYjPGGFhEaf5zfPAqXeNHCEG56PNhFDTWBQQiPbKb/ka /LSJ0JIqcM6MdySCMDUJQHItds0oaztnH5zT8XcXlRVv+SDb7si1oaMrlCL7i8VZNLB2 BPXcli0j+QnYJlZEuvxaU3x6iMZC59c0/CePZ5SJIQsMHzGXKEKo9RMqei/gjQb5Y6SK MgyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2lW6uzJS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n22si13422294ejr.464.2020.12.28.06.26.38; Mon, 28 Dec 2020 06:27:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2lW6uzJS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503075AbgL1OY0 (ORCPT + 99 others); Mon, 28 Dec 2020 09:24:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:60368 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503056AbgL1OYV (ORCPT ); Mon, 28 Dec 2020 09:24:21 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8278622B2C; Mon, 28 Dec 2020 14:23:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165421; bh=4DT9h3pHSBNGUxNybzRIjOWQSIfJaDQoxw4cmhTJjb0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2lW6uzJS7Bdhhg1nHBF/IQTYXkIItMEAnNSmjyS7OHLJ+P2Z8XGf4/mjOzibDwmxH 0t4bHc8V8zGp1Spe6ZNiIR8b4jKkcslLSdAK4kJZJye7CnWAgx0d5yRRnYZwZYEltT LRdcpnWk9eKcOq1HS4ruDApHA43r7oauDVvRWUiE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sakari Ailus , Laurent Pinchart , Bingbu Cao , Andy Shevchenko , Mauro Carvalho Chehab Subject: [PATCH 5.10 526/717] media: ipu3-cio2: Serialise access to pad format Date: Mon, 28 Dec 2020 13:48:44 +0100 Message-Id: <20201228125046.164885091@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sakari Ailus commit 55a6c6b2be3d6670bf5772364d8208bd8dc17da4 upstream. Pad format can be accessed from user space. Serialise access to it. Fixes: c2a6a07afe4a ("media: intel-ipu3: cio2: add new MIPI-CSI2 driver") Signed-off-by: Sakari Ailus Reviewed-by: Laurent Pinchart Reviewed-by: Bingbu Cao Reviewed-by: Andy Shevchenko Cc: stable@vger.kernel.org # v4.16 and up Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 11 +++++++++++ drivers/media/pci/intel/ipu3/ipu3-cio2.h | 1 + 2 files changed, 12 insertions(+) --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c @@ -1234,11 +1234,15 @@ static int cio2_subdev_get_fmt(struct v4 { struct cio2_queue *q = container_of(sd, struct cio2_queue, subdev); + mutex_lock(&q->subdev_lock); + if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) fmt->format = *v4l2_subdev_get_try_format(sd, cfg, fmt->pad); else fmt->format = q->subdev_fmt; + mutex_unlock(&q->subdev_lock); + return 0; } @@ -1262,6 +1266,8 @@ static int cio2_subdev_set_fmt(struct v4 if (fmt->pad == CIO2_PAD_SOURCE) return cio2_subdev_get_fmt(sd, cfg, fmt); + mutex_lock(&q->subdev_lock); + if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format; } else { @@ -1272,6 +1278,8 @@ static int cio2_subdev_set_fmt(struct v4 fmt->format = q->subdev_fmt; } + mutex_unlock(&q->subdev_lock); + return 0; } @@ -1530,6 +1538,7 @@ static int cio2_queue_init(struct cio2_d /* Initialize miscellaneous variables */ mutex_init(&q->lock); + mutex_init(&q->subdev_lock); /* Initialize formats to default values */ fmt = &q->subdev_fmt; @@ -1646,6 +1655,7 @@ fail_vdev_media_entity: fail_subdev_media_entity: cio2_fbpt_exit(q, &cio2->pci_dev->dev); fail_fbpt: + mutex_destroy(&q->subdev_lock); mutex_destroy(&q->lock); return r; @@ -1658,6 +1668,7 @@ static void cio2_queue_exit(struct cio2_ v4l2_device_unregister_subdev(&q->subdev); media_entity_cleanup(&q->subdev.entity); cio2_fbpt_exit(q, &cio2->pci_dev->dev); + mutex_destroy(&q->subdev_lock); mutex_destroy(&q->lock); } --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.h +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.h @@ -335,6 +335,7 @@ struct cio2_queue { /* Subdev, /dev/v4l-subdevX */ struct v4l2_subdev subdev; + struct mutex subdev_lock; /* Serialise acces to subdev_fmt field */ struct media_pad subdev_pads[CIO2_PADS]; struct v4l2_mbus_framefmt subdev_fmt; atomic_t frame_sequence;