Skip to content

Commit

Permalink
[PATCH] I2O: second code cleanup of sparse warnings and unneeded sync…
Browse files Browse the repository at this point in the history
…ronization

Changes:
 - Added header "core.h" for i2o_core.ko internal definitions
 - More sparse fixes
 - Changed display of TID's in sysfs attributes from XXX to 0xXXX
 - Use the right functions for accessing I/O and normal memory
 - Removed error handling of SCSI device errors and let the SCSI layer
   take care of it
 - Added new device / removed device handling to SCSI-OSM
 - Make status access volatile
 - Cleaned up activation of I2O controller
 - Removed unnecessary wmb() and rmb() calls
 - Use own struct i2o_io for I/O memory instead of struct i2o_dma

Signed-off-by: Markus Lidel <Markus.Lidel@shadowconnect.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Markus Lidel authored and Linus Torvalds committed Jun 24, 2005
1 parent b2aaee3 commit 9e87545
Show file tree
Hide file tree
Showing 12 changed files with 275 additions and 358 deletions.
55 changes: 55 additions & 0 deletions drivers/message/i2o/core.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* I2O core internal declarations
*
* Copyright (C) 2005 Markus Lidel <Markus.Lidel@shadowconnect.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* Fixes/additions:
* Markus Lidel <Markus.Lidel@shadowconnect.com>
* initial version.
*/

/* Exec-OSM */
extern struct bus_type i2o_bus_type;

extern struct i2o_driver i2o_exec_driver;
extern int i2o_exec_lct_get(struct i2o_controller *);

extern int __init i2o_exec_init(void);
extern void __exit i2o_exec_exit(void);

/* driver */
extern int i2o_driver_dispatch(struct i2o_controller *, u32);

extern int __init i2o_driver_init(void);
extern void __exit i2o_driver_exit(void);

/* PCI */
extern int __init i2o_pci_init(void);
extern void __exit i2o_pci_exit(void);

/* device */
extern void i2o_device_remove(struct i2o_device *);
extern int i2o_device_parse_lct(struct i2o_controller *);

extern int i2o_device_init(void);
extern void i2o_device_exit(void);

/* IOP */
extern struct i2o_controller *i2o_iop_alloc(void);
extern void i2o_iop_free(struct i2o_controller *);

extern int i2o_iop_add(struct i2o_controller *);
extern void i2o_iop_remove(struct i2o_controller *);

/* control registers relative to c->base */
#define I2O_IRQ_STATUS 0x30
#define I2O_IRQ_MASK 0x34
#define I2O_IN_PORT 0x40
#define I2O_OUT_PORT 0x44

#define I2O_IRQ_OUTBOUND_POST 0x00000008
3 changes: 0 additions & 3 deletions drivers/message/i2o/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include <linux/pci.h>
#include <linux/i2o.h>

