From patchwork Fri Sep 17 13:33:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 514179 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp2235892jao; Fri, 17 Sep 2021 06:34:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3yFI2u6kJDh3jBIbhtBwaUUfIR08qRwz2o9Hfu1ecPNKR8zqH+GuWad8LFYh115LzpmVg X-Received: by 2002:a17:906:1e11:: with SMTP id g17mr12982973ejj.154.1631885653565; Fri, 17 Sep 2021 06:34:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631885653; cv=none; d=google.com; s=arc-20160816; b=v1X66XEbb5SPYug3Dn+3TpWAjjyDfw9+JOfWcfTXamM0tMMd0NAkcqsxTqh1YyxpDl DHFK1GM87+xmVsJfN8ciCpmNQYtD3+yPutnr/ddHjI+4tygqkzhxdB6U68h8ZjH8Xsh7 ARPDR00LYaepu2duIkNcL9b/II6MaFM9X9TihS+5b3I3OBArxp0y+j9+9n+MZveiMhMs O7+7k55rfMf4p1QcOnhz+G0NBj5kWRC39xXsPXqDg/+i6UipKxIN9+Zs5YVO0Y/rl4R/ AHO7VrGpHdEzlOynlL09SniSk8KTItlp5NrAuyR1IAf4HvxkeQWiItqYGe2Wv6tgSARh hE3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Q9O3evplOGjIOY/28OgNy86LQIgpZeKP1BXdbP7DPkE=; b=kilS57IGGihQ6x9H/i8u04Ygdu/gr1eiRqR5nA9yXg2BWn/eThZsYiP2s1mwlxQgpz A2RD0mZ2mOzTaocw0t2u8DrrUCu82lXNuZdScDXyboxuWmZKvJ4T8cYsohSdWGsr3gIC 6JZ4l7r5gC1TuSYqwKYOynHyhCCF9LgXJYjwsnDU5z+iXi2RdcZhFKVrhJB+m28jixO4 QaIoxD0tyQTs9QDIX1CBhg/Fy/iAQ0BL0I1ScMtaM6DJCGp5X9bwTOkl0P36XgUH05jW n7tCq6NWHyQqFB9GVPGmtyS8PRCYbQf+bO19JJqAvqrO6HWEllgS1xSnnaV9S/a92M3a Fw2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e23si6751823edj.198.2021.09.17.06.34.13; Fri, 17 Sep 2021 06:34:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244913AbhIQNfe (ORCPT + 2 others); Fri, 17 Sep 2021 09:35:34 -0400 Received: from foss.arm.com ([217.140.110.172]:53256 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240873AbhIQNfa (ORCPT ); Fri, 17 Sep 2021 09:35:30 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D789F1063; Fri, 17 Sep 2021 06:34:07 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id F2A913F719; Fri, 17 Sep 2021 06:34:06 -0700 (PDT) From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Cristian Marussi , "Rafael J . Wysocki" , Jassi Brar Subject: [PATCH v2 01/14] mailbox: pcc: Fix kernel doc warnings Date: Fri, 17 Sep 2021 14:33:44 +0100 Message-Id: <20210917133357.1911092-2-sudeep.holla@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917133357.1911092-1-sudeep.holla@arm.com> References: <20210917133357.1911092-1-sudeep.holla@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Kernel doc validation script is unhappy and complains with the below set of warnings. | drivers/mailbox/pcc.c:179: warning: Function parameter or member 'irq' | not described in 'pcc_mbox_irq' | drivers/mailbox/pcc.c:179: warning: Function parameter or member 'p' | not described in 'pcc_mbox_irq' | drivers/mailbox/pcc.c:378: warning: expecting prototype for | parse_pcc_subspaces(). Prototype was for parse_pcc_subspace() instead Fix it. Signed-off-by: Sudeep Holla --- drivers/mailbox/pcc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 0296558f9e22..23391e224a68 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -174,6 +174,10 @@ static int pcc_map_interrupt(u32 interrupt, u32 flags) /** * pcc_mbox_irq - PCC mailbox interrupt handler + * @irq: interrupt number + * @p: data/cookie passed from the caller to identify the channel + * + * Returns: IRQ_HANDLED if interrupt is handled or IRQ_NONE if not */ static irqreturn_t pcc_mbox_irq(int irq, void *p) { @@ -364,7 +368,7 @@ static const struct mbox_chan_ops pcc_chan_ops = { }; /** - * parse_pcc_subspaces -- Count PCC subspaces defined + * parse_pcc_subspace - Count PCC subspaces defined * @header: Pointer to the ACPI subtable header under the PCCT. * @end: End of subtable entry. * From patchwork Fri Sep 17 13:33:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 514180 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp2235910jao; Fri, 17 Sep 2021 06:34:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdto/3+ohJS9kUgzfgMph4Knp6KJ1bANd+L1G7Iw6sUUE/Rgka9hF653zfg3grYLUBogN4 X-Received: by 2002:a7b:ce93:: with SMTP id q19mr10442959wmj.195.1631885654198; Fri, 17 Sep 2021 06:34:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631885654; cv=none; d=google.com; s=arc-20160816; b=j5rLmex854JoZhhaONTn4x+aKRGPumvgdRNy6lzgvVIkALW64t5NqjUUMJ49ibzkS/ w5dnZIqWZNSF2AuXDjxnHmz1aiQnZcBPKcrNt9TPGTGpPVr0DHRKRE5+AjyTMuSzTJrw YjU/dLCDeRLVeCezU0wHJkzfGcLliK+o11naPwW9mqXEdrJG61kh1ZsoTKStrrpMS2uM LppAYABdDJF5XfzLXOSijsuyQGBYMQbLgHihMzCW4xvoEZBG1DNE9h8a3gzm9zrSj6t2 j3iXSw0qkmU1ng2XV5+Mz0LEfklo6gFBg+UWxgK+fV/HaJnrZL1Af9dzdOhNvK657Gi0 HETg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=UKpDK7AyTL1bz8o+w+wXAdS8UYRiJcU36xB1nAukeXk=; b=SwRHADnr50BEOSmsXc0fR5SIqiaakciplhGQBeIuqz8DCFIs50lv0SutgPNUtrJuGc mVE5M7hxPeUu7DaOBnYKoKy9zCKZhBW71dfg7MqXP8D3xNi7uaMsAqx+cltyAYk1W7lI tuzA35cB3XsCripoIyjzqRLqXhdTEZy+c+C5wUIiGKE4OQEhiOfQJw35K+KYah0J+4BI PQF8NNd05QJttzzm1UrGLfihPSEzAIcf6F9YdzLy1Z1MNIDluU+V3/m8cF++omS2+c81 4HvHnrKCUUDeX+L9dkO7tbyLzYZ9wIH4ruQP3Bsm2aTBDVF30bonU5PnBBwH7DPFCEP+ 6s9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e23si6751823edj.198.2021.09.17.06.34.14; Fri, 17 Sep 2021 06:34:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241544AbhIQNfe (ORCPT + 2 others); Fri, 17 Sep 2021 09:35:34 -0400 Received: from foss.arm.com ([217.140.110.172]:53266 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242548AbhIQNfb (ORCPT ); Fri, 17 Sep 2021 09:35:31 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F0F1B31B; Fri, 17 Sep 2021 06:34:08 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 16AB73F719; Fri, 17 Sep 2021 06:34:07 -0700 (PDT) From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Cristian Marussi , "Rafael J . Wysocki" , Jassi Brar Subject: [PATCH v2 02/14] ACPI: CPPC: Fix kernel doc warnings Date: Fri, 17 Sep 2021 14:33:45 +0100 Message-Id: <20210917133357.1911092-3-sudeep.holla@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917133357.1911092-1-sudeep.holla@arm.com> References: <20210917133357.1911092-1-sudeep.holla@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Kernel doc validation script is unhappy and complains with the below set of warnings. | drivers/acpi/cppc_acpi.c:560: warning: Function parameter or member | 'pcc_ss_id' not described in 'pcc_data_alloc' | drivers/acpi/cppc_acpi.c:1343: warning: Function parameter or member | 'cpu_num' not described in 'cppc_get_transition_latency' Fix it. Signed-off-by: Sudeep Holla --- drivers/acpi/cppc_acpi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index bd482108310c..e195123e26c0 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -561,6 +561,7 @@ bool __weak cpc_ffh_supported(void) /** * pcc_data_alloc() - Allocate the pcc_data memory for pcc subspace + * @pcc_ss_id: PCC Subspace channel identifier * * Check and allocate the cppc_pcc_data memory. * In some processor configurations it is possible that same subspace @@ -1360,12 +1361,16 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) EXPORT_SYMBOL_GPL(cppc_set_perf); /** - * cppc_get_transition_latency - returns frequency transition latency in ns + * cppc_get_transition_latency - Provides frequency transition latency in ns + * @cpu_num: Logical index of the CPU for which latencty is requested * * ACPI CPPC does not explicitly specify how a platform can specify the * transition latency for performance change requests. The closest we have * is the timing information from the PCCT tables which provides the info * on the number and frequency of PCC commands the platform can handle. + * + * Returns: frequency transition latency on success or CPUFREQ_ETERNAL on + * failure */ unsigned int cppc_get_transition_latency(int cpu_num) { From patchwork Fri Sep 17 13:33:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 514181 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp2235950jao; Fri, 17 Sep 2021 06:34:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5EmNc1cobVjCURGOPo/thZol3aBdKUndQbN7uXjYYO89F+mIbpeSbY3pYExoObOFV8xDW X-Received: by 2002:a05:600c:4eca:: with SMTP id g10mr15563058wmq.13.1631885656216; Fri, 17 Sep 2021 06:34:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631885656; cv=none; d=google.com; s=arc-20160816; b=Lp1eCqPtgIY+pLRDG/r9j7xp1RWJPFK5ZVr6QYZmHDbbBCw66eXGGhEO8r9xFCiVVa y7zY70TkbOPPhiEFlrMCHF/u+2KRODB51n4e7LsfBQtrAFSOF6C0PNfxVwfpy3W9V2B1 PpWdVexbwg2QukFFKRLXGQ3VsUYpoR2/WcFVfaI5yhlMx/d1wCizMBE5QHs0edgMw+Zo OfnEBJaNrlQw8Um06MVvMq8ZtUyrXw9ukJU2N0TBZ+TpdZkgbvh155V4NRaJoPtKZ2qy S8CZuTeTtSdwu001KRLBQ8tH0MAVpBi7fo5Yg3vBryvNrJdSvrLTanPBQcDjh4ov84mw nJPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=q8x/FJjObmw+zszVbsWksSuQevtL1rhN29vOIIzLOe8=; b=KrszcmKdxoWHJmeRRbSPxAlqKyeM22a9QnrhxPEaqAoezJQ5InzycjAHB1qAQDV7dj bk1+hgG0/PSYhh8NRB5zoLBMPRdP1g1juOdv9Ona3G9obEAlgPh2wR5l0xl5gQA8pT7e 208y1Docdo3NyR8dI0CjxE+casbETkS8vMWxcGLLzy36W9pzmDLrkDOigUJKMqqmNy9e EmH8nr5x/1LAShHTnDw05yAxm+fyXo31UAY7CbabWtIS/xKLy23q296DffFAJy0SS5ZT t4P5jl1n0R5YjjHn6lUd94cH2DB0o0/oqX9bzETFA0P9HX1uJpnNXkhfwmqGEfCrkAIf uUJQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e23si6751823edj.198.2021.09.17.06.34.16; Fri, 17 Sep 2021 06:34:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245041AbhIQNff (ORCPT + 2 others); Fri, 17 Sep 2021 09:35:35 -0400 Received: from foss.arm.com ([217.140.110.172]:53274 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244214AbhIQNfc (ORCPT ); Fri, 17 Sep 2021 09:35:32 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 13CFA113E; Fri, 17 Sep 2021 06:34:10 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2F15B3F719; Fri, 17 Sep 2021 06:34:09 -0700 (PDT) From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Cristian Marussi , "Rafael J . Wysocki" , Jassi Brar Subject: [PATCH v2 03/14] mailbox: pcc: Refactor all PCC channel information into a structure Date: Fri, 17 Sep 2021 14:33:46 +0100 Message-Id: <20210917133357.1911092-4-sudeep.holla@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917133357.1911092-1-sudeep.holla@arm.com> References: <20210917133357.1911092-1-sudeep.holla@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently all the PCC channel specific information are stored/maintained in global individual arrays for each of those information. It is not scalable and not clean if we have to stash more channel specific information. Couple of reasons to stash more information are to extend the support to Type 3/4 PCCT subspace and also to avoid accessing the PCCT table entries themselves each time we need the information. This patch moves all those PCC channel specific information into a separate structure pcc_chan_info. Signed-off-by: Sudeep Holla --- drivers/mailbox/pcc.c | 107 +++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 53 deletions(-) -- 2.25.1 diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 23391e224a68..588d2207edf9 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -64,12 +64,20 @@ static struct mbox_chan *pcc_mbox_channels; -/* Array of cached virtual address for doorbell registers */ -static void __iomem **pcc_doorbell_vaddr; -/* Array of cached virtual address for doorbell ack registers */ -static void __iomem **pcc_doorbell_ack_vaddr; -/* Array of doorbell interrupts */ -static int *pcc_doorbell_irq; +/** + * struct pcc_chan_info - PCC channel specific information + * + * @db_vaddr: cached virtual address for doorbell register + * @db_ack_vaddr: cached virtual address for doorbell ack register + * @db_irq: doorbell interrupt + */ +struct pcc_chan_info { + void __iomem *db_vaddr; + void __iomem *db_ack_vaddr; + int db_irq; +}; + +static struct pcc_chan_info *chan_info; static struct mbox_controller pcc_mbox_ctrl = {}; /** @@ -183,6 +191,7 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) { struct acpi_generic_address *doorbell_ack; struct acpi_pcct_hw_reduced *pcct_ss; + struct pcc_chan_info *pchan; struct mbox_chan *chan = p; u64 doorbell_ack_preserve; u64 doorbell_ack_write; @@ -197,17 +206,17 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) struct acpi_pcct_hw_reduced_type2 *pcct2_ss = chan->con_priv; u32 id = chan - pcc_mbox_channels; + pchan = chan_info + id; doorbell_ack = &pcct2_ss->platform_ack_register; doorbell_ack_preserve = pcct2_ss->ack_preserve_mask; doorbell_ack_write = pcct2_ss->ack_write_mask; - ret = read_register(pcc_doorbell_ack_vaddr[id], - &doorbell_ack_val, - doorbell_ack->bit_width); + ret = read_register(pchan->db_ack_vaddr, + &doorbell_ack_val, doorbell_ack->bit_width); if (ret) return IRQ_NONE; - ret = write_register(pcc_doorbell_ack_vaddr[id], + ret = write_register(pchan->db_ack_vaddr, (doorbell_ack_val & doorbell_ack_preserve) | doorbell_ack_write, doorbell_ack->bit_width); @@ -232,8 +241,9 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) * ERR_PTR. */ struct mbox_chan *pcc_mbox_request_channel(struct mbox_client *cl, - int subspace_id) + int subspace_id) { + struct pcc_chan_info *pchan; struct device *dev = pcc_mbox_ctrl.dev; struct mbox_chan *chan; unsigned long flags; @@ -251,6 +261,7 @@ struct mbox_chan *pcc_mbox_request_channel(struct mbox_client *cl, dev_err(dev, "Channel not found for idx: %d\n", subspace_id); return ERR_PTR(-EBUSY); } + pchan = chan_info + subspace_id; spin_lock_irqsave(&chan->lock, flags); chan->msg_free = 0; @@ -264,14 +275,14 @@ struct mbox_chan *pcc_mbox_request_channel(struct mbox_client *cl, spin_unlock_irqrestore(&chan->lock, flags); - if (pcc_doorbell_irq[subspace_id] > 0) { + if (pchan->db_irq > 0) { int rc; - rc = devm_request_irq(dev, pcc_doorbell_irq[subspace_id], - pcc_mbox_irq, 0, MBOX_IRQ_NAME, chan); + rc = devm_request_irq(dev, pchan->db_irq, pcc_mbox_irq, 0, + MBOX_IRQ_NAME, chan); if (unlikely(rc)) { dev_err(dev, "failed to register PCC interrupt %d\n", - pcc_doorbell_irq[subspace_id]); + pchan->db_irq); pcc_mbox_free_channel(chan); chan = ERR_PTR(rc); } @@ -290,6 +301,7 @@ EXPORT_SYMBOL_GPL(pcc_mbox_request_channel); void pcc_mbox_free_channel(struct mbox_chan *chan) { u32 id = chan - pcc_mbox_channels; + struct pcc_chan_info *pchan; unsigned long flags; if (!chan || !chan->cl) @@ -300,8 +312,9 @@ void pcc_mbox_free_channel(struct mbox_chan *chan) return; } - if (pcc_doorbell_irq[id] > 0) - devm_free_irq(chan->mbox->dev, pcc_doorbell_irq[id], chan); + pchan = chan_info + id; + if (pchan->db_irq > 0) + devm_free_irq(chan->mbox->dev, pchan->db_irq, chan); spin_lock_irqsave(&chan->lock, flags); chan->cl = NULL; @@ -329,6 +342,7 @@ static int pcc_send_data(struct mbox_chan *chan, void *data) { struct acpi_pcct_hw_reduced *pcct_ss = chan->con_priv; struct acpi_generic_address *doorbell; + struct pcc_chan_info *pchan; u64 doorbell_preserve; u64 doorbell_val; u64 doorbell_write; @@ -340,19 +354,20 @@ static int pcc_send_data(struct mbox_chan *chan, void *data) return -ENOENT; } + pchan = chan_info + id; doorbell = &pcct_ss->doorbell_register; doorbell_preserve = pcct_ss->preserve_mask; doorbell_write = pcct_ss->write_mask; /* Sync notification from OS to Platform. */ - if (pcc_doorbell_vaddr[id]) { - ret = read_register(pcc_doorbell_vaddr[id], &doorbell_val, - doorbell->bit_width); + if (pchan->db_vaddr) { + ret = read_register(pchan->db_vaddr, &doorbell_val, + doorbell->bit_width); if (ret) return ret; - ret = write_register(pcc_doorbell_vaddr[id], - (doorbell_val & doorbell_preserve) | doorbell_write, - doorbell->bit_width); + ret = write_register(pchan->db_vaddr, + (doorbell_val & doorbell_preserve) + | doorbell_write, doorbell->bit_width); } else { ret = acpi_read(&doorbell_val, doorbell); if (ret) @@ -398,12 +413,13 @@ static int parse_pcc_subspace(union acpi_subtable_headers *header, * * This gets called for each entry in the PCC table. */ -static int pcc_parse_subspace_irq(int id, - struct acpi_pcct_hw_reduced *pcct_ss) +static int pcc_parse_subspace_irq(int id, struct acpi_pcct_hw_reduced *pcct_ss) { - pcc_doorbell_irq[id] = pcc_map_interrupt(pcct_ss->platform_interrupt, - (u32)pcct_ss->flags); - if (pcc_doorbell_irq[id] <= 0) { + struct pcc_chan_info *pchan = chan_info + id; + + pchan->db_irq = pcc_map_interrupt(pcct_ss->platform_interrupt, + (u32)pcct_ss->flags); + if (pchan->db_irq <= 0) { pr_err("PCC GSI %d not registered\n", pcct_ss->platform_interrupt); return -EINVAL; @@ -413,10 +429,10 @@ static int pcc_parse_subspace_irq(int id, == ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2) { struct acpi_pcct_hw_reduced_type2 *pcct2_ss = (void *)pcct_ss; - pcc_doorbell_ack_vaddr[id] = acpi_os_ioremap( - pcct2_ss->platform_ack_register.address, - pcct2_ss->platform_ack_register.bit_width / 8); - if (!pcc_doorbell_ack_vaddr[id]) { + pchan->db_ack_vaddr = + acpi_os_ioremap(pcct2_ss->platform_ack_register.address, + pcct2_ss->platform_ack_register.bit_width / 8); + if (!pchan->db_ack_vaddr) { pr_err("Failed to ioremap PCC ACK register\n"); return -ENOMEM; } @@ -474,24 +490,12 @@ static int __init acpi_pcc_probe(void) goto err_put_pcct; } - pcc_doorbell_vaddr = kcalloc(count, sizeof(void *), GFP_KERNEL); - if (!pcc_doorbell_vaddr) { + chan_info = kcalloc(count, sizeof(*chan_info), GFP_KERNEL); + if (!chan_info) { rc = -ENOMEM; goto err_free_mbox; } - pcc_doorbell_ack_vaddr = kcalloc(count, sizeof(void *), GFP_KERNEL); - if (!pcc_doorbell_ack_vaddr) { - rc = -ENOMEM; - goto err_free_db_vaddr; - } - - pcc_doorbell_irq = kcalloc(count, sizeof(int), GFP_KERNEL); - if (!pcc_doorbell_irq) { - rc = -ENOMEM; - goto err_free_db_ack_vaddr; - } - /* Point to the first PCC subspace entry */ pcct_entry = (struct acpi_subtable_header *) ( (unsigned long) pcct_tbl + sizeof(struct acpi_table_pcct)); @@ -501,6 +505,7 @@ static int __init acpi_pcc_probe(void) pcc_mbox_ctrl.txdone_irq = true; for (i = 0; i < count; i++) { + struct pcc_chan_info *pchan = chan_info + i; struct acpi_generic_address *db_reg; struct acpi_pcct_subspace *pcct_ss; pcc_mbox_channels[i].con_priv = pcct_entry; @@ -522,8 +527,8 @@ static int __init acpi_pcc_probe(void) /* If doorbell is in system memory cache the virt address */ db_reg = &pcct_ss->doorbell_register; if (db_reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) - pcc_doorbell_vaddr[i] = acpi_os_ioremap(db_reg->address, - db_reg->bit_width/8); + pchan->db_vaddr = acpi_os_ioremap(db_reg->address, + db_reg->bit_width / 8); pcct_entry = (struct acpi_subtable_header *) ((unsigned long) pcct_entry + pcct_entry->length); } @@ -535,11 +540,7 @@ static int __init acpi_pcc_probe(void) return 0; err: - kfree(pcc_doorbell_irq); -err_free_db_ack_vaddr: - kfree(pcc_doorbell_ack_vaddr); -err_free_db_vaddr: - kfree(pcc_doorbell_vaddr); + kfree(chan_info); err_free_mbox: kfree(pcc_mbox_channels); err_put_pcct: From patchwork Fri Sep 17 13:33:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 514182 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp2236006jao; Fri, 17 Sep 2021 06:34:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0OniaJ/vLxLWIwfnVuvQLJl/wG88xMVIxY8lMt3lKJE5AJobEdcyrZa4j63aZjK2ytxqI X-Received: by 2002:a7b:cb53:: with SMTP id v19mr10648685wmj.127.1631885658913; Fri, 17 Sep 2021 06:34:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631885658; cv=none; d=google.com; s=arc-20160816; b=FwxQiaZzVPhtn3uY4NY8UfS4m+gctD3X4Rbe6NN36hzW48RGKW1Ip04tI85/0rIU8u j0HzvMbUAjCkQWG8smvgg1sGk15QxjA9EudV7qkQlj+v27fMSNLukSwRdA6KpQj39T7P VFE09fVpQFxhOyxy9aiz5y3dygW42tvWYZIuQ4PNNPO8lhid/QrLMcfkkARSPjGn0WkA Fjx9/iqjPGqhwKQgQP4JaxDmBqrl2s1r1/0rqjHPdiywsYMBQyIa/y6EcL6HX0Mdmv91 QiQZ4XidOx8KR0/oTeBDviYDOQPohS6/foHOt7rPHhrbskBWUIBMzT4bPyYeCDl3+X9v 5gbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=PIfJPaXL1450V/0tWZM0n1NlRDCZtSyPAliXYUds05U=; b=janDeQUaA3nmdl6hc4E/v+yYIjtb5+A2CRcSjZtMcRIGLsVqBk02ulf5Tiryf0HyGk q/uoUipvdqLfWD2HctcH2PD4MTSztmxGU8YJxWn1tQ6InLewa+PiLzt0uXhPBivH6qxv WvRbLn2IT8lcZhdJIUQCH62x2vaYCMZjEjW7+/xERH0KTuVAuqFeMT9XDyeyHve1QUt0 +UlNzsKkmdKYOHeDeMt7iy1a3AWOSOPxjzCGI5rV3ioKGk+MmaeOitfpg233B0Kkqj5F FEfJZZsp7Rok/8oOYgdUWeKf8qkUUas2g7Ol8R9E0DZkOs/dCbr8OOK6+RYkEIZXra3E INWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e23si6751823edj.198.2021.09.17.06.34.18; Fri, 17 Sep 2021 06:34:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245057AbhIQNfg (ORCPT + 2 others); Fri, 17 Sep 2021 09:35:36 -0400 Received: from foss.arm.com ([217.140.110.172]:53282 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240676AbhIQNfd (ORCPT ); Fri, 17 Sep 2021 09:35:33 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2BDD811B3; Fri, 17 Sep 2021 06:34:11 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 474D53F719; Fri, 17 Sep 2021 06:34:10 -0700 (PDT) From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Cristian Marussi , "Rafael J . Wysocki" , Jassi Brar Subject: [PATCH v2 04/14] mailbox: pcc: Consolidate subspace interrupt information parsing Date: Fri, 17 Sep 2021 14:33:47 +0100 Message-Id: <20210917133357.1911092-5-sudeep.holla@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917133357.1911092-1-sudeep.holla@arm.com> References: <20210917133357.1911092-1-sudeep.holla@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Extended PCC subspaces(Type 3 and 4) differ from generic(Type 0) and HW-Reduced Communication(Type 1 and 2) subspace structures. However some fields share same offsets and same type of structure can be use to extract the fields. In order to simplify that, let us move all the IRQ related information parsing into pcc_parse_subspace_irq and consolidate there. It will be easier to extend it if required within the same. Reviewed-by: Cristian Marussi Signed-off-by: Sudeep Holla --- drivers/mailbox/pcc.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) -- 2.25.1 diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 588d2207edf9..efde77d7038c 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -405,18 +405,26 @@ static int parse_pcc_subspace(union acpi_subtable_headers *header, /** * pcc_parse_subspace_irq - Parse the PCC IRQ and PCC ACK register - * There should be one entry per PCC client. - * @id: PCC subspace index. - * @pcct_ss: Pointer to the ACPI subtable header under the PCCT. + * + * @pchan: Pointer to the PCC channel info structure. + * @pcct_entry: Pointer to the ACPI subtable header. * * Return: 0 for Success, else errno. * - * This gets called for each entry in the PCC table. + * There should be one entry per PCC channel. This gets called for each + * entry in the PCC table. This uses PCCY Type1 structure for all applicable + * types(Type 1-4) to fetch irq */ -static int pcc_parse_subspace_irq(int id, struct acpi_pcct_hw_reduced *pcct_ss) +static int pcc_parse_subspace_irq(struct pcc_chan_info *pchan, + struct acpi_subtable_header *pcct_entry) { - struct pcc_chan_info *pchan = chan_info + id; + struct acpi_pcct_hw_reduced *pcct_ss; + if (pcct_entry->type < ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE || + pcct_entry->type > ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE) + return 0; + + pcct_ss = (struct acpi_pcct_hw_reduced *)pcct_entry; pchan->db_irq = pcc_map_interrupt(pcct_ss->platform_interrupt, (u32)pcct_ss->flags); if (pchan->db_irq <= 0) { @@ -425,8 +433,7 @@ static int pcc_parse_subspace_irq(int id, struct acpi_pcct_hw_reduced *pcct_ss) return -EINVAL; } - if (pcct_ss->header.type - == ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2) { + if (pcct_ss->header.type == ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2) { struct acpi_pcct_hw_reduced_type2 *pcct2_ss = (void *)pcct_ss; pchan->db_ack_vaddr = @@ -510,17 +517,10 @@ static int __init acpi_pcc_probe(void) struct acpi_pcct_subspace *pcct_ss; pcc_mbox_channels[i].con_priv = pcct_entry; - if (pcct_entry->type == ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE || - pcct_entry->type == ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2) { - struct acpi_pcct_hw_reduced *pcct_hrss; - - pcct_hrss = (struct acpi_pcct_hw_reduced *) pcct_entry; - - if (pcc_mbox_ctrl.txdone_irq) { - rc = pcc_parse_subspace_irq(i, pcct_hrss); - if (rc < 0) - goto err; - } + if (pcc_mbox_ctrl.txdone_irq) { + rc = pcc_parse_subspace_irq(pchan, pcct_entry); + if (rc < 0) + goto err; } pcct_ss = (struct acpi_pcct_subspace *) pcct_entry; From patchwork Fri Sep 17 13:33:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 514183 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp2236073jao; Fri, 17 Sep 2021 06:34:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvgi3D23iBf+YsqREAofsoJhf6KA2fSZKmv6XbfycEOJOee3GuGscvDpXrutErhuPfhYUq X-Received: by 2002:a17:906:b7cf:: with SMTP id fy15mr12514879ejb.397.1631885662552; Fri, 17 Sep 2021 06:34:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631885662; cv=none; d=google.com; s=arc-20160816; b=MdbDdYmELnU3uvnOSoXVHhNU+rQMS3tXpb3nCPrcP5lc3eOt+Utspl+gAg+XbOg8MH /lgkjkPiv3hcZbkUBmLOcmVT5rtOHUtbK/Jnguig6+FoErgSlXwLsNz1NivNoLZwn6Si kwfMmFF3jRSkpNDB+wQnp7/9u0yTu9EQaMbXorFm9hHW5D1QhRDrkZKRVwnylAW+h5fN dcGhgh5GmcpeAUdRMo++gP2Zbe+mb3Q7I3EdOqBtnXT0ztfNldE8Ngu0mN5rK7UxQ5ch z9vblvt4k8EvLOGUFXw/E1kTEqq/dCDU5m0nlYHmWPwdYECiCatXMfFz86kxUeSjMRWb ubsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=uywjvFr7ZBP6NM+Rxe/22MlLrePXJIyX80Pxxb+0lrc=; b=tBbvIkHy31Ugw7S3JziRF4vYCa3qQnPQaNZRYPLmZ4pNeTGkdhMk+t33SMZazfB3n4 HYQncUFmMC3b+GmYkloABOkDhKPXMbX1n+YvJ3xcrofD3ei+Xwyr1V1bLF6EDqii7+yb ubBR6Va2+EsdnfqKET9rTKrA6zyDHFHajmdrMos9nc1nLPjwdRTiMBE5tGo0HnWYnuSR Os8ayBhu7Fpad6oa418Dvpd+SRX3xWJbOUEwYnLdI0r4LsoDEI/PNv/Zm94f+ZlwGA6n pWU1Ehs7FKHw9j5SnTeE54whgTq/yX7FJmLvAOxiKwbG0P1w4ildOUXO3nobNKlm+R2Q oM2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 5si1232151ejq.398.2021.09.17.06.34.22; Fri, 17 Sep 2021 06:34:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245263AbhIQNfn (ORCPT + 2 others); Fri, 17 Sep 2021 09:35:43 -0400 Received: from foss.arm.com ([217.140.110.172]:53286 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244872AbhIQNfe (ORCPT ); Fri, 17 Sep 2021 09:35:34 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4460011D4; Fri, 17 Sep 2021 06:34:12 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5F87F3F719; Fri, 17 Sep 2021 06:34:11 -0700 (PDT) From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Cristian Marussi , "Rafael J . Wysocki" , Jassi Brar Subject: [PATCH v2 05/14] mailbox: pcc: Consolidate subspace doorbell register parsing Date: Fri, 17 Sep 2021 14:33:48 +0100 Message-Id: <20210917133357.1911092-6-sudeep.holla@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917133357.1911092-1-sudeep.holla@arm.com> References: <20210917133357.1911092-1-sudeep.holla@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Extended PCC subspaces(Type 3 and 4) differ from generic(Type 0) and HW-Reduced Communication(Type 1 and 2) subspace structures. However some fields share same offsets and same type of structure can be use to extract the fields. In order to simplify that, let us move all the doorbell register parsing into pcc_parse_subspace_db_reg and consolidate there. It will be easier to extend it if required within the same. Reviewed-by: Cristian Marussi Signed-off-by: Sudeep Holla --- drivers/mailbox/pcc.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) -- 2.25.1 diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index efde77d7038c..97c44c431ada 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -448,6 +448,28 @@ static int pcc_parse_subspace_irq(struct pcc_chan_info *pchan, return 0; } +/** + * pcc_parse_subspace_db_reg - Parse the PCC doorbell register + * + * @pchan: Pointer to the PCC channel info structure. + * @pcct_entry: Pointer to the ACPI subtable header. + * + */ +static void pcc_parse_subspace_db_reg(struct pcc_chan_info *pchan, + struct acpi_subtable_header *pcct_entry) +{ + struct acpi_pcct_subspace *pcct_ss; + struct acpi_generic_address *db_reg; + + pcct_ss = (struct acpi_pcct_subspace *)pcct_entry; + + /* If doorbell is in system memory cache the virt address */ + db_reg = &pcct_ss->doorbell_register; + if (db_reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) + pchan->db_vaddr = acpi_os_ioremap(db_reg->address, + db_reg->bit_width / 8); +} + /** * acpi_pcc_probe - Parse the ACPI tree for the PCCT. * @@ -513,8 +535,6 @@ static int __init acpi_pcc_probe(void) for (i = 0; i < count; i++) { struct pcc_chan_info *pchan = chan_info + i; - struct acpi_generic_address *db_reg; - struct acpi_pcct_subspace *pcct_ss; pcc_mbox_channels[i].con_priv = pcct_entry; if (pcc_mbox_ctrl.txdone_irq) { @@ -522,13 +542,8 @@ static int __init acpi_pcc_probe(void) if (rc < 0) goto err; } - pcct_ss = (struct acpi_pcct_subspace *) pcct_entry; + pcc_parse_subspace_db_reg(pchan, pcct_entry); - /* If doorbell is in system memory cache the virt address */ - db_reg = &pcct_ss->doorbell_register; - if (db_reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) - pchan->db_vaddr = acpi_os_ioremap(db_reg->address, - db_reg->bit_width / 8); pcct_entry = (struct acpi_subtable_header *) ((unsigned long) pcct_entry + pcct_entry->length); } From patchwork Fri Sep 17 13:33:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 514184 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp2236176jao; Fri, 17 Sep 2021 06:34:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyISmYGQVKQHBJQ9mtkD4S4VZK0spg2CG3b2y04Nq3U+SpEd61QRHfuVvf5E9eeThhiuKk X-Received: by 2002:adf:ee49:: with SMTP id w9mr12034327wro.158.1631885668170; Fri, 17 Sep 2021 06:34:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631885668; cv=none; d=google.com; s=arc-20160816; b=VxVS/AU+MXoGbCROYCv6yt/pb5hyiemncbvkUi347xqAfEkUsGcunGTvXn1DZJYvtI kBKNhceYj3YB0rNszfTuv5U3hNlTOtuQJhAb/Uqkcrtl0TEydGsLT0mgSulB+ZCs3fSu sAj6HfE5xOJZbcqNIScc65q4+4dpa/3GYmo6RQcp5T0t3p1HI9lDRE3eIiA4DI86Z8VR nysp4Nd6rq/wkXwv1ci4f6mey3mgMjRdm92PhE1SgA7X05ywk2ejxGoNxOQOcTTeEZSv je8WrfJAj58uOIH21QqBArv8cK83AlfJDtF9cq9QZd/LHkagwk3BR8Bk/g26ToAErP9r jPXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=2Jbuh89PE6hEuUvCetJuTyWBSKAk2FyqyrvStyF+yFY=; b=0Pre6Lid9hiucIely5e7ay8BWqSDedJw34NPG28SCigShQ6LAMS6xHTmg4+aqhl8Zy BMhsxvxfJecBH9R4R11rR4PrpWJJ+98RwJ4Tqx0T6fUuOX91P6f7ix58OAMA0y280AQM 26W176V2bM0oRPHeqMfwSu7EqJl2ROBQbGxRH2jZ4qZYoFH3KwtJQyx4STezpLRaj1/A KMibdz0fifHH3iuTiygJSfhFkEBWEoxVjXTO8w7mVBhIugy25D0BgwfJUPs1ic1t3Bpe +0OgnChojfyg0O0tbTTRguP6wL4BJjJrkJXq7Wp+TZMz5EBR+xZa/sxlTX8DsPbUByVd 4qwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x16si8402433edd.25.2021.09.17.06.34.27; Fri, 17 Sep 2021 06:34:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245380AbhIQNft (ORCPT + 2 others); Fri, 17 Sep 2021 09:35:49 -0400 Received: from foss.arm.com ([217.140.110.172]:53292 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245047AbhIQNff (ORCPT ); Fri, 17 Sep 2021 09:35:35 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5C7CE31B; Fri, 17 Sep 2021 06:34:13 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 77D3A3F719; Fri, 17 Sep 2021 06:34:12 -0700 (PDT) From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Cristian Marussi , "Rafael J . Wysocki" , Jassi Brar Subject: [PATCH v2 06/14] mailbox: pcc: Add pcc_mbox_chan structure to hold shared memory region info Date: Fri, 17 Sep 2021 14:33:49 +0100 Message-Id: <20210917133357.1911092-7-sudeep.holla@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917133357.1911092-1-sudeep.holla@arm.com> References: <20210917133357.1911092-1-sudeep.holla@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently PCC mailbox controller sets con_priv in each channel to hold the pointer to pcct subspace entry it corresponds to. The mailbox user will then fetch this pointer from the channel descriptor they get when they request for the channel. Using that pointer they then parse the pcct entry again to fetch all the information about shared memory region. In order to remove individual users of PCC mailbox parsing the PCCT subspace entries to fetch same information, let us consolidate the same in pcc mailbox controller by parsing all the shared memory region information into a structure that can also hold the mbox_chan pointer it represent. This can then be used as main PCC mailbox channel pointer that we can return as part of pcc_mbox_request_channel instead of standard mailbox channel pointer. Reviewed-by: Cristian Marussi Signed-off-by: Sudeep Holla --- drivers/mailbox/pcc.c | 27 +++++++++++++++++++++++++++ include/acpi/pcc.h | 9 +++++++++ 2 files changed, 36 insertions(+) -- 2.25.1 diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 97c44c431ada..f358ced827f2 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -67,11 +67,13 @@ static struct mbox_chan *pcc_mbox_channels; /** * struct pcc_chan_info - PCC channel specific information * + * @chan: PCC channel information with Shared Memory Region info * @db_vaddr: cached virtual address for doorbell register * @db_ack_vaddr: cached virtual address for doorbell ack register * @db_irq: doorbell interrupt */ struct pcc_chan_info { + struct pcc_mbox_chan chan; void __iomem *db_vaddr; void __iomem *db_ack_vaddr; int db_irq; @@ -470,6 +472,27 @@ static void pcc_parse_subspace_db_reg(struct pcc_chan_info *pchan, db_reg->bit_width / 8); } +/** + * pcc_parse_subspace_shmem - Parse the PCC Shared Memory Region information + * + * @pchan: Pointer to the PCC channel info structure. + * @pcct_entry: Pointer to the ACPI subtable header. + * + */ +static void pcc_parse_subspace_shmem(struct pcc_chan_info *pchan, + struct acpi_subtable_header *pcct_entry) +{ + struct acpi_pcct_subspace *pcct_ss; + + pcct_ss = (struct acpi_pcct_subspace *)pcct_entry; + + pchan->chan.shmem_base_addr = pcct_ss->base_address; + pchan->chan.shmem_size = pcct_ss->length; + pchan->chan.latency = pcct_ss->latency; + pchan->chan.max_access_rate = pcct_ss->max_access_rate; + pchan->chan.min_turnaround_time = pcct_ss->min_turnaround_time; +} + /** * acpi_pcc_probe - Parse the ACPI tree for the PCCT. * @@ -537,6 +560,8 @@ static int __init acpi_pcc_probe(void) struct pcc_chan_info *pchan = chan_info + i; pcc_mbox_channels[i].con_priv = pcct_entry; + pchan->chan.mchan = &pcc_mbox_channels[i]; + if (pcc_mbox_ctrl.txdone_irq) { rc = pcc_parse_subspace_irq(pchan, pcct_entry); if (rc < 0) @@ -544,6 +569,8 @@ static int __init acpi_pcc_probe(void) } pcc_parse_subspace_db_reg(pchan, pcct_entry); + pcc_parse_subspace_shmem(pchan, pcct_entry); + pcct_entry = (struct acpi_subtable_header *) ((unsigned long) pcct_entry + pcct_entry->length); } diff --git a/include/acpi/pcc.h b/include/acpi/pcc.h index 4dec4ed138cd..5e510a6b8052 100644 --- a/include/acpi/pcc.h +++ b/include/acpi/pcc.h @@ -9,6 +9,15 @@ #include #include +struct pcc_mbox_chan { + struct mbox_chan *mchan; + u64 shmem_base_addr; + u64 shmem_size; + u32 latency; + u32 max_access_rate; + u16 min_turnaround_time; +}; + #define MAX_PCC_SUBSPACES 256 #ifdef CONFIG_PCC extern struct mbox_chan *pcc_mbox_request_channel(struct mbox_client *cl, From patchwork Fri Sep 17 13:33:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 514185 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp2236190jao; Fri, 17 Sep 2021 06:34:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKZvSoV7kL2JSdbQuXAnKues6UQKeplfTCEol85Ae9POCDS/MHek4IEJfIRVAnbBox79C3 X-Received: by 2002:a5d:4bc8:: with SMTP id l8mr12536521wrt.105.1631885669321; Fri, 17 Sep 2021 06:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631885669; cv=none; d=google.com; s=arc-20160816; b=fO1zPssl1DGkyDu63DyLHUS6nRQmDSLe7xZyAeQL/Dqy42+pA+S+qANLON6Wk647SG ckj02HwFuvmKo3b7K0a2gmhzyNHII+qToFbl2l/Xpd6xuTTWFnFvPThhnlpZ6YZ0I4Gm SIo+f5Ob6KLf2D53hYGkd6YK8olNVUWgRFErpCaZYJt36GscBv0KKJBtSyvhspWTmhYT BXXWLN/eW/mcLl/Ulg0rOSS5RSmWZpQdirx+vfjJyVD0/P1oiribw4JBikQDSAbEz6Ae EJrovEDUuwZuJt9XZ8Ad2TjR3Fw6knlSdUULeu3mPkDeJ1ap9BOsH/F5dmGf3NbPUjZW Tr/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=IRyQ9tW2b7NgOHg7KS22k/R/kz61rZeTs8tzO3rkbyE=; b=gCnPjND+L1+keTREmQdwamF6d9NkZ5h3sXAa8f8oPYQnMRaFFSBcaoDAyLWq6E8nP6 TxjUtSo16uo74vdjJsbzc+xvx1hGP8unhb/WvUHU79M4beUlW5j4ceL4GGDAVWf4ndqs USD9AoGGSmm5cfRIQAn7JrHX/U6oac11u4SoaMgb1o0ZdgU7zSEdo1Wd6IB8X2+1cDbC BgTksJb2NWVhNwI19c/P1oV1sUW0H5QwY/7p2kfvTL2OmNpRuGrSn1kjfJ4L7zJh/SWq 5zJHjQ9ABBvM+/xIuXoJJrEHG4nP2HGvOvM+AKyL4IA/x2mcwfbfpKLN24zwZgPCJaZm 9DSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x16si8402433edd.25.2021.09.17.06.34.29; Fri, 17 Sep 2021 06:34:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245447AbhIQNft (ORCPT + 2 others); Fri, 17 Sep 2021 09:35:49 -0400 Received: from foss.arm.com ([217.140.110.172]:53302 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244821AbhIQNfj (ORCPT ); Fri, 17 Sep 2021 09:35:39 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 218B61063; Fri, 17 Sep 2021 06:34:15 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 914413F719; Fri, 17 Sep 2021 06:34:13 -0700 (PDT) From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Cristian Marussi , "Rafael J . Wysocki" , Jassi Brar , Jean Delvare , Guenter Roeck , Wolfram Sang , linux-hwmon@vger.kernel.org, linux-i2c@vger.kernel.org Subject: [PATCH v2 07/14] mailbox: pcc: Use PCC mailbox channel pointer instead of standard Date: Fri, 17 Sep 2021 14:33:50 +0100 Message-Id: <20210917133357.1911092-8-sudeep.holla@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917133357.1911092-1-sudeep.holla@arm.com> References: <20210917133357.1911092-1-sudeep.holla@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Now that we have all the shared memory region information populated in the pcc_mbox_chan, let us propagate the pointer to the same as the return value to pcc_mbox_request channel. This eliminates the need for the individual users of PCC mailbox to parse the PCCT subspace entries and fetch the shmem information. This also eliminates the need for PCC mailbox controller to set con_priv to PCCT subspace entries. This is required as con_priv is private to the controller driver to attach private data associated with the channel and not meant to be used by the mailbox client/users. Let us convert all the users of pcc_mbox_{request,free}_channel to use new interface. Cc: Jean Delvare Cc: Guenter Roeck Cc: Wolfram Sang Cc: linux-hwmon@vger.kernel.org Cc: linux-i2c@vger.kernel.org Signed-off-by: Sudeep Holla --- drivers/acpi/cppc_acpi.c | 43 ++++++------------ drivers/hwmon/xgene-hwmon.c | 35 ++++++-------- drivers/i2c/busses/i2c-xgene-slimpro.c | 33 +++++--------- drivers/mailbox/pcc.c | 63 ++++++++------------------ include/acpi/pcc.h | 12 ++--- 5 files changed, 64 insertions(+), 122 deletions(-) -- 2.25.1 Acked-by: Wolfram Sang Acked-by: Guenter Roeck diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index e195123e26c0..aa6623bd3f00 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -43,7 +43,7 @@ #include struct cppc_pcc_data { - struct mbox_chan *pcc_channel; + struct pcc_mbox_chan *pcc_channel; void __iomem *pcc_comm_addr; bool pcc_channel_acquired; unsigned int deadline_us; @@ -295,7 +295,7 @@ static int send_pcc_cmd(int pcc_ss_id, u16 cmd) pcc_ss_data->platform_owns_pcc = true; /* Ring doorbell */ - ret = mbox_send_message(pcc_ss_data->pcc_channel, &cmd); + ret = mbox_send_message(pcc_ss_data->pcc_channel->mchan, &cmd); if (ret < 0) { pr_err("Err sending PCC mbox message. ss: %d cmd:%d, ret:%d\n", pcc_ss_id, cmd, ret); @@ -308,10 +308,10 @@ static int send_pcc_cmd(int pcc_ss_id, u16 cmd) if (pcc_ss_data->pcc_mrtt) pcc_ss_data->last_cmd_cmpl_time = ktime_get(); - if (pcc_ss_data->pcc_channel->mbox->txdone_irq) - mbox_chan_txdone(pcc_ss_data->pcc_channel, ret); + if (pcc_ss_data->pcc_channel->mchan->mbox->txdone_irq) + mbox_chan_txdone(pcc_ss_data->pcc_channel->mchan, ret); else - mbox_client_txdone(pcc_ss_data->pcc_channel, ret); + mbox_client_txdone(pcc_ss_data->pcc_channel->mchan, ret); end: if (cmd == CMD_WRITE) { @@ -493,46 +493,33 @@ EXPORT_SYMBOL_GPL(acpi_get_psd_map); static int register_pcc_channel(int pcc_ss_idx) { - struct acpi_pcct_hw_reduced *cppc_ss; + struct pcc_mbox_chan *pcc_chan; u64 usecs_lat; if (pcc_ss_idx >= 0) { - pcc_data[pcc_ss_idx]->pcc_channel = - pcc_mbox_request_channel(&cppc_mbox_cl, pcc_ss_idx); + pcc_chan = pcc_mbox_request_channel(&cppc_mbox_cl, pcc_ss_idx); - if (IS_ERR(pcc_data[pcc_ss_idx]->pcc_channel)) { + if (IS_ERR(pcc_chan)) { pr_err("Failed to find PCC channel for subspace %d\n", pcc_ss_idx); return -ENODEV; } - /* - * The PCC mailbox controller driver should - * have parsed the PCCT (global table of all - * PCC channels) and stored pointers to the - * subspace communication region in con_priv. - */ - cppc_ss = (pcc_data[pcc_ss_idx]->pcc_channel)->con_priv; - - if (!cppc_ss) { - pr_err("No PCC subspace found for %d CPPC\n", - pcc_ss_idx); - return -ENODEV; - } - + pcc_data[pcc_ss_idx]->pcc_channel = pcc_chan; /* * cppc_ss->latency is just a Nominal value. In reality * the remote processor could be much slower to reply. * So add an arbitrary amount of wait on top of Nominal. */ - usecs_lat = NUM_RETRIES * cppc_ss->latency; + usecs_lat = NUM_RETRIES * pcc_chan->latency; pcc_data[pcc_ss_idx]->deadline_us = usecs_lat; - pcc_data[pcc_ss_idx]->pcc_mrtt = cppc_ss->min_turnaround_time; - pcc_data[pcc_ss_idx]->pcc_mpar = cppc_ss->max_access_rate; - pcc_data[pcc_ss_idx]->pcc_nominal = cppc_ss->latency; + pcc_data[pcc_ss_idx]->pcc_mrtt = pcc_chan->min_turnaround_time; + pcc_data[pcc_ss_idx]->pcc_mpar = pcc_chan->max_access_rate; + pcc_data[pcc_ss_idx]->pcc_nominal = pcc_chan->latency; pcc_data[pcc_ss_idx]->pcc_comm_addr = - acpi_os_ioremap(cppc_ss->base_address, cppc_ss->length); + acpi_os_ioremap(pcc_chan->shmem_base_addr, + pcc_chan->shmem_size); if (!pcc_data[pcc_ss_idx]->pcc_comm_addr) { pr_err("Failed to ioremap PCC comm region mem for %d\n", pcc_ss_idx); diff --git a/drivers/hwmon/xgene-hwmon.c b/drivers/hwmon/xgene-hwmon.c index 382ef0395d8e..30aae8642069 100644 --- a/drivers/hwmon/xgene-hwmon.c +++ b/drivers/hwmon/xgene-hwmon.c @@ -93,6 +93,7 @@ struct slimpro_resp_msg { struct xgene_hwmon_dev { struct device *dev; struct mbox_chan *mbox_chan; + struct pcc_mbox_chan *pcc_chan; struct mbox_client mbox_client; int mbox_idx; @@ -652,7 +653,7 @@ static int xgene_hwmon_probe(struct platform_device *pdev) goto out_mbox_free; } } else { - struct acpi_pcct_hw_reduced *cppc_ss; + struct pcc_mbox_chan *pcc_chan; const struct acpi_device_id *acpi_id; int version; @@ -671,26 +672,16 @@ static int xgene_hwmon_probe(struct platform_device *pdev) } cl->rx_callback = xgene_hwmon_pcc_rx_cb; - ctx->mbox_chan = pcc_mbox_request_channel(cl, ctx->mbox_idx); - if (IS_ERR(ctx->mbox_chan)) { + pcc_chan = pcc_mbox_request_channel(cl, ctx->mbox_idx); + if (IS_ERR(pcc_chan)) { dev_err(&pdev->dev, "PPC channel request failed\n"); rc = -ENODEV; goto out_mbox_free; } - /* - * The PCC mailbox controller driver should - * have parsed the PCCT (global table of all - * PCC channels) and stored pointers to the - * subspace communication region in con_priv. - */ - cppc_ss = ctx->mbox_chan->con_priv; - if (!cppc_ss) { - dev_err(&pdev->dev, "PPC subspace not found\n"); - rc = -ENODEV; - goto out; - } + ctx->pcc_chan = pcc_chan; + ctx->mbox_chan = pcc_chan->mchan; if (!ctx->mbox_chan->mbox->txdone_irq) { dev_err(&pdev->dev, "PCC IRQ not supported\n"); @@ -702,16 +693,16 @@ static int xgene_hwmon_probe(struct platform_device *pdev) * This is the shared communication region * for the OS and Platform to communicate over. */ - ctx->comm_base_addr = cppc_ss->base_address; + ctx->comm_base_addr = pcc_chan->shmem_base_addr; if (ctx->comm_base_addr) { if (version == XGENE_HWMON_V2) ctx->pcc_comm_addr = (void __force *)ioremap( ctx->comm_base_addr, - cppc_ss->length); + pcc_chan->shmem_size); else ctx->pcc_comm_addr = memremap( ctx->comm_base_addr, - cppc_ss->length, + pcc_chan->shmem_size, MEMREMAP_WB); } else { dev_err(&pdev->dev, "Failed to get PCC comm region\n"); @@ -727,11 +718,11 @@ static int xgene_hwmon_probe(struct platform_device *pdev) } /* - * cppc_ss->latency is just a Nominal value. In reality + * pcc_chan->latency is just a Nominal value. In reality * the remote processor could be much slower to reply. * So add an arbitrary amount of wait on top of Nominal. */ - ctx->usecs_lat = PCC_NUM_RETRIES * cppc_ss->latency; + ctx->usecs_lat = PCC_NUM_RETRIES * pcc_chan->latency; } ctx->hwmon_dev = hwmon_device_register_with_groups(ctx->dev, @@ -757,7 +748,7 @@ static int xgene_hwmon_probe(struct platform_device *pdev) if (acpi_disabled) mbox_free_channel(ctx->mbox_chan); else - pcc_mbox_free_channel(ctx->mbox_chan); + pcc_mbox_free_channel(ctx->pcc_chan); out_mbox_free: kfifo_free(&ctx->async_msg_fifo); @@ -773,7 +764,7 @@ static int xgene_hwmon_remove(struct platform_device *pdev) if (acpi_disabled) mbox_free_channel(ctx->mbox_chan); else - pcc_mbox_free_channel(ctx->mbox_chan); + pcc_mbox_free_channel(ctx->pcc_chan); return 0; } diff --git a/drivers/i2c/busses/i2c-xgene-slimpro.c b/drivers/i2c/busses/i2c-xgene-slimpro.c index bba08cbce6e1..1a19ebad60ad 100644 --- a/drivers/i2c/busses/i2c-xgene-slimpro.c +++ b/drivers/i2c/busses/i2c-xgene-slimpro.c @@ -103,6 +103,7 @@ struct slimpro_i2c_dev { struct i2c_adapter adapter; struct device *dev; struct mbox_chan *mbox_chan; + struct pcc_mbox_chan *pcc_chan; struct mbox_client mbox_client; int mbox_idx; struct completion rd_complete; @@ -466,7 +467,7 @@ static int xgene_slimpro_i2c_probe(struct platform_device *pdev) return PTR_ERR(ctx->mbox_chan); } } else { - struct acpi_pcct_hw_reduced *cppc_ss; + struct pcc_mbox_chan *pcc_chan; const struct acpi_device_id *acpi_id; int version = XGENE_SLIMPRO_I2C_V1; @@ -483,24 +484,14 @@ static int xgene_slimpro_i2c_probe(struct platform_device *pdev) cl->tx_block = false; cl->rx_callback = slimpro_i2c_pcc_rx_cb; - ctx->mbox_chan = pcc_mbox_request_channel(cl, ctx->mbox_idx); - if (IS_ERR(ctx->mbox_chan)) { + pcc_chan = pcc_mbox_request_channel(cl, ctx->mbox_idx); + if (IS_ERR(pcc_chan)) { dev_err(&pdev->dev, "PCC mailbox channel request failed\n"); - return PTR_ERR(ctx->mbox_chan); + return PTR_ERR(ctx->pcc_chan); } - /* - * The PCC mailbox controller driver should - * have parsed the PCCT (global table of all - * PCC channels) and stored pointers to the - * subspace communication region in con_priv. - */ - cppc_ss = ctx->mbox_chan->con_priv; - if (!cppc_ss) { - dev_err(&pdev->dev, "PPC subspace not found\n"); - rc = -ENOENT; - goto mbox_err; - } + ctx->pcc_chan = pcc_chan; + ctx->mbox_chan = pcc_chan->mchan; if (!ctx->mbox_chan->mbox->txdone_irq) { dev_err(&pdev->dev, "PCC IRQ not supported\n"); @@ -512,17 +503,17 @@ static int xgene_slimpro_i2c_probe(struct platform_device *pdev) * This is the shared communication region * for the OS and Platform to communicate over. */ - ctx->comm_base_addr = cppc_ss->base_address; + ctx->comm_base_addr = pcc_chan->shmem_base_addr; if (ctx->comm_base_addr) { if (version == XGENE_SLIMPRO_I2C_V2) ctx->pcc_comm_addr = memremap( ctx->comm_base_addr, - cppc_ss->length, + pcc_chan->shmem_size, MEMREMAP_WT); else ctx->pcc_comm_addr = memremap( ctx->comm_base_addr, - cppc_ss->length, + pcc_chan->shmem_size, MEMREMAP_WB); } else { dev_err(&pdev->dev, "Failed to get PCC comm region\n"); @@ -561,7 +552,7 @@ static int xgene_slimpro_i2c_probe(struct platform_device *pdev) if (acpi_disabled) mbox_free_channel(ctx->mbox_chan); else - pcc_mbox_free_channel(ctx->mbox_chan); + pcc_mbox_free_channel(ctx->pcc_chan); return rc; } @@ -575,7 +566,7 @@ static int xgene_slimpro_i2c_remove(struct platform_device *pdev) if (acpi_disabled) mbox_free_channel(ctx->mbox_chan); else - pcc_mbox_free_channel(ctx->mbox_chan); + pcc_mbox_free_channel(ctx->pcc_chan); return 0; } diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index f358ced827f2..453a58fda3a4 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -79,24 +79,9 @@ struct pcc_chan_info { int db_irq; }; +#define to_pcc_chan_info(c) container_of(c, struct pcc_chan_info, chan) static struct pcc_chan_info *chan_info; - static struct mbox_controller pcc_mbox_ctrl = {}; -/** - * get_pcc_channel - Given a PCC subspace idx, get - * the respective mbox_channel. - * @id: PCC subspace index. - * - * Return: ERR_PTR(errno) if error, else pointer - * to mbox channel. - */ -static struct mbox_chan *get_pcc_channel(int id) -{ - if (id < 0 || id >= pcc_mbox_ctrl.num_chans) - return ERR_PTR(-ENOENT); - - return &pcc_mbox_channels[id]; -} /* * PCC can be used with perf critical drivers such as CPPC @@ -239,31 +224,25 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) * ACPI package. This is used to lookup the array of PCC * subspaces as parsed by the PCC Mailbox controller. * - * Return: Pointer to the Mailbox Channel if successful or - * ERR_PTR. + * Return: Pointer to the PCC Mailbox Channel if successful or ERR_PTR. */ -struct mbox_chan *pcc_mbox_request_channel(struct mbox_client *cl, - int subspace_id) +struct pcc_mbox_chan * +pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id) { struct pcc_chan_info *pchan; struct device *dev = pcc_mbox_ctrl.dev; struct mbox_chan *chan; unsigned long flags; - /* - * Each PCC Subspace is a Mailbox Channel. - * The PCC Clients get their PCC Subspace ID - * from their own tables and pass it here. - * This returns a pointer to the PCC subspace - * for the Client to operate on. - */ - chan = get_pcc_channel(subspace_id); + if (subspace_id < 0 || subspace_id >= pcc_mbox_ctrl.num_chans) + return ERR_PTR(-ENOENT); + pchan = chan_info + subspace_id; + chan = pchan->chan.mchan; if (IS_ERR(chan) || chan->cl) { dev_err(dev, "Channel not found for idx: %d\n", subspace_id); return ERR_PTR(-EBUSY); } - pchan = chan_info + subspace_id; spin_lock_irqsave(&chan->lock, flags); chan->msg_free = 0; @@ -285,38 +264,32 @@ struct mbox_chan *pcc_mbox_request_channel(struct mbox_client *cl, if (unlikely(rc)) { dev_err(dev, "failed to register PCC interrupt %d\n", pchan->db_irq); - pcc_mbox_free_channel(chan); - chan = ERR_PTR(rc); + pcc_mbox_free_channel(&pchan->chan); + return ERR_PTR(rc); } } - return chan; + return &pchan->chan; } EXPORT_SYMBOL_GPL(pcc_mbox_request_channel); /** * pcc_mbox_free_channel - Clients call this to free their Channel. * - * @chan: Pointer to the mailbox channel as returned by - * pcc_mbox_request_channel() + * @pchan: Pointer to the PCC mailbox channel as returned by + * pcc_mbox_request_channel() */ -void pcc_mbox_free_channel(struct mbox_chan *chan) +void pcc_mbox_free_channel(struct pcc_mbox_chan *pchan) { - u32 id = chan - pcc_mbox_channels; - struct pcc_chan_info *pchan; + struct pcc_chan_info *pchan_info = to_pcc_chan_info(pchan); + struct mbox_chan *chan = pchan->mchan; unsigned long flags; if (!chan || !chan->cl) return; - if (id >= pcc_mbox_ctrl.num_chans) { - pr_debug("pcc_mbox_free_channel: Invalid mbox_chan passed\n"); - return; - } - - pchan = chan_info + id; - if (pchan->db_irq > 0) - devm_free_irq(chan->mbox->dev, pchan->db_irq, chan); + if (pchan_info->db_irq > 0) + devm_free_irq(chan->mbox->dev, pchan_info->db_irq, chan); spin_lock_irqsave(&chan->lock, flags); chan->cl = NULL; diff --git a/include/acpi/pcc.h b/include/acpi/pcc.h index 5e510a6b8052..73e806fe7ce7 100644 --- a/include/acpi/pcc.h +++ b/include/acpi/pcc.h @@ -20,16 +20,16 @@ struct pcc_mbox_chan { #define MAX_PCC_SUBSPACES 256 #ifdef CONFIG_PCC -extern struct mbox_chan *pcc_mbox_request_channel(struct mbox_client *cl, - int subspace_id); -extern void pcc_mbox_free_channel(struct mbox_chan *chan); +extern struct pcc_mbox_chan * +pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id); +extern void pcc_mbox_free_channel(struct pcc_mbox_chan *chan); #else -static inline struct mbox_chan *pcc_mbox_request_channel(struct mbox_client *cl, - int subspace_id) +static inline struct pcc_mbox_chan * +pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id) { return ERR_PTR(-ENODEV); } -static inline void pcc_mbox_free_channel(struct mbox_chan *chan) { } +static inline void pcc_mbox_free_channel(struct pcc_mbox_chan *chan) { } #endif #endif /* _PCC_H */ From patchwork Fri Sep 17 13:33:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 514186 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp2236255jao; Fri, 17 Sep 2021 06:34:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPTMpocufyAk1VSrEfUCSB3Q+l2RCj/a2Dbp8y9c0HfrFdhr8KRUcgw7AC4cNun9s1OKXG X-Received: by 2002:adf:f4ca:: with SMTP id h10mr12281218wrp.159.1631885673107; Fri, 17 Sep 2021 06:34:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631885673; cv=none; d=google.com; s=arc-20160816; b=hWEFGSUYQclPjbF343Y1xAKpufrPi7tiNaiE5SyYjLsgEXVH97RD5R7KZjxB1CntHZ 33u0d6aJSi/da6eSaM8wsGFa5khne7mdrybD+l2IPL97R0IyPu5aFr0wtLtLWO/vexfe xeXyHl84Mua/nvmWMsjQ45uUSo/aQEfOAQxG6ENPUOI5KwHUAS3cXly/JgaWBbAojRQ7 xpagXLjLDDyKg0Apb5BsO7e40NN7sQZbrlMSHQuruWXuZOXvpjhJyvZAfz7JSVB9oIbi ROQ4Z/gt4QUS5hP+mrP4ctUsqt/GldVVjCwqrdvqf87gVAcZM9+ea0AacE0sPbF6luOh L+SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=dRwuVUClxRa7Y6o4ytTCqqywv97bhBtf32apcmvkhao=; b=JFwJSn25mzMKHNG80lDiqWWxc8EJOMedGwbcSJEuupgZdW9IHndvWR4rBjhVGkFOjA /dUKVAAUGiAkHTrIZa7Z5jfZfkw3tLMHOOrIDaccJ1wQ4sSI39rwNZOcFm//1TImAXa+ CsGX/IVko+OM/sFViZh4DC4JBtea6cfdwcKq222Eh6T88yNsWT0KwH4ARacToKGb81dF OHPMGTUbzpVWxy1y0AkCTxMcPjKTXvs8MX7eoCnFpMMoX0q1WuOd/HQrsRqyrwhYHB5t IFkPI+jL+FjNTO8g3ZVoVVqqH+k+Yg1FZi+VNUZ+80shHm7X2aoey3Oeopfd7fxfXf+k CCSA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x16si8402433edd.25.2021.09.17.06.34.32; Fri, 17 Sep 2021 06:34:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244997AbhIQNfu (ORCPT + 2 others); Fri, 17 Sep 2021 09:35:50 -0400 Received: from foss.arm.com ([217.140.110.172]:53314 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245138AbhIQNfj (ORCPT ); Fri, 17 Sep 2021 09:35:39 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 396DE11B3; Fri, 17 Sep 2021 06:34:16 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 54CF43F719; Fri, 17 Sep 2021 06:34:15 -0700 (PDT) From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Cristian Marussi , "Rafael J . Wysocki" , Jassi Brar Subject: [PATCH v2 08/14] mailbox: pcc: Rename doorbell ack to platform interrupt ack register Date: Fri, 17 Sep 2021 14:33:51 +0100 Message-Id: <20210917133357.1911092-9-sudeep.holla@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917133357.1911092-1-sudeep.holla@arm.com> References: <20210917133357.1911092-1-sudeep.holla@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The specification refers this register and associated bitmask as platform interrupt acknowledge register. Let us rename it so that it is easier to map and understand. Signed-off-by: Sudeep Holla --- drivers/mailbox/pcc.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) -- 2.25.1 diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 453a58fda3a4..ae4b7a4b3531 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -69,14 +69,15 @@ static struct mbox_chan *pcc_mbox_channels; * * @chan: PCC channel information with Shared Memory Region info * @db_vaddr: cached virtual address for doorbell register - * @db_ack_vaddr: cached virtual address for doorbell ack register - * @db_irq: doorbell interrupt + * @plat_irq_ack_vaddr: cached virtual address for platform interrupt + * acknowledge register + * @plat_irq: platform interrupt */ struct pcc_chan_info { struct pcc_mbox_chan chan; void __iomem *db_vaddr; - void __iomem *db_ack_vaddr; - int db_irq; + void __iomem *plat_irq_ack_vaddr; + int plat_irq; }; #define to_pcc_chan_info(c) container_of(c, struct pcc_chan_info, chan) @@ -198,12 +199,12 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) doorbell_ack_preserve = pcct2_ss->ack_preserve_mask; doorbell_ack_write = pcct2_ss->ack_write_mask; - ret = read_register(pchan->db_ack_vaddr, + ret = read_register(pchan->plat_irq_ack_vaddr, &doorbell_ack_val, doorbell_ack->bit_width); if (ret) return IRQ_NONE; - ret = write_register(pchan->db_ack_vaddr, + ret = write_register(pchan->plat_irq_ack_vaddr, (doorbell_ack_val & doorbell_ack_preserve) | doorbell_ack_write, doorbell_ack->bit_width); @@ -256,14 +257,14 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id) spin_unlock_irqrestore(&chan->lock, flags); - if (pchan->db_irq > 0) { + if (pchan->plat_irq > 0) { int rc; - rc = devm_request_irq(dev, pchan->db_irq, pcc_mbox_irq, 0, + rc = devm_request_irq(dev, pchan->plat_irq, pcc_mbox_irq, 0, MBOX_IRQ_NAME, chan); if (unlikely(rc)) { dev_err(dev, "failed to register PCC interrupt %d\n", - pchan->db_irq); + pchan->plat_irq); pcc_mbox_free_channel(&pchan->chan); return ERR_PTR(rc); } @@ -288,8 +289,8 @@ void pcc_mbox_free_channel(struct pcc_mbox_chan *pchan) if (!chan || !chan->cl) return; - if (pchan_info->db_irq > 0) - devm_free_irq(chan->mbox->dev, pchan_info->db_irq, chan); + if (pchan_info->plat_irq > 0) + devm_free_irq(chan->mbox->dev, pchan_info->plat_irq, chan); spin_lock_irqsave(&chan->lock, flags); chan->cl = NULL; @@ -400,9 +401,9 @@ static int pcc_parse_subspace_irq(struct pcc_chan_info *pchan, return 0; pcct_ss = (struct acpi_pcct_hw_reduced *)pcct_entry; - pchan->db_irq = pcc_map_interrupt(pcct_ss->platform_interrupt, - (u32)pcct_ss->flags); - if (pchan->db_irq <= 0) { + pchan->plat_irq = pcc_map_interrupt(pcct_ss->platform_interrupt, + (u32)pcct_ss->flags); + if (pchan->plat_irq <= 0) { pr_err("PCC GSI %d not registered\n", pcct_ss->platform_interrupt); return -EINVAL; @@ -411,10 +412,10 @@ static int pcc_parse_subspace_irq(struct pcc_chan_info *pchan, if (pcct_ss->header.type == ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2) { struct acpi_pcct_hw_reduced_type2 *pcct2_ss = (void *)pcct_ss; - pchan->db_ack_vaddr = + pchan->plat_irq_ack_vaddr = acpi_os_ioremap(pcct2_ss->platform_ack_register.address, pcct2_ss->platform_ack_register.bit_width / 8); - if (!pchan->db_ack_vaddr) { + if (!pchan->plat_irq_ack_vaddr) { pr_err("Failed to ioremap PCC ACK register\n"); return -ENOMEM; } From patchwork Fri Sep 17 13:33:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 514187 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp2236264jao; Fri, 17 Sep 2021 06:34:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqVw5asdYWey0pCf5LMcFuV+zHhh3dbC9k81DoPBdDEPDFAQTF0kvZiuB+6+gRPueyalmk X-Received: by 2002:a17:906:39cd:: with SMTP id i13mr11648320eje.227.1631885673480; Fri, 17 Sep 2021 06:34:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631885673; cv=none; d=google.com; s=arc-20160816; b=AZ6GwCbdjfHJWkEZ1xtPFK8O/snm0VnwKXaEKSYAvE31+kZQzPVkMRO8YEvX4d2mTT wjVpExSRS/4R1KInlPxRrC7PWGhu5GtIE3qpkjRuUoC4m/Q/mEdp2OWf8kDbKEkkcIlK LFawTTqTZJ671cbT/rGWQ1OXNfFSeUqgTu6Qk17YuCx3bmhkl6tgDrComRA7jBP2dJQ1 uNooCfqrv1faLyD2qh7SjhYi0VhhBPvZXWBW6nRon+N8SDWP8feCPWC4a1kNp+sTFpbK 0LjcaE1rzaVbBSngt/TJ7dMZ31/bpVSPoXGETxJSdVJ1Ljbm+oE8tDbysAGr4CDhp65Z 9iYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=g+qL01Jd8FoLatChRQUeB5HqdjNbrgR4GYYHNj6r2uI=; b=Cp/6jkdma3V9eSsqvwraBAH8RGn0J10giaj2iMqu26HWKi3/lvZmkhKYkQbN1ip+zQ uVvvs/PCm8F52qGpF3GTvHjcLNPz/T6GshOwgfa/duDQ/1UJi02GGFrIB0IcBOsIUium 14xqT2BkGjCByUKG2VM4iWn1HeqX8CTAj7Z1aeh6TWhZjBJREgkYJtbL/Nmf4GPtyHpb co9bY7MKfVd/sLf+VbxI8Pp0CQdZecvW4qlDh1HCdxmCHDRc0beioB3ZPhsxF8JZtVk9 ndJWSPbTOROekCsyAwo3D7CrZPfU+CgcPpUlW3wpyDJM2D4wVcUz+o6uYxHnWMMgvCPI VJcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x16si8402433edd.25.2021.09.17.06.34.33; Fri, 17 Sep 2021 06:34:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245487AbhIQNfu (ORCPT + 2 others); Fri, 17 Sep 2021 09:35:50 -0400 Received: from foss.arm.com ([217.140.110.172]:53322 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245149AbhIQNfj (ORCPT ); Fri, 17 Sep 2021 09:35:39 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 514C111FB; Fri, 17 Sep 2021 06:34:17 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6C9E13F719; Fri, 17 Sep 2021 06:34:16 -0700 (PDT) From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Cristian Marussi , "Rafael J . Wysocki" , Jassi Brar Subject: [PATCH v2 09/14] mailbox: pcc: Add PCC register bundle and associated accessor functions Date: Fri, 17 Sep 2021 14:33:52 +0100 Message-Id: <20210917133357.1911092-10-sudeep.holla@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917133357.1911092-1-sudeep.holla@arm.com> References: <20210917133357.1911092-1-sudeep.holla@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Extended PCC subspaces introduces more registers into the PCCT. In order to consolidate access to these registers and to keep all the details contained in one place, let us introduce PCC register bundle that holds the ACPI Generic Address Structure as well as the virtual address for the same if it is mapped in the OS. It also contains the various masks used to access the register and the associated read, write and read-modify-write accessors. We can also clean up the initialisations by having a helper function for the same. Signed-off-by: Sudeep Holla --- drivers/mailbox/pcc.c | 90 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) -- 2.25.1 diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index ae4b7a4b3531..deaea9d423a7 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,23 @@ static struct mbox_chan *pcc_mbox_channels; +/** + * struct pcc_chan_reg - PCC register bundle + * + * @vaddr: cached virtual address for this register + * @gas: pointer to the generic address structure for this register + * @preserve_mask: bitmask to preserve when writing to this register + * @set_mask: bitmask to set when writing to this register + * @status_mask: bitmask to determine and/or update the status for this register + */ +struct pcc_chan_reg { + void __iomem *vaddr; + struct acpi_generic_address *gas; + u64 preserve_mask; + u64 set_mask; + u64 status_mask; +}; + /** * struct pcc_chan_info - PCC channel specific information * @@ -144,6 +162,53 @@ static int write_register(void __iomem *vaddr, u64 val, unsigned int bit_width) return ret_val; } +static int pcc_chan_reg_read(struct pcc_chan_reg *reg, u64 *val) +{ + int ret = 0; + + if (!reg->gas) { + *val = 0; + return 0; + } + + if (reg->vaddr) + ret = read_register(reg->vaddr, val, reg->gas->bit_width); + else + ret = acpi_read(val, reg->gas); + + return ret; +} + +static int pcc_chan_reg_write(struct pcc_chan_reg *reg, u64 val) +{ + int ret = 0; + + if (!reg->gas) + return 0; + + if (reg->vaddr) + ret = write_register(reg->vaddr, val, reg->gas->bit_width); + else + ret = acpi_write(val, reg->gas); + + return ret; +} + +static int pcc_chan_reg_read_modify_write(struct pcc_chan_reg *reg) +{ + int ret = 0; + u64 val; + + ret = pcc_chan_reg_read(reg, &val); + if (ret) + return ret; + + val &= reg->preserve_mask; + val |= reg->set_mask; + + return pcc_chan_reg_write(reg, val); +} + /** * pcc_map_interrupt - Map a PCC subspace GSI to a linux IRQ number * @interrupt: GSI number. @@ -379,6 +444,31 @@ static int parse_pcc_subspace(union acpi_subtable_headers *header, return -EINVAL; } +static int +pcc_chan_reg_init(struct pcc_chan_reg *reg, struct acpi_generic_address *gas, + u64 preserve_mask, u64 set_mask, u64 status_mask, char *name) +{ + if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { + if (!(gas->bit_width >= 8 && gas->bit_width <= 64 && + is_power_of_2(gas->bit_width))) { + pr_err("Error: Cannot access register of %u bit width", + gas->bit_width); + return -EFAULT; + } + + reg->vaddr = acpi_os_ioremap(gas->address, gas->bit_width / 8); + if (!reg->vaddr) { + pr_err("Failed to ioremap PCC %s register\n", name); + return -ENOMEM; + } + } + reg->gas = gas; + reg->preserve_mask = preserve_mask; + reg->set_mask = set_mask; + reg->status_mask = status_mask; + return 0; +} + /** * pcc_parse_subspace_irq - Parse the PCC IRQ and PCC ACK register * From patchwork Fri Sep 17 13:33:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 514188 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp2236278jao; Fri, 17 Sep 2021 06:34:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhT0rxht4XGiumIvU8Qoc7yxELUJPxqFZbtP0gl6RVnrNYZ/w0uJqts+w9olbc/YIdnSzK X-Received: by 2002:a05:6402:897:: with SMTP id e23mr12649908edy.366.1631885673887; Fri, 17 Sep 2021 06:34:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631885673; cv=none; d=google.com; s=arc-20160816; b=uMa7ftmX9ViK3VUZmYwV5baBW+0jseIJVw60ADA496Cd9YoVk+RhoF1M0gGEluLzwj iXLCmFir0b23VT9EmMcU65pS1YygTStIDeUurpAUs0yGrfJMIjYvXHPhUaknDnIkDQth o2XR3a39gdpcqaSFlbp/NprIbLqQOn8sFSj09tQEqOXtmXF5BWRwJn/5X3duuH3oaPRn kV0oAWQ7lgOxkWeFZ/H7bxViVU2AI26D7lM8PuWUIzFAhBcR/S6u0xHETulckrVGZHzd ajY3rFwiM/j60Ubmdgv1xW4B11VgPnbgc/ltdNJUydnqOfyRlmAQ5xQQ8ZAxa3yq8gmc x0aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=mTFLYk6fRbnXNsPZDsbuHmRQSZJkn0ARC3OLDTRTV4c=; b=ltyFs/zWDeCevc7N+kZxlSDoXDur1iH81ZsCRHPg0GL6xci/1emYfmVuvC2RzbP735 o5s41xP/u6uqxN9i5mQt7lTcFEWQn02zgfmnlchxcsRp4j1+jlQi0OsbNfkh+2WiuLfa 1O0x/dUE+9CAQ6uM3WGnqmnyJLWhH/gUZctC9d3ahoQebRJQU7Nx/MKRQTtnFx1BbW3s EOzXschD5qD2wWF+TU2mrCnhvYkW40a/tHoLVZnvxNzeihlNkgW34UYmwUfdyCmgh2J6 hKofYI3pAyEcO/K3y3pYGnsIeAf2cNFURKvMV4hsUV3eUlqvDmatefAJbXbUL7btwXQf Qtgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x16si8402433edd.25.2021.09.17.06.34.33; Fri, 17 Sep 2021 06:34:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245107AbhIQNfw (ORCPT + 2 others); Fri, 17 Sep 2021 09:35:52 -0400 Received: from foss.arm.com ([217.140.110.172]:53328 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245180AbhIQNfk (ORCPT ); Fri, 17 Sep 2021 09:35:40 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6997712FC; Fri, 17 Sep 2021 06:34:18 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 84CC73F719; Fri, 17 Sep 2021 06:34:17 -0700 (PDT) From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Cristian Marussi , "Rafael J . Wysocki" , Jassi Brar Subject: [PATCH v2 10/14] mailbox: pcc: Avoid accessing PCCT table in pcc_send_data and pcc_mbox_irq Date: Fri, 17 Sep 2021 14:33:53 +0100 Message-Id: <20210917133357.1911092-11-sudeep.holla@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917133357.1911092-1-sudeep.holla@arm.com> References: <20210917133357.1911092-1-sudeep.holla@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Now that the con_priv is availvale solely for PCC mailbox controller driver, let us use the same to save the channel specific information in it so that we can it whenever required instead of parsing the PCCT table entries every time in both pcc_send_data and pcc_mbox_irq. We can now use the newly introduces PCC register bundle to simplify both saving of channel specific information and accessing them without repeated checks for the subspace type. Reviewed-by: Cristian Marussi Signed-off-by: Sudeep Holla --- drivers/mailbox/pcc.c | 119 ++++++++++++------------------------------ 1 file changed, 32 insertions(+), 87 deletions(-) -- 2.25.1 diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index deaea9d423a7..ed635f7d3f60 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -86,15 +86,15 @@ struct pcc_chan_reg { * struct pcc_chan_info - PCC channel specific information * * @chan: PCC channel information with Shared Memory Region info - * @db_vaddr: cached virtual address for doorbell register - * @plat_irq_ack_vaddr: cached virtual address for platform interrupt - * acknowledge register + * @db: PCC register bundle for the doorbell register + * @plat_irq_ack: PCC register bundle for the platform interrupt acknowledge + * register * @plat_irq: platform interrupt */ struct pcc_chan_info { struct pcc_mbox_chan chan; - void __iomem *db_vaddr; - void __iomem *plat_irq_ack_vaddr; + struct pcc_chan_reg db; + struct pcc_chan_reg plat_irq_ack; int plat_irq; }; @@ -242,40 +242,15 @@ static int pcc_map_interrupt(u32 interrupt, u32 flags) */ static irqreturn_t pcc_mbox_irq(int irq, void *p) { - struct acpi_generic_address *doorbell_ack; - struct acpi_pcct_hw_reduced *pcct_ss; struct pcc_chan_info *pchan; struct mbox_chan *chan = p; - u64 doorbell_ack_preserve; - u64 doorbell_ack_write; - u64 doorbell_ack_val; - int ret; - pcct_ss = chan->con_priv; + pchan = chan->con_priv; - mbox_chan_received_data(chan, NULL); + if (pcc_chan_reg_read_modify_write(&pchan->plat_irq_ack)) + return IRQ_NONE; - if (pcct_ss->header.type == ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2) { - struct acpi_pcct_hw_reduced_type2 *pcct2_ss = chan->con_priv; - u32 id = chan - pcc_mbox_channels; - - pchan = chan_info + id; - doorbell_ack = &pcct2_ss->platform_ack_register; - doorbell_ack_preserve = pcct2_ss->ack_preserve_mask; - doorbell_ack_write = pcct2_ss->ack_write_mask; - - ret = read_register(pchan->plat_irq_ack_vaddr, - &doorbell_ack_val, doorbell_ack->bit_width); - if (ret) - return IRQ_NONE; - - ret = write_register(pchan->plat_irq_ack_vaddr, - (doorbell_ack_val & doorbell_ack_preserve) - | doorbell_ack_write, - doorbell_ack->bit_width); - if (ret) - return IRQ_NONE; - } + mbox_chan_received_data(chan, NULL); return IRQ_HANDLED; } @@ -381,42 +356,9 @@ EXPORT_SYMBOL_GPL(pcc_mbox_free_channel); */ static int pcc_send_data(struct mbox_chan *chan, void *data) { - struct acpi_pcct_hw_reduced *pcct_ss = chan->con_priv; - struct acpi_generic_address *doorbell; - struct pcc_chan_info *pchan; - u64 doorbell_preserve; - u64 doorbell_val; - u64 doorbell_write; - u32 id = chan - pcc_mbox_channels; - int ret = 0; + struct pcc_chan_info *pchan = chan->con_priv; - if (id >= pcc_mbox_ctrl.num_chans) { - pr_debug("pcc_send_data: Invalid mbox_chan passed\n"); - return -ENOENT; - } - - pchan = chan_info + id; - doorbell = &pcct_ss->doorbell_register; - doorbell_preserve = pcct_ss->preserve_mask; - doorbell_write = pcct_ss->write_mask; - - /* Sync notification from OS to Platform. */ - if (pchan->db_vaddr) { - ret = read_register(pchan->db_vaddr, &doorbell_val, - doorbell->bit_width); - if (ret) - return ret; - ret = write_register(pchan->db_vaddr, - (doorbell_val & doorbell_preserve) - | doorbell_write, doorbell->bit_width); - } else { - ret = acpi_read(&doorbell_val, doorbell); - if (ret) - return ret; - ret = acpi_write((doorbell_val & doorbell_preserve) | doorbell_write, - doorbell); - } - return ret; + return pcc_chan_reg_read_modify_write(&pchan->db); } static const struct mbox_chan_ops pcc_chan_ops = { @@ -484,6 +426,7 @@ pcc_chan_reg_init(struct pcc_chan_reg *reg, struct acpi_generic_address *gas, static int pcc_parse_subspace_irq(struct pcc_chan_info *pchan, struct acpi_subtable_header *pcct_entry) { + int ret = 0; struct acpi_pcct_hw_reduced *pcct_ss; if (pcct_entry->type < ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE || @@ -502,16 +445,14 @@ static int pcc_parse_subspace_irq(struct pcc_chan_info *pchan, if (pcct_ss->header.type == ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2) { struct acpi_pcct_hw_reduced_type2 *pcct2_ss = (void *)pcct_ss; - pchan->plat_irq_ack_vaddr = - acpi_os_ioremap(pcct2_ss->platform_ack_register.address, - pcct2_ss->platform_ack_register.bit_width / 8); - if (!pchan->plat_irq_ack_vaddr) { - pr_err("Failed to ioremap PCC ACK register\n"); - return -ENOMEM; - } + ret = pcc_chan_reg_init(&pchan->plat_irq_ack, + &pcct2_ss->platform_ack_register, + pcct2_ss->ack_preserve_mask, + pcct2_ss->ack_write_mask, 0, + "PLAT IRQ ACK"); } - return 0; + return ret; } /** @@ -520,20 +461,22 @@ static int pcc_parse_subspace_irq(struct pcc_chan_info *pchan, * @pchan: Pointer to the PCC channel info structure. * @pcct_entry: Pointer to the ACPI subtable header. * + * Return: 0 for Success, else errno. */ -static void pcc_parse_subspace_db_reg(struct pcc_chan_info *pchan, - struct acpi_subtable_header *pcct_entry) +static int pcc_parse_subspace_db_reg(struct pcc_chan_info *pchan, + struct acpi_subtable_header *pcct_entry) { + int ret = 0; + struct acpi_pcct_subspace *pcct_ss; - struct acpi_generic_address *db_reg; pcct_ss = (struct acpi_pcct_subspace *)pcct_entry; - /* If doorbell is in system memory cache the virt address */ - db_reg = &pcct_ss->doorbell_register; - if (db_reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) - pchan->db_vaddr = acpi_os_ioremap(db_reg->address, - db_reg->bit_width / 8); + ret = pcc_chan_reg_init(&pchan->db, + &pcct_ss->doorbell_register, + pcct_ss->preserve_mask, + pcct_ss->write_mask, 0, "Doorbell"); + return ret; } /** @@ -622,8 +565,8 @@ static int __init acpi_pcc_probe(void) for (i = 0; i < count; i++) { struct pcc_chan_info *pchan = chan_info + i; - pcc_mbox_channels[i].con_priv = pcct_entry; + pcc_mbox_channels[i].con_priv = pchan; pchan->chan.mchan = &pcc_mbox_channels[i]; if (pcc_mbox_ctrl.txdone_irq) { @@ -631,7 +574,9 @@ static int __init acpi_pcc_probe(void) if (rc < 0) goto err; } - pcc_parse_subspace_db_reg(pchan, pcct_entry); + rc = pcc_parse_subspace_db_reg(pchan, pcct_entry); + if (rc < 0) + goto err; pcc_parse_subspace_shmem(pchan, pcct_entry); From patchwork Fri Sep 17 13:33:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 514189 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp2236356jao; Fri, 17 Sep 2021 06:34:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzP/CMD6LGTMG85dp/v0mM7+Rp1/yxEgjrRObucW/HtiKLveb+KZCHrTFLc1Wv6B1Su5sR6 X-Received: by 2002:a17:907:7755:: with SMTP id kx21mr12135814ejc.463.1631885678426; Fri, 17 Sep 2021 06:34:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631885678; cv=none; d=google.com; s=arc-20160816; b=H0ptU1ve5BQqqu7d2R5gnbhAOBwceSZAu/mMwY/frhoKMHgvZJV5UK4Sa4OtAWI4Hl UUvz5t2OoPKGR1fqAhJlGJDhV3wElXnYloxmWOS0UoPx/8JweKCtWEt7VeACw3UoTRQ5 mc0DeWaFUSU0sWBfr83O5AkDiV/p4Zl7LuqnHG/X0QQM91sDZM6lgR7/mVPej6E7wMIA kNbTYWcksDVsUP974G7ouxrvMuQXNaH+yRa6W4+dKrs0rEOjEZfUdZL1EOfMpU1DwTeA 32nBF6Ux2wfyCVz2DeCd9qMDK24OA+ZuG3Njm1dXvicw7F+/zCiz6+AhAsTZAi6nY+em 9DcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=c4aeYE/1WubxwQKowc8xLfAYzuxqBeZv8Y9/pcwiKsU=; b=cGLu4mOuH49H/C+51EZVm4vdS2wQaXVmMEXnE4NsH01CkYl3iATKjE5ib/rQTQxE9P NybAzOcBsYYjw3Zus+xEiBUtLiqSmmnmvPYcfvgW1qXSzHyEPIJMBh1BQHLK/7o42/v3 ltUvy5L9EiSExiF2IgIlWLLOBOmKQkkAXFEwEjlE46+GjsYUgbv+Xce7HRAEep5WBUO1 fvcz13Rmrk1zPQE5P1zKlBMdxo22R+eKRcKvllm0wxQlcLtvVT4EGS4Ekh2cKZfMajnE Raj9lyZoGaq+QDLVFk3r/4FfqWJReUw+ueIcWSlI4eP3LfCdLULxEejPMhmDLf4X7sDO vMtg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x16si8402433edd.25.2021.09.17.06.34.38; Fri, 17 Sep 2021 06:34:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245568AbhIQNf6 (ORCPT + 2 others); Fri, 17 Sep 2021 09:35:58 -0400 Received: from foss.arm.com ([217.140.110.172]:53334 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245234AbhIQNfm (ORCPT ); Fri, 17 Sep 2021 09:35:42 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 81636113E; Fri, 17 Sep 2021 06:34:19 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9CAB03F719; Fri, 17 Sep 2021 06:34:18 -0700 (PDT) From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Cristian Marussi , "Rafael J . Wysocki" , Jassi Brar Subject: [PATCH v2 11/14] mailbox: pcc: Drop handling invalid bit-width in {read, write}_register Date: Fri, 17 Sep 2021 14:33:54 +0100 Message-Id: <20210917133357.1911092-12-sudeep.holla@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917133357.1911092-1-sudeep.holla@arm.com> References: <20210917133357.1911092-1-sudeep.holla@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org pcc_chan_reg_init now checks if the register bit width is within the list [8, 16, 32, 64] and flags error if that is not the case. Therefore there is no need to handling invalid bit-width in both read_register and write_register. We can drop that along with the return values for these 2 functions. Signed-off-by: Sudeep Holla --- drivers/mailbox/pcc.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) -- 2.25.1 diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index ed635f7d3f60..4bace1fa48f0 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -110,10 +110,8 @@ static struct mbox_controller pcc_mbox_ctrl = {}; * The below read_register and write_registers are used to read and * write from perf critical registers such as PCC doorbell register */ -static int read_register(void __iomem *vaddr, u64 *val, unsigned int bit_width) +static void read_register(void __iomem *vaddr, u64 *val, unsigned int bit_width) { - int ret_val = 0; - switch (bit_width) { case 8: *val = readb(vaddr); @@ -127,19 +125,11 @@ static int read_register(void __iomem *vaddr, u64 *val, unsigned int bit_width) case 64: *val = readq(vaddr); break; - default: - pr_debug("Error: Cannot read register of %u bit width", - bit_width); - ret_val = -EFAULT; - break; } - return ret_val; } -static int write_register(void __iomem *vaddr, u64 val, unsigned int bit_width) +static void write_register(void __iomem *vaddr, u64 val, unsigned int bit_width) { - int ret_val = 0; - switch (bit_width) { case 8: writeb(val, vaddr); @@ -153,13 +143,7 @@ static int write_register(void __iomem *vaddr, u64 val, unsigned int bit_width) case 64: writeq(val, vaddr); break; - default: - pr_debug("Error: Cannot write register of %u bit width", - bit_width); - ret_val = -EFAULT; - break; } - return ret_val; } static int pcc_chan_reg_read(struct pcc_chan_reg *reg, u64 *val) @@ -172,7 +156,7 @@ static int pcc_chan_reg_read(struct pcc_chan_reg *reg, u64 *val) } if (reg->vaddr) - ret = read_register(reg->vaddr, val, reg->gas->bit_width); + read_register(reg->vaddr, val, reg->gas->bit_width); else ret = acpi_read(val, reg->gas); @@ -187,7 +171,7 @@ static int pcc_chan_reg_write(struct pcc_chan_reg *reg, u64 val) return 0; if (reg->vaddr) - ret = write_register(reg->vaddr, val, reg->gas->bit_width); + write_register(reg->vaddr, val, reg->gas->bit_width); else ret = acpi_write(val, reg->gas); From patchwork Fri Sep 17 13:33:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 514190 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp2236369jao; Fri, 17 Sep 2021 06:34:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw58/ii56hQ7CgM8+Ba+BCmuaOiFa7lLsDpAKQ+qdk5Fusa7JaBLRM7W/SoKTaeKxJRtM5y X-Received: by 2002:aa7:c9cd:: with SMTP id i13mr12760897edt.178.1631885679419; Fri, 17 Sep 2021 06:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631885679; cv=none; d=google.com; s=arc-20160816; b=VzMHUpOQh7dSomI63qZ2p9owm1FL8HdS9aJAeUlqPZZZGE8/9A1vr/XNcuGD+pnhqN aoKodg1rfIqDhuq+7hDyJdCGgyG3aW8RGLBun/Hq0pM1iaErfLde1Lo13z857FJHA1U+ ElwuICysVZLCfFeGebx0D7McNLZtTj6m9n4guvXzPzZFHlLJ7zhYRZJeNKdiJ0pLDFjy 5jOK2oC+nPKdm7F2i7yBOYSx7ktYgptjTraAzaZVOKPm6Q+bO9Ms2+YtzH4uboVsKIQc uFaZCMSbR1qGdj+X53bA7St2Y3D9DYAGm369tGqqWQywZq51Bj+iF8e7toPTUadGJpix +86A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Ly8ZDAzkvivO9CHhJ/7Yh+h+jaexUFcB46Zldf9IXiQ=; b=pY/TJ3wD1bT+8YlFBi7Vc3ChnCEwpLknegn26x5YfZHCdpAzLpTFwd15FlI0pxXj8U oohYco+axRm1r5JDL185V1cpc3b5LMXzLZ00tQm/1mOtLEVqSl0XkUHF56VXmUQlNADw sYmQtnmeo71w/pAU26f7pvbvQwudLWhVOe919OVsltYer0uoQUkb8Glli7aGySO7+AwC rb9/wx0VnIbhOumkCvo7BLq9k/CfPO4wyhCQISwVbjjGIUuqS/10jrY5HHyidzBBac4n jzIuiAQhyOmOP+cBYP+VQ2u1/k9OvGZiAnV6CFb3Ck4c64P5ncyQOm7E4s4g7aUcV6Vg kTSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x16si8402433edd.25.2021.09.17.06.34.39; Fri, 17 Sep 2021 06:34:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245613AbhIQNf7 (ORCPT + 2 others); Fri, 17 Sep 2021 09:35:59 -0400 Received: from foss.arm.com ([217.140.110.172]:53340 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245255AbhIQNfm (ORCPT ); Fri, 17 Sep 2021 09:35:42 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 99ABD139F; Fri, 17 Sep 2021 06:34:20 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B4ECE3F719; Fri, 17 Sep 2021 06:34:19 -0700 (PDT) From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Cristian Marussi , "Rafael J . Wysocki" , Jassi Brar Subject: [PATCH v2 12/14] mailbox: pcc: Add support for PCCT extended PCC subspaces(type 3/4) Date: Fri, 17 Sep 2021 14:33:55 +0100 Message-Id: <20210917133357.1911092-13-sudeep.holla@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917133357.1911092-1-sudeep.holla@arm.com> References: <20210917133357.1911092-1-sudeep.holla@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org With all the plumbing in place to avoid accessing PCCT type and other fields directly from the PCCT table all the time, let us now add the support for extended PCC subspaces(type 3 and 4). Signed-off-by: Sudeep Holla --- drivers/mailbox/pcc.c | 126 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 109 insertions(+), 17 deletions(-) -- 2.25.1 diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 4bace1fa48f0..eb90c9eaaf9c 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -89,12 +89,18 @@ struct pcc_chan_reg { * @db: PCC register bundle for the doorbell register * @plat_irq_ack: PCC register bundle for the platform interrupt acknowledge * register + * @cmd_complete: PCC register bundle for the command complete check register + * @cmd_update: PCC register bundle for the command complete update register + * @error: PCC register bundle for the error status register * @plat_irq: platform interrupt */ struct pcc_chan_info { struct pcc_mbox_chan chan; struct pcc_chan_reg db; struct pcc_chan_reg plat_irq_ack; + struct pcc_chan_reg cmd_complete; + struct pcc_chan_reg cmd_update; + struct pcc_chan_reg error; int plat_irq; }; @@ -228,9 +234,29 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) { struct pcc_chan_info *pchan; struct mbox_chan *chan = p; + u64 val; + int ret; pchan = chan->con_priv; + ret = pcc_chan_reg_read(&pchan->cmd_complete, &val); + if (ret) + return IRQ_NONE; + + val &= pchan->cmd_complete.status_mask; + if (!val) + return IRQ_NONE; + + ret = pcc_chan_reg_read(&pchan->error, &val); + if (ret) + return IRQ_NONE; + val &= pchan->error.status_mask; + if (val) { + val &= ~pchan->error.status_mask; + pcc_chan_reg_write(&pchan->error, val); + return IRQ_NONE; + } + if (pcc_chan_reg_read_modify_write(&pchan->plat_irq_ack)) return IRQ_NONE; @@ -340,8 +366,13 @@ EXPORT_SYMBOL_GPL(pcc_mbox_free_channel); */ static int pcc_send_data(struct mbox_chan *chan, void *data) { + int ret; struct pcc_chan_info *pchan = chan->con_priv; + ret = pcc_chan_reg_read_modify_write(&pchan->cmd_update); + if (ret) + return ret; + return pcc_chan_reg_read_modify_write(&pchan->db); } @@ -434,6 +465,16 @@ static int pcc_parse_subspace_irq(struct pcc_chan_info *pchan, pcct2_ss->ack_preserve_mask, pcct2_ss->ack_write_mask, 0, "PLAT IRQ ACK"); + + } else if (pcct_ss->header.type == ACPI_PCCT_TYPE_EXT_PCC_MASTER_SUBSPACE || + pcct_ss->header.type == ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE) { + struct acpi_pcct_ext_pcc_master *pcct_ext = (void *)pcct_ss; + + ret = pcc_chan_reg_init(&pchan->plat_irq_ack, + &pcct_ext->platform_ack_register, + pcct_ext->ack_preserve_mask, + pcct_ext->ack_set_mask, 0, + "PLAT IRQ ACK"); } return ret; @@ -452,14 +493,48 @@ static int pcc_parse_subspace_db_reg(struct pcc_chan_info *pchan, { int ret = 0; - struct acpi_pcct_subspace *pcct_ss; - - pcct_ss = (struct acpi_pcct_subspace *)pcct_entry; - - ret = pcc_chan_reg_init(&pchan->db, - &pcct_ss->doorbell_register, - pcct_ss->preserve_mask, - pcct_ss->write_mask, 0, "Doorbell"); + if (pcct_entry->type <= ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2) { + struct acpi_pcct_subspace *pcct_ss; + + pcct_ss = (struct acpi_pcct_subspace *)pcct_entry; + + ret = pcc_chan_reg_init(&pchan->db, + &pcct_ss->doorbell_register, + pcct_ss->preserve_mask, + pcct_ss->write_mask, 0, "Doorbell"); + + } else { + struct acpi_pcct_ext_pcc_master *pcct_ext; + + pcct_ext = (struct acpi_pcct_ext_pcc_master *)pcct_entry; + + ret = pcc_chan_reg_init(&pchan->db, + &pcct_ext->doorbell_register, + pcct_ext->preserve_mask, + pcct_ext->write_mask, 0, "Doorbell"); + if (ret) + return ret; + + ret = pcc_chan_reg_init(&pchan->cmd_complete, + &pcct_ext->cmd_complete_register, + 0, 0, pcct_ext->cmd_complete_mask, + "Command Complete Check"); + if (ret) + return ret; + + ret = pcc_chan_reg_init(&pchan->cmd_update, + &pcct_ext->cmd_update_register, + pcct_ext->cmd_update_preserve_mask, + pcct_ext->cmd_update_set_mask, 0, + "Command Complete Update"); + if (ret) + return ret; + + ret = pcc_chan_reg_init(&pchan->error, + &pcct_ext->error_status_register, + 0, 0, pcct_ext->error_status_mask, + "Error Status"); + } return ret; } @@ -473,15 +548,25 @@ static int pcc_parse_subspace_db_reg(struct pcc_chan_info *pchan, static void pcc_parse_subspace_shmem(struct pcc_chan_info *pchan, struct acpi_subtable_header *pcct_entry) { - struct acpi_pcct_subspace *pcct_ss; - - pcct_ss = (struct acpi_pcct_subspace *)pcct_entry; - - pchan->chan.shmem_base_addr = pcct_ss->base_address; - pchan->chan.shmem_size = pcct_ss->length; - pchan->chan.latency = pcct_ss->latency; - pchan->chan.max_access_rate = pcct_ss->max_access_rate; - pchan->chan.min_turnaround_time = pcct_ss->min_turnaround_time; + if (pcct_entry->type <= ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2) { + struct acpi_pcct_subspace *pcct_ss = + (struct acpi_pcct_subspace *)pcct_entry; + + pchan->chan.shmem_base_addr = pcct_ss->base_address; + pchan->chan.shmem_size = pcct_ss->length; + pchan->chan.latency = pcct_ss->latency; + pchan->chan.max_access_rate = pcct_ss->max_access_rate; + pchan->chan.min_turnaround_time = pcct_ss->min_turnaround_time; + } else { + struct acpi_pcct_ext_pcc_master *pcct_ext = + (struct acpi_pcct_ext_pcc_master *)pcct_entry; + + pchan->chan.shmem_base_addr = pcct_ext->base_address; + pchan->chan.shmem_size = pcct_ext->length; + pchan->chan.latency = pcct_ext->latency; + pchan->chan.max_access_rate = pcct_ext->max_access_rate; + pchan->chan.min_turnaround_time = pcct_ext->min_turnaround_time; + } } /** @@ -553,6 +638,13 @@ static int __init acpi_pcc_probe(void) pcc_mbox_channels[i].con_priv = pchan; pchan->chan.mchan = &pcc_mbox_channels[i]; + if (pcct_entry->type == ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE && + !pcc_mbox_ctrl.txdone_irq) { + pr_err("Plaform Interrupt flag must be set to 1"); + rc = -EINVAL; + goto err; + } + if (pcc_mbox_ctrl.txdone_irq) { rc = pcc_parse_subspace_irq(pchan, pcct_entry); if (rc < 0) From patchwork Fri Sep 17 13:33:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 514191 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp2236375jao; Fri, 17 Sep 2021 06:34:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEFjv4LPpZN/KBtvPzTUWyw/3H/iSo2z7UW7EOmX8FsBlIaSjCF44MAjhOuiNY/xjVl4XQ X-Received: by 2002:a17:906:7217:: with SMTP id m23mr12085208ejk.466.1631885679955; Fri, 17 Sep 2021 06:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631885679; cv=none; d=google.com; s=arc-20160816; b=xfp0yTka0P2C+lJoffyK4yOQ+37m3j4w4gMCabarcMdsz+B0Aw4r1gjGR+FHv4djZF YD3SApjaFh5YaYCcuNrOlnu1fD3neLZJVbeGArpApPsf020eU5gJdYkM5Mq/j6yvGJhG M/JOc0rADg9Vhyyo+tmZ60FE9QR+4jUHSa77oFWaC3kS8KmOzs1aI+nS5UxzBa5m4HFI 1CI+DgXgof0ke9dy76dzWdpDgnyTAFZHdmKL0O4ZG3e5ZKrYPwI6rDVgrbbMtRTEX7b8 TCm7H0u+qjj6TIw8Qbh67dWfhEZI+PCEEtJVZ34odzdEQdvZD4UIXyt8GAeKTbef1Owc lEkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=kCN9tU3FPdrhsXqsyawAbkRAI1VuXQH8gOS3OfUvJYo=; b=I4eU03qqH99CoNTnBDQPburuWj1L4CtuDY/8lwVIBAE7G80f2oa7hpYwqcGFsolIav 8WCfAUC00s+VtngArKRU1UlrKtPbycAcouEBJ0cQCiJmt4MOjy6gFYicT8oZZHrd7Qi0 qoo9c4tCLOOrWtslMJvpS7wY0FlBlesXpR8ty8Jz9j7UsUNmUTGyMep+1/bjEmacCpqU NtetNarReG9VC/SbPOpPQIf2MUwfkHNJgCDj6H83/jn2/PiLnrzJC6l7wB3I+ddpLIZP NqaWPpPCe6OQ8w46INsNGUGIH65G8+tlkjgyfAdpAVDpaZA6klXLyAhYYSWMAtaHcXcX NQCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x16si8402433edd.25.2021.09.17.06.34.39; Fri, 17 Sep 2021 06:34:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245638AbhIQNgA (ORCPT + 2 others); Fri, 17 Sep 2021 09:36:00 -0400 Received: from foss.arm.com ([217.140.110.172]:53344 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245265AbhIQNfn (ORCPT ); Fri, 17 Sep 2021 09:35:43 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B19F611D4; Fri, 17 Sep 2021 06:34:21 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CCDA83F719; Fri, 17 Sep 2021 06:34:20 -0700 (PDT) From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Cristian Marussi , "Rafael J . Wysocki" , Jassi Brar Subject: [PATCH v2 13/14] mailbox: pcc: Move bulk of PCCT parsing into pcc_mbox_probe Date: Fri, 17 Sep 2021 14:33:56 +0100 Message-Id: <20210917133357.1911092-14-sudeep.holla@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917133357.1911092-1-sudeep.holla@arm.com> References: <20210917133357.1911092-1-sudeep.holla@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Move the PCCT subspace parsing and allocation into pcc_mbox_probe so that we can get rid of global PCC channel and mailbox controller data. It also helps to make use of devm_* APIs for all the allocations. Signed-off-by: Sudeep Holla --- drivers/mailbox/pcc.c | 124 ++++++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 58 deletions(-) -- 2.25.1 diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index eb90c9eaaf9c..887a3704c12e 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -63,8 +63,6 @@ #define MBOX_IRQ_NAME "pcc-mbox" -static struct mbox_chan *pcc_mbox_channels; - /** * struct pcc_chan_reg - PCC register bundle * @@ -106,7 +104,7 @@ struct pcc_chan_info { #define to_pcc_chan_info(c) container_of(c, struct pcc_chan_info, chan) static struct pcc_chan_info *chan_info; -static struct mbox_controller pcc_mbox_ctrl = {}; +static int pcc_chan_count; /* * PCC can be used with perf critical drivers such as CPPC @@ -281,11 +279,11 @@ struct pcc_mbox_chan * pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id) { struct pcc_chan_info *pchan; - struct device *dev = pcc_mbox_ctrl.dev; struct mbox_chan *chan; + struct device *dev; unsigned long flags; - if (subspace_id < 0 || subspace_id >= pcc_mbox_ctrl.num_chans) + if (subspace_id < 0 || subspace_id >= pcc_chan_count) return ERR_PTR(-ENOENT); pchan = chan_info + subspace_id; @@ -294,6 +292,7 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id) dev_err(dev, "Channel not found for idx: %d\n", subspace_id); return ERR_PTR(-EBUSY); } + dev = chan->mbox->dev; spin_lock_irqsave(&chan->lock, flags); chan->msg_free = 0; @@ -576,16 +575,12 @@ static void pcc_parse_subspace_shmem(struct pcc_chan_info *pchan, */ static int __init acpi_pcc_probe(void) { + int count, i, rc = 0; + acpi_status status; struct acpi_table_header *pcct_tbl; - struct acpi_subtable_header *pcct_entry; - struct acpi_table_pcct *acpi_pcct_tbl; struct acpi_subtable_proc proc[ACPI_PCCT_TYPE_RESERVED]; - int count, i, rc; - acpi_status status = AE_OK; - /* Search for PCCT */ status = acpi_get_table(ACPI_SIG_PCCT, 0, &pcct_tbl); - if (ACPI_FAILURE(status) || !pcct_tbl) return -ENODEV; @@ -607,21 +602,60 @@ static int __init acpi_pcc_probe(void) pr_warn("Invalid PCCT: %d PCC subspaces\n", count); rc = -EINVAL; - goto err_put_pcct; + } else { + pcc_chan_count = count; } - pcc_mbox_channels = kcalloc(count, sizeof(struct mbox_chan), - GFP_KERNEL); + acpi_put_table(pcct_tbl); + + return rc; +} + +/** + * pcc_mbox_probe - Called when we find a match for the + * PCCT platform device. This is purely used to represent + * the PCCT as a virtual device for registering with the + * generic Mailbox framework. + * + * @pdev: Pointer to platform device returned when a match + * is found. + * + * Return: 0 for Success, else errno. + */ +static int pcc_mbox_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct mbox_controller *pcc_mbox_ctrl; + struct mbox_chan *pcc_mbox_channels; + struct acpi_table_header *pcct_tbl; + struct acpi_subtable_header *pcct_entry; + struct acpi_table_pcct *acpi_pcct_tbl; + acpi_status status = AE_OK; + int i, rc, count = pcc_chan_count; + + /* Search for PCCT */ + status = acpi_get_table(ACPI_SIG_PCCT, 0, &pcct_tbl); + + if (ACPI_FAILURE(status) || !pcct_tbl) + return -ENODEV; + + pcc_mbox_channels = devm_kcalloc(dev, count, sizeof(*pcc_mbox_channels), + GFP_KERNEL); if (!pcc_mbox_channels) { - pr_err("Could not allocate space for PCC mbox channels\n"); rc = -ENOMEM; - goto err_put_pcct; + goto err; } - chan_info = kcalloc(count, sizeof(*chan_info), GFP_KERNEL); + chan_info = devm_kcalloc(dev, count, sizeof(*chan_info), GFP_KERNEL); if (!chan_info) { rc = -ENOMEM; - goto err_free_mbox; + goto err; + } + + pcc_mbox_ctrl = devm_kmalloc(dev, sizeof(*pcc_mbox_ctrl), GFP_KERNEL); + if (!pcc_mbox_ctrl) { + rc = -ENOMEM; + goto err; } /* Point to the first PCC subspace entry */ @@ -630,7 +664,7 @@ static int __init acpi_pcc_probe(void) acpi_pcct_tbl = (struct acpi_table_pcct *) pcct_tbl; if (acpi_pcct_tbl->flags & ACPI_PCCT_DOORBELL) - pcc_mbox_ctrl.txdone_irq = true; + pcc_mbox_ctrl->txdone_irq = true; for (i = 0; i < count; i++) { struct pcc_chan_info *pchan = chan_info + i; @@ -639,13 +673,13 @@ static int __init acpi_pcc_probe(void) pchan->chan.mchan = &pcc_mbox_channels[i]; if (pcct_entry->type == ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE && - !pcc_mbox_ctrl.txdone_irq) { + !pcc_mbox_ctrl->txdone_irq) { pr_err("Plaform Interrupt flag must be set to 1"); rc = -EINVAL; goto err; } - if (pcc_mbox_ctrl.txdone_irq) { + if (pcc_mbox_ctrl->txdone_irq) { rc = pcc_parse_subspace_irq(pchan, pcct_entry); if (rc < 0) goto err; @@ -660,51 +694,25 @@ static int __init acpi_pcc_probe(void) ((unsigned long) pcct_entry + pcct_entry->length); } - pcc_mbox_ctrl.num_chans = count; + pcc_mbox_ctrl->num_chans = count; - pr_info("Detected %d PCC Subspaces\n", pcc_mbox_ctrl.num_chans); + pr_info("Detected %d PCC Subspaces\n", pcc_mbox_ctrl->num_chans); - return 0; + pcc_mbox_ctrl->chans = pcc_mbox_channels; + pcc_mbox_ctrl->ops = &pcc_chan_ops; + pcc_mbox_ctrl->dev = dev; + pr_info("Registering PCC driver as Mailbox controller\n"); + rc = mbox_controller_register(pcc_mbox_ctrl); + if (rc) + pr_err("Err registering PCC as Mailbox controller: %d\n", rc); + else + return 0; err: - kfree(chan_info); -err_free_mbox: - kfree(pcc_mbox_channels); -err_put_pcct: acpi_put_table(pcct_tbl); return rc; } -/** - * pcc_mbox_probe - Called when we find a match for the - * PCCT platform device. This is purely used to represent - * the PCCT as a virtual device for registering with the - * generic Mailbox framework. - * - * @pdev: Pointer to platform device returned when a match - * is found. - * - * Return: 0 for Success, else errno. - */ -static int pcc_mbox_probe(struct platform_device *pdev) -{ - int ret = 0; - - pcc_mbox_ctrl.chans = pcc_mbox_channels; - pcc_mbox_ctrl.ops = &pcc_chan_ops; - pcc_mbox_ctrl.dev = &pdev->dev; - - pr_info("Registering PCC driver as Mailbox controller\n"); - ret = mbox_controller_register(&pcc_mbox_ctrl); - - if (ret) { - pr_err("Err registering PCC as Mailbox controller: %d\n", ret); - ret = -ENODEV; - } - - return ret; -} - static struct platform_driver pcc_mbox_driver = { .probe = pcc_mbox_probe, .driver = { From patchwork Fri Sep 17 13:33:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 514192 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp2236400jao; Fri, 17 Sep 2021 06:34:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFO8OoOsFm34xDr3ARPpFXCXImAt/xYalFfD3+Lh23Ew55Q9ry4jGmym1cGfIPfap8g+sI X-Received: by 2002:a17:906:cc57:: with SMTP id mm23mr12427181ejb.540.1631885681579; Fri, 17 Sep 2021 06:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631885681; cv=none; d=google.com; s=arc-20160816; b=T+W1Jpa6HTh0XlBFlBd39KfwyxGKbreCYASKclGxmLe/kZiUmCdGDLiYaMra3GKZJ8 uoONWp3eEiQkW3fiXEi97g7eS5KRlmDYBubCCXkywwJpI4QTDKnDG23j2ef2NeuUxxuM 71OQ/bZf9o9561o36hfetXtkv1UKoZpjOEs/KXKFsECh3VcVcQ3IWO8YvDCdsLKcqdut XRQHvjFP6liCKWCiLkNkEqwK6WQYoIHopxfBHy09LDnsfgM+461UTOw4EjJQYPgIJ/0D s3jAgwBjLCgqkq67l/zXMH1q6nSO/5VP1Otfz/fbBz4J2XhmyyobcP5DwkmjMx+REEi2 76qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=hJUoVd9HsJPnXG0B4kNo0CnVCh+kyoLO5GV3O2MCxyw=; b=c+x3d+sZu7D91/jNfMkSNDB1o+lfxIwdHueD6qLqYvFYcYrCu9Oy2exSQ98+8qXPtd 8iVhYvIYQ01xeWTZTk+oVdC9A6CsrSCixsMpmGnRZLvfjO1/9z9ldFG5CPDJwzcKzRGD 04vBzKXnlRgMC8tYCnUZBbsiRFifoEtVtU+yZZCkAPrpmsb/zSZ1HOsR9FJ3520qfX7S AOnEsWGn5Er/dM8pwWQWVvT1v4O2TzAYmVcrppBoIH5GfDsHoSfrenkwOARokcaBpJHG TmEoAOizGNh52u5D9Wyss0hXec0XNgZ+A8GvgQBgb0X45bQGLLb4HzA/QFqpVWcD3sLF ydGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x16si8402433edd.25.2021.09.17.06.34.41; Fri, 17 Sep 2021 06:34:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245282AbhIQNgB (ORCPT + 2 others); Fri, 17 Sep 2021 09:36:01 -0400 Received: from foss.arm.com ([217.140.110.172]:53356 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245321AbhIQNfp (ORCPT ); Fri, 17 Sep 2021 09:35:45 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 25C3713A1; Fri, 17 Sep 2021 06:34:23 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E57423F719; Fri, 17 Sep 2021 06:34:21 -0700 (PDT) From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Cristian Marussi , "Rafael J . Wysocki" , Jassi Brar , "Rafael J. Wysocki" , "Rafael J. Wysocki" , Jassi Brar Subject: [PATCH v2 14/14] ACPI/PCC: Add myself as maintainer for PCC mailbox driver Date: Fri, 17 Sep 2021 14:33:57 +0100 Message-Id: <20210917133357.1911092-15-sudeep.holla@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917133357.1911092-1-sudeep.holla@arm.com> References: <20210917133357.1911092-1-sudeep.holla@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Not much functionality is added since PCC driver was added 5 years ago. There is need to restructure the driver while adding support for PCC Extended subspaces type 3&4. There is more rework needed as more users adopt PCC on arm64 platforms. In order to ease the same, I would like to take responsibility to maintain this driver. Cc: "Rafael J. Wysocki" Cc: "Rafael J. Wysocki" Cc: Jassi Brar Signed-off-by: Sudeep Holla --- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) Hi Rafael, As you mentioned offline that you haven't followed ACPI PCC changes much and don't have time to review this, I thought of adding myself as maintainer for the ACPI PCC part of the mailbox as I will be tracking and using PCCT. Let me know if you have any objections. Regards, Sudeep -- 2.25.1 Acked-by: "Rafael J. Wysocki" diff --git a/MAINTAINERS b/MAINTAINERS index eeb4c70b3d5b..8d41dd710ae9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -401,6 +401,12 @@ L: platform-driver-x86@vger.kernel.org S: Maintained F: drivers/platform/x86/i2c-multi-instantiate.c +ACPI PCC(Platform Communication Channel) MAILBOX DRIVER +M: Sudeep Holla +L: linux-acpi@vger.kernel.org +S: Supported +F: drivers/mailbox/pcc.c + ACPI PMIC DRIVERS M: "Rafael J. Wysocki" M: Len Brown