Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1678398pxb; Wed, 9 Feb 2022 01:59:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwe0dXVEph8qN7R3bVSiwMaeSYOEntzRWFKAPbzY/70mL8TtzIwJ8RqyeYl+Ka9xOxXclEG X-Received: by 2002:a05:6a00:1494:: with SMTP id v20mr1412497pfu.82.1644400778155; Wed, 09 Feb 2022 01:59:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644400778; cv=none; d=google.com; s=arc-20160816; b=dr8gQI6w+QL464srJvG2der8B0MwS+pQZt6jo38y+BuC00wKg2ZHAk1glkoXbC8jd4 TpsDbEdh8oPRdun6ETjz3YcvDOJJDFsJy1H+5n0vFQ3rylylGNKYn7ydKi077bNZKJCs ooTUvAcsnXJ/MiE9V9rYgTUG500H2+B5ByNIxQuBvVShh5pcV3cP53BuSMd76XMguRXe TAiyTbWvH3KBGVP3I6f+RNi1XnXpE+e7LmsJoUzK/xhzbL7pkqPTDh/sqbzCOb5VC+/Z qMNiKk1iDblEYMX2h/a+zIOxZdT+WJOuwCb/DesRjL14PfbrSI6LvfS0xJC8lUISotAQ 5bNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date; bh=7wXqTFG4cE82MExmSEtZAFLdNTXJfQGr6IsHeNmAHug=; b=RI1OkOnzgUWjughAl7fuvhLl8Zlwbsbc/DSUCL8vqZ576PEEagvycADmsS9AYuE6Z9 wIFyKNiPqp8gdkB0kN0zbaxMFII4X2t8uYrbKqkr3wGg7GKuniex7/RJlOg5UIYz6sKs 520vU72440sAM5zX1dNy3T0gt8rHjjSZXxwt82anY2RgGTo2b4WFl9Np62XwmeRglIf1 8VFVPr9CTd/bBXC14OzPaRONjGhwY63FRtGE3iLb+y2ib41MrZod9/MphKHzeTJFD/cD S2ZN680lNp7JxpJ5Bv3o9p776q0pbel7MGkB1KmhHFENLwwKF8fx40vwX941srOQBaJr QSpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s12si2491661plq.16.2022.02.09.01.59.22; Wed, 09 Feb 2022 01:59:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385537AbiBHSzg (ORCPT + 99 others); Tue, 8 Feb 2022 13:55:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385532AbiBHSzc (ORCPT ); Tue, 8 Feb 2022 13:55:32 -0500 Received: from mx1.smtp.larsendata.com (mx1.smtp.larsendata.com [91.221.196.215]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DFD6C0612C1 for ; Tue, 8 Feb 2022 10:55:30 -0800 (PST) Received: from mail01.mxhotel.dk (mail01.mxhotel.dk [91.221.196.236]) by mx1.smtp.larsendata.com (Halon) with ESMTPS id d4e32d3c-8910-11ec-b20b-0050568c148b; Tue, 08 Feb 2022 18:56:32 +0000 (UTC) Received: from ravnborg.org (80-162-45-141-cable.dk.customer.tdc.net [80.162.45.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: sam@ravnborg.org) by mail01.mxhotel.dk (Postfix) with ESMTPSA id 26746194B43; Tue, 8 Feb 2022 19:55:29 +0100 (CET) Date: Tue, 8 Feb 2022 19:55:26 +0100 X-Report-Abuse-To: abuse@mxhotel.dk From: Sam Ravnborg To: DRI Development , linux-fbdev@vger.kernel.org, Du Cheng , Tetsuo Handa , Intel Graphics Development , LKML , Claudio Suarez , Greg Kroah-Hartman , Daniel Vetter Subject: Re: [PATCH 19/21] fbcon: Maintain a private array of fb_info Message-ID: References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> <20220131210552.482606-20-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Daniel, On Tue, Feb 08, 2022 at 03:03:28PM +0100, Daniel Vetter wrote: > On Fri, Feb 04, 2022 at 09:15:40PM +0100, Sam Ravnborg wrote: > > Hi Daniel, > > > > On Mon, Jan 31, 2022 at 10:05:50PM +0100, Daniel Vetter wrote: > > > Accessing the one in fbmem.c without taking the right locks is a bad > > > idea. Instead maintain our own private copy, which is fully protected > > > by console_lock() (like everything else in fbcon.c). That copy is > > > serialized through fbcon_fb_registered/unregistered() calls. > > > > I fail to see why we can make a private copy of registered_fb > > just like that - are they not somehow shared between fbcon and fbmem. > > So when fbmem updates it, then fbcon will use the entry or such? > > > > I guess I am just ignorant of how registered_fb is used - but please > > explain. > > The private copy is protected under console_lock, and hence safe to access > from fbcon.c code. > > The main registered_fb array is protected by a different mutex, so we > could indeed end up with hilarious corruption because the value is > inconsistent while we try to access it (e.g. we check for !NULL, but later > on gcc decides to reload the value and now it's suddenly become NULL and > we blow up). > > The two are synchronized by fbmem.c calling fbcon_register/unregister, so > aside from the different locks if there's no race going on, they will > always be identical. IT was this part that I missed, and it is already spelled out in the commit message. > > Other option would be to roll out get_fb_info() to fbcon.c, but since > fbcon.c is fully protected by console_lock that would add complexity in > the code flow that we don't really need. And we'd have to wire fb_info > through all call chains, since the right way to use get_fb_info is to look > it up once and then only drop it when your callback has finished. > > Since the current code just assume it's all protected by console_lock and > we never drop that during a callback this would mean major surgery and > essentially refactoring all of fbcon.c to only access the fbcon stuff > through fb_info, i.e. to get rid of _all_ the global arrays we have more > or less. I'm not volunteering for that (despite that really this would be > the right thing to do if we'd have infinite engineering time). > > Ack with that explainer added to the commit message? I consider the current commit message fine - it helps when you actually read it. Acked-by: Sam Ravnborg