Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752702AbdHPMGQ (ORCPT ); Wed, 16 Aug 2017 08:06:16 -0400 Received: from mail-co1nam03on0045.outbound.protection.outlook.com ([104.47.40.45]:37792 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752337AbdHPMGM (ORCPT ); Wed, 16 Aug 2017 08:06:12 -0400 Subject: Re: [PATCH 3/3] soc: xilinx: zynqmp: Add firmware interface To: Michal Simek , Arnd Bergmann 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> <247a5660-6c53-ccc3-7b9f-bfd2a11f6f54@xilinx.com> From: Michal Simek Message-ID: <1074f025-404e-f6a1-cc69-4f9ea7b366a7@xilinx.com> Date: Wed, 16 Aug 2017 14:05:58 +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: <247a5660-6c53-ccc3-7b9f-bfd2a11f6f54@xilinx.com> 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.83;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(39860400002)(2980300002)(438002)(199003)(189002)(377454003)(24454002)(65826007)(50986999)(305945005)(77096006)(63266004)(54906002)(36386004)(2950100002)(189998001)(626005)(8676002)(33646002)(4001350100001)(230700001)(8936002)(54356999)(83506001)(478600001)(81166006)(81156014)(8656003)(36756003)(356003)(229853002)(31686004)(65806001)(65956001)(7416002)(23676002)(47776003)(93886004)(86362001)(31696002)(50466002)(53546010)(6666003)(76176999)(2906002)(9786002)(106466001)(64126003)(6246003)(4326008)(5660300001)(107986001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR02MB2467;H:xsj-pvapsmtpgw01;FPR:;SPF:Pass;PTR:unknown-60-83.xilinx.com;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;CY1NAM02FT021;1:RRBWg4rTSJT+ronNt9pcAczyohNmGOXvU8y8aTCA4FLQ44Pn1UjuRUw+QIcDRxCSUqN8S/Rvx/5iwTqXeukWlCQ9OH8KPssJmX+GU+JZEXX0/U6gCV9ycwsVC0CtnV3AgrW3PnGuUI/DUBwf6ZAeExHOaL0qjaRnwBALm8/AVoI+fi8s1oE8xx72TQF2YX4feLrgjCIj5NLXrkPOKmubpvSXYgtLh1nmj/Loo9EqRGwVZRLHaiPl93izqQCo0OcMob4TpinPWfUjGKqNi8ZB0ixL0IKdyGh4wJ5C/6yzFi3EQuoX4qZR+Uffxie2GsClQDEQJxHjE84zT4A9CKeXZyh9bPlZvIu2FKWpDY/1ua3zcmm4OYkDoq/WW3IXxEls5qqfvWkdDoScLguJbD9tCEdC0ofDFN8tfzq2PgsZNjNDGJm3Jj1uAizVSJ78dvFzDKJ3Iu1PEJqqNVyM+LSECjv3fbG2mLppG4iz2kFBSQkn6nCDZokROuw3pjsWa/wuTMHFOHqOX/LTM0xGswiI99iQWURQhuz0lVGsfXPv57OwD666oebRn3FJdRP6/6rOBN0eVlCF6/g60gqmXNBtUf3mFXsCu59AiFHUwPEUUGDWLPabjTgb2muJulRqllAXkQLyIcgsAMpg9wKpabLLTgmiIEw6xNeNqsZrwc/PCf2GPKT3mk+cHSVGe2yxwjAHGGXIS0ZhUGK2sRKU1p/8wSSV/v3w2W81p5YtfuQYAWMgxRWSYQhLt/6rPbw1U3BaTjT4hPo17bU79eRK1lAeZrPvGCTSzUGciqc/czi5h1v5vHO5UmIDlGHtlqe+E15f9W3j7uB9Rf1897yGMSRxOg== X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9c1c793e-ac16-4099-bc57-08d4e49f2d4e X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(8251501002)(300000503095)(300135400095)(2017052603157)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BN6PR02MB2467; X-Microsoft-Exchange-Diagnostics: 1;BN6PR02MB2467;3:ZtVqeaWI6HGTg0kysmkjE/mwxQ+9YoxDa559mMVIP8DCKSqZXHpQLVBX16ojY0/3dShHozoZNpXlq3yn9TQgoPZ+0dKkRO7woF892z9Lu8RvLT9MBBsG3HLVfBlhaqEg3cuZaO26CTpp3RSlepTb6Vh/YUAN6zeKpO0LZNkBbtbyzvIed8DlCS1Aob2dcYiVqMs5Qa+/F2jJ7Ou6cgBsKmMCIyWbVqN7m9Cv4Fh/lgx+ZRntwnZdH+X0sXj1tol12i24kZ8z0XRK6bZ4DrxbLl2pvkRfSASeNDFxhl0p2/VVHuUiYJkBZ8qqxk1IbXJxTQsvPbY2/ZhSDrsT56q6a+4HIRfAfM7AT67EW0yQjqE=;25:FEfDOWp1rrsz2zhZP9HwzMcAQCCrEhd9ow7zUCTyMwZVbJFq57B6b7Qz1lQTzHUg5daOeurt9h/8DSdpkoSplQevfn7k+JPW2ymj65gb/1MATCmmJdiTX1bomTEixYQIi9eu6HqhvNingxxNXmcSk2KtHjhs8Sm47/M/kcRaFKGrf4tUfPDz9ddnqQjN08CWQQzQVQJvripQ/VmMUKiYTVlTtam1/7WjhuHNY+HGa3wWaJrKAMNJzVhvzMn2r78tASeg0i+p1MQPbhfTqzNAg2P/wVSGnCRq8eNuLqnTT7oKqHBhvtSStmPSp6vuoWNjcTkjGX6KtXtHhCGDw0QEjQ== X-MS-TrafficTypeDiagnostic: BN6PR02MB2467: X-LD-Processed: 657af505-d5df-48d0-8300-c31994686c5c,ExtAddr X-Microsoft-Exchange-Diagnostics: 1;BN6PR02MB2467;31:huhHFIQ+zSQZTxIrdqg2o10gbHy3nJSnrBmAZ0RvEgdP/uS6K0QjVjaaRMJ5HuXe+yHchOsiJhGdfeek+B2d+sn3lCHUPoZ2vaPAolcdai7IFFpfPOxRhKNciCwMIQq3UdUXE9/NYpj8cXZ1/iPwTHIc1J9R96aTIULT1QWGDa8fggXn/yGPLBN+bah9o6mTPBS25gW7hMzX85i1lv4p8GLZaQo7sgV4F39eCVI+dFo=;20:fQUOxMEXU8P8uMLhK6nCInTZ4tZsXZWhgAKKfr1F5UD3AnQHJpPmudE/Q3MHzIe5j/GAD4B9qPymnAiwKkiHg2/ZOsg7hDh8nhQvoCQw7vbYVBUyhU09ZTtpEzgokMILWiUHkwsi6Ygemr8C+zH+kRnMRafdKYTeSa5sJDQCVYVkdYRlRItwFIE106tVSa8jCMOQNpmBppdJS/N8stiVWj8uqzYtsz2qf9CI4h7rylKbq1Z1XRjKPuPfo7xnCoVb1XhQawyRRxgajbcRwcYlDOQ3h/4xz55hexxGXIidlAlP9DVJVlYVLx2YLuAlnMysC+Ct46s6Az9RJ1ihf3Qrnch7yuhE+07rJPaTLeLvUtn6MVxlBK/t2rM1ZAY+oQUNlhqQI0DeaGsj5ZCJHK4UyX9z2r1KLx+NqztwmuxG5VTXGGf9/oskZfCrTas7McW24Kms8FSHcywprxNHrKuTnZsRsDSGsmgNLKHSuxVGRbuYmT8Jkc18Yeff9ryPlxon 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)(8121501046)(13016025)(5005006)(13018025)(93006095)(93004095)(10201501046)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(20161123562025)(20161123564025)(20161123560025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BN6PR02MB2467;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BN6PR02MB2467; X-Microsoft-Exchange-Diagnostics: 1;BN6PR02MB2467;4:itlQip6Hnc63Afl3wuWc9o7U9TbSI83pil+9CqAvt4UEB3kJuvIioZgDDiXmGGHKST2oj8nSykmKcIdkfVoDd2v567hPKTmR6MAdq8g373W4PaEKrK8clxZuibeYdOfLW7Atnig/wq3wK0pwo52MD7loiCmzfn4Fbzah961m+G0AnTUi+X1HNk8uf1h8HFTGIfpqbQXINWwSyxeqvXy/hSUt98xEMezTWfjNOB98cD9m4tH0QXkRgAArDnNPfhS1PmbLHur+5QBd9YmDc94mXpTObtfnPeMMJVaELMTH2Hc= X-Forefront-PRVS: 0401647B7F X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjZQUjAyTUIyNDY3OzIzOjhnNXVDWXk5eXJaSWNBVVlLQWloQnFwSWta?= =?utf-8?B?NVdIS01CVFRGanQxNzZRc0J6bTBuUC9UUTNCblZ4WlZWSTFKSnlXR0JkRGM0?= =?utf-8?B?Ty82TzNHUk9lejZPeXI4ZnN0azB6R0N3ekwvV0JnMEdpVjhmREVySENhSFQ2?= =?utf-8?B?SWxsdmcyMDZnUVM5ME1NR205OWRZL2NmRFhVbXpyM3Vxa0NLOXUxQzBaMVRP?= =?utf-8?B?eHp6S0xwZGhJV3gzdmk2Qy9KSkJaVmxEWlpEbFNvd21NTmVscXBicjB3WkhF?= =?utf-8?B?czAreXgyUE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FFByWc8Epnw5kAj297gCv94S2TlbqaRHPDlUusuowBMjDvnAnEhIrLy67NxttJfccIp7wD+XOQ==;24:vQf+uOFr3FJv4alBCejNaI/m8025w/KOL6pVXeQRe8B0VlVnAEEkLwnKhJXsw/abfmMP7agBvKmIYiuaglSTh6xcoqMtBMDUjABJOkhjKcw=;7:amglRFYWjdPOzsQAhiRyiNU0B5LIMi0A7yqPutQS4Urkw7WGNzD5W2PaLve8GIgo+sQQiCRRh6lxkmcEoOBxgmLx2wrra/OnmYqrWfM6kJPXO9WZLtuMep4vEZ+AFvI5rdcrwOmHNX7vO+q4JUQKbDQttr/69S5W1FhSJH5NylpvDk/BBy2pzABycLJEKFXltzVGkCs5DCJ4RHZqEVnnKDEpKNXRfRqqd2ndbluYz+A= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2017 12:06:06.9337 (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.83];Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR02MB2467 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4450 Lines: 127 On 16.8.2017 13:51, Michal Simek wrote: > 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. Sorry got your comment now - will mark that internal functions as static to get them out of this header. Thanks, Michal