Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp3169071ybn; Fri, 27 Sep 2019 02:09:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIiIK9a4Aem5g8UNQBBpg0FZ7GVp256jDe4AG9OVwRE0aDuhxdaSzj5BSUS4Hzi6ctRZ3Z X-Received: by 2002:a17:907:20f1:: with SMTP id rh17mr6867972ejb.110.1569575369448; Fri, 27 Sep 2019 02:09:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569575369; cv=none; d=google.com; s=arc-20160816; b=WPGOj0TQX1KtH9pIswu2gpbE1zQs23KaN1V1+zXOotDeP/kDi6maMNy9ge9YweDvtp 7NFi2Hz4SvdwVM8q6hGUBRLdHgY1lAgAJ80sNQ8Tpq5P5qSwZ+nvjSbDUfSWCAx0xXSS 9qbwtWCJko0iuNCNDmk8vYqIkvJENw4fo/GZRV/eO1Bz4aU4PA/Yd4cF9Zdkra9a+dRh lfKqFADG50sMKbECz7KzQe0mqgjiQLGu/T2LJEs9LKQdubp11LlsJczATlF8Qz4IIjfR Q8rfu8zLauNDxpYuNb96uWM5FS4BndSDCg5vyPK0cuYBBFGzLtCrSCLkNbb+LuzhmT41 q+Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=2zUnlYp3UN4ej4vD4p3qZOSkwPc0bu09YV/M6UdTtvo=; b=plhWSqxHlP0UkCwuXRlrKjqcciQAKwQE3XQRdZYys2ZyOmzPGvsWy8dEVpRQCVI8Fd fVHkGXQWmGZVwzjoPpC9RM7ngM2aezxinq6zWy5r3bZZGt+N2RmOoXwlbYtwwP9cmxA7 y8t3AfjPZmWJi4hMMvi1BbAx/hi7b5MnJj64KfeBRucAvBgNCcl495Myl0zsiMLsKQyg KL/Q5okEPoew/DQK2lf5RwZAsFM99S6TpXr39Y5OgVygW3Xmfrtx8dZIeDLfkqU7oFbj JLC45QhFusK1mTrjBGFuCS9fjucsFWyohWzVuDNKNFBXyGyTR4kDjCaq+WGvew/CjV7h F+cg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h51si1124129eda.85.2019.09.27.02.09.04; Fri, 27 Sep 2019 02:09:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726645AbfI0JGO (ORCPT + 99 others); Fri, 27 Sep 2019 05:06:14 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:48875 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726033AbfI0JGO (ORCPT ); Fri, 27 Sep 2019 05:06:14 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iDmCY-0000x0-Co; Fri, 27 Sep 2019 11:06:10 +0200 Received: from mfe by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1iDmCX-0008Rx-Qm; Fri, 27 Sep 2019 11:06:09 +0200 Date: Fri, 27 Sep 2019 11:06:09 +0200 From: Marco Felsch To: Anson Huang Cc: Leonard Crestez , Aisheng Dong , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "kernel@pengutronix.de" , "festevam@gmail.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , dl-linux-imx Subject: Re: [PATCH] firmware: imx: Skip return value check for some special SCU firmware APIs Message-ID: <20190927090609.fyxdekkzrco7memt@pengutronix.de> References: <1569406066-16626-1-git-send-email-Anson.Huang@nxp.com> <20190926075914.i7tsd3cbpitrqe4q@pengutronix.de> <20190926100558.egils3ds37m3s5wo@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 10:49:01 up 132 days, 15:07, 85 users, load average: 0.03, 0.07, 0.08 User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Anson, Leonard, On 19-09-27 01:20, Anson Huang wrote: > Hi, Leonard > > > On 2019-09-26 1:06 PM, Marco Felsch wrote: > > > On 19-09-26 08:03, Anson Huang wrote: > > >>> On 19-09-25 18:07, Anson Huang wrote: > > >>>> The SCU firmware does NOT always have return value stored in > > >>>> message header's function element even the API has response data, > > >>>> those special APIs are defined as void function in SCU firmware, so > > >>>> they should be treated as return success always. > > >>>> > > >>>> +static const struct imx_sc_rpc_msg whitelist[] = { > > >>>> + { .svc = IMX_SC_RPC_SVC_MISC, .func = > > >>> IMX_SC_MISC_FUNC_UNIQUE_ID }, > > >>>> + { .svc = IMX_SC_RPC_SVC_MISC, .func = > > >>>> +IMX_SC_MISC_FUNC_GET_BUTTON_STATUS }, }; > > >>> > > >>> Is this going to be extended in the near future? I see some upcoming > > >>> problems here if someone uses a different scu-fw<->kernel > > >>> combination as nxp would suggest. > > >> > > >> Could be, but I checked the current APIs, ONLY these 2 will be used > > >> in Linux kernel, so I ONLY add these 2 APIs for now. > > > > > > Okay. > > > > > >> However, after rethink, maybe we should add another imx_sc_rpc API > > >> for those special APIs? To avoid checking it for all the APIs called which > > may impact some performance. > > >> Still under discussion, if you have better idea, please advise, thanks! > > > > My suggestion is to refactor the code and add a new API for the this "no > > error value" convention. Internally they can call a common function with > > flags. > > If I understand your point correctly, that means the loop check of whether the API > is with "no error value" for every API still NOT be skipped, it is just refactoring the code, > right? How makes this things easier? > > > Adding a special api shouldn't be the right fix. Imagine if someone > > > (not a nxp-developer) wants to add a new driver. How could he be > > > expected to know which api he should use. The better abbroach would be > > > to fix the scu-fw instead of adding quirks.. > > Yes, fixing SCU FW is the best solution, but we have talked to SCU FW owner, the SCU > FW released has been finalized, so the API implementation can NOT be changed, but > they will pay attention to this issue for new added APIs later. That means the number > of APIs having this issue a very limited. This means those APIs which already have this bug will not be fixed? IMHO this sounds a bit weird since this is a changeable peace of code ;) > > Right now developers who want to make SCFW calls in upstream need to > > define the message struct in their driver based on protocol documentation. > > This includes: > > > > * Binary layout of the message (a packed struct) > > * If the message has a response (already a bool flag) > > * If an error code is returned (this patch adds support for it) Why should I specify if a error code is returned? Regards, Marco > > Since callers are already exposed to the binary protocol exposing them to > > minor quirks of the calling convention also seems reasonable. Having the > > low-level IPC code peek at message IDs seems like a hack; this belong at a > > slightly higher level. > > A little confused, so what you suggested is to add make the imx_scu_call_rpc() > becomes the "slightly higher level" API, then in this API, check the message IDs > to decide whether to return error value, then calls a new API which will have > the low-level IPC code, the this new API will have a flag passed from imx_scu_call_rpc() > function, am I right? > > Anson -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |