* [PATCH 2.6.18-rc4-mm1 0/8] ieee1394: fixes and touch-ups for sbp2
@ 2006-08-14 17:40 Stefan Richter
2006-08-14 17:42 ` [PATCH 2.6.18-rc4-mm1 1/8] the scheduled removal of drivers/ieee1394/sbp2.c:force_inquiry_hack Stefan Richter
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Stefan Richter @ 2006-08-14 17:40 UTC (permalink / raw)
To: linux1394-devel; +Cc: Ben Collins, Andrew Morton, linux-kernel
Here are 5 bug fixes for sbp2, 2 code updates, 1 Kconfig improvement.
If nothing gets in the way I will probably resend some of these fixes
and one or two which are already in -mm for proposed inclusion into
2.6.18-rcX circa next Monday.
Adrian Bunk:
[resend] the scheduled removal of drivers/ieee1394/sbp2.c:force_inquiry_hack
Stefan Richter:
[update] ieee1394: sbp2: handle "sbp2util_node_write_no_wait failed"
[new ] ieee1394: sbp2: safer agent reset in error handlers
[new ] ieee1394: sbp2: recheck node generation in sbp2_update
[new ] ieee1394: sbp2: better handling of transport errors
[new ] ieee1394: sbp2: select SCSI in Kconfig
[new ] ieee1394: sbp2: update includes
[new ] ieee1394: sbp2: prevent rare deadlock in shutdown
Documentation/feature-removal-schedule.txt | 9 -
drivers/ieee1394/Kconfig | 12 +
drivers/ieee1394/sbp2.c | 166 ++++++++++++++-------
drivers/ieee1394/sbp2.h | 16 +-
4 files changed, 137 insertions(+), 66 deletions(-)
--
Stefan Richter
-=====-=-==- =--- -===-
http://arcgraph.de/sr/
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2.6.18-rc4-mm1 1/8] the scheduled removal of drivers/ieee1394/sbp2.c:force_inquiry_hack
2006-08-14 17:40 [PATCH 2.6.18-rc4-mm1 0/8] ieee1394: fixes and touch-ups for sbp2 Stefan Richter
@ 2006-08-14 17:42 ` Stefan Richter
2006-08-14 17:45 ` [PATCH 2.6.18-rc4-mm1 2/8] ieee1394: sbp2: handle "sbp2util_node_write_no_wait failed" Stefan Richter
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Stefan Richter @ 2006-08-14 17:42 UTC (permalink / raw)
To: linux1394-devel; +Cc: Ben Collins, Andrew Morton, linux-kernel
Date: Sat, 29 Jul 2006 19:48:28 +0200
From: Adrian Bunk <bunk@stusta.de>
Subject: the scheduled removal of drivers/ieee1394/sbp2.c:force_inquiry_hack
This patch contains the scheduled removal of the force_inquiry_hack
module parameter.
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
Documentation/feature-removal-schedule.txt | 9 ---------
drivers/ieee1394/sbp2.c | 10 ----------
2 files changed, 19 deletions(-)
Index: linux-2.6.18-rc4-mm1/Documentation/feature-removal-schedule.txt
===================================================================
--- linux-2.6.18-rc4-mm1.orig/Documentation/feature-removal-schedule.txt 2006-08-14 18:12:47.000000000 +0200
+++ linux-2.6.18-rc4-mm1/Documentation/feature-removal-schedule.txt 2006-08-14 18:21:46.000000000 +0200
@@ -23,15 +23,6 @@ Who: Jody McIntyre <scjody@modernduck.co
---------------------------
-What: sbp2: module parameter "force_inquiry_hack"
-When: July 2006
-Why: Superceded by parameter "workarounds". Both parameters are meant to be
- used ad-hoc and for single devices only, i.e. not in modprobe.conf,
- therefore the impact of this feature replacement should be low.
-Who: Stefan Richter <stefanr@s5r6.in-berlin.de>
-
----------------------------
-
What: Video4Linux API 1 ioctls and video_decoder.h from Video devices.
When: July 2006
Why: V4L1 AP1 was replaced by V4L2 API. during migration from 2.4 to 2.6
Index: linux-2.6.18-rc4-mm1/drivers/ieee1394/sbp2.c
===================================================================
--- linux-2.6.18-rc4-mm1.orig/drivers/ieee1394/sbp2.c 2006-08-14 18:12:59.000000000 +0200
+++ linux-2.6.18-rc4-mm1/drivers/ieee1394/sbp2.c 2006-08-14 18:21:46.000000000 +0200
@@ -174,11 +174,6 @@ MODULE_PARM_DESC(workarounds, "Work arou
", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE)
", or a combination)");
-/* legacy parameter */
-static int force_inquiry_hack;
-module_param(force_inquiry_hack, int, 0644);
-MODULE_PARM_DESC(force_inquiry_hack, "Deprecated, use 'workarounds'");
-
/*
* Export information about protocols/devices supported by this driver.
*/
@@ -1564,11 +1559,6 @@ static void sbp2_parse_unit_directory(st
}
workarounds = sbp2_default_workarounds;
- if (force_inquiry_hack) {
- SBP2_WARN("force_inquiry_hack is deprecated. "
- "Use parameter 'workarounds' instead.");
- workarounds |= SBP2_WORKAROUND_INQUIRY_36;
- }
if (!(workarounds & SBP2_WORKAROUND_OVERRIDE))
for (i = 0; i < ARRAY_SIZE(sbp2_workarounds_table); i++) {
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2.6.18-rc4-mm1 2/8] ieee1394: sbp2: handle "sbp2util_node_write_no_wait failed"
2006-08-14 17:40 [PATCH 2.6.18-rc4-mm1 0/8] ieee1394: fixes and touch-ups for sbp2 Stefan Richter
2006-08-14 17:42 ` [PATCH 2.6.18-rc4-mm1 1/8] the scheduled removal of drivers/ieee1394/sbp2.c:force_inquiry_hack Stefan Richter
@ 2006-08-14 17:45 ` Stefan Richter
2006-08-14 17:47 ` [PATCH 2.6.18-rc4-mm1 3/8] ieee1394: sbp2: safer agent reset in error handlers Stefan Richter
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Stefan Richter @ 2006-08-14 17:45 UTC (permalink / raw)
To: linux1394-devel; +Cc: Ben Collins, Andrew Morton, linux-kernel
Fix for http://bugzilla.kernel.org/show_bug.cgi?id=6948
Because sbp2 writes to the target's fetch agent's registers from within
atomic context, it cannot sleep to guaranteedly get a free transaction
label. This may repeatedly lead to "sbp2util_node_write_no_wait failed"
and consequently to SCSI command abortion after timeout. A likely cause
is that many queue_command softirqs may occur before khpsbpkt (the
ieee1394 driver's thread which cleans up after finished transactions) is
woken up to recycle tlabels.
Sbp2 now schedules a workqueue job whenever sbp2_link_orb_command fails
in sbp2util_node_write_no_wait. The job will reliably get a transaction
label because it can sleep.
We use the kernel-wide shared workqueue because it is unlikely that the
job itself actually needs to sleep. In the improbable case that it has
to sleep, it doesn't need to sleep long since the standard transaction
timeout is 100ms.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
drivers/ieee1394/sbp2.c | 71 +++++++++++++++++++++++++++++++++++++---
drivers/ieee1394/sbp2.h | 3 +
2 files changed, 69 insertions(+), 5 deletions(-)
Index: linux/drivers/ieee1394/sbp2.h
===================================================================
--- linux.orig/drivers/ieee1394/sbp2.h 2006-08-13 23:40:12.000000000 +0200
+++ linux/drivers/ieee1394/sbp2.h 2006-08-14 00:21:34.000000000 +0200
@@ -347,6 +347,9 @@ struct scsi_id_instance_data {
/* Device specific workarounds/brokeness */
unsigned workarounds;
+
+ atomic_t unfinished_reset;
+ struct work_struct protocol_work;
};
/* Sbp2 host data structure (one per IEEE1394 host) */
Index: linux/drivers/ieee1394/sbp2.c
===================================================================
--- linux.orig/drivers/ieee1394/sbp2.c 2006-08-14 00:20:26.000000000 +0200
+++ linux/drivers/ieee1394/sbp2.c 2006-08-14 00:21:55.000000000 +0200
@@ -475,6 +475,44 @@ static int sbp2util_node_write_no_wait(s
return 0;
}
+static void sbp2util_notify_fetch_agent(struct scsi_id_instance_data *scsi_id,
+ u64 offset, quadlet_t *data, size_t len)
+{
+ /*
+ * There is a small window after a bus reset within which the node
+ * entry's generation is current but the reconnect wasn't completed.
+ */
+ if (atomic_read(&scsi_id->unfinished_reset))
+ return;
+
+ if (hpsb_node_write(scsi_id->ne,
+ scsi_id->sbp2_command_block_agent_addr + offset,
+ data, len))
+ SBP2_ERR("sbp2util_notify_fetch_agent failed.");
+ /*
+ * Now accept new SCSI commands, unless a bus reset happended during
+ * hpsb_node_write.
+ */
+ if (!atomic_read(&scsi_id->unfinished_reset))
+ scsi_unblock_requests(scsi_id->scsi_host);
+}
+
+static void sbp2util_write_orb_pointer(void *p)
+{
+ quadlet_t data[2];
+
+ data[0] = ORB_SET_NODE_ID(
+ ((struct scsi_id_instance_data *)p)->hi->host->node_id);
+ data[1] = ((struct scsi_id_instance_data *)p)->last_orb_dma;
+ sbp2util_cpu_to_be32_buffer(data, 8);
+ sbp2util_notify_fetch_agent(p, SBP2_ORB_POINTER_OFFSET, data, 8);
+}
+
+static void sbp2util_write_doorbell(void *p)
+{
+ sbp2util_notify_fetch_agent(p, SBP2_DOORBELL_OFFSET, NULL, 4);
+}
+
/*
* This function is called to create a pool of command orbs used for
* command processing. It is called when a new sbp2 device is detected.
@@ -722,6 +760,7 @@ static int sbp2_remove(struct device *de
sbp2scsi_complete_all_commands(scsi_id, DID_NO_CONNECT);
/* scsi_remove_device() will trigger shutdown functions of SCSI
* highlevel drivers which would deadlock if blocked. */
+ atomic_set(&scsi_id->unfinished_reset, 0);
scsi_unblock_requests(scsi_id->scsi_host);
}
sdev = scsi_id->sdev;
@@ -775,6 +814,7 @@ static int sbp2_update(struct unit_direc
/* Make sure we unblock requests (since this is likely after a bus
* reset). */
+ atomic_set(&scsi_id->unfinished_reset, 0);
scsi_unblock_requests(scsi_id->scsi_host);
return 0;
@@ -805,6 +845,8 @@ static struct scsi_id_instance_data *sbp
INIT_LIST_HEAD(&scsi_id->sbp2_command_orb_completed);
INIT_LIST_HEAD(&scsi_id->scsi_list);
spin_lock_init(&scsi_id->sbp2_command_orb_lock);
+ atomic_set(&scsi_id->unfinished_reset, 0);
+ INIT_WORK(&scsi_id->protocol_work, NULL, NULL);
ud->device.driver_data = scsi_id;
@@ -889,8 +931,10 @@ static void sbp2_host_reset(struct hpsb_
hi = hpsb_get_hostinfo(&sbp2_highlevel, host);
if (hi) {
- list_for_each_entry(scsi_id, &hi->scsi_ids, scsi_list)
+ list_for_each_entry(scsi_id, &hi->scsi_ids, scsi_list) {
+ atomic_set(&scsi_id->unfinished_reset, 1);
scsi_block_requests(scsi_id->scsi_host);
+ }
}
}
@@ -1042,7 +1086,7 @@ static void sbp2_remove_device(struct sc
scsi_remove_host(scsi_id->scsi_host);
scsi_host_put(scsi_id->scsi_host);
}
-
+ flush_scheduled_work();
sbp2util_remove_command_orb_pool(scsi_id);
list_del(&scsi_id->scsi_list);
@@ -1671,6 +1715,10 @@ static int sbp2_agent_reset(struct scsi_
SBP2_DEBUG_ENTER();
+ cancel_delayed_work(&scsi_id->protocol_work);
+ if (wait)
+ flush_scheduled_work();
+
data = ntohl(SBP2_AGENT_RESET_DATA);
addr = scsi_id->sbp2_command_block_agent_addr + SBP2_AGENT_RESET_OFFSET;
@@ -1992,9 +2040,22 @@ static void sbp2_link_orb_command(struct
SBP2_ORB_DEBUG("write to %s register, command orb %p",
last_orb ? "DOORBELL" : "ORB_POINTER", command_orb);
- if (sbp2util_node_write_no_wait(scsi_id->ne, addr, data, length))
- SBP2_ERR("sbp2util_node_write_no_wait failed.\n");
- /* We rely on SCSI EH to deal with _node_write_ failures. */
+ if (sbp2util_node_write_no_wait(scsi_id->ne, addr, data, length)) {
+ /*
+ * sbp2util_node_write_no_wait failed. We certainly ran out
+ * of transaction labels, perhaps just because there were no
+ * context switches which gave khpsbpkt a chance to collect
+ * free tlabels. Try again in non-atomic context. If necessary,
+ * the workqueue job will sleep to guaranteedly get a tlabel.
+ * We do not accept new commands until the job is over.
+ */
+ scsi_block_requests(scsi_id->scsi_host);
+ PREPARE_WORK(&scsi_id->protocol_work,
+ last_orb ? sbp2util_write_doorbell:
+ sbp2util_write_orb_pointer,
+ scsi_id);
+ schedule_work(&scsi_id->protocol_work);
+ }
}
/*
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2.6.18-rc4-mm1 3/8] ieee1394: sbp2: safer agent reset in error handlers
2006-08-14 17:40 [PATCH 2.6.18-rc4-mm1 0/8] ieee1394: fixes and touch-ups for sbp2 Stefan Richter
2006-08-14 17:42 ` [PATCH 2.6.18-rc4-mm1 1/8] the scheduled removal of drivers/ieee1394/sbp2.c:force_inquiry_hack Stefan Richter
2006-08-14 17:45 ` [PATCH 2.6.18-rc4-mm1 2/8] ieee1394: sbp2: handle "sbp2util_node_write_no_wait failed" Stefan Richter
@ 2006-08-14 17:47 ` Stefan Richter
2006-08-14 17:48 ` [PATCH 2.6.18-rc4-mm1 4/8] ieee1394: sbp2: recheck node generation in sbp2_update Stefan Richter
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Stefan Richter @ 2006-08-14 17:47 UTC (permalink / raw)
To: linux1394-devel; +Cc: Ben Collins, Andrew Morton, linux-kernel
The scsi_host_template's eh_abort_handler and eh_device_reset_handler
are allowed to sleep. Use this to run sbp2_agent_reset in the more
reliable mode which returns _after_ its write transaction was finished.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
Index: linux/drivers/ieee1394/sbp2.c
===================================================================
--- linux.orig/drivers/ieee1394/sbp2.c 2006-08-14 00:21:55.000000000 +0200
+++ linux/drivers/ieee1394/sbp2.c 2006-08-14 00:22:32.000000000 +0200
@@ -2588,7 +2588,7 @@ static int sbp2scsi_abort(struct scsi_cm
/*
* Initiate a fetch agent reset.
*/
- sbp2_agent_reset(scsi_id, 0);
+ sbp2_agent_reset(scsi_id, 1);
sbp2scsi_complete_all_commands(scsi_id, DID_BUS_BUSY);
}
@@ -2607,7 +2607,7 @@ static int sbp2scsi_reset(struct scsi_cm
if (sbp2util_node_is_available(scsi_id)) {
SBP2_ERR("Generating sbp2 fetch agent reset");
- sbp2_agent_reset(scsi_id, 0);
+ sbp2_agent_reset(scsi_id, 1);
}
return SUCCESS;
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2.6.18-rc4-mm1 4/8] ieee1394: sbp2: recheck node generation in sbp2_update
2006-08-14 17:40 [PATCH 2.6.18-rc4-mm1 0/8] ieee1394: fixes and touch-ups for sbp2 Stefan Richter
` (2 preceding siblings ...)
2006-08-14 17:47 ` [PATCH 2.6.18-rc4-mm1 3/8] ieee1394: sbp2: safer agent reset in error handlers Stefan Richter
@ 2006-08-14 17:48 ` Stefan Richter
2006-08-14 17:49 ` [PATCH 2.6.18-rc4-mm1 5/8] ieee1394: sbp2: better handling of transport errors Stefan Richter
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Stefan Richter @ 2006-08-14 17:48 UTC (permalink / raw)
To: linux1394-devel; +Cc: Ben Collins, Andrew Morton, linux-kernel
While sbp2_update() is doing its duties after a bus reset, another reset
could happen. Don't accept new requests until the next undisturbed
sbp2_update() or until sbp2_remove().
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
Index: linux/drivers/ieee1394/sbp2.c
===================================================================
--- linux.orig/drivers/ieee1394/sbp2.c 2006-08-14 00:22:32.000000000 +0200
+++ linux/drivers/ieee1394/sbp2.c 2006-08-14 00:27:15.000000000 +0200
@@ -812,11 +812,12 @@ static int sbp2_update(struct unit_direc
*/
sbp2scsi_complete_all_commands(scsi_id, DID_BUS_BUSY);
- /* Make sure we unblock requests (since this is likely after a bus
- * reset). */
- atomic_set(&scsi_id->unfinished_reset, 0);
- scsi_unblock_requests(scsi_id->scsi_host);
-
+ /* Accept new commands unless there was another bus reset in the
+ * meantime. */
+ if (hpsb_node_entry_valid(scsi_id->ne)) {
+ atomic_set(&scsi_id->unfinished_reset, 0);
+ scsi_unblock_requests(scsi_id->scsi_host);
+ }
return 0;
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2.6.18-rc4-mm1 5/8] ieee1394: sbp2: better handling of transport errors
2006-08-14 17:40 [PATCH 2.6.18-rc4-mm1 0/8] ieee1394: fixes and touch-ups for sbp2 Stefan Richter
` (3 preceding siblings ...)
2006-08-14 17:48 ` [PATCH 2.6.18-rc4-mm1 4/8] ieee1394: sbp2: recheck node generation in sbp2_update Stefan Richter
@ 2006-08-14 17:49 ` Stefan Richter
2006-08-14 17:50 ` [PATCH 2.6.18-rc4-mm1 6/8] ieee1394: sbp2: select SCSI in Kconfig Stefan Richter
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Stefan Richter @ 2006-08-14 17:49 UTC (permalink / raw)
To: linux1394-devel; +Cc: Ben Collins, Andrew Morton, linux-kernel
If the target signals a transport failure via status block, complete the
request with DID_BUSY to indicate to the SCSI subsystem that the command
may succeed when retried.
Also log diagnostic information if the status block shows a transport
related problem. It may point to hardware faults.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
drivers/ieee1394/sbp2.c | 16 +++++++++++-----
drivers/ieee1394/sbp2.h | 6 +++---
2 files changed, 14 insertions(+), 8 deletions(-)
Index: linux/drivers/ieee1394/sbp2.h
===================================================================
--- linux.orig/drivers/ieee1394/sbp2.h
+++ linux/drivers/ieee1394/sbp2.h
@@ -181,11 +181,11 @@ struct sbp2_unrestricted_page_table {
#define SBP2_SCSI_STATUS_SELECTION_TIMEOUT 0xff
#define STATUS_GET_SRC(value) (((value) >> 30) & 0x3)
+#define STATUS_GET_RESP(value) (((value) >> 28) & 0x3)
#define STATUS_GET_LEN(value) (((value) >> 24) & 0x7)
+#define STATUS_GET_SBP_STATUS(value) (((value) >> 16) & 0xff)
#define STATUS_GET_ORB_OFFSET_HI(value) ((value) & 0x0000ffff)
-#define STATUS_TEST_D(value) ((value) & 0x08000000)
-/* test 'resp' | 'sbp2_status' */
-#define STATUS_TEST_RS(value) ((value) & 0x30ff0000)
+#define STATUS_TEST_DEAD(value) ((value) & 0x08000000)
/* test 'resp' | 'dead' | 'sbp2_status' */
#define STATUS_TEST_RDS(value) ((value) & 0x38ff0000)
Index: linux/drivers/ieee1394/sbp2.c
===================================================================
--- linux.orig/drivers/ieee1394/sbp2.c
+++ linux/drivers/ieee1394/sbp2.c
@@ -2223,28 +2223,34 @@ static int sbp2_handle_status_write(stru
spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
if (SCpnt) {
- if (STATUS_TEST_RS(sb->ORB_offset_hi_misc))
+ u32 h = sb->ORB_offset_hi_misc;
+ u32 r = STATUS_GET_RESP(h);
+
+ if (r != RESP_STATUS_REQUEST_COMPLETE) {
+ SBP2_WARN("resp 0x%x, sbp_status 0x%x",
+ r, STATUS_GET_SBP_STATUS(h));
scsi_status =
+ r == RESP_STATUS_TRANSPORT_FAILURE ?
+ SBP2_SCSI_STATUS_BUSY :
SBP2_SCSI_STATUS_COMMAND_TERMINATED;
+ }
/*
* See if the target stored any scsi status information.
*/
- if (STATUS_GET_LEN(sb->ORB_offset_hi_misc) > 1) {
+ if (STATUS_GET_LEN(h) > 1) {
SBP2_DEBUG("CHECK CONDITION");
scsi_status = sbp2_status_to_sense_data(
(unchar *)sb, SCpnt->sense_buffer);
}
-
/*
* Check to see if the dead bit is set. If so, we'll
* have to initiate a fetch agent reset.
*/
- if (STATUS_TEST_D(sb->ORB_offset_hi_misc)) {
+ if (STATUS_TEST_DEAD(h)) {
SBP2_DEBUG("Dead bit set - "
"initiating fetch agent reset");
sbp2_agent_reset(scsi_id, 0);
}
-
SBP2_ORB_DEBUG("completing command orb %p", &command->command_orb);
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2.6.18-rc4-mm1 6/8] ieee1394: sbp2: select SCSI in Kconfig
2006-08-14 17:40 [PATCH 2.6.18-rc4-mm1 0/8] ieee1394: fixes and touch-ups for sbp2 Stefan Richter
` (4 preceding siblings ...)
2006-08-14 17:49 ` [PATCH 2.6.18-rc4-mm1 5/8] ieee1394: sbp2: better handling of transport errors Stefan Richter
@ 2006-08-14 17:50 ` Stefan Richter
2006-08-14 17:51 ` [PATCH 2.6.18-rc4-mm1 7/8] ieee1394: sbp2: update includes Stefan Richter
2006-08-14 17:53 ` [PATCH 2.6.18-rc4-mm1 8/8] ieee1394: sbp2: prevent rare deadlock in shutdown Stefan Richter
7 siblings, 0 replies; 9+ messages in thread
From: Stefan Richter @ 2006-08-14 17:50 UTC (permalink / raw)
To: linux1394-devel; +Cc: Ben Collins, Andrew Morton, linux-kernel
Konfiguration menu item of sbp2: Replace 'depends on SCSI' by 'select
SCSI'. Extend help text.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
Index: linux/drivers/ieee1394/Kconfig
===================================================================
--- linux.orig/drivers/ieee1394/Kconfig 2006-08-13 23:11:34.000000000 +0200
+++ linux/drivers/ieee1394/Kconfig 2006-08-14 00:28:03.000000000 +0200
@@ -122,10 +122,16 @@ config IEEE1394_VIDEO1394
config IEEE1394_SBP2
tristate "SBP-2 support (Harddisks etc.)"
- depends on IEEE1394 && SCSI && (PCI || BROKEN)
+ depends on IEEE1394 && (PCI || BROKEN)
+ select SCSI
help
- This option enables you to use SBP-2 devices connected to your IEEE
- 1394 bus. SBP-2 devices include harddrives and DVD devices.
+ This option enables you to use SBP-2 devices connected to an IEEE
+ 1394 bus. SBP-2 devices include storage devices like harddisks and
+ DVD drives, also some other FireWire devices like scanners.
+
+ This option depends on and will select basic SCSI support. You
+ should also enable support for disks, CD-ROMs, etc. in the SCSI
+ configuration section.
config IEEE1394_SBP2_PHYS_DMA
bool "Enable replacement for physical DMA in SBP2"
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2.6.18-rc4-mm1 7/8] ieee1394: sbp2: update includes
2006-08-14 17:40 [PATCH 2.6.18-rc4-mm1 0/8] ieee1394: fixes and touch-ups for sbp2 Stefan Richter
` (5 preceding siblings ...)
2006-08-14 17:50 ` [PATCH 2.6.18-rc4-mm1 6/8] ieee1394: sbp2: select SCSI in Kconfig Stefan Richter
@ 2006-08-14 17:51 ` Stefan Richter
2006-08-14 17:53 ` [PATCH 2.6.18-rc4-mm1 8/8] ieee1394: sbp2: prevent rare deadlock in shutdown Stefan Richter
7 siblings, 0 replies; 9+ messages in thread
From: Stefan Richter @ 2006-08-14 17:51 UTC (permalink / raw)
To: linux1394-devel; +Cc: Ben Collins, Andrew Morton, linux-kernel
Remove unused includes. Add missing includes, i.e. explicitly include
all used headers. Sort includes alphabetically. Replace one call to
signal_pending(current) to avoid to include headers just for this line.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
drivers/ieee1394/sbp2.c | 49 ++++++++++++++++++++++------------------
1 files changed, 27 insertions(+), 22 deletions(-)
Index: linux/drivers/ieee1394/sbp2.c
===================================================================
--- linux.orig/drivers/ieee1394/sbp2.c 2006-08-14 00:27:43.000000000 +0200
+++ linux/drivers/ieee1394/sbp2.c 2006-08-14 00:28:25.000000000 +0200
@@ -38,31 +38,36 @@
* but the code needs additional debugging.
*/
+#include <linux/blkdev.h>
+#include <linux/compiler.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/dma-mapping.h>
+#include <linux/gfp.h>
+#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/list.h>
-#include <linux/string.h>
-#include <linux/stringify.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/fs.h>
-#include <linux/poll.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
-#include <linux/types.h>
-#include <linux/delay.h>
-#include <linux/sched.h>
-#include <linux/blkdev.h>
-#include <linux/smp_lock.h>
-#include <linux/init.h>
#include <linux/pci.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/stat.h>
+#include <linux/string.h>
+#include <linux/stringify.h>
+#include <linux/types.h>
#include <linux/wait.h>
-#include <asm/current.h>
-#include <asm/uaccess.h>
-#include <asm/io.h>
#include <asm/byteorder.h>
-#include <asm/system.h>
+#include <asm/errno.h>
+#include <asm/param.h>
#include <asm/scatterlist.h>
+#include <asm/system.h>
+#include <asm/types.h>
+
+#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
+#include <asm/io.h> /* for bus_to_virt */
+#endif
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
@@ -71,13 +76,14 @@
#include <scsi/scsi_host.h>
#include "csr1212.h"
+#include "highlevel.h"
+#include "hosts.h"
#include "ieee1394.h"
-#include "ieee1394_types.h"
#include "ieee1394_core.h"
-#include "nodemgr.h"
-#include "hosts.h"
-#include "highlevel.h"
+#include "ieee1394_hotplug.h"
#include "ieee1394_transactions.h"
+#include "ieee1394_types.h"
+#include "nodemgr.h"
#include "sbp2.h"
/*
@@ -1021,8 +1027,7 @@ static int sbp2_start_device(struct scsi
* connected to the sbp2 device being removed. That host would
* have a certain amount of time to relogin before the sbp2 device
* allows someone else to login instead. One second makes sense. */
- msleep_interruptible(1000);
- if (signal_pending(current)) {
+ if (msleep_interruptible(1000)) {
sbp2_remove_device(scsi_id);
return -EINTR;
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2.6.18-rc4-mm1 8/8] ieee1394: sbp2: prevent rare deadlock in shutdown
2006-08-14 17:40 [PATCH 2.6.18-rc4-mm1 0/8] ieee1394: fixes and touch-ups for sbp2 Stefan Richter
` (6 preceding siblings ...)
2006-08-14 17:51 ` [PATCH 2.6.18-rc4-mm1 7/8] ieee1394: sbp2: update includes Stefan Richter
@ 2006-08-14 17:53 ` Stefan Richter
7 siblings, 0 replies; 9+ messages in thread
From: Stefan Richter @ 2006-08-14 17:53 UTC (permalink / raw)
To: linux1394-devel; +Cc: Ben Collins, Andrew Morton, linux-kernel
Scsi_remove_device() may go into uninterruptible sleep if blocked.
Therefore sbp2_remove() unblocks the Scsi_Host before the device is
requested to be removed. But there could be another 1394 bus reset
after that which would block the host again. The 1394 subsystem won't
call sbp2_update() concurrently to sbp2_remove(), which is why there is
no chance for sbp2_remove() to be unblocked by sbp2_update().
The fix is to tell sbp2's bus reset handler when a device is to be shut
down so that it skips scsi_block_requests() on that host. As before,
any new commands after a reset without reconnect will be failed quickly
by sbp2scsi_queuecommand().
In the long term, means to go without scsi_block_requests() should be
found.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
drivers/ieee1394/sbp2.c | 21 +++++++++++----------
drivers/ieee1394/sbp2.h | 9 ++++++++-
2 files changed, 19 insertions(+), 11 deletions(-)
Index: linux/drivers/ieee1394/sbp2.h
===================================================================
--- linux.orig/drivers/ieee1394/sbp2.h 2006-08-14 12:46:13.000000000 +0200
+++ linux/drivers/ieee1394/sbp2.h 2006-08-14 17:21:32.000000000 +0200
@@ -348,10 +348,17 @@ struct scsi_id_instance_data {
/* Device specific workarounds/brokeness */
unsigned workarounds;
- atomic_t unfinished_reset;
+ atomic_t state;
struct work_struct protocol_work;
};
+/* For use in scsi_id_instance_data.state */
+enum sbp2lu_state_types {
+ SBP2LU_STATE_RUNNING, /* all normal */
+ SBP2LU_STATE_IN_RESET, /* between bus reset and reconnect */
+ SBP2LU_STATE_IN_SHUTDOWN /* when sbp2_remove was called */
+};
+
/* Sbp2 host data structure (one per IEEE1394 host) */
struct sbp2scsi_host_info {
struct hpsb_host *host; /* IEEE1394 host */
Index: linux/drivers/ieee1394/sbp2.c
===================================================================
--- linux.orig/drivers/ieee1394/sbp2.c 2006-08-14 12:46:15.000000000 +0200
+++ linux/drivers/ieee1394/sbp2.c 2006-08-14 12:46:16.000000000 +0200
@@ -488,7 +488,7 @@ static void sbp2util_notify_fetch_agent(
* There is a small window after a bus reset within which the node
* entry's generation is current but the reconnect wasn't completed.
*/
- if (atomic_read(&scsi_id->unfinished_reset))
+ if (unlikely(atomic_read(&scsi_id->state) == SBP2LU_STATE_IN_RESET))
return;
if (hpsb_node_write(scsi_id->ne,
@@ -499,7 +499,7 @@ static void sbp2util_notify_fetch_agent(
* Now accept new SCSI commands, unless a bus reset happended during
* hpsb_node_write.
*/
- if (!atomic_read(&scsi_id->unfinished_reset))
+ if (likely(atomic_read(&scsi_id->state) != SBP2LU_STATE_IN_RESET))
scsi_unblock_requests(scsi_id->scsi_host);
}
@@ -766,7 +766,7 @@ static int sbp2_remove(struct device *de
sbp2scsi_complete_all_commands(scsi_id, DID_NO_CONNECT);
/* scsi_remove_device() will trigger shutdown functions of SCSI
* highlevel drivers which would deadlock if blocked. */
- atomic_set(&scsi_id->unfinished_reset, 0);
+ atomic_set(&scsi_id->state, SBP2LU_STATE_IN_SHUTDOWN);
scsi_unblock_requests(scsi_id->scsi_host);
}
sdev = scsi_id->sdev;
@@ -821,7 +821,7 @@ static int sbp2_update(struct unit_direc
/* Accept new commands unless there was another bus reset in the
* meantime. */
if (hpsb_node_entry_valid(scsi_id->ne)) {
- atomic_set(&scsi_id->unfinished_reset, 0);
+ atomic_set(&scsi_id->state, SBP2LU_STATE_RUNNING);
scsi_unblock_requests(scsi_id->scsi_host);
}
return 0;
@@ -852,7 +852,7 @@ static struct scsi_id_instance_data *sbp
INIT_LIST_HEAD(&scsi_id->sbp2_command_orb_completed);
INIT_LIST_HEAD(&scsi_id->scsi_list);
spin_lock_init(&scsi_id->sbp2_command_orb_lock);
- atomic_set(&scsi_id->unfinished_reset, 0);
+ atomic_set(&scsi_id->state, SBP2LU_STATE_RUNNING);
INIT_WORK(&scsi_id->protocol_work, NULL, NULL);
ud->device.driver_data = scsi_id;
@@ -936,13 +936,14 @@ static void sbp2_host_reset(struct hpsb_
struct scsi_id_instance_data *scsi_id;
hi = hpsb_get_hostinfo(&sbp2_highlevel, host);
-
- if (hi) {
- list_for_each_entry(scsi_id, &hi->scsi_ids, scsi_list) {
- atomic_set(&scsi_id->unfinished_reset, 1);
+ if (!hi)
+ return;
+ list_for_each_entry(scsi_id, &hi->scsi_ids, scsi_list)
+ if (likely(atomic_read(&scsi_id->state) !=
+ SBP2LU_STATE_IN_SHUTDOWN)) {
+ atomic_set(&scsi_id->state, SBP2LU_STATE_IN_RESET);
scsi_block_requests(scsi_id->scsi_host);
}
- }
}
/*
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2006-08-14 17:54 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-14 17:40 [PATCH 2.6.18-rc4-mm1 0/8] ieee1394: fixes and touch-ups for sbp2 Stefan Richter
2006-08-14 17:42 ` [PATCH 2.6.18-rc4-mm1 1/8] the scheduled removal of drivers/ieee1394/sbp2.c:force_inquiry_hack Stefan Richter
2006-08-14 17:45 ` [PATCH 2.6.18-rc4-mm1 2/8] ieee1394: sbp2: handle "sbp2util_node_write_no_wait failed" Stefan Richter
2006-08-14 17:47 ` [PATCH 2.6.18-rc4-mm1 3/8] ieee1394: sbp2: safer agent reset in error handlers Stefan Richter
2006-08-14 17:48 ` [PATCH 2.6.18-rc4-mm1 4/8] ieee1394: sbp2: recheck node generation in sbp2_update Stefan Richter
2006-08-14 17:49 ` [PATCH 2.6.18-rc4-mm1 5/8] ieee1394: sbp2: better handling of transport errors Stefan Richter
2006-08-14 17:50 ` [PATCH 2.6.18-rc4-mm1 6/8] ieee1394: sbp2: select SCSI in Kconfig Stefan Richter
2006-08-14 17:51 ` [PATCH 2.6.18-rc4-mm1 7/8] ieee1394: sbp2: update includes Stefan Richter
2006-08-14 17:53 ` [PATCH 2.6.18-rc4-mm1 8/8] ieee1394: sbp2: prevent rare deadlock in shutdown Stefan Richter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome