From patchwork Wed Apr 20 08:52:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 12819948 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14A37C433EF for ; Wed, 20 Apr 2022 08:53:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376971AbiDTI4K (ORCPT ); Wed, 20 Apr 2022 04:56:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376989AbiDTI4J (ORCPT ); Wed, 20 Apr 2022 04:56:09 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 361E43B2AC for ; Wed, 20 Apr 2022 01:53:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650444802; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=E0YhsAgzYjv+lmX1BaJJCZkRLt/I7LvOa39GZEIhqUY=; b=jWzjsTSsSPE5iLwShWqu5TnEfR9MypvVHiP1G4J7L8UjxdYCpUQIIej8MBvApzOUtu3lcR /OLiKp6nV46SzqAjouVr4mqK5hkYGkmn1jYu9wNxWIT7Crl3uvQWB1pm9DJOmVCRU1SuCA xwxcmeQUkBIZNrolwFm4p0py2HgQuJQ= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-130-BUk7ooBLOxmZWwphObJLWw-1; Wed, 20 Apr 2022 04:53:17 -0400 X-MC-Unique: BUk7ooBLOxmZWwphObJLWw-1 Received: by mail-wm1-f69.google.com with SMTP id k16-20020a7bc310000000b0038e6cf00439so686138wmj.0 for ; Wed, 20 Apr 2022 01:53:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=E0YhsAgzYjv+lmX1BaJJCZkRLt/I7LvOa39GZEIhqUY=; b=EoiNeiluv1mgsypjvDVENHB9gbptMQfr3vPwi3AmGsHe016fW7yDScZc/kTUZvKJXT 6NEmuK62FdO+zRjgzuTDaIOzRNNukE8we9w2TDZlF1rVWyfW6yyfJyDOzSWdmw4Pu6sY KxPuRTeSFgotoyDpD8WRaUPhzERqF1z++2gcLDksL/T/XBtzByn/ooxQx9nYglbdMVRU GXeLFtzioxPq/A+uJpQqIKy8aTDvmhr1lHOGwbKRUWvCVf0AmXsttPuxzYQhSU8lT0RP GjYhb0TMBREz7Ovb7gxcJc4ABl/lwDV7CZaV85q+iI/pnHRSP/g+7AqHLb5V8xHFRJXN 4BbQ== X-Gm-Message-State: AOAM533Elu86BZpVt9gKutosZGm7GLctvPF0/Mkh6SBXJPQrA2LFfwhJ 4yNkyrvKjQWWSd5sOlvkO30HNsc2YNusLZGSbPEMeNsdJCQpLWD80z9qG2cUdNelJDF1LnPfMTt bKa17kscwgkoyY6HOSMzkUJI= X-Received: by 2002:a1c:f018:0:b0:37b:c13c:3128 with SMTP id a24-20020a1cf018000000b0037bc13c3128mr2496899wmb.157.1650444794363; Wed, 20 Apr 2022 01:53:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxheIU3MZtHSmbm2S30h9XB//sGVs+fBzUrdX6TE0Ye/x/JWHfdB5GuD6LrNgo08kTzLr689Q== X-Received: by 2002:a1c:f018:0:b0:37b:c13c:3128 with SMTP id a24-20020a1cf018000000b0037bc13c3128mr2496874wmb.157.1650444794081; Wed, 20 Apr 2022 01:53:14 -0700 (PDT) Received: from minerva.home ([92.176.231.205]) by smtp.gmail.com with ESMTPSA id i14-20020a0560001ace00b0020aac00f862sm1895343wry.98.2022.04.20.01.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 01:53:13 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Daniel Vetter , dri-devel@lists.freedesktop.org, Thomas Zimmermann , Javier Martinez Canillas , Alex Deucher , Borislav Petkov , Changcheng Deng , Daniel Vetter , Hans de Goede , Helge Deller , Johan Hovold , Jonathan Corbet , Miaoqian Lin , Peter Jones , Sam Ravnborg , Tetsuo Handa , Yizhuo Zhai , Zhen Lei , linux-doc@vger.kernel.org, linux-fbdev@vger.kernel.org Subject: [PATCH v3 0/5] Fix some race conditions that exists between fbmem and sysfb Date: Wed, 20 Apr 2022 10:52:58 +0200 Message-Id: <20220420085303.100654-1-javierm@redhat.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Hello, The patches in this series are mostly changes suggested by Daniel Vetter to fix some race conditions that exists between the fbdev core (fbmem) and sysfb with regard to device registration and removal. For example, it is currently possible for sysfb to register a platform device after a real DRM driver was registered and requested to remove the conflicting framebuffers. A symptom of this issue, was worked around with by commit fb561bf9abde ("fbdev: Prevent probing generic drivers if a FB is already registered") but that's really a hack and should be reverted. This series attempt to fix it more properly and revert the mentioned hack. That will also unblock a pending patch to not make the num_registered_fb variable visible to drivers anymore, since that's internal to fbdev core. Patch #1 is just a trivial preparatory change. Patch #2 add sysfb_disable() and sysfb_try_unregister() helpers for fbmem to use them. Patch #3 changes how is dealt with conflicting framebuffers unregistering, rather than having a variable to determine if a lock should be take, it just drops the lock before unregistering the platform device. Patch #4 fixes the mentioned race conditions and finally patch #5 is the revert patch that was posted by Daniel before but he dropped from his set. The patches were tested on a rpi4 using different video configurations: (simpledrm -> vc4 both builtin, only vc4 builtin, only simpledrm builtin and simpledrm builtin with vc4 built as a module). Best regards, Javier Changes in v3: - Rebase on top of latest drm-misc-next branch. Changes in v2: - Rebase on top of latest drm-misc-next and fix conflicts (Daniel Vetter). - Add kernel-doc comments and include in other_interfaces.rst (Daniel Vetter). - Explain in the commit message that fbmem has to unregister the device as fallback if a driver registered the device itself (Daniel Vetter). - Also explain that fallback in a comment in the code (Daniel Vetter). - Don't encode in fbmem the assumption that sysfb will always register platform devices (Daniel Vetter). - Add a FIXME comment about drivers registering devices (Daniel Vetter). - Drop RFC prefix since patches were already reviewed by Daniel Vetter. - Add Daniel Reviewed-by tags to the patches. Daniel Vetter (1): Revert "fbdev: Prevent probing generic drivers if a FB is already registered" Javier Martinez Canillas (4): firmware: sysfb: Make sysfb_create_simplefb() return a pdev pointer firmware: sysfb: Add helpers to unregister a pdev and disable registration fbdev: Restart conflicting fb removal loop when unregistering devices fbdev: Fix some race conditions between fbmem and sysfb .../driver-api/firmware/other_interfaces.rst | 6 ++ drivers/firmware/sysfb.c | 77 +++++++++++++++++-- drivers/firmware/sysfb_simplefb.c | 16 ++-- drivers/video/fbdev/core/fbmem.c | 62 ++++++++++++--- drivers/video/fbdev/efifb.c | 11 --- drivers/video/fbdev/simplefb.c | 11 --- include/linux/fb.h | 1 - include/linux/sysfb.h | 29 +++++-- 8 files changed, 158 insertions(+), 55 deletions(-) Acked-by: Greg Kroah-Hartman