Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/816409/?format=api
{ "id": 816409, "url": "http://patchwork.ozlabs.org/api/patches/816409/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-i2c/patch/20170920185956.13874-3-wsa+renesas@sang-engineering.com/", "project": { "id": 35, "url": "http://patchwork.ozlabs.org/api/projects/35/?format=api", "name": "Linux I2C development", "link_name": "linux-i2c", "list_id": "linux-i2c.vger.kernel.org", "list_email": "linux-i2c@vger.kernel.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170920185956.13874-3-wsa+renesas@sang-engineering.com>", "list_archive_url": null, "date": "2017-09-20T18:59:52", "name": "[RFC,v5,2/6] i2c: add helpers to ease DMA handling", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "47233e35813774c47fe6addc90dbe459c65d834b", "submitter": { "id": 69646, "url": "http://patchwork.ozlabs.org/api/people/69646/?format=api", "name": "Wolfram Sang", "email": "wsa+renesas@sang-engineering.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-i2c/patch/20170920185956.13874-3-wsa+renesas@sang-engineering.com/mbox/", "series": [ { "id": 4199, "url": "http://patchwork.ozlabs.org/api/series/4199/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-i2c/list/?series=4199", "date": "2017-09-20T18:59:56", "name": "i2c: document DMA handling and add helpers for it", "version": 5, "mbox": "http://patchwork.ozlabs.org/series/4199/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/816409/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/816409/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linux-i2c-owner@vger.kernel.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-i2c-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xy8Hb0KFdz9sNr\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 05:02:03 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751723AbdITTBp (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tWed, 20 Sep 2017 15:01:45 -0400", "from sauhun.de ([88.99.104.3]:38837 \"EHLO pokefinder.org\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751476AbdITTAE (ORCPT <rfc822;linux-i2c@vger.kernel.org>);\n\tWed, 20 Sep 2017 15:00:04 -0400", "from localhost (p54B332E6.dip0.t-ipconnect.de [84.179.50.230])\n\tby pokefinder.org (Postfix) with ESMTPSA id 6C2CB2C439B;\n\tWed, 20 Sep 2017 21:00:02 +0200 (CEST)" ], "From": "Wolfram Sang <wsa+renesas@sang-engineering.com>", "To": "linux-i2c@vger.kernel.org", "Cc": "linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org,\n\tlinux-iio@vger.kernel.org, linux-input@vger.kernel.org,\n\tlinux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,\n\tWolfram Sang <wsa+renesas@sang-engineering.com>", "Subject": "[RFC PATCH v5 2/6] i2c: add helpers to ease DMA handling", "Date": "Wed, 20 Sep 2017 20:59:52 +0200", "Message-Id": "<20170920185956.13874-3-wsa+renesas@sang-engineering.com>", "X-Mailer": "git-send-email 2.11.0", "In-Reply-To": "<20170920185956.13874-1-wsa+renesas@sang-engineering.com>", "References": "<20170920185956.13874-1-wsa+renesas@sang-engineering.com>", "Sender": "linux-i2c-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<linux-i2c.vger.kernel.org>", "X-Mailing-List": "linux-i2c@vger.kernel.org" }, "content": "One helper checks if DMA is suitable and optionally creates a bounce\nbuffer, if not. The other function returns the bounce buffer and makes\nsure the data is properly copied back to the message.\n\nSigned-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>\n---\n drivers/i2c/i2c-core-base.c | 45 +++++++++++++++++++++++++++++++++++++++++++++\n include/linux/i2c.h | 3 +++\n 2 files changed, 48 insertions(+)", "diff": "diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c\nindex 56e46581b84bdb..925a22794d3ced 100644\n--- a/drivers/i2c/i2c-core-base.c\n+++ b/drivers/i2c/i2c-core-base.c\n@@ -2241,6 +2241,51 @@ void i2c_put_adapter(struct i2c_adapter *adap)\n }\n EXPORT_SYMBOL(i2c_put_adapter);\n \n+/**\n+ * i2c_get_dma_safe_msg_buf() - get a DMA safe buffer for the given i2c_msg\n+ * @msg: the message to be checked\n+ * @threshold: the amount of byte from which using DMA makes sense\n+ *\n+ * Return: NULL if a DMA safe buffer was not obtained. Use msg->buf with PIO.\n+ *\n+ *\t Or a valid pointer to be used with DMA. Note that it can either be\n+ *\t msg->buf or a bounce buffer. After use, release it by calling\n+ *\t i2c_release_dma_safe_msg_buf().\n+ *\n+ * This function must only be called from process context!\n+ */\n+u8 *i2c_get_dma_safe_msg_buf(struct i2c_msg *msg, unsigned int threshold)\n+{\n+\tif (msg->len < threshold)\n+\t\treturn NULL;\n+\n+\tif (msg->flags & I2C_M_DMA_SAFE)\n+\t\treturn msg->buf;\n+\n+\tif (msg->flags & I2C_M_RD)\n+\t\treturn kzalloc(msg->len, GFP_KERNEL);\n+\telse\n+\t\treturn kmemdup(msg->buf, msg->len, GFP_KERNEL);\n+}\n+EXPORT_SYMBOL_GPL(i2c_get_dma_safe_msg_buf);\n+\n+/**\n+ * i2c_release_dma_safe_msg_buf - release DMA safe buffer and sync with i2c_msg\n+ * @msg: the message to be synced with\n+ * @buf: the buffer obtained from i2c_get_dma_safe_msg_buf(). May be NULL.\n+ */\n+void i2c_release_dma_safe_msg_buf(struct i2c_msg *msg, u8 *buf)\n+{\n+\tif (!buf || buf == msg->buf)\n+\t\treturn;\n+\n+\tif (msg->flags & I2C_M_RD)\n+\t\tmemcpy(msg->buf, buf, msg->len);\n+\n+\tkfree(buf);\n+}\n+EXPORT_SYMBOL_GPL(i2c_release_dma_safe_msg_buf);\n+\n MODULE_AUTHOR(\"Simon G. Vogl <simon@tk.uni-linz.ac.at>\");\n MODULE_DESCRIPTION(\"I2C-Bus main module\");\n MODULE_LICENSE(\"GPL\");\ndiff --git a/include/linux/i2c.h b/include/linux/i2c.h\nindex d501d3956f13f0..1e99342f180f45 100644\n--- a/include/linux/i2c.h\n+++ b/include/linux/i2c.h\n@@ -767,6 +767,9 @@ static inline u8 i2c_8bit_addr_from_msg(const struct i2c_msg *msg)\n \treturn (msg->addr << 1) | (msg->flags & I2C_M_RD ? 1 : 0);\n }\n \n+u8 *i2c_get_dma_safe_msg_buf(struct i2c_msg *msg, unsigned int threshold);\n+void i2c_release_dma_safe_msg_buf(struct i2c_msg *msg, u8 *buf);\n+\n int i2c_handle_smbus_host_notify(struct i2c_adapter *adap, unsigned short addr);\n /**\n * module_i2c_driver() - Helper macro for registering a modular I2C driver\n", "prefixes": [ "RFC", "v5", "2/6" ] }