Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/ieee1394/linux1394-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6:
  firewire: reorder struct fw_card for better cache efficiency
  firewire: fix resetting of bus manager retry counter
  firewire: improve refcounting of fw_card
  firewire: typo in comment
  firewire: fix small memory leak at module removal
  firewire: fw-sbp2: remove unnecessary locking
  ieee1934: dv1394: interrupt enabling/disabling broken on big-endian
  ieee1394: dv1394: annotate frame input/output structs as little endian
  ieee1394: eth1394: trivial sparse annotations
  ieee1394: mark bus_info_data as a __be32 array
  ieee1394: replace CSR_SET_BUS_INFO_GENERATION macro
  ieee1394: pcilynx: trivial endian annotation
  ieee1394: ignore nonzero Bus_Info_Block.max_rom, fetch config ROM in quadlets
  ieee1394: consolidate uses of IEEE1934_BUSID_MAGIC
  ieee1394: ohci1394: flush MMIO writes before delay in initialization
  ieee1394: ohci1394: pass error codes from request_irq through
  ieee1394: ohci1394: don't leave interrupts enabled during suspend/resume
  ieee1394: mark all hpsb_address_ops instances as const
  ieee1394: replace a GFP_ATOMIC by GFP_KERNEL allocation
  • Loading branch information
Linus Torvalds committed Jan 7, 2009
2 parents a0c9f24 + c8a12d4 commit daf4b80
Show file tree
Hide file tree
Showing 27 changed files with 163 additions and 181 deletions.
20 changes: 16 additions & 4 deletions drivers/firewire/fw-card.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ generate_config_rom(struct fw_card *card, size_t *config_rom_length)
* controller, block reads to the config rom accesses the host
* memory, but quadlet read access the hardware bus info block
* registers. That's just crack, but it means we should make
* sure the contents of bus info block in host memory mathces
* sure the contents of bus info block in host memory matches
* the version stored in the OHCI registers.
*/

Expand Down Expand Up @@ -189,6 +189,17 @@ static const char gap_count_table[] = {
63, 5, 7, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 35, 37, 40
};

void
fw_schedule_bm_work(struct fw_card *card, unsigned long delay)
{
int scheduled;

fw_card_get(card);
scheduled = schedule_delayed_work(&card->work, delay);
if (!scheduled)
fw_card_put(card);
}

static void
fw_card_bm_work(struct work_struct *work)
{
Expand All @@ -206,7 +217,7 @@ fw_card_bm_work(struct work_struct *work)

if (local_node == NULL) {
spin_unlock_irqrestore(&card->lock, flags);
return;
goto out_put_card;
}
fw_node_get(local_node);
fw_node_get(root_node);
Expand Down Expand Up @@ -280,7 +291,7 @@ fw_card_bm_work(struct work_struct *work)
* this task 100ms from now.
*/
spin_unlock_irqrestore(&card->lock, flags);
schedule_delayed_work(&card->work, DIV_ROUND_UP(HZ, 10));
fw_schedule_bm_work(card, DIV_ROUND_UP(HZ, 10));
goto out;
}

Expand Down Expand Up @@ -355,6 +366,8 @@ fw_card_bm_work(struct work_struct *work)
fw_device_put(root_device);
fw_node_put(root_node);
fw_node_put(local_node);
out_put_card:
fw_card_put(card);
}

static void
Expand Down Expand Up @@ -510,7 +523,6 @@ fw_core_remove_card(struct fw_card *card)
fw_card_put(card);
wait_for_completion(&card->done);

cancel_delayed_work_sync(&card->work);
WARN_ON(!list_empty(&card->transaction_list));
del_timer_sync(&card->flush_timer);
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/firewire/fw-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ static int shutdown_unit(struct device *device, void *data)
*/
DECLARE_RWSEM(fw_device_rwsem);

static DEFINE_IDR(fw_device_idr);
DEFINE_IDR(fw_device_idr);
int fw_cdev_major;

struct fw_device *fw_device_get_by_devt(dev_t devt)
Expand Down Expand Up @@ -689,7 +689,7 @@ static void fw_device_init(struct work_struct *work)
fw_notify("giving up on config rom for node id %x\n",
device->node_id);
if (device->node == device->card->root_node)
schedule_delayed_work(&device->card->work, 0);
fw_schedule_bm_work(device->card, 0);
fw_device_release(&device->device);
}
return;
Expand Down Expand Up @@ -758,7 +758,7 @@ static void fw_device_init(struct work_struct *work)
* pretty harmless.
*/
if (device->node == device->card->root_node)
schedule_delayed_work(&device->card->work, 0);
fw_schedule_bm_work(device->card, 0);

return;

Expand Down Expand Up @@ -892,7 +892,7 @@ static void fw_device_refresh(struct work_struct *work)
fw_device_shutdown(work);
out:
if (node_id == card->root_node->node_id)
schedule_delayed_work(&card->work, 0);
fw_schedule_bm_work(card, 0);
}

void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
Expand Down
2 changes: 2 additions & 0 deletions drivers/firewire/fw-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/idr.h>
#include <linux/rwsem.h>
#include <asm/atomic.h>

Expand Down Expand Up @@ -99,6 +100,7 @@ void fw_device_cdev_update(struct fw_device *device);
void fw_device_cdev_remove(struct fw_device *device);

extern struct rw_semaphore fw_device_rwsem;
extern struct idr fw_device_idr;
extern int fw_cdev_major;

/*
Expand Down
21 changes: 6 additions & 15 deletions drivers/firewire/fw-sbp2.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,17 +670,6 @@ static void sbp2_agent_reset_no_wait(struct sbp2_logical_unit *lu)
&d, sizeof(d), complete_agent_reset_write_no_wait, t);
}

static void sbp2_set_generation(struct sbp2_logical_unit *lu, int generation)
{
struct fw_card *card = fw_device(lu->tgt->unit->device.parent)->card;
unsigned long flags;

/* serialize with comparisons of lu->generation and card->generation */
spin_lock_irqsave(&card->lock, flags);
lu->generation = generation;
spin_unlock_irqrestore(&card->lock, flags);
}

static inline void sbp2_allow_block(struct sbp2_logical_unit *lu)
{
/*
Expand Down Expand Up @@ -884,7 +873,7 @@ static void sbp2_login(struct work_struct *work)
goto out;

generation = device->generation;
smp_rmb(); /* node_id must not be older than generation */
smp_rmb(); /* node IDs must not be older than generation */
node_id = device->node_id;
local_node_id = device->card->node_id;

Expand All @@ -908,7 +897,8 @@ static void sbp2_login(struct work_struct *work)

tgt->node_id = node_id;
tgt->address_high = local_node_id << 16;
sbp2_set_generation(lu, generation);
smp_wmb(); /* node IDs must not be older than generation */
lu->generation = generation;

lu->command_block_agent_address =
((u64)(be32_to_cpu(response.command_block_agent.high) & 0xffff)
Expand Down Expand Up @@ -1201,7 +1191,7 @@ static void sbp2_reconnect(struct work_struct *work)
goto out;

generation = device->generation;
smp_rmb(); /* node_id must not be older than generation */
smp_rmb(); /* node IDs must not be older than generation */
node_id = device->node_id;
local_node_id = device->card->node_id;

Expand All @@ -1228,7 +1218,8 @@ static void sbp2_reconnect(struct work_struct *work)

tgt->node_id = node_id;
tgt->address_high = local_node_id << 16;
sbp2_set_generation(lu, generation);
smp_wmb(); /* node IDs must not be older than generation */
lu->generation = generation;

fw_notify("%s: reconnected to LUN %04x (%d retries)\n",
tgt->bus_id, lu->lun, lu->retries);
Expand Down
16 changes: 7 additions & 9 deletions drivers/firewire/fw-topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@ report_lost_node(struct fw_card *card,
{
fw_node_event(card, node, FW_NODE_DESTROYED);
fw_node_put(node);

/* Topology has changed - reset bus manager retry counter */
card->bm_retries = 0;
}

static void
Expand All @@ -374,6 +377,9 @@ report_found_node(struct fw_card *card,
}

fw_node_event(card, node, FW_NODE_CREATED);

/* Topology has changed - reset bus manager retry counter */
card->bm_retries = 0;
}

void fw_destroy_nodes(struct fw_card *card)
Expand Down Expand Up @@ -514,14 +520,6 @@ fw_core_handle_bus_reset(struct fw_card *card,

spin_lock_irqsave(&card->lock, flags);

/*
* If the new topology has a different self_id_count the topology
* changed, either nodes were added or removed. In that case we
* reset the IRM reset counter.
*/
if (card->self_id_count != self_id_count)
card->bm_retries = 0;

card->node_id = node_id;
/*
* Update node_id before generation to prevent anybody from using
Expand All @@ -530,7 +528,7 @@ fw_core_handle_bus_reset(struct fw_card *card,
smp_wmb();
card->generation = generation;
card->reset_jiffies = jiffies;
schedule_delayed_work(&card->work, 0);
fw_schedule_bm_work(card, 0);

local_node = build_tree(card, self_ids, self_id_count);

Expand Down
2 changes: 2 additions & 0 deletions drivers/firewire/fw-transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

#include <linux/completion.h>
#include <linux/idr.h>
#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/module.h>
Expand Down Expand Up @@ -971,6 +972,7 @@ static void __exit fw_core_cleanup(void)
{
unregister_chrdev(fw_cdev_major, "firewire");
bus_unregister(&fw_bus_type);
idr_destroy(&fw_device_idr);
}

module_init(fw_core_init);
Expand Down
13 changes: 5 additions & 8 deletions drivers/firewire/fw-transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,6 @@ struct fw_card {
int link_speed;
int config_rom_generation;

/*
* We need to store up to 4 self ID for a maximum of 63
* devices plus 3 words for the topology map header.
*/
int self_id_count;
u32 topology_map[252 + 3];
u32 broadcast_channel;

spinlock_t lock; /* Take this lock when handling the lists in
* this struct. */
struct fw_node *local_node;
Expand All @@ -262,6 +254,9 @@ struct fw_card {
struct delayed_work work;
int bm_retries;
int bm_generation;

u32 broadcast_channel;
u32 topology_map[(CSR_TOPOLOGY_MAP_END - CSR_TOPOLOGY_MAP) / 4];
};

static inline struct fw_card *fw_card_get(struct fw_card *card)
Expand All @@ -278,6 +273,8 @@ static inline void fw_card_put(struct fw_card *card)
kref_put(&card->kref, fw_card_release);
}

extern void fw_schedule_bm_work(struct fw_card *card, unsigned long delay);

/*
* The iso packet format allows for an immediate header/payload part
* stored in 'header' immediately after the packet info plus an
Expand Down
12 changes: 6 additions & 6 deletions drivers/ieee1394/csr.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,22 @@ static struct hpsb_highlevel csr_highlevel = {
.host_reset = host_reset,
};

static struct hpsb_address_ops map_ops = {
const static struct hpsb_address_ops map_ops = {
.read = read_maps,
};

static struct hpsb_address_ops fcp_ops = {
const static struct hpsb_address_ops fcp_ops = {
.write = write_fcp,
};

static struct hpsb_address_ops reg_ops = {
const static struct hpsb_address_ops reg_ops = {
.read = read_regs,
.write = write_regs,
.lock = lock_regs,
.lock64 = lock64_regs,
};

static struct hpsb_address_ops config_rom_ops = {
const static struct hpsb_address_ops config_rom_ops = {
.read = read_config_rom,
};

Expand Down Expand Up @@ -217,7 +217,7 @@ static void add_host(struct hpsb_host *host)

host->csr.generation = 2;

bus_info[1] = __constant_cpu_to_be32(0x31333934);
bus_info[1] = IEEE1394_BUSID_MAGIC;
bus_info[2] = cpu_to_be32((hpsb_disable_irm ? 0 : 1 << CSR_IRMC_SHIFT) |
(1 << CSR_CMC_SHIFT) |
(1 << CSR_ISC_SHIFT) |
Expand Down Expand Up @@ -250,7 +250,7 @@ static void remove_host(struct hpsb_host *host)
{
quadlet_t bus_info[CSR_BUS_INFO_SIZE];

bus_info[1] = __constant_cpu_to_be32(0x31333934);
bus_info[1] = IEEE1394_BUSID_MAGIC;
bus_info[2] = cpu_to_be32((0 << CSR_IRMC_SHIFT) |
(0 << CSR_CMC_SHIFT) |
(0 << CSR_ISC_SHIFT) |
Expand Down
10 changes: 5 additions & 5 deletions drivers/ieee1394/csr.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
#define CSR_MAX_ROM_SHIFT 8
#define CSR_GENERATION_SHIFT 4

#define CSR_SET_BUS_INFO_GENERATION(csr, gen) \
((csr)->bus_info_data[2] = \
cpu_to_be32((be32_to_cpu((csr)->bus_info_data[2]) & \
~(0xf << CSR_GENERATION_SHIFT)) | \
(gen) << CSR_GENERATION_SHIFT))
static inline void csr_set_bus_info_generation(struct csr1212_csr *csr, u8 gen)
{
csr->bus_info_data[2] &= ~cpu_to_be32(0xf << CSR_GENERATION_SHIFT);
csr->bus_info_data[2] |= cpu_to_be32((u32)gen << CSR_GENERATION_SHIFT);
}

struct csr_control {
spinlock_t lock;
Expand Down
Loading

0 comments on commit daf4b80

Please sign in to comment.