From patchwork Tue Apr 10 22:44:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 896965 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Np3mkwLX"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40LMjC4hNnz9s0n for ; Wed, 11 Apr 2018 08:46:23 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Y/BP7G1HgPg0000X2kbgtgMDkYNuyXfj/4AsMxZ1RUU=; b=Np3mkwLXyaoLHWYhwtYyZxe2rY 8h+mOuz8tGWxQngHDYkl4SQHpbanZEbgsrmYMFF3QWNkjgDcIpM9OfHnb/YbPMmcoPacPJKbZjFtb +3VvU6ZQVfbn+eGJbsQ+N5umgizc36PqD4TuJ3Ov85clMnHZ8VasNX7buif+Uwd0iEuLaBj77NZZP zCLVUxe1X+QN2hAvr1TlmPNZLb+UQRa0xyRT0Tiqp8livkG6gJOdpo1/wKK/18c4d7o1ESY3ouv2r 2kx6sHawjj9teDLl3ia08vXHWd5UJ1STeDpa8VkJUIyGI1rh2Q+muibF3XoF42wXiSQxj3egGsrfN 8PlNfJnA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f621o-0008Bn-Ck; Tue, 10 Apr 2018 22:46:16 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f620X-00061X-7z for linux-mtd@lists.infradead.org; Tue, 10 Apr 2018 22:45:00 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 687962077B; Wed, 11 Apr 2018 00:44:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (unknown [91.160.177.164]) by mail.bootlin.com (Postfix) with ESMTPSA id 04C7A2071B; Wed, 11 Apr 2018 00:44:45 +0200 (CEST) From: Boris Brezillon To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Cyrille Pitchen , linux-mtd@lists.infradead.org, Miquel Raynal , Mark Brown , linux-spi@vger.kernel.org Subject: [PATCH v2 03/10] spi: Add an helper to flush the message queue Date: Wed, 11 Apr 2018 00:44:32 +0200 Message-Id: <20180410224439.9260-4-boris.brezillon@bootlin.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180410224439.9260-1-boris.brezillon@bootlin.com> References: <20180410224439.9260-1-boris.brezillon@bootlin.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180410_154457_451025_14B6C647 X-CRM114-Status: GOOD ( 16.82 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [62.4.15.54 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yogesh Gaur , Vignesh R , Kamal Dasu , Maxime Chevallier , Peter Pan , Frieder Schrempf , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Sourav Poddar MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This is needed by the spi-mem logic to force all messages that have been queued before a memory operation to be sent before we start the memory operation. We do that in order to guarantee that spi-mem operations do not preempt regular SPI transfers. Signed-off-by: Boris Brezillon --- As for the spi_map/unmap_buf() I'd suggest to move the prototype definition to an internal header file. --- drivers/spi/spi.c | 16 ++++++++++++++++ include/linux/spi/spi.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 308e4c2114d8..d7e046128b3f 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1520,6 +1520,22 @@ static int spi_controller_initialize_queue(struct spi_controller *ctlr) return ret; } +/** + * spi_flush_queue - Send all pending messages in the queue from the callers' + * context + * @ctlr: controller to process queue for + * + * This should be used when one wants to ensure all pending messages have been + * sent before doing something. Is used by the spi-mem code to make sure SPI + * memory operations do not preempt regular SPI transfers that have been queued + * before the spi-mem operation. + */ +void spi_flush_queue(struct spi_controller *ctlr) +{ + if (ctlr->transfer == spi_queued_transfer) + __spi_pump_messages(ctlr, false); +} + /*-------------------------------------------------------------------------*/ #if defined(CONFIG_OF) diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index de6fd95a61c5..3489fc9c0410 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -619,6 +619,8 @@ extern int spi_controller_resume(struct spi_controller *ctlr); * Helpers needed by the spi-mem logic. Should not be used outside of * spi-mem.c */ +void spi_flush_queue(struct spi_controller *ctrl); + #ifdef CONFIG_HAS_DMA int spi_map_buf(struct spi_controller *ctlr, struct device *dev, struct sg_table *sgt, void *buf, size_t len,