Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1101156rwb; Wed, 26 Jul 2023 07:37:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlHt1UY/9ALLjmdbi1gGRbC5SiGWularUyog26/AzN+xn1AoiJrPPNawIUAfn8UHRky2Wthr X-Received: by 2002:a05:6a20:32aa:b0:138:5a28:e8cc with SMTP id g42-20020a056a2032aa00b001385a28e8ccmr1878359pzd.37.1690382251146; Wed, 26 Jul 2023 07:37:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690382251; cv=none; d=google.com; s=arc-20160816; b=y8z6ZLQEOGBfXa1LT5lAeMfHWh3qA+YFFK8kYswkrvJzhKChq727fdgAj7cvE4i8wa Ba9EL1MqLhqeBCIEQ/Gm7+Xu8UJshZaIQ9NUmDJfYI7SQjnGIvduMb4o0a80BuDJ9MkT aTVALYJOlYBMfEqNhI/K4RvkwN+Xsbm7juu8WcabuS10eBCx0nB8iSuHXvrk+40FsCZ/ UiZ1fH2ihf3gir762pGEdiShFXwg6dHDYrXGbAVlx3W6E1ZSkSZL1okHkWvQfrm8lLbd 8PT4FxTXS8TWzxeXiX1soZA15rlhHLWX9J6F6Pedw4sQid7YahAQaTIaarXleDeFWG7V ZR9w== 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; bh=2ywtgcRk6+oAidfEgLfgbk4ziugZGP09/wTDVALNvQE=; fh=p3Tlq66Ivy0OmGGZbrPsAsH/MptVXTSdstbk6LXkouw=; b=UhIaM7/30rNvdCG3jecHh1iz8+JII1f3h6WzpVswYrFVtOPNKYlIsRHejdr1kkIOo7 wuClf0Yy6uoi2dqwQhkKPNSocsRPzQC+hwqoh0d3krq5U58EatoKy8OyVqcxXlaxBpHS a5K67OCxliS/QhE/hGyByCoIkcJXmg2Xn7Nbk0guHXWLvI4Vj5kLs7tiruwNRiHNs+HO 3CPzs7NnchkRJ9ZcNS2S+2b5pY6QYRMLJb4wve66lJfK4uxrWLfaWJlzVGz3p687IPcP GutDMbEACx27NnDvGq0ues8YiCDCuOhIJ5NRDTppItD4A7dDL7xwAq5/NhHMwqnqEVaR AWiA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d2-20020a63d702000000b005347aba7376si13022699pgg.297.2023.07.26.07.37.18; Wed, 26 Jul 2023 07:37:31 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231925AbjGZOQg convert rfc822-to-8bit (ORCPT + 99 others); Wed, 26 Jul 2023 10:16:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234508AbjGZOQQ (ORCPT ); Wed, 26 Jul 2023 10:16:16 -0400 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28A202D42 for ; Wed, 26 Jul 2023 07:15:06 -0700 (PDT) Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-6b9c9944da8so5618300a34.3 for ; Wed, 26 Jul 2023 07:15:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690380858; x=1690985658; 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:message-id:reply-to; bh=hYmXF6+fhXjo5iXeYGhM12iR95vAqcFzUbgaNOIrO3o=; b=ARCVNh9u84aWPUOC95raEa3iUzmQ9tpqsM6QnlQRsG+yO+MEF0KJHS3G47IfJnqBGo WYgxite+YQxJz5U0J8sUh1HDA/4wWEV0ueJGvf976FNroIWflWGDzWXpMNQqjTRQ8NlH 5JcWp+0OOUqFy/vVU3ZBGME3Vnmm/MGCi0lIo5LKJ1qrnpQPIgULVfsharpkRyYMjuGJ sqsNRVfI701Y3t90QX50q+RK7BjyL5wbP4tir7Xl2BSopN2FhPyVG3ZNelnN8uGckZyY CqxScExsoEB7YLvhrTE/aHmWshF64SRj5pf7DS9kyOGogtiqiBGscjaMdn7fvw7K5Xb0 QY/w== X-Gm-Message-State: ABy/qLZbRhlUObcPdHmuewVnSe9ZSCrkIy9iIjBz6+IeHR7AREChDkC3 VFMYIqcmFvzdis3mrggfv6A/bo/IJLQxJQ== X-Received: by 2002:a05:6358:7e12:b0:135:a5fe:53e1 with SMTP id o18-20020a0563587e1200b00135a5fe53e1mr2165108rwm.14.1690380857982; Wed, 26 Jul 2023 07:14:17 -0700 (PDT) Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com. [209.85.219.169]) by smtp.gmail.com with ESMTPSA id y1-20020a056902052100b00d0fe6cb4741sm1668367ybs.25.2023.07.26.07.14.17 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Jul 2023 07:14:17 -0700 (PDT) Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-c11e2b31b95so7149362276.3 for ; Wed, 26 Jul 2023 07:14:17 -0700 (PDT) X-Received: by 2002:a25:828c:0:b0:d0b:5a37:1aa0 with SMTP id r12-20020a25828c000000b00d0b5a371aa0mr1586828ybk.36.1690380856985; Wed, 26 Jul 2023 07:14:16 -0700 (PDT) MIME-Version: 1.0 References: <20230721070955.1170974-1-javierm@redhat.com> <874jlqlv5v.fsf@minerva.mail-host-address-is-not-set> In-Reply-To: From: Geert Uytterhoeven Date: Wed, 26 Jul 2023 16:14:04 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4] drm/ssd130x: Allocate buffers in the plane's .atomic_check callback To: Maxime Ripard Cc: Javier Martinez Canillas , linux-kernel@vger.kernel.org, Thomas Zimmermann , Daniel Vetter , Daniel Vetter , David Airlie , dri-devel@lists.freedesktop.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 Hi Maxime, On Wed, Jul 26, 2023 at 3:54 PM Maxime Ripard wrote: > On Wed, Jul 26, 2023 at 02:33:06PM +0200, Geert Uytterhoeven wrote: > > > >> Also, Javier pointed me to a discussion you had on IRC about using devm > > > >> allocation here. We can't really do that. KMS devices are only freed > > > >> once the last userspace application closes its fd to the device file, so > > > >> you have an unbounded window during which the driver is still callable > > > >> by userspace (and thus can still trigger an atomic commit) but the > > > >> buffer would have been freed for a while. > > > > > > > > It should still be safe for (at least) the data_array buffer. That > > > > buffer is only used to store pixels in hardware format, and immediately > > > > send them to the hardware. If this can be called that late, it will > > > > fail horribly, as you can no longer talk to the hardware at that point > > > > (as ssd130x is an i2c driver, it might actually work; but a DRM driver > > > > that calls devm_platform_ioremap_resource() will crash when writing > > > > to its MMIO registers)?!? > > > > > > At the very least the SPI driver will fail since the GPIO that is used to > > > toggle the D/C pin is allocated with devm_gpiod_get_optional(), but also > > > the regulator, backlight device, etc. > > > > > > But in any case, as mentioned it is only relevant if the data_array buffer > > > is allocated at probe time, and from Maxime's explanation is more correct > > > to do it in the .atomic_check handler. > > > > You need (at least) data_array for clear_screen, too, which is called > > from .atomic_disable(). > > I'm not sure I get what your concern is? > > Even if we entirely disable the plane, the state will not have been > destroyed yet so you still have at least access to the data_array from > the old state. Currently, clearing the screen is done from the plane's .atomic_disable() callback, so the plane's state should be fine. But IIUIC, DRM allows the user to enable/disable the display without creating any plane first, so clearing should be handled in the CRTC's .atomic_disable() callback instead? Then, would we still have access to valid plane state? Thanks! Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds