From: kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org
To: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>,
Lee Jones <lee-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>,
linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
Subject: [PATCH 3/3] spi: bcm2835: moved to the spi_transfer transformation to avoid HW restrictions
Date: Mon, 30 Nov 2015 13:04:54 +0000 [thread overview]
Message-ID: <1448888695-2260-4-git-send-email-kernel@martin.sperl.org> (raw)
In-Reply-To: <1448888695-2260-1-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
From: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
Moved to the new spi_transfer transformation methods to work arround
the HW restrictions in place arround DMA and alignment or max_length.
Signed-off-by: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
---
drivers/spi/spi-bcm2835.c | 53 ++++++++++++++++++---------------------------
1 file changed, 21 insertions(+), 32 deletions(-)
diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
index cf04960..67516f7 100644
--- a/drivers/spi/spi-bcm2835.c
+++ b/drivers/spi/spi-bcm2835.c
@@ -365,38 +365,6 @@ static bool bcm2835_spi_can_dma(struct spi_master *master,
if (tfr->len < BCM2835_SPI_DMA_MIN_LENGTH)
return false;
- /* BCM2835_SPI_DLEN has defined a max transfer size as
- * 16 bit, so max is 65535
- * we can revisit this by using an alternative transfer
- * method - ideally this would get done without any more
- * interaction...
- */
- if (tfr->len > 65535) {
- dev_warn_once(&spi->dev,
- "transfer size of %d too big for dma-transfer\n",
- tfr->len);
- return false;
- }
-
- /* if we run rx/tx_buf with word aligned addresses then we are OK */
- if ((((size_t)tfr->rx_buf & 3) == 0) &&
- (((size_t)tfr->tx_buf & 3) == 0))
- return true;
-
- /* otherwise we only allow transfers within the same page
- * to avoid wasting time on dma_mapping when it is not practical
- */
- if (((size_t)tfr->tx_buf & (PAGE_SIZE - 1)) + tfr->len > PAGE_SIZE) {
- dev_warn_once(&spi->dev,
- "Unaligned spi tx-transfer bridging page\n");
- return false;
- }
- if (((size_t)tfr->rx_buf & (PAGE_SIZE - 1)) + tfr->len > PAGE_SIZE) {
- dev_warn_once(&spi->dev,
- "Unaligned spi rx-transfer bridging page\n");
- return false;
- }
-
/* return OK */
return true;
}
@@ -598,8 +566,28 @@ static int bcm2835_spi_prepare_message(struct spi_master *master,
struct spi_device *spi = msg->spi;
struct bcm2835_spi *bs = spi_master_get_devdata(master);
u32 cs = bcm2835_rd(bs, BCM2835_SPI_CS);
+ int ret;
+
+ /* apply some spi_transfer transformations */
+
+ /* align transfers on words length - avoiding
+ * that the scatter/gather list produces transfers
+ * that are not a multiple of 4
+ */
+ ret = spi_split_transfers_first_page_len_not_aligned(
+ master, msg, true, 4);
+ if (ret)
+ return ret;
+
+ /* limit the max transfer size to 15 * PAGE_SIZE
+ * the bcm2835 HW limit is actually 65535, but to avoid
+ * another set of alignment issues we limit ourselves
+ */
+ ret = spi_split_transfers_maxsize(master, msg, 15 * PAGE_SIZE);
+ if (ret)
+ return ret;
+ /* setting up clock and data polarity prior to asserting GPIO-cs */
cs &= ~(BCM2835_SPI_CS_CPOL | BCM2835_SPI_CS_CPHA);
if (spi->mode & SPI_CPOL)
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2015-11-30 13:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-30 13:04 [PATCH 0/3] spi: spi-message transformation framework kernel-TqfNSX0MhmxHKSADF0wUEw
[not found] ` <1448888695-2260-1-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-11-30 13:04 ` [PATCH 1/3] spi: added spi_resource management kernel-TqfNSX0MhmxHKSADF0wUEw
[not found] ` <1448888695-2260-2-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-12-01 21:04 ` Mark Brown
[not found] ` <20151201210410.GU1929-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-12-02 7:30 ` Martin Sperl
[not found] ` <56C9120A-8979-4156-B3C4-5851D695BDF0-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-12-02 12:29 ` Mark Brown
[not found] ` <20151202122953.GG1929-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-12-02 13:04 ` Martin Sperl
[not found] ` <565EEC58.4040006-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-12-02 13:32 ` Mark Brown
[not found] ` <20151202133232.GK1929-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-12-02 13:53 ` Martin Sperl
2015-11-30 13:04 ` [PATCH 2/3] spi: add initial set of spi_transfer transformation methods kernel-TqfNSX0MhmxHKSADF0wUEw
[not found] ` <1448888695-2260-3-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-12-01 21:29 ` Mark Brown
[not found] ` <20151201212929.GV1929-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-12-02 7:25 ` Martin Sperl
[not found] ` <35C5C134-8291-4856-8916-7EDDFB07A0A9-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-12-03 0:36 ` Mark Brown
[not found] ` <20151203003618.GQ1929-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-12-03 6:22 ` Martin Sperl
[not found] ` <91B0D66C-97E5-4683-8896-091C4BD7FCAF-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-12-03 14:34 ` Mark Brown
[not found] ` <20151203143417.GE5727-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-12-03 15:33 ` Martin Sperl
[not found] ` <9DF774BE-EA2B-40E8-9CBF-E0A06AB5A751-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-12-03 18:04 ` Mark Brown
2015-11-30 13:04 ` kernel-TqfNSX0MhmxHKSADF0wUEw [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1448888695-2260-4-git-send-email-kernel@martin.sperl.org \
--to=kernel-tqfnsx0mhmxhksadf0wuew@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org \
--cc=lee-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).