All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: linux-ide@vger.kernel.org
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 07/10] ide: add ->dma_check method
Date: Fri, 20 Feb 2009 18:12:29 +0100	[thread overview]
Message-ID: <20090220171229.25429.16478.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20090220171139.25429.26702.sendpatchset@localhost.localdomain>

From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: add ->dma_check method

* Add (an optional) ->dma_check method for checking if DMA can be
  used for a given command and fail DMA setup in ide_dma_prepare()
  if necessary.

* Convert alim15x3 and trm290 host drivers to use ->dma_check.

* Rename ali15x3_dma_setup() to ali_dma_setup() while at it.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/alim15x3.c |    9 +++++----
 drivers/ide/ide-dma.c  |    5 ++++-
 drivers/ide/trm290.c   |   17 ++++++++++-------
 include/linux/ide.h    |    1 +
 4 files changed, 20 insertions(+), 12 deletions(-)

Index: b/drivers/ide/alim15x3.c
===================================================================
--- a/drivers/ide/alim15x3.c
+++ b/drivers/ide/alim15x3.c
@@ -189,20 +189,20 @@ static void ali_set_dma_mode(ide_drive_t
 }
 
 /**
- *	ali15x3_dma_setup	-	begin a DMA phase
+ *	ali_dma_check	-	DMA check
  *	@drive:	target device
  *	@cmd: command
  *
  *	Returns 1 if the DMA cannot be performed, zero on success.
  */
 
-static int ali15x3_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
+static int ali_dma_check(ide_drive_t *drive, struct ide_cmd *cmd)
 {
 	if (m5229_revision < 0xC2 && drive->media != ide_disk) {
 		if (cmd->tf_flags & IDE_TFLAG_WRITE)
 			return 1;	/* try PIO instead of DMA */
 	}
-	return ide_dma_setup(drive, cmd);
+	return 0;
 }
 
 /**
@@ -503,11 +503,12 @@ static const struct ide_port_ops ali_por
 
 static const struct ide_dma_ops ali_dma_ops = {
 	.dma_host_set		= ide_dma_host_set,
-	.dma_setup		= ali15x3_dma_setup,
+	.dma_setup		= ide_dma_setup,
 	.dma_start		= ide_dma_start,
 	.dma_end		= ide_dma_end,
 	.dma_test_irq		= ide_dma_test_irq,
 	.dma_lost_irq		= ide_dma_lost_irq,
+	.dma_check		= ali_dma_check,
 	.dma_timer_expiry	= ide_dma_sff_timer_expiry,
 	.dma_sff_read_status	= ide_dma_sff_read_status,
 };
Index: b/drivers/ide/ide-dma.c
===================================================================
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -562,9 +562,12 @@ EXPORT_SYMBOL_GPL(ide_allocate_dma_engin
 
 int ide_dma_prepare(ide_drive_t *drive, struct ide_cmd *cmd)
 {
+	const struct ide_dma_ops *dma_ops = drive->hwif->dma_ops;
+
 	if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0 ||
+	    (dma_ops->dma_check && dma_ops->dma_check(drive, cmd)) ||
 	    ide_build_sglist(drive, cmd) == 0 ||
-	    drive->hwif->dma_ops->dma_setup(drive, cmd))
+	    dma_ops->dma_setup(drive, cmd))
 		return 1;
 	return 0;
 }
Index: b/drivers/ide/trm290.c
===================================================================
--- a/drivers/ide/trm290.c
+++ b/drivers/ide/trm290.c
@@ -176,19 +176,21 @@ static void trm290_selectproc (ide_drive
 	trm290_prepare_drive(drive, !!(drive->dev_flags & IDE_DFLAG_USING_DMA));
 }
 
-static int trm290_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
+static int trm290_dma_check(ide_drive_t *drive, struct ide_cmd *cmd)
 {
-	ide_hwif_t *hwif = drive->hwif;
-	unsigned int count, rw;
-
 	if (cmd->tf_flags & IDE_TFLAG_WRITE) {
 #ifdef TRM290_NO_DMA_WRITES
 		/* always use PIO for writes */
 		return 1;
 #endif
-		rw = 1;
-	} else
-		rw = 2;
+	}
+	return 0;
+}
+
+static int trm290_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
+{
+	ide_hwif_t *hwif = drive->hwif;
+	unsigned int count, rw = (cmd->tf_flags & IDE_TFLAG_WRITE) ? 1 : 2;
 
 	count = ide_build_dmatable(drive, cmd);
 	if (count == 0) {
@@ -312,6 +314,7 @@ static struct ide_dma_ops trm290_dma_ops
 	.dma_end		= trm290_dma_end,
 	.dma_test_irq		= trm290_dma_test_irq,
 	.dma_lost_irq		= ide_dma_lost_irq,
+	.dma_check		= trm290_dma_check,
 };
 
 static const struct ide_port_info trm290_chipset __devinitdata = {
Index: b/include/linux/ide.h
===================================================================
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -716,6 +716,7 @@ struct ide_dma_ops {
 	int	(*dma_test_irq)(struct ide_drive_s *);
 	void	(*dma_lost_irq)(struct ide_drive_s *);
 	/* below ones are optional */
+	int	(*dma_check)(struct ide_drive_s *, struct ide_cmd *);
 	int	(*dma_timer_expiry)(struct ide_drive_s *);
 	void	(*dma_clear)(struct ide_drive_s *);
 	/*

  parent reply	other threads:[~2009-02-20 17:10 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-20 17:11 [PATCH 00/10] ide: DMA methods cleanups/sanitizations Bartlomiej Zolnierkiewicz
2009-02-20 17:11 ` [PATCH 01/10] ide: add ->dma_clear method and remove ->dma_timeout one Bartlomiej Zolnierkiewicz
2009-03-08 22:17   ` Sergei Shtylyov
2009-02-20 17:11 ` [PATCH 02/10] ide: inline ide_dma_timeout() into ide_dma_timeout_retry() Bartlomiej Zolnierkiewicz
2009-03-08 22:18   ` Sergei Shtylyov
2009-02-20 17:12 ` [PATCH 03/10] ide: destroy DMA mappings after ending DMA Bartlomiej Zolnierkiewicz
2009-03-09 14:00   ` Sergei Shtylyov
2009-03-14  7:12   ` Grant Grundler
2009-03-14 19:51     ` Bartlomiej Zolnierkiewicz
2009-03-14 20:45       ` Grant Grundler
2009-03-14 20:50         ` James Bottomley
2009-02-20 17:12 ` [PATCH 04/10] ide: add ide_dma_prepare() helper Bartlomiej Zolnierkiewicz
2009-03-09 14:36   ` Sergei Shtylyov
2009-02-20 17:12 ` [PATCH 05/10] ns87415: use custom ->dma_{start,end} to handle ns87415_prepare_drive() Bartlomiej Zolnierkiewicz
2009-03-08 22:22   ` Sergei Shtylyov
2009-02-20 17:12 ` [PATCH 06/10] trm290: use custom ->dma_{start,end} to handle trm290_prepare_drive() Bartlomiej Zolnierkiewicz
2009-03-08 22:26   ` Sergei Shtylyov
2009-02-20 17:12 ` Bartlomiej Zolnierkiewicz [this message]
2009-03-08 22:32   ` [PATCH 07/10] ide: add ->dma_check method Sergei Shtylyov
2009-03-11 16:36     ` Bartlomiej Zolnierkiewicz
2009-02-20 17:12 ` [PATCH 08/10] ide: move ide_map_sg() call out from ->dma_setup method Bartlomiej Zolnierkiewicz
2009-03-09 14:42   ` Sergei Shtylyov
2009-03-11 16:36     ` Bartlomiej Zolnierkiewicz
2009-03-11 17:10       ` Sergei Shtylyov
2009-03-11 17:36         ` Bartlomiej Zolnierkiewicz
2009-02-20 17:12 ` [PATCH 09/10] ide: set/clear drive->waiting_for_dma flag in the core code Bartlomiej Zolnierkiewicz
2009-03-10 15:05   ` Sergei Shtylyov
2009-02-20 17:12 ` [PATCH 10/10] ide: sanitize ide_build_sglist() and ide_destroy_dmatable() Bartlomiej Zolnierkiewicz

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=20090220171229.25429.16478.sendpatchset@localhost.localdomain \
    --to=bzolnier@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.