From nobody Wed Oct 30 18:21:01 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XdwRf2lkTz5bndW; Wed, 30 Oct 2024 18:21:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XdwRd6DpJz4NZJ; Wed, 30 Oct 2024 18:21:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730312461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/PJRLkyiZKehZBK3YXMnQtsV6ovIJX9CoSyPnfWPxFg=; b=ocO0Oy38nosE0baShU0YA0+6LLYAEU+wT8lZpYV8PiWyGNkMiX4Yf2miMg/phOiYuhuEUx f3AGG0yhtHGJcljgIiFOaGhONV9X36ixqGiM2njxw40IB1OSyLCVj4Q5DQNxgxGqNLiUHg mGyp/kgHE8ZMP0EA+L+AKiDM/HxdPSsYhORqsr9wj2krZ2uCDjlWpGZ1Kwsh2ycjnEtzI6 9uG/qcpEzftYyC5QUyAUe6A0M+8aqIjaIE/PpsGUCvXFPQM25bb5s/nceCijc44PLcXXaj 0H016kyKO8v1YUEjm9JKUCDTXAOfnu5n+MFrUzeqpFJkYqbX6xGzzg8oQ55dkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730312461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/PJRLkyiZKehZBK3YXMnQtsV6ovIJX9CoSyPnfWPxFg=; b=yncmFshLKx8wldmAOhivCL26IBJIw8+o8PfZ9cHsej7aWx4K3M0adqhx1wGJAXjBoV57XI egqYREuuVk3FZqZO6XQBg3lj6b5l0mtuII0m3iZ1ZJuNaCtmGlrsj+DQ+WLBLnT4wFMzpz XQsHAZ0WqeMhMx7XFU4iwa6rVxGHJokYLkwsDNdunby+pTw+HQhfXSgLJJ0qz2GcUY2c3o rllgfX6aFJ2/4ZJgRva0EYY8aXr4HgWgyAytN3TUuoH3PT4xCLpQciz0m1GDQ2Ncl3I9xh tCubt4/mtR5c7CdsJ40oLHfCTHDFCOxdz2gAjqmFG/5FXJFHepea3OX6y9f7zQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730312461; a=rsa-sha256; cv=none; b=MMKlkDHbvfK/G3FYYQnSV08UdV40XmcYK68n2XWVmspugXC7P0NULWnCEjGSmddy2SZbeV kDMRws0MjNUNyRSMrcmbDHZHNdKjJ2i4+T8LJlYR4mMIdddrGsWL1eAYQoYuyc77UZ7AOg qiYpCbsXe7Oae+l1g3widutRrBok3PB6Ph2OQZU5ze5USMfVw5GD/l0dpjAwyZKO5M2/vf 4w3pGjILampK8/TWdYDKCNcF1XT5N2d3KeHcBUdhL+wJ3CV8U5K4w9iojSA5vQTEQ/FpiE XOyJX0U+Lyz0lrtuy4vTkovhDw9/ApJyyo+oh6Q1/na18AfkS1k4Bb4JfDPz5A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XdwRd5lgqz1Hgq; Wed, 30 Oct 2024 18:21:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49UIL17w048892; Wed, 30 Oct 2024 18:21:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49UIL11v048889; Wed, 30 Oct 2024 18:21:01 GMT (envelope-from git) Date: Wed, 30 Oct 2024 18:21:01 GMT Message-Id: <202410301821.49UIL11v048889@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: d584228930a1 - main - plic, aplic: handle all pending interrupts for hart List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d584228930a1689479d62fb303a51c42ecd7b6ec Auto-Submitted: auto-generated The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=d584228930a1689479d62fb303a51c42ecd7b6ec commit d584228930a1689479d62fb303a51c42ecd7b6ec Author: Mitchell Horne AuthorDate: 2024-10-30 18:16:47 +0000 Commit: Mitchell Horne CommitDate: 2024-10-30 18:16:47 +0000 plic, aplic: handle all pending interrupts for hart Otherwise, we are going to take another interrupt-induced exception immediately upon execution of the sret instruction -- overall wasting cycles. Reviewed by: br MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D47134 --- sys/riscv/riscv/aplic.c | 18 ++++++++++-------- sys/riscv/riscv/plic.c | 5 ++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/sys/riscv/riscv/aplic.c b/sys/riscv/riscv/aplic.c index af58bb014745..6550b7ba36d1 100644 --- a/sys/riscv/riscv/aplic.c +++ b/sys/riscv/riscv/aplic.c @@ -224,21 +224,23 @@ aplic_intr(void *arg) { struct aplic_softc *sc; struct trapframe *tf; - u_int claimi, prio, irq; + uint32_t claimi; + u_int prio, irq; int cpu; sc = arg; cpu = PCPU_GET(cpuid); - /* Claim any pending interrupt. */ - claimi = aplic_read(sc, APLIC_IDC_CLAIMI(sc, cpu)); - prio = APLIC_IDC_CLAIMI_PRIO(claimi); - irq = APLIC_IDC_CLAIMI_IRQ(claimi); + /* Claim all pending interrupts. */ + while ((claimi = aplic_read(sc, APLIC_IDC_CLAIMI(sc, cpu))) != 0) { + prio = APLIC_IDC_CLAIMI_PRIO(claimi); + irq = APLIC_IDC_CLAIMI_IRQ(claimi); - KASSERT((irq != 0), ("Invalid IRQ 0")); + KASSERT((irq != 0), ("Invalid IRQ 0")); - tf = curthread->td_intr_frame; - aplic_irq_dispatch(sc, irq, prio, tf); + tf = curthread->td_intr_frame; + aplic_irq_dispatch(sc, irq, prio, tf); + } return (FILTER_HANDLED); } diff --git a/sys/riscv/riscv/plic.c b/sys/riscv/riscv/plic.c index 7ae68c00d78a..e28019e6f458 100644 --- a/sys/riscv/riscv/plic.c +++ b/sys/riscv/riscv/plic.c @@ -175,9 +175,8 @@ plic_intr(void *arg) sc = arg; cpu = PCPU_GET(cpuid); - /* Claim any pending interrupt. */ - pending = RD4(sc, PLIC_CLAIM(sc, cpu)); - if (pending) { + /* Claim all pending interrupts. */ + while ((pending = RD4(sc, PLIC_CLAIM(sc, cpu))) != 0) { tf = curthread->td_intr_frame; plic_irq_dispatch(sc, pending, tf); }