lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210421100052.gujzkrafp26e6tcz@gilmour>
Date:   Wed, 21 Apr 2021 12:00:52 +0200
From:   Maxime Ripard <maxime@...no.tech>
To:     Kevin Tang <kevin3.tang@...il.com>
Cc:     Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
        Sean Paul <sean@...rly.run>, David Airlie <airlied@...ux.ie>,
        Daniel Vetter <daniel@...ll.ch>,
        Rob Herring <robh+dt@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Orson Zhai <orsonzhai@...il.com>,
        Chunyan Zhang <zhang.lyra@...il.com>,
        "Linux-Kernel@...r. Kernel. Org" <linux-kernel@...r.kernel.org>,
        ML dri-devel <dri-devel@...ts.freedesktop.org>,
        devicetree@...r.kernel.org
Subject: Re: [PATCH v4 4/6] drm/sprd: add Unisoc's drm display controller
 driver

On Mon, Apr 19, 2021 at 07:01:00AM +0800, Kevin Tang wrote:
> Maxime Ripard <maxime@...no.tech> 于2021年4月15日周四 下午5:03写道:
> > On Thu, Apr 15, 2021 at 08:18:52AM +0800, Kevin Tang wrote:
> > > Maxime Ripard <maxime@...no.tech> 于2021年3月24日周三 下午7:10写道:
> > > > > +static struct sprd_dpu *sprd_crtc_init(struct drm_device *drm,
> > > > > +                      struct drm_plane *primary)
> > > > > +{
> > > > > +     struct device_node *port;
> > > > > +     struct sprd_dpu *dpu;
> > > > > +
> > > > > +     /*
> > > > > +      * set crtc port so that drm_of_find_possible_crtcs call works
> > > > > +      */
> > > > > +     port = of_parse_phandle(drm->dev->of_node, "ports", 0);
> > > > > +     if (!port) {
> > > > > +             drm_err(drm, "find 'ports' phandle of %s failed\n",
> > > > > +                       drm->dev->of_node->full_name);
> > > > > +             return ERR_PTR(-EINVAL);
> > > > > +     }
> > > > > +     of_node_put(port);
> > > >
> > > > The YAML binding should already make sure that your binding is sane, and
> > > > if you still get a DT that doesn't follow it, you have a whole lot of
> > > > other issues than whether ports is there :)
> > > >
> > > > > +     dpu = drmm_crtc_alloc_with_planes(drm, struct sprd_dpu, base,
> > > > > +                                     primary, NULL,
> > > > > +                                     &sprd_crtc_funcs, NULL);
> > > > > +     if (IS_ERR(dpu)) {
> > > > > +             drm_err(drm, "failed to init crtc.\n");
> > > > > +             return dpu;
> > > > > +     }
> > > > > +
> > > > > +     dpu->base.port = port;
> > > >
> > > > But you're still referencing it here, while you called of_node_put on it
> > > > already? You should only call it once you're done with it.
> > >
> > >  of_node_put should be called after done with it, this maybe indeed be a bug.
> > > i will fix it.
> > > >
> > > >
> > > > I'm not really sure why you would need drm_of_find_possible_crtcs to
> > > > work then if you don't follow the OF-Graph bindings.
> > >
> > > it scan all endports of encoder, if a matching crtc is found by
> > > OF-Graph bindings
> > > and then genarate the crtc mask, here is description:
> > > 41  /**
> > > 42   * drm_of_find_possible_crtcs - find the possible CRTCs for an encoder port
> > > 43   * @dev: DRM device
> > > 44   * @port: encoder port to scan for endpoints
> > > 45   *
> > > 46   * Scan all endpoints attached to a port, locate their attached CRTCs,
> > > 47   * and generate the DRM mask of CRTCs which may be attached to this
> > > 48   * encoder.
> > > 49   *
> > > if we don't follow the OF-Graph bindings, crtc can't attched to encoder.
> >
> > Yeah, what I'm actually confused about is why you would need the
> > of_parse_phandle call. You usually call drm_of_find_possible_crtcs with
> > the encoder device node, so from your MIPI-DSI driver in your case, and
> > with it's device->of_node pointer and it should work perfectly fine?
> I still confused about use drm_of_find_possible_crtcs to bind crtc and
> encoder, the port of drm_crtc, default is null?
> 
> 709  /**
> 710   * struct drm_crtc - central CRTC control structure
> 711   * @dev: parent DRM device
> 712   * @port: OF node used by drm_of_find_possible_crtcs()
> -----------------------------------------------------------------------------------------------------
> 25  static uint32_t drm_crtc_port_mask(struct drm_device *dev,
> 26     struct device_node *port)
> 27  {
> 28   unsigned int index = 0;
> 29   struct drm_crtc *tmp;
> 30
> 31   drm_for_each_crtc(tmp, dev) {
> 32   if (tmp->port == port)
> 33   return 1 << index;
> 34
> 35   index++;
> 36   }
> 37
> 38   return 0;
> 39  }
> 
> I did not see any place to initialize the port of drm_crtc in the drm
> framework, if not setup it.
> it looks like the port of drm_crtc is undefined.
> 
> https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/rockchip/rockchip_drm_vop.c#L1851
> https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/tilcdc/tilcdc_crtc.c#L1051

Yeah, you need to initialize it for drm_of_find_possible_crtcs to work,
but my point was that you shouldn't do it through of_parse_phandle, just
put the output of_graph_get_port_by_id like you found in those drivers.

Maxime

Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