Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6650543ybn; Mon, 30 Sep 2019 01:15:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTYIKuyl8vMwNosOV17kld5YXLn/oKv4AdA3jEy7quQIt4dwGjI5OI3QQ55bA4k7jrmwGp X-Received: by 2002:a17:906:74d4:: with SMTP id z20mr18071517ejl.191.1569831357955; Mon, 30 Sep 2019 01:15:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569831357; cv=none; d=google.com; s=arc-20160816; b=zWxXECk1Au9DJjb93gtlhonM0JMdbWysv2jfSk7t6RpCMEriiX53iAvdqgO9R7Q3tZ 7AFn4RP1cp3Q3eWN63DMVDotVQQrOdoDpLyb/RiM/rKvEi0f8NYP/F1wVLjBokd/PeQ6 3brAo60AOiqgPBZwEwBSUF3zHB0UxG9Egawzr4uoKeQ3i4oo+Rf+nU/1WF8IEC3rtIr9 lPo05jDR+l/Axf2PTG2C5AX79IMM/Uly2BNeZPoVBCsqdFHkxU+s3GTc1wxC3K3l+RjT KnuIwNVObWsFmss59onqYQtdWnzBKQ8e9kBTCejMZFKvAQj+fWmzNxBRT7+4rMqn8I80 cMrQ== 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=TTCCPtXwZT3zFUABal+HKYwJTvQjl+u8nVmuCGWRSaQ=; b=e4v/TRrjwseS8/biLIT8pb+Y0NlANc0Ywm+xUJ7AKjETKALAuPaM5/v5wPn8tbBpZM Zed8tCCpcevA2q7arYYx7Cnpe2uNRMkwXubjgUkx7dHjkx3mO93RFoUNgmTdBTDVGqMj 4Ko21irbtHJDyUEfqzM4/ksSAYzS01Ws3Yt/AzywjbceWEGb2qD+D5Oiu9GO6C2K/WYa 4vP5A9ru6XUf/qbh2ZWq5f7QWJW8f4+vxDbDdX9KKDsbFyUCxB7S3t3CRu93OzkyEZ2o MkQV1qK6CN2JIWjPDOOTBdc5TjufuPlj481KZLGiRZwI+9EglxYUqPSRAVsd6YV1GuSQ 41tQ== 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 y44si6464841edb.251.2019.09.30.01.15.33; Mon, 30 Sep 2019 01:15:57 -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 S1729765AbfI3IOi (ORCPT + 99 others); Mon, 30 Sep 2019 04:14:38 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:44529 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726008AbfI3IOi (ORCPT ); Mon, 30 Sep 2019 04:14:38 -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 1iEqpI-00012w-AU; Mon, 30 Sep 2019 10:14:36 +0200 Received: from mfe by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1iEqpG-0002Dx-6y; Mon, 30 Sep 2019 10:14:34 +0200 Date: Mon, 30 Sep 2019 10:14:34 +0200 From: Marco Felsch To: Anson Huang Cc: Leonard Crestez , Aisheng Dong , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "linux-kernel@vger.kernel.org" , dl-linux-imx , "kernel@pengutronix.de" , "festevam@gmail.com" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH] firmware: imx: Skip return value check for some special SCU firmware APIs Message-ID: <20190930081434.qrrv3yqczzxihntm@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: 09:49:54 up 135 days, 14:08, 87 users, load average: 0.01, 0.02, 0.07 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-30 07:42, Anson Huang wrote: > Hi, Leonard > > > On 2019-09-27 4:20 AM, Anson Huang wrote: > > >> 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? > > > > There would be no "loop" anywhere: the responsibility would fall on the call > > to call the right RPC function. In the current layering scheme (drivers -> RPC -> > > mailbox) the RPC layer treats all calls the same and it's up the the caller to > > provide information about calling convention. > > > > An example implementation: > > * Rename imx_sc_rpc_call to __imx_sc_rpc_call_flags > > * Make a tiny imx_sc_rpc_call wrapper which just converts resp/noresp to a > > flag > > * Make get button status call __imx_sc_rpc_call_flags with the > > _IMX_SC_RPC_NOERROR flag > > > > Hope this makes my suggestion clearer? Pushing this to the caller is a bit ugly > > but I think it's worth preserving the fact that the imx rpc core treats services > > in an uniform way. > > It is clear now, so essentially it is same as 2 separate APIs, still need to change the > button driver and uid driver to use the special flag, meanwhile, need to change the > third parament of imx_sc_rpc_call() from bool to u32. > > If no one opposes this approach, I will redo the patch together with the button driver > and uid driver after holiday. As Ansons said that are two approaches and in both ways the caller needs to know if the error code is valid. Extending the flags seems better to me but it looks still not that good. One question, does the scu-fw set the error-msg to something? If not than why should we specify a flag or a other api? Nowadays the caller needs to know that the error-msg-field isn't set so if the caller sets the msg-packet to zero and fills the rpc-id the error-msg-field shouldn't be touched by the firmware. So it should be zero. Regards, Marco > Anson > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel > -- 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 |