From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8886BC4741F for ; Fri, 6 Nov 2020 16:27:54 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 103A021556 for ; Fri, 6 Nov 2020 16:27:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="M3F7yVlA"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PcFL9oHL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 103A021556 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NRa8P2Lr+gR1P7R0b/DcYlxcoOCyamj8dmSgt0RM4NY=; b=M3F7yVlAfADsEtJBJ4FzA3nwD 9Sk3z0cc2nnu/d2jUjrATE/fkX3mJkKNkbotQTbvL6KMldw3JGmTjv6NCenKmtl6TFaDXnRjdhdNl 5tlR1a3zNnXF3kVeLxILi2TPXFToqsjIszMa7VUvTnIzJiDA4ohbtKqh5XPa7MMs8TgoRzDmybt/v Fh0WME3dTk46BLJcKn6pQL78h02b48jk7X/7QzsZDY5roBTEvvtWxlFPw0kR3PDunVg3v9gvKeRDb 4GtE3hBHz4mTPI8LgjJdQaIrj1hORavMHqOnUuXptDoTLeuUsQ7HHXISbVRzDb7uCQ7GBurSQFF0N V97jOvR2Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kb4Zd-0004Z7-GL; Fri, 06 Nov 2020 16:26:49 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kb4Zb-0004Y1-6f for linux-arm-kernel@lists.infradead.org; Fri, 06 Nov 2020 16:26:48 +0000 Received: by mail-qt1-x841.google.com with SMTP id n63so1139992qte.4 for ; Fri, 06 Nov 2020 08:26:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=BS6hnd+mn2KOb96zjpH6hQK2KHkxoDPNVR2pa7FD2yE=; b=PcFL9oHLE7kDCMw4fCngNIyZoVhs9qIObXlFNgPNXVvlp6jZw8Qzs18oA9Jmwv24Lg cmcuYmY2lGEUgEzwc7mYN9EEo20fyVLz8qnwsDfKDxxLkynU8tbH4F0ZIISJTqaVKfZQ U1piVPmoijhzCKeCW3LrKP4DTwv3D73ZB3fTDOWodEZ4cwtawnOmFy4qQ+1i7Pe70I9m rhQMgVgtqASq7AubWErhQWjxPCvqtdLMpmRaRJC5PaRoROOeksmKttOZgX/uHVgGx/jz 0UwzE3qS0fCE2DQ8SzB2rnJZzXZf692NttfPRqWTV6dFp2gTEQdcs9S5zjTgU88Z+zWu Mmwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=BS6hnd+mn2KOb96zjpH6hQK2KHkxoDPNVR2pa7FD2yE=; b=bRxzNTd1daxYwA5Gr3dtPkayetED3g7eh643Vd5J6QJhHk/djl3x2bcU/N05NtbhQS zeVOp5X4y3CcfV+MJupxVOhU7KZWldE12j2ZJ0UGuf5JWdhrJqOlKc0EQzeI7GQndt3Z rFkYWHoUJfZOHkp21Rb3WTUpL/G0Sqe9P28yLDdVuY1xrVMwlV/MG2tgpNl46FX37ABX 1WLHOkJDqWHtsr7Wb4eOh8tXgk/508afDrqceQBoSQbq1vyEvitrfn98Evx5DrEcx0BH qeqz423lEtp8eLLnqDJHJ7wCAUl2SzkFQYxYcaExUu0aEVQlJycM9d/pm8+QJ1iP+U/2 cT6A== X-Gm-Message-State: AOAM531iZZgqGjeGRDRObNJXtGniCaFyjsnyUe8MfqzRIgyM3zIr+3cM ossrl10AygNi4GHclE8z0AXbyQ== X-Google-Smtp-Source: ABdhPJyN55QAu4juuLhQCFMe0eug0jiDEy+gUhi5BMg0fU7MFFk/abEed+QXGKQ8P8QjlTwDbFwWKA== X-Received: by 2002:aed:3048:: with SMTP id 66mr2298658qte.374.1604680005666; Fri, 06 Nov 2020 08:26:45 -0800 (PST) Received: from [192.168.1.93] (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.gmail.com with ESMTPSA id u31sm828224qtu.87.2020.11.06.08.26.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Nov 2020 08:26:44 -0800 (PST) Subject: Re: [PATCH v2 2/8] firmware: arm_scmi: introduce protocol handles To: Cristian Marussi References: <20201028202914.43662-1-cristian.marussi@arm.com> <20201028202914.43662-3-cristian.marussi@arm.com> <20201104174427.GB24640@e120937-lin> From: Thara Gopinath Message-ID: <745d52d0-8578-6a25-c55e-e628d970e9fe@linaro.org> Date: Fri, 6 Nov 2020 11:26:44 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201104174427.GB24640@e120937-lin> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201106_112647_297065_294E5DB5 X-CRM114-Status: GOOD ( 25.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: f.fainelli@gmail.com, vincent.guittot@linaro.org, sudeep.holla@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.quinlan@broadcom.com, Jonathan.Cameron@Huawei.com, souvik.chakravarty@arm.com, etienne.carriere@linaro.org, lukasz.luba@arm.com Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 11/4/20 12:44 PM, Cristian Marussi wrote: > Hi > > On Wed, Nov 04, 2020 at 11:16:18AM -0500, Thara Gopinath wrote: >> >> Hi Cristian, >> >> On 10/28/20 4:29 PM, Cristian Marussi wrote: >>> Add basic protocol handles definitions and helpers support. >>> All protocols initialization code and SCMI drivers probing is still >>> performed using the handle based interface. >>> >>> Signed-off-by: Cristian Marussi >>> --- >>> drivers/firmware/arm_scmi/common.h | 61 ++++++++++++++++++++++++++++ >>> drivers/firmware/arm_scmi/driver.c | 64 ++++++++++++++++++++++++++++++ >>> 2 files changed, 125 insertions(+) >>> >>> diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h >>> index b08a8ddbc22a..f0678be02a09 100644 >>> --- a/drivers/firmware/arm_scmi/common.h >>> +++ b/drivers/firmware/arm_scmi/common.h >>> @@ -151,6 +151,67 @@ int scmi_xfer_get_init(const struct scmi_handle *h, u8 msg_id, u8 prot_id, >>> size_t tx_size, size_t rx_size, struct scmi_xfer **p); >>> void scmi_reset_rx_to_maxsz(const struct scmi_handle *handle, >>> struct scmi_xfer *xfer); >>> + >>> +struct scmi_xfer_ops; >>> + >>> +/** >>> + * struct scmi_protocol_handle - Reference to an initialized protocol instance >>> + * >>> + * @dev: A reference to the associated SCMI instance device (handle->dev). >>> + * @xops: A reference to a struct holding refs to the core xfer operations that >>> + * can be used by the protocol implementation to generate SCMI messages. >>> + * @set_priv: A method to set protocol private data for this instance. >>> + * @get_priv: A method to get protocol private data previously set. >>> + * >>> + * This structure represents a protocol initialized against specific SCMI >>> + * instance and it will be used as follows: >>> + * - as a parameter fed from the core to the protocol initialization code so >>> + * that it can access the core xfer operations to build and generate SCMI >>> + * messages exclusively for the specific underlying protocol instance. >>> + * - as an opaque handle fed by an SCMI driver user when it tries to access >>> + * this protocol through its own protocol operations. >>> + * In this case this handle will be returned as an opaque object together >>> + * with the related protocol operations when the SCMI driver tries to access >>> + * the protocol. >>> + */ >>> +struct scmi_protocol_handle { >>> + struct device *dev; >>> + const struct scmi_xfer_ops *xops; >>> + int (*set_priv)(const struct scmi_protocol_handle *ph, void *priv); >>> + void *(*get_priv)(const struct scmi_protocol_handle *ph); >>> +}; >> >> So scmi_xfer_ops are the ops that actually talks with the scmi firmware on >> the other end , right ? IIUC, these ops are the same for all the protocols >> of a scmi instance. Imho, this struct is not the right place for these ops >> to reside.You are inadvertently exposing scmi internal details to the client >> drivers. There is no reason why this should be part of scmi_handle. The >> protocols can extract it from the handle during protocol_reigster, right? >> >> So, now to the second part, why do you need a scmi_protocol_handle? Again >> IIUC, if you have set_priv and get_priv hooks and get_ops and put_ops hooks, >> there is nothing that scmi_protocol_handle is providing extra, right? As >> mentioned in the comments for last patch any reason all of this cannot be >> rolled into scmi_protocol? > > The basic idea for protocol_hande existence is that the protocol code > should be able to access the core xfer ops (without EXPORTing all > scmi_xfer ops) but protoX should NOT be allowed to mistakenly or > maliciously build and send protoY messages: since the protocol_handle > for protoX is embedded in a specific protocol_instance in this way you > can call from your protocol code something like: > > ph->xops->xfer_get_init(ph, ...) I am still confused by this one... scmi_protocol_instance has a pointer to scmi_handle. So why not handle->xops->xfer_get_init(pi, ....). Here also protoX will not be allowed to send protoY messages, right? And then again set_priv and get_priv can be moved to scmi_protocol_instance right ? -- Warm Regards Thara _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel