Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5641040img; Wed, 27 Mar 2019 12:15:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwThPLQCEZirD8xjkTwf5t3mEqdFpolojanYErL9lW6tD6F88IKoz9GeKXKcpfeXpIfe8VI X-Received: by 2002:a63:ff18:: with SMTP id k24mr36710938pgi.140.1553714136425; Wed, 27 Mar 2019 12:15:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714136; cv=none; d=google.com; s=arc-20160816; b=nNj7CKcqRE3dLSgzxbpFH/lFUy+G2mu7PRKWOvdX0kAnoi7DhBAOH1XUnWCCAyR4kq rCuJj9F41ij3jWct5Bra47ctjTtNaSPwR5JjtlXjLD7RNpqsRze1EdmTcbdqTJoFSzJx PSJyRFi2Xqlkgs29tOuezKtWbRuO97hcuAX3UZnDZp+xhUtfdwkVjR3dsvtywXMXqX9B s8jAc2IWrQFRKihs3GnQH/L4JRvS01cCeRX5U6/L+UNHk2J63Kd9CZswI3W9bnsLWA/v Bn27VGtZ3acM9uq4aDFEDCPCqDtzHbK7Zs73/YMPrFi6RbPUzASW2Rql6pORcZcOQzh3 KE7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Gt66Ga+BKu9o7ya9Y7yMVScIaORvHw1Kp+hRyJ0XS/A=; b=wVnlS6C7hfbsO46YINFQVFIUgIlTtqcf8SvR0dCcMEZz4tSYigN/9BMx0F3ShZQIdH CW2X+gdl0zOOFPlb+LeoIIRqq+GHjVx/vPbh5vSjis48aDZhotI8EN2hEqpkh4VHc6Th b2ReQqxKhjGpa366oyKGiBPB/fYjmLsKWicLEgxLtJ7aU9FfYcYUP/fVHWBeSE+6rb2v Lcfj4v2dQCwznENQKqA3wXgmInaIAKafeQCH0VRNFnx5W0W3UjfC3QltJiROcbXtZgcu 5j87MC3cvsPFdnl+QJtw8tvTXv9d0AEVrbpZnq9LTC2P/Pgs9LuYdiji7inj2cMYY8DX K+fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cZsIKk4D; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si21095024plw.390.2019.03.27.12.15.20; Wed, 27 Mar 2019 12:15:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cZsIKk4D; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389016AbfC0TOn (ORCPT + 99 others); Wed, 27 Mar 2019 15:14:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:51448 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388580AbfC0SJi (ORCPT ); Wed, 27 Mar 2019 14:09:38 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E79D42147C; Wed, 27 Mar 2019 18:09:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710176; bh=e45cM2WgidIGs7IgVAuofmMVPFcRQacvL4u/PQRtuRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cZsIKk4D9H0UNxuNTx5YN8Puyt/OfEBul2akGSPJB53tutFvvBs/5DBIffICuEy/g qmb8WdOVs8q4wvidSP8NPPc/XugXmOUxmMuvvfuu69WdsUX6vbG9X7NBBL9E20iUwD vHvxN5wqkUDGDTWiOxTifBBXJ1iNP7JoWuvWM/JM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Steve Longerbeam , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 235/262] media: rcar-vin: Allow independent VIN link enablement Date: Wed, 27 Mar 2019 14:01:30 -0400 Message-Id: <20190327180158.10245-235-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steve Longerbeam [ Upstream commit c5ff0edb8e2270a75935c73217fb0de1abd2d910 ] There is a block of code in rvin_group_link_notify() that prevents enabling a link to a VIN node if any entity in the media graph is in use. This prevents enabling a VIN link even if there is an in-use entity somewhere in the graph that is independent of the link's pipeline. For example, the code block will prevent enabling a link from the first rcar-csi2 receiver to a VIN node even if there is an enabled link somewhere far upstream on the second independent rcar-csi2 receiver pipeline. If this code block is meant to prevent modifying a link if any entity in the graph is actively involved in streaming (because modifying the CHSEL register fields can disrupt any/all running streams), then the entities stream counts should be checked rather than the use counts. (There is already such a check in __media_entity_setup_link() that verifies the stream_count of the link's source and sink entities are both zero, but that is insufficient, since there should be no running streams in the entire graph). Modify the code block to check the entity stream_count instead of the use_count (and elaborate on the comment). VIN node links can now be enabled even if there are other independent in-use entities that are not streaming. Fixes: c0cc5aef31 ("media: rcar-vin: add link notify for Gen3") Signed-off-by: Steve Longerbeam Reviewed-by: Niklas Söderlund Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/rcar-vin/rcar-core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c index f0719ce24b97..aef8d8dab6ab 100644 --- a/drivers/media/platform/rcar-vin/rcar-core.c +++ b/drivers/media/platform/rcar-vin/rcar-core.c @@ -131,9 +131,13 @@ static int rvin_group_link_notify(struct media_link *link, u32 flags, !is_media_entity_v4l2_video_device(link->sink->entity)) return 0; - /* If any entity is in use don't allow link changes. */ + /* + * Don't allow link changes if any entity in the graph is + * streaming, modifying the CHSEL register fields can disrupt + * running streams. + */ media_device_for_each_entity(entity, &group->mdev) - if (entity->use_count) + if (entity->stream_count) return -EBUSY; mutex_lock(&group->lock); -- 2.19.1