extern struct i2o_driver **i2o_drivers;
extern unsigned int i2o_max_drivers;
static void i2o_report_util_cmd(u8 cmd);
static void i2o_report_exec_cmd(u8 cmd);
static void i2o_report_fail_status(u8 req_status, u32 * msg);
Expand All @@ -23,7 +21,6 @@ void i2o_report_status(const char *severity, const char *str,
u8 cmd = (msg[1] >> 24) & 0xFF;
u8 req_status = (msg[4] >> 24) & 0xFF;
u16 detailed_status = msg[4] & 0xFFFF;
//struct i2o_driver *h = i2o_drivers[msg[2] & (i2o_max_drivers-1)];

if (cmd == I2O_CMD_UTIL_EVT_REGISTER)
return; // No status in this reply
Expand Down
22 changes: 13 additions & 9 deletions drivers/message/i2o/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
#include <linux/module.h>
#include <linux/i2o.h>
#include <linux/delay.h>

/* Exec OSM functions */
extern struct bus_type i2o_bus_type;
#include "core.h"

/**
* i2o_device_issue_claim - claim or release a device
Expand Down Expand Up @@ -293,12 +291,12 @@ int i2o_device_parse_lct(struct i2o_controller *c)
}

if (lct->table_size * 4 > c->dlct.len) {
memcpy_fromio(c->lct, c->dlct.virt, c->dlct.len);
memcpy(c->lct, c->dlct.virt, c->dlct.len);
up(&c->lct_lock);
return -EAGAIN;
}

memcpy_fromio(c->lct, c->dlct.virt, lct->table_size * 4);
memcpy(c->lct, c->dlct.virt, lct->table_size * 4);

lct = c->lct;

Expand Down Expand Up @@ -353,7 +351,7 @@ static ssize_t i2o_device_class_show_class_id(struct class_device *cd,
{
struct i2o_device *dev = to_i2o_device(cd->dev);

sprintf(buf, "%03x\n", dev->lct_data.class_id);
sprintf(buf, "0x%03x\n", dev->lct_data.class_id);
return strlen(buf) + 1;
};

Expand All @@ -368,7 +366,7 @@ static ssize_t i2o_device_class_show_tid(struct class_device *cd, char *buf)
{
struct i2o_device *dev = to_i2o_device(cd->dev);

sprintf(buf, "%03x\n", dev->lct_data.tid);
sprintf(buf, "0x%03x\n", dev->lct_data.tid);
return strlen(buf) + 1;
};

Expand Down Expand Up @@ -490,7 +488,7 @@ static int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist,
if (rc == -ETIMEDOUT)
return rc;

memcpy_fromio(reslist, res.virt, res.len);
memcpy(reslist, res.virt, res.len);
i2o_dma_free(dev, &res);

/* Query failed */
Expand Down Expand Up @@ -532,17 +530,23 @@ int i2o_parm_field_get(struct i2o_device *i2o_dev, int group, int field,
void *buf, int buflen)
{
u16 opblk[] = { 1, 0, I2O_PARAMS_FIELD_GET, group, 1, field };
u8 resblk[8 + buflen]; /* 8 bytes for header */
u8 *resblk; /* 8 bytes for header */
int size;

if (field == -1) /* whole group */
opblk[4] = -1;

resblk = kmalloc(buflen + 8, GFP_KERNEL | GFP_ATOMIC);
if (!resblk)
return -ENOMEM;

size = i2o_parm_issue(i2o_dev, I2O_CMD_UTIL_PARAMS_GET, opblk,
sizeof(opblk), resblk, buflen + 8);

memcpy(buf, resblk + 8, buflen); /* cut off header */

kfree(resblk);

if (size > buflen)
return buflen;

Expand Down
24 changes: 10 additions & 14 deletions drivers/message/i2o/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
#include <linux/module.h>
#include <linux/rwsem.h>
#include <linux/i2o.h>
#include "core.h"

#define OSM_NAME "i2o"

/* max_drivers - Maximum I2O drivers (OSMs) which could be registered */
unsigned int i2o_max_drivers = I2O_MAX_DRIVERS;
static unsigned int i2o_max_drivers = I2O_MAX_DRIVERS;
module_param_named(max_drivers, i2o_max_drivers, uint, 0);
MODULE_PARM_DESC(max_drivers, "maximum number of OSM's to support");

Expand Down Expand Up @@ -179,15 +180,10 @@ void i2o_driver_unregister(struct i2o_driver *drv)
int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
{
struct i2o_driver *drv;
struct i2o_message __iomem *msg = i2o_msg_out_to_virt(c, m);
u32 context;
struct i2o_message *msg = i2o_msg_out_to_virt(c, m);
u32 context = le32_to_cpu(msg->u.s.icntxt);
unsigned long flags;

if(unlikely(!msg))
return -EIO;

context = readl(&msg->u.s.icntxt);

if (unlikely(context >= i2o_max_drivers)) {
osm_warn("%s: Spurious reply to unknown driver %d\n", c->name,
context);
Expand All @@ -204,28 +200,28 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
return -EIO;
}

if ((readl(&msg->u.head[1]) >> 24) == I2O_CMD_UTIL_EVT_REGISTER) {
if ((le32_to_cpu(msg->u.head[1]) >> 24) == I2O_CMD_UTIL_EVT_REGISTER) {
struct i2o_device *dev, *tmp;
struct i2o_event *evt;
u16 size;
u16 tid = readl(&msg->u.head[1]) & 0xfff;
u16 tid = le32_to_cpu(msg->u.head[1]) & 0xfff;

osm_debug("event received from device %d\n", tid);

if (!drv->event)
return -EIO;

/* cut of header from message size (in 32-bit words) */
size = (readl(&msg->u.head[0]) >> 16) - 5;
size = (le32_to_cpu(msg->u.head[0]) >> 16) - 5;

evt = kmalloc(size * 4 + sizeof(*evt), GFP_ATOMIC | __GFP_ZERO);
if (!evt)
return -ENOMEM;

evt->size = size;
evt->tcntxt = readl(&msg->u.s.tcntxt);
evt->event_indicator = readl(&msg->body[0]);
memcpy_fromio(&evt->tcntxt, &msg->u.s.tcntxt, size * 4);
evt->tcntxt = le32_to_cpu(msg->u.s.tcntxt);
evt->event_indicator = le32_to_cpu(msg->body[0]);
memcpy(&evt->tcntxt, &msg->u.s.tcntxt, size * 4);

list_for_each_entry_safe(dev, tmp, &c->devices, list)
if (dev->lct_data.tid == tid) {
Expand Down
27 changes: 12 additions & 15 deletions drivers/message/i2o/exec-osm.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@
#include <linux/module.h>
#include <linux/i2o.h>
#include <linux/delay.h>
#include "core.h"

#define OSM_NAME "exec-osm"

struct i2o_driver i2o_exec_driver;

static int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind);

/* Module internal functions from other sources */
extern int i2o_device_parse_lct(struct i2o_controller *);

/* global wait list for POST WAIT */
static LIST_HEAD(i2o_exec_wait_list);

Expand All @@ -50,7 +48,7 @@ struct i2o_exec_wait {
u32 tcntxt; /* transaction context from reply */
int complete; /* 1 if reply received otherwise 0 */
u32 m; /* message id */
struct i2o_message __iomem *msg; /* pointer to the reply message */
struct i2o_message *msg; /* pointer to the reply message */
struct list_head list; /* node in global wait list */
};

Expand Down Expand Up @@ -162,7 +160,7 @@ int i2o_msg_post_wait_mem(struct i2o_controller *c, u32 m, unsigned long
barrier();

if (wait->complete) {
rc = readl(&wait->msg->body[0]) >> 24;
rc = le32_to_cpu(wait->msg->body[0]) >> 24;
i2o_flush_reply(c, wait->m);
i2o_exec_wait_free(wait);
} else {
Expand Down Expand Up @@ -202,8 +200,7 @@ int i2o_msg_post_wait_mem(struct i2o_controller *c, u32 m, unsigned long
* message must also be given back to the controller.
*/
static int i2o_msg_post_wait_complete(struct i2o_controller *c, u32 m,
struct i2o_message __iomem *msg,
u32 context)
struct i2o_message *msg, u32 context)
{
struct i2o_exec_wait *wait, *tmp;
unsigned long flags;
Expand Down Expand Up @@ -378,19 +375,19 @@ static void i2o_exec_lct_modified(struct i2o_controller *c)
* code on failure and if the reply should be flushed.
*/
static int i2o_exec_reply(struct i2o_controller *c, u32 m,
struct i2o_message __iomem *msg)
struct i2o_message *msg)
{
u32 context;

if (readl(&msg->u.head[0]) & MSG_FAIL) {
if (le32_to_cpu(msg->u.head[0]) & MSG_FAIL) {
/*
* If Fail bit is set we must take the transaction context of
* the preserved message to find the right request again.
*/
struct i2o_message __iomem *pmsg;
u32 pm;

pm = readl(&msg->body[3]);
pm = le32_to_cpu(msg->body[3]);

pmsg = i2o_msg_in_to_virt(c, pm);

Expand All @@ -401,12 +398,12 @@ static int i2o_exec_reply(struct i2o_controller *c, u32 m,
/* Release the preserved msg */
i2o_msg_nop(c, pm);
} else
context = readl(&msg->u.s.tcntxt);
context = le32_to_cpu(msg->u.s.tcntxt);

if (context & 0x80000000)
return i2o_msg_post_wait_complete(c, m, msg, context);

if ((readl(&msg->u.head[1]) >> 24) == I2O_CMD_LCT_NOTIFY) {
if ((le32_to_cpu(msg->u.head[1]) >> 24) == I2O_CMD_LCT_NOTIFY) {
struct work_struct *work;

pr_debug("%s: LCT notify received\n", c->name);
Expand Down Expand Up @@ -442,9 +439,9 @@ static int i2o_exec_reply(struct i2o_controller *c, u32 m,
*/
static void i2o_exec_event(struct i2o_event *evt)
{
if(likely(evt->i2o_dev))
osm_info("Event received from device: %d\n",
evt->i2o_dev->lct_data.tid);
if (likely(evt->i2o_dev))
osm_debug("Event received from device: %d\n",
evt->i2o_dev->lct_data.tid);
kfree(evt);
};

Expand Down
4 changes: 2 additions & 2 deletions drivers/message/i2o/i2o_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#include "i2o_block.h"

#define OSM_NAME "block-osm"
#define OSM_VERSION "$Rev$"
#define OSM_VERSION "1.287"
#define OSM_DESCRIPTION "I2O Block Device OSM"

static struct i2o_driver i2o_block_driver;
Expand Down Expand Up @@ -537,7 +537,7 @@ static int i2o_block_reply(struct i2o_controller *c, u32 m,

static void i2o_block_event(struct i2o_event *evt)
{
osm_info("event received\n");
osm_debug("event received\n");
kfree(evt);
};

Expand Down
8 changes: 5 additions & 3 deletions drivers/message/i2o/i2o_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

#include <asm/uaccess.h>

#define SG_TABLESIZE 30

extern int i2o_parm_issue(struct i2o_device *, int, void *, int, void *, int);

static int i2o_cfg_ioctl(struct inode *inode, struct file *fp, unsigned int cmd,
Expand Down Expand Up @@ -663,15 +665,15 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd, unsigned long ar
goto sg_list_cleanup;

if (sg_offset) {
u32 msg[MSG_FRAME_SIZE];
u32 msg[I2O_OUTBOUND_MSG_FRAME_SIZE];
/* Copy back the Scatter Gather buffers back to user space */
u32 j;
// TODO 64bit fix
struct sg_simple_element *sg;
int sg_size;

// re-acquire the original message to handle correctly the sg copy operation
memset(&msg, 0, MSG_FRAME_SIZE * 4);
memset(&msg, 0, I2O_OUTBOUND_MSG_FRAME_SIZE * 4);
// get user msg size in u32s
if (get_user(size, &user_msg[0])) {
rcode = -EFAULT;
Expand Down Expand Up @@ -902,7 +904,7 @@ static int i2o_cfg_passthru(unsigned long arg)
int sg_size;

// re-acquire the original message to handle correctly the sg copy operation
memset(&msg, 0, MSG_FRAME_SIZE * 4);
memset(&msg, 0, I2O_OUTBOUND_MSG_FRAME_SIZE * 4);
// get user msg size in u32s
if (get_user(size, &user_msg[0])) {
rcode = -EFAULT;
Expand Down
Loading

0 comments on commit 9e87545

Please sign in to comment.