rapidio: add common mapping APIs for RapidIO memory access
Subsystems (4)
PATCH 1/6 rapidio: add common mapping APIs for RapidIO memory access
Add the mapping functions used to support direct IO memory access of rapidIO.
--- drivers/rapidio/rio.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/rio.h | 25 ++++++++++++ include/linux/rio_drv.h | 24 +++++++++--- 3 files changed, 138 insertions(+), 6 deletions(-)
drivers/rapidio/rio.c +95 -0
@@ -2,6 +2,8 @@* RapidIO interconnect services * (RapidIO Interconnect Specification, http://www.rapidio.org) * +* Copyright (C) 2007-2009 Freescale Semiconductor, Inc. +* * Copyright 2005 MontaVista Software, Inc. * Matt Porter <[email protected]> *
@@ -24,11 +26,23 @@#include <linux/spinlock.h> #include <linux/slab.h> #include <linux/interrupt.h> +#include <linux/dma-mapping.h> +#include <linux/hardirq.h> #include "rio.h" static LIST_HEAD (rio_mports); +static DEFINE_SPINLOCK (rio_config_lock); + +struct resource rio_resource = { + .name ="RapidIO GSM" , + .start =0 , + .end =-1 , + .flags =IORESOURCE_MEM , +}; +EXPORT_SYMBOL (rio_resource); +/** * rio_local_get_device_id - Get the base/extended device id for a port * @port: RIO master port from which to get the deviceid
@@ -333,6 +347,87 @@ int rio_release_outb_dbell(struct rio_dev *rdev, struct resource *res) }/** +* rio_map_inb_region -- Mapping inbound memory region. +* @mport: Master port. +* @mem: Memory struction for mapping. +* @rflags: Flags for mapping. +* +* Return: 0 -- Success. +* +* This function will create the mapping from rio space to local mem. +*/ +int rio_map_inb_region (struct rio_mport *mport,struct resource *rio_res, +dma_addr_t local,u32 rflags) +{ +int rc =0 ; +unsigned long flags; + +if (!mport->mops) +return -1 ; +spin_lock_irqsave (&rio_config_lock, flags); + rc = mport->mops->map_inb (mport, local, rio_res->start, +resource_size (rio_res), rflags); +spin_unlock_irqrestore (&rio_config_lock, flags); +return rc; +} + +/** +* rio_map_outb_region -- Mapping outbound memory region. +* @mport: Master port. +* @tid: Target RapidIO device id. +* @mem: Memory struction for mapping. +* @rflags: Flags for mapping. +* +* Return: 0 -- Success. +* +* This function will create the mapping from local iomem to rio space. +*/ +int rio_map_outb_region (struct rio_mport *mport,u16 tid, +struct resource *rio_res,phys_addr_t lstart,u32 rflags) +{ +int rc =0 ; +unsigned long flags; + +if (!mport->mops) +return -1 ; +spin_lock_irqsave (&rio_config_lock, flags); + rc = mport->mops->map_outb (mport, lstart, rio_res->start, +resource_size (rio_res), tid, rflags); +spin_unlock_irqrestore (&rio_config_lock, flags); +return rc; +} + +/** +* rio_unmap_inb_region -- Unmap the inbound memory region +* @mport: Master port +* @mem: Memory struction for unmapping. +*/ +void rio_unmap_inb_region (struct rio_mport *mport,dma_addr_t lstart) +{ +unsigned long flags; +if (!mport->mops) +return ; +spin_lock_irqsave (&rio_config_lock, flags); + mport->mops->unmap_inb (mport, lstart); +spin_unlock_irqrestore (&rio_config_lock, flags); +} + +/** +* rio_unmap_outb_region -- Unmap the outbound memory region +* @mport: Master port +* @mem: Memory struction for unmapping. +*/ +void rio_unmap_outb_region (struct rio_mport *mport,phys_addr_t lstart) +{ +unsigned long flags; +if (!mport->mops) +return ; +spin_lock_irqsave (&rio_config_lock, flags); + mport->mops->unmap_outb (mport, lstart); +spin_unlock_irqrestore (&rio_config_lock, flags); +} + +/** * rio_mport_get_feature - query for devices' extended features * @port: Master port to issue transaction * @local: Indicate a local master port or remote device access
include/linux/rio.h +25 -0
@@ -176,6 +176,7 @@ struct rio_mport {struct rio_msg outb_msg[RIO_MAX_MBOX ];int host_deviceid;/* Host device ID */ struct rio_ops *ops;/* maintenance transaction functions */ +struct rio_mem_ops *mops;/* Memory functions */ unsigned char id;/* port ID, unique among all ports */ unsigned char index;/* port index, unique among all port interfaces of the same type */
@@ -185,6 +186,7 @@ struct rio_mport {*/ enum rio_phy_type phy_type;/* RapidIO phy type */ unsigned char name[40 ]; +struct device *dev;void *priv;/* Master port private data */ };
@@ -319,6 +321,29 @@ struct rio_route_ops { u16 table, u16 route_destid, u8 * route_port); }; +extern struct resource rio_resource; +#define request_rio_region (start, n, name, flag) \ + __request_region(&rio_resource, (start), (n), (name), (flag)) +#define release_rio_region (start, n) __release_region(&rio_resource, (start), (n)) + +/** +* Struct for RIO memory definition. +* @map_inb: The function for mapping inbound memory window. +* @map_outb: The function for mapping outbound memory window. +* @unmap_inb: The function for unmapping inbound memory window. +* @unmap_outb: The function for unmapping outbound memory window. +*/ +struct rio_mem_ops { +int (*map_inb) (struct rio_mport *,dma_addr_t lstart, +resource_size_t rstart, +resource_size_t size,u32 flags); +int (*map_outb) (struct rio_mport *,phys_addr_t lstart, +resource_size_t rstart, +resource_size_t size,u16 tid,u32 flags); +void (*unmap_inb) (struct rio_mport *,dma_addr_t lstart); +void (*unmap_outb) (struct rio_mport *,phys_addr_t lstart); +}; +/* Architecture and hardware-specific functions */ extern int rio_init_mports (void );extern void rio_register_mport (struct rio_mport *);
include/linux/rio_drv.h +18 -6
@@ -332,6 +332,16 @@ static inline void rio_init_dbell_res(struct resource *res, u16 start, u16 end) res->flags =RIO_RESOURCE_DOORBELL ; } +static inline void rio_init_io_res (struct resource *res,resource_size_t start, +resource_size_t size,const char *name,unsigned long flag) +{ +memset (res,0 ,sizeof (struct resource )); + res->start = start; + res->end = start + size -1 ; + res->name = name; + res->flags = flag; +} +/** * RIO_DEVICE - macro used to describe a specific RIO device * @dev: the 16 bit RIO device ID
@@ -406,12 +416,13 @@ extern int rio_release_inb_dbell(struct rio_mport *, 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 *); -/* Memory region management */ -int rio_claim_resource (struct rio_dev *,int ); -int rio_request_regions (struct rio_dev *,char *); -void rio_release_regions (struct rio_dev *); -int rio_request_region (struct rio_dev *,int ,char *); -void rio_release_region (struct rio_dev *,int ); +/* Memory low-level mapping functions */ +extern int rio_map_inb_region (struct rio_mport *,struct resource *, +dma_addr_t ,u32 ); +extern int rio_map_outb_region (struct rio_mport *,u16 ,struct resource *, +phys_addr_t ,u32 ); +extern void rio_unmap_inb_region (struct rio_mport *,dma_addr_t ); +extern void rio_unmap_outb_region (struct rio_mport *,phys_addr_t );/* LDM support */ int rio_register_driver (struct rio_driver *);
@@ -461,5 +472,6 @@ extern u16 rio_local_get_device_id(struct rio_mport *port);extern struct rio_dev *rio_get_device (u16 vid,u16 did,struct rio_dev *from);extern struct rio_dev *rio_get_asm (u16 vid,u16 did,u16 asm_vid,u16 asm_did,struct rio_dev *from); +extern u32 rio_get_mport_id (struct rio_mport *);#endif /* LINUX_RIO_DRV_H */
Signature · 1 line
1.5.4
PATCH 2/6 powerpc/fsl_rio: use LAW address from device tree
Instead of fixed address in old code.
--- arch/powerpc/sysdev/fsl_rio.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-)
arch/powerpc/sysdev/fsl_rio.c +7 -5
@@ -1077,8 +1077,9 @@ int fsl_rio_setup(struct of_device *dev)INIT_LIST_HEAD (&port->dbells); port->iores.start = law_start; - port->iores.end = law_start + law_size; + port->iores.end = law_start + law_size -1 ; port->iores.flags =IORESOURCE_MEM ; + port->iores.name ="rio_io_win" ; priv->bellirq =irq_of_parse_and_map (dev->node,2 ); priv->txirq =irq_of_parse_and_map (dev->node,3 );
@@ -1156,14 +1157,15 @@ int fsl_rio_setup(struct of_device *dev)out_be32 ((priv->regs_win +RIO_ISR_AACR ),RIO_ISR_AACR_AA );/* Configure maintenance transaction window */ -out_be32 (&priv->maint_atmu_regs->rowbar,0x000c0000 ); -out_be32 (&priv->maint_atmu_regs->rowar,0x80077015 ); +out_be32 (&priv->maint_atmu_regs->rowbar, law_start >>12 ); +out_be32 (&priv->maint_atmu_regs->rowar,0x80077015 );/* 4M */ priv->maint_win =ioremap (law_start,RIO_MAINT_WIN_SIZE );/* Configure outbound doorbell window */ -out_be32 (&priv->dbell_atmu_regs->rowbar,0x000c0400 ); -out_be32 (&priv->dbell_atmu_regs->rowar,0x8004200b ); +out_be32 (&priv->dbell_atmu_regs->rowbar, + (law_start +RIO_MAINT_WIN_SIZE ) >>12 ); +out_be32 (&priv->dbell_atmu_regs->rowar,0x8004200b );/* 4k */ fsl_rio_doorbell_init (port);return 0 ;
Signature · 1 line
1.5.4
PATCH 3/6 powerpc: add memory map support to Freescale RapidIO block
The RIO memory map functions are used to support direct IO memory access to RapidIO space. The patch adds its support for Freescale RapidIO block driver.
--- arch/powerpc/sysdev/fsl_rio.c | 217 ++++++++++++++++++++++++++++++++++++++++- 1 files changed, 215 insertions(+), 2 deletions(-)
arch/powerpc/sysdev/fsl_rio.c +215 -2
@@ -31,6 +31,9 @@#define IRQ_RIO_TX (m) (((struct rio_priv *)(m->priv))->txirq)#define IRQ_RIO_RX (m) (((struct rio_priv *)(m->priv))->rxirq) +#define IS_64BIT_DMA ((sizeof(dma_addr_t) == 8) ? 1 : 0) +#define IS_64BIT_PHYS ((sizeof(phys_addr_t) == 8) ? 1 : 0) +#define RIO_ATMU_REGS_OFFSET 0x10c00#define RIO_P_MSG_REGS_OFFSET 0x11000#define RIO_S_MSG_REGS_OFFSET 0x13000
@@ -40,6 +43,15 @@#define RIO_ISR_AACR_AA 0x1/* Accept All ID */ #define RIO_MAINT_WIN_SIZE 0x400000#define RIO_DBELL_WIN_SIZE 0x1000 +#define RIO_MAX_INB_ATMU 4 +#define RIO_MAX_OUTB_ATMU 8 +#define RIO_INB_ATMU_REGS_OFFSET 0x10de0 +#define RIO_ATMU_EN_MASK 0x80000000 + +#define RIO_NREAD 0x4 +#define RIO_NWRITE 0x4 +#define RIO_NWRITE_R 0x5 +#define RIO_NREAD_R 0x5#define RIO_MSG_OMR_MUI 0x00000002#define RIO_MSG_OSR_TE 0x00000080
@@ -83,6 +95,15 @@ struct rio_atmu_regs {u32 pad3[3 ]; }; +struct rio_inb_atmu_regs { +u32 riwtar; +u32 pad1; +u32 riwbar; +u32 pad2; +u32 riwar; +u32 pad3[3 ]; +}; +struct rio_msg_regs {u32 omr;u32 osr;
@@ -341,6 +362,188 @@ fsl_rio_config_write(struct rio_mport *mport, int index, u16 destid, }/** +* fsl_rio_map_inb_mem -- Mapping inbound memory region. +* @mport: RapidIO master port +* @lstart: Local memory space start address. +* @rstart: RapidIO space start address. +* @size: The mapping region size. +* @flags: Flags for mapping. 0 for using default flags. +* +* Return: 0 -- Success. +* +* This function will create the inbound mapping +* from rstart to lstart. +*/ +static int fsl_rio_map_inb_mem (struct rio_mport *mport,dma_addr_t lstart, +resource_size_t rstart,resource_size_t size,u32 flags) +{ +int i; +struct rio_priv *priv = mport->priv; +struct rio_inb_atmu_regs __iomem *inbatmu = (struct rio_inb_atmu_regs *) + (priv->regs_win +RIO_INB_ATMU_REGS_OFFSET ) -1 ; +int size_ffs; +resource_size_t align; + +if (flags ==0 ) + flags = (RIO_NREAD_R <<4 ) |RIO_NWRITE_R ; + + align = (size <0x1000 ) ?0x1000 :1 << (__ilog2 (size -1 ) +1 ); + +/* Align the size */ +if ((lstart + size) > (_ALIGN_DOWN (lstart, align) + align)) { + size_ffs =__ffs (_ALIGN_DOWN (lstart + size -1 , align)); + size =1 << (size_ffs + (((_ALIGN_DOWN (lstart,1 << size_ffs) + + (1 << size_ffs)) < (lstart + size)) ?1 :0 )); + }else + size = align; + +if ((lstart & (size -1 )) != (rstart & (size -1 ))) { +dev_err (mport->dev,"The local address 0x%llx can not be " +"aligned to the same size 0x%llx with the RapidIO " +"space address 0x%llx!\n" , (unsigned long long )lstart, + (unsigned long long )size, (unsigned long long )rstart); +return -EINVAL ; + } + +/* Search for free inbound ATMU */ +for (i =1 ; + (i <=RIO_MAX_INB_ATMU ) && (inbatmu->riwar &RIO_ATMU_EN_MASK ); + i++, inbatmu--) + ; + +if (i >RIO_MAX_INB_ATMU ) { +dev_err (mport->dev,"No free inbound ATMU!\n" ); +return -EBUSY ; + } +out_be32 (&inbatmu->riwtar, ((IS_64BIT_DMA ? (lstart >>32 ) + &0xf :0 ) <<20 ) | ((lstart >>12 ) &0xfffff )); +out_be32 (&inbatmu->riwbar, ((IS_64BIT_DMA ? (rstart >>32 ) + &0x3 :0 ) <<20 ) | ((rstart >>12 ) &0xfffff )); +out_be32 (&inbatmu->riwar,0x80000000 | (0xf <<20 ) + | ((flags &0xff ) <<12 ) + | (__ilog2 (size) -1 )); +return 0 ; +} + +/** +* fsl_rio_map_outb_mem -- Mapping outbound memory region. +* @mport: RapidIO master port +* @lstart: Local memory space start address. +* @rstart: RapidIO space start address. +* @size: The mapping region size. +* @tid: The target RapidIO device id. +* @flags: Flags for mapping. 0 for using default flags. +* +* Return: 0 -- Success. +* +* This function will create the outbound mapping +* from lstart to rstart. +*/ +static int fsl_rio_map_outb_mem (struct rio_mport *mport,phys_addr_t lstart, +resource_size_t rstart,resource_size_t size, +u16 tid,u32 flags) +{ +int i; +struct rio_priv *priv = mport->priv; +struct rio_atmu_regs __iomem *outbatmu = (struct rio_atmu_regs *) + (priv->regs_win +RIO_ATMU_REGS_OFFSET ) +1 ; +int size_ffs; +resource_size_t align; + +if (flags ==0 ) + flags = (RIO_NREAD <<4 ) |RIO_NWRITE_R ; + + align = (size <0x1000 ) ?0x1000 :1 << (__ilog2 (size -1 ) +1 ); + +/* Align the size */ +if ((lstart + size) > (_ALIGN_DOWN (lstart, align) + align)) { + size_ffs =__ffs (_ALIGN_DOWN (lstart + size -1 , align)); + size =1 << (size_ffs + (((_ALIGN_DOWN (lstart,1 << size_ffs) + + (1 << size_ffs)) < (lstart + size)) ?1 :0 )); + }else + size = align; + +if ((lstart & (size -1 )) != (rstart & (size -1 ))) { +dev_err (mport->dev,"The local address 0x%llx can not be " +"aligned to the same size 0x%llx with the RapidIO " +"space address 0x%llx!\n" , (unsigned long long )lstart, + (unsigned long long )size, (unsigned long long )rstart); +return -EINVAL ; + } + +/* Search for free outbound ATMU */ +for (i =1 ; + (i <=RIO_MAX_OUTB_ATMU ) && (outbatmu->rowar &RIO_ATMU_EN_MASK ); + i++, outbatmu++) + ; + +if (i >RIO_MAX_OUTB_ATMU ) { +dev_err (mport->dev,"No free outbound ATMU!\n" ); +return -EBUSY ; + } +out_be32 (&outbatmu->rowtar, ((tid &0x3ff ) <<22 ) + | ((IS_64BIT_PHYS ? (rstart >>32 ) &0x3 :0 ) <<20 ) + | ((rstart >>12 ) &0xfffff )); +if (mport->phy_type ==RIO_PHY_SERIAL ) +out_be32 (&outbatmu->rowtear, tid >>10 ); +out_be32 (&outbatmu->rowbar, ((IS_64BIT_PHYS ? + (lstart >>32 ) &0xf :0 ) <<20 ) + | ((lstart >>12 ) &0xfffff )); +out_be32 (&outbatmu->rowar,0x80000000 + | ((flags &0xff ) <<12 ) + | (__ilog2 (size) -1 )); +return 0 ; +} + +/** +* fsl_rio_unmap_inb_mem -- Unmapping inbound memory region. +* @mport: RapidIO master port +* @lstart: Local memory space start address. +*/ +static void fsl_rio_unmap_inb_mem (struct rio_mport *mport, +dma_addr_t lstart) +{ +int i; +struct rio_priv *priv = mport->priv; +struct rio_inb_atmu_regs __iomem *inbatmu = (struct rio_inb_atmu_regs *) + (priv->regs_win +RIO_INB_ATMU_REGS_OFFSET ) -1 ; + +/* Search for inbound ATMU */ +for (i =1 ; i <=RIO_MAX_INB_ATMU ; i++, inbatmu--) { +u32 tar = ((IS_64BIT_DMA ? (lstart >>32 ) &0xf :0 ) <<20 ) + | ((lstart >>12 ) &0xfffff ); +if (inbatmu->riwtar == tar) { +out_be32 (&inbatmu->riwar, ~(RIO_ATMU_EN_MASK )); +return ; + } + } +} + +/** +* fsl_rio_unmap_outb_mem -- Unmapping outbound memory region. +* @mport: RapidIO master port +* @lstart: Local memory space start address. +*/ +static void fsl_rio_unmap_outb_mem (struct rio_mport *mport, +phys_addr_t lstart) +{ +int i; +struct rio_priv *priv = mport->priv; +struct rio_atmu_regs __iomem *outbatmu = (struct rio_atmu_regs *) + (priv->regs_win +RIO_ATMU_REGS_OFFSET ) +1 ; + +/* Search for outbound ATMU */ +for (i =1 ; i <=RIO_MAX_OUTB_ATMU ; i++, outbatmu++) { +u32 bar = ((IS_64BIT_PHYS ? (lstart >>32 ) &0xf :0 ) <<20 ) + | ((lstart >>12 ) &0xfffff ); +if (outbatmu->rowbar == bar) { +out_be32 (&outbatmu->rowar, ~(RIO_ATMU_EN_MASK )); +return ; + } + } +} + +/** * rio_hw_add_outb_message - Add message to the MPC85xx outbound message queue * @mport: Master port with outbound message queue * @rdev: Target of outbound message
@@ -951,6 +1154,13 @@ static int fsl_rio_get_cmdline(char *s)__setup ("riohdid=" , fsl_rio_get_cmdline); +static struct rio_mem_ops fsl_mem_ops = { + .map_inb = fsl_rio_map_inb_mem, + .map_outb = fsl_rio_map_outb_mem, + .unmap_inb = fsl_rio_unmap_inb_mem, + .unmap_outb = fsl_rio_unmap_outb_mem, +}; +static inline void fsl_rio_info (struct device *dev,u32 ccsr) {const char *str;
@@ -1026,8 +1236,9 @@ int fsl_rio_setup(struct of_device *dev)return -EFAULT ; }dev_info (&dev->dev,"Of-device full name %s\n" , dev->node->full_name); -dev_info (&dev->dev,"Regs start 0x%08x size 0x%08x\n" , regs.start, - regs.end - regs.start +1 ); +dev_info (&dev->dev,"Regs start 0x%llx size 0x%llx\n" , + (unsigned long long )regs.start, + (unsigned long long )(regs.end - regs.start +1 )); dt_range =of_get_property (dev->node,"ranges" , &rlen);if (!dt_range) {
@@ -1067,6 +1278,7 @@ int fsl_rio_setup(struct of_device *dev) port =kzalloc (sizeof (struct rio_mport ),GFP_KERNEL ); port->id =0 ; port->index =0 ; + port->dev = &dev->dev; priv =kzalloc (sizeof (struct rio_priv ),GFP_KERNEL );if (!priv) {
@@ -1095,6 +1307,7 @@ int fsl_rio_setup(struct of_device *dev) priv->dev = &dev->dev; port->ops = ops; + port->mops = &fsl_mem_ops; port->host_deviceid =fsl_rio_get_hdid (port->id); port->priv = priv;
Signature · 1 line
1.5.4
PATCH 4/6 rionet: add memory access to simulated Ethernet over rapidio
Through the newly added IO memory access of RapidIO, sender can write directly to recipient's rx buffer, either by cpu or DMA engine.
--- drivers/net/Kconfig | 10 ++ drivers/net/rionet.c | 365 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 371 insertions(+), 4 deletions(-)
drivers/net/Kconfig +10 -0
@@ -2736,6 +2736,16 @@ config RIONET_RX_SIZE depends on RIONET default "128" +config RIONET_MEMMAP + bool "Use memory map instead of message" + depends on RIONET + default n + +config RIONET_DMA + bool "Use DMA for memory mapping data transfer" + depends on RIONET_MEMMAP && FSL_DMA + default y + config FDDI tristate "FDDI driver support" depends on (PCI || EISA || TC)
drivers/net/rionet.c +361 -4
499 lines not on this page · raw message
Signature · 1 line
1.5.4
PATCH 5/6 rio: warn_unused_result warnings fix
Adding failure path for the following two cases.
warning: ignoring return value of 'device_add', declared with attribute warn_unused_result
warning: ignoring return value of 'sysfs_create_bin_file', declared with attribute warn_unused_result
--- drivers/rapidio/rio-scan.c | 44 ++++++++++++++++++++++++++---------------- drivers/rapidio/rio-sysfs.c | 6 +++- 2 files changed, 31 insertions(+), 19 deletions(-)
drivers/rapidio/rio-scan.c +27 -17
@@ -263,15 +263,21 @@ static void rio_route_set_ops(struct rio_dev *rdev)* device to the RIO device list. Creates the generic sysfs nodes * for an RIO device. */ -static void __devinit rio_add_device (struct rio_dev *rdev) +static int __devinit rio_add_device (struct rio_dev *rdev) { -device_add (&rdev->dev); +int err; + + err =device_add (&rdev->dev); +if (err) +return err;spin_lock (&rio_global_list_lock);list_add_tail (&rdev->global_list, &rio_devices);spin_unlock (&rio_global_list_lock);rio_create_sysfs_dev_files (rdev); + +return 0 ; }/**
@@ -294,13 +300,14 @@ static struct rio_dev *rio_setup_device(struct rio_net *net, struct rio_mport *port, u16 destid, u8 hopcount, int do_enum) { + int ret = 0;struct rio_dev *rdev; -struct rio_switch *rswitch; +struct rio_switch *rswitch =NULL ;int result, rdid; rdev =kzalloc (sizeof (struct rio_dev ),GFP_KERNEL );if (!rdev) - goto out; +return NULL ; rdev->net = net; rio_mport_read_config_32(port, destid, hopcount, RIO_DEV_ID_CAR,
@@ -343,23 +350,16 @@ static struct rio_dev *rio_setup_device(struct rio_net *net,rio_mport_read_config_32 (port, destid, hopcount,RIO_SWP_INFO_CAR , &rdev->swpinfo); rswitch =kmalloc (sizeof (struct rio_switch ),GFP_KERNEL ); -if (!rswitch) { -kfree (rdev); - rdev =NULL ; - goto out; - } +if (!rswitch) + goto cleanup; rswitch->switchid = next_switchid; rswitch->hopcount = hopcount; rswitch->destid = destid; rswitch->route_table =kzalloc (sizeof (u8)*RIO_MAX_ROUTE_ENTRIES (port->sys_size),GFP_KERNEL ); -if (!rswitch->route_table) { -kfree (rdev); - rdev =NULL ; -kfree (rswitch); - goto out; - } +if (!rswitch->route_table) + goto cleanup;/* Initialize switch route table */ for (rdid =0 ; rdid <RIO_MAX_ROUTE_ENTRIES (port->sys_size); rdid++)
@@ -390,10 +390,20 @@ static struct rio_dev *rio_setup_device(struct rio_net *net,rio_init_dbell_res (&rdev->riores[RIO_DOORBELL_RESOURCE ],0 ,0xffff ); -rio_add_device (rdev); + ret =rio_add_device (rdev); +if (ret) + goto cleanup; - out:return rdev; + +cleanup: +if (rswitch) { +if (rswitch->route_table) +kfree (rswitch->route_table); +kfree (rswitch); + } +kfree (rdev); +return NULL ; }/**
drivers/rapidio/rio-sysfs.c +4 -2
@@ -214,9 +214,11 @@ static struct bin_attribute rio_config_attr = {*/ int rio_create_sysfs_dev_files (struct rio_dev *rdev) { -sysfs_create_bin_file (&rdev->dev.kobj, &rio_config_attr); +int err =0 ; -return 0 ; + err =sysfs_create_bin_file (&rdev->dev.kobj, &rio_config_attr); + +return err; }/**
Signature · 1 line
1.5.4
PATCH 6/6 rio: fix section mismatch
--- drivers/rapidio/rio-scan.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/rapidio/rio-scan.c +3 -3
@@ -296,7 +296,7 @@ static int __devinit rio_add_device(struct rio_dev *rdev)* to a RIO device on success or NULL on failure. * */ -static struct rio_dev *rio_setup_device (struct rio_net *net, +static struct rio_dev __devinit *rio_setup_device (struct rio_net *net,struct rio_mport *port,u16 destid,u8 hopcount,int do_enum) {
@@ -569,7 +569,7 @@ static void rio_net_add_mport(struct rio_net *net, struct rio_mport *port)* Recursively enumerates a RIO network. Transactions are sent via the * master port passed in @port. */ -static int rio_enum_peer (struct rio_net *net,struct rio_mport *port, +static int __devinit rio_enum_peer (struct rio_net *net,struct rio_mport *port,u8 hopcount) {int port_num;
@@ -728,7 +728,7 @@ static int rio_enum_complete(struct rio_mport *port)* Recursively discovers a RIO network. Transactions are sent via the * master port passed in @port. */ -static int +static int __devinit rio_disc_peer (struct rio_net *net,struct rio_mport *port,u16 destid,u8 hopcount) {
Signature · 1 line
1.5.4
Kumar Gala
AppliedRe: [PATCH 6/6] rio: fix section mismatch
Quoted 4 lines · Li Yang
Signed-off-by Li Yang <[email protected]>---
drivers/rapidio/rio-scan.c| 6 +++---1 files changed, 3 insertions(+), 3 deletions(-)
applied to next
- k
Re: [PATCH 5/6] rio: warn_unused_result warnings fix
In reply to Li Yangdrivers/rapidio/rio-scan.c static struct rio_dev *rio_setup_device(struct rio_net *net, · line 401
Quoted 2 lines · On Tue, 12 May 2009 16:36:02 +0800 Li Yang <[email protected]> wrote:
drivers/rapidio/rio-scan.c +2
-0+if (rswitch) { +if (rswitch->route_table)
this `if' is unneeded.
Quoted 3 lines
drivers/rapidio/rio-scan.c +3
-0+kfree (rswitch->route_table); +kfree (rswitch); + }
Re: [PATCH 5/6] rio: warn_unused_result warnings fix
In reply to Li YangQuoted 11 lines · Li Yang
Adding failure path for the following two cases.
warning: ignoring return value of '
device_add', declared with attributewarn_unused_result
warning: ignoring return value of 'sysfs_create_bin_file', declared with attributewarn_unused_resultSigned-off-by Li Yang <[email protected]>---
drivers/rapidio/rio-scan.c| 44 ++++++++++++++++++++++++++---------------- drivers/rapidio/rio-sysfs.c | 6 +++- 2 files changed, 31 insertions(+), 19 deletions(-)
applied w/fixup based on Andrew's comments.
- k
Re: [PATCH 4/6] rionet: add memory access to simulated Ethernet over rapidio
In reply to Li Yangdrivers/net/rionet.c MODULE_LICENSE("GPL"); · line 67
Quoted 11 lines · On Tue, 12 May 2009 16:36:01 +0800 Li Yang <[email protected]> wrote:
Through the newly added IO memory access of RapidIO, sender can write directly to recipient's rx buffer, either by cpu or DMA engine.
...
drivers/net/rionet.c +6
-0+/* Definitions for rionet memory map driver */ +#define RIONET_DRVID 0x101 +#define RIONET_MAX_SK_DATA_SIZE 0x1000 +#define RIONET_MEM_RIO_BASE 0x10000000 +#define RIONET_TX_RX_BUFF_SIZE (0x1000 * (128 + 128)) +#define RIONET_QUEUE_NEXT (x) (((x) < 127) ? ((x) + 1) : 0)
References its arg multiple times, hence is buggy or inefficient when passed an expression with side-effects.
static inline int rionet_queue_next(int x)
would be better. Assuming that some sane identifier is used instead of "x".
Quoted 1 line
+#define
RIONET_QUEUE_INC(x)(x =RIONET_QUEUE_NEXT(x))
It's pretty ugly to hide an assignment inside a macro like this. Why not do
foo = rionet_queue_inc(foo);
at the callsites? It makes it much clearer for the reader.
drivers/net/rionet.c static void rionet_rx_fill(struct net_device *ndev, int end) · line 216
Quoted 12 lines
...
drivers/net/rionet.c +9
-0+#ifdef CONFIG_RIONET_MEMMAP +static int rio_send_mem (struct sk_buff *skb, +struct net_device *ndev,struct rio_dev *rdev) +{ +struct rionet_private *rnet =netdev_priv (ndev); +int enqueue, dequeue; + +if (!rdev) +return -EFAULT ;
Is that an appropriate error code?
Quoted 3 lines
...
Re: [PATCH 3/6] powerpc: add memory map support to Freescale RapidIO block
In reply to Li Yangarch/powerpc/sysdev/fsl_rio.c fsl_rio_config_write(struct rio_mport *mport, int index, u16 destid, · line 393
Quoted 4 lines · On Tue, 12 May 2009 16:36:00 +0800 Li Yang <[email protected]> wrote:
arch/powerpc/sysdev/fsl_rio.c +4
-0+ align = (size <0x1000 ) ?0x1000 :1 << (__ilog2 (size -1 ) +1 ); + +/* Align the size */ +if ((lstart + size) > (_ALIGN_DOWN (lstart, align) + align)) {
__ilog2() and _ALIGN_DOWN() are powerpc-specific functions. It would be preferable to use more general helpers if possible. ALIGN() and ilog2() might suit here.
Re: [PATCH 3/6] powerpc: add memory map support to Freescale RapidIO block
Quoted 11 lines · Andrew Morton
Quoted 4 lines · On Tue, 12 May 2009 16:36:00 +0800 Li Yang <[email protected]> wrote:
+ align = (size <
0x1000) ?0x1000: 1 << (__ilog2(size - 1)+ 1); +
+ /* Align the size */
+ if ((lstart + size) > (_ALIGN_DOWN(lstart, align)+ align)) {
__ilog2()and_ALIGN_DOWN()are powerpc-specific functions. It would be preferable to use more general helpers if possible. ALIGN() andilog2()might suit here.
Will change to use ilog2().
_ALIGN_DOWN() gets a lower aligned address while ALIGN() gets a higher address. It seems that we don't have a general helper to do the same.
- Leo
Kumar Gala
AppliedRe: [PATCH 2/6] powerpc/fsl_rio: use LAW address from device tree
In reply to Li YangQuoted 6 lines · Li Yang
Instead of fixed address in old code.
Signed-off-by Li Yang <[email protected]>---
arch/powerpc/sysdev/fsl_rio.c| 12 +++++++-----1 files changed, 7 insertions(+), 5 deletions(-)
applied to next
- k
Quoted 5 lines · Li Yang
Add the mapping functions used to support direct IO memory access of rapidIO.
Signed-off-by Zhang Wei <[email protected]>Signed-off-by Li Yang <[email protected]>
Use inbnd/outbnd instead of inb/outb which make one think of byte level io accessors.
As I look at this I don't think this is the correct API. I think we should be using the DMA mapping API to hide these details. The concept of mapping like this seems to be more a function of FSL's Address translation/mapping unit (ATMU) than anything specific to the RIO bus standard.
Quoted 6 lines
---
drivers/rapidio/rio.c| 95 ++++++++++++++++++++++++++++++++++++++
+++++++++include/linux/rio.h | 25 ++++++++++++ include/linux/rio_drv.h | 24 +++++++++--- 3 files changed, 138 insertions(+), 6 deletions(-)
- k
Quoted 8 lines · Li Yang
Quoted 6 lines
Add the mapping functions used to support direct IO memory access of rapidIO.
Signed-off-by Zhang Wei <[email protected]>Signed-off-by Li Yang <[email protected]>
Quoted 8 lines
Use inbnd/outbnd instead of inb/outb which make one think of byte level io accessors.
As I look at this I don't think this is the correct API. I think we should be using the DMA mapping API to hide these details. The concept of mapping like this seems to be more a function of FSL's Address translation/mapping unit (ATMU) than anything specific to the RIO bus standard.
This is a separate RIO block level ATMU. Although it looks like the system level ATMU, system ATMU doesn't have the knowledge of rapidIO target device ID. The mapping need to be dynamic, as it's easy to have more RIO devices than the outbound windows.
- Leo
Quoted 17 lines · On Jun 11, 2009, at 4:47 AM, Li Yang-R58472 wrote:
Quoted 8 lines · Li Yang
Quoted 6 lines
Add the mapping functions used to support direct IO memory access of rapidIO.
Signed-off-by Zhang Wei <[email protected]>Signed-off-by Li Yang <[email protected]>Quoted 8 lines
Use inbnd/outbnd instead of inb/outb which make one think of byte level io accessors.
As I look at this I don't think this is the correct API. I think we should be using the DMA mapping API to hide these details. The concept of mapping like this seems to be more a function of FSL's Address translation/mapping unit (ATMU) than anything specific to the RIO bus standard.
Quoted 4 lines
This is a separate RIO block level ATMU. Although it looks like the system level ATMU, system ATMU doesn't have the knowledge of rapidIO target device ID. The mapping need to be dynamic, as it's easy to have more RIO devices than the outbound windows.
I understand that. What I'm saying is the RIO block level ATMU is a Freescale specific detail and not part of any standard RIO bus programming model. We have mapping APIs that we can connect to for this via the DMA API layer.
- k
Quoted 25 lines · Kumar Gala
Quoted 17 lines · On Jun 11, 2009, at 4:47 AM, Li Yang-R58472 wrote:
Quoted 8 lines · Li Yang
Quoted 6 lines
Add the mapping functions used to support direct IO memory access of rapidIO.
Signed-off-by Zhang Wei <[email protected]>Signed-off-by Li Yang <[email protected]>Quoted 8 lines
Use inbnd/outbnd instead of inb/outb which make one think of byte level io accessors.
As I look at this I don't think this is the correct API. I think we should be using the DMA mapping API to hide these details. The concept of mapping like this seems to be more a function of FSL's Address translation/mapping unit (ATMU) than anything specific to the RIO bus standard.
Quoted 4 lines
This is a separate RIO block level ATMU. Although it looks like the system level ATMU, system ATMU doesn't have the knowledge of rapidIO target device ID. The mapping need to be dynamic, as it's easy to have more RIO devices than the outbound windows.
Quoted 4 lines
I understand that. What I'm saying is the RIO block level ATMU is a Freescale specific detail and not part of any standard RIO bus programming model. We have mapping APIs that we can connect to for this via the DMA API layer.
Ok, I see your point now. Do you mean dma_map_*() for DMA API layer? But in my understanding the current dma_map_*() APIs are preparing local memory for device to access which is similar to the inbound case. Is it suitable to also use them for mapping device's space for CPU access? Can you give an example of using this API for Address Translation and Mapping purpose?
- Leo
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
Quoted 31 lines · Li Yang
Quoted 25 lines · Kumar Gala
Quoted 17 lines · On Jun 11, 2009, at 4:47 AM, Li Yang-R58472 wrote:
Quoted 8 lines · Li Yang
Quoted 6 lines
Add the mapping functions used to support direct IO memory access of rapidIO.
Signed-off-by Zhang Wei <[email protected]>Signed-off-by Li Yang <[email protected]>Quoted 8 lines
Use inbnd/outbnd instead of inb/outb which make one think of byte level io accessors.
As I look at this I don't think this is the correct API. I think we should be using the DMA mapping API to hide these details. The concept of mapping like this seems to be more a function of FSL's Address translation/mapping unit (ATMU) than anything specific to the RIO bus standard.
Quoted 4 lines
This is a separate RIO block level ATMU. Although it looks like the system level ATMU, system ATMU doesn't have the knowledge of rapidIO target device ID. The mapping need to be dynamic, as it's easy to have more RIO devices than the outbound windows.
Quoted 4 lines
I understand that. What I'm saying is the RIO block level ATMU is a Freescale specific detail and not part of any standard RIO bus programming model. We have mapping APIs that we can connect to for this via the DMA API layer.
Quoted 6 lines
Ok, I see your point now. Do you mean dma_map_*() for DMA API layer? But in my understanding the current dma_map_*() APIs are preparing local memory for device to access which is similar to the inbound case. Is it suitable to also use them for mapping device's space for CPU access? Can you give an example of using this API for Address Translation and Mapping purpose?
Yes, I meant the dma_map_*() API. Any system with a true IOMMU uses the dma_map_ layer as the way to do address translation.
- k
Quoted 44 lines · Kumar Gala
Quoted 34 lines · Li Yang
Quoted 25 lines · Kumar Gala
Quoted 17 lines · On Jun 11, 2009, at 4:47 AM, Li Yang-R58472 wrote:
Quoted 8 lines · Li Yang
Quoted 6 lines
Add the mapping functions used to support direct IO memory access of rapidIO.
Signed-off-by Zhang Wei <[email protected]>Signed-off-by Li Yang <[email protected]>Quoted 8 lines
Use inbnd/outbnd instead of inb/outb which make one think of byte level io accessors.
As I look at this I don't think this is the correct API. I think we should be using the DMA mapping API to hide these details. The concept of mapping like this seems to be more a function of FSL's Address translation/mapping unit (ATMU) than anything specific to the RIO bus standard.
Quoted 4 lines
This is a separate RIO block level ATMU. Although it looks like the system level ATMU, system ATMU doesn't have the knowledge of rapidIO target device ID. The mapping need to be dynamic, as it's easy to have more RIO devices than the outbound windows.
Quoted 6 lines
I understand that. What I'm saying is the RIO block level ATMU is a Freescale specific detail and not part of any standard RIO bus programming
model. We have mapping APIs that we can connect to for this via the DMA API
layer.Quoted 6 lines
Ok, I see your point now. Do you mean dma_map_*() for DMA API layer? But in my understanding the current dma_map_*() APIs are preparing local memory for device to access which is similar to the inbound case. Is it suitable to also use them for mapping device's space for CPU access? Can you give an example of using this API for Address Translation and Mapping purpose?
Quoted 2 lines
Yes, I meant the dma_map_*() API. Any system with a true IOMMU uses the
dma_map_layer as the way to do address translation.
IOMMU case is not very similar to the RapidIO scenario. RapidIO mapping is more like PCI address space mapping.
To be specific, the DMA API return dma_addr_t not the rapidIO address type. And they can only handle inbound mapping not both ways. I don't think the DMA API is competent enough to be used here for RIO mapping. Unless we have a more universal mapping API, it can be justified to create its own API.
- Leo