From nobody Fri Oct 3 15:33:23 2025 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (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 AE8E63081D4 for ; Fri, 29 Aug 2025 10:14:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756462475; cv=none; b=WEOwjVFNUaLpSxoHZtNHGE1YkJ+H6qL78dw+SneRjViO94Fbz0IBga7Jc2/9tC1CUDKBV/iaj1nHsnXNfLR80yhKluyQrV3TJtx+pBgNEvE22V0Bu2IgN0yn1nvL0TXWVx3dhIYOcp4Vz4PoklTc6ESpmycMrZjEivBoSgQiJl8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756462475; c=relaxed/simple; bh=N2NvpHg88S62Uc5fbVIvESI1ayJo/wLkVMflp508xBI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KhRlK8tOSPSpY1GpeqUoR4i+/OS+Rt+JIACW85Nr5eX1V1G0bSsADZCjPwIaGrwB1pBuxF5/Mg4AoDXMeT/JC9NdyOyMFB7TiB2eePMPA1zYUnrc/e+fzWDktGHTsjFRuhkeVI97vFPUcd4mBxrX20uxUw+0aX5Q6A0KX+geOkw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4cCvJG5Fdsz14MCg; Fri, 29 Aug 2025 18:14:22 +0800 (CST) Received: from dggemv706-chm.china.huawei.com (unknown [10.3.19.33]) by mail.maildlp.com (Postfix) with ESMTPS id 7E111180B54; Fri, 29 Aug 2025 18:14:30 +0800 (CST) Received: from kwepemn100008.china.huawei.com (7.202.194.111) by dggemv706-chm.china.huawei.com (10.3.19.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 29 Aug 2025 18:14:30 +0800 Received: from localhost.huawei.com (10.90.31.46) by kwepemn100008.china.huawei.com (7.202.194.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 29 Aug 2025 18:14:29 +0800 From: Yushan Wang To: , , , CC: , , , , , , , , , Subject: [PATCH v3 3/9] drivers/perf: hisi: Simplify the probe process of each L3C PMU version Date: Fri, 29 Aug 2025 18:14:21 +0800 Message-ID: <20250829101427.2557899-4-wangyushan12@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20250829101427.2557899-1-wangyushan12@huawei.com> References: <20250829101427.2557899-1-wangyushan12@huawei.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 X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemn100008.china.huawei.com (7.202.194.111) Content-Type: text/plain; charset="utf-8" From: Yicong Yang Version 1 and 2 of L3C PMU also use different HID. Make use of struct acpi_device_id::driver_data for version specific information rather than judge the version register. This will help to simplify the probe process and also a bit easier for extension. Acked-by: Jonathan Cameron Signed-off-by: Yicong Yang Signed-off-by: Yushan Wang --- drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c | 43 ++++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c b/drivers/perf/hi= silicon/hisi_uncore_l3c_pmu.c index 412fc3a97963..db683dd7375c 100644 --- a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c +++ b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c @@ -345,13 +345,6 @@ static void hisi_l3c_pmu_clear_int_status(struct hisi_= pmu *l3c_pmu, int idx) writel(1 << idx, l3c_pmu->base + L3C_INT_CLEAR); } =20 -static const struct acpi_device_id hisi_l3c_pmu_acpi_match[] =3D { - { "HISI0213", }, - { "HISI0214", }, - {} -}; -MODULE_DEVICE_TABLE(acpi, hisi_l3c_pmu_acpi_match); - static int hisi_l3c_pmu_init_data(struct platform_device *pdev, struct hisi_pmu *l3c_pmu) { @@ -371,6 +364,10 @@ static int hisi_l3c_pmu_init_data(struct platform_devi= ce *pdev, return -EINVAL; } =20 + l3c_pmu->dev_info =3D device_get_match_data(&pdev->dev); + if (!l3c_pmu->dev_info) + return -ENODEV; + l3c_pmu->base =3D devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(l3c_pmu->base)) { dev_err(&pdev->dev, "ioremap failed for l3c_pmu resource\n"); @@ -457,6 +454,18 @@ static const struct attribute_group *hisi_l3c_pmu_v2_a= ttr_groups[] =3D { NULL }; =20 +static const struct hisi_pmu_dev_info hisi_l3c_pmu_v1 =3D { + .attr_groups =3D hisi_l3c_pmu_v1_attr_groups, + .counter_bits =3D 48, + .check_event =3D L3C_V1_NR_EVENTS, +}; + +static const struct hisi_pmu_dev_info hisi_l3c_pmu_v2 =3D { + .attr_groups =3D hisi_l3c_pmu_v2_attr_groups, + .counter_bits =3D 64, + .check_event =3D L3C_V2_NR_EVENTS, +}; + static const struct hisi_uncore_ops hisi_uncore_l3c_ops =3D { .write_evtype =3D hisi_l3c_pmu_write_evtype, .get_event_idx =3D hisi_uncore_pmu_get_event_idx, @@ -487,16 +496,9 @@ static int hisi_l3c_pmu_dev_probe(struct platform_devi= ce *pdev, if (ret) return ret; =20 - if (l3c_pmu->identifier >=3D HISI_PMU_V2) { - l3c_pmu->counter_bits =3D 64; - l3c_pmu->check_event =3D L3C_V2_NR_EVENTS; - l3c_pmu->pmu_events.attr_groups =3D hisi_l3c_pmu_v2_attr_groups; - } else { - l3c_pmu->counter_bits =3D 48; - l3c_pmu->check_event =3D L3C_V1_NR_EVENTS; - l3c_pmu->pmu_events.attr_groups =3D hisi_l3c_pmu_v1_attr_groups; - } - + l3c_pmu->pmu_events.attr_groups =3D l3c_pmu->dev_info->attr_groups; + l3c_pmu->counter_bits =3D l3c_pmu->dev_info->counter_bits; + l3c_pmu->check_event =3D l3c_pmu->dev_info->check_event; l3c_pmu->num_counters =3D L3C_NR_COUNTERS; l3c_pmu->ops =3D &hisi_uncore_l3c_ops; l3c_pmu->dev =3D &pdev->dev; @@ -554,6 +556,13 @@ static void hisi_l3c_pmu_remove(struct platform_device= *pdev) &l3c_pmu->node); } =20 +static const struct acpi_device_id hisi_l3c_pmu_acpi_match[] =3D { + { "HISI0213", (kernel_ulong_t)&hisi_l3c_pmu_v1 }, + { "HISI0214", (kernel_ulong_t)&hisi_l3c_pmu_v2 }, + {} +}; +MODULE_DEVICE_TABLE(acpi, hisi_l3c_pmu_acpi_match); + static struct platform_driver hisi_l3c_pmu_driver =3D { .driver =3D { .name =3D "hisi_l3c_pmu", --=20 2.33.0