From patchwork Wed Aug 10 00:39:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 73595 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp149068qga; Tue, 9 Aug 2016 17:39:28 -0700 (PDT) X-Received: by 10.98.157.12 with SMTP id i12mr2076271pfd.164.1470789568310; Tue, 09 Aug 2016 17:39:28 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gi5si45312274pac.242.2016.08.09.17.39.27; Tue, 09 Aug 2016 17:39:28 -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; dkim=pass header.i=@linaro.org; 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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932713AbcHJAjY (ORCPT + 27 others); Tue, 9 Aug 2016 20:39:24 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:33887 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932452AbcHJAjW (ORCPT ); Tue, 9 Aug 2016 20:39:22 -0400 Received: by mail-pf0-f176.google.com with SMTP id p64so9882518pfb.1 for ; Tue, 09 Aug 2016 17:39:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=99PMnVZULqnwBZYB6tJevGVFYdh3WO8wbk+sei8ID9Q=; b=AB/Lh6/PgLDGai14cyQlTtBVq5INLfEQiNGYrNmNQQq7AP/zdOp6ocbhdKxbSz3KqD Mcsxq+RKfbsSD4fxpCkTkums9kHVLPrBsOxbwSa4ZmZJvE7hlt8DWLbM7OV7v0cDDwRv xdXeoKaw7Na7il0G53dBmkEIUn0ohhAxC+UJ8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=99PMnVZULqnwBZYB6tJevGVFYdh3WO8wbk+sei8ID9Q=; b=hy0bEfDC6g1gDBUMRSxUmOGPMm6buFtmntYl/0tE7Jr/a89L+1IJe79AS3gxYTuqZY dbOYv9XHeWmwgzI6XhWtJI9BZ3EUGr75AMHBFZ0JGCju/1IDM2apChCFXMNXTtvW55rn Zh1g8dSCVoSg1c6YANLxQ2zCiHSdlOI1nrKmJx4HwELmmTSlMaCDKFG6+Vf/hjJcRtdM v5nh0xCPKiOtEfxk4pgVi33RQEavj0FX4efm/+fPmPoxZdCHYxrwoaeRoyO7AMwj7UF3 o7eUr90hlONOS33mzK5TTPoafhkDSGastz/hlA1UbbMdfuuWrpkti6tgblY0eZpcOxCF wY0w== X-Gm-Message-State: AEkoous+cSeHVN1SBGOsJE1AU5hbS1q+LtXLvUYny4ri+liD8yLOtsV7TeHQ+KJleppffYt/ X-Received: by 10.98.104.71 with SMTP id d68mr1997122pfc.163.1470789561533; Tue, 09 Aug 2016 17:39:21 -0700 (PDT) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id uc9sm52209271pab.12.2016.08.09.17.39.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Aug 2016 17:39:20 -0700 (PDT) From: Bjorn Andersson To: Andy Gross Cc: linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] soc: qcom: smd: Simplify multi channel handling Date: Tue, 9 Aug 2016 17:39:19 -0700 Message-Id: <1470789559-5379-1-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Multi-channel clients split between several drivers need a way to close individual channels, as these drivers might be removed individually. With this in place the responsibility of closing additionally opened channels to the client as well only concerning smd about the primary channel. With this approach we will only trigger removal of SMD devices based on the state of the primary channel, however we get in sync with how rpmsg works. Signed-off-by: Bjorn Andersson --- We do not have any drivers in the tree that will suffer from the loss of this. drivers/soc/qcom/smd.c | 34 ++++++++++++++++------------------ include/linux/soc/qcom/smd.h | 7 +++++++ 2 files changed, 23 insertions(+), 18 deletions(-) -- 2.5.0 diff --git a/drivers/soc/qcom/smd.c b/drivers/soc/qcom/smd.c index ac1957dfdf24..63e72eb9baa7 100644 --- a/drivers/soc/qcom/smd.c +++ b/drivers/soc/qcom/smd.c @@ -197,7 +197,6 @@ struct qcom_smd_channel { void *drvdata; struct list_head list; - struct list_head dev_list; }; /** @@ -891,8 +890,6 @@ static int qcom_smd_dev_remove(struct device *dev) struct qcom_smd_device *qsdev = to_smd_device(dev); struct qcom_smd_driver *qsdrv = to_smd_driver(dev); struct qcom_smd_channel *channel = qsdev->channel; - struct qcom_smd_channel *tmp; - struct qcom_smd_channel *ch; qcom_smd_channel_set_state(channel, SMD_CHANNEL_CLOSING); @@ -911,15 +908,9 @@ static int qcom_smd_dev_remove(struct device *dev) if (qsdrv->remove) qsdrv->remove(qsdev); - /* - * The client is now gone, close and release all channels associated - * with this sdev - */ - list_for_each_entry_safe(ch, tmp, &channel->dev_list, dev_list) { - qcom_smd_channel_close(ch); - list_del(&ch->dev_list); - ch->qsdev = NULL; - } + /* The client is now gone, close the primary channel */ + qcom_smd_channel_close(channel); + channel->qsdev = NULL; return 0; } @@ -1091,6 +1082,8 @@ qcom_smd_find_channel(struct qcom_smd_edge *edge, const char *name) * * Returns a channel handle on success, or -EPROBE_DEFER if the channel isn't * ready. + * + * Any channels returned must be closed with a call to qcom_smd_close_channel() */ struct qcom_smd_channel *qcom_smd_open_channel(struct qcom_smd_channel *parent, const char *name, @@ -1120,15 +1113,21 @@ struct qcom_smd_channel *qcom_smd_open_channel(struct qcom_smd_channel *parent, return ERR_PTR(ret); } - /* - * Append the list of channel to the channels associated with the sdev - */ - list_add_tail(&channel->dev_list, &sdev->channel->dev_list); - return channel; } EXPORT_SYMBOL(qcom_smd_open_channel); +/** + * qcom_smd_close_channel() - close an additionally opened channel + * @channel: channel handle, returned by qcom_smd_open_channel() + */ +void qcom_smd_close_channel(struct qcom_smd_channel *channel) +{ + qcom_smd_channel_close(channel); + channel->qsdev = NULL; +} +EXPORT_SYMBOL(qcom_smd_close_channel); + /* * Allocate the qcom_smd_channel object for a newly found smd channel, * retrieving and validating the smem items involved. @@ -1150,7 +1149,6 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed if (!channel) return ERR_PTR(-ENOMEM); - INIT_LIST_HEAD(&channel->dev_list); channel->edge = edge; channel->name = devm_kstrdup(smd->dev, name, GFP_KERNEL); if (!channel->name) diff --git a/include/linux/soc/qcom/smd.h b/include/linux/soc/qcom/smd.h index 910ce1d9ba89..324b1decfffb 100644 --- a/include/linux/soc/qcom/smd.h +++ b/include/linux/soc/qcom/smd.h @@ -55,6 +55,7 @@ void qcom_smd_driver_unregister(struct qcom_smd_driver *drv); struct qcom_smd_channel *qcom_smd_open_channel(struct qcom_smd_channel *channel, const char *name, qcom_smd_cb_t cb); +void qcom_smd_close_channel(struct qcom_smd_channel *channel); void *qcom_smd_get_drvdata(struct qcom_smd_channel *channel); void qcom_smd_set_drvdata(struct qcom_smd_channel *channel, void *data); int qcom_smd_send(struct qcom_smd_channel *channel, const void *data, int len); @@ -83,6 +84,12 @@ qcom_smd_open_channel(struct qcom_smd_channel *channel, return NULL; } +static inline void qcom_smd_close_channel(struct qcom_smd_channel *channel) +{ + /* This shouldn't be possible */ + WARN_ON(1); +} + static inline void *qcom_smd_get_drvdata(struct qcom_smd_channel *channel) { /* This shouldn't be possible */