From patchwork Fri Feb 10 15:29:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frode Isaksen X-Patchwork-Id: 9566993 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AE0D7601C3 for ; Fri, 10 Feb 2017 15:38:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B72A285A3 for ; Fri, 10 Feb 2017 15:38:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 904E1285A4; Fri, 10 Feb 2017 15:38:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B529285A2 for ; Fri, 10 Feb 2017 15:38:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752654AbdBJPiG (ORCPT ); Fri, 10 Feb 2017 10:38:06 -0500 Received: from mail-wr0-f179.google.com ([209.85.128.179]:33539 "EHLO mail-wr0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752385AbdBJPh2 (ORCPT ); Fri, 10 Feb 2017 10:37:28 -0500 Received: by mail-wr0-f179.google.com with SMTP id i10so110712407wrb.0 for ; Fri, 10 Feb 2017 07:36:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6XizEQptIfAa5DQVsfoe69Fg99gtgGqEelNUwu1XQFk=; b=aRHyZHY1VlbdbZ+nA6n5cWzN5AtW8gCr4Xm0vlOHxJaTFYXOAehj3R0Azv2k7SZAGs vdzyXGd0nKRpl58K22ZUXAVRYPJDt1sVj6+rJNModVQcX+eu5t28gZJlqwbqFSa4vnQd BW6EV9DyGZNLCBKa2LjXTWFcTlgchMTugWsfmqXuxKUyNmDgzsldS8gqd8KInEtZE1sA fOSvS9OdkcgIKV3nJFF6siXBTkDMm1YMkhaeeI+92oWXQ9cxeeRlZIeeh6v8kFbG65xO VNxuos86+jUJDdZMCzzbb5Rm7r8YlGIn72hFDrmnCyH5xCKEUcZ3TsAF7dxV9US1UdZn 0j8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6XizEQptIfAa5DQVsfoe69Fg99gtgGqEelNUwu1XQFk=; b=oDjY61PwILLyR5m6Sjs7otxAmIX+bYuoKyYWIGQuOjF9hSwHy/hNIHYZtOSIdWDzEQ IPrEkmSQoSRnLB5IMf1upqW87+t/pjZQKTbzNzb7gqXLtUHmGMpwl21aP7PkzR4IN8gd +Bwj1kX5crBvzlrX58LHF/nV9NKuzlR7GXD9es8rxAfCgC0sKLYqBaHsM4HMTllD0g6c E0Ry7gInuMWrC9T9MTYUxWoMkjKEvXBcBARjGSejO0nHFZQmQOEjYlGSOjh0jbWNBgCa NvTuHXyunV5BU70wZewg39fs7VceSkyOe+D2+lyq1O7yUX2TpvA4980sOHfpFAh5F9bY nuRg== X-Gm-Message-State: AMke39nES4LdvWlS+lEhfeC1RxZw225zBLzHeeIs8RuqeI4CbbwdbtfPR2AjFVV+7uhbUPeK X-Received: by 10.223.147.130 with SMTP id 2mr8223863wrp.53.1486740643022; Fri, 10 Feb 2017 07:30:43 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id o143sm2068192wmd.3.2017.02.10.07.30.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Feb 2017 07:30:42 -0800 (PST) From: Frode Isaksen To: nsekhar@ti.com, khilman@baylibre.com, ptitiano@baylibre.com, linux-arm-kernel@lists.infradead.org Cc: broonie@kernel.org, linux-spi@vger.kernel.org, Frode Isaksen Subject: [PATCH 3/8] spi: davinci: limit the transfer size if DMA enabled Date: Fri, 10 Feb 2017 16:29:39 +0100 Message-Id: <1486740584-17875-4-git-send-email-fisaksen@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486740584-17875-1-git-send-email-fisaksen@baylibre.com> References: <1486740584-17875-1-git-send-email-fisaksen@baylibre.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Limit the transfer size to 20 scatter/gather pages if DMA is enabled. The eDMA DMA engine is limited to 20 SG entries in one DMA transaction. If this number is exceeded, DMA receive fails. This error occurs with large vmalloc'ed buffers. Signed-off-by: Frode Isaksen --- drivers/spi/spi-davinci.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index b7b2da1..f1b46f6 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c @@ -485,6 +485,16 @@ static bool davinci_spi_can_dma(struct spi_master *master, return __davinci_spi_can_dma(spi); } +static size_t davinci_spi_max_transfer_size(struct spi_device *spi) +{ + /* + * The eDMA DMA engine is limited to 20 SG entries in one DMA + * transaction. If this number is exceeded, DMA receive fails. + * An extra SG entry is needed when the buffer is not page aligned. + */ + return (__davinci_spi_can_dma(spi)) ? 19 * PAGE_SIZE : SIZE_MAX; +} + static int davinci_spi_check_error(struct davinci_spi *dspi, int int_status) { struct device *sdev = dspi->bitbang.master->dev.parent; @@ -1010,6 +1020,7 @@ static int davinci_spi_probe(struct platform_device *pdev) master->setup = davinci_spi_setup; master->cleanup = davinci_spi_cleanup; master->can_dma = davinci_spi_can_dma; + master->max_transfer_size = davinci_spi_max_transfer_size; dspi->bitbang.chipselect = davinci_spi_chipselect; dspi->bitbang.setup_transfer = davinci_spi_setup_transfer;