From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
To: kvalo@codeaurora.org
Cc: johannes@sipsolutions.net, linux-wireless@vger.kernel.org,
luca@coelho.fi, Tomas Winkler <tomas.winkler@intel.com>,
Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Subject: [PATCH 1/5] mei: allow map and unmap of client dma buffer only for disconnected client
Date: Mon, 22 Mar 2021 22:46:29 +0200 [thread overview]
Message-ID: <20210322204633.102581-2-emmanuel.grumbach@intel.com> (raw)
In-Reply-To: <20210322204633.102581-1-emmanuel.grumbach@intel.com>
From: Tomas Winkler <tomas.winkler@intel.com>
Allow map and unmap of the client dma buffer only when the client is not
connected. The functions return -EPROTO if the client is already connected.
This is to fix the race when traffic may start or stop when buffer
is not available.
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
drivers/misc/mei/client.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index 4378a9b25848..2cc370adb238 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -2286,8 +2286,8 @@ int mei_cl_dma_alloc_and_map(struct mei_cl *cl, const struct file *fp,
if (buffer_id == 0)
return -EINVAL;
- if (!mei_cl_is_connected(cl))
- return -ENODEV;
+ if (mei_cl_is_connected(cl))
+ return -EPROTO;
if (cl->dma_mapped)
return -EPROTO;
@@ -2327,9 +2327,7 @@ int mei_cl_dma_alloc_and_map(struct mei_cl *cl, const struct file *fp,
mutex_unlock(&dev->device_lock);
wait_event_timeout(cl->wait,
- cl->dma_mapped ||
- cl->status ||
- !mei_cl_is_connected(cl),
+ cl->dma_mapped || cl->status,
mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT));
mutex_lock(&dev->device_lock);
@@ -2376,8 +2374,9 @@ int mei_cl_dma_unmap(struct mei_cl *cl, const struct file *fp)
return -EOPNOTSUPP;
}
- if (!mei_cl_is_connected(cl))
- return -ENODEV;
+ /* do not allow unmap for connected client */
+ if (mei_cl_is_connected(cl))
+ return -EPROTO;
if (!cl->dma_mapped)
return -EPROTO;
@@ -2405,9 +2404,7 @@ int mei_cl_dma_unmap(struct mei_cl *cl, const struct file *fp)
mutex_unlock(&dev->device_lock);
wait_event_timeout(cl->wait,
- !cl->dma_mapped ||
- cl->status ||
- !mei_cl_is_connected(cl),
+ !cl->dma_mapped || cl->status,
mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT));
mutex_lock(&dev->device_lock);
--
2.25.1
next prev parent reply other threads:[~2021-03-22 20:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-22 20:46 [RESEND PATCH 0/5] Add support for AMT over WLAN Emmanuel Grumbach
2021-03-22 20:46 ` Emmanuel Grumbach [this message]
2021-03-23 15:15 ` [PATCH 1/5] mei: allow map and unmap of client dma buffer only for disconnected client Emmanuel Grumbach
2021-03-22 20:46 ` [PATCH 2/5] mei: bus: add client dma interface Emmanuel Grumbach
2021-03-22 20:46 ` [PATCH 3/5] cfg80211: allow to specifying a reason for hw_rfkill Emmanuel Grumbach
2021-03-22 20:46 ` [PATCH 4/5] iwlwifi: mei: add the driver to allow cooperation with CSME Emmanuel Grumbach
2021-03-22 20:46 ` [PATCH 5/5] iwlwifi: integrate with iwlmei Emmanuel Grumbach
-- strict thread matches above, loose matches on Subject: below --
2021-03-22 20:41 [PATCH 0/5] Add support for AMT over WLAN Emmanuel Grumbach
2021-03-22 20:41 ` [PATCH 1/5] mei: allow map and unmap of client dma buffer only for disconnected client Emmanuel Grumbach
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210322204633.102581-2-emmanuel.grumbach@intel.com \
--to=emmanuel.grumbach@intel.com \
--cc=johannes@sipsolutions.net \
--cc=kvalo@codeaurora.org \
--cc=linux-wireless@vger.kernel.org \
--cc=luca@coelho.fi \
--cc=tomas.winkler@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).