From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 011CBCA9ED5 for ; Mon, 12 Oct 2026 06:46:40 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4j37Kq4Kjnz2yPR; Mon, 12 Oct 2026 17:46:39 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2600:3c0a:e001:78e:0:1991:8:25" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1791787599; cv=none; b=KaXXgxqLlOyMc8BCRV5mrM80qy6yhVKZRcciLmLUp8Yax4T3J/5GPsL7+rCROsXBlSzeq5kuQ+/EFYp8mZKrZ8Sl3s2rGiDmgdX5wmWJU5ccgRQnS2xyoKPl9/ulvSVvQYlibxhQHxzhntvp/r6VBHKkk61RSxpIAH6ohOaAB8cWSqE0Q5rJw31bZy+T7pRtge3Gjsc2HlMJBRDkXIIhUJh1SSeElu0/JMB0NvWQfweEyG1/51p8wbytkUfSzxm4ikO3eCw/KR9ofXW4mnlS5eb0UDjw/xCLR9lxWf8UPu3IYFMZcyr0poWcOWnVCBXBNtOJbUcZxIh7lX4bVg9Jpw== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1791787599; c=relaxed/relaxed; bh=1er6KN0USDluOlCwl7bI7udanJGh8XBrVh6eYmX9B2E=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=KfWxQ5StHmjzsUKwmyeWGoW3axc3oW1jS2HNnQi1cnlnZ6Kp5KOmzIprnyaKCP65b4i/7q/lLPDMSL23NezFx0DvKVlqQXszxbWg4xVINZ4KVhtA7Re7OTctUpZiNajL3c+4/Cmw15mlri9Ke89yVwhTYja22hEjxlKrLmpRpsTRTwMuZBs/LEjmkH50GZ2GWNkclYHdN4q8ahLGnOFCQDHq2v49HlzpQvWf38NRzskaQTPk5TmhCz7jLcE8SErTNDs85x3unedZ5jvFh+USm9rt3L0oD9a9NSluz2Le8Kdy4/nKwV3xe7G6pjoKddi3rwI62Jt/2y29RAi8PpNK8g== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mP4GUgGY; dkim-atps=neutral; spf=pass (client-ip=2600:3c0a:e001:78e:0:1991:8:25; helo=sea.source.kernel.org; envelope-from=jirislaby@kernel.org; receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mP4GUgGY; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=2600:3c0a:e001:78e:0:1991:8:25; helo=sea.source.kernel.org; envelope-from=jirislaby@kernel.org; receiver=lists.ozlabs.org) Received: from sea.source.kernel.org (sea.source.kernel.org [IPv6:2600:3c0a:e001:78e:0:1991:8:25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4j37Kp4NdJz2xwZ for ; Mon, 12 Oct 2026 17:46:38 +1100 (AEDT) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 30E3F41F97; Mon, 12 Oct 2026 06:46:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E65741F008A1; Mon, 12 Oct 2026 06:46:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1791787595; bh=1er6KN0USDluOlCwl7bI7udanJGh8XBrVh6eYmX9B2E=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=mP4GUgGYNCxnuPmvg1lujMqLPA7vMvng2SS0pBMHoCRbwwxluGZ1CHCAITsQFxIwd x7wKsblnmPblKZwTGS63Z/VPkeuzGjAUyGwhVXZx5K7K7unAzwoOLZVUFY+nkDURjW X0PNZL/iyeF9Cmy/UiMXAC9LcPt+sCJ2zDtDxDVofUzZDrWFH4BbiVCkN31UXOkwew 7cFyBQv7+jpMiLRzknsZ4/q2Gv1tg6cM3zuY9oI8TvIJk3SVGG9xD3lPxaYZfAFa/o FSMhNavBKkxYI/LnLbQ/SDmexIWtlzK0PhS9vRqFDnFRDwv0wP34GrPxp+Iu/3/Ysz nTnGWliycn2uQ== Message-ID: <1f66c850-faa7-477f-9535-761074ccc077@kernel.org> Date: Mon, 12 Oct 2026 08:46:30 +0200 X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 6/6] hvc: add an M3000 firmware console backend To: Magnus Lindholm , davem@davemloft.net, andreas@gaisler.com, sparclinux@vger.kernel.org Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, linux-serial@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, krzk@kernel.org, oleg@redhat.com References: <20261011195729.981243-1-linmag7@gmail.com> <20261011195729.981243-7-linmag7@gmail.com> Content-Language: en-US From: Jiri Slaby Autocrypt: addr=jirislaby@kernel.org; keydata= xsFNB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EmxyUNBHHnBKHQxz 1j+mzH0HjZZtXjGu2KLJ18G07q0fpz2ZPk2D53Ww39VNI/J9ABEBAAHCwV8EGAECAAkFAk6S 54YCGwwACgkQvSWxBAa0cEk3tRAAgO+DFpbyIa4RlnfpcW17AfnpZi9VR5+zr496n2jH/1ld wRO/S+QNSA8qdABqMb9WI4BNaoANgcg0AS429Mq0taaWKkAjkkGAT7mD1Q5PiLr06Y/+Kzdr 90eUVneqM2TUQQbK+Kh7JwmGVrRGNqQrDk+gRNvKnGwFNeTkTKtJ0P8jYd7P1gZb9Fwj9YLx jhn/sVIhNmEBLBoI7PL+9fbILqJPHgAwW35rpnq4f/EYTykbk1sa13Tav6btJ+4QOgbcezWI wZ5w/JVfEJW9JXp3BFAVzRQ5nVrrLDAJZ8Y5ioWcm99JtSIIxXxt9FJaGc1Bgsi5K/+dyTKL wLMJgiBzbVx8G+fCJJ9YtlNOPWhbKPlrQ8+AY52Aagi9WNhe6XfJdh5g6ptiOILm330mkR4g W6nEgZVyIyTq3ekOuruftWL99qpP5zi+eNrMmLRQx9iecDNgFr342R9bTDlb1TLuRb+/tJ98 f/bIWIr0cqQmqQ33FgRhrG1+Xml6UXyJ2jExmlO8JljuOGeXYh6ZkIEyzqzffzBLXZCujlYQ DFXpyMNVJ2ZwPmX2mWEoYuaBU0JN7wM+/zWgOf2zRwhEuD3A2cO2PxoiIfyUEfB9SSmffaK/ S4xXoB6wvGENZ85Hg37C7WDNdaAt6Xh2uQIly5grkgvWppkNy4ZHxE+jeNsU7tg= In-Reply-To: <20261011195729.981243-7-linmag7@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11. 10. 26, 21:55, Magnus Lindholm wrote: ... > --- /dev/null > +++ b/drivers/tty/hvc/hvc_m3000.c > @@ -0,0 +1,205 @@ > +struct m3000_console { > + int stdin; > + bool ready; > + u8 buffer[256]; > + raw_spinlock_t buffer_lock; > + struct timer_list poll_timer; > + struct mutex poll_mutex; /* Serialize open against synchronous close. */ > + spinlock_t poll_lock; /* Protect active state and timer rearming. */ > + bool poll_active; Perhaps group these a bit better, so that there are not such holes? > +}; ... > +/* > + * HVC's idle backoff can exceed the firmware input FIFO's capacity. > + * Wake its worker each tick while open; keep PROM calls out of the timer. > + */ > +static void m3000_poll_tick(struct timer_list *timer) > +{ > + struct m3000_console *con = timer_container_of(con, timer, poll_timer); > + unsigned long flags; > + > + spin_lock_irqsave(&con->poll_lock, flags); Any reason not to use guard()s? > + if (con->poll_active) { > + hvc_kick(); > + mod_timer(&con->poll_timer, jiffies + 1); > + } > + spin_unlock_irqrestore(&con->poll_lock, flags); > +} > + > +static int m3000_open(struct hvc_struct *hp, int data) > +{ > + struct m3000_console *con = m3000_console(hp->vtermno); > + unsigned long flags; > + > + if (!con) > + return -ENODEV; > + mutex_lock(&con->poll_mutex); > + spin_lock_irqsave(&con->poll_lock, flags); Same here. > + con->poll_active = true; > + mod_timer(&con->poll_timer, jiffies + 1); > + spin_unlock_irqrestore(&con->poll_lock, flags); > + mutex_unlock(&con->poll_mutex); > + return 0; > +} > + > +static void m3000_close(struct hvc_struct *hp, int data) > +{ > + struct m3000_console *con = m3000_console(hp->vtermno); > + unsigned long flags; > + > + if (!con) > + return; > + mutex_lock(&con->poll_mutex); > + spin_lock_irqsave(&con->poll_lock, flags); And here. > + con->poll_active = false; > + spin_unlock_irqrestore(&con->poll_lock, flags); > + /* Block reopen until the callback has finished and cannot rearm. */ > + timer_delete_sync(&con->poll_timer); > + mutex_unlock(&con->poll_mutex); > +} > + > +static ssize_t m3000_io(struct m3000_console *con, u8 *in, > + const u8 *out, size_t count) > +{ > + unsigned long args[7], flags; > + bool input = in; You can test "in" below directly, right? > + int ret; > + > + if (!count) > + return 0; > + count = min(count, input ? 1 : sizeof(con->buffer)); > + /* Console writes can run with interrupts disabled; this lock cannot sleep. */ > + raw_spin_lock_irqsave(&con->buffer_lock, flags); scoped_guard() > + if (!input) > + memcpy(con->buffer, out, count); > + args[0] = (unsigned long)(input ? "read" : "write"); > + args[1] = 3; > + args[2] = 1; > + args[3] = (unsigned int)(input ? con->stdin : prom_stdout); > + args[4] = (unsigned long)con->buffer; > + args[5] = count; > + args[6] = (unsigned long)-1; > + p1275_cmd_direct(args); > + ret = (int)args[6]; > + if (ret > 0 && ret <= count && input) > + memcpy(in, con->buffer, ret); > + raw_spin_unlock_irqrestore(&con->buffer_lock, flags); > + if (ret == -2 || ret == 0) That's full of magic constants. Can we have defines for those? > + return 0; > + if (ret < 0 || ret > count) > + return -EIO; > + return ret; thanks, -- js suse labs