* [PATCH 1/4] video1394: add poll file operation support
2006-08-08 19:18 [PATCH 0/4] ieee1394: misc updates Stefan Richter
@ 2006-08-08 19:21 ` Stefan Richter
2006-08-08 19:22 ` [PATCH 2/4] ieee1394: safer definition of empty macros Stefan Richter
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Richter @ 2006-08-08 19:21 UTC (permalink / raw)
To: linux-kernel; +Cc: Ben Collins, Andrew Morton, linux1394-devel
Date: Tue, 01 Aug 2006 19:00:31 -0400
From: David Moore <dcm@acm.org>
Subject: [PATCH] video1394: add poll file operation support
This patch adds support for the poll file operation to the video1394
driver.
Signed-off-by: David Moore <dcm@acm.org>
---
Index: linux/drivers/ieee1394/video1394.c
===================================================================
--- linux.orig/drivers/ieee1394/video1394.c 2006-08-02 18:23:28.000000000 +0200
+++ linux/drivers/ieee1394/video1394.c 2006-08-02 18:23:42.000000000 +0200
@@ -1181,7 +1181,8 @@ static int video1394_mmap(struct file *f
lock_kernel();
if (ctx->current_ctx == NULL) {
- PRINT(KERN_ERR, ctx->ohci->host->id, "Current iso context not set");
+ PRINT(KERN_ERR, ctx->ohci->host->id,
+ "Current iso context not set");
} else
res = dma_region_mmap(&ctx->current_ctx->dma, file, vma);
unlock_kernel();
@@ -1189,6 +1190,40 @@ static int video1394_mmap(struct file *f
return res;
}
+static unsigned int video1394_poll(struct file *file, poll_table *pt)
+{
+ struct file_ctx *ctx;
+ unsigned int mask = 0;
+ unsigned long flags;
+ struct dma_iso_ctx *d;
+ int i;
+
+ lock_kernel();
+ ctx = file->private_data;
+ d = ctx->current_ctx;
+ if (d == NULL) {
+ PRINT(KERN_ERR, ctx->ohci->host->id,
+ "Current iso context not set");
+ mask = POLLERR;
+ goto done;
+ }
+
+ poll_wait(file, &d->waitq, pt);
+
+ spin_lock_irqsave(&d->lock, flags);
+ for (i = 0; i < d->num_desc; i++) {
+ if (d->buffer_status[i] == VIDEO1394_BUFFER_READY) {
+ mask |= POLLIN | POLLRDNORM;
+ break;
+ }
+ }
+ spin_unlock_irqrestore(&d->lock, flags);
+done:
+ unlock_kernel();
+
+ return mask;
+}
+
static int video1394_open(struct inode *inode, struct file *file)
{
int i = ieee1394_file_to_instance(file);
@@ -1257,6 +1292,7 @@ static struct file_operations video1394_
#ifdef CONFIG_COMPAT
.compat_ioctl = video1394_compat_ioctl,
#endif
+ .poll = video1394_poll,
.mmap = video1394_mmap,
.open = video1394_open,
.release = video1394_release
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 2/4] ieee1394: safer definition of empty macros
2006-08-08 19:18 [PATCH 0/4] ieee1394: misc updates Stefan Richter
2006-08-08 19:21 ` [PATCH 1/4] video1394: add poll file operation support Stefan Richter
@ 2006-08-08 19:22 ` Stefan Richter
2006-08-08 19:24 ` [PATCH 3/4] ieee1394: sbp2: workaround for write protect bit of Initio firmware Stefan Richter
2006-08-08 19:25 ` [PATCH 4/4] ieee1394: sbp2: enable auto spin-up for all SBP-2 devices Stefan Richter
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Richter @ 2006-08-08 19:22 UTC (permalink / raw)
To: linux-kernel; +Cc: Ben Collins, Andrew Morton, linux1394-devel
A deactivated macro, defined as "#define foo(bar)", will result in
silent corruption if somebody forgets a semicolon after a call to foo.
Replace it by "#define foo(bar) do {} while (0)" which will reveal any
respective syntax errors.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
drivers/ieee1394/dv1394.c | 4 ++--
drivers/ieee1394/ieee1394_core.c | 2 +-
drivers/ieee1394/ieee1394_types.h | 2 +-
drivers/ieee1394/ohci1394.c | 8 ++++----
drivers/ieee1394/raw1394.c | 2 +-
drivers/ieee1394/sbp2.c | 18 +++++++++---------
drivers/ieee1394/video1394.c | 2 +-
7 files changed, 19 insertions(+), 19 deletions(-)
Index: linux/drivers/ieee1394/dv1394.c
===================================================================
--- linux.orig/drivers/ieee1394/dv1394.c 2006-07-29 20:11:13.000000000 +0200
+++ linux/drivers/ieee1394/dv1394.c 2006-08-01 20:36:25.000000000 +0200
@@ -137,13 +137,13 @@
#if DV1394_DEBUG_LEVEL >= 2
#define irq_printk( args... ) printk( args )
#else
-#define irq_printk( args... )
+#define irq_printk( args... ) do {} while (0)
#endif
#if DV1394_DEBUG_LEVEL >= 1
#define debug_printk( args... ) printk( args)
#else
-#define debug_printk( args... )
+#define debug_printk( args... ) do {} while (0)
#endif
/* issue a dummy PCI read to force the preceding write
Index: linux/drivers/ieee1394/ieee1394_core.c
===================================================================
--- linux.orig/drivers/ieee1394/ieee1394_core.c 2006-07-29 20:11:13.000000000 +0200
+++ linux/drivers/ieee1394/ieee1394_core.c 2006-08-01 20:37:04.000000000 +0200
@@ -85,7 +85,7 @@ static void dump_packet(const char *text
printk("\n");
}
#else
-#define dump_packet(a,b,c,d)
+#define dump_packet(a,b,c,d) do {} while (0)
#endif
static void abort_requests(struct hpsb_host *host);
Index: linux/drivers/ieee1394/ieee1394_types.h
===================================================================
--- linux.orig/drivers/ieee1394/ieee1394_types.h 2006-07-29 20:11:13.000000000 +0200
+++ linux/drivers/ieee1394/ieee1394_types.h 2006-08-01 20:37:55.000000000 +0200
@@ -41,7 +41,7 @@ typedef u16 arm_length_t;
#define HPSB_VERBOSE(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args)
#define HPSB_DEBUG_TLABELS
#else
-#define HPSB_VERBOSE(fmt, args...)
+#define HPSB_VERBOSE(fmt, args...) do {} while (0)
#endif
#ifdef __BIG_ENDIAN
Index: linux/drivers/ieee1394/ohci1394.c
===================================================================
--- linux.orig/drivers/ieee1394/ohci1394.c 2006-07-29 20:11:13.000000000 +0200
+++ linux/drivers/ieee1394/ohci1394.c 2006-08-01 20:53:27.000000000 +0200
@@ -136,7 +136,7 @@
#define DBGMSG(fmt, args...) \
printk(KERN_INFO "%s: fw-host%d: " fmt "\n" , OHCI1394_DRIVER_NAME, ohci->host->id , ## args)
#else
-#define DBGMSG(fmt, args...)
+#define DBGMSG(fmt, args...) do {} while (0)
#endif
#ifdef CONFIG_IEEE1394_OHCI_DMA_DEBUG
@@ -148,8 +148,8 @@ printk(KERN_INFO "%s: fw-host%d: " fmt "
--global_outstanding_dmas, ## args)
static int global_outstanding_dmas = 0;
#else
-#define OHCI_DMA_ALLOC(fmt, args...)
-#define OHCI_DMA_FREE(fmt, args...)
+#define OHCI_DMA_ALLOC(fmt, args...) do {} while (0)
+#define OHCI_DMA_FREE(fmt, args...) do {} while (0)
#endif
/* print general (card independent) information */
@@ -210,7 +210,7 @@ static inline void packet_swab(quadlet_t
}
#else
/* Don't waste cycles on same sex byte swaps */
-#define packet_swab(w,x)
+#define packet_swab(w,x) do {} while (0)
#endif /* !LITTLE_ENDIAN */
/***********************************
Index: linux/drivers/ieee1394/raw1394.c
===================================================================
--- linux.orig/drivers/ieee1394/raw1394.c 2006-07-29 20:11:13.000000000 +0200
+++ linux/drivers/ieee1394/raw1394.c 2006-08-01 20:39:34.000000000 +0200
@@ -67,7 +67,7 @@
#define DBGMSG(fmt, args...) \
printk(KERN_INFO "raw1394:" fmt "\n" , ## args)
#else
-#define DBGMSG(fmt, args...)
+#define DBGMSG(fmt, args...) do {} while (0)
#endif
static LIST_HEAD(host_info_list);
Index: linux/drivers/ieee1394/sbp2.c
===================================================================
--- linux.orig/drivers/ieee1394/sbp2.c 2006-07-29 20:11:13.000000000 +0200
+++ linux/drivers/ieee1394/sbp2.c 2006-08-01 20:54:17.000000000 +0200
@@ -203,9 +203,9 @@ static u32 global_outstanding_command_or
#define outstanding_orb_incr global_outstanding_command_orbs++
#define outstanding_orb_decr global_outstanding_command_orbs--
#else
-#define SBP2_ORB_DEBUG(fmt, args...)
-#define outstanding_orb_incr
-#define outstanding_orb_decr
+#define SBP2_ORB_DEBUG(fmt, args...) do {} while (0)
+#define outstanding_orb_incr do {} while (0)
+#define outstanding_orb_decr do {} while (0)
#endif
#ifdef CONFIG_IEEE1394_SBP2_DEBUG_DMA
@@ -217,8 +217,8 @@ static u32 global_outstanding_command_or
--global_outstanding_dmas, ## args)
static u32 global_outstanding_dmas = 0;
#else
-#define SBP2_DMA_ALLOC(fmt, args...)
-#define SBP2_DMA_FREE(fmt, args...)
+#define SBP2_DMA_ALLOC(fmt, args...) do {} while (0)
+#define SBP2_DMA_FREE(fmt, args...) do {} while (0)
#endif
#if CONFIG_IEEE1394_SBP2_DEBUG >= 2
@@ -232,7 +232,7 @@ static u32 global_outstanding_dmas = 0;
#define SBP2_NOTICE(fmt, args...) HPSB_NOTICE("sbp2: "fmt, ## args)
#define SBP2_WARN(fmt, args...) HPSB_WARN("sbp2: "fmt, ## args)
#else
-#define SBP2_DEBUG(fmt, args...)
+#define SBP2_DEBUG(fmt, args...) do {} while (0)
#define SBP2_INFO(fmt, args...) HPSB_INFO("sbp2: "fmt, ## args)
#define SBP2_NOTICE(fmt, args...) HPSB_NOTICE("sbp2: "fmt, ## args)
#define SBP2_WARN(fmt, args...) HPSB_WARN("sbp2: "fmt, ## args)
@@ -375,8 +375,8 @@ static inline void sbp2util_cpu_to_be32_
}
#else /* BIG_ENDIAN */
/* Why waste the cpu cycles? */
-#define sbp2util_be32_to_cpu_buffer(x,y)
-#define sbp2util_cpu_to_be32_buffer(x,y)
+#define sbp2util_be32_to_cpu_buffer(x,y) do {} while (0)
+#define sbp2util_cpu_to_be32_buffer(x,y) do {} while (0)
#endif
#ifdef CONFIG_IEEE1394_SBP2_PACKET_DUMP
@@ -412,7 +412,7 @@ static void sbp2util_packet_dump(void *b
return;
}
#else
-#define sbp2util_packet_dump(w,x,y,z)
+#define sbp2util_packet_dump(w,x,y,z) do {} while (0)
#endif
static DECLARE_WAIT_QUEUE_HEAD(access_wq);
Index: linux/drivers/ieee1394/video1394.c
===================================================================
--- linux.orig/drivers/ieee1394/video1394.c 2006-07-29 20:11:13.000000000 +0200
+++ linux/drivers/ieee1394/video1394.c 2006-08-01 20:42:56.000000000 +0200
@@ -129,7 +129,7 @@ struct file_ctx {
#define DBGMSG(card, fmt, args...) \
printk(KERN_INFO "video1394_%d: " fmt "\n" , card , ## args)
#else
-#define DBGMSG(card, fmt, args...)
+#define DBGMSG(card, fmt, args...) do {} while (0)
#endif
/* print general (card independent) information */
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 3/4] ieee1394: sbp2: workaround for write protect bit of Initio firmware
2006-08-08 19:18 [PATCH 0/4] ieee1394: misc updates Stefan Richter
2006-08-08 19:21 ` [PATCH 1/4] video1394: add poll file operation support Stefan Richter
2006-08-08 19:22 ` [PATCH 2/4] ieee1394: safer definition of empty macros Stefan Richter
@ 2006-08-08 19:24 ` Stefan Richter
2006-08-08 19:25 ` [PATCH 4/4] ieee1394: sbp2: enable auto spin-up for all SBP-2 devices Stefan Richter
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Richter @ 2006-08-08 19:24 UTC (permalink / raw)
To: linux-kernel; +Cc: Ben Collins, Andrew Morton, linux1394-devel
Yet another mode pages related bug of Initio firmwares was seen.
INIC-1530 with a firmware by Initio responded with garbage to MODE SENSE
(10). Some HDDs were therefore incorrectly marked as write protected:
http://bugzilla.kernel.org/show_bug.cgi?id=6947
Sbp2 now tells scsi_lib to use MODE SENSE (6) for the one known
defective model. The workaround could be expanded to other or perhaps
even all model IDs of Initio firmwares if necessary. At least it worked
OK with an INIC-2430 with different model ID and without the MS(10) bug.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
drivers/ieee1394/sbp2.c | 18 +++++++++++++++---
drivers/ieee1394/sbp2.h | 3 ++-
2 files changed, 17 insertions(+), 4 deletions(-)
Index: linux/drivers/ieee1394/sbp2.h
===================================================================
--- linux.orig/drivers/ieee1394/sbp2.h 2006-08-05 12:27:04.000000000 +0200
+++ linux/drivers/ieee1394/sbp2.h 2006-08-05 12:27:18.000000000 +0200
@@ -239,8 +239,9 @@ struct sbp2_status_block {
/* Flags for detected oddities and brokeness */
#define SBP2_WORKAROUND_128K_MAX_TRANS 0x1
#define SBP2_WORKAROUND_INQUIRY_36 0x2
-#define SBP2_WORKAROUND_MODE_SENSE_8 0x4
+#define SBP2_WORKAROUND_SKIP_PAGE_08 0x4
#define SBP2_WORKAROUND_FIX_CAPACITY 0x8
+#define SBP2_WORKAROUND_MODE_SENSE_6 0x10
#define SBP2_WORKAROUND_OVERRIDE 0x100
/* This is the two dma types we use for cmd_dma below */
Index: linux/drivers/ieee1394/sbp2.c
===================================================================
--- linux.orig/drivers/ieee1394/sbp2.c 2006-08-05 12:27:04.000000000 +0200
+++ linux/drivers/ieee1394/sbp2.c 2006-08-05 12:29:24.000000000 +0200
@@ -168,8 +168,9 @@ module_param_named(workarounds, sbp2_def
MODULE_PARM_DESC(workarounds, "Work around device bugs (default = 0"
", 128kB max transfer = " __stringify(SBP2_WORKAROUND_128K_MAX_TRANS)
", 36 byte inquiry = " __stringify(SBP2_WORKAROUND_INQUIRY_36)
- ", skip mode page 8 = " __stringify(SBP2_WORKAROUND_MODE_SENSE_8)
+ ", skip mode page 08 = " __stringify(SBP2_WORKAROUND_SKIP_PAGE_08)
", fix capacity = " __stringify(SBP2_WORKAROUND_FIX_CAPACITY)
+ ", use mode sense 6 = " __stringify(SBP2_WORKAROUND_MODE_SENSE_6)
", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE)
", or a combination)");
@@ -296,6 +297,10 @@ static struct hpsb_protocol_driver sbp2_
* The firmware_revision field, masked with 0xffff00, is the best indicator
* for the type of bridge chip of a device. It yields a few false positives
* but this did not break correctly behaving devices so far.
+ *
+ * The order of table entries is from special to general, like for example
+ * the Initio entries. This order is necessary because once an entry matches,
+ * the rest of the table is skipped.
*/
static const struct {
u32 firmware_revision;
@@ -306,7 +311,12 @@ static const struct {
.firmware_revision = 0x002800,
.model_id = 0x001010,
.workarounds = SBP2_WORKAROUND_INQUIRY_36 |
- SBP2_WORKAROUND_MODE_SENSE_8,
+ SBP2_WORKAROUND_SKIP_PAGE_08,
+ },
+ /* Initio INIC-1530 with a firmware apparently from Initio */ {
+ .firmware_revision = 0x000200,
+ .model_id = 0x000540,
+ .workarounds = SBP2_WORKAROUND_MODE_SENSE_6,
},
/* Initio bridges, actually only needed for some older ones */ {
.firmware_revision = 0x000200,
@@ -2457,10 +2467,12 @@ static int sbp2scsi_slave_configure(stru
sdev->use_10_for_ms = 1;
if (sdev->type == TYPE_DISK &&
- scsi_id->workarounds & SBP2_WORKAROUND_MODE_SENSE_8)
+ scsi_id->workarounds & SBP2_WORKAROUND_SKIP_PAGE_08)
sdev->skip_ms_page_8 = 1;
if (scsi_id->workarounds & SBP2_WORKAROUND_FIX_CAPACITY)
sdev->fix_capacity = 1;
+ if (scsi_id->workarounds & SBP2_WORKAROUND_MODE_SENSE_6)
+ sdev->use_10_for_ms = 0;
if (scsi_id->ne->guid_vendor_id == 0x0010b9 && /* Maxtor's OUI */
(sdev->type == TYPE_DISK || sdev->type == TYPE_RBC))
sdev->allow_restart = 1;
^ permalink raw reply [flat|nested] 5+ messages in thread