Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6852796imu; Thu, 27 Dec 2018 07:39:38 -0800 (PST) X-Google-Smtp-Source: ALg8bN6MN7texsyOpyKBWUoaU7YgV2F4KAS3CYe2vaRWmU9RlEK8AKHAjRqd3QjbDh+kKmPCl9o3 X-Received: by 2002:aa7:84d3:: with SMTP id x19mr24442834pfn.220.1545925178448; Thu, 27 Dec 2018 07:39:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545925178; cv=none; d=google.com; s=arc-20160816; b=Owgm4YpAtNGnOQ9h3sIL8dmyZM/KWohGRFb5++M/a3cZEkhKzgQG1qr3CT/VaKOQOP ZiBDjwFhG7S7Ssa+z8MC2QQeWd0cU+JQcdd2p+4AdGxFVNcZUEp9rQ20oAROxajtXSqz HfQOAx3ZZPev3ZCpGrOcAP9HJ8cvhhKO1dTxjc2v8tNw8IsKwcYQ/SN0k4ycYX2WqsHA 7YdqDBNq9WkJP0BJ5KIW5u8WQBnh/9g4ThQpnGNf7iPBEnv7JayWvLLLgxDqLUljgOy0 lxtqwC4zSEYdP+iKgkFzLHr5wcwX1GDXZFUXf1Fr/WGG6gsmnUxxos7lTMXVb0HKGDqg PWOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=uH/pa7SFbafKjIu7Tgwhca4U1gxNiGLmaZb2brlO4XY=; b=M8Ky4Hw4onGYZnR18ONcsT+FMd4+ZzQMkmxN4HfG0bvJ66EJW9V1HCMMIqKsXEfdkC xnLtQSgRJMHlTHUi326Xz4JlSe8e7Jqzwr3znv7OhVxXAtlDDK0fYRhhmUcS9FhUFO9U F+UQ20Nrzg/gxjh00ApS12j+eRlvi4sKaDDD/++5n2BU4DUUp0Ih2KKeWY0Gbk3Pl/Po 93caYcVwhQoyzv0/Zj7nooK6+EsLuaIvv4Po9irKVGFeEAY+FPKvnWXNPoyhpm+EE2Pd g0iZngAUnp1KC/EEdNoasElW0EOG5uv01ilhoQLobX1QdQIuCgFvAsQGVw9l5od9Cv47 8Z5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ragnatech-se.20150623.gappssmtp.com header.s=20150623 header.b=BcWgCGAU; 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 o5si33851766plk.360.2018.12.27.07.39.23; Thu, 27 Dec 2018 07:39:38 -0800 (PST) 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=@ragnatech-se.20150623.gappssmtp.com header.s=20150623 header.b=BcWgCGAU; 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 S1728072AbeL0Ava (ORCPT + 99 others); Wed, 26 Dec 2018 19:51:30 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:40727 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726770AbeL0Ava (ORCPT ); Wed, 26 Dec 2018 19:51:30 -0500 Received: by mail-lj1-f195.google.com with SMTP id n18-v6so15005783lji.7 for ; Wed, 26 Dec 2018 16:51:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=uH/pa7SFbafKjIu7Tgwhca4U1gxNiGLmaZb2brlO4XY=; b=BcWgCGAUTyl21MebFT1YNOvIF3YmpJj5ghIPyMj5YbxQ/yfkVtDTwRkkMGk/vKv+CV j09MivrDQ/mUuh3P6/NmR47edxp7oGRFpToy8R69kp6RGFk7WoN7zdgmkS+Zenc7CeHN EdKdjVoRbzY2wJlSALgGp03NOJEDk7dVdPFU6PqP0SH3qktbuVKBn28/1c/Hy+MSRFEz Hy4aIcQF8A095NttKzrulpmoBhr+UT7ywOOIi6uR7Cg5MXB9RnChzhB3ajtIT5+uQh1z HBP4heE3RosypR6XwBSrvy0GxA5agkrQc3H0LB06Bsa7SIMkV4BwhOD1MUbAMXjAxqgs 36rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=uH/pa7SFbafKjIu7Tgwhca4U1gxNiGLmaZb2brlO4XY=; b=dm9PnNgNyQu0Tu+OJgarNobfrAEsrh/p9qAWs+AYTsKyeIco2WC9ZnUDR8arlNGZDj C4pdlVKn2nCkfxqVqnLUMMKuH+c9oivNzd4JItNKn5WhqObv464emzE2eOC0DeoRkeMS QTAfsUWvOmxrfCA+7S3XmjLYaqS+D6ItZR8b8dFiWsao89u4gRqDFjmt1dKIQrc7UJdY qH1glbqNSNuoKnZYEo5RfwAJ1Msca9OF4C3Cgktooo/9PHiNDHHSo218doZVtjBtz9rt LVa+81AOrmSvZf/0atG9j3KFOpcUyp9NKtHLiFNRDlXFeXvGbrDZ7UGxu26EvPg46mNQ T6eg== X-Gm-Message-State: AJcUukeYupkoyy8TVjvltA+TquWmk+/CiBXOEP2Y1JxJksJZ819nwn6Z V5WOLcFtbRU5zbBLSMTFQ4eHxA== X-Received: by 2002:a2e:89d7:: with SMTP id c23-v6mr4910848ljk.0.1545871887182; Wed, 26 Dec 2018 16:51:27 -0800 (PST) Received: from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99]) by smtp.gmail.com with ESMTPSA id m10-v6sm7747503ljj.34.2018.12.26.16.51.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Dec 2018 16:51:26 -0800 (PST) Date: Thu, 27 Dec 2018 01:51:25 +0100 From: Niklas =?iso-8859-1?Q?S=F6derlund?= To: Steve Longerbeam Cc: linux-media@vger.kernel.org, Mauro Carvalho Chehab , "open list:MEDIA DRIVERS FOR RENESAS - VIN" , open list Subject: Re: [RFC PATCH] media: rcar-vin: Allow independent VIN link enablement Message-ID: <20181227005125.GK19796@bigcity.dyn.berto.se> References: <20181225232725.15935-1-slongerbeam@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181225232725.15935-1-slongerbeam@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Steve, Thanks for your patch. On 2018-12-25 15:27:25 -0800, Steve Longerbeam wrote: > 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. Unfortunately this is by design and needed due to the hardware design. The different VIN endpoints shares a configuration register which controls the routing from the CSI-2 receivers to the VIN (register name CHSEL). Modifying the CHSEL register which is what happens when a link is enabled/disabled can have side effects on running streams even if they are not shown to be dependent in the media graph. There is a CHSEL register in VIN0 which controls the routing from all CSI-2 receivers to VIN0-3 and a CHSEL register in VIN4 which controls the same for VIN4-7. > > If this code block is meant to prevent modifying a link if the > link is actively involved in streaming, 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. For the reason above the check in __media_entity_setup_link() is not enough :-( This register sharing is my least favorite thing about the VIN on Gen3 and forces the driver to become more complex as all VIN instances needs to know about each other and interact. > > Remove the code block so that VIN node links can be enabled even if > there are other independent in-use entities. There is room for some improvement in this area disregarding the odd hardware design. It *could* be allowed to change a link terminating in VIN4-7 even if there is a stream running for one or more in VIN0-3. I would be interested to test such a patch but to allow any link change which is allowed by __media_entity_setup_link() is unfortunately not possible, as I understand it. Maybe someone more clever then me can find ways to unlock even more then just the split between VIN0-3 and VIn4-7. In essence the CHSEL register can not be changed if it's involved in a running pipeline even if the end result would be that the running pipeline would look the same. This is possible as there are multiple CHSEL settings where the same source is connected to a specific VIN while other members of the "subgroup of VINs" (e.g. VIN0-3) is routed to something else for the two CHSEL settings. > > Fixes: c0cc5aef31 ("media: rcar-vin: add link notify for Gen3") > > Signed-off-by: Steve Longerbeam > --- > drivers/media/platform/rcar-vin/rcar-core.c | 6 ------ > 1 file changed, 6 deletions(-) > > diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c > index f0719ce24b97..b2c9a876969e 100644 > --- a/drivers/media/platform/rcar-vin/rcar-core.c > +++ b/drivers/media/platform/rcar-vin/rcar-core.c > @@ -116,7 +116,6 @@ static int rvin_group_link_notify(struct media_link *link, u32 flags, > struct rvin_group, mdev); > unsigned int master_id, channel, mask_new, i; > unsigned int mask = ~0; > - struct media_entity *entity; > struct video_device *vdev; > struct media_pad *csi_pad; > struct rvin_dev *vin = NULL; > @@ -131,11 +130,6 @@ 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. */ > - media_device_for_each_entity(entity, &group->mdev) > - if (entity->use_count) > - return -EBUSY; > - > mutex_lock(&group->lock); > > /* Find the master VIN that controls the routes. */ > -- > 2.17.1 > -- Regards, Niklas S?derlund