From patchwork Tue Dec 12 23:58:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 121685 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4784359qgn; Tue, 12 Dec 2017 15:59:18 -0800 (PST) X-Google-Smtp-Source: ACJfBovVyoueD4+fUcfkgQjdc7qY9uurG2Cm9IuIS9GnxVNTBn1IwJzmE+fNoUnSgWzbEqKMewtp X-Received: by 10.98.215.90 with SMTP id v26mr4023424pfl.174.1513123158260; Tue, 12 Dec 2017 15:59:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513123158; cv=none; d=google.com; s=arc-20160816; b=Oh2oIpM703D0JgGAWgcOPlXWGzNvfGOHqEefM+58IeAsbTz1csIFGgakGaXPJ+vSOx 22embCFGhNQT67MHcEBzGY94anC8EDfZtXvgNKwWz0av29FYcZdf9WxuxymJZTUbaS59 I1HXpWZ3IzGPYr9CJ1FBQnveZSmpZMHpit+C2H2v9ulyfaC5fbPNWRh/HEKGhFYb78qR du4rR4fdlngRIKqrzX2n+i7qez7UnSNtbLLslEQDk96nhDkd2CAsVSaLRsnc5mtT+bB4 n6Zh7Ajkm4QnDq0w39RnxrgQfZx0STTi3RLQTy5jsPOJd+G/M+ev62wsnSOSiLt9qsnq leuQ== 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=r7hVHeASRwnG15giTIwXO7iaztMlse8qsnfaY/wNG6E=; b=z82IDiqPBnsfJjPCYQ7VMxY61EwOZuZ7cENrU81874q37SqdnudUfTxjjdAR/uBKIZ m8CpN3M0kJ5YRqlug5V6uxmdvdxO8LcLaM91oEvlfeDleH/PbOIroLM16MsxbeGRRujX 8L9hIvrcirJejnsxq4XpBLx+oZ4Llx5K86+F4lUMzuj9GPKEvdbFRrJplRyRpjHLIts/ WY+FYkiBv+TCjdtwNM9nUhjFvjLLcIMNrLTVQ1hr9buTMV3sUWq64Ch5jcS252LlU0RW 4z3NpPoVcqGTnfZcMv7Okj1Ihpq8x9CD/Vph9h1sdC1UoZhAF6CZNHlcVV36yx0cK9/m lDOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V63R61/X; 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; dmarc=pass (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.18; Tue, 12 Dec 2017 15:59:18 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=V63R61/X; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752953AbdLLX7O (ORCPT + 11 others); Tue, 12 Dec 2017 18:59:14 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:46409 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752882AbdLLX7G (ORCPT ); Tue, 12 Dec 2017 18:59:06 -0500 Received: by mail-pf0-f193.google.com with SMTP id c204so473144pfc.13 for ; Tue, 12 Dec 2017 15:59:06 -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=r7hVHeASRwnG15giTIwXO7iaztMlse8qsnfaY/wNG6E=; b=V63R61/Xc1zqKg8u67vbDijEQHtEJ7r7ZdncaG3G0y+eHQ0nXlis0CODkxfFN9fS5J sFNZPMk6yT5Pv8vKwCqRe4i4ARVNE7IYDU1Ii/nvdVqEHRbmWrz20p6mdrndWLCZPjH9 049tth1PLmDfPNZOcsc/qzogJhqvKV45eg4r8= 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=r7hVHeASRwnG15giTIwXO7iaztMlse8qsnfaY/wNG6E=; b=LKvB2b6rcqI0cZWjHfS89dAwAghwQ4yV09z90xCJ26I9VtnuTlACZl+y2VITo5dkLF DMt/CRL+U0m0qzwMCUaiCxJBbitB2VKT4PBnwAtV0zWIUktzmW/7ECTQlP5DEIdKZkfT i6SV/h6qNeo5CToOIBQDcg56OvWyf8ydGow0E5nH4QrU4ybZSv+FmEz3fyQkR3j2x8BJ ig2vyeNxY+7fnNAF4zchNBx8eKlkXuG9xIkPiuPB8/eDh8JYmpbRD2P+FeYC3g7woJ4w FQGye+SA/0U3pqcb5uHezCRZ03FU1CR/+DbGwoNC0pGih3b7za7pWrOvc7lAzmGhvouw ydtQ== X-Gm-Message-State: AKGB3mIbRycaJBJY/u/2ltOoiQlbL78ay5r+XA6xreY0nRajV268KwIu 1+jWwBzMAaPmn4AWMjmLD/o67A== X-Received: by 10.84.168.37 with SMTP id e34mr4027730plb.10.1513123145653; Tue, 12 Dec 2017 15:59:05 -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.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 15:59:04 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Chris Lew , Jeremy McNicoll , Will Newton Subject: [PATCH 4/5] rpmsg: smd: Fail send on a closed channel Date: Tue, 12 Dec 2017 15:58:56 -0800 Message-Id: <20171212235857.10432-5-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move the check for a closed channel out from the tx-full loop to fail any send request on a non-open channel. Signed-off-by: Bjorn Andersson --- drivers/rpmsg/qcom_smd.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) -- 2.15.0 diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c index 0993e95bf0f5..ed167ab52a68 100644 --- a/drivers/rpmsg/qcom_smd.c +++ b/drivers/rpmsg/qcom_smd.c @@ -743,17 +743,13 @@ static int __qcom_smd_send(struct qcom_smd_channel *channel, const void *data, if (ret) return ret; - while (qcom_smd_get_tx_avail(channel) < tlen) { + while (qcom_smd_get_tx_avail(channel) < tlen && + channel->state == SMD_CHANNEL_OPENED) { if (!wait) { ret = -EAGAIN; goto out; } - if (channel->state != SMD_CHANNEL_OPENED) { - ret = -EPIPE; - goto out; - } - SET_TX_CHANNEL_FLAG(channel, fBLOCKREADINTR, 0); ret = wait_event_interruptible(channel->fblockread_event, @@ -765,6 +761,12 @@ static int __qcom_smd_send(struct qcom_smd_channel *channel, const void *data, SET_TX_CHANNEL_FLAG(channel, fBLOCKREADINTR, 1); } + /* Fail if the channel was closed */ + if (channel->state != SMD_CHANNEL_OPENED) { + ret = -EPIPE; + goto out; + } + SET_TX_CHANNEL_FLAG(channel, fTAIL, 0); qcom_smd_write_fifo(channel, hdr, sizeof(hdr));