From c1bc97f8f498a2bfab63ceef761fb0e88ef7c065 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 28 Apr 2014 20:50:56 +0100 Subject: goldfish bus: don't call request_mem_region This is a bug fix that has been lurking in the Google tree but not pushed upstream. From: Octavian Purdila The memory region is already reserved in goldfish_init() during platform init. Signed-off-by: Octavian Purdila Signed-off-by: Jun Tian Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/platform/goldfish/pdev_bus.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'drivers/platform') diff --git a/drivers/platform/goldfish/pdev_bus.c b/drivers/platform/goldfish/pdev_bus.c index 92cc4cfafde5..4eb2bb34790d 100644 --- a/drivers/platform/goldfish/pdev_bus.c +++ b/drivers/platform/goldfish/pdev_bus.c @@ -184,11 +184,6 @@ static int goldfish_pdev_bus_probe(struct platform_device *pdev) pdev_bus_addr = r->start; pdev_bus_len = resource_size(r); - if (request_mem_region(pdev_bus_addr, pdev_bus_len, "goldfish")) { - dev_err(&pdev->dev, "unable to reserve Goldfish MMIO.\n"); - return -EBUSY; - } - pdev_bus_base = ioremap(pdev_bus_addr, pdev_bus_len); if (pdev_bus_base == NULL) { ret = -ENOMEM; -- cgit v1.2.3 From 49a75c444fcf07fdde2ec74428b6b1b9ff1c6b15 Mon Sep 17 00:00:00 2001 From: Jun Tian Date: Mon, 12 May 2014 16:54:46 +0100 Subject: goldfish: 64-bit pipe driver for goldfish platform Support 64-bit channel and address for the goldfish pipe driver. Signed-off-by: Jun Tian Signed-off-by: Octavian Purdila Signed-off-by: Brian Wood Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/platform/goldfish/goldfish_pipe.c | 35 +++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'drivers/platform') diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c index 4f5aa831f549..f33c6e0e7fb0 100644 --- a/drivers/platform/goldfish/goldfish_pipe.c +++ b/drivers/platform/goldfish/goldfish_pipe.c @@ -66,8 +66,14 @@ #define PIPE_REG_COMMAND 0x00 /* write: value = command */ #define PIPE_REG_STATUS 0x04 /* read */ #define PIPE_REG_CHANNEL 0x08 /* read/write: channel id */ +#ifdef CONFIG_64BIT +#define PIPE_REG_CHANNEL_HIGH 0x30 /* read/write: channel id */ +#endif #define PIPE_REG_SIZE 0x0c /* read/write: buffer size */ #define PIPE_REG_ADDRESS 0x10 /* write: physical address */ +#ifdef CONFIG_64BIT +#define PIPE_REG_ADDRESS_HIGH 0x34 /* write: physical address */ +#endif #define PIPE_REG_WAKES 0x14 /* read: wake flags */ #define PIPE_REG_PARAMS_ADDR_LOW 0x18 /* read/write: batch data address */ #define PIPE_REG_PARAMS_ADDR_HIGH 0x1c /* read/write: batch data address */ @@ -109,9 +115,9 @@ #define PIPE_WAKE_WRITE (1 << 2) /* pipe can now be written to */ struct access_params { - u32 channel; + unsigned long channel; u32 size; - u32 address; + unsigned long address; u32 cmd; u32 result; /* reserved for future extension */ @@ -155,7 +161,10 @@ static u32 goldfish_cmd_status(struct goldfish_pipe *pipe, u32 cmd) struct goldfish_pipe_dev *dev = pipe->dev; spin_lock_irqsave(&dev->lock, flags); - writel((u32)pipe, dev->base + PIPE_REG_CHANNEL); + writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); +#ifdef CONFIG_64BIT + writel((u32)((u64)pipe >> 32), dev->base + PIPE_REG_CHANNEL_HIGH); +#endif writel(cmd, dev->base + PIPE_REG_COMMAND); status = readl(dev->base + PIPE_REG_STATUS); spin_unlock_irqrestore(&dev->lock, flags); @@ -168,7 +177,10 @@ static void goldfish_cmd(struct goldfish_pipe *pipe, u32 cmd) struct goldfish_pipe_dev *dev = pipe->dev; spin_lock_irqsave(&dev->lock, flags); - writel((u32)pipe, dev->base + PIPE_REG_CHANNEL); + writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); +#ifdef CONFIG_64BIT + writel((u32)((u64)pipe >> 32), dev->base + PIPE_REG_CHANNEL_HIGH); +#endif writel(cmd, dev->base + PIPE_REG_COMMAND); spin_unlock_irqrestore(&dev->lock, flags); } @@ -322,9 +334,15 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer, spin_lock_irqsave(&dev->lock, irq_flags); if (access_with_param(dev, CMD_WRITE_BUFFER + cmd_offset, address, avail, pipe, &status)) { - writel((u32)pipe, dev->base + PIPE_REG_CHANNEL); + writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); +#ifdef CONFIG_64BIT + writel((u32)((u64)pipe >> 32), dev->base + PIPE_REG_CHANNEL_HIGH); +#endif writel(avail, dev->base + PIPE_REG_SIZE); writel(address, dev->base + PIPE_REG_ADDRESS); +#ifdef CONFIG_64BIT + writel((u32)((u64)address >> 32), dev->base + PIPE_REG_ADDRESS_HIGH); +#endif writel(CMD_WRITE_BUFFER + cmd_offset, dev->base + PIPE_REG_COMMAND); status = readl(dev->base + PIPE_REG_STATUS); @@ -447,7 +465,12 @@ static irqreturn_t goldfish_pipe_interrupt(int irq, void *dev_id) /* First read the channel, 0 means the end of the list */ struct goldfish_pipe *pipe; unsigned long wakes; - unsigned long channel = readl(dev->base + PIPE_REG_CHANNEL); + unsigned long channel = 0; + +#ifdef CONFIG_64BIT + channel = (u64)readl(dev->base + PIPE_REG_CHANNEL_HIGH) << 32; +#endif + channel |= readl(dev->base + PIPE_REG_CHANNEL); if (channel == 0) break; -- cgit v1.2.3 From 25c72c786cb571cfdf39a31f9f64d143d8623a7a Mon Sep 17 00:00:00 2001 From: Jun Tian Date: Mon, 12 May 2014 16:54:57 +0100 Subject: goldfish: fix kernel panic when using multiple adb connection When using multiple adb on 64 bit kernel to transfer data, the goldfish pipe interrupt will crash the kernel. Signed-off-by: Jun Tian Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/platform/goldfish/goldfish_pipe.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/platform') diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c index f33c6e0e7fb0..670b9b94f74b 100644 --- a/drivers/platform/goldfish/goldfish_pipe.c +++ b/drivers/platform/goldfish/goldfish_pipe.c @@ -469,6 +469,9 @@ static irqreturn_t goldfish_pipe_interrupt(int irq, void *dev_id) #ifdef CONFIG_64BIT channel = (u64)readl(dev->base + PIPE_REG_CHANNEL_HIGH) << 32; + + if (channel == 0) + break; #endif channel |= readl(dev->base + PIPE_REG_CHANNEL); -- cgit v1.2.3 From f10d8434201859d5ad7f51032dcd2d0c09e85ee2 Mon Sep 17 00:00:00 2001 From: Octavian Purdila Date: Mon, 12 May 2014 16:55:05 +0100 Subject: goldfish: add support for 64bit to the virtual bus This patchs adds a new register to pass the upper 32bits for the device name address when running in 64bit mode. Signed-off-by: Octavian Purdila Signed-off-by: Jun Tian Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/platform/goldfish/pdev_bus.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/platform') diff --git a/drivers/platform/goldfish/pdev_bus.c b/drivers/platform/goldfish/pdev_bus.c index 4eb2bb34790d..eb254400c44a 100644 --- a/drivers/platform/goldfish/pdev_bus.c +++ b/drivers/platform/goldfish/pdev_bus.c @@ -36,6 +36,7 @@ #define PDEV_BUS_IO_SIZE (0x14) #define PDEV_BUS_IRQ (0x18) #define PDEV_BUS_IRQ_COUNT (0x1c) +#define PDEV_BUS_GET_NAME_HIGH (0x20) struct pdev_bus_dev { struct list_head list; @@ -129,7 +130,10 @@ static int goldfish_new_pdev(void) dev->pdev.dev.dma_mask = (void *)(dev->pdev.name + name_len + 1); *dev->pdev.dev.dma_mask = ~0; - writel((unsigned long)name, pdev_bus_base + PDEV_BUS_GET_NAME); +#ifdef CONFIG_64BIT + writel((u32)((u64)name>>32), pdev_bus_base + PDEV_BUS_GET_NAME_HIGH); +#endif + writel((u32)(u64)name, pdev_bus_base + PDEV_BUS_GET_NAME); name[name_len] = '\0'; dev->pdev.id = readl(pdev_bus_base + PDEV_BUS_ID); dev->pdev.resource[0].start = base; -- cgit v1.2.3 From a99698facdb92adebf4a4ed7691493b7e08ff5b6 Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 12 May 2014 16:57:22 +0100 Subject: goldfish: clean up the pipe driver 64bit ifdefs Use the 64bit helper method to scrub most of the ifdefs from the driver. The pipe reading has a funny case we can't scrub completely. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/platform/goldfish/goldfish_pipe.c | 33 +++++++++++-------------------- 1 file changed, 11 insertions(+), 22 deletions(-) (limited to 'drivers/platform') diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c index 670b9b94f74b..c86180bba72e 100644 --- a/drivers/platform/goldfish/goldfish_pipe.c +++ b/drivers/platform/goldfish/goldfish_pipe.c @@ -56,6 +56,7 @@ #include #include #include +#include /* * IMPORTANT: The following constants must match the ones used and defined @@ -66,14 +67,10 @@ #define PIPE_REG_COMMAND 0x00 /* write: value = command */ #define PIPE_REG_STATUS 0x04 /* read */ #define PIPE_REG_CHANNEL 0x08 /* read/write: channel id */ -#ifdef CONFIG_64BIT #define PIPE_REG_CHANNEL_HIGH 0x30 /* read/write: channel id */ -#endif #define PIPE_REG_SIZE 0x0c /* read/write: buffer size */ #define PIPE_REG_ADDRESS 0x10 /* write: physical address */ -#ifdef CONFIG_64BIT #define PIPE_REG_ADDRESS_HIGH 0x34 /* write: physical address */ -#endif #define PIPE_REG_WAKES 0x14 /* read: wake flags */ #define PIPE_REG_PARAMS_ADDR_LOW 0x18 /* read/write: batch data address */ #define PIPE_REG_PARAMS_ADDR_HIGH 0x1c /* read/write: batch data address */ @@ -155,16 +152,14 @@ enum { static u32 goldfish_cmd_status(struct goldfish_pipe *pipe, u32 cmd) -{ +{ unsigned long flags; u32 status; struct goldfish_pipe_dev *dev = pipe->dev; spin_lock_irqsave(&dev->lock, flags); - writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); -#ifdef CONFIG_64BIT - writel((u32)((u64)pipe >> 32), dev->base + PIPE_REG_CHANNEL_HIGH); -#endif + gf_write64((u64)pipe, dev->base + PIPE_REG_CHANNEL, + dev->base + PIPE_REG_CHANNEL_HIGH); writel(cmd, dev->base + PIPE_REG_COMMAND); status = readl(dev->base + PIPE_REG_STATUS); spin_unlock_irqrestore(&dev->lock, flags); @@ -172,15 +167,13 @@ static u32 goldfish_cmd_status(struct goldfish_pipe *pipe, u32 cmd) } static void goldfish_cmd(struct goldfish_pipe *pipe, u32 cmd) -{ +{ unsigned long flags; struct goldfish_pipe_dev *dev = pipe->dev; spin_lock_irqsave(&dev->lock, flags); - writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); -#ifdef CONFIG_64BIT - writel((u32)((u64)pipe >> 32), dev->base + PIPE_REG_CHANNEL_HIGH); -#endif + gf_write64((u64)pipe, dev->base + PIPE_REG_CHANNEL, + dev->base + PIPE_REG_CHANNEL_HIGH); writel(cmd, dev->base + PIPE_REG_COMMAND); spin_unlock_irqrestore(&dev->lock, flags); } @@ -334,15 +327,11 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer, spin_lock_irqsave(&dev->lock, irq_flags); if (access_with_param(dev, CMD_WRITE_BUFFER + cmd_offset, address, avail, pipe, &status)) { - writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); -#ifdef CONFIG_64BIT - writel((u32)((u64)pipe >> 32), dev->base + PIPE_REG_CHANNEL_HIGH); -#endif + gf_write64((u64)pipe, dev->base + PIPE_REG_CHANNEL, + dev->base + PIPE_REG_CHANNEL_HIGH); writel(avail, dev->base + PIPE_REG_SIZE); - writel(address, dev->base + PIPE_REG_ADDRESS); -#ifdef CONFIG_64BIT - writel((u32)((u64)address >> 32), dev->base + PIPE_REG_ADDRESS_HIGH); -#endif + gf_write64(address, dev->base + PIPE_REG_ADDRESS, + dev->base + PIPE_REG_ADDRESS_HIGH); writel(CMD_WRITE_BUFFER + cmd_offset, dev->base + PIPE_REG_COMMAND); status = readl(dev->base + PIPE_REG_STATUS); -- cgit v1.2.3 From f2dbdf625ddc98fece71a79d78d0981204e933ee Mon Sep 17 00:00:00 2001 From: Octavian Purdila Date: Fri, 16 May 2014 08:24:58 +0300 Subject: goldfish: bus: fix warnings for 32bit builds drivers/platform/goldfish/pdev_bus.c: In function 'goldfish_new_pdev': drivers/platform/goldfish/pdev_bus.c:136:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] writel((u32)(u64)name, pdev_bus_base + PDEV_BUS_GET_NAME); Reported-by: Fengguang Wu Cc: Jun Tian Acked-by: Alan Cox Signed-off-by: Octavian Purdila Signed-off-by: Greg Kroah-Hartman --- drivers/platform/goldfish/pdev_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/platform') diff --git a/drivers/platform/goldfish/pdev_bus.c b/drivers/platform/goldfish/pdev_bus.c index eb254400c44a..8c43589c3edb 100644 --- a/drivers/platform/goldfish/pdev_bus.c +++ b/drivers/platform/goldfish/pdev_bus.c @@ -133,7 +133,7 @@ static int goldfish_new_pdev(void) #ifdef CONFIG_64BIT writel((u32)((u64)name>>32), pdev_bus_base + PDEV_BUS_GET_NAME_HIGH); #endif - writel((u32)(u64)name, pdev_bus_base + PDEV_BUS_GET_NAME); + writel((u32)(unsigned long)name, pdev_bus_base + PDEV_BUS_GET_NAME); name[name_len] = '\0'; dev->pdev.id = readl(pdev_bus_base + PDEV_BUS_ID); dev->pdev.resource[0].start = base; -- cgit v1.2.3 From f4e131dc38d34469b9fee1840ad237324831bce3 Mon Sep 17 00:00:00 2001 From: Octavian Purdila Date: Fri, 16 May 2014 08:24:59 +0300 Subject: goldfish: pipe: fix warnings for 32bit builds drivers/platform/goldfish/goldfish_pipe.c: In function 'goldfish_cmd_status': drivers/platform/goldfish/goldfish_pipe.c:164:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); ^ drivers/platform/goldfish/goldfish_pipe.c: In function 'goldfish_cmd': drivers/platform/goldfish/goldfish_pipe.c:180:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); ^ drivers/platform/goldfish/goldfish_pipe.c: In function 'goldfish_pipe_read_write': drivers/platform/goldfish/goldfish_pipe.c:337:16: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); Reported-by: Fengguang Wu Cc: Jun Tian Acked-by: Alan Cox Signed-off-by: Octavian Purdila Signed-off-by: Greg Kroah-Hartman --- drivers/platform/goldfish/goldfish_pipe.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers/platform') diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c index c86180bba72e..d9a09d9637d9 100644 --- a/drivers/platform/goldfish/goldfish_pipe.c +++ b/drivers/platform/goldfish/goldfish_pipe.c @@ -158,7 +158,7 @@ static u32 goldfish_cmd_status(struct goldfish_pipe *pipe, u32 cmd) struct goldfish_pipe_dev *dev = pipe->dev; spin_lock_irqsave(&dev->lock, flags); - gf_write64((u64)pipe, dev->base + PIPE_REG_CHANNEL, + gf_write64((u64)(unsigned long)pipe, dev->base + PIPE_REG_CHANNEL, dev->base + PIPE_REG_CHANNEL_HIGH); writel(cmd, dev->base + PIPE_REG_COMMAND); status = readl(dev->base + PIPE_REG_STATUS); @@ -172,7 +172,7 @@ static void goldfish_cmd(struct goldfish_pipe *pipe, u32 cmd) struct goldfish_pipe_dev *dev = pipe->dev; spin_lock_irqsave(&dev->lock, flags); - gf_write64((u64)pipe, dev->base + PIPE_REG_CHANNEL, + gf_write64((u64)(unsigned long)pipe, dev->base + PIPE_REG_CHANNEL, dev->base + PIPE_REG_CHANNEL_HIGH); writel(cmd, dev->base + PIPE_REG_COMMAND); spin_unlock_irqrestore(&dev->lock, flags); @@ -327,8 +327,9 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer, spin_lock_irqsave(&dev->lock, irq_flags); if (access_with_param(dev, CMD_WRITE_BUFFER + cmd_offset, address, avail, pipe, &status)) { - gf_write64((u64)pipe, dev->base + PIPE_REG_CHANNEL, - dev->base + PIPE_REG_CHANNEL_HIGH); + gf_write64((u64)(unsigned long)pipe, + dev->base + PIPE_REG_CHANNEL, + dev->base + PIPE_REG_CHANNEL_HIGH); writel(avail, dev->base + PIPE_REG_SIZE); gf_write64(address, dev->base + PIPE_REG_ADDRESS, dev->base + PIPE_REG_ADDRESS_HIGH); -- cgit v1.2.3