Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp111334lqt; Mon, 18 Mar 2024 03:03:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUb+ZNKsto23YTzoIoII1bn4inKHLPWaRGl3Tm/ppgHNHbALtLAkIPT0LKlbJ50ScoGo9SXZ+zABS9tcCeI0Zu0lMGeVmTQBvtEZrigQA== X-Google-Smtp-Source: AGHT+IFTbfBZmuzl3CYtyRXVZ45h2O8S6IIzjnMRrClXPmOicfG/hUQ2dMld562e0PDt0wH7vUuR X-Received: by 2002:a05:6a00:3a12:b0:6e6:bfb6:371 with SMTP id fj18-20020a056a003a1200b006e6bfb60371mr14261720pfb.34.1710756213040; Mon, 18 Mar 2024 03:03:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710756213; cv=pass; d=google.com; s=arc-20160816; b=0zdwjP3SGgWXbD4pVEV0MoFTctx1rRoRIPWvzIKdHXcBlIWBUDoaP7YbJ/D/eD/oGw ZQtxwFSfVDjTNNkPPqewy/DzRe38D8sYEDGoct+bV5jrJfMUjwbrWv35/bI7Z5OYuJcQ sqytHu+YV+7AB8bFbjBGOh7JmHFXA9aHUSUVYqWivkLsEKw3UntlFwIei/zAQCB5wWW/ tSRykbVq2YhCiP9xYcOEzOnWsvZCBm2cCRKfy67aU7zxR4T3Air5NbQSDNM1RKB2zolP eiz3SQYQK53DObNTmwsUQ0RS+x4fCyyTGIvVZFBFPaMwb/0yR+/kWF1u8twt2AlDqydo ReJA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=gV1l9rmzBCzJNW3ECkvyrqDRGHWu7/CWeWMayLYT9Qk=; fh=cctyKf7ZJ5vStyEAdK5dn3r6BDQem3jHG7aDIwIM1vw=; b=rfGJ2NSKNeCuYw6CMjX5N7XE+7U9cCJn2Cr30UfvntbJR6I+NxUTi1voAI2trV83fQ e8f3CT+AsoY2Pq5emtQ9hJ+LjUEJHsXb09IAo79vWhE0o228Bumu5GiLIzFuNlxWycW6 2U6gwMZSJBPgbOpaMU+sPRGgl9zjg/ZuoXeZIUHYiZl6bkz3WeY4mJ3jjNkBRy9XAwUP wTts2tQBSBgC80recnVRFRp4Xs7Z8D2D5DnC/C2KuPXIvXXhLvcep8CAkxQdyBcF1VaJ leDK7WUFldanvu/ii2Jn/PScncKB/REjzyQBbD9PxGJjgQAcRFE3hWKwbQmi8LsV4A7x lTog==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UPBhNVYN; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-105936-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105936-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g2-20020a056a000b8200b006e6b6f824eesi8934409pfj.336.2024.03.18.03.03.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 03:03:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-105936-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UPBhNVYN; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-105936-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105936-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 1FB7A2816E4 for ; Mon, 18 Mar 2024 10:03:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1057A2E622; Mon, 18 Mar 2024 10:02:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UPBhNVYN" Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7DB02D627 for ; Mon, 18 Mar 2024 10:02:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710756175; cv=none; b=AMVPL6IL/S8ztrq3frkeQtnviRJiBtq1sJdKMbPH6ToyUJeWvNd45rDmc+EoRGT8isNgxHWRqjjOB9VFIkPJ/LLdl+yFJ2fnCKhKFY9aM785PlYZycw2IQUpjCg+77fFtlsaLovIDxNFAWiQSYFjFOxRhvv9Vsf5Eskec7ethjs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710756175; c=relaxed/simple; bh=23AJFBOQzolb/bX7PhDzjxxjGAgihS0rUtF2sxZKRPg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ca7/PrCeDWfepW4QChvJihVyPc0ukOV6H6F9/FkL0ybhaeiQ0sHMsp/WAM7wBQAsBfk8QVg7VScjx7rNYPcEx1AY1K8tzuiGzqys+zppurCYWft8RjQwZT3slpaB8SR1Joa6O7xopacJE32CV1mNCDbSaafsC78PkJqvE9NTlC4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UPBhNVYN; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1dddad37712so39303745ad.3 for ; Mon, 18 Mar 2024 03:02:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710756173; x=1711360973; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gV1l9rmzBCzJNW3ECkvyrqDRGHWu7/CWeWMayLYT9Qk=; b=UPBhNVYNbDfuGoWKqZgic7sn1XRBEpjI9evX6FAluPcLWR6J0Tij3fNpbsfjCqKPtb u8KkyVFNApTRxwLb3nVm3Hod48WRmBgBiKylGOx4/ilDLutKzr9+SLRDpa45qA3ikNPl 9hOcYmPZ3OYefG/WHMlktmkOxglpOK4s3aWFm2vlckXJRpnsHHFJB0BghyZvNaemXsD2 Cqt8HZRpCSxFpNJNHunYjACJzi6T6FlxYf6TiC4XYiPm5RCPv75ZvXE8X/pqVnq6EO7e xsRuy9eIEt6BdJFydUyZ9UA6dXnM9NRdSnQpOb3SfyxzxfuOgk01mmFpUO9DYWAoP+3m P70w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710756173; x=1711360973; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gV1l9rmzBCzJNW3ECkvyrqDRGHWu7/CWeWMayLYT9Qk=; b=AvgDJSyaOwS2WIAjCnJaJhDvGT6+kNrozbRW6QLpFSK8bo/cUNN43ksaUice9eBotu 77ebvxvMc6dccfaldwHx6O46pHPO8wD6xP+zPc8DuFK+1dT0+yTTKqkTLmvhUZBLsBGz R0au5fUXsXtu85LS3/RsOa8P42B/+UC/I1F6KXgYmjx8HL8gUYilkFIXjt2PWu2pPEs1 XpUlvLtM0Vp7Ydo75EBFmcquI9aWRJZLufPLGDilCUd1OIhxKLzJpVePJ7l+mSqh1YvY d1aPlqvD/1ud7iOApqZsdfbNvGFbDU80p14w8AICKLQs9r7SLNMkgiH59Uc9qwN62j/J nIyw== X-Forwarded-Encrypted: i=1; AJvYcCW0jJN/u3Zucy5N+baN7q9DxASEQ/UD9tjBFPfUgT2EAKdp0nHNQb5TqcvdMAz6EGTXs5LRg9DTPY7BcfQ03MJMiCBQof5FW77UtNja X-Gm-Message-State: AOJu0YwGrVNA6WHn3CIPqTOJiBHY7jDcd0nZuGRbsyprZRcd2SX2InR7 bs5TRVw7PWY4GFzGXYxJ3ojqJ97rWd8x9GrQlyMs0kXwvuAtfvSm X-Received: by 2002:a17:90b:440b:b0:29c:7845:cba with SMTP id hx11-20020a17090b440b00b0029c78450cbamr10647032pjb.36.1710756172888; Mon, 18 Mar 2024 03:02:52 -0700 (PDT) Received: from DESKTOP-4R0U3NR.siflower.com ([2a09:bac5:6249:183c::26a:36]) by smtp.gmail.com with ESMTPSA id rr7-20020a17090b2b4700b0029bcf877eabsm7360608pjb.10.2024.03.18.03.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 03:02:52 -0700 (PDT) From: Qingfang Deng To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Atish Patra , Anup Patel , Will Deacon , Mark Rutland , Andrew Jones , Conor Dooley , Heiko Stuebner , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Qingfang Deng Subject: [PATCH v2] perf: RISC-V: fix IRQ detection on T-Head C908 Date: Mon, 18 Mar 2024 18:02:40 +0800 Message-Id: <20240318100241.267857-1-dqfext@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Qingfang Deng T-Head C908 has the same IRQ num and CSR as previous C9xx cores, but reports non-zero marchid and mimpid. Add the check for C908 ID. Fixes: 65e9fb081877 ("drivers/perf: riscv_pmu_sbi: add support for PMU variant on T-Head C9xx cores") Signed-off-by: Qingfang Deng --- v2: add C908 ID check arch/riscv/errata/thead/errata.c | 5 +++-- arch/riscv/include/asm/vendorid_list.h | 2 ++ drivers/perf/riscv_pmu_sbi.c | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/riscv/errata/thead/errata.c b/arch/riscv/errata/thead/errata.c index b1c410bbc1ae..da3b34866d8f 100644 --- a/arch/riscv/errata/thead/errata.c +++ b/arch/riscv/errata/thead/errata.c @@ -125,8 +125,9 @@ static bool errata_probe_pmu(unsigned int stage, if (!IS_ENABLED(CONFIG_ERRATA_THEAD_PMU)) return false; - /* target-c9xx cores report arch_id and impid as 0 */ - if (arch_id != 0 || impid != 0) + /* Early c9xx cores report arch_id and impid as 0 */ + if (!((arch_id == 0 && impid == 0) || + (arch_id == THEAD_C908_ARCH_ID && impid == THEAD_C908_IMP_ID))) return false; if (stage == RISCV_ALTERNATIVES_EARLY_BOOT) diff --git a/arch/riscv/include/asm/vendorid_list.h b/arch/riscv/include/asm/vendorid_list.h index 2f2bb0c84f9a..57b3de510d38 100644 --- a/arch/riscv/include/asm/vendorid_list.h +++ b/arch/riscv/include/asm/vendorid_list.h @@ -8,5 +8,7 @@ #define ANDES_VENDOR_ID 0x31e #define SIFIVE_VENDOR_ID 0x489 #define THEAD_VENDOR_ID 0x5b7 +#define THEAD_C908_ARCH_ID 0x8000000009140d00 +#define THEAD_C908_IMP_ID 0x8a000 #endif diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c index bbd6fe021b3a..34d8689982de 100644 --- a/drivers/perf/riscv_pmu_sbi.c +++ b/drivers/perf/riscv_pmu_sbi.c @@ -833,8 +833,10 @@ static int pmu_sbi_setup_irqs(struct riscv_pmu *pmu, struct platform_device *pde riscv_pmu_use_irq = true; } else if (IS_ENABLED(CONFIG_ERRATA_THEAD_PMU) && riscv_cached_mvendorid(0) == THEAD_VENDOR_ID && - riscv_cached_marchid(0) == 0 && - riscv_cached_mimpid(0) == 0) { + ((riscv_cached_marchid(0) == 0 && + riscv_cached_mimpid(0) == 0) || + (riscv_cached_marchid(0) == THEAD_C908_ARCH_ID && + riscv_cached_mimpid(0) == THEAD_C908_IMP_ID))) { riscv_pmu_irq_num = THEAD_C9XX_RV_IRQ_PMU; riscv_pmu_use_irq = true; } else if (riscv_isa_extension_available(NULL, XANDESPMU) && -- 2.34.1