Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753692AbdDDKwt (ORCPT ); Tue, 4 Apr 2017 06:52:49 -0400 Received: from mail-by2nam03on0058.outbound.protection.outlook.com ([104.47.42.58]:8992 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753300AbdDDKvl (ORCPT ); Tue, 4 Apr 2017 06:51:41 -0400 Authentication-Results: codeaurora.org; dkim=none (message not signed) header.d=none;codeaurora.org; dmarc=none action=none header.from=caviumnetworks.com; Subject: Re: [PATCH 2/2] ACPI / CPPC: Make cppc acpi driver aware of pcc subspace ids To: Alexey Klimov , George Cherian References: <1490941442-11954-1-git-send-email-george.cherian@cavium.com> <1490941442-11954-3-git-send-email-george.cherian@cavium.com> <20170403173746.GA27057@arm.com> Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, devel@acpica.org, ashwin.chaugule@linaro.org, rjw@rjwysocki.net, lenb@kernel.org, jassisinghbrar@gmail.com, robert.moore@intel.com, lv.zheng@intel.com, pprakash@codeaurora.org From: George Cherian Message-ID: <58E37AA8.40308@caviumnetworks.com> Date: Tue, 4 Apr 2017 16:21:20 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20170403173746.GA27057@arm.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: PN1PR01CA0064.INDPRD01.PROD.OUTLOOK.COM (10.164.136.164) To BY1PR0701MB1705.namprd07.prod.outlook.com (10.162.111.12) X-MS-Office365-Filtering-Correlation-Id: 9c5d5b82-74ae-4a4d-e8c8-08d47b4892fd X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BY1PR0701MB1705; X-Microsoft-Exchange-Diagnostics: 1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gy5/lKega8s2YETu7MbJ83s=;20:0Pcc4miAZtKMoVk7paC2Lek5sChhpBv4bz81M6MRFi9U8xw8wL6KcK1+1Amn24DmtjbGsLCSrbBTwnOSzjBNva4usnka4qntjVhlxeTqCgrjOZHfwLSzDMsLXAvbsLQ/zoIRhNT9SaBF/oU+qwaGyVVEUhGKffmPBwiJkVBdW4xSvu/JWBSfUCAVV0dwCvA2fEg4+uZzmturkaY5RlPPzsCMqsvSH5lRCT9smhjvzc2WsLZGtTIEYbVEaEmXT0SAZNgTXdcyXuhVKeH007uhHNCieqGFlxBQRDVt4ppM2VOiwQAB0puZMkpMhSkBlUutroj3O8HqukkHMf9McDuhJqRRTFhFKUmkr6n9o69E5OTM2Rh0xaU4BF/tW/TtfK/AdpmBgnf2aELb8eixei70Fkzz2NVrHE7jJjIrmwuKUPfzifETa/PTjF+DzCOIfy/NNmozx2spytR7oAzt7QCGM0CBDmbbBa0v1xkRqQeZ4TZFfy2px1XaF55/HYpnLtHgQE2gN3TzkCeEkulT/lXsmlYZSiL1zTU5SG13wOLC9I5jRxVJLkkPa093244w3NhGKuifUNNMz8RCOclOkj94sG+6qJTWsJ1T+6PndNbeUOc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(60795455431006)(17755550239193); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(3002001)(10201501046)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123564025)(20161123562025)(6072148);SRVR:BY1PR0701MB1705;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1705; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1705;4:4jCiNBXH0AZwNyZAm9YgWT23YI8oE2dorwqf1O/3OAKymiMEu5jDH4oYodqoWjMARdOZhlzMO3OYWRmR0wgxLbDWST56OVGZxV3kUrqy0vEZ+/5OS5oMN4LrndTLwMWHHNBEBh9IBwQIx3pvbsu/h8Vw9d18Dpc70cCL1dCh+AVdakDM4cAyT7V9vL6ojWcyn+yybC+dYGvUXn0HPnSe/5Tlc5MWoxL6hr+NJFUbalRUc3nWYWkfVUxG+7wh0iUqCqyp4KPHpkQJxFccLsHJdDQMLcPHa0QSeLRGU/TKo+Qz6drQxpk3TM26UAKGM6CWzXCYVkpkWHR1dy9Z8FEv4kJacBzR+xw4ud8FLV0UglIX4p43KG9RfkmuYI9wGrweu8M/AX2mAO1/ZzGm2rnzOvuOWp7DQK3vTQC4+UiGEae+AM+xvn70m4s7380jdzTszQojTgekmSPQp6aeoAfiA9hhpgvRJWipPYwCB7YrLZYpf6q8Q6tiAl2ZVgolNlSFD2RilfthJ1fMvsa0Q5JvHUXddm8yrBKUOZq6hWEExtAOyZeGTY/rBR0ZRELzjFkt9W2bA5UbviMMbLKw2WWTOCILMYAbvC8WoNFP6entXoyzuYi75hHigVqQGW3p0eyKbcie+s+747/OjhRg6N+SuX+hAmazke+E/A+IEDdvyMIWhAWUPuLIZE/OSjeoEem2ehryV8IFKDITsPZtfMwfvmXZplJjvzp9GjG1+KAX9nC7vLAInPEIno15qqqRgPnmq/oSvJW6C8OD9AC3eOLLyQ== X-Forefront-PRVS: 0267E514F9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6049001)(6009001)(39410400002)(39850400002)(39450400003)(39400400002)(39840400002)(377454003)(24454002)(8676002)(81166006)(7416002)(5009440100003)(3846002)(6116002)(5660300001)(230700001)(53546009)(229853002)(6666003)(2950100002)(25786009)(42882006)(36756003)(50986999)(305945005)(54356999)(7736002)(6486002)(77096006)(4326008)(53936002)(42186005)(50466002)(189998001)(33656002)(90366009)(64126003)(65806001)(23746002)(66066001)(83506001)(6246003)(65956001)(47776003)(2906002)(38730400002)(4001350100001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1705;H:[10.167.103.57];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;BY1PR0701MB1705;23:D6MQA8pqGYAZEfj0qbU4C/mHKZJpHpNI3nR?= =?Windows-1252?Q?dpGKheQM2pgguEuMYlyGs7khVAMuD1E7KtMP1cn7g/r4QHnOpXGu/ldW?= =?Windows-1252?Q?kxtiZIaUDBvXYk9TUGDNwkYYYzzc6RaslgLRuxq/dc9Jn+nUzLFNYD7c?= =?Windows-1252?Q?Gn+tpvAt0FKKvfA+tbx9PK3L3vb5PHioZQR620rHfEvW8PFS+FMZxe5t?= =?Windows-1252?Q?Dp9zEbVwLQu/bSJt+qFE2y8ZKAyRqiRHyzFzU50FuO07jDtpEYVLWhN/?= =?Windows-1252?Q?/DZTLrWiiI2/SnU8KzkzZ+uB0tMycmwVOzV4ni4gUc5Gr/rsU+25imny?= =?Windows-1252?Q?wZUV6DMd4sTK5PxzwI58PWm8cQyNK4RaRf74W3jHllJ5aID4Wwxj72h4?= =?Windows-1252?Q?VLiA+QiNwvwNgUkzoYeWBqDCMXAJ6vYYFyZ0jBxZw9A08Rg5etKM1LiY?= =?Windows-1252?Q?q9IatTo5ctmFLJje3XlONjeR5vAI7ho5RrbRO7mhJnA52HBvWL6vYKSM?= =?Windows-1252?Q?0w9PwvLV67La4w8jbisfeLRadRaPRSeS8oNRLpvtrNMnClnvUEU46Ybt?= =?Windows-1252?Q?xbbrUdJ80vwcwTI+niUpyM+Hem/FA4DShn/pi44B6tv9m5RexZCvmn/8?= =?Windows-1252?Q?Yf3E8WiJSWxOTKA1j7Py6Tkz9o9zRhNNny+BnVktvY9167dN4E3wp/b5?= =?Windows-1252?Q?+Utudcoegbas0+Ha7mv2kfPkdpLnhVdl3atKz+LCHJSuhq9Ws6ezL2Jp?= =?Windows-1252?Q?FpYJCPZNajVHxgcDNiqnZEi2p4YdzaAqNa2zqnZAf300qxRPc2FQm29r?= =?Windows-1252?Q?eFkfjw5mjIAgJL64Yr9YS1ZCWnmEfO1qfiAeaeWGGjsDSZiUYk7+1Xov?= =?Windows-1252?Q?j1xO9VO2GCSQ8sgJsyjsCm8i+7SFlwgjE0OQrieKn9mG3q06oA0sxx6r?= =?Windows-1252?Q?QX33z6Xw88cVNbOMlf5p0bcnPK7KWWOj83xkNgN1UkGu9cUoa6NcP97V?= =?Windows-1252?Q?Y22nYLTyd7cjmDMeU3NqEoRcl8FdxcYbIn4fmjOvKihQ4lsJEMNeCDEh?= =?Windows-1252?Q?mHqxcMSEpHzZA9tOE6OB+UQHq/+8B+n8PD3cpfkcySwF83N1ajD56sEb?= =?Windows-1252?Q?GFKHPH26/QH+P3mi4aFinoR3zo8jDca+XWqs4MKDLOQSqpWS3d5g6zkR?= =?Windows-1252?Q?02QJxFtWUMbUspal9hWiQX6uq895HDfyBz2oZgvVgeqK+K0ODAQe4Hb/?= =?Windows-1252?Q?juoKZPU/vicxkf9mrIU3qVrZfWhYvjciv8B6uwi4kyBV9QIWpDaui6rK?= =?Windows-1252?Q?/QS+7FmDYs3VKf4HqAfC1Hmr52Q=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1705;6:WqcfnIxHroPG+57ub78Ruk4A8rR04wXRRcCaL9wHVwGIL+yBIQ1drYjC2V1riqiUZOeMuv9duEX/Wzma6Jz6OxEtSx/f6suDzm4PZNna9cJm7bMIlgaagPNNVv7We7ofVzLPdV/dpJxsVBEyOUT8UGEo4+9a2A3Q3CF8IiJuacMUEMA8+csK9odwoycMkpZMFoMOu6aSgsPEsn8ji+psQZsJpVhsx0sDDH8b85Lxt7bz0HpxB2El6qst/QjX8qwhue9ETIf18Ioc9To3K98kMRm+I588TuSp/M9N5q1Pb/+WeIEEuQcgeH0ND6tvHm7TfF6SOCLNff857XiYQUDI7buufMM6G/eHoo9DCD9i8ccO+QDVj3qhTMhZ867uTGqRLxpvmSqA13ezF9sl0zTgtw==;5:79FjIAGqOyDgb7UD+LmrFrG1v4tNc56wuCdfZ07x+Z3bsSIwTPVOIPnhCvvohuTO7RiO/w02DoVkZZtuMnFy+OuROKTqL3BwkGZTBteeXPc3z7PBS5nDenFWAmApEfR/5SlCo+rnWMI6kkj2Etg1Fg==;24:rosbYMsnUymhqPDThV1mwdKxJ7ZsmAOdNNSelZfMpKH0y5AnNtbttwj+6+YpGDT/3EW3TQQ2grLUfPwA5JVd0Jignr5y0W8vrY0ZJSI/mPQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1705;7:qV4AWfQ0PQyKvoEHTNXogdTWBmgEEIr2sogKnbKkgLsyqYnTQRmbpWkWaU/sjpXYapkDiIVPVKx5QpnaG9yLC1J0mibAMnE5ZHpgHF5eTX863nrntMliXs3Yyh8jDTynQbWV9HvGsKdUQUkvUD5SYYmM9/Ne0HScWPZQf0tOy9y6Lh/4zthO2+tTkWk+9OybKC1iBENX3V5DXYW7Yzb7R2xiQ15P2zB2EkO1Wa7A4DOmt7GsF+wMw4HyzPZHTzKDjHUREDVqbrvuldttskvz2ROmvfuQicXbJ2lTXwYJ2BOvEq3YTj+eAnNPA6uNvW1TIhzGukeiyTxjhR8Zim/A/w== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2017 10:51:36.3594 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1705 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5459 Lines: 142 Hi Alexey, On 04/03/2017 11:07 PM, Alexey Klimov wrote: > (adding Prashanth to c/c) > > Hi George, > > On Fri, Mar 31, 2017 at 06:24:02AM +0000, George Cherian wrote: >> 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. > > Could you please provide clarification on why sum of total_mpar_count is > required? Do you assume that there always will be only one single firmware CPU > that handles PCC commands on another side? Yes you are right the total_mpar_count should be removed and should be handled per subspace id. Moreover the current logic of not sending the command to PCC and returning with -EIO is also flawed. It should actually have a retry mechanism instead of returning -EIO even without submitting the request to the channel. > > Theoretically different PCC channels can be connected to different platform CPUs > on other end (imagine NUMA systems in case of CPPC) so it's not clear why transport > layer of PCC should use that global count. Also, ACPI spec 6.1 (page 701) in > in description of MPAR states "The maximum number of periodic requests that the subspace > channel can support". > > > >> 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) > > > I don't like the direction of where it's going. > > To send commands through PCC channel you don't need to know CPU number. > Ideally, send_pcc_cmd() shouldn't care a lot about software entity that uses > it (CPPC, RASF, MPST, etc) and passing some CPU number to this function you > bind it to CPPC interfaces while it shouldn't depend on it. > Maybe you can pass subspace it here instead. Actually if you look inside send_pcc_cmd it does a mapping of cpu to subspace id. To avoid confusion it is better to pass the subspace id to this function than the cpu number. > > BTW, is it possible to make separate mailbox PCC client and move it out from > CPPC code? Why do you think it is necessary? Currently CPPC driver itself is the client for mailbox/pcc driver. > > > [...] > > > Best regards, > Alexey Klimov. > >