提交 6978bbc0 编写于 作者: M Matt Porter 提交者: Linus Torvalds

[PATCH] rapidio: message interface updates

Updates the RIO messaging interface to pass a device instance into the
event registeration and callbacks.
Signed-off-by: NMatt Porter <mporter@kernel.crashing.org>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 2b0c28d7
...@@ -135,6 +135,7 @@ static struct rio_msg_tx_ring { ...@@ -135,6 +135,7 @@ static struct rio_msg_tx_ring {
dma_addr_t phys_buffer[RIO_MAX_TX_RING_SIZE]; dma_addr_t phys_buffer[RIO_MAX_TX_RING_SIZE];
int tx_slot; int tx_slot;
int size; int size;
void *dev_id;
} msg_tx_ring; } msg_tx_ring;
static struct rio_msg_rx_ring { static struct rio_msg_rx_ring {
...@@ -143,6 +144,7 @@ static struct rio_msg_rx_ring { ...@@ -143,6 +144,7 @@ static struct rio_msg_rx_ring {
void *virt_buffer[RIO_MAX_RX_RING_SIZE]; void *virt_buffer[RIO_MAX_RX_RING_SIZE];
int rx_slot; int rx_slot;
int size; int size;
void *dev_id;
} msg_rx_ring; } msg_rx_ring;
/** /**
...@@ -376,7 +378,7 @@ mpc85xx_rio_tx_handler(int irq, void *dev_instance, struct pt_regs *regs) ...@@ -376,7 +378,7 @@ mpc85xx_rio_tx_handler(int irq, void *dev_instance, struct pt_regs *regs)
if (osr & RIO_MSG_OSR_EOMI) { if (osr & RIO_MSG_OSR_EOMI) {
u32 dqp = in_be32((void *)&msg_regs->odqdpar); u32 dqp = in_be32((void *)&msg_regs->odqdpar);
int slot = (dqp - msg_tx_ring.phys) >> 5; int slot = (dqp - msg_tx_ring.phys) >> 5;
port->outb_msg[0].mcback(port, -1, slot); port->outb_msg[0].mcback(port, msg_tx_ring.dev_id, -1, slot);
/* Ack the end-of-message interrupt */ /* Ack the end-of-message interrupt */
out_be32((void *)&msg_regs->osr, RIO_MSG_OSR_EOMI); out_be32((void *)&msg_regs->osr, RIO_MSG_OSR_EOMI);
...@@ -389,6 +391,7 @@ mpc85xx_rio_tx_handler(int irq, void *dev_instance, struct pt_regs *regs) ...@@ -389,6 +391,7 @@ mpc85xx_rio_tx_handler(int irq, void *dev_instance, struct pt_regs *regs)
/** /**
* rio_open_outb_mbox - Initialize MPC85xx outbound mailbox * rio_open_outb_mbox - Initialize MPC85xx outbound mailbox
* @mport: Master port implementing the outbound message unit * @mport: Master port implementing the outbound message unit
* @dev_id: Device specific pointer to pass on event
* @mbox: Mailbox to open * @mbox: Mailbox to open
* @entries: Number of entries in the outbound mailbox ring * @entries: Number of entries in the outbound mailbox ring
* *
...@@ -396,7 +399,7 @@ mpc85xx_rio_tx_handler(int irq, void *dev_instance, struct pt_regs *regs) ...@@ -396,7 +399,7 @@ mpc85xx_rio_tx_handler(int irq, void *dev_instance, struct pt_regs *regs)
* and enables the outbound message unit. Returns %0 on success and * and enables the outbound message unit. Returns %0 on success and
* %-EINVAL or %-ENOMEM on failure. * %-EINVAL or %-ENOMEM on failure.
*/ */
int rio_open_outb_mbox(struct rio_mport *mport, int mbox, int entries) int rio_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries)
{ {
int i, j, rc = 0; int i, j, rc = 0;
...@@ -407,6 +410,7 @@ int rio_open_outb_mbox(struct rio_mport *mport, int mbox, int entries) ...@@ -407,6 +410,7 @@ int rio_open_outb_mbox(struct rio_mport *mport, int mbox, int entries)
} }
/* Initialize shadow copy ring */ /* Initialize shadow copy ring */
msg_tx_ring.dev_id = dev_id;
msg_tx_ring.size = entries; msg_tx_ring.size = entries;
for (i = 0; i < msg_tx_ring.size; i++) { for (i = 0; i < msg_tx_ring.size; i++) {
...@@ -541,7 +545,7 @@ mpc85xx_rio_rx_handler(int irq, void *dev_instance, struct pt_regs *regs) ...@@ -541,7 +545,7 @@ mpc85xx_rio_rx_handler(int irq, void *dev_instance, struct pt_regs *regs)
* make the callback with an unknown/invalid mailbox number * make the callback with an unknown/invalid mailbox number
* argument. * argument.
*/ */
port->inb_msg[0].mcback(port, -1, -1); port->inb_msg[0].mcback(port, msg_rx_ring.dev_id, -1, -1);
/* Ack the queueing interrupt */ /* Ack the queueing interrupt */
out_be32((void *)&msg_regs->isr, RIO_MSG_ISR_DIQI); out_be32((void *)&msg_regs->isr, RIO_MSG_ISR_DIQI);
...@@ -554,6 +558,7 @@ mpc85xx_rio_rx_handler(int irq, void *dev_instance, struct pt_regs *regs) ...@@ -554,6 +558,7 @@ mpc85xx_rio_rx_handler(int irq, void *dev_instance, struct pt_regs *regs)
/** /**
* rio_open_inb_mbox - Initialize MPC85xx inbound mailbox * rio_open_inb_mbox - Initialize MPC85xx inbound mailbox
* @mport: Master port implementing the inbound message unit * @mport: Master port implementing the inbound message unit
* @dev_id: Device specific pointer to pass on event
* @mbox: Mailbox to open * @mbox: Mailbox to open
* @entries: Number of entries in the inbound mailbox ring * @entries: Number of entries in the inbound mailbox ring
* *
...@@ -561,7 +566,7 @@ mpc85xx_rio_rx_handler(int irq, void *dev_instance, struct pt_regs *regs) ...@@ -561,7 +566,7 @@ mpc85xx_rio_rx_handler(int irq, void *dev_instance, struct pt_regs *regs)
* and enables the inbound message unit. Returns %0 on success * and enables the inbound message unit. Returns %0 on success
* and %-EINVAL or %-ENOMEM on failure. * and %-EINVAL or %-ENOMEM on failure.
*/ */
int rio_open_inb_mbox(struct rio_mport *mport, int mbox, int entries) int rio_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries)
{ {
int i, rc = 0; int i, rc = 0;
...@@ -572,6 +577,7 @@ int rio_open_inb_mbox(struct rio_mport *mport, int mbox, int entries) ...@@ -572,6 +577,7 @@ int rio_open_inb_mbox(struct rio_mport *mport, int mbox, int entries)
} }
/* Initialize client buffer ring */ /* Initialize client buffer ring */
msg_rx_ring.dev_id = dev_id;
msg_rx_ring.size = entries; msg_rx_ring.size = entries;
msg_rx_ring.rx_slot = 0; msg_rx_ring.rx_slot = 0;
for (i = 0; i < msg_rx_ring.size; i++) for (i = 0; i < msg_rx_ring.size; i++)
...@@ -777,7 +783,7 @@ mpc85xx_rio_dbell_handler(int irq, void *dev_instance, struct pt_regs *regs) ...@@ -777,7 +783,7 @@ mpc85xx_rio_dbell_handler(int irq, void *dev_instance, struct pt_regs *regs)
} }
} }
if (found) { if (found) {
dbell->dinb(port, DBELL_SID(dmsg), DBELL_TID(dmsg), dbell->dinb(port, dbell->dev_id, DBELL_SID(dmsg), DBELL_TID(dmsg),
DBELL_INF(dmsg)); DBELL_INF(dmsg));
} else { } else {
pr_debug pr_debug
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
/* Sysfs support */ /* Sysfs support */
#define rio_config_attr(field, format_string) \ #define rio_config_attr(field, format_string) \
static ssize_t \ static ssize_t \
field##_show(struct device *dev, char *buf) \ field##_show(struct device *dev, struct device_attribute *attr, char *buf) \
{ \ { \
struct rio_dev *rdev = to_rio_dev(dev); \ struct rio_dev *rdev = to_rio_dev(dev); \
\ \
...@@ -35,7 +35,7 @@ rio_config_attr(asm_did, "0x%04x\n"); ...@@ -35,7 +35,7 @@ rio_config_attr(asm_did, "0x%04x\n");
rio_config_attr(asm_vid, "0x%04x\n"); rio_config_attr(asm_vid, "0x%04x\n");
rio_config_attr(asm_rev, "0x%04x\n"); rio_config_attr(asm_rev, "0x%04x\n");
static ssize_t routes_show(struct device *dev, char *buf) static ssize_t routes_show(struct device *dev, struct device_attribute *attr, char *buf)
{ {
struct rio_dev *rdev = to_rio_dev(dev); struct rio_dev *rdev = to_rio_dev(dev);
char *str = buf; char *str = buf;
......
...@@ -48,6 +48,7 @@ u16 rio_local_get_device_id(struct rio_mport *port) ...@@ -48,6 +48,7 @@ u16 rio_local_get_device_id(struct rio_mport *port)
/** /**
* rio_request_inb_mbox - request inbound mailbox service * rio_request_inb_mbox - request inbound mailbox service
* @mport: RIO master port from which to allocate the mailbox resource * @mport: RIO master port from which to allocate the mailbox resource
* @dev_id: Device specific pointer to pass on event
* @mbox: Mailbox number to claim * @mbox: Mailbox number to claim
* @entries: Number of entries in inbound mailbox queue * @entries: Number of entries in inbound mailbox queue
* @minb: Callback to execute when inbound message is received * @minb: Callback to execute when inbound message is received
...@@ -56,9 +57,10 @@ u16 rio_local_get_device_id(struct rio_mport *port) ...@@ -56,9 +57,10 @@ u16 rio_local_get_device_id(struct rio_mport *port)
* a callback function to the resource. Returns %0 on success. * a callback function to the resource. Returns %0 on success.
*/ */
int rio_request_inb_mbox(struct rio_mport *mport, int rio_request_inb_mbox(struct rio_mport *mport,
void *dev_id,
int mbox, int mbox,
int entries, int entries,
void (*minb) (struct rio_mport * mport, int mbox, void (*minb) (struct rio_mport * mport, void *dev_id, int mbox,
int slot)) int slot))
{ {
int rc = 0; int rc = 0;
...@@ -81,7 +83,7 @@ int rio_request_inb_mbox(struct rio_mport *mport, ...@@ -81,7 +83,7 @@ int rio_request_inb_mbox(struct rio_mport *mport,
/* Hook the inbound message callback */ /* Hook the inbound message callback */
mport->inb_msg[mbox].mcback = minb; mport->inb_msg[mbox].mcback = minb;
rc = rio_open_inb_mbox(mport, mbox, entries); rc = rio_open_inb_mbox(mport, dev_id, mbox, entries);
} else } else
rc = -ENOMEM; rc = -ENOMEM;
...@@ -108,6 +110,7 @@ int rio_release_inb_mbox(struct rio_mport *mport, int mbox) ...@@ -108,6 +110,7 @@ int rio_release_inb_mbox(struct rio_mport *mport, int mbox)
/** /**
* rio_request_outb_mbox - request outbound mailbox service * rio_request_outb_mbox - request outbound mailbox service
* @mport: RIO master port from which to allocate the mailbox resource * @mport: RIO master port from which to allocate the mailbox resource
* @dev_id: Device specific pointer to pass on event
* @mbox: Mailbox number to claim * @mbox: Mailbox number to claim
* @entries: Number of entries in outbound mailbox queue * @entries: Number of entries in outbound mailbox queue
* @moutb: Callback to execute when outbound message is sent * @moutb: Callback to execute when outbound message is sent
...@@ -116,10 +119,10 @@ int rio_release_inb_mbox(struct rio_mport *mport, int mbox) ...@@ -116,10 +119,10 @@ int rio_release_inb_mbox(struct rio_mport *mport, int mbox)
* a callback function to the resource. Returns 0 on success. * a callback function to the resource. Returns 0 on success.
*/ */
int rio_request_outb_mbox(struct rio_mport *mport, int rio_request_outb_mbox(struct rio_mport *mport,
void *dev_id,
int mbox, int mbox,
int entries, int entries,
void (*moutb) (struct rio_mport * mport, int mbox, void (*moutb) (struct rio_mport * mport, void *dev_id, int mbox, int slot))
int slot))
{ {
int rc = 0; int rc = 0;
...@@ -141,7 +144,7 @@ int rio_request_outb_mbox(struct rio_mport *mport, ...@@ -141,7 +144,7 @@ int rio_request_outb_mbox(struct rio_mport *mport,
/* Hook the inbound message callback */ /* Hook the inbound message callback */
mport->outb_msg[mbox].mcback = moutb; mport->outb_msg[mbox].mcback = moutb;
rc = rio_open_outb_mbox(mport, mbox, entries); rc = rio_open_outb_mbox(mport, dev_id, mbox, entries);
} else } else
rc = -ENOMEM; rc = -ENOMEM;
...@@ -168,6 +171,7 @@ int rio_release_outb_mbox(struct rio_mport *mport, int mbox) ...@@ -168,6 +171,7 @@ int rio_release_outb_mbox(struct rio_mport *mport, int mbox)
/** /**
* rio_setup_inb_dbell - bind inbound doorbell callback * rio_setup_inb_dbell - bind inbound doorbell callback
* @mport: RIO master port to bind the doorbell callback * @mport: RIO master port to bind the doorbell callback
* @dev_id: Device specific pointer to pass on event
* @res: Doorbell message resource * @res: Doorbell message resource
* @dinb: Callback to execute when doorbell is received * @dinb: Callback to execute when doorbell is received
* *
...@@ -176,8 +180,8 @@ int rio_release_outb_mbox(struct rio_mport *mport, int mbox) ...@@ -176,8 +180,8 @@ int rio_release_outb_mbox(struct rio_mport *mport, int mbox)
* satisfied. * satisfied.
*/ */
static int static int
rio_setup_inb_dbell(struct rio_mport *mport, struct resource *res, rio_setup_inb_dbell(struct rio_mport *mport, void *dev_id, struct resource *res,
void (*dinb) (struct rio_mport * mport, u16 src, u16 dst, void (*dinb) (struct rio_mport * mport, void *dev_id, u16 src, u16 dst,
u16 info)) u16 info))
{ {
int rc = 0; int rc = 0;
...@@ -190,6 +194,7 @@ rio_setup_inb_dbell(struct rio_mport *mport, struct resource *res, ...@@ -190,6 +194,7 @@ rio_setup_inb_dbell(struct rio_mport *mport, struct resource *res,
dbell->res = res; dbell->res = res;
dbell->dinb = dinb; dbell->dinb = dinb;
dbell->dev_id = dev_id;
list_add_tail(&dbell->node, &mport->dbells); list_add_tail(&dbell->node, &mport->dbells);
...@@ -200,6 +205,7 @@ rio_setup_inb_dbell(struct rio_mport *mport, struct resource *res, ...@@ -200,6 +205,7 @@ rio_setup_inb_dbell(struct rio_mport *mport, struct resource *res,
/** /**
* rio_request_inb_dbell - request inbound doorbell message service * rio_request_inb_dbell - request inbound doorbell message service
* @mport: RIO master port from which to allocate the doorbell resource * @mport: RIO master port from which to allocate the doorbell resource
* @dev_id: Device specific pointer to pass on event
* @start: Doorbell info range start * @start: Doorbell info range start
* @end: Doorbell info range end * @end: Doorbell info range end
* @dinb: Callback to execute when doorbell is received * @dinb: Callback to execute when doorbell is received
...@@ -209,9 +215,10 @@ rio_setup_inb_dbell(struct rio_mport *mport, struct resource *res, ...@@ -209,9 +215,10 @@ rio_setup_inb_dbell(struct rio_mport *mport, struct resource *res,
* has been satisfied. * has been satisfied.
*/ */
int rio_request_inb_dbell(struct rio_mport *mport, int rio_request_inb_dbell(struct rio_mport *mport,
void *dev_id,
u16 start, u16 start,
u16 end, u16 end,
void (*dinb) (struct rio_mport * mport, u16 src, void (*dinb) (struct rio_mport * mport, void *dev_id, u16 src,
u16 dst, u16 info)) u16 dst, u16 info))
{ {
int rc = 0; int rc = 0;
...@@ -230,7 +237,7 @@ int rio_request_inb_dbell(struct rio_mport *mport, ...@@ -230,7 +237,7 @@ int rio_request_inb_dbell(struct rio_mport *mport,
} }
/* Hook the doorbell callback */ /* Hook the doorbell callback */
rc = rio_setup_inb_dbell(mport, res, dinb); rc = rio_setup_inb_dbell(mport, dev_id, res, dinb);
} else } else
rc = -ENOMEM; rc = -ENOMEM;
......
...@@ -132,7 +132,7 @@ struct rio_dev { ...@@ -132,7 +132,7 @@ struct rio_dev {
*/ */
struct rio_msg { struct rio_msg {
struct resource *res; struct resource *res;
void (*mcback) (struct rio_mport * mport, int mbox, int slot); void (*mcback) (struct rio_mport * mport, void *dev_id, int mbox, int slot);
}; };
/** /**
...@@ -140,11 +140,13 @@ struct rio_msg { ...@@ -140,11 +140,13 @@ struct rio_msg {
* @node: Node in list of doorbell events * @node: Node in list of doorbell events
* @res: Doorbell resource * @res: Doorbell resource
* @dinb: Doorbell event callback * @dinb: Doorbell event callback
* @dev_id: Device specific pointer to pass on event
*/ */
struct rio_dbell { struct rio_dbell {
struct list_head node; struct list_head node;
struct resource *res; struct resource *res;
void (*dinb) (struct rio_mport * mport, u16 src, u16 dst, u16 info); void (*dinb) (struct rio_mport *mport, void *dev_id, u16 src, u16 dst, u16 info);
void *dev_id;
}; };
/** /**
...@@ -314,9 +316,9 @@ extern int rio_hw_add_outb_message(struct rio_mport *, struct rio_dev *, int, ...@@ -314,9 +316,9 @@ extern int rio_hw_add_outb_message(struct rio_mport *, struct rio_dev *, int,
void *, size_t); void *, size_t);
extern int rio_hw_add_inb_buffer(struct rio_mport *, int, void *); extern int rio_hw_add_inb_buffer(struct rio_mport *, int, void *);
extern void *rio_hw_get_inb_message(struct rio_mport *, int); extern void *rio_hw_get_inb_message(struct rio_mport *, int);
extern int rio_open_inb_mbox(struct rio_mport *, int, int); extern int rio_open_inb_mbox(struct rio_mport *, void *, int, int);
extern void rio_close_inb_mbox(struct rio_mport *, int); extern void rio_close_inb_mbox(struct rio_mport *, int);
extern int rio_open_outb_mbox(struct rio_mport *, int, int); extern int rio_open_outb_mbox(struct rio_mport *, void *, int, int);
extern void rio_close_outb_mbox(struct rio_mport *, int); extern void rio_close_outb_mbox(struct rio_mport *, int);
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -348,8 +348,8 @@ static inline void rio_init_dbell_res(struct resource *res, u16 start, u16 end) ...@@ -348,8 +348,8 @@ static inline void rio_init_dbell_res(struct resource *res, u16 start, u16 end)
.asm_did = RIO_ANY_ID, .asm_vid = RIO_ANY_ID .asm_did = RIO_ANY_ID, .asm_vid = RIO_ANY_ID
/* Mailbox management */ /* Mailbox management */
extern int rio_request_outb_mbox(struct rio_mport *, int, int, extern int rio_request_outb_mbox(struct rio_mport *, void *, int, int,
void (*)(struct rio_mport *, int, int)); void (*)(struct rio_mport *, void *,int, int));
extern int rio_release_outb_mbox(struct rio_mport *, int); extern int rio_release_outb_mbox(struct rio_mport *, int);
/** /**
...@@ -370,8 +370,8 @@ static inline int rio_add_outb_message(struct rio_mport *mport, ...@@ -370,8 +370,8 @@ static inline int rio_add_outb_message(struct rio_mport *mport,
return rio_hw_add_outb_message(mport, rdev, mbox, buffer, len); return rio_hw_add_outb_message(mport, rdev, mbox, buffer, len);
} }
extern int rio_request_inb_mbox(struct rio_mport *, int, int, extern int rio_request_inb_mbox(struct rio_mport *, void *, int, int,
void (*)(struct rio_mport *, int, int)); void (*)(struct rio_mport *, void *, int, int));
extern int rio_release_inb_mbox(struct rio_mport *, int); extern int rio_release_inb_mbox(struct rio_mport *, int);
/** /**
...@@ -403,8 +403,8 @@ static inline void *rio_get_inb_message(struct rio_mport *mport, int mbox) ...@@ -403,8 +403,8 @@ static inline void *rio_get_inb_message(struct rio_mport *mport, int mbox)
} }
/* Doorbell management */ /* Doorbell management */
extern int rio_request_inb_dbell(struct rio_mport *, u16, u16, extern int rio_request_inb_dbell(struct rio_mport *, void *, u16, u16,
void (*)(struct rio_mport *, u16, u16, u16)); void (*)(struct rio_mport *, void *, u16, u16, u16));
extern int rio_release_inb_dbell(struct rio_mport *, u16, u16); extern int rio_release_inb_dbell(struct rio_mport *, u16, u16);
extern struct resource *rio_request_outb_dbell(struct rio_dev *, u16, u16); extern struct resource *rio_request_outb_dbell(struct rio_dev *, u16, u16);
extern int rio_release_outb_dbell(struct rio_dev *, struct resource *); extern int rio_release_outb_dbell(struct rio_dev *, struct resource *);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册