Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752353AbdHPOAv (ORCPT ); Wed, 16 Aug 2017 10:00:51 -0400 Received: from mail-co1nam03on0077.outbound.protection.outlook.com ([104.47.40.77]:1817 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751764AbdHPOAp (ORCPT ); Wed, 16 Aug 2017 10:00:45 -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; 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> <247a5660-6c53-ccc3-7b9f-bfd2a11f6f54@xilinx.com> From: Michal Simek Message-ID: Date: Wed, 16 Aug 2017 16:00:27 +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)(189002)(377454003)(199003)(24454002)(4326008)(53546010)(77096006)(305945005)(229853002)(2906002)(36756003)(9786002)(83506001)(8936002)(36386004)(189998001)(31686004)(47776003)(65826007)(5660300001)(65956001)(65806001)(626005)(50466002)(86362001)(81166006)(6666003)(81156014)(8656003)(4001350100001)(7416002)(54906002)(8676002)(31696002)(6246003)(2950100002)(76176999)(54356999)(230700001)(23676002)(93886004)(63266004)(50986999)(64126003)(33646002)(106466001)(478600001)(356003)(107986001)(5001870100001);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR02MB2479;H:xsj-pvapsmtpgw02;FPR:;SPF:Pass;PTR:xapps1.xilinx.com,unknown-60-100.xilinx.com;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2NAM02FT030;1:p66ERSCxgpt/TbiccfPPMo9KT5yglDveCzCxTGAhKWpoyRpXYjf7cwY3+pAv80a7yYOb/FzR/9CtNiqaCC4ZvqwqdGCtg3ZI7RfVpY7rZGidsYSEbSNqdouvSEz2QGhlRd19VLrks4ktbDx6VRAYjh0MhJYXLBm6VEBD3YkyAKVAdUlrcmNWZGZLn1ZfvTRLDyBlrD03wmUAD6SCxoYEwoBkAYk6OtXr87Szgb6azAHR6doubJD5O0HZrouGkIzBicGv8JOG483blnsaohfq2+p8NNCH7KKRkgqRJ51yXH4dKw9RInZUqaFs1cYG/byL7Ov6ZHk0TSof3+rxtpcD/om78TywjrAYr8KlyJ4YxuDq6wLY6o0b2V8NgpBF9jvsoFfTLjsoZyIygtUBIYRr5vUuEsEaKl2G00sV1pNggXG5scKNiLMhIdBsMnG0KZNbZ5tFct8Q5G0MB5Kv0M89u/b0/BydWyyTDCJLRPSmN/DFQkRo+AzJMHtr5ht67UBYZEtF6QrJ4EeJuu56qyi+R/10vB+D1is6kmXLt/PVMk+PDQMOpp5EOtMOxOgiQHpdChlY57IxnTV/awmfgdBsBfgsjsj26/D9b78juMewybBmlvkvak3KPDOxdFx+Kzky0iRE083kBngg+20SeUW3gbpUFEkv+p57ljQZLUq/xtIOXbUDl3FAnjQjq5GkIEktH5w4ch3j25jyOP0cnlkg8mg0NS7nhG/PTR493vn56rmIfP2zPoPZaFGyNRsI2TY1WaDvsyvKcVy/0ZPXbZjflPBpW1gXlGsZygNWOYUZCGl0y/muVrr/4KgjznhbvfEq4gjxVs+dayJkzGa1Ot3x9g== X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 38b094a5-cae9-4719-52d7-08d4e4af2f84 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(8251501002)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:MWHPR02MB2479; X-Microsoft-Exchange-Diagnostics: 1;MWHPR02MB2479;3:IWvE7lstL4qyCqv4MUG7DFke/DWLvlgnsHPF2F85OyhT/TEiRA0BDRFOevsk5cfkOiykW/2NYY7vfe3OqQoKWC0szAOW2z8rZpdojAZwszovh7syOc9OV3dKviA4G1gbXczVjDQWHPYNJ2VxYR86hsjqtpjkT84tJqJlY3vp5HyNZUPzzyFn3UdLU+AMRKwESL4D/W8qf2SjcdhjkyR7L0A+BT6WBDld4B/EUF2YIciY81hqwjFZMFbwrlc01ebVST7aYMaLiRSeXxuX0ktL0TDzGKb0OWHjMkWGxjp/U4VpOGjW41tnvznjVaeafUOlGwBgeLnWnCUx8NFU1r8kmYZCc4Lehhw09AawGi5zNoM=;25:LfVk+yM2lf4kWIZbUYZfaBxPt2Mfo3iCnJtbmk5i7hC4Mg9M8WpThzOlgEkOHrarpQrCpdgFEwEewqxElxwAETqjI8UwrNrE6gT5lbW0Wh2zhFVn8mqzx14d8sVPDfa2Pq5x9fYu8jSY3At3SUX0RmQGFQB+dxirhx1YWUdF+QmFR/kyE/DEOST1Xz2Fsv61NI1PPs3RBkC6zP0FnLQPPNEUD5rxNarOFgGGeKN5FNK9lhtdnKYEs9q6oPeLZyJ+Qb5SFazFMM2UXYW1wU+/Qgak0Fk5hEaBrcxJW+XsHNZ/etwN/XuZMleplcq92meIMnnNufhX25oWVgHAxAW8Pw== X-MS-TrafficTypeDiagnostic: MWHPR02MB2479: X-LD-Processed: 657af505-d5df-48d0-8300-c31994686c5c,ExtAddr X-Microsoft-Exchange-Diagnostics: 1;MWHPR02MB2479;31:+SJv4EM7g7rRl2+CsG/V5k6chkXYt2sIeXNolgnQlcj4WZyCEYBx+JP9sBbP/XRXTnogJ2uImXEY0fcAdRIy4+KM+LodGSIXlUEK5Ov5es1STWvkIye6Bh9K42r3JmFyioB40oJeZ7xHpL9/gm3Ah8LzclMg2uCLZJazCnZZb8ULhK2K66oqtKzryU+x3Ocu5ctYVArmOdNPgC0+a3DBY++xKxmAnNhvFDYpixX1CxM=;20:cGRPDkXa1m57czdhX4Tbho348bADUJ9uJMe7FWig6t4o0CtiEMJGqiU49VIfyRhCosM4FSXI/b4hg7x1ASuBKeYzNCVOTD/FnUdsrsnIIK6fR6u246rVqBdM6a0oRveoLAOfsWfGEYfHL4itd/DAAC0iM4l8r+kiQw4dmI8n6Ny45jtarm/V92qG7omLt0erugGjacIk2VHctGBcG5OxNPWGA+owcpYHTSGpCjKlPYw63hG6bDexd+/yitQ2MSWDamueSD67L4HDj3hrtL3vISNGM39yJZHKhVBgpQCaqDEt1yb2y/SJ4e6h4quDioy5MQio/s85G3Z58LxGNiX4P+jg7vJ0e74tWtrkFBTKCHH2GQLUQxOPyHNeami6kInMw+JjM40u/kDmEJR9KGhMoGUKPuSrEo2WrYylufGoEiEBfZWkgV34Gz5L9JAZxsxE9y8FuuoqPYTAQok3wpiV1BaO4TfTWRFVU7HWi+wpNFftRYCizPxAMsaQxPoQXTkj 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)(5005006)(13018025)(8121501046)(13016025)(93006095)(93004095)(100000703101)(100105400095)(10201501046)(3002001)(6055026)(6041248)(20161123560025)(20161123555025)(20161123562025)(20161123564025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:MWHPR02MB2479;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:MWHPR02MB2479; X-Microsoft-Exchange-Diagnostics: 1;MWHPR02MB2479;4:/XmL2BTMaFMxtSf26gqJngaMIpUVVvf2C+mrmbEuNlcu7qjz+32MxaSZ+0cn5xzpVSuWMZQLzk7maVx/Z2F5ldETRrDVzZk4OhW0CVy89ofppbI0YNQKAWzpGeSOi2mnVwdPZNA5HtVW3cr+Q4e5h1G+F9QNwuWXg5049nUiYk9L6VW5okEp21Gc3gpIiuH/6ZMhtMY2wJor1tpj6DwYqreq6bPodKQ4WUeNGhjGzshKp6TuhokWQz1kXmNjtVe+dRTFXiWfRmVtr6L1U9jx01hEJ2uicNFFDa97FniSVDA= X-Forefront-PRVS: 0401647B7F X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjAyTUIyNDc5OzIzOlhkK0J5ODdvN2F4YnM1enZzY2Z4TGt4ZHdU?= =?utf-8?B?R0FndmQ4ZHBVU2hlek92ak5sNEZhakRqMVJ5ZGNESXB6NS9Rc3JrTU1Mbm04?= =?utf-8?B?cW9UaGFnY1FwY1poMmxxR3hwMkJ2dE5SU1ZXUkJWRldGcEI5anQrM2Y2NlZF?= =?utf-8?B?R1pLYWpuckpTaks5czY5Y3VvVnd4ZWhib2wwK1pudlJUZkppOFhFcWhLaGs4?= =?utf-8?B?RS9PYUg0Wkp6MUVxQ0FvQzRKbzFCUXlGSVhua1JQVWxVNFFib2tKWHZZWUNO?= =?ut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v5cbvdm9Qlp8Pz5J86y7g==;5:biRCx3RV0dkBCYE85+YjVqxfGTx5oomOHSZl5OHBCApqDFHCjSRq6YFvO22Ys9Ng2xrGLn8rNv6zDWI/2qCX1+CZAIVrfeQXNZH3ONUDMKHtKEf7t3dS7RTKuAZT37xycn4LKdzpkCHmZdQRMNGfuw==;24:KrK7YrbqxjqoX3O9xvRi4xXFHokPqoW+fw6v/P2wBVj6IxtGHRgueb5xDHQ9JmIkAWwTd76lpaE4U5hITXs4AXjnwmYbv8/uxFMJyEhkx0M=;7:GpMAEiORDZ/+a/dYauMHZ6UygTLqX5jCjj3jZUhE4D8XCVv6FPnQbFxkMSWA437JzqtKw122PNbNVxPnS+vNZwa+HJ53Hvexp+Xl8jUy9VFZa/uW0wbJezlRAS+Q7tM+eH51heTmBhnp8IAI9rLBN9XcWeywdttv0kj3HTP8BjV5OKeTJbAoPDLM8RvSd/CzFHEcZoxmUrZikYNqNJ9T6V3PHhU7+HUz/aVJGKg6HQM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2017 14:00:43.1193 (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: MWHPR02MB2479 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4465 Lines: 110 On 16.8.2017 14:41, Arnd Bergmann wrote: > On Wed, Aug 16, 2017 at 1:51 PM, 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. > > Ok, thanks. As a general rule, I prefer kernel code to be written > in a portable way even when you assume that is not necessary. > > Besides the obvious problem of users that end up wanting to do > something you don't expect, there is the more general issue of > copying code into another driver that may need to be more portable. I fully understand this. Let me play with it but I expect there will be different issues then just 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. > > Ok. For the purpose of the power management driver, you > probably also want a different name, as what you are interested > in is not the API version but the firmware version. I am really looking forward to see xilinx PM guys to start to upstream their code. And they most likely need this API version. But for that stuff which are the part of this patch all functions should be there. If function is not implemented then you get error back which is sign that firmware doesn't support it. Definitely we can consider to add compatible string with version suffix in future when the same SMCs will be used for different purpose. >>> 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. > > My point was that you can't even ask for a version number without > first knowing what you are talking to, and that information comes from > the DT node describing the interface. Ok. Got you and yes there must be at least any node. Thanks, Michal