Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp261168ybi; Fri, 7 Jun 2019 07:40:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxdNzkwjJIflDbH9g9pzCogip2LADdnrqFZ2QVtvwjR0XH31pan+0nyXk+ALAe0kaLEWTGQ X-Received: by 2002:a62:ee04:: with SMTP id e4mr56619291pfi.232.1559918408205; Fri, 07 Jun 2019 07:40:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559918408; cv=none; d=google.com; s=arc-20160816; b=jnPEKV4yTUIqX/vKK4C36bhVTgEJLvG1xS3bMnc4ErsbAHE44IRHmbL2bKv5KfYZsT WfqRVik9K2J2xMS0LT9VAEYadbrzcAn4wyu2LwRQeja4/SeGZKYmMOiZuQklyC1dMUZz B3FLs4DypgKHTyo18YLmBZrGiYCkoJXb6Ic2rEszz3XHi2d4BSpQW8uIm4hnMSUNEJKy 2JoijuOhpYPvGLlo42AukbT4SmvjsXka4vRlIJfDmrfmF2rEIMtqSsGPv/xgXQXG5MsT dcbv/PU2DSiwpo+Sqb4PnQT7PGRIfhPFh8JoVAveiN8JO2jaX+HiookpgbfRxqWKA+5p pWuw== 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=TKjcG7F74rIiLByNRNXlvSG6M2lGgmcbBTtJHkAJ5zo=; b=qw0noEJNcH8FF69Lf/A7mZg74+IOHpRH2E4l6lgDbezql4oIUFsHw1zI63cY8qWDwf QlzmdKlbLCgEZQTuqaYBjMMwRHlPA68HOG+fbFy1m3AKOtkKQA3l7nua/IaPsHro+KNH eNFXlo/funfWYBff7fY5fip1C74i5ZQYz2K+9GrQuBUuh6y89Vk/jyLW1ZrlhJNuqdDV hkKtWwke2P8oxtrevy0BjkoiMoFZYii4t1nf5szP2lZ5yzzh9oqTlmmPeDde59GVgYN1 895i4K6ES7OT6tRtJ9KM5zaNgmV5BJXfmQuA39hds5ojuSjo9Pwct6xWliaN5aHMXcSu F9nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NFCzRvA7; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3si1860644pfa.234.2019.06.07.07.39.51; Fri, 07 Jun 2019 07:40:08 -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=@gmail.com header.s=20161025 header.b=NFCzRvA7; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729080AbfFGOiI (ORCPT + 99 others); Fri, 7 Jun 2019 10:38:08 -0400 Received: from mail-vk1-f196.google.com ([209.85.221.196]:43503 "EHLO mail-vk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728311AbfFGOiI (ORCPT ); Fri, 7 Jun 2019 10:38:08 -0400 Received: by mail-vk1-f196.google.com with SMTP id m193so415370vke.10 for ; Fri, 07 Jun 2019 07:38:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TKjcG7F74rIiLByNRNXlvSG6M2lGgmcbBTtJHkAJ5zo=; b=NFCzRvA7xNGXFJIiBAGsFIew1vbH/17AMDoG4G0Z0LDcyOjXCE4LF0R8qHY3CvI1H6 NVZSIY6YpynXHyOycMicg5UGDAT4WIt+k74SkUmCmiCbUh9X5EUBtvUEekb8zmN57KfT eYGkIZ6KMvS7vS3yyKkJ/CvCdx6BmOcoy2CPYJBfJKbnpiLRiPFY0vCbh2ahi272nknF Bt83j4br8JxQRV9f7VP3knUKXEeh75MfPrmswl3y+AxqCj4KQrNr0hyP0wuDego20FBr K/lKhiOHvWMNR3mvUgkdEotSgJH/z5h6SyHdydQSEJWFtAYx/jYYLLq6gYKK6wOcUwak ccsw== 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=TKjcG7F74rIiLByNRNXlvSG6M2lGgmcbBTtJHkAJ5zo=; b=CZFq7c2HjKFrYHA8q8qp3m0skXV3FRXbId3VXQdtD/2wAqaJqshB90LH4/j8nArgSM u0ytWmqXfVOFRpnw7jO1eJeEUxzSwHc3Ygd4s2pnIej3TJiYwADplBA0E2xXZCluM85D oU3EMpR6iKikqti51769XQalI08A5WGMxhluw2f6hwlFzaxrNNJinTn18sDscDvbKdml UZFDskQJQJm0jxDl/3lQuUWZBVSGhZH13xwTJWdfwhephNwGloNW8ugbDUU9YZpr+SbA Aucy5PN+gC4PbwXWZNREFcHOZqepBb7Db2ap+1h/KpSbacaxdbzjm88Jb2Jypzhrkk9D anIQ== X-Gm-Message-State: APjAAAUF0eVzZrjuXfDVN5vGAsjLfVSBWfK4CHmGbXPfEK8hS53LHeQQ CB8abOc743vT5Gv+CJLU/T00vuPixYtAs7sa5Sg= X-Received: by 2002:a1f:12d5:: with SMTP id 204mr8721141vks.4.1559918286637; Fri, 07 Jun 2019 07:38:06 -0700 (PDT) MIME-Version: 1.0 References: <20190607073957.GB21222@phenom.ffwll.local> In-Reply-To: <20190607073957.GB21222@phenom.ffwll.local> From: Rodrigo Siqueira Date: Fri, 7 Jun 2019 11:37:55 -0300 Message-ID: Subject: Re: [PATCH 1/2] drm/vkms: Use index instead of 0 in possible crtc To: Rodrigo Siqueira , Brian Starkey , Liviu Dudau , Haneen Mohammed , Simon Ser , dri-devel , Linux Kernel Mailing List Cc: Daniel Vetter 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 Fri, Jun 7, 2019 at 4:40 AM Daniel Vetter wrote: > > On Thu, Jun 06, 2019 at 07:40:38PM -0300, Rodrigo Siqueira wrote: > > When vkms calls drm_universal_plane_init(), it sets 0 for the > > possible_crtcs parameter which works well for a single encoder and > > connector; however, this approach is not flexible and does not fit well > > for vkms. This commit adds an index parameter for vkms_plane_init() > > which makes code flexible and enables vkms to support other DRM features. > > > > Signed-off-by: Rodrigo Siqueira > > I think a core patch to WARN_ON if this is NULL would be good. Since > that's indeed a bit broken ... We'd need to check all callers to make sure > there's not other such bugs anywhere ofc. > -Daniel Do you mean add WARN_ON in `drm_universal_plane_init()` if `possible_crtcs` is equal to zero? > > --- > > drivers/gpu/drm/vkms/vkms_drv.c | 2 +- > > drivers/gpu/drm/vkms/vkms_drv.h | 4 ++-- > > drivers/gpu/drm/vkms/vkms_output.c | 6 +++--- > > drivers/gpu/drm/vkms/vkms_plane.c | 4 ++-- > > 4 files changed, 8 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c > > index 738dd6206d85..92296bd8f623 100644 > > --- a/drivers/gpu/drm/vkms/vkms_drv.c > > +++ b/drivers/gpu/drm/vkms/vkms_drv.c > > @@ -92,7 +92,7 @@ static int vkms_modeset_init(struct vkms_device *vkmsdev) > > dev->mode_config.max_height = YRES_MAX; > > dev->mode_config.preferred_depth = 24; > > > > - return vkms_output_init(vkmsdev); > > + return vkms_output_init(vkmsdev, 0); > > } > > > > static int __init vkms_init(void) > > diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h > > index 81f1cfbeb936..e81073dea154 100644 > > --- a/drivers/gpu/drm/vkms/vkms_drv.h > > +++ b/drivers/gpu/drm/vkms/vkms_drv.h > > @@ -113,10 +113,10 @@ bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe, > > int *max_error, ktime_t *vblank_time, > > bool in_vblank_irq); > > > > -int vkms_output_init(struct vkms_device *vkmsdev); > > +int vkms_output_init(struct vkms_device *vkmsdev, int index); > > > > struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev, > > - enum drm_plane_type type); > > + enum drm_plane_type type, int index); > > > > /* Gem stuff */ > > struct drm_gem_object *vkms_gem_create(struct drm_device *dev, > > diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c > > index 3b162b25312e..1442b447c707 100644 > > --- a/drivers/gpu/drm/vkms/vkms_output.c > > +++ b/drivers/gpu/drm/vkms/vkms_output.c > > @@ -36,7 +36,7 @@ static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = { > > .get_modes = vkms_conn_get_modes, > > }; > > > > -int vkms_output_init(struct vkms_device *vkmsdev) > > +int vkms_output_init(struct vkms_device *vkmsdev, int index) > > { > > struct vkms_output *output = &vkmsdev->output; > > struct drm_device *dev = &vkmsdev->drm; > > @@ -46,12 +46,12 @@ int vkms_output_init(struct vkms_device *vkmsdev) > > struct drm_plane *primary, *cursor = NULL; > > int ret; > > > > - primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY); > > + primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY, index); > > if (IS_ERR(primary)) > > return PTR_ERR(primary); > > > > if (enable_cursor) { > > - cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR); > > + cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR, index); > > if (IS_ERR(cursor)) { > > ret = PTR_ERR(cursor); > > goto err_cursor; > > diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c > > index 0e67d2d42f0c..20ffc52f9194 100644 > > --- a/drivers/gpu/drm/vkms/vkms_plane.c > > +++ b/drivers/gpu/drm/vkms/vkms_plane.c > > @@ -168,7 +168,7 @@ static const struct drm_plane_helper_funcs vkms_primary_helper_funcs = { > > }; > > > > struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev, > > - enum drm_plane_type type) > > + enum drm_plane_type type, int index) > > { > > struct drm_device *dev = &vkmsdev->drm; > > const struct drm_plane_helper_funcs *funcs; > > @@ -190,7 +190,7 @@ struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev, > > funcs = &vkms_primary_helper_funcs; > > } > > > > - ret = drm_universal_plane_init(dev, plane, 0, > > + ret = drm_universal_plane_init(dev, plane, 1 << index, > > &vkms_plane_funcs, > > formats, nformats, > > NULL, type, NULL); > > -- > > 2.21.0 > > > > -- > Daniel Vetter > Software Engineer, Intel Corporation > http://blog.ffwll.ch -- Rodrigo Siqueira https://siqueira.tech