Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp948947rwb; Wed, 26 Jul 2023 05:35:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlFptgnT93U+joehhoosflXOXl6P4LltapT1Sd3dh7AMvZnFeqh8QMzhXicQTyS5+0YMwwlt X-Received: by 2002:a19:4f0a:0:b0:4f8:711b:18b0 with SMTP id d10-20020a194f0a000000b004f8711b18b0mr1523206lfb.3.1690374927919; Wed, 26 Jul 2023 05:35:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690374927; cv=none; d=google.com; s=arc-20160816; b=kyigJ4cIm32H2s/hUQyZwu837KPvCCyyZLsm2HTCNBgrZLT/oaw9qkmoEOAtfTMAGD s1DIthWGu6pRth7AF/VbZCXsQwXw0VfvLn/4JfvJQ3tljNTkMsASyfwF9/hJbHcPRqJ+ mbSiXM4lr6KcaKeuNzLFmDe7RMU+/gQtS2HgS9v31nVAq1e0mydz0X0AzNEV1ljwFXkD mWbuzj6GzjVf2PGsxnik6NTAs2dzNfNny5o/w3h3EwOe8KRtYNfFMntMSPunnwwk3YDd sUTszqH9vFpy5dIBOuQkBqdfmhB4Hwnbz3F8DT44U4Lt4s+GBFRdssZfJbfPb0iAyJMN b+JA== 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=/eH15WL4iKuqlDox+/YoMnY9jbrjr/b9mBAQS1i/VOw=; fh=6p2R86Y/sESwhN4XG7qZosJ8KscnHiMs4LmCOXbOaLo=; b=HjFnVOwOFbDVGdebSGSEBh6YlvaXRC01q/irEly3UHPr7rqFxyFIjy75YNMmNHRKHq 5K1zPBwm6gI+lIG+taUSYbbijt9tz8t2xVb+EYs7ul/YjvaroD6p9/zCVxyqA/wIr6jg g+dVhNTwI0xD91U4aTSekyG/8KElznX8dQ6zhKGMb5ckB0uL9YQZ4j1B3xN++kU4ZgRY PFLqGnHJjlof537I1g9S5iG64JYWavAimSR7PRR+//eR+AjPFB3W9h7IpNqDDc7YVZcL r/Rz4DYv/6jO2N9fcwByIZNbgtzkrD3YudUpIxwIaHVgZQ/Z2v3xDKKzjl+Qkyfxo0ps KG1g== 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 c7-20020aa7d607000000b005222709bc35si5511993edr.197.2023.07.26.05.35.03; Wed, 26 Jul 2023 05:35:27 -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 S231145AbjGZME3 convert rfc822-to-8bit (ORCPT + 99 others); Wed, 26 Jul 2023 08:04:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230305AbjGZME1 (ORCPT ); Wed, 26 Jul 2023 08:04:27 -0400 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D871FAA for ; Wed, 26 Jul 2023 05:04:26 -0700 (PDT) Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6b9d68a7abaso5293334a34.3 for ; Wed, 26 Jul 2023 05:04:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690373066; x=1690977866; 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=d8EFa5XQd76ZWyggXmDp/7dYxuK3+nTVxrOJ5ZnejRg=; b=D77IPW98frQ6lcbelUA6c1NWiqfsVhuh2u11NopcP6uZ/XdvMmocd+KjEuPNNUR9vn KDG1/rpKpRb+G1e2Y+UGcDQ3YUwG8fvLKGLWQT62eAwHvafy1w6ZpkbxCCpl1anartZc DcWcDe7LUGASyN2NdwXbx6m7EWHn8Yzeapmkm1I+HVZpXgjiG+9fX2WzPg8nfkwc7wLG ssjYzJULCQEvHaQFJTRin1CK/17DHbVOx0B2x4xyq732UapGhLX0giJ2vkMXt9Ok2GJj jMekvS5oK/VsFvFvmL2ndmPgeZUF6M8G6lMSMt//wmsVqrnqZQ28hIC81SFdtNaE37SV 9JGg== X-Gm-Message-State: ABy/qLYeTmpORPL7dxxGcdJBy4gl5undW4MUvBE5fFsGSkFm7sRQTUCZ kUfo/pe09gAiV2ndparTSvM7mKUCQ+BTOQ== X-Received: by 2002:a05:6870:56a9:b0:17f:7388:4c69 with SMTP id p41-20020a05687056a900b0017f73884c69mr2505527oao.30.1690373065971; Wed, 26 Jul 2023 05:04:25 -0700 (PDT) Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com. [209.85.128.180]) by smtp.gmail.com with ESMTPSA id i199-20020a816dd0000000b005774338d039sm1810429ywc.96.2023.07.26.05.04.25 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Jul 2023 05:04:25 -0700 (PDT) Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-5839f38342fso60333687b3.0 for ; Wed, 26 Jul 2023 05:04:25 -0700 (PDT) X-Received: by 2002:a05:6902:523:b0:ced:974a:1aae with SMTP id y3-20020a056902052300b00ced974a1aaemr1534872ybs.58.1690373065221; Wed, 26 Jul 2023 05:04:25 -0700 (PDT) MIME-Version: 1.0 References: <20230726105433.389740-1-javierm@redhat.com> <20230726105433.389740-2-javierm@redhat.com> In-Reply-To: <20230726105433.389740-2-javierm@redhat.com> From: Geert Uytterhoeven Date: Wed, 26 Jul 2023 14:04:13 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 2/2] drm/ssd130x: Allocate buffer in the plane's .atomic_check() callback To: Javier Martinez Canillas Cc: linux-kernel@vger.kernel.org, Thomas Zimmermann , Daniel Vetter , Maxime Ripard , 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 Javier, On Wed, Jul 26, 2023 at 12:55 PM Javier Martinez Canillas wrote: > Drivers are not allowed to fail after drm_atomic_helper_swap_state() has > been called and the new atomic state is stored into the current sw state. > > Since the struct ssd130x_device .data_array is allocated in the encoder's > .atomic_enable callback, the operation can fail and this is after the new > state has been stored. So it can break an atomic mode settings assumption. > > Fix this by having custom helpers to allocate, duplicate and destroy the > plane state, that will take care of allocating and freeing these buffers. > > Suggested-by: Maxime Ripard > Signed-off-by: Javier Martinez Canillas > Acked-by: Maxime Ripard > Tested-by: Geert Uytterhoeven > --- > > Changes in v5: > - Add collected tags from Maxime and Geert. > - Update commit message to not mention the kernel oops (Geert Uytterhoeven). > - Drop Reported-by and Fixes tags (Geert Uytterhoeven). > - Update comment about buffer and data_array fields (Geert Uytterhoeven). > - Remove superfluous NULL check in ssd130x_fb_blit_rect() (Geert Uytterhoeven). > - Reset .buffer to NULL if .data_array allocation fails (Geert Uytterhoeven). > - Inline buffer alloc/free helper functions (Geert Uytterhoeven). Thanks for the update! > --- a/drivers/gpu/drm/solomon/ssd130x.c > +++ b/drivers/gpu/drm/solomon/ssd130x.c > @@ -535,7 +550,8 @@ static int ssd130x_update_rect(struct ssd130x_device *ssd130x, struct drm_rect * > return ret; > } > > -static void ssd130x_clear_screen(struct ssd130x_device *ssd130x) > +static void ssd130x_clear_screen(struct ssd130x_device *ssd130x, > + struct ssd130x_plane_state *ssd130x_state) > { > struct drm_rect fullscreen = { > .x1 = 0, > @@ -544,21 +560,21 @@ static void ssd130x_clear_screen(struct ssd130x_device *ssd130x) > .y2 = ssd130x->height, > }; > > - ssd130x_update_rect(ssd130x, &fullscreen); > + ssd130x_update_rect(ssd130x, ssd130x_state, &fullscreen); I've just realized another issue: since 49d7d581ceaf4cf8 ("drm/ssd130x: Don't allocate buffers on each plane update"). this no longer clears the screens, but just updates the hardware with the data in ssd130x_device.buffer, i.e. with the last image shown. So this should at least clear all of ssd130x_device.buffer before calling ssd130x_update_rect(). As it's a bit pointless to transpose a black image, a better fix would be to just clear ssd130x.data_array, and call the low-level hardware functions like ssd130x_update_rect() does. > } 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