From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 953A11FBC86 for ; Fri, 3 Jan 2025 15:30:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735918209; cv=none; b=bWMCvaIzdhJn7HfhbM/jpGtMxzhlogx46IimMrpf1YVPFJeN4D/Ai02uVzaka0UVztE3JIJXmH/UOHTWRfBPKGdSE7+XQRZkD4tNbHOxujcnwTElLatxkYqqGS4vey4X9J1dqYgODk93vWGEHIYoIgmDCnTkUZzmtm04AbzSGk8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735918209; c=relaxed/simple; bh=Qqcj0OUvhvzwX8pQNRhvvaozpW4SpClzd3s6PmyvN8M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=M2wn8747LPulUE1aSU2n4dxEq3x0WR4ZjtKe6DCN5ReyxQor6SbJk2kCAYcwt/91evUJQdJZIrLOQ3peNAKjjPGLtFQR1BMjeok54h6AyLsdcOzEa7y9QJPrreMwAsr7IcKjUB0VxU2jjhBlUnzuRNtLb8LPBS5kdY6J0046n9E= 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=N9jBhNUe; arc=none smtp.client-ip=209.85.221.47 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="N9jBhNUe" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-385df53e559so9729017f8f.3 for ; Fri, 03 Jan 2025 07:30:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1735918204; x=1736523004; 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=ice7cYRdFs+QLoHiO93smnTaXPt65ioMoXGDDatRNI4=; b=N9jBhNUe0FayS9tfP15EBhAyd0detxGPw5RXJ6pO8dlSfqKAZX2Vg3aZsl/NaVi+qm CAdoUA8aGgtFRx0n+QQv6AYHaikdEhElg/6NcmL1O/fIs2yOjEFdAHJGpZuVGQUxL2an ion31lFwtz/52CxzqE/rutluI3DEwIUzUGJG0PYg+XgcaXYv3lwwpkRyNQwvz0hMZol0 KB966DutOkaLuYzg8JrKTSsiTPMY9ytQjdJ3gRu5p1EcHjrjQrFrqpJkuSjh+MPbcHPQ x93Nst5au2sMam0ALxF8UQwJWmn1nt3olIDYTJoYwzH/6xJCJVtdAPwxmhOhvP590zOt k6qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735918204; x=1736523004; 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=ice7cYRdFs+QLoHiO93smnTaXPt65ioMoXGDDatRNI4=; b=QrdNsu2igW2QvDx1jE/+0bYDgSD4Ckf+4glQg2sKmX9T9ZAJ3QsTTKIam62sDVV885 QQB9inK5ysU492bl+93KziC0atq3uQPeweG6POkZ+7kSA83/xdSiclYyXT+pqiptfhhz e3BIi09yKSW8AoMfduNWfp7xvgv5EdIrS8bfQw5XW6vSFEam9EGo+qNwS9yJ3auULb1F UxHwHY7/SjYVliHcfhYEYTJkPdw5wjEO0St7pV18T72Q2+mK+kslKD62sG0K6VJm5usj EK55SNB4YkOM+xVw7QyyHZxpuw2MDbT+lbx+sO2HxIWwbailpWYN3aA4bhrbOzDlXK25 rc9A== X-Forwarded-Encrypted: i=1; AJvYcCV14DuIPtt/V2Gu0PX2B02rp6CgedDlOT/AvYpTzbujv7hqtp2dwbK6nXns19F5QE/gtcitD3IbaHnFRSw=@vger.kernel.org X-Gm-Message-State: AOJu0YwjOWeT6y/FCp3LJtUafzGv0fL37wqWISnubIAWyYoWMEmgcDXU FIQ0V5aMYYQ97nZw2GTrqDOeGY8GYuw/r0tTva2Ffi7B7ZwImopn0XQbyrnlBQ4= X-Gm-Gg: ASbGncvDu8tCQALQJK7p6b3ieMQmCgK8s0/Glp+38sX41h7nF25fOz/tdHjgvJIN88j jMsJurTQifYmUjs+KQ2HJs8FIeDm9QHcJEfJ7AspHU7RtW9PEPK04v09slOrQ5Vr6AC3zUf+vPo MnWsXvVJFtnRTDlG+gSo5mXtqdYG4PMP3uXcIWADQXzErLF9abrj/riv8YkCqKXhdolOuGw64Be 3p4dYOZgCsjyIMLuwSHmDRLQAfoHV698aaV86+Ly1ro11BYaCSh8EBgHw== X-Google-Smtp-Source: AGHT+IH6JmsUHg85TdAQhpQucHKqxoNFRbNhm5zR5E1P6rwqwaNo/Q6VArzNm4hYKNojN140/QcgDQ== X-Received: by 2002:a5d:6da1:0:b0:385:e5d8:2bea with SMTP id ffacd0b85a97d-38a221fa065mr40145822f8f.20.1735918204519; Fri, 03 Jan 2025 07:30:04 -0800 (PST) Received: from pathway.suse.cz ([176.114.240.50]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c89e1a1sm40462019f8f.69.2025.01.03.07.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 07:30:03 -0800 (PST) Date: Fri, 3 Jan 2025 16:30:00 +0100 From: Petr Mladek To: John Ogness Cc: Greg Kroah-Hartman , Jiri Slaby , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , Esben Haabendal , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , Andy Shevchenko , Arnd Bergmann , Sunil V L , Matt Turner , Stefan Wahren , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Kevin Hilman , Markus Schneider-Pargmann , Udit Kumar , Griffin Kroah-Hartman , Niklas Schnelle , Serge Semin , linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH tty-next v4 4/6] serial: 8250: Provide flag for IER toggling for RS485 Message-ID: References: <20241227224523.28131-1-john.ogness@linutronix.de> <20241227224523.28131-5-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: <20241227224523.28131-5-john.ogness@linutronix.de> On Fri 2024-12-27 23:51:20, John Ogness wrote: > For RS485 mode, if SER_RS485_RX_DURING_TX is not available, the > console ->write() callback needs to enable/disable Tx. It does > this by calling the ->rs485_start_tx() and ->rs485_stop_tx() > callbacks. However, some of these callbacks also disable/enable > interrupts and makes power management calls. This causes 2 > problems for console writing: > > 1. A console write can occur in contexts that are illegal for > pm_runtime_*(). It is not even necessary for console writing > to use pm_runtime_*() because a console already does this in > serial8250_console_setup() and serial8250_console_exit(). > > 2. The console ->write() callback already handles > disabling/enabling the interrupts by properly restoring the > previous IER value. I was a bit confused by the description of the 2nd problem. It is not clear whether it actually is a problem. My understanding is that the nested IER manipulation does not harm. And it is not needed at the same time. As a result, the related pr_runtime_*() calls are not needed either. So this is 2nd reason why the problematic pr_runtime_*() calls can be removed in the serial8250_console_write() code path. > Add an argument @toggle_ier to the ->rs485_start_tx() and > ->rs485_stop_tx() callbacks to specify if they may disable/enable > receive interrupts while using pm_runtime_*(). Console writing > will not allow the toggling. > > For all call sites other than console writing there is no > functional change. > > Signed-off-by: John Ogness It seems that the patch does what is says. I'll try to describe it using my words to explain how I understand it. IMHO, the main motivation is to prevent calling pm_runtime_*() in serial8250_console_write(). It is not safe in some contexts, especially in NMI. And it is not needed from two reasons: 1. The console->write() callback is used only by registered consoles. And the pm_runtime usage counter is already bumped during the console registration by serial8250_console_setup(). 2. The pm_runtime_*() calls are used in the following code path + serial8250_console_write() + up->rs485_start_tx() + serial8250_em485_start_tx() + serial8250_stop_rx() This code is not needed because serial8250_console_write() always clears IER by __serial8250_clear_IER(up) anyway. In fact, the extra IER manipulation in serial8250_em485_start_tx() might be seen as a bug. Well, it is a NOP. All in all, the patch looks good to me. Reviewed-by: Petr Mladek Best Regards, Petr