Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4452768ybc; Tue, 26 Nov 2019 09:09:36 -0800 (PST) X-Google-Smtp-Source: APXvYqzB8vYAwwL93QUk/60IK3nt/yaMGKR62YA17ccDVpMk9nUMSiGkQLYexQyDDIihscWL+oIP X-Received: by 2002:aa7:c694:: with SMTP id n20mr26679194edq.87.1574788176263; Tue, 26 Nov 2019 09:09:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574788176; cv=none; d=google.com; s=arc-20160816; b=DmHoBGN9Tn6IwtfSR0BSIyz2NNJk8KDe0tzhFC0bSK1RSXtlFEqhM5HLm2huVEK9fF HoH7+LtDvVl7mDAyp7fE395PyoM7IT0BCLH482NCw9eFbBhyyRr38sZSGCHEr+vBXkoO 1l3NyEhd7SEExusQnegsoEb6GLp4++AXEW0nIWUVHHW3LYfnQjU7ttaDx6wD7AO1wlKY sTB3fcSDpGxc8dlI/XhHPet0YqygxYYE/8pmwBgNi8TaeaZAZR4eS8dynQThmgNtuKhM 8KEee/nGnvlLx1sOimgAhyPCOQmVR37KM6FBqLLw4b6J3zZw8UJfT4upIubXFC0PIri7 f84w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=0aRqjubVebGkfF0Se7BSThAXYeQQXVaR/wxZsEbt0q8=; b=kcwHHJMVp9Q+CvApiYuqFDKzfcDgC9tDPVAqqCY5zaOoy9nsa6LD3W+p8Edx4duJa8 gav2i24gKEW3Hze93BWtOO0Ot8CycxiIPbG/V8UHyTACnjd+4uv+fBk5NOCJVFWUIN8f d+pmghVJfdq/wsTKESN7X9tP/mLxF448hkEPl35olucqpG/cj1ndKw9hE82fyJ5B92e4 F20sbYduJnQb/Vaq1EL3BNfDIcWjuwa04wLUSDkySpFjGnN3s6RX+GdrXFm6HdHu74hr kNNYhOmquoD7gmQezTLnmNKkCmMSPEheXn/QObBILLuDtKIoGXN6Xzzd+6rQroqcZgSC 7Y6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=UpyrP3YA; 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 y18si7318127edr.347.2019.11.26.09.09.10; Tue, 26 Nov 2019 09:09:36 -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=@ffwll.ch header.s=google header.b=UpyrP3YA; 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 S1728576AbfKZREh (ORCPT + 99 others); Tue, 26 Nov 2019 12:04:37 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:36145 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727309AbfKZREh (ORCPT ); Tue, 26 Nov 2019 12:04:37 -0500 Received: by mail-ot1-f65.google.com with SMTP id p19so72362otc.3 for ; Tue, 26 Nov 2019 09:04:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0aRqjubVebGkfF0Se7BSThAXYeQQXVaR/wxZsEbt0q8=; b=UpyrP3YA6tguIzdLA7TVi9RB4XydlLBFFWdnNBuzbspnU1ZjNvXrgfsuXbY99Roizt lg7ffuqfaTVeRlmXWIPImxwH59yWclys3ymaIZUo+TPLThcHHCPmmPsGRVonwKq+akkr 2QSNGsHYfVT0M3IT4B7mpvGAhowY2QbFgQye8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0aRqjubVebGkfF0Se7BSThAXYeQQXVaR/wxZsEbt0q8=; b=hLuWFiOr4ovTyb22/RgJQ+A3Dfk5qt28Z4Ela3mjgV6Lbjh81hBEOE2VhRfSXNTfzI dY2W+7oJ9fp5969omRWLEnRk0M7j83dn/mQ3oLjjj7aLhtvMAZ0uisAgKLqcLughlxdm OpRBW8hQt4upnetGfB43VE+1nu630C4AEn8n9LTmLjpEGAbh1kGZ0wFRdACUCKPr4zUx Tn+B/eosSu0vW7fIei51i9EjoyrbmLXOjpyMa7sZc2Y7rTcg00yJcKfwkHOV8HpfpGFo VuBhZqy9+9v0uOsWAQ7DfYmNMcNyqyCRPxMsN3GoJiNhlhsoFEOq8WtYVXMWE4MnWw+W dUWw== X-Gm-Message-State: APjAAAVUbQsLWmu6d0/sKRavFw3lIkB56bjDIpopZsLKQNOhp48lq30e MKOISm13MQroH9j2/0mrg3NRTmh790UlV2sVd6OomDGn X-Received: by 2002:a9d:1b4b:: with SMTP id l69mr3042854otl.303.1574787875817; Tue, 26 Nov 2019 09:04:35 -0800 (PST) MIME-Version: 1.0 References: <20191126131541.47393-1-mihail.atanassov@arm.com> <20191126131541.47393-2-mihail.atanassov@arm.com> <20191126142610.GV29965@phenom.ffwll.local> <11447519.fzG14qnjOE@e123338-lin> In-Reply-To: <11447519.fzG14qnjOE@e123338-lin> From: Daniel Vetter Date: Tue, 26 Nov 2019 18:04:24 +0100 Message-ID: Subject: Re: [PATCH 01/30] drm: Introduce drm_bridge_init() To: Mihail Atanassov Cc: "dri-devel@lists.freedesktop.org" , nd , Maarten Lankhorst , Maxime Ripard , David Airlie , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 26, 2019 at 4:55 PM Mihail Atanassov wrote: > > Hi Daniel, > > Thanks for the quick review. > > On Tuesday, 26 November 2019 14:26:10 GMT Daniel Vetter wrote: > > On Tue, Nov 26, 2019 at 01:15:59PM +0000, Mihail Atanassov wrote: > > > A simple convenience function to initialize the struct drm_bridge. > > > > > > Signed-off-by: Mihail Atanassov > > > > The commit message here leaves figuring out why we need this to the > > reader. Reading ahead the reasons seems to be to roll out bridge->dev > > setting for everyone, so that we can set the device_link. Please explain > > that in the commit message so the patch is properly motivated. > > Ack, but with one caveat: bridge->dev is the struct drm_device that is > the bridge client, we need to add a bridge->device (patch 29 in this > series) which is the struct device that will manage the bridge lifetime. Ah yes, ->dev is for drm_bridge_attach. > > > > > --- > > > drivers/gpu/drm/drm_bridge.c | 29 +++++++++++++++++++++++++++++ > > > include/drm/drm_bridge.h | 4 ++++ > > > 2 files changed, 33 insertions(+) > > > > > > diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c > > > index cba537c99e43..cbe680aa6eac 100644 > > > --- a/drivers/gpu/drm/drm_bridge.c > > > +++ b/drivers/gpu/drm/drm_bridge.c > > > @@ -89,6 +89,35 @@ void drm_bridge_remove(struct drm_bridge *bridge) > > > } > > > EXPORT_SYMBOL(drm_bridge_remove); > > > > > > +/** > > > + * drm_bridge_init - initialise a drm_bridge structure > > > + * > > > + * @bridge: bridge control structure > > > + * @funcs: control functions > > > + * @dev: device > > > + * @timings: timing specification for the bridge; optional (may be NULL) > > > + * @driver_private: pointer to the bridge driver internal context (may be NULL) > > > > Please also sprinkle some links to this new function to relevant places, > > I'd add at least: > > > > "Drivers should call drm_bridge_init() first." to the kerneldoc for > > drm_bridge_add. drm_bridge_add should also mention drm_bridge_remove as > > the undo function. > > > > And perhaps a longer paragraph to &struct drm_bridge: > > > > "Bridge drivers should call drm_bridge_init() to initialized a bridge > > driver, and then register it with drm_bridge_add(). > > > > "Users of bridges link a bridge driver into their overall display output > > pipeline by calling drm_bridge_attach()." > > Will do. > > > > > > + */ > > > +void drm_bridge_init(struct drm_bridge *bridge, struct device *dev, > > > + const struct drm_bridge_funcs *funcs, > > > + const struct drm_bridge_timings *timings, > > > + void *driver_private) > > > +{ > > > + WARN_ON(!funcs); > > > + > > > + bridge->dev = NULL; > > > > Given that the goal here is to get bridge->dev set up, why not > > > > WARN_ON(!dev); > > bridge->dev = dev; > > See above struct device vs struct drm_device. I add a > > bridge->device = dev; > > in patch 29, which takes care of that. I skipped the warn since > there's a dereference of dev, but I now realized it's behind CONFIG_OF, > so I'll add it in for v2. Ok, sounds good. Having the WARN_ON in patch 1 should also help making sure all the conversion patches dtrt (and any future users). -Daniel > Yes, 'device' isn't the best of names, but I took Russell's patch > almost as-is, I didn't have any better ideas for bikeshedding. > > > > > That should help us to really move forward with all this. > > -Daniel > > > > > + bridge->encoder = NULL; > > > + bridge->next = NULL; > > > + > > > +#ifdef CONFIG_OF > > > + bridge->of_node = dev->of_node; > > > +#endif > > > + bridge->timings = timings; > > > + bridge->funcs = funcs; > > > + bridge->driver_private = driver_private; > > > +} > > > +EXPORT_SYMBOL(drm_bridge_init); > > > + > > > /** > > > * drm_bridge_attach - attach the bridge to an encoder's chain > > > * > > > diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h > > > index c0a2286a81e9..d6d9d5301551 100644 > > > --- a/include/drm/drm_bridge.h > > > +++ b/include/drm/drm_bridge.h > > > @@ -402,6 +402,10 @@ struct drm_bridge { > > > > > > void drm_bridge_add(struct drm_bridge *bridge); > > > void drm_bridge_remove(struct drm_bridge *bridge); > > > +void drm_bridge_init(struct drm_bridge *bridge, struct device *dev, > > > + const struct drm_bridge_funcs *funcs, > > > + const struct drm_bridge_timings *timings, > > > + void *driver_private); > > > struct drm_bridge *of_drm_find_bridge(struct device_node *np); > > > int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, > > > struct drm_bridge *previous); > > > > > > > -- > Mihail > > > -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch