From patchwork Tue Dec 12 23:58:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 121688 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4785696qgn; Tue, 12 Dec 2017 16:00:36 -0800 (PST) X-Google-Smtp-Source: ACJfBougybTxJDD0LmeVMxC+M1CptJov1KD9psj5WU506AoExNzKSXfrqDVA4YXEOQ235eyY54J6 X-Received: by 10.84.234.135 with SMTP id n7mr3785686plk.298.1513123236497; Tue, 12 Dec 2017 16:00:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513123236; cv=none; d=google.com; s=arc-20160816; b=HB1ScNaRGp3n6lpszQQyNlYvNeTy/b9uHj0Hl2EEDzdMkQGnpVoyaYKnYLjPhXhd7x vLH8CwouKaIvUwdLglAhoOLtzCDtX3Zpw1sReJwuS6Oke+YBStYQjcSjUmUDZgVLHBjc 9mKIUGPE27MhM8XQXiSJPicvxGH46qgl4Vq1ee1ExiqsgTrFHzsJXsCva1lbzJt2Jn/c 2ATbaduTVrWm/vZ6rKyY46w5Qm1e6RRXQUFwYS+ZLu/E0+Ll2Jm2D2ta5PYZS66c3Wh7 rl5t/UsLr3gDX0Tnm43pnApMftl+xTJRVFz1V7bpWLe3zDC5UJ9vHnDZi87bnqSzpdB8 qkHw== 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:dkim-signature:arc-authentication-results; bh=YXR+Zj6Z1qfQPkK/HMLffsyX/njqlb19NyAECCzfFcs=; b=l4zgHDbfZ4w3nYm0BoAHliu0wVLkL3BkvAa6paO0GqfXFMSnu6yAONeWz97yL4pZ6y HU2biq/0rd8BPCuA+vrxFTzpgoDplefwuckUGulILPRV9d0/obdfSDsLvRBwjft1lp8j K9xYKinx0SCVg1RlfVIE7bJsiguZufGts65PTLSy5oE68wwqmptlw5jrY1L658wT++3B giR2NbAKJ6NqdMxeYtthMFhBSjlqh3GY0ndY7jShvOquZbQEg/y3V4bCcCGHBOovVhGW aQPVExOO9b49gEcdO1LCeax5xymmN5FzdEnWXEA8kK0qXrvL7N7Lflz8n8cjA0VWAJh5 P4XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fxhuJf+C; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ba12si247680plb.784.2017.12.12.16.00.36; Tue, 12 Dec 2017 16:00:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fxhuJf+C; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752875AbdLMAAf (ORCPT + 10 others); Tue, 12 Dec 2017 19:00:35 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:43633 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752822AbdLLX7C (ORCPT ); Tue, 12 Dec 2017 18:59:02 -0500 Received: by mail-pf0-f196.google.com with SMTP id e3so482559pfi.10 for ; Tue, 12 Dec 2017 15:59:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Hu6BsG1JTKNbTp7QNPwW5B/ymudxfxLU+z44D53QaMI=; b=fxhuJf+C9nPyMzJiU8YLwlnmX5HEA8xy7f/GqeIVQVqJT10pYSKzmrQbu5KOc+gne/ HVLhmfO9C2eY+pHk4A4lBZQZPzW+gOauKE4whHIBh1z6knW+OturQkqMLDSjbC8Bd9Ql jLYu7HVUk6l2+kUEYuyDLU7PnC8CDqPYYepPA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Hu6BsG1JTKNbTp7QNPwW5B/ymudxfxLU+z44D53QaMI=; b=elLxMTz01sGEVclPLtAbeZUcN1hNklK+pYfnObJx9W9HpAW/kMoAU5KWKrZOpKypC/ tozeH5mSD8TE+AqYXJBh7qRvPbRxCAmvrzUyuBAO4WSxIIVSs95gi2jdbA+CpZYozDlG tf1b3XfW1Be8YPIi5U1h1iVi9cmPPaX3Sh+xvv1aWskxxmlCm6emnes40YwH8jQymM9p 3iPxP5u1p39TNXnx1NTP94Rm24NRfmTJw+aNejR/SQ4BQFuSIu3xJKqJz527QNKGtlf0 G6mK22CbsC7P2PrvLxHtTfivxvlbCFqqDtTilC/iPsVHMuVndff+X8lWjfbhhiK4lRFV KHFg== X-Gm-Message-State: AKGB3mLHTdZY0eW7LpN/EMpMZOp3zjGa4QGewD0K5gCa6sHK+o5NizTy P5dRonDfvSTYViEmMtpJQQrXQernY9Y= X-Received: by 10.84.128.36 with SMTP id 33mr4027181pla.329.1513123141704; Tue, 12 Dec 2017 15:59:01 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id t202sm270317pgb.75.2017.12.12.15.59.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 15:59:01 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson , Jeremy McNicoll , Will Newton Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Chris Lew Subject: [PATCH 1/5] rpmsg: smd: Perform handshake during open Date: Tue, 12 Dec 2017 15:58:53 -0800 Message-Id: <20171212235857.10432-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171212235857.10432-1-bjorn.andersson@linaro.org> References: <20171212235857.10432-1-bjorn.andersson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Validate the the remote side is opening the channel that we've found by performing a handshake when opening the channel. Signed-off-by: Bjorn Andersson --- drivers/rpmsg/qcom_smd.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) -- 2.15.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c index b01774e9fac0..58dd44493420 100644 --- a/drivers/rpmsg/qcom_smd.c +++ b/drivers/rpmsg/qcom_smd.c @@ -200,6 +200,7 @@ struct qcom_smd_channel { char *name; enum smd_channel_state state; enum smd_channel_state remote_state; + wait_queue_head_t state_change_event; struct smd_channel_info_pair *info; struct smd_channel_info_word_pair *info_word; @@ -570,6 +571,8 @@ static bool qcom_smd_channel_intr(struct qcom_smd_channel *channel) if (remote_state != channel->remote_state) { channel->remote_state = remote_state; need_state_scan = true; + + wake_up_interruptible_all(&channel->state_change_event); } /* Indicate that we have seen any state change */ SET_RX_CHANNEL_FLAG(channel, fSTATE, 0); @@ -786,7 +789,9 @@ static int __qcom_smd_send(struct qcom_smd_channel *channel, const void *data, static int qcom_smd_channel_open(struct qcom_smd_channel *channel, rpmsg_rx_cb_t cb) { + struct qcom_smd_edge *edge = channel->edge; size_t bb_size; + int ret; /* * Packets are maximum 4k, but reduce if the fifo is smaller @@ -798,9 +803,33 @@ static int qcom_smd_channel_open(struct qcom_smd_channel *channel, qcom_smd_channel_set_callback(channel, cb); qcom_smd_channel_set_state(channel, SMD_CHANNEL_OPENING); + + /* Wait for remote to enter opening or opened */ + ret = wait_event_interruptible_timeout(channel->state_change_event, + channel->remote_state == SMD_CHANNEL_OPENING || + channel->remote_state == SMD_CHANNEL_OPENED, + HZ); + if (!ret) { + dev_err(&edge->dev, "remote side did not enter opening state\n"); + goto out_close_timeout; + } + qcom_smd_channel_set_state(channel, SMD_CHANNEL_OPENED); + /* Wait for remote to enter opened */ + ret = wait_event_interruptible_timeout(channel->state_change_event, + channel->remote_state == SMD_CHANNEL_OPENED, + HZ); + if (!ret) { + dev_err(&edge->dev, "remote side did not enter open state\n"); + goto out_close_timeout; + } + return 0; + +out_close_timeout: + qcom_smd_channel_set_state(channel, SMD_CHANNEL_CLOSED); + return -ETIMEDOUT; } /* @@ -1055,6 +1084,7 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed mutex_init(&channel->tx_lock); spin_lock_init(&channel->recv_lock); init_waitqueue_head(&channel->fblockread_event); + init_waitqueue_head(&channel->state_change_event); info = qcom_smem_get(edge->remote_pid, smem_info_item, &info_size); if (IS_ERR(info)) { From patchwork Tue Dec 12 23:58:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 121684 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4784282qgn; Tue, 12 Dec 2017 15:59:14 -0800 (PST) X-Google-Smtp-Source: ACJfBovKPDGz0fSAsMSgGlMpjrWAfq3g8JxEIJ27J1L6tg7OknJc1FZXKCnoVR1kjh9NEmuB3//1 X-Received: by 10.101.87.196 with SMTP id q4mr3538940pgr.97.1513123154544; Tue, 12 Dec 2017 15:59:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513123154; cv=none; d=google.com; s=arc-20160816; b=i9Lvyw1R2UHlrJSx0Xj9t7u7hI3SSP88sQisAHvn2ZNv6GTXwrf+Q7IPtvTrwHf1oJ 6a96J5WYqgp0ykWnx7M90jnGnKODY1nl7BeFXpZGc4RnjoHtLZOcHn+eFspeyJIZ1wij YHMW3ppZv6xG1x+JKs7axjXBhTn5TtJzaCkYxtVaHnuTionIp6SwNxFtqsNUo4lDDVYt HSF9BtwKvJkiP8khfXpXWc3PE+83b9f+mYgvDjovc7kdxb4MtwXiNYCywWVBZjaK84V1 wlbDZ4mH3kzQ/+5E/XR2NbgdVk0ZM1j2ctx/D5F2dvvKDtUA3udBjexG7XFAAVHuxGE2 MVxA== 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:dkim-signature:arc-authentication-results; bh=Ws7Tm2fA9PsyubP+rHSWsFC9zySk3ypJJbP9VCdWR6Y=; b=hoeOGKbuKWEVn1PtDFWc2ftqmDmKYBS0cqBhJWwp3Dwzh4jMsFMBRRpO9tDUGyZZMn 9UH3xqCjIxUAIQQPoJVsVBMTs4YupTXoYI6lsIVyqoAwPUo52JTfyRa9b6ppSQowUvxy Wj3F3YYMOoXYvsGjEl/hmb5Y03omY4jtuJ+b3Vybtj/NiKKrwT+fu1d/+uguBU+5dYft eKpp5KgEoxV75dl5z5rY0f2viA1siIfGbg05Hg+wYfZi70IKGssimRLkIXMGxWJCKgsj 0CnPYws+kYT45AEAjiZ64lU/VtyuIeT0RSgG59aBOrvN9/MF4AAhoLIdfE+8OfKRoOV2 9bBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Ll3rRIn8; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7si250703plt.807.2017.12.12.15.59.14; Tue, 12 Dec 2017 15:59:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Ll3rRIn8; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752928AbdLLX7N (ORCPT + 10 others); Tue, 12 Dec 2017 18:59:13 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:45601 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752861AbdLLX7E (ORCPT ); Tue, 12 Dec 2017 18:59:04 -0500 Received: by mail-pf0-f196.google.com with SMTP id u19so477277pfa.12 for ; Tue, 12 Dec 2017 15:59:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8bJKWS73bc4REiX8W8V3Riejuy9weI3MHLqmkG8C3Cw=; b=Ll3rRIn8pclpSSS+F3086KSMqlzaaJx/WBxgeGifu92TcTNz975M6BOfG9WcJ96H+E Bj77+pUaPOJkwqZPI+7ljWdkrRXoKloPqd+NumTdxGY8UJjSHcq8af8Hi7bpRgm073MB Avu5DZB3nF7AozPWOfxgoKf5FBe7EvPNtOgME= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8bJKWS73bc4REiX8W8V3Riejuy9weI3MHLqmkG8C3Cw=; b=cdk6p4rki8g5wy9VS/GLRm3K/jskHevP0ZFvjq/tX6Ral6RwrgdO2gdSZfBlW6XJCq VdO5D8tgLx1JTpeW698jTCxufgFqh4mHBLnOGqEqOTu6XigJgvl+gqJa97nOaQFOeNdg /TsOwR8HEF+ZsJHZ0qUXjtk3YkLfjm2mISVwDgAc5tvrAh7qwuE0kWqxntDrX3LH5Yg+ xMrAmWguQhd5yFq7Kqax8dMYyGcCLP+nlconc/1VPLGn0x+Hcksku2XiX5wIoqfO+op3 0OqIASRlRPCqqCOKsCNqHaf9bkV/m4zUZJwKN49r4WYNeGmBVsr8LifX3Xcpl+cPkqV6 rf8A== X-Gm-Message-State: AKGB3mJxpkL8VpZlS4wIY16ZSIYyOHfnu4bR6+zOf+be7RVpw2pSC2ns t6/LfKmVMq0BmZYVq5Idz5gjZQ== X-Received: by 10.101.80.133 with SMTP id r5mr3634559pgp.314.1513123143314; Tue, 12 Dec 2017 15:59:03 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id t202sm270317pgb.75.2017.12.12.15.59.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 15:59:02 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson , Jeremy McNicoll , Will Newton Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Chris Lew Subject: [PATCH 2/5] rpmsg: smd: Create device for all channels Date: Tue, 12 Dec 2017 15:58:54 -0800 Message-Id: <20171212235857.10432-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171212235857.10432-1-bjorn.andersson@linaro.org> References: <20171212235857.10432-1-bjorn.andersson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Rather than selectively creating devices only for the channels that the remote have moved to "opening" state let's create devices for all channels found. The driver model will match drivers to the ones we care about and attempt to open these. The one case where this fails is if the user loads a firmware that lacks a particular channel of the previous firmware that was running, in which case we would find the old channel and attempt to probe it. The channel opening handshake will ensure this will result in a graceful failure. The result of this patch is that we will actively open the RPM channel even though it's left in a state other than "opening" after the boot loader's closing of the channel. Reported-by: Jeremy McNicoll Reported-by: Will Newton Signed-off-by: Bjorn Andersson --- drivers/rpmsg/qcom_smd.c | 5 ----- 1 file changed, 5 deletions(-) -- 2.15.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c index 58dd44493420..1beddea6f087 100644 --- a/drivers/rpmsg/qcom_smd.c +++ b/drivers/rpmsg/qcom_smd.c @@ -1225,11 +1225,6 @@ static void qcom_channel_state_worker(struct work_struct *work) if (channel->state != SMD_CHANNEL_CLOSED) continue; - remote_state = GET_RX_CHANNEL_INFO(channel, state); - if (remote_state != SMD_CHANNEL_OPENING && - remote_state != SMD_CHANNEL_OPENED) - continue; - if (channel->registered) continue;