Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1172259rwb; Wed, 26 Jul 2023 08:33:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlGMBMNqp+Ak1daQ/dRZkTQaef8JgMLW5V7bav5RKDqeWTE9I/OYGn3piKjcUfFqlYqa4V4l X-Received: by 2002:a05:6a21:3b45:b0:133:be9d:a9e6 with SMTP id zy5-20020a056a213b4500b00133be9da9e6mr2688532pzb.17.1690385609864; Wed, 26 Jul 2023 08:33:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690385609; cv=none; d=google.com; s=arc-20160816; b=phIA6t1XlWAWsap3SB9ZEOM87hCJPBppezu3LNbm61pTMbhQp4rpgjyr4/KHBjYq3U fH6syoEKPn2IdHSWD9SMsRx2Wvd3qwcBT9FZvfBatpL7+XR1H7xNvywqACmo61CSgwWl bZMv62B7UDR35mBC1o4em+8zfTi1/oSM88g18FZ5sm/GkQfOsUJ7vBhw081oorGvJI9w xGHzx4K77p3YybPWKeSqrXM3Cl3LM6TBXREQasmEfAaaMoanRM2X63Yb0DtpNij55n/n n2HVMhf18obgDt6w9u4TEBSIRU29p2IpfWy+2zZvbE34IMPeORVqErQV+GFYmuBL60f/ nbJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=gyMSRcxy/2ogHzH4JMQXVtrL8+3uUTaWkvxjprHFoKs=; fh=1iaXdNovkLcsHU7klnja0n9BVzJYoQQXMsllbhFgXkE=; b=TzvG6nQgklqFX14QsR1bLeKcqLdq0wbVtbb1qVty7X4eF172OZrXVNi8kiEHYiWpST 2Pg+elAf249rKqLPh6g+EfiF6MStdSv8kYnwqVWJGlBQaHUbjcg0PTfJznrqAyQbpwaG AvzvRiNNSkYBm/nHuC2sUSRbpJ25TWLCIi5GsU6D4xPgTiDE5uPS1JsGbVAt73/j8yRz SQmxw4odfS13PvQBkvsXxr5g9F8TIstI09fPVZak3OBbLvye3q8IwUPwyEvFPXUtH52P UI0WzHIr+Ne2+9B1G8aENxAIreEAaDzJakf1yZ7DTQSj5XTshyC2YjrllqB2BlAL4M5x ATaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iG0MyWJy; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t23-20020a656097000000b005638ffaa99fsi9622295pgu.82.2023.07.26.08.33.17; Wed, 26 Jul 2023 08:33:29 -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=@redhat.com header.s=mimecast20190719 header.b=iG0MyWJy; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234361AbjGZOXm (ORCPT + 99 others); Wed, 26 Jul 2023 10:23:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234364AbjGZOXj (ORCPT ); Wed, 26 Jul 2023 10:23:39 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A4E3196 for ; Wed, 26 Jul 2023 07:22:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690381372; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gyMSRcxy/2ogHzH4JMQXVtrL8+3uUTaWkvxjprHFoKs=; b=iG0MyWJyPbiWprMOiBLErMjqA24VEE7b5TEQRfwyldw7yXYBVfhtBznZ2GveypWVn31RWR mo0vzVpStnsNjf1OOfceG/0NnKG6Ze3LKS0vAQUUbB5KNu1btL8uytaOtlzuUZDSKIuP/A hDLyM726FUNrED798HkGvWw2w5tayKk= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-91-S2f4KJudMTiFxMWaIXogrw-1; Wed, 26 Jul 2023 10:22:48 -0400 X-MC-Unique: S2f4KJudMTiFxMWaIXogrw-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3fa8f8fb7b3so40397955e9.2 for ; Wed, 26 Jul 2023 07:22:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690381367; x=1690986167; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gyMSRcxy/2ogHzH4JMQXVtrL8+3uUTaWkvxjprHFoKs=; b=grglc1e+JuY4rhpw99co7ZdxWt51W3gSgijSGN3mpappYC+nlInKhlDH+TLxTa/M/A aPaytZdeb1FOeIxFyKoqFGfvYMRCeaCHCGNd0hTscyBksqRovrZo0tYtz6v2iZBqz1LM rMrxVAf4CaVYw0oplBStUW8xKNKfXZvJRU35ZinQiIU3/iWap/4Ah4jZZfDON6wB9RvV gH4oJLjcgmyyf0o9zQ8Bz1wFinsQEL1Rog9F5iCq+4yLxadPaqV3cJuF61GGqFsQuhS5 /BUzyMcqfsmDlFhc8Ai5SLb2XsNsBCMuYZANRSfcc8RXfRcY0FD2s32yHSBc/eGe2bIp Ef7w== X-Gm-Message-State: ABy/qLZUwwXaKZBmkd9hHiv81gww9J53Wm0P39avQFraFUB7qet42FyH 1DehoBbf13ssdAzev6SnVlykBKjvNP+yyFo0srLj/3/EFs00C/rfmZInHANzf9brhNz9mRj4zTX eByiPgEjmmxYvahc5XkOPea2O X-Received: by 2002:a05:600c:2103:b0:3fb:424b:ef6e with SMTP id u3-20020a05600c210300b003fb424bef6emr1545558wml.23.1690381367204; Wed, 26 Jul 2023 07:22:47 -0700 (PDT) X-Received: by 2002:a05:600c:2103:b0:3fb:424b:ef6e with SMTP id u3-20020a05600c210300b003fb424bef6emr1545539wml.23.1690381366875; Wed, 26 Jul 2023 07:22:46 -0700 (PDT) Received: from localhost (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id q8-20020a1ce908000000b003fba6709c68sm2174121wmc.47.2023.07.26.07.22.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 07:22:46 -0700 (PDT) From: Javier Martinez Canillas To: Geert Uytterhoeven , Maxime Ripard Cc: linux-kernel@vger.kernel.org, Thomas Zimmermann , Daniel Vetter , Daniel Vetter , David Airlie , dri-devel@lists.freedesktop.org Subject: Re: [PATCH v4] drm/ssd130x: Allocate buffers in the plane's .atomic_check callback In-Reply-To: References: <20230721070955.1170974-1-javierm@redhat.com> <874jlqlv5v.fsf@minerva.mail-host-address-is-not-set> Date: Wed, 26 Jul 2023 16:22:45 +0200 Message-ID: <87cz0e4uru.fsf@minerva.mail-host-address-is-not-set> MIME-Version: 1.0 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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 Geert Uytterhoeven writes: Hello Geert, > Hi Maxime, > > On Wed, Jul 26, 2023 at 3:54=E2=80=AFPM 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 usin= g devm >> > > >> allocation here. We can't really do that. KMS devices are only fr= eed >> > > >> once the last userspace application closes its fd to the device f= ile, so >> > > >> you have an unbounded window during which the driver is still cal= lable >> > > >> 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 immedi= ately >> > > > send them to the hardware. If this can be called that late, it wi= ll >> > > > fail horribly, as you can no longer talk to the hardware at that p= oint >> > > > (as ssd130x is an i2c driver, it might actually work; but a DRM dr= iver >> > > > that calls devm_platform_ioremap_resource() will crash when writi= ng >> > > > to its MMIO registers)?!? >> > > >> > > At the very least the SPI driver will fail since the GPIO that is us= ed 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 co= rrect >> > > 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 But it's needed to be clared in this case? Currently the power on/off is done in the encoder's .atomic_{en,dis}able() but the actual panel clear is only done for the plane disable as you mentioned. > .atomic_disable() callback instead? Then, would we still have access > to valid plane state? > If the clear has to be moved to the CRTC atomic enable/disable, then the driver should be reworked to not use the data_array and instead just allocate a zero'ed buffer and pass that as you proposed. But again that's something that could be done later as another patch. > Thanks! > > Gr{oetje,eeting}s, > --=20 Best regards, Javier Martinez Canillas Core Platforms Red Hat