Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp281216lqn; Fri, 12 Apr 2024 00:48:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWCAoxatonOzSQ7yEBPfY9ETSRRT9Gq1AH4fgQzA4FFQpSpUN8YKhFdDk0mJrKE4QTJ6XqJDScEPwRYCKR3IcjlExB2+CGSULGkBa4xnA== X-Google-Smtp-Source: AGHT+IFEkU/HLl4E0C8tmsODddNiCI/R5Jd8ONHc1iZRkOVduHJc5V69jblONtlok/n7yV4mdBRb X-Received: by 2002:a05:6e02:144f:b0:36a:3a8d:673e with SMTP id p15-20020a056e02144f00b0036a3a8d673emr2385030ilo.0.1712908108317; Fri, 12 Apr 2024 00:48:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712908108; cv=pass; d=google.com; s=arc-20160816; b=J8J216a6H21UDa5ewacG+SphsvM7RVz/lrAPsnlouVpaKhkRLiMgem1LGhiM4wvGbq qBEmUfTQLZiU2C4kPhvBZZDf7Og9+qMwftUqFG+ZFUf3+ACUOTulegpbpMoHgOpYZdeP X74ByzxXuIfCp3bSIuBv8zlcmD3l1ftsmwDqgrwQi4OH3Cq09+vgjBjboEeqz8AC+BM9 N8uDLgbOl+idmWyGsOEtkTEG59nKNnKpazz6Zozf9wfLb8HzRiWAgOB1/ZFQQpzgEaM5 4PnPJaW34qVbUL2iC7bVGcoC4Bl1Q4mol/PaLkMG/J+7BYF/x39bmcewvr0C+Lys502y MS3Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:cc:to:from:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:references:in-reply-to:message-id:date; bh=DZHeMuFP55VyLgcMvDL4jb6ALntKOohFw04ixzqkuj4=; fh=30IucGZHj4fAzK0mmdw2blDDdXas7wVuHYEEp7uFAIw=; b=O0AbsVIvVNsm0+GiHNIe6GoKdS8Byd4iePwtCBHCA+HtwSeNOKNjAwB9I1euXoR04p sEb1hjpKOOvhCAcxU1s0QTEU2yGrZB4H5ZlLDF7MLNyPV2cAxOnx1tG3/7BWj5ZbDSZq K8IWOU1PbM5ptXCweQN3AevVcpD6xOsfkmw72zjj8+qE5mEOd5RrkFix5kg5xED0fjaI Pb6fAXBYMZueHvuvL/KOp7XUCQ7NPcN2Tte+dvluq+p8a1ZGNierYpoTkOWSU3s96+xs 7qzN57isyorMR20y1VhSOWcyaTuQZUAgdg0p2LqssvHW+OzAfhrJDG5XOyZjfvdonZl8 EuMA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=zte.com.cn dmarc=pass fromdomain=zte.com.cn); spf=pass (google.com: domain of linux-kernel+bounces-142175-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142175-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id o18-20020a634e52000000b005f41ecd9987si2687665pgl.823.2024.04.12.00.48.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:48:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142175-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; arc=pass (i=1 spf=pass spfdomain=zte.com.cn dmarc=pass fromdomain=zte.com.cn); spf=pass (google.com: domain of linux-kernel+bounces-142175-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142175-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn 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 F0359283E8E for ; Fri, 12 Apr 2024 07:48:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 187964D595; Fri, 12 Apr 2024 07:48:23 +0000 (UTC) Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 290FA482DA for ; Fri, 12 Apr 2024 07:48:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=63.216.63.40 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712908102; cv=none; b=KceSNnhkrgXEmt204gzgp/9MB8HyQlA/WfQOuMKo31J8Ek75qwsyJmzOT1yxJZlcmTIyb21y/siw5uTHiIw27yGFcb8jBfNnNSlS9NfDio16351UrtEZAt/zsTKLHL+Sl7VzjUGAEhkbJVc1bAdOGzIx4AvWLcdY9N6BPLDO0dk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712908102; c=relaxed/simple; bh=B1uQVK0k0DZBtuOYjQrE7vq5W6eOZW3yvRW1Nld4Vsg=; h=Date:Message-ID:In-Reply-To:References:Mime-Version:From:To:Cc: Subject:Content-Type; b=XdnN4I9q5LASUZCznIQ8MPrC6vfImzRsuGiiUJ6SMVuNXz/vxH2L4sLrVAB/rPLPE+6g/a6BvwY4u3io3ccVLrJGi1lJAsN8fK8gMf7puLOUt7dsy8PBPhMzYnid9pO2N4XWY9gEJL4cguZhZPtoKsrzVNOWD4kA7F+E8LbC2/U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zte.com.cn; spf=pass smtp.mailfrom=zte.com.cn; arc=none smtp.client-ip=63.216.63.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zte.com.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zte.com.cn Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4VG7wL0YBBz8XrRK; Fri, 12 Apr 2024 15:48:18 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.99.176]) by mse-fl1.zte.com.cn with SMTP id 43C7m3bH093870; Fri, 12 Apr 2024 15:48:03 +0800 (+08) (envelope-from li.hao40@zte.com.cn) Received: from mapi (xaxapp01[null]) by mapi (Zmail) with MAPI id mid31; Fri, 12 Apr 2024 15:48:06 +0800 (CST) Date: Fri, 12 Apr 2024 15:48:06 +0800 (CST) X-Zmail-TransId: 2af96618e73623d-204a2 X-Mailer: Zmail v1.0 Message-ID: <20240412154806397beb4yGovKASnUXpyoxUJu@zte.com.cn> In-Reply-To: <75dff5cd-7b0e-4039-9157-8bf10cf7ba29@kernel.org> References: 20240412113848167egmP7kBg1Qm5sxfwGALG-@zte.com.cn,75dff5cd-7b0e-4039-9157-8bf10cf7ba29@kernel.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 From: To: Cc: , , Subject: =?UTF-8?B?UmU6IFJlOiBbUEFUQ0hdIHR0eTogaHZjOiB3YWtldXAgaHZjIGNvbnNvbGUgaW1tZWRpYXRlbHkgd2hlbiBuZWVkZWQ=?= Content-Type: text/plain; charset="UTF-8" X-MAIL:mse-fl1.zte.com.cn 43C7m3bH093870 X-Fangmail-Gw-Spam-Type: 0 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6618E742.000/4VG7wL0YBBz8XrRK > On 12. 04. 24, 5:38, li.hao40@zte.com.cn wrote: > > From: Li Hao > > > > Cancel the do_wakeup flag in hvc_struct, and change it to immediately > > wake up tty when hp->n_outbuf is 0 in hvc_push(). > > > > When we receive a key input character, the interrupt handling function > > hvc_handle_interrupt() will be executed, and the echo thread > > flush_to_ldisc() will be added to the queue. > > > > If the user is currently using tcsetattr(), a hang may occur. tcsetattr() > > enters kernel and waits for hp->n_outbuf to become 0 via > > tty_wait_until_sent(). If the echo thread finishes executing before > > reaching tty_wait_until_sent (for example, put_chars() takes too long), > > it will cause while meeting the wakeup condition (hp->do_wakeup = 1), > > tty_wait_until_sent() cannot be woken up (missed the tty_wakeup() of > > this round's tty_poll). Unless the next key input character comes, > > hvc_poll will be executed, and tty_wakeup() will be performed through > > the do_wakeup flag. > > > > Signed-off-by: Li Hao > > --- > > drivers/tty/hvc/hvc_console.c | 12 +++++------- > > drivers/tty/hvc/hvc_console.h | 1 - > > 2 files changed, 5 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c > > index cd1f657f7..2fa90d938 100644 > > --- a/drivers/tty/hvc/hvc_console.c > > +++ b/drivers/tty/hvc/hvc_console.c > > @@ -476,11 +476,13 @@ static void hvc_hangup(struct tty_struct *tty) > > static int hvc_push(struct hvc_struct *hp) > > { > > int n; > > + struct tty_struct *tty; > > > > n = hp->ops->put_chars(hp->vtermno, hp->outbuf, hp->n_outbuf); > > + tty = tty_port_tty_get(&hp->port); > > if (n <= 0) { > > if (n == 0 || n == -EAGAIN) { > > - hp->do_wakeup = 1; > > + tty_wakeup(tty); > > What if tty is NULL? Did you intent to use tty_port_tty_wakeup() instead? > > thanks, > -- > js > suse labs Thank you for your prompt reply. tty_port_tty_wakeup() is better, it no longer check if tty is NULL in hvc_push() Li Hao