From patchwork Mon Jul 8 15:47:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 168686 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7331895ilk; Mon, 8 Jul 2019 08:48:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqydh9USR8UsNoz3rpXCEcR3nRXD0XwW6piGDjr26/IhtNSzza1itD/yoj03otR8xIeF1yx9 X-Received: by 2002:a17:90a:3086:: with SMTP id h6mr27157009pjb.14.1562600911657; Mon, 08 Jul 2019 08:48:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562600911; cv=none; d=google.com; s=arc-20160816; b=b2PhroAjPn1qQOvc/LJz53ENu6qT45AuO1trDFp+ilHvJK0H+WqtdTMH/aOxbQbubH p2URJcKn4fXABiNesWTkErGC/yj0r+EeqhLDPPrVFp0AWB4bCb8Nm5LH2kFn/PCpkCWM 0DDX3XpH6qj8MgpoiMwRI656iTRmYr6A2rRtpSkvkcDWveuyFl4I7rDuE5pWGK32uzW+ KmRSN8pyeKZC/Y9/QUXvf2RgEndgwsROi2qh6yEo4NnhS4H+hGeJ71+a6bG94606BBvO o0QRERkfRexvQBl+o7EGWKFw6guYJD39PXBF345EVZknv1RnM2O5zUtSY2kyTtmvw4Ha QsBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=GS4PEkazwKHNal8nTTgVU/YeXN1XTNaTTbX/tbYT1YM=; b=0edwSVBaVY4gxE97/mimbjoEl9TiIwVxVc+vQAn0KB918AglSs2Zs563ASecEzE3sX pSKUGHA8q8U45r3Bl4UmppGgPuQXJinFq020MWmeIrmgmsVTEpzAWjvARqd5MKLFsUsG A3E24UA6Oufl4qNvomiwUseCskYfPzt7CUzCtYucLaGW12P+nvmiy/RyGWK5pgj2DhLK DfzIrG8QVLZNDQfGPr997HGkFlb9xTzCEE2oikye/OhLj+MaFY50hn0TjcfhwrIpaPun B7sgQ79uyF8WoUx3zHzWUn1Z4ZPftN02j4xIUt/jDM1SR6g+UIuxIdxu9df9X03kS4z3 viOQ== 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 33si18218861pli.144.2019.07.08.08.48.31; Mon, 08 Jul 2019 08:48:31 -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 S2391310AbfGHPsa (ORCPT + 30 others); Mon, 8 Jul 2019 11:48:30 -0400 Received: from foss.arm.com ([217.140.110.172]:52326 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388947AbfGHPrn (ORCPT ); Mon, 8 Jul 2019 11:47:43 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8EB79CFC; Mon, 8 Jul 2019 08:47:42 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8BF583F59C; Mon, 8 Jul 2019 08:47:41 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Peng Fan , Jim Quinlan , Bo Zhang , Volodymyr Babchuk Subject: [PATCH 01/11] firmware: arm_scmi: Reorder some functions to avoid forward declarations Date: Mon, 8 Jul 2019 16:47:20 +0100 Message-Id: <20190708154730.16643-2-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708154730.16643-1-sudeep.holla@arm.com> References: <20190708154730.16643-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Re-shuffling few functions to keep definitions and their usages close. This is also needed to avoid too many unnecessary forward declarations while adding new features(delayed response and notifications). Keeping this separate to avoid mixing up of these trivial change that doesn't affect functionality into the ones that does. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/driver.c | 180 ++++++++++++++--------------- 1 file changed, 90 insertions(+), 90 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 765573756987..0bd2af0a008f 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -197,44 +197,6 @@ static void scmi_fetch_response(struct scmi_xfer *xfer, memcpy_fromio(xfer->rx.buf, mem->msg_payload + 4, xfer->rx.len); } -/** - * scmi_rx_callback() - mailbox client callback for receive messages - * - * @cl: client pointer - * @m: mailbox message - * - * Processes one received message to appropriate transfer information and - * signals completion of the transfer. - * - * NOTE: This function will be invoked in IRQ context, hence should be - * as optimal as possible. - */ -static void scmi_rx_callback(struct mbox_client *cl, void *m) -{ - u16 xfer_id; - struct scmi_xfer *xfer; - struct scmi_chan_info *cinfo = client_to_scmi_chan_info(cl); - struct device *dev = cinfo->dev; - struct scmi_info *info = handle_to_scmi_info(cinfo->handle); - struct scmi_xfers_info *minfo = &info->minfo; - struct scmi_shared_mem __iomem *mem = cinfo->payload; - - xfer_id = MSG_XTRACT_TOKEN(ioread32(&mem->msg_header)); - - /* Are we even expecting this? */ - if (!test_bit(xfer_id, minfo->xfer_alloc_table)) { - dev_err(dev, "message for %d is not expected!\n", xfer_id); - return; - } - - xfer = &minfo->xfer_block[xfer_id]; - - scmi_dump_header_dbg(dev, &xfer->hdr); - - scmi_fetch_response(xfer, mem); - complete(&xfer->done); -} - /** * pack_scmi_header() - packs and returns 32-bit header * @@ -349,6 +311,44 @@ void scmi_xfer_put(const struct scmi_handle *handle, struct scmi_xfer *xfer) spin_unlock_irqrestore(&minfo->xfer_lock, flags); } +/** + * scmi_rx_callback() - mailbox client callback for receive messages + * + * @cl: client pointer + * @m: mailbox message + * + * Processes one received message to appropriate transfer information and + * signals completion of the transfer. + * + * NOTE: This function will be invoked in IRQ context, hence should be + * as optimal as possible. + */ +static void scmi_rx_callback(struct mbox_client *cl, void *m) +{ + u16 xfer_id; + struct scmi_xfer *xfer; + struct scmi_chan_info *cinfo = client_to_scmi_chan_info(cl); + struct device *dev = cinfo->dev; + struct scmi_info *info = handle_to_scmi_info(cinfo->handle); + struct scmi_xfers_info *minfo = &info->minfo; + struct scmi_shared_mem __iomem *mem = cinfo->payload; + + xfer_id = MSG_XTRACT_TOKEN(ioread32(&mem->msg_header)); + + /* Are we even expecting this? */ + if (!test_bit(xfer_id, minfo->xfer_alloc_table)) { + dev_err(dev, "message for %d is not expected!\n", xfer_id); + return; + } + + xfer = &minfo->xfer_block[xfer_id]; + + scmi_dump_header_dbg(dev, &xfer->hdr); + + scmi_fetch_response(xfer, mem); + complete(&xfer->done); +} + static bool scmi_xfer_poll_done(const struct scmi_chan_info *cinfo, struct scmi_xfer *xfer) { @@ -599,20 +599,6 @@ int scmi_handle_put(const struct scmi_handle *handle) return 0; } -static const struct scmi_desc scmi_generic_desc = { - .max_rx_timeout_ms = 30, /* We may increase this if required */ - .max_msg = 20, /* Limited by MBOX_TX_QUEUE_LEN */ - .max_msg_size = 128, -}; - -/* Each compatible listed below must have descriptor associated with it */ -static const struct of_device_id scmi_of_match[] = { - { .compatible = "arm,scmi", .data = &scmi_generic_desc }, - { /* Sentinel */ }, -}; - -MODULE_DEVICE_TABLE(of, scmi_of_match); - static int scmi_xfer_info_init(struct scmi_info *sinfo) { int i; @@ -659,44 +645,6 @@ static int scmi_mailbox_check(struct device_node *np) return of_parse_phandle_with_args(np, "mboxes", "#mbox-cells", 0, NULL); } -static int scmi_mbox_free_channel(int id, void *p, void *data) -{ - struct scmi_chan_info *cinfo = p; - struct idr *idr = data; - - if (!IS_ERR_OR_NULL(cinfo->chan)) { - mbox_free_channel(cinfo->chan); - cinfo->chan = NULL; - } - - idr_remove(idr, id); - - return 0; -} - -static int scmi_remove(struct platform_device *pdev) -{ - int ret = 0; - struct scmi_info *info = platform_get_drvdata(pdev); - struct idr *idr = &info->tx_idr; - - mutex_lock(&scmi_list_mutex); - if (info->users) - ret = -EBUSY; - else - list_del(&info->node); - mutex_unlock(&scmi_list_mutex); - - if (ret) - return ret; - - /* Safe to free channels since no more users */ - ret = idr_for_each(idr, scmi_mbox_free_channel, idr); - idr_destroy(&info->tx_idr); - - return ret; -} - static inline int scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev, int prot_id) { @@ -856,6 +804,58 @@ static int scmi_probe(struct platform_device *pdev) return 0; } +static int scmi_mbox_free_channel(int id, void *p, void *data) +{ + struct scmi_chan_info *cinfo = p; + struct idr *idr = data; + + if (!IS_ERR_OR_NULL(cinfo->chan)) { + mbox_free_channel(cinfo->chan); + cinfo->chan = NULL; + } + + idr_remove(idr, id); + + return 0; +} + +static int scmi_remove(struct platform_device *pdev) +{ + int ret = 0; + struct scmi_info *info = platform_get_drvdata(pdev); + struct idr *idr = &info->tx_idr; + + mutex_lock(&scmi_list_mutex); + if (info->users) + ret = -EBUSY; + else + list_del(&info->node); + mutex_unlock(&scmi_list_mutex); + + if (ret) + return ret; + + /* Safe to free channels since no more users */ + ret = idr_for_each(idr, scmi_mbox_free_channel, idr); + idr_destroy(&info->tx_idr); + + return ret; +} + +static const struct scmi_desc scmi_generic_desc = { + .max_rx_timeout_ms = 30, /* We may increase this if required */ + .max_msg = 20, /* Limited by MBOX_TX_QUEUE_LEN */ + .max_msg_size = 128, +}; + +/* Each compatible listed below must have descriptor associated with it */ +static const struct of_device_id scmi_of_match[] = { + { .compatible = "arm,scmi", .data = &scmi_generic_desc }, + { /* Sentinel */ }, +}; + +MODULE_DEVICE_TABLE(of, scmi_of_match); + static struct platform_driver scmi_driver = { .driver = { .name = "arm-scmi", From patchwork Mon Jul 8 15:47:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 168676 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7331087ilk; Mon, 8 Jul 2019 08:47:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqynhRdm27FYjedS183AiGgzX+kL5cXGvLnrl/X+Wwu/fYV6iltZsw5UKs/WSb+o8ZlqxU54 X-Received: by 2002:a63:2f44:: with SMTP id v65mr24204626pgv.185.1562600867938; Mon, 08 Jul 2019 08:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562600867; cv=none; d=google.com; s=arc-20160816; b=eO1jI+qvx1UqwO6i57eSdl7nyneUFxqU4Iw6WTBwh6Xj4Zx6FJ63wcQGhZ9tra3SyH KmGJu3BSDUQZjthv5W+QZpiT93q1I2ICTzA0h4GeqaYrHail/6JJntqoSqmFpuoXtrc9 Xnm4NTs5UBU7/Wk2CEQX7vn1Uglu1+BxYHdIS/Gy8gdT8V4atbp30al5P1sWA6+sBci1 YW65pxEwu3BkIAyLCVbJzP4jiZtmdYMHLXB3gEeBL7iesTSo3nIE3Cwk21QqVbQrr6+O cABNyT2DMCLkTlxNIOn4gAR8P2SpeKf8E1JkpqlVVXBGe/pOHaCG9vgogdq/KynPfArS fPzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=H9WMx4jYdpUgwq31fAeuJYoGvXH+rA4Gg+NrFLHhsSw=; b=jKVNm58TGgEADaa3gg/IIpQ9CCzPBgn1zMDxBWcO9aoWU3H0IlDOrsmdMHdZ1KftbR yDsq1aDs/3p3Hv4fnAPbX5t5e9OT4IKOxlZwoRc4e8pCDlZtBP6VqmBGPUgLp/6JPQCm HILOazQgCPdC5n5jK7co3Wu/jpE8Lk06xHgDlqriMy2RB3mXeL8MJEmZqEnfdZiXO7Y2 OBgZJZ4wDSxNGsRAN/E5WjRbOBZKRmEmd3A4yxV5dJDxQwN6mdQdZbxsvuZ8kOqC47kR PIxcGdZ17mUbilSt9d1+zpvsEet8/7LleQx731FyhzY4ewPPpg7fAdUAt8awQAgIaSSO maxw== 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 f74si19378230pfa.57.2019.07.08.08.47.47; Mon, 08 Jul 2019 08:47:47 -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 S2391298AbfGHPrq (ORCPT + 30 others); Mon, 8 Jul 2019 11:47:46 -0400 Received: from foss.arm.com ([217.140.110.172]:52340 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391277AbfGHPro (ORCPT ); Mon, 8 Jul 2019 11:47:44 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C62471509; Mon, 8 Jul 2019 08:47:43 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C2DDF3F59C; Mon, 8 Jul 2019 08:47:42 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Peng Fan , Jim Quinlan , Bo Zhang , Volodymyr Babchuk Subject: [PATCH 02/11] firmware: arm_scmi: Segregate tx channel handling and prepare to add rx Date: Mon, 8 Jul 2019 16:47:21 +0100 Message-Id: <20190708154730.16643-3-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708154730.16643-1-sudeep.holla@arm.com> References: <20190708154730.16643-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The transmit(Tx) channels are specified as the first entry and the receive(Rx) channels are the second entry as per the device tree bindings. Since we currently just support Tx, index 0 is hardcoded at all required callsites. In order to prepare for adding Rx support, let's remove those hardcoded index and add boolean parameter to identify Tx/Rx channels when setting them up. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/driver.c | 33 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 15 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 0bd2af0a008f..f7fb6d5bfc64 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -112,7 +112,7 @@ struct scmi_chan_info { * @version: SCMI revision information containing protocol version, * implementation version and (sub-)vendor identification. * @minfo: Message info - * @tx_idr: IDR object to map protocol id to channel info pointer + * @tx_idr: IDR object to map protocol id to Tx channel info pointer * @protocols_imp: List of protocols implemented, currently maximum of * MAX_PROTOCOLS_IMP elements allocated by the base protocol * @node: List head @@ -640,22 +640,26 @@ static int scmi_xfer_info_init(struct scmi_info *sinfo) return 0; } -static int scmi_mailbox_check(struct device_node *np) +static int scmi_mailbox_check(struct device_node *np, int idx) { - return of_parse_phandle_with_args(np, "mboxes", "#mbox-cells", 0, NULL); + return of_parse_phandle_with_args(np, "mboxes", "#mbox-cells", + idx, NULL); } -static inline int -scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev, int prot_id) +static int scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev, + int prot_id, bool tx) { - int ret; + int ret, idx; struct resource res; resource_size_t size; struct device_node *shmem, *np = dev->of_node; struct scmi_chan_info *cinfo; struct mbox_client *cl; - if (scmi_mailbox_check(np)) { + /* Transmit channel is first entry i.e. index 0 */ + idx = tx ? 0 : 1; + + if (scmi_mailbox_check(np, idx)) { cinfo = idr_find(&info->tx_idr, SCMI_PROTOCOL_BASE); goto idr_alloc; } @@ -669,11 +673,11 @@ scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev, int prot_id) cl = &cinfo->cl; cl->dev = dev; cl->rx_callback = scmi_rx_callback; - cl->tx_prepare = scmi_tx_prepare; + cl->tx_prepare = tx ? scmi_tx_prepare : NULL; cl->tx_block = false; - cl->knows_txdone = true; + cl->knows_txdone = tx; - shmem = of_parse_phandle(np, "shmem", 0); + shmem = of_parse_phandle(np, "shmem", idx); ret = of_address_to_resource(shmem, 0, &res); of_node_put(shmem); if (ret) { @@ -688,8 +692,7 @@ scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev, int prot_id) return -EADDRNOTAVAIL; } - /* Transmit channel is first entry i.e. index 0 */ - cinfo->chan = mbox_request_channel(cl, 0); + cinfo->chan = mbox_request_channel(cl, idx); if (IS_ERR(cinfo->chan)) { ret = PTR_ERR(cinfo->chan); if (ret != -EPROBE_DEFER) @@ -721,7 +724,7 @@ scmi_create_protocol_device(struct device_node *np, struct scmi_info *info, return; } - if (scmi_mbox_chan_setup(info, &sdev->dev, prot_id)) { + if (scmi_mbox_chan_setup(info, &sdev->dev, prot_id, true)) { dev_err(&sdev->dev, "failed to setup transport\n"); scmi_device_destroy(sdev); return; @@ -741,7 +744,7 @@ static int scmi_probe(struct platform_device *pdev) struct device_node *child, *np = dev->of_node; /* Only mailbox method supported, check for the presence of one */ - if (scmi_mailbox_check(np)) { + if (scmi_mailbox_check(np, 0)) { dev_err(dev, "no mailbox found in %pOF\n", np); return -EINVAL; } @@ -769,7 +772,7 @@ static int scmi_probe(struct platform_device *pdev) handle->dev = info->dev; handle->version = &info->version; - ret = scmi_mbox_chan_setup(info, dev, SCMI_PROTOCOL_BASE); + ret = scmi_mbox_chan_setup(info, dev, SCMI_PROTOCOL_BASE, true); if (ret) return ret; From patchwork Mon Jul 8 15:47:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 168677 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7331129ilk; Mon, 8 Jul 2019 08:47:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqyAS7JgVo31L1ZIoljIpokMBKva60dQYXprDhtDoGJz+bPVUjyctijOmzyLYul2VL+fb3qJ X-Received: by 2002:a63:4c14:: with SMTP id z20mr24662016pga.360.1562600870776; Mon, 08 Jul 2019 08:47:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562600870; cv=none; d=google.com; s=arc-20160816; b=emWq5Sg9br54cQbixJsYg9hyLOHVP2TAPxJRhzt4X5nUNknU8UPgRrEcQSWr7QINWe 2rYK5qoouxy7lYaBIJnUnJ3egxxiAELScMD0hcJULYrYFauo9iAxGGq/kExB30VmM6dp qAYNV8hL+QZ8HkidHe5xOeDjtaxbdg0sC/nh8BuUbCbJmp8/eG04Yld2KLmO8zxT1DXt y9BYrVh3hcrcXp1tAHy9RoRGrkjm7YQar2QMU/iEFPk5/w1ZSyUmuJXe7g19G/taq7Na faMbB7rCEp6cxwCRwKzzaEGnXNIKUfARsXQQqjavZzKfUWDmUfATCqRn7xDYAWBZyRd1 qdvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=FeopbYsfh9LsOs0qP3rx+WAYv8Qbig4VwCedicEqRTg=; b=znXkT/LAfiP9B98ew/IHs7kd1CBwTSmU1juD2w0Z3XPMIXfu1XbVOA3u8MzLBfhD0q VVG6pE4C8UUZ87ZDwhWvf9LhPoVd1hGCWBuc3P7RwsGryxxwV3Co8eMQmQfaQ6BzjXkE fF/BMXeA8UXn2Y3w5WxJgMxRQ6AVnTjOD18Ttyg/PpxWbmp1Qy+5VLSEacCwbU+maCES dRE0AXZqoTJot1UnxBZZ9faJcfTW11x+h5mERKW1GlaSeGZQ8X/2wLM9GYUIMp//KFTG tlpgROKv4ea0qFSC26r9T1GfPxmuOCErReCp5SqVd0NY20SUHMULQ1jhAxl1kpydi6aB KrmA== 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 f74si19378230pfa.57.2019.07.08.08.47.50; Mon, 08 Jul 2019 08:47:50 -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 S2391322AbfGHPrt (ORCPT + 30 others); Mon, 8 Jul 2019 11:47:49 -0400 Received: from foss.arm.com ([217.140.110.172]:52352 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391283AbfGHPrp (ORCPT ); Mon, 8 Jul 2019 11:47:45 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 08E25360; Mon, 8 Jul 2019 08:47:45 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 061383F59C; Mon, 8 Jul 2019 08:47:43 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Peng Fan , Jim Quinlan , Bo Zhang , Volodymyr Babchuk Subject: [PATCH 03/11] firmware: arm_scmi: Add receive channel support for notifications Date: Mon, 8 Jul 2019 16:47:22 +0100 Message-Id: <20190708154730.16643-4-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708154730.16643-1-sudeep.holla@arm.com> References: <20190708154730.16643-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With scmi_mbox_chan_setup enabled to identify and setup both Tx and Rx, let's consolidate setting up of both the channels under the function scmi_mbox_txrx_setup. Since some platforms may opt not to support notifications or delayed response, they may not need support for Rx. Hence Rx is optional and failure of setting one up is not considered fatal. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/driver.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index f7fb6d5bfc64..e9b762348eff 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -113,6 +113,7 @@ struct scmi_chan_info { * implementation version and (sub-)vendor identification. * @minfo: Message info * @tx_idr: IDR object to map protocol id to Tx channel info pointer + * @rx_idr: IDR object to map protocol id to Rx channel info pointer * @protocols_imp: List of protocols implemented, currently maximum of * MAX_PROTOCOLS_IMP elements allocated by the base protocol * @node: List head @@ -125,6 +126,7 @@ struct scmi_info { struct scmi_handle handle; struct scmi_xfers_info minfo; struct idr tx_idr; + struct idr rx_idr; u8 *protocols_imp; struct list_head node; int users; @@ -655,12 +657,16 @@ static int scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev, struct device_node *shmem, *np = dev->of_node; struct scmi_chan_info *cinfo; struct mbox_client *cl; + struct idr *idr; /* Transmit channel is first entry i.e. index 0 */ idx = tx ? 0 : 1; + idr = tx ? &info->tx_idr : &info->rx_idr; if (scmi_mailbox_check(np, idx)) { - cinfo = idr_find(&info->tx_idr, SCMI_PROTOCOL_BASE); + cinfo = idr_find(idr, SCMI_PROTOCOL_BASE); + if (unlikely(!cinfo)) /* Possible only if platform has no Rx */ + return -EINVAL; goto idr_alloc; } @@ -701,7 +707,7 @@ static int scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev, } idr_alloc: - ret = idr_alloc(&info->tx_idr, cinfo, prot_id, prot_id + 1, GFP_KERNEL); + ret = idr_alloc(idr, cinfo, prot_id, prot_id + 1, GFP_KERNEL); if (ret != prot_id) { dev_err(dev, "unable to allocate SCMI idr slot err %d\n", ret); return ret; @@ -711,6 +717,17 @@ static int scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev, return 0; } +static inline int +scmi_mbox_txrx_setup(struct scmi_info *info, struct device *dev, int prot_id) +{ + int ret = scmi_mbox_chan_setup(info, dev, prot_id, true); + + if (!ret) /* Rx is optional, hence no error check */ + scmi_mbox_chan_setup(info, dev, prot_id, false); + + return ret; +} + static inline void scmi_create_protocol_device(struct device_node *np, struct scmi_info *info, int prot_id) @@ -724,7 +741,7 @@ scmi_create_protocol_device(struct device_node *np, struct scmi_info *info, return; } - if (scmi_mbox_chan_setup(info, &sdev->dev, prot_id, true)) { + if (scmi_mbox_txrx_setup(info, &sdev->dev, prot_id)) { dev_err(&sdev->dev, "failed to setup transport\n"); scmi_device_destroy(sdev); return; @@ -767,12 +784,13 @@ static int scmi_probe(struct platform_device *pdev) platform_set_drvdata(pdev, info); idr_init(&info->tx_idr); + idr_init(&info->rx_idr); handle = &info->handle; handle->dev = info->dev; handle->version = &info->version; - ret = scmi_mbox_chan_setup(info, dev, SCMI_PROTOCOL_BASE, true); + ret = scmi_mbox_txrx_setup(info, dev, SCMI_PROTOCOL_BASE); if (ret) return ret; @@ -842,6 +860,10 @@ static int scmi_remove(struct platform_device *pdev) ret = idr_for_each(idr, scmi_mbox_free_channel, idr); idr_destroy(&info->tx_idr); + idr = &info->rx_idr; + ret = idr_for_each(idr, scmi_mbox_free_channel, idr); + idr_destroy(&info->rx_idr); + return ret; } From patchwork Mon Jul 8 15:47:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 168685 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7331760ilk; Mon, 8 Jul 2019 08:48:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNImSaoZv+nOM84Qt5u+lS+GCfKHhxbh/tyEKRS4ZvmZoMRvTkoT9P64uBnsXJcKf1PyoM X-Received: by 2002:a17:90a:380d:: with SMTP id w13mr26357680pjb.138.1562600905535; Mon, 08 Jul 2019 08:48:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562600905; cv=none; d=google.com; s=arc-20160816; b=OMGA5ktMwZB/m45UNxta0IsvfyDpxzMJWMUpgDDYrKgT2VsCGpKm0G2GdKVuoDed+Z 3YOrrn8DznVKMHAWtUKlZ41263AvTe04r6G2mzJXHFgFrfgAVajhrWgFERoj95Ukmwa7 CyMIyrWWQzHxdE5YOuIeyR0QMTZdQddkXaJa/lmd+TJh/HOJ6Pe7Vxd+CkwLvlgOqM3G fiPbRsmDrqKoRHnMgVJgZgWJuvuThKim3uMfL61IG97xahcF1nKTz24mlj2HqYmec6tX GE4IX7h0u6pnNulkid87T5QzMbCej9snysAOakz7YKcmcTW77GBb0JAzDYE5ygSrS16y MftA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=yz1My+xhlG0a04KXS4A+ETr9qK6wXjFkMB4dppuj33s=; b=fBADPcm7ykh2Hdy/Hcr6mBGdgyPSKDjAYiGhwDbo+8/3YtzuYG4ZZGpSgpZrtvtE13 1lD9lJ32+9MgHgVgr7MwPP68Kc5tnDzWsI/teBYbUoo/O/Bf3U7y9vOiDtfVJHJN/8Op jE4SXpGBcwe7GwHWnKsVlRCF9uru53W+qOLMA8pbMgiKquXwvtXL7VYE+qRqqF4r7q4m jFY24id5CpGzFVLFAReYDNbuLG9gn1IbglgIVonMKlpOyLoSi6fe1XqQU2i690ZFqbpQ 9TsJGJKEWnOqjQb/YnLjqu6TmgYsVsicNs9eShVROjC1gNIN0j9aDGM2NnoAEFlbVRbj euEQ== 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 r8si8652450pgr.243.2019.07.08.08.48.25; Mon, 08 Jul 2019 08:48:25 -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 S2403936AbfGHPsY (ORCPT + 30 others); Mon, 8 Jul 2019 11:48:24 -0400 Received: from foss.arm.com ([217.140.110.172]:52364 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387472AbfGHPrr (ORCPT ); Mon, 8 Jul 2019 11:47:47 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3F4A61516; Mon, 8 Jul 2019 08:47:46 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3C8C33F59C; Mon, 8 Jul 2019 08:47:45 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Peng Fan , Jim Quinlan , Bo Zhang , Volodymyr Babchuk Subject: [PATCH 04/11] firmware: arm_scmi: Separate out tx buffer handling and prepare to add rx Date: Mon, 8 Jul 2019 16:47:23 +0100 Message-Id: <20190708154730.16643-5-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708154730.16643-1-sudeep.holla@arm.com> References: <20190708154730.16643-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently we pre-allocate transmit buffers only and use the first free slot in that pre-allocated buffer for transmitting any new message that are generally originated from OS to the platform firmware. Notifications or the delayed responses on the other hand are originated from the platform firmware and consumes by the OS. It's better to have separate and dedicated pre-allocated buffers to handle the notifications. We can still use the transmit buffers for the delayed responses. In addition, let's prepare existing scmi_xfer_{get,put} for acquiring and releasing a slot to identify the right(tx/rx) buffers. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/driver.c | 40 ++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 13 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index e9b762348eff..1a7ffd3f8534 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -111,7 +111,7 @@ struct scmi_chan_info { * @handle: Instance of SCMI handle to send to clients * @version: SCMI revision information containing protocol version, * implementation version and (sub-)vendor identification. - * @minfo: Message info + * @tx_minfo: Universal Transmit Message management info * @tx_idr: IDR object to map protocol id to Tx channel info pointer * @rx_idr: IDR object to map protocol id to Rx channel info pointer * @protocols_imp: List of protocols implemented, currently maximum of @@ -124,7 +124,7 @@ struct scmi_info { const struct scmi_desc *desc; struct scmi_revision_info version; struct scmi_handle handle; - struct scmi_xfers_info minfo; + struct scmi_xfers_info tx_minfo; struct idr tx_idr; struct idr rx_idr; u8 *protocols_imp; @@ -251,6 +251,7 @@ static void scmi_tx_prepare(struct mbox_client *cl, void *m) * scmi_xfer_get() - Allocate one message * * @handle: Pointer to SCMI entity handle + * @minfo: Pointer to Tx/Rx Message management info based on channel type * * Helper function which is used by various message functions that are * exposed to clients of this driver for allocating a message traffic event. @@ -261,13 +262,13 @@ static void scmi_tx_prepare(struct mbox_client *cl, void *m) * * Return: 0 if all went fine, else corresponding error. */ -static struct scmi_xfer *scmi_xfer_get(const struct scmi_handle *handle) +static struct scmi_xfer *scmi_xfer_get(const struct scmi_handle *handle, + struct scmi_xfers_info *minfo) { u16 xfer_id; struct scmi_xfer *xfer; unsigned long flags, bit_pos; struct scmi_info *info = handle_to_scmi_info(handle); - struct scmi_xfers_info *minfo = &info->minfo; /* Keep the locked section as small as possible */ spin_lock_irqsave(&minfo->xfer_lock, flags); @@ -290,18 +291,17 @@ static struct scmi_xfer *scmi_xfer_get(const struct scmi_handle *handle) } /** - * scmi_xfer_put() - Release a message + * __scmi_xfer_put() - Release a message * - * @handle: Pointer to SCMI entity handle + * @minfo: Pointer to Tx/Rx Message management info based on channel type * @xfer: message that was reserved by scmi_xfer_get * * This holds a spinlock to maintain integrity of internal data structures. */ -void scmi_xfer_put(const struct scmi_handle *handle, struct scmi_xfer *xfer) +static void +__scmi_xfer_put(struct scmi_xfers_info *minfo, struct scmi_xfer *xfer) { unsigned long flags; - struct scmi_info *info = handle_to_scmi_info(handle); - struct scmi_xfers_info *minfo = &info->minfo; /* * Keep the locked section as small as possible @@ -332,7 +332,7 @@ static void scmi_rx_callback(struct mbox_client *cl, void *m) struct scmi_chan_info *cinfo = client_to_scmi_chan_info(cl); struct device *dev = cinfo->dev; struct scmi_info *info = handle_to_scmi_info(cinfo->handle); - struct scmi_xfers_info *minfo = &info->minfo; + struct scmi_xfers_info *minfo = &info->tx_minfo; struct scmi_shared_mem __iomem *mem = cinfo->payload; xfer_id = MSG_XTRACT_TOKEN(ioread32(&mem->msg_header)); @@ -351,6 +351,19 @@ static void scmi_rx_callback(struct mbox_client *cl, void *m) complete(&xfer->done); } +/** + * scmi_xfer_put() - Release a transmit message + * + * @handle: Pointer to SCMI entity handle + * @xfer: message that was reserved by scmi_xfer_get + */ +void scmi_xfer_put(const struct scmi_handle *handle, struct scmi_xfer *xfer) +{ + struct scmi_info *info = handle_to_scmi_info(handle); + + __scmi_xfer_put(&info->tx_minfo, xfer); +} + static bool scmi_xfer_poll_done(const struct scmi_chan_info *cinfo, struct scmi_xfer *xfer) { @@ -440,7 +453,7 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) } /** - * scmi_xfer_get_init() - Allocate and initialise one message + * scmi_xfer_get_init() - Allocate and initialise one message for transmit * * @handle: Pointer to SCMI entity handle * @msg_id: Message identifier @@ -461,6 +474,7 @@ int scmi_xfer_get_init(const struct scmi_handle *handle, u8 msg_id, u8 prot_id, int ret; struct scmi_xfer *xfer; struct scmi_info *info = handle_to_scmi_info(handle); + struct scmi_xfers_info *minfo = &info->tx_minfo; struct device *dev = info->dev; /* Ensure we have sane transfer sizes */ @@ -468,7 +482,7 @@ int scmi_xfer_get_init(const struct scmi_handle *handle, u8 msg_id, u8 prot_id, tx_size > info->desc->max_msg_size) return -ERANGE; - xfer = scmi_xfer_get(handle); + xfer = scmi_xfer_get(handle, minfo); if (IS_ERR(xfer)) { ret = PTR_ERR(xfer); dev_err(dev, "failed to get free message slot(%d)\n", ret); @@ -607,7 +621,7 @@ static int scmi_xfer_info_init(struct scmi_info *sinfo) struct scmi_xfer *xfer; struct device *dev = sinfo->dev; const struct scmi_desc *desc = sinfo->desc; - struct scmi_xfers_info *info = &sinfo->minfo; + struct scmi_xfers_info *info = &sinfo->tx_minfo; /* Pre-allocated messages, no more than what hdr.seq can support */ if (WARN_ON(desc->max_msg >= MSG_TOKEN_MAX)) { From patchwork Mon Jul 8 15:47:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 168683 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7331613ilk; Mon, 8 Jul 2019 08:48:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyw90Zywz3OJbFgaGDc8+PVoKQwgLJIIpiUmG9QRi8kVsLmLgfBnuPaXBrRkz+DEZXfrksb X-Received: by 2002:a17:902:fe14:: with SMTP id g20mr24579224plj.54.1562600898027; Mon, 08 Jul 2019 08:48:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562600898; cv=none; d=google.com; s=arc-20160816; b=TxQHp73B6lMj2aCe/zWCGd3cJgeNwcZsVD7PO8JvDrIqeO5Z+KvZ0yUoPEGQdFfdbF j90IY2pkcMKICvDgMr5GResR1Bct4kqdav872BBDnYrr6Cu0A/kpI5RUqdgN1TTDOrUH QI9Zj6Z0kx51M2C/tVx9VJ3kGjw5SFJecRC7m4T0rfAIr1qxe572ed5loARxSRymjt5t HyhP3ckQ1G56GDoq2qescLgfjxrDaEPeVCqlGIrjDtgeVGZcPF8q0vCjPCdeAbKwp1S+ /2OOpSbo5oQQvIbVavxTeB2BjmHJfLv5yafPF3H1hZcCSS36xt2TUhHDnWml+eScdGyR P1sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=g/3WsBsgQJoCdVtn+mXu+FHko0OYuBudeVV55osqeOk=; b=D56i539aIJ0vGg962q942FHDziwGEwYGtR25DqgkT+iB+jHzw4J89plnkqZ/Ltpo/c 8LDZrG9T9RM7HGlq3MxFqUb+F83KPWpx3Mb0UPh4jmcnL/YQTSMz7NIjpCXwbDtAVRUi 0kCJE80Qld6dUugvHFeh+U0ORQDkjX7oV++/vtzxQ0VahHXA1fEWmmBoOrKPUG/Kz/Rj 13CjAC4LfkB2xpgmN8/O4wXcF5tyykrC0HyCUa+37kIf3g1AgnNwKtc4xGWILQwp4ieg QeSeeA72UnV+eqHL5KAy6ji/JYgfqhDUae5ngm69TSJaiK7CT9JEBMbWDudNZec4Z/ju LszQ== 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 s7si13060799plr.95.2019.07.08.08.48.17; Mon, 08 Jul 2019 08:48:18 -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 S2403926AbfGHPsQ (ORCPT + 30 others); Mon, 8 Jul 2019 11:48:16 -0400 Received: from foss.arm.com ([217.140.110.172]:52378 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391302AbfGHPrs (ORCPT ); Mon, 8 Jul 2019 11:47:48 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 75F64CFC; Mon, 8 Jul 2019 08:47:47 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 734513F59C; Mon, 8 Jul 2019 08:47:46 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Peng Fan , Jim Quinlan , Bo Zhang , Volodymyr Babchuk Subject: [PATCH 05/11] firmware: arm_scmi: Add receive buffer support for notifications Date: Mon, 8 Jul 2019 16:47:24 +0100 Message-Id: <20190708154730.16643-6-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708154730.16643-1-sudeep.holla@arm.com> References: <20190708154730.16643-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With all the plumbing in place, let's just add the separate dedicated receive buffers to handle notifications that can arrive asynchronously from the platform firmware to OS. Also add check to see if the platform supports any receive channels before allocating the receive buffers. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/driver.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 1a7ffd3f8534..eb5a2f271806 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -112,6 +112,7 @@ struct scmi_chan_info { * @version: SCMI revision information containing protocol version, * implementation version and (sub-)vendor identification. * @tx_minfo: Universal Transmit Message management info + * @rx_minfo: Universal Receive Message management info * @tx_idr: IDR object to map protocol id to Tx channel info pointer * @rx_idr: IDR object to map protocol id to Rx channel info pointer * @protocols_imp: List of protocols implemented, currently maximum of @@ -125,6 +126,7 @@ struct scmi_info { struct scmi_revision_info version; struct scmi_handle handle; struct scmi_xfers_info tx_minfo; + struct scmi_xfers_info rx_minfo; struct idr tx_idr; struct idr rx_idr; u8 *protocols_imp; @@ -615,13 +617,13 @@ int scmi_handle_put(const struct scmi_handle *handle) return 0; } -static int scmi_xfer_info_init(struct scmi_info *sinfo) +static int __scmi_xfer_info_init(struct scmi_info *sinfo, bool tx) { int i; struct scmi_xfer *xfer; struct device *dev = sinfo->dev; const struct scmi_desc *desc = sinfo->desc; - struct scmi_xfers_info *info = &sinfo->tx_minfo; + struct scmi_xfers_info *info = tx ? &sinfo->tx_minfo : &sinfo->rx_minfo; /* Pre-allocated messages, no more than what hdr.seq can support */ if (WARN_ON(desc->max_msg >= MSG_TOKEN_MAX)) { @@ -656,6 +658,16 @@ static int scmi_xfer_info_init(struct scmi_info *sinfo) return 0; } +static int scmi_xfer_info_init(struct scmi_info *sinfo) +{ + int ret = __scmi_xfer_info_init(sinfo, true); + + if (!ret && idr_find(&sinfo->rx_idr, SCMI_PROTOCOL_BASE)) + ret = __scmi_xfer_info_init(sinfo, false); + + return ret; +} + static int scmi_mailbox_check(struct device_node *np, int idx) { return of_parse_phandle_with_args(np, "mboxes", "#mbox-cells", @@ -792,10 +804,6 @@ static int scmi_probe(struct platform_device *pdev) info->desc = desc; INIT_LIST_HEAD(&info->node); - ret = scmi_xfer_info_init(info); - if (ret) - return ret; - platform_set_drvdata(pdev, info); idr_init(&info->tx_idr); idr_init(&info->rx_idr); @@ -808,6 +816,10 @@ static int scmi_probe(struct platform_device *pdev) if (ret) return ret; + ret = scmi_xfer_info_init(info); + if (ret) + return ret; + ret = scmi_base_protocol_init(handle); if (ret) { dev_err(dev, "unable to communicate with SCMI(%d)\n", ret); From patchwork Mon Jul 8 15:47:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 168678 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7331183ilk; Mon, 8 Jul 2019 08:47:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQdeDD+tICZGDu3i2/0sKbwj8UOlyyf4TE4rVEpCH/htASQGHjNkiuZxn1sxxUBj8G3wLm X-Received: by 2002:a65:44c8:: with SMTP id g8mr24502097pgs.443.1562600873812; Mon, 08 Jul 2019 08:47:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562600873; cv=none; d=google.com; s=arc-20160816; b=ZLi2QaCeMf7YenPTBc4/e5cB+2tquDM/+bVKKav+MgECkq0kyJEiCozkgPEK+Ez7i4 /NW6rsLf+2mpOhEzZw1IrdhnpcRlygV1JaRKJwXFZR7mBiqjBARv6c1QhlJcCYc6yYbW knRviVUt6CGuNNCNrOPZKc2S0k84bbkFRL0n0nxRONHl/2zzntV4aHmcGKe0G5ooiTqR wVgzuWNEd+hjSZwAlmGUCGedTv1L8h6AcxyyYYfEWDYOgAbniwKEU6fKNiXhotizlDmZ k5ZC+G7t5+mgHhWw+fcXClAn98vUbETXAUWI5ujUxTOE1mFOy0vzBD1IwPyqL7cKuDc4 H6MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=G5u18gST3P5z1dSHkdRsT03fztTeInB+nkzmjegL22I=; b=hQCsMbENmgFJjxlHHP2r3H9iQmLwQJAwgg8ZMyWDkzOZocARudP3ZsYQuExQxjI0qM 5f5NwTGN5Vd9MbWK2qszcRKnqrDnZd9yIDKAXn5SzSlGAhQqiU6tN3h40oWEJp3EhUfc +30SH0l5PkQh6KOZiSyReI8LvYbb4rqIQXjx+S62A97J2wHsE55fx+v3MiLR71IWctT4 p8fLyIkOVkgjC71BoTVlG1FmgFIL/R/TZ/DKZkuEJVOJ5+osEhUn9hlMvnJ8QPumW139 psxW1gdc+ZqCGIN9jKHavm5eYMBjrkmXsVngDBPeCIHmqXVVz52pO68jJRiTWfL8Vncl G8vg== 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 f74si19378230pfa.57.2019.07.08.08.47.53; Mon, 08 Jul 2019 08:47:53 -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 S2391336AbfGHPrw (ORCPT + 30 others); Mon, 8 Jul 2019 11:47:52 -0400 Received: from foss.arm.com ([217.140.110.172]:52386 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391308AbfGHPrt (ORCPT ); Mon, 8 Jul 2019 11:47:49 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ABE591509; Mon, 8 Jul 2019 08:47:48 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A948A3F59C; Mon, 8 Jul 2019 08:47:47 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Peng Fan , Jim Quinlan , Bo Zhang , Volodymyr Babchuk Subject: [PATCH 06/11] firmware: arm_scmi: Add mechanism to unpack message headers Date: Mon, 8 Jul 2019 16:47:25 +0100 Message-Id: <20190708154730.16643-7-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708154730.16643-1-sudeep.holla@arm.com> References: <20190708154730.16643-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to identify the message type when a response arrives, we need a mechanism to unpack the message header similar to packing. Let's add one. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/driver.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) -- 2.17.1 diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index eb5a2f271806..b384c818d8dd 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -30,8 +30,14 @@ #include "common.h" #define MSG_ID_MASK GENMASK(7, 0) +#define MSG_XTRACT_ID(hdr) FIELD_GET(MSG_ID_MASK, (hdr)) #define MSG_TYPE_MASK GENMASK(9, 8) +#define MSG_XTRACT_TYPE(hdr) FIELD_GET(MSG_TYPE_MASK, (hdr)) +#define MSG_TYPE_COMMAND 0 +#define MSG_TYPE_DELAYED_RESP 2 +#define MSG_TYPE_NOTIFICATION 3 #define MSG_PROTOCOL_ID_MASK GENMASK(17, 10) +#define MSG_XTRACT_PROT_ID(hdr) FIELD_GET(MSG_PROTOCOL_ID_MASK, (hdr)) #define MSG_TOKEN_ID_MASK GENMASK(27, 18) #define MSG_XTRACT_TOKEN(hdr) FIELD_GET(MSG_TOKEN_ID_MASK, (hdr)) #define MSG_TOKEN_MAX (MSG_XTRACT_TOKEN(MSG_TOKEN_ID_MASK) + 1) @@ -216,6 +222,18 @@ static inline u32 pack_scmi_header(struct scmi_msg_hdr *hdr) FIELD_PREP(MSG_PROTOCOL_ID_MASK, hdr->protocol_id); } +/** + * unpack_scmi_header() - unpacks and records message and protocol id + * + * @msg_hdr: 32-bit packed message header sent from the platform + * @hdr: pointer to header to fetch message and protocol id. + */ +static inline void unpack_scmi_header(u32 msg_hdr, struct scmi_msg_hdr *hdr) +{ + hdr->id = MSG_XTRACT_ID(msg_hdr); + hdr->protocol_id = MSG_XTRACT_PROT_ID(msg_hdr); +} + /** * scmi_tx_prepare() - mailbox client callback to prepare for the transfer * From patchwork Mon Jul 8 15:47:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 168684 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7331674ilk; Mon, 8 Jul 2019 08:48:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSQ+y5fdbgQI6nQth/r7W/oBmHMD8CnfjK3h7f8GQ1ze+4Q67xLqBDw1JulwA4aivODFwd X-Received: by 2002:a17:902:28e9:: with SMTP id f96mr24910610plb.114.1562600901792; Mon, 08 Jul 2019 08:48:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562600901; cv=none; d=google.com; s=arc-20160816; b=wkFm84BBXhtAT6D1lNuSVKd9Xf7yZdTwTNu76MFSQy14q68t65EZtgj36MGTjzd/ig rgp4qdnlN4r2VTCk7pixkMxdvWffQq6SAc8KqpxmF/HVoutcQFu6kDbWkGjXyFRS4FC6 vDyrVrR8u77d5WvdRL6QbgGoBmgSjSIHS/MgHZXb7FTIwqugjkd4emYy5l8yV1TlgR+b eUlQqfWGjSG+mfVGx+bjZlRuL+hFoHo3xKNHeXwytygqyJOLh+OM4h61kpSPV7Oi5FK9 Ur4E9OCXyjDGhPNTPdx9li5X+CcgEwofnuSL8+LfB2cC6bchc4pCJaNYzXd08dHzyPOz Jv0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=ISRVkqg3muPnIGnVBRuwT/HxImaeDEUdcX4kyPsUq5k=; b=uT23sLuvAkOYh/uyNrLKAcPWBji0ick6ABGEzPqmEqKSkRKcumRnvL49Nq6/hj80ce e5JxxA86o7iGhLnqvt9fVG/b53taoSisc9Y4etn4z1YSWBEz56xxfpMjL6kMkEM8arIo UK84f7vJzqcNq3xTD5OvsnsIXQdc77TkcHf52/0jOwoQselBZHvuuj3mdwCo9Ex1Umuf 7OslXyviYlF/3vhvDbOB20R8F5qv4JJNLIoo3jscEKgBf3a1zem2c059cbqKVrV+VkJW OcM62P8iGMMnZ68EvA9CeRiSZ40aYbQQG43uaisURax5/tdEBc8rEynywy6rAHNkR8x8 p3GA== 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 r8si8652450pgr.243.2019.07.08.08.48.21; Mon, 08 Jul 2019 08:48:21 -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 S2403913AbfGHPsP (ORCPT + 30 others); Mon, 8 Jul 2019 11:48:15 -0400 Received: from foss.arm.com ([217.140.110.172]:52392 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391324AbfGHPru (ORCPT ); Mon, 8 Jul 2019 11:47:50 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E2BEB360; Mon, 8 Jul 2019 08:47:49 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DFF7C3F59C; Mon, 8 Jul 2019 08:47:48 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Peng Fan , Jim Quinlan , Bo Zhang , Volodymyr Babchuk Subject: [PATCH 07/11] firmware: arm_scmi: Add support for asynchronous commands and delayed response Date: Mon, 8 Jul 2019 16:47:26 +0100 Message-Id: <20190708154730.16643-8-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708154730.16643-1-sudeep.holla@arm.com> References: <20190708154730.16643-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Messages that are sent to platform, also known as commands and can be: 1. Synchronous commands that block the channel until the requested work has been completed. The platform responds to these commands over the same channel and hence can't be used to send another command until the previous command has completed. 2. Asynchronous commands on the other hand, the platform schedules the requested work to complete later in time and returns almost immediately freeing the channel for new commands. The response indicates the success or failure in the ability to schedule the requested work. When the work has completed, the platform sends an additional delayed response message. Using the same transmit buffer used for sending the asynchronous command even for the delayed response corresponding to it simplifies handling of the delayed response. It's the caller of asynchronous command that is responsible for allocating the completion flag that scmi driver can complete to indicate the arrival of delayed response. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/common.h | 6 ++++- drivers/firmware/arm_scmi/driver.c | 43 ++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h index 4349d836b392..f89fa3f74a6f 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -84,17 +84,21 @@ struct scmi_msg { * @rx: Receive message, the buffer should be pre-allocated to store * message. If request-ACK protocol is used, we can reuse the same * buffer for the rx path as we use for the tx path. - * @done: completion event + * @done: command message transmit completion event + * @async: pointer to delayed response message received event completion */ struct scmi_xfer { struct scmi_msg_hdr hdr; struct scmi_msg tx; struct scmi_msg rx; struct completion done; + struct completion *async_done; }; void scmi_xfer_put(const struct scmi_handle *h, struct scmi_xfer *xfer); int scmi_do_xfer(const struct scmi_handle *h, struct scmi_xfer *xfer); +int scmi_do_xfer_with_response(const struct scmi_handle *h, + struct scmi_xfer *xfer); 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); int scmi_handle_put(const struct scmi_handle *handle); diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index b384c818d8dd..049bb4af6b60 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -347,6 +347,8 @@ __scmi_xfer_put(struct scmi_xfers_info *minfo, struct scmi_xfer *xfer) */ static void scmi_rx_callback(struct mbox_client *cl, void *m) { + u8 msg_type; + u32 msg_hdr; u16 xfer_id; struct scmi_xfer *xfer; struct scmi_chan_info *cinfo = client_to_scmi_chan_info(cl); @@ -355,7 +357,12 @@ static void scmi_rx_callback(struct mbox_client *cl, void *m) struct scmi_xfers_info *minfo = &info->tx_minfo; struct scmi_shared_mem __iomem *mem = cinfo->payload; - xfer_id = MSG_XTRACT_TOKEN(ioread32(&mem->msg_header)); + msg_hdr = ioread32(&mem->msg_header); + msg_type = MSG_XTRACT_TYPE(msg_hdr); + xfer_id = MSG_XTRACT_TOKEN(msg_hdr); + + if (msg_type == MSG_TYPE_NOTIFICATION) + return; /* Notifications not yet supported */ /* Are we even expecting this? */ if (!test_bit(xfer_id, minfo->xfer_alloc_table)) { @@ -368,7 +375,11 @@ static void scmi_rx_callback(struct mbox_client *cl, void *m) scmi_dump_header_dbg(dev, &xfer->hdr); scmi_fetch_response(xfer, mem); - complete(&xfer->done); + + if (msg_type == MSG_TYPE_DELAYED_RESP) + complete(xfer->async_done); + else + complete(&xfer->done); } /** @@ -472,6 +483,34 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) return ret; } +#define SCMI_MAX_RESPONSE_TIMEOUT (2 * MSEC_PER_SEC) + +/** + * scmi_do_xfer_with_response() - Do one transfer and wait until the delayed + * response is received + * + * @handle: Pointer to SCMI entity handle + * @xfer: Transfer to initiate and wait for response + * + * Return: -ETIMEDOUT in case of no delayed response, if transmit error, + * return corresponding error, else if all goes well, return 0. + */ +int scmi_do_xfer_with_response(const struct scmi_handle *handle, + struct scmi_xfer *xfer) +{ + int ret, timeout = msecs_to_jiffies(SCMI_MAX_RESPONSE_TIMEOUT); + DECLARE_COMPLETION_ONSTACK(async_response); + + xfer->async_done = &async_response; + + ret = scmi_do_xfer(handle, xfer); + if (!ret && !wait_for_completion_timeout(xfer->async_done, timeout)) + ret = -ETIMEDOUT; + + xfer->async_done = NULL; + return ret; +} + /** * scmi_xfer_get_init() - Allocate and initialise one message for transmit * From patchwork Mon Jul 8 15:47:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 168679 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7331250ilk; Mon, 8 Jul 2019 08:47:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzL4a1g/HPQS7Wk4s8+C2bd7otuk83x3fsgciTQNa6oBE0VjZnGS1ojwpXCXUQDSnR6ti9n X-Received: by 2002:a17:90a:30aa:: with SMTP id h39mr26770258pjb.32.1562600877668; Mon, 08 Jul 2019 08:47:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562600877; cv=none; d=google.com; s=arc-20160816; b=N78qwX5TSffQnYR19hYe7BErRgdlUcC8FARZPlHqtH+7FN2Pp92IwDvRMmGc4FNzIB IxFTu3M+i/mNbYP35bf84/WXxnoGmSG9nvUkXdf0v0vWlSMduUEDpkTArjw3FjU3j1Tb uFIZkkly7jPnyI3IzT5bwpHdr0+4Agrh6cVsWZyw8sUQq9hHvsuG1CMlqQQ+yUM5FWFA Ng4KKGh3WTXHoCBa9pkuJkd/PkF035I3xqYX37tEOWcWhU17CX9sNsWTLapsg466L5E2 BaRGc1JEdW7KRo/RM1HyeRbtUbAu+UTAbl/15zJABAqiyssF1Anb9u/d/PmxID4P/Hzp YTlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=hWVHrvg8mnc4KCnKydbF/kcrPYGf3kaxW2vh1Bg1glM=; b=XIF0DcGEPX39a+H0xWbi0bwi2UtVtJq8RPqNB4T0n5WIg8gjckdgm5VZ3I0S6v3f8y W6S4ScE/HjdMuWCSoxXKgrMMz096l2Otlrlt1PZqZaXc/GMHEMEhhL+k5jYZHPG/MSGb lTzuSEOU9GQtffPGbnVsgwelBVMpcoyGzYgmuf7PqKtQyDSXXLtGG0/Yrr3J5FDeKjpx fwW1t1rVBix3JWWoanzRez/Yik1Vo3A1zqwThs2+j3hCE/FZv2HieOP2WaACFcugXOlz OA0GoGC/C7WLdRmo2foTLatu5sG0fEN7pRqyRX6poLUufpw5d2xi7HU+I5d9OElnnglf Mbcw== 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 f74si19378230pfa.57.2019.07.08.08.47.57; Mon, 08 Jul 2019 08:47: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 S2391361AbfGHPrz (ORCPT + 30 others); Mon, 8 Jul 2019 11:47:55 -0400 Received: from foss.arm.com ([217.140.110.172]:52400 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391330AbfGHPrw (ORCPT ); Mon, 8 Jul 2019 11:47:52 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5BF301516; Mon, 8 Jul 2019 08:47:51 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 22E9F3F59C; Mon, 8 Jul 2019 08:47:50 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Peng Fan , Jim Quinlan , Bo Zhang , Volodymyr Babchuk , Guenter Roeck , linux-hwmon@vger.kernel.org Subject: [PATCH 08/11] firmware: arm_scmi: Drop async flag in sensor_ops->reading_get Date: Mon, 8 Jul 2019 16:47:27 +0100 Message-Id: <20190708154730.16643-9-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708154730.16643-1-sudeep.holla@arm.com> References: <20190708154730.16643-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org SENSOR_DESCRIPTION_GET provides attributes to indicate if the sensor supports asynchronous read. Ideally we should be able to read that flag and use asynchronous reads for any sensors with that attribute set. In order to add that support, let's drop the async flag passed to sensor_ops->reading_get and dynamically switch between sync and async flags based on the attributes as provided by the firmware. Cc: Guenter Roeck Cc: linux-hwmon@vger.kernel.org Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/sensors.c | 4 ++-- drivers/hwmon/scmi-hwmon.c | 2 +- include/linux/scmi_protocol.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) -- 2.17.1 Acked-by: Guenter Roeck diff --git a/drivers/firmware/arm_scmi/sensors.c b/drivers/firmware/arm_scmi/sensors.c index 17dbabd8a94a..1b5757c77a35 100644 --- a/drivers/firmware/arm_scmi/sensors.c +++ b/drivers/firmware/arm_scmi/sensors.c @@ -211,7 +211,7 @@ scmi_sensor_trip_point_config(const struct scmi_handle *handle, u32 sensor_id, } static int scmi_sensor_reading_get(const struct scmi_handle *handle, - u32 sensor_id, bool async, u64 *value) + u32 sensor_id, u64 *value) { int ret; struct scmi_xfer *t; @@ -225,7 +225,7 @@ static int scmi_sensor_reading_get(const struct scmi_handle *handle, sensor = t->tx.buf; sensor->id = cpu_to_le32(sensor_id); - sensor->flags = cpu_to_le32(async ? SENSOR_READ_ASYNC : 0); + sensor->flags = cpu_to_le32(0); ret = scmi_do_xfer(handle, t); if (!ret) { diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c index 0c93fc5ca762..8a7732c0bef3 100644 --- a/drivers/hwmon/scmi-hwmon.c +++ b/drivers/hwmon/scmi-hwmon.c @@ -72,7 +72,7 @@ static int scmi_hwmon_read(struct device *dev, enum hwmon_sensor_types type, const struct scmi_handle *h = scmi_sensors->handle; sensor = *(scmi_sensors->info[type] + channel); - ret = h->sensor_ops->reading_get(h, sensor->id, false, &value); + ret = h->sensor_ops->reading_get(h, sensor->id, &value); if (ret) return ret; diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index ea6b72018752..697e30fb9004 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -182,7 +182,7 @@ struct scmi_sensor_ops { int (*trip_point_config)(const struct scmi_handle *handle, u32 sensor_id, u8 trip_id, u64 trip_value); int (*reading_get)(const struct scmi_handle *handle, u32 sensor_id, - bool async, u64 *value); + u64 *value); }; /** From patchwork Mon Jul 8 15:47:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 168682 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7331515ilk; Mon, 8 Jul 2019 08:48:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqy+rSrNrPAWvLod2D414ymwu4nkL9NcTbpBFmbr9Cncl1jNbOJnfEErjSEMgPkFiALEGC4U X-Received: by 2002:a63:1046:: with SMTP id 6mr25546746pgq.111.1562600891873; Mon, 08 Jul 2019 08:48:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562600891; cv=none; d=google.com; s=arc-20160816; b=hZHIoKtjAE1obOgIcVi8tNLi1CzDtqMEjp+pRW7GxcNVQ5xkLDYloMgFtAotPh9wX2 r1ErO0IHsvp1IjMDvx5rL0xiRiboej6v8lpazHOjCD4dq4l+f0qVVvxq5CZ0XjleBlP8 Hd1stBx7DzTOSX4TFEPszEqyXPYoHeh+UTipBc2a0fmCURWRelAYkyYb1QbY7SMF63Tr lUj3p4NC04u1rXI8B1IdFA3ytpTjYJ3L+5WT9JNTcDzWUmy4JP9NrCldKrKJ2eyQ/p73 Caq0GuC5Zb0L9zsqcc0ukgSBRnP9Y1ucQDm9tud3/hkTL2ThkhQhS0w6PVzm0wjDhrPr uPCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=A14YQaT5MvNTyqXk+fqrk3dMHZRdkvpc6074AquUoyQ=; b=KHMnr0rvSqVabzS5UqrjKG8wt7lOE4L9FdK90RePmIf+0E4q3i0vspt//jtll8tnTW SKQEM2b8I3MS1DedsTtTp91WzGxBXmvu+4lR1BBR4Srr0kTBsnFyY24cX/sy9VVY0G/b /kou8d2heEe5WyTyEF10l+shWppPkHX74cjjgrOaixU5DiqWtt0mGdac6dAxLFjpFmG7 LKjPUydGYkuKr0qpgi4ztEXrCkGEPG8CXuzyIyNlcLQfZLOhan1tLnH4B2SCPhbLxbfg DM1hzk73SI5erZmf0JiBqvbFlrmw97tDYxyfuETLdaCvnJ/TdZYRxg1l9xfoPbbRb4wJ qoAA== 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 s7si13060799plr.95.2019.07.08.08.48.11; Mon, 08 Jul 2019 08:48:11 -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 S2388299AbfGHPsK (ORCPT + 30 others); Mon, 8 Jul 2019 11:48:10 -0400 Received: from foss.arm.com ([217.140.110.172]:52412 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391308AbfGHPrx (ORCPT ); Mon, 8 Jul 2019 11:47:53 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 941A7152B; Mon, 8 Jul 2019 08:47:52 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8FD363F59C; Mon, 8 Jul 2019 08:47:51 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Peng Fan , Jim Quinlan , Bo Zhang , Volodymyr Babchuk Subject: [PATCH 09/11] firmware: arm_scmi: Add asynchronous sensor read if it supports Date: Mon, 8 Jul 2019 16:47:28 +0100 Message-Id: <20190708154730.16643-10-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708154730.16643-1-sudeep.holla@arm.com> References: <20190708154730.16643-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org SENSOR_DESCRIPTION_GET provides attributes to indicate if the sensor supports asynchronous read. We can read that flag and use asynchronous reads for any sensors with that attribute set. Let's use the new scmi_do_xfer_with_response to support asynchronous sensor reads. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/sensors.c | 30 +++++++++++++++++++++-------- include/linux/scmi_protocol.h | 2 ++ 2 files changed, 24 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/arm_scmi/sensors.c b/drivers/firmware/arm_scmi/sensors.c index 1b5757c77a35..b8f226a365de 100644 --- a/drivers/firmware/arm_scmi/sensors.c +++ b/drivers/firmware/arm_scmi/sensors.c @@ -136,9 +136,10 @@ static int scmi_sensor_description_get(const struct scmi_handle *handle, } for (cnt = 0; cnt < num_returned; cnt++) { - u32 attrh; + u32 attrh, attrl; struct scmi_sensor_info *s; + attrl = le32_to_cpu(buf->desc[cnt].attributes_low); attrh = le32_to_cpu(buf->desc[cnt].attributes_high); s = &si->sensors[desc_index + cnt]; s->id = le32_to_cpu(buf->desc[cnt].id); @@ -147,6 +148,8 @@ static int scmi_sensor_description_get(const struct scmi_handle *handle, /* Sign extend to a full s8 */ if (s->scale & SENSOR_SCALE_SIGN) s->scale |= SENSOR_SCALE_EXTEND; + s->async = SUPPORTS_ASYNC_READ(attrl); + s->num_trip_points = NUM_TRIP_POINTS(attrl); strlcpy(s->name, buf->desc[cnt].name, SCMI_MAX_STR_SIZE); } @@ -214,8 +217,11 @@ static int scmi_sensor_reading_get(const struct scmi_handle *handle, u32 sensor_id, u64 *value) { int ret; + __le32 *pval; struct scmi_xfer *t; struct scmi_msg_sensor_reading_get *sensor; + struct sensors_info *si = handle->sensor_priv; + struct scmi_sensor_info *s = si->sensors + sensor_id; ret = scmi_xfer_get_init(handle, SENSOR_READING_GET, SCMI_PROTOCOL_SENSOR, sizeof(*sensor), @@ -223,16 +229,24 @@ static int scmi_sensor_reading_get(const struct scmi_handle *handle, if (ret) return ret; + pval = t->rx.buf; sensor = t->tx.buf; sensor->id = cpu_to_le32(sensor_id); - sensor->flags = cpu_to_le32(0); - - ret = scmi_do_xfer(handle, t); - if (!ret) { - __le32 *pval = t->rx.buf; - *value = le32_to_cpu(*pval); - *value |= (u64)le32_to_cpu(*(pval + 1)) << 32; + if (s->async) { + sensor->flags = cpu_to_le32(SENSOR_READ_ASYNC); + ret = scmi_do_xfer_with_response(handle, t); + if (!ret) { + *value = le32_to_cpu(*pval + 1); + *value |= (u64)le32_to_cpu(*(pval + 2)) << 32; + } + } else { + sensor->flags = cpu_to_le32(0); + ret = scmi_do_xfer(handle, t); + if (!ret) { + *value = le32_to_cpu(*pval); + *value |= (u64)le32_to_cpu(*(pval + 1)) << 32; + } } scmi_xfer_put(handle, t); diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 697e30fb9004..1be16d7730e2 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -145,6 +145,8 @@ struct scmi_sensor_info { u32 id; u8 type; s8 scale; + u8 num_trip_points; + bool async; char name[SCMI_MAX_STR_SIZE]; }; From patchwork Mon Jul 8 15:47:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 168681 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7331395ilk; Mon, 8 Jul 2019 08:48:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/q/rN70BtqfRPP+qm2tmCHp/2Vl9arFNNZ0CZhKpNQP9zUDLZL7Tbz4/Goshw91kmqSIj X-Received: by 2002:a17:90a:2488:: with SMTP id i8mr26147139pje.123.1562600885454; Mon, 08 Jul 2019 08:48:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562600885; cv=none; d=google.com; s=arc-20160816; b=Q2XUiccoVe2gxaQ2bFHH+bGRvSp4SpJI5gJEXyXnDihMR6UfzgZgZflQBbal1WkyiG 9vf9B/gyVEePi1Kn0S0H54yIE5sqCbYQFVr9Gk8Z/X1Jqa6AdCoOekH2rHJ+KqD7r9PE OehuL2R/vfksozkThBaGSW2qwW2eHMo6wxxLPGSJkOU1oVanhPaNMlla1WTdKntkTKRM WK0FarO6dRN5ClTBg3qq0SKqNwA3/AzVPc8aUz7O6OKfBgYDkpEGYfofsfoyEctz1fEE bqUQM5PnpjunZJFlV2O7AEsRD6KD0hGrxs3d+l4RBIhuTnaGcwkC6saMYOcP+ivkF/0F zTBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=4RyTSizP+zkYJs/Fjy2ds8UgeZgC74oNNcWH+B8xxLE=; b=t7cEwVnRQ/dcFO22eEKT9HKF4rx/cCTszN/Sq2rJFg29YnxSNCpqxY8hLLDLgOdBBj Q0FiNgY8peKV4/fg51yvM9hEzbbn+9qlAmCvtq4yStwB/MeHnW5ez/Tu8aRRxJkJsQYF pMtUTbFSeCHezxcA8dtuk3juereKa6NG+uQev/dgbxQVfrZNkUC4/5/nNYahFO5M4GqN +85tod1i5KXxPKHiyDLGL3HHh44Ivj1emLsZKXS2tE6R8AJX4wJ8ajPwGxMmp2lI/9PC qpW+XEo98W0GiQ9LEsjKXt0PuxKtekHXJuYMAy6f/XxvgV91veXz7mpeXvQtFDPXwJqS 3+6A== 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 n187si18384414pgn.362.2019.07.08.08.48.05; Mon, 08 Jul 2019 08:48:05 -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 S2391406AbfGHPsD (ORCPT + 30 others); Mon, 8 Jul 2019 11:48:03 -0400 Received: from foss.arm.com ([217.140.110.172]:52420 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391341AbfGHPry (ORCPT ); Mon, 8 Jul 2019 11:47:54 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0C12B360; Mon, 8 Jul 2019 08:47:54 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C750F3F59C; Mon, 8 Jul 2019 08:47:52 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Peng Fan , Jim Quinlan , Bo Zhang , Volodymyr Babchuk , Stephen Boyd , linux-clk@vger.kernel.org Subject: [PATCH 10/11] firmware: arm_scmi: Drop config flag in clk_ops->rate_set Date: Mon, 8 Jul 2019 16:47:29 +0100 Message-Id: <20190708154730.16643-11-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708154730.16643-1-sudeep.holla@arm.com> References: <20190708154730.16643-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org CLOCK_PROTOCOL_ATTRIBUTES provides attributes to indicate the maximum number of pending asynchronous clock rate changes supported by the platform. If it's non-zero, then we should be able to use asynchronous clock rate set for any clocks until the maximum limit is reached. In order to add that support, let's drop the config flag passed to clk_ops->rate_set and handle the asynchronous requests dynamically. Cc: Stephen Boyd Cc: linux-clk@vger.kernel.org Signed-off-by: Sudeep Holla --- drivers/clk/clk-scmi.c | 2 +- drivers/firmware/arm_scmi/clock.c | 4 ++-- include/linux/scmi_protocol.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) -- 2.17.1 Acked-by: Stephen Boyd diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c index a2287c770d5c..886f7c5df51a 100644 --- a/drivers/clk/clk-scmi.c +++ b/drivers/clk/clk-scmi.c @@ -69,7 +69,7 @@ static int scmi_clk_set_rate(struct clk_hw *hw, unsigned long rate, { struct scmi_clk *clk = to_scmi_clk(hw); - return clk->handle->clk_ops->rate_set(clk->handle, clk->id, 0, rate); + return clk->handle->clk_ops->rate_set(clk->handle, clk->id, rate); } static int scmi_clk_enable(struct clk_hw *hw) diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c index 0a194af92438..dd215bd11a58 100644 --- a/drivers/firmware/arm_scmi/clock.c +++ b/drivers/firmware/arm_scmi/clock.c @@ -218,7 +218,7 @@ scmi_clock_rate_get(const struct scmi_handle *handle, u32 clk_id, u64 *value) } static int scmi_clock_rate_set(const struct scmi_handle *handle, u32 clk_id, - u32 config, u64 rate) + u64 rate) { int ret; struct scmi_xfer *t; @@ -230,7 +230,7 @@ static int scmi_clock_rate_set(const struct scmi_handle *handle, u32 clk_id, return ret; cfg = t->tx.buf; - cfg->flags = cpu_to_le32(config); + cfg->flags = cpu_to_le32(0); cfg->id = cpu_to_le32(clk_id); cfg->value_low = cpu_to_le32(rate & 0xffffffff); cfg->value_high = cpu_to_le32(rate >> 32); diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 1be16d7730e2..1694ee1b410e 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -71,7 +71,7 @@ struct scmi_clk_ops { int (*rate_get)(const struct scmi_handle *handle, u32 clk_id, u64 *rate); int (*rate_set)(const struct scmi_handle *handle, u32 clk_id, - u32 config, u64 rate); + u64 rate); int (*enable)(const struct scmi_handle *handle, u32 clk_id); int (*disable)(const struct scmi_handle *handle, u32 clk_id); }; From patchwork Mon Jul 8 15:47:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 168680 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7331308ilk; Mon, 8 Jul 2019 08:48:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzh7SPk/VUArviIJd8U+l+VMBAZONsTQgzhzp4fYFzln4tO8fWicAVho9muAadKbVOiiJPl X-Received: by 2002:a63:c508:: with SMTP id f8mr25192129pgd.48.1562600880965; Mon, 08 Jul 2019 08:48:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562600880; cv=none; d=google.com; s=arc-20160816; b=NpovHvK4pGG897JfBzCjp3/tXGUFBoq6pg18TkS08qROrBUFNp4eUF9zoNigqWBvmD atBJbgPQGO/OZy2rmFpdnbc5K4PJYoPh7fnjXaRPveAIltluaWPPJF9sw9YreqUQe08F Bi/00/LxYrJb+aE35CZDWu531s4u6QYVFJn8R+weOSxd46yFfNL6EtUTIpKuLUiVHHcU mpw02wOWPgYsiLb9tiJ1Hj2nkRMHZ6faEnvfAQq/USCgXEwvDpwco4tyJ8dgZ8uEj/o1 HbQ5nJpMOol/ygqshN4KZnIYBsMvBPBze9GPa6Gcwjp+5wiMqozmCiJItv0fWW4UV4SX z24w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=1ErbM/I6OV9NXtunUPFjTaTSw8ruJxHurmMAz0mWtLk=; b=udLQQMw6Iv1EBDCxBoDAxpp76OgjK5EsCL3RT0ONYDD5X4hhuVE9LxdFrPHek5UMiD fXwyPjMPdGzgYsOHf9xn9Yp5UiOlNsOArxvOE4FmcE+eA3N652f5SytD6zXfyWmFTq7M 8AsMrUt59OweykLFGQBpiRzDGe4Ax7/NJIdYpJvyaUTtYZyhiEpZ7FTop8j47TnDVSmx UmYkZ1Cz+twI4/x6Q17gWNeRdPkY2dHINsw3Do8Evcg97Kl9QBnSFsNVn7Z3dB7Lqa/U LFQDgg2b1kVJHMpFQ6aTfEcEsqX3kYj+xrlFtfrLqe988BPy/FnyQNbblLRa1ZmUvoBz 93Hw== 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 n187si18384414pgn.362.2019.07.08.08.48.00; Mon, 08 Jul 2019 08:48:00 -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 S2391381AbfGHPr7 (ORCPT + 30 others); Mon, 8 Jul 2019 11:47:59 -0400 Received: from foss.arm.com ([217.140.110.172]:52426 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391358AbfGHPrz (ORCPT ); Mon, 8 Jul 2019 11:47:55 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 428EDCFC; Mon, 8 Jul 2019 08:47:55 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3FB5A3F59C; Mon, 8 Jul 2019 08:47:54 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Peng Fan , Jim Quinlan , Bo Zhang , Volodymyr Babchuk Subject: [PATCH 11/11] firmware: arm_scmi: Use asynchronous CLOCK_RATE_SET when possible Date: Mon, 8 Jul 2019 16:47:30 +0100 Message-Id: <20190708154730.16643-12-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708154730.16643-1-sudeep.holla@arm.com> References: <20190708154730.16643-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org CLOCK_PROTOCOL_ATTRIBUTES provides attributes to indicate the maximum number of pending asynchronous clock rate changes supported by the platform. If it's non-zero, then we should be able to use asynchronous clock rate set for any clocks until the maximum limit is reached. Keeping the current count of pending asynchronous clock set rate requests, we can decide if we can you asynchronous request for the incoming/new request. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/clock.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c index dd215bd11a58..70044b7c812e 100644 --- a/drivers/firmware/arm_scmi/clock.c +++ b/drivers/firmware/arm_scmi/clock.c @@ -56,7 +56,7 @@ struct scmi_msg_resp_clock_describe_rates { struct scmi_clock_set_rate { __le32 flags; #define CLOCK_SET_ASYNC BIT(0) -#define CLOCK_SET_DELAYED BIT(1) +#define CLOCK_SET_IGNORE_RESP BIT(1) #define CLOCK_SET_ROUND_UP BIT(2) #define CLOCK_SET_ROUND_AUTO BIT(3) __le32 id; @@ -67,6 +67,7 @@ struct scmi_clock_set_rate { struct clock_info { int num_clocks; int max_async_req; + atomic_t cur_async_req; struct scmi_clock_info *clk; }; @@ -221,21 +222,35 @@ static int scmi_clock_rate_set(const struct scmi_handle *handle, u32 clk_id, u64 rate) { int ret; + u32 flags = 0; struct scmi_xfer *t; struct scmi_clock_set_rate *cfg; + struct clock_info *ci = handle->clk_priv; ret = scmi_xfer_get_init(handle, CLOCK_RATE_SET, SCMI_PROTOCOL_CLOCK, sizeof(*cfg), 0, &t); if (ret) return ret; + if (ci->max_async_req) { + if (atomic_inc_return(&ci->cur_async_req) < ci->max_async_req) + flags |= CLOCK_SET_ASYNC; + else + atomic_dec(&ci->cur_async_req); + } + cfg = t->tx.buf; - cfg->flags = cpu_to_le32(0); + cfg->flags = cpu_to_le32(flags); cfg->id = cpu_to_le32(clk_id); cfg->value_low = cpu_to_le32(rate & 0xffffffff); cfg->value_high = cpu_to_le32(rate >> 32); - ret = scmi_do_xfer(handle, t); + if (flags & CLOCK_SET_ASYNC) { + ret = scmi_do_xfer_with_response(handle, t); + atomic_dec(&ci->cur_async_req); + } else { + ret = scmi_do_xfer(handle, t); + } scmi_xfer_put(handle, t); return ret;