Commit f50d5e03 authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://bk.linux1394.org/ieee1394-2.6

into ppc970.osdl.org:/home/torvalds/v2.5/linux
parents 6a59dff3 55387c40
......@@ -47,6 +47,23 @@ config IEEE1394_OUI_DB
This option is not needed for userspace programs like gscanbus
to show this information.
config IEEE1394_EXTRA_CONFIG_ROMS
bool "Build in extra config rom entries for certain functionality"
depends on IEEE1394
help
Some IEEE1394 functionality depends on extra config rom entries
being available in the host adapters CSR. These options will
allow you to choose which ones.
config IEEE1394_CONFIG_ROM_IP1394
bool "IP-1394 Entry"
depends on IEEE1394_EXTRA_CONFIG_ROMS && IEEE1394
help
Adds an entry for using IP-over-1394. If you want to use your
IEEE1394 bus as a network for IP systems (including interacting
with MacOSX and WinXP IP-over-1394), enable this option and the
eth1394 option below.
comment "Device Drivers"
depends on IEEE1394
......@@ -108,6 +125,8 @@ config IEEE1394_SBP2_PHYS_DMA
config IEEE1394_ETH1394
tristate "Ethernet over 1394"
depends on IEEE1394 && EXPERIMENTAL
select IEEE1394_CONFIG_ROM_IP1394
select IEEE1394_EXTRA_CONFIG_ROMS
help
This driver implements a functional majority of RFC 2734: IPv4 over
1394. It will provide IP connectivity with implementations of RFC
......
......@@ -4,7 +4,7 @@
ieee1394-objs := ieee1394_core.o ieee1394_transactions.o hosts.o \
highlevel.o csr.o nodemgr.o oui.o dma.o iso.o \
csr1212.o
csr1212.o config_roms.o
obj-$(CONFIG_IEEE1394) += ieee1394.o
obj-$(CONFIG_IEEE1394_PCILYNX) += pcilynx.o
......
......@@ -1227,15 +1227,15 @@ static void amdtp_add_host(struct hpsb_host *host)
ah->host = host;
ah->ohci = host->hostdata;
hpsb_set_hostinfo_key(&amdtp_highlevel, host, ah->ohci->id);
hpsb_set_hostinfo_key(&amdtp_highlevel, host, ah->host->id);
minor = IEEE1394_MINOR_BLOCK_AMDTP * 16 + ah->ohci->id;
minor = IEEE1394_MINOR_BLOCK_AMDTP * 16 + ah->host->id;
INIT_LIST_HEAD(&ah->stream_list);
spin_lock_init(&ah->stream_list_lock);
devfs_mk_cdev(MKDEV(IEEE1394_MAJOR, minor),
S_IFCHR|S_IRUSR|S_IWUSR, "amdtp/%d", ah->ohci->id);
S_IFCHR|S_IRUSR|S_IWUSR, "amdtp/%d", ah->host->id);
}
static void amdtp_remove_host(struct hpsb_host *host)
......@@ -1243,7 +1243,7 @@ static void amdtp_remove_host(struct hpsb_host *host)
struct amdtp_host *ah = hpsb_get_hostinfo(&amdtp_highlevel, host);
if (ah)
devfs_remove("amdtp/%d", ah->ohci->id);
devfs_remove("amdtp/%d", ah->host->id);
return;
}
......
/*
* IEEE 1394 for Linux
*
* ConfigROM entries
*
* Copyright (C) 2004 Ben Collins
*
* This code is licensed under the GPL. See the file COPYING in the root
* directory of the kernel sources for details.
*/
#include <linux/config.h>
#include <linux/types.h>
#include "csr1212.h"
#include "ieee1394.h"
#include "ieee1394_types.h"
#include "hosts.h"
#include "ieee1394_core.h"
#include "highlevel.h"
#include "csr.h"
#include "config_roms.h"
struct hpsb_config_rom_entry {
const char *name;
/* Base initialization, called at module load */
int (*init)(void);
/* Add entry to specified host */
int (*add)(struct hpsb_host *host);
/* Remove entry from specified host */
void (*remove)(struct hpsb_host *host);
/* Cleanup called at module exit */
void (*cleanup)(void);
/* The flag added to host->config_roms */
unsigned int flag;
};
int hpsb_default_host_entry(struct hpsb_host *host)
{
struct csr1212_keyval *root;
struct csr1212_keyval *vend_id = NULL;
struct csr1212_keyval *text = NULL;
char csr_name[128];
int ret;
sprintf(csr_name, "Linux - %s", host->driver->name);
root = host->csr.rom->root_kv;
vend_id = csr1212_new_immediate(CSR1212_KV_ID_VENDOR, host->csr.guid_hi >> 8);
text = csr1212_new_string_descriptor_leaf(csr_name);
if (!vend_id || !text) {
if (vend_id)
csr1212_release_keyval(vend_id);
if (text)
csr1212_release_keyval(text);
csr1212_destroy_csr(host->csr.rom);
return -ENOMEM;
}
ret = csr1212_associate_keyval(vend_id, text);
csr1212_release_keyval(text);
ret |= csr1212_attach_keyval_to_directory(root, vend_id);
if (ret != CSR1212_SUCCESS) {
csr1212_release_keyval(vend_id);
csr1212_destroy_csr(host->csr.rom);
return -ENOMEM;
}
host->update_config_rom = 1;
return 0;
}
#ifdef CONFIG_IEEE1394_CONFIG_ROM_IP1394
#include "eth1394.h"
static struct csr1212_keyval *ip1394_ud;
static int config_rom_ip1394_init(void)
{
struct csr1212_keyval *spec_id = NULL;
struct csr1212_keyval *spec_desc = NULL;
struct csr1212_keyval *ver = NULL;
struct csr1212_keyval *ver_desc = NULL;
int ret = -ENOMEM;
ip1394_ud = csr1212_new_directory(CSR1212_KV_ID_UNIT);
spec_id = csr1212_new_immediate(CSR1212_KV_ID_SPECIFIER_ID,
ETHER1394_GASP_SPECIFIER_ID);
spec_desc = csr1212_new_string_descriptor_leaf("IANA");
ver = csr1212_new_immediate(CSR1212_KV_ID_VERSION,
ETHER1394_GASP_VERSION);
ver_desc = csr1212_new_string_descriptor_leaf("IPv4");
if (!ip1394_ud || !spec_id || !spec_desc || !ver || !ver_desc)
goto ip1394_fail;
if (csr1212_associate_keyval(spec_id, spec_desc) == CSR1212_SUCCESS &&
csr1212_associate_keyval(ver, ver_desc) == CSR1212_SUCCESS &&
csr1212_attach_keyval_to_directory(ip1394_ud, spec_id) == CSR1212_SUCCESS &&
csr1212_attach_keyval_to_directory(ip1394_ud, ver) == CSR1212_SUCCESS)
ret = 0;
ip1394_fail:
if (ret && ip1394_ud) {
csr1212_release_keyval(ip1394_ud);
ip1394_ud = NULL;
}
if (spec_id)
csr1212_release_keyval(spec_id);
if (spec_desc)
csr1212_release_keyval(spec_desc);
if (ver)
csr1212_release_keyval(ver);
if (ver_desc)
csr1212_release_keyval(ver_desc);
return ret;
}
static void config_rom_ip1394_cleanup(void)
{
if (ip1394_ud) {
csr1212_release_keyval(ip1394_ud);
ip1394_ud = NULL;
}
}
static int config_rom_ip1394_add(struct hpsb_host *host)
{
if (!ip1394_ud)
return -ENODEV;
if (csr1212_attach_keyval_to_directory(host->csr.rom->root_kv,
ip1394_ud) != CSR1212_SUCCESS)
return -ENOMEM;
return 0;
}
static void config_rom_ip1394_remove(struct hpsb_host *host)
{
csr1212_detach_keyval_from_directory(host->csr.rom->root_kv, ip1394_ud);
}
static struct hpsb_config_rom_entry ip1394_entry = {
.name = "ip1394",
.init = config_rom_ip1394_init,
.add = config_rom_ip1394_add,
.remove = config_rom_ip1394_remove,
.cleanup = config_rom_ip1394_cleanup,
.flag = HPSB_CONFIG_ROM_ENTRY_IP1394,
};
#endif /* CONFIG_IEEE1394_CONFIG_ROM_IP1394 */
static struct hpsb_config_rom_entry *const config_rom_entries[] = {
#ifdef CONFIG_IEEE1394_CONFIG_ROM_IP1394
&ip1394_entry,
#endif
NULL,
};
int hpsb_init_config_roms(void)
{
int i, error = 0;
for (i = 0; config_rom_entries[i]; i++) {
if (!config_rom_entries[i]->init)
continue;
if (config_rom_entries[i]->init()) {
HPSB_ERR("Failed to initialize config rom entry `%s'",
config_rom_entries[i]->name);
error = -1;
} else
HPSB_DEBUG("Initialized config rom entry `%s'",
config_rom_entries[i]->name);
}
return error;
}
void hpsb_cleanup_config_roms(void)
{
int i;
for (i = 0; config_rom_entries[i]; i++) {
if (config_rom_entries[i]->cleanup)
config_rom_entries[i]->cleanup();
}
}
int hpsb_add_extra_config_roms(struct hpsb_host *host)
{
int i, error = 0;
for (i = 0; config_rom_entries[i]; i++) {
if (config_rom_entries[i]->add(host)) {
HPSB_ERR("fw-host%d: Failed to attach config rom entry `%s'",
host->id, config_rom_entries[i]->name);
error = -1;
} else {
host->config_roms |= config_rom_entries[i]->flag;
host->update_config_rom = 1;
}
}
return error;
}
void hpsb_remove_extra_config_roms(struct hpsb_host *host)
{
int i;
for (i = 0; config_rom_entries[i]; i++) {
if (!(host->config_roms & config_rom_entries[i]->flag))
continue;
config_rom_entries[i]->remove(host);
host->config_roms &= ~config_rom_entries[i]->flag;
host->update_config_rom = 1;
}
}
#ifndef _IEEE1394_CONFIG_ROMS_H
#define _IEEE1394_CONFIG_ROMS_H
#include "ieee1394_types.h"
#include "hosts.h"
/* The default host entry. This must succeed. */
int hpsb_default_host_entry(struct hpsb_host *host);
/* Initialize all config roms */
int hpsb_init_config_roms(void);
/* Cleanup all config roms */
void hpsb_cleanup_config_roms(void);
/* Add extra config roms to specified host */
int hpsb_add_extra_config_roms(struct hpsb_host *host);
/* Remove extra config roms from specified host */
void hpsb_remove_extra_config_roms(struct hpsb_host *host);
/* List of flags to check if a host contains a certain extra config rom
* entry. Available in the host->config_roms member. */
#define HPSB_CONFIG_ROM_ENTRY_IP1394 0x00000001
#endif /* _IEEE1394_CONFIG_ROMS_H */
......@@ -704,10 +704,11 @@ void _csr1212_destroy_keyval(struct csr1212_keyval *kv)
if (k->key.type == CSR1212_KV_TYPE_DIRECTORY) {
/* If the current entry is a directory, then move all
* the entries to the destruction list. */
tail->next = k->value.directory.dentries_head;
if (k->value.directory.dentries_head)
if (k->value.directory.dentries_head) {
tail->next = k->value.directory.dentries_head;
k->value.directory.dentries_head->prev = tail;
tail = k->value.directory.dentries_tail;
tail = k->value.directory.dentries_tail;
}
}
free_keyval(k);
k = a;
......@@ -1347,6 +1348,12 @@ int csr1212_parse_keyval(struct csr1212_keyval *kv,
case CSR1212_KV_TYPE_DIRECTORY:
for (i = 0; i < kvi_len; i++) {
csr1212_quad_t ki = kvi->data[i];
/* Some devices put null entries in their unit
* directories. If we come across such and entry,
* then skip it. */
if (ki == 0x0)
continue;
ret = csr1212_parse_dir_entry(kv, ki,
(kv->offset +
quads_to_bytes(i + 1)),
......
......@@ -2222,7 +2222,7 @@ static int dv1394_init(struct ti_ohci *ohci, enum pal_or_ntsc format, enum modes
video->ohci = ohci;
/* lower 2 bits of id indicate which of four "plugs"
per host */
video->id = ohci->id << 2;
video->id = ohci->host->id << 2;
if (format == DV1394_NTSC)
video->id |= mode;
else
......@@ -2302,47 +2302,49 @@ static void dv1394_un_init(struct video_card *video)
);
devfs_remove("ieee1394/%s", buf);
list_del(&video->list);
kfree(video);
}
static void dv1394_remove_host (struct hpsb_host *host)
{
struct ti_ohci *ohci;
struct video_card *video = NULL;
struct video_card *video;
unsigned long flags;
struct list_head *lh, *templh;
int n;
int id = host->id;
/* We only work with the OHCI-1394 driver */
if (strcmp(host->driver->name, OHCI1394_DRIVER_NAME))
return;
ohci = (struct ti_ohci *)host->hostdata;
/* find the corresponding video_cards */
do {
struct video_card *tmp_vid;
video = NULL;
/* find the corresponding video_cards */
spin_lock_irqsave(&dv1394_cards_lock, flags);
if (!list_empty(&dv1394_cards)) {
list_for_each_safe(lh, templh, &dv1394_cards) {
video = list_entry(lh, struct video_card, list);
if ((video->id >> 2) == ohci->id)
dv1394_un_init(video);
spin_lock_irqsave(&dv1394_cards_lock, flags);
list_for_each_entry(tmp_vid, &dv1394_cards, list) {
if ((tmp_vid->id >> 2) == id) {
list_del(&tmp_vid->list);
video = tmp_vid;
break;
}
}
}
spin_unlock_irqrestore(&dv1394_cards_lock, flags);
spin_unlock_irqrestore(&dv1394_cards_lock, flags);
n = (video->id >> 2);
if (video)
dv1394_un_init(video);
} while (video != NULL);
devfs_remove("ieee1394/dv/host%d/NTSC", n);
devfs_remove("ieee1394/dv/host%d/PAL", n);
devfs_remove("ieee1394/dv/host%d", n);
devfs_remove("ieee1394/dv/host%d/NTSC", id);
devfs_remove("ieee1394/dv/host%d/PAL", id);
devfs_remove("ieee1394/dv/host%d", id);
}
static void dv1394_add_host (struct hpsb_host *host)
{
struct ti_ohci *ohci;
int id = host->id;
/* We only work with the OHCI-1394 driver */
if (strcmp(host->driver->name, OHCI1394_DRIVER_NAME))
......@@ -2350,9 +2352,9 @@ static void dv1394_add_host (struct hpsb_host *host)
ohci = (struct ti_ohci *)host->hostdata;
devfs_mk_dir("ieee1394/dv/host%d", ohci->id);
devfs_mk_dir("ieee1394/dv/host%d/NTSC", ohci->id);
devfs_mk_dir("ieee1394/dv/host%d/PAL", ohci->id);
devfs_mk_dir("ieee1394/dv/host%d", id);
devfs_mk_dir("ieee1394/dv/host%d/NTSC", id);
devfs_mk_dir("ieee1394/dv/host%d/PAL", id);
dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE);
dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT);
......@@ -2369,7 +2371,7 @@ static void dv1394_add_host (struct hpsb_host *host)
static void dv1394_host_reset(struct hpsb_host *host)
{
struct ti_ohci *ohci;
struct video_card *video = NULL;
struct video_card *video = NULL, *tmp_vid;
unsigned long flags;
/* We only work with the OHCI-1394 driver */
......@@ -2381,10 +2383,10 @@ static void dv1394_host_reset(struct hpsb_host *host)
/* find the corresponding video_cards */
spin_lock_irqsave(&dv1394_cards_lock, flags);
if (!list_empty(&dv1394_cards)) {
list_for_each_entry(video, &dv1394_cards, list) {
if ((video->id >> 2) == ohci->id)
break;
list_for_each_entry(tmp_vid, &dv1394_cards, list) {
if ((tmp_vid->id >> 2) == host->id) {
video = tmp_vid;
break;
}
}
spin_unlock_irqrestore(&dv1394_cards_lock, flags);
......
......@@ -76,6 +76,7 @@
#include "iso.h"
#include "nodemgr.h"
#include "eth1394.h"
#include "config_roms.h"
#define ETH1394_PRINT_G(level, fmt, args...) \
printk(level "%s: " fmt, driver_name, ## args)
......@@ -88,7 +89,7 @@
#define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__)
static char version[] __devinitdata =
"$Rev: 1133 $ Ben Collins <bcollins@debian.org>";
"$Rev: 1175 $ Ben Collins <bcollins@debian.org>";
struct fragment_info {
struct list_head list;
......@@ -106,8 +107,6 @@ struct partial_datagram {
struct list_head frag_info;
};
static struct csr1212_keyval *eth1394_ud = NULL;
struct pdg_list {
struct list_head list; /* partial datagram list per node */
unsigned int sz; /* partial datagram list size per node */
......@@ -461,6 +460,8 @@ static struct ieee1394_device_id eth1394_id_table[] = {
{}
};
MODULE_DEVICE_TABLE(ieee1394, eth1394_id_table);
static struct hpsb_protocol_driver eth1394_proto_driver = {
.name = "IPv4 over 1394 Driver",
.id_table = eth1394_id_table,
......@@ -553,9 +554,11 @@ static void ether1394_add_host (struct hpsb_host *host)
struct net_device *dev = NULL;
struct eth1394_priv *priv;
static int version_printed = 0;
u64 fifo_addr;
if (!(host->config_roms & HPSB_CONFIG_ROM_ENTRY_IP1394))
return;
fifo_addr = hpsb_allocate_and_register_addrspace(&eth1394_highlevel,
host,
&addr_ops,
......@@ -634,14 +637,6 @@ static void ether1394_add_host (struct hpsb_host *host)
priv->bc_state = ETHER1394_BC_RUNNING;
}
if (csr1212_attach_keyval_to_directory(host->csr.rom->root_kv,
eth1394_ud) != CSR1212_SUCCESS) {
ETH1394_PRINT (KERN_ERR, dev->name,
"Cannot attach IP 1394 Unit Directory to "
"Config ROM\n");
goto out;
}
hi->host->update_config_rom = 1;
return;
out:
......@@ -668,10 +663,6 @@ static void ether1394_remove_host (struct hpsb_host *host)
if (priv->iso != NULL)
hpsb_iso_shutdown(priv->iso);
csr1212_detach_keyval_from_directory(hi->host->csr.rom->root_kv,
eth1394_ud);
hi->host->update_config_rom = 1;
if (hi->dev) {
unregister_netdev (hi->dev);
free_netdev(hi->dev);
......@@ -1483,7 +1474,6 @@ static inline struct hpsb_packet *ether1394_alloc_common_packet(struct hpsb_host
p = hpsb_alloc_packet(0);
if (p) {
p->host = host;
p->data = NULL;
p->generation = get_hpsb_generation(host);
p->type = hpsb_async;
}
......@@ -1514,7 +1504,7 @@ static inline int ether1394_prep_write_packet(struct hpsb_packet *p,
| (1 << 8) | (TCODE_WRITEB << 4);
p->header[3] = tx_len << 16;
p->data_size = tx_len + (tx_len % 4 ? 4 - (tx_len % 4) : 0);
p->data_size = (tx_len + 3) & ~3;
p->data = (quadlet_t*)data;
return 0;
......@@ -1807,7 +1797,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: 1133 $");
strcpy (info.version, "$Rev: 1175 $");
/* FIXME XXX provide sane businfo */
strcpy (info.bus_info, "ieee1394");
if (copy_to_user (useraddr, &info, sizeof (info)))
......@@ -1830,67 +1820,13 @@ static int ether1394_ethtool_ioctl(struct net_device *dev, void *useraddr)
static int __init ether1394_init_module (void)
{
int ret;
struct csr1212_keyval *spec_id = NULL;
struct csr1212_keyval *spec_desc = NULL;
struct csr1212_keyval *ver = NULL;
struct csr1212_keyval *ver_desc = NULL;
packet_task_cache = kmem_cache_create("packet_task", sizeof(struct packet_task),
0, 0, NULL, NULL);
eth1394_ud = csr1212_new_directory(CSR1212_KV_ID_UNIT);
spec_id = csr1212_new_immediate(CSR1212_KV_ID_SPECIFIER_ID,
ETHER1394_GASP_SPECIFIER_ID);
spec_desc = csr1212_new_string_descriptor_leaf("IANA");
ver = csr1212_new_immediate(CSR1212_KV_ID_VERSION,
ETHER1394_GASP_VERSION);
ver_desc = csr1212_new_string_descriptor_leaf("IPv4");
if ((!eth1394_ud) ||
(!spec_id) ||
(!spec_desc) ||
(!ver) ||
(!ver_desc)) {
ret = -ENOMEM;
goto out;
}
ret = csr1212_associate_keyval(spec_id, spec_desc);
if (ret != CSR1212_SUCCESS)
goto out;
ret = csr1212_associate_keyval(ver, ver_desc);
if (ret != CSR1212_SUCCESS)
goto out;
ret = csr1212_attach_keyval_to_directory(eth1394_ud, spec_id);
if (ret != CSR1212_SUCCESS)
goto out;
ret = csr1212_attach_keyval_to_directory(eth1394_ud, ver);
if (ret != CSR1212_SUCCESS)
goto out;
/* Register ourselves as a highlevel driver */
hpsb_register_highlevel(&eth1394_highlevel);
ret = hpsb_register_protocol(&eth1394_proto_driver);
out:
if ((ret != 0) && eth1394_ud) {
csr1212_release_keyval(eth1394_ud);
}
if (spec_id)
csr1212_release_keyval(spec_id);
if (spec_desc)
csr1212_release_keyval(spec_desc);
if (ver)
csr1212_release_keyval(ver);
if (ver_desc)
csr1212_release_keyval(ver_desc);
return ret;
return hpsb_register_protocol(&eth1394_proto_driver);
}
static void __exit ether1394_exit_module (void)
......@@ -1898,10 +1834,6 @@ static void __exit ether1394_exit_module (void)
hpsb_unregister_protocol(&eth1394_proto_driver);
hpsb_unregister_highlevel(&eth1394_highlevel);
kmem_cache_destroy(packet_task_cache);
if (eth1394_ud) {
csr1212_release_keyval(eth1394_ud);
}
}
module_init(ether1394_init_module);
......
......@@ -24,6 +24,8 @@
#ifndef __ETH1394_H
#define __ETH1394_H
#include <linux/netdevice.h>
#include "ieee1394.h"
/* Register for incoming packets. This is 4096 bytes, which supports up to
......
......@@ -27,6 +27,7 @@
#include "highlevel.h"
#include "nodemgr.h"
#include "csr.h"
#include "config_roms.h"
static void delayed_reset_bus(unsigned long __reset_info)
......@@ -103,6 +104,7 @@ static int alloc_hostnum_cb(struct hpsb_host *host, void *__data)
* Return Value: a pointer to the &hpsb_host if succesful, %NULL if
* no memory was available.
*/
static DECLARE_MUTEX(host_num_alloc);
struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
struct device *dev)
......@@ -148,14 +150,12 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
h->topology_map = h->csr.topology_map + 3;
h->speed_map = (u8 *)(h->csr.speed_map + 2);
while (1) {
if (!nodemgr_for_each_host(&hostnum, alloc_hostnum_cb)) {
h->id = hostnum;
break;
}
down(&host_num_alloc);
while (nodemgr_for_each_host(&hostnum, alloc_hostnum_cb))
hostnum++;
}
h->id = hostnum;
memcpy(&h->device, &nodemgr_dev_template_host, sizeof(h->device));
h->device.parent = dev;
......@@ -169,12 +169,21 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
class_device_register(&h->class_dev);
get_device(&h->device);
up(&host_num_alloc);
return h;
}
void hpsb_add_host(struct hpsb_host *host)
int hpsb_add_host(struct hpsb_host *host)
{
highlevel_add_host(host);
if (hpsb_default_host_entry(host))
return -ENOMEM;
hpsb_add_extra_config_roms(host);
highlevel_add_host(host);
return 0;
}
void hpsb_remove_host(struct hpsb_host *host)
......@@ -184,6 +193,8 @@ void hpsb_remove_host(struct hpsb_host *host)
highlevel_remove_host(host);
hpsb_remove_extra_config_roms(host);
class_device_unregister(&host->class_dev);
device_unregister(&host->device);
}
......
......@@ -66,6 +66,8 @@ struct hpsb_host {
int update_config_rom;
struct timer_list delayed_reset;
unsigned int config_roms;
struct list_head addr_space;
};
......@@ -191,7 +193,7 @@ struct hpsb_host_driver {
struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
struct device *dev);
void hpsb_add_host(struct hpsb_host *host);
int hpsb_add_host(struct hpsb_host *host);
void hpsb_remove_host(struct hpsb_host *h);
/* The following 2 functions are deprecated and will be removed when the
......
......@@ -36,8 +36,11 @@
#define ACK_BUSY_X 0x4
#define ACK_BUSY_A 0x5
#define ACK_BUSY_B 0x6
#define ACK_TARDY 0xb
#define ACK_CONFLICT_ERROR 0xc
#define ACK_DATA_ERROR 0xd
#define ACK_TYPE_ERROR 0xe
#define ACK_ADDRESS_ERROR 0xf
/* Non-standard "ACK codes" for internal use */
#define ACKX_NONE (-1)
......
......@@ -44,6 +44,7 @@
#include "nodemgr.h"
#include "dma.h"
#include "iso.h"
#include "config_roms.h"
/*
* Disable the nodemgr detection and config rom reading functionality.
......@@ -92,7 +93,7 @@ static void queue_packet_complete(struct hpsb_packet *packet);
void hpsb_set_packet_complete_task(struct hpsb_packet *packet,
void (*routine)(void *), void *data)
{
BUG_ON(packet->complete_routine != NULL);
WARN_ON(packet->complete_routine != NULL);
packet->complete_routine = routine;
packet->complete_data = data;
return;
......@@ -120,34 +121,35 @@ void hpsb_set_packet_complete_task(struct hpsb_packet *packet,
*/
struct hpsb_packet *hpsb_alloc_packet(size_t data_size)
{
struct hpsb_packet *packet = NULL;
void *data = NULL;
packet = kmem_cache_alloc(hpsb_packet_cache, GFP_ATOMIC);
if (packet == NULL)
return NULL;
memset(packet, 0, sizeof(struct hpsb_packet));
packet->header = packet->embedded_header;
if (data_size) {
data = kmalloc(data_size + 8, GFP_ATOMIC);
if (data == NULL) {
struct hpsb_packet *packet = NULL;
void *data = NULL;
int gfp_flags = (in_atomic() || irqs_disabled()) ? GFP_ATOMIC : GFP_KERNEL;
packet = kmem_cache_alloc(hpsb_packet_cache, gfp_flags);
if (packet == NULL)
return NULL;
memset(packet, 0, sizeof(*packet));
packet->header = packet->embedded_header;
INIT_LIST_HEAD(&packet->list);
packet->state = hpsb_unused;
packet->generation = -1;
atomic_set(&packet->refcnt, 1);
if (data_size) {
data_size = (data_size + 3) & ~3;
data = kmalloc(data_size + 8, gfp_flags);
if (data == NULL) {
kmem_cache_free(hpsb_packet_cache, packet);
return NULL;
}
packet->data = data;
packet->data_size = data_size;
}
return NULL;
}
INIT_LIST_HEAD(&packet->list);
packet->complete_routine = NULL;
packet->complete_data = NULL;
packet->state = hpsb_unused;
packet->generation = -1;
packet->data = data;
packet->data_size = data_size;
}
return packet;
return packet;
}
......@@ -155,15 +157,14 @@ struct hpsb_packet *hpsb_alloc_packet(size_t data_size)
* hpsb_free_packet - free packet and data associated with it
* @packet: packet to free (is NULL safe)
*
* This function will free packet->data, packet->header and finally the packet
* itself.
* This function will free packet->data and finally the packet itself.
*/
void hpsb_free_packet(struct hpsb_packet *packet)
{
if (!packet) return;
kfree(packet->data);
kmem_cache_free(hpsb_packet_cache, packet);
if (packet && atomic_dec_and_test(&packet->refcnt)) {
kfree(packet->data);
kmem_cache_free(hpsb_packet_cache, packet);
}
}
......@@ -402,28 +403,30 @@ void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot)
void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet,
int ackcode)
{
unsigned long flags;
packet->ack_code = ackcode;
packet->ack_code = ackcode;
if (packet->no_waiter) {
/* must not have a tlabel allocated */
hpsb_free_packet(packet);
return;
}
if (packet->no_waiter) {
/* must not have a tlabel allocated */
hpsb_free_packet(packet);
return;
}
if (ackcode != ACK_PENDING || !packet->expect_response) {
packet->state = hpsb_complete;
queue_packet_complete(packet);
return;
}
if (ackcode != ACK_PENDING || !packet->expect_response) {
atomic_dec(&packet->refcnt);
list_del(&packet->list);
packet->state = hpsb_complete;
queue_packet_complete(packet);
return;
}
packet->state = hpsb_pending;
packet->sendtime = jiffies;
if (packet->state == hpsb_complete) {
hpsb_free_packet(packet);
return;
}
spin_lock_irqsave(&host->pending_pkt_lock, flags);
list_add_tail(&packet->list, &host->pending_packets);
spin_unlock_irqrestore(&host->pending_pkt_lock, flags);
atomic_dec(&packet->refcnt);
packet->state = hpsb_pending;
packet->sendtime = jiffies;
mod_timer(&host->timeout, jiffies + host->timeout_interval);
}
......@@ -492,7 +495,7 @@ int hpsb_send_phy_config(struct hpsb_host *host, int rootid, int gapcnt)
*/
int hpsb_send_packet(struct hpsb_packet *packet)
{
struct hpsb_host *host = packet->host;
struct hpsb_host *host = packet->host;
if (host->is_shutdown)
return -EINVAL;
......@@ -502,6 +505,15 @@ int hpsb_send_packet(struct hpsb_packet *packet)
packet->state = hpsb_queued;
if (!packet->no_waiter || packet->expect_response) {
unsigned long flags;
atomic_inc(&packet->refcnt);
spin_lock_irqsave(&host->pending_pkt_lock, flags);
list_add_tail(&packet->list, &host->pending_packets);
spin_unlock_irqrestore(&host->pending_pkt_lock, flags);
}
if (packet->node_id == host->node_id)
{ /* it is a local request, so handle it locally */
quadlet_t *data;
......@@ -658,7 +670,12 @@ void handle_packet_response(struct hpsb_host *host, int tcode, quadlet_t *data,
break;
}
packet->state = hpsb_complete;
if (packet->state == hpsb_queued) {
packet->sendtime = jiffies;
packet->ack_code = ACK_PENDING;
}
packet->state = hpsb_complete;
queue_packet_complete(packet);
}
......@@ -1024,10 +1041,16 @@ static int hpsbpkt_thread(void *__hi)
complete_and_exit(&khpsbpkt_complete, 0);
}
static int __init ieee1394_init(void)
{
int i;
if (hpsb_init_config_roms()) {
HPSB_ERR("Failed to initialize some config rom entries.\n");
HPSB_ERR("Some features may not be available\n");
}
khpsbpkt_pid = kernel_thread(hpsbpkt_thread, NULL, CLONE_KERNEL);
if (khpsbpkt_pid < 0) {
HPSB_ERR("Failed to start hpsbpkt thread!\n");
......@@ -1044,7 +1067,7 @@ static int __init ieee1394_init(void)
devfs_mk_dir("ieee1394");
hpsb_packet_cache = kmem_cache_create("hpsb_packet", sizeof(struct hpsb_packet),
0, 0, NULL, NULL);
0, SLAB_HWCACHE_ALIGN, NULL, NULL);
bus_register(&ieee1394_bus_type);
for (i = 0; fw_bus_attrs[i]; i++)
......@@ -1083,6 +1106,8 @@ static void __exit ieee1394_cleanup(void)
kmem_cache_destroy(hpsb_packet_cache);
hpsb_cleanup_config_roms();
unregister_chrdev_region(IEEE1394_CORE_DEV, 256);
devfs_remove("ieee1394");
}
......
......@@ -4,6 +4,7 @@
#include <linux/slab.h>
#include <linux/devfs_fs_kernel.h>
#include <asm/atomic.h>
#include <asm/semaphore.h>
#include "hosts.h"
......@@ -59,6 +60,8 @@ struct hpsb_packet {
struct hpsb_host *host;
unsigned int generation;
atomic_t refcnt;
/* Function (and possible data to pass to it) to call when this
* packet is completed. */
void (*complete_routine)(void *);
......
......@@ -239,6 +239,11 @@ int hpsb_packet_success(struct hpsb_packet *packet)
return -EAGAIN;
}
case ACK_ADDRESS_ERROR:
return -EINVAL;
case ACK_TARDY:
case ACK_CONFLICT_ERROR:
case ACKX_NONE:
case ACKX_SEND_ERROR:
case ACKX_ABORTED:
......@@ -263,7 +268,7 @@ struct hpsb_packet *hpsb_make_readpacket(struct hpsb_host *host, nodeid_t node,
if (length == 0)
return NULL;
packet = hpsb_alloc_packet(length + (length % 4 ? 4 - (length % 4) : 0));
packet = hpsb_alloc_packet((length + 3) & ~3);
if (!packet)
return NULL;
......@@ -291,7 +296,7 @@ struct hpsb_packet *hpsb_make_writepacket (struct hpsb_host *host, nodeid_t node
if (length == 0)
return NULL;
packet = hpsb_alloc_packet(length + (length % 4 ? 4 - (length % 4) : 0));
packet = hpsb_alloc_packet((length + 3) & ~3);
if (!packet)
return NULL;
......@@ -325,7 +330,7 @@ struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 *buffer, i
if (length == 0)
return NULL;
packet = hpsb_alloc_packet(length + (length % 4 ? 4 - (length % 4) : 0));
packet = hpsb_alloc_packet((length + 3) & ~3);
if (!packet)
return NULL;
......
......@@ -79,7 +79,7 @@ static int nodemgr_bus_read(struct csr1212_csr *csr, u64 addr, u16 length,
static int nodemgr_get_max_rom(quadlet_t *bus_info_data, void *__ci)
{
return (bus_info_data[2] >> 8) & 0x3;
return (CSR1212_BE32_TO_CPU(bus_info_data[2]) >> 8) & 0x3;
}
static struct csr1212_bus_ops nodemgr_csr_ops = {
......@@ -1286,18 +1286,19 @@ static void nodemgr_resume_ne(struct node_entry *ne)
}
static void nodemgr_ud_update_pdrv(struct unit_directory *ud)
static void nodemgr_update_pdrv(struct node_entry *ne)
{
struct device *dev;
struct unit_directory *ud;
struct hpsb_protocol_driver *pdrv;
struct class *class = &nodemgr_ud_class;
struct class_device *cdev;
if (!get_device(&ud->device))
return;
list_for_each_entry(dev, &ud->device.children, node)
nodemgr_ud_update_pdrv(container_of(dev, struct unit_directory, device));
down_read(&class->subsys.rwsem);
list_for_each_entry(cdev, &class->children, node) {
ud = container_of(cdev, struct unit_directory, class_dev);
if (ud->ne != ne || !ud->device.driver)
continue;
if (ud->device.driver) {
pdrv = container_of(ud->device.driver, struct hpsb_protocol_driver, driver);
if (pdrv->update && pdrv->update(ud)) {
......@@ -1306,14 +1307,13 @@ static void nodemgr_ud_update_pdrv(struct unit_directory *ud)
up_write(&ud->device.bus->subsys.rwsem);
}
}
put_device(&ud->device);
up_read(&class->subsys.rwsem);
}
static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int generation)
{
struct device *dev, *udev;
struct device *dev;
if (ne->host != hi->host || ne->in_limbo)
return;
......@@ -1330,8 +1330,7 @@ static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int ge
if (ne->needs_probe)
nodemgr_process_root_directory(hi, ne);
else if (ne->generation == generation)
list_for_each_entry(udev, &dev->children, node)
nodemgr_ud_update_pdrv(container_of(udev, struct unit_directory, device));
nodemgr_update_pdrv(ne);
else
nodemgr_suspend_ne(ne);
......
......@@ -134,10 +134,10 @@
#endif
#ifdef OHCI1394_DEBUG
#define DBGMSG(card, fmt, args...) \
printk(KERN_INFO "%s: fw-host%d: " fmt "\n" , OHCI1394_DRIVER_NAME, card , ## args)
#define DBGMSG(fmt, args...) \
printk(KERN_INFO "%s: fw-host%d: " fmt "\n" , OHCI1394_DRIVER_NAME, ohci->host->id , ## args)
#else
#define DBGMSG(card, fmt, args...)
#define DBGMSG(fmt, args...)
#endif
#ifdef CONFIG_IEEE1394_OHCI_DMA_DEBUG
......@@ -158,11 +158,11 @@ static int global_outstanding_dmas = 0;
printk(level "%s: " fmt "\n" , OHCI1394_DRIVER_NAME , ## args)
/* print card specific information */
#define PRINT(level, card, fmt, args...) \
printk(level "%s: fw-host%d: " fmt "\n" , OHCI1394_DRIVER_NAME, card , ## args)
#define PRINT(level, fmt, args...) \
printk(level "%s: fw-host%d: " fmt "\n" , OHCI1394_DRIVER_NAME, ohci->host->id , ## args)
static char version[] __devinitdata =
"$Rev: 1131 $ Ben Collins <bcollins@debian.org>";
"$Rev: 1172 $ Ben Collins <bcollins@debian.org>";
/* Module Parameters */
static int phys_dma = 1;
......@@ -241,7 +241,7 @@ static u8 get_phy_reg(struct ti_ohci *ohci, u8 addr)
r = reg_read(ohci, OHCI1394_PhyControl);
if (i >= OHCI_LOOP_COUNT)
PRINT (KERN_ERR, ohci->id, "Get PHY Reg timeout [0x%08x/0x%08x/%d]",
PRINT (KERN_ERR, "Get PHY Reg timeout [0x%08x/0x%08x/%d]",
r, r & 0x80000000, i);
spin_unlock_irqrestore (&ohci->phy_reg_lock, flags);
......@@ -268,7 +268,7 @@ static void set_phy_reg(struct ti_ohci *ohci, u8 addr, u8 data)
}
if (i == OHCI_LOOP_COUNT)
PRINT (KERN_ERR, ohci->id, "Set PHY Reg timeout [0x%08x/0x%08x/%d]",
PRINT (KERN_ERR, "Set PHY Reg timeout [0x%08x/0x%08x/%d]",
r, r & 0x00004000, i);
spin_unlock_irqrestore (&ohci->phy_reg_lock, flags);
......@@ -305,7 +305,7 @@ static void handle_selfid(struct ti_ohci *ohci, struct hpsb_host *host,
if ((self_id_count & 0x80000000) ||
((self_id_count & 0x00FF0000) != (q0 & 0x00FF0000))) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"Error in reception of SelfID packets [0x%08x/0x%08x] (count: %d)",
self_id_count, q0, ohci->self_id_errors);
......@@ -315,7 +315,7 @@ static void handle_selfid(struct ti_ohci *ohci, struct hpsb_host *host,
set_phy_reg_mask (ohci, 1, 0x40);
ohci->self_id_errors++;
} else {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"Too many errors on SelfID error reception, giving up!");
}
return;
......@@ -337,19 +337,19 @@ static void handle_selfid(struct ti_ohci *ohci, struct hpsb_host *host,
}
if (q0 == ~q1) {
DBGMSG (ohci->id, "SelfID packet 0x%x received", q0);
DBGMSG ("SelfID packet 0x%x received", q0);
hpsb_selfid_received(host, cpu_to_be32(q0));
if (((q0 & 0x3f000000) >> 24) == phyid)
DBGMSG (ohci->id, "SelfID for this node is 0x%08x", q0);
DBGMSG ("SelfID for this node is 0x%08x", q0);
} else {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"SelfID is inconsistent [0x%08x/0x%08x]", q0, q1);
}
q += 2;
size -= 2;
}
DBGMSG(ohci->id, "SelfID complete");
DBGMSG("SelfID complete");
return;
}
......@@ -364,7 +364,7 @@ static void ohci_soft_reset(struct ti_ohci *ohci) {
break;
mdelay(1);
}
DBGMSG (ohci->id, "Soft reset finished");
DBGMSG ("Soft reset finished");
}
static int run_context(struct ti_ohci *ohci, int reg, char *msg)
......@@ -374,14 +374,14 @@ static int run_context(struct ti_ohci *ohci, int reg, char *msg)
/* check that the node id is valid */
nodeId = reg_read(ohci, OHCI1394_NodeID);
if (!(nodeId&0x80000000)) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"Running dma failed because Node ID is not valid");
return -1;
}
/* check that the node number != 63 */
if ((nodeId&0x3f)==63) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"Running dma failed because Node ID == 63");
return -1;
}
......@@ -389,7 +389,7 @@ static int run_context(struct ti_ohci *ohci, int reg, char *msg)
/* Run the dma context */
reg_write(ohci, reg, 0x8000);
if (msg) PRINT(KERN_DEBUG, ohci->id, "%s", msg);
if (msg) PRINT(KERN_DEBUG, "%s", msg);
return 0;
}
......@@ -451,7 +451,7 @@ static void initialize_dma_rcv_ctx(struct dma_rcv_ctx *d, int generate_irq)
/* Run context */
reg_write(ohci, d->ctrlSet, 0x00008000);
DBGMSG(ohci->id, "Receive DMA ctx=%d initialized", d->ctx);
DBGMSG("Receive DMA ctx=%d initialized", d->ctx);
}
/* Initialize the dma transmit context */
......@@ -474,7 +474,7 @@ static void initialize_dma_trm_ctx(struct dma_trm_ctx *d)
reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, 1 << d->ctx);
}
DBGMSG(ohci->id, "Transmit DMA ctx=%d initialized", d->ctx);
DBGMSG("Transmit DMA ctx=%d initialized", d->ctx);
}
/* Count the number of available iso contexts */
......@@ -486,7 +486,7 @@ static int get_nb_iso_ctx(struct ti_ohci *ohci, int reg)
reg_write(ohci, reg, 0xffffffff);
tmp = reg_read(ohci, reg);
DBGMSG(ohci->id,"Iso contexts reg: %08x implemented: %08x", reg, tmp);
DBGMSG("Iso contexts reg: %08x implemented: %08x", reg, tmp);
/* Count the number of contexts */
for (i=0; i<32; i++) {
......@@ -600,7 +600,7 @@ static void ohci_initialize(struct ti_ohci *ohci)
#else
sprintf (irq_buf, "%s", __irq_itoa(ohci->dev->irq));
#endif
PRINT(KERN_INFO, ohci->id, "OHCI-1394 %d.%d (PCI): IRQ=[%s] "
PRINT(KERN_INFO, "OHCI-1394 %d.%d (PCI): IRQ=[%s] "
"MMIO=[%lx-%lx] Max Packet=[%d]",
((((buf) >> 16) & 0xf) + (((buf) >> 20) & 0xf) * 10),
((((buf) >> 4) & 0xf) + ((buf) & 0xf) * 10), irq_buf,
......@@ -635,7 +635,7 @@ static void insert_packet(struct ti_ohci *ohci,
u32 cycleTimer;
int idx = d->prg_ind;
DBGMSG(ohci->id, "Inserting packet for node " NODE_BUS_FMT
DBGMSG("Inserting packet for node " NODE_BUS_FMT
", tlabel=%d, tcode=0x%x, speed=%d",
NODE_BUS_ARGS(ohci->host, packet->node_id), packet->tlabel,
packet->tcode, packet->speed_code);
......@@ -653,7 +653,7 @@ static void insert_packet(struct ti_ohci *ohci,
(((((cycleTimer>>25)&0x7)+1)&0x7)<<13) |
((cycleTimer&0x01fff000)>>12));
DBGMSG(ohci->id, "cycleTimer: %08x timeStamp: %08x",
DBGMSG("cycleTimer: %08x timeStamp: %08x",
cycleTimer, d->prg_cpu[idx]->begin.status);
} else
d->prg_cpu[idx]->begin.status = 0;
......@@ -709,7 +709,7 @@ static void insert_packet(struct ti_ohci *ohci,
if (cross_bound((unsigned long)packet->data,
packet->data_size)>0) {
/* FIXME: do something about it */
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"%s: packet data addr: %p size %Zd bytes "
"cross page boundary", __FUNCTION__,
packet->data, packet->data_size);
......@@ -773,7 +773,7 @@ static void insert_packet(struct ti_ohci *ohci,
d->prg_cpu[idx]->end.branchAddress = 0;
d->prg_cpu[idx]->end.status = 0;
DBGMSG(ohci->id, "Iso xmit context info: header[%08x %08x]\n"
DBGMSG("Iso xmit context info: header[%08x %08x]\n"
" begin=%08x %08x %08x %08x\n"
" %08x %08x %08x %08x\n"
" end =%08x %08x %08x %08x",
......@@ -827,19 +827,19 @@ static int dma_trm_flush(struct ti_ohci *ohci, struct dma_trm_ctx *d)
}
if (d->free_prgs == 0)
DBGMSG(ohci->id, "Transmit DMA FIFO ctx=%d is full... waiting", d->ctx);
DBGMSG("Transmit DMA FIFO ctx=%d is full... waiting", d->ctx);
/* Is the context running ? (should be unless it is
the first packet to be sent in this context) */
if (!(reg_read(ohci, d->ctrlSet) & 0x8000)) {
DBGMSG(ohci->id,"Starting transmit DMA ctx=%d",d->ctx);
DBGMSG("Starting transmit DMA ctx=%d",d->ctx);
reg_write(ohci, d->cmdPtr, d->prg_bus[idx]|z);
run_context(ohci, d->ctrlSet, NULL);
}
else {
/* Wake up the dma context if necessary */
if (!(reg_read(ohci, d->ctrlSet) & 0x400)) {
DBGMSG(ohci->id,"Waking transmit DMA ctx=%d",d->ctx);
DBGMSG("Waking transmit DMA ctx=%d",d->ctx);
}
/* do this always, to avoid race condition */
......@@ -856,7 +856,7 @@ static int ohci_transmit(struct hpsb_host *host, struct hpsb_packet *packet)
unsigned long flags;
if (packet->data_size > ohci->max_packet_size) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"Transmit packet size %Zd is too big",
packet->data_size);
return -EOVERFLOW;
......@@ -874,7 +874,7 @@ static int ohci_transmit(struct hpsb_host *host, struct hpsb_packet *packet)
if (ohci->it_legacy_context.ohci == NULL) {
if (in_interrupt()) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"legacy IT context cannot be initialized during interrupt");
return -EINVAL;
}
......@@ -882,7 +882,7 @@ static int ohci_transmit(struct hpsb_host *host, struct hpsb_packet *packet)
if (alloc_dma_trm_ctx(ohci, &ohci->it_legacy_context,
DMA_CTX_ISO, 0, IT_NUM_DESC,
OHCI1394_IsoXmitContextBase) < 0) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"error initializing legacy IT context");
return -ENOMEM;
}
......@@ -974,7 +974,7 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
break;
case SET_BUS_ID:
PRINT(KERN_ERR, ohci->id, "devctl command SET_BUS_ID err");
PRINT(KERN_ERR, "devctl command SET_BUS_ID err");
break;
case ACT_CYCLE_MASTER:
......@@ -985,7 +985,7 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
/*
* enable cycleTimer, cycleMaster
*/
DBGMSG(ohci->id, "Cycle master enabled");
DBGMSG("Cycle master enabled");
reg_write(ohci, OHCI1394_LinkControlSet,
OHCI1394_LinkControl_CycleTimerEnable |
OHCI1394_LinkControl_CycleMaster);
......@@ -1000,7 +1000,7 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
break;
case CANCEL_REQUESTS:
DBGMSG(ohci->id, "Cancel request received");
DBGMSG("Cancel request received");
dma_trm_reset(&ohci->at_req_context);
dma_trm_reset(&ohci->at_resp_context);
break;
......@@ -1010,7 +1010,7 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
u64 mask;
if (arg<0 || arg>63) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"%s: IS0 listen channel %d is out of range",
__FUNCTION__, arg);
return -EFAULT;
......@@ -1022,14 +1022,14 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
DMA_CTX_ISO, 0, IR_NUM_DESC,
IR_BUF_SIZE, IR_SPLIT_BUF_SIZE,
OHCI1394_IsoRcvContextBase) < 0) {
PRINT(KERN_ERR, ohci->id, "%s: failed to allocate an IR context",
PRINT(KERN_ERR, "%s: failed to allocate an IR context",
__FUNCTION__);
return -ENOMEM;
}
ohci->ir_legacy_channels = 0;
initialize_dma_rcv_ctx(&ohci->ir_legacy_context, 1);
DBGMSG(ohci->id, "ISO receive legacy context activated");
DBGMSG("ISO receive legacy context activated");
}
mask = (u64)0x1<<arg;
......@@ -1037,7 +1037,7 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
spin_lock_irqsave(&ohci->IR_channel_lock, flags);
if (ohci->ISO_channel_usage & mask) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"%s: IS0 listen channel %d is already used",
__FUNCTION__, arg);
spin_unlock_irqrestore(&ohci->IR_channel_lock, flags);
......@@ -1055,7 +1055,7 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
1<<arg);
spin_unlock_irqrestore(&ohci->IR_channel_lock, flags);
DBGMSG(ohci->id, "Listening enabled on channel %d", arg);
DBGMSG("Listening enabled on channel %d", arg);
break;
}
case ISO_UNLISTEN_CHANNEL:
......@@ -1063,7 +1063,7 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
u64 mask;
if (arg<0 || arg>63) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"%s: IS0 unlisten channel %d is out of range",
__FUNCTION__, arg);
return -EFAULT;
......@@ -1074,7 +1074,7 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
spin_lock_irqsave(&ohci->IR_channel_lock, flags);
if (!(ohci->ISO_channel_usage & mask)) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"%s: IS0 unlisten channel %d is not used",
__FUNCTION__, arg);
spin_unlock_irqrestore(&ohci->IR_channel_lock, flags);
......@@ -1092,12 +1092,12 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
1<<arg);
spin_unlock_irqrestore(&ohci->IR_channel_lock, flags);
DBGMSG(ohci->id, "Listening disabled on channel %d", arg);
DBGMSG("Listening disabled on channel %d", arg);
if (ohci->ir_legacy_channels == 0) {
stop_dma_rcv_ctx(&ohci->ir_legacy_context);
free_dma_rcv_ctx(&ohci->ir_legacy_context);
DBGMSG(ohci->id, "ISO receive legacy context deactivated");
DBGMSG("ISO receive legacy context deactivated");
}
break;
}
......@@ -1209,7 +1209,7 @@ static int ohci_iso_recv_init(struct hpsb_iso *iso)
/* one block per page of data in the DMA buffer, minus the final guard page */
recv->nblocks = iso->buf_size/PAGE_SIZE - 1;
if (recv->nblocks < 3) {
DBGMSG(ohci->id, "ohci_iso_recv_init: DMA buffer too small");
DBGMSG("ohci_iso_recv_init: DMA buffer too small");
goto err;
}
......@@ -1245,7 +1245,7 @@ static int ohci_iso_recv_init(struct hpsb_iso *iso)
if (recv->buf_stride*iso->buf_packets > iso->buf_size ||
recv->buf_stride > PAGE_SIZE) {
/* this shouldn't happen, but anyway... */
DBGMSG(ohci->id, "ohci_iso_recv_init: problem choosing a buffer stride");
DBGMSG("ohci_iso_recv_init: problem choosing a buffer stride");
goto err;
}
}
......@@ -1289,7 +1289,7 @@ static int ohci_iso_recv_init(struct hpsb_iso *iso)
/* write the DMA program */
ohci_iso_recv_program(iso);
DBGMSG(ohci->id, "ohci_iso_recv_init: %s mode, DMA buffer is %lu pages"
DBGMSG("ohci_iso_recv_init: %s mode, DMA buffer is %lu pages"
" (%u bytes), using %u blocks, buf_stride %u, block_irq_interval %d",
recv->dma_mode == BUFFER_FILL_MODE ?
"buffer-fill" : "packet-per-buffer",
......@@ -1430,6 +1430,7 @@ static void ohci_iso_recv_set_channel_mask(struct hpsb_iso *iso, u64 mask)
static int ohci_iso_recv_start(struct hpsb_iso *iso, int cycle, int tag_mask, int sync)
{
struct ohci_iso_recv *recv = iso->hostdata;
struct ti_ohci *ohci = recv->ohci;
u32 command, contextMatch;
reg_write(recv->ohci, recv->ContextControlClear, 0xFFFFFFFF);
......@@ -1508,7 +1509,7 @@ static int ohci_iso_recv_start(struct hpsb_iso *iso, int cycle, int tag_mask, in
/* check RUN */
if (!(reg_read(recv->ohci, recv->ContextControlSet) & 0x8000)) {
PRINT(KERN_ERR, recv->ohci->id,
PRINT(KERN_ERR,
"Error starting IR DMA (ContextControl 0x%08x)\n",
reg_read(recv->ohci, recv->ContextControlSet));
return -1;
......@@ -1591,6 +1592,7 @@ static void ohci_iso_recv_bufferfill_parse(struct hpsb_iso *iso, struct ohci_iso
{
int wake = 0;
int runaway = 0;
struct ti_ohci *ohci = recv->ohci;
while (1) {
/* we expect the next parsable packet to begin at recv->dma_offset */
......@@ -1607,7 +1609,7 @@ static void ohci_iso_recv_bufferfill_parse(struct hpsb_iso *iso, struct ohci_iso
/* don't loop indefinitely */
if (runaway++ > 100000) {
atomic_inc(&iso->overflows);
PRINT(KERN_ERR, recv->ohci->id,
PRINT(KERN_ERR,
"IR DMA error - Runaway during buffer parsing!\n");
break;
}
......@@ -1626,7 +1628,7 @@ static void ohci_iso_recv_bufferfill_parse(struct hpsb_iso *iso, struct ohci_iso
len = p[recv->dma_offset+2] | (p[recv->dma_offset+3] << 8);
if (len > 4096) {
PRINT(KERN_ERR, recv->ohci->id,
PRINT(KERN_ERR,
"IR DMA error - bogus 'len' value %u\n", len);
}
......@@ -1694,6 +1696,7 @@ static void ohci_iso_recv_bufferfill_parse(struct hpsb_iso *iso, struct ohci_iso
static void ohci_iso_recv_bufferfill_task(struct hpsb_iso *iso, struct ohci_iso_recv *recv)
{
int loop;
struct ti_ohci *ohci = recv->ohci;
/* loop over all blocks */
for (loop = 0; loop < recv->nblocks; loop++) {
......@@ -1716,7 +1719,7 @@ static void ohci_iso_recv_bufferfill_task(struct hpsb_iso *iso, struct ohci_iso_
if (event != 0x11) {
atomic_inc(&iso->overflows);
PRINT(KERN_ERR, recv->ohci->id,
PRINT(KERN_ERR,
"IR DMA error - OHCI error code 0x%02x\n", event);
}
......@@ -1739,7 +1742,7 @@ static void ohci_iso_recv_bufferfill_task(struct hpsb_iso *iso, struct ohci_iso_
if ((recv->block_dma+1) % recv->nblocks == recv->block_reader) {
atomic_inc(&iso->overflows);
DBGMSG(recv->ohci->id, "ISO reception overflow - "
DBGMSG("ISO reception overflow - "
"ran out of DMA blocks");
}
}
......@@ -1752,6 +1755,7 @@ static void ohci_iso_recv_packetperbuf_task(struct hpsb_iso *iso, struct ohci_is
{
int count;
int wake = 0;
struct ti_ohci *ohci = recv->ohci;
/* loop over the entire buffer */
for (count = 0; count < recv->nblocks; count++) {
......@@ -1779,9 +1783,9 @@ static void ohci_iso_recv_packetperbuf_task(struct hpsb_iso *iso, struct ohci_is
packet_len = recv->buf_stride - rescount;
} else if (event == 0x02) {
PRINT(KERN_ERR, recv->ohci->id, "IR DMA error - packet too long for buffer\n");
PRINT(KERN_ERR, "IR DMA error - packet too long for buffer\n");
} else if (event) {
PRINT(KERN_ERR, recv->ohci->id, "IR DMA error - OHCI error code 0x%02x\n", event);
PRINT(KERN_ERR, "IR DMA error - OHCI error code 0x%02x\n", event);
}
/* sync our view of the buffer */
......@@ -1911,6 +1915,7 @@ static int ohci_iso_xmit_init(struct hpsb_iso *iso)
static void ohci_iso_xmit_stop(struct hpsb_iso *iso)
{
struct ohci_iso_xmit *xmit = iso->hostdata;
struct ti_ohci *ohci = xmit->ohci;
/* disable interrupts */
reg_write(xmit->ohci, OHCI1394_IsoXmitIntMaskClear, 1 << xmit->task.context);
......@@ -1918,7 +1923,7 @@ static void ohci_iso_xmit_stop(struct hpsb_iso *iso)
/* halt DMA */
if (ohci1394_stop_context(xmit->ohci, xmit->ContextControlClear, NULL)) {
/* XXX the DMA context will lock up if you try to send too much data! */
PRINT(KERN_ERR, xmit->ohci->id,
PRINT(KERN_ERR,
"you probably exceeded the OHCI card's bandwidth limit - "
"reload the module and reduce xmit bandwidth");
}
......@@ -1943,6 +1948,7 @@ static void ohci_iso_xmit_task(unsigned long data)
{
struct hpsb_iso *iso = (struct hpsb_iso*) data;
struct ohci_iso_xmit *xmit = iso->hostdata;
struct ti_ohci *ohci = xmit->ohci;
int wake = 0;
int count;
......@@ -1963,7 +1969,7 @@ static void ohci_iso_xmit_task(unsigned long data)
}
if (event != 0x11)
PRINT(KERN_ERR, xmit->ohci->id,
PRINT(KERN_ERR,
"IT DMA error - OHCI error code 0x%02x\n", event);
/* at least one packet went out, so wake up the writer */
......@@ -1986,6 +1992,7 @@ static void ohci_iso_xmit_task(unsigned long data)
static int ohci_iso_xmit_queue(struct hpsb_iso *iso, struct hpsb_iso_packet_info *info)
{
struct ohci_iso_xmit *xmit = iso->hostdata;
struct ti_ohci *ohci = xmit->ohci;
int next_i, prev_i;
struct iso_xmit_cmd *next, *prev;
......@@ -1997,7 +2004,7 @@ static int ohci_iso_xmit_queue(struct hpsb_iso *iso, struct hpsb_iso_packet_info
/* check that the packet doesn't cross a page boundary
(we could allow this if we added OUTPUT_MORE descriptor support) */
if (cross_bound(info->offset, info->len)) {
PRINT(KERN_ERR, xmit->ohci->id,
PRINT(KERN_ERR,
"rawiso xmit: packet %u crosses a page boundary",
iso->first_packet);
return -EINVAL;
......@@ -2081,6 +2088,7 @@ static int ohci_iso_xmit_queue(struct hpsb_iso *iso, struct hpsb_iso_packet_info
static int ohci_iso_xmit_start(struct hpsb_iso *iso, int cycle)
{
struct ohci_iso_xmit *xmit = iso->hostdata;
struct ti_ohci *ohci = xmit->ohci;
/* clear out the control register */
reg_write(xmit->ohci, xmit->ContextControlClear, 0xFFFFFFFF);
......@@ -2118,7 +2126,7 @@ static int ohci_iso_xmit_start(struct hpsb_iso *iso, int cycle)
/* check the RUN bit */
if (!(reg_read(xmit->ohci, xmit->ContextControlSet) & 0x8000)) {
PRINT(KERN_ERR, xmit->ohci->id, "Error starting IT DMA (ContextControl 0x%08x)\n",
PRINT(KERN_ERR, "Error starting IT DMA (ContextControl 0x%08x)\n",
reg_read(xmit->ohci, xmit->ContextControlSet));
return -1;
}
......@@ -2192,8 +2200,9 @@ static void dma_trm_reset(struct dma_trm_ctx *d)
{
unsigned long flags;
LIST_HEAD(packet_list);
struct ti_ohci *ohci = d->ohci;
ohci1394_stop_context(d->ohci, d->ctrlClear, NULL);
ohci1394_stop_context(ohci, d->ctrlClear, NULL);
/* Lock the context, reset it and release it. Move the packets
* that were pending in the context to packet_list and free
......@@ -2217,10 +2226,10 @@ static void dma_trm_reset(struct dma_trm_ctx *d)
while (!list_empty(&packet_list)) {
struct hpsb_packet *p = driver_packet(packet_list.next);
PRINT(KERN_INFO, d->ohci->id,
PRINT(KERN_INFO,
"AT dma reset ctx=%d, aborting transmission", d->ctx);
list_del(&p->driver_list);
hpsb_packet_sent(d->ohci->host, p, ACKX_ABORTED);
hpsb_packet_sent(ohci->host, p, ACKX_ABORTED);
}
}
......@@ -2270,43 +2279,43 @@ static irqreturn_t ohci_irq_handler(int irq, void *dev_id,
* we just return, and clean up in the ohci1394_pci_remove
* function. */
if (event == ~(u32) 0) {
DBGMSG(ohci->id, "Device removed.");
DBGMSG("Device removed.");
return IRQ_NONE;
}
DBGMSG(ohci->id, "IntEvent: %08x", event);
DBGMSG("IntEvent: %08x", event);
if (event & OHCI1394_unrecoverableError) {
int ctx;
PRINT(KERN_ERR, ohci->id, "Unrecoverable error!");
PRINT(KERN_ERR, "Unrecoverable error!");
if (reg_read(ohci, OHCI1394_AsReqTrContextControlSet) & 0x800)
PRINT(KERN_ERR, ohci->id, "Async Req Tx Context died: "
PRINT(KERN_ERR, "Async Req Tx Context died: "
"ctrl[%08x] cmdptr[%08x]",
reg_read(ohci, OHCI1394_AsReqTrContextControlSet),
reg_read(ohci, OHCI1394_AsReqTrCommandPtr));
if (reg_read(ohci, OHCI1394_AsRspTrContextControlSet) & 0x800)
PRINT(KERN_ERR, ohci->id, "Async Rsp Tx Context died: "
PRINT(KERN_ERR, "Async Rsp Tx Context died: "
"ctrl[%08x] cmdptr[%08x]",
reg_read(ohci, OHCI1394_AsRspTrContextControlSet),
reg_read(ohci, OHCI1394_AsRspTrCommandPtr));
if (reg_read(ohci, OHCI1394_AsReqRcvContextControlSet) & 0x800)
PRINT(KERN_ERR, ohci->id, "Async Req Rcv Context died: "
PRINT(KERN_ERR, "Async Req Rcv Context died: "
"ctrl[%08x] cmdptr[%08x]",
reg_read(ohci, OHCI1394_AsReqRcvContextControlSet),
reg_read(ohci, OHCI1394_AsReqRcvCommandPtr));
if (reg_read(ohci, OHCI1394_AsRspRcvContextControlSet) & 0x800)
PRINT(KERN_ERR, ohci->id, "Async Rsp Rcv Context died: "
PRINT(KERN_ERR, "Async Rsp Rcv Context died: "
"ctrl[%08x] cmdptr[%08x]",
reg_read(ohci, OHCI1394_AsRspRcvContextControlSet),
reg_read(ohci, OHCI1394_AsRspRcvCommandPtr));
for (ctx = 0; ctx < ohci->nb_iso_xmit_ctx; ctx++) {
if (reg_read(ohci, OHCI1394_IsoXmitContextControlSet + (16 * ctx)) & 0x800)
PRINT(KERN_ERR, ohci->id, "Iso Xmit %d Context died: "
PRINT(KERN_ERR, "Iso Xmit %d Context died: "
"ctrl[%08x] cmdptr[%08x]", ctx,
reg_read(ohci, OHCI1394_IsoXmitContextControlSet + (16 * ctx)),
reg_read(ohci, OHCI1394_IsoXmitCommandPtr + (16 * ctx)));
......@@ -2314,7 +2323,7 @@ static irqreturn_t ohci_irq_handler(int irq, void *dev_id,
for (ctx = 0; ctx < ohci->nb_iso_rcv_ctx; ctx++) {
if (reg_read(ohci, OHCI1394_IsoRcvContextControlSet + (32 * ctx)) & 0x800)
PRINT(KERN_ERR, ohci->id, "Iso Recv %d Context died: "
PRINT(KERN_ERR, "Iso Recv %d Context died: "
"ctrl[%08x] cmdptr[%08x] match[%08x]", ctx,
reg_read(ohci, OHCI1394_IsoRcvContextControlSet + (32 * ctx)),
reg_read(ohci, OHCI1394_IsoRcvCommandPtr + (32 * ctx)),
......@@ -2328,7 +2337,7 @@ static irqreturn_t ohci_irq_handler(int irq, void *dev_id,
/* We subscribe to the cycleInconsistent event only to
* clear the corresponding event bit... otherwise,
* isochronous cycleMatch DMA won't work. */
DBGMSG(ohci->id, "OHCI1394_cycleInconsistent");
DBGMSG("OHCI1394_cycleInconsistent");
event &= ~OHCI1394_cycleInconsistent;
}
......@@ -2359,7 +2368,7 @@ static irqreturn_t ohci_irq_handler(int irq, void *dev_id,
* to solve this problem. This mainly effects nForce2. */
if (loop_count > 10000) {
ohci_devctl(host, RESET_BUS, LONG_RESET);
DBGMSG(ohci->id, "Detected bus-reset loop. Forced a bus reset!");
DBGMSG("Detected bus-reset loop. Forced a bus reset!");
loop_count = 0;
}
......@@ -2368,7 +2377,7 @@ static irqreturn_t ohci_irq_handler(int irq, void *dev_id,
}
spin_unlock_irqrestore(&ohci->event_lock, flags);
if (!host->in_bus_reset) {
DBGMSG(ohci->id, "irq_handler: Bus reset requested");
DBGMSG("irq_handler: Bus reset requested");
/* Subsystem call */
hpsb_bus_reset(ohci->host);
......@@ -2376,24 +2385,20 @@ static irqreturn_t ohci_irq_handler(int irq, void *dev_id,
event &= ~OHCI1394_busReset;
}
/* XXX: We need a way to also queue the OHCI1394_reqTxComplete,
* but for right now we simply run it upon reception, to make sure
* we get sent acks before response packets. This sucks mainly
* because it halts the interrupt handler. */
if (event & OHCI1394_reqTxComplete) {
struct dma_trm_ctx *d = &ohci->at_req_context;
DBGMSG(ohci->id, "Got reqTxComplete interrupt "
DBGMSG("Got reqTxComplete interrupt "
"status=0x%08X", reg_read(ohci, d->ctrlSet));
if (reg_read(ohci, d->ctrlSet) & 0x800)
ohci1394_stop_context(ohci, d->ctrlClear,
"reqTxComplete");
else
dma_trm_tasklet ((unsigned long)d);
tasklet_schedule(&d->task);
event &= ~OHCI1394_reqTxComplete;
}
if (event & OHCI1394_respTxComplete) {
struct dma_trm_ctx *d = &ohci->at_resp_context;
DBGMSG(ohci->id, "Got respTxComplete interrupt "
DBGMSG("Got respTxComplete interrupt "
"status=0x%08X", reg_read(ohci, d->ctrlSet));
if (reg_read(ohci, d->ctrlSet) & 0x800)
ohci1394_stop_context(ohci, d->ctrlClear,
......@@ -2404,7 +2409,7 @@ static irqreturn_t ohci_irq_handler(int irq, void *dev_id,
}
if (event & OHCI1394_RQPkt) {
struct dma_rcv_ctx *d = &ohci->ar_req_context;
DBGMSG(ohci->id, "Got RQPkt interrupt status=0x%08X",
DBGMSG("Got RQPkt interrupt status=0x%08X",
reg_read(ohci, d->ctrlSet));
if (reg_read(ohci, d->ctrlSet) & 0x800)
ohci1394_stop_context(ohci, d->ctrlClear, "RQPkt");
......@@ -2414,7 +2419,7 @@ static irqreturn_t ohci_irq_handler(int irq, void *dev_id,
}
if (event & OHCI1394_RSPkt) {
struct dma_rcv_ctx *d = &ohci->ar_resp_context;
DBGMSG(ohci->id, "Got RSPkt interrupt status=0x%08X",
DBGMSG("Got RSPkt interrupt status=0x%08X",
reg_read(ohci, d->ctrlSet));
if (reg_read(ohci, d->ctrlSet) & 0x800)
ohci1394_stop_context(ohci, d->ctrlClear, "RSPkt");
......@@ -2443,7 +2448,7 @@ static irqreturn_t ohci_irq_handler(int irq, void *dev_id,
node_id = reg_read(ohci, OHCI1394_NodeID);
if (!(node_id & 0x80000000)) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"SelfID received, but NodeID invalid "
"(probably new bus reset occurred): %08X",
node_id);
......@@ -2453,8 +2458,7 @@ static irqreturn_t ohci_irq_handler(int irq, void *dev_id,
phyid = node_id & 0x0000003f;
isroot = (node_id & 0x40000000) != 0;
DBGMSG(ohci->id,
"SelfID interrupt received "
DBGMSG("SelfID interrupt received "
"(phyid %d, %s)", phyid,
(isroot ? "root" : "not root"));
......@@ -2484,13 +2488,13 @@ static irqreturn_t ohci_irq_handler(int irq, void *dev_id,
reg_write(ohci,OHCI1394_PhyReqFilterLoSet, 0x00000000);
}
DBGMSG(ohci->id, "PhyReqFilter=%08x%08x",
DBGMSG("PhyReqFilter=%08x%08x",
reg_read(ohci,OHCI1394_PhyReqFilterHiSet),
reg_read(ohci,OHCI1394_PhyReqFilterLoSet));
hpsb_selfid_complete(host, phyid, isroot);
} else
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"SelfID received outside of bus reset sequence");
selfid_not_valid:
......@@ -2500,7 +2504,7 @@ static irqreturn_t ohci_irq_handler(int irq, void *dev_id,
/* Make sure we handle everything, just in case we accidentally
* enabled an interrupt that we didn't write a handler for. */
if (event)
PRINT(KERN_ERR, ohci->id, "Unhandled interrupt(s) 0x%08x",
PRINT(KERN_ERR, "Unhandled interrupt(s) 0x%08x",
event);
return IRQ_HANDLED;
......@@ -2510,7 +2514,7 @@ static irqreturn_t ohci_irq_handler(int irq, void *dev_id,
static void insert_dma_buffer(struct dma_rcv_ctx *d, int idx)
{
struct ti_ohci *ohci = (struct ti_ohci*)(d->ohci);
DBGMSG(ohci->id, "Inserting dma buf ctx=%d idx=%d", d->ctx, idx);
DBGMSG("Inserting dma buf ctx=%d idx=%d", d->ctx, idx);
d->prg_cpu[idx]->status = cpu_to_le32(d->buf_size);
d->prg_cpu[idx]->branchAddress &= le32_to_cpu(0xfffffff0);
......@@ -2519,7 +2523,7 @@ static void insert_dma_buffer(struct dma_rcv_ctx *d, int idx)
/* wake up the dma context if necessary */
if (!(reg_read(ohci, d->ctrlSet) & 0x400)) {
PRINT(KERN_INFO, ohci->id,
PRINT(KERN_INFO,
"Waking dma ctx=%d ... processing is probably too slow",
d->ctx);
}
......@@ -2606,7 +2610,7 @@ static void dma_rcv_tasklet (unsigned long data)
* over more than one descriptor. The next case is where
* it's all in the first descriptor. */
if ((offset + length) > d->buf_size) {
DBGMSG(ohci->id,"Split packet rcv'd");
DBGMSG("Split packet rcv'd");
if (length > d->split_buf_size) {
ohci1394_stop_context(ohci, d->ctrlClear,
"Split packet size exceeded");
......@@ -2621,7 +2625,7 @@ static void dma_rcv_tasklet (unsigned long data)
/* Other part of packet not written yet.
* this should never happen I think
* anyway we'll get it on the next call. */
PRINT(KERN_INFO, ohci->id,
PRINT(KERN_INFO,
"Got only half a packet!");
d->buf_ind = idx;
d->buf_offset = offset;
......@@ -2654,7 +2658,7 @@ static void dma_rcv_tasklet (unsigned long data)
buf_ptr += offset/4;
}
} else {
DBGMSG(ohci->id,"Single packet rcv'd");
DBGMSG("Single packet rcv'd");
memcpy(d->spb, buf_ptr, length);
offset += length;
buf_ptr += length/4;
......@@ -2671,7 +2675,7 @@ static void dma_rcv_tasklet (unsigned long data)
if (tcode != OHCI1394_TCODE_PHY) {
if (!ohci->no_swap_incoming)
packet_swab(d->spb, tcode);
DBGMSG(ohci->id, "Packet received from node"
DBGMSG("Packet received from node"
" %d ack=0x%02X spd=%d tcode=0x%X"
" length=%d ctx=%d tlabel=%d",
(d->spb[1]>>16)&0x3f,
......@@ -2688,7 +2692,7 @@ static void dma_rcv_tasklet (unsigned long data)
}
#ifdef OHCI1394_DEBUG
else
PRINT (KERN_DEBUG, ohci->id, "Got phy packet ctx=%d ... discarded",
PRINT (KERN_DEBUG, "Got phy packet ctx=%d ... discarded",
d->ctx);
#endif
......@@ -2733,8 +2737,7 @@ static void dma_trm_tasklet (unsigned long data)
#ifdef OHCI1394_DEBUG
if (datasize)
if (((le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])>>4)&0xf) == 0xa)
DBGMSG(ohci->id,
"Stream packet sent to channel %d tcode=0x%X "
DBGMSG("Stream packet sent to channel %d tcode=0x%X "
"ack=0x%X spd=%d dataLength=%d ctx=%d",
(le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])>>8)&0x3f,
(le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])>>4)&0xf,
......@@ -2742,8 +2745,7 @@ static void dma_trm_tasklet (unsigned long data)
le32_to_cpu(d->prg_cpu[d->sent_ind]->data[1])>>16,
d->ctx);
else
DBGMSG(ohci->id,
"Packet sent to node %d tcode=0x%X tLabel="
DBGMSG("Packet sent to node %d tcode=0x%X tLabel="
"0x%02X ack=0x%X spd=%d dataLength=%d ctx=%d",
(le32_to_cpu(d->prg_cpu[d->sent_ind]->data[1])>>16)&0x3f,
(le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])>>4)&0xf,
......@@ -2752,8 +2754,7 @@ static void dma_trm_tasklet (unsigned long data)
le32_to_cpu(d->prg_cpu[d->sent_ind]->data[3])>>16,
d->ctx);
else
DBGMSG(ohci->id,
"Packet sent to node %d tcode=0x%X tLabel="
DBGMSG("Packet sent to node %d tcode=0x%X tLabel="
"0x%02X ack=0x%X spd=%d data=0x%08X ctx=%d",
(le32_to_cpu(d->prg_cpu[d->sent_ind]->data[1])
>>16)&0x3f,
......@@ -2773,7 +2774,7 @@ static void dma_trm_tasklet (unsigned long data)
case EVT_NO_STATUS: /* that should never happen */
case EVT_RESERVED_A: /* that should never happen */
case EVT_LONG_PACKET: /* that should never happen */
PRINT(KERN_WARNING, ohci->id, "Received OHCI evt_* error 0x%x", status & 0x1f);
PRINT(KERN_WARNING, "Received OHCI evt_* error 0x%x", status & 0x1f);
ack = ACKX_SEND_ERROR;
break;
case EVT_MISSING_ACK:
......@@ -2783,7 +2784,7 @@ static void dma_trm_tasklet (unsigned long data)
ack = ACKX_SEND_ERROR;
break;
case EVT_OVERRUN: /* that should never happen */
PRINT(KERN_WARNING, ohci->id, "Received OHCI evt_* error 0x%x", status & 0x1f);
PRINT(KERN_WARNING, "Received OHCI evt_* error 0x%x", status & 0x1f);
ack = ACKX_SEND_ERROR;
break;
case EVT_DESCRIPTOR_READ:
......@@ -2792,7 +2793,7 @@ static void dma_trm_tasklet (unsigned long data)
ack = ACKX_SEND_ERROR;
break;
case EVT_BUS_RESET: /* that should never happen */
PRINT(KERN_WARNING, ohci->id, "Received OHCI evt_* error 0x%x", status & 0x1f);
PRINT(KERN_WARNING, "Received OHCI evt_* error 0x%x", status & 0x1f);
ack = ACKX_SEND_ERROR;
break;
case EVT_TIMEOUT:
......@@ -2803,7 +2804,7 @@ static void dma_trm_tasklet (unsigned long data)
break;
case EVT_RESERVED_B: /* that should never happen */
case EVT_RESERVED_C: /* that should never happen */
PRINT(KERN_WARNING, ohci->id, "Received OHCI evt_* error 0x%x", status & 0x1f);
PRINT(KERN_WARNING, "Received OHCI evt_* error 0x%x", status & 0x1f);
ack = ACKX_SEND_ERROR;
break;
case EVT_UNKNOWN:
......@@ -2811,7 +2812,7 @@ static void dma_trm_tasklet (unsigned long data)
ack = ACKX_SEND_ERROR;
break;
default:
PRINT(KERN_ERR, ohci->id, "Unhandled OHCI evt_* error 0x%x", status & 0x1f);
PRINT(KERN_ERR, "Unhandled OHCI evt_* error 0x%x", status & 0x1f);
ack = ACKX_SEND_ERROR;
BUG();
}
......@@ -2855,17 +2856,18 @@ static void stop_dma_rcv_ctx(struct dma_rcv_ctx *d)
static void free_dma_rcv_ctx(struct dma_rcv_ctx *d)
{
int i;
struct ti_ohci *ohci = d->ohci;
if (d->ohci == NULL)
if (ohci == NULL)
return;
DBGMSG(d->ohci->id, "Freeing dma_rcv_ctx %d", d->ctx);
DBGMSG("Freeing dma_rcv_ctx %d", d->ctx);
if (d->buf_cpu) {
for (i=0; i<d->num_desc; i++)
if (d->buf_cpu[i] && d->buf_bus[i]) {
pci_free_consistent(
d->ohci->dev, d->buf_size,
ohci->dev, d->buf_size,
d->buf_cpu[i], d->buf_bus[i]);
OHCI_DMA_FREE("consistent dma_rcv buf[%d]", i);
}
......@@ -2912,7 +2914,7 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
d->buf_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_KERNEL);
if (d->buf_cpu == NULL || d->buf_bus == NULL) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate dma buffer");
PRINT(KERN_ERR, "Failed to allocate dma buffer");
free_dma_rcv_ctx(d);
return -ENOMEM;
}
......@@ -2924,7 +2926,7 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
d->prg_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_KERNEL);
if (d->prg_cpu == NULL || d->prg_bus == NULL) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate dma prg");
PRINT(KERN_ERR, "Failed to allocate dma prg");
free_dma_rcv_ctx(d);
return -ENOMEM;
}
......@@ -2934,7 +2936,7 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
d->spb = kmalloc(d->split_buf_size, GFP_KERNEL);
if (d->spb == NULL) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate split buffer");
PRINT(KERN_ERR, "Failed to allocate split buffer");
free_dma_rcv_ctx(d);
return -ENOMEM;
}
......@@ -2952,7 +2954,7 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
if (d->buf_cpu[i] != NULL) {
memset(d->buf_cpu[i], 0, d->buf_size);
} else {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"Failed to allocate dma buffer");
free_dma_rcv_ctx(d);
return -ENOMEM;
......@@ -2964,7 +2966,7 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
if (d->prg_cpu[i] != NULL) {
memset(d->prg_cpu[i], 0, sizeof(struct dma_cmd));
} else {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"Failed to allocate dma prg");
free_dma_rcv_ctx(d);
return -ENOMEM;
......@@ -2979,7 +2981,7 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
dma_rcv_tasklet, (unsigned long) d);
if (ohci1394_register_iso_tasklet(ohci,
&ohci->ir_legacy_tasklet) < 0) {
PRINT(KERN_ERR, ohci->id, "No IR DMA context available");
PRINT(KERN_ERR, "No IR DMA context available");
free_dma_rcv_ctx(d);
return -EBUSY;
}
......@@ -3005,11 +3007,12 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
static void free_dma_trm_ctx(struct dma_trm_ctx *d)
{
int i;
struct ti_ohci *ohci = d->ohci;
if (d->ohci == NULL)
if (ohci == NULL)
return;
DBGMSG(d->ohci->id, "Freeing dma_trm_ctx %d", d->ctx);
DBGMSG("Freeing dma_trm_ctx %d", d->ctx);
if (d->prg_cpu) {
for (i=0; i<d->num_desc; i++)
......@@ -3047,7 +3050,7 @@ alloc_dma_trm_ctx(struct ti_ohci *ohci, struct dma_trm_ctx *d,
d->prg_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_KERNEL);
if (d->prg_cpu == NULL || d->prg_bus == NULL) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate at dma prg");
PRINT(KERN_ERR, "Failed to allocate at dma prg");
free_dma_trm_ctx(d);
return -ENOMEM;
}
......@@ -3065,7 +3068,7 @@ alloc_dma_trm_ctx(struct ti_ohci *ohci, struct dma_trm_ctx *d,
if (d->prg_cpu[i] != NULL) {
memset(d->prg_cpu[i], 0, sizeof(struct at_dma_prg));
} else {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"Failed to allocate at dma prg");
free_dma_trm_ctx(d);
return -ENOMEM;
......@@ -3080,7 +3083,7 @@ alloc_dma_trm_ctx(struct ti_ohci *ohci, struct dma_trm_ctx *d,
dma_trm_tasklet, (unsigned long) d);
if (ohci1394_register_iso_tasklet(ohci,
&ohci->it_legacy_tasklet) < 0) {
PRINT(KERN_ERR, ohci->id, "No IT DMA context available");
PRINT(KERN_ERR, "No IT DMA context available");
free_dma_trm_ctx(d);
return -EBUSY;
}
......@@ -3157,11 +3160,6 @@ do { \
static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
struct csr1212_keyval *root;
struct csr1212_keyval *vend_id = NULL;
struct csr1212_keyval *text = NULL;
int ret;
static int version_printed = 0;
struct hpsb_host *host;
......@@ -3179,7 +3177,6 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
if (!host) FAIL(-ENOMEM, "Failed to allocate host structure");
ohci = host->hostdata;
ohci->id = host->id;
ohci->dev = dev;
ohci->host = host;
ohci->init_state = OHCI_INIT_ALLOC_HOST;
......@@ -3223,7 +3220,7 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
* clearly says it's 2kb, so this shouldn't be a problem. */
ohci_base = pci_resource_start(dev, 0);
if (pci_resource_len(dev, 0) != OHCI1394_REGISTER_SIZE)
PRINT(KERN_WARNING, ohci->id, "Unexpected PCI resource length of %lx!",
PRINT(KERN_WARNING, "Unexpected PCI resource length of %lx!",
pci_resource_len(dev, 0));
/* Seems PCMCIA handles this internally. Not sure why. Seems
......@@ -3239,7 +3236,7 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
if (ohci->registers == NULL)
FAIL(-ENXIO, "Failed to remap registers - card not accessible");
ohci->init_state = OHCI_INIT_HAVE_IOMAPPING;
DBGMSG(ohci->id, "Remapped memory spaces reg 0x%p", ohci->registers);
DBGMSG("Remapped memory spaces reg 0x%p", ohci->registers);
/* csr_config rom allocation */
ohci->csr_config_rom_cpu =
......@@ -3261,7 +3258,7 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
ohci->init_state = OHCI_INIT_HAVE_SELFID_BUFFER;
if ((unsigned long)ohci->selfid_buf_cpu & 0x1fff)
PRINT(KERN_INFO, ohci->id, "SelfID buffer %p is not aligned on "
PRINT(KERN_INFO, "SelfID buffer %p is not aligned on "
"8Kb boundary... may cause problems on some CXD3222 chip",
ohci->selfid_buf_cpu);
......@@ -3315,12 +3312,12 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
/* Determine the number of available IR and IT contexts. */
ohci->nb_iso_rcv_ctx =
get_nb_iso_ctx(ohci, OHCI1394_IsoRecvIntMaskSet);
DBGMSG(ohci->id, "%d iso receive contexts available",
DBGMSG("%d iso receive contexts available",
ohci->nb_iso_rcv_ctx);
ohci->nb_iso_xmit_ctx =
get_nb_iso_ctx(ohci, OHCI1394_IsoXmitIntMaskSet);
DBGMSG(ohci->id, "%d iso transmit contexts available",
DBGMSG("%d iso transmit contexts available",
ohci->nb_iso_xmit_ctx);
/* Set the usage bits for non-existent contexts so they can't
......@@ -3346,38 +3343,6 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
ohci->init_state = OHCI_INIT_HAVE_IRQ;
ohci_initialize(ohci);
/* Setup initial root directory entries */
root = host->csr.rom->root_kv;
vend_id = csr1212_new_immediate(CSR1212_KV_ID_VENDOR,
reg_read(ohci, OHCI1394_GUIDHi) >> 8);
text = csr1212_new_string_descriptor_leaf("Linux 1394 - OHCI");
if (!vend_id || !text) {
if (vend_id) {
csr1212_release_keyval(vend_id);
}
if (text) {
csr1212_release_keyval(text);
}
FAIL(-ENOMEM, "Failed to allocate memory for mandatory ConfigROM entries!");
}
ret = csr1212_associate_keyval(vend_id, text);
csr1212_release_keyval(text);
if(ret != CSR1212_SUCCESS) {
csr1212_release_keyval(vend_id);
FAIL(ret, "Failed to associate text descriptor to vendor id");
}
ret = csr1212_attach_keyval_to_directory(root, vend_id);
if(ret != CSR1212_SUCCESS) {
csr1212_release_keyval(vend_id);
FAIL(ret, "Failed to attach vendor id to root directory");
}
host->update_config_rom = 1;
/* Set certain csr values */
host->csr.guid_hi = reg_read(ohci, OHCI1394_GUIDHi);
host->csr.guid_lo = reg_read(ohci, OHCI1394_GUIDLo);
......@@ -3386,7 +3351,9 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
host->csr.lnk_spd = reg_read(ohci, OHCI1394_BusOptions) & 0x7;
/* Tell the highlevel this host is ready */
hpsb_add_host(host);
if (hpsb_add_host(host))
FAIL(-ENOMEM, "Failed to register host with highlevel");
ohci->init_state = OHCI_INIT_DONE;
return 0;
......@@ -3582,7 +3549,7 @@ int ohci1394_stop_context(struct ti_ohci *ohci, int reg, char *msg)
while (reg_read(ohci, reg) & 0x400) {
i++;
if (i>5000) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR,
"Runaway loop while stopping context: %s...", msg ? msg : "");
return 1;
}
......@@ -3590,7 +3557,7 @@ int ohci1394_stop_context(struct ti_ohci *ohci, int reg, char *msg)
mb();
udelay(10);
}
if (msg) PRINT(KERN_ERR, ohci->id, "%s: dma prg stopped", msg);
if (msg) PRINT(KERN_ERR, "%s: dma prg stopped", msg);
return 0;
}
......
......@@ -149,8 +149,6 @@ struct ohci1394_iso_tasklet {
};
struct ti_ohci {
int id; /* sequential card number */
struct pci_dev *dev;
enum {
......
......@@ -1516,11 +1516,6 @@ static int __devinit add_card(struct pci_dev *dev,
return error; \
} while (0)
struct csr1212_keyval *root;
struct csr1212_keyval *vend_id = NULL;
struct csr1212_keyval *text = NULL;
int ret;
char irq_buf[16];
struct hpsb_host *host;
struct ti_lynx *lynx; /* shortcut to currently handled device */
......@@ -1890,42 +1885,14 @@ static int __devinit add_card(struct pci_dev *dev,
else
host->csr.lnk_spd = be32_to_cpu(lynx->bus_info_block[2]) & 0x7;
/* Setup initial root directory entries */
root = host->csr.rom->root_kv;
vend_id = csr1212_new_immediate(CSR1212_KV_ID_VENDOR,
be32_to_cpu(lynx->bus_info_block[3]) >> 8);
text = csr1212_new_string_descriptor_leaf("Linux 1394 - PCI-Lynx");
if (!vend_id || !text) {
if (vend_id)
csr1212_release_keyval(vend_id);
if (text)
csr1212_release_keyval(text);
if (hpsb_add_host(host)) {
error = -ENOMEM;
FAIL("Failed to allocate memory for mandatory ConfigROM entries!");
}
ret = csr1212_associate_keyval(vend_id, text);
csr1212_release_keyval(text); /* no longer needed locally. */
if(ret != CSR1212_SUCCESS) {
csr1212_release_keyval(vend_id);
error = ret;
FAIL("Failed to associate text descriptor to vendor id");
}
ret = csr1212_attach_keyval_to_directory(root, vend_id);
csr1212_release_keyval(vend_id); /* no longer needed locally. */
if(ret != CSR1212_SUCCESS) {
error = ret;
FAIL("Failed to attach vendor id to root directory");
FAIL("Failed to register host with highlevel");
}
host->update_config_rom = 1;
hpsb_add_host(host);
lynx->state = is_host;
return ret;
return 0;
#undef FAIL
}
......
......@@ -78,7 +78,7 @@
#include "sbp2.h"
static char version[] __devinitdata =
"$Rev: 1144 $ Ben Collins <bcollins@debian.org>";
"$Rev: 1170 $ Ben Collins <bcollins@debian.org>";
/*
* Module load parameter definitions
......@@ -677,6 +677,10 @@ static int sbp2_update(struct unit_directory *ud)
*/
sbp2scsi_complete_all_commands(scsi_id, DID_BUS_BUSY);
/* Make sure we unblock requests (since this is likely after a bus
* reset). */
scsi_unblock_requests(scsi_id->scsi_host);
return 0;
}
......@@ -2544,8 +2548,6 @@ static void sbp2scsi_complete_all_commands(struct scsi_id_instance_data *scsi_id
}
}
scsi_unblock_requests(scsi_id->scsi_host);
return;
}
......
......@@ -155,7 +155,7 @@ static int free_dma_iso_ctx(struct dma_iso_ctx *d)
{
int i;
DBGMSG(d->ohci->id, "Freeing dma_iso_ctx %d", d->ctx);
DBGMSG(d->ohci->host->id, "Freeing dma_iso_ctx %d", d->ctx);
ohci1394_stop_context(d->ohci, d->ctrlClear, NULL);
if (d->iso_tasklet.link.next != NULL)
......@@ -200,7 +200,7 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
d = kmalloc(sizeof(struct dma_iso_ctx), GFP_KERNEL);
if (d == NULL) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate dma_iso_ctx");
PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma_iso_ctx");
return NULL;
}
......@@ -221,7 +221,7 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
if (dma_region_alloc(&d->dma, d->num_desc * d->buf_size, ohci->dev,
PCI_DMA_BIDIRECTIONAL)) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate dma buffer");
PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma buffer");
free_dma_iso_ctx(d);
return NULL;
}
......@@ -236,7 +236,7 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
(unsigned long) d);
if (ohci1394_register_iso_tasklet(ohci, &d->iso_tasklet) < 0) {
PRINT(KERN_ERR, ohci->id, "no free iso %s contexts",
PRINT(KERN_ERR, ohci->host->id, "no free iso %s contexts",
type == OHCI_ISO_RECEIVE ? "receive" : "transmit");
free_dma_iso_ctx(d);
return NULL;
......@@ -246,7 +246,7 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
d->prg_reg = kmalloc(d->num_desc * sizeof(struct dma_prog_region),
GFP_KERNEL);
if (d->prg_reg == NULL) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate ir prg regs");
PRINT(KERN_ERR, ohci->host->id, "Failed to allocate ir prg regs");
free_dma_iso_ctx(d);
return NULL;
}
......@@ -264,7 +264,7 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
GFP_KERNEL);
if (d->ir_prg == NULL) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate dma ir prg");
PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma ir prg");
free_dma_iso_ctx(d);
return NULL;
}
......@@ -277,7 +277,7 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
for (i = 0;i < d->num_desc; i++) {
if (dma_prog_region_alloc(&d->prg_reg[i], d->nb_cmd *
sizeof(struct dma_cmd), ohci->dev)) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate dma ir prg");
PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma ir prg");
free_dma_iso_ctx(d);
return NULL;
}
......@@ -293,7 +293,7 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
GFP_KERNEL);
if (d->it_prg == NULL) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"Failed to allocate dma it prg");
free_dma_iso_ctx(d);
return NULL;
......@@ -303,7 +303,7 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
d->packet_size = packet_size;
if (PAGE_SIZE % packet_size || packet_size>4096) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"Packet size %d (page_size: %ld) "
"not yet supported\n",
packet_size, PAGE_SIZE);
......@@ -321,7 +321,7 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
for (i = 0; i < d->num_desc; i++) {
if (dma_prog_region_alloc(&d->prg_reg[i], d->nb_cmd *
sizeof(struct it_dma_prg), ohci->dev)) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate dma it prg");
PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma it prg");
free_dma_iso_ctx(d);
return NULL;
}
......@@ -339,22 +339,22 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
GFP_KERNEL);
if (d->buffer_status == NULL) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate buffer_status");
PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_status");
free_dma_iso_ctx(d);
return NULL;
}
if (d->buffer_time == NULL) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate buffer_time");
PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_time");
free_dma_iso_ctx(d);
return NULL;
}
if (d->last_used_cmd == NULL) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate last_used_cmd");
PRINT(KERN_ERR, ohci->host->id, "Failed to allocate last_used_cmd");
free_dma_iso_ctx(d);
return NULL;
}
if (d->next_buffer == NULL) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate next_buffer");
PRINT(KERN_ERR, ohci->host->id, "Failed to allocate next_buffer");
free_dma_iso_ctx(d);
return NULL;
}
......@@ -365,7 +365,7 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
spin_lock_init(&d->lock);
PRINT(KERN_INFO, ohci->id, "Iso %s DMA: %d buffers "
PRINT(KERN_INFO, ohci->host->id, "Iso %s DMA: %d buffers "
"of size %d allocated for a frame size %d, each with %d prgs",
(type == OHCI_ISO_RECEIVE) ? "receive" : "transmit",
d->num_desc, d->buf_size, d->frame_size, d->nb_cmd);
......@@ -725,7 +725,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
for (i=0; i<ISO_CHANNELS; i++) {
if (!(ohci->ISO_channel_usage & mask)) {
v.channel = i;
PRINT(KERN_INFO, ohci->id, "Found free channel %d", i);
PRINT(KERN_INFO, ohci->host->id, "Found free channel %d", i);
break;
}
mask = mask << 1;
......@@ -733,7 +733,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
}
if (v.channel<0 || v.channel>(ISO_CHANNELS-1)) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"Iso channel %d out of bounds", v.channel);
return -EFAULT;
}
......@@ -743,26 +743,26 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
(u32)(ohci->ISO_channel_usage>>32),
(u32)(ohci->ISO_channel_usage&0xffffffff));
if (ohci->ISO_channel_usage & mask) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"Channel %d is already taken", v.channel);
return -EFAULT;
}
ohci->ISO_channel_usage |= mask;
if (v.buf_size == 0 || v.buf_size > VIDEO1394_MAX_SIZE) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"Invalid %d length buffer requested",v.buf_size);
return -EFAULT;
}
if (v.nb_buffers == 0 || v.nb_buffers > VIDEO1394_MAX_SIZE) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"Invalid %d buffers requested",v.nb_buffers);
return -EFAULT;
}
if (v.nb_buffers * v.buf_size > VIDEO1394_MAX_SIZE) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"%d buffers of size %d bytes is too big",
v.nb_buffers, v.buf_size);
return -EFAULT;
......@@ -774,7 +774,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
v.channel, 0);
if (d == NULL) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"Couldn't allocate ir context");
return -EFAULT;
}
......@@ -785,7 +785,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
v.buf_size = d->buf_size;
list_add_tail(&d->link, &ctx->context_list);
PRINT(KERN_INFO, ohci->id,
PRINT(KERN_INFO, ohci->host->id,
"iso context %d listen on channel %d",
d->ctx, v.channel);
}
......@@ -795,7 +795,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
v.channel, v.packet_size);
if (d == NULL) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"Couldn't allocate it context");
return -EFAULT;
}
......@@ -808,7 +808,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
list_add_tail(&d->link, &ctx->context_list);
PRINT(KERN_INFO, ohci->id,
PRINT(KERN_INFO, ohci->host->id,
"Iso context %d talk on channel %d", d->ctx,
v.channel);
}
......@@ -829,13 +829,13 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
return -EFAULT;
if (channel<0 || channel>(ISO_CHANNELS-1)) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"Iso channel %d out of bound", channel);
return -EFAULT;
}
mask = (u64)0x1<<channel;
if (!(ohci->ISO_channel_usage & mask)) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"Channel %d is not being used", channel);
return -EFAULT;
}
......@@ -849,7 +849,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, channel);
if (d == NULL) return -EFAULT;
PRINT(KERN_INFO, ohci->id, "Iso context %d "
PRINT(KERN_INFO, ohci->host->id, "Iso context %d "
"stop talking on channel %d", d->ctx, channel);
free_dma_iso_ctx(d);
......@@ -866,7 +866,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel);
if ((v.buffer<0) || (v.buffer>d->num_desc)) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"Buffer %d out of range",v.buffer);
return -EFAULT;
}
......@@ -874,7 +874,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
spin_lock_irqsave(&d->lock,flags);
if (d->buffer_status[v.buffer]==VIDEO1394_BUFFER_QUEUED) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"Buffer %d is already used",v.buffer);
spin_unlock_irqrestore(&d->lock,flags);
return -EFAULT;
......@@ -895,7 +895,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
if (!(reg_read(ohci, d->ctrlSet) & 0x8000))
{
DBGMSG(ohci->id, "Starting iso DMA ctx=%d",d->ctx);
DBGMSG(ohci->host->id, "Starting iso DMA ctx=%d",d->ctx);
/* Tell the controller where the first program is */
reg_write(ohci, d->cmdPtr,
......@@ -907,7 +907,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
else {
/* Wake up dma context if necessary */
if (!(reg_read(ohci, d->ctrlSet) & 0x400)) {
PRINT(KERN_INFO, ohci->id,
PRINT(KERN_INFO, ohci->host->id,
"Waking up iso dma ctx=%d", d->ctx);
reg_write(ohci, d->ctrlSet, 0x1000);
}
......@@ -928,7 +928,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel);
if ((v.buffer<0) || (v.buffer>d->num_desc)) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"Buffer %d out of range",v.buffer);
return -EFAULT;
}
......@@ -970,7 +970,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
d->buffer_status[v.buffer]=VIDEO1394_BUFFER_FREE;
break;
default:
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"Buffer %d is not queued",v.buffer);
spin_unlock_irqrestore(&d->lock, flags);
return -EFAULT;
......@@ -1011,7 +1011,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, v.channel);
if ((v.buffer<0) || (v.buffer>d->num_desc)) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"Buffer %d out of range",v.buffer);
return -EFAULT;
}
......@@ -1038,7 +1038,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
spin_lock_irqsave(&d->lock,flags);
if (d->buffer_status[v.buffer]!=VIDEO1394_BUFFER_FREE) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"Buffer %d is already used",v.buffer);
spin_unlock_irqrestore(&d->lock,flags);
if (qv.packet_sizes)
......@@ -1075,7 +1075,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
if (!(reg_read(ohci, d->ctrlSet) & 0x8000))
{
DBGMSG(ohci->id, "Starting iso transmit DMA ctx=%d",
DBGMSG(ohci->host->id, "Starting iso transmit DMA ctx=%d",
d->ctx);
put_timestamp(ohci, d, d->last_buffer);
......@@ -1089,7 +1089,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
else {
/* Wake up dma context if necessary */
if (!(reg_read(ohci, d->ctrlSet) & 0x400)) {
PRINT(KERN_INFO, ohci->id,
PRINT(KERN_INFO, ohci->host->id,
"Waking up iso transmit dma ctx=%d",
d->ctx);
put_timestamp(ohci, d, d->last_buffer);
......@@ -1114,7 +1114,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, v.channel);
if ((v.buffer<0) || (v.buffer>d->num_desc)) {
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"Buffer %d out of range",v.buffer);
return -EFAULT;
}
......@@ -1140,7 +1140,7 @@ static int video1394_ioctl(struct inode *inode, struct file *file,
d->buffer_status[v.buffer]=VIDEO1394_BUFFER_FREE;
return 0;
default:
PRINT(KERN_ERR, ohci->id,
PRINT(KERN_ERR, ohci->host->id,
"Buffer %d is not queued",v.buffer);
return -EFAULT;
}
......@@ -1166,7 +1166,7 @@ int video1394_mmap(struct file *file, struct vm_area_struct *vma)
lock_kernel();
if (ctx->current_ctx == NULL) {
PRINT(KERN_ERR, ctx->ohci->id, "Current iso context not set");
PRINT(KERN_ERR, ctx->ohci->host->id, "Current iso context not set");
} else
res = dma_region_mmap(&ctx->current_ctx->dma, file, vma);
unlock_kernel();
......@@ -1186,7 +1186,7 @@ static int video1394_open(struct inode *inode, struct file *file)
ctx = kmalloc(sizeof(struct file_ctx), GFP_KERNEL);
if (ctx == NULL) {
PRINT(KERN_ERR, ohci->id, "Cannot malloc file_ctx");
PRINT(KERN_ERR, ohci->host->id, "Cannot malloc file_ctx");
return -ENOMEM;
}
......@@ -1213,11 +1213,11 @@ static int video1394_release(struct inode *inode, struct file *file)
mask = (u64) 1 << d->channel;
if (!(ohci->ISO_channel_usage & mask))
PRINT(KERN_ERR, ohci->id, "On release: Channel %d "
PRINT(KERN_ERR, ohci->host->id, "On release: Channel %d "
"is not being used", d->channel);
else
ohci->ISO_channel_usage &= ~mask;
PRINT(KERN_INFO, ohci->id, "On release: Iso %s context "
PRINT(KERN_INFO, ohci->host->id, "On release: Iso %s context "
"%d stop listening on channel %d",
d->type == OHCI_ISO_RECEIVE ? "receive" : "transmit",
d->ctx, d->channel);
......@@ -1278,17 +1278,17 @@ static void video1394_add_host (struct hpsb_host *host)
ohci = (struct ti_ohci *)host->hostdata;
if (!hpsb_create_hostinfo(&video1394_highlevel, host, 0)) {
PRINT(KERN_ERR, ohci->id, "Cannot allocate hostinfo");
PRINT(KERN_ERR, ohci->host->id, "Cannot allocate hostinfo");
return;
}
hpsb_set_hostinfo(&video1394_highlevel, host, ohci);
hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->id);
hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id);
minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->id;
minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id;
devfs_mk_cdev(MKDEV(IEEE1394_MAJOR, minor),
S_IFCHR | S_IRUSR | S_IWUSR,
"%s/%d", VIDEO1394_DRIVER_NAME, ohci->id);
"%s/%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
}
......@@ -1297,7 +1297,7 @@ static void video1394_remove_host (struct hpsb_host *host)
struct ti_ohci *ohci = hpsb_get_hostinfo(&video1394_highlevel, host);
if (ohci)
devfs_remove("%s/%d", VIDEO1394_DRIVER_NAME, ohci->id);
devfs_remove("%s/%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
return;
}
......@@ -1459,7 +1459,7 @@ static int __init video1394_init_module (void)
video1394_cdev.owner = THIS_MODULE;
kobject_set_name(&video1394_cdev.kobj, VIDEO1394_DRIVER_NAME);
ret = cdev_add(&video1394_cdev, IEEE1394_VIDEO1394_DEV, 16);
if (cdev_add(&video1394_cdev, IEEE1394_VIDEO1394_DEV, 16)) {
if (ret) {
PRINT_G(KERN_ERR, "video1394: unable to get minor device block");
return ret;
}
......
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