Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752066AbdHPOfA (ORCPT ); Wed, 16 Aug 2017 10:35:00 -0400 Received: from mail-bl2nam02on0065.outbound.protection.outlook.com ([104.47.38.65]:51456 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751893AbdHPOe5 (ORCPT ); Wed, 16 Aug 2017 10:34:57 -0400 Authentication-Results: spf=pass (sender IP is 149.199.60.83) 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 From: Michal Simek 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> Message-ID: <3809b6a0-1cb9-37af-a524-8bc1986268ec@xilinx.com> Date: Wed, 16 Aug 2017 16:34:44 +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.83;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(438002)(199003)(24454002)(76104003)(189002)(377454003)(47776003)(50986999)(5660300001)(106466001)(63266004)(2906002)(65826007)(81166006)(83506001)(36386004)(7416002)(8936002)(77096006)(6666003)(76176999)(81156014)(54356999)(230700001)(23676002)(33646002)(31686004)(2950100002)(8656003)(229853002)(189998001)(53546010)(65806001)(54906002)(93886004)(36756003)(31696002)(4326008)(356003)(9786002)(305945005)(8676002)(65956001)(86362001)(6246003)(478600001)(64126003)(4001350100001)(626005)(50466002)(107986001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR02MB2242;H:xsj-pvapsmtpgw01;FPR:;SPF:Pass;PTR:unknown-60-83.xilinx.com;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2NAM02FT026;1:6ZgrRfcaRp1P+4WMiMdIJmadbyiseyNsNDrDLKjS9LnXbpLVJMXqErgEQHNdxAj7xeXP5Oga4QCrL+PnAslVbPEbbHQgjsWWEeqlDkXcYwGBY4gWgWKN7ibkP7ERGboq X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f21dcbb1-3fec-42d7-f98e-08d4e4b3f560 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:BN6PR02MB2242; X-Microsoft-Exchange-Diagnostics: 1;BN6PR02MB2242;3:6bYExBtt55fYw1WN/UvWGqHkhrTU+m+4V5ff3xoSgwS3tPxMSmvfLjqhOFU5743ukvfoS6StvZJvXgnanDg8P+gt2Fx/8PFU35N+7Mu3JBuoeiKKlIFmOM0JHUsHokX2MpQAiVFv5ZPaYv+O5yQfQv11iB72gDnwa2FNJAWWFPLkeRmq10Yz0GiDwWxu1ac0tSNo1rgcSO0V80gs8Ia2+lb4vaMpV+nSX3QBxG0SGZ+CsumQ7HydzO3gKSCiRKGHvD18sZ9uJS0XeM2/fUmW+8dRUK0QpsCSI6mHlRcwTK3s0gq610sCOin0Ol0svZDUg4n2PODeNnIrozCE4385WfhXcUkxEgH9/76o6OnIoFg=;25:17YPi/SurCsUcx6Opm5Xl4Vel1a6xUXgMf+jiAvzztS0oYnynHP8XNtdy4XJiFR1oBOQ9dw9PCpTuXxy9p6wFLn90l2XbZ4Kj/vR1nLg+M0Vg81ooI26XaCItiHzqQOuAJt7XoLLyHB7sS+KE8WhNA36padGGdAajsOsGoBMobHjosNwfLpRTSnBH/ME0CgAZ07nhs6iVRwKdhM02IvL0qPWO/7p7egteztehcjPtoGnPEGvAZ6+r1HOhrphsM67i4OAiFgzznPHkolbaVGEUSPzdsQYcd9d2aCg72Jvvi1GOQic3HJlbdl1mvDePWkJyUXTCUa2BKwFw3b1WlTy2A== X-MS-TrafficTypeDiagnostic: BN6PR02MB2242: X-LD-Processed: 657af505-d5df-48d0-8300-c31994686c5c,ExtAddr X-Microsoft-Exchange-Diagnostics: 1;BN6PR02MB2242;31:IUXnySPlkHWapA8k7ICIkJrXd/yZKmuHVQZkBG+LbIR5xQAVDRnYBB6hub4CkMwy7O1gKD+LPfNipXDEQ2FDN92EaDTJOnqYgzPSOt9kxKyfkOqgP8MKMVHZAbZThzdGRJNTkhzYU7gt+7Lh2tpUyp3vA5+VVcrnDo/+wG/6Pi0pzWHMld8ttAveZ9X4z6qxs9QyzwlWx7/ZmCRRyo/ePHHTnf7QRiflrmCW0ztHA70=;20:ZoJjUUJVaor3pR4vYMEpe+QspljzlBwvMrfZd2vAtvjfe5GerzPlw0AFaI5LSLjZNS/y91X0I2OdRMQK6AnNlemYV2nEMmrtysJpO6igtM46TllL/e3AWhEI17NCsTFmqooFlxL9pLV9WfNfJfRlWM+rmdMKeFHdzQZt7yTRItRpFodVxaKei6jxFQJaJ1YnU/bhs14M7JyO0ffOqqNE4d1IT1gw0iZ381GgO4RFgC052EF4eUFd0+Wc3UD+Evo22EN3ChnESeE9x/JS5wJDER/nmS8fWWUXDFJNJN862NqQKBQ6LXVHpKvCGIan9wRZE/8sg/2Zf6Vg7ld9Ys667+8zNGzeWFDwdH/QlbOyKidCt5Gd2uPVR2dAFt4TUqn+x98gy4IlivLlFiHKIjNW8DLe7klzpLlO1jYJwHfwFe4cDDEubQS7NKBNlUx2ea7fJoHE7F9tQ4Kyt4j5XzWizbUMuiSn5Lz7d7BWN0hp7rQu7+u7U/lhXKd36zE5p3pr 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)(3002001)(10201501046)(100000703101)(100105400095)(93006095)(93004095)(6055026)(6041248)(20161123558100)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123564025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BN6PR02MB2242;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BN6PR02MB2242; X-Microsoft-Exchange-Diagnostics: 1;BN6PR02MB2242;4:qEh7hT/Lncrh8D4gWqtZFNa+K7HUDpbRyE/MnsQOysRJTkMibI1SOT97QR04mIDT2z8zHDk9FFxwsS7/xYOn3XUfFezkvCfYVLnSQWlaFFBNvIKO1FzewXoey/75p9Vx1gR6267vCMql/noVIqCruCb1B5sga4rE6ImJk+epJzxlX/aqbDn1/alyiAG11db7FR4IC0VeRElAawKsrWg1JK+IRdv+6QBPckwsQDTwZ2DGFt4k1ENEUZWd8iLXVxBtyd8X1rHQ6TgCXy7ZLw10GbV66v4/hwQbWsAZKayqPD0= X-Forefront-PRVS: 0401647B7F X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SB4WUuHPaYZPkuebsaYwM5agMUetlXJYEBQmn0k24017SmO6tEkg1whnY2q5jdirAL+Z+0+v5HS1jr03VQjb5KFdB7tIy1S+mnwaZrA+qHB/LLlkxe7pLGqOWdJJUdheSvI4JSrafpptSPM4nOu2wI3nlK7gaBOzgERrGgdWSUNAJshtv0+e40fK9yX1HCu90Qih0yPCy40vKOR8TFxKEkTY+kbIEEK+Jx7uPJ/Zu7E2ZzJ9M1ZcxsTAW90RtWqKsf5wfHRwuU8IVAe+6r7aGHDK8aZtMS2ZNHkBt886o4R0THQHJU8N+xOEaSfPBUYRG6ojdCTA==;5:OYLoMAIu+pkuS0WYh8LrXXKL6ffVND/Q0XQ21AMkRAUkayVTIM3dhWNZ97lC+YmW7dqRuKVz4aXHFZVhYqZQTbZdMZVlfCW8cPW4cMgD29L++yRyKWoVfYZmd74aFT1tM/GENdwN1YOJxFOX3RiIiw==;24:1/5ziVQzS0aenrjmmRrfGBnzQoT87rZiqhd5aahyfqKiIrbBkQKPMVQImy+emy3NgmQY5yN+RlhooiEtxMXJKuGurQAYTpAZ+/yLR2Xx0U4=;7:4gB5fIov0Z2puT9x+CeWC3qwFqu5oSp0xy8r1JpZbgs8zR/W4TG3LRksisBe2eE/2YhBGTmxOWuRz5kIlS8jEy1t5P/zSy2mZWvJb4S1aQMrd+KYb0moSIDVjHLyWSNy8/zf7Mp3XO2kL/KFeyoA+LC09C5XkDeD0rVWKnQ3rUyrFy7U+7edYR2a/fbcfK96M+uExl19O5BxCzdjDidgeIj+mQgwwpWxQ/CLicgRmw0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2017 14:34:53.0478 (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: BN6PR02MB2242 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2623 Lines: 72 On 16.8.2017 16:00, Michal Simek wrote: > 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. > What do you think? ret_payload[0] = lower_32_bits(le64_to_cpu(res.a0)); ret_payload[1] = upper_32_bits(le64_to_cpu(res.a0)); ret_payload[2] = lower_32_bits(le64_to_cpu(res.a1)); ret_payload[3] = upper_32_bits(le64_to_cpu(res.a1)); ret_payload[4] = lower_32_bits(le64_to_cpu(res.a2)); There should be probably also change in invoke_pm_fn to do conversion from cpu to le64. int invoke_pm_fn(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 *ret_payload) { /* * Added SIP service call Function Identifier * Make sure to stay in x0 register */ u64 smc_arg[4]; smc_arg[0] = cpu_to_le64(PM_SIP_SVC | pm_api_id); smc_arg[1] = cpu_to_le64(((u64)arg1 << 32) | arg0); smc_arg[2] = cpu_to_le64(((u64)arg3 << 32) | arg2); return do_fw_call(smc_arg[0], smc_arg[1], smc_arg[2], ret_payload); } This is not tested on BE just on LE. Thanks, Michal