Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1866346lqe; Tue, 9 Apr 2024 02:46:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXlKgoOrs0q3gPTxb35xla0bxh8dFOT7uvFI4JF0wyfJ+3nN2c7x8/HYh421dGa+qWq32ZnL5/hUBU1JBAAEdHCSuII7QG+RSJaggLtUA== X-Google-Smtp-Source: AGHT+IHMrlVrg5AeZ6W7Bwjj7XZy9SEUDGo3nWr9vHAXW4XWpeclC0+qVlVVzkh12rrJGkIlU/U6 X-Received: by 2002:a17:902:d511:b0:1e3:faec:dc33 with SMTP id b17-20020a170902d51100b001e3faecdc33mr5826503plg.43.1712656012266; Tue, 09 Apr 2024 02:46:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712656012; cv=pass; d=google.com; s=arc-20160816; b=Xni44r96BIM2Mrbr8zVDf3a2rzKY1M5WeYqha06DGnGmn36/JuJVIKshrAIHqDqpkz asu4jZp90XwkJhC+vrSzatybtg6bJMtVRZYsfhIphwiGH22t9Csbdk7W14nOX7b7j4rr AP3WWyT9WBYaw4Uc72SslItw2MyOvI/A74l+PS5FEgHH1azNNqclVHvoc0A6mq2tm3On XSPikg4HJqa1rMtXotB8qtGF27K2AS9/vRQxnYGVH6zobS9lpNehKnEHrTGFD9upXCn7 6X/MZ2vS6BEnAjVQPy/z6qitYXhjqSjMuN1h1NY5ATI9fUgUTTRZ8OBkDUmGHV/1DQpI ZPLA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=DidLSXvh5/1hQWAaoglzJs78OkjbxqNx+xlmjiU4CrE=; fh=0x0H/weCp81S7hf1+J0qumtZsNMrpgDIJALZMHyp9kI=; b=P8Bi1ZTmbo16Js504S+TA4rlEgxCigVzlVSrkcM2mkAsmzW/bCygBzBHCB8EGld2aS o316pgz6jKmVg9pip8AeH5MfZTc9pzmEV/uP1kQORowwRwsnvRxI6UPew7fckxE6uvr5 VHlpZyLVobHPrhq+uesPm8AlR+EcUffO6s5HRZlUXXo/5fueqqWNR5vnWLnnDDa5NZkN 2dspPWOa+fpPYlK8g5RZ7T0Ib6Nks+jaNf/HvOld9e8GX4BBCiGBhn2/UdzTaHABBav1 UVlLAcshgrqC+IPzoGqHV02F/X4dSB882EBmLB2B1fd5hLCA5Ih7O1MwbyoQvyqBabLC 89mw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=dBplVnu5; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-136590-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136590-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p1-20020a170902e74100b001e3c9090026si7661450plf.476.2024.04.09.02.46.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 02:46:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136590-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=dBplVnu5; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-136590-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136590-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EEF1D284ECA for ; Tue, 9 Apr 2024 09:46:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 524AD8063B; Tue, 9 Apr 2024 09:46:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="dBplVnu5" Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 251057FBC7 for ; Tue, 9 Apr 2024 09:46:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712655998; cv=none; b=XlFA2XbCiDwF5jbPCjrh7Jmpx7H4D4OG3GmeqLfuFsxbVwS+kB5PQ/FUw/NXyt6M2DqtfJfIuChoQMC1eJ5i378aQhMGfjV/BVve806aH1d5W2tPowCa5sxpdXgi1Krqh5BWhMvhjZvlgXkI3FwPCG9y36zdEadzl3lzUsS2wfI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712655998; c=relaxed/simple; bh=3oLuWwlw+UA9jWk1fW4KtxdWBjfj8RgQrkzBwOMwbK8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fI+gIBGWcAdDDKwBM/d2uk9YggnsfWpX/mGh5vhu79+d3asLapPnwtM90ll6QCkV6bCwvQ10AQ37kS0gi2EAfuFw3yIgZdNoLx/CufgOAW+ygrZ281DXlSj8VPJkEgK/MH/ispSRzMFBxI3KhFUnUH0wZu1tbZglgh27Sm7Ij0g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=dBplVnu5; arc=none smtp.client-ip=209.85.167.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-516d2600569so5664306e87.0 for ; Tue, 09 Apr 2024 02:46:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1712655994; x=1713260794; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=DidLSXvh5/1hQWAaoglzJs78OkjbxqNx+xlmjiU4CrE=; b=dBplVnu5aZRkIPj1XP4OF3jn+AaUXzjSREZN4Sx3nlvZMQpi0m4E8qvSybxqKIcFo9 TqVkeV72ip2VHCBhwAW2Xaiynl0dB58rrn063U3aS/e443+a3Jq+PQoAtC3vOLn0vyVq 1E1R7yK2qPjD29DieSDJVjUnvzudYTntL85lveu4N9ozaHnQJJblJGlY3iSV+NqhM/+0 gmnU1XG8jfHoGAPLjFTlh225Mvkxs1C7psEfdOjMZjAXcpMBa4KB3ldVrtziCgej5HGR woxAgRZiKqetV3dRShlxS5uTWPNC6m5da0ptO44MTmyrRk1raneC3ltblv2vmnhF3XUo YOsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712655994; x=1713260794; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=DidLSXvh5/1hQWAaoglzJs78OkjbxqNx+xlmjiU4CrE=; b=BQMQTG2t6iDqTe5MYfmlPDygJZFv/4q9gq7tcc7Kfrg3TF+ZzmUuDd+iA2cgM+ILXM p/9O5LPiRJZNUI4qaCAUa6KG9QQwEng7yC5GwFrG90rR26/jwVL9Bxybz2cvBm//uXyI HSFrD+fWP6KutRqAygDzanSqLecchjDO+fdC0QRBLcMwDvNY9lMitJRnKOR3bSqngcO6 Fsjy2xVaFzT4XqQOcoGCHZpSxjhCTjMYGa16TzQpbwx2w9TtfFoDhwiVLvr9PCTxukrN Evt0EoEYx9Y5k4CV2VbRdUu64IrBO75KkFGcHTfNugnSmiCEBqrfijan5skbJB+m/CB4 OWlQ== X-Forwarded-Encrypted: i=1; AJvYcCX/Co5a6lcatDaQfJBbBiCu5fn2VrWywLUrVG7dKYxUfN34zY2Ll9Wn5NNPnoMVHJ5v0ldfJqMvFx0pKEkcNSsTLTg8dVe9KLXEWBuX X-Gm-Message-State: AOJu0Yx2V5ImqDNE85O4bXhI6TXYvIBUx93eQjflpV7EuHKg5XbxZGRU bhU6eNDKDWN6R63HcEWoMLAECn7JiYtDOeE0qMAr4OYu02ZokPROE0hrkTWqy+C1KDbcpNvjDFx / X-Received: by 2002:a19:ca07:0:b0:516:ced5:3afa with SMTP id a7-20020a19ca07000000b00516ced53afamr7482570lfg.5.1712655994292; Tue, 09 Apr 2024 02:46:34 -0700 (PDT) Received: from localhost.localdomain ([176.114.240.50]) by smtp.gmail.com with ESMTPSA id j15-20020a5d452f000000b00343e825d679sm10574650wra.87.2024.04.09.02.46.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 02:46:34 -0700 (PDT) Date: Tue, 9 Apr 2024 11:46:32 +0200 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: [PATCH printk v4 07/27] printk: nbcon: Use driver synchronization while registering Message-ID: References: <20240402221129.2613843-1-john.ogness@linutronix.de> <20240402221129.2613843-8-john.ogness@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240402221129.2613843-8-john.ogness@linutronix.de> On Wed 2024-04-03 00:17:09, John Ogness wrote: > Depending on if an nbcon console is registered, a driver may > handle its internal locking differently. If a driver is holding > its internal lock while the nbcon console is registered, there > may be a risk that two different contexts access the hardware > simultaneously without synchronization. (For example, if the > printk subsystem invokes atomic printing while another driver > context acquired the internal lock without considering the > atomic console.) > > Use the driver synchronization while a registering nbcon console > transitions to being registered. This guarantees that if the > driver acquires its internal lock when the nbcon console was not > registered, it will remain unregistered until that context > releases the lock. > > Signed-off-by: John Ogness Looks reasonable: Reviewed-by: Petr Mladek Note: The printk kthread integration is not part of this patchset. I see in linux-rt-devel that nbcon_kthread_func() emits a pending record under con->driver_lock(). This is a solution to prevent a race with the driver lock. IMHO, it is not strictly necessary to take the driver_lock() in the kthread. Instead, it would be enough to make sure that the kthread is running only when the device driver is properly registered as the console driver. Well, we should probably discuss this in the patchset introducing the kthread. Best Regards, Petr