{"id":808569,"url":"http://patchwork.ozlabs.org/api/1.0/patches/808569/?format=json","project":{"id":3,"url":"http://patchwork.ozlabs.org/api/1.0/projects/3/?format=json","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},"msgid":"<1504252841-2445-5-git-send-email-bmeng.cn@gmail.com>","date":"2017-09-01T08:00:35","name":"[04/10] spi-nor: intel-spi: Check transfer length in the HW/SW cycle","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"3c8cf2f4b09f3a45395c243ab9408b8f12b87a53","submitter":{"id":64981,"url":"http://patchwork.ozlabs.org/api/1.0/people/64981/?format=json","name":"Bin Meng","email":"bmeng.cn@gmail.com"},"delegate":{"id":63396,"url":"http://patchwork.ozlabs.org/api/1.0/users/63396/?format=json","username":"cpitchen","first_name":"Cyrille","last_name":"Pitchen","email":"cyrille.pitchen@atmel.com"},"mbox":"http://patchwork.ozlabs.org/project/linux-mtd/patch/1504252841-2445-5-git-send-email-bmeng.cn@gmail.com/mbox/","series":[{"id":969,"url":"http://patchwork.ozlabs.org/api/1.0/series/969/?format=json","date":"2017-09-01T08:00:33","name":"spi-nor: intel-spi: Various fixes and enhancements","version":1,"mbox":"http://patchwork.ozlabs.org/series/969/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/808569/checks/","tags":{},"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=\"BMiyo3Z2\"; \n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"WzkJcj8s\"; dkim-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 3xkBTR2NLFz9s81\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 17:59:07 +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 1dngqw-0003Iu-En; Fri, 01 Sep 2017 07:58:58 +0000","from mail-io0-x241.google.com ([2607:f8b0:4001:c06::241])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dngoq-0001XW-1j\n\tfor linux-mtd@lists.infradead.org; Fri, 01 Sep 2017 07:56:49 +0000","by mail-io0-x241.google.com with SMTP id 2so2154262ion.3\n\tfor <linux-mtd@lists.infradead.org>;\n\tFri, 01 Sep 2017 00:56:27 -0700 (PDT)","from ala-d2121-lx1.wrs.com (unknown-156-139.windriver.com.\n\t[147.11.156.139]) by smtp.gmail.com with ESMTPSA id\n\td187sm853502iod.7.2017.09.01.00.56.25\n\t(version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tFri, 01 Sep 2017 00:56:26 -0700 (PDT)"],"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:References:\n\tIn-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID:\n\tContent-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc\n\t:Resent-Message-ID:List-Owner;\n\tbh=n327keBQG/HCv3fDzYK1YgUHnsI5mhoBBQAAbpMcpQI=;\n\tb=BMiyo3Z2pgtYuuiuDkjd10TtrM\n\tuefVIOOvXc1Tep3n/Tk0CfUqqVMRVszq0U7y1vnhvDEL0nTeS9hIDLm4YjB1t1FF/Ok9g+3b+BIC+\n\tLT9NnNmIQ/XvWaaXks5JaSCxRcTja63QzZnxx00S9Q/+0RG/rxcvu1fzX5z8Wtpa7H5df2A21bjN1\n\tZuY4rxR8llCNnkCPUQ7mkcTjXz9D1HZ5UV56BuOT0q066SqYLBvv3JZRGb53cOMreMru/Djqzj1A7\n\tIAFTGTdLCuU2Nw65pDUb0KiWQS4tKo76BvzjctE0YDU0og/mX3m+rr6+pxVqO8nH+wRSylgXNpK7q\n\tqu6jEmeQ==;","v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=d+moQZ7Q25JF8ty11T9jxCSisdCQrjKQQIoyDlfBxD0=;\n\tb=WzkJcj8sqY9KC9AH7dRyP26Nk0BxilN29r1QOIeadf29v9OS5VJKmi9I8W7xufqW+y\n\tCz9KIaqk9dfUdmWE0pPVVkT9PZEAEfgyx3OLKxB6omXRaZtnFQ8zhL6EaLofIZLWe+Lo\n\tiQYzGO0HVOEYWA0rYuq9L1vN3HaoM6Tlk1P/Z2T3UdKl/2DNlwcBJvSe6qv69qMBYF4o\n\t8nKGrysVVl1lBo9oecYz6g+o/VhD/AQ5eILGG2+aBrrGgfPi2amZmZLdL3R+sIvtB7Qj\n\tkLjJd/Vb+qE215WVNUMRYyiXfrUkW9ypRj7b5chKP/47cAPyqCcqq4jjtxM3ATZdOl6Y\n\tSBKA=="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=d+moQZ7Q25JF8ty11T9jxCSisdCQrjKQQIoyDlfBxD0=;\n\tb=JM65O8JB5IFd62/niDIkD7soCuqSyVyPign+B2e4Is+YPUiJgPZaurwT+AyhDm6UKu\n\t+iu1wLSBt/BQjJAh40DUkX1kg1WPMdTsBQuVMYbn/9iJZFPIaSA4uj2J0C0WlVVMIPwQ\n\tAwGvzuJKR4J8tjv9ZghuJvgLCoPnkTuIGew5mGUM+zNkslK+7eqCVvr4S2QWMJPIr24o\n\th1Q7x9vdaANuGyWSnCnNdwO6CuXW4RssSyGmw2lFZyS/HbrKtACTtJ3I/IL12nNn3r0O\n\tKL04Onzr3REL3BBHbU+g1xx1Gs4ivnFdCB/onOqIwjOz9UbzvsRYT2/hC4iqf9uaIxie\n\tyY4w==","X-Gm-Message-State":"AHPjjUhBl2sDd66XU47Au60bTVp8y/mUWaMp81RwHjrUhvubjJAj4E2e\n\tN7bQnVI5ISLn0w==","X-Google-Smtp-Source":"ADKCNb5gsQOZgphBEbjIAzUhvalewD25eN8Gll6OVyQpUXSOCLIQ9/nboQXVhL2trG4M6H3q/oDlgQ==","X-Received":"by 10.107.163.195 with SMTP id m186mr791187ioe.358.1504252587058;\n\tFri, 01 Sep 2017 00:56:27 -0700 (PDT)","From":"Bin Meng <bmeng.cn@gmail.com>","To":"Mika Westerberg <mika.westerberg@linux.intel.com>,\n\tCyrille Pitchen <cyrille.pitchen@wedev4u.fr>,\n\tMarek Vasut <marek.vasut@gmail.com>,\n\tBoris Brezillon <boris.brezillon@free-electrons.com>,\n\tBrian Norris <computersforpeace@gmail.com>,\n\tRichard Weinberger <richard@nod.at>,\n\tDavid Woodhouse <dwmw2@infradead.org>, \n\tlinux-mtd <linux-mtd@lists.infradead.org>,\n\tlinux-kernel <linux-kernel@vger.kernel.org>","Subject":"[PATCH 04/10] spi-nor: intel-spi: Check transfer length in the HW/SW\n\tcycle","Date":"Fri,  1 Sep 2017 01:00:35 -0700","Message-Id":"<1504252841-2445-5-git-send-email-bmeng.cn@gmail.com>","X-Mailer":"git-send-email 1.7.9.5","In-Reply-To":"<1504252841-2445-1-git-send-email-bmeng.cn@gmail.com>","References":"<1504252841-2445-1-git-send-email-bmeng.cn@gmail.com>","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170901_005648_241265_BABD4345 ","X-CRM114-Status":"GOOD (  13.08  )","X-Spam-Score":"-2.7 (--)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-2.7 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\n\ttrust [2607:f8b0:4001:c06:0:0:0:241 listed in] [list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\n\tprovider (bmeng.cn[at]gmail.com)\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature\n\t0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n\tnot necessarily valid\n\t-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n\tauthor's domain","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":"Stefan Roese <sr@denx.de>","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":"Intel SPI controller only has a 64 bytes FIFO. This adds a sanity\ncheck before triggering any HW/SW sequencer work.\n\nAdditionally for the SW sequencer, if given data length is zero,\nwe should not mark the 'Data Cycle' bit.\n\nSigned-off-by: Bin Meng <bmeng.cn@gmail.com>\n---\n\n drivers/mtd/spi-nor/intel-spi.c | 12 ++++++++++--\n 1 file changed, 10 insertions(+), 2 deletions(-)","diff":"diff --git a/drivers/mtd/spi-nor/intel-spi.c b/drivers/mtd/spi-nor/intel-spi.c\nindex 263c6ab..c4a9de6 100644\n--- a/drivers/mtd/spi-nor/intel-spi.c\n+++ b/drivers/mtd/spi-nor/intel-spi.c\n@@ -399,6 +399,9 @@ static int intel_spi_hw_cycle(struct intel_spi *ispi, u8 opcode, int len)\n \t\treturn -EINVAL;\n \t}\n \n+\tif (len > INTEL_SPI_FIFO_SZ)\n+\t\treturn -EINVAL;\n+\n \tval |= (len - 1) << HSFSTS_CTL_FDBC_SHIFT;\n \tval |= HSFSTS_CTL_FCERR | HSFSTS_CTL_FDONE;\n \tval |= HSFSTS_CTL_FGO;\n@@ -419,14 +422,19 @@ static int intel_spi_hw_cycle(struct intel_spi *ispi, u8 opcode, int len)\n \n static int intel_spi_sw_cycle(struct intel_spi *ispi, u8 opcode, int len)\n {\n-\tu32 val, status;\n+\tu32 val = 0, status;\n \tint ret;\n \n \tret = intel_spi_opcode_index(ispi, opcode);\n \tif (ret < 0)\n \t\treturn ret;\n \n-\tval = ((len - 1) << SSFSTS_CTL_DBC_SHIFT) | SSFSTS_CTL_DS;\n+\tif (len > INTEL_SPI_FIFO_SZ)\n+\t\treturn -EINVAL;\n+\n+\t/* Only mark 'Data Cycle' bit when there is data to be transferred */\n+\tif (len > 0)\n+\t\tval = ((len - 1) << SSFSTS_CTL_DBC_SHIFT) | SSFSTS_CTL_DS;\n \tval |= ret << SSFSTS_CTL_COP_SHIFT;\n \tval |= SSFSTS_CTL_FCERR | SSFSTS_CTL_FDONE;\n \tval |= SSFSTS_CTL_SCGO;\n","prefixes":["04/10"]}