Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2824966rwb; Mon, 19 Sep 2022 10:28:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5bZ+g213OyhKFvqphIJQ4rLhW6tqnxxiBLUx0fjs62WfFJTZp2WBhnA+6RHaWiuZP2Gf9H X-Received: by 2002:a17:902:e5cd:b0:176:ad01:ab47 with SMTP id u13-20020a170902e5cd00b00176ad01ab47mr782792plf.133.1663608536651; Mon, 19 Sep 2022 10:28:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663608536; cv=none; d=google.com; s=arc-20160816; b=rVDKJdiHegE7MpzBRGTPX2yarHX76S0VbO0uShU9jP8lseVOBo5O/Nhn1D05xAX8fQ OIS5cHoU+cr7MexmP6q6suz6a2cvm283HPYhukjaYWBKkIEN7Zc79cuBCWMQIMWjnRmh 8CzFVW818jTDS+hAqqsztw80osiQkyyetDMDZCPTvquOOWIIyPig+WIYLp81yzVtB/Xb BN8vcQNk5Z96WbUeNxLnX5JU/e9msgB8xaySm5M3DhPtsd/SOpYlk4IkopS5djrRfdw4 T67Q8b+S8FJ9rQRyurKl4RmJwNtBz1aFQ1gOEXemzooifnwOI6jspJmkWXsCuA+ui4nn ooQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=B79VNmtksFZCxxDMaKm5/f3GDhn1sPWt9TTqsHjBc44=; b=p1i/GvUj7utkZorfH09bsr437SQ9xI0QUvL3U8+NJT3UcpcxtUnI9MpuS4zY6X4hq5 PGdFglNRz7o3TPH5jn/51SdoXwIbMNhmzOiyJZGZxDR/mzN8HpvSFZbQ1nI1BBn1Fbkx zJyOcQmU/oLDHpw3MnS377x+URCmXfuLCWpja5ht8tlYk45Z8w2b98b0+giTAEuHnnOw Y+oV4QC4AHvm5ZYaisbocBRicwPlYgVcTIBgO3Ix8O9RU2nN59Mr3rLM15fhgR+pwMsp nXsVJpYD/5w5htcz404ToaJ0u8fZsg51u7xNk2IsD3nyvE5EiN6qvCDwL+mGJgw1XiAb 5rHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=p4KBBtjP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o5-20020a637305000000b004157aa8707csi384537pgc.110.2022.09.19.10.28.45; Mon, 19 Sep 2022 10:28:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=p4KBBtjP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229953AbiISQ0R (ORCPT + 99 others); Mon, 19 Sep 2022 12:26:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229908AbiISQ0Q (ORCPT ); Mon, 19 Sep 2022 12:26:16 -0400 Received: from mail-oa1-x2e.google.com (mail-oa1-x2e.google.com [IPv6:2001:4860:4864:20::2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 142323B967 for ; Mon, 19 Sep 2022 09:26:14 -0700 (PDT) Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-11eab59db71so104175fac.11 for ; Mon, 19 Sep 2022 09:26:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date; bh=B79VNmtksFZCxxDMaKm5/f3GDhn1sPWt9TTqsHjBc44=; b=p4KBBtjPK5F6KjhfBxOotM/kEf99VqLGvag9iPunX57HEavFuYwQ0Gtr4amfWbjcWh jt1cAKnoH/x09ARebwlsO6Tot4ODwrwH35uTlEqt1p5PSaTMUsaoOe9NgqMAikbvX2+z qhca/cOrPTbArKoxRZmGe9Zk1eykZbYcrfPnXc6xnMU7d8ajY5o/vag9Jug+zD12uAWS flj2v9wTuVQ46qrR7ITj+hG6acIg70QwC9PoDNu1c3GaM1a0oDpRx6lhZUDD1uw7XZkV 1ArvlG5ixJKONjKXgPTpCh7KZM0blxlfw4ucY9uqP5SxcyxiwRmQaSevilZmz9GSwLfA O7MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=B79VNmtksFZCxxDMaKm5/f3GDhn1sPWt9TTqsHjBc44=; b=qdaZtJzV/xqI91HL1CVFgIMoJ00HkzZ131LkTrnBBVSsVgNLtORNRDV1PL6gVm4Hqt TcuFw4URSWSgdloB+41whMqiK8D1opOh40GlfjR68PV6Vnem5bQYLrfuE+gPIAndVXe/ ShZfXkR09HfmW1cTbVKBM+dKCAj70/AZvMluYXRZRcR0wD8xuEIFkGXWKUGirHk8OOQE xWxQEPihKabXfXD8jJGI7yfCdMgBK49dtcwthrVePNH7EQum7aUrUr0W1edcp9CHtqFB 5uUALajQi4z6FHSVG1YhstYpkZV52DqfwUgmLpHF1aRrJnoz665x8xBJLUC7A76Vtx+m KRkQ== X-Gm-Message-State: ACgBeo3j12qVWdDJcyw+UdEDkL6Q8b2myjcXSvQab/r9xcHWuGVZklQh 4rbhGleFg+6fMpT2+aT27rfecfgRqJ9/b++MY/k= X-Received: by 2002:a05:6870:1783:b0:12a:f442:504d with SMTP id r3-20020a056870178300b0012af442504dmr16904152oae.46.1663604773291; Mon, 19 Sep 2022 09:26:13 -0700 (PDT) MIME-Version: 1.0 References: <20220906195721.143022-1-hamza.mahfooz@amd.com> <99314fcf-b886-a7bd-3866-241af6ac9831@suse.de> In-Reply-To: <99314fcf-b886-a7bd-3866-241af6ac9831@suse.de> From: Alex Deucher Date: Mon, 19 Sep 2022 12:26:01 -0400 Message-ID: Subject: Re: [PATCH] drm/amdgpu: use dirty framebuffer helper To: Thomas Zimmermann Cc: Hamza Mahfooz , linux-kernel@vger.kernel.org, Guchun Chen , David Airlie , "Pan, Xinhui" , amd-gfx@lists.freedesktop.org, Aurabindo Pillai , Sean Paul , dri-devel@lists.freedesktop.org, Alex Deucher , =?UTF-8?Q?Christian_K=C3=B6nig?= , Fernando Ramos Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 19, 2022 at 2:44 AM Thomas Zimmermann wro= te: > > Hi > > Am 06.09.22 um 21:57 schrieb Hamza Mahfooz: > > Currently, we aren't handling DRM_IOCTL_MODE_DIRTYFB. So, use > > drm_atomic_helper_dirtyfb() as the dirty callback in the amdgpu_fb_func= s > > struct. > > drm_atomic_helper_dirtyfb() creates a new atomic commit for the > frambuffer's planes. Drivers can then updates these planes' output > (e.g., writeback to video memory). I thought that amdgpu simply scans > out from the framebuffer's memory regions in VRAM. So I'm curious why > this patch is necessary. I think in this particular case, the problem is that there are still some asic which default to non-atomic code which is what is causing the problem here. Something like this would fix that: diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index 5b09c8f4fe95..f5e9dd454c54 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c @@ -497,6 +497,11 @@ bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector, static const struct drm_framebuffer_funcs amdgpu_fb_funcs =3D { .destroy =3D drm_gem_fb_destroy, .create_handle =3D drm_gem_fb_create_handle, +}; + +static const struct drm_framebuffer_funcs amdgpu_fb_funcs_atomic =3D { + .destroy =3D drm_gem_fb_destroy, + .create_handle =3D drm_gem_fb_create_handle, .dirty =3D drm_atomic_helper_dirtyfb, }; @@ -1102,7 +1107,10 @@ static int amdgpu_display_gem_fb_verify_and_init(struct drm_device *dev, if (ret) goto err; - ret =3D drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs); + if (drm_drv_uses_atomic_modeset(adev_to_drm(adev))) + ret =3D drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs_atomic); + else + ret =3D drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_fu= ncs); if (ret) goto err; As for why we need the dirty callback, I think it's used for PSR. Alex > > Best regards > Thomas > > > > > Signed-off-by: Hamza Mahfooz > > --- > > drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/= drm/amd/amdgpu/amdgpu_display.c > > index c20922a5af9f..5b09c8f4fe95 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c > > @@ -38,6 +38,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -496,6 +497,7 @@ bool amdgpu_display_ddc_probe(struct amdgpu_connect= or *amdgpu_connector, > > static const struct drm_framebuffer_funcs amdgpu_fb_funcs =3D { > > .destroy =3D drm_gem_fb_destroy, > > .create_handle =3D drm_gem_fb_create_handle, > > + .dirty =3D drm_atomic_helper_dirtyfb, > > }; > > > > uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev, > > -- > Thomas Zimmermann > Graphics Driver Developer > SUSE Software Solutions Germany GmbH > Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany > (HRB 36809, AG N=C3=BCrnberg) > Gesch=C3=A4ftsf=C3=BChrer: Ivo Totev