Commit 0b53593b authored by Ben Collins's avatar Ben Collins

[PATCH] Update IEEE1394 (r1023)

 misc      : - Signed cleanups.
	     - Convert to correct min/max macros.

 subsystem : - Attempt to fix sleeping call in hpsb_get_tlabel when
	       preempt is enabled.

 eth1394   : - Fix packet sizes for S800+.
parent 3369ce4f
......@@ -159,7 +159,7 @@ static void cmp_host_reset(struct hpsb_host *host)
}
static int pcr_read(struct hpsb_host *host, int nodeid, quadlet_t *buf,
u64 addr, unsigned int length, u16 flags)
u64 addr, size_t length, u16 flags)
{
int csraddr = addr - CSR_REGISTER_BASE;
int plug;
......
......@@ -20,6 +20,7 @@
#include <linux/string.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/param.h>
#include "ieee1394_types.h"
#include "hosts.h"
......@@ -190,7 +191,7 @@ int hpsb_get_config_rom(struct hpsb_host *host, quadlet_t *buffer,
/* Read topology / speed maps and configuration ROM */
static int read_maps(struct hpsb_host *host, int nodeid, quadlet_t *buffer,
u64 addr, unsigned int length, u16 fl)
u64 addr, size_t length, u16 fl)
{
unsigned long flags;
int csraddr = addr - CSR_REGISTER_BASE;
......@@ -219,7 +220,7 @@ static int read_maps(struct hpsb_host *host, int nodeid, quadlet_t *buffer,
#define out if (--length == 0) break
static int read_regs(struct hpsb_host *host, int nodeid, quadlet_t *buf,
u64 addr, unsigned int length, u16 flags)
u64 addr, size_t length, u16 flags)
{
int csraddr = addr - CSR_REGISTER_BASE;
int oldcycle;
......@@ -333,7 +334,7 @@ static int read_regs(struct hpsb_host *host, int nodeid, quadlet_t *buf,
}
static int write_regs(struct hpsb_host *host, int nodeid, int destid,
quadlet_t *data, u64 addr, unsigned int length, u16 flags)
quadlet_t *data, u64 addr, size_t length, u16 flags)
{
int csraddr = addr - CSR_REGISTER_BASE;
......@@ -659,7 +660,7 @@ static int lock64_regs(struct hpsb_host *host, int nodeid, octlet_t * store,
}
static int write_fcp(struct hpsb_host *host, int nodeid, int dest,
quadlet_t *data, u64 addr, unsigned int length, u16 flags)
quadlet_t *data, u64 addr, size_t length, u16 flags)
{
int csraddr = addr - CSR_REGISTER_BASE;
......
......@@ -89,7 +89,7 @@
#define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__)
static char version[] __devinitdata =
"$Rev: 1010 $ Ben Collins <bcollins@debian.org>";
"$Rev: 1020 $ Ben Collins <bcollins@debian.org>";
struct fragment_info {
struct list_head list;
......@@ -130,7 +130,7 @@ static const int hdr_type_len[] = {
static const u16 eth1394_speedto_maxpayload[] = {
/* S100, S200, S400, S800, S1600, S3200 */
512, 1024, 2048, 4096, 8192, 16384
512, 1024, 2048, 4096, 4096, 4096
};
MODULE_AUTHOR("Ben Collins (bcollins@debian.org)");
......@@ -1086,7 +1086,7 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
}
static int ether1394_write(struct hpsb_host *host, int srcid, int destid,
quadlet_t *data, u64 addr, unsigned int len, u16 flags)
quadlet_t *data, u64 addr, size_t len, u16 flags)
{
struct host_info *hi = hpsb_get_hostinfo(&eth1394_highlevel, host);
......@@ -1283,7 +1283,7 @@ static inline int ether1394_prep_write_packet(struct hpsb_packet *p,
p->header_size = 16;
p->expect_response = 1;
if (hpsb_get_tlabel(p, !in_interrupt())) {
if (hpsb_get_tlabel(p)) {
ETH1394_PRINT_G(KERN_ERR, "No more tlabels left while sending "
"to node " NODE_BUS_FMT "\n", NODE_BUS_ARGS(host, node));
return -1;
......@@ -1600,7 +1600,7 @@ static int ether1394_ethtool_ioctl(struct net_device *dev, void *useraddr)
case ETHTOOL_GDRVINFO: {
struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
strcpy (info.driver, driver_name);
strcpy (info.version, "$Rev: 1010 $");
strcpy (info.version, "$Rev: 1020 $");
/* FIXME XXX provide sane businfo */
strcpy (info.bus_info, "ieee1394");
if (copy_to_user (useraddr, &info, sizeof (info)))
......
......@@ -26,9 +26,9 @@
#include "ieee1394.h"
/* Register for incoming packets. This is 8192 bytes, which supports up to
* 1600mbs. We'll need to change this if that ever becomes "small" :) */
#define ETHER1394_REGION_ADDR_LEN 8192
/* Register for incoming packets. This is 4096 bytes, which supports up to
* S3200 (per Table 16-3 of IEEE 1394b-2002). */
#define ETHER1394_REGION_ADDR_LEN 4096
#define ETHER1394_REGION_ADDR 0xfffff0200000ULL
#define ETHER1394_REGION_ADDR_END (ETHER1394_REGION_ADDR + ETHER1394_REGION_ADDR_LEN)
......
......@@ -436,7 +436,7 @@ void highlevel_host_reset(struct hpsb_host *host)
}
void highlevel_iso_receive(struct hpsb_host *host, void *data,
unsigned int length)
size_t length)
{
struct list_head *entry;
struct hpsb_highlevel *hl;
......@@ -456,7 +456,7 @@ void highlevel_iso_receive(struct hpsb_host *host, void *data,
}
void highlevel_fcp_request(struct hpsb_host *host, int nodeid, int direction,
void *data, unsigned int length)
void *data, size_t length)
{
struct list_head *entry;
struct hpsb_highlevel *hl;
......
......@@ -46,14 +46,14 @@ struct hpsb_highlevel {
* packet header (first quadlet, CRCs are missing). You may get called
* for channel/host combinations you did not request. */
void (*iso_receive) (struct hpsb_host *host, int channel,
quadlet_t *data, unsigned int length);
quadlet_t *data, size_t length);
/* A write request was received on either the FCP_COMMAND (direction =
* 0) or the FCP_RESPONSE (direction = 1) register. The cts arg
* contains the cts field (first byte of data).
*/
void (*fcp_request) (struct hpsb_host *host, int nodeid, int direction,
int cts, u8 *data, unsigned int length);
int cts, u8 *data, size_t length);
struct list_head hl_list;
......@@ -79,9 +79,9 @@ struct hpsb_address_ops {
will send the response itself
*/
int (*read) (struct hpsb_host *host, int nodeid, quadlet_t *buffer,
u64 addr, unsigned int length, u16 flags);
u64 addr, size_t length, u16 flags);
int (*write) (struct hpsb_host *host, int nodeid, int destid,
quadlet_t *data, u64 addr, unsigned int length, u16 flags);
quadlet_t *data, u64 addr, size_t length, u16 flags);
/* Lock transactions: write results of ext_tcode operation into
* *store. */
......@@ -117,9 +117,9 @@ int highlevel_lock64(struct hpsb_host *host, int nodeid, octlet_t *store,
u64 addr, octlet_t data, octlet_t arg, int ext_tcode, u16 flags);
void highlevel_iso_receive(struct hpsb_host *host, void *data,
unsigned int length);
size_t length);
void highlevel_fcp_request(struct hpsb_host *host, int nodeid, int direction,
void *data, unsigned int length);
void *data, size_t length);
/*
......
......@@ -281,8 +281,8 @@ static int check_selfids(struct hpsb_host *host)
static void build_speed_map(struct hpsb_host *host, int nodecount)
{
char speedcap[nodecount];
char cldcnt[nodecount];
u8 speedcap[nodecount];
u8 cldcnt[nodecount];
u8 *map = host->speed_map;
struct selfid *sid;
struct ext_selfid *esid;
......@@ -333,7 +333,7 @@ static void build_speed_map(struct hpsb_host *host, int nodecount)
for (i = 1; i < nodecount; i++) {
for (j = cldcnt[i], n = i - 1; j > 0; j--) {
cldcnt[i] += cldcnt[n];
speedcap[n] = MIN(speedcap[n], speedcap[i]);
speedcap[n] = min(speedcap[n], speedcap[i]);
n -= cldcnt[n] + 1;
}
}
......@@ -342,11 +342,11 @@ static void build_speed_map(struct hpsb_host *host, int nodecount)
for (i = n - cldcnt[n]; i <= n; i++) {
for (j = 0; j < (n - cldcnt[n]); j++) {
map[j*64 + i] = map[i*64 + j] =
MIN(map[i*64 + j], speedcap[n]);
min(map[i*64 + j], speedcap[n]);
}
for (j = n + 1; j < nodecount; j++) {
map[j*64 + i] = map[i*64 + j] =
MIN(map[i*64 + j], speedcap[n]);
min(map[i*64 + j], speedcap[n]);
}
}
}
......
......@@ -113,35 +113,33 @@ static void fill_async_stream_packet(struct hpsb_packet *packet, int length,
/**
* hpsb_get_tlabel - allocate a transaction label
* @packet: the packet who's tlabel/tpool we set
* @wait: whether to sleep if no tlabel is available
*
* Every asynchronous transaction on the 1394 bus needs a transaction label to
* match the response to the request. This label has to be different from any
* other transaction label in an outstanding request to the same node to make
* matching possible without ambiguity.
* Every asynchronous transaction on the 1394 bus needs a transaction
* label to match the response to the request. This label has to be
* different from any other transaction label in an outstanding request to
* the same node to make matching possible without ambiguity.
*
* There are 64 different tlabels, so an allocated tlabel has to be freed with
* hpsb_free_tlabel() after the transaction is complete (unless it's reused again for
* the same target node).
*
* @wait cannot be set if in_interrupt()
* There are 64 different tlabels, so an allocated tlabel has to be freed
* with hpsb_free_tlabel() after the transaction is complete (unless it's
* reused again for the same target node).
*
* Return value: Zero on success, otherwise non-zero. A non-zero return
* generally means there are no available tlabels.
* generally means there are no available tlabels. If this is called out
* of interrupt or atomic context, then it will sleep until can return a
* tlabel.
*/
int hpsb_get_tlabel(struct hpsb_packet *packet, int wait)
int hpsb_get_tlabel(struct hpsb_packet *packet)
{
unsigned long flags;
struct hpsb_tlabel_pool *tp;
tp = &packet->host->tpool[packet->node_id & NODE_MASK];
if (wait) {
BUG_ON(in_interrupt());
down(&tp->count);
} else {
if (in_interrupt() || in_atomic()) {
if (down_trylock(&tp->count))
return 1;
} else {
down(&tp->count);
}
spin_lock_irqsave(&tp->lock, flags);
......@@ -270,7 +268,7 @@ struct hpsb_packet *hpsb_make_readpacket(struct hpsb_host *host, nodeid_t node,
packet->host = host;
packet->node_id = node;
if (hpsb_get_tlabel(packet, in_interrupt() ? 0 : 1)) {
if (hpsb_get_tlabel(packet)) {
free_hpsb_packet(packet);
return NULL;
}
......@@ -301,7 +299,7 @@ struct hpsb_packet *hpsb_make_writepacket (struct hpsb_host *host, nodeid_t node
packet->host = host;
packet->node_id = node;
if (hpsb_get_tlabel(packet, in_interrupt() ? 0 : 1)) {
if (hpsb_get_tlabel(packet)) {
free_hpsb_packet(packet);
return NULL;
}
......@@ -329,7 +327,7 @@ struct hpsb_packet *hpsb_make_lockpacket(struct hpsb_host *host, nodeid_t node,
p->host = host;
p->node_id = node;
if (hpsb_get_tlabel(p, in_interrupt() ? 0 : 1)) {
if (hpsb_get_tlabel(p)) {
free_hpsb_packet(p);
return NULL;
}
......@@ -366,7 +364,7 @@ struct hpsb_packet *hpsb_make_lock64packet(struct hpsb_host *host, nodeid_t node
p->host = host;
p->node_id = node;
if (hpsb_get_tlabel(p, in_interrupt() ? 0 : 1)) {
if (hpsb_get_tlabel(p)) {
free_hpsb_packet(p);
return NULL;
}
......
......@@ -7,7 +7,7 @@
/*
* Get and free transaction labels.
*/
int hpsb_get_tlabel(struct hpsb_packet *packet, int wait);
int hpsb_get_tlabel(struct hpsb_packet *packet);
void hpsb_free_tlabel(struct hpsb_packet *packet);
struct hpsb_packet *hpsb_make_readpacket(struct hpsb_host *host, nodeid_t node,
......
......@@ -7,7 +7,7 @@
#include <linux/version.h>
#include <linux/list.h>
#include <linux/init.h>
#include <linux/string.h>
#include <linux/spinlock.h>
#include <asm/semaphore.h>
#include <asm/byteorder.h>
......@@ -18,11 +18,6 @@
#define minor(dev) MINOR(dev)
#endif
#include <linux/spinlock.h>
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
/* Transaction Label handling */
struct hpsb_tlabel_pool {
......
......@@ -63,7 +63,7 @@ static char *nodemgr_find_oui_name(int oui)
*/
/*
* The nodemgr relies heavily on the Drive Model for device callbacks and
* The nodemgr relies heavily on the Driver Model for device callbacks and
* driver/device mappings. The old nodemgr used to handle all this itself,
* but now we are much simpler because of the LDM.
*/
......
......@@ -161,7 +161,7 @@ printk(level "%s: " fmt "\n" , OHCI1394_DRIVER_NAME , ## args)
printk(level "%s_%d: " fmt "\n" , OHCI1394_DRIVER_NAME, card , ## args)
static char version[] __devinitdata =
"$Rev: 1011 $ Ben Collins <bcollins@debian.org>";
"$Rev: 1023 $ Ben Collins <bcollins@debian.org>";
/* Module Parameters */
static int phys_dma = 1;
......
......@@ -1000,7 +1000,7 @@ static ssize_t mem_dmaread(struct memdata *md, u32 physbuf, ssize_t count,
DECLARE_WAITQUEUE(wait, current);
count &= ~3;
count = MIN(count, 53196);
count = min(count, 53196);
retval = count;
if (reg_read(md->lynx, DMA_CHAN_CTRL(CHANNEL_LOCALBUS))
......@@ -1011,14 +1011,14 @@ static ssize_t mem_dmaread(struct memdata *md, u32 physbuf, ssize_t count,
reg_write(md->lynx, LBUS_ADDR, md->type | offset);
pcl = edit_pcl(md->lynx, md->lynx->dmem_pcl, &pcltmp);
pcl->buffer[0].control = PCL_CMD_LBUS_TO_PCI | MIN(count, 4092);
pcl->buffer[0].control = PCL_CMD_LBUS_TO_PCI | min(count, 4092);
pcl->buffer[0].pointer = physbuf;
count -= 4092;
i = 0;
while (count > 0) {
i++;
pcl->buffer[i].control = MIN(count, 4092);
pcl->buffer[i].control = min(count, 4092);
pcl->buffer[i].pointer = physbuf + i * 4092;
count -= 4092;
}
......
......@@ -83,9 +83,9 @@ static const int iso_buffer_max = 4 * 1024 * 1024; /* 4 MB */
static struct hpsb_highlevel raw1394_highlevel;
static int arm_read (struct hpsb_host *host, int nodeid, quadlet_t *buffer,
u64 addr, unsigned int length, u16 flags);
u64 addr, size_t length, u16 flags);
static int arm_write (struct hpsb_host *host, int nodeid, int destid,
quadlet_t *data, u64 addr, unsigned int length, u16 flags);
quadlet_t *data, u64 addr, size_t length, u16 flags);
static int arm_lock (struct hpsb_host *host, int nodeid, quadlet_t *store,
u64 addr, quadlet_t data, quadlet_t arg, int ext_tcode, u16 flags);
static int arm_lock64 (struct hpsb_host *host, int nodeid, octlet_t *store,
......@@ -293,7 +293,7 @@ static void host_reset(struct hpsb_host *host)
}
static void iso_receive(struct hpsb_host *host, int channel, quadlet_t *data,
unsigned int length)
size_t length)
{
unsigned long flags;
struct list_head *lh;
......@@ -345,7 +345,7 @@ static void iso_receive(struct hpsb_host *host, int channel, quadlet_t *data,
req->req.generation = get_hpsb_generation(host);
req->req.misc = 0;
req->req.recvb = ptr2int(fi->iso_buffer);
req->req.length = MIN(length, fi->iso_buffer_length);
req->req.length = min(length, fi->iso_buffer_length);
list_add_tail(&req->list, &reqs);
}
......@@ -362,7 +362,7 @@ static void iso_receive(struct hpsb_host *host, int channel, quadlet_t *data,
}
static void fcp_request(struct hpsb_host *host, int nodeid, int direction,
int cts, u8 *data, unsigned int length)
int cts, u8 *data, size_t length)
{
unsigned long flags;
struct list_head *lh;
......@@ -538,9 +538,9 @@ static int state_initialized(struct file_info *fi, struct pending_request *req)
if (khl != NULL) {
req->req.error = RAW1394_ERROR_NONE;
req->req.length = MIN(req->req.length,
sizeof(struct raw1394_khost_list)
* req->req.misc);
req->req.length = min(req->req.length,
(u32)(sizeof(struct raw1394_khost_list)
* req->req.misc));
req->free_data = 1;
} else {
return -ENOMEM;
......@@ -878,7 +878,7 @@ static int handle_async_send(struct file_info *fi, struct pending_request *req)
}
static int arm_read (struct hpsb_host *host, int nodeid, quadlet_t *buffer,
u64 addr, unsigned int length, u16 flags)
u64 addr, size_t length, u16 flags)
{
struct pending_request *req;
struct list_head *lh;
......@@ -1014,7 +1014,7 @@ static int arm_read (struct hpsb_host *host, int nodeid, quadlet_t *buffer,
}
static int arm_write (struct hpsb_host *host, int nodeid, int destid,
quadlet_t *data, u64 addr, unsigned int length, u16 flags)
quadlet_t *data, u64 addr, size_t length, u16 flags)
{
struct pending_request *req;
struct list_head *lh;
......@@ -2079,6 +2079,9 @@ static int raw1394_iso_xmit_init(struct file_info *fi, void *uaddr)
{
struct raw1394_iso_status stat;
if (!fi->host)
return -EINVAL;
if (copy_from_user(&stat, uaddr, sizeof(stat)))
return -EFAULT;
......@@ -2108,6 +2111,9 @@ static int raw1394_iso_recv_init(struct file_info *fi, void *uaddr)
{
struct raw1394_iso_status stat;
if (!fi->host)
return -EINVAL;
if (copy_from_user(&stat, uaddr, sizeof(stat)))
return -EFAULT;
......
......@@ -80,7 +80,7 @@
#include "sbp2.h"
static char version[] __devinitdata =
"$Rev: 1010 $ Ben Collins <bcollins@debian.org>";
"$Rev: 1018 $ Ben Collins <bcollins@debian.org>";
/*
* Module load parameter definitions
......@@ -944,6 +944,16 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
return -EBUSY;
}
/* Schedule a timeout here. The reason is that we may be so close
* to a bus reset, that the device is not available for logins.
* This can happen when the bus reset is caused by the host
* 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. */
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(HZ);
/*
* Login to the sbp-2 device
*/
......@@ -1060,7 +1070,7 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id)
* 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,
u64 addr, unsigned int length, u16 flags)
u64 addr, size_t length, u16 flags)
{
/*
......@@ -1076,7 +1086,7 @@ static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid, int des
* physical dma in hardware). Mostly just here for debugging...
*/
static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid, quadlet_t *data,
u64 addr, unsigned int length, u16 flags)
u64 addr, size_t length, u16 flags)
{
/*
......@@ -2399,7 +2409,7 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id,
* This function deals with status writes from the SBP-2 device
*/
static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int destid,
quadlet_t *data, u64 addr, unsigned int length, u16 fl)
quadlet_t *data, u64 addr, size_t length, u16 fl)
{
struct sbp2scsi_host_info *hi = NULL;
struct scsi_id_instance_data *scsi_id = NULL;
......
......@@ -479,9 +479,9 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id);
#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid, int destid, quadlet_t *data,
u64 addr, unsigned int length, u16 flags);
u64 addr, size_t length, u16 flags);
static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid, quadlet_t *data,
u64 addr, unsigned int length, u16 flags);
u64 addr, size_t length, u16 flags);
#endif
/*
......@@ -492,7 +492,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id);
static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id);
static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id);
static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int destid,
quadlet_t *data, u64 addr, unsigned int length, u16 flags);
quadlet_t *data, u64 addr, size_t length, u16 flags);
static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait);
static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
struct sbp2_command_info *command,
......
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