Received: by 10.192.165.148 with SMTP id m20csp81558imm; Fri, 20 Apr 2018 03:26:29 -0700 (PDT) X-Google-Smtp-Source: AIpwx48o/pE74rrIcK00jbMQZ3vZTlHF++EAdPWL8v1v8Ah6wTzhUtcXsOjUYy3xAeQAJFrqB7H8 X-Received: by 10.167.131.92 with SMTP id z28mr576834pfm.237.1524219989560; Fri, 20 Apr 2018 03:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524219989; cv=none; d=google.com; s=arc-20160816; b=eQ/iZL/wETTEeehAJ06vJxeo98XYB2IsfCNHPFDCNhQWTN/1pQYdtW1aghs6DEnKqT Gl0RKyYX1tN4S0OhIoVH7nNuYqkOE+VJflyyK4qggniM067Jsmp8JPfdBlWJCevWXUxt MNvvLsvkOlvKGlyXJCXMrMAGgVtQxgEDWNjQkfsfh3CvkRNTcilOapFL0rEh4UbJNAIl +bIAMeCr9KD1kcB/MWNl+KhxW9HwAB199THOHqe3tQyfB8ntSwhZt+GplcqKEWsHgb/e +7Emx6R3LcqkKQLQnzHJoYtdK4W/oEQ3W4uD+z5tYNWOYsQU586ZpkyeDksx33dOxaYT yzJA== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=FWKAwtYr2g40k/UQIlZgXVDmAp6WK1/cSvo4ztXeEUs=; b=Vz/sroijUztsaghS7HfRykTj1eUDHlaZaWuvaA3e+7MQ23MILx3WZa2BKptUsmvJJb toEWV8n7XOSDqrBUgraYxDFIT6JfGch+XzCWaITkoby/exz1BIq97Ic8DbgYhTAX1X1V upk2LSTvMHUKgjjn7//tbp8mltfWH5s3Rzb76FFIcCdtrfpwQVPQAkkIMwiwascGN2Qt gXQ2Lljg8Ji6jXv/1vwv3U7H2m3N0MUQv3jhPTfZHJo3mIe46KmtIuHCJ3SRFM0pcqXW 4p7hkvoBE3lwaAQp3ZLuTLWAxXD/g4rv3i5kkSnUGECZuBSO5imEvDCsGWTQJIinw7h9 bLpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=fsyk+vjP; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7-v6si5533889plk.129.2018.04.20.03.26.15; Fri, 20 Apr 2018 03:26:29 -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=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=fsyk+vjP; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754663AbeDTKYp (ORCPT + 99 others); Fri, 20 Apr 2018 06:24:45 -0400 Received: from pandora.armlinux.org.uk ([78.32.30.218]:45508 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754595AbeDTKYm (ORCPT ); Fri, 20 Apr 2018 06:24:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FWKAwtYr2g40k/UQIlZgXVDmAp6WK1/cSvo4ztXeEUs=; b=fsyk+vjP/IzWdUxqA7WzSabwi wRlS3ry93ch/EPRVT1PiLoc+WA9Sw8HsdRp6L1lVyLpaVPsw/sNvFh7LDTArAD9ZkKvK2c+o38pho 6Y0MRNEsHrqG8AUYsXO/HL5NDVVg6BdlPxg8DOBJ5K42weKv04YDjcn93wpw2TnXqJqzw=; Received: from n2100.armlinux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:4f86]:57399) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) (envelope-from ) id 1f9TDH-0004mo-De; Fri, 20 Apr 2018 11:24:19 +0100 Received: from linux by n2100.armlinux.org.uk with local (Exim 4.90_1) (envelope-from ) id 1f9TDB-0008OS-Ai; Fri, 20 Apr 2018 11:24:13 +0100 Date: Fri, 20 Apr 2018 11:24:09 +0100 From: Russell King - ARM Linux To: Laurent Pinchart Cc: dri-devel@lists.freedesktop.org, Mark Rutland , Boris Brezillon , Alexandre Belloni , devicetree@vger.kernel.org, David Airlie , linux-kernel@vger.kernel.org, Rob Herring , Jacopo Mondi , Daniel Vetter , Peter Rosin , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 7/7] drm/i2c: tda998x: register as a drm bridge Message-ID: <20180420102408.GW16141@n2100.armlinux.org.uk> References: <20180419162751.25223-1-peda@axentia.se> <20180419162751.25223-8-peda@axentia.se> <2556566.3fxMPoIyx0@avalon> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2556566.3fxMPoIyx0@avalon> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 20, 2018 at 01:06:49PM +0300, Laurent Pinchart wrote: > Hi Peter, > > Thank you for the patch. > > On Thursday, 19 April 2018 19:27:51 EEST Peter Rosin wrote: > > This makes this driver work with all(?) drivers that are not > > componentized and instead expect to connect to a panel/bridge. That > > said, the only one tested is atmel_hlcdc. > > > > This hooks the relevant work function previously called by the encoder > > and the component also to the bridge, since the encoder goes away when > > connecting to the bridge interface of the driver and the equivalent of > > bind/unbind of the component is handled by bridge attach/detach. > > > > The lifetime requirements of a bridge and a component are slightly > > different, which is the reason for struct tda998x_bridge. > > Couldn't you move the allocation and initialization (tda998x_create) of the > tda998x_priv structure to probe time ? I think you wouldn't need a separate > structure in that case. Unless I'm mistaken there would be an added benefit of > separating component and bridge initialization, resulting in the encoder not > being initialized at all if the component isn't used. You wouldn't need to add > a local_encoder parameter to the tda998x_init() function. No, I don't like that idea one bit, as I've stated in the past about the component API. The same (probably) goes for the bridge stuff too. Consider the following: Your DRM system is initialised. You then remove a module, which results in the DRM system being torn down. You re-insert the module (eg, having made a change to it). The DRM system is then re-initialised. At this point, what is the state of variables such as priv->is_on if you allocate the structure at probe time? What about all the other variables in the driver private structure - are you sure that the driver can cope with random values from the previous "usage" remaining there? At the moment, this isn't a concern for the driver because we dev_kzalloc() the structure in the bind callback. Move that to the probe function, and the structure is no longer re-initialised each time, and so it retains the previous state. The driver is not setup to cope with that. So, to work around that, you would need to reinitialise _everything_ in the structure that the driver requires, which IMHO is a very open to bugs (eg, if a member is missed, or added without the necessary re-initialisation), _especially_ when this is not a path that will get regular testing. If you want to do this for a subset of data, it would be much better to separate them into independent structures (maybe one embedded into the other) so that this problem can not occur. That way, a subset of the data can be memset() when bound to the rest of the DRM system ensuring a consistent driver state and still achieve what you're suggesting. -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up According to speedtest.net: 8.21Mbps down 510kbps up