Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/810816/?format=api
{ "id": 810816, "url": "http://patchwork.ozlabs.org/api/1.2/patches/810816/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-mtd/patch/20170906214502.26748-1-cyrille.pitchen@wedev4u.fr/", "project": { "id": 3, "url": "http://patchwork.ozlabs.org/api/1.2/projects/3/?format=api", "name": "Linux MTD development", "link_name": "linux-mtd", "list_id": "linux-mtd.lists.infradead.org", "list_email": "linux-mtd@lists.infradead.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170906214502.26748-1-cyrille.pitchen@wedev4u.fr>", "list_archive_url": null, "date": "2017-09-06T21:45:02", "name": "mtd: spi-nor: fix DMA unsafe buffer issue in spi_nor_read_sfdp()", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "d176dc91fc64ea2476106eabe54f30f8a98cfeb4", "submitter": { "id": 70551, "url": "http://patchwork.ozlabs.org/api/1.2/people/70551/?format=api", "name": "Cyrille Pitchen", "email": "cyrille.pitchen@wedev4u.fr" }, "delegate": { "id": 58324, "url": "http://patchwork.ozlabs.org/api/1.2/users/58324/?format=api", "username": "bbrezillon", "first_name": "Boris", "last_name": "Brezillon", "email": "boris.brezillon@free-electrons.com" }, "mbox": "http://patchwork.ozlabs.org/project/linux-mtd/patch/20170906214502.26748-1-cyrille.pitchen@wedev4u.fr/mbox/", "series": [ { "id": 1890, "url": "http://patchwork.ozlabs.org/api/1.2/series/1890/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-mtd/list/?series=1890", "date": "2017-09-06T21:45:02", "name": "mtd: spi-nor: fix DMA unsafe buffer issue in spi_nor_read_sfdp()", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/1890/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/810816/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/810816/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org; spf=none (mailfrom)\n\tsmtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133;\n\thelo=bombadil.infradead.org;\n\tenvelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"agCAzWLb\"; \n\tdkim-atps=neutral" ], "Received": [ "from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xncbW2jWcz9t2W\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 7 Sep 2017 07:46:15 +1000 (AEST)", "from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dpi95-0001W6-AS; Wed, 06 Sep 2017 21:46:03 +0000", "from 2.mo3.mail-out.ovh.net ([46.105.75.36])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dpi8g-0001Rv-45\n\tfor linux-mtd@lists.infradead.org; Wed, 06 Sep 2017 21:45:40 +0000", "from player732.ha.ovh.net (b6.ovh.net [213.186.33.56])\n\tby mo3.mail-out.ovh.net (Postfix) with ESMTP id 8F29A149189\n\tfor <linux-mtd@lists.infradead.org>;\n\tWed, 6 Sep 2017 23:45:13 +0200 (CEST)", "from mountainer.wedev4u.int (cor13-1-82-232-94-13.fbx.proxad.net\n\t[82.232.94.13]) (Authenticated sender: cyrille.pitchen@wedev4u.fr)\n\tby player732.ha.ovh.net (Postfix) with ESMTPSA id AF5D820075;\n\tWed, 6 Sep 2017 23:45:03 +0200 (CEST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe:\n\tList-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:\n\tSubject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:\n\tResent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:\n\tReferences:List-Owner; bh=QtzUPdV39dIIEm1hUXq7l8duZ3EUuIALBOE/2P9/Xek=;\n\tb=agC\n\tAzWLbjOvbhoai2WYQdrzg5R+j+GzeqPudZEJGNu9aiXYeNSmhkooiZ8qygVXKH/lWnl8qsYdblqQh\n\tcZEILu4qdYb2wEDtwWvkFbAU4NN0yPdPp/pqCpGChmpPf5VT8+2037tMJk7DNvxyruLIHPFjKJP4/\n\td4nYPJ2NbxGA8TUga/xgTcjDbioxfdnbnndqoraGr9mNXHrNgj8X5u2uHMnG/ZUKwlHJXVmmRCHlZ\n\tvb1vbGK4NaYeyGM5EXng/IZXeBdma7XuBktAlCbdNUSmbaP7VjE7pmF4HEXKABlG5ucU7+bRL7WMB\n\trntpTaaU/fjB2P/zApqw7DS+5dP68wQ==;", "From": "Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>", "To": "marek.vasut@gmail.com, linux-mtd@lists.infradead.org,\n\tgeert@linux-m68k.org", "Subject": "[PATCH] mtd: spi-nor: fix DMA unsafe buffer issue in\n\tspi_nor_read_sfdp()", "Date": "Wed, 6 Sep 2017 23:45:02 +0200", "Message-Id": "<20170906214502.26748-1-cyrille.pitchen@wedev4u.fr>", "X-Mailer": "git-send-email 2.11.0", "X-Ovh-Tracer-Id": "7811775029125011336", "X-VR-SPAMSTATE": "OK", "X-VR-SPAMSCORE": "0", "X-VR-SPAMCAUSE": "gggruggvucftvghtrhhoucdtuddrfeelledrfedugddtlecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecu", "X-CRM114-Version": "20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ", "X-CRM114-CacheID": "sfid-20170906_144538_360140_3F364F8E ", "X-CRM114-Status": "GOOD ( 13.22 )", "X-Spam-Score": "-2.6 (--)", "X-Spam-Report": "SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details: (-2.6 points)\n\tpts rule name description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/,\n\tlow trust [46.105.75.36 listed in list.dnswl.org]\n\t-0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3)\n\t[46.105.75.36 listed in wl.mailspike.net]\n\t-0.0 SPF_PASS SPF: sender matches SPF record\n\t-1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.0 RCVD_IN_MSPIKE_WL Mailspike good senders", "X-BeenThere": "linux-mtd@lists.infradead.org", "X-Mailman-Version": "2.1.21", "Precedence": "list", "List-Id": "Linux MTD discussion mailing list <linux-mtd.lists.infradead.org>", "List-Unsubscribe": "<http://lists.infradead.org/mailman/options/linux-mtd>,\n\t<mailto:linux-mtd-request@lists.infradead.org?subject=unsubscribe>", "List-Archive": "<http://lists.infradead.org/pipermail/linux-mtd/>", "List-Post": "<mailto:linux-mtd@lists.infradead.org>", "List-Help": "<mailto:linux-mtd-request@lists.infradead.org?subject=help>", "List-Subscribe": "<http://lists.infradead.org/mailman/listinfo/linux-mtd>,\n\t<mailto:linux-mtd-request@lists.infradead.org?subject=subscribe>", "Cc": "boris.brezillon@free-electrons.com, richard@nod.at,\n\tlinux-kernel@vger.kernel.org,\n\tCyrille Pitchen <cyrille.pitchen@wedev4u.fr>, \n\tcomputersforpeace@gmail.com, dwmw2@infradead.org", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Sender": "\"linux-mtd\" <linux-mtd-bounces@lists.infradead.org>", "Errors-To": "linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org" }, "content": "spi_nor_read_sfdp() calls nor->read() to read the SFDP data.\nWhen the m25p80 driver is used (pretty common case), nor->read() is then\nimplemented by the m25p80_read() function, which is likely to initialize a\n'struct spi_transfer' from its buf argument before appending this\nstructure inside the 'struct spi_message' argument of spi_sync().\n\nBesides the SPI sub-system states that both .tx_buf and .rx_buf members of\n'struct spi_transfer' must point into dma-safe memory. However, two of the\nthree calls of spi_nor_read_sfdp() were given pointers to stack allocated\nmemory as buf argument, hence not in a dma-safe area.\nHopefully, the third and last call of spi_nor_read_sfdp() was already\ngiven a kmalloc'ed buffer argument, hence dma-safe.\n\nSo this patch fixes this issue by introducing a\nspi_nor_read_sfdp_dma_unsafe() function which simply wraps the existing\nspi_nor_read_sfdp() function and uses some kmalloc'ed memory as a bounce\nbuffer.\n\nReported-by: Geert Uytterhoeven <geert@linux-m68k.org>\nSigned-off-by: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>\n---\n\nCompiled but not tested yet!\n\n drivers/mtd/spi-nor/spi-nor.c | 36 +++++++++++++++++++++++++++++++++---\n 1 file changed, 33 insertions(+), 3 deletions(-)", "diff": "diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c\nindex cf1d4a15e10a..05254dd6a4a0 100644\n--- a/drivers/mtd/spi-nor/spi-nor.c\n+++ b/drivers/mtd/spi-nor/spi-nor.c\n@@ -1784,7 +1784,7 @@ spi_nor_set_pp_settings(struct spi_nor_pp_command *pp,\n * @nor:\tpointer to a 'struct spi_nor'\n * @addr:\toffset in the SFDP area to start reading data from\n * @len:\tnumber of bytes to read\n- * @buf:\tbuffer where the SFDP data are copied into\n+ * @buf:\tbuffer where the SFDP data are copied into (dma-safe memory)\n *\n * Whatever the actual numbers of bytes for address and dummy cycles are\n * for (Fast) Read commands, the Read SFDP (5Ah) instruction is always\n@@ -1829,6 +1829,36 @@ static int spi_nor_read_sfdp(struct spi_nor *nor, u32 addr,\n \treturn ret;\n }\n \n+/**\n+ * spi_nor_read_sfdp_dma_unsafe() - read Serial Flash Discoverable Parameters.\n+ * @nor:\tpointer to a 'struct spi_nor'\n+ * @addr:\toffset in the SFDP area to start reading data from\n+ * @len:\tnumber of bytes to read\n+ * @buf:\tbuffer where the SFDP data are copied into\n+ *\n+ * Wrap spi_nor_read_sfdp() using a kmalloc'ed bounce buffer as @buf is now not\n+ * guaranteed to be dma-safe.\n+ *\n+ * Return: -ENOMEM if kmalloc() fails, the return code of spi_nor_read_sfdp()\n+ * otherwise.\n+ */\n+static int spi_nor_read_sfdp_dma_unsafe(struct spi_nor *nor, u32 addr,\n+\t\t\t\t\tsize_t len, void *buf)\n+{\n+\tvoid *dma_safe_buf;\n+\tint ret;\n+\n+\tdma_safe_buf = kmalloc(len, GFP_KERNEL);\n+\tif (!dma_safe_buf)\n+\t\treturn -ENOMEM;\n+\n+\tret = spi_nor_read_sfdp(nor, addr, len, dma_safe_buf);\n+\tmemcpy(buf, dma_safe_buf, len);\n+\tkfree(dma_safe_buf);\n+\n+\treturn ret;\n+}\n+\n struct sfdp_parameter_header {\n \tu8\t\tid_lsb;\n \tu8\t\tminor;\n@@ -2101,7 +2131,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,\n \t\t bfpt_header->length * sizeof(u32));\n \taddr = SFDP_PARAM_HEADER_PTP(bfpt_header);\n \tmemset(&bfpt, 0, sizeof(bfpt));\n-\terr = spi_nor_read_sfdp(nor, addr, len, &bfpt);\n+\terr = spi_nor_read_sfdp_dma_unsafe(nor, addr, len, &bfpt);\n \tif (err < 0)\n \t\treturn err;\n \n@@ -2243,7 +2273,7 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor,\n \tint i, err;\n \n \t/* Get the SFDP header. */\n-\terr = spi_nor_read_sfdp(nor, 0, sizeof(header), &header);\n+\terr = spi_nor_read_sfdp_dma_unsafe(nor, 0, sizeof(header), &header);\n \tif (err < 0)\n \t\treturn err;\n \n", "prefixes": [] }