Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9434453pxu; Mon, 28 Dec 2020 16:25:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEzUYeqC5fhZByrCU78BmncSqHg2lxEggPpX+fGl+HGRClqE/gXWn0OgYJ0eV+Apw2/8IE X-Received: by 2002:aa7:ce94:: with SMTP id y20mr43588470edv.361.1609201519895; Mon, 28 Dec 2020 16:25:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609201519; cv=none; d=google.com; s=arc-20160816; b=LyyIfG/JqBqthfbJ0WCYjCQ/YLI9OkVpcRFjdrSnvqoUm4jbxkWh00PyzCfkaJoa6f xjk1Jo71F4W6b2RFR6n3lnSgTUJNWhIdXJ8sfE81xth8RyNlAI4+jMSQVbM0ZKGf3ikh RBFoS0KsHFbtkEFA/Ft5OkMEI00tTsM6VBJeYkkwVc5O0mcUBpuNIIlqYresDk87s+rW b/LDosZ8KQsZIu0w6IeiBkaiZlnkPdFgcEL+M494Ys+BnX+QMfEQDSBKrCZPhREA71y6 KVKIZT7CW4d46Zjr7Qn6H7ozqqx4Sqpa3I9GGIfQtEaSu/LXeYPfDodqPDB+TtmdVU1k yIQw== 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=GRrUPUXCQvaELqi9valr6WpaiogQLC3k5PBq7nF5r8k=; b=CO9lhyN1w/0RjUeml8OKclecpJENBQ96uZeJsukI1JbOHTctazLrAcuNhYh+kfjSb9 /Su9G/ieLZW0sTxjsswdMGWnrPQI+kZUEu9GQ8sYM98T0Rh0lHBENTvpn1qyiAOFS1hN 4UaJVzveewtroe1E7oc3FWXEQzsumdPqaUAzpfaGTjQMsX7u4tB9eJlSljMj/eembJYz Fv9Xd/AQ9oVRyf/DXig/TypvQo4M8/g01ByLdLBLDZXKHe1Ww41IfaFeANW00/uJ2pvl mdE0yKgTXVPcapaYMGjZWtPVDVUUoUwlBAPkCSlM3NCvoQrr6FK2SDLdqSQUuAVtYttD nGmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TLErrBNi; 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 sb9si20805885ejb.219.2020.12.28.16.24.58; Mon, 28 Dec 2020 16:25:19 -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=TLErrBNi; 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 S2408601AbgL1PfR (ORCPT + 99 others); Mon, 28 Dec 2020 10:35:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:55090 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407285AbgL1NxP (ORCPT ); Mon, 28 Dec 2020 08:53:15 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 63C9721D94; Mon, 28 Dec 2020 13:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609163555; bh=8W7/UbKT4IKzBx2mjAVno5Z6ewQ4qx+xBS0ILnnNQFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TLErrBNiGI9yeBVeBAJeq8pd7POFeCjyuDBxFHQQQTMfZ8amGqCXXdj4phDa1YuTk dpmo3QYxG948WlzsB5yJGg/vC8Gk34Espc4r47KGTPA9QRPUQ5sDAlJaIi6K66WmuB shXpGtTI1S6ozBSozeBO5L5Z6WoOTeyIBW6HHP8s= 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.4 326/453] media: ipu3-cio2: Serialise access to pad format Date: Mon, 28 Dec 2020 13:49:22 +0100 Message-Id: <20201228124952.897283258@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124937.240114599@linuxfoundation.org> References: <20201228124937.240114599@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 @@ -1245,11 +1245,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; } @@ -1273,6 +1277,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 { @@ -1283,6 +1289,8 @@ static int cio2_subdev_set_fmt(struct v4 fmt->format = q->subdev_fmt; } + mutex_unlock(&q->subdev_lock); + return 0; } @@ -1541,6 +1549,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; @@ -1659,6 +1668,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; @@ -1672,6 +1682,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 @@ -332,6 +332,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;