get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2173982/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2173982,
    "url": "http://patchwork.ozlabs.org/api/patches/2173982/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/kvm-riscv/patch/20251213150848.149729-3-jamestiotio@gmail.com/",
    "project": {
        "id": 70,
        "url": "http://patchwork.ozlabs.org/api/projects/70/?format=api",
        "name": "Linux KVM RISC-V",
        "link_name": "kvm-riscv",
        "list_id": "kvm-riscv.lists.infradead.org",
        "list_email": "kvm-riscv@lists.infradead.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "http://lists.infradead.org/pipermail/kvm-riscv/",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20251213150848.149729-3-jamestiotio@gmail.com>",
    "list_archive_url": null,
    "date": "2025-12-13T15:08:46",
    "name": "[kvm-unit-tests,2/4] lib: riscv: Add SBI PMU support",
    "commit_ref": null,
    "pull_url": null,
    "state": "handled-elsewhere",
    "archived": false,
    "hash": "fc81bdd4aad003195009bc6778588fa1a76300c0",
    "submitter": {
        "id": 85990,
        "url": "http://patchwork.ozlabs.org/api/people/85990/?format=api",
        "name": "James Raphael Tiovalen",
        "email": "jamestiotio@gmail.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/kvm-riscv/patch/20251213150848.149729-3-jamestiotio@gmail.com/mbox/",
    "series": [
        {
            "id": 485289,
            "url": "http://patchwork.ozlabs.org/api/series/485289/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/kvm-riscv/list/?series=485289",
            "date": "2025-12-13T15:08:44",
            "name": "riscv: sbi: Add support to test PMU extension",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/485289/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2173982/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2173982/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "\n <kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=lists.infradead.org header.i=@lists.infradead.org\n header.a=rsa-sha256 header.s=bombadil.20210309 header.b=KfAGaX97;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20230601 header.b=JeJtquNd;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=none (no SPF record) smtp.mailfrom=lists.infradead.org\n (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org;\n envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n receiver=patchwork.ozlabs.org)"
        ],
        "Received": [
            "from bombadil.infradead.org (bombadil.infradead.org\n [IPv6:2607:7c80:54:3::133])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4dT8qk4YSkz1y0v\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 14 Dec 2025 02:09:18 +1100 (AEDT)",
            "from localhost ([::1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1vURFD-00000001ieQ-0nQ2;\n\tSat, 13 Dec 2025 15:09:15 +0000",
            "from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635])\n\tby bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1vURFA-00000001ide-3Jq6\n\tfor kvm-riscv@lists.infradead.org;\n\tSat, 13 Dec 2025 15:09:14 +0000",
            "by mail-pl1-x635.google.com with SMTP id\n d9443c01a7336-2984dfae043so20448115ad.0\n        for <kvm-riscv@lists.infradead.org>;\n Sat, 13 Dec 2025 07:09:12 -0800 (PST)",
            "from JRT-PC.. ([111.94.32.24])\n        by smtp.gmail.com with ESMTPSA id\n d9443c01a7336-29eea016c6esm85494715ad.59.2025.12.13.07.09.09\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Sat, 13 Dec 2025 07:09:11 -0800 (PST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20210309; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=qaTkgEOPCZYV+SPhBNPlSMlds0y43qTVGGd9oGxAQJc=; b=KfAGaX970kjJ/v\n\tznQVy0+8Z0h3N60IeMjiEQGWgvXb4AlDPGNrYJ42FQUMVzSJEpP9LLbzwiKbo2bLJ1L2a8xrhrOth\n\tyN03p0aaDaBOw7pN1A6XnVgrHoDFZniI1iD2EP7VJ9paMKUEDgZBV6/kLe2HBPCJVkP2OUNkl0V5i\n\tMxGoTX0RkDsjZkucd7r6t0eRW2+o3xMEHbSghA+VbbKqTb5pdVPPz1GesJqRyNNaBSZ4zKz3AaYc5\n\tRnNXn4WiYzxyQYg7dPgpRn519Q9/VIFqS2obQb1RmirUeXtyPepj+7y/Vkpax6qH6Ofi82ha3L8jm\n\tgR5CtVHINHLQQDZvZdvA==;",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20230601; t=1765638552; x=1766243352;\n darn=lists.infradead.org;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n         :message-id:reply-to;\n        bh=Gz8I5jl1qyQO0MpJuF22MiSS1lFlGXvXKCb0VFWa7N0=;\n        b=JeJtquNdaP2H3aM7H7DRyXD2j5fvx/93yr26FuHR2J/xfmaHLzJxXe3r3GnFIsGDRG\n         FAGStdkUO9cSSRvzOKxyuQR+EQELqunQbpFfszBkkny29qDL332pe/TqVcHrIUx4YiEj\n         C4hWTgiQgFg/lestE9Dgb2Q8VGsw0e5F5On6T48lNjcFxSmwb6H5myr4Jezsozvq64Kl\n         v8FCiSc8hqBzrS5PFcHVyQ/mOQpy0sKck8OU85FrQ2N/QYi7zlNjsqKgtlmIaAtRjvKp\n         Hn44c05yE+rrFTTRBbOmgats/414njA9I8kuwASHRT+wc3doWo9op+3y02WXe4QwqGxH\n         1TdQ=="
        ],
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20230601; t=1765638552; x=1766243352;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n         :to:cc:subject:date:message-id:reply-to;\n        bh=Gz8I5jl1qyQO0MpJuF22MiSS1lFlGXvXKCb0VFWa7N0=;\n        b=MNPFo77GKLtIqtDhmDK5osJxOhDpKur8agSVQf+XmzmH+WxFaZuH6ilbBFaOediDmN\n         hOKnIuCA5ve8sKhqKTqFH09iyKJ1L3GfX35HmFTKSSyHZ9gWMdUU9pWawUgk/HTvyC7v\n         6vauEr+VracfeTGxEu/yFie+3kDS6e/YrTYtxiM/R3BrG1vpJ2WFrjBmlbDA3UkMOFHU\n         K6sHIeVW+4Ey9TvuFd03R3TKcLWJe8wyIIpBOw7OzNuSfHXRZhyI2qKRpwrzegQgswSP\n         SMSbRtOt4LUfopxWRVH3ujKT2vNVNFKjtMn+44tBVwwVQyk347GN9iQDBC1BbC5bxu1Q\n         aUcg==",
        "X-Forwarded-Encrypted": "i=1;\n AJvYcCWC3pq0rzjgMO9lkFkeKBrWOXQtI7xDpYVL9ZSGrrny14PH/h41ylEpMc+CUpgGV1c6edUGHjCtsvg=@lists.infradead.org",
        "X-Gm-Message-State": "AOJu0YzsgAZn3zQ5S/w46A2mAyAqv0iJ+GN+E5lqD8DI5EaEJFb4tZfB\n\tgqGLD5e1x6Zbf7zlcRBqecTury2AJK8m2NW5rS61YRJtVRTkT5QqyhLq",
        "X-Gm-Gg": "AY/fxX7w4BhhIGOyzsbTUcstzHWtvbR07FhlKD45vY26sHfNwCatpNrDpQU4bZcA8Bu\n\twl1iwpy0Ysb1T+dvBi7Ak3NnVBay2TJj2AizCwqCQE4600IAw2lrbbtxIEKw3/GIs9Baoy3NOwR\n\tidU3AjB6SuUmvrG8L0kp/ERpy7leXMbRmWZl03It4FNHfZcPukUv9jGt+LrCNG/396FnpJ2a1vh\n\tJuN3hSgWPo5ZiMqETOtJ5weVt5d0yDz/x8vKk6XV4lxwtUi/8HsbULPCqJcgNX+P3Ncdhyr0rVm\n\t+Getn/IvMK2fU+YWIc2dtRk+F0CoENIPX4VQnHDcqcgOLb9005hfXAsyhppRYykxOklSPyPXH4J\n\t5KgkXGrdYVll/ua7Mn/jsgAyRvMRB3LOSw7+ClPqJELCO68Kj3ZwHpRPuTKl9MsU2AToAFF2nMp\n\tbCbXJ4IxZPf64UkuTv",
        "X-Google-Smtp-Source": "\n AGHT+IHhr/NTcyCI0sQBcui69+ks4sJWgn/BIWiamUG1k98Zmrlr/Bt9eoe/k8Ql/eMzC92DGm9lfQ==",
        "X-Received": "by 2002:a17:903:2308:b0:295:5945:2930 with SMTP id\n d9443c01a7336-29f23dd7126mr61354455ad.2.1765638551861;\n        Sat, 13 Dec 2025 07:09:11 -0800 (PST)",
        "From": "James Raphael Tiovalen <jamestiotio@gmail.com>",
        "To": "kvm@vger.kernel.org,\n\tkvm-riscv@lists.infradead.org",
        "Cc": "andrew.jones@linux.dev,\n\tatishp@rivosinc.com,\n\tJames Raphael Tiovalen <jamestiotio@gmail.com>",
        "Subject": "[kvm-unit-tests PATCH 2/4] lib: riscv: Add SBI PMU support",
        "Date": "Sat, 13 Dec 2025 23:08:46 +0800",
        "Message-ID": "<20251213150848.149729-3-jamestiotio@gmail.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20251213150848.149729-1-jamestiotio@gmail.com>",
        "References": "<20251213150848.149729-1-jamestiotio@gmail.com>",
        "MIME-Version": "1.0",
        "X-CRM114-Version": "20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ",
        "X-CRM114-CacheID": "sfid-20251213_070912_882930_EA14197D ",
        "X-CRM114-Status": "UNSURE (   7.92  )",
        "X-CRM114-Notice": "Please train this message.",
        "X-Spam-Score": "-2.1 (--)",
        "X-Spam-Report": "Spam detection software,\n running on the system \"bombadil.infradead.org\",\n has NOT identified this incoming email as spam.  The original\n message has been attached to this so you can view it or label\n similar future email.  If you have any questions, see\n the administrator of that system for details.\n Content preview:  Add support for all of the SBI PMU functions, which will be\n    used by the SBI tests. Signed-off-by: James Raphael Tiovalen ---\n lib/riscv/asm/sbi.h\n    | 22 ++++++++++++++ lib/riscv/sbi.c | 73\n +++++++++++++++++++++++++++++++++++++++++++++\n    2 files changed, 95 insertions(+)\n Content analysis details:   (-2.1 points, 5.0 required)\n  pts rule name              description\n ---- ----------------------\n --------------------------------------------------\n -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/, no\n                             trust\n                             [2607:f8b0:4864:20:0:0:0:635 listed in]\n                             [list.dnswl.org]\n -0.0 SPF_PASS               SPF: sender matches SPF record\n  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record\n -0.1 DKIM_VALID_AU          Message has a valid DKIM or DK signature from\n author's\n                             domain\n -0.1 DKIM_VALID             Message has at least one valid DKIM or DK\n signature\n  0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n not necessarily valid\n -0.1 DKIM_VALID_EF          Message has a valid DKIM or DK signature from\n                             envelope-from domain\n -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n                             [score: 0.0000]\n  0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail\n provider\n                             [jamestiotio(at)gmail.com]",
        "X-BeenThere": "kvm-riscv@lists.infradead.org",
        "X-Mailman-Version": "2.1.34",
        "Precedence": "list",
        "List-Id": "<kvm-riscv.lists.infradead.org>",
        "List-Unsubscribe": "<http://lists.infradead.org/mailman/options/kvm-riscv>,\n <mailto:kvm-riscv-request@lists.infradead.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.infradead.org/pipermail/kvm-riscv/>",
        "List-Post": "<mailto:kvm-riscv@lists.infradead.org>",
        "List-Help": "<mailto:kvm-riscv-request@lists.infradead.org?subject=help>",
        "List-Subscribe": "<http://lists.infradead.org/mailman/listinfo/kvm-riscv>,\n <mailto:kvm-riscv-request@lists.infradead.org?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Sender": "\"kvm-riscv\" <kvm-riscv-bounces@lists.infradead.org>",
        "Errors-To": "kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org"
    },
    "content": "Add support for all of the SBI PMU functions, which will be used by the\nSBI tests.\n\nSigned-off-by: James Raphael Tiovalen <jamestiotio@gmail.com>\n---\n lib/riscv/asm/sbi.h | 22 ++++++++++++++\n lib/riscv/sbi.c     | 73 +++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 95 insertions(+)",
    "diff": "diff --git a/lib/riscv/asm/sbi.h b/lib/riscv/asm/sbi.h\nindex 35dbf508..8794c126 100644\n--- a/lib/riscv/asm/sbi.h\n+++ b/lib/riscv/asm/sbi.h\n@@ -390,5 +390,27 @@ struct sbiret sbi_fwft_set(uint32_t feature, unsigned long value, unsigned long\n struct sbiret sbi_fwft_get_raw(unsigned long feature);\n struct sbiret sbi_fwft_get(uint32_t feature);\n \n+struct sbiret sbi_pmu_num_counters(void);\n+struct sbiret sbi_pmu_counter_get_info(unsigned long counter_idx);\n+struct sbiret sbi_pmu_counter_config_matching(unsigned long counter_idx_base,\n+\t\t\t\t\t      unsigned long counter_idx_mask,\n+\t\t\t\t\t      unsigned long config_flags,\n+\t\t\t\t\t      unsigned long event_idx,\n+\t\t\t\t\t      unsigned long event_data);\n+struct sbiret sbi_pmu_counter_start(unsigned long counter_idx_base, unsigned long counter_idx_mask,\n+\t\t\t\t    unsigned long start_flags, unsigned long initial_value);\n+struct sbiret sbi_pmu_counter_stop(unsigned long counter_idx_base, unsigned long counter_idx_mask,\n+\t\t\t\t   unsigned long stop_flags);\n+struct sbiret sbi_pmu_counter_fw_read(unsigned long counter_idx);\n+struct sbiret sbi_pmu_counter_fw_read_hi(unsigned long counter_idx);\n+struct sbiret sbi_pmu_snapshot_set_shmem_raw(unsigned long shmem_phys_lo,\n+\t\t\t\t\t     unsigned long shmem_phys_hi,\n+\t\t\t\t\t     unsigned long flags);\n+struct sbiret sbi_pmu_snapshot_set_shmem(unsigned long *shmem, unsigned long flags);\n+struct sbiret sbi_pmu_event_get_info_raw(unsigned long shmem_phys_lo, unsigned long shmem_phys_hi,\n+\t\t\t\t\t unsigned long num_entries, unsigned long flags);\n+struct sbiret sbi_pmu_event_get_info(unsigned long *shmem, unsigned long num_entries,\n+\t\t\t\t     unsigned long flags);\n+\n #endif /* !__ASSEMBLER__ */\n #endif /* _ASMRISCV_SBI_H_ */\ndiff --git a/lib/riscv/sbi.c b/lib/riscv/sbi.c\nindex 39f6138f..ca8f3d33 100644\n--- a/lib/riscv/sbi.c\n+++ b/lib/riscv/sbi.c\n@@ -32,6 +32,79 @@ struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,\n \treturn ret;\n }\n \n+struct sbiret sbi_pmu_num_counters(void)\n+{\n+\treturn sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_NUM_COUNTERS, 0, 0, 0, 0, 0, 0);\n+}\n+\n+struct sbiret sbi_pmu_counter_get_info(unsigned long counter_idx)\n+{\n+\treturn sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_GET_INFO, counter_idx, 0, 0, 0, 0, 0);\n+}\n+\n+struct sbiret sbi_pmu_counter_config_matching(unsigned long counter_idx_base,\n+\t\t\t\t\t      unsigned long counter_idx_mask,\n+\t\t\t\t\t      unsigned long config_flags,\n+\t\t\t\t\t      unsigned long event_idx,\n+\t\t\t\t\t      unsigned long event_data)\n+{\n+\treturn sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_CONFIG_MATCHING, counter_idx_base,\n+\t\t\t counter_idx_mask, config_flags, event_idx, event_data, 0);\n+}\n+\n+struct sbiret sbi_pmu_counter_start(unsigned long counter_idx_base, unsigned long counter_idx_mask,\n+\t\t\t\t    unsigned long start_flags, unsigned long initial_value)\n+{\n+\treturn sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, counter_idx_base,\n+\t\t\t counter_idx_mask, start_flags, initial_value, 0, 0);\n+}\n+\n+struct sbiret sbi_pmu_counter_stop(unsigned long counter_idx_base, unsigned long counter_idx_mask,\n+\t\t\t\t   unsigned long stop_flags)\n+{\n+\treturn sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_STOP, counter_idx_base,\n+\t\t\t counter_idx_mask, stop_flags, 0, 0, 0);\n+}\n+\n+struct sbiret sbi_pmu_counter_fw_read(unsigned long counter_idx)\n+{\n+\treturn sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_FW_READ, counter_idx, 0, 0, 0, 0, 0);\n+}\n+\n+struct sbiret sbi_pmu_counter_fw_read_hi(unsigned long counter_idx)\n+{\n+\treturn sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_FW_READ_HI, counter_idx, 0, 0, 0, 0, 0);\n+}\n+\n+struct sbiret sbi_pmu_snapshot_set_shmem_raw(unsigned long shmem_phys_lo, unsigned long shmem_phys_hi,\n+\t\t\t\t\t     unsigned long flags)\n+{\n+\treturn sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_SNAPSHOT_SET_SHMEM, shmem_phys_lo,\n+\t\t\t shmem_phys_hi, flags, 0, 0, 0);\n+}\n+\n+struct sbiret sbi_pmu_snapshot_set_shmem(unsigned long *shmem, unsigned long flags)\n+{\n+\tphys_addr_t p = virt_to_phys(shmem);\n+\n+\treturn sbi_pmu_snapshot_set_shmem_raw(lower_32_bits(p), upper_32_bits(p), flags);\n+}\n+\n+struct sbiret sbi_pmu_event_get_info_raw(unsigned long shmem_phys_lo, unsigned long shmem_phys_hi,\n+\t\t\t\t\t unsigned long num_entries, unsigned long flags)\n+{\n+\treturn sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_EVENT_GET_INFO, shmem_phys_lo,\n+\t\t\t shmem_phys_hi, num_entries, flags, 0, 0);\n+}\n+\n+struct sbiret sbi_pmu_event_get_info(unsigned long *shmem, unsigned long num_entries,\n+\t\t\t\t     unsigned long flags)\n+{\n+\tphys_addr_t p = virt_to_phys(shmem);\n+\n+\treturn sbi_pmu_event_get_info_raw(lower_32_bits(p), upper_32_bits(p), num_entries, flags);\n+}\n+\n struct sbiret sbi_sse_read_attrs_raw(unsigned long event_id, unsigned long base_attr_id,\n \t\t\t\t     unsigned long attr_count, unsigned long phys_lo,\n \t\t\t\t     unsigned long phys_hi)\n",
    "prefixes": [
        "kvm-unit-tests",
        "2/4"
    ]
}