Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751731AbdHPLvj (ORCPT ); Wed, 16 Aug 2017 07:51:39 -0400 Received: from mail-co1nam03on0044.outbound.protection.outlook.com ([104.47.40.44]:32542 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751461AbdHPLvg (ORCPT ); Wed, 16 Aug 2017 07:51:36 -0400 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; arndb.de; dkim=none (message not signed) header.d=none;arndb.de; dmarc=bestguesspass action=none header.from=xilinx.com; From: Michal Simek Subject: Re: [PATCH 3/3] soc: xilinx: zynqmp: Add firmware interface To: Arnd Bergmann , Michal Simek CC: Linux ARM , =?UTF-8?Q?S=c3=b6ren_Brinkmann?= , Lucas Stach , Michal Simek , yangbo lu , =?UTF-8?Q?Andreas_F=c3=a4rber?= , Linux Kernel Mailing List , Alexandre Belloni , Baoyou Xie , Shawn Guo , Geert Uytterhoeven , Nicolas Ferre , Simon Horman References: <98038734d73c604dee6ac0d34740d5bc2034e87d.1501854302.git.michal.simek@xilinx.com> Message-ID: <247a5660-6c53-ccc3-7b9f-bfd2a11f6f54@xilinx.com> Date: Wed, 16 Aug 2017 13:51:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.1.0.1062-23260.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.100;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(39860400002)(2980300002)(438002)(199003)(377454003)(189002)(24454002)(63266004)(2950100002)(478600001)(106466001)(23676002)(33646002)(54906002)(53546010)(64126003)(31696002)(50466002)(229853002)(6246003)(6666003)(77096006)(86362001)(230700001)(8656003)(83506001)(4326008)(9786002)(2906002)(81166006)(81156014)(36756003)(7416002)(8676002)(626005)(31686004)(4001350100001)(356003)(305945005)(5660300001)(47776003)(65956001)(65806001)(65826007)(189998001)(36386004)(8936002)(50986999)(76176999)(54356999)(107986001)(5001870100001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR02MB2471;H:xsj-pvapsmtpgw02;FPR:;SPF:Pass;PTR:xapps1.xilinx.com,unknown-60-100.xilinx.com;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;SN1NAM02FT024;1:3bwybW3Nun7LAoivI4QNH6QbigMCPEColgqwzFzFSNZh6sLbJdCWh7BzbAPXWC6xcFYATvqRG8fBhzG4cOW9cA7kYoJEyAKST/EEGtbaVWOJJnWjUt7PoVI5DJjWbbjZ X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ce1ef273-2311-4272-0e71-08d4e49d2414 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(8251501002)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:CY4PR02MB2471; X-Microsoft-Exchange-Diagnostics: 1;CY4PR02MB2471;3:zf1nt4cZ8X88vZ6z+wYNzf+ReaSiH245plGZ3EbPGybanmB7ebl0Ab6HrXdFt2eMNmAZ7nepZTpmbLa9QTr5/BTh8YOekDfB9lVSySnhAW4b6U1ffarznHn0YCt5UBtjxtsEJJ12jQh9ikd/RejlOYbMSYVzzNiqrpquwEL798WR0Hhcl6UTKPCBJQT2s/ycRkKdQlAvXQHvn4GpcX1EvTyNXEcz5XFBfNxDS32aexRdndKwF0f3ZSu4b0k4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QmIwKUDK6JluaCllzzAteuuDxlXEQKqPGUKKOiP8xYLjioxvtEaGMfYDlwVBZrUkAydOQAlo8BA/ZFNYZbnbe4SfrGIj0tS0PENzA8rTqlQNQQKNB7U3PEsE7k2dR+rYazKoPCxwySRuQGkrn16zoiReLaMOBIppAnGnNgVn0WuGxVHa6QGTJOxKhZ+RwWnKTejpEXsXQQ7jy6l+yWR6mVMsby0O+OVb6xNh2dYu52mnDeJhvegEkA7RI X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(13018025)(13016025)(5005006)(8121501046)(100000703101)(100105400095)(93006095)(93004095)(10201501046)(3002001)(6055026)(6041248)(20161123560025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123564025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY4PR02MB2471;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY4PR02MB2471; X-Microsoft-Exchange-Diagnostics: 1;CY4PR02MB2471;4:rsQg4HXtmrvhaJBb+yiREpW8Iy2oRsdwqyofcnviHKZw+iNKNZbmTDzbxFKBWTVht5Ys/c3v+e6UpqKxb+1+gK8biGw4qoPz+eIBLJjF1t89pBYysdi2kVF0ARDrxyRTcpbvHGfFiXmL2FbhFOrPxV0YzCn04Wdz2Bb8boYjqzWy/z0UwjKUebA9Nq3Fjh74dNQOPqd6umy+2GIephRb3RHTMPgVK/5sL3+I1s8ueswWMYGo6xFJCRAhs7zEODVo0dSf9pUUXumTkrnnQiIWu1W9giLM1tDaHkRFX7Ikxk4= X-Forefront-PRVS: 0401647B7F X-Microsoft-Exchange-Diagnostics: =?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2LcSXyZFltcIN/d9+PYyi/8PqqkcP4d735f5DueIUUFJ1cgI45Edzvx+Oc/FUNKCY33b0S2yf6NJxUv7CGD09EWFlSM+xA4NpRCQpgID7NbOgR2DDMk747zar57EUqcQCtoOY3RPAxK1/TQTKyjCbIjGv3Fvnc732ky2kPl6pJ/YBmNzXQO2KlfFNJKnrAlUGi16fUJU/ZoNmV+40QqP39SZTtwgIFpd2ptBR6mGSEUqAIauGWMhBEqHI0gKoFVNbsn8MtSx52INiEZMQ9/Rs1VMSKdme6EwZhX22K2vfULuvDPkIcPern4jpoCYzw3/mw==;5:VnleAO3oV59bMlMS7RW+FYWcgS4wYIWe/fjbKluZFkrPhEMgYZCElnF1wh612xgOgpK9aNE5lpG7u0S1g/UoQ2DtjqOWnajk37c9pt91BIbPNfPkxxewWAdKES18Qu+IrVGmiXsVseYrhfp2qwHyyw==;24:ea7smoF9+TzWYbX3WrKvC9+A1BeMGowuoThSAXcrWx0iqmvF89cOwX0t0es6aTPNXAy5W+nR+A+t/INRPLc2CrUh8NIz5W3u7sndbxXEsWA=;7:WEdMen+oaN28GjXY97leHbMzfJJkSn7BFk0+5QK9IP7ArTy4ABNY9iq2qVh4mpn2GZge/VDCu29C7OgmHKw+l9IcVmgc3jXspK6fOi2A7ldlmcYFpwPHTGJ5qW+Qe7EbLX87CKVf943WOe4lj0YLITMMN+IydVfz4BevybO6ofZ/7R6iJkFe0GjJ4Uasm6foKJ4vOkni8B7zsRf5fmlqXOdEgc3hGEQZxNHmugsHaC8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2017 11:51:32.6906 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.100];Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR02MB2471 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4461 Lines: 131 On 14.8.2017 17:06, Arnd Bergmann wrote: > On Fri, Aug 4, 2017 at 3:45 PM, Michal Simek wrote: >> +static noinline int do_fw_call_smc(u64 arg0, u64 arg1, u64 arg2, >> + u32 *ret_payload) >> +{ >> + struct arm_smccc_res res; >> + >> + arm_smccc_smc(arg0, arg1, arg2, 0, 0, 0, 0, 0, &res); >> + >> + if (ret_payload) { >> + ret_payload[0] = (u32)res.a0; >> + ret_payload[1] = (u32)(res.a0 >> 32); >> + ret_payload[2] = (u32)res.a1; >> + ret_payload[3] = (u32)(res.a1 >> 32); >> + ret_payload[4] = (u32)res.a2; >> + } >> + >> + return zynqmp_pm_ret_code((enum pm_ret_status)res.a0); >> +} > > It looks like you forgot to add the cpu_to_le32/le32_to_cpu conversions > here to make this work on big-endian kernels. We have discussed support for big endian kernels in past and discussion end up with that there is no customer for this. It means I can change this but none will use this. > >> + >> +static u32 pm_api_version; >> + >> +/** >> + * zynqmp_pm_get_api_version - Get version number of PMU PM firmware >> + * @version: Returned version value >> + * >> + * Return: Returns status, either success or error+reason >> + */ >> +int zynqmp_pm_get_api_version(u32 *version) >> +{ >> + u32 ret_payload[PAYLOAD_ARG_CNT]; >> + >> + if (!version) >> + return zynqmp_pm_ret_code(XST_PM_CONFLICT); >> + >> + /* Check is PM API version already verified */ >> + if (pm_api_version > 0) { >> + *version = pm_api_version; >> + return XST_PM_SUCCESS; >> + } >> + invoke_pm_fn(GET_API_VERSION, 0, 0, 0, 0, ret_payload); >> + *version = ret_payload[1]; >> + >> + return zynqmp_pm_ret_code((enum pm_ret_status)ret_payload[0]); >> +} >> +EXPORT_SYMBOL_GPL(zynqmp_pm_get_api_version); > > How is this supposed to be used? API version number interfaces > are generally problematic, as you don't have that interface any > more if you change the version. This function is called from power management driver to find out a version of PMUFW. It is not a problem to save version in the driver and provide another function to access it instead of asking firmware again. Or also remove this completely because it is more for power management then for communication. And this patch is just about communication. > > Normally this should be based on the "compatible" string > in DT to find our what you are talking to, in combination with > a list of features that you can query to find out if something > is available that you can't just try out by calling. How can you find out what you are talking to without asking for version? It should be probably be based on some sort of list of services and based on that enabled features. Anyway I don't need this function to be in this interface driver that's why I will remove this part in v2. >> diff --git a/include/linux/soc/xilinx/zynqmp/firmware.h b/include/linux/soc/xilinx/zynqmp/firmware.h >> new file mode 100644 >> index 000000000000..5beb5988e3de >> --- /dev/null >> +++ b/include/linux/soc/xilinx/zynqmp/firmware.h >> @@ -0,0 +1,246 @@ >> + >> +#ifndef __SOC_ZYNQMP_FIRMWARE_H__ >> +#define __SOC_ZYNQMP_FIRMWARE_H__ >> + >> +#define ZYNQMP_PM_VERSION_MAJOR 0 >> +#define ZYNQMP_PM_VERSION_MINOR 3 > > Again, having the version number hardcoded in a global constant > seems pointless. If you expect to have to support different incompatible > versions in the future, name the header file firmware-0-3.h and > prefix the constants with the current version. Will remove. > >> +/* >> + * Internal functions >> + */ >> +int invoke_pm_fn(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3, >> + u32 *ret_payload); >> +int zynqmp_pm_ret_code(u32 ret_status); >> + >> +/* Miscellaneous API functions */ >> +int zynqmp_pm_get_api_version(u32 *version); This will go out too. >> +int zynqmp_pm_get_chipid(u32 *idcode, u32 *version); > > The "internal" functions probably shouldn't be declared in a global > header file. Ok. This function will be called by nvmem driver which provides an option to expose chip id to kernel and user space. I can call this function just once internally and then expose another function which will simply just provide access to that static variable. Please let me know what you prefer. Thanks, Michal