Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932587AbdCaGYi (ORCPT ); Fri, 31 Mar 2017 02:24:38 -0400 Received: from mail-sn1nam02on0058.outbound.protection.outlook.com ([104.47.36.58]:46741 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753049AbdCaGYd (ORCPT ); Fri, 31 Mar 2017 02:24:33 -0400 Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=cavium.com; From: George Cherian To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, devel@acpica.org Cc: ashwin.chaugule@linaro.org, rjw@rjwysocki.net, lenb@kernel.org, jassisinghbrar@gmail.com, robert.moore@intel.com, lv.zheng@intel.com, George Cherian Subject: [PATCH 2/2] ACPI / CPPC: Make cppc acpi driver aware of pcc subspace ids Date: Fri, 31 Mar 2017 06:24:02 +0000 Message-Id: <1490941442-11954-3-git-send-email-george.cherian@cavium.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1490941442-11954-1-git-send-email-george.cherian@cavium.com> References: <1490941442-11954-1-git-send-email-george.cherian@cavium.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: PN1PR01CA0081.INDPRD01.PROD.OUTLOOK.COM (10.174.144.149) To BLUPR0701MB1699.namprd07.prod.outlook.com (10.163.85.13) X-MS-Office365-Filtering-Correlation-Id: c5cf27b7-ddb0-480c-6c88-08d477fe96f0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BLUPR0701MB1699; X-Microsoft-Exchange-Diagnostics: 1;BLUPR0701MB1699;3:/7AKLwKEtzdkV+vFxq7nz7JK9xS41XPbSL4KSwBgYwHkzOnGZUePSdBT/xnOKleVWEOmBcz2FwMHQZHwJ91qE9JO7Ur4F9BGL+eYG3UF3y/jrD0z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BpITuQ2n6AfOfWqEdfeCECoV6WXYLT+CRBPqMs/iNHXHCS0DcOj9k+GAYGnM56Vb/ukIBFNNusLQ6Zx2BiqEzcoKtxOfo7JGatznCMGn+VRWw5J0pzrLse97jwV4MwF4C9h9PY2GIYY7si6k8WZhy2yP18yKI7BlMdtUo54oLXn0d9KKpXcO35x0loQydt2t4SrQDz6Pdmq8lvCAT9f6Ml233LzU+5TA/nbrnrWhW0LqlxXtF6vIjdOOcWNL2K5tlhr1zHiu9hKn4AFTxM18DZtXqob7qO+xPAWC+7BGNzFPP7l3p+ynEd9aWc7ld9myTpYsvznC1HF4bbLJwCEmdGssSM6nryn91NnWticVos3VTP3WFLCg94w8HD/VKFNhRSZgORDM3pY2vJNtS0RV3eqEwYfhPMIWJO58hOP X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(60795455431006); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006091)(93001091)(6041248)(20161123555025)(20161123562025)(20161123560025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(6072148);SRVR:BLUPR0701MB1699;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0701MB1699; X-Microsoft-Exchange-Diagnostics: 1;BLUPR0701MB1699;4:Y3q9CjUkdKqewXtfEBjga3ofmiN4T+SSRf+9hGCCLzZ/2IkZXjg/i6D+WxsoorOiYBj9HxFcKJUnnqaLS2iW+ItfuOEdCHynkI8mw+ibtw12Eaet2HY1rz9BDE3bQAV4tO3GBEepcZcU0uja6So9KGvcTbf4DctiZjtIGOzRNpxLRshF/LQi6EXMx5B/IJHTVUg7uYZDjyIr1uGtLnIkv6V6Hu/dUZ8wnpiRfzDJL/LMZt1TQlCfh9ZJh+bF7akXo+TyV7wTKqar+nhnWcip8eN0mlWFHWIrSBY7PzW+FJiXjHnlFWYrGQ90F35bQ0hQEzz9xsnY1OzFmgwY3tJSKmkaD26gMI+TPdLrHh/CdFThCLpBxzXOgCNqcPGAuUoIoWBFQ+N8RmCsC5LEioMJW/Weatrb1Jbf/Ktj/2tKeilRQuFIYWMjEqoC/weIxQd9I13MY8WSHO1x0jp734K4sCpUAB5gah3Io9u49fnfCDN3+6Nag/CcrWZs/0V0B6osecVFf5dLAi1C3c87WMxcGdslTG0om63ZpSLhV/FwSRKV1pZyZbzQxGFiHzRsuf6o7xBJJNcEe/ipJGvuqLzhROTAqE6EzO5cbg1z+S8EtAR5agc8hVcxN4FIhATJqQTCgADjGiHl4+4L5LG9NH6prgefJ7n8v7nYLdjeH3jV3Te2fSBe1ny2/YvL153SCeXdfqqI80x/0PqlMUb/TporAM2ybXtgYB4vBl+BhUSrX+DHWcjk65GLUDxPgvTwe4Pk X-Forefront-PRVS: 02638D901B X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(39840400002)(39450400003)(39410400002)(39400400002)(4326008)(2950100002)(6666003)(110136004)(53936002)(107886003)(38730400002)(6486002)(6512007)(2906002)(86362001)(25786009)(6506006)(5009440100003)(50226002)(8676002)(189998001)(33646002)(42186005)(305945005)(53416004)(50986999)(6116002)(66066001)(3846002)(5660300001)(36756003)(76176999)(5003940100001)(47776003)(81166006)(48376002)(50466002)(7736002);DIR:OUT;SFP:1101;SCL:1;SRVR:BLUPR0701MB1699;H:ubuntu.caveonetworks.com;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR0701MB1699;23:HlsMbFl2AJebi38MOwHwjHOBmmFSFMAVhAmzJ/I?= =?us-ascii?Q?GLomRMNzyJT4GJxIECkHLBv1B8LNROxkIp3JAowAjT1CKSObwrB19nHYicmD?= =?us-ascii?Q?6MQTs/t3MpAqPARY8fLCYO0fNAmZWpCVXUBFp4/USehtukD0HVBweMj0IevO?= =?us-ascii?Q?QJ6HL36a4cic0nQLv9ykpJwmDJfDDOQ+pNtvi06g9+ouDVGexP5RD/R6alub?= =?us-ascii?Q?2s1j1we66j8UKZcWGaBn6G80b7K2FxWUmq4d9dpJnSqrxfHMP879tovRQnKC?= =?us-ascii?Q?f79fzaSqh7jXA5LI10BquP8IOJF0+hpb8R3IozBg6IWDdLVDY8c8clj4QPhm?= =?us-ascii?Q?keo+EHWOwPnHoL5DdaiXmdhQ0rIt8ay3N8P7qiUptl79pa50dNvbzDlNi9Zs?= =?us-ascii?Q?Q3/0wbGQ+Kw+KadzNasMHFV7ODeOtMvtjDK2xdoEsBF4fspzpkY/y3fJICKP?= =?us-ascii?Q?O+UJUzK/ayG6yFiINzaYuh1gMjdxyft3srj1IZfQ1uRlWANi9Xq5FtDPvbJo?= =?us-ascii?Q?zwXMFp+nA4XYPpYdS4etqJtOSc1zBso5aaegcBn1pEjAkTLzKfutWXZAh/Vm?= =?us-ascii?Q?9AUIIdf+MiasU9H58nS2BprdV7OyLbJABCIk9/SjCmhRZs7DCyy6ODk0goKO?= =?us-ascii?Q?eb02f2hkvIE/C04E76FtY08j/15z/JfcmUZAWfXo8lPIXzO5QHnjf9l0dWgO?= =?us-ascii?Q?UcpV+idjENdrBvG6z9ae1jnIpbZKniU9PNxHgqxiwVSr3GeOCvskKOKF/gxc?= =?us-ascii?Q?sM9p8Llq+xWgG2FjTWtTzhW526Ch3UNU3DM6Jid/0VuCv/l6/8vVnjBTntRG?= =?us-ascii?Q?fDlQbgDkOl2AdySLiegzDrkLm1igqDBVIXzk+H8ExEmw8/5khgNF1erIOf/M?= =?us-ascii?Q?Wecl3xgKpxe4CPjJI7auf2kxHJOLeeGIsbf58FzcVLTrQUtfj406Xuo0i9xV?= =?us-ascii?Q?QAChF060nqmsd1mCEupp6GA3WJEzYCZn8423EY8RbaGEBvJOhxANUrMkhgKZ?= =?us-ascii?Q?pASsuRACj1WvaOcTDM6bBz2wligGeuLq9v99Fqyrqxg5rqA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR0701MB1699;6:dVbCS1YUbtIM+wqQ4LAaE56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orOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2017 06:24:27.0537 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1699 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 18192 Lines: 489 Based on Section 14.1 of ACPI specification, it is possible to have a maximum of 256 PCC subspace ids. Add support of multiple PCC subspace id instead of using a single global pcc_data structure. While at that fix the time_delta check in send_pcc_cmd() so that last_mpar_reset and mpar_count is initialized properly. Also maintain a global total_mpar_count which is a sum of per subspace id mpar value. Signed-off-by: George Cherian --- drivers/acpi/cppc_acpi.c | 189 ++++++++++++++++++++++++++--------------------- 1 file changed, 105 insertions(+), 84 deletions(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 3ca0729..7ba05ac 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -77,12 +77,16 @@ struct cppc_pcc_data { wait_queue_head_t pcc_write_wait_q; }; -/* Structure to represent the single PCC channel */ -static struct cppc_pcc_data pcc_data = { - .pcc_subspace_idx = -1, - .platform_owns_pcc = true, -}; +/* Array to represent the PCC channel per subspace id */ +static struct cppc_pcc_data pcc_data[MAX_PCC_SUBSPACES]; +/* + * It is quiet possible that multiple CPU's can share + * same subspace ids. The cpu_pcc_subspace_idx maintains + * the cpu to pcc subspace id map. + */ +static DEFINE_PER_CPU(int, cpu_pcc_subspace_idx); +static int total_mpar_count; /* * The cpc_desc structure contains the ACPI register details * as described in the per CPU _CPC tables. The details @@ -93,7 +97,8 @@ static struct cppc_pcc_data pcc_data = { static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr); /* pcc mapped address + header size + offset within PCC subspace */ -#define GET_PCC_VADDR(offs) (pcc_data.pcc_comm_addr + 0x8 + (offs)) +#define GET_PCC_VADDR(offs, pcc_ss_id) (pcc_data[pcc_ss_id].pcc_comm_addr + \ + 0x8 + (offs)) /* Check if a CPC regsiter is in PCC */ #define CPC_IN_PCC(cpc) ((cpc)->type == ACPI_TYPE_BUFFER && \ @@ -183,13 +188,17 @@ static struct kobj_type cppc_ktype = { .default_attrs = cppc_attrs, }; -static int check_pcc_chan(bool chk_err_bit) +static int check_pcc_chan(int cpunum, bool chk_err_bit) { int ret = -EIO, status = 0; - struct acpi_pcct_shared_memory __iomem *generic_comm_base = pcc_data.pcc_comm_addr; - ktime_t next_deadline = ktime_add(ktime_get(), pcc_data.deadline); - - if (!pcc_data.platform_owns_pcc) + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum); + struct cppc_pcc_data *pcc_ss_data = &pcc_data[pcc_ss_id]; + struct acpi_pcct_shared_memory __iomem *generic_comm_base = + pcc_ss_data->pcc_comm_addr; + ktime_t next_deadline = ktime_add(ktime_get(), + pcc_ss_data->deadline); + + if (!pcc_ss_data->platform_owns_pcc) return 0; /* Retry in case the remote processor was too slow to catch up. */ @@ -214,7 +223,7 @@ static int check_pcc_chan(bool chk_err_bit) } if (likely(!ret)) - pcc_data.platform_owns_pcc = false; + pcc_ss_data->platform_owns_pcc = false; else pr_err("PCC check channel failed. Status=%x\n", status); @@ -225,11 +234,13 @@ static int check_pcc_chan(bool chk_err_bit) * This function transfers the ownership of the PCC to the platform * So it must be called while holding write_lock(pcc_lock) */ -static int send_pcc_cmd(u16 cmd) +static int send_pcc_cmd(int cpunum, u16 cmd) { int ret = -EIO, i; + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum); + struct cppc_pcc_data *pcc_ss_data = &pcc_data[pcc_ss_id]; struct acpi_pcct_shared_memory *generic_comm_base = - (struct acpi_pcct_shared_memory *) pcc_data.pcc_comm_addr; + (struct acpi_pcct_shared_memory *)pcc_ss_data->pcc_comm_addr; static ktime_t last_cmd_cmpl_time, last_mpar_reset; static int mpar_count; unsigned int time_delta; @@ -244,24 +255,24 @@ static int send_pcc_cmd(u16 cmd) * before write completion, so first send a WRITE command to * platform */ - if (pcc_data.pending_pcc_write_cmd) - send_pcc_cmd(CMD_WRITE); + if (pcc_ss_data->pending_pcc_write_cmd) + send_pcc_cmd(cpunum, CMD_WRITE); - ret = check_pcc_chan(false); + ret = check_pcc_chan(cpunum, false); if (ret) goto end; } else /* CMD_WRITE */ - pcc_data.pending_pcc_write_cmd = FALSE; + pcc_ss_data->pending_pcc_write_cmd = FALSE; /* * Handle the Minimum Request Turnaround Time(MRTT) * "The minimum amount of time that OSPM must wait after the completion * of a command before issuing the next command, in microseconds" */ - if (pcc_data.pcc_mrtt) { + if (pcc_ss_data->pcc_mrtt) { time_delta = ktime_us_delta(ktime_get(), last_cmd_cmpl_time); - if (pcc_data.pcc_mrtt > time_delta) - udelay(pcc_data.pcc_mrtt - time_delta); + if (pcc_ss_data->pcc_mrtt > time_delta) + udelay(pcc_ss_data->pcc_mrtt - time_delta); } /* @@ -275,16 +286,16 @@ static int send_pcc_cmd(u16 cmd) * not send the request to the platform after hitting the MPAR limit in * any 60s window */ - if (pcc_data.pcc_mpar) { + if (pcc_ss_data->pcc_mpar) { if (mpar_count == 0) { time_delta = ktime_ms_delta(ktime_get(), last_mpar_reset); - if (time_delta < 60 * MSEC_PER_SEC) { + if ((time_delta < 60 * MSEC_PER_SEC) && last_mpar_reset) { pr_debug("PCC cmd not sent due to MPAR limit"); ret = -EIO; goto end; } last_mpar_reset = ktime_get(); - mpar_count = pcc_data.pcc_mpar; + mpar_count = total_mpar_count; } mpar_count--; } @@ -295,10 +306,10 @@ static int send_pcc_cmd(u16 cmd) /* Flip CMD COMPLETE bit */ writew_relaxed(0, &generic_comm_base->status); - pcc_data.platform_owns_pcc = true; + pcc_ss_data->platform_owns_pcc = true; /* Ring doorbell */ - ret = mbox_send_message(pcc_data.pcc_channel, &cmd); + ret = mbox_send_message(pcc_ss_data->pcc_channel, &cmd); if (ret < 0) { pr_err("Err sending PCC mbox message. cmd:%d, ret:%d\n", cmd, ret); @@ -306,15 +317,15 @@ static int send_pcc_cmd(u16 cmd) } /* wait for completion and check for PCC errro bit */ - ret = check_pcc_chan(true); + ret = check_pcc_chan(cpunum, true); - if (pcc_data.pcc_mrtt) + if (pcc_ss_data->pcc_mrtt) last_cmd_cmpl_time = ktime_get(); - if (pcc_data.pcc_channel->mbox->txdone_irq) - mbox_chan_txdone(pcc_data.pcc_channel, ret); + if (pcc_ss_data->pcc_channel->mbox->txdone_irq) + mbox_chan_txdone(pcc_ss_data->pcc_channel, ret); else - mbox_client_txdone(pcc_data.pcc_channel, ret); + mbox_client_txdone(pcc_ss_data->pcc_channel, ret); end: if (cmd == CMD_WRITE) { @@ -324,12 +335,12 @@ static int send_pcc_cmd(u16 cmd) if (!desc) continue; - if (desc->write_cmd_id == pcc_data.pcc_write_cnt) + if (desc->write_cmd_id == pcc_ss_data->pcc_write_cnt) desc->write_cmd_status = ret; } } - pcc_data.pcc_write_cnt++; - wake_up_all(&pcc_data.pcc_write_wait_q); + pcc_ss_data->pcc_write_cnt++; + wake_up_all(&pcc_ss_data->pcc_write_wait_q); } return ret; @@ -531,16 +542,16 @@ int acpi_get_psd_map(struct cppc_cpudata **all_cpu_data) } EXPORT_SYMBOL_GPL(acpi_get_psd_map); -static int register_pcc_channel(int pcc_subspace_idx) +static int register_pcc_channel(int pcc_ss_idx) { struct acpi_pcct_hw_reduced *cppc_ss; u64 usecs_lat; - if (pcc_subspace_idx >= 0) { - pcc_data.pcc_channel = pcc_mbox_request_channel(&cppc_mbox_cl, - pcc_subspace_idx); + if (pcc_ss_idx >= 0) { + pcc_data[pcc_ss_idx].pcc_channel = + pcc_mbox_request_channel(&cppc_mbox_cl, pcc_ss_idx); - if (IS_ERR(pcc_data.pcc_channel)) { + if (IS_ERR(pcc_data[pcc_ss_idx].pcc_channel)) { pr_err("Failed to find PCC communication channel\n"); return -ENODEV; } @@ -551,7 +562,7 @@ static int register_pcc_channel(int pcc_subspace_idx) * PCC channels) and stored pointers to the * subspace communication region in con_priv. */ - cppc_ss = (pcc_data.pcc_channel)->con_priv; + cppc_ss = (pcc_data[pcc_ss_idx].pcc_channel)->con_priv; if (!cppc_ss) { pr_err("No PCC subspace found for CPPC\n"); @@ -564,19 +575,21 @@ static int register_pcc_channel(int pcc_subspace_idx) * So add an arbitrary amount of wait on top of Nominal. */ usecs_lat = NUM_RETRIES * cppc_ss->latency; - pcc_data.deadline = ns_to_ktime(usecs_lat * NSEC_PER_USEC); - pcc_data.pcc_mrtt = cppc_ss->min_turnaround_time; - pcc_data.pcc_mpar = cppc_ss->max_access_rate; - pcc_data.pcc_nominal = cppc_ss->latency; - - pcc_data.pcc_comm_addr = acpi_os_ioremap(cppc_ss->base_address, cppc_ss->length); - if (!pcc_data.pcc_comm_addr) { + pcc_data[pcc_ss_idx].deadline = ns_to_ktime(usecs_lat * NSEC_PER_USEC); + 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; + total_mpar_count += cppc_ss->max_access_rate; + + pcc_data[pcc_ss_idx].pcc_comm_addr = + acpi_os_ioremap(cppc_ss->base_address, cppc_ss->length); + if (!pcc_data[pcc_ss_idx].pcc_comm_addr) { pr_err("Failed to ioremap PCC comm region mem\n"); return -ENOMEM; } /* Set flag so that we dont come here for each CPU. */ - pcc_data.pcc_channel_acquired = true; + pcc_data[pcc_ss_idx].pcc_channel_acquired = true; } return 0; @@ -656,6 +669,7 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) struct device *cpu_dev; acpi_handle handle = pr->handle; unsigned int num_ent, i, cpc_rev; + unsigned int pcc_subspace_id = 0; acpi_status status; int ret = -EFAULT; @@ -728,12 +742,9 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) * so extract it only once. */ if (gas_t->space_id == ACPI_ADR_SPACE_PLATFORM_COMM) { - if (pcc_data.pcc_subspace_idx < 0) - pcc_data.pcc_subspace_idx = gas_t->access_width; - else if (pcc_data.pcc_subspace_idx != gas_t->access_width) { - pr_debug("Mismatched PCC ids.\n"); - goto out_free; - } + pcc_subspace_id = gas_t->access_width; + pcc_data[pcc_subspace_id].pcc_subspace_idx = gas_t->access_width; + per_cpu(cpu_pcc_subspace_idx, pr->id) = gas_t->access_width; } else if (gas_t->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { if (gas_t->address) { void __iomem *addr; @@ -766,14 +777,14 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) if (ret) goto out_free; - /* Register PCC channel once for all CPUs. */ - if (!pcc_data.pcc_channel_acquired) { - ret = register_pcc_channel(pcc_data.pcc_subspace_idx); + /* Register PCC channel once for all PCC subspace id. */ + if (!pcc_data[pcc_subspace_id].pcc_channel_acquired) { + ret = register_pcc_channel(pcc_data[pcc_subspace_id].pcc_subspace_idx); if (ret) goto out_free; - init_rwsem(&pcc_data.pcc_lock); - init_waitqueue_head(&pcc_data.pcc_write_wait_q); + init_rwsem(&pcc_data[pcc_subspace_id].pcc_lock); + init_waitqueue_head(&pcc_data[pcc_subspace_id].pcc_write_wait_q); } /* Everything looks okay */ @@ -883,6 +894,7 @@ static int cpc_read(int cpu, struct cpc_register_resource *reg_res, u64 *val) { int ret_val = 0; void __iomem *vaddr = 0; + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu); struct cpc_reg *reg = ®_res->cpc_entry.reg; if (reg_res->type == ACPI_TYPE_INTEGER) { @@ -892,7 +904,7 @@ static int cpc_read(int cpu, struct cpc_register_resource *reg_res, u64 *val) *val = 0; if (reg->space_id == ACPI_ADR_SPACE_PLATFORM_COMM) - vaddr = GET_PCC_VADDR(reg->address); + vaddr = GET_PCC_VADDR(reg->address, pcc_ss_id); else if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) vaddr = reg_res->sys_mem_vaddr; else if (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) @@ -927,10 +939,11 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val) { int ret_val = 0; void __iomem *vaddr = 0; + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu); struct cpc_reg *reg = ®_res->cpc_entry.reg; if (reg->space_id == ACPI_ADR_SPACE_PLATFORM_COMM) - vaddr = GET_PCC_VADDR(reg->address); + vaddr = GET_PCC_VADDR(reg->address, pcc_ss_id); else if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) vaddr = reg_res->sys_mem_vaddr; else if (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) @@ -974,6 +987,8 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps) struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum); struct cpc_register_resource *highest_reg, *lowest_reg, *ref_perf, *nom_perf; + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum); + struct cppc_pcc_data *pcc_ss_data = &pcc_data[pcc_ss_id]; u64 high, low, nom; int ret = 0, regs_in_pcc = 0; @@ -991,9 +1006,9 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps) if (CPC_IN_PCC(highest_reg) || CPC_IN_PCC(lowest_reg) || CPC_IN_PCC(ref_perf) || CPC_IN_PCC(nom_perf)) { regs_in_pcc = 1; - down_write(&pcc_data.pcc_lock); + down_write(&pcc_ss_data->pcc_lock); /* Ring doorbell once to update PCC subspace */ - if (send_pcc_cmd(CMD_READ) < 0) { + if (send_pcc_cmd(cpunum, CMD_READ) < 0) { ret = -EIO; goto out_err; } @@ -1013,7 +1028,7 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps) out_err: if (regs_in_pcc) - up_write(&pcc_data.pcc_lock); + up_write(&pcc_ss_data->pcc_lock); return ret; } EXPORT_SYMBOL_GPL(cppc_get_perf_caps); @@ -1030,6 +1045,8 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs) struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum); struct cpc_register_resource *delivered_reg, *reference_reg, *ref_perf_reg, *ctr_wrap_reg; + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum); + struct cppc_pcc_data *pcc_ss_data = &pcc_data[pcc_ss_id]; u64 delivered, reference, ref_perf, ctr_wrap_time; int ret = 0, regs_in_pcc = 0; @@ -1053,10 +1070,10 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs) /* Are any of the regs PCC ?*/ if (CPC_IN_PCC(delivered_reg) || CPC_IN_PCC(reference_reg) || CPC_IN_PCC(ctr_wrap_reg) || CPC_IN_PCC(ref_perf_reg)) { - down_write(&pcc_data.pcc_lock); + down_write(&pcc_ss_data->pcc_lock); regs_in_pcc = 1; /* Ring doorbell once to update PCC subspace */ - if (send_pcc_cmd(CMD_READ) < 0) { + if (send_pcc_cmd(cpunum, CMD_READ) < 0) { ret = -EIO; goto out_err; } @@ -1086,7 +1103,7 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs) perf_fb_ctrs->ctr_wrap_time = ctr_wrap_time; out_err: if (regs_in_pcc) - up_write(&pcc_data.pcc_lock); + up_write(&pcc_ss_data->pcc_lock); return ret; } EXPORT_SYMBOL_GPL(cppc_get_perf_ctrs); @@ -1102,6 +1119,8 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) { struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpu); struct cpc_register_resource *desired_reg; + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu); + struct cppc_pcc_data *pcc_ss_data = &pcc_data[pcc_ss_id]; int ret = 0; if (!cpc_desc) { @@ -1119,11 +1138,11 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) * achieve that goal here */ if (CPC_IN_PCC(desired_reg)) { - down_read(&pcc_data.pcc_lock); /* BEGIN Phase-I */ - if (pcc_data.platform_owns_pcc) { - ret = check_pcc_chan(false); + down_read(&pcc_ss_data->pcc_lock); /* BEGIN Phase-I */ + if (pcc_ss_data->platform_owns_pcc) { + ret = check_pcc_chan(cpu, false); if (ret) { - up_read(&pcc_data.pcc_lock); + up_read(&pcc_ss_data->pcc_lock); return ret; } } @@ -1131,8 +1150,8 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) * Update the pending_write to make sure a PCC CMD_READ will not * arrive and steal the channel during the switch to write lock */ - pcc_data.pending_pcc_write_cmd = true; - cpc_desc->write_cmd_id = pcc_data.pcc_write_cnt; + pcc_ss_data->pending_pcc_write_cmd = true; + cpc_desc->write_cmd_id = pcc_ss_data->pcc_write_cnt; cpc_desc->write_cmd_status = 0; } @@ -1143,7 +1162,7 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) cpc_write(cpu, desired_reg, perf_ctrls->desired_perf); if (CPC_IN_PCC(desired_reg)) - up_read(&pcc_data.pcc_lock); /* END Phase-I */ + up_read(&pcc_ss_data->pcc_lock); /* END Phase-I */ /* * This is Phase-II where we transfer the ownership of PCC to Platform * @@ -1191,15 +1210,15 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) * the write command before servicing the read command */ if (CPC_IN_PCC(desired_reg)) { - if (down_write_trylock(&pcc_data.pcc_lock)) { /* BEGIN Phase-II */ + if (down_write_trylock(&pcc_ss_data->pcc_lock)) {/* BEGIN Phase-II */ /* Update only if there are pending write commands */ - if (pcc_data.pending_pcc_write_cmd) - send_pcc_cmd(CMD_WRITE); - up_write(&pcc_data.pcc_lock); /* END Phase-II */ + if (pcc_ss_data->pending_pcc_write_cmd) + send_pcc_cmd(cpu, CMD_WRITE); + up_write(&pcc_ss_data->pcc_lock); /* END Phase-II */ } else /* Wait until pcc_write_cnt is updated by send_pcc_cmd */ - wait_event(pcc_data.pcc_write_wait_q, - cpc_desc->write_cmd_id != pcc_data.pcc_write_cnt); + wait_event(pcc_ss_data->pcc_write_wait_q, + cpc_desc->write_cmd_id != pcc_ss_data->pcc_write_cnt); /* send_pcc_cmd updates the status in case of failure */ ret = cpc_desc->write_cmd_status; @@ -1232,6 +1251,8 @@ unsigned int cppc_get_transition_latency(int cpu_num) unsigned int latency_ns = 0; struct cpc_desc *cpc_desc; struct cpc_register_resource *desired_reg; + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu_num); + struct cppc_pcc_data *pcc_ss_data = &pcc_data[pcc_ss_id]; cpc_desc = per_cpu(cpc_desc_ptr, cpu_num); if (!cpc_desc) @@ -1241,11 +1262,11 @@ unsigned int cppc_get_transition_latency(int cpu_num) if (!CPC_IN_PCC(desired_reg)) return CPUFREQ_ETERNAL; - if (pcc_data.pcc_mpar) - latency_ns = 60 * (1000 * 1000 * 1000 / pcc_data.pcc_mpar); + if (pcc_ss_data->pcc_mpar) + latency_ns = 60 * (1000 * 1000 * 1000 / pcc_ss_data->pcc_mpar); - latency_ns = max(latency_ns, pcc_data.pcc_nominal * 1000); - latency_ns = max(latency_ns, pcc_data.pcc_mrtt * 1000); + latency_ns = max(latency_ns, pcc_ss_data->pcc_nominal * 1000); + latency_ns = max(latency_ns, pcc_ss_data->pcc_mrtt * 1000); return latency_ns; } -- 2.1.4