Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rapidio: add architecture specific callbacks

This set of patches eliminates RapidIO dependency on PowerPC architecture
and makes it available to other architectures (x86 and MIPS). It also
enables support of new platform independent RapidIO controllers such as
PCI-to-SRIO and PCI Express-to-SRIO.

This patch:

Extend number of mport callback functions to eliminate direct linking of
architecture specific mport operations.

Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Li Yang <leoli@freescale.com>
Cc: Thomas Moll <thomas.moll@sysgo.com>
Cc: Micha Nelissen <micha@neli.hopto.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexandre Bounine and committed by
Linus Torvalds
f8f06269 e15b4d68

+75 -45
+27 -25
arch/powerpc/sysdev/fsl_rio.c
··· 482 482 } 483 483 484 484 /** 485 - * rio_hw_add_outb_message - Add message to the MPC85xx outbound message queue 485 + * fsl_add_outb_message - Add message to the MPC85xx outbound message queue 486 486 * @mport: Master port with outbound message queue 487 487 * @rdev: Target of outbound message 488 488 * @mbox: Outbound mailbox ··· 492 492 * Adds the @buffer message to the MPC85xx outbound message queue. Returns 493 493 * %0 on success or %-EINVAL on failure. 494 494 */ 495 - int 496 - rio_hw_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox, 495 + static int 496 + fsl_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox, 497 497 void *buffer, size_t len) 498 498 { 499 499 struct rio_priv *priv = mport->priv; ··· 502 502 + priv->msg_tx_ring.tx_slot; 503 503 int ret = 0; 504 504 505 - pr_debug 506 - ("RIO: rio_hw_add_outb_message(): destid %4.4x mbox %d buffer %8.8x len %8.8x\n", 507 - rdev->destid, mbox, (int)buffer, len); 505 + pr_debug("RIO: fsl_add_outb_message(): destid %4.4x mbox %d buffer " \ 506 + "%8.8x len %8.8x\n", rdev->destid, mbox, (int)buffer, len); 508 507 509 508 if ((len < 8) || (len > RIO_MAX_MSG_SIZE)) { 510 509 ret = -EINVAL; ··· 553 554 return ret; 554 555 } 555 556 556 - EXPORT_SYMBOL_GPL(rio_hw_add_outb_message); 557 - 558 557 /** 559 558 * fsl_rio_tx_handler - MPC85xx outbound message interrupt handler 560 559 * @irq: Linux interrupt number ··· 597 600 } 598 601 599 602 /** 600 - * rio_open_outb_mbox - Initialize MPC85xx outbound mailbox 603 + * fsl_open_outb_mbox - Initialize MPC85xx outbound mailbox 601 604 * @mport: Master port implementing the outbound message unit 602 605 * @dev_id: Device specific pointer to pass on event 603 606 * @mbox: Mailbox to open ··· 607 610 * and enables the outbound message unit. Returns %0 on success and 608 611 * %-EINVAL or %-ENOMEM on failure. 609 612 */ 610 - int rio_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries) 613 + static int 614 + fsl_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries) 611 615 { 612 616 int i, j, rc = 0; 613 617 struct rio_priv *priv = mport->priv; ··· 704 706 } 705 707 706 708 /** 707 - * rio_close_outb_mbox - Shut down MPC85xx outbound mailbox 709 + * fsl_close_outb_mbox - Shut down MPC85xx outbound mailbox 708 710 * @mport: Master port implementing the outbound message unit 709 711 * @mbox: Mailbox to close 710 712 * 711 713 * Disables the outbound message unit, free all buffers, and 712 714 * frees the outbound message interrupt. 713 715 */ 714 - void rio_close_outb_mbox(struct rio_mport *mport, int mbox) 716 + static void fsl_close_outb_mbox(struct rio_mport *mport, int mbox) 715 717 { 716 718 struct rio_priv *priv = mport->priv; 717 719 /* Disable inbound message unit */ ··· 768 770 } 769 771 770 772 /** 771 - * rio_open_inb_mbox - Initialize MPC85xx inbound mailbox 773 + * fsl_open_inb_mbox - Initialize MPC85xx inbound mailbox 772 774 * @mport: Master port implementing the inbound message unit 773 775 * @dev_id: Device specific pointer to pass on event 774 776 * @mbox: Mailbox to open ··· 778 780 * and enables the inbound message unit. Returns %0 on success 779 781 * and %-EINVAL or %-ENOMEM on failure. 780 782 */ 781 - int rio_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries) 783 + static int 784 + fsl_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries) 782 785 { 783 786 int i, rc = 0; 784 787 struct rio_priv *priv = mport->priv; ··· 843 844 } 844 845 845 846 /** 846 - * rio_close_inb_mbox - Shut down MPC85xx inbound mailbox 847 + * fsl_close_inb_mbox - Shut down MPC85xx inbound mailbox 847 848 * @mport: Master port implementing the inbound message unit 848 849 * @mbox: Mailbox to close 849 850 * 850 851 * Disables the inbound message unit, free all buffers, and 851 852 * frees the inbound message interrupt. 852 853 */ 853 - void rio_close_inb_mbox(struct rio_mport *mport, int mbox) 854 + static void fsl_close_inb_mbox(struct rio_mport *mport, int mbox) 854 855 { 855 856 struct rio_priv *priv = mport->priv; 856 857 /* Disable inbound message unit */ ··· 865 866 } 866 867 867 868 /** 868 - * rio_hw_add_inb_buffer - Add buffer to the MPC85xx inbound message queue 869 + * fsl_add_inb_buffer - Add buffer to the MPC85xx inbound message queue 869 870 * @mport: Master port implementing the inbound message unit 870 871 * @mbox: Inbound mailbox number 871 872 * @buf: Buffer to add to inbound queue ··· 873 874 * Adds the @buf buffer to the MPC85xx inbound message queue. Returns 874 875 * %0 on success or %-EINVAL on failure. 875 876 */ 876 - int rio_hw_add_inb_buffer(struct rio_mport *mport, int mbox, void *buf) 877 + static int fsl_add_inb_buffer(struct rio_mport *mport, int mbox, void *buf) 877 878 { 878 879 int rc = 0; 879 880 struct rio_priv *priv = mport->priv; 880 881 881 - pr_debug("RIO: rio_hw_add_inb_buffer(), msg_rx_ring.rx_slot %d\n", 882 + pr_debug("RIO: fsl_add_inb_buffer(), msg_rx_ring.rx_slot %d\n", 882 883 priv->msg_rx_ring.rx_slot); 883 884 884 885 if (priv->msg_rx_ring.virt_buffer[priv->msg_rx_ring.rx_slot]) { ··· 897 898 return rc; 898 899 } 899 900 900 - EXPORT_SYMBOL_GPL(rio_hw_add_inb_buffer); 901 - 902 901 /** 903 - * rio_hw_get_inb_message - Fetch inbound message from the MPC85xx message unit 902 + * fsl_get_inb_message - Fetch inbound message from the MPC85xx message unit 904 903 * @mport: Master port implementing the inbound message unit 905 904 * @mbox: Inbound mailbox number 906 905 * 907 906 * Gets the next available inbound message from the inbound message queue. 908 907 * A pointer to the message is returned on success or NULL on failure. 909 908 */ 910 - void *rio_hw_get_inb_message(struct rio_mport *mport, int mbox) 909 + static void *fsl_get_inb_message(struct rio_mport *mport, int mbox) 911 910 { 912 911 struct rio_priv *priv = mport->priv; 913 912 u32 phys_buf, virt_buf; ··· 941 944 out2: 942 945 return buf; 943 946 } 944 - 945 - EXPORT_SYMBOL_GPL(rio_hw_get_inb_message); 946 947 947 948 /** 948 949 * fsl_rio_dbell_handler - MPC85xx doorbell interrupt handler ··· 1426 1431 ops->cwrite = fsl_rio_config_write; 1427 1432 ops->dsend = fsl_rio_doorbell_send; 1428 1433 ops->pwenable = fsl_rio_pw_enable; 1434 + ops->open_outb_mbox = fsl_open_outb_mbox; 1435 + ops->open_inb_mbox = fsl_open_inb_mbox; 1436 + ops->close_outb_mbox = fsl_close_outb_mbox; 1437 + ops->close_inb_mbox = fsl_close_inb_mbox; 1438 + ops->add_outb_message = fsl_add_outb_message; 1439 + ops->add_inb_buffer = fsl_add_inb_buffer; 1440 + ops->get_inb_message = fsl_get_inb_message; 1429 1441 1430 1442 port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL); 1431 1443 if (!port) {
+26 -12
drivers/rapidio/rio.c
··· 68 68 void (*minb) (struct rio_mport * mport, void *dev_id, int mbox, 69 69 int slot)) 70 70 { 71 - int rc = 0; 71 + int rc = -ENOSYS; 72 + struct resource *res; 72 73 73 - struct resource *res = kmalloc(sizeof(struct resource), GFP_KERNEL); 74 + if (mport->ops->open_inb_mbox == NULL) 75 + goto out; 76 + 77 + res = kmalloc(sizeof(struct resource), GFP_KERNEL); 74 78 75 79 if (res) { 76 80 rio_init_mbox_res(res, mbox, mbox); ··· 92 88 /* Hook the inbound message callback */ 93 89 mport->inb_msg[mbox].mcback = minb; 94 90 95 - rc = rio_open_inb_mbox(mport, dev_id, mbox, entries); 91 + rc = mport->ops->open_inb_mbox(mport, dev_id, mbox, entries); 96 92 } else 97 93 rc = -ENOMEM; 98 94 ··· 110 106 */ 111 107 int rio_release_inb_mbox(struct rio_mport *mport, int mbox) 112 108 { 113 - rio_close_inb_mbox(mport, mbox); 109 + if (mport->ops->close_inb_mbox) { 110 + mport->ops->close_inb_mbox(mport, mbox); 114 111 115 - /* Release the mailbox resource */ 116 - return release_resource(mport->inb_msg[mbox].res); 112 + /* Release the mailbox resource */ 113 + return release_resource(mport->inb_msg[mbox].res); 114 + } else 115 + return -ENOSYS; 117 116 } 118 117 119 118 /** ··· 136 129 int entries, 137 130 void (*moutb) (struct rio_mport * mport, void *dev_id, int mbox, int slot)) 138 131 { 139 - int rc = 0; 132 + int rc = -ENOSYS; 133 + struct resource *res; 140 134 141 - struct resource *res = kmalloc(sizeof(struct resource), GFP_KERNEL); 135 + if (mport->ops->open_outb_mbox == NULL) 136 + goto out; 137 + 138 + res = kmalloc(sizeof(struct resource), GFP_KERNEL); 142 139 143 140 if (res) { 144 141 rio_init_mbox_res(res, mbox, mbox); ··· 160 149 /* Hook the inbound message callback */ 161 150 mport->outb_msg[mbox].mcback = moutb; 162 151 163 - rc = rio_open_outb_mbox(mport, dev_id, mbox, entries); 152 + rc = mport->ops->open_outb_mbox(mport, dev_id, mbox, entries); 164 153 } else 165 154 rc = -ENOMEM; 166 155 ··· 178 167 */ 179 168 int rio_release_outb_mbox(struct rio_mport *mport, int mbox) 180 169 { 181 - rio_close_outb_mbox(mport, mbox); 170 + if (mport->ops->close_outb_mbox) { 171 + mport->ops->close_outb_mbox(mport, mbox); 182 172 183 - /* Release the mailbox resource */ 184 - return release_resource(mport->outb_msg[mbox].res); 173 + /* Release the mailbox resource */ 174 + return release_resource(mport->outb_msg[mbox].res); 175 + } else 176 + return -ENOSYS; 185 177 } 186 178 187 179 /**
+18 -5
include/linux/rio.h
··· 241 241 struct rio_msg inb_msg[RIO_MAX_MBOX]; 242 242 struct rio_msg outb_msg[RIO_MAX_MBOX]; 243 243 int host_deviceid; /* Host device ID */ 244 - struct rio_ops *ops; /* maintenance transaction functions */ 244 + struct rio_ops *ops; /* low-level architecture-dependent routines */ 245 245 unsigned char id; /* port ID, unique among all ports */ 246 246 unsigned char index; /* port index, unique among all port 247 247 interfaces of the same type */ ··· 285 285 * @cwrite: Callback to perform network write of config space. 286 286 * @dsend: Callback to send a doorbell message. 287 287 * @pwenable: Callback to enable/disable port-write message handling. 288 + * @open_outb_mbox: Callback to initialize outbound mailbox. 289 + * @close_outb_mbox: Callback to shut down outbound mailbox. 290 + * @open_inb_mbox: Callback to initialize inbound mailbox. 291 + * @close_inb_mbox: Callback to shut down inbound mailbox. 292 + * @add_outb_message: Callback to add a message to an outbound mailbox queue. 293 + * @add_inb_buffer: Callback to add a buffer to an inbound mailbox queue. 294 + * @get_inb_message: Callback to get a message from an inbound mailbox queue. 288 295 */ 289 296 struct rio_ops { 290 297 int (*lcread) (struct rio_mport *mport, int index, u32 offset, int len, ··· 304 297 u8 hopcount, u32 offset, int len, u32 data); 305 298 int (*dsend) (struct rio_mport *mport, int index, u16 destid, u16 data); 306 299 int (*pwenable) (struct rio_mport *mport, int enable); 300 + int (*open_outb_mbox)(struct rio_mport *mport, void *dev_id, 301 + int mbox, int entries); 302 + void (*close_outb_mbox)(struct rio_mport *mport, int mbox); 303 + int (*open_inb_mbox)(struct rio_mport *mport, void *dev_id, 304 + int mbox, int entries); 305 + void (*close_inb_mbox)(struct rio_mport *mport, int mbox); 306 + int (*add_outb_message)(struct rio_mport *mport, struct rio_dev *rdev, 307 + int mbox, void *buffer, size_t len); 308 + int (*add_inb_buffer)(struct rio_mport *mport, int mbox, void *buf); 309 + void *(*get_inb_message)(struct rio_mport *mport, int mbox); 307 310 }; 308 311 309 312 #define RIO_RESOURCE_MEM 0x00000100 ··· 397 380 /* Architecture and hardware-specific functions */ 398 381 extern int rio_init_mports(void); 399 382 extern void rio_register_mport(struct rio_mport *); 400 - extern int rio_hw_add_outb_message(struct rio_mport *, struct rio_dev *, int, 401 - void *, size_t); 402 - extern int rio_hw_add_inb_buffer(struct rio_mport *, int, void *); 403 - extern void *rio_hw_get_inb_message(struct rio_mport *, int); 404 383 extern int rio_open_inb_mbox(struct rio_mport *, void *, int, int); 405 384 extern void rio_close_inb_mbox(struct rio_mport *, int); 406 385 extern int rio_open_outb_mbox(struct rio_mport *, void *, int, int);
+4 -3
include/linux/rio_drv.h
··· 317 317 struct rio_dev *rdev, int mbox, 318 318 void *buffer, size_t len) 319 319 { 320 - return rio_hw_add_outb_message(mport, rdev, mbox, buffer, len); 320 + return mport->ops->add_outb_message(mport, rdev, mbox, 321 + buffer, len); 321 322 } 322 323 323 324 extern int rio_request_inb_mbox(struct rio_mport *, void *, int, int, ··· 337 336 static inline int rio_add_inb_buffer(struct rio_mport *mport, int mbox, 338 337 void *buffer) 339 338 { 340 - return rio_hw_add_inb_buffer(mport, mbox, buffer); 339 + return mport->ops->add_inb_buffer(mport, mbox, buffer); 341 340 } 342 341 343 342 /** ··· 349 348 */ 350 349 static inline void *rio_get_inb_message(struct rio_mport *mport, int mbox) 351 350 { 352 - return rio_hw_get_inb_message(mport, mbox); 351 + return mport->ops->get_inb_message(mport, mbox); 353 352 } 354 353 355 354 /* Doorbell management */