Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5490764rwb; Tue, 22 Nov 2022 00:15:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf4OHHrBOR3Tmt6uoQl71KTKHGBs7NvLfo0L9IqWlxguuc+Kq2Iij/IfE4pGWfu82oII1pIk X-Received: by 2002:a05:6402:3205:b0:467:3015:ad42 with SMTP id g5-20020a056402320500b004673015ad42mr3081262eda.259.1669104921935; Tue, 22 Nov 2022 00:15:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669104921; cv=none; d=google.com; s=arc-20160816; b=taZMWLu4xJs9dGBuDcv/m+SAs5PPlC8in8yfnH0Svfiy/RpuvS2ONH052eDWMY3mnN mHgiVGJ7Y30hospa9WCgaqK43cOCzHFyKK7Z3gatm6Rdo7dn558N3NUMYMDfb0qiUj3N +IOCaMHF953yVsM25TNR1LSwKJU1vGGBfS2msYeo6+nAVIm0b7CZmqwWEAnqy+Ygsgtm 1+57s9xybfPWKXtbPfKMORez+MRHg3X5V4ej5Kygqmi1hiqlbFWcCEpSce0nfcl9q8tm kN6HI2+4hpLUW5WQDsDw4GjHRXolbQ7IRBd4pCgoKGcD6BIREMNrpydILTF1uVFVaXjs 4u9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=xslK4TJ5lzZn3rrEbVLf4tuQt9CQu1qn6KfjRbgvDi4=; b=R4x2LA+I40fazbCzZV8RuPMUBQ8OxpZCwdklHUmMyh5GUvAsfoKRj5usVe0BPSPVf2 dD/XIws6b4w4+Aflwf2GzaGvubOxIjmdo0KJadtVPQLC9ETROpukFUvtfVh4jiqxptn7 C20Hw3WnjkJ8CZ77Ta9q6qZrTEsJkxRT0UxYLh51Q4vLDi3R4lW8Dp4g9JQ5Xhr+fB+h N5Uw4SEU1GFgEE3Vn7TC0SChrD74SCwI0NVqK2nkCvcNsCkuaKDQpUaewumYB840GgsN YNEItAAus2SO0yF/+4ZyhuKdikAbUe5yjtVFWj1DDXPz2kACvjArl6dp9bLocPMr933e UJIQ== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb13-20020a1709077e8d00b007ad9f041c3bsi27507ejc.27.2022.11.22.00.14.58; Tue, 22 Nov 2022 00:15:21 -0800 (PST) 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232547AbiKVHo4 (ORCPT + 92 others); Tue, 22 Nov 2022 02:44:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232598AbiKVHoi (ORCPT ); Tue, 22 Nov 2022 02:44:38 -0500 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B7E432B8A; Mon, 21 Nov 2022 23:44:16 -0800 (PST) Received: by mail-ed1-f45.google.com with SMTP id z18so19435695edb.9; Mon, 21 Nov 2022 23:44:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xslK4TJ5lzZn3rrEbVLf4tuQt9CQu1qn6KfjRbgvDi4=; b=pxZouPYiKmwu4E3IxUVgmKsEDrJ8ySlvd23drAdd3OBUjZjqMJDRbMoeUCltGAtkmZ tjJ6ruGPzm/VQ/zIIr6BP7dz3okvObZ54lTEScvFPPezGNqrzzNqp4bTuwalY+en8H9V GVyaqwVqPOgc6y4pPywNuIU8KSJoBPlbofyRazwdJReuFJAhE/Lia2U+1R69SjHSqac6 g/IDigfM81RpIhQCqVkj/4fmjOuUvD9d/xO6no0JBPnINjZxFNwZ1nEmP/VeMqNNC9J0 1xz8oMcaGbmEsXKgQjPWu6nXmfc+OOcmNxWjN98oP3dgjuq+3IY44hSq0qXi8XvEJCBJ McRQ== X-Gm-Message-State: ANoB5pm/T+5TE5s0s45NzNvoMRoVY2R/9F4jIrmtOHZXMDhX8E0Xqibe G3khY+/7wVpsaG3RkuvomkE0o7tHON2UBA== X-Received: by 2002:a05:6402:520b:b0:464:718c:b271 with SMTP id s11-20020a056402520b00b00464718cb271mr3639808edd.287.1669103055417; Mon, 21 Nov 2022 23:44:15 -0800 (PST) Received: from ?IPV6:2a0b:e7c0:0:107::aaaa:49? ([2a0b:e7c0:0:107::aaaa:49]) by smtp.gmail.com with ESMTPSA id fe4-20020a056402390400b0046856c307d0sm6084847edb.5.2022.11.21.23.44.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Nov 2022 23:44:15 -0800 (PST) Message-ID: <8dd90e39-087e-984c-c289-dbfa766359a8@kernel.org> Date: Tue, 22 Nov 2022 08:44:12 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH v5 12/14] serial: liteuart: add IRQ support for the RX path Content-Language: en-US To: "Gabriel L. Somlo" Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, kgugala@antmicro.com, mholenko@antmicro.com, joel@jms.id.au, david.abdurachmanov@gmail.com, florent@enjoy-digital.fr, geert@linux-m68k.org, ilpo.jarvinen@linux.intel.com References: <20221118145512.509950-1-gsomlo@gmail.com> <20221118145512.509950-13-gsomlo@gmail.com> From: Jiri Slaby In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS 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 On 21. 11. 22, 19:50, Gabriel L. Somlo wrote: >>> static void liteuart_timer(struct timer_list *t) >>> { >>> struct liteuart_port *uart = from_timer(uart, t, timer); >>> struct uart_port *port = &uart->port; >>> - liteuart_rx_chars(port); >>> - >>> + liteuart_interrupt(0, port); >> >> Are you sure spin_lock() is safe from this path? I assume so, but have you >> thought about it? > > I checked and at that point `in_serving_softirq()` is true. > > *However*, after studying spin_lock() and friends for a while, I'm > not quite clear on whether that unequivocally translates > to "yes, we're safe" :) Depends whether some hard irq context is grabbing the port lock too. If it does, it will spin forever waiting for this soft irq to finish (never happens as it was interrupted). > As such, I'm inclined to switch to `spin_lock_irqsave()` and > `spin_unlock_irqrestore()` even in the interrupt handler, which is > explicitly stated to be "safe from any context": > https://www.kernel.org/doc/html/v4.15/kernel-hacking/locking.html#cheat-sheet-for-locking > The alternative could be to set `TIMER_IRQSAFE` in `timer_setup()`, > but no other tty driver seems to be doing that, so I'd be a bit off > the beaten path there... :) Ah, no. > Please do let me know what you think about this, particularly if you > consider going the spin_lock_irqsave-everywhere-just-to-be-safe route > overkill... :) If you are unsure about the other contexts, irqsave/restore is the way to go. It can be lifted later, if someone investigates harder. thanks, -- js