From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 36D24C001DF for ; Fri, 28 Jul 2023 14:41:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1s4DclkXlA10prxTae2rgIsC25mp7yDlwrjR8O3bngM=; b=hOwSZry8rK44HJ BfCtCotghTkBZlH6nbpD6Nt831iysYHSOSoM7Pgh7nRYxBj3c/AUNQBLx1ZPr7suHG30gYDQfCmhp xTUXEhOw1daH/J/c+1oNlvWIC3E8LA/TN62WgwjQA7MJngPdPM/xfCMv3yn46HJLyuvPVpWyBplmy LSq4QvrmMsJ+9uEz8l5Y/06/tWb/hhYR/nL7/x7tNj3pQvhcCuZuVgsftmIxhkZShEfpZX/WCUJUH QLziR2zsIh9MVF8HWXtt0vxzg2zhLDTcOBPQqn4+kqrsvQZqu5IyY/zqISa/D1NVphNvWrLGHcZie WgdRYWqFfcb2DUwbhwpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qPOeQ-003j8X-1s; Fri, 28 Jul 2023 14:41:06 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qPOeN-003j87-2M for linux-arm-kernel@lists.infradead.org; Fri, 28 Jul 2023 14:41:05 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C88EB62180; Fri, 28 Jul 2023 14:41:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E46AC433C8; Fri, 28 Jul 2023 14:41:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690555261; bh=kSXsnHnwVcJeZp6xR87fgehZfFMYiwcUJhbgW1tPkp8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LOM6vudpAc9TxxYRLu9oYyWRiQzi3SLFY4/7ktvnUqaD0+H6Uensn1ACf9+BWOyD1 yPWlQ7JqpbKqgrqQpAeTNauI+mozOUVOJwnTk2jzLT6NvBVmd6+rq5O1uRb1SEs8Np DeuuhuBLhPIQpK3AZQbjaIJgMNifZ1UOUdIbXsZXQk1cX00smBn0/V404oT5Npfl2a QaTPxBpgo0+9UjhpEoC3FnR2Qb58MlHPKSSNIVQ6Lk3UUmwlbm80s331IiVP14FyKC x5SXJM1rczf546NzeJevmgy+hpKqS2ws7yhQRs+yybC2ZuUNAzgJxg9RjPoWRkBXtM utfFNV6zclPww== Date: Fri, 28 Jul 2023 15:40:57 +0100 From: Will Deacon To: Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, suzuki.poulose@arm.com, Catalin Marinas , Mark Rutland , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] arm_pmu: acpi: Add a representative platform device for TRBE Message-ID: <20230728144056.GE21718@willie-the-truck> References: <20230728112733.359620-1-anshuman.khandual@arm.com> <20230728112733.359620-2-anshuman.khandual@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230728112733.359620-2-anshuman.khandual@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230728_074103_854363_047CCEE9 X-CRM114-Status: GOOD ( 25.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jul 28, 2023 at 04:57:31PM +0530, Anshuman Khandual wrote: > ACPI TRBE does not have a HID for identification which could create and add > a platform device into the platform bus. Also without a platform device, it > cannot be probed and bound to a platform driver. > > This creates a dummy platform device for TRBE after ascertaining that ACPI > provides required interrupts uniformly across all cpus on the system. This > device gets created inside drivers/perf/arm_pmu_acpi.c to accommodate TRBE > being built as a module. > > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Mark Rutland > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Anshuman Khandual --->8 > diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c > index 90815ad762eb..dd3df6729808 100644 > --- a/drivers/perf/arm_pmu_acpi.c > +++ b/drivers/perf/arm_pmu_acpi.c > @@ -139,6 +139,68 @@ static inline void arm_spe_acpi_register_device(void) > } > #endif /* CONFIG_ARM_SPE_PMU */ > > +#ifdef CONFIG_CORESIGHT_TRBE > +static struct resource trbe_acpi_resources[] = { > + { > + /* irq */ > + .flags = IORESOURCE_IRQ, > + } > +}; > + > +static struct platform_device trbe_acpi_dev = { > + .name = ARMV8_TRBE_PDEV_NAME, > + .id = -1, > + .resource = trbe_acpi_resources, > + .num_resources = ARRAY_SIZE(trbe_acpi_resources) > +}; > + > +static void arm_trbe_acpi_register_device(void) > +{ > + int cpu, hetid, irq, ret; > + bool first = true; > + u16 gsi = 0; > + > + for_each_possible_cpu(cpu) { > + struct acpi_madt_generic_interrupt *gicc; > + > + gicc = acpi_cpu_get_madt_gicc(cpu); > + if (gicc->header.length < ACPI_MADT_GICC_TRBE) > + return; > + > + if (first) { > + gsi = gicc->trbe_interrupt; > + if (!gsi) > + return; > + > + hetid = find_acpi_cpu_topology_hetero_id(cpu); > + first = false; > + } else if ((gsi != gicc->trbe_interrupt) || > + (hetid != find_acpi_cpu_topology_hetero_id(cpu))) { > + pr_warn("ACPI: TRBE must be homogeneous\n"); > + return; > + } > + } > + > + irq = acpi_register_gsi(NULL, gsi, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_HIGH); > + if (irq < 0) { > + pr_warn("ACPI: TRBE Unable to register interrupt: %d\n", gsi); > + return; > + } > + trbe_acpi_resources[0].start = irq; > + > + ret = platform_device_register(&trbe_acpi_dev); > + if (ret < 0) { > + pr_warn("ACPI: TRBE: Unable to register device\n"); > + acpi_unregister_gsi(gsi); > + } > +} > +#else > +static inline void arm_trbe_acpi_register_device(void) > +{ > + > +} > +#endif /* CONFIG_CORESIGHT_TRBE */ This looks like you ran s/spe/trbe/ over the SPE device registration code :) Please can you refactor things so we don't have all the duplication? I suspect this won't be the last device which needs the same treatement. Cheers, Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel