Skip to contentSkip to conversation

Add PRUSS UIO driver support

PATCH Superseded Pratheesh Gangadhar 4 participants 10 messages Feb 23, 2011 – Feb 24, 2011

Subsystems (4)

v3 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add PRUSS UIO driver support

This patch series add support for PRUSS (Programmable Real-time Unit Sub System) UIO driver in Texas Instruments DA850, AM18xx and OMAPL1-38 processors. PRUSS is programmable RISC core which can be used to implement Soft IPs (eg:- DMA, CAN, UART,SmartCard) and Industrial communications data link layers (eg:- PROFIBUS). UIO driver exposes PRUSS resources like memory and interrupts to user space application.PRUSS UIO application API can be used to control PRUs
in PRUSS, setup PRU INTC, load firmware to PRUs and implement IPC between Host processor and PRUs. More information on PRUSS and UIO linux user space API
available in the links below

http://processors.wiki.ti.com/index.php/Programmable_Realtime_Unit_Subsystem
http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader
http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide

Pratheesh Gangadhar (2):
PRUSS UIO driver support
Defines DA850/AM18xx/OMAPL1-38 SOC resources used by PRUSS UIO driver

 arch/arm/mach-davinci/board-da850-evm.c    |    4 +
 arch/arm/mach-davinci/da850.c              |   35 +++++
 arch/arm/mach-davinci/devices-da8xx.c      |   73 +++++++++
 arch/arm/mach-davinci/include/mach/da8xx.h |    3 +
 drivers/uio/Kconfig                        |   17 ++
 drivers/uio/Makefile                       |    1 +
 drivers/uio/uio_pruss.c                    |  223 ++++++++++++++++++++++++++++
 7 files changed, 356 insertions(+), 0 deletions(-)
 create mode 100644 drivers/uio/uio_pruss.c
#1 lore raw

PATCH v3 1/2 PRUSS UIO driver support

This patch implements PRUSS (Programmable Real-time Unit Sub System) UIO driver which exports SOC resources associated with PRUSS like I/O, memories and IRQs to user space. PRUSS is dual 32-bit RISC processors which is efficient in performing embedded tasks that require manipulation of packed memory mapped data structures and efficient in handling system events that have tight real time constraints. This driver is currently supported on Texas Instruments DA850, AM18xx and OMAPL1-38 devices.
For example, PRUSS runs firmware for real-time critical industrial communication data link layer and communicates with application stack running in user space via shared memory and IRQs.

---
 drivers/uio/Kconfig     |   17 ++++
 drivers/uio/Makefile    |    1 +
 drivers/uio/uio_pruss.c |  223 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 241 insertions(+), 0 deletions(-)
 create mode 100644 drivers/uio/uio_pruss.c
drivers/uio/Kconfig +17 -0
index bb44079..6f3ea9b 100644
@@ -94,4 +94,21 @@ config UIO_NETX
 	  To compile this driver as a module, choose M here; the module
 	  will be called uio_netx.
 
+config UIO_PRUSS
+	tristate "Texas Instruments PRUSS driver"
+	depends on ARCH_DAVINCI_DA850
+	help
+	  PRUSS driver for OMAPL138/DA850/AM18XX devices
+	  PRUSS driver requires user space components, examples and user space
+	  driver is available from below SVN repo - you may use anonymous login
+
+	  https://gforge.ti.com/gf/project/pru_sw/
+
+	  More info on API is available at below wiki
+
+	  http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called uio_pruss.
+
 endif
drivers/uio/Makefile +1 -0
index 18fd818..d4dd9a5 100644
@@ -6,3 +6,4 @@ obj-$(CONFIG_UIO_AEC)	+= uio_aec.o
 obj-$(CONFIG_UIO_SERCOS3)	+= uio_sercos3.o
 obj-$(CONFIG_UIO_PCI_GENERIC)	+= uio_pci_generic.o
 obj-$(CONFIG_UIO_NETX)	+= uio_netx.o
+obj-$(CONFIG_UIO_PRUSS)         += uio_pruss.o
drivers/uio/uio_pruss.c new file +223 -0

223 lines not on this page · raw message

Signature · 1 line
1.6.0.6
#2 lore raw

PATCH v3 2/2 Defines DA850/AM18xx/OMAPL1-38 SOC resources used by PRUSS UIO driver

This patch defines PRUSS, ECAP clocks, memory and IRQ resources used by PRUSS UIO driver in DA850/AM18xx/OMAPL1-38 devices. UIO driver exports 64K I/O region of PRUSS, 128KB L3 RAM and 256KB DDR buffer to user space. PRUSS has 8 host event interrupt lines mapped to IRQ_DA8XX_EVTOUT0..7 of ARM9 INTC.These in conjunction with shared memory can be used to implement IPC between ARM9 and PRUSS.

---
 arch/arm/mach-davinci/board-da850-evm.c    |    4 ++
 arch/arm/mach-davinci/da850.c              |   35 +++++++++++++
 arch/arm/mach-davinci/devices-da8xx.c      |   73 ++++++++++++++++++++++++++++
 arch/arm/mach-davinci/include/mach/da8xx.h |    3 +
 4 files changed, 115 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/board-da850-evm.c +4 -0
index 11f986b..bd85aa3 100644
@@ -1077,6 +1077,10 @@ static __init void da850_evm_init(void)
 		pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
 				ret);
 
+	ret = da8xx_register_pruss();
+	if (ret)
+		pr_warning("da850_evm_init: pruss registration failed: %d\n",
+				ret);
 
 	ret = da8xx_register_watchdog();
 	if (ret)
arch/arm/mach-davinci/da850.c +35 -0
index 3443d97..0096d4f 100644
@@ -238,6 +238,13 @@ static struct clk tptc2_clk = {
 	.flags		= ALWAYS_ENABLED,
 };
 
+static struct clk pruss_clk = {
+	.name		= "pruss",
+	.parent		= &pll0_sysclk2,
+	.lpsc		= DA8XX_LPSC0_DMAX,
+	.flags		= ALWAYS_ENABLED,
+};
+
 static struct clk uart0_clk = {
 	.name		= "uart0",
 	.parent		= &pll0_sysclk2,
@@ -359,6 +366,30 @@ static struct clk usb20_clk = {
 	.gpsc		= 1,
 };
 
+static struct clk ecap0_clk = {
+	.name		= "ecap0",
+	.parent		= &pll0_sysclk2,
+	.lpsc		= DA8XX_LPSC1_ECAP,
+	.flags		= DA850_CLK_ASYNC3,
+	.gpsc		= 1,
+};
+
+static struct clk ecap1_clk = {
+	.name		= "ecap1",
+	.parent		= &pll0_sysclk2,
+	.lpsc		= DA8XX_LPSC1_ECAP,
+	.flags		= DA850_CLK_ASYNC3,
+	.gpsc		= 1,
+};
+
+static struct clk ecap2_clk = {
+	.name		= "ecap2",
+	.parent		= &pll0_sysclk2,
+	.lpsc		= DA8XX_LPSC1_ECAP,
+	.flags		= DA850_CLK_ASYNC3,
+	.gpsc		= 1,
+};
+
 static struct clk_lookup da850_clks[] = {
 	CLK(NULL,		"ref",		&ref_clk),
 	CLK(NULL,		"pll0",		&pll0_clk),
@@ -386,6 +417,7 @@ static struct clk_lookup da850_clks[] = {
 	CLK(NULL,		"tptc1",	&tptc1_clk),
 	CLK(NULL,		"tpcc1",	&tpcc1_clk),
 	CLK(NULL,		"tptc2",	&tptc2_clk),
+	CLK(NULL,		"pruss",	&pruss_clk),
 	CLK(NULL,		"uart0",	&uart0_clk),
 	CLK(NULL,		"uart1",	&uart1_clk),
 	CLK(NULL,		"uart2",	&uart2_clk),
@@ -403,6 +435,9 @@ static struct clk_lookup da850_clks[] = {
 	CLK(NULL,		"aemif",	&aemif_clk),
 	CLK(NULL,		"usb11",	&usb11_clk),
 	CLK(NULL,		"usb20",	&usb20_clk),
+	CLK(NULL,		"ecap0",	&ecap0_clk),
+	CLK(NULL,		"ecap1",	&ecap1_clk),
+	CLK(NULL,		"ecap2",	&ecap2_clk),
 	CLK(NULL,		NULL,		NULL),
 };
 
arch/arm/mach-davinci/devices-da8xx.c +73 -0

76 lines not on this page · raw message

arch/arm/mach-davinci/include/mach/da8xx.h +3 -0
index cfcb223..3ed6ee0 100644
@@ -60,6 +60,7 @@ extern unsigned int da850_max_speed;
 #define DA8XX_PLL0_BASE		0x01c11000
 #define DA8XX_TIMER64P0_BASE	0x01c20000
 #define DA8XX_TIMER64P1_BASE	0x01c21000
+#define DA8XX_PRUSS_BASE	0x01c30000
 #define DA8XX_GPIO_BASE		0x01e26000
 #define DA8XX_PSC1_BASE		0x01e27000
 #define DA8XX_LCD_CNTRL_BASE	0x01e13000
@@ -68,6 +69,7 @@ extern unsigned int da850_max_speed;
 #define DA8XX_AEMIF_CS2_BASE	0x60000000
 #define DA8XX_AEMIF_CS3_BASE	0x62000000
 #define DA8XX_AEMIF_CTL_BASE	0x68000000
+#define DA8XX_L3RAM_BASE	0x80000000
 #define DA8XX_DDR2_CTL_BASE	0xb0000000
 #define DA8XX_ARM_RAM_BASE	0xffff0000
 
@@ -90,6 +92,7 @@ int da850_register_cpufreq(char *async_clk);
 int da8xx_register_cpuidle(void);
 void __iomem * __init da8xx_get_mem_ctlr(void);
 int da850_register_pm(struct platform_device *pdev);
+int da8xx_register_pruss(void);
 
 extern struct platform_device da8xx_serial_device;
 extern struct emac_platform_data da8xx_emac_pdata;
Signature · 1 line
1.6.0.6
#3 lore raw

Re: [PATCH v3 1/2] PRUSS UIO driver support

In reply to Pratheesh Gangadhar
Quoted 20 lines · Pratheesh Gangadhar

This patch implements PRUSS (Programmable Real-time Unit Sub System) UIO driver which exports SOC resources associated with PRUSS like I/O, memories and IRQs to user space. PRUSS is dual 32-bit RISC processors which is efficient in performing embedded tasks that require manipulation of packed memory mapped data structures and efficient in handling system events that have tight real time constraints. This driver is currently supported on Texas Instruments DA850, AM18xx and OMAPL1-38 devices.
For example, PRUSS runs firmware for real-time critical industrial communication data link layer and communicates with application stack running in user space via shared memory and IRQs.

---
 drivers/uio/Kconfig     |   17 ++++
 drivers/uio/Makefile    |    1 +
 drivers/uio/uio_pruss.c |  223 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 241 insertions(+), 0 deletions(-)
 create mode 100644 drivers/uio/uio_pruss.c

[...]

Quoted 8 lines
drivers/uio/uio_pruss.c new file +8 -0
+
+static int __devinit pruss_probe(struct platform_device *dev)
+{
+	int ret = -ENODEV, count = 0;
+	struct resource *regs_prussio, *regs_l3ram, *regs_ddr;
+	struct uio_info *p;
+
+	info = kzalloc(sizeof(struct uio_info) * MAX_PRUSS_EVTOUT_INSTANCE,

drivers/uio/uio_pruss.c line 107

Quoted 10 lines
drivers/uio/uio_pruss.c new file +10 -0
+		       GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
+	/* Power on PRU in case its not done as part of boot-loader */
+	pruss_clk = clk_get(&dev->dev, "pruss");
+	if (IS_ERR(pruss_clk)) {
+		dev_err(&dev->dev, "Failed to get clock\n");
+		ret = PTR_ERR(pruss_clk);
+		return ret;

You leak memory here. What about freeing "info"?

drivers/uio/uio_pruss.c line 110

Quoted 3 lines
drivers/uio/uio_pruss.c new file +3 -0
+	} else {
+		clk_enable(pruss_clk);
+	}

Thanks,
Hans

#4 lore raw

RE: [PATCH v3 1/2] PRUSS UIO driver support

Quoted 48 lines

-----Original Message-----
From: Hans J. Koch [mailto:hjk at hansjkoch.de]
Sent: Wednesday, February 23, 2011 11:07 PM
To: TK, Pratheesh Gangadhar
Cc: davinci-linux-open-source at linux.davincidsp.com; hjk at hansjkoch.de; gregkh at suse.de; Chatterjee, Amit; linux-kernel at vger.kernel.org; linux-arm- kernel at lists.infradead.org
Subject: Re: [PATCH v3 1/2] PRUSS UIO driver support

Quoted 12 lines · Pratheesh Gangadhar

This patch implements PRUSS (Programmable Real-time Unit Sub System) UIO driver which exports SOC resources associated with PRUSS like I/O, memories and IRQs to user space. PRUSS is dual 32-bit RISC processors which is efficient in performing embedded tasks that require manipulation of packed memory mapped data structures and efficient in handling system events that have tight real time constraints. This driver is currently supported on Texas Instruments DA850, AM18xx and OMAPL1-38 devices.
For example, PRUSS runs firmware for real-time critical industrial communication data link layer and communicates with application stack running in user space via shared memory and IRQs.

Quoted 5 lines
---
 drivers/uio/Kconfig     |   17 ++++
 drivers/uio/Makefile    |    1 +
 drivers/uio/uio_pruss.c |  223

+++++++++++++++++++++++++++++++++++++++++++++++

Quoted 3 lines
 3 files changed, 241 insertions(+), 0 deletions(-)
 create mode 100644 drivers/uio/uio_pruss.c

[...]

Quoted 12 lines
drivers/uio/uio_pruss.c new file +12 -0
+
+static int __devinit pruss_probe(struct platform_device *dev)
+{
+	int ret = -ENODEV, count = 0;
+	struct resource *regs_prussio, *regs_l3ram, *regs_ddr;
+	struct uio_info *p;
+
+	info = kzalloc(sizeof(struct uio_info) * MAX_PRUSS_EVTOUT_INSTANCE,
+		       GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
Quoted 8 lines

drivers/uio/uio_pruss.c line 107

Quoted 6 lines
drivers/uio/uio_pruss.c new file +6 -0
+	/* Power on PRU in case its not done as part of boot-loader */
+	pruss_clk = clk_get(&dev->dev, "pruss");
+	if (IS_ERR(pruss_clk)) {
+		dev_err(&dev->dev, "Failed to get clock\n");
+		ret = PTR_ERR(pruss_clk);
+		return ret;

You leak memory here. What about freeing "info"?

Ok. Will fix.

Thanks,
Pratheesh

#5 lore raw

Re: [PATCH v3 1/2] PRUSS UIO driver support

In reply to Pratheesh Gangadhar

On Wed, 23 Feb 2011, Pratheesh Gangadhar wrote:

Is it actually too much of an hassle to cc the people who spent their time to review previous versions of your patch ?

drivers/uio/uio_pruss.c line 53

Quoted 3 lines
drivers/uio/uio_pruss.c new file +3 -0
+struct clk *pruss_clk;
+struct uio_info *info;
+void *ddr_virt_addr = NULL, *prussio_virt_addr = NULL;

Grrr. We do not initialize with NULL.

Quoted 1 line

+dma_addr_t ddr_phy_addr;

Also all of these want to be static.

drivers/uio/uio_pruss.c line 66

Quoted 11 lines
drivers/uio/uio_pruss.c new file +11 -0
+static irqreturn_t pruss_handler(int irq, struct uio_info *dev_info)
+{
+	void __iomem *base = dev_info->mem[0].internal_addr;
+	void __iomem *intren_reg = base + PINTC_HIER;
+	void __iomem *intrstat_reg = base + PINTC_HIPIR + ((irq - 1) << 2);
+	int intren_regval = ioread32(intren_reg), intr_mask = (1 << (irq - 1));
+
+	/* Is interrupt enabled and active ? */
+	if (!(intren_regval & intr_mask)
+	    && (ioread32(intrstat_reg) & PINTC_HIPIR_NO_PEND_MASK))
+		return IRQ_NONE;

You could avoid all these ugly line breaks by chosing sensible short names for variables and defines.

drivers/uio/uio_pruss.c line 76

Quoted 9 lines
drivers/uio/uio_pruss.c new file +9 -0
+	/* Disable interrupt */
+	iowrite32((intren_regval & ~intr_mask), intren_reg);
+	return IRQ_HANDLED;
+}
+
+static void pruss_cleanup(struct platform_device *dev, struct uio_info *info)
+{
+	int count;
+	struct uio_info *p;

Nit: I prefer the longer declarations above the shorter ones. It's easier to parse, but that's really my personal preference.

	struct uio_info *p;
	int count;

Compare and contrast it and decide yourself.

drivers/uio/uio_pruss.c line 79

Quoted 3 lines
drivers/uio/uio_pruss.c new file +3 -0
+
+	for (count = 0, p = info; count < MAX_PRUSS_EVTOUT_INSTANCE;
+	     count++, p++) {

Aside of making that constant shorter, you could assign info to p in the variable declaration already. So avoid that line break.

drivers/uio/uio_pruss.c line 85

Quoted 6 lines
drivers/uio/uio_pruss.c new file +6 -0
+		uio_unregister_device(p);
+		kfree(p->name);
+	}
+	iounmap(prussio_virt_addr);
+	dma_free_coherent(&dev->dev, info[0].mem[2].size,
+			  info[0].mem[2].internal_addr, info[0].mem[2].addr);

You sure, that iounmap and dma_free_coherent are too happy about being called with NULL pointers?

Quoted 12 lines
drivers/uio/uio_pruss.c new file +12 -0
+
+	kfree(info);
+	clk_put(pruss_clk);
+}
+
+static int __devinit pruss_probe(struct platform_device *dev)
+{
+	int ret = -ENODEV, count = 0;
+	struct resource *regs_prussio, *regs_l3ram, *regs_ddr;
+	struct uio_info *p;
+
+	info = kzalloc(sizeof(struct uio_info) * MAX_PRUSS_EVTOUT_INSTANCE,

drivers/uio/uio_pruss.c line 107

Quoted 10 lines
drivers/uio/uio_pruss.c new file +10 -0
+		       GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
+	/* Power on PRU in case its not done as part of boot-loader */
+	pruss_clk = clk_get(&dev->dev, "pruss");
+	if (IS_ERR(pruss_clk)) {
+		dev_err(&dev->dev, "Failed to get clock\n");
+		ret = PTR_ERR(pruss_clk);
+		return ret;

Memory leak.

Quoted 28 lines
drivers/uio/uio_pruss.c new file +28 -0
+	} else {
+		clk_enable(pruss_clk);
+	}
+
+	regs_prussio = platform_get_resource(dev, IORESOURCE_MEM, 0);
+	if (!regs_prussio) {
+		dev_err(&dev->dev, "No PRUSS I/O resource specified\n");
+		goto out_free;
+	}
+
+	regs_l3ram = platform_get_resource(dev, IORESOURCE_MEM, 1);
+	if (!regs_l3ram) {
+		dev_err(&dev->dev, "No L3 RAM resource specified\n");
+		goto out_free;
+	}
+
+	regs_ddr = platform_get_resource(dev, IORESOURCE_MEM, 2);
+	if (!regs_ddr) {
+		dev_err(&dev->dev, "No External RAM resource specified\n");
+		goto out_free;
+	}
+
+	if (!regs_prussio->start || !regs_l3ram->start) {
+		dev_err(&dev->dev, "Invalid memory resource\n");
+		goto out_free;
+	}
+
+	ddr_virt_addr =

drivers/uio/uio_pruss.c line 145

Quoted 10 lines
drivers/uio/uio_pruss.c new file +10 -0
+	    dma_alloc_coherent(&dev->dev, regs_ddr->end - regs_ddr->start + 1,
+			       &ddr_phy_addr, GFP_KERNEL | GFP_DMA);
+	if (!ddr_virt_addr) {
+		dev_err(&dev->dev, "Could not allocate external memory\n");
+		goto out_free;
+	}
+
+	prussio_virt_addr =
+	    ioremap(regs_prussio->start,
+		    regs_prussio->end - regs_prussio->start + 1);

Either make those variable names shorter or do:

       len = regs_prussio->end - regs_prussio->start + 1;
       prussio_virt_addr = ioremap(regs_prussio->start, len);

Those multi line breaks are irritating and not necessary at all.

They result from mindlessly converting code following an unfortunately popular codingstyle which is only readable on extra wide screen monitors. I really wonder when people start to understand that the human eye can only parse up to a certain line width easily. There is a reason why newspapers are printed in columns.

Please be a bit more careful about this. Just mechanically converting existing horrible code to 80 chars does not make it more readable and less horrible than not converting it at all.

drivers/uio/uio_pruss.c line 152

Quoted 7 lines
drivers/uio/uio_pruss.c new file +7 -0
+	if (prussio_virt_addr) {
+		dev_err(&dev->dev, "Can't remap PRUSS I/O  address range\n");
+		goto out_free;
+	}
+
+	for (count = 0, p = info; count < MAX_PRUSS_EVTOUT_INSTANCE;
+	     count++, p++) {

See above.

	for (cnt = 0, p = info; cnt < MAX_PRUSS_EVT; cnt++, p++) {

is better readable and contains exactly the same amount of information.

Thanks,

tglx

#6 lore raw

Re: [PATCH v3 1/2] PRUSS UIO driver support

Hello.

Quoted 7 lines · Thomas Gleixner

drivers/uio/uio_pruss.c line 145

Quoted 3 lines
drivers/uio/uio_pruss.c new file +3 -0
+	prussio_virt_addr =
+	    ioremap(regs_prussio->start,
+		    regs_prussio->end - regs_prussio->start + 1);

Either make those variable names shorter or do:

        len = regs_prussio->end - regs_prussio->start + 1;
    Or even:

	len = resource_size(regs_prussio);
Quoted 1 line
        prussio_virt_addr = ioremap(regs_prussio->start, len);

WBR, Sergei

#7 lore raw

Re: [PATCH v3 1/2] PRUSS UIO driver support

Quoted 10 lines · Sergei Shtylyov

Hello.

Quoted 5 lines · Thomas Gleixner

drivers/uio/uio_pruss.c line 145

Quoted 3 lines
drivers/uio/uio_pruss.c new file +3 -0
+	prussio_virt_addr =
+	    ioremap(regs_prussio->start,
+		    regs_prussio->end - regs_prussio->start + 1);

Either make those variable names shorter or do:

Quoted 7 lines
Quoted 1 line
        len = regs_prussio->end - regs_prussio->start + 1;
   Or even:

	len = resource_size(regs_prussio);
Quoted 1 line
        prussio_virt_addr = ioremap(regs_prussio->start, len);

Good point. Forgot about that one :)

Thanks,

tglx

#8 lore raw

RE: [PATCH v3 1/2] PRUSS UIO driver support

Quoted 24 lines

-----Original Message-----
From: Thomas Gleixner [mailto:tglx at linutronix.de]
Sent: Thursday, February 24, 2011 2:24 AM
To: Sergei Shtylyov
Cc: TK, Pratheesh Gangadhar; davinci-linux-open-
source at linux.davincidsp.com; Chatterjee, Amit; gregkh at suse.de; linux- kernel at vger.kernel.org; hjk at hansjkoch.de; linux-arm- kernel at lists.infradead.org
Subject: Re: [PATCH v3 1/2] PRUSS UIO driver support

Quoted 12 lines · Sergei Shtylyov

Hello.

Quoted 7 lines · Thomas Gleixner

drivers/uio/uio_pruss.c line 145

Quoted 3 lines
drivers/uio/uio_pruss.c new file +3 -0
+	prussio_virt_addr =
+	    ioremap(regs_prussio->start,
+		    regs_prussio->end - regs_prussio->start + 1);

Either make those variable names shorter or do:

        len = regs_prussio->end - regs_prussio->start + 1;
Quoted 8 lines
Quoted 5 lines
   Or even:

	len = resource_size(regs_prussio);
Quoted 1 line
        prussio_virt_addr = ioremap(regs_prussio->start, len);

Good point. Forgot about that one :)

Thanks will do this.

Pratheesh

#9 lore raw

RE: [PATCH v3 1/2] PRUSS UIO driver support

In reply to Thomas Gleixner
Quoted 10 lines

-----Original Message-----
From: Thomas Gleixner [mailto:tglx at linutronix.de]
Sent: Thursday, February 24, 2011 1:56 AM
To: TK, Pratheesh Gangadhar
Cc: davinci-linux-open-source at linux.davincidsp.com; hjk at hansjkoch.de; gregkh at suse.de; Chatterjee, Amit; linux-kernel at vger.kernel.org; linux-arm- kernel at lists.infradead.org
Subject: Re: [PATCH v3 1/2] PRUSS UIO driver support

Quoted 5 lines

On Wed, 23 Feb 2011, Pratheesh Gangadhar wrote:

Is it actually too much of an hassle to cc the people who spent their time to review previous versions of your patch ?

Sorry. Will do...

Quoted 10 lines

drivers/uio/uio_pruss.c line 53

Quoted 3 lines
drivers/uio/uio_pruss.c new file +3 -0
+struct clk *pruss_clk;
+struct uio_info *info;
+void *ddr_virt_addr = NULL, *prussio_virt_addr = NULL;

Grrr. We do not initialize with NULL.

Quoted 1 line

+dma_addr_t ddr_phy_addr;

Also all of these want to be static.

Ok.

Quoted 11 lines

drivers/uio/uio_pruss.c line 85

Quoted 7 lines
drivers/uio/uio_pruss.c new file +6 -0
+		uio_unregister_device(p);
+		kfree(p->name);
+	}
+	iounmap(prussio_virt_addr);
+	dma_free_coherent(&dev->dev, info[0].mem[2].size,
+			  info[0].mem[2].internal_addr, info[0].mem[2].addr);

You sure, that iounmap and dma_free_coherent are too happy about being called with NULL pointers?

For iounmap its ok, not ok for dma_free_coherent. Will fix.

Quoted 16 lines
Quoted 16 lines
drivers/uio/uio_pruss.c new file +16 -0
+
+	kfree(info);
+	clk_put(pruss_clk);
+}
+
+static int __devinit pruss_probe(struct platform_device *dev)
+{
+	int ret = -ENODEV, count = 0;
+	struct resource *regs_prussio, *regs_l3ram, *regs_ddr;
+	struct uio_info *p;
+
+	info = kzalloc(sizeof(struct uio_info) * MAX_PRUSS_EVTOUT_INSTANCE,
+		       GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
Quoted 8 lines

drivers/uio/uio_pruss.c line 107

Quoted 6 lines
drivers/uio/uio_pruss.c new file +6 -0
+	/* Power on PRU in case its not done as part of boot-loader */
+	pruss_clk = clk_get(&dev->dev, "pruss");
+	if (IS_ERR(pruss_clk)) {
+		dev_err(&dev->dev, "Failed to get clock\n");
+		ret = PTR_ERR(pruss_clk);
+		return ret;

Memory leak.

Will fix.

Thanks,
Pratheesh