Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1008779yba; Thu, 4 Apr 2019 02:19:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzl2BruMHTdpOrrOBxgA904gnRrT2ZyShdHJO4NxwRI6dOsRNvOWOUBjuwxwI+9MVg2ukyV X-Received: by 2002:a63:cc0d:: with SMTP id x13mr4823236pgf.280.1554369542216; Thu, 04 Apr 2019 02:19:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554369542; cv=none; d=google.com; s=arc-20160816; b=fci9dsDdFrznapnxGX/zxzG10ZjtoX8Lw9+N57u+Lveayvt/tWvi3Y00w4Gqx2Bqmf NxoCh8OYCSRdpuNqfMlURy0ePjdKtxm58wRWXP6Zecym3lnuNFI0AXWnx+NlR1u8Y2qo uz2YG075t6rDXvC7wpBDhQnLgaGjqlXyYjR9PpaP8uF+LGGA6aiY3PDXMrRcycQXY6Sc cIiysfkJcveDA7jRs9AAQujGRD4my/4Utbfc5aRNz36dm9U1Q7Gt3x2bJC27ibBvvbeE +Vq5hj3mJ2hz1cnQnDFOENEk9SqpRqUR6apevAZiSik5JLPGQae0fOq8UkEkpwcPyXjM 6y0A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ak/ljbh7NUIkvirixBcSdOUOLB87lj90GB9YUtcifDI=; b=ds4xoIdgrgelqtMVX5Pai+oFlPXX+mTjkzLuvRLXUYFero4SBry/ePkdZkdKZZrqx+ 4epT5v65ZWB0KZiSEdwLUR5eTFmKM+bVgbFzvOX8W43UwTUBMYw0NOK6vEtwdZ0FAU98 tITm9NDIzM9AXc6aKAt19dEm6Y0w4UchEA/0vstzOjFlWgbRKPZm09LmDVaR5Y0OV3/i PeW9NNoyHZdo30Kb6QukoCvm0xWPg4GeXHGveM++R50gkDAEpeaAX8EoFwEBIi2FmUwE /4YJu2hDWhYLUxRkUPSu3LTYDtzE/mxooxV3UOOFPjxK9PLHPmtWwIKQyHrgYl5FGHSM g3+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d0awLiU4; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1si16266184pgi.414.2019.04.04.02.18.46; Thu, 04 Apr 2019 02:19:02 -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=d0awLiU4; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388340AbfDDJSQ (ORCPT + 99 others); Thu, 4 Apr 2019 05:18:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:60324 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728775AbfDDJSO (ORCPT ); Thu, 4 Apr 2019 05:18:14 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 10B7521734; Thu, 4 Apr 2019 09:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554369493; bh=ovr7gJtBwRmh9JyplybTL6oD+gmbRRDtAfRe8tRzlUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d0awLiU40HdEKcxmY6Wj6pwdLHvYge8Szp+1ylakn/SKremdyH/H6+YNXdwO78loM J/6+o9EkhIDJVO9wZYLOYCXVDnBhaM9u53N7lcnaAQdfGrgUe3pmROil2pE2zve3ON lHCEZkwNkYDjj7xO/uNRH/s1NVyS4EuF2FAxi5Vw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steve Longerbeam , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.0 219/246] media: rcar-vin: Allow independent VIN link enablement Date: Thu, 4 Apr 2019 10:48:39 +0200 Message-Id: <20190404084626.866583328@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084619.236418459@linuxfoundation.org> References: <20190404084619.236418459@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 5.0-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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