Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp940337imu; Thu, 20 Dec 2018 07:40:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/X1wL/uB+POdMf/eUSsCOlbD2ZIVTckCow2Vpy+zH+Jos5iZvk9lS+WrovOtA+A8f5M2Lti X-Received: by 2002:a17:902:714c:: with SMTP id u12mr24304101plm.234.1545320455800; Thu, 20 Dec 2018 07:40:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545320455; cv=none; d=google.com; s=arc-20160816; b=Vpo2kECIdEIJ7DMxslcPCxp3+wzhxnS8BFyMHg3y4w3EXAHhp3B1VZf1Wdrl43XDu3 MqnYalRnCZSCSkmcz1io8kJPFmYRwxtnVWohFIH6o8ej+Qj45W5wYlUmEEXF0Ji28OEa JreQZO9ygEFcENDkTCiZtKIpQ3VLMRD+6E4esLPCwdJtBzAt4nMns5J8Beq3DgR7IcK9 gxV1ik2X+S+Cai9pXsU3mulNcmnYsulm07OV2DyVJNbDuhcs4Fh6vZR7VpeN+Ko6TI5F +N41QZGQBsVPN6fi8/tqyYaehebv35MF1wgi6TQK/cGiOaeNUSi3hQxfvmTFOSypiQzx 3r+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=ykPQgd+D8oV9K7tP/NcA/KVCltx/mFL7ha6/pueegv8=; b=dQhvzU7ZHYLqHPXS43eFII66D5nMQ6rPrtOnI8k8LnPAubOb/ich1pb78+k4sIUdzH Suf21udXkVTWxvdPIHdigMC66zdU66S0JAFynkx4oTaMFb40te1HzWEhLP0xR5eV0K8C GYNtrpHl23eNnhlKvLNuGDLG5smzMt+VgiNl0i3z6Hh9y7iIyzQVelBczd3sbpg1PUGm n6kxNRjDMKmGqBkjSEoRNotsoUNlBmfIh3AOcbvU+0yX9iHMfBlprVsMgIvMhzqMbGuq 2oa2IJZ+BVum6ixOZUfbE6svdNmatGLqDCh2MDWV2t3k4CzikApjq2ZOjGiwt8aXAOGa ev/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZeSreWHN; 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 27si18611174pgu.421.2018.12.20.07.40.40; Thu, 20 Dec 2018 07:40:55 -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=@gmail.com header.s=20161025 header.b=ZeSreWHN; 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 S1731782AbeLTMOb (ORCPT + 99 others); Thu, 20 Dec 2018 07:14:31 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:44809 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728588AbeLTMOa (ORCPT ); Thu, 20 Dec 2018 07:14:30 -0500 Received: by mail-lj1-f195.google.com with SMTP id k19-v6so1324770lji.11 for ; Thu, 20 Dec 2018 04:14:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=ykPQgd+D8oV9K7tP/NcA/KVCltx/mFL7ha6/pueegv8=; b=ZeSreWHNuOd/8BzwWqmsC26IQzsJ8nu2I8fyzIWWl/5n9SHkbyiWney1TaI8UF1ej/ mokJ8pbNuVb5DF8Ka6op8VnyXPeLw6w+eHW/pllJQic2lYxlrzgr53TOFnFdeqgvUggo yCoXawR3HFsDPwyTa1y3rVzbEpPXhLt3sluBPR1BQqCAHhQ3spMrzxnR+P5OaXQ+QOPm nvS76fo9jKcl/zFycOf2kVY35O/Yc8BrHqgQg4M/6o5ywnOtug1UnnpmOR/iN4qypZ59 tuKPr2YSBgT+vg/QYWYLhHEMEk3LnVqfX714lp6iMUjE7VHmbB+ikQIlMoKfeqihpG29 mBbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=ykPQgd+D8oV9K7tP/NcA/KVCltx/mFL7ha6/pueegv8=; b=TjpivzHs7CdvKcFMkHz3Oy89/A1h+w7DaRgtJQQn7YxoAQbgAvI+obYDdr8D7jbLCn 9T5H/QQh4ClByzvezAis2q5Y7iQHNpl/x9sHkD+rNMhC7dyT8wjQZOPedZ3pwnVtRuqH Ik3/qYw266e+BlouwA+Siq2/Iq/rGMotqHoL1DeygkcffQf0kqlUT2eqadGz2HFqqsrj 6ij4fkNmVlbQYMbc4QRgh3Z1YZWoUw+7LL6uTwVNG70HMn0AP9ZUgUDgkkLJG+BjTNrb syl19Z7Elru6jDg016Mbhr5hl+SPIyvVVw8bTC8xy9US+cpkvIJ8T44uOIa01NmcJSmN SXwA== X-Gm-Message-State: AA+aEWZ2iGyND+GQjgWlDi2GnmyGgZG7ahCZVxEUfA0dMq8HYnSgfe9X AD58L699VVjXxdg7I7aGKhE= X-Received: by 2002:a2e:a202:: with SMTP id h2-v6mr14878874ljm.72.1545308068073; Thu, 20 Dec 2018 04:14:28 -0800 (PST) Received: from [10.17.182.20] (ll-22.209.223.85.sovam.net.ua. [85.223.209.22]) by smtp.gmail.com with ESMTPSA id s24sm4178942lfc.30.2018.12.20.04.14.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 04:14:27 -0800 (PST) Subject: Re: [PATCH 05/14] drm/bochs: atomic: switch planes to atomic, wire up helpers. To: Gerd Hoffmann , dri-devel@lists.freedesktop.org, David Airlie Cc: David Airlie , open list , "open list:DRM DRIVER FOR BOCHS VIRTUAL GPU" References: <20181219115127.31359-1-kraxel@redhat.com> <20181219115127.31359-6-kraxel@redhat.com> From: Oleksandr Andrushchenko Message-ID: <277f1e16-aa7b-b741-4ceb-3dea0f776a60@gmail.com> Date: Thu, 20 Dec 2018 14:14:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181219115127.31359-6-kraxel@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/19/18 1:51 PM, Gerd Hoffmann wrote: > Conversion to atomic modesetting, step three. > Wire up atomic helpers. Switch planes to atomic. > > We are late to the party, the transitional helpers are gone, > so this can't be splitted into smaller steps any more. > > Signed-off-by: Gerd Hoffmann > --- > drivers/gpu/drm/bochs/bochs_fbdev.c | 3 ++ > drivers/gpu/drm/bochs/bochs_kms.c | 70 +++++++++++++++++++++++++++++++++++-- > 2 files changed, 70 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/bochs/bochs_fbdev.c b/drivers/gpu/drm/bochs/bochs_fbdev.c > index dd3c7df267..d9f3d42999 100644 > --- a/drivers/gpu/drm/bochs/bochs_fbdev.c > +++ b/drivers/gpu/drm/bochs/bochs_fbdev.c > @@ -6,6 +6,7 @@ > */ > > #include "bochs.h" > +#include > #include > > /* ---------------------------------------------------------------------- */ > @@ -149,6 +150,8 @@ bochs_gem_fb_create(struct drm_device *dev, struct drm_file *file, > > const struct drm_mode_config_funcs bochs_mode_funcs = { > .fb_create = bochs_gem_fb_create, > + .atomic_check = drm_atomic_helper_check, > + .atomic_commit = drm_atomic_helper_commit, > }; > > int bochs_fbdev_init(struct bochs_device *bochs) > diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c > index 18b705fb0b..aa3ba0377a 100644 > --- a/drivers/gpu/drm/bochs/bochs_kms.c > +++ b/drivers/gpu/drm/bochs/bochs_kms.c > @@ -6,7 +6,9 @@ > */ > > #include "bochs.h" > +#include > #include > +#include > > static int defx = 1024; > static int defy = 768; > @@ -113,7 +115,7 @@ static int bochs_crtc_page_flip(struct drm_crtc *crtc, > struct drm_framebuffer *old_fb = crtc->primary->fb; > unsigned long irqflags; > > - crtc->primary->fb = fb; > + drm_atomic_set_fb_for_plane(crtc->primary->state, fb); Taking into account that crtc->primary access goes away in the series: Reviewed-by: Oleksandr Andrushchenko > bochs_crtc_mode_set_base(crtc, 0, 0, old_fb); > if (event) { > spin_lock_irqsave(&bochs->dev->event_lock, irqflags); > @@ -151,6 +153,9 @@ static const struct drm_crtc_funcs bochs_crtc_funcs = { > .set_config = drm_crtc_helper_set_config, > .destroy = drm_crtc_cleanup, > .page_flip = bochs_crtc_page_flip, > + .reset = drm_atomic_helper_crtc_reset, > + .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, > + .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, > }; > > static const struct drm_crtc_helper_funcs bochs_helper_funcs = { > @@ -169,6 +174,59 @@ static const uint32_t bochs_formats[] = { > DRM_FORMAT_BGRX8888, > }; > > +static void bochs_plane_atomic_update(struct drm_plane *plane, > + struct drm_plane_state *old_state) > +{ > + struct bochs_device *bochs = plane->dev->dev_private; > + struct bochs_bo *bo; > + > + if (!plane->state->fb) > + return; > + bo = gem_to_bochs_bo(plane->state->fb->obj[0]); > + bochs_hw_setbase(bochs, > + plane->state->crtc_x, > + plane->state->crtc_y, > + bo->bo.offset); > + bochs_hw_setformat(bochs, plane->state->fb->format); > +} > + > +static int bochs_plane_prepare_fb(struct drm_plane *plane, > + struct drm_plane_state *new_state) > +{ > + struct bochs_bo *bo; > + > + if (!new_state->fb) > + return 0; > + bo = gem_to_bochs_bo(new_state->fb->obj[0]); > + return bochs_bo_pin(bo, TTM_PL_FLAG_VRAM, NULL); > +} > + > +static void bochs_plane_cleanup_fb(struct drm_plane *plane, > + struct drm_plane_state *old_state) > +{ > + struct bochs_bo *bo; > + > + if (!old_state->fb) > + return; > + bo = gem_to_bochs_bo(old_state->fb->obj[0]); > + bochs_bo_unpin(bo); > +} > + > +static const struct drm_plane_helper_funcs bochs_plane_helper_funcs = { > + .atomic_update = bochs_plane_atomic_update, > + .prepare_fb = bochs_plane_prepare_fb, > + .cleanup_fb = bochs_plane_cleanup_fb, > +}; > + > +static const struct drm_plane_funcs bochs_plane_funcs = { > + .update_plane = drm_atomic_helper_update_plane, > + .disable_plane = drm_atomic_helper_disable_plane, > + .destroy = drm_primary_helper_destroy, > + .reset = drm_atomic_helper_plane_reset, > + .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, > + .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, > +}; > + > static struct drm_plane *bochs_primary_plane(struct drm_device *dev) > { > struct drm_plane *primary; > @@ -181,16 +239,17 @@ static struct drm_plane *bochs_primary_plane(struct drm_device *dev) > } > > ret = drm_universal_plane_init(dev, primary, 0, > - &drm_primary_helper_funcs, > + &bochs_plane_funcs, > bochs_formats, > ARRAY_SIZE(bochs_formats), > NULL, > DRM_PLANE_TYPE_PRIMARY, NULL); > if (ret) { > kfree(primary); > - primary = NULL; > + return NULL; > } > > + drm_plane_helper_add(primary, &bochs_plane_helper_funcs); > return primary; > } > > @@ -275,6 +334,9 @@ static const struct drm_connector_funcs bochs_connector_connector_funcs = { > .dpms = drm_helper_connector_dpms, > .fill_modes = drm_helper_probe_single_connector_modes, > .destroy = drm_connector_cleanup, > + .reset = drm_atomic_helper_connector_reset, > + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, > + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, > }; > > static void bochs_connector_init(struct drm_device *dev) > @@ -318,6 +380,8 @@ int bochs_kms_init(struct bochs_device *bochs) > drm_connector_attach_encoder(&bochs->connector, > &bochs->encoder); > > + drm_mode_config_reset(bochs->dev); > + > return 0; > } >