Commit a237f35f authored by Stefan Richter's avatar Stefan Richter Committed by Jody McIntyre

sbp2, ohci1394 cleanups:

sbp2: various code formatting cleanups
ohci1394: remove form feed characters
Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: default avatarJody McIntyre <scjody@modernduck.com>
parent e309fc6d
...@@ -3201,8 +3201,6 @@ static struct hpsb_host_driver ohci1394_driver = { ...@@ -3201,8 +3201,6 @@ static struct hpsb_host_driver ohci1394_driver = {
.hw_csr_reg = ohci_hw_csr_reg, .hw_csr_reg = ohci_hw_csr_reg,
}; };
/*********************************** /***********************************
* PCI Driver Interface functions * * PCI Driver Interface functions *
***********************************/ ***********************************/
...@@ -3606,8 +3604,6 @@ static struct pci_driver ohci1394_pci_driver = { ...@@ -3606,8 +3604,6 @@ static struct pci_driver ohci1394_pci_driver = {
.suspend = ohci1394_pci_suspend, .suspend = ohci1394_pci_suspend,
}; };
/*********************************** /***********************************
* OHCI1394 Video Interface * * OHCI1394 Video Interface *
***********************************/ ***********************************/
...@@ -3714,7 +3710,6 @@ EXPORT_SYMBOL(ohci1394_init_iso_tasklet); ...@@ -3714,7 +3710,6 @@ EXPORT_SYMBOL(ohci1394_init_iso_tasklet);
EXPORT_SYMBOL(ohci1394_register_iso_tasklet); EXPORT_SYMBOL(ohci1394_register_iso_tasklet);
EXPORT_SYMBOL(ohci1394_unregister_iso_tasklet); EXPORT_SYMBOL(ohci1394_unregister_iso_tasklet);
/*********************************** /***********************************
* General module initialization * * General module initialization *
***********************************/ ***********************************/
......
...@@ -151,18 +151,15 @@ static int force_inquiry_hack; ...@@ -151,18 +151,15 @@ static int force_inquiry_hack;
module_param(force_inquiry_hack, int, 0444); module_param(force_inquiry_hack, int, 0444);
MODULE_PARM_DESC(force_inquiry_hack, "Force SCSI inquiry hack (default = 0)"); MODULE_PARM_DESC(force_inquiry_hack, "Force SCSI inquiry hack (default = 0)");
/* /*
* Export information about protocols/devices supported by this driver. * Export information about protocols/devices supported by this driver.
*/ */
static struct ieee1394_device_id sbp2_id_table[] = { static struct ieee1394_device_id sbp2_id_table[] = {
{ {
.match_flags =IEEE1394_MATCH_SPECIFIER_ID | .match_flags = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION,
IEEE1394_MATCH_VERSION, .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff,
.specifier_id = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff, .version = SBP2_SW_VERSION_ENTRY & 0xffffff},
.version = SBP2_SW_VERSION_ENTRY & 0xffffff {}
},
{ }
}; };
MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table); MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table);
...@@ -221,7 +218,6 @@ static u32 global_outstanding_dmas = 0; ...@@ -221,7 +218,6 @@ static u32 global_outstanding_dmas = 0;
#define SBP2_ERR(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args) #define SBP2_ERR(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args)
/* /*
* Globals * Globals
*/ */
...@@ -254,8 +250,8 @@ static struct hpsb_address_ops sbp2_ops = { ...@@ -254,8 +250,8 @@ static struct hpsb_address_ops sbp2_ops = {
#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA #ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
static struct hpsb_address_ops sbp2_physdma_ops = { static struct hpsb_address_ops sbp2_physdma_ops = {
.read = sbp2_handle_physdma_read, .read = sbp2_handle_physdma_read,
.write = sbp2_handle_physdma_write, .write = sbp2_handle_physdma_write,
}; };
#endif #endif
...@@ -287,7 +283,6 @@ static u32 sbp2_broken_inquiry_list[] = { ...@@ -287,7 +283,6 @@ static u32 sbp2_broken_inquiry_list[] = {
* General utility functions * General utility functions
**************************************/ **************************************/
#ifndef __BIG_ENDIAN #ifndef __BIG_ENDIAN
/* /*
* Converts a buffer from be32 to cpu byte ordering. Length is in bytes. * Converts a buffer from be32 to cpu byte ordering. Length is in bytes.
...@@ -324,7 +319,8 @@ static __inline__ void sbp2util_cpu_to_be32_buffer(void *buffer, int length) ...@@ -324,7 +319,8 @@ static __inline__ void sbp2util_cpu_to_be32_buffer(void *buffer, int length)
/* /*
* Debug packet dump routine. Length is in bytes. * Debug packet dump routine. Length is in bytes.
*/ */
static void sbp2util_packet_dump(void *buffer, int length, char *dump_name, u32 dump_phys_addr) static void sbp2util_packet_dump(void *buffer, int length, char *dump_name,
u32 dump_phys_addr)
{ {
int i; int i;
unsigned char *dump = buffer; unsigned char *dump = buffer;
...@@ -345,7 +341,7 @@ static void sbp2util_packet_dump(void *buffer, int length, char *dump_name, u32 ...@@ -345,7 +341,7 @@ static void sbp2util_packet_dump(void *buffer, int length, char *dump_name, u32
printk(" "); printk(" ");
if ((i & 0xf) == 0) if ((i & 0xf) == 0)
printk("\n "); printk("\n ");
printk("%02x ", (int) dump[i]); printk("%02x ", (int)dump[i]);
} }
printk("\n"); printk("\n");
...@@ -364,9 +360,9 @@ static int sbp2util_down_timeout(atomic_t *done, int timeout) ...@@ -364,9 +360,9 @@ static int sbp2util_down_timeout(atomic_t *done, int timeout)
for (i = timeout; (i > 0 && atomic_read(done) == 0); i-= HZ/10) { for (i = timeout; (i > 0 && atomic_read(done) == 0); i-= HZ/10) {
if (msleep_interruptible(100)) /* 100ms */ if (msleep_interruptible(100)) /* 100ms */
return(1); return 1;
} }
return ((i > 0) ? 0:1); return (i > 0) ? 0 : 1;
} }
/* Free's an allocated packet */ /* Free's an allocated packet */
...@@ -380,21 +376,22 @@ static void sbp2_free_packet(struct hpsb_packet *packet) ...@@ -380,21 +376,22 @@ static void sbp2_free_packet(struct hpsb_packet *packet)
* subaction and returns immediately. Can be used from interrupts. * subaction and returns immediately. Can be used from interrupts.
*/ */
static int sbp2util_node_write_no_wait(struct node_entry *ne, u64 addr, static int sbp2util_node_write_no_wait(struct node_entry *ne, u64 addr,
quadlet_t *buffer, size_t length) quadlet_t *buffer, size_t length)
{ {
struct hpsb_packet *packet; struct hpsb_packet *packet;
packet = hpsb_make_writepacket(ne->host, ne->nodeid, packet = hpsb_make_writepacket(ne->host, ne->nodeid,
addr, buffer, length); addr, buffer, length);
if (!packet) if (!packet)
return -ENOMEM; return -ENOMEM;
hpsb_set_packet_complete_task(packet, (void (*)(void*))sbp2_free_packet, hpsb_set_packet_complete_task(packet,
(void (*)(void *))sbp2_free_packet,
packet); packet);
hpsb_node_fill_packet(ne, packet); hpsb_node_fill_packet(ne, packet);
if (hpsb_send_packet(packet) < 0) { if (hpsb_send_packet(packet) < 0) {
sbp2_free_packet(packet); sbp2_free_packet(packet);
return -EIO; return -EIO;
} }
...@@ -420,19 +417,21 @@ static int sbp2util_create_command_orb_pool(struct scsi_id_instance_data *scsi_i ...@@ -420,19 +417,21 @@ static int sbp2util_create_command_orb_pool(struct scsi_id_instance_data *scsi_i
command = (struct sbp2_command_info *) command = (struct sbp2_command_info *)
kmalloc(sizeof(struct sbp2_command_info), GFP_ATOMIC); kmalloc(sizeof(struct sbp2_command_info), GFP_ATOMIC);
if (!command) { if (!command) {
spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock,
return(-ENOMEM); flags);
return -ENOMEM;
} }
memset(command, '\0', sizeof(struct sbp2_command_info)); memset(command, '\0', sizeof(struct sbp2_command_info));
command->command_orb_dma = command->command_orb_dma =
pci_map_single (hi->host->pdev, &command->command_orb, pci_map_single(hi->host->pdev, &command->command_orb,
sizeof(struct sbp2_command_orb), sizeof(struct sbp2_command_orb),
PCI_DMA_BIDIRECTIONAL); PCI_DMA_BIDIRECTIONAL);
SBP2_DMA_ALLOC("single command orb DMA"); SBP2_DMA_ALLOC("single command orb DMA");
command->sge_dma = command->sge_dma =
pci_map_single (hi->host->pdev, &command->scatter_gather_element, pci_map_single(hi->host->pdev,
sizeof(command->scatter_gather_element), &command->scatter_gather_element,
PCI_DMA_BIDIRECTIONAL); sizeof(command->scatter_gather_element),
PCI_DMA_BIDIRECTIONAL);
SBP2_DMA_ALLOC("scatter_gather_element"); SBP2_DMA_ALLOC("scatter_gather_element");
INIT_LIST_HEAD(&command->list); INIT_LIST_HEAD(&command->list);
list_add_tail(&command->list, &scsi_id->sbp2_command_orb_completed); list_add_tail(&command->list, &scsi_id->sbp2_command_orb_completed);
...@@ -488,7 +487,7 @@ static struct sbp2_command_info *sbp2util_find_command_for_orb( ...@@ -488,7 +487,7 @@ static struct sbp2_command_info *sbp2util_find_command_for_orb(
list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) { list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) {
if (command->command_orb_dma == orb) { if (command->command_orb_dma == orb) {
spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
return (command); return command;
} }
} }
} }
...@@ -496,7 +495,7 @@ static struct sbp2_command_info *sbp2util_find_command_for_orb( ...@@ -496,7 +495,7 @@ static struct sbp2_command_info *sbp2util_find_command_for_orb(
SBP2_ORB_DEBUG("could not match command orb %x", (unsigned int)orb); SBP2_ORB_DEBUG("could not match command orb %x", (unsigned int)orb);
return(NULL); return NULL;
} }
/* /*
...@@ -513,12 +512,12 @@ static struct sbp2_command_info *sbp2util_find_command_for_SCpnt(struct scsi_id_ ...@@ -513,12 +512,12 @@ static struct sbp2_command_info *sbp2util_find_command_for_SCpnt(struct scsi_id_
list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) { list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) {
if (command->Current_SCpnt == SCpnt) { if (command->Current_SCpnt == SCpnt) {
spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
return (command); return command;
} }
} }
} }
spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
return(NULL); return NULL;
} }
/* /*
...@@ -545,7 +544,7 @@ static struct sbp2_command_info *sbp2util_allocate_command_orb( ...@@ -545,7 +544,7 @@ static struct sbp2_command_info *sbp2util_allocate_command_orb(
SBP2_ERR("sbp2util_allocate_command_orb - No orbs available!"); SBP2_ERR("sbp2util_allocate_command_orb - No orbs available!");
} }
spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
return (command); return command;
} }
/* Free our DMA's */ /* Free our DMA's */
...@@ -587,7 +586,8 @@ static void sbp2util_free_command_dma(struct sbp2_command_info *command) ...@@ -587,7 +586,8 @@ static void sbp2util_free_command_dma(struct sbp2_command_info *command)
/* /*
* This function moves a command to the completed orb list. * This function moves a command to the completed orb list.
*/ */
static void sbp2util_mark_command_completed(struct scsi_id_instance_data *scsi_id, struct sbp2_command_info *command) static void sbp2util_mark_command_completed(struct scsi_id_instance_data *scsi_id,
struct sbp2_command_info *command)
{ {
unsigned long flags; unsigned long flags;
...@@ -606,8 +606,6 @@ static inline int sbp2util_node_is_available(struct scsi_id_instance_data *scsi_ ...@@ -606,8 +606,6 @@ static inline int sbp2util_node_is_available(struct scsi_id_instance_data *scsi_
return scsi_id && scsi_id->ne && !scsi_id->ne->in_limbo; return scsi_id && scsi_id->ne && !scsi_id->ne->in_limbo;
} }
/********************************************* /*********************************************
* IEEE-1394 core driver stack related section * IEEE-1394 core driver stack related section
*********************************************/ *********************************************/
...@@ -627,14 +625,14 @@ static int sbp2_probe(struct device *dev) ...@@ -627,14 +625,14 @@ static int sbp2_probe(struct device *dev)
if (ud->flags & UNIT_DIRECTORY_HAS_LUN_DIRECTORY) if (ud->flags & UNIT_DIRECTORY_HAS_LUN_DIRECTORY)
return -ENODEV; return -ENODEV;
scsi_id = sbp2_alloc_device(ud); scsi_id = sbp2_alloc_device(ud);
if (!scsi_id) if (!scsi_id)
return -ENOMEM; return -ENOMEM;
sbp2_parse_unit_directory(scsi_id, ud); sbp2_parse_unit_directory(scsi_id, ud);
return sbp2_start_device(scsi_id); return sbp2_start_device(scsi_id);
} }
static int sbp2_remove(struct device *dev) static int sbp2_remove(struct device *dev)
...@@ -769,7 +767,7 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud ...@@ -769,7 +767,7 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
/* Register our host with the SCSI stack. */ /* Register our host with the SCSI stack. */
scsi_host = scsi_host_alloc(&scsi_driver_template, scsi_host = scsi_host_alloc(&scsi_driver_template,
sizeof (unsigned long)); sizeof(unsigned long));
if (!scsi_host) { if (!scsi_host) {
SBP2_ERR("failed to register scsi host"); SBP2_ERR("failed to register scsi host");
goto failed_alloc; goto failed_alloc;
...@@ -790,7 +788,6 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud ...@@ -790,7 +788,6 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
return NULL; return NULL;
} }
static void sbp2_host_reset(struct hpsb_host *host) static void sbp2_host_reset(struct hpsb_host *host)
{ {
struct sbp2scsi_host_info *hi; struct sbp2scsi_host_info *hi;
...@@ -804,7 +801,6 @@ static void sbp2_host_reset(struct hpsb_host *host) ...@@ -804,7 +801,6 @@ static void sbp2_host_reset(struct hpsb_host *host)
} }
} }
/* /*
* This function is where we first pull the node unique ids, and then * This function is where we first pull the node unique ids, and then
* allocate memory and register a SBP-2 device. * allocate memory and register a SBP-2 device.
...@@ -818,7 +814,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) ...@@ -818,7 +814,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
/* Login FIFO DMA */ /* Login FIFO DMA */
scsi_id->login_response = scsi_id->login_response =
pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_login_response), pci_alloc_consistent(hi->host->pdev,
sizeof(struct sbp2_login_response),
&scsi_id->login_response_dma); &scsi_id->login_response_dma);
if (!scsi_id->login_response) if (!scsi_id->login_response)
goto alloc_fail; goto alloc_fail;
...@@ -826,7 +823,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) ...@@ -826,7 +823,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
/* Query logins ORB DMA */ /* Query logins ORB DMA */
scsi_id->query_logins_orb = scsi_id->query_logins_orb =
pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_query_logins_orb), pci_alloc_consistent(hi->host->pdev,
sizeof(struct sbp2_query_logins_orb),
&scsi_id->query_logins_orb_dma); &scsi_id->query_logins_orb_dma);
if (!scsi_id->query_logins_orb) if (!scsi_id->query_logins_orb)
goto alloc_fail; goto alloc_fail;
...@@ -834,7 +832,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) ...@@ -834,7 +832,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
/* Query logins response DMA */ /* Query logins response DMA */
scsi_id->query_logins_response = scsi_id->query_logins_response =
pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_query_logins_response), pci_alloc_consistent(hi->host->pdev,
sizeof(struct sbp2_query_logins_response),
&scsi_id->query_logins_response_dma); &scsi_id->query_logins_response_dma);
if (!scsi_id->query_logins_response) if (!scsi_id->query_logins_response)
goto alloc_fail; goto alloc_fail;
...@@ -842,7 +841,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) ...@@ -842,7 +841,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
/* Reconnect ORB DMA */ /* Reconnect ORB DMA */
scsi_id->reconnect_orb = scsi_id->reconnect_orb =
pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_reconnect_orb), pci_alloc_consistent(hi->host->pdev,
sizeof(struct sbp2_reconnect_orb),
&scsi_id->reconnect_orb_dma); &scsi_id->reconnect_orb_dma);
if (!scsi_id->reconnect_orb) if (!scsi_id->reconnect_orb)
goto alloc_fail; goto alloc_fail;
...@@ -850,7 +850,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) ...@@ -850,7 +850,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
/* Logout ORB DMA */ /* Logout ORB DMA */
scsi_id->logout_orb = scsi_id->logout_orb =
pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_logout_orb), pci_alloc_consistent(hi->host->pdev,
sizeof(struct sbp2_logout_orb),
&scsi_id->logout_orb_dma); &scsi_id->logout_orb_dma);
if (!scsi_id->logout_orb) if (!scsi_id->logout_orb)
goto alloc_fail; goto alloc_fail;
...@@ -858,7 +859,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) ...@@ -858,7 +859,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
/* Login ORB DMA */ /* Login ORB DMA */
scsi_id->login_orb = scsi_id->login_orb =
pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_login_orb), pci_alloc_consistent(hi->host->pdev,
sizeof(struct sbp2_login_orb),
&scsi_id->login_orb_dma); &scsi_id->login_orb_dma);
if (!scsi_id->login_orb) { if (!scsi_id->login_orb) {
alloc_fail: alloc_fail:
...@@ -880,25 +882,25 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) ...@@ -880,25 +882,25 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
if (scsi_id->logout_orb) { if (scsi_id->logout_orb) {
pci_free_consistent(hi->host->pdev, pci_free_consistent(hi->host->pdev,
sizeof(struct sbp2_logout_orb), sizeof(struct sbp2_logout_orb),
scsi_id->logout_orb, scsi_id->logout_orb,
scsi_id->logout_orb_dma); scsi_id->logout_orb_dma);
SBP2_DMA_FREE("logout ORB DMA"); SBP2_DMA_FREE("logout ORB DMA");
} }
if (scsi_id->reconnect_orb) { if (scsi_id->reconnect_orb) {
pci_free_consistent(hi->host->pdev, pci_free_consistent(hi->host->pdev,
sizeof(struct sbp2_reconnect_orb), sizeof(struct sbp2_reconnect_orb),
scsi_id->reconnect_orb, scsi_id->reconnect_orb,
scsi_id->reconnect_orb_dma); scsi_id->reconnect_orb_dma);
SBP2_DMA_FREE("reconnect ORB DMA"); SBP2_DMA_FREE("reconnect ORB DMA");
} }
if (scsi_id->login_response) { if (scsi_id->login_response) {
pci_free_consistent(hi->host->pdev, pci_free_consistent(hi->host->pdev,
sizeof(struct sbp2_login_response), sizeof(struct sbp2_login_response),
scsi_id->login_response, scsi_id->login_response,
scsi_id->login_response_dma); scsi_id->login_response_dma);
SBP2_DMA_FREE("login FIFO DMA"); SBP2_DMA_FREE("login FIFO DMA");
} }
...@@ -906,7 +908,7 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) ...@@ -906,7 +908,7 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
kfree(scsi_id); kfree(scsi_id);
SBP2_ERR ("Could not allocate memory for scsi_id"); SBP2_ERR("Could not allocate memory for scsi_id");
return -ENOMEM; return -ENOMEM;
} }
...@@ -935,7 +937,7 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) ...@@ -935,7 +937,7 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
sbp2_remove_device(scsi_id); sbp2_remove_device(scsi_id);
return -EINTR; return -EINTR;
} }
/* /*
* Login to the sbp-2 device * Login to the sbp-2 device
*/ */
...@@ -1054,36 +1056,39 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id) ...@@ -1054,36 +1056,39 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id)
* This function deals with physical dma write requests (for adapters that do not support * This function deals with physical dma write requests (for adapters that do not support
* physical dma in hardware). Mostly just here for debugging... * physical dma in hardware). Mostly just here for debugging...
*/ */
static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid, int destid, quadlet_t *data, static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid,
u64 addr, size_t length, u16 flags) int destid, quadlet_t *data, u64 addr,
size_t length, u16 flags)
{ {
/* /*
* Manually put the data in the right place. * Manually put the data in the right place.
*/ */
memcpy(bus_to_virt((u32)addr), data, length); memcpy(bus_to_virt((u32) addr), data, length);
sbp2util_packet_dump(data, length, "sbp2 phys dma write by device", (u32)addr); sbp2util_packet_dump(data, length, "sbp2 phys dma write by device",
return(RCODE_COMPLETE); (u32) addr);
return RCODE_COMPLETE;
} }
/* /*
* This function deals with physical dma read requests (for adapters that do not support * This function deals with physical dma read requests (for adapters that do not support
* physical dma in hardware). Mostly just here for debugging... * physical dma in hardware). Mostly just here for debugging...
*/ */
static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid, quadlet_t *data, static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid,
u64 addr, size_t length, u16 flags) quadlet_t *data, u64 addr, size_t length,
u16 flags)
{ {
/* /*
* Grab data from memory and send a read response. * Grab data from memory and send a read response.
*/ */
memcpy(data, bus_to_virt((u32)addr), length); memcpy(data, bus_to_virt((u32) addr), length);
sbp2util_packet_dump(data, length, "sbp2 phys dma read by device", (u32)addr); sbp2util_packet_dump(data, length, "sbp2 phys dma read by device",
return(RCODE_COMPLETE); (u32) addr);
return RCODE_COMPLETE;
} }
#endif #endif
/************************************** /**************************************
* SBP-2 protocol related section * SBP-2 protocol related section
**************************************/ **************************************/
...@@ -1147,12 +1152,12 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id) ...@@ -1147,12 +1152,12 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 2*HZ)) { if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 2*HZ)) {
SBP2_INFO("Error querying logins to SBP-2 device - timed out"); SBP2_INFO("Error querying logins to SBP-2 device - timed out");
return(-EIO); return -EIO;
} }
if (scsi_id->status_block.ORB_offset_lo != scsi_id->query_logins_orb_dma) { if (scsi_id->status_block.ORB_offset_lo != scsi_id->query_logins_orb_dma) {
SBP2_INFO("Error querying logins to SBP-2 device - timed out"); SBP2_INFO("Error querying logins to SBP-2 device - timed out");
return(-EIO); return -EIO;
} }
if (STATUS_GET_RESP(scsi_id->status_block.ORB_offset_hi_misc) || if (STATUS_GET_RESP(scsi_id->status_block.ORB_offset_hi_misc) ||
...@@ -1160,7 +1165,7 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id) ...@@ -1160,7 +1165,7 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) {
SBP2_INFO("Error querying logins to SBP-2 device - timed out"); SBP2_INFO("Error querying logins to SBP-2 device - timed out");
return(-EIO); return -EIO;
} }
sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_response, sizeof(struct sbp2_query_logins_response)); sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_response, sizeof(struct sbp2_query_logins_response));
...@@ -1177,7 +1182,7 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id) ...@@ -1177,7 +1182,7 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
SBP2_DEBUG("Number of active logins: %d", active_logins); SBP2_DEBUG("Number of active logins: %d", active_logins);
if (active_logins >= max_logins) { if (active_logins >= max_logins) {
return(-EIO); return -EIO;
} }
return 0; return 0;
...@@ -1196,13 +1201,13 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) ...@@ -1196,13 +1201,13 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
if (!scsi_id->login_orb) { if (!scsi_id->login_orb) {
SBP2_DEBUG("sbp2_login_device: login_orb not alloc'd!"); SBP2_DEBUG("sbp2_login_device: login_orb not alloc'd!");
return(-EIO); return -EIO;
} }
if (!exclusive_login) { if (!exclusive_login) {
if (sbp2_query_logins(scsi_id)) { if (sbp2_query_logins(scsi_id)) {
SBP2_INFO("Device does not support any more concurrent logins"); SBP2_INFO("Device does not support any more concurrent logins");
return(-EIO); return -EIO;
} }
} }
...@@ -1269,7 +1274,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) ...@@ -1269,7 +1274,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
*/ */
if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 20*HZ)) { if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 20*HZ)) {
SBP2_ERR("Error logging into SBP-2 device - login timed-out"); SBP2_ERR("Error logging into SBP-2 device - login timed-out");
return(-EIO); return -EIO;
} }
/* /*
...@@ -1277,7 +1282,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) ...@@ -1277,7 +1282,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
*/ */
if (scsi_id->status_block.ORB_offset_lo != scsi_id->login_orb_dma) { if (scsi_id->status_block.ORB_offset_lo != scsi_id->login_orb_dma) {
SBP2_ERR("Error logging into SBP-2 device - login timed-out"); SBP2_ERR("Error logging into SBP-2 device - login timed-out");
return(-EIO); return -EIO;
} }
/* /*
...@@ -1288,7 +1293,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) ...@@ -1288,7 +1293,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) {
SBP2_ERR("Error logging into SBP-2 device - login failed"); SBP2_ERR("Error logging into SBP-2 device - login failed");
return(-EIO); return -EIO;
} }
/* /*
...@@ -1312,7 +1317,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) ...@@ -1312,7 +1317,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
SBP2_INFO("Logged into SBP-2 device"); SBP2_INFO("Logged into SBP-2 device");
return(0); return 0;
} }
...@@ -1366,8 +1371,7 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id) ...@@ -1366,8 +1371,7 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id)
atomic_set(&scsi_id->sbp2_login_complete, 0); atomic_set(&scsi_id->sbp2_login_complete, 0);
error = hpsb_node_write(scsi_id->ne, error = hpsb_node_write(scsi_id->ne,
scsi_id->sbp2_management_agent_addr, scsi_id->sbp2_management_agent_addr, data, 8);
data, 8);
if (error) if (error)
return error; return error;
...@@ -1377,7 +1381,7 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id) ...@@ -1377,7 +1381,7 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id)
SBP2_INFO("Logged out of SBP-2 device"); SBP2_INFO("Logged out of SBP-2 device");
return(0); return 0;
} }
...@@ -1437,8 +1441,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) ...@@ -1437,8 +1441,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
atomic_set(&scsi_id->sbp2_login_complete, 0); atomic_set(&scsi_id->sbp2_login_complete, 0);
error = hpsb_node_write(scsi_id->ne, error = hpsb_node_write(scsi_id->ne,
scsi_id->sbp2_management_agent_addr, scsi_id->sbp2_management_agent_addr, data, 8);
data, 8);
if (error) if (error)
return error; return error;
...@@ -1447,7 +1450,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) ...@@ -1447,7 +1450,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
*/ */
if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, HZ)) { if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, HZ)) {
SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out"); SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out");
return(-EIO); return -EIO;
} }
/* /*
...@@ -1455,7 +1458,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) ...@@ -1455,7 +1458,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
*/ */
if (scsi_id->status_block.ORB_offset_lo != scsi_id->reconnect_orb_dma) { if (scsi_id->status_block.ORB_offset_lo != scsi_id->reconnect_orb_dma) {
SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out"); SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out");
return(-EIO); return -EIO;
} }
/* /*
...@@ -1466,12 +1469,12 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) ...@@ -1466,12 +1469,12 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) {
SBP2_ERR("Error reconnecting to SBP-2 device - reconnect failed"); SBP2_ERR("Error reconnecting to SBP-2 device - reconnect failed");
return(-EIO); return -EIO;
} }
HPSB_DEBUG("Reconnected to SBP-2 device"); HPSB_DEBUG("Reconnected to SBP-2 device");
return(0); return 0;
} }
...@@ -1494,10 +1497,9 @@ static int sbp2_set_busy_timeout(struct scsi_id_instance_data *scsi_id) ...@@ -1494,10 +1497,9 @@ static int sbp2_set_busy_timeout(struct scsi_id_instance_data *scsi_id)
SBP2_ERR("sbp2_set_busy_timeout error"); SBP2_ERR("sbp2_set_busy_timeout error");
} }
return(0); return 0;
} }
/* /*
* This function is called to parse sbp2 device's config rom unit * This function is called to parse sbp2 device's config rom unit
* directory. Used to determine things like sbp2 management agent offset, * directory. Used to determine things like sbp2 management agent offset,
...@@ -1510,7 +1512,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, ...@@ -1510,7 +1512,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
struct csr1212_dentry *dentry; struct csr1212_dentry *dentry;
u64 management_agent_addr; u64 management_agent_addr;
u32 command_set_spec_id, command_set, unit_characteristics, u32 command_set_spec_id, command_set, unit_characteristics,
firmware_revision, workarounds; firmware_revision, workarounds;
int i; int i;
SBP2_DEBUG("sbp2_parse_unit_directory"); SBP2_DEBUG("sbp2_parse_unit_directory");
...@@ -1528,13 +1530,14 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, ...@@ -1528,13 +1530,14 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
if (kv->key.type == CSR1212_KV_TYPE_CSR_OFFSET) { if (kv->key.type == CSR1212_KV_TYPE_CSR_OFFSET) {
/* Save off the management agent address */ /* Save off the management agent address */
management_agent_addr = management_agent_addr =
CSR1212_REGISTER_SPACE_BASE + CSR1212_REGISTER_SPACE_BASE +
(kv->value.csr_offset << 2); (kv->value.csr_offset << 2);
SBP2_DEBUG("sbp2_management_agent_addr = %x", SBP2_DEBUG("sbp2_management_agent_addr = %x",
(unsigned int) management_agent_addr); (unsigned int)management_agent_addr);
} else if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) { } else if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) {
scsi_id->sbp2_lun = ORB_SET_LUN(kv->value.immediate); scsi_id->sbp2_lun =
ORB_SET_LUN(kv->value.immediate);
} }
break; break;
...@@ -1542,14 +1545,14 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, ...@@ -1542,14 +1545,14 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
/* Command spec organization */ /* Command spec organization */
command_set_spec_id = kv->value.immediate; command_set_spec_id = kv->value.immediate;
SBP2_DEBUG("sbp2_command_set_spec_id = %x", SBP2_DEBUG("sbp2_command_set_spec_id = %x",
(unsigned int) command_set_spec_id); (unsigned int)command_set_spec_id);
break; break;
case SBP2_COMMAND_SET_KEY: case SBP2_COMMAND_SET_KEY:
/* Command set used by sbp2 device */ /* Command set used by sbp2 device */
command_set = kv->value.immediate; command_set = kv->value.immediate;
SBP2_DEBUG("sbp2_command_set = %x", SBP2_DEBUG("sbp2_command_set = %x",
(unsigned int) command_set); (unsigned int)command_set);
break; break;
case SBP2_UNIT_CHARACTERISTICS_KEY: case SBP2_UNIT_CHARACTERISTICS_KEY:
...@@ -1559,7 +1562,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, ...@@ -1559,7 +1562,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
*/ */
unit_characteristics = kv->value.immediate; unit_characteristics = kv->value.immediate;
SBP2_DEBUG("sbp2_unit_characteristics = %x", SBP2_DEBUG("sbp2_unit_characteristics = %x",
(unsigned int) unit_characteristics); (unsigned int)unit_characteristics);
break; break;
case SBP2_FIRMWARE_REVISION_KEY: case SBP2_FIRMWARE_REVISION_KEY:
...@@ -1567,9 +1570,10 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, ...@@ -1567,9 +1570,10 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
firmware_revision = kv->value.immediate; firmware_revision = kv->value.immediate;
if (force_inquiry_hack) if (force_inquiry_hack)
SBP2_INFO("sbp2_firmware_revision = %x", SBP2_INFO("sbp2_firmware_revision = %x",
(unsigned int) firmware_revision); (unsigned int)firmware_revision);
else SBP2_DEBUG("sbp2_firmware_revision = %x", else
(unsigned int) firmware_revision); SBP2_DEBUG("sbp2_firmware_revision = %x",
(unsigned int)firmware_revision);
break; break;
default: default:
...@@ -1647,8 +1651,9 @@ static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id) ...@@ -1647,8 +1651,9 @@ static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id)
SBP2_DEBUG("sbp2_max_speed_and_size"); SBP2_DEBUG("sbp2_max_speed_and_size");
/* Initial setting comes from the hosts speed map */ /* Initial setting comes from the hosts speed map */
scsi_id->speed_code = hi->host->speed_map[NODEID_TO_NODE(hi->host->node_id) * 64 scsi_id->speed_code =
+ NODEID_TO_NODE(scsi_id->ne->nodeid)]; hi->host->speed_map[NODEID_TO_NODE(hi->host->node_id) * 64 +
NODEID_TO_NODE(scsi_id->ne->nodeid)];
/* Bump down our speed if the user requested it */ /* Bump down our speed if the user requested it */
if (scsi_id->speed_code > max_speed) { if (scsi_id->speed_code > max_speed) {
...@@ -1659,15 +1664,16 @@ static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id) ...@@ -1659,15 +1664,16 @@ static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id)
/* Payload size is the lesser of what our speed supports and what /* Payload size is the lesser of what our speed supports and what
* our host supports. */ * our host supports. */
scsi_id->max_payload_size = min(sbp2_speedto_max_payload[scsi_id->speed_code], scsi_id->max_payload_size =
(u8)(hi->host->csr.max_rec - 1)); min(sbp2_speedto_max_payload[scsi_id->speed_code],
(u8) (hi->host->csr.max_rec - 1));
HPSB_DEBUG("Node " NODE_BUS_FMT ": Max speed [%s] - Max payload [%u]", HPSB_DEBUG("Node " NODE_BUS_FMT ": Max speed [%s] - Max payload [%u]",
NODE_BUS_ARGS(hi->host, scsi_id->ne->nodeid), NODE_BUS_ARGS(hi->host, scsi_id->ne->nodeid),
hpsb_speedto_str[scsi_id->speed_code], hpsb_speedto_str[scsi_id->speed_code],
1 << ((u32)scsi_id->max_payload_size + 2)); 1 << ((u32) scsi_id->max_payload_size + 2));
return(0); return 0;
} }
/* /*
...@@ -1702,7 +1708,7 @@ static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait) ...@@ -1702,7 +1708,7 @@ static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait)
*/ */
scsi_id->last_orb = NULL; scsi_id->last_orb = NULL;
return(0); return 0;
} }
/* /*
...@@ -1716,10 +1722,9 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, ...@@ -1716,10 +1722,9 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
unsigned int scsi_request_bufflen, unsigned int scsi_request_bufflen,
void *scsi_request_buffer, void *scsi_request_buffer,
enum dma_data_direction dma_dir) enum dma_data_direction dma_dir)
{ {
struct sbp2scsi_host_info *hi = scsi_id->hi; struct sbp2scsi_host_info *hi = scsi_id->hi;
struct scatterlist *sgpnt = (struct scatterlist *) scsi_request_buffer; struct scatterlist *sgpnt = (struct scatterlist *)scsi_request_buffer;
struct sbp2_command_orb *command_orb = &command->command_orb; struct sbp2_command_orb *command_orb = &command->command_orb;
struct sbp2_unrestricted_page_table *scatter_gather_element = struct sbp2_unrestricted_page_table *scatter_gather_element =
&command->scatter_gather_element[0]; &command->scatter_gather_element[0];
...@@ -1739,30 +1744,30 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, ...@@ -1739,30 +1744,30 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
command_orb->next_ORB_lo = 0x0; command_orb->next_ORB_lo = 0x0;
command_orb->misc = ORB_SET_MAX_PAYLOAD(scsi_id->max_payload_size); command_orb->misc = ORB_SET_MAX_PAYLOAD(scsi_id->max_payload_size);
command_orb->misc |= ORB_SET_SPEED(scsi_id->speed_code); command_orb->misc |= ORB_SET_SPEED(scsi_id->speed_code);
command_orb->misc |= ORB_SET_NOTIFY(1); /* Notify us when complete */ command_orb->misc |= ORB_SET_NOTIFY(1); /* Notify us when complete */
/* /*
* Get the direction of the transfer. If the direction is unknown, then use our * Get the direction of the transfer. If the direction is unknown, then use our
* goofy table as a back-up. * goofy table as a back-up.
*/ */
switch (dma_dir) { switch (dma_dir) {
case DMA_NONE: case DMA_NONE:
orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER; orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER;
break; break;
case DMA_TO_DEVICE: case DMA_TO_DEVICE:
orb_direction = ORB_DIRECTION_WRITE_TO_MEDIA; orb_direction = ORB_DIRECTION_WRITE_TO_MEDIA;
break; break;
case DMA_FROM_DEVICE: case DMA_FROM_DEVICE:
orb_direction = ORB_DIRECTION_READ_FROM_MEDIA; orb_direction = ORB_DIRECTION_READ_FROM_MEDIA;
break; break;
case DMA_BIDIRECTIONAL: case DMA_BIDIRECTIONAL:
default: default:
SBP2_ERR("SCSI data transfer direction not specified. " SBP2_ERR("SCSI data transfer direction not specified. "
"Update the SBP2 direction table in sbp2.h if " "Update the SBP2 direction table in sbp2.h if "
"necessary for your application"); "necessary for your application");
__scsi_print_command(scsi_cmd); __scsi_print_command(scsi_cmd);
orb_direction = sbp2scsi_direction_table[*scsi_cmd]; orb_direction = sbp2scsi_direction_table[*scsi_cmd];
break; break;
} }
/* /*
...@@ -1865,9 +1870,9 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, ...@@ -1865,9 +1870,9 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
command->dma_dir = dma_dir; command->dma_dir = dma_dir;
command->dma_size = scsi_request_bufflen; command->dma_size = scsi_request_bufflen;
command->dma_type = CMD_DMA_SINGLE; command->dma_type = CMD_DMA_SINGLE;
command->cmd_dma = pci_map_single (hi->host->pdev, scsi_request_buffer, command->cmd_dma =
command->dma_size, pci_map_single(hi->host->pdev, scsi_request_buffer,
command->dma_dir); command->dma_size, command->dma_dir);
SBP2_DMA_ALLOC("single bulk"); SBP2_DMA_ALLOC("single bulk");
/* /*
...@@ -1954,7 +1959,7 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, ...@@ -1954,7 +1959,7 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
memset(command_orb->cdb, 0, 12); memset(command_orb->cdb, 0, 12);
memcpy(command_orb->cdb, scsi_cmd, COMMAND_SIZE(*scsi_cmd)); memcpy(command_orb->cdb, scsi_cmd, COMMAND_SIZE(*scsi_cmd));
return(0); return 0;
} }
/* /*
...@@ -1970,7 +1975,7 @@ static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id, ...@@ -1970,7 +1975,7 @@ static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
outstanding_orb_incr; outstanding_orb_incr;
SBP2_ORB_DEBUG("sending command orb %p, total orbs = %x", SBP2_ORB_DEBUG("sending command orb %p, total orbs = %x",
command_orb, global_outstanding_command_orbs); command_orb, global_outstanding_command_orbs);
pci_dma_sync_single_for_device(hi->host->pdev, command->command_orb_dma, pci_dma_sync_single_for_device(hi->host->pdev, command->command_orb_dma,
sizeof(struct sbp2_command_orb), sizeof(struct sbp2_command_orb),
...@@ -2015,10 +2020,11 @@ static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id, ...@@ -2015,10 +2020,11 @@ static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
* both by the sbp2 device and us. * both by the sbp2 device and us.
*/ */
scsi_id->last_orb->next_ORB_lo = scsi_id->last_orb->next_ORB_lo =
cpu_to_be32(command->command_orb_dma); cpu_to_be32(command->command_orb_dma);
/* Tells hardware that this pointer is valid */ /* Tells hardware that this pointer is valid */
scsi_id->last_orb->next_ORB_hi = 0x0; scsi_id->last_orb->next_ORB_hi = 0x0;
pci_dma_sync_single_for_device(hi->host->pdev, scsi_id->last_orb_dma, pci_dma_sync_single_for_device(hi->host->pdev,
scsi_id->last_orb_dma,
sizeof(struct sbp2_command_orb), sizeof(struct sbp2_command_orb),
PCI_DMA_BIDIRECTIONAL); PCI_DMA_BIDIRECTIONAL);
...@@ -2032,14 +2038,14 @@ static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id, ...@@ -2032,14 +2038,14 @@ static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
if (sbp2util_node_write_no_wait(ne, addr, &data, 4) < 0) { if (sbp2util_node_write_no_wait(ne, addr, &data, 4) < 0) {
SBP2_ERR("sbp2util_node_write_no_wait failed"); SBP2_ERR("sbp2util_node_write_no_wait failed");
return(-EIO); return -EIO;
} }
scsi_id->last_orb = command_orb; scsi_id->last_orb = command_orb;
scsi_id->last_orb_dma = command->command_orb_dma; scsi_id->last_orb_dma = command->command_orb_dma;
} }
return(0); return 0;
} }
/* /*
...@@ -2066,7 +2072,7 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id, ...@@ -2066,7 +2072,7 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
*/ */
command = sbp2util_allocate_command_orb(scsi_id, SCpnt, done); command = sbp2util_allocate_command_orb(scsi_id, SCpnt, done);
if (!command) { if (!command) {
return(-EIO); return -EIO;
} }
/* /*
...@@ -2101,10 +2107,9 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id, ...@@ -2101,10 +2107,9 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
*/ */
sbp2_link_orb_command(scsi_id, command); sbp2_link_orb_command(scsi_id, command);
return(0); return 0;
} }
/* /*
* Translates SBP-2 status into SCSI sense data for check conditions * Translates SBP-2 status into SCSI sense data for check conditions
*/ */
...@@ -2132,14 +2137,14 @@ static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense ...@@ -2132,14 +2137,14 @@ static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense
sense_data[14] = sbp2_status[20]; sense_data[14] = sbp2_status[20];
sense_data[15] = sbp2_status[21]; sense_data[15] = sbp2_status[21];
return(sbp2_status[8] & 0x3f); /* return scsi status */ return sbp2_status[8] & 0x3f; /* return scsi status */
} }
/* /*
* This function is called after a command is completed, in order to do any necessary SBP-2 * This function is called after a command is completed, in order to do any necessary SBP-2
* response data translations for the SCSI stack * response data translations for the SCSI stack
*/ */
static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id,
struct scsi_cmnd *SCpnt) struct scsi_cmnd *SCpnt)
{ {
u8 *scsi_buf = SCpnt->request_buffer; u8 *scsi_buf = SCpnt->request_buffer;
...@@ -2148,24 +2153,24 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, ...@@ -2148,24 +2153,24 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id,
switch (SCpnt->cmnd[0]) { switch (SCpnt->cmnd[0]) {
case INQUIRY: case INQUIRY:
/* /*
* Make sure data length is ok. Minimum length is 36 bytes * Make sure data length is ok. Minimum length is 36 bytes
*/ */
if (scsi_buf[4] == 0) { if (scsi_buf[4] == 0) {
scsi_buf[4] = 36 - 5; scsi_buf[4] = 36 - 5;
} }
/* /*
* Fix ansi revision and response data format * Fix ansi revision and response data format
*/ */
scsi_buf[2] |= 2; scsi_buf[2] |= 2;
scsi_buf[3] = (scsi_buf[3] & 0xf0) | 2; scsi_buf[3] = (scsi_buf[3] & 0xf0) | 2;
break; break;
default: default:
break; break;
} }
return; return;
} }
...@@ -2190,14 +2195,14 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest ...@@ -2190,14 +2195,14 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest
if (!host) { if (!host) {
SBP2_ERR("host is NULL - this is bad!"); SBP2_ERR("host is NULL - this is bad!");
return(RCODE_ADDRESS_ERROR); return RCODE_ADDRESS_ERROR;
} }
hi = hpsb_get_hostinfo(&sbp2_highlevel, host); hi = hpsb_get_hostinfo(&sbp2_highlevel, host);
if (!hi) { if (!hi) {
SBP2_ERR("host info is NULL - this is bad!"); SBP2_ERR("host info is NULL - this is bad!");
return(RCODE_ADDRESS_ERROR); return RCODE_ADDRESS_ERROR;
} }
/* /*
...@@ -2214,7 +2219,7 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest ...@@ -2214,7 +2219,7 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest
if (!scsi_id) { if (!scsi_id) {
SBP2_ERR("scsi_id is NULL - device is gone?"); SBP2_ERR("scsi_id is NULL - device is gone?");
return(RCODE_ADDRESS_ERROR); return RCODE_ADDRESS_ERROR;
} }
/* /*
...@@ -2312,10 +2317,9 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest ...@@ -2312,10 +2317,9 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest
SBP2_ORB_DEBUG("command orb completed"); SBP2_ORB_DEBUG("command orb completed");
} }
return(RCODE_COMPLETE); return RCODE_COMPLETE;
} }
/************************************** /**************************************
* SCSI interface related section * SCSI interface related section
**************************************/ **************************************/
...@@ -2448,55 +2452,56 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id, ...@@ -2448,55 +2452,56 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
* complete the command, just let it get retried at the end of the * complete the command, just let it get retried at the end of the
* bus reset. * bus reset.
*/ */
if (!hpsb_node_entry_valid(scsi_id->ne) && (scsi_status != SBP2_SCSI_STATUS_GOOD)) { if (!hpsb_node_entry_valid(scsi_id->ne)
&& (scsi_status != SBP2_SCSI_STATUS_GOOD)) {
SBP2_ERR("Bus reset in progress - retry command later"); SBP2_ERR("Bus reset in progress - retry command later");
return; return;
} }
/* /*
* Switch on scsi status * Switch on scsi status
*/ */
switch (scsi_status) { switch (scsi_status) {
case SBP2_SCSI_STATUS_GOOD: case SBP2_SCSI_STATUS_GOOD:
SCpnt->result = DID_OK; SCpnt->result = DID_OK;
break; break;
case SBP2_SCSI_STATUS_BUSY: case SBP2_SCSI_STATUS_BUSY:
SBP2_ERR("SBP2_SCSI_STATUS_BUSY"); SBP2_ERR("SBP2_SCSI_STATUS_BUSY");
SCpnt->result = DID_BUS_BUSY << 16; SCpnt->result = DID_BUS_BUSY << 16;
break; break;
case SBP2_SCSI_STATUS_CHECK_CONDITION: case SBP2_SCSI_STATUS_CHECK_CONDITION:
SBP2_DEBUG("SBP2_SCSI_STATUS_CHECK_CONDITION"); SBP2_DEBUG("SBP2_SCSI_STATUS_CHECK_CONDITION");
SCpnt->result = CHECK_CONDITION << 1; SCpnt->result = CHECK_CONDITION << 1;
/* /*
* Debug stuff * Debug stuff
*/ */
#if CONFIG_IEEE1394_SBP2_DEBUG >= 1 #if CONFIG_IEEE1394_SBP2_DEBUG >= 1
scsi_print_command(SCpnt); scsi_print_command(SCpnt);
scsi_print_sense("bh", SCpnt); scsi_print_sense("bh", SCpnt);
#endif #endif
break; break;
case SBP2_SCSI_STATUS_SELECTION_TIMEOUT: case SBP2_SCSI_STATUS_SELECTION_TIMEOUT:
SBP2_ERR("SBP2_SCSI_STATUS_SELECTION_TIMEOUT"); SBP2_ERR("SBP2_SCSI_STATUS_SELECTION_TIMEOUT");
SCpnt->result = DID_NO_CONNECT << 16; SCpnt->result = DID_NO_CONNECT << 16;
scsi_print_command(SCpnt); scsi_print_command(SCpnt);
break; break;
case SBP2_SCSI_STATUS_CONDITION_MET: case SBP2_SCSI_STATUS_CONDITION_MET:
case SBP2_SCSI_STATUS_RESERVATION_CONFLICT: case SBP2_SCSI_STATUS_RESERVATION_CONFLICT:
case SBP2_SCSI_STATUS_COMMAND_TERMINATED: case SBP2_SCSI_STATUS_COMMAND_TERMINATED:
SBP2_ERR("Bad SCSI status = %x", scsi_status); SBP2_ERR("Bad SCSI status = %x", scsi_status);
SCpnt->result = DID_ERROR << 16; SCpnt->result = DID_ERROR << 16;
scsi_print_command(SCpnt); scsi_print_command(SCpnt);
break; break;
default: default:
SBP2_ERR("Unsupported SCSI status = %x", scsi_status); SBP2_ERR("Unsupported SCSI status = %x", scsi_status);
SCpnt->result = DID_ERROR << 16; SCpnt->result = DID_ERROR << 16;
} }
/* /*
...@@ -2510,7 +2515,8 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id, ...@@ -2510,7 +2515,8 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
* If a bus reset is in progress and there was an error, complete * If a bus reset is in progress and there was an error, complete
* the command as busy so that it will get retried. * the command as busy so that it will get retried.
*/ */
if (!hpsb_node_entry_valid(scsi_id->ne) && (scsi_status != SBP2_SCSI_STATUS_GOOD)) { if (!hpsb_node_entry_valid(scsi_id->ne)
&& (scsi_status != SBP2_SCSI_STATUS_GOOD)) {
SBP2_ERR("Completing command with busy (bus reset)"); SBP2_ERR("Completing command with busy (bus reset)");
SCpnt->result = DID_BUS_BUSY << 16; SCpnt->result = DID_BUS_BUSY << 16;
} }
...@@ -2531,17 +2537,15 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id, ...@@ -2531,17 +2537,15 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
/* /*
* Tell scsi stack that we're done with this command * Tell scsi stack that we're done with this command
*/ */
done (SCpnt); done(SCpnt);
} }
static int sbp2scsi_slave_alloc(struct scsi_device *sdev) static int sbp2scsi_slave_alloc(struct scsi_device *sdev)
{ {
((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = sdev; ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = sdev;
return 0; return 0;
} }
static int sbp2scsi_slave_configure(struct scsi_device *sdev) static int sbp2scsi_slave_configure(struct scsi_device *sdev)
{ {
blk_queue_dma_alignment(sdev->request_queue, (512 - 1)); blk_queue_dma_alignment(sdev->request_queue, (512 - 1));
...@@ -2550,14 +2554,12 @@ static int sbp2scsi_slave_configure(struct scsi_device *sdev) ...@@ -2550,14 +2554,12 @@ static int sbp2scsi_slave_configure(struct scsi_device *sdev)
return 0; return 0;
} }
static void sbp2scsi_slave_destroy(struct scsi_device *sdev) static void sbp2scsi_slave_destroy(struct scsi_device *sdev)
{ {
((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = NULL; ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = NULL;
return; return;
} }
/* /*
* Called by scsi stack when something has really gone wrong. Usually * Called by scsi stack when something has really gone wrong. Usually
* called when a command has timed-out for some reason. * called when a command has timed-out for some reason.
...@@ -2603,7 +2605,7 @@ static int sbp2scsi_abort(struct scsi_cmnd *SCpnt) ...@@ -2603,7 +2605,7 @@ static int sbp2scsi_abort(struct scsi_cmnd *SCpnt)
sbp2scsi_complete_all_commands(scsi_id, DID_BUS_BUSY); sbp2scsi_complete_all_commands(scsi_id, DID_BUS_BUSY);
} }
return(SUCCESS); return SUCCESS;
} }
/* /*
...@@ -2629,12 +2631,14 @@ static int sbp2scsi_reset(struct scsi_cmnd *SCpnt) ...@@ -2629,12 +2631,14 @@ static int sbp2scsi_reset(struct scsi_cmnd *SCpnt)
return SUCCESS; return SUCCESS;
} }
static const char *sbp2scsi_info (struct Scsi_Host *host) static const char *sbp2scsi_info(struct Scsi_Host *host)
{ {
return "SCSI emulation for IEEE-1394 SBP-2 Devices"; return "SCSI emulation for IEEE-1394 SBP-2 Devices";
} }
static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr, char *buf) static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{ {
struct scsi_device *sdev; struct scsi_device *sdev;
struct scsi_id_instance_data *scsi_id; struct scsi_id_instance_data *scsi_id;
...@@ -2705,7 +2709,6 @@ static int sbp2_module_init(void) ...@@ -2705,7 +2709,6 @@ static int sbp2_module_init(void)
/* Set max sectors (module load option). Default is 255 sectors. */ /* Set max sectors (module load option). Default is 255 sectors. */
scsi_driver_template.max_sectors = max_sectors; scsi_driver_template.max_sectors = max_sectors;
/* Register our high level driver with 1394 stack */ /* Register our high level driver with 1394 stack */
hpsb_register_highlevel(&sbp2_highlevel); hpsb_register_highlevel(&sbp2_highlevel);
......
...@@ -119,8 +119,8 @@ struct sbp2_query_logins_response { ...@@ -119,8 +119,8 @@ struct sbp2_query_logins_response {
struct sbp2_reconnect_orb { struct sbp2_reconnect_orb {
u32 reserved1; u32 reserved1;
u32 reserved2; u32 reserved2;
u32 reserved3; u32 reserved3;
u32 reserved4; u32 reserved4;
u32 login_ID_misc; u32 login_ID_misc;
u32 reserved5; u32 reserved5;
u32 status_FIFO_hi; u32 status_FIFO_hi;
...@@ -130,8 +130,8 @@ struct sbp2_reconnect_orb { ...@@ -130,8 +130,8 @@ struct sbp2_reconnect_orb {
struct sbp2_logout_orb { struct sbp2_logout_orb {
u32 reserved1; u32 reserved1;
u32 reserved2; u32 reserved2;
u32 reserved3; u32 reserved3;
u32 reserved4; u32 reserved4;
u32 login_ID_misc; u32 login_ID_misc;
u32 reserved5; u32 reserved5;
u32 status_FIFO_hi; u32 status_FIFO_hi;
...@@ -188,7 +188,7 @@ struct sbp2_unrestricted_page_table { ...@@ -188,7 +188,7 @@ struct sbp2_unrestricted_page_table {
struct sbp2_status_block { struct sbp2_status_block {
u32 ORB_offset_hi_misc; u32 ORB_offset_hi_misc;
u32 ORB_offset_lo; u32 ORB_offset_lo;
u8 command_set_dependent[24]; u8 command_set_dependent[24];
}; };
/* /*
...@@ -211,7 +211,7 @@ struct sbp2_status_block { ...@@ -211,7 +211,7 @@ struct sbp2_status_block {
* specified for write posting, where the ohci controller will * specified for write posting, where the ohci controller will
* automatically send an ack_complete when the status is written by the * automatically send an ack_complete when the status is written by the
* sbp2 device... saving a split transaction. =) * sbp2 device... saving a split transaction. =)
*/ */
#define SBP2_STATUS_FIFO_ADDRESS 0xfffe00000000ULL #define SBP2_STATUS_FIFO_ADDRESS 0xfffe00000000ULL
#define SBP2_STATUS_FIFO_ADDRESS_HI 0xfffe #define SBP2_STATUS_FIFO_ADDRESS_HI 0xfffe
#define SBP2_STATUS_FIFO_ADDRESS_LO 0x0 #define SBP2_STATUS_FIFO_ADDRESS_LO 0x0
...@@ -333,10 +333,8 @@ struct sbp2_command_info { ...@@ -333,10 +333,8 @@ struct sbp2_command_info {
#define SBP2_BREAKAGE_128K_MAX_TRANSFER 0x1 #define SBP2_BREAKAGE_128K_MAX_TRANSFER 0x1
#define SBP2_BREAKAGE_INQUIRY_HACK 0x2 #define SBP2_BREAKAGE_INQUIRY_HACK 0x2
struct sbp2scsi_host_info; struct sbp2scsi_host_info;
/* /*
* Information needed on a per scsi id basis (one for each sbp2 device) * Information needed on a per scsi id basis (one for each sbp2 device)
*/ */
...@@ -406,7 +404,6 @@ struct scsi_id_instance_data { ...@@ -406,7 +404,6 @@ struct scsi_id_instance_data {
u32 workarounds; u32 workarounds;
}; };
/* Sbp2 host data structure (one per IEEE1394 host) */ /* Sbp2 host data structure (one per IEEE1394 host) */
struct sbp2scsi_host_info { struct sbp2scsi_host_info {
struct hpsb_host *host; /* IEEE1394 host */ struct hpsb_host *host; /* IEEE1394 host */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment