From nobody Sat Feb 7 17:19:50 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 C19A21B966 for ; Fri, 16 Feb 2024 08:00:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708070428; cv=none; b=CdX0945px40GpcT6BGfG2GIeY7si7WZwEBNeNnYNm+eKFfMM9cPCWFXOC35io+c5wWMR7YwSrBHs51PuGhSnUhx0x4/uA56YjXbN+fILYR7EyBaiaxqmxSnoKwVOiG5/13SSh3aPWdD/f9Uhty29z/jZoAW0xEP5milxOGjgOQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708070428; c=relaxed/simple; bh=I7YQyvteIahvp42EiZA+1wJMmZSJKR2ugc165xDp9JA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dnw6qHnGze9x/vuyHwwZQr8s+BE5O8gAofGLcp8S6MNleGj/W9+QegQ7C2JXn31RE2Y9ji1D3UIQ2MS31Z5/qbTMqMNrhn2jtDW56UJ/UKyM7l0hTwze4TnXs8Ua+l+1QrCLFaTVciqaMDbFRwlT1pn/jrG1+OTYg9KSHrlx+Xw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DBE+Xc9t; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DBE+Xc9t" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708070424; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LC1bKFmWstjcuRp0NCZgXGUr7lDByzyZO+jUi4bsRIg=; b=DBE+Xc9tJl/0LeLAU81fPIj28BzWM1ii/y6wBbv4DwWcoXtvCZGEDhVTvP7eYtrQPZvXcm 6cTQXWriR/KdfVQrGY27/kxWmtGuoDZD8kP/QxrSZy50NCf7DiKeeTCeiu3ret5WUlQJdl Q3ob2rSwXumZjTCEyfMqLrEksd10hrc= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-245-FaZWLHlCNle43F5nURfdvg-1; Fri, 16 Feb 2024 03:00:21 -0500 X-MC-Unique: FaZWLHlCNle43F5nURfdvg-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-781d8e14fd8so229610385a.3 for ; Fri, 16 Feb 2024 00:00:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708070420; x=1708675220; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LC1bKFmWstjcuRp0NCZgXGUr7lDByzyZO+jUi4bsRIg=; b=Q9kj+fyAmwB+fzbr9FRKaCLXWN/lockWZvS6V35OdWQ2CJQV/jf+wZtIzGwpflYloI BMciXkj0iqoRW28F8gX8pIUfr0nFBgGOToh87t4KrxUmV8gPFfEbxtaHxDAwNmSSTYY2 jq/SWWlw72xmJjNBRDYnzKEzuJI7pav29rlnm1tAYr9kO2narBS2XVaCmhPuJx0xhqUb cuYsRKnaMVkjc7wc0fwKjHLkbmnUbR/iQJDD9K5HFwtWoDs+B4xDSC4QT4rrma5845Nl DS6nKKanvwTNjQjyJ+XhvlR+iPBVZjmB2mlvwkwbyspVMyA5V0vn4H+1uyHlPurhkUTn 0jrQ== X-Gm-Message-State: AOJu0YzhgiZslAMbBauRh6OtYpeLJO9X7/RomN9zIcV6nCKscRb+9eWV kVd2/xeCS9AnvNEqJiS1VrRBisCwMFlFdhFKOgcD1WYpUyZjDHG3l+JQk1iyAgxunMH1EZm2dcj BrlpFk1u6aSs/+BQZUvnN4XgWF8r/ZYsqvDXlbsC/VCndZEGz01M+oLEITh1g2Q== X-Received: by 2002:a05:620a:810:b0:787:28cb:5ab8 with SMTP id s16-20020a05620a081000b0078728cb5ab8mr4048020qks.41.1708070420521; Fri, 16 Feb 2024 00:00:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IEzZCXcZ+QKr/cGMalNAF5gKgIDpVXp4WPWqbLnkgifvRtX29FergWTakc9zo0gqPSZwxJx4Q== X-Received: by 2002:a05:620a:810:b0:787:28cb:5ab8 with SMTP id s16-20020a05620a081000b0078728cb5ab8mr4047996qks.41.1708070420262; Fri, 16 Feb 2024 00:00:20 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a800:4770:9d0:4bac:1782:4637]) by smtp.gmail.com with ESMTPSA id br37-20020a05620a462500b00787346f1edasm1300756qkb.54.2024.02.16.00.00.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 00:00:19 -0800 (PST) From: Leonardo Bras To: Greg Kroah-Hartman , Jiri Slaby , Thomas Gleixner , Tony Lindgren , Andy Shevchenko , John Ogness , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Leonardo Bras , Florian Fainelli , Shanker Donthineni Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [RFC PATCH v2 1/4] irq: Move spurious_deferred bit from BIT(31) to BIT(0) Date: Fri, 16 Feb 2024 04:59:43 -0300 Message-ID: <20240216075948.131372-3-leobras@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240216075948.131372-2-leobras@redhat.com> References: <20240216075948.131372-2-leobras@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Makes sure the threads_handled reserve a bit for that. This will be useful in the next patch in this series. Signed-off-by: Leonardo Bras --- include/linux/irqdesc.h | 9 +++++++++ kernel/irq/manage.c | 4 ++-- kernel/irq/spurious.c | 6 ++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h index d9451d456a733..62aff209315fe 100644 --- a/include/linux/irqdesc.h +++ b/include/linux/irqdesc.h @@ -251,4 +251,13 @@ irq_set_lockdep_class(unsigned int irq, struct lock_cl= ass_key *lock_class, __irq_set_lockdep_class(irq, lock_class, request_class); } =20 +#define SPURIOUS_DEFERRED (0x1) +#define SPURIOUS_DEFERRED_SHIFT (1) + +static inline void irq_add_handled(struct irq_desc *desc, int i) +{ + i <<=3D SPURIOUS_DEFERRED_SHIFT; + atomic_add(i, &desc->threads_handled); +} + #endif diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 1782f90cd8c6c..5bc609c7b728c 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1191,7 +1191,7 @@ irq_forced_thread_fn(struct irq_desc *desc, struct ir= qaction *action) local_irq_disable(); ret =3D action->thread_fn(action->irq, action->dev_id); if (ret =3D=3D IRQ_HANDLED) - atomic_inc(&desc->threads_handled); + irq_add_handled(desc, 1); =20 irq_finalize_oneshot(desc, action); if (!IS_ENABLED(CONFIG_PREEMPT_RT)) @@ -1212,7 +1212,7 @@ static irqreturn_t irq_thread_fn(struct irq_desc *des= c, =20 ret =3D action->thread_fn(action->irq, action->dev_id); if (ret =3D=3D IRQ_HANDLED) - atomic_inc(&desc->threads_handled); + irq_add_handled(desc, 1); =20 irq_finalize_oneshot(desc, action); return ret; diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c index 02b2daf074414..d92f33b2e31ee 100644 --- a/kernel/irq/spurious.c +++ b/kernel/irq/spurious.c @@ -267,8 +267,6 @@ try_misrouted_irq(unsigned int irq, struct irq_desc *de= sc, return action && (action->flags & IRQF_IRQPOLL); } =20 -#define SPURIOUS_DEFERRED 0x80000000 - void note_interrupt(struct irq_desc *desc, irqreturn_t action_ret) { unsigned int irq; @@ -312,7 +310,7 @@ void note_interrupt(struct irq_desc *desc, irqreturn_t = action_ret) if (action_ret =3D=3D IRQ_WAKE_THREAD) { int handled; /* - * We use bit 31 of thread_handled_last to + * We use bit 0 of thread_handled_last to * denote the deferred spurious detection * active. No locking necessary as * thread_handled_last is only accessed here @@ -328,7 +326,7 @@ void note_interrupt(struct irq_desc *desc, irqreturn_t = action_ret) * returned IRQ_HANDLED since the last * interrupt happened. * - * For simplicity we just set bit 31, as it is + * For simplicity we just set bit 0, as it is * set in threads_handled_last as well. So we * avoid extra masking. And we really do not * care about the high bits of the handled --=20 2.43.2 From nobody Sat Feb 7 17:19:50 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 658A01BC30 for ; Fri, 16 Feb 2024 08:00:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708070432; cv=none; b=fUdEcf5SMGeorYDshgt/DqdpNp6liXDD7u+XH1O3RZ9uu0QMIIYh7AXQyli42uGfMwYcVzvJreERZCTX3U6gP2zJ1ieBFbAd9UR2c+kakG0xOQvjLNUlH7DoXcToVYMFSF+VFV2VDucOgBceoF8Ywb0XmmcbZLVPDNgvTQZ74TU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708070432; c=relaxed/simple; bh=aEHy6hiozJg0zLqSV3cEv145/oODe8VbFXoxgPA/6rM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i69shDsMgbPU5mP6qxbVX95p+e/68U5unxT717HxMtOGwYzseZ4xvgBzh+sBq8o9CYEK2sNiwS0U9K2P0KMI1hhnbarRLi0xsfv+Jr6GFq3OY87Q6epXx2VbLBPBLoLrCfPfPuLGxGUBWELuCqaUmo9hp2Nz0yCKLw5oEEIB9BM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=M7qmMtQ9; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="M7qmMtQ9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708070429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d3/GSmZNXXq4OmuXU9kp4Oh7aTznSf//j0PB7MhvXcY=; b=M7qmMtQ9h/tVlim7Iu/AT12Rb4aU5Qv6Bv07d7JSYxEHOjQWImk1KdyemsAM3Uf34KZnDC H5EykllLMOWs0M1Z2AtoclS86MPd6AvWx/pfMh6SNh2ztNGGqEW1tr0ohxU+PxmDwr1nE8 ahuwyU16NmHIUFIfmyRVEJRECfyCTrw= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-96-_PLKMkuAOouGUMwm9pvHKg-1; Fri, 16 Feb 2024 03:00:23 -0500 X-MC-Unique: _PLKMkuAOouGUMwm9pvHKg-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-78732274d13so43725385a.1 for ; Fri, 16 Feb 2024 00:00:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708070423; x=1708675223; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d3/GSmZNXXq4OmuXU9kp4Oh7aTznSf//j0PB7MhvXcY=; b=Z2AQOAFAWTLkU/J5FLObcmmNsHRPbEfdnQwA24TlFEoHu3lco/Yw4VUYC/ujzpEisj +fcWTJjwszoS/7UatD5+E2MDNEMDEFcYQk7NmRiN3oN5a/SH++GNHxyiib0BdC8EPUp9 tRLfLiklZdtJR17z5/J1RxXoM0WT8/uRKOcpZBE+y1ZDMIrOx+xrtKgamfkwb9bF/Bfg lyRMRFU1c5FGOEigk5yBPoxq9vYJEc+kxgh6aepk4A0Ou40FvjyoO4mzjBchzKnQz2JS AEDOsjFjk57qMY4DaBNaSJzflOK0FbNmGh8mUN379hshS0BDwkarbbY/brjbw106OvEL Q+0A== X-Gm-Message-State: AOJu0YzAQLV2XlbKKeCx2ybHf90vZXTJuDE8h5+9gmFLuLNrmQrpdnSZ XWO5HQjTJDVShvMHLGfvK3Hv2w/OD06yGXoMlDRBO2cqOV9juXRI4qLb7HN+A7y0RY0lMfBkc4W R+/nn7bKDyOib4/5KM0oFuzHT1isGFPBNn/gASOjrXMaTXRIUC9kv2OEpm9W3EQ== X-Received: by 2002:a05:620a:20dc:b0:785:bd25:e5f7 with SMTP id f28-20020a05620a20dc00b00785bd25e5f7mr4327146qka.40.1708070423378; Fri, 16 Feb 2024 00:00:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IHDRyKi0XcKVQ1C8Z+dCIrgkoC1k7NPLTiBJp4VU065CynceYB7WcSQnoLO8F0WxfTXSA0FUQ== X-Received: by 2002:a05:620a:20dc:b0:785:bd25:e5f7 with SMTP id f28-20020a05620a20dc00b00785bd25e5f7mr4327129qka.40.1708070423128; Fri, 16 Feb 2024 00:00:23 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a800:4770:9d0:4bac:1782:4637]) by smtp.gmail.com with ESMTPSA id br37-20020a05620a462500b00787346f1edasm1300756qkb.54.2024.02.16.00.00.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 00:00:22 -0800 (PST) From: Leonardo Bras To: Greg Kroah-Hartman , Jiri Slaby , Thomas Gleixner , Tony Lindgren , Andy Shevchenko , John Ogness , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Leonardo Bras , Florian Fainelli , Shanker Donthineni Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [RFC PATCH v2 2/4] irq/spurious: Account for multiple handles in note_interrupt Date: Fri, 16 Feb 2024 04:59:44 -0300 Message-ID: <20240216075948.131372-4-leobras@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240216075948.131372-2-leobras@redhat.com> References: <20240216075948.131372-2-leobras@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently note_interrupt() will check threads_handled for changes and use it to mark an IRQ as handled, in order to avoid having a threaded interrupt to falsely trigger unhandled IRQ detection. This detection can still be falsely triggered if we have many IRQ handled accounted between each check of threads_handled, as those will be counted as a single one in the unhandled IRQ detection. In order to fix this, subtract from irqs_unhandled the number of IRQs handled since the last check (threads_handled_last - threads_handled). Signed-off-by: Leonardo Bras --- include/linux/irqdesc.h | 2 +- kernel/irq/spurious.c | 53 ++++++++++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h index 62aff209315fe..957ac02e9ec2b 100644 --- a/include/linux/irqdesc.h +++ b/include/linux/irqdesc.h @@ -67,7 +67,7 @@ struct irq_desc { unsigned long last_unhandled; /* Aging timer for unhandled count */ unsigned int irqs_unhandled; atomic_t threads_handled; - int threads_handled_last; + unsigned int threads_handled_last; raw_spinlock_t lock; struct cpumask *percpu_enabled; const struct cpumask *percpu_affinity; diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c index d92f33b2e31ee..4e8e2727b8beb 100644 --- a/kernel/irq/spurious.c +++ b/kernel/irq/spurious.c @@ -267,6 +267,28 @@ try_misrouted_irq(unsigned int irq, struct irq_desc *d= esc, return action && (action->flags & IRQF_IRQPOLL); } =20 +static inline int get_handled_diff(struct irq_desc *desc) +{ + unsigned int handled; + int diff; + + handled =3D (unsigned int)atomic_read(&desc->threads_handled); + handled |=3D SPURIOUS_DEFERRED; + + diff =3D handled - desc->threads_handled_last; + diff >>=3D SPURIOUS_DEFERRED_SHIFT; + + /* + * Note: We keep the SPURIOUS_DEFERRED bit set. We are handling the + * previous invocation right now. Keep it for the current one, so the + * next hardware interrupt will account for it. + */ + if (diff !=3D 0) + desc->threads_handled_last =3D handled; + + return diff; +} + void note_interrupt(struct irq_desc *desc, irqreturn_t action_ret) { unsigned int irq; @@ -308,7 +330,7 @@ void note_interrupt(struct irq_desc *desc, irqreturn_t = action_ret) * interrupt. */ if (action_ret =3D=3D IRQ_WAKE_THREAD) { - int handled; + int diff; /* * We use bit 0 of thread_handled_last to * denote the deferred spurious detection @@ -325,27 +347,20 @@ void note_interrupt(struct irq_desc *desc, irqreturn_= t action_ret) * Check whether one of the threaded handlers * returned IRQ_HANDLED since the last * interrupt happened. - * - * For simplicity we just set bit 0, as it is - * set in threads_handled_last as well. So we - * avoid extra masking. And we really do not - * care about the high bits of the handled - * count. We just care about the count being - * different than the one we saw before. */ - handled =3D atomic_read(&desc->threads_handled); - handled |=3D SPURIOUS_DEFERRED; - if (handled !=3D desc->threads_handled_last) { - action_ret =3D IRQ_HANDLED; + diff =3D get_handled_diff(desc); + if (diff > 0) { /* - * Note: We keep the SPURIOUS_DEFERRED - * bit set. We are handling the - * previous invocation right now. - * Keep it for the current one, so the - * next hardware interrupt will - * account for it. + * Subtract from irqs_unhandled the number of + * IRQs handled since the last change in + * threads_handled. */ - desc->threads_handled_last =3D handled; + if (diff < desc->irqs_unhandled) + desc->irqs_unhandled -=3D diff; + else + desc->irqs_unhandled =3D 0; + + action_ret =3D IRQ_HANDLED; } else { /* * None of the threaded handlers felt --=20 2.43.2 From nobody Sat Feb 7 17:19:50 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 EBA431BC39 for ; Fri, 16 Feb 2024 08:00:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708070432; cv=none; b=kY/26h06JAeNLEsmcLpo1cbUiuzgbLNTkKiD16xl4S4+O0XXsxZTqSN/U66UwlbMWfivdNGX72hi3ZTfxA2R+HlIoB1dIgH4EI3I5iq1IvC1hOy4f4tURF2pizlWFc8P34StkcpTjC3ID6OSFbhwApRSCNp0EVyHTQB/0g+3UUs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708070432; c=relaxed/simple; bh=Ap0hhSVhCcUi+ugheKg7fHGNULFldbyGXWaIBynCIwo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TYe9reLImW9Dyd0evJe3lDqq70fssn0Wa9B4456An2AQZfrWW6RI/YUdHL9u+UfI6aB19t9uAZTCO8Zy19emQynV2tX29Lk4v+MOz5kVM1BkYMwuAIqJ3DRiBd+TOWciYUDxDSQ/4wmLs9dMzgxLfC8vy6Yx7BLyUejyJg54nUU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=gMUWd2iW; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gMUWd2iW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708070429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lf9jFY+y8CayXQz2V+yS9ViGyyGoBfGEuY3heLM9Fu0=; b=gMUWd2iW71WYeAHeazHEo7DdiWwwCQwa7tMLQ0z7UsDbFzkaR+RbjO1nsoazHkZo7TmMZm uSdTCF4irKKjtMU/P8weT4ZZ4RJFKtDLgBFjbb8p1mL8BVWtmpgWewfwow2hllMmcAbFBZ M4AVfG830dPYPTRH+FX/4k2QMi7Ift0= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-68-3isx2fRgMLm3cMqidJZdYA-1; Fri, 16 Feb 2024 03:00:26 -0500 X-MC-Unique: 3isx2fRgMLm3cMqidJZdYA-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-7873fd60a11so97553185a.1 for ; Fri, 16 Feb 2024 00:00:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708070426; x=1708675226; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lf9jFY+y8CayXQz2V+yS9ViGyyGoBfGEuY3heLM9Fu0=; b=kwFSI7I035ox5ACIUsneSZ/WrvCFWtHlhQvaj8ZXou08lgJEwvZZ7eiwgMll59iXzY v7pZwi1YolbRRMXN/n+/lz2zf4joguqPqCghixHqYMpqPt3LDZJZpJEnaZmChZgLUaFb w1y5tx/QOJTdAsgNK9SHDUtjhDBQcOnRsfvgIR3JXUMrDz22yhxPLuJG9AYzNdafo7pj l7eEtSyz2P2Yxgl8/NO/+CoyQq8NGkIMyMzAEaNnRk8qIe1A8EWdd1EbzAYfpAH1GVN5 nhB8gMy1T9ZvofugwRg71zZrLY3Dk1P9UaG/Qxw0p2pE6pye1w78z0lZfZRdbdde6fk7 5PCg== X-Gm-Message-State: AOJu0YzpT1rfTM8Yju1eFPX1E6uwK/c+ozQjzcNRBB7PSlmUfc/HM+uO /9e5hOk7Ze7TMouviptmNr3NEpPjL/677IVK2VvFfvwR/aTmsmaFGEmHnWJBRt0Pg+7Y49dyWN2 LeVowWA/A6zAi2XRtG49QKWxzQbwhxgVLnIvH2uOrfE5U1UI21JLLY962MPZ7iQ== X-Received: by 2002:a05:620a:372a:b0:787:2d4a:e91 with SMTP id de42-20020a05620a372a00b007872d4a0e91mr12380860qkb.12.1708070426070; Fri, 16 Feb 2024 00:00:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IHLG7XvZtlTywNrtd9AYcJ1Px0bo2LO9DGLhh4nIJjj5II6F+o5xx7gYe26QguBGg3mPZZ7zA== X-Received: by 2002:a05:620a:372a:b0:787:2d4a:e91 with SMTP id de42-20020a05620a372a00b007872d4a0e91mr12380824qkb.12.1708070425766; Fri, 16 Feb 2024 00:00:25 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a800:4770:9d0:4bac:1782:4637]) by smtp.gmail.com with ESMTPSA id br37-20020a05620a462500b00787346f1edasm1300756qkb.54.2024.02.16.00.00.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 00:00:25 -0800 (PST) From: Leonardo Bras To: Greg Kroah-Hartman , Jiri Slaby , Thomas Gleixner , Tony Lindgren , Andy Shevchenko , John Ogness , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Leonardo Bras , Florian Fainelli , Shanker Donthineni Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [RFC PATCH v2 3/4] irq: Introduce IRQ_HANDLED_MANY Date: Fri, 16 Feb 2024 04:59:45 -0300 Message-ID: <20240216075948.131372-5-leobras@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240216075948.131372-2-leobras@redhat.com> References: <20240216075948.131372-2-leobras@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In threaded IRQs, some irq handlers are able to handle many requests at a single run, but this is only accounted as a single IRQ_HANDLED when increasing threads_handled. In order to fix this, introduce IRQ_HANDLED_MANY, so the returned value of those IRQ handlers are able to signal that many IRQs got handled at that run. Is scenarios where there is no need to keep track of IRQ handled, convert it back to IRQ_HANDLED. Signed-off-by: Leonardo Bras --- include/linux/irqreturn.h | 23 ++++++++++++++++++++++- kernel/irq/chip.c | 10 ++++++++-- kernel/irq/handle.c | 3 +++ kernel/irq/manage.c | 4 ++++ 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/include/linux/irqreturn.h b/include/linux/irqreturn.h index d426c7ad92bfd..204030696676c 100644 --- a/include/linux/irqreturn.h +++ b/include/linux/irqreturn.h @@ -7,14 +7,35 @@ * @IRQ_NONE: interrupt was not from this device or was not handled * @IRQ_HANDLED: interrupt was handled by this device * @IRQ_WAKE_THREAD: handler requests to wake the handler thread + * @IRQ_HANDLED_MANY: interrupt was handled by this device multiple times + * should be the only bit set in the first 3 bits, and + * carry a count > 1 in the next bits. */ enum irqreturn { IRQ_NONE =3D (0 << 0), IRQ_HANDLED =3D (1 << 0), IRQ_WAKE_THREAD =3D (1 << 1), + IRQ_HANDLED_MANY =3D (1 << 2), + IRQ_RETMASK =3D IRQ_HANDLED | IRQ_WAKE_THREAD | IRQ_HANDLED_MANY, }; =20 -typedef enum irqreturn irqreturn_t; +#define IRQ_HANDLED_MANY_SHIFT (3) + +typedef int irqreturn_t; #define IRQ_RETVAL(x) ((x) ? IRQ_HANDLED : IRQ_NONE) +#define IRQ_RETVAL_MANY(x) \ +({ \ + __typeof__(x) __x =3D (x); \ + irqreturn_t __ret; \ + if (__x =3D=3D 0) \ + __ret =3D IRQ_NONE; \ + else if (__x =3D=3D 1) \ + __ret =3D IRQ_HANDLED; \ + else \ + __ret =3D IRQ_HANDLED_MANY | (__x << IRQ_HANDLED_MANY_SHIFT); \ + __ret; \ +}) + +#define IRQ_HANDLED_MANY_GET(x) ((x) >> IRQ_HANDLED_MANY_SHIFT) =20 #endif diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index dc94e0bf2c940..233cf22a5b771 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -482,8 +482,14 @@ void handle_nested_irq(unsigned int irq) raw_spin_unlock_irq(&desc->lock); =20 action_ret =3D IRQ_NONE; - for_each_action_of_desc(desc, action) - action_ret |=3D action->thread_fn(action->irq, action->dev_id); + for_each_action_of_desc(desc, action) { + irqreturn_t ret =3D action->thread_fn(action->irq, action->dev_id); + + if ((ret & IRQ_RETMASK) =3D=3D IRQ_HANDLED_MANY) + ret =3D IRQ_HANDLED; + + action_ret |=3D ret; + } =20 if (!irq_settings_no_debug(desc)) note_interrupt(desc, action_ret); diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c index 9489f93b3db34..bfc6e3e43045a 100644 --- a/kernel/irq/handle.c +++ b/kernel/irq/handle.c @@ -162,6 +162,9 @@ irqreturn_t __handle_irq_event_percpu(struct irq_desc *= desc) irq, action->handler)) local_irq_disable(); =20 + if ((res & IRQ_RETMASK) =3D=3D IRQ_HANDLED_MANY) + res =3D IRQ_HANDLED; + switch (res) { case IRQ_WAKE_THREAD: /* diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 5bc609c7b728c..e684c7107ff90 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1192,6 +1192,8 @@ irq_forced_thread_fn(struct irq_desc *desc, struct ir= qaction *action) ret =3D action->thread_fn(action->irq, action->dev_id); if (ret =3D=3D IRQ_HANDLED) irq_add_handled(desc, 1); + else if ((ret & IRQ_RETMASK) =3D=3D IRQ_HANDLED_MANY) + irq_add_handled(desc, IRQ_HANDLED_MANY_GET(ret)); =20 irq_finalize_oneshot(desc, action); if (!IS_ENABLED(CONFIG_PREEMPT_RT)) @@ -1213,6 +1215,8 @@ static irqreturn_t irq_thread_fn(struct irq_desc *des= c, ret =3D action->thread_fn(action->irq, action->dev_id); if (ret =3D=3D IRQ_HANDLED) irq_add_handled(desc, 1); + else if ((ret & IRQ_RETMASK) =3D=3D IRQ_HANDLED_MANY) + irq_add_handled(desc, IRQ_HANDLED_MANY_GET(ret)); =20 irq_finalize_oneshot(desc, action); return ret; --=20 2.43.2 From nobody Sat Feb 7 17:19:50 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 40E921BC5E for ; Fri, 16 Feb 2024 08:00:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708070433; cv=none; b=I81MSrAJE2MzD9KPVR3uoa1xHLk+/5xhRMR5GZH0IfZH4Az20jM/ZzJAxwHuXEJ6Rc+KUEse7eKUlsuWAvgIgseJlQEWf5d4L5cfvFFUVdh6yw0S85lOJ0BgB1XXz69g/iaQ3WCx1CMYnXDkOcoJ1bv0+oS9tpZjQw/gT/qwU1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708070433; c=relaxed/simple; bh=DpW7fdG3PEtBSw4uHybL/y6wUJ0RIFhtQZUvi+EiDQI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iJusRGlNsDF7ZsAHjdEu2/nUO8ydR22ARxe8drFe2d/J7uMktudVhiK+lkzXQfFcFuDZ6qCHTzk5CpBytGpFueeNdXYPmZLmQtmMdAF4+3nDdURZ+xMOjCpqLhobFaxEqvHfResKBHVMH0Ju9OKDS61m6vrZ4zyHb9K/AiWNOVo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=RraAo3q5; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RraAo3q5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708070431; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bho+yn8M4kGUaS4UAXQ+fSY/db1hBVlHnbWifBhcoOQ=; b=RraAo3q5dyTB7UDfIRn+NPY26twP/+NfzQNQoOL7jVuF6W3eR7ZZr896GbEahfwks+nXH/ VeL2hjBoV1zNBturjEXnfZz2s6eTb2UUDLxLkiTFITz0IeYXsvA08yz1VVedQeyXK9XUVV iFU0iOj52V5hsoqQgfJ1mQhocwY2X/M= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-440-noXIOcegN7GhhCaugE67Mw-1; Fri, 16 Feb 2024 03:00:29 -0500 X-MC-Unique: noXIOcegN7GhhCaugE67Mw-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-785d3e4f98aso189429485a.1 for ; Fri, 16 Feb 2024 00:00:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708070429; x=1708675229; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bho+yn8M4kGUaS4UAXQ+fSY/db1hBVlHnbWifBhcoOQ=; b=nq5oWPgHEEdEdQPK6L19RAPXJsonPr9N8VnOxgYktr1h3+jz+GtuZUVa3/A+ijsOyy ZZckuQ0FjwTYIQETx46AAMCo7yTjib0FDAfwfLklrdjIu0uQ48ZTEMOA2NTiQmEb5EdJ Vc5MklfCyTYpWgaG+tG4Dex9UsI7X9Ju25t7j0ISslvSd9P5WZkioVe0rav5OG2mYW+T Jpzetf6PTRkLB4xanwo2xoR79r3v9Wy3EHEqJbBdV+IJ45zYq9raz1uMj+7qy6JcncI+ ab2UvZLpsWwvXI6eGfhYDG6OE2fL5SSAHQnkTC1tsycXlFmw/jZC1OMApS3ZbohxBbjv pUig== X-Gm-Message-State: AOJu0YzB5q7wsh0z6wx4Okn7hcwGC/R6salun8wX/SS/QgMZLN3nIe2D FMjqXy4kDxtTqa5AopTZs9ZePGsqLbVbKZ3wtam2tfZ9A1zCuONPuz8kaEehJeUpM/GO91XAFFZ 7ae12ld3YL5cBIfocPtQeXMkZ6vb1WP+AaSwBOqWVNSzkshfRdUY84gbUA3pcbw== X-Received: by 2002:a05:620a:564a:b0:785:ec1f:6aee with SMTP id vw10-20020a05620a564a00b00785ec1f6aeemr3631452qkn.27.1708070428744; Fri, 16 Feb 2024 00:00:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IHk5xfmE9icqXe3ltJz8nq6nkHMSdP3/86CuMkgc0dqcATRNh3NfMI3OUZi8MhWVBnCnizQ8w== X-Received: by 2002:a05:620a:564a:b0:785:ec1f:6aee with SMTP id vw10-20020a05620a564a00b00785ec1f6aeemr3631427qkn.27.1708070428387; Fri, 16 Feb 2024 00:00:28 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a800:4770:9d0:4bac:1782:4637]) by smtp.gmail.com with ESMTPSA id br37-20020a05620a462500b00787346f1edasm1300756qkb.54.2024.02.16.00.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 00:00:28 -0800 (PST) From: Leonardo Bras To: Greg Kroah-Hartman , Jiri Slaby , Thomas Gleixner , Tony Lindgren , Andy Shevchenko , John Ogness , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Leonardo Bras , Florian Fainelli , Shanker Donthineni Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [RFC PATCH v2 4/4] tty/serial8250: Make use of IRQ_HANDLED_MANY interface Date: Fri, 16 Feb 2024 04:59:46 -0300 Message-ID: <20240216075948.131372-6-leobras@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240216075948.131372-2-leobras@redhat.com> References: <20240216075948.131372-2-leobras@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For every TX byte an IRQ is requested. On threaded IRQs, the handler calls serial8250_tx_chars can send multiple bytes, limited to it's queue size (tx_loadsz). When this happens, the handler return IRQ_HANDLED with reduces the unhandled IRQ counter only by 1, even though many requests have been handled at once. This causes the unhandled IRQ counter to go up until it reaches the maximum and causes the registered IRQ to be disabled, thus breaking the serial console. Make use of the newly introduced IRQ_HANDLED_MANY interface to return the number of requests handled, so the unhandled IRQ counter can get decreased accordingly. Signed-off-by: Leonardo Bras --- include/linux/serial_8250.h | 2 +- drivers/tty/serial/8250/8250_core.c | 13 ++++++++----- drivers/tty/serial/8250/8250_port.c | 16 ++++++++++------ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h index ec46e3b49ee99..c9d4271b71d70 100644 --- a/include/linux/serial_8250.h +++ b/include/linux/serial_8250.h @@ -200,7 +200,7 @@ int fsl8250_handle_irq(struct uart_port *port); int serial8250_handle_irq(struct uart_port *port, unsigned int iir); u16 serial8250_rx_chars(struct uart_8250_port *up, u16 lsr); void serial8250_read_char(struct uart_8250_port *up, u16 lsr); -void serial8250_tx_chars(struct uart_8250_port *up); +int serial8250_tx_chars(struct uart_8250_port *up); unsigned int serial8250_modem_status(struct uart_8250_port *up); void serial8250_init_port(struct uart_8250_port *up); void serial8250_set_defaults(struct uart_8250_port *up); diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/= 8250_core.c index ae637155fe7cd..2fab9102eec45 100644 --- a/drivers/tty/serial/8250/8250_core.c +++ b/drivers/tty/serial/8250/8250_core.c @@ -110,7 +110,7 @@ static irqreturn_t serial8250_interrupt(int irq, void *= dev_id) { struct irq_info *i =3D dev_id; struct list_head *l, *end =3D NULL; - int pass_counter =3D 0, handled =3D 0; + int pass_counter =3D 0, handled_total =3D 0; =20 pr_debug("%s(%d): start\n", __func__, irq); =20 @@ -120,15 +120,18 @@ static irqreturn_t serial8250_interrupt(int irq, void= *dev_id) do { struct uart_8250_port *up; struct uart_port *port; + int handled; =20 up =3D list_entry(l, struct uart_8250_port, list); port =3D &up->port; =20 - if (port->handle_irq(port)) { - handled =3D 1; + handled =3D port->handle_irq(port); + if (handled) { + handled_total +=3D handled; end =3D NULL; - } else if (end =3D=3D NULL) + } else if (end =3D=3D NULL) { end =3D l; + } =20 l =3D l->next; =20 @@ -140,7 +143,7 @@ static irqreturn_t serial8250_interrupt(int irq, void *= dev_id) =20 pr_debug("%s(%d): end\n", __func__, irq); =20 - return IRQ_RETVAL(handled); + return IRQ_RETVAL_MANY(handled_total); } =20 /* diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/= 8250_port.c index f799c34f1603c..74d53507a73d4 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1802,7 +1802,7 @@ u16 serial8250_rx_chars(struct uart_8250_port *up, u1= 6 lsr) } EXPORT_SYMBOL_GPL(serial8250_rx_chars); =20 -void serial8250_tx_chars(struct uart_8250_port *up) +int serial8250_tx_chars(struct uart_8250_port *up) { struct uart_port *port =3D &up->port; struct circ_buf *xmit =3D &port->state->xmit; @@ -1810,15 +1810,15 @@ void serial8250_tx_chars(struct uart_8250_port *up) =20 if (port->x_char) { uart_xchar_out(port, UART_TX); - return; + return 0; } if (uart_tx_stopped(port)) { serial8250_stop_tx(port); - return; + return 0; } if (uart_circ_empty(xmit)) { __stop_tx(up); - return; + return 0; } =20 count =3D up->tx_loadsz; @@ -1858,6 +1858,9 @@ void serial8250_tx_chars(struct uart_8250_port *up) */ if (uart_circ_empty(xmit) && !(up->capabilities & UART_CAP_RPM)) __stop_tx(up); + + /* Return number of chars sent */ + return up->tx_loadsz - count; } EXPORT_SYMBOL_GPL(serial8250_tx_chars); =20 @@ -1923,6 +1926,7 @@ int serial8250_handle_irq(struct uart_port *port, uns= igned int iir) bool skip_rx =3D false; unsigned long flags; u16 status; + int handled =3D 0; =20 if (iir & UART_IIR_NO_INT) return 0; @@ -1956,14 +1960,14 @@ int serial8250_handle_irq(struct uart_port *port, u= nsigned int iir) serial8250_modem_status(up); if ((status & UART_LSR_THRE) && (up->ier & UART_IER_THRI)) { if (!up->dma || up->dma->tx_err) - serial8250_tx_chars(up); + handled =3D serial8250_tx_chars(up); else if (!up->dma->tx_running) __stop_tx(up); } =20 uart_unlock_and_check_sysrq_irqrestore(port, flags); =20 - return 1; + return handled ? : 1; } EXPORT_SYMBOL_GPL(serial8250_handle_irq); =20 --=20 2.43.2