Re: [PATCH v6 1/3] spi/pl022: Add chip select handling via GPIO

2012-09-02 Thread Linus Walleij
On Sat, Sep 1, 2012 at 1:14 PM, shiraz hashim
 wrote:
> Hi Roland,
>
> On Wed, Aug 22, 2012 at 7:19 PM, Roland Stigge  wrote:
>> @@ -2016,6 +2030,8 @@ pl022_probe(struct amba_device *adev, co
>> pl022->master_info = platform_info;
>> pl022->adev = adev;
>> pl022->vendor = id->data;
>> +   /* Point chipselects to allocated memory beyond the main struct */
>> +   pl022->chipselects = (int *) pl022 + sizeof(struct pl022);
>
> This is going beyond memory allocated for chipselects
> as it adds 4 * sizeof(struct pl022) bytes to pl022.

Yes that is why the allocation looks like this:

+   master = spi_alloc_master(dev, sizeof(struct pl022) + sizeof(int) *
+ platform_info->num_chipselect);

> pl022->chipselects = (int *) &pl022[1];
> can be musch safer.

I see absolutely no sematic difference between these two
methods to reach the first position beyond the first struct.

If we're gonna be debating this it's a safe sign that this is
not a good design pattern at all, so then it is better to simply
devm_kzalloc(sizeof(int) * platform_info->num_chipselect);
separately.

(But I'm happy with the patch as it is. And the other way
too, since I'm not very picky.)

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] i825xx: fix paging fault on znet_probe()

2012-09-02 Thread Fengguang Wu
In znet_probe(), strncmp() may access beyond 0x10 and
trigger the below oops in kvm.  Fix it by limiting the loop
under 0x10-8. I suspect the limit could be further decreased
to 0x10-sizeof(struct netidblk), however no datasheet at hand..

[3.744312] BUG: unable to handle kernel paging request at 8010
[3.746145] IP: [<8119d12a>] strncmp+0xc/0x20
[3.747446] *pde = 01d10067 *pte = 00100160 
[3.747493] Oops:  [#1] DEBUG_PAGEALLOC
[3.747493] Pid: 1, comm: swapper Not tainted 3.6.0-rc1-00018-g57bfc0a #73 
Bochs Bochs
[3.747493] EIP: 0060:[<8119d12a>] EFLAGS: 00010206 CPU: 0
[3.747493] EIP is at strncmp+0xc/0x20
[3.747493] EAX: 800fff4e EBX: 0006 ECX: 0006 EDX: 814d2bb9
[3.747493] ESI: 8010 EDI: 814d2bba EBP: 8e03dfa0 ESP: 8e03df98
[3.747493]  DS: 007b ES: 007b FS:  GS: 00e0 SS: 0068
[3.747493] CR0: 8005003b CR2: 8010 CR3: 016f7000 CR4: 0690
[3.747493] DR0:  DR1:  DR2:  DR3: 
[3.747493] DR6: 0ff0 DR7: 0400
[3.747493] Process swapper (pid: 1, ti=8e03c000 task=8e04 
task.ti=8e03c000)
[3.747493] Stack:
[3.747493]  800f  8e03dfb4 816a1376 0006 816a134a  
8e03dfd0
[3.747493]  816819b5 816ed1c0 8e03dfe4 0006 0123 816ed604 8e03dfe4 
81681b29
[3.747493]   81681a5b   8134e542   

[3.747493] Call Trace:
[3.747493]  [<816a1376>] znet_probe+0x2c/0x26b 
[3.747493]  [<816a134a>] ? dnet_driver_init+0xf/0xf
[3.747493]  [<816819b5>] do_one_initcall+0x6a/0x110
[3.747493]  [<81681b29>] kernel_init+0xce/0x14b

Signed-off-by: Fengguang Wu 
---
 drivers/net/ethernet/i825xx/znet.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

--- linux.orig/drivers/net/ethernet/i825xx/znet.c   2012-05-24 
19:03:06.928430941 +0800
+++ linux/drivers/net/ethernet/i825xx/znet.c2012-09-02 15:14:24.943249546 
+0800
@@ -139,8 +139,11 @@ struct znet_private {
 /* Only one can be built-in;-> */
 static struct net_device *znet_dev;
 
+#define NETIDBLK_MAGIC "NETIDBLK"
+#define NETIDBLK_MAGIC_SIZE8
+
 struct netidblk {
-   char magic[8];  /* The magic number (string) "NETIDBLK" */
+   char magic[NETIDBLK_MAGIC_SIZE];/* The magic number (string) 
"NETIDBLK" */
unsigned char netid[8]; /* The physical station address */
char nettype, globalopt;
char vendor[8]; /* The machine vendor and product name. */
@@ -373,14 +376,16 @@ static int __init znet_probe (void)
struct znet_private *znet;
struct net_device *dev;
char *p;
+   char *plast = phys_to_virt(0x10 - NETIDBLK_MAGIC_SIZE);
int err = -ENOMEM;
 
/* This code scans the region 0xf to 0xf for a "NETIDBLK". */
-   for(p = (char *)phys_to_virt(0xf); p < (char 
*)phys_to_virt(0x10); p++)
-   if (*p == 'N'  &&  strncmp(p, "NETIDBLK", 8) == 0)
+   for(p = (char *)phys_to_virt(0xf); p <= plast; p++)
+   if (*p == 'N' &&
+   strncmp(p, NETIDBLK_MAGIC, NETIDBLK_MAGIC_SIZE) == 0)
break;
 
-   if (p >= (char *)phys_to_virt(0x10)) {
+   if (p > plast) {
if (znet_debug > 1)
printk(KERN_INFO "No Z-Note ethernet adaptor found.\n");
return -ENODEV;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 16/20] HID: Only dump input if someone is listening

2012-09-02 Thread Jiri Kosina
On Sat, 1 Sep 2012, Henrik Rydberg wrote:

> Going through the motions of printing the debug message information
> takes a long time; using the keyboard can lead to a 160 us irqsoff
> latency. This patch skips hid_dump_input() when there are no open
> handles, which brings latency down to 100 us.
> 
> Signed-off-by: Henrik Rydberg 
> ---
>  drivers/hid/hid-core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> index 60ea284..5b74e78 100644
> --- a/drivers/hid/hid-core.c
> +++ b/drivers/hid/hid-core.c
> @@ -996,7 +996,8 @@ static void hid_process_event(struct hid_device *hid, 
> struct hid_field *field,
>   struct hid_driver *hdrv = hid->driver;
>   int ret;
>  
> - hid_dump_input(hid, usage, value);
> + if (!list_empty(&hid->debug_list))
> + hid_dump_input(hid, usage, value);
>  
>   if (hdrv && hdrv->event && hid_match_usage(hid, usage)) {
>   ret = hdrv->event(hid, field, usage, value);

Henrik,

I have applied this one right away, so you can drop it from your series. 
The remaining ones I am still about to review (currently travelling).

There is no inter-dependency between the Input and HID ones, and so we can 
handle them with Dmitry as two independent Input and HID series, right?

Thanks a lot,

-- 
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Documentation: fix broken utf8 encoding

2012-09-02 Thread Jiri Kosina
On Tue, 21 Aug 2012, Oskar Schirmer wrote:

> conversion to utf8 left some extra control character here,
> remove it.
>
> Signed-off-by: Oskar Schirmer 
> Cc: John Anthony Kazos Jr 
> Cc: Rob Landley 
> ---
> Documentation/power/swsusp.txt |2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Documentation/power/swsusp.txt b/Documentation/power/swsusp.txt
> index 92341b8..0b4b63e 100644
> --- a/Documentation/power/swsusp.txt
> +++ b/Documentation/power/swsusp.txt
> @@ -53,7 +53,7 @@ before suspend (it is limited to 500 MB by default).
>
> Article about goals and implementation of Software Suspend for Linux
> 
> -Author: Gbor Kuti
> +Author: G??bor Kuti
> Last revised: 2003-10-20 by Pavel Machek
>
> Idea and goals to achieve

Well, your MTA didn't make it any better by not encoding it properly :)

I have fixed it manually and applied.

-- 
Jiri Kosina
SUSE Labs

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/9] pinctrl: mvebu: pinctrl driver core

2012-09-02 Thread Linus Walleij
On Mon, Aug 27, 2012 at 6:33 AM, Stephen Warren  wrote:
> On 08/25/2012 08:53 AM, Sebastian Hesselbarth wrote:
>>
>> now I do understand but in the current driver we pass pingroups associated
>> with the available functions, i.e. "mpp2" with "uart1", "uart2",
>> "sdio0", aso.
>> IMHO for the above three functions it would be better to have functions
>> associated
>> with the corresponding groups, i.e. "uart1" with "mpp_uart1", "mpp2",
>> "mpp3", aso.
>
> The pinctrl subsystem does expect a list of functions, and for each
> function, a list of the groups where it can be selected. I admit that
> when I think about this, it's slightly backward, since HW typically has
> a list of pins/groups, and for each, a certain set of functions can be
> selected. Oh well...

I agree that this is how we engineered it, would it create big hassles
for you to fix up the driver so it's the other way around Sebastian?

I understand that the driver is perfectly working as it is, but from
a subsystem maintainer point of view it is annoying if one driver
turns the concepts around and it gets hard to maintain.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] [trivial] dma: Fix typo various drivers in dma

2012-09-02 Thread Jiri Kosina
On Fri, 3 Aug 2012, Masanari Iida wrote:

> Correct spelling typo in drivers/dma.

Applied.

-- 
Jiri Kosina
SUSE Labs

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] security: unconditionally call Yama

2012-09-02 Thread Jiri Kosina
On Fri, 31 Aug 2012, Kees Cook wrote:

> Given that several distros use (or want to use) Yama, I think that's 
> reason enough for this. I think it's important for us to take a 
> practical approach here, and having the big LSMs each hook Yama instead 
> of doing this in a single global place will make it needlessly 
> duplicated code.

With my SUSE hat on, I would be really reluctant to enable config option 
in the distribution kernel that will make attaching gdb to running 
processess impossible without any further tuning (like sysctl/procfs knob 
to explicitly enable this feature).

Thanks,

-- 
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH -v2 02/13] x86, mm: Split out split_mem_range

2012-09-02 Thread Yinghai Lu
from init_memory_mapping, so make init_memory_mapping readable.

Suggested-by: Ingo Molnar 
Signed-off-by: Yinghai Lu 
---
 arch/x86/mm/init.c |   42 ++
 1 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 838e9bc..7d05e28 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -143,25 +143,13 @@ static int __meminit save_mr(struct map_range *mr, int 
nr_range,
return nr_range;
 }
 
-/*
- * Setup the direct mapping of the physical memory at PAGE_OFFSET.
- * This runs before bootmem is initialized and gets pages directly from
- * the physical memory. To access them they are temporarily mapped.
- */
-unsigned long __init_refok init_memory_mapping(unsigned long start,
-  unsigned long end)
+static int __meminit split_mem_range(struct map_range *mr, int nr_range,
+unsigned long start,
+unsigned long end)
 {
unsigned long start_pfn, end_pfn;
-   unsigned long ret = 0;
unsigned long pos;
-   struct map_range mr[NR_RANGE_MR];
-   int nr_range, i;
-
-   printk(KERN_INFO "init_memory_mapping: [mem %#010lx-%#010lx]\n",
-  start, end - 1);
-
-   memset(mr, 0, sizeof(mr));
-   nr_range = 0;
+   int i;
 
/* head if not big page alignment ? */
start_pfn = start >> PAGE_SHIFT;
@@ -255,6 +243,28 @@ unsigned long __init_refok init_memory_mapping(unsigned 
long start,
(mr[i].page_size_mask & (1

[PATCH -v2 00/13] x86, mm: init_memory_mapping cleanup

2012-09-02 Thread Yinghai Lu
Only create mapping for E820_820 and E820_RESERVED_KERN.

Seperate calculate_table_space_size and find_early_page_table out with
init_memory_mapping.

Also for 64bit, first 1M's page table will be in BRK.

For other range, will allocate page table one time, but init mapping
only for E820 RAM and E820_RESERVED_KERN.

Could be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git 
for-x86-mm

Thanks
Yinghai

Jacob Shin (4):
  x86: if kernel .text .data .bss are not marked as E820_RAM, complain
and fix
  x86: Fixup code testing if a pfn is direct mapped
  x86: Only direct map addresses that are marked as E820_RAM
  x86/mm: calculate_table_space_size based on memory ranges that are
being mapped

Yinghai Lu (9):
  x86, mm: Add global page_size_mask
  x86, mm: Split out split_mem_range
  x86, mm: Moving init_memory_mapping calling
  x86, mm: Revert back good_end setting for 64bit
  x86, mm: Find early page table only one time
  x86, mm: Separate out calculate_table_space_size()
  x86, mm: Move down two calculate_table_space_size down.
  x86, mm: Use func pointer to table size calculation and mapping.
  x86, 64bit: Map first 1M ram early before memblock_x86_fill()

 arch/x86/include/asm/init.h   |1 -
 arch/x86/include/asm/page_types.h |3 +
 arch/x86/include/asm/pgtable.h|2 +
 arch/x86/kernel/cpu/amd.c |8 +-
 arch/x86/kernel/head64.c  |2 +-
 arch/x86/kernel/setup.c   |   36 ++--
 arch/x86/mm/init.c|  381 ++---
 arch/x86/mm/init_64.c |   13 +-
 arch/x86/platform/efi/efi.c   |8 +-
 9 files changed, 315 insertions(+), 139 deletions(-)

-- 
1.7.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH -v2 04/13] x86, mm: Revert back good_end setting for 64bit

2012-09-02 Thread Yinghai Lu
So we could put page table high again for 64bit.

Signed-off-by: Yinghai Lu 
---
 arch/x86/mm/init.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 15a6a38..cca9b7d 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -76,8 +76,8 @@ static void __init find_early_table_space(struct map_range 
*mr,
 #ifdef CONFIG_X86_32
/* for fixmap */
tables += roundup(__end_of_fixed_addresses * sizeof(pte_t), PAGE_SIZE);
-#endif
good_end = max_pfn_mapped << PAGE_SHIFT;
+#endif
 
base = memblock_find_in_range(start, good_end, tables, PAGE_SIZE);
if (!base)
-- 
1.7.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH -v2 07/13] x86, mm: Move down two calculate_table_space_size down.

2012-09-02 Thread Yinghai Lu
So later could make it call split_mem_range...

Signed-off-by: Yinghai Lu 
---
 arch/x86/mm/init.c |  116 ++--
 1 files changed, 58 insertions(+), 58 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index fcb44c5..a475d7f 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -37,64 +37,6 @@ struct map_range {
 
 static int page_size_mask;
 
-static unsigned long __init calculate_table_space_size(unsigned long begin,
- unsigned long end)
-{
-   unsigned long puds, pmds, ptes, tables;
-
-   puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
-   tables = roundup(puds * sizeof(pud_t), PAGE_SIZE);
-
-   if (page_size_mask & (1 << PG_LEVEL_1G)) {
-   unsigned long extra;
-
-   extra = end - ((end>>PUD_SHIFT) << PUD_SHIFT);
-   pmds = (extra + PMD_SIZE - 1) >> PMD_SHIFT;
-   } else
-   pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
-
-   tables += roundup(pmds * sizeof(pmd_t), PAGE_SIZE);
-
-   if (page_size_mask & (1 << PG_LEVEL_2M)) {
-   unsigned long extra;
-
-   extra = end - ((end>>PMD_SHIFT) << PMD_SHIFT);
-#ifdef CONFIG_X86_32
-   extra += PMD_SIZE;
-#endif
-   /* The first 2/4M doesn't use large pages. */
-   if (begin < PMD_SIZE)
-   extra += (PMD_SIZE - begin) >> PAGE_SHIFT;
-
-   ptes = (extra + PAGE_SIZE - 1) >> PAGE_SHIFT;
-   } else
-   ptes = (end + PAGE_SIZE - 1) >> PAGE_SHIFT;
-
-   tables += roundup(ptes * sizeof(pte_t), PAGE_SIZE);
-
-#ifdef CONFIG_X86_32
-   /* for fixmap */
-   tables += roundup(__end_of_fixed_addresses * sizeof(pte_t), PAGE_SIZE);
-#endif
-
-   return tables;
-}
-
-static void __init find_early_table_space(unsigned long start,
- unsigned long good_end,
- unsigned long tables)
-{
-   phys_addr_t base;
-
-   base = memblock_find_in_range(start, good_end, tables, PAGE_SIZE);
-   if (!base)
-   panic("Cannot find space for the kernel page tables");
-
-   pgt_buf_start = base >> PAGE_SHIFT;
-   pgt_buf_end = pgt_buf_start;
-   pgt_buf_top = pgt_buf_start + (tables >> PAGE_SHIFT);
-}
-
 static void __init probe_page_size_mask(void)
 {
 #if !defined(CONFIG_DEBUG_PAGEALLOC) && !defined(CONFIG_KMEMCHECK)
@@ -249,6 +191,64 @@ static int __meminit split_mem_range(struct map_range *mr, 
int nr_range,
return nr_range;
 }
 
+static unsigned long __init calculate_table_space_size(unsigned long begin,
+ unsigned long end)
+{
+   unsigned long puds, pmds, ptes, tables;
+
+   puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
+   tables = roundup(puds * sizeof(pud_t), PAGE_SIZE);
+
+   if (page_size_mask & (1 << PG_LEVEL_1G)) {
+   unsigned long extra;
+
+   extra = end - ((end>>PUD_SHIFT) << PUD_SHIFT);
+   pmds = (extra + PMD_SIZE - 1) >> PMD_SHIFT;
+   } else
+   pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
+
+   tables += roundup(pmds * sizeof(pmd_t), PAGE_SIZE);
+
+   if (page_size_mask & (1 << PG_LEVEL_2M)) {
+   unsigned long extra;
+
+   extra = end - ((end>>PMD_SHIFT) << PMD_SHIFT);
+#ifdef CONFIG_X86_32
+   extra += PMD_SIZE;
+#endif
+   /* The first 2/4M doesn't use large pages. */
+   if (begin < PMD_SIZE)
+   extra += (PMD_SIZE - begin) >> PAGE_SHIFT;
+
+   ptes = (extra + PAGE_SIZE - 1) >> PAGE_SHIFT;
+   } else
+   ptes = (end + PAGE_SIZE - 1) >> PAGE_SHIFT;
+
+   tables += roundup(ptes * sizeof(pte_t), PAGE_SIZE);
+
+#ifdef CONFIG_X86_32
+   /* for fixmap */
+   tables += roundup(__end_of_fixed_addresses * sizeof(pte_t), PAGE_SIZE);
+#endif
+
+   return tables;
+}
+
+static void __init find_early_table_space(unsigned long start,
+ unsigned long good_end,
+ unsigned long tables)
+{
+   phys_addr_t base;
+
+   base = memblock_find_in_range(start, good_end, tables, PAGE_SIZE);
+   if (!base)
+   panic("Cannot find space for the kernel page tables");
+
+   pgt_buf_start = base >> PAGE_SHIFT;
+   pgt_buf_end = pgt_buf_start;
+   pgt_buf_top = pgt_buf_start + (tables >> PAGE_SHIFT);
+}
+
 /*
  * Setup the direct mapping of the physical memory at PAGE_OFFSET.
  * This runs before bootmem is initialized and gets pages directly from
-- 
1.7.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH -v2 12/13] x86, mm: Use func pointer to table size calculation and mapping.

2012-09-02 Thread Yinghai Lu
They all need to go over ram range in same sequence. So add shared function
to reduce duplicated code.

Signed-off-by: Yinghai Lu 
---
 arch/x86/mm/init.c |   64 ++-
 1 files changed, 23 insertions(+), 41 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 7830db9..343d925 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -243,14 +243,15 @@ static unsigned long __init 
calculate_table_space_size(unsigned long start,
return tables;
 }
 
-static unsigned long __init calculate_all_table_space_size(void)
+static void __init with_all_ram_ranges(
+   void (*work_fn)(unsigned long, unsigned long, void *),
+   void *data)
 {
unsigned long start_pfn, end_pfn;
-   unsigned long tables;
int i;
 
/* the ISA range is always mapped regardless of memory holes */
-   tables = calculate_table_space_size(0, ISA_END_ADDRESS);
+   work_fn(0, ISA_END_ADDRESS, data);
 
for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, NULL) {
u64 start = start_pfn << PAGE_SHIFT;
@@ -269,10 +270,15 @@ static unsigned long __init 
calculate_all_table_space_size(void)
if ((end >> PAGE_SHIFT) > max_low_pfn)
end = max_low_pfn << PAGE_SHIFT;
 #endif
-   tables += calculate_table_space_size(start, end);
+   work_fn(start, end, data);
}
+}
 
-   return tables;
+static void __init size_work_fn(unsigned long start, unsigned long end, void 
*data)
+{
+   unsigned long *size = data;
+
+   *size += calculate_table_space_size(start, end);
 }
 
 static void __init find_early_table_space(unsigned long start,
@@ -361,45 +367,15 @@ unsigned long __init_refok init_memory_mapping(unsigned 
long start,
  * Depending on the alignment of E820 ranges, this may possibly result in using
  * smaller size (i.e. 4K instead of 2M or 1G) page tables.
  */
-static void __init init_all_memory_mapping(void)
+static void __init mapping_work_fn(unsigned long start, unsigned long end,
+void *data)
 {
-   unsigned long start_pfn, end_pfn;
-   int i;
-
-   /* the ISA range is always mapped regardless of memory holes */
-   init_memory_mapping(0, ISA_END_ADDRESS);
-
-   for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, NULL) {
-   u64 start = start_pfn << PAGE_SHIFT;
-   u64 end = end_pfn << PAGE_SHIFT;
-
-   if (end <= ISA_END_ADDRESS)
-   continue;
-
-   if (start < ISA_END_ADDRESS)
-   start = ISA_END_ADDRESS;
-#ifdef CONFIG_X86_32
-   /* on 32 bit, we only map up to max_low_pfn */
-   if ((start >> PAGE_SHIFT) >= max_low_pfn)
-   continue;
-
-   if ((end >> PAGE_SHIFT) > max_low_pfn)
-   end = max_low_pfn << PAGE_SHIFT;
-#endif
-   init_memory_mapping(start, end);
-   }
-
-#ifdef CONFIG_X86_64
-   if (max_pfn > max_low_pfn) {
-   /* can we preseve max_low_pfn ?*/
-   max_low_pfn = max_pfn;
-   }
-#endif
+   init_memory_mapping(start, end);
 }
 
 void __init init_mem_mapping(void)
 {
-   unsigned long tables, good_end, end;
+   unsigned long tables = 0, good_end, end;
 
probe_page_size_mask();
 
@@ -417,15 +393,21 @@ void __init init_mem_mapping(void)
end = max_low_pfn << PAGE_SHIFT;
good_end = max_pfn_mapped << PAGE_SHIFT;
 #endif
-   tables = calculate_all_table_space_size();
+   with_all_ram_ranges(size_work_fn, &tables);
find_early_table_space(0, good_end, tables);
printk(KERN_DEBUG "kernel direct mapping tables up to %#lx @ [mem 
%#010lx-%#010lx] prealloc\n",
end - 1, pgt_buf_start << PAGE_SHIFT,
(pgt_buf_top << PAGE_SHIFT) - 1);
 
max_pfn_mapped = 0; /* will get exact value next */
-   init_all_memory_mapping();
+   with_all_ram_ranges(mapping_work_fn, NULL);
 
+#ifdef CONFIG_X86_64
+   if (max_pfn > max_low_pfn) {
+   /* can we preseve max_low_pfn ?*/
+   max_low_pfn = max_pfn;
+   }
+#endif
/*
 * Reserve the kernel pagetable pages we used (pgt_buf_start -
 * pgt_buf_end) and free the other ones (pgt_buf_end - pgt_buf_top)
-- 
1.7.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH -v2 01/13] x86, mm: Add global page_size_mask

2012-09-02 Thread Yinghai Lu
detect if need to use 1G or 2M and store them in page_size_mask.

Only probe them one time.

Suggested-by: Ingo Molnar 
Signed-off-by: Yinghai Lu 
---
 arch/x86/include/asm/pgtable.h |1 +
 arch/x86/kernel/setup.c|1 +
 arch/x86/mm/init.c |   66 +++-
 3 files changed, 33 insertions(+), 35 deletions(-)

diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 49afb3f..e47e4db 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -597,6 +597,7 @@ static inline int pgd_none(pgd_t pgd)
 #ifndef __ASSEMBLY__
 
 extern int direct_gbpages;
+void probe_page_size_mask(void);
 
 /* local pte updates need not use xchg for locking */
 static inline pte_t native_local_ptep_get_and_clear(pte_t *ptep)
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index f4b9b80..d6e8c03 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -912,6 +912,7 @@ void __init setup_arch(char **cmdline_p)
setup_real_mode();
 
init_gbpages();
+   probe_page_size_mask();
 
/* max_pfn_mapped is updated here */
max_low_pfn_mapped = init_memory_mapping(0, max_low_pfn<> PUD_SHIFT;
tables = roundup(puds * sizeof(pud_t), PAGE_SIZE);
 
-   if (use_gbpages) {
+   if (page_size_mask & (1 << PG_LEVEL_1G)) {
unsigned long extra;
 
extra = end - ((end>>PUD_SHIFT) << PUD_SHIFT);
@@ -54,7 +56,7 @@ static void __init find_early_table_space(struct map_range 
*mr, unsigned long en
 
tables += roundup(pmds * sizeof(pmd_t), PAGE_SIZE);
 
-   if (use_pse) {
+   if (page_size_mask & (1 << PG_LEVEL_2M)) {
unsigned long extra;
 
extra = end - ((end>>PMD_SHIFT) << PMD_SHIFT);
@@ -90,6 +92,30 @@ static void __init find_early_table_space(struct map_range 
*mr, unsigned long en
(pgt_buf_top << PAGE_SHIFT) - 1);
 }
 
+void probe_page_size_mask(void)
+{
+#if !defined(CONFIG_DEBUG_PAGEALLOC) && !defined(CONFIG_KMEMCHECK)
+   /*
+* For CONFIG_DEBUG_PAGEALLOC, identity mapping will use small pages.
+* This will simplify cpa(), which otherwise needs to support splitting
+* large pages into small in interrupt context, etc.
+*/
+   if (direct_gbpages)
+   page_size_mask |= 1 << PG_LEVEL_1G;
+   if (cpu_has_pse)
+   page_size_mask |= 1 << PG_LEVEL_2M;
+#endif
+
+   /* Enable PSE if available */
+   if (cpu_has_pse)
+   set_in_cr4(X86_CR4_PSE);
+
+   /* Enable PGE if available */
+   if (cpu_has_pge) {
+   set_in_cr4(X86_CR4_PGE);
+   __supported_pte_mask |= _PAGE_GLOBAL;
+   }
+}
 void __init native_pagetable_reserve(u64 start, u64 end)
 {
memblock_reserve(start, end - start);
@@ -125,45 +151,15 @@ static int __meminit save_mr(struct map_range *mr, int 
nr_range,
 unsigned long __init_refok init_memory_mapping(unsigned long start,
   unsigned long end)
 {
-   unsigned long page_size_mask = 0;
unsigned long start_pfn, end_pfn;
unsigned long ret = 0;
unsigned long pos;
-
struct map_range mr[NR_RANGE_MR];
int nr_range, i;
-   int use_pse, use_gbpages;
 
printk(KERN_INFO "init_memory_mapping: [mem %#010lx-%#010lx]\n",
   start, end - 1);
 
-#if defined(CONFIG_DEBUG_PAGEALLOC) || defined(CONFIG_KMEMCHECK)
-   /*
-* For CONFIG_DEBUG_PAGEALLOC, identity mapping will use small pages.
-* This will simplify cpa(), which otherwise needs to support splitting
-* large pages into small in interrupt context, etc.
-*/
-   use_pse = use_gbpages = 0;
-#else
-   use_pse = cpu_has_pse;
-   use_gbpages = direct_gbpages;
-#endif
-
-   /* Enable PSE if available */
-   if (cpu_has_pse)
-   set_in_cr4(X86_CR4_PSE);
-
-   /* Enable PGE if available */
-   if (cpu_has_pge) {
-   set_in_cr4(X86_CR4_PGE);
-   __supported_pte_mask |= _PAGE_GLOBAL;
-   }
-
-   if (use_gbpages)
-   page_size_mask |= 1 << PG_LEVEL_1G;
-   if (use_pse)
-   page_size_mask |= 1 << PG_LEVEL_2M;
-
memset(mr, 0, sizeof(mr));
nr_range = 0;
 
@@ -267,7 +263,7 @@ unsigned long __init_refok init_memory_mapping(unsigned 
long start,
 * nodes are discovered.
 */
if (!after_bootmem)
-   find_early_table_space(&mr[0], end, use_pse, use_gbpages);
+   find_early_table_space(&mr[0], end);
 
for (i = 0; i < nr_range; i++)
ret = kernel_physical_mapping_init(mr[i].start, mr[i].end,
-- 
1.7.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the

[PATCH -v2 03/13] x86, mm: Moving init_memory_mapping calling

2012-09-02 Thread Yinghai Lu
from setup.c to mm/init.c

So could update all related calling together later

Signed-off-by: Yinghai Lu 
---
 arch/x86/include/asm/init.h|1 -
 arch/x86/include/asm/pgtable.h |2 +-
 arch/x86/kernel/setup.c|   13 +
 arch/x86/mm/init.c |   19 ++-
 4 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/init.h b/arch/x86/include/asm/init.h
index adcc0ae..4f13998 100644
--- a/arch/x86/include/asm/init.h
+++ b/arch/x86/include/asm/init.h
@@ -12,7 +12,6 @@ kernel_physical_mapping_init(unsigned long start,
 unsigned long end,
 unsigned long page_size_mask);
 
-
 extern unsigned long __initdata pgt_buf_start;
 extern unsigned long __meminitdata pgt_buf_end;
 extern unsigned long __meminitdata pgt_buf_top;
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index e47e4db..ae2cabb 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -597,7 +597,7 @@ static inline int pgd_none(pgd_t pgd)
 #ifndef __ASSEMBLY__
 
 extern int direct_gbpages;
-void probe_page_size_mask(void);
+void init_mem_mapping(void);
 
 /* local pte updates need not use xchg for locking */
 static inline pte_t native_local_ptep_get_and_clear(pte_t *ptep)
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index d6e8c03..c30c78c 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -912,20 +912,9 @@ void __init setup_arch(char **cmdline_p)
setup_real_mode();
 
init_gbpages();
-   probe_page_size_mask();
 
-   /* max_pfn_mapped is updated here */
-   max_low_pfn_mapped = init_memory_mapping(0, max_low_pfn< max_low_pfn) {
-   max_pfn_mapped = init_memory_mapping(1UL<<32,
-max_pfn<> PAGE_SHIFT;
 }
 
+void __init init_mem_mapping(void)
+{
+   probe_page_size_mask();
+
+   /* max_pfn_mapped is updated here */
+   max_low_pfn_mapped = init_memory_mapping(0, max_low_pfn< max_low_pfn) {
+   max_pfn_mapped = init_memory_mapping(1UL<<32,
+max_pfn

[PATCH -v2 09/13] x86: Fixup code testing if a pfn is direct mapped

2012-09-02 Thread Yinghai Lu
From: Jacob Shin 

Update code that previously assumed pfns [ 0 - max_low_pfn_mapped ) and
[ 4GB - max_pfn_mapped ) were always direct mapped, to now look up
pfn_mapped ranges instead.


-v2: change applying sequence to keep git bisecting working.
 so add dummy pfn_range_is_mapped(). - Yinghai Lu

Signed-off-by: Jacob Shin 
---
 arch/x86/include/asm/page_types.h |8 
 arch/x86/kernel/cpu/amd.c |8 +++-
 arch/x86/platform/efi/efi.c   |8 
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/arch/x86/include/asm/page_types.h 
b/arch/x86/include/asm/page_types.h
index e21fdd1..45aae6e 100644
--- a/arch/x86/include/asm/page_types.h
+++ b/arch/x86/include/asm/page_types.h
@@ -51,6 +51,14 @@ static inline phys_addr_t get_max_mapped(void)
return (phys_addr_t)max_pfn_mapped << PAGE_SHIFT;
 }
 
+static inline bool pfn_range_is_mapped(unsigned long start_pfn,
+   unsigned long end_pfn)
+{
+   return end_pfn <= max_low_pfn_mapped ||
+  (end_pfn > (1UL << (32 - PAGE_SHIFT)) &&
+   end_pfn <= max_pfn_mapped);
+}
+
 extern unsigned long init_memory_mapping(unsigned long start,
 unsigned long end);
 
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 9d92e19..4235553 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -676,12 +676,10 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
 * benefit in doing so.
 */
if (!rdmsrl_safe(MSR_K8_TSEG_ADDR, &tseg)) {
+   unsigned long pfn = tseg >> PAGE_SHIFT;
+
printk(KERN_DEBUG "tseg: %010llx\n", tseg);
-   if ((tseg>>PMD_SHIFT) <
-   (max_low_pfn_mapped>>(PMD_SHIFT-PAGE_SHIFT)) ||
-   ((tseg>>PMD_SHIFT) <
-   (max_pfn_mapped>>(PMD_SHIFT-PAGE_SHIFT)) &&
-   (tseg>>PMD_SHIFT) >= (1ULL<<(32 - PMD_SHIFT
+   if (pfn_range_is_mapped(pfn, pfn + 1))
set_memory_4k((unsigned long)__va(tseg), 1);
}
}
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 92660eda..f1facde 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -776,7 +776,7 @@ void __init efi_enter_virtual_mode(void)
efi_memory_desc_t *md, *prev_md = NULL;
efi_status_t status;
unsigned long size;
-   u64 end, systab, addr, npages, end_pfn;
+   u64 end, systab, addr, npages, start_pfn, end_pfn;
void *p, *va, *new_memmap = NULL;
int count = 0;
 
@@ -827,10 +827,10 @@ void __init efi_enter_virtual_mode(void)
size = md->num_pages << EFI_PAGE_SHIFT;
end = md->phys_addr + size;
 
+   start_pfn = PFN_DOWN(md->phys_addr);
end_pfn = PFN_UP(end);
-   if (end_pfn <= max_low_pfn_mapped
-   || (end_pfn > (1UL << (32 - PAGE_SHIFT))
-   && end_pfn <= max_pfn_mapped))
+
+   if (pfn_range_is_mapped(start_pfn, end_pfn))
va = __va(md->phys_addr);
else
va = efi_ioremap(md->phys_addr, size, md->type);
-- 
1.7.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH -v2 11/13] x86/mm: calculate_table_space_size based on memory ranges that are being mapped

2012-09-02 Thread Yinghai Lu
From: Jacob Shin 

Current logic finds enough space for direct mapping page tables from 0
to end. Instead, we only need to find enough space to cover mr[0].start
to mr[nr_range].end -- the range that is actually being mapped by
init_memory_mapping()

This patch also reportedly fixes suspend/resume issue reported in:

https://lkml.org/lkml/2012/8/11/83

-v2: update with calculate_table_space_size()
 clear max_pfn_mapped before init_all_memory_mapping to get right value
  -Yinghai Lu

Signed-off-by: Jacob Shin 
---
 arch/x86/mm/init.c |   51 ++-
 1 files changed, 30 insertions(+), 21 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 47b6e41..7830db9 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -191,39 +191,48 @@ static int __meminit split_mem_range(struct map_range 
*mr, int nr_range,
return nr_range;
 }
 
-static unsigned long __init calculate_table_space_size(unsigned long begin,
+static unsigned long __init calculate_table_space_size(unsigned long start,
  unsigned long end)
 {
-   unsigned long puds, pmds, ptes, tables;
+   unsigned long puds = 0, pmds = 0, ptes = 0, tables;
+   struct map_range mr[NR_RANGE_MR];
+   int nr_range, i;
 
-   puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
-   tables = roundup(puds * sizeof(pud_t), PAGE_SIZE);
+   pr_info("calculate_table_space_size: [mem %#010lx-%#010lx]\n",
+  start, end - 1);
 
-   if (page_size_mask & (1 << PG_LEVEL_1G)) {
-   unsigned long extra;
+   memset(mr, 0, sizeof(mr));
+   nr_range = 0;
+   nr_range = split_mem_range(mr, nr_range, start, end);
 
-   extra = end - ((end>>PUD_SHIFT) << PUD_SHIFT);
-   pmds = (extra + PMD_SIZE - 1) >> PMD_SHIFT;
-   } else
-   pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
+   for (i = 0; i < nr_range; i++) {
+   unsigned long range, extra;
 
-   tables += roundup(pmds * sizeof(pmd_t), PAGE_SIZE);
+   range = mr[i].end - mr[i].start;
+   puds += (range + PUD_SIZE - 1) >> PUD_SHIFT;
 
-   if (page_size_mask & (1 << PG_LEVEL_2M)) {
-   unsigned long extra;
+   if (mr[i].page_size_mask & (1 << PG_LEVEL_1G)) {
+   extra = range - ((range >> PUD_SHIFT) << PUD_SHIFT);
+   pmds += (extra + PMD_SIZE - 1) >> PMD_SHIFT;
+   } else
+   pmds += (range + PMD_SIZE - 1) >> PMD_SHIFT;
 
-   extra = end - ((end>>PMD_SHIFT) << PMD_SHIFT);
+   if (mr[i].page_size_mask & (1 << PG_LEVEL_2M)) {
+   extra = range - ((range >> PMD_SHIFT) << PMD_SHIFT);
 #ifdef CONFIG_X86_32
-   extra += PMD_SIZE;
+   extra += PMD_SIZE;
 #endif
-   /* The first 2/4M doesn't use large pages. */
-   if (begin < PMD_SIZE)
-   extra += (PMD_SIZE - begin) >> PAGE_SHIFT;
+   /* The first 2/4M doesn't use large pages. */
+   if (mr[i].start < PMD_SIZE)
+   extra += range;
 
-   ptes = (extra + PAGE_SIZE - 1) >> PAGE_SHIFT;
-   } else
-   ptes = (end + PAGE_SIZE - 1) >> PAGE_SHIFT;
+   ptes += (extra + PAGE_SIZE - 1) >> PAGE_SHIFT;
+   } else
+   ptes += (range + PAGE_SIZE - 1) >> PAGE_SHIFT;
+   }
 
+   tables = roundup(puds * sizeof(pud_t), PAGE_SIZE);
+   tables += roundup(pmds * sizeof(pmd_t), PAGE_SIZE);
tables += roundup(ptes * sizeof(pte_t), PAGE_SIZE);
 
 #ifdef CONFIG_X86_32
-- 
1.7.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH -v2 06/13] x86, mm: Separate out calculate_table_space_size()

2012-09-02 Thread Yinghai Lu
it should take physical address range that will need to be mapped.
and find_early_table_space should take range that pgt buff should be in.
Separate those two to reduce confusion.

Signed-off-by: Yinghai Lu 
---
 arch/x86/mm/init.c |   39 ---
 1 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 0ada295..fcb44c5 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -37,11 +37,10 @@ struct map_range {
 
 static int page_size_mask;
 
-static void __init find_early_table_space(unsigned long begin,
+static unsigned long __init calculate_table_space_size(unsigned long begin,
  unsigned long end)
 {
-   unsigned long puds, pmds, ptes, tables, start = 0, good_end = end;
-   phys_addr_t base;
+   unsigned long puds, pmds, ptes, tables;
 
puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
tables = roundup(puds * sizeof(pud_t), PAGE_SIZE);
@@ -76,9 +75,17 @@ static void __init find_early_table_space(unsigned long 
begin,
 #ifdef CONFIG_X86_32
/* for fixmap */
tables += roundup(__end_of_fixed_addresses * sizeof(pte_t), PAGE_SIZE);
-   good_end = max_pfn_mapped << PAGE_SHIFT;
 #endif
 
+   return tables;
+}
+
+static void __init find_early_table_space(unsigned long start,
+ unsigned long good_end,
+ unsigned long tables)
+{
+   phys_addr_t base;
+
base = memblock_find_in_range(start, good_end, tables, PAGE_SIZE);
if (!base)
panic("Cannot find space for the kernel page tables");
@@ -86,10 +93,6 @@ static void __init find_early_table_space(unsigned long 
begin,
pgt_buf_start = base >> PAGE_SHIFT;
pgt_buf_end = pgt_buf_start;
pgt_buf_top = pgt_buf_start + (tables >> PAGE_SHIFT);
-
-   printk(KERN_DEBUG "kernel direct mapping tables up to %#lx @ [mem 
%#010lx-%#010lx]\n",
-   end - 1, pgt_buf_start << PAGE_SHIFT,
-   (pgt_buf_top << PAGE_SHIFT) - 1);
 }
 
 static void __init probe_page_size_mask(void)
@@ -282,6 +285,8 @@ unsigned long __init_refok init_memory_mapping(unsigned 
long start,
 
 void __init init_mem_mapping(void)
 {
+   unsigned long tables, good_end, end;
+
probe_page_size_mask();
 
/*
@@ -292,10 +297,18 @@ void __init init_mem_mapping(void)
 * nodes are discovered.
 */
 #ifdef CONFIG_X86_64
-   find_early_table_space(0, max_pfn< pgt_buf_start)
+   if (pgt_buf_end > pgt_buf_start) {
+   printk(KERN_DEBUG "kernel direct mapping tables up to %#lx @ 
[mem %#010lx-%#010lx] final\n",
+   end - 1, pgt_buf_start << PAGE_SHIFT,
+   (pgt_buf_end << PAGE_SHIFT) - 1);
x86_init.mapping.pagetable_reserve(PFN_PHYS(pgt_buf_start),
PFN_PHYS(pgt_buf_end));
+   }
 
/* stop the wrong using */
pgt_buf_top = 0;
-- 
1.7.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH -v2 13/13] x86, 64bit: Map first 1M ram early before memblock_x86_fill()

2012-09-02 Thread Yinghai Lu
This one intend to fix bugs:
when efi booting have too many memmap entries, will need to double memblock
memory array or reserved array.

For 64bit, We have low kernel mapping, and high kernel mapping.
high kernel mapping is done early in head_64.S.
low kernel mapping is done in init_memory_mapping.

Now we have max_pfn_mapped actually is for high mapping, so later we
need to get buff for the doubling memblock, but we can not use it.
as __va will return virtual address with low kernel mapping.

The patch will try to map first 1M range, and find early page table space
from BRK.

Also add max_pfn_high_mapped to track high mapped range.

Signed-off-by: Yinghai Lu 
---
 arch/x86/include/asm/page_types.h |1 +
 arch/x86/include/asm/pgtable.h|1 +
 arch/x86/kernel/head64.c  |2 +-
 arch/x86/kernel/setup.c   |2 ++
 arch/x86/mm/init.c|   37 +++--
 arch/x86/mm/init_64.c |7 ++-
 6 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/page_types.h 
b/arch/x86/include/asm/page_types.h
index 54c9787..1903736 100644
--- a/arch/x86/include/asm/page_types.h
+++ b/arch/x86/include/asm/page_types.h
@@ -45,6 +45,7 @@ extern int devmem_is_allowed(unsigned long pagenr);
 
 extern unsigned long max_low_pfn_mapped;
 extern unsigned long max_pfn_mapped;
+extern unsigned long max_pfn_high_mapped;
 
 static inline phys_addr_t get_max_mapped(void)
 {
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index ae2cabb..c67a684 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -598,6 +598,7 @@ static inline int pgd_none(pgd_t pgd)
 
 extern int direct_gbpages;
 void init_mem_mapping(void);
+void early_init_mem_mapping(void);
 
 /* local pte updates need not use xchg for locking */
 static inline pte_t native_local_ptep_get_and_clear(pte_t *ptep)
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index 037df57..b11bde0 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -76,7 +76,7 @@ void __init x86_64_start_kernel(char * real_mode_data)
/* Make NULL pointers segfault */
zap_identity_mappings();
 
-   max_pfn_mapped = KERNEL_IMAGE_SIZE >> PAGE_SHIFT;
+   max_pfn_high_mapped = KERNEL_IMAGE_SIZE >> PAGE_SHIFT;
 
for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) {
 #ifdef CONFIG_EARLY_PRINTK
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 2eb91b7..b942036 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -896,6 +896,8 @@ void __init setup_arch(char **cmdline_p)
 
reserve_ibft_region();
 
+   early_init_mem_mapping();
+
/*
 * Need to conclude brk, before memblock_x86_fill()
 *  it could use memblock_find_in_range, could overlap with
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 343d925..c96b731 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -377,8 +377,6 @@ void __init init_mem_mapping(void)
 {
unsigned long tables = 0, good_end, end;
 
-   probe_page_size_mask();
-
/*
 * Find space for the kernel direct mapping tables.
 *
@@ -437,6 +435,41 @@ void __init init_mem_mapping(void)
early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
 }
 
+RESERVE_BRK(early_pgt_alloc, 65536);
+
+void  __init early_init_mem_mapping(void)
+{
+   unsigned long tables;
+   phys_addr_t base;
+   unsigned long start = 0, end = ISA_END_ADDRESS;
+
+   probe_page_size_mask();
+
+   if (max_pfn_mapped)
+   return;
+
+   tables = calculate_table_space_size(start, end);
+   base = __pa(extend_brk(tables, PAGE_SIZE));
+
+   pgt_buf_start = base >> PAGE_SHIFT;
+   pgt_buf_end = pgt_buf_start;
+   pgt_buf_top = pgt_buf_start + (tables >> PAGE_SHIFT);
+
+   printk(KERN_DEBUG "kernel direct mapping tables up to %#lx @ [mem 
%#010lx-%#010lx] prealloc\n",
+   end - 1, pgt_buf_start << PAGE_SHIFT,
+   (pgt_buf_top << PAGE_SHIFT) - 1);
+
+   init_memory_mapping(start, end);
+
+   printk(KERN_DEBUG "kernel direct mapping tables up to %#lx @ [mem 
%#010lx-%#010lx] final\n",
+   end - 1, pgt_buf_start << PAGE_SHIFT,
+   (pgt_buf_end << PAGE_SHIFT) - 1);
+   /* return not used brk */
+   _brk_end -= (pgt_buf_top - pgt_buf_end) << PAGE_SHIFT;
+
+   pgt_buf_top = 0;
+}
+
 /*
  * devmem_is_allowed() checks to see if /dev/mem access to a certain address
  * is valid. The argument is a physical page number.
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index ab558eb..832ac89 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -286,6 +286,7 @@ void __init init_extra_mapping_uc(unsigned long phys, 
unsigned long size)
__init_extra_mapping(phys, size, PAGE_KERNEL_LARGE_NOCACHE);
 }
 
+unsigned long max_pfn_high_mapped;
 /*
  * The head.S code sets up the

[PATCH -v2 10/13] x86: Only direct map addresses that are marked as E820_RAM

2012-09-02 Thread Yinghai Lu
From: Jacob Shin 

Currently direct mappings are created for [ 0 to max_low_pfn<
---
 arch/x86/include/asm/page_types.h |8 +--
 arch/x86/kernel/setup.c   |8 ++-
 arch/x86/mm/init.c|  119 +
 arch/x86/mm/init_64.c |6 +-
 4 files changed, 116 insertions(+), 25 deletions(-)

diff --git a/arch/x86/include/asm/page_types.h 
b/arch/x86/include/asm/page_types.h
index 45aae6e..54c9787 100644
--- a/arch/x86/include/asm/page_types.h
+++ b/arch/x86/include/asm/page_types.h
@@ -51,13 +51,7 @@ static inline phys_addr_t get_max_mapped(void)
return (phys_addr_t)max_pfn_mapped << PAGE_SHIFT;
 }
 
-static inline bool pfn_range_is_mapped(unsigned long start_pfn,
-   unsigned long end_pfn)
-{
-   return end_pfn <= max_low_pfn_mapped ||
-  (end_pfn > (1UL << (32 - PAGE_SHIFT)) &&
-   end_pfn <= max_pfn_mapped);
-}
+bool pfn_range_is_mapped(unsigned long start_pfn, unsigned long end_pfn);
 
 extern unsigned long init_memory_mapping(unsigned long start,
 unsigned long end);
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 587dcd9..2eb91b7 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -115,9 +115,11 @@
 #include 
 
 /*
- * end_pfn only includes RAM, while max_pfn_mapped includes all e820 entries.
- * The direct mapping extends to max_pfn_mapped, so that we can directly access
- * apertures, ACPI and other tables without having to play with fixmaps.
+ * max_low_pfn_mapped: highest direct mapped pfn under 4GB
+ * max_pfn_mapped: highest direct mapped pfn over 4GB
+ *
+ * The direct mapping only covers E820_RAM regions, so the ranges and gaps are
+ * represented by pfn_mapped
  */
 unsigned long max_low_pfn_mapped;
 unsigned long max_pfn_mapped;
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index a475d7f..47b6e41 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -234,6 +234,38 @@ static unsigned long __init 
calculate_table_space_size(unsigned long begin,
return tables;
 }
 
+static unsigned long __init calculate_all_table_space_size(void)
+{
+   unsigned long start_pfn, end_pfn;
+   unsigned long tables;
+   int i;
+
+   /* the ISA range is always mapped regardless of memory holes */
+   tables = calculate_table_space_size(0, ISA_END_ADDRESS);
+
+   for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, NULL) {
+   u64 start = start_pfn << PAGE_SHIFT;
+   u64 end = end_pfn << PAGE_SHIFT;
+
+   if (end <= ISA_END_ADDRESS)
+   continue;
+
+   if (start < ISA_END_ADDRESS)
+   start = ISA_END_ADDRESS;
+#ifdef CONFIG_X86_32
+   /* on 32 bit, we only map up to max_low_pfn */
+   if ((start >> PAGE_SHIFT) >= max_low_pfn)
+   continue;
+
+   if ((end >> PAGE_SHIFT) > max_low_pfn)
+   end = max_low_pfn << PAGE_SHIFT;
+#endif
+   tables += calculate_table_space_size(start, end);
+   }
+
+   return tables;
+}
+
 static void __init find_early_table_space(unsigned long start,
  unsigned long good_end,
  unsigned long tables)
@@ -249,6 +281,33 @@ static void __init find_early_table_space(unsigned long 
start,
pgt_buf_top = pgt_buf_start + (tables >> PAGE_SHIFT);
 }
 
+static struct range pfn_mapped[E820_X_MAX];
+static int nr_pfn_mapped;
+
+static void add_pfn_range_mapped(unsigned long start_pfn, unsigned long 
end_pfn)
+{
+   nr_pfn_mapped = add_range_with_merge(pfn_mapped, E820_X_MAX,
+nr_pfn_mapped, start_pfn, end_pfn);
+   nr_pfn_mapped = clean_sort_range(pfn_mapped, E820_X_MAX);
+
+   max_pfn_mapped = max(max_pfn_mapped, end_pfn);
+
+   if (end_pfn <= (1UL << (32 - PAGE_SHIFT)))
+   max_low_pfn_mapped = max(max_low_pfn_mapped, end_pfn);
+}
+
+bool pfn_range_is_mapped(unsigned long start_pfn, unsigned long end_pfn)
+{
+   int i;
+
+   for (i = 0; i < nr_pfn_mapped; i++)
+   if ((start_pfn >= pfn_mapped[i].start) &&
+   (end_pfn <= pfn_mapped[i].end))
+   return true;
+
+   return false;
+}
+
 /*
  * Setup the direct mapping of the physical memory at PAGE_OFFSET.
  * This runs before bootmem is initialized and gets pages directly from
@@ -280,9 +339,55 @@ unsigned long __init_refok init_memory_mapping(unsigned 
long start,
 
__flush_tlb_all();
 
+   add_pfn_range_mapped(start >> PAGE_SHIFT, ret >> PAGE_SHIFT);
+
return ret >> PAGE_SHIFT;
 }
 
+/*
+ * Iterate through E820 memory map and create direct mappings for only E820_RAM
+ * regions. We cannot simply create direct mappings for all pfns from
+ * [0 to max_low_pfn) and [4GB to m

[PATCH -v2 05/13] x86, mm: Find early page table only one time

2012-09-02 Thread Yinghai Lu
Should not do that in every calling of init_memory_mapping.
Actually in early time, only need do once.

Also move down early_memtest.

-v2: fix one early_memtest with 32bit by passing max_pfn_mapped instead.

Signed-off-by: Yinghai Lu 
---
 arch/x86/mm/init.c |   72 ++-
 1 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index cca9b7d..0ada295 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -37,7 +37,7 @@ struct map_range {
 
 static int page_size_mask;
 
-static void __init find_early_table_space(struct map_range *mr,
+static void __init find_early_table_space(unsigned long begin,
  unsigned long end)
 {
unsigned long puds, pmds, ptes, tables, start = 0, good_end = end;
@@ -64,8 +64,8 @@ static void __init find_early_table_space(struct map_range 
*mr,
extra += PMD_SIZE;
 #endif
/* The first 2/4M doesn't use large pages. */
-   if (mr->start < PMD_SIZE)
-   extra += mr->end - mr->start;
+   if (begin < PMD_SIZE)
+   extra += (PMD_SIZE - begin) >> PAGE_SHIFT;
 
ptes = (extra + PAGE_SIZE - 1) >> PAGE_SHIFT;
} else
@@ -265,16 +265,6 @@ unsigned long __init_refok init_memory_mapping(unsigned 
long start,
nr_range = 0;
nr_range = split_mem_range(mr, nr_range, start, end);
 
-   /*
-* Find space for the kernel direct mapping tables.
-*
-* Later we should allocate these tables in the local node of the
-* memory mapped. Unfortunately this is done currently before the
-* nodes are discovered.
-*/
-   if (!after_bootmem)
-   find_early_table_space(&mr[0], end);
-
for (i = 0; i < nr_range; i++)
ret = kernel_physical_mapping_init(mr[i].start, mr[i].end,
   mr[i].page_size_mask);
@@ -287,6 +277,36 @@ unsigned long __init_refok init_memory_mapping(unsigned 
long start,
 
__flush_tlb_all();
 
+   return ret >> PAGE_SHIFT;
+}
+
+void __init init_mem_mapping(void)
+{
+   probe_page_size_mask();
+
+   /*
+* Find space for the kernel direct mapping tables.
+*
+* Later we should allocate these tables in the local node of the
+* memory mapped. Unfortunately this is done currently before the
+* nodes are discovered.
+*/
+#ifdef CONFIG_X86_64
+   find_early_table_space(0, max_pfn< max_low_pfn) {
+   max_pfn_mapped = init_memory_mapping(1UL<<32,
+max_pfn< pgt_buf_start)
+   if (pgt_buf_end > pgt_buf_start)
x86_init.mapping.pagetable_reserve(PFN_PHYS(pgt_buf_start),
PFN_PHYS(pgt_buf_end));
 
-   if (!after_bootmem)
-   early_memtest(start, end);
+   /* stop the wrong using */
+   pgt_buf_top = 0;
 
-   return ret >> PAGE_SHIFT;
-}
-
-void __init init_mem_mapping(void)
-{
-   probe_page_size_mask();
-
-   /* max_pfn_mapped is updated here */
-   max_low_pfn_mapped = init_memory_mapping(0, max_low_pfn< max_low_pfn) {
-   max_pfn_mapped = init_memory_mapping(1UL<<32,
-max_pfn

[PATCH -v2 08/13] x86: if kernel .text .data .bss are not marked as E820_RAM, complain and fix

2012-09-02 Thread Yinghai Lu
From: Jacob Shin 

There could be cases where user supplied memmap=exactmap memory
mappings do not mark the region where the kernel .text .data and
.bss reside as E820_RAM, as reported here:

https://lkml.org/lkml/2012/8/14/86

Handle it by complaining, and adding the range back into the e820.

Signed-off-by: Jacob Shin 
---
 arch/x86/kernel/setup.c |   14 ++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index c30c78c..587dcd9 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -831,6 +831,20 @@ void __init setup_arch(char **cmdline_p)
insert_resource(&iomem_resource, &data_resource);
insert_resource(&iomem_resource, &bss_resource);
 
+   /*
+* Complain if .text .data and .bss are not marked as E820_RAM and
+* attempt to fix it by adding the range. We may have a confused BIOS,
+* or the user may have incorrectly supplied it via memmap=exactmap. If
+* we really are running on top non-RAM, we will crash later anyways.
+*/
+   if (!e820_all_mapped(code_resource.start, __pa(__brk_limit), E820_RAM)) 
{
+   pr_warn(".text .data .bss are not marked as E820_RAM!\n");
+
+   e820_add_region(code_resource.start,
+   __pa(__brk_limit) - code_resource.start + 1,
+   E820_RAM);
+   }
+
trim_bios_range();
 #ifdef CONFIG_X86_32
if (ppro_with_ram_bug()) {
-- 
1.7.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


input0: bad kobj_uevent_env content in show_uevent()

2012-09-02 Thread Fengguang Wu
Hi all,

After the __devinit* removal series, I can still get kernel panic in
show_uevent(). So there are more sources of bug..

Debug patch:

@@ -343,8 +343,11 @@ static ssize_t show_uevent(struct device
goto out;

/* copy keys to file */
-   for (i = 0; i < env->envp_idx; i++)
+   dev_err(dev, "uevent %d env[%d]: %s/.../%s\n", env->buflen, 
env->envp_idx, top_kobj->name, dev->kobj.name);
+   for (i = 0; i < env->envp_idx; i++) {
+   printk(KERN_ERR "uevent %d env[%d]: %s\n", (int)count, i, 
env->envp[i]);
count += sprintf(&buf[count], "%s\n", env->envp[i]);
+   }

Oops message, the env[] is again not properly initilized:

[   44.068623] input input0: uevent 61 env[805306368]: input0/.../input0
[   44.069552] uevent 0 env[0]: (null)
[   44.070107] uevent 7 env[1]: (null)
[   44.070609] uevent 14 env[2]: (null)
[   44.071136] uevent 21 env[3]: (null)
[   44.071637] uevent 28 env[4]: (null)
[   44.072166] uevent 35 env[5]: (null)
[   44.072674] uevent 42 env[6]: (null)
[   44.073188] uevent 49 env[7]: (null)
[   44.073694] uevent 56 env[8]: (null)
[   44.074207] uevent 63 env[9]: (null)
[   44.074709] uevent 70 env[10]: (null)
[   44.075235] uevent 77 env[11]: (null)
[   44.075748] uevent 84 env[12]: (null)
[   44.076270] uevent 91 env[13]: (null)
[   44.076783] uevent 98 env[14]: (null)
[   44.077310] uevent 105 env[15]: (null)
[   44.077843] uevent 112 env[16]: (null)
[   44.078384] uevent 119 env[17]: (null)
[   44.078911] uevent 126 env[18]: (null)
[   44.079451] uevent 133 env[19]: (null)
[   44.079979] uevent 140 env[20]: (null)
[   44.080537] uevent 147 env[21]: (null)
[   44.081077] uevent 154 env[22]: (null)
[   44.081614] uevent 161 env[23]: (null)
[   44.082151] uevent 168 env[24]: (null)
[   44.082680] uevent 175 env[25]: (null)
[   44.083217] uevent 182 env[26]: (null)
[   44.083740] uevent 189 env[27]: (null)
[   44.084282] uevent 196 env[28]: (null)
[   44.084810] uevent 203 env[29]: (null)
[   44.085350] uevent 210 env[30]: (null)
[   44.085889] uevent 217 env[31]: (null)
[   44.086434] general protection fault:  [#1] PREEMPT 
[   44.087232] CPU 0 
[   44.087505] Pid: 135, comm: trinity-child0 Not tainted 
3.6.0-rc4-bisect2-1-gb6d86d3-dirty #25 Bochs Bochs
[   44.088928] RIP: 0010:[]  [] 
strnlen+0x23/0x70
[   44.090037] RSP: 0018:8800073dfc58  EFLAGS: 00010006
[   44.090522] RAX: 8800073dfe00 RBX: 8291f0f6 RCX: 0001c66a
[   44.090522] RDX: 303031333000 RSI:  RDI: 303031333000
[   44.090522] RBP: 8800073dfc58 R08:  R09: 
[   44.090522] R10: 0001 R11: 0001 R12: 303031333000
[   44.090522] R13: 8291f4c0 R14:  R15: 
[   44.090522] FS:  7ff846958700() GS:8222d000() 
knlGS:
[   44.090522] CS:  0010 DS:  ES:  CR0: 8005003b
[   44.090522] CR2: 030e5000 CR3: 073ee000 CR4: 06b0
[   44.090522] DR0:  DR1:  DR2: 
[   44.090522] DR3:  DR6: 0ff0 DR7: 0400
[   44.090522] Process trinity-child0 (pid: 135, threadinfo 8800073de000, 
task 880006c0c000)
[   44.090522] Stack:
[   44.090522]  8800073dfc98 81268ccc 82252f18 
81faf19e
[   44.090522]  8291f4c0 8800073dfdd0 81faf19e 
8291f0f6
[   44.090522]  8800073dfd18 81269e89 82250002 
82252ea0
[   44.090522] Call Trace:
[   44.090522]  [] string.isra.4+0x4c/0x120
[   44.090522]  [] vsnprintf+0x2c9/0x900
[   44.090522]  [] vscnprintf+0x19/0x50
[   44.090522]  [] vprintk_emit+0xe7/0x750
[   44.090522]  [] printk+0x4f/0x58
[   44.090522]  [] show_uevent+0x1cb/0x220
[   44.090522]  [] dev_attr_show+0x2b/0x90
[   44.090522]  [] ? sysfs_read_file+0x112/0x290
[   44.090522]  [] ? __get_free_pages+0x24/0xc0
[   44.090522]  [] sysfs_read_file+0x14e/0x290
[   44.090522]  [] vfs_read+0xc7/0x200
[   44.090522]  [] sys_read+0x60/0xd0
[   44.090522]  [] system_call_fastpath+0x16/0x1b

Thanks,
Fengguang
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: linux page table

2012-09-02 Thread Jiri Kosina
On Sat, 1 Sep 2012, Xin Tong wrote:

> When a process is created in Linux, corresponding page table is
> implemented. In the current x86 linux, the page table is a multi-level
> page table and CR3 points to the first level of the page table.  I
> have 2 questions.
> 
> 1. is the value in CR3 virtual address or physical address ?

Physical, otherwise you will have chicken-egg problem.

> 2. can the address of the first level of the page table during a
> process's lifetime change ?

In theory it would be possible to implement. But I don't see a scenario 
when it might be useful.

> 3. can two different processes have their CR3 being the same value
> even though they have different first level page tables ?

Yes, if they are created by clone(CLONE_VM). In such case they share the 
same mm_struct, and therefore mm_struct->pgd (which is exactly what is 
loaded into cr3 in switch_mm()) is the same.

LKML is however very inappropriate list for such questions. Please ask on 
kernelnewbies list next time.

-- 
Jiri Kosina
SUSE Labs

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v7 1/8] Talitos: Support for async_tx XOR offload

2012-09-02 Thread Dan Williams
On Thu, Aug 9, 2012 at 1:20 AM,   wrote:
> From: Qiang Liu 
>
> Expose Talitos's XOR functionality to be used for RAID parity
> calculation via the Async_tx layer.
>
> Cc: Herbert Xu 
> Cc: David S. Miller 
> Signed-off-by: Dipen Dudhat 
> Signed-off-by: Maneesh Gupta 
> Signed-off-by: Kim Phillips 
> Signed-off-by: Vishnu Suresh 
> Signed-off-by: Qiang Liu 
> ---
>  drivers/crypto/Kconfig   |9 +
>  drivers/crypto/talitos.c |  413 
> ++
>  drivers/crypto/talitos.h |   53 ++
>  3 files changed, 475 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
> index be6b2ba..f0a7c29 100644
> --- a/drivers/crypto/Kconfig
> +++ b/drivers/crypto/Kconfig
> @@ -222,6 +222,15 @@ config CRYPTO_DEV_TALITOS
>   To compile this driver as a module, choose M here: the module
>   will be called talitos.
>
> +config CRYPTO_DEV_TALITOS_RAIDXOR
> +   bool "Talitos RAID5 XOR Calculation Offload"
> +   default y

No, default y.  The user should explicitly enable this.

> +   select DMA_ENGINE
> +   depends on CRYPTO_DEV_TALITOS
> +   help
> + Say 'Y' here to use the Freescale Security Engine (SEC) to
> + offload RAID XOR parity Calculation
> +

Is it faster than cpu xor?

Will this engine be coordinating with another to handle memory copies?
 The dma mapping code for async_tx/raid is broken when dma mapping
requests overlap or cross dma device boundaries [1].

[1]: http://marc.info/?l=linux-arm-kernel&m=129407269402930&w=2

> +static void talitos_process_pending(struct talitos_xor_chan *xor_chan)
> +{
> +   struct talitos_xor_desc *desc, *_desc;
> +   unsigned long flags;
> +   int status;
> +   struct talitos_private *priv;
> +   int ch;
> +
> +   priv = dev_get_drvdata(xor_chan->dev);
> +   ch = atomic_inc_return(&priv->last_chan) &
> + (priv->num_channels - 1);

Maybe a comment about why this this is duplicated from
talitos_cra_init()?  It sticks out here and I had to go looking to
find out why this channel number increments on submit.


> +   spin_lock_irqsave(&xor_chan->desc_lock, flags);
> +
> +   list_for_each_entry_safe(desc, _desc, &xor_chan->pending_q, node) {
> +   status = talitos_submit(xor_chan->dev, ch, &desc->hwdesc,
> +   talitos_release_xor, desc);
> +   if (status != -EINPROGRESS)
> +   break;
> +
> +   list_del(&desc->node);
> +   list_add_tail(&desc->node, &xor_chan->in_progress_q);
> +   }
> +
> +   spin_unlock_irqrestore(&xor_chan->desc_lock, flags);
> +}
> +
> +static void talitos_xor_run_tx_complete_actions(struct talitos_xor_desc 
> *desc,
> +   struct talitos_xor_chan *xor_chan)
> +{
> +   struct device *dev = xor_chan->dev;
> +   dma_addr_t dest, addr;
> +   unsigned int src_cnt = desc->unmap_src_cnt;
> +   unsigned int len = desc->unmap_len;
> +   enum dma_ctrl_flags flags = desc->async_tx.flags;
> +   struct dma_async_tx_descriptor *tx = &desc->async_tx;
> +
> +   /* unmap dma addresses */
> +   dest = desc->hwdesc.ptr[6].ptr;
> +   if (likely(!(flags & DMA_COMPL_SKIP_DEST_UNMAP)))
> +   dma_unmap_page(dev, dest, len, DMA_BIDIRECTIONAL);
> +
> +   desc->idx = 6 - src_cnt;
> +   if (likely(!(flags & DMA_COMPL_SKIP_SRC_UNMAP))) {
> +   while(desc->idx < 6) {

Checkpatch says:
ERROR: space required before the open parenthesis '('


> +   addr = desc->hwdesc.ptr[desc->idx++].ptr;
> +   if (addr == dest)
> +   continue;
> +   dma_unmap_page(dev, addr, len, DMA_TO_DEVICE);
> +   }
> +   }
> +
> +   /* run dependent operations */
> +   dma_run_dependencies(tx);

Here is where we run into problems if another engine accesses these
same buffers, especially on ARM v6+.

> +}
> +
> +static void talitos_release_xor(struct device *dev, struct talitos_desc 
> *hwdesc,
> +   void *context, int error)
> +{
> +   struct talitos_xor_desc *desc = context;
> +   struct talitos_xor_chan *xor_chan;
> +   dma_async_tx_callback callback;
> +   void *callback_param;
> +
> +   if (unlikely(error))
> +   dev_err(dev, "xor operation: talitos error %d\n", error);
> +
> +   xor_chan = container_of(desc->async_tx.chan, struct talitos_xor_chan,
> +   common);
> +   spin_lock_bh(&xor_chan->desc_lock);
> +   if (xor_chan->completed_cookie < desc->async_tx.cookie)
> +   xor_chan->completed_cookie = desc->async_tx.cookie;
> +

Use dma_cookie_complete().

> +   callback = desc->async_tx.callback;
> +   callback_param = desc->async_tx.callback_param;
> +
> +   if (callback) {
> +   spin_unlock_bh(&xo

Re: [PATCH v2 1/9] pinctrl: mvebu: pinctrl driver core

2012-09-02 Thread Sebastian Hesselbarth

On 09/02/2012 09:30 AM, Linus Walleij wrote:

On Mon, Aug 27, 2012 at 6:33 AM, Stephen Warren  wrote:

The pinctrl subsystem does expect a list of functions, and for each
function, a list of the groups where it can be selected. I admit that
when I think about this, it's slightly backward, since HW typically has
a list of pins/groups, and for each, a certain set of functions can be
selected. Oh well...


I agree that this is how we engineered it, would it create big hassles
for you to fix up the driver so it's the other way around Sebastian?

I understand that the driver is perfectly working as it is, but from
a subsystem maintainer point of view it is annoying if one driver
turns the concepts around and it gets hard to maintain.


Stephen, Linus, Jason,

there is a v3 of the patch under internal review right now.

I know Stephen will not like it, but I decided not to have the list of
functions passed statically from the SoC specific part but generate it
out of pingroups during probe().

As soon as I have confirmation that it still works on the other SoCs,
I will send the updated patches for public review.

Maybe Jason can also comment on what branch he wants to have it based
on, as we all agreed to get it through the Marvell tree.

Sebastian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: regression 3.5->3.6: usb keyboard not working anymore

2012-09-02 Thread Jiri Kosina
On Thu, 30 Aug 2012, Andres Freund wrote:

> > With a quick grep I just discovered that a new driver for this (or
> > similar?) keyboards has been added. I have *not* compiled this in though:
> > +# CONFIG_HID_LENOVO_TPKBD is not set
> > 
> > Is the new, unconditional, entry in the hid_have_special_driver struct the
> > problem?
> > diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> > index 8e3a6b2..f695680 100644
> > --- a/drivers/hid/hid-core.c
> > +++ b/drivers/hid/hid-core.c
> > @@ -1544,6 +1544,7 @@ static const struct hid_device_id
> > hid_have_special_driver[] = {
> > { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M610X) },
> > { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC,
> > USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) },
> > { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000 )
> > }, +   { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPKBD)
> > }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER)
> > }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER)
> > }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2)
> > },
> > 
> > Other entries seem to be protected via things like:
> > #if IS_ENABLED(CONFIG_HID_LOGITECH_DJ)
> > 
> > I have somewhat obsoleted my original line of thought in this email, but
> > hell. Will try this and send a patch if it works.
> Works.
> 
> Could somebody integrate the attached patch?

Hmm ... you are right, that this is a regression in a sense that if you 
have a working kernel, do oldconfig with the default settings, and then 
you lose your keyboard.

I don't like the aproach you used in your patch though ... we are not 
doing this for other devices either. For those, which were previously 
supported by core driver and then a new driver with enhanced support was 
spinned of, we rather make different default config option.

So how about rather something like

 drivers/hid/Kconfig |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index a451cdb..d5b98d9 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -289,6 +289,7 @@ config HID_LENOVO_TPKBD
depends on USB_HID
select NEW_LEDS
select LEDS_CLASS
+   default HID_GENERIC
---help---
Support for the Lenovo ThinkPad USB Keyboard with TrackPoint.
 
That will fix the oldconfig issue and will not polute the 
hid_have_special_driver[] by a rather ugly ifdef.

Thanks,

-- 
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: input0: bad kobj_uevent_env content in show_uevent()

2012-09-02 Thread Fengguang Wu
It's more than the input device that can trigger the panic.
Here is another trace which panics on accessing dmi/id/uevent:

[   32.380795] sysfs_read_file: /sys/devices/virtual/dmi/id/uevent
[   32.399379] dmi id: uevent 73 env[1677721600]: id/.../id
[   32.400780] uevent 0 env[0]: (null)
[   32.401695] uevent 7 env[1]: (null)
...
[   32.478415] general protection fault:  [#1] PREEMPT 
[   32.479953] CPU 0 
[   32.480433] Pid: 114, comm: trinity-child0 Not tainted 
3.6.0-rc4-bisect2-1-gb6d86d3-dirty #26 Bochs Bochs
[   32.482995] RIP: 0010:[]  [] 
strnlen+0x23/0x70
...
[   32.486234] Call Trace:
[   32.486234]  [] string.isra.4+0x4c/0x120
[   32.486234]  [] vsnprintf+0x2c9/0x900
[   32.486234]  [] vscnprintf+0x19/0x50
[   32.486234]  [] vprintk_emit+0xe7/0x750
[   32.486234]  [] printk+0x4f/0x58
[   32.486234]  [] show_uevent+0x1cb/0x220
[   32.486234]  [] dev_attr_show+0x2b/0x90
[   32.486234]  [] ? sysfs_read_file+0x18a/0x320
[   32.486234]  [] ? __get_free_pages+0x24/0xc0
[   32.486234]  [] sysfs_read_file+0x1cd/0x320

Thanks,
Fengguang

On Sun, Sep 02, 2012 at 03:59:46PM +0800, Fengguang Wu wrote:
> Hi all,
> 
> After the __devinit* removal series, I can still get kernel panic in
> show_uevent(). So there are more sources of bug..
> 
> Debug patch:
> 
> @@ -343,8 +343,11 @@ static ssize_t show_uevent(struct device
> goto out;
> 
> /* copy keys to file */
> -   for (i = 0; i < env->envp_idx; i++)
> +   dev_err(dev, "uevent %d env[%d]: %s/.../%s\n", env->buflen, 
> env->envp_idx, top_kobj->name, dev->kobj.name);
> +   for (i = 0; i < env->envp_idx; i++) {
> +   printk(KERN_ERR "uevent %d env[%d]: %s\n", (int)count, i, 
> env->envp[i]);
> count += sprintf(&buf[count], "%s\n", env->envp[i]);
> +   }
> 
> Oops message, the env[] is again not properly initilized:
> 
> [   44.068623] input input0: uevent 61 env[805306368]: input0/.../input0
> [   44.069552] uevent 0 env[0]: (null)
> [   44.070107] uevent 7 env[1]: (null)
> [   44.070609] uevent 14 env[2]: (null)
> [   44.071136] uevent 21 env[3]: (null)
> [   44.071637] uevent 28 env[4]: (null)
> [   44.072166] uevent 35 env[5]: (null)
> [   44.072674] uevent 42 env[6]: (null)
> [   44.073188] uevent 49 env[7]: (null)
> [   44.073694] uevent 56 env[8]: (null)
> [   44.074207] uevent 63 env[9]: (null)
> [   44.074709] uevent 70 env[10]: (null)
> [   44.075235] uevent 77 env[11]: (null)
> [   44.075748] uevent 84 env[12]: (null)
> [   44.076270] uevent 91 env[13]: (null)
> [   44.076783] uevent 98 env[14]: (null)
> [   44.077310] uevent 105 env[15]: (null)
> [   44.077843] uevent 112 env[16]: (null)
> [   44.078384] uevent 119 env[17]: (null)
> [   44.078911] uevent 126 env[18]: (null)
> [   44.079451] uevent 133 env[19]: (null)
> [   44.079979] uevent 140 env[20]: (null)
> [   44.080537] uevent 147 env[21]: (null)
> [   44.081077] uevent 154 env[22]: (null)
> [   44.081614] uevent 161 env[23]: (null)
> [   44.082151] uevent 168 env[24]: (null)
> [   44.082680] uevent 175 env[25]: (null)
> [   44.083217] uevent 182 env[26]: (null)
> [   44.083740] uevent 189 env[27]: (null)
> [   44.084282] uevent 196 env[28]: (null)
> [   44.084810] uevent 203 env[29]: (null)
> [   44.085350] uevent 210 env[30]: (null)
> [   44.085889] uevent 217 env[31]: (null)
> [   44.086434] general protection fault:  [#1] PREEMPT 
> [   44.087232] CPU 0 
> [   44.087505] Pid: 135, comm: trinity-child0 Not tainted 
> 3.6.0-rc4-bisect2-1-gb6d86d3-dirty #25 Bochs Bochs
> [   44.088928] RIP: 0010:[]  [] 
> strnlen+0x23/0x70
> [   44.090037] RSP: 0018:8800073dfc58  EFLAGS: 00010006
> [   44.090522] RAX: 8800073dfe00 RBX: 8291f0f6 RCX: 
> 0001c66a
> [   44.090522] RDX: 303031333000 RSI:  RDI: 
> 303031333000
> [   44.090522] RBP: 8800073dfc58 R08:  R09: 
> 
> [   44.090522] R10: 0001 R11: 0001 R12: 
> 303031333000
> [   44.090522] R13: 8291f4c0 R14:  R15: 
> 
> [   44.090522] FS:  7ff846958700() GS:8222d000() 
> knlGS:
> [   44.090522] CS:  0010 DS:  ES:  CR0: 8005003b
> [   44.090522] CR2: 030e5000 CR3: 073ee000 CR4: 
> 06b0
> [   44.090522] DR0:  DR1:  DR2: 
> 
> [   44.090522] DR3:  DR6: 0ff0 DR7: 
> 0400
> [   44.090522] Process trinity-child0 (pid: 135, threadinfo 8800073de000, 
> task 880006c0c000)
> [   44.090522] Stack:
> [   44.090522]  8800073dfc98 81268ccc 82252f18 
> 81faf19e
> [   44.090522]  8291f4c0 8800073dfdd0 81faf19e 
> 8291f0f6
> [   44.090522]  8800073dfd18 81269e89 82250002 
> 82252ea0
> [   44.090522] Call Trace:
> [   44.090522]  [] string.isra.4+0x4c/0x120
> [   44.090522]  [] vsnpri

Re: input0: bad kobj_uevent_env content in show_uevent()

2012-09-02 Thread Fengguang Wu
On Sun, Sep 02, 2012 at 04:34:02PM +0800, Fengguang Wu wrote:
> It's more than the input device that can trigger the panic.
> Here is another trace which panics on accessing dmi/id/uevent:
> 
> [   32.380795] sysfs_read_file: /sys/devices/virtual/dmi/id/uevent
> [   32.399379] dmi id: uevent 73 env[1677721600]: id/.../id
> [   32.400780] uevent 0 env[0]: (null)
> [   32.401695] uevent 7 env[1]: (null)
> ...

And one more:

[   49.861849] sysfs_read_file: 
/sys/devices/LNXSYSTM:00/device:00/PNP0A03:00/device:02/PNP0400:00/uevent
[   49.863815] acpi PNP0400:00: uevent 13 env[1627389952]: 
PNP0400:00/.../PNP0400:00
[   49.865698] uevent 0 env[0]: (null)
[   49.866581] uevent 7 env[1]: (null)

Thanks,
Fengguang

> [   32.478415] general protection fault:  [#1] PREEMPT 
> [   32.479953] CPU 0 
> [   32.480433] Pid: 114, comm: trinity-child0 Not tainted 
> 3.6.0-rc4-bisect2-1-gb6d86d3-dirty #26 Bochs Bochs
> [   32.482995] RIP: 0010:[]  [] 
> strnlen+0x23/0x70
> ...
> [   32.486234] Call Trace:
> [   32.486234]  [] string.isra.4+0x4c/0x120
> [   32.486234]  [] vsnprintf+0x2c9/0x900
> [   32.486234]  [] vscnprintf+0x19/0x50
> [   32.486234]  [] vprintk_emit+0xe7/0x750
> [   32.486234]  [] printk+0x4f/0x58
> [   32.486234]  [] show_uevent+0x1cb/0x220
> [   32.486234]  [] dev_attr_show+0x2b/0x90
> [   32.486234]  [] ? sysfs_read_file+0x18a/0x320
> [   32.486234]  [] ? __get_free_pages+0x24/0xc0
> [   32.486234]  [] sysfs_read_file+0x1cd/0x320
> 
> Thanks,
> Fengguang
> 
> On Sun, Sep 02, 2012 at 03:59:46PM +0800, Fengguang Wu wrote:
> > Hi all,
> > 
> > After the __devinit* removal series, I can still get kernel panic in
> > show_uevent(). So there are more sources of bug..
> > 
> > Debug patch:
> > 
> > @@ -343,8 +343,11 @@ static ssize_t show_uevent(struct device
> > goto out;
> > 
> > /* copy keys to file */
> > -   for (i = 0; i < env->envp_idx; i++)
> > +   dev_err(dev, "uevent %d env[%d]: %s/.../%s\n", env->buflen, 
> > env->envp_idx, top_kobj->name, dev->kobj.name);
> > +   for (i = 0; i < env->envp_idx; i++) {
> > +   printk(KERN_ERR "uevent %d env[%d]: %s\n", (int)count, i, 
> > env->envp[i]);
> > count += sprintf(&buf[count], "%s\n", env->envp[i]);
> > +   }
> > 
> > Oops message, the env[] is again not properly initilized:
> > 
> > [   44.068623] input input0: uevent 61 env[805306368]: input0/.../input0
> > [   44.069552] uevent 0 env[0]: (null)
> > [   44.070107] uevent 7 env[1]: (null)
> > [   44.070609] uevent 14 env[2]: (null)
> > [   44.071136] uevent 21 env[3]: (null)
> > [   44.071637] uevent 28 env[4]: (null)
> > [   44.072166] uevent 35 env[5]: (null)
> > [   44.072674] uevent 42 env[6]: (null)
> > [   44.073188] uevent 49 env[7]: (null)
> > [   44.073694] uevent 56 env[8]: (null)
> > [   44.074207] uevent 63 env[9]: (null)
> > [   44.074709] uevent 70 env[10]: (null)
> > [   44.075235] uevent 77 env[11]: (null)
> > [   44.075748] uevent 84 env[12]: (null)
> > [   44.076270] uevent 91 env[13]: (null)
> > [   44.076783] uevent 98 env[14]: (null)
> > [   44.077310] uevent 105 env[15]: (null)
> > [   44.077843] uevent 112 env[16]: (null)
> > [   44.078384] uevent 119 env[17]: (null)
> > [   44.078911] uevent 126 env[18]: (null)
> > [   44.079451] uevent 133 env[19]: (null)
> > [   44.079979] uevent 140 env[20]: (null)
> > [   44.080537] uevent 147 env[21]: (null)
> > [   44.081077] uevent 154 env[22]: (null)
> > [   44.081614] uevent 161 env[23]: (null)
> > [   44.082151] uevent 168 env[24]: (null)
> > [   44.082680] uevent 175 env[25]: (null)
> > [   44.083217] uevent 182 env[26]: (null)
> > [   44.083740] uevent 189 env[27]: (null)
> > [   44.084282] uevent 196 env[28]: (null)
> > [   44.084810] uevent 203 env[29]: (null)
> > [   44.085350] uevent 210 env[30]: (null)
> > [   44.085889] uevent 217 env[31]: (null)
> > [   44.086434] general protection fault:  [#1] PREEMPT 
> > [   44.087232] CPU 0 
> > [   44.087505] Pid: 135, comm: trinity-child0 Not tainted 
> > 3.6.0-rc4-bisect2-1-gb6d86d3-dirty #25 Bochs Bochs
> > [   44.088928] RIP: 0010:[]  [] 
> > strnlen+0x23/0x70
> > [   44.090037] RSP: 0018:8800073dfc58  EFLAGS: 00010006
> > [   44.090522] RAX: 8800073dfe00 RBX: 8291f0f6 RCX: 
> > 0001c66a
> > [   44.090522] RDX: 303031333000 RSI:  RDI: 
> > 303031333000
> > [   44.090522] RBP: 8800073dfc58 R08:  R09: 
> > 
> > [   44.090522] R10: 0001 R11: 0001 R12: 
> > 303031333000
> > [   44.090522] R13: 8291f4c0 R14:  R15: 
> > 
> > [   44.090522] FS:  7ff846958700() GS:8222d000() 
> > knlGS:
> > [   44.090522] CS:  0010 DS:  ES:  CR0: 8005003b
> > [   44.090522] CR2: 030e5000 CR3: 073ee000 CR4: 
> > 06b0
> > [   44.090522] DR0:  DR1:  DR2: 
> > 0

Re: [PATCH] staging/rts_pstor: remove braces {} in sd.c

2012-09-02 Thread Toshiaki Yamane
On Sun, Sep 2, 2012 at 12:05 AM, devendra.aaru  wrote:
> Hello,
>
> This is a very big patch. It will be difficult for reviewers to review.
>
> i think it will be good if you can split into multiple patches.

Thanks for your reply.

Should I do that ?
I have a similar patch some more.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v7 6/8] fsl-dma: use spin_lock_bh to instead of spin_lock_irqsave

2012-09-02 Thread Dan Williams
On Thu, Aug 9, 2012 at 1:23 AM,   wrote:
> From: Qiang Liu 
>
> The use of spin_lock_irqsave() is a stronger locking mechanism than is
> required throughout the driver. The minimum locking required should be
> used instead. Interrupts will be turned off and context will be saved,
> there is needless to use irqsave.
>
> Change all instances of spin_lock_irqsave() to spin_lock_bh().
> All manipulation of protected fields is done using tasklet context or
> weaker, which makes spin_lock_bh() the correct choice.

It seems you are coordinating fsl-dma copy and talitos xor operations.
 It looks like fsl-dma will be called through
talitos_process_pending()->dma_run_dependencies(), which is
potentially called in hard irq context.

This all comes back to the need to fix raid offload to manage the
channels explicitly rather than the current dependency chains.

--
Dan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 16/20] HID: Only dump input if someone is listening

2012-09-02 Thread Henrik Rydberg
Hi Jiri,

> I have applied this one right away, so you can drop it from your series. 
> The remaining ones I am still about to review (currently travelling).

Great, thanks. The notification callback can also be applied if you want.

> There is no inter-dependency between the Input and HID ones, and so we can 
> handle them with Dmitry as two independent Input and HID series, right?

Not quite, I am afraid. Some of the overlap has disappeared, true.
However, the hid-multitouch patches depend on new variables defined in
the input-mt patches, which in turn depend on the input core
changes. The hid-multitouch patches will apply (with a tiny merge
conflict), but they will not compile.

I can split the input-core and hid-core changes into separate sets,
and those could be applied separately. The input-mt and bcm5974 will
then build on input-core, and hid-multitouch will build on both
input-core and hid-core. I am not sure if this helps anyone, though.

Thanks,
Henrik
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] staging/rts_pstor: remove braces {} in sd.c

2012-09-02 Thread devendra.aaru
On Sun, Sep 2, 2012 at 6:25 AM, Joe Perches  wrote:
> On Sat, 2012-09-01 at 20:35 +0530, devendra.aaru wrote:
>> Hello,
>> This is a very big patch. It will be difficult for reviewers to review.
>
> Hello, this is a carelessly large reply quoting all 100K of
> the original patch for your three sentences.  Don't do that.
>
> Thanks
>
Yeah, sorry about that, i realised now,

Thanks
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


does gcc gives a false warning in kernel/trace/trace_events_filter.c ?

2012-09-02 Thread Toralf Förster
The current git tree of linux gave with gcc-4.6.3 :

kernel/trace/trace_events_filter.c: In function ‘ftrace_function_set_filter_cb’:
kernel/trace/trace_events_filter.c:2074:8: warning: ‘ret’ may be used 
uninitialized in this function [-Wuninitialized] 


which refers to this piece of code:


  2061  static int ftrace_function_set_filter_cb(enum move_type move,
  2062   struct filter_pred *pred,
  2063   int *err, void *data)
  2064  {
  2065  /* Checking the node is valid for function trace. */
  2066  if ((move != MOVE_DOWN) ||
  2067  (pred->left != FILTER_PRED_INVALID)) {
  2068  *err = ftrace_function_check_pred(pred, 0);
  2069  } else {
  2070  *err = ftrace_function_check_pred(pred, 1);
  2071  if (*err)
  2072  return WALK_PRED_ABORT;
  2073 
  2074  *err = __ftrace_function_set_filter(pred->op == OP_EQ,
  2075  pred->regex.pattern,
  2076  pred->regex.len,
  2077  data);
  2078  }
  2079 
  2080  return (*err) ? WALK_PRED_ABORT : WALK_PRED_DEFAULT;
  2081  }
  2082  


>From a Gentoo forum user I got a hint :

"Maybe it's some kind of a weird inlining issue? I think it's referring to the 
ret in __ftrace_function_set_filter(), which would be uninitialized if the 
for-loop does not run (re_cnt ≤ 0)"

Now I'm wondering if re_cnt can become zero or if gcc is wrong here ?

-- 
MfG/Sincerely
Toralf Förster
pgp finger print: 7B1A 07F4 EC82 0F90 D4C2 8936 872A E508 7DB6 9DA3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 18/20] HID: hid-multitouch: Simplify setup and frame synchronization

2012-09-02 Thread Henrik Rydberg
With the input_configured() callback in place, the setup and frame
synchronization can be simplified. The input device initialization is
moved to mt_input_configured(), to make sure the full HID report has been
seen.

Cc: Benjamin Tissoires 
Signed-off-by: Henrik Rydberg 
---
 drivers/hid/hid-multitouch.c | 67 +---
 1 file changed, 38 insertions(+), 29 deletions(-)

diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index c400d90..1df86a7 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -92,8 +92,10 @@ struct mt_device {
__u8 touches_by_report; /* how many touches are present in one report:
* 1 means we should use a serial protocol
* > 1 means hybrid (multitouch) protocol */
+   bool serial_maybe;  /* need to check for serial protocol */
bool curvalid;  /* is the current contact valid? */
struct mt_slot *slots;
+   unsigned mt_flags;  /* flags to pass to input-mt */
 };
 
 /* classes of device behavior */
@@ -319,24 +321,16 @@ static int mt_input_mapping(struct hid_device *hdev, 
struct hid_input *hi,
* We need to ignore fields that belong to other collections
* such as Mouse that might have the same GenericDesktop usages. */
if (field->application == HID_DG_TOUCHSCREEN)
-   set_bit(INPUT_PROP_DIRECT, hi->input->propbit);
+   td->mt_flags |= INPUT_MT_DIRECT;
else if (field->application != HID_DG_TOUCHPAD)
return 0;
 
-   /* In case of an indirect device (touchpad), we need to add
-* specific BTN_TOOL_* to be handled by the synaptics xorg
-* driver.
-* We also consider that touchscreens providing buttons are touchpads.
+   /*
+* Model touchscreens providing buttons as touchpads.
 */
if (field->application == HID_DG_TOUCHPAD ||
-   (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON ||
-   cls->is_indirect) {
-   set_bit(INPUT_PROP_POINTER, hi->input->propbit);
-   set_bit(BTN_TOOL_FINGER, hi->input->keybit);
-   set_bit(BTN_TOOL_DOUBLETAP, hi->input->keybit);
-   set_bit(BTN_TOOL_TRIPLETAP, hi->input->keybit);
-   set_bit(BTN_TOOL_QUADTAP, hi->input->keybit);
-   }
+   (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON)
+   td->mt_flags |= INPUT_MT_POINTER;
 
/* eGalax devices provide a Digitizer.Stylus input which overrides
 * the correct Digitizers.Finger X/Y ranges.
@@ -353,8 +347,6 @@ static int mt_input_mapping(struct hid_device *hdev, struct 
hid_input *hi,
EV_ABS, ABS_MT_POSITION_X);
set_abs(hi->input, ABS_MT_POSITION_X, field,
cls->sn_move);
-   /* touchscreen emulation */
-   set_abs(hi->input, ABS_X, field, cls->sn_move);
mt_store_field(usage, td, hi);
td->last_field_index = field->index;
return 1;
@@ -363,8 +355,6 @@ static int mt_input_mapping(struct hid_device *hdev, struct 
hid_input *hi,
EV_ABS, ABS_MT_POSITION_Y);
set_abs(hi->input, ABS_MT_POSITION_Y, field,
cls->sn_move);
-   /* touchscreen emulation */
-   set_abs(hi->input, ABS_Y, field, cls->sn_move);
mt_store_field(usage, td, hi);
td->last_field_index = field->index;
return 1;
@@ -388,9 +378,6 @@ static int mt_input_mapping(struct hid_device *hdev, struct 
hid_input *hi,
td->last_field_index = field->index;
return 1;
case HID_DG_CONTACTID:
-   if (!td->maxcontacts)
-   td->maxcontacts = MT_DEFAULT_MAXCONTACT;
-   input_mt_init_slots(hi->input, td->maxcontacts, 0);
mt_store_field(usage, td, hi);
td->last_field_index = field->index;
td->touches_by_report++;
@@ -418,9 +405,6 @@ static int mt_input_mapping(struct hid_device *hdev, struct 
hid_input *hi,
EV_ABS, ABS_MT_PRESSURE);
set_abs(hi->input, ABS_MT_PRESSURE, field,
cls->sn_pressure);
-   /* touchscreen emulation */
-   set_abs(hi->input, ABS_PRESSURE, field,
-   cls->sn_pressure);
mt_store_field(usage, td, hi);
td->last_field_index = field->index;
return 1;
@@ -536,7 +520,7 @@ static void mt_emit_event(struct mt_d

Re: Build regressions/improvements in v3.6-rc4

2012-09-02 Thread Geert Uytterhoeven
On Sun, Sep 2, 2012 at 11:21 AM, Geert Uytterhoeven
 wrote:
> JFYI, when comparing v3.6-rc4 to v3.6-rc3[3], the summaries are:
>   - build errors: +6/-13

6 regressions:
  + drivers/input/touchscreen/edt-ft5x06.c: error: 'struct
edt_ft5x06_ts_data' has no member named 'raw_buffer':  => 846:14

powerpc-randconfig, fix reported as queued by Dmitry.

  + error: eni.c: relocation truncated to fit: R_PPC64_REL24 against
symbol `_restgpr0_25' defined in .text.save.restore section in
arch/powerpc/lib/built-in.o:  => (.text+0x1ff96e4), (.text+0x1ff9438),
(.text+0x1ff8e74)
  + error: eni.c: relocation truncated to fit: R_PPC64_REL24 against
symbol `_restgpr0_28' defined in .text.save.restore section in
arch/powerpc/lib/built-in.o:  => (.text+0x1ff9848)
  + error: eni.c: relocation truncated to fit: R_PPC64_REL24 against
symbol `_restgpr0_30' defined in .text.save.restore section in
arch/powerpc/lib/built-in.o:  => (.text+0x1ff8ea8), (.text+0x1ff8edc)
  + error: eni.c: relocation truncated to fit: R_PPC64_REL24 against
symbol `_savegpr0_29' defined in .text.save.restore section in
arch/powerpc/lib/built-in.o:  => (.text+0x1ff9cf0)
  + error: fore200e.c: relocation truncated to fit: R_PPC64_REL24
against symbol `_restgpr0_22' defined in .text.save.restore section in
arch/powerpc/lib/built-in.o:  => (.text+0x1ff8608), (.text+0x1ff7e5c)

powerpc-allyesconfig

> [1] http://kisskb.ellerman.id.au/kisskb/head/5381/ (all 116 configs)
> [3] http://kisskb.ellerman.id.au/kisskb/head/5359/ (all 116 configs)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] pwm: Add Ingenic JZ4740 support

2012-09-02 Thread Thierry Reding
This commit moves the driver to drivers/pwm and converts it to the new
PWM framework.

Signed-off-by: Thierry Reding 
---
 arch/mips/include/asm/mach-jz4740/platform.h |   1 +
 arch/mips/jz4740/Kconfig |   3 -
 arch/mips/jz4740/Makefile|   2 +-
 arch/mips/jz4740/board-qi_lb60.c |   3 +-
 arch/mips/jz4740/platform.c  |   6 +
 arch/mips/jz4740/pwm.c   | 177 ---
 drivers/pwm/Kconfig  |  12 +-
 drivers/pwm/Makefile |   1 +
 drivers/pwm/core.c   |   2 +-
 drivers/pwm/pwm-jz4740.c | 205 +++
 10 files changed, 228 insertions(+), 184 deletions(-)
 delete mode 100644 arch/mips/jz4740/pwm.c
 create mode 100644 drivers/pwm/pwm-jz4740.c

diff --git a/arch/mips/include/asm/mach-jz4740/platform.h 
b/arch/mips/include/asm/mach-jz4740/platform.h
index 564ab81..163e81d 100644
--- a/arch/mips/include/asm/mach-jz4740/platform.h
+++ b/arch/mips/include/asm/mach-jz4740/platform.h
@@ -31,6 +31,7 @@ extern struct platform_device jz4740_pcm_device;
 extern struct platform_device jz4740_codec_device;
 extern struct platform_device jz4740_adc_device;
 extern struct platform_device jz4740_wdt_device;
+extern struct platform_device jz4740_pwm_device;
 
 void jz4740_serial_device_register(void);
 
diff --git a/arch/mips/jz4740/Kconfig b/arch/mips/jz4740/Kconfig
index 3e7141f..4689030 100644
--- a/arch/mips/jz4740/Kconfig
+++ b/arch/mips/jz4740/Kconfig
@@ -7,6 +7,3 @@ config JZ4740_QI_LB60
bool "Qi Hardware Ben NanoNote"
 
 endchoice
-
-config HAVE_PWM
-   bool
diff --git a/arch/mips/jz4740/Makefile b/arch/mips/jz4740/Makefile
index e44abea..63bad0e 100644
--- a/arch/mips/jz4740/Makefile
+++ b/arch/mips/jz4740/Makefile
@@ -5,7 +5,7 @@
 # Object file lists.
 
 obj-y += prom.o irq.o time.o reset.o setup.o dma.o \
-   gpio.o clock.o platform.o timer.o pwm.o serial.o
+   gpio.o clock.o platform.o timer.o serial.o
 
 obj-$(CONFIG_DEBUG_FS) += clock-debugfs.o
 
diff --git a/arch/mips/jz4740/board-qi_lb60.c b/arch/mips/jz4740/board-qi_lb60.c
index 9a3d9de..405382c 100644
--- a/arch/mips/jz4740/board-qi_lb60.c
+++ b/arch/mips/jz4740/board-qi_lb60.c
@@ -394,7 +394,7 @@ static struct platform_device qi_lb60_pwm_beeper = {
.name = "pwm-beeper",
.id = -1,
.dev = {
-   .platform_data = (void *)4,
+   .platform_data = (void *)2,
},
 };
 
@@ -437,6 +437,7 @@ static struct platform_device *jz_platform_devices[] 
__initdata = {
&jz4740_codec_device,
&jz4740_rtc_device,
&jz4740_adc_device,
+   &jz4740_pwm_device,
&qi_lb60_gpio_keys,
&qi_lb60_pwm_beeper,
&qi_lb60_charger_device,
diff --git a/arch/mips/jz4740/platform.c b/arch/mips/jz4740/platform.c
index e342ed4..6d14dcd 100644
--- a/arch/mips/jz4740/platform.c
+++ b/arch/mips/jz4740/platform.c
@@ -323,3 +323,9 @@ struct platform_device jz4740_wdt_device = {
.num_resources = ARRAY_SIZE(jz4740_wdt_resources),
.resource  = jz4740_wdt_resources,
 };
+
+/* PWM */
+struct platform_device jz4740_pwm_device = {
+   .name = "jz4740-pwm",
+   .id   = -1,
+};
diff --git a/arch/mips/jz4740/pwm.c b/arch/mips/jz4740/pwm.c
deleted file mode 100644
index a26a6fa..000
--- a/arch/mips/jz4740/pwm.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- *  Copyright (C) 2010, Lars-Peter Clausen 
- *  JZ4740 platform PWM support
- *
- *  This program is free software; you can redistribute it and/or modify it
- *  under  the terms of the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the License, or (at your
- *  option) any later version.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include 
-
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include "timer.h"
-
-static struct clk *jz4740_pwm_clk;
-
-DEFINE_MUTEX(jz4740_pwm_mutex);
-
-struct pwm_device {
-   unsigned int id;
-   unsigned int gpio;
-   bool used;
-};
-
-static struct pwm_device jz4740_pwm_list[] = {
-   { 2, JZ_GPIO_PWM2, false },
-   { 3, JZ_GPIO_PWM3, false },
-   { 4, JZ_GPIO_PWM4, false },
-   { 5, JZ_GPIO_PWM5, false },
-   { 6, JZ_GPIO_PWM6, false },
-   { 7, JZ_GPIO_PWM7, false },
-};
-
-struct pwm_device *pwm_request(int id, const char *label)
-{
-   int ret = 0;
-   struct pwm_device *pwm;
-
-   if (id < 2 || id > 7 || !jz4740_pwm_clk)
-   return ERR_PTR(-ENODEV);
-
-   mutex_lock(&jz4740_pwm_mutex);
-
-   pwm = &jz4740_pwm_list[id - 2];
-   if (pwm->used)
-   ret = -EBUSY;
-   else
-   pwm->used = true;
-
-   mutex_unlock(&jz4740_pwm_mutex);
-
-   if (re

Re: regression 3.5->3.6: usb keyboard not working anymore

2012-09-02 Thread Andres Freund
Hi,

On Sunday, September 02, 2012 10:33:20 AM Jiri Kosina wrote:
> On Thu, 30 Aug 2012, Andres Freund wrote:
> > > With a quick grep I just discovered that a new driver for this (or
> > > similar?) keyboards has been added. I have *not* compiled this in
> > > though: +# CONFIG_HID_LENOVO_TPKBD is not set
> > > 
> > > Is the new, unconditional, entry in the hid_have_special_driver struct
> > > the problem?
> > > diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> > > index 8e3a6b2..f695680 100644
> > > --- a/drivers/hid/hid-core.c
> > > +++ b/drivers/hid/hid-core.c
> > > @@ -1544,6 +1544,7 @@ static const struct hid_device_id
> > > hid_have_special_driver[] = {
> > > 
> > > { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
> > > USB_DEVICE_ID_KYE_EASYPEN_M610X) }, {
> > > HID_USB_DEVICE(USB_VENDOR_ID_LABTEC,
> > > 
> > > USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) },
> > > 
> > > { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER,
> > > USB_DEVICE_ID_LCPOWER_LC1000 )
> > > 
> > > }, +   { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO,
> > > USB_DEVICE_ID_LENOVO_TPKBD) }, {
> > > HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER)
> > > }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
> > > USB_DEVICE_ID_S510_RECEIVER) }, {
> > > HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2)
> > > },
> > > 
> > > Other entries seem to be protected via things like:
> > > #if IS_ENABLED(CONFIG_HID_LOGITECH_DJ)
> > > 
> > > I have somewhat obsoleted my original line of thought in this email,
> > > but hell. Will try this and send a patch if it works.
> > 
> > Works.
> > 
> > Could somebody integrate the attached patch?
> 
> Hmm ... you are right, that this is a regression in a sense that if you
> have a working kernel, do oldconfig with the default settings, and then
> you lose your keyboard.
> 
> I don't like the aproach you used in your patch though ... we are not
> doing this for other devices either. For those, which were previously
> supported by core driver and then a new driver with enhanced support was
> spinned of, we rather make different default config option.
I don't find my approach elegant either. It has the big advantage though that 
you can still walk up to some random computer and be pretty sure the keyboard 
just works without needing to recompile the kernel. Until now it worked on 
every kernel with just CONFIG_USB_HID. Its somewhat harder to recompile a 
kernel without a keyboard...

Greetings,

Andres
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/3] MIPS: JZ4740: Move PWM driver to PWM framework

2012-09-02 Thread Thierry Reding
Hi,

This small series fixes a build error due to a circular header
dependency, exports the timer API so it can be used outside of
the arch/mips/jz4740 tree and finally moves and converts the
JZ4740 PWM driver to the PWM framework.

Note that I don't have any hardware to test this on, so I had to
rely on compile tests only. Patches 1 and 2 should probably go
through the MIPS tree, while I can take patch 3 through the PWM
tree. It touches a couple of files in arch/mips but the changes
are unlikely to cause conflicts.

Thierry

Thierry Reding (3):
  MIPS: JZ4740: Break circular header dependency
  MIPS: JZ4740: Export timer API
  pwm: Add Ingenic JZ4740 support

 arch/mips/include/asm/mach-jz4740/irq.h  |   5 +
 arch/mips/include/asm/mach-jz4740/platform.h |   1 +
 arch/mips/include/asm/mach-jz4740/timer.h|  35 +
 arch/mips/jz4740/Kconfig |   3 -
 arch/mips/jz4740/Makefile|   2 +-
 arch/mips/jz4740/board-qi_lb60.c |   3 +-
 arch/mips/jz4740/irq.h   |  23 ---
 arch/mips/jz4740/platform.c  |   6 +
 arch/mips/jz4740/pwm.c   | 177 ---
 arch/mips/jz4740/time.c  |   2 +-
 arch/mips/jz4740/timer.c | 128 +++--
 arch/mips/jz4740/timer.h | 136 --
 drivers/pwm/Kconfig  |  12 +-
 drivers/pwm/Makefile |   1 +
 drivers/pwm/core.c   |   2 +-
 drivers/pwm/pwm-jz4740.c | 205 +++
 16 files changed, 386 insertions(+), 355 deletions(-)
 delete mode 100644 arch/mips/jz4740/irq.h
 delete mode 100644 arch/mips/jz4740/pwm.c
 delete mode 100644 arch/mips/jz4740/timer.h
 create mode 100644 drivers/pwm/pwm-jz4740.c

-- 
1.7.12

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] MIPS: JZ4740: Export timer API

2012-09-02 Thread Thierry Reding
This is a prerequisite for allowing the PWM driver to be converted to
the PWM framework.

Signed-off-by: Thierry Reding 
---
 arch/mips/include/asm/mach-jz4740/timer.h |  35 
 arch/mips/jz4740/time.c   |   2 +-
 arch/mips/jz4740/timer.c  | 128 +---
 arch/mips/jz4740/timer.h  | 136 --
 4 files changed, 153 insertions(+), 148 deletions(-)
 delete mode 100644 arch/mips/jz4740/timer.h

diff --git a/arch/mips/include/asm/mach-jz4740/timer.h 
b/arch/mips/include/asm/mach-jz4740/timer.h
index 9baa03c..9e41d0e 100644
--- a/arch/mips/include/asm/mach-jz4740/timer.h
+++ b/arch/mips/include/asm/mach-jz4740/timer.h
@@ -16,6 +16,41 @@
 #ifndef __ASM_MACH_JZ4740_TIMER
 #define __ASM_MACH_JZ4740_TIMER
 
+#define JZ_TIMER_CTRL_PWM_ABBRUPT_SHUTDOWN BIT(9)
+#define JZ_TIMER_CTRL_PWM_ACTIVE_LOW   BIT(8)
+#define JZ_TIMER_CTRL_PWM_ENABLE   BIT(7)
+#define JZ_TIMER_CTRL_PRESCALE_MASK0x1c
+#define JZ_TIMER_CTRL_PRESCALE_OFFSET  0x3
+#define JZ_TIMER_CTRL_PRESCALE_1   (0 << 3)
+#define JZ_TIMER_CTRL_PRESCALE_4   (1 << 3)
+#define JZ_TIMER_CTRL_PRESCALE_16  (2 << 3)
+#define JZ_TIMER_CTRL_PRESCALE_64  (3 << 3)
+#define JZ_TIMER_CTRL_PRESCALE_256 (4 << 3)
+#define JZ_TIMER_CTRL_PRESCALE_1024(5 << 3)
+
+#define JZ_TIMER_CTRL_PRESCALER(x) ((x) << JZ_TIMER_CTRL_PRESCALE_OFFSET)
+
+#define JZ_TIMER_CTRL_SRC_EXT  BIT(2)
+#define JZ_TIMER_CTRL_SRC_RTC  BIT(1)
+#define JZ_TIMER_CTRL_SRC_PCLK BIT(0)
+
+void __init jz4740_timer_init(void);
+
+void jz4740_timer_stop(unsigned int timer);
+void jz4740_timer_start(unsigned int timer);
+bool jz4740_timer_is_enabled(unsigned int timer);
+void jz4740_timer_enable(unsigned int timer);
+void jz4740_timer_disable(unsigned int timer);
+void jz4740_timer_set_period(unsigned int timer, uint16_t period);
+void jz4740_timer_set_duty(unsigned int timer, uint16_t duty);
+void jz4740_timer_set_count(unsigned int timer, uint16_t count);
+uint16_t jz4740_timer_get_count(unsigned int timer);
+void jz4740_timer_ack_full(unsigned int timer);
+void jz4740_timer_irq_full_enable(unsigned int timer);
+void jz4740_timer_irq_full_disable(unsigned int timer);
+uint16_t jz4740_timer_get_ctrl(unsigned int timer);
+void jz4740_timer_set_ctrl(unsigned int timer, uint16_t ctrl);
+
 void jz4740_timer_enable_watchdog(void);
 void jz4740_timer_disable_watchdog(void);
 
diff --git a/arch/mips/jz4740/time.c b/arch/mips/jz4740/time.c
index f83c2dd..39bb4bb 100644
--- a/arch/mips/jz4740/time.c
+++ b/arch/mips/jz4740/time.c
@@ -20,10 +20,10 @@
 #include 
 
 #include 
+#include 
 #include 
 
 #include "clock.h"
-#include "timer.h"
 
 #define TIMER_CLOCKEVENT 0
 #define TIMER_CLOCKSOURCE 1
diff --git a/arch/mips/jz4740/timer.c b/arch/mips/jz4740/timer.c
index 654d5c3..79c4354 100644
--- a/arch/mips/jz4740/timer.c
+++ b/arch/mips/jz4740/timer.c
@@ -21,19 +21,28 @@
 
 #include 
 
-void __iomem *jz4740_timer_base;
+#define JZ_REG_TIMER_STOP  0x0C
+#define JZ_REG_TIMER_STOP_SET  0x1C
+#define JZ_REG_TIMER_STOP_CLEAR0x2C
+#define JZ_REG_TIMER_ENABLE0x00
+#define JZ_REG_TIMER_ENABLE_SET0x04
+#define JZ_REG_TIMER_ENABLE_CLEAR  0x08
+#define JZ_REG_TIMER_FLAG  0x10
+#define JZ_REG_TIMER_FLAG_SET  0x14
+#define JZ_REG_TIMER_FLAG_CLEAR0x18
+#define JZ_REG_TIMER_MASK  0x20
+#define JZ_REG_TIMER_MASK_SET  0x24
+#define JZ_REG_TIMER_MASK_CLEAR0x28
 
-void jz4740_timer_enable_watchdog(void)
-{
-   writel(BIT(16), jz4740_timer_base + JZ_REG_TIMER_STOP_CLEAR);
-}
-EXPORT_SYMBOL_GPL(jz4740_timer_enable_watchdog);
+#define JZ_REG_TIMER_DFR(x) (((x) * 0x10) + 0x30)
+#define JZ_REG_TIMER_DHR(x) (((x) * 0x10) + 0x34)
+#define JZ_REG_TIMER_CNT(x) (((x) * 0x10) + 0x38)
+#define JZ_REG_TIMER_CTRL(x) (((x) * 0x10) + 0x3C)
 
-void jz4740_timer_disable_watchdog(void)
-{
-   writel(BIT(16), jz4740_timer_base + JZ_REG_TIMER_STOP_SET);
-}
-EXPORT_SYMBOL_GPL(jz4740_timer_disable_watchdog);
+#define JZ_TIMER_IRQ_HALF(x) BIT((x) + 0x10)
+#define JZ_TIMER_IRQ_FULL(x) BIT(x)
+
+void __iomem *jz4740_timer_base;
 
 void __init jz4740_timer_init(void)
 {
@@ -48,3 +57,100 @@ void __init jz4740_timer_init(void)
/* Timer irqs are unmasked by default, mask them */
writel(0x00ff00ff, jz4740_timer_base + JZ_REG_TIMER_MASK_SET);
 }
+
+void jz4740_timer_stop(unsigned int timer)
+{
+   writel(BIT(timer), jz4740_timer_base + JZ_REG_TIMER_STOP_SET);
+}
+EXPORT_SYMBOL_GPL(jz4740_timer_stop);
+
+void jz4740_timer_start(unsigned int timer)
+{
+   writel(BIT(timer), jz4740_timer_base + JZ_REG_TIMER_STOP_CLEAR);
+}
+EXPORT_SYMBOL_GPL(jz4740_timer_start);
+
+bool jz4740_timer_is_enabled(unsigned int timer)
+{
+   return readb(jz4740_timer_base + JZ_REG_TIMER_ENABLE) & BIT

[PATCH 1/3] MIPS: JZ4740: Break circular header dependency

2012-09-02 Thread Thierry Reding
When including irq.h, arch/mips/jz4740/irq.h will be selected as the
first candidate. This header does not include the proper definitions
(most notably NR_IRQS) required by subsequent headers. To solve this
arch/mips/jz4740/irq.h can be deleted and its contents can be moved
into arch/mips/include/asm/mach-jz4740/irq.h, which will then be
correctly included.

Signed-off-by: Thierry Reding 
---
 arch/mips/include/asm/mach-jz4740/irq.h |  5 +
 arch/mips/jz4740/irq.h  | 23 ---
 2 files changed, 5 insertions(+), 23 deletions(-)
 delete mode 100644 arch/mips/jz4740/irq.h

diff --git a/arch/mips/include/asm/mach-jz4740/irq.h 
b/arch/mips/include/asm/mach-jz4740/irq.h
index 5ad1a9c..aa6fd90 100644
--- a/arch/mips/include/asm/mach-jz4740/irq.h
+++ b/arch/mips/include/asm/mach-jz4740/irq.h
@@ -54,4 +54,9 @@
 
 #define NR_IRQS (JZ4740_IRQ_ADC_BASE + 6)
 
+struct irq_data;
+
+extern void jz4740_irq_suspend(struct irq_data *data);
+extern void jz4740_irq_resume(struct irq_data *data);
+
 #endif
diff --git a/arch/mips/jz4740/irq.h b/arch/mips/jz4740/irq.h
deleted file mode 100644
index f75e39d..000
--- a/arch/mips/jz4740/irq.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- *  Copyright (C) 2010, Lars-Peter Clausen 
- *
- *  This program is free software; you can redistribute it and/or modify it
- *  under  the terms of the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the License, or (at your
- *  option) any later version.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#ifndef __MIPS_JZ4740_IRQ_H__
-#define __MIPS_JZ4740_IRQ_H__
-
-#include 
-
-extern void jz4740_irq_suspend(struct irq_data *data);
-extern void jz4740_irq_resume(struct irq_data *data);
-
-#endif
-- 
1.7.12

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC 1/1] kvm: Use vcpu_id as pivot instead of last boosted vcpu in PLE handler

2012-09-02 Thread Gleb Natapov
On Thu, Aug 30, 2012 at 12:51:01AM +0530, Raghavendra K T wrote:
>  The idea of starting from next vcpu (source of yield_to + 1) seem to work
>  well for overcomitted guest rather than using last boosted vcpu. We can also
>  remove per VM variable with this approach.
>  
>  Iteration for eligible candidate after this patch starts from vcpu source+1
>  and ends at source-1 (after wrapping)
>  
>  Thanks Nikunj for his quick verification of the patch.
>  
>  Please let me know if this patch is interesting and makes sense.
> 
This last_boosted_vcpu thing caused us trouble during attempt to
implement vcpu destruction. It is good to see it removed from this POV.

> 8<
> From: Raghavendra K T 
> 
>  Currently we use next vcpu to last boosted vcpu as starting point
>  while deciding eligible vcpu for directed yield.
> 
>  In overcomitted scenarios, if more vcpu try to do directed yield,
>  they start from same vcpu, resulting in wastage of cpu time (because of
>  failing yields and double runqueue lock).
>  
>  Since probability of same vcpu trying to do directed yield is already
>  prevented by improved PLE handler, we can start from next vcpu from source
>  of yield_to.
> 
> Suggested-by: Srikar Dronamraju 
> Signed-off-by: Raghavendra K T 
> ---
> 
>  include/linux/kvm_host.h |1 -
>  virt/kvm/kvm_main.c  |   12 
>  2 files changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index b70b48b..64a090d 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -275,7 +275,6 @@ struct kvm {
>  #endif
>   struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
>   atomic_t online_vcpus;
> - int last_boosted_vcpu;
>   struct list_head vm_list;
>   struct mutex lock;
>   struct kvm_io_bus *buses[KVM_NR_BUSES];
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 2468523..65a6c83 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1584,7 +1584,6 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *me)
>  {
>   struct kvm *kvm = me->kvm;
>   struct kvm_vcpu *vcpu;
> - int last_boosted_vcpu = me->kvm->last_boosted_vcpu;
>   int yielded = 0;
>   int pass;
>   int i;
> @@ -1594,21 +1593,18 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *me)
>* currently running, because it got preempted by something
>* else and called schedule in __vcpu_run.  Hopefully that
>* VCPU is holding the lock that we need and will release it.
> -  * We approximate round-robin by starting at the last boosted VCPU.
> +  * We approximate round-robin by starting at the next VCPU.
>*/
>   for (pass = 0; pass < 2 && !yielded; pass++) {
>   kvm_for_each_vcpu(i, vcpu, kvm) {
> - if (!pass && i <= last_boosted_vcpu) {
> - i = last_boosted_vcpu;
> + if (!pass && i <= me->vcpu_id) {
> + i = me->vcpu_id;
>   continue;
> - } else if (pass && i > last_boosted_vcpu)
> + } else if (pass && i >= me->vcpu_id)
>   break;
> - if (vcpu == me)
> - continue;
>   if (waitqueue_active(&vcpu->wq))
>   continue;
>   if (kvm_vcpu_yield_to(vcpu)) {
> - kvm->last_boosted_vcpu = i;
>   yielded = 1;
>   break;
>   }

--
Gleb.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/6] unicore32: pwm: Properly remap memory-mapped registers

2012-09-02 Thread Thierry Reding
Instead of writing to the timer controller registers by dereferencing a
pointer to the memory location, properly remap the memory region with a
call to ioremap_nocache() and access the registers using writel().

Signed-off-by: Thierry Reding 
---
 arch/unicore32/kernel/pwm.c | 25 ++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/arch/unicore32/kernel/pwm.c b/arch/unicore32/kernel/pwm.c
index 4615d51..410b786 100644
--- a/arch/unicore32/kernel/pwm.c
+++ b/arch/unicore32/kernel/pwm.c
@@ -23,10 +23,16 @@
 #include 
 #include 
 
+#define PWCR 0x00
+#define DCCR 0x04
+#define PCR  0x08
+
 struct pwm_device {
struct list_headnode;
struct platform_device *pdev;
 
+   void __iomem*base;
+
const char  *label;
struct clk  *clk;
int clk_enabled;
@@ -69,9 +75,11 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int 
period_ns)
 * before writing to the registers
 */
clk_enable(pwm->clk);
-   OST_PWMPWCR = prescale;
-   OST_PWMDCCR = pv - dc;
-   OST_PWMPCR  = pv;
+
+   writel(prescale, pwm->base + PWCR);
+   writel(pv - dc, pwm->base + DCCR);
+   writel(pv, pwm->base + PCR);
+
clk_disable(pwm->clk);
 
return 0;
@@ -190,10 +198,19 @@ static struct pwm_device *pwm_probe(struct 
platform_device *pdev,
goto err_free_clk;
}
 
+   pwm->base = ioremap_nocache(r->start, resource_size(r));
+   if (pwm->base == NULL) {
+   dev_err(&pdev->dev, "failed to remap memory resource\n");
+   ret = -EADDRNOTAVAIL;
+   goto err_release_mem;
+   }
+
__add_pwm(pwm);
platform_set_drvdata(pdev, pwm);
return pwm;
 
+err_release_mem:
+   release_mem_region(r->start, resource_size(r));
 err_free_clk:
clk_put(pwm->clk);
 err_free:
@@ -224,6 +241,8 @@ static int __devexit pwm_remove(struct platform_device 
*pdev)
list_del(&pwm->node);
mutex_unlock(&pwm_lock);
 
+   iounmap(pwm->base);
+
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(r->start, resource_size(r));
 
-- 
1.7.12

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/6] unicore32: Add common clock support

2012-09-02 Thread Thierry Reding
This commit adds support for the common clock framework to the Unicore32
architecture.

Signed-off-by: Thierry Reding 
---
 arch/unicore32/Kconfig  |   1 +
 arch/unicore32/include/asm/clkdev.h |  26 ++
 arch/unicore32/kernel/clock.c   | 560 
 3 files changed, 339 insertions(+), 248 deletions(-)
 create mode 100644 arch/unicore32/include/asm/clkdev.h

diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig
index b0a4743..46b3a15 100644
--- a/arch/unicore32/Kconfig
+++ b/arch/unicore32/Kconfig
@@ -14,6 +14,7 @@ config UNICORE32
select GENERIC_IRQ_SHOW
select ARCH_WANT_FRAME_POINTERS
select GENERIC_IOMAP
+   select COMMON_CLK
help
  UniCore-32 is 32-bit Instruction Set Architecture,
  including a series of low-power-consumption RISC chip
diff --git a/arch/unicore32/include/asm/clkdev.h 
b/arch/unicore32/include/asm/clkdev.h
new file mode 100644
index 000..201645d
--- /dev/null
+++ b/arch/unicore32/include/asm/clkdev.h
@@ -0,0 +1,26 @@
+/*
+ *  based on arch/arm/include/asm/clkdev.h
+ *
+ *  Copyright (C) 2008 Russell King.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Helper for the clk API to assist looking up a struct clk.
+ */
+
+#ifndef __ASM_CLKDEV_H
+#define __ASM_CLKDEV_H
+
+#include 
+
+#define __clk_get(clk) ({ 1; })
+#define __clk_put(clk) do { } while (0)
+
+static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
+{
+   return kzalloc(size, GFP_KERNEL);
+}
+
+#endif
diff --git a/arch/unicore32/kernel/clock.c b/arch/unicore32/kernel/clock.c
index 18d4563..197f885 100644
--- a/arch/unicore32/kernel/clock.c
+++ b/arch/unicore32/kernel/clock.c
@@ -17,223 +17,50 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
-/*
- * Very simple clock implementation
- */
-struct clk {
-   struct list_headnode;
-   unsigned long   rate;
-   const char  *name;
-};
-
-static struct clk clk_ost_clk = {
-   .name   = "OST_CLK",
-   .rate   = CLOCK_TICK_RATE,
-};
-
-static struct clk clk_mclk_clk = {
-   .name   = "MAIN_CLK",
-};
-
-static struct clk clk_bclk32_clk = {
-   .name   = "BUS32_CLK",
+struct clk_uc {
+   struct clk_hw hw;
 };
 
-static struct clk clk_ddr_clk = {
-   .name   = "DDR_CLK",
-};
-
-static struct clk clk_vga_clk = {
-   .name   = "VGA_CLK",
-};
-
-static LIST_HEAD(clocks);
-static DEFINE_MUTEX(clocks_mutex);
-
-struct clk *clk_get(struct device *dev, const char *id)
-{
-   struct clk *p, *clk = ERR_PTR(-ENOENT);
-
-   mutex_lock(&clocks_mutex);
-   list_for_each_entry(p, &clocks, node) {
-   if (strcmp(id, p->name) == 0) {
-   clk = p;
-   break;
-   }
-   }
-   mutex_unlock(&clocks_mutex);
-
-   return clk;
-}
-EXPORT_SYMBOL(clk_get);
-
-void clk_put(struct clk *clk)
-{
-}
-EXPORT_SYMBOL(clk_put);
-
-int clk_enable(struct clk *clk)
-{
-   return 0;
-}
-EXPORT_SYMBOL(clk_enable);
-
-void clk_disable(struct clk *clk)
+static inline struct clk_uc *to_clk_uc(struct clk_hw *hw)
 {
+   return container_of(hw, struct clk_uc, hw);
 }
-EXPORT_SYMBOL(clk_disable);
-
-unsigned long clk_get_rate(struct clk *clk)
-{
-   return clk->rate;
-}
-EXPORT_SYMBOL(clk_get_rate);
-
-struct {
-   unsigned long rate;
-   unsigned long cfg;
-   unsigned long div;
-} vga_clk_table[] = {
-   {.rate =  25175000, .cfg = 0x2001, .div = 0x9},
-   {.rate =  3150, .cfg = 0x2001, .div = 0x7},
-   {.rate =  4000, .cfg = 0x3801, .div = 0x9},
-   {.rate =  4950, .cfg = 0x3801, .div = 0x7},
-   {.rate =  6500, .cfg = 0x2c01, .div = 0x4},
-   {.rate =  7875, .cfg = 0x2400, .div = 0x7},
-   {.rate = 10800, .cfg = 0x2c01, .div = 0x2},
-   {.rate = 10650, .cfg = 0x3c01, .div = 0x3},
-   {.rate =  5065, .cfg = 0x00106400, .div = 0x9},
-   {.rate =  6150, .cfg = 0x00106400, .div = 0xa},
-   {.rate =  8550, .cfg = 0x2800, .div = 0x6},
-};
-
-struct {
-   unsigned long mrate;
-   unsigned long prate;
-} mclk_clk_table[] = {
-   {.mrate = 5, .prate = 0x00109801},
-   {.mrate = 52500, .prate = 0x00104C00},
-   {.mrate = 55000, .prate = 0x00105000},
-   {.mrate = 57500, .prate = 0x00105400},
-   {.mrate = 6, .prate = 0x00105800},
-   {.mrate = 62500, .prate = 0x00105C00},
-   {.mrate = 65000, .prate = 0x00106000},
-   {.mrate = 67500, .prate = 0x00106400},
-   {.mrate = 7, .prate = 0x00106800},
-   {.mrate = 72500, .prate = 0x00106C00},
-   {.mrate = 75000, 

[PATCH 3/6] unicore32: pwm: Remove unnecessary indirection

2012-09-02 Thread Thierry Reding
Calling the actual probing function through a proxy isn't required and
makes the code needlessly complex.

Signed-off-by: Thierry Reding 
---
 arch/unicore32/kernel/pwm.c | 23 ++-
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/arch/unicore32/kernel/pwm.c b/arch/unicore32/kernel/pwm.c
index 22a7098..d0cdfc0 100644
--- a/arch/unicore32/kernel/pwm.c
+++ b/arch/unicore32/kernel/pwm.c
@@ -160,8 +160,7 @@ static inline void __add_pwm(struct pwm_device *pwm)
mutex_unlock(&pwm_lock);
 }
 
-static struct pwm_device *pwm_probe(struct platform_device *pdev,
-   unsigned int pwm_id, struct pwm_device *parent_pwm)
+static int __devinit pwm_probe(struct platform_device *pdev)
 {
struct pwm_device *pwm;
struct resource *r;
@@ -170,7 +169,7 @@ static struct pwm_device *pwm_probe(struct platform_device 
*pdev,
pwm = kzalloc(sizeof(struct pwm_device), GFP_KERNEL);
if (pwm == NULL) {
dev_err(&pdev->dev, "failed to allocate memory\n");
-   return ERR_PTR(-ENOMEM);
+   return -ENOMEM;
}
 
pwm->clk = clk_get(NULL, "OST_CLK");
@@ -181,7 +180,7 @@ static struct pwm_device *pwm_probe(struct platform_device 
*pdev,
pwm->clk_enabled = 0;
 
pwm->use_count = 0;
-   pwm->pwm_id = pwm_id;
+   pwm->pwm_id = pdev->id;
pwm->pdev = pdev;
 
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -207,7 +206,7 @@ static struct pwm_device *pwm_probe(struct platform_device 
*pdev,
 
__add_pwm(pwm);
platform_set_drvdata(pdev, pwm);
-   return pwm;
+   return 0;
 
 err_release_mem:
release_mem_region(r->start, resource_size(r));
@@ -215,17 +214,7 @@ err_free_clk:
clk_put(pwm->clk);
 err_free:
kfree(pwm);
-   return ERR_PTR(ret);
-}
-
-static int __devinit puv3_pwm_probe(struct platform_device *pdev)
-{
-   struct pwm_device *pwm = pwm_probe(pdev, pdev->id, NULL);
-
-   if (IS_ERR(pwm))
-   return PTR_ERR(pwm);
-
-   return 0;
+   return ret;
 }
 
 static int __devexit pwm_remove(struct platform_device *pdev)
@@ -255,7 +244,7 @@ static struct platform_driver puv3_pwm_driver = {
.driver = {
.name   = "PKUnity-v3-PWM",
},
-   .probe  = puv3_pwm_probe,
+   .probe  = pwm_probe,
.remove = __devexit_p(pwm_remove),
 };
 module_platform_driver(puv3_pwm_driver);
-- 
1.7.12

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/6] unicore32: pwm: Use managed resource allocations

2012-09-02 Thread Thierry Reding
This commit uses the managed resource allocation functions to simplify
the cleanup paths on error and removal.

Signed-off-by: Thierry Reding 
---
 arch/unicore32/kernel/pwm.c | 47 +
 1 file changed, 9 insertions(+), 38 deletions(-)

diff --git a/arch/unicore32/kernel/pwm.c b/arch/unicore32/kernel/pwm.c
index d0cdfc0..795c1ba 100644
--- a/arch/unicore32/kernel/pwm.c
+++ b/arch/unicore32/kernel/pwm.c
@@ -164,19 +164,17 @@ static int __devinit pwm_probe(struct platform_device 
*pdev)
 {
struct pwm_device *pwm;
struct resource *r;
-   int ret = 0;
 
-   pwm = kzalloc(sizeof(struct pwm_device), GFP_KERNEL);
+   pwm = devm_kzalloc(&pdev->dev, sizeof(struct pwm_device), GFP_KERNEL);
if (pwm == NULL) {
dev_err(&pdev->dev, "failed to allocate memory\n");
return -ENOMEM;
}
 
-   pwm->clk = clk_get(NULL, "OST_CLK");
-   if (IS_ERR(pwm->clk)) {
-   ret = PTR_ERR(pwm->clk);
-   goto err_free;
-   }
+   pwm->clk = devm_clk_get(&pdev->dev, "OST_CLK");
+   if (IS_ERR(pwm->clk))
+   return PTR_ERR(pwm->clk);
+
pwm->clk_enabled = 0;
 
pwm->use_count = 0;
@@ -186,41 +184,21 @@ static int __devinit pwm_probe(struct platform_device 
*pdev)
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (r == NULL) {
dev_err(&pdev->dev, "no memory resource defined\n");
-   ret = -ENODEV;
-   goto err_free_clk;
-   }
-
-   r = request_mem_region(r->start, resource_size(r), pdev->name);
-   if (r == NULL) {
-   dev_err(&pdev->dev, "failed to request memory resource\n");
-   ret = -EBUSY;
-   goto err_free_clk;
+   return -ENODEV;
}
 
-   pwm->base = ioremap_nocache(r->start, resource_size(r));
-   if (pwm->base == NULL) {
-   dev_err(&pdev->dev, "failed to remap memory resource\n");
-   ret = -EADDRNOTAVAIL;
-   goto err_release_mem;
-   }
+   pwm->base = devm_request_and_ioremap(&pdev->dev, r);
+   if (pwm->base == NULL)
+   return -EADDRNOTAVAIL;
 
__add_pwm(pwm);
platform_set_drvdata(pdev, pwm);
return 0;
-
-err_release_mem:
-   release_mem_region(r->start, resource_size(r));
-err_free_clk:
-   clk_put(pwm->clk);
-err_free:
-   kfree(pwm);
-   return ret;
 }
 
 static int __devexit pwm_remove(struct platform_device *pdev)
 {
struct pwm_device *pwm;
-   struct resource *r;
 
pwm = platform_get_drvdata(pdev);
if (pwm == NULL)
@@ -230,13 +208,6 @@ static int __devexit pwm_remove(struct platform_device 
*pdev)
list_del(&pwm->node);
mutex_unlock(&pwm_lock);
 
-   iounmap(pwm->base);
-
-   r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   release_mem_region(r->start, resource_size(r));
-
-   clk_put(pwm->clk);
-   kfree(pwm);
return 0;
 }
 
-- 
1.7.12

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/6] unicore32: pwm: Use module_platform_driver()

2012-09-02 Thread Thierry Reding
Some of the boilerplate code can be eliminated by using this macro. The
driver was previously registered with an arch_initcall(), so technically
this is no longer the same, but when the driver is moved to the PWM
framework, deferred probing will take care of any driver probe ordering
issues.

Signed-off-by: Thierry Reding 
---
 arch/unicore32/kernel/pwm.c | 21 +
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/arch/unicore32/kernel/pwm.c b/arch/unicore32/kernel/pwm.c
index 410b786..22a7098 100644
--- a/arch/unicore32/kernel/pwm.c
+++ b/arch/unicore32/kernel/pwm.c
@@ -258,25 +258,6 @@ static struct platform_driver puv3_pwm_driver = {
.probe  = puv3_pwm_probe,
.remove = __devexit_p(pwm_remove),
 };
-
-static int __init pwm_init(void)
-{
-   int ret = 0;
-
-   ret = platform_driver_register(&puv3_pwm_driver);
-   if (ret) {
-   printk(KERN_ERR "failed to register puv3_pwm_driver\n");
-   return ret;
-   }
-
-   return ret;
-}
-arch_initcall(pwm_init);
-
-static void __exit pwm_exit(void)
-{
-   platform_driver_unregister(&puv3_pwm_driver);
-}
-module_exit(pwm_exit);
+module_platform_driver(puv3_pwm_driver);
 
 MODULE_LICENSE("GPL v2");
-- 
1.7.12

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/6] unicore32: Move PWM driver to PWM framework

2012-09-02 Thread Thierry Reding
This series cleans up the PWM driver as well as moves and converts it
to the PWM framework.

Part of this series is a patch that converts the Unicore32 clock code
to the common clock framework, which allows devm_clk_get() to be used
for further cleanup. I'm not very familiar with the clock framework,
so this might need some extra thorough review.

I don't have any Unicore32 hardware, so all I could do was test if the
kernel builds properly with the patches applied. I think except for
the final patch all of these should go through the Unicore32 tree.

Thierry

Thierry Reding (6):
  unicore32: pwm: Properly remap memory-mapped registers
  unicore32: pwm: Use module_platform_driver()
  unicore32: pwm: Remove unnecessary indirection
  unicore32: Add common clock support
  unicore32: pwm: Use managed resource allocations
  pwm: Move PUV3 PWM driver to PWM framework

 arch/unicore32/Kconfig  |  13 +-
 arch/unicore32/include/asm/clkdev.h |  26 ++
 arch/unicore32/kernel/Makefile  |   1 -
 arch/unicore32/kernel/clock.c   | 560 
 arch/unicore32/kernel/pwm.c | 263 -
 drivers/pwm/Kconfig |  10 +-
 drivers/pwm/Makefile|   1 +
 drivers/pwm/pwm-puv3.c  | 165 +++
 8 files changed, 516 insertions(+), 523 deletions(-)
 create mode 100644 arch/unicore32/include/asm/clkdev.h
 delete mode 100644 arch/unicore32/kernel/pwm.c
 create mode 100644 drivers/pwm/pwm-puv3.c

-- 
1.7.12

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] pwm: Move PUV3 PWM driver to PWM framework

2012-09-02 Thread Thierry Reding
This commit moves the driver to drivers/pwm and converts it to the new
PWM framework.

Signed-off-by: Thierry Reding 
---
 arch/unicore32/Kconfig |  12 +--
 arch/unicore32/kernel/Makefile |   1 -
 arch/unicore32/kernel/pwm.c| 223 -
 drivers/pwm/Kconfig|  10 +-
 drivers/pwm/Makefile   |   1 +
 drivers/pwm/pwm-puv3.c | 165 ++
 6 files changed, 177 insertions(+), 235 deletions(-)
 delete mode 100644 arch/unicore32/kernel/pwm.c
 create mode 100644 drivers/pwm/pwm-puv3.c

diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig
index 46b3a15..abbc7e4 100644
--- a/arch/unicore32/Kconfig
+++ b/arch/unicore32/Kconfig
@@ -21,9 +21,6 @@ config UNICORE32
  designs licensed by PKUnity Ltd.
  Please see web page at .
 
-config HAVE_PWM
-   bool
-
 config GENERIC_GPIO
def_bool y
 
@@ -106,7 +103,8 @@ config PUV3_DB0913
 
 config PUV3_NB0916
bool "NetBook board (0916)"
-   select HAVE_PWM
+   select PWM
+   select PWM_PUV3
 
 config PUV3_SMW0919
bool "Security Mini-Workstation board (0919)"
@@ -220,12 +218,6 @@ config PUV3_GPIO
select GPIO_SYSFS if EXPERIMENTAL
default y
 
-config PUV3_PWM
-   tristate
-   default BACKLIGHT_PWM
-   help
- Enable support for NB0916 PWM controllers
-
 if PUV3_NB0916
 
 menu "PKUnity NetBook-0916 Features"
diff --git a/arch/unicore32/kernel/Makefile b/arch/unicore32/kernel/Makefile
index 3240101..fa497e0 100644
--- a/arch/unicore32/kernel/Makefile
+++ b/arch/unicore32/kernel/Makefile
@@ -16,7 +16,6 @@ obj-$(CONFIG_UNICORE_FPU_F64) += fpu-ucf64.o
 obj-$(CONFIG_ARCH_PUV3)+= clock.o irq.o time.o
 
 obj-$(CONFIG_PUV3_GPIO)+= gpio.o
-obj-$(CONFIG_PUV3_PWM) += pwm.o
 obj-$(CONFIG_PUV3_PM)  += pm.o sleep.o
 obj-$(CONFIG_HIBERNATION)  += hibernate.o hibernate_asm.o
 
diff --git a/arch/unicore32/kernel/pwm.c b/arch/unicore32/kernel/pwm.c
deleted file mode 100644
index 795c1ba..000
--- a/arch/unicore32/kernel/pwm.c
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * linux/arch/unicore32/kernel/pwm.c
- *
- * Code specific to PKUnity SoC and UniCore ISA
- *
- * Maintained by GUAN Xue-tao 
- * Copyright (C) 2001-2010 Guan Xuetao
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-
-#define PWCR 0x00
-#define DCCR 0x04
-#define PCR  0x08
-
-struct pwm_device {
-   struct list_headnode;
-   struct platform_device *pdev;
-
-   void __iomem*base;
-
-   const char  *label;
-   struct clk  *clk;
-   int clk_enabled;
-
-   unsigned intuse_count;
-   unsigned intpwm_id;
-};
-
-/*
- * period_ns = 10^9 * (PRESCALE + 1) * (PV + 1) / PWM_CLK_RATE
- * duty_ns   = 10^9 * (PRESCALE + 1) * DC / PWM_CLK_RATE
- */
-int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
-{
-   unsigned long long c;
-   unsigned long period_cycles, prescale, pv, dc;
-
-   if (pwm == NULL || period_ns == 0 || duty_ns > period_ns)
-   return -EINVAL;
-
-   c = clk_get_rate(pwm->clk);
-   c = c * period_ns;
-   do_div(c, 10);
-   period_cycles = c;
-
-   if (period_cycles < 1)
-   period_cycles = 1;
-   prescale = (period_cycles - 1) / 1024;
-   pv = period_cycles / (prescale + 1) - 1;
-
-   if (prescale > 63)
-   return -EINVAL;
-
-   if (duty_ns == period_ns)
-   dc = OST_PWMDCCR_FDCYCLE;
-   else
-   dc = (pv + 1) * duty_ns / period_ns;
-
-   /* NOTE: the clock to PWM has to be enabled first
-* before writing to the registers
-*/
-   clk_enable(pwm->clk);
-
-   writel(prescale, pwm->base + PWCR);
-   writel(pv - dc, pwm->base + DCCR);
-   writel(pv, pwm->base + PCR);
-
-   clk_disable(pwm->clk);
-
-   return 0;
-}
-EXPORT_SYMBOL(pwm_config);
-
-int pwm_enable(struct pwm_device *pwm)
-{
-   int rc = 0;
-
-   if (!pwm->clk_enabled) {
-   rc = clk_enable(pwm->clk);
-   if (!rc)
-   pwm->clk_enabled = 1;
-   }
-   return rc;
-}
-EXPORT_SYMBOL(pwm_enable);
-
-void pwm_disable(struct pwm_device *pwm)
-{
-   if (pwm->clk_enabled) {
-   clk_disable(pwm->clk);
-   pwm->clk_enabled = 0;
-   }
-}
-EXPORT_SYMBOL(pwm_disable);
-
-static DEFINE_MUTEX(pwm_lock);
-static LIST_HEAD(pwm_list);
-
-struct pwm_device *pwm_request(int pwm_id, const char *label)
-{
-   struct pwm_device *pwm;
-   int found = 0;
-
-   mutex_lock(&pwm_lock);
-
-   list_for_each_entry(pwm, &pwm_list,

[PATCH] pwm: Move AB8500 PWM driver to PWM framework

2012-09-02 Thread Thierry Reding
This commit moves the driver to drivers/pwm and converts it to the new
PWM framework.

Signed-off-by: Thierry Reding 
---
Note: I'll take this through the PWM tree, but I'd like to have it
acknowledged by a few people who know the hardware and can actually
test whether this still works.

 drivers/misc/Kconfig  |  10 ---
 drivers/misc/Makefile |   1 -
 drivers/misc/ab8500-pwm.c | 169 --
 drivers/pwm/Kconfig   |   9 +++
 drivers/pwm/Makefile  |   1 +
 drivers/pwm/pwm-ab8500.c  | 153 +
 6 files changed, 163 insertions(+), 180 deletions(-)
 delete mode 100644 drivers/misc/ab8500-pwm.c
 create mode 100644 drivers/pwm/pwm-ab8500.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 98a442d..041b656 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -60,16 +60,6 @@ config ATMEL_PWM
  purposes including software controlled power-efficient backlights
  on LCD displays, motor control, and waveform generation.
 
-config AB8500_PWM
-   bool "AB8500 PWM support"
-   depends on AB8500_CORE && ARCH_U8500
-   select HAVE_PWM
-   depends on !PWM
-   help
- This driver exports functions to enable/disble/config/free Pulse
- Width Modulation in the Analog Baseband Chip AB8500.
- It is used by led and backlight driver to control the intensity.
-
 config ATMEL_TCLIB
bool "Atmel AT32/AT91 Timer/Counter Library"
depends on (AVR32 || ARCH_AT91)
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index b88df7a..2129377 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -44,7 +44,6 @@ obj-$(CONFIG_VMWARE_BALLOON)  += vmw_balloon.o
 obj-$(CONFIG_ARM_CHARLCD)  += arm-charlcd.o
 obj-$(CONFIG_PCH_PHUB) += pch_phub.o
 obj-y  += ti-st/
-obj-$(CONFIG_AB8500_PWM)   += ab8500-pwm.o
 obj-y  += lis3lv02d/
 obj-y  += carma/
 obj-$(CONFIG_USB_SWITCH_FSA9480) += fsa9480.o
diff --git a/drivers/misc/ab8500-pwm.c b/drivers/misc/ab8500-pwm.c
deleted file mode 100644
index d7a9aa1..000
--- a/drivers/misc/ab8500-pwm.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) ST-Ericsson SA 2010
- *
- * Author: Arun R Murthy 
- * License terms: GNU General Public License (GPL) version 2
- */
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/*
- * PWM Out generators
- * Bank: 0x10
- */
-#define AB8500_PWM_OUT_CTRL1_REG   0x60
-#define AB8500_PWM_OUT_CTRL2_REG   0x61
-#define AB8500_PWM_OUT_CTRL7_REG   0x66
-
-/* backlight driver constants */
-#define ENABLE_PWM 1
-#define DISABLE_PWM0
-
-struct pwm_device {
-   struct device *dev;
-   struct list_head node;
-   const char *label;
-   unsigned int pwm_id;
-};
-
-static LIST_HEAD(pwm_list);
-
-int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
-{
-   int ret = 0;
-   unsigned int higher_val, lower_val;
-   u8 reg;
-
-   /*
-* get the first 8 bits that are be written to
-* AB8500_PWM_OUT_CTRL1_REG[0:7]
-*/
-   lower_val = duty_ns & 0x00FF;
-   /*
-* get bits [9:10] that are to be written to
-* AB8500_PWM_OUT_CTRL2_REG[0:1]
-*/
-   higher_val = ((duty_ns & 0x0300) >> 8);
-
-   reg = AB8500_PWM_OUT_CTRL1_REG + ((pwm->pwm_id - 1) * 2);
-
-   ret = abx500_set_register_interruptible(pwm->dev, AB8500_MISC,
-   reg, (u8)lower_val);
-   if (ret < 0)
-   return ret;
-   ret = abx500_set_register_interruptible(pwm->dev, AB8500_MISC,
-   (reg + 1), (u8)higher_val);
-
-   return ret;
-}
-EXPORT_SYMBOL(pwm_config);
-
-int pwm_enable(struct pwm_device *pwm)
-{
-   int ret;
-
-   ret = abx500_mask_and_set_register_interruptible(pwm->dev,
-   AB8500_MISC, AB8500_PWM_OUT_CTRL7_REG,
-   1 << (pwm->pwm_id-1), ENABLE_PWM);
-   if (ret < 0)
-   dev_err(pwm->dev, "%s: Failed to disable PWM, Error %d\n",
-   pwm->label, ret);
-   return ret;
-}
-EXPORT_SYMBOL(pwm_enable);
-
-void pwm_disable(struct pwm_device *pwm)
-{
-   int ret;
-
-   ret = abx500_mask_and_set_register_interruptible(pwm->dev,
-   AB8500_MISC, AB8500_PWM_OUT_CTRL7_REG,
-   1 << (pwm->pwm_id-1), DISABLE_PWM);
-   if (ret < 0)
-   dev_err(pwm->dev, "%s: Failed to disable PWM, Error %d\n",
-   pwm->label, ret);
-   return;
-}
-EXPORT_SYMBOL(pwm_disable);
-
-struct pwm_device *pwm_request(int pwm_id, const char *label)
-{
-   struct pwm_device *pwm;
-
-   list_for_each_entry(pwm, &pwm_list, node) {
-   if (pwm->pwm_i

[PATCH 1/2] mfd: twl: Replace twl_has_*() macros by IS_ENABLED()

2012-09-02 Thread Thierry Reding
Instead of reinventing macros for the same purpose, use the standard
macros.

Signed-off-by: Thierry Reding 
---
 drivers/mfd/twl-core.c | 117 +++--
 1 file changed, 25 insertions(+), 92 deletions(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 1c32afe..5fbb2a6 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -63,70 +63,6 @@
 
 #define DRIVER_NAME"twl"
 
-#if defined(CONFIG_KEYBOARD_TWL4030) || defined(CONFIG_KEYBOARD_TWL4030_MODULE)
-#define twl_has_keypad()   true
-#else
-#define twl_has_keypad()   false
-#endif
-
-#if defined(CONFIG_GPIO_TWL4030) || defined(CONFIG_GPIO_TWL4030_MODULE)
-#define twl_has_gpio() true
-#else
-#define twl_has_gpio() false
-#endif
-
-#if defined(CONFIG_REGULATOR_TWL4030) \
-   || defined(CONFIG_REGULATOR_TWL4030_MODULE)
-#define twl_has_regulator()true
-#else
-#define twl_has_regulator()false
-#endif
-
-#if defined(CONFIG_TWL4030_MADC) || defined(CONFIG_TWL4030_MADC_MODULE)
-#define twl_has_madc() true
-#else
-#define twl_has_madc() false
-#endif
-
-#ifdef CONFIG_TWL4030_POWER
-#define twl_has_power()true
-#else
-#define twl_has_power()false
-#endif
-
-#if defined(CONFIG_RTC_DRV_TWL4030) || defined(CONFIG_RTC_DRV_TWL4030_MODULE)
-#define twl_has_rtc()  true
-#else
-#define twl_has_rtc()  false
-#endif
-
-#if defined(CONFIG_TWL4030_USB) || defined(CONFIG_TWL4030_USB_MODULE) ||\
-   defined(CONFIG_TWL6030_USB) || defined(CONFIG_TWL6030_USB_MODULE)
-#define twl_has_usb()  true
-#else
-#define twl_has_usb()  false
-#endif
-
-#if defined(CONFIG_TWL4030_WATCHDOG) || \
-   defined(CONFIG_TWL4030_WATCHDOG_MODULE)
-#define twl_has_watchdog()true
-#else
-#define twl_has_watchdog()false
-#endif
-
-#if defined(CONFIG_MFD_TWL4030_AUDIO) || \
-   defined(CONFIG_MFD_TWL4030_AUDIO_MODULE)
-#define twl_has_codec()true
-#else
-#define twl_has_codec()false
-#endif
-
-#if defined(CONFIG_CHARGER_TWL4030) || defined(CONFIG_CHARGER_TWL4030_MODULE)
-#define twl_has_bci()  true
-#else
-#define twl_has_bci()  false
-#endif
-
 /* Triton Core internal information (BEGIN) */
 
 /* Last - for index max*/
@@ -134,13 +70,6 @@
 
 #define TWL_NUM_SLAVES 4
 
-#if defined(CONFIG_INPUT_TWL4030_PWRBUTTON) \
-   || defined(CONFIG_INPUT_TWL4030_PWRBUTTON_MODULE)
-#define twl_has_pwrbutton()true
-#else
-#define twl_has_pwrbutton()false
-#endif
-
 #define SUB_CHIP_ID0 0
 #define SUB_CHIP_ID1 1
 #define SUB_CHIP_ID2 2
@@ -669,7 +598,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned 
irq_base,
struct device   *child;
unsigned sub_chip_id;
 
-   if (twl_has_gpio() && pdata->gpio) {
+   if (IS_ENABLED(CONFIG_GPIO_TWL4030) && pdata->gpio) {
child = add_child(SUB_CHIP_ID1, "twl4030_gpio",
pdata->gpio, sizeof(*pdata->gpio),
false, irq_base + GPIO_INTR_OFFSET, 0);
@@ -677,7 +606,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned 
irq_base,
return PTR_ERR(child);
}
 
-   if (twl_has_keypad() && pdata->keypad) {
+   if (IS_ENABLED(CONFIG_KEYBOARD_TWL4030) && pdata->keypad) {
child = add_child(SUB_CHIP_ID2, "twl4030_keypad",
pdata->keypad, sizeof(*pdata->keypad),
true, irq_base + KEYPAD_INTR_OFFSET, 0);
@@ -685,7 +614,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned 
irq_base,
return PTR_ERR(child);
}
 
-   if (twl_has_madc() && pdata->madc) {
+   if (IS_ENABLED(CONFIG_TWL4030_MADC) && pdata->madc) {
child = add_child(2, "twl4030_madc",
pdata->madc, sizeof(*pdata->madc),
true, irq_base + MADC_INTR_OFFSET, 0);
@@ -693,7 +622,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned 
irq_base,
return PTR_ERR(child);
}
 
-   if (twl_has_rtc()) {
+   if (IS_ENABLED(CONFIG_RTC_DRV_TWL4030)) {
/*
 * REVISIT platform_data here currently might expose the
 * "msecure" line ... but for now we just expect board
@@ -709,7 +638,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned 
irq_base,
return PTR_ERR(child);
}
 
-   if (twl_has_usb() && pdata->usb && twl_class_is_4030()) {
+   if (IS_ENABLED(CONFIG_TWL4030_USB) && pdata->usb &&
+   twl_class_is_4030()) {
 
static struct regulator_consumer_supply usb1v5 = {
.supply =   "usb1v5",
@@ -723,7 +653,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned 
irq_base,
};
 
/* First add the regulators so that they can be used by transceiver */
-   if (twl_has_regulator()) {
+ 

[PATCH 2/2] pwm: Move TWL6030 PWM driver to PWM framework

2012-09-02 Thread Thierry Reding
This commit moves the driver to drivers/pwm and converts it to the new
PWM framework. In order for this to work properly, register the PWM as
child of the multi-function TWL6030 device.

Signed-off-by: Thierry Reding 
---
 drivers/mfd/Kconfig   |  10 ---
 drivers/mfd/Makefile  |   1 -
 drivers/mfd/twl-core.c|   7 ++
 drivers/mfd/twl6030-pwm.c | 165 -
 drivers/pwm/Kconfig   |   9 +++
 drivers/pwm/Makefile  |   1 +
 drivers/pwm/pwm-twl6030.c | 184 ++
 7 files changed, 201 insertions(+), 176 deletions(-)
 delete mode 100644 drivers/mfd/twl6030-pwm.c
 create mode 100644 drivers/pwm/pwm-twl6030.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index d1facef..2f45891 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -298,16 +298,6 @@ config MFD_TWL4030_AUDIO
select MFD_CORE
default n
 
-config TWL6030_PWM
-   tristate "TWL6030 PWM (Pulse Width Modulator) Support"
-   depends on TWL4030_CORE
-   select HAVE_PWM
-   depends on !PWM
-   default n
-   help
- Say yes here if you want support for TWL6030 PWM.
- This is used to control charging LED brightness.
-
 config TWL6040_CORE
bool "Support for TWL6040 audio codec"
depends on I2C=y && GENERIC_HARDIRQS
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 79dd22d..53063a8 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -63,7 +63,6 @@ obj-$(CONFIG_TWL4030_CORE)+= twl-core.o twl4030-irq.o 
twl6030-irq.o
 obj-$(CONFIG_TWL4030_MADC)  += twl4030-madc.o
 obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o
 obj-$(CONFIG_MFD_TWL4030_AUDIO)+= twl4030-audio.o
-obj-$(CONFIG_TWL6030_PWM)  += twl6030-pwm.o
 obj-$(CONFIG_TWL6040_CORE) += twl6040-core.o twl6040-irq.o
 
 obj-$(CONFIG_MFD_MC13XXX)  += mc13xxx-core.o
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 5fbb2a6..1b1a789 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -638,6 +638,13 @@ add_children(struct twl4030_platform_data *pdata, unsigned 
irq_base,
return PTR_ERR(child);
}
 
+   if (IS_ENABLED(CONFIG_PWM_TWL6030)) {
+   child = add_child(TWL6030_MODULE_ID1, "twl6030-pwm", NULL, 0,
+ false, 0, 0);
+   if (IS_ERR(child))
+   return PTR_ERR(child);
+   }
+
if (IS_ENABLED(CONFIG_TWL4030_USB) && pdata->usb &&
twl_class_is_4030()) {
 
diff --git a/drivers/mfd/twl6030-pwm.c b/drivers/mfd/twl6030-pwm.c
deleted file mode 100644
index e8fee14..000
--- a/drivers/mfd/twl6030-pwm.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * twl6030_pwm.c
- * Driver for PHOENIX (TWL6030) Pulse Width Modulator
- *
- * Copyright (C) 2010 Texas Instruments
- * Author: Hemanth V 
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program.  If not, see .
- */
-
-#include 
-#include 
-#include 
-#include 
-
-#define LED_PWM_CTRL1  0xF4
-#define LED_PWM_CTRL2  0xF5
-
-/* Max value for CTRL1 register */
-#define PWM_CTRL1_MAX  255
-
-/* Pull down disable */
-#define PWM_CTRL2_DIS_PD   (1 << 6)
-
-/* Current control 2.5 milli Amps */
-#define PWM_CTRL2_CURR_02  (2 << 4)
-
-/* LED supply source */
-#define PWM_CTRL2_SRC_VAC  (1 << 2)
-
-/* LED modes */
-#define PWM_CTRL2_MODE_HW  (0 << 0)
-#define PWM_CTRL2_MODE_SW  (1 << 0)
-#define PWM_CTRL2_MODE_DIS (2 << 0)
-
-#define PWM_CTRL2_MODE_MASK0x3
-
-struct pwm_device {
-   const char *label;
-   unsigned int pwm_id;
-};
-
-int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
-{
-   u8 duty_cycle;
-   int ret;
-
-   if (pwm == NULL || period_ns == 0 || duty_ns > period_ns)
-   return -EINVAL;
-
-   duty_cycle = (duty_ns * PWM_CTRL1_MAX) / period_ns;
-
-   ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, duty_cycle, LED_PWM_CTRL1);
-
-   if (ret < 0) {
-   pr_err("%s: Failed to configure PWM, Error %d\n",
-   pwm->label, ret);
-   return ret;
-   }
-   return 0;
-}
-EXPORT_SYMBOL(pwm_config);
-
-int pwm_enable(struct pwm_device *pwm)
-{
-   u8 val;
-   int ret;
-
-   ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2);
-   if (ret < 0) {
-   pr_err("%s: Failed to enable PWM, Error %d\n", pwm->label, ret);
-  

[PATCH 0/2] mfd: twl: Move PWM driver to PWM framework

2012-09-02 Thread Thierry Reding
Hi,

This mini series replaces the twl_has_*() macros by the equivalent
standard IS_ENABLED() macro and moves the PWM driver to the PWM
framework.

I'll take the second patch through the PWM tree but would like to have
some Acked-bys from people that know and have the hardware and can
verify that I haven't broken anything.

Thierry

Thierry Reding (2):
  mfd: twl: Replace twl_has_*() macros by IS_ENABLED()
  pwm: Move TWL6030 PWM driver to PWM framework

 drivers/mfd/Kconfig   |  10 ---
 drivers/mfd/Makefile  |   1 -
 drivers/mfd/twl-core.c| 124 ---
 drivers/mfd/twl6030-pwm.c | 165 -
 drivers/pwm/Kconfig   |   9 +++
 drivers/pwm/Makefile  |   1 +
 drivers/pwm/pwm-twl6030.c | 184 ++
 7 files changed, 226 insertions(+), 268 deletions(-)
 delete mode 100644 drivers/mfd/twl6030-pwm.c
 create mode 100644 drivers/pwm/pwm-twl6030.c

-- 
1.7.12

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH tip/core/rcu 12/23] rcu: Prevent force_quiescent_state() memory contention

2012-09-02 Thread Josh Triplett
On Thu, Aug 30, 2012 at 11:18:27AM -0700, Paul E. McKenney wrote:
> --- a/kernel/rcutree.c
> +++ b/kernel/rcutree.c
[...]
> @@ -1824,16 +1825,35 @@ static void force_qs_rnp(struct rcu_state *rsp, int 
> (*f)(struct rcu_data *))
>  static void force_quiescent_state(struct rcu_state *rsp)
>  {
>   unsigned long flags;
> - struct rcu_node *rnp = rcu_get_root(rsp);
> + bool ret;
> + struct rcu_node *rnp;
> + struct rcu_node *rnp_old = NULL;
> +
> + /* Funnel through hierarchy to reduce memory contention. */
> + rnp = per_cpu_ptr(rsp->rda, raw_smp_processor_id())->mynode;

What makes this use of raw_smp_processor_id() safe?  (And, could you
document the answer here?)

> + for (; rnp != NULL; rnp = rnp->parent) {
> + ret = (ACCESS_ONCE(rsp->gp_flags) & RCU_GP_FLAG_FQS) ||
> +   !raw_spin_trylock(&rnp->fqslock);

So, the root lock will still get trylocked by one CPU per second-level
tree node, just not by every CPU?

> @@ -2721,10 +2741,14 @@ static void __init rcu_init_levelspread(struct 
> rcu_state *rsp)
>  static void __init rcu_init_one(struct rcu_state *rsp,
>   struct rcu_data __percpu *rda)
>  {
> - static char *buf[] = { "rcu_node_level_0",
> -"rcu_node_level_1",
> -"rcu_node_level_2",
> -"rcu_node_level_3" };  /* Match MAX_RCU_LVLS */
> + static char *buf[] = { "rcu_node_0",
> +"rcu_node_1",
> +"rcu_node_2",
> +"rcu_node_3" };  /* Match MAX_RCU_LVLS */

Why rename these?

- Josh Triplett
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] mtd: cmdlinepart: fix the wrong check condition

2012-09-02 Thread Artem Bityutskiy
On Sat, 2012-08-25 at 12:31 +0300, Shmulik Ladkani wrote:
> Hi Huang, Artem,
> 
> On Sat, 25 Aug 2012 16:06:50 -0400 Huang Shijie  wrote:
> > diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
> > index fc960a3..216d751 100644
> > --- a/drivers/mtd/cmdlinepart.c
> > +++ b/drivers/mtd/cmdlinepart.c
> > @@ -322,13 +322,16 @@ static int parse_cmdline_partitions(struct mtd_info 
> > *master,
> > struct cmdline_mtd_partition *part;
> > const char *mtd_id = master->name;
> >  
> > +   if (!mtd_id)
> > +   return 0;
> > +
> > /* parse command line */
> > if (!cmdline_parsed)
> > mtdpart_setup_real(cmdline);
> >  
> > for(part = partitions; part; part = part->next)
> > {
> > -   if ((!mtd_id) || (!strcmp(part->mtd_id, mtd_id)))
> > +   if (!strcmp(part->mtd_id, mtd_id))
> > {
> > for(i = 0, offset = 0; i < part->num_parts; i++)
> > {
> 
> This changes the behavior of cmdling parsing, which might affect users
> expecting the old behavior.

Yes, you are right, we should not change the mtd_id hack unless we have
checked all the users.

-- 
Best Regards,
Artem Bityutskiy


signature.asc
Description: This is a digitally signed message part


Mailing List

2012-09-02 Thread Ashley HARBEN

Can you please add my email to the mailing list .

Regards. 


Sent from my iPhone
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ARM: ux500: Fix build error due to missing include of asm/pmu.h in cpu-db8500.c

2012-09-02 Thread Axel Lin
Include asm/pmu.h to fix below build error:

  CC  arch/arm/mach-ux500/cpu-db8500.o
arch/arm/mach-ux500/cpu-db8500.c:118:8: error: variable 'db8500_pmu_platdata' 
has initializer but incomplete type
arch/arm/mach-ux500/cpu-db8500.c:119:2: error: unknown field 'handle_irq' 
specified in initializer
arch/arm/mach-ux500/cpu-db8500.c:119:2: warning: excess elements in struct 
initializer [enabled by default]
arch/arm/mach-ux500/cpu-db8500.c:119:2: warning: (near initialization for 
'db8500_pmu_platdata') [enabled by default]
make[1]: *** [arch/arm/mach-ux500/cpu-db8500.o] Error 1
make: *** [arch/arm/mach-ux500] Error 2

Signed-off-by: Axel Lin 
---
 arch/arm/mach-ux500/cpu-db8500.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index 8169f2c..3ce7d94 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
-- 
1.7.9.5



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/6] KVM: MMU: release noslot pfn on the fail path properly

2012-09-02 Thread Xiao Guangrong
We can not directly call kvm_release_pfn_clean to release the pfn
since we can meet noslot pfn which is used to cache mmio info into
spte

Introduce mmu_release_pfn_clean to do this kind of thing

Signed-off-by: Xiao Guangrong 
---
 arch/x86/kvm/mmu.c |   19 ++-
 arch/x86/kvm/paging_tmpl.h |4 ++--
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 399c177..3c10bca 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2432,6 +2432,16 @@ done:
return ret;
 }

+/*
+ * The primary user is page fault path which call it to properly
+ * release noslot_pfn.
+ */
+static void mmu_release_pfn_clean(pfn_t pfn)
+{
+   if (!is_error_pfn(pfn))
+   kvm_release_pfn_clean(pfn);
+}
+
 static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
 unsigned pt_access, unsigned pte_access,
 int user_fault, int write_fault,
@@ -2497,8 +2507,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 
*sptep,
}
}

-   if (!is_error_pfn(pfn))
-   kvm_release_pfn_clean(pfn);
+   mmu_release_pfn_clean(pfn);
 }

 static void nonpaging_new_cr3(struct kvm_vcpu *vcpu)
@@ -2618,7 +2627,7 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, 
int write,
  1, ACC_ALL, iterator.sptep);
if (!sp) {
pgprintk("nonpaging_map: ENOMEM\n");
-   kvm_release_pfn_clean(pfn);
+   mmu_release_pfn_clean(pfn);
return -ENOMEM;
}

@@ -2882,7 +2891,7 @@ static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, 
u32 error_code,

 out_unlock:
spin_unlock(&vcpu->kvm->mmu_lock);
-   kvm_release_pfn_clean(pfn);
+   mmu_release_pfn_clean(pfn);
return 0;
 }

@@ -3350,7 +3359,7 @@ static int tdp_page_fault(struct kvm_vcpu *vcpu, gva_t 
gpa, u32 error_code,

 out_unlock:
spin_unlock(&vcpu->kvm->mmu_lock);
-   kvm_release_pfn_clean(pfn);
+   mmu_release_pfn_clean(pfn);
return 0;
 }

diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index bf8c42b..f075259 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -544,7 +544,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
 out_gpte_changed:
if (sp)
kvm_mmu_put_page(sp, it.sptep);
-   kvm_release_pfn_clean(pfn);
+   mmu_release_pfn_clean(pfn);
return NULL;
 }

@@ -645,7 +645,7 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t 
addr, u32 error_code,

 out_unlock:
spin_unlock(&vcpu->kvm->mmu_lock);
-   kvm_release_pfn_clean(pfn);
+   mmu_release_pfn_clean(pfn);
return 0;
 }

-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/6] KVM: MMU: remove unnecessary check

2012-09-02 Thread Xiao Guangrong
Checking the return of kvm_mmu_get_page is unnecessary since it is
guaranteed by memory cache

Signed-off-by: Xiao Guangrong 
---
 arch/x86/kvm/mmu.c |5 -
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 3c10bca..98cf4bf 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2625,11 +2625,6 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, 
int write,
sp = kvm_mmu_get_page(vcpu, pseudo_gfn, iterator.addr,
  iterator.level - 1,
  1, ACC_ALL, iterator.sptep);
-   if (!sp) {
-   pgprintk("nonpaging_map: ENOMEM\n");
-   mmu_release_pfn_clean(pfn);
-   return -ENOMEM;
-   }

mmu_spte_set(iterator.sptep,
 __pa(sp->spt)
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/6] KVM: fix release error page

2012-09-02 Thread Xiao Guangrong
This bug was triggered:
[ 4220.198458] BUG: unable to handle kernel paging request at fffe
[ 4220.203907] IP: [] put_page+0xf/0x34
..
[ 4220.237326] Call Trace:
[ 4220.237361]  [] kvm_arch_destroy_vm+0xf9/0x101 [kvm]
[ 4220.237382]  [] kvm_put_kvm+0xcc/0x127 [kvm]
[ 4220.237401]  [] kvm_vcpu_release+0x18/0x1c [kvm]
[ 4220.237407]  [] __fput+0x111/0x1ed
[ 4220.237411]  [] fput+0xe/0x10
[ 4220.237418]  [] task_work_run+0x5d/0x88
[ 4220.237424]  [] do_exit+0x2bf/0x7ca

The test case:

#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 

#include 

#define die(fmt, args...)   do {\
printf(fmt, ##args);\
exit(-1);} while (0)

static int create_vm(void)
{
int sys_fd, vm_fd;

sys_fd = open("/dev/kvm", O_RDWR);
if (sys_fd < 0)
die("open /dev/kvm fail.\n");

vm_fd = ioctl(sys_fd, KVM_CREATE_VM, 0);
if (vm_fd < 0)
die("KVM_CREATE_VM fail.\n");

return vm_fd;
}

static int create_vcpu(int vm_fd)
{
int vcpu_fd;

vcpu_fd = ioctl(vm_fd, KVM_CREATE_VCPU, 0);
if (vcpu_fd < 0)
die("KVM_CREATE_VCPU ioctl.\n");
printf("Create vcpu.\n");
return vcpu_fd;
}

static void *vcpu_thread(void *arg)
{
int vm_fd = (int)(long)arg;

create_vcpu(vm_fd);
return NULL;
}

int main(int argc, char *argv[])
{
pthread_t thread;
int vm_fd;

(void)argc;
(void)argv;

vm_fd = create_vm();
pthread_create(&thread, NULL, vcpu_thread, (void *)(long)vm_fd);
printf("Exit.\n");
return 0;
}

It is caused by release kvm->arch.ept_identity_map_addr which is the
error page.

The parent thread can send KILL signal to the vcpu thread when it was
exiting which stops faulting pages and potentially allocating memory.
So gfn_to_pfn/gfn_to_page may fail at this time

Fixed by checking the page before it is used

Signed-off-by: Xiao Guangrong 
---
 arch/x86/kvm/vmx.c |   19 ---
 arch/x86/kvm/x86.c |   13 ++---
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 248c2b4..ccea20a 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3590,6 +3590,7 @@ static void seg_setup(int seg)

 static int alloc_apic_access_page(struct kvm *kvm)
 {
+   struct page *page;
struct kvm_userspace_memory_region kvm_userspace_mem;
int r = 0;

@@ -3604,7 +3605,13 @@ static int alloc_apic_access_page(struct kvm *kvm)
if (r)
goto out;

-   kvm->arch.apic_access_page = gfn_to_page(kvm, 0xfee00);
+   page = gfn_to_page(kvm, 0xfee00);
+   if (is_error_page(page)) {
+   r = -EFAULT;
+   goto out;
+   }
+
+   kvm->arch.apic_access_page = page;
 out:
mutex_unlock(&kvm->slots_lock);
return r;
@@ -3612,6 +3619,7 @@ out:

 static int alloc_identity_pagetable(struct kvm *kvm)
 {
+   struct page *page;
struct kvm_userspace_memory_region kvm_userspace_mem;
int r = 0;

@@ -3627,8 +3635,13 @@ static int alloc_identity_pagetable(struct kvm *kvm)
if (r)
goto out;

-   kvm->arch.ept_identity_pagetable = gfn_to_page(kvm,
-   kvm->arch.ept_identity_map_addr >> PAGE_SHIFT);
+   page = gfn_to_page(kvm, kvm->arch.ept_identity_map_addr >> PAGE_SHIFT);
+   if (is_error_page(page)) {
+   r = -EFAULT;
+   goto out;
+   }
+
+   kvm->arch.ept_identity_pagetable = page;
 out:
mutex_unlock(&kvm->slots_lock);
return r;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index d8fba22..d44edaa 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5101,17 +5101,20 @@ static void post_kvm_run_save(struct kvm_vcpu *vcpu)
!kvm_event_needs_reinjection(vcpu);
 }

-static void vapic_enter(struct kvm_vcpu *vcpu)
+static int vapic_enter(struct kvm_vcpu *vcpu)
 {
struct kvm_lapic *apic = vcpu->arch.apic;
struct page *page;

if (!apic || !apic->vapic_addr)
-   return;
+   return 0;

page = gfn_to_page(vcpu->kvm, apic->vapic_addr >> PAGE_SHIFT);
+   if (is_error_page(page))
+   return -EFAULT;

vcpu->arch.apic->vapic_page = page;
+   return 0;
 }

 static void vapic_exit(struct kvm_vcpu *vcpu)
@@ -5418,7 +5421,11 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
}

vcpu->srcu_idx = srcu_read_lock(&kvm->srcu);
-   vapic_enter(vcpu);
+   r = vapic_enter(vcpu);
+   if (r) {
+   srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx);
+   return r;
+   }

r = 1;
while (r > 0) {
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  h

Re: [PATCH v6 1/3] spi/pl022: Add chip select handling via GPIO

2012-09-02 Thread shiraz hashim
Hi Linus,

On Sun, Sep 2, 2012 at 12:48 PM, Linus Walleij  wrote:
> On Sat, Sep 1, 2012 at 1:14 PM, shiraz hashim
>  wrote:
>> Hi Roland,
>>
>> On Wed, Aug 22, 2012 at 7:19 PM, Roland Stigge  wrote:
>>> @@ -2016,6 +2030,8 @@ pl022_probe(struct amba_device *adev, co
>>> pl022->master_info = platform_info;
>>> pl022->adev = adev;
>>> pl022->vendor = id->data;
>>> +   /* Point chipselects to allocated memory beyond the main struct */
>>> +   pl022->chipselects = (int *) pl022 + sizeof(struct pl022);
>>
>> This is going beyond memory allocated for chipselects
>> as it adds 4 * sizeof(struct pl022) bytes to pl022.
>
> Yes that is why the allocation looks like this:
>
> +   master = spi_alloc_master(dev, sizeof(struct pl022) + sizeof(int) *
> + platform_info->num_chipselect);
>

The allocation is such because type of chipselects is int.

The statement for allocation is correct, but

   pl022->chipselects = (int *) pl022 + sizeof(struct pl022);

is not adding  sizeof(struct pl022) bytes to pl022 base (which we want),
but infact 4 times the size of pl022 (because type of pl022 is now int *).

Do you get my point ?  This would go way beyond memory allocated
for chipselects.

-- 
regards
Shiraz Hashim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] kdb: fix possible memory leak in kdb_defcmd2()

2012-09-02 Thread Wei Yongjun
From: Wei Yongjun 

In the error handling case of kdb_defcmd2() s->command has
been set to NULL but the save_command remain no free, this will
cause memory leak.

spatch with a semantic match is used to found this problem.
(http://coccinelle.lip6.fr/)

Signed-off-by: Wei Yongjun 
---
 kernel/debug/kdb/kdb_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 31df170..0cbe79f 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -651,6 +651,7 @@ static int kdb_defcmd2(const char *cmdstr, const char 
*argv0)
kdb_printf("Could not allocate new kdb_defcmd table for %s\n",
   cmdstr);
s->usable = 0;
+   kfree(save_command);
return KDB_NOTIMP;
}
memcpy(s->command, save_command, s->count * sizeof(*(s->command)));


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: input0: bad kobj_uevent_env content in show_uevent()

2012-09-02 Thread Bjørn Mork
Fengguang Wu  writes:

> After the __devinit* removal series, I can still get kernel panic in
> show_uevent(). So there are more sources of bug..
>
> Debug patch:
>
> @@ -343,8 +343,11 @@ static ssize_t show_uevent(struct device
> goto out;
>
> /* copy keys to file */
> -   for (i = 0; i < env->envp_idx; i++)
> +   dev_err(dev, "uevent %d env[%d]: %s/.../%s\n", env->buflen, 
> env->envp_idx, top_kobj->name, dev->kobj.name);
> +   for (i = 0; i < env->envp_idx; i++) {
> +   printk(KERN_ERR "uevent %d env[%d]: %s\n", (int)count, i, 
> env->envp[i]);
> count += sprintf(&buf[count], "%s\n", env->envp[i]);
> +   }
>
> Oops message, the env[] is again not properly initilized:
>
> [   44.068623] input input0: uevent 61 env[805306368]: input0/.../input0
> [   44.069552] uevent 0 env[0]: (null)

This is a completely different CONFIG_HOTPLUG problem, only
demonstrating another reason why CONFIG_HOTPLUG should go away.  I had a
hard time trying to disable it anyway ;-)

The problem this time is lots of code assuming that a call to
add_uevent_var() will guarantee that env->buflen > 0.  This is not true
if CONFIG_HOTPLUG is unset.  So things like this end up overwriting
env->envp_idx because the array index is -1:

if (add_uevent_var(env, "MODALIAS="))
return -ENOMEM;
len = input_print_modalias(&env->buf[env->buflen - 1],
   sizeof(env->buf) - env->buflen,
   dev, 0);


Don't know what the best action is, given that there seem to be a *lot*
of this around the kernel.  This patch "fixes" the problem for me, but I
don't know if it can be considered an appropriate fix:


diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index fc615a9..1e57449 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -224,7 +224,7 @@ static inline int kobject_uevent_env(struct kobject *kobj,
 
 static inline __printf(2, 3)
 int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...)
-{ return 0; }
+{ return -ENOMEM; }
 
 static inline int kobject_action_type(const char *buf, size_t count,
  enum kobject_action *type)




Bjørn
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 0/3] MIPS: JZ4740: Move PWM driver to PWM framework

2012-09-02 Thread Maarten ter Huurne
On Sunday 02 September 2012 11:52:27 Thierry Reding wrote:

> This small series fixes a build error due to a circular header
> dependency, exports the timer API so it can be used outside of
> the arch/mips/jz4740 tree and finally moves and converts the
> JZ4740 PWM driver to the PWM framework.
> 
> Note that I don't have any hardware to test this on, so I had to
> rely on compile tests only. Patches 1 and 2 should probably go
> through the MIPS tree, while I can take patch 3 through the PWM
> tree. It touches a couple of files in arch/mips but the changes
> are unlikely to cause conflicts.

Exporting the hardware outputs PWM2-7 as index 0-5 in the PWM core is rather 
confusing. I discussed with Lars on IRC and it's probably better to expose 
PWM0-7 through the API, but refuse to hand out PWM0 and PWM1 when requested, 
since their associated timers are in use by the system. I attached a diff 
that illustrates this approach.

Note that if this approach is taken, the beeper ID in board-qi_lb60.c should 
be changed back from 2 to 4, since the beeper is attached to PWM4.

I tested the "for-next" branch on the Dingoo A320 with the pwm-backlight 
driver. It didn't work at first, because the PWM number and the timer number 
didn't align: I requested PWM number 5 to get PWM7 and the GPIO of PWM7 was 
used, but with timer 5 instead of timer 7, resulting in a dark screen. 
However, it works fine after adding PWM0/1 as described above.

If other people want to test on real hardware, you can find the code in 
branch jz-3.6-rc2-pwm in the qi-kernel repository. Unfortunately our web 
interface for git is still broken, but the repo itself is fine.
  git://projects.qi-hardware.com/qi-kernel.git

Bye,
Maarten
diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
index db29b37..554e414 100644
--- a/drivers/pwm/pwm-jz4740.c
+++ b/drivers/pwm/pwm-jz4740.c
@@ -24,9 +24,11 @@
 #include 
 #include 
 
-#define NUM_PWM 6
+#define NUM_PWM 8
 
 static const unsigned int jz4740_pwm_gpio_list[NUM_PWM] = {
+	JZ_GPIO_PWM0,
+	JZ_GPIO_PWM1,
 	JZ_GPIO_PWM2,
 	JZ_GPIO_PWM3,
 	JZ_GPIO_PWM4,
@@ -50,6 +52,13 @@ static int jz4740_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
 	unsigned int gpio = jz4740_pwm_gpio_list[pwm->hwpwm];
 	int ret;
 
+	/*
+	 * Timer 0 and 1 are used for system tasks, so they are unavailable
+	 * for use as PWMs.
+	 */
+	if (pwm->hwpwm < 2)
+		return -EBUSY;
+
 	ret = gpio_request(gpio, pwm->label);
 
 	if (ret) {


[PATCH v2 4/6] KVM: trace the events of mmu_notifier

2012-09-02 Thread Xiao Guangrong
mmu_notifier is the interface to broadcast the mm events to KVM, the
tracepoints introduced in this patch can trace all these events, it is
very helpful for us to notice and fix the bug caused by mm

Signed-off-by: Xiao Guangrong 
---
 include/trace/events/kvm.h |  129 
 virt/kvm/kvm_main.c|   19 +++
 2 files changed, 148 insertions(+), 0 deletions(-)

diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h
index 7ef9e75..5d082b7 100644
--- a/include/trace/events/kvm.h
+++ b/include/trace/events/kvm.h
@@ -309,6 +309,135 @@ TRACE_EVENT(

 #endif

+#if defined(CONFIG_MMU_NOTIFIER) && defined(KVM_ARCH_WANT_MMU_NOTIFIER)
+TRACE_EVENT(kvm_mmu_notifier_invalidate_page,
+
+   TP_PROTO(unsigned long hva),
+
+   TP_ARGS(hva),
+
+   TP_STRUCT__entry(
+   __field(unsigned long, hva)
+   ),
+
+   TP_fast_assign(
+   __entry->hva = hva;
+   ),
+
+   TP_printk("hva %lx", __entry->hva)
+);
+
+DECLARE_EVENT_CLASS(mmu_notifier_young_class,
+
+   TP_PROTO(unsigned long hva, int young),
+
+   TP_ARGS(hva, young),
+
+   TP_STRUCT__entry(
+   __field(unsigned long, hva)
+   __field(int, young)
+   ),
+
+   TP_fast_assign(
+   __entry->hva = hva;
+   __entry->young = young;
+   ),
+
+   TP_printk("hva %lx young %x", __entry->hva, __entry->young)
+);
+
+DEFINE_EVENT(mmu_notifier_young_class, kvm_mmu_notifier_clear_flush_young,
+
+   TP_PROTO(unsigned long hva, int young),
+
+   TP_ARGS(hva, young)
+);
+
+DEFINE_EVENT(mmu_notifier_young_class, kvm_mmu_notifier_test_young,
+
+   TP_PROTO(unsigned long hva, int young),
+
+   TP_ARGS(hva, young)
+);
+
+DECLARE_EVENT_CLASS(mmu_notifier_range_class,
+
+   TP_PROTO(unsigned long start, unsigned long end),
+
+   TP_ARGS(start, end),
+
+   TP_STRUCT__entry(
+   __field(unsigned long, start)
+   __field(unsigned long, end)
+   ),
+
+   TP_fast_assign(
+   __entry->start = start;
+   __entry->end = end;
+   ),
+
+   TP_printk("start %lx end %lx", __entry->start, __entry->end)
+);
+
+DEFINE_EVENT(mmu_notifier_range_class, kvm_mmu_notifier_invalidate_range_start,
+
+   TP_PROTO(unsigned long start, unsigned long end),
+
+   TP_ARGS(start, end)
+);
+
+DEFINE_EVENT(mmu_notifier_range_class, kvm_mmu_notifier_invalidate_range_end,
+
+   TP_PROTO(unsigned long start, unsigned long end),
+
+   TP_ARGS(start, end)
+);
+
+#define pte_bit(func, bit) \
+   (pte_##func(__pte(__entry->pteval)) ? bit : '-')
+
+TRACE_EVENT(kvm_mmu_notifier_change_pte,
+
+   TP_PROTO(unsigned long hva, pte_t pte),
+
+   TP_ARGS(hva, pte),
+
+   TP_STRUCT__entry(
+   __field(unsigned long, hva)
+   __field(unsigned long long, pteval)
+   __field(pfn_t, pfn)
+   __field(bool, writable)
+   ),
+
+   TP_fast_assign(
+   __entry->hva = hva;
+   __entry->pteval = (long long)pte_val(pte);
+   ),
+
+   TP_printk("hva %lx pte %llx pfn %lx bits %c%c%c%c", __entry->hva,
+ __entry->pteval, pte_pfn(__pte(__entry->pteval)),
+ pte_bit(present, 'p'), pte_bit(write, 'w'),
+ pte_bit(dirty, 'd'), pte_bit(young, 'a'))
+);
+
+TRACE_EVENT(kvm_mmu_notifier_release,
+
+   TP_PROTO(struct kvm *kvm),
+
+   TP_ARGS(kvm),
+
+   TP_STRUCT__entry(
+   __field(struct kvm *, kvm)
+   ),
+
+   TP_fast_assign(
+   __entry->kvm = kvm;
+   ),
+
+   TP_printk("kvm %p", __entry->kvm)
+);
+#endif
+
 #endif /* _TRACE_KVM_MAIN_H */

 /* This part must be outside protection */
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 0cbc809..9604f4c 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -287,6 +287,8 @@ static void kvm_mmu_notifier_invalidate_page(struct 
mmu_notifier *mn,
idx = srcu_read_lock(&kvm->srcu);
spin_lock(&kvm->mmu_lock);

+   trace_kvm_mmu_notifier_invalidate_page(address);
+
kvm->mmu_notifier_seq++;
need_tlb_flush = kvm_unmap_hva(kvm, address) | kvm->tlbs_dirty;
/* we've to flush the tlb before the pages can be freed */
@@ -307,6 +309,9 @@ static void kvm_mmu_notifier_change_pte(struct mmu_notifier 
*mn,

idx = srcu_read_lock(&kvm->srcu);
spin_lock(&kvm->mmu_lock);
+
+   trace_kvm_mmu_notifier_change_pte(address, pte);
+
kvm->mmu_notifier_seq++;
kvm_set_spte_hva(kvm, address, pte);
spin_unlock(&kvm->mmu_lock);
@@ -323,6 +328,9 @@ static void kvm_mmu_notifier_invalidate_range_start(struct 
mmu_notifier *mn,

idx = srcu_read_lock(&kvm->srcu);
spin_lock(&kvm->mmu_lock);
+
+   trace_kvm_mmu_notifier_invalidate_range_start(start, end);
+
/*
 * The count increase must become visible at unlock time as no
 

Re: [PATCH v7 3/3] KVM: perf: kvm events analysis tool

2012-09-02 Thread don

于 2012年08月27日 23:53, Andrew Jones 写道:

On Mon, Aug 27, 2012 at 05:51:46PM +0800, Dong Hao wrote:




+struct event_stats {
+   u64 count;
+   u64 time;
+
+   /* used to calculate stddev. */
+   double mean;
+   double M2;
+};

How about moving the stats functions from builtin-stat.c to e.g.
util/stats.c, and then reusing them? Then this struct (which I would
rename to kvm_event_stats) would look like this

struct kvm_event_stats {
 u64 time;
 struct stats stats;
};

of course the get_event_ accessor generators would need tweaking




+static void update_event_stats(struct event_stats *stats, u64 time_diff)
+{
+   double delta;
+
+   stats->count++;
+   stats->time += time_diff;
+
+   delta = time_diff - stats->mean;
+   stats->mean += delta / stats->count;
+   stats->M2 += delta*(time_diff - stats->mean);
+}

Reusing stats would allow this to become just

static void update_event_stats(struct kvm_event_stats *stats, u64 time_diff)
{
update_stats(&kvm_stats->stats, time_diff);
kvm_stats->time += time_diff;
}


+
+static double event_stats_stddev(int vcpu_id, struct kvm_event *event)
+{
+   struct event_stats *stats = &event->total;
+   double variance, variance_mean, stddev;
+
+   if (vcpu_id != -1)
+   stats = &event->vcpu[vcpu_id];
+
+   BUG_ON(!stats->count);
+
+   variance = stats->M2 / (stats->count - 1);
+   variance_mean = variance / stats->count;
+   stddev = sqrt(variance_mean);
+
+   return stddev * 100 / stats->mean;

This function's name implies it returns the stddev, but it returns the
relative stddev instead. Maybe rename it? This would be simplified
with code reuse too to basically just

return stddev_stats(&kvm_stats->stats) * 100 / kvm_stats->stats.mean;

Drew

Sorry for my late response, Andrew and thank you very much for your 
comments. We will try

to realize it in our next version.

Thanks,
Dong

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/6] KVM: MMU: release noslot pfn on the fail path properly

2012-09-02 Thread Xiao Guangrong
Sorry, i forgot to modify the patch title, total patch number is 3, so the title
should be 1/3, 2/3, 3/3. :(

On 09/02/2012 08:56 PM, Xiao Guangrong wrote:
> We can not directly call kvm_release_pfn_clean to release the pfn
> since we can meet noslot pfn which is used to cache mmio info into
> spte
> 
> Introduce mmu_release_pfn_clean to do this kind of thing
> 
> Signed-off-by: Xiao Guangrong 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ALSA: fix possible memory leak in snd_mixer_oss_build_input()

2012-09-02 Thread Wei Yongjun
From: Wei Yongjun 

uinfo has been allocated in this function and should be
freed before leaving from the error handling cases.

spatch with a semantic match is used to found this problem.
(http://coccinelle.lip6.fr/)

Signed-off-by: Wei Yongjun 
---
 sound/core/oss/mixer_oss.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index 18297f7..29f6ded 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -1046,6 +1046,7 @@ static int snd_mixer_oss_build_input(struct snd_mixer_oss 
*mixer, struct snd_mix

if (kctl->info(kctl, uinfo)) {
up_read(&mixer->card->controls_rwsem);
+   kfree(uinfo);
return 0;
}
strcpy(str, ptr->name);
@@ -1061,6 +1062,7 @@ static int snd_mixer_oss_build_input(struct snd_mixer_oss 
*mixer, struct snd_mix
uinfo->value.enumerated.item = 
slot.capture_item;
if (kctl->info(kctl, uinfo)) {
up_read(&mixer->card->controls_rwsem);
+   kfree(uinfo);
return 0;
}
if (!strcmp(uinfo->value.enumerated.name, str)) 
{


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] dma-debug: Add dma map/unmap error tracking support

2012-09-02 Thread Shuah Khan
A recent dma mapping error analysis effort showed that a large precentage
of dma_map_single() and dma_map_page() returns are not checked for mapping
errors. Reference: https://lkml.org/lkml/2012/8/10/326

Adding support for tracking dma mapping and unmapping errors to help assess
the following:

When do dma mapping errors get detected?
How often do these errors occur?
Why don't we see failures related to missing dma mapping error checks?
Are they silent failures?

Signed-off-by: Shuah Khan 
---
 Documentation/DMA-API.txt |7 +++
 lib/dma-debug.c   |   26 +-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
index 66bd97a..ee10a11 100644
--- a/Documentation/DMA-API.txt
+++ b/Documentation/DMA-API.txt
@@ -638,6 +638,13 @@ this directory the following files can currently be found:
dma-api/error_count This file is read-only and shows the total
numbers of errors found.
 
+   dma-api/dma_map_errors  This file is read-only and shows the total
+   number of dma mapping errors detected.
+
+   dma-api/dma_unmap_errors
+   This file is read-only and shows the total
+   number of invalid dma unmapping attempts.
+
dma-api/num_errors  The number in this file shows how many
warnings will be printed to the kernel log
before it stops. This number is initialized to
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 66ce414..8596114 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -83,6 +83,10 @@ static u32 global_disable __read_mostly;
 /* Global error count */
 static u32 error_count;
 
+/* dma mapping error counts */
+static u32 dma_map_errors;
+static u32 dma_unmap_errors;
+
 /* Global error show enable*/
 static u32 show_all_errors __read_mostly;
 /* Number of errors to show */
@@ -104,6 +108,8 @@ static struct dentry *show_num_errors_dent  __read_mostly;
 static struct dentry *num_free_entries_dent __read_mostly;
 static struct dentry *min_free_entries_dent __read_mostly;
 static struct dentry *filter_dent   __read_mostly;
+static struct dentry *dma_map_errors_dent   __read_mostly;
+static struct dentry *dma_unmap_errors_dent __read_mostly;
 
 /* per-driver filter related state */
 
@@ -695,6 +701,19 @@ static int dma_debug_fs_init(void)
if (!filter_dent)
goto out_err;
 
+   dma_map_errors_dent = debugfs_create_u32("dma_map_errors", 0444,
+   dma_debug_dent,
+   &dma_map_errors);
+
+   if (!dma_map_errors_dent)
+   goto out_err;
+
+   dma_unmap_errors_dent = debugfs_create_u32("dma_unmap_errors", 0444,
+   dma_debug_dent,
+   &dma_unmap_errors);
+   if (!dma_unmap_errors_dent)
+   goto out_err;
+
return 0;
 
 out_err:
@@ -850,6 +869,7 @@ static void check_unmap(struct dma_debug_entry *ref)
unsigned long flags;
 
if (dma_mapping_error(ref->dev, ref->dev_addr)) {
+   dma_unmap_errors += 1;
err_printk(ref->dev, NULL, "DMA-API: device driver tries "
   "to free an invalid DMA memory address\n");
return;
@@ -1022,8 +1042,12 @@ void debug_dma_map_page(struct device *dev, struct page 
*page, size_t offset,
if (unlikely(global_disable))
return;
 
-   if (unlikely(dma_mapping_error(dev, dma_addr)))
+   if (unlikely(dma_mapping_error(dev, dma_addr))) {
+   dma_map_errors += 1;
+   err_printk(dev, NULL,
+  "DMA-API: dma_map_page() returned error\n");
return;
+   }
 
entry = dma_entry_alloc();
if (!entry)
-- 
1.7.9.5



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mtd: fix possible memory leak in logfs_mtd_can_write_buf()

2012-09-02 Thread Wei Yongjun
From: Wei Yongjun 

buf has been allocated in this function and should be
freed before leaving from the error handling case.

spatch with a semantic match is used to found this problem.
(http://coccinelle.lip6.fr/)

Signed-off-by: Wei Yongjun 
---
 fs/logfs/dev_mtd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/logfs/dev_mtd.c b/fs/logfs/dev_mtd.c
index 9c50144..427bb73 100644
--- a/fs/logfs/dev_mtd.c
+++ b/fs/logfs/dev_mtd.c
@@ -245,8 +245,8 @@ static int logfs_mtd_can_write_buf(struct super_block *sb, 
u64 ofs)
goto out;
if (memchr_inv(buf, 0xff, super->s_writesize))
err = -EIO;
-   kfree(buf);
 out:
+   kfree(buf);
return err;
 }
 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


ASpeed Technologies KMS VGA Driver error in log

2012-09-02 Thread Keven
1. ASpeed Technologies KMS VGA Driver error in log
2. Hi, I have an error message in my kernel log and I don't know if this
need to be taken care of or this is a normal behaviour. 

The component is [PATCH] drm: Initial KMS driver for AST (ASpeed
Technologies) 2000 series
This article is related to the new compoent. 
http://lists.freedesktop.org/archives/dri-devel/2012-April/021578.html

The code file should be 
Linux/drivers/gpu/drm/ast/ast_mode.c

The error I have is  
[7.518793] [drm:ast_cursor_init] *ERROR* pinned cursor cache at 0

When I start my machine, I receive these messages from the component.

[7.515770] ast :01:01.0: enabling device ( -> 0003)
[7.516711] [drm] AST 1100 detected
[7.516764] [drm] dram 32400 0 32 0400
**
[7.518793] [drm:ast_cursor_init] *ERROR* pinned cursor cache at 0
**
[   23.703894] fb1: astdrmfb frame buffer device
[   23.703897] drm: registered panic notifier
[   23.703902] [drm] Initialized ast 0.1.0 20120228 for :01:01.0 on
minor 0



This can be traced back to the function
int ast_cursor_init(struct drm_device *dev)
and 
DRM_ERROR("pinned cursor cache at %llx\n", ast->cursor_cache_gpu_addr);

So.. is this normal ? ? ?

3. /proc/version Linux version 3.5.3-1-ARCH (tobias@T-POWA-LX) (gcc
version 4.7.1 20120721 (prerelease) (GCC) ) #1 SMP PREEMPT Sun Aug 26
09:14:51 CEST 2012

7.lspci -
01:01.0 VGA compatible controller: ASPEED Technology, Inc. ASPEED
Graphics Family (rev 10) (prog-if 00 [VGA controller])
Subsystem: ASPEED Technology, Inc. ASPEED Graphics Family
Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr-
Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort-
SERR- http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/3] pwm: Add Ingenic JZ4740 support

2012-09-02 Thread Lars-Peter Clausen
On 09/02/2012 11:52 AM, Thierry Reding wrote:
> This commit moves the driver to drivers/pwm and converts it to the new
> PWM framework.
> 

Thanks for taking care of this, some comments inline.

[...]
> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index 92b1782..f5acdaa 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -371,7 +371,7 @@ EXPORT_SYMBOL_GPL(pwm_free);
>   */
>  int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
>  {
> - if (!pwm || period_ns == 0 || duty_ns > period_ns)
> + if (!pwm || duty_ns < 0 || period_ns <= 0 || duty_ns > period_ns)
>   return -EINVAL;
>  

This change seems to be unrelated.

>   return pwm->chip->ops->config(pwm->chip, pwm, duty_ns, period_ns);
> diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
> new file mode 100644
> index 000..db29b37
> --- /dev/null
> +++ b/drivers/pwm/pwm-jz4740.c
> @@ -0,0 +1,205 @@
> +/*
> + *  Copyright (C) 2010, Lars-Peter Clausen 
> + *  JZ4740 platform PWM support
> + *
> + *  This program is free software; you can redistribute it and/or modify it
> + *  under  the terms of the GNU General  Public License as published by the
> + *  Free Software Foundation;  either version 2 of the License, or (at your
> + *  option) any later version.
> + *
> + *  You should have received a copy of the GNU General Public License along
> + *  with this program; if not, write to the Free Software Foundation, Inc.,
> + *  675 Mass Ave, Cambridge, MA 02139, USA.
> + *
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 

#include 

> +
> +#define NUM_PWM 6
> +
> +static const unsigned int jz4740_pwm_gpio_list[NUM_PWM] = {

As mth said, it would be better to have JZ_GPIO_PWM0 and here as well and set
NUM_PWM to 8. Right now we are using the timers associated to PWM channel 0 and
1 as system timers. But there might be devices where this is not possible, e.g.
because the PWM is actually connected to something. Also this fixes the of by
two for the hwpwm id.

> + JZ_GPIO_PWM2,
> + JZ_GPIO_PWM3,
> + JZ_GPIO_PWM4,
> + JZ_GPIO_PWM5,
> + JZ_GPIO_PWM6,
> + JZ_GPIO_PWM7,
> +};
> +
> +struct jz4740_pwm_chip {
> + struct pwm_chip chip;
> + struct clk *clk;
> +};
> +
> +static inline struct jz4740_pwm_chip *to_jz4740(struct pwm_chip *chip)
> +{
> + return container_of(chip, struct jz4740_pwm_chip, chip);
> +}
> +
> +static int jz4740_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
> +{
> + unsigned int gpio = jz4740_pwm_gpio_list[pwm->hwpwm];
> + int ret;
> +
> + ret = gpio_request(gpio, pwm->label);
> +
> + if (ret) {
> + printk(KERN_ERR "Failed to request pwm gpio: %d\n", ret);

dev_err(chip->dev, 

> + return ret;
> + }
> +
> + jz_gpio_set_function(gpio, JZ_GPIO_FUNC_PWM);
> +
> + jz4740_timer_start(pwm->hwpwm);
> +
> + return 0;
> +}
> +
> +static void jz4740_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
> +{
> + unsigned int gpio = jz4740_pwm_gpio_list[pwm->hwpwm];
> +
> + jz4740_timer_set_ctrl(pwm->hwpwm, 0);
> +
> + jz_gpio_set_function(gpio, JZ_GPIO_FUNC_NONE);
> + gpio_free(gpio);
> +
> + jz4740_timer_stop(pwm->hwpwm);
> +}
> +
> +static int jz4740_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> +  int duty_ns, int period_ns)
> +{
> + struct jz4740_pwm_chip *jz4740 = to_jz4740(pwm->chip);
> + unsigned long long tmp;
> + unsigned long period, duty;
> + unsigned int prescaler = 0;
> + uint16_t ctrl;
> + bool is_enabled;
> +
> + tmp = (unsigned long long)clk_get_rate(jz4740->clk) * period_ns;
> + do_div(tmp, 10);
> + period = tmp;
> +
> + while (period > 0x && prescaler < 6) {
> + period >>= 2;
> + ++prescaler;
> + }
> +
> + if (prescaler == 6)
> + return -EINVAL;
> +
> + tmp = (unsigned long long)period * duty_ns;
> + do_div(tmp, period_ns);
> + duty = period - tmp;
> +
> + if (duty >= period)
> + duty = period - 1;
> +
> + is_enabled = jz4740_timer_is_enabled(pwm->hwpwm);
> + if (is_enabled)
> + pwm_disable(pwm);

I think this should be jz4740_pwm_disable

> +
> + jz4740_timer_set_count(pwm->hwpwm, 0);
> + jz4740_timer_set_duty(pwm->hwpwm, duty);
> + jz4740_timer_set_period(pwm->hwpwm, period);
> +
> + ctrl = JZ_TIMER_CTRL_PRESCALER(prescaler) | JZ_TIMER_CTRL_SRC_EXT |
> + JZ_TIMER_CTRL_PWM_ABBRUPT_SHUTDOWN;
> +
> + jz4740_timer_set_ctrl(pwm->hwpwm, ctrl);
> +
> + if (is_enabled)
> + pwm_enable(pwm);

and jz4740_pwm_enable here.

> +
> + return 0;
> +}
> +

> +
> +static const struct pwm_ops jz4740_pwm_ops = {
> + .request = jz4740_pwm_request,
> + .free = jz4740_pwm_free,
> + .config = jz4740_pwm_config,
> + .enable = jz4740_p

Re: [PATCH 2/3] MIPS: JZ4740: Export timer API

2012-09-02 Thread Lars-Peter Clausen
On 09/02/2012 11:52 AM, Thierry Reding wrote:
> This is a prerequisite for allowing the PWM driver to be converted to
> the PWM framework.
> 
> Signed-off-by: Thierry Reding 

I'd prefer to keep the timer functions inline, some of them are called quite
often in the system clock code.

> ---
>  arch/mips/include/asm/mach-jz4740/timer.h |  35 
>  arch/mips/jz4740/time.c   |   2 +-
>  arch/mips/jz4740/timer.c  | 128 +---
>  arch/mips/jz4740/timer.h  | 136 
> --
>  4 files changed, 153 insertions(+), 148 deletions(-)
>  delete mode 100644 arch/mips/jz4740/timer.h
> 
> diff --git a/arch/mips/include/asm/mach-jz4740/timer.h 
> b/arch/mips/include/asm/mach-jz4740/timer.h
> index 9baa03c..9e41d0e 100644
> --- a/arch/mips/include/asm/mach-jz4740/timer.h
> +++ b/arch/mips/include/asm/mach-jz4740/timer.h
> @@ -16,6 +16,41 @@
>  #ifndef __ASM_MACH_JZ4740_TIMER
>  #define __ASM_MACH_JZ4740_TIMER
>  
> +#define JZ_TIMER_CTRL_PWM_ABBRUPT_SHUTDOWN   BIT(9)
> +#define JZ_TIMER_CTRL_PWM_ACTIVE_LOW BIT(8)
> +#define JZ_TIMER_CTRL_PWM_ENABLE BIT(7)
> +#define JZ_TIMER_CTRL_PRESCALE_MASK  0x1c
> +#define JZ_TIMER_CTRL_PRESCALE_OFFSET0x3
> +#define JZ_TIMER_CTRL_PRESCALE_1 (0 << 3)
> +#define JZ_TIMER_CTRL_PRESCALE_4 (1 << 3)
> +#define JZ_TIMER_CTRL_PRESCALE_16(2 << 3)
> +#define JZ_TIMER_CTRL_PRESCALE_64(3 << 3)
> +#define JZ_TIMER_CTRL_PRESCALE_256   (4 << 3)
> +#define JZ_TIMER_CTRL_PRESCALE_1024  (5 << 3)
> +
> +#define JZ_TIMER_CTRL_PRESCALER(x) ((x) << JZ_TIMER_CTRL_PRESCALE_OFFSET)
> +
> +#define JZ_TIMER_CTRL_SRC_EXTBIT(2)
> +#define JZ_TIMER_CTRL_SRC_RTCBIT(1)
> +#define JZ_TIMER_CTRL_SRC_PCLK   BIT(0)
> +
> +void __init jz4740_timer_init(void);
> +
> +void jz4740_timer_stop(unsigned int timer);
> +void jz4740_timer_start(unsigned int timer);
> +bool jz4740_timer_is_enabled(unsigned int timer);
> +void jz4740_timer_enable(unsigned int timer);
> +void jz4740_timer_disable(unsigned int timer);
> +void jz4740_timer_set_period(unsigned int timer, uint16_t period);
> +void jz4740_timer_set_duty(unsigned int timer, uint16_t duty);
> +void jz4740_timer_set_count(unsigned int timer, uint16_t count);
> +uint16_t jz4740_timer_get_count(unsigned int timer);
> +void jz4740_timer_ack_full(unsigned int timer);
> +void jz4740_timer_irq_full_enable(unsigned int timer);
> +void jz4740_timer_irq_full_disable(unsigned int timer);
> +uint16_t jz4740_timer_get_ctrl(unsigned int timer);
> +void jz4740_timer_set_ctrl(unsigned int timer, uint16_t ctrl);
> +
>  void jz4740_timer_enable_watchdog(void);
>  void jz4740_timer_disable_watchdog(void);
>  
> diff --git a/arch/mips/jz4740/time.c b/arch/mips/jz4740/time.c
> index f83c2dd..39bb4bb 100644
> --- a/arch/mips/jz4740/time.c
> +++ b/arch/mips/jz4740/time.c
> @@ -20,10 +20,10 @@
>  #include 
>  
>  #include 
> +#include 
>  #include 
>  
>  #include "clock.h"
> -#include "timer.h"
>  
>  #define TIMER_CLOCKEVENT 0
>  #define TIMER_CLOCKSOURCE 1
> diff --git a/arch/mips/jz4740/timer.c b/arch/mips/jz4740/timer.c
> index 654d5c3..79c4354 100644
> --- a/arch/mips/jz4740/timer.c
> +++ b/arch/mips/jz4740/timer.c
> @@ -21,19 +21,28 @@
>  
>  #include 
>  
> -void __iomem *jz4740_timer_base;
> +#define JZ_REG_TIMER_STOP0x0C
> +#define JZ_REG_TIMER_STOP_SET0x1C
> +#define JZ_REG_TIMER_STOP_CLEAR  0x2C
> +#define JZ_REG_TIMER_ENABLE  0x00
> +#define JZ_REG_TIMER_ENABLE_SET  0x04
> +#define JZ_REG_TIMER_ENABLE_CLEAR0x08
> +#define JZ_REG_TIMER_FLAG0x10
> +#define JZ_REG_TIMER_FLAG_SET0x14
> +#define JZ_REG_TIMER_FLAG_CLEAR  0x18
> +#define JZ_REG_TIMER_MASK0x20
> +#define JZ_REG_TIMER_MASK_SET0x24
> +#define JZ_REG_TIMER_MASK_CLEAR  0x28
>  
> -void jz4740_timer_enable_watchdog(void)
> -{
> - writel(BIT(16), jz4740_timer_base + JZ_REG_TIMER_STOP_CLEAR);
> -}
> -EXPORT_SYMBOL_GPL(jz4740_timer_enable_watchdog);
> +#define JZ_REG_TIMER_DFR(x) (((x) * 0x10) + 0x30)
> +#define JZ_REG_TIMER_DHR(x) (((x) * 0x10) + 0x34)
> +#define JZ_REG_TIMER_CNT(x) (((x) * 0x10) + 0x38)
> +#define JZ_REG_TIMER_CTRL(x) (((x) * 0x10) + 0x3C)
>  
> -void jz4740_timer_disable_watchdog(void)
> -{
> - writel(BIT(16), jz4740_timer_base + JZ_REG_TIMER_STOP_SET);
> -}
> -EXPORT_SYMBOL_GPL(jz4740_timer_disable_watchdog);
> +#define JZ_TIMER_IRQ_HALF(x) BIT((x) + 0x10)
> +#define JZ_TIMER_IRQ_FULL(x) BIT(x)
> +
> +void __iomem *jz4740_timer_base;
>  
>  void __init jz4740_timer_init(void)
>  {
> @@ -48,3 +57,100 @@ void __init jz4740_timer_init(void)
>   /* Timer irqs are unmasked by default, mask them */
>   writel(0x00ff00ff, jz4740_timer_base + JZ_REG_TIMER_MASK_SET);
>  }
> +
> +void jz4740_timer_stop(unsigned int timer

Re: [PATCH 1/3] MIPS: JZ4740: Break circular header dependency

2012-09-02 Thread Lars-Peter Clausen
On 09/02/2012 11:52 AM, Thierry Reding wrote:
> When including irq.h, arch/mips/jz4740/irq.h will be selected as the
> first candidate. This header does not include the proper definitions
> (most notably NR_IRQS) required by subsequent headers. To solve this
> arch/mips/jz4740/irq.h can be deleted and its contents can be moved
> into arch/mips/include/asm/mach-jz4740/irq.h, which will then be
> correctly included.
> 

Where exactly did you have this problem? arch/mips/jz4740/ should not be in the
include path, so "#include " should not cause arch/mips/jz4740/irq.h to
be included.

> Signed-off-by: Thierry Reding 
> ---
>  arch/mips/include/asm/mach-jz4740/irq.h |  5 +
>  arch/mips/jz4740/irq.h  | 23 ---
>  2 files changed, 5 insertions(+), 23 deletions(-)
>  delete mode 100644 arch/mips/jz4740/irq.h
> 
> diff --git a/arch/mips/include/asm/mach-jz4740/irq.h 
> b/arch/mips/include/asm/mach-jz4740/irq.h
> index 5ad1a9c..aa6fd90 100644
> --- a/arch/mips/include/asm/mach-jz4740/irq.h
> +++ b/arch/mips/include/asm/mach-jz4740/irq.h
> @@ -54,4 +54,9 @@
>  
>  #define NR_IRQS (JZ4740_IRQ_ADC_BASE + 6)
>  
> +struct irq_data;
> +
> +extern void jz4740_irq_suspend(struct irq_data *data);
> +extern void jz4740_irq_resume(struct irq_data *data);
> +
>  #endif
> diff --git a/arch/mips/jz4740/irq.h b/arch/mips/jz4740/irq.h
> deleted file mode 100644
> index f75e39d..000
> --- a/arch/mips/jz4740/irq.h
> +++ /dev/null
> @@ -1,23 +0,0 @@
> -/*
> - *  Copyright (C) 2010, Lars-Peter Clausen 
> - *
> - *  This program is free software; you can redistribute it and/or modify it
> - *  under  the terms of the GNU General  Public License as published by the
> - *  Free Software Foundation;  either version 2 of the License, or (at your
> - *  option) any later version.
> - *
> - *  You should have received a copy of the GNU General Public License along
> - *  with this program; if not, write to the Free Software Foundation, Inc.,
> - *  675 Mass Ave, Cambridge, MA 02139, USA.
> - *
> - */
> -
> -#ifndef __MIPS_JZ4740_IRQ_H__
> -#define __MIPS_JZ4740_IRQ_H__
> -
> -#include 
> -
> -extern void jz4740_irq_suspend(struct irq_data *data);
> -extern void jz4740_irq_resume(struct irq_data *data);
> -
> -#endif

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3] hwmon: add Maxim MAX197 support

2012-09-02 Thread Guenter Roeck
On Sat, Sep 01, 2012 at 11:31:11AM +0200, Lars-Peter Clausen wrote:
> On 08/31/2012 06:04 PM, Guenter Roeck wrote:
> > On Thu, Aug 30, 2012 at 09:42:57PM -0400, Vivien Didelot wrote:
> >> The MAX197 is an A/D converter, made by Maxim. This driver currently
> >> supports the MAX197, and MAX199. They are both 8-Channel, Multi-Range,
> >> 5V, 12-Bit DAS with 8+4 Bus Interface and Fault Protection.
> >>
> >> The available ranges for the MAX197 are {0,-5V} to 5V, and {0,-10V} to
> >> 10V, while they are {0,-2V} to 2V, and {0,-4V} to 4V on the MAX199.
> >>
> >> Signed-off-by: Vivien Didelot 
> > 
> > Applied to -next.
> > 
> 
> Hm, now it's probably to late, but for this kind of general purpose ADC the 
> IIO
> framework is in my opinion the better place to add support for it.
> 
Possibly. If someone writes an iio driver for it, and everyone agrees,
we can drop it from hwmon at that time.

Guenter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/5] drivers/video/jz4740_fb.c: use devm_ functions

2012-09-02 Thread Lars-Peter Clausen
On 08/23/2012 10:41 PM, Florian Tobias Schandinat wrote:
> On 08/03/2012 03:40 PM, Damien Cassou wrote:
>> From: Damien Cassou 
>>
>> The various devm_ functions allocate memory that is released when a driver
>> detaches. This patch uses these functions for data that is allocated in the
>> probe function of a platform device and is only freed in the remove function.
>>
>> Signed-off-by: Damien Cassou 
> 
> Applied.
> 
> 
> Thanks,
> 
> Florian Tobias Schandinat
> 
>>
>> ---
>>  drivers/video/jz4740_fb.c |   22 ++
>>  1 file changed, 6 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/video/jz4740_fb.c b/drivers/video/jz4740_fb.c
>> index de36693..7669770 100644
>> --- a/drivers/video/jz4740_fb.c
>> +++ b/drivers/video/jz4740_fb.c
>> @@ -659,25 +659,25 @@ static int __devinit jzfb_probe(struct platform_device 
>> *pdev)
>>  jzfb->pdata = pdata;
>>  jzfb->mem = mem;
>>
>> -jzfb->ldclk = clk_get(&pdev->dev, "lcd");
>> +jzfb->ldclk = devm_clk_get(&pdev->dev, "lcd");

I guess I'm a bit late, but we do not have devm_clk_get on jz4740 (yet), so
this patch breaks linking for this driver in next. I'll to to have this added
for the next release, but if I do not succeed we'll have to revert part of this
patch.

Also the driver does not include #include , since it is required
for devm_ioremap compilation is also broken. This one is easy to fix though,
will send a follow-up patch.

- Lars
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] [RFC]power: battery: Generic battery driver using IIO

2012-09-02 Thread anish kumar
From: anish kumar 

This patch is to use IIO to write a generic batttery driver.
There are some inherent assumptions here:
1.User is having both main battery and backup battery.
2.Both batteries use same channel to get the information.

Signed-off-by: anish kumar 
---
 drivers/power/Kconfig |8 +
 drivers/power/Makefile|1 +
 drivers/power/generic-battery.c   |  374 +
 include/linux/power/generic-battery.h |   26 +++
 4 files changed, 409 insertions(+), 0 deletions(-)
 create mode 100644 drivers/power/generic-battery.c
 create mode 100644 include/linux/power/generic-battery.h

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index fcc1bb0..546e86b 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -309,6 +309,14 @@ config AB8500_BATTERY_THERM_ON_BATCTRL
help
  Say Y to enable battery temperature measurements using
  thermistor connected on BATCTRL ADC.
+
+config GENERIC_BATTERY
+   tristate "Generic battery support using IIO"
+   depends on IIO
+   help
+ Say Y here to enable support for the generic battery driver
+ which uses IIO framework to read adc for it's main and backup
+ battery.
 endif # POWER_SUPPLY
 
 source "drivers/power/avs/Kconfig"
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index ee58afb..8284f9c 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -45,3 +45,4 @@ obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o
 obj-$(CONFIG_CHARGER_MAX8998)  += max8998_charger.o
 obj-$(CONFIG_POWER_AVS)+= avs/
 obj-$(CONFIG_CHARGER_SMB347)   += smb347-charger.o
+obj-$(CONFIG_GENERIC_BATTERY)  += generic-battery.o
diff --git a/drivers/power/generic-battery.c b/drivers/power/generic-battery.c
new file mode 100644
index 000..33170b7
--- /dev/null
+++ b/drivers/power/generic-battery.c
@@ -0,0 +1,374 @@
+/*
+ * Generice battery driver code using IIO
+ * Copyright (C) 2012, Anish Kumar 
+ * based on jz4740-battery.c
+ * based on s3c_adc_battery.c
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file COPYING in the main directory of this archive for
+ * more details.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#define BAT_POLL_INTERVAL  1 /* ms */
+#define JITTER_DELAY   500 /* ms */
+
+enum BAT {
+   MAIN_BAT = 0,
+   BACKUP_BAT,
+   BAT_MAX,
+};
+
+struct generic_adc_bat {
+   struct power_supply psy;
+   struct iio_channel  *channels;
+   int channel_index;
+};
+
+struct generic_bat {
+   struct generic_adc_bat bat[BAT_MAX];
+   struct generic_platform_datapdata;
+   int volt_value;
+   int cur_value;
+   unsigned inttimestamp;
+   int level;
+   int status;
+   int cable_plugged:1;
+};
+
+static struct generic_bat generic_bat = {
+   .bat[MAIN_BAT] = {
+   .psy.name = "main-bat",
+   },
+   .bat[BACKUP_BAT] = {
+   .psy.name = "backup-bat",
+   },
+};
+
+static struct delayed_work bat_work;
+
+static void generic_adc_bat_ext_power_changed(struct power_supply *psy)
+{
+   schedule_delayed_work(&bat_work,
+   msecs_to_jiffies(JITTER_DELAY));
+}
+
+static enum power_supply_property generic_adc_main_bat_props[] = {
+   POWER_SUPPLY_PROP_STATUS,
+   POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
+   POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN,
+   POWER_SUPPLY_PROP_CHARGE_NOW,
+   POWER_SUPPLY_PROP_VOLTAGE_NOW,
+   POWER_SUPPLY_PROP_CURRENT_NOW,
+   POWER_SUPPLY_PROP_TECHNOLOGY,
+   POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
+   POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
+   POWER_SUPPLY_PROP_MODEL_NAME,
+};
+
+static int charge_finished(struct generic_bat *bat)
+{
+   return bat->pdata.gpio_inverted ?
+   !gpio_get_value(bat->pdata.gpio_charge_finished) :
+   gpio_get_value(bat->pdata.gpio_charge_finished);
+}
+
+static int generic_adc_bat_get_property(struct power_supply *psy,
+   enum power_supply_property psp,
+   union power_supply_propval *val)
+{
+   struct generic_adc_bat *adc_bat;
+   struct generic_bat *bat;
+   int ret, scaleint, scalepart, iio_val;
+   long result = 0;
+
+   if (!strcmp(psy->name, "main-battery")) {
+   adc_bat = container_of(psy,
+   struct generic_adc_bat, psy);
+   bat = container_of(adc_bat,
+   struct generic_bat, bat[MAIN_BAT]);
+   } else if (!strcmp(psy-

Re: linux page table

2012-09-02 Thread Xin Tong
On Sun, Sep 2, 2012 at 1:10 AM, Jiri Kosina  wrote:
> On Sat, 1 Sep 2012, Xin Tong wrote:
>
>> When a process is created in Linux, corresponding page table is
>> implemented. In the current x86 linux, the page table is a multi-level
>> page table and CR3 points to the first level of the page table.  I
>> have 2 questions.
>>
>> 1. is the value in CR3 virtual address or physical address ?
>
> Physical, otherwise you will have chicken-egg problem.
>
>> 2. can the address of the first level of the page table during a
>> process's lifetime change ?
>
> In theory it would be possible to implement. But I don't see a scenario
> when it might be useful.
>
>> 3. can two different processes have their CR3 being the same value
>> even though they have different first level page tables ?
>
> Yes, if they are created by clone(CLONE_VM). In such case they share the
> same mm_struct, and therefore mm_struct->pgd (which is exactly what is
> loaded into cr3 in switch_mm()) is the same.
>

Is this the COW mechanism in linux. what if the cloned process need to
have set of its own pages later. do the CR3s for the 2 processes
become different at that point ?

> LKML is however very inappropriate list for such questions. Please ask on
> kernelnewbies list next time.
>

Thank you for letting me know. Will do next time.
> --
> Jiri Kosina
> SUSE Labs
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] [RFC]power: battery: Generic battery driver using IIO

2012-09-02 Thread Sannu K
On Sun, Sep 2, 2012 at 9:09 PM, anish kumar  wrote:
> From: anish kumar 
>
> This patch is to use IIO to write a generic batttery driver.
> There are some inherent assumptions here:
> 1.User is having both main battery and backup battery.
> 2.Both batteries use same channel to get the information.
>
> Signed-off-by: anish kumar 
> ---
>  drivers/power/Kconfig |8 +
>  drivers/power/Makefile|1 +
>  drivers/power/generic-battery.c   |  374 
> +
>  include/linux/power/generic-battery.h |   26 +++
>  4 files changed, 409 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/power/generic-battery.c
>  create mode 100644 include/linux/power/generic-battery.h
>
> diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
> index fcc1bb0..546e86b 100644
> --- a/drivers/power/Kconfig
> +++ b/drivers/power/Kconfig
> @@ -309,6 +309,14 @@ config AB8500_BATTERY_THERM_ON_BATCTRL
> help
>   Say Y to enable battery temperature measurements using
>   thermistor connected on BATCTRL ADC.
> +
> +config GENERIC_BATTERY
> +   tristate "Generic battery support using IIO"
> +   depends on IIO
> +   help
> + Say Y here to enable support for the generic battery driver
> + which uses IIO framework to read adc for it's main and backup
> + battery.
>  endif # POWER_SUPPLY
>
>  source "drivers/power/avs/Kconfig"
> diff --git a/drivers/power/Makefile b/drivers/power/Makefile
> index ee58afb..8284f9c 100644
> --- a/drivers/power/Makefile
> +++ b/drivers/power/Makefile
> @@ -45,3 +45,4 @@ obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o
>  obj-$(CONFIG_CHARGER_MAX8998)  += max8998_charger.o
>  obj-$(CONFIG_POWER_AVS)+= avs/
>  obj-$(CONFIG_CHARGER_SMB347)   += smb347-charger.o
> +obj-$(CONFIG_GENERIC_BATTERY)  += generic-battery.o
> diff --git a/drivers/power/generic-battery.c b/drivers/power/generic-battery.c
> new file mode 100644
> index 000..33170b7
> --- /dev/null
> +++ b/drivers/power/generic-battery.c
> @@ -0,0 +1,374 @@
> +/*
> + * Generice battery driver code using IIO
> + * Copyright (C) 2012, Anish Kumar 
> + * based on jz4740-battery.c
> + * based on s3c_adc_battery.c
> + *
> + * This file is subject to the terms and conditions of the GNU General Public
> + * License.  See the file COPYING in the main directory of this archive for
> + * more details.
> + *
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#define BAT_POLL_INTERVAL  1 /* ms */
> +#define JITTER_DELAY   500 /* ms */
> +
> +enum BAT {
> +   MAIN_BAT = 0,
> +   BACKUP_BAT,
> +   BAT_MAX,
> +};
> +
> +struct generic_adc_bat {
> +   struct power_supply psy;
> +   struct iio_channel  *channels;
> +   int channel_index;
> +};
> +
> +struct generic_bat {
> +   struct generic_adc_bat bat[BAT_MAX];
> +   struct generic_platform_datapdata;
> +   int volt_value;
> +   int cur_value;
> +   unsigned inttimestamp;
> +   int level;
> +   int status;
> +   int cable_plugged:1;
> +};
> +
> +static struct generic_bat generic_bat = {
> +   .bat[MAIN_BAT] = {
> +   .psy.name = "main-bat",
> +   },
> +   .bat[BACKUP_BAT] = {
> +   .psy.name = "backup-bat",
> +   },
> +};
> +
> +static struct delayed_work bat_work;
> +
> +static void generic_adc_bat_ext_power_changed(struct power_supply *psy)
> +{
> +   schedule_delayed_work(&bat_work,
> +   msecs_to_jiffies(JITTER_DELAY));
> +}
> +
> +static enum power_supply_property generic_adc_main_bat_props[] = {
> +   POWER_SUPPLY_PROP_STATUS,
> +   POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
> +   POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN,
> +   POWER_SUPPLY_PROP_CHARGE_NOW,
> +   POWER_SUPPLY_PROP_VOLTAGE_NOW,
> +   POWER_SUPPLY_PROP_CURRENT_NOW,
> +   POWER_SUPPLY_PROP_TECHNOLOGY,
> +   POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
> +   POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
> +   POWER_SUPPLY_PROP_MODEL_NAME,
> +};
> +
> +static int charge_finished(struct generic_bat *bat)
> +{
> +   return bat->pdata.gpio_inverted ?
> +   !gpio_get_value(bat->pdata.gpio_charge_finished) :
> +   gpio_get_value(bat->pdata.gpio_charge_finished);
> +}
> +
> +static int generic_adc_bat_get_property(struct power_supply *psy,
> +   enum power_supply_property psp,
> +   union power_supply_propval *val)
> +{
> +   struct generic_adc_bat *adc_bat;
> +   struct generic_bat *bat;
> +   int ret, scaleint, scalep

Re: [PATCH]Documentation: Chinese translation of Documentation/video4linux/v4l2-framework.txt

2012-09-02 Thread harryxiyou
On Sun, Sep 2, 2012 at 8:53 PM, Rafaman  wrote:
> At 2012-09-02 00:51:51,"Ninja Tekkaman"  wrote:
>>This is a Chinese translated version of
>>Documentation/video4linux/v4l2-framework.txt
>>
>>Signed-off-by: Fu Wei 
>

Acked-by: Harry Wei 


-- 
Thanks
Harry Wei
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC 1/1] kvm: Use vcpu_id as pivot instead of last boosted vcpu in PLE handler

2012-09-02 Thread Rik van Riel

On 09/02/2012 06:12 AM, Gleb Natapov wrote:

On Thu, Aug 30, 2012 at 12:51:01AM +0530, Raghavendra K T wrote:

  The idea of starting from next vcpu (source of yield_to + 1) seem to work
  well for overcomitted guest rather than using last boosted vcpu. We can also
  remove per VM variable with this approach.

  Iteration for eligible candidate after this patch starts from vcpu source+1
  and ends at source-1 (after wrapping)

  Thanks Nikunj for his quick verification of the patch.

  Please let me know if this patch is interesting and makes sense.


This last_boosted_vcpu thing caused us trouble during attempt to
implement vcpu destruction. It is good to see it removed from this POV.


I like this implementation.  It should achieve pretty much
the same as my old code, but without the downsides and without
having to keep the same amount of global state.

--
All rights reversed
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] tpm: fix tpm_acpi sparse warning on different address spaces

2012-09-02 Thread Dan Carpenter
On Thu, Aug 30, 2012 at 02:21:55PM -0500, Kent Yoder wrote:
> On Thu, Aug 30, 2012 at 10:45:56AM -0700, Dan Carpenter wrote:
> > On Thu, Aug 30, 2012 at 09:38:41AM -0500, Kent Yoder wrote:
> > > acpi_os_map_memory expects its return value to be in the __iomem address
> > > space. Cast it back later when used in a memcpy to avoid the same sparse
> > > warning there.
> > > 
> > > Signed-off-by: Kent Yoder 
> > 
> > I can't download linux-next right now but I don't think this is the
> > correct fix.  I don't think you can memcpy() directly from __iomem.
> > The static checker is warning about a valid bug which should be
> > addressed instead of just casted away and silenced.
> 
>   I took a look at other uses of the return from acpi_os_map_memory(),
> such as acpi_tb_parse_fadt(), which passes the returned pointer to
> acpi_tb_create_local_fadt(), which uses ACPI_MEMCPY on it, which is just
> memcpy.  This code lives in drivers/acpi.
> 

Sparse finds that bug as well.  ;)

drivers/acpi/acpica/tbfadt.c:247:15: warning: incorrect type in assignment 
(different address spaces)
drivers/acpi/acpica/tbfadt.c:247:15:expected struct acpi_table_header *table
drivers/acpi/acpica/tbfadt.c:247:15:got void [noderef] *
drivers/acpi/acpica/tbfadt.c:266:30: warning: incorrect type in argument 1 
(different address spaces)
drivers/acpi/acpica/tbfadt.c:266:30:expected void [noderef] 
*logical_address
drivers/acpi/acpica/tbfadt.c:266:30:got struct acpi_table_header *table

It should be memcpy_fromio() probably.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: input0: bad kobj_uevent_env content in show_uevent()

2012-09-02 Thread Fengguang Wu
On Sun, Sep 02, 2012 at 03:41:34PM +0200, Bjørn Mork wrote:
> Fengguang Wu  writes:
> 
> > After the __devinit* removal series, I can still get kernel panic in
> > show_uevent(). So there are more sources of bug..
> >
> > Debug patch:
> >
> > @@ -343,8 +343,11 @@ static ssize_t show_uevent(struct device
> > goto out;
> >
> > /* copy keys to file */
> > -   for (i = 0; i < env->envp_idx; i++)
> > +   dev_err(dev, "uevent %d env[%d]: %s/.../%s\n", env->buflen, 
> > env->envp_idx, top_kobj->name, dev->kobj.name);
> > +   for (i = 0; i < env->envp_idx; i++) {
> > +   printk(KERN_ERR "uevent %d env[%d]: %s\n", (int)count, i, 
> > env->envp[i]);
> > count += sprintf(&buf[count], "%s\n", env->envp[i]);
> > +   }
> >
> > Oops message, the env[] is again not properly initilized:
> >
> > [   44.068623] input input0: uevent 61 env[805306368]: input0/.../input0
> > [   44.069552] uevent 0 env[0]: (null)
> 
> This is a completely different CONFIG_HOTPLUG problem, only
> demonstrating another reason why CONFIG_HOTPLUG should go away.  I had a
> hard time trying to disable it anyway ;-)
> 
> The problem this time is lots of code assuming that a call to
> add_uevent_var() will guarantee that env->buflen > 0.  This is not true
> if CONFIG_HOTPLUG is unset.  So things like this end up overwriting
> env->envp_idx because the array index is -1:
> 
>   if (add_uevent_var(env, "MODALIAS="))
>   return -ENOMEM;
> len = input_print_modalias(&env->buf[env->buflen - 1],
>  sizeof(env->buf) - env->buflen,
>  dev, 0);
> 
> 
> Don't know what the best action is, given that there seem to be a *lot*
> of this around the kernel.  This patch "fixes" the problem for me, but I

It also works reliably for me: 300 boots without a single failure.

Tested-by: Fengguang Wu  

Thanks!
Fengguang
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] staging: bcm: fix error handling in bcm_init()

2012-09-02 Thread Kevin McKinney
On Sun, Sep 02, 2012 at 01:37:36AM +0400, Alexey Khoroshilov wrote:
> bcm_init() does not have proper error handling of usb_register().
> The patch implements one.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov 
> ---
>  drivers/staging/bcm/InterfaceInit.c |   12 +++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/bcm/InterfaceInit.c 
> b/drivers/staging/bcm/InterfaceInit.c
> index 8f85de6..0049890 100644
> --- a/drivers/staging/bcm/InterfaceInit.c
> +++ b/drivers/staging/bcm/InterfaceInit.c
> @@ -669,6 +669,8 @@ struct class *bcm_class;
>  
>  static __init int bcm_init(void)
>  {
> + int retval;
> +
>   printk(KERN_INFO "%s: %s, %s\n", DRV_NAME, DRV_DESCRIPTION, 
> DRV_VERSION);
>   printk(KERN_INFO "%s\n", DRV_COPYRIGHT);
>  
> @@ -678,7 +680,15 @@ static __init int bcm_init(void)
>   return PTR_ERR(bcm_class);
>   }
>  
> - return usb_register(&usbbcm_driver);
> + retval = usb_register(&usbbcm_driver);
> + if (retval < 0) {
> + printk(KERN_ERR DRV_NAME ": could not register usb driver\n");
> + goto out_class;
> + }
> + return 0;
> +out_class:
> + class_destroy(bcm_class);
> + return retval;
>  }
>  
Hi Alexey,

Instead of using a goto statement, can we just: (1) destory the class and (2) 
return retval within the if statement? i.e:

if (retval < 0) {
printk(KERN_ERR DRV_NAME ": could not register usb driver\n");
+class_destroy(bcm_class);
+return retval;
}

goto statements are very useful and handy when a function exits from multiple 
locations because they provide a 
common exit point. The compiler will translate this into a "jump" instruction. 
However in this case I am not sure
it is simplifying our logic because we only have one usage. lets just call the 
two lines of code directly within the
if statement.

In addition, while you are in this code can you replace the "printk" statements 
with the preferred "pr_info" in a separate patch?  

Thanks,
Kevin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH] Kconfig: Make EARLY_PRINTK "depends on" PRINTK

2012-09-02 Thread Joe Perches
While breaking up what I think is the overly large printk.c,
this non-dependency between CONFIG_PRINTK and CONFIG_EARLY_PRINTK
showed up.

Perhaps CONFIG_EARLY_PRINTK should be marked "depends on" PRINTK.

Uncompiled, untested.

---

 arch/alpha/Kconfig.debug  |2 +-
 arch/arm/Kconfig.debug|2 +-
 arch/blackfin/Kconfig.debug   |1 +
 arch/hexagon/Kconfig  |1 +
 arch/m68k/Kconfig.debug   |2 +-
 arch/microblaze/Kconfig.debug |2 +-
 arch/mips/Kconfig.debug   |2 +-
 arch/powerpc/Kconfig  |1 +
 arch/tile/Kconfig.debug   |1 +
 arch/um/Kconfig.debug |1 +
 arch/unicore32/Kconfig.debug  |1 +
 arch/x86/Kconfig.debug|1 +
 12 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/arch/alpha/Kconfig.debug b/arch/alpha/Kconfig.debug
index 3f6265f..7f051ec 100644
--- a/arch/alpha/Kconfig.debug
+++ b/arch/alpha/Kconfig.debug
@@ -4,7 +4,7 @@ source "lib/Kconfig.debug"
 
 config EARLY_PRINTK
bool
-   depends on ALPHA_GENERIC || ALPHA_SRM
+   depends on (ALPHA_GENERIC || ALPHA_SRM) && PRINTK
default y
 
 config ALPHA_LEGACY_START_ADDRESS
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index f15f82b..ce6d532 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -375,7 +375,7 @@ endchoice
 
 config EARLY_PRINTK
bool "Early printk"
-   depends on DEBUG_LL
+   depends on DEBUG_LL && PRINTK
help
  Say Y here if you want to have an early console using the
  kernel low-level debugging functions. Add earlyprintk to your
diff --git a/arch/blackfin/Kconfig.debug b/arch/blackfin/Kconfig.debug
index 7959469..292bb2b 100644
--- a/arch/blackfin/Kconfig.debug
+++ b/arch/blackfin/Kconfig.debug
@@ -202,6 +202,7 @@ config DEBUG_BFIN_NO_KERN_HWTRACE
 
 config EARLY_PRINTK
bool "Early printk" 
+   depends on PRINTK
default n
select SERIAL_CORE_CONSOLE
help
diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
index b2fdfb7..30b84c9 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -57,6 +57,7 @@ config PCI
 
 config EARLY_PRINTK
def_bool y
+   depends on PRINTK
 
 config MMU
def_bool y
diff --git a/arch/m68k/Kconfig.debug b/arch/m68k/Kconfig.debug
index 87233ac..cb47cbb 100644
--- a/arch/m68k/Kconfig.debug
+++ b/arch/m68k/Kconfig.debug
@@ -12,7 +12,7 @@ config BOOTPARAM_STRING
 
 config EARLY_PRINTK
bool "Early printk" if EMBEDDED
-   depends on MVME16x || MAC
+   depends on (MVME16x || MAC) && PRINTK
default y
help
   Write kernel log output directly to a serial port.
diff --git a/arch/microblaze/Kconfig.debug b/arch/microblaze/Kconfig.debug
index 012e377..2f60150 100644
--- a/arch/microblaze/Kconfig.debug
+++ b/arch/microblaze/Kconfig.debug
@@ -10,7 +10,7 @@ source "lib/Kconfig.debug"
 
 config EARLY_PRINTK
bool "Early printk function for kernel"
-   depends on SERIAL_UARTLITE_CONSOLE || SERIAL_8250_CONSOLE
+   depends on (SERIAL_UARTLITE_CONSOLE || SERIAL_8250_CONSOLE) && PRINTK
default n
help
  This option turns on/off early printk messages to console.
diff --git a/arch/mips/Kconfig.debug b/arch/mips/Kconfig.debug
index 5a43aa0..f9338da 100644
--- a/arch/mips/Kconfig.debug
+++ b/arch/mips/Kconfig.debug
@@ -8,7 +8,7 @@ source "lib/Kconfig.debug"
 
 config EARLY_PRINTK
bool "Early printk" if EXPERT
-   depends on SYS_HAS_EARLY_PRINTK
+   depends on SYS_HAS_EARLY_PRINTK && PRINTK
default y
help
  This option enables special console drivers which allow the kernel
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 352f416..6ba5995 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -142,6 +142,7 @@ config PPC
 
 config EARLY_PRINTK
bool
+   depends on PRINTK
default y
 
 config COMPAT
diff --git a/arch/tile/Kconfig.debug b/arch/tile/Kconfig.debug
index ddbfc33..be306cc 100644
--- a/arch/tile/Kconfig.debug
+++ b/arch/tile/Kconfig.debug
@@ -4,6 +4,7 @@ source "lib/Kconfig.debug"
 
 config EARLY_PRINTK
bool "Early printk" if EXPERT && DEBUG_KERNEL
+   depends on PRINTK
default y
help
  Write kernel log output directly via the hypervisor console.
diff --git a/arch/um/Kconfig.debug b/arch/um/Kconfig.debug
index 68205fd..d3f7567 100644
--- a/arch/um/Kconfig.debug
+++ b/arch/um/Kconfig.debug
@@ -30,6 +30,7 @@ config GCOV
 
 config EARLY_PRINTK
bool "Early printk"
+   depends on PRINTK
default y
---help---
  Write kernel log output directly to stdout.
diff --git a/arch/unicore32/Kconfig.debug b/arch/unicore32/Kconfig.debug
index 1a36262..98f644c 100644
--- a/arch/unicore32/Kconfig.debug
+++ b/arch/unicore32/Kconfig.debug
@@ -18,6 +18,7 @@ config STRICT_DEVMEM
 
 config EARLY_PRINTK
def_bool DEBUG_OCD
+   depends on PRINTK
help

[PATCH] net/can: rename peak_usb dump_mem function

2012-09-02 Thread Randy Dunlap
From: Randy Dunlap 

Rename generic-sounding function dump_mem() to pcan_dump_mem()
so that it does not conflict with the dump_mem() function in
arch/sh/include/asm/kdebug.h.

drivers/net/can/usb/peak_usb/pcan_usb_core.c: error: conflicting types for 
'dump_mem':  => 56:6
drivers/net/can/usb/peak_usb/pcan_usb_core.h: error: conflicting types for 
'dump_mem':  => 134:6

Not tested.

Signed-off-by: Randy Dunlap 
Reported-by: Geert Uytterhoeven 
Cc: Stephane Grosjean 
Cc: Wolfgang Grandegger 
Cc: Marc Kleine-Budde 
---
 drivers/net/can/usb/peak_usb/pcan_usb_core.c |2 +-
 drivers/net/can/usb/peak_usb/pcan_usb_core.h |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

--- lnx-36-rc4.orig/drivers/net/can/usb/peak_usb/pcan_usb_core.c
+++ lnx-36-rc4/drivers/net/can/usb/peak_usb/pcan_usb_core.c
@@ -53,7 +53,7 @@ static struct peak_usb_adapter *peak_usb
  * dump memory
  */
 #define DUMP_WIDTH 16
-void dump_mem(char *prompt, void *p, int l)
+void pcan_dump_mem(char *prompt, void *p, int l)
 {
pr_info("%s dumping %s (%d bytes):\n",
PCAN_USB_DRIVER_NAME, prompt ? prompt : "memory", l);
--- lnx-36-rc4.orig/drivers/net/can/usb/peak_usb/pcan_usb_core.h
+++ lnx-36-rc4/drivers/net/can/usb/peak_usb/pcan_usb_core.h
@@ -131,7 +131,7 @@ struct peak_usb_device {
struct peak_usb_device *next_siblings;
 };
 
-void dump_mem(char *prompt, void *p, int l);
+void pcan_dump_mem(char *prompt, void *p, int l);
 
 /* common timestamp management */
 void peak_usb_init_time_ref(struct peak_time_ref *time_ref,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: linux page table

2012-09-02 Thread Jiri Kosina
On Sun, 2 Sep 2012, Xin Tong wrote:

> >> 3. can two different processes have their CR3 being the same value
> >> even though they have different first level page tables ?
> >
> > Yes, if they are created by clone(CLONE_VM). In such case they share the
> > same mm_struct, and therefore mm_struct->pgd (which is exactly what is
> > loaded into cr3 in switch_mm()) is the same.
> >
> 
> Is this the COW mechanism in linux. what if the cloned process need to
> have set of its own pages later. do the CR3s for the 2 processes
> become different at that point ?

That is a different story. COW is applied on fork() (i.e. spawning new 
process), not on clone(CLONE_VM) (i.e. spawning new thread).

-- 
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 1/3] dw_dmac: make driver endianness configurable

2012-09-02 Thread Hein Tibosch
From: Hein Tibosch 

v4: now based and tested on 3.6-rc4

The dw_dmac was originally developed for avr32 to be used with the Synopsys
DesignWare AHB DMA controller. After 2.6.38, access to the device's i/o
memory was done with the little-endian readl/writel functions
(https://patchwork.kernel.org/patch/608211)

This didn't work on the avr32 platform, because it needs native-endian
(i.e. big-endian) accessors.
This patch makes the endianness configurable using 'DW_DMAC_BIG_ENDIAN_IO',
which will default be true for AVR32

Signed-off-by: Hein Tibosch 
Acked-by: Viresh Kumar 
Acked-by: Arnd Bergmann 
Reviewed-by: Hans-Christian Egtvedt 

---
 drivers/dma/Kconfig|   11 +++
 drivers/dma/dw_dmac_regs.h |   14 ++
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index d06ea29..5a26d46 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -90,6 +90,17 @@ config DW_DMAC
  Support the Synopsys DesignWare AHB DMA controller.  This
  can be integrated in chips such as the Atmel AT32ap7000.
 
+config DW_DMAC_BIG_ENDIAN_IO
+   bool "Use big endian I/O register access"
+   default y if AVR32
+   depends on DW_DMAC
+   help
+ Say yes here to use big endian I/O access when reading and writing
+ to the DMA controller registers. This is needed on some platforms,
+ like the Atmel AVR32 architecture.
+
+ If unsure, use the default setting.
+
 config AT_HDMAC
tristate "Atmel AHB DMA support"
depends on ARCH_AT91
diff --git a/drivers/dma/dw_dmac_regs.h b/drivers/dma/dw_dmac_regs.h
index 50830be..8aad868 100644
--- a/drivers/dma/dw_dmac_regs.h
+++ b/drivers/dma/dw_dmac_regs.h
@@ -175,10 +175,17 @@ __dwc_regs(struct dw_dma_chan *dwc)
return dwc->ch_regs;
 }
 
+#ifdef CONFIG_DW_DMAC_BIG_ENDIAN_IO
+#define channel_readl(dwc, name) \
+   ioread32be(&(__dwc_regs(dwc)->name))
+#define channel_writel(dwc, name, val) \
+   iowrite32be((val), &(__dwc_regs(dwc)->name))
+#else
 #define channel_readl(dwc, name) \
readl(&(__dwc_regs(dwc)->name))
 #define channel_writel(dwc, name, val) \
writel((val), &(__dwc_regs(dwc)->name))
+#endif
 
 static inline struct dw_dma_chan *to_dw_dma_chan(struct dma_chan *chan)
 {
@@ -201,10 +208,17 @@ static inline struct dw_dma_regs __iomem 
*__dw_regs(struct dw_dma *dw)
return dw->regs;
 }
 
+#ifdef CONFIG_DW_DMAC_BIG_ENDIAN_IO
+#define dma_readl(dwc, name) \
+   ioread32be(&(__dw_regs(dw)->name))
+#define dma_writel(dwc, name, val) \
+   iowrite32be((val), &(__dw_regs(dw)->name))
+#else
 #define dma_readl(dw, name) \
readl(&(__dw_regs(dw)->name))
 #define dma_writel(dw, name, val) \
writel((val), &(__dw_regs(dw)->name))
+#endif
 
 #define channel_set_bit(dw, reg, mask) \
dma_writel(dw, reg, ((mask) << 8) | (mask))
-- 
1.7.8.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 3/3] avr32: at32ap700x: set DMA slave properties for MCI dw_dmac

2012-09-02 Thread Hein Tibosch
From: Hein Tibosch 

v4: now based and tested on 3.6-rc4

The MCI makes use of the dw_dmac driver when DMA is being used.
Due to recent changes to dw_dmac the MCI+DMA driver was broken because:
- a patch in dw_dmac allowed for 64-bit transfers on the memory side, giving
an illegal value of 3 in the SRC/DST_TR_WIDTH register
(http://lkml.org/lkml/2012/1/18/52)
- the SMS field in the CTLL register received the wrong value 0

This patch sets the SMS (Source Master Select) to 1 and limits
the maximum transfer width to 32 bits.

Note: this can only be applied after the previous:
[PATCH v3 2/3] dw_dmac: max_mem_width limits value for SRC/DST_TR_WID register

Signed-off-by: Hein Tibosch 
Acked-by: Hans-Christian Egtvedt 
---
 arch/avr32/mach-at32ap/at32ap700x.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/avr32/mach-at32ap/at32ap700x.c 
b/arch/avr32/mach-at32ap/at32ap700x.c
index 0445c4f..33c56e7 100644
--- a/arch/avr32/mach-at32ap/at32ap700x.c
+++ b/arch/avr32/mach-at32ap/at32ap700x.c
@@ -1355,6 +1355,10 @@ at32_add_device_mci(unsigned int id, struct 
mci_platform_data *data)
| DWC_CFGH_DST_PER(1));
slave->sdata.cfg_lo &= ~(DWC_CFGL_HS_DST_POL
| DWC_CFGL_HS_SRC_POL);
+   /* Setup DMA controller: let source be master */
+   slave->sdata.src_master = 1;
+   /* Limit maximum transfer width to 32-bit */
+   slave->sdata.max_mem_width = DW_MEM_WIDTH_32;

data->dma_slave = slave;

-- 
1.7.8.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 0/3] dw_dmac: repair driver for use with AVR32 (AP7000)

2012-09-02 Thread Hein Tibosch
v3 was based and tested on 3.5.2. the patches didn't apply
to the latest kernel because dw_dmac.c has had some changes since then.
Now it is based and tested on linux-3.6-rc4


From: Hein Tibosch 

v4: now based and tested on 3.6-rc4

After some recent changes to dw_dmac, the driver got broken for the
AVR32 platform for several reasons:

The accessors to i/o memory had become little-endian.
The maximum transfer width on the memory side was increased from 32 to 64 bits.
This led to undefined behavior on the avr32 platform.

These patches will repair the driver so it can be used again on avr32. For
other users of dw_dmac (ARM platform), nothing will change and no code has
to be adapted.

The small patch for Atmel (at32ap700x.c) is included here because of its
dependency on the second dw_dmac patch.

Thanks to all for reviewing, both people from Atmel and Linaro

Hein Tibosch (3):
  dw_dmac: make driver endianness configurable
  dw_dmac: max_mem_width limits value for SRC/DST_TR_WID register
  avr32: at32ap700x: set DMA slave properties for MCI dw_dmac

 arch/avr32/mach-at32ap/at32ap700x.c |4 
 drivers/dma/Kconfig |   11 +++
 drivers/dma/dw_dmac.c   |   13 +++--
 drivers/dma/dw_dmac_regs.h  |   14 ++
 include/linux/dw_dmac.h |3 +++
 5 files changed, 39 insertions(+), 6 deletions(-)

-- 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 2/3] dw_dmac: max_mem_width limits value for SRC/DST_TR_WID register

2012-09-02 Thread Hein Tibosch
From: Hein Tibosch 

v4: now based and tested on 3.6-rc4

The dw_dmac driver was earlier adapted to do 64-bit transfers on the memory
side (see https://lkml.org/lkml/2012/1/18/52)
This works on ARM platforms but for AVR32 (AP700x) the maximum allowed transfer
size is 32-bits.
This patch allows the arch code to set a new slave property max_mem_width to
limit the size.

Allowable values are:

#define DW_MEM_WIDTH_64 0   /* default */
#define DW_MEM_WIDTH_32 1   /* e.g. for avr32 */

Signed-off-by: Hein Tibosch 
Acked-by: Viresh Kumar 
---
 drivers/dma/dw_dmac.c   |   13 +++--
 include/linux/dw_dmac.h |3 +++
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index d3c5a5a..311953c 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -190,14 +190,14 @@ static void dwc_initialize(struct dw_dma_chan *dwc)
 }
 
 /*--*/
-
-static inline unsigned int dwc_fast_fls(unsigned long long v)
+static inline unsigned int dwc_fast_fls(unsigned long long v,
+   struct dw_dma_slave *dws)
 {
/*
 * We can be a lot more clever here, but this should take care
 * of the most common optimization.
 */
-   if (!(v & 7))
+   if (dws->max_mem_width == DW_MEM_WIDTH_64 && !(v & 7))
return 3;
else if (!(v & 3))
return 2;
@@ -636,6 +636,7 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, 
dma_addr_t src,
size_t len, unsigned long flags)
 {
struct dw_dma_chan  *dwc = to_dw_dma_chan(chan);
+   struct dw_dma_slave *dws = chan->private;
struct dw_desc  *desc;
struct dw_desc  *first;
struct dw_desc  *prev;
@@ -655,7 +656,7 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, 
dma_addr_t src,
return NULL;
}
 
-   src_width = dst_width = dwc_fast_fls(src | dest | len);
+   src_width = dst_width = dwc_fast_fls(src | dest | len, dws);
 
ctllo = DWC_DEFAULT_CTLLO(chan)
| DWC_CTLL_DST_WIDTH(dst_width)
@@ -755,7 +756,7 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist 
*sgl,
mem = sg_dma_address(sg);
len = sg_dma_len(sg);
 
-   mem_width = dwc_fast_fls(mem | len);
+   mem_width = dwc_fast_fls(mem | len, dws);
 
 slave_sg_todev_fill_desc:
desc = dwc_desc_get(dwc);
@@ -815,7 +816,7 @@ slave_sg_todev_fill_desc:
mem = sg_dma_address(sg);
len = sg_dma_len(sg);
 
-   mem_width = dwc_fast_fls(mem | len);
+   mem_width = dwc_fast_fls(mem | len, dws);
 
 slave_sg_fromdev_fill_desc:
desc = dwc_desc_get(dwc);
diff --git a/include/linux/dw_dmac.h b/include/linux/dw_dmac.h
index 2412e02..330afb2 100644
--- a/include/linux/dw_dmac.h
+++ b/include/linux/dw_dmac.h
@@ -58,6 +58,9 @@ struct dw_dma_slave {
u32 cfg_lo;
u8  src_master;
u8  dst_master;
+#defineDW_MEM_WIDTH_64 0
+#defineDW_MEM_WIDTH_32 1   /* e.g. for avr32 */
+   u8  max_mem_width;
 };
 
 /* Platform-configurable bits in CFG_HI */
-- 
1.7.8.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] pwm: Move AB8500 PWM driver to PWM framework

2012-09-02 Thread Arnd Bergmann
On Sunday 02 September 2012, Thierry Reding wrote:
> This commit moves the driver to drivers/pwm and converts it to the new
> PWM framework.
> 
> Signed-off-by: Thierry Reding 
> ---
> Note: I'll take this through the PWM tree, but I'd like to have it
> acknowledged by a few people who know the hardware and can actually
> test whether this still works.

Did you create the patch using 'git format-patch -M'? It should
show the changes as a move plus changes rather than a file remove
and another file add.

The change to the common framework is of course very welcome,

Acked-by: Arnd Bergmann 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] pwm: Move AB8500 PWM driver to PWM framework

2012-09-02 Thread Thierry Reding
On Sun, Sep 02, 2012 at 06:55:11PM +, Arnd Bergmann wrote:
> On Sunday 02 September 2012, Thierry Reding wrote:
> > This commit moves the driver to drivers/pwm and converts it to the new
> > PWM framework.
> > 
> > Signed-off-by: Thierry Reding 
> > ---
> > Note: I'll take this through the PWM tree, but I'd like to have it
> > acknowledged by a few people who know the hardware and can actually
> > test whether this still works.
> 
> Did you create the patch using 'git format-patch -M'? It should
> show the changes as a move plus changes rather than a file remove
> and another file add.

Yeah, I forgot that... again. Sorry for that.

> The change to the common framework is of course very welcome,
> 
> Acked-by: Arnd Bergmann 

Thierry


pgpusuWiEUYDo.pgp
Description: PGP signature


Re: [PATCH 1/3] MIPS: JZ4740: Break circular header dependency

2012-09-02 Thread Thierry Reding
On Sun, Sep 02, 2012 at 04:48:46PM +0200, Lars-Peter Clausen wrote:
> On 09/02/2012 11:52 AM, Thierry Reding wrote:
> > When including irq.h, arch/mips/jz4740/irq.h will be selected as the
> > first candidate. This header does not include the proper definitions
> > (most notably NR_IRQS) required by subsequent headers. To solve this
> > arch/mips/jz4740/irq.h can be deleted and its contents can be moved
> > into arch/mips/include/asm/mach-jz4740/irq.h, which will then be
> > correctly included.
> > 
> 
> Where exactly did you have this problem? arch/mips/jz4740/ should not be in 
> the
> include path, so "#include " should not cause arch/mips/jz4740/irq.h to
> be included.

While compile-testing I did make ARCH=mips menuconfig and selected
JZ4740 plus the new PWM driver option, then ran make ARCH=mips. That
showed errors like struct irq_data not being declared or NR_IRQS not
being defined. Maybe I was just using a very strange configuration.

I tested this with 3.6-rc3 and linux-next, both had this problem.
Neither of them had a default configuration for JZ4740, so maybe I'm
just missing a configuration option.

Thierry


pgpFOqMJAK96p.pgp
Description: PGP signature


Re: [PATCH 0/3] MIPS: JZ4740: Move PWM driver to PWM framework

2012-09-02 Thread Thierry Reding
On Sun, Sep 02, 2012 at 03:25:55PM +0200, Maarten ter Huurne wrote:
> On Sunday 02 September 2012 11:52:27 Thierry Reding wrote:
> 
> > This small series fixes a build error due to a circular header
> > dependency, exports the timer API so it can be used outside of
> > the arch/mips/jz4740 tree and finally moves and converts the
> > JZ4740 PWM driver to the PWM framework.
> > 
> > Note that I don't have any hardware to test this on, so I had to
> > rely on compile tests only. Patches 1 and 2 should probably go
> > through the MIPS tree, while I can take patch 3 through the PWM
> > tree. It touches a couple of files in arch/mips but the changes
> > are unlikely to cause conflicts.
> 
> Exporting the hardware outputs PWM2-7 as index 0-5 in the PWM core is rather 
> confusing. I discussed with Lars on IRC and it's probably better to expose 
> PWM0-7 through the API, but refuse to hand out PWM0 and PWM1 when requested, 
> since their associated timers are in use by the system. I attached a diff 
> that illustrates this approach.
> 
> Note that if this approach is taken, the beeper ID in board-qi_lb60.c should 
> be changed back from 2 to 4, since the beeper is attached to PWM4.
> 
> I tested the "for-next" branch on the Dingoo A320 with the pwm-backlight 
> driver. It didn't work at first, because the PWM number and the timer number 
> didn't align: I requested PWM number 5 to get PWM7 and the GPIO of PWM7 was 
> used, but with timer 5 instead of timer 7, resulting in a dark screen. 
> However, it works fine after adding PWM0/1 as described above.

I haven't seen any usage of the pwm-backlight driver in mainline. I
assume this is only present in some downstream repository?

> If other people want to test on real hardware, you can find the code in 
> branch jz-3.6-rc2-pwm in the qi-kernel repository. Unfortunately our web 
> interface for git is still broken, but the repo itself is fine.
>   git://projects.qi-hardware.com/qi-kernel.git
> 
> Bye,
>   Maarten

> diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
> index db29b37..554e414 100644
> --- a/drivers/pwm/pwm-jz4740.c
> +++ b/drivers/pwm/pwm-jz4740.c
> @@ -24,9 +24,11 @@
>  #include 
>  #include 
>  
> -#define NUM_PWM 6
> +#define NUM_PWM 8
>  
>  static const unsigned int jz4740_pwm_gpio_list[NUM_PWM] = {
> + JZ_GPIO_PWM0,
> + JZ_GPIO_PWM1,
>   JZ_GPIO_PWM2,
>   JZ_GPIO_PWM3,
>   JZ_GPIO_PWM4,
> @@ -50,6 +52,13 @@ static int jz4740_pwm_request(struct pwm_chip *chip, 
> struct pwm_device *pwm)
>   unsigned int gpio = jz4740_pwm_gpio_list[pwm->hwpwm];
>   int ret;
>  
> + /*
> +  * Timer 0 and 1 are used for system tasks, so they are unavailable
> +  * for use as PWMs.
> +  */
> + if (pwm->hwpwm < 2)
> + return -EBUSY;
> +
>   ret = gpio_request(gpio, pwm->label);
>  
>   if (ret) {

An alternative approach would be to change pwm_chip.base from -1
(dynamically allocated) to 2, which would leave 0 and 1 unavailable.
That should at least solve the problem that you had regarding the GPIO
and timer mismatch.

But the above also sounds sensible, and since both you and Lars agree
that this is the better option, I can squash these changes into my patch
with your permission.

Thierry


pgpR2niGBRUbu.pgp
Description: PGP signature


[PATCH v2] staging: bcm: fix error handling in bcm_init()

2012-09-02 Thread Alexey Khoroshilov
bcm_init() does not have proper error handling of usb_register().
The patch implements one.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov 
---
 drivers/staging/bcm/InterfaceInit.c |   10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/bcm/InterfaceInit.c 
b/drivers/staging/bcm/InterfaceInit.c
index 8f85de6..57452ef 100644
--- a/drivers/staging/bcm/InterfaceInit.c
+++ b/drivers/staging/bcm/InterfaceInit.c
@@ -669,6 +669,8 @@ struct class *bcm_class;
 
 static __init int bcm_init(void)
 {
+   int retval;
+
printk(KERN_INFO "%s: %s, %s\n", DRV_NAME, DRV_DESCRIPTION, 
DRV_VERSION);
printk(KERN_INFO "%s\n", DRV_COPYRIGHT);
 
@@ -678,7 +680,13 @@ static __init int bcm_init(void)
return PTR_ERR(bcm_class);
}
 
-   return usb_register(&usbbcm_driver);
+   retval = usb_register(&usbbcm_driver);
+   if (retval < 0) {
+   printk(KERN_ERR DRV_NAME ": could not register usb driver\n");
+   class_destroy(bcm_class);
+   return retval;
+   }
+   return 0;
 }
 
 static __exit void bcm_exit(void)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: bcm: use pr_info and pr_err rather than printk

2012-09-02 Thread Alexey Khoroshilov
Convert printk(KERN_INFO to pr_info( and printk(KERN_ERR to pr_err(.

Signed-off-by: Alexey Khoroshilov 
---
 drivers/staging/bcm/InterfaceInit.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/bcm/InterfaceInit.c 
b/drivers/staging/bcm/InterfaceInit.c
index 57452ef..dfee0ce 100644
--- a/drivers/staging/bcm/InterfaceInit.c
+++ b/drivers/staging/bcm/InterfaceInit.c
@@ -671,18 +671,18 @@ static __init int bcm_init(void)
 {
int retval;
 
-   printk(KERN_INFO "%s: %s, %s\n", DRV_NAME, DRV_DESCRIPTION, 
DRV_VERSION);
-   printk(KERN_INFO "%s\n", DRV_COPYRIGHT);
+   pr_info("%s: %s, %s\n", DRV_NAME, DRV_DESCRIPTION, DRV_VERSION);
+   pr_info("%s\n", DRV_COPYRIGHT);
 
bcm_class = class_create(THIS_MODULE, DRV_NAME);
if (IS_ERR(bcm_class)) {
-   printk(KERN_ERR DRV_NAME ": could not create class\n");
+   pr_err(DRV_NAME ": could not create class\n");
return PTR_ERR(bcm_class);
}
 
retval = usb_register(&usbbcm_driver);
if (retval < 0) {
-   printk(KERN_ERR DRV_NAME ": could not register usb driver\n");
+   pr_err(DRV_NAME ": could not register usb driver\n");
class_destroy(bcm_class);
return retval;
}
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 03/13] perf tools: drop asm/byteorder.h wrapper

2012-09-02 Thread Irina Tirdea
> This https://lkml.org/lkml/2012/8/29/150 should fix the netinet/tcp.h build
> problem.
>

Thanks! Removing the header files is a much cleaner solution. I will
remove this patch and use yours.

Irina
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/3] pwm: Add Ingenic JZ4740 support

2012-09-02 Thread Thierry Reding
On Sun, Sep 02, 2012 at 04:44:15PM +0200, Lars-Peter Clausen wrote:
> On 09/02/2012 11:52 AM, Thierry Reding wrote:
> > diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> > index 92b1782..f5acdaa 100644
> > --- a/drivers/pwm/core.c
> > +++ b/drivers/pwm/core.c
> > @@ -371,7 +371,7 @@ EXPORT_SYMBOL_GPL(pwm_free);
> >   */
> >  int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
> >  {
> > -   if (!pwm || period_ns == 0 || duty_ns > period_ns)
> > +   if (!pwm || duty_ns < 0 || period_ns <= 0 || duty_ns > period_ns)
> > return -EINVAL;
> >  
> 
> This change seems to be unrelated.

Yes, that slipped in by mistake. That was supposed to go into a separate
patch so that the .config of each driver doesn't have to repeat these
checks.

> > return pwm->chip->ops->config(pwm->chip, pwm, duty_ns, period_ns);
> > diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
> > new file mode 100644
> > index 000..db29b37
> > --- /dev/null
> > +++ b/drivers/pwm/pwm-jz4740.c
> > @@ -0,0 +1,205 @@
> > +/*
> > + *  Copyright (C) 2010, Lars-Peter Clausen 
> > + *  JZ4740 platform PWM support
> > + *
> > + *  This program is free software; you can redistribute it and/or modify it
> > + *  under  the terms of the GNU General  Public License as published by the
> > + *  Free Software Foundation;  either version 2 of the License, or (at your
> > + *  option) any later version.
> > + *
> > + *  You should have received a copy of the GNU General Public License along
> > + *  with this program; if not, write to the Free Software Foundation, Inc.,
> > + *  675 Mass Ave, Cambridge, MA 02139, USA.
> > + *
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> 
> #include 
> 
> > +
> > +#define NUM_PWM 6
> > +
> > +static const unsigned int jz4740_pwm_gpio_list[NUM_PWM] = {
> 
> As mth said, it would be better to have JZ_GPIO_PWM0 and here as well and set
> NUM_PWM to 8. Right now we are using the timers associated to PWM channel 0 
> and
> 1 as system timers. But there might be devices where this is not possible, 
> e.g.
> because the PWM is actually connected to something. Also this fixes the of by
> two for the hwpwm id.

Okay. I was actually planning on doing some cleanup in a follow-up patch
and try to limit actual changes in this patch to what is required by the
conversion. However if Maarten and you both are okay with it I can make
these additional changes while at it.

> > +   if (ret) {
> > +   printk(KERN_ERR "Failed to request pwm gpio: %d\n", ret);
> 
> dev_err(chip->dev, 

Okay.

> > +   is_enabled = jz4740_timer_is_enabled(pwm->hwpwm);
> > +   if (is_enabled)
> > +   pwm_disable(pwm);
> 
> I think this should be jz4740_pwm_disable
> 
> > +
> > +   jz4740_timer_set_count(pwm->hwpwm, 0);
> > +   jz4740_timer_set_duty(pwm->hwpwm, duty);
> > +   jz4740_timer_set_period(pwm->hwpwm, period);
> > +
> > +   ctrl = JZ_TIMER_CTRL_PRESCALER(prescaler) | JZ_TIMER_CTRL_SRC_EXT |
> > +   JZ_TIMER_CTRL_PWM_ABBRUPT_SHUTDOWN;
> > +
> > +   jz4740_timer_set_ctrl(pwm->hwpwm, ctrl);
> > +
> > +   if (is_enabled)
> > +   pwm_enable(pwm);
> 
> and jz4740_pwm_enable here.

I wonder if this is actually required here. Can the timer really not be
reprogrammed while enabled?

> > +
> > +   return 0;
> > +}
> > +
> 
> > +
> > +static const struct pwm_ops jz4740_pwm_ops = {
> > +   .request = jz4740_pwm_request,
> > +   .free = jz4740_pwm_free,
> > +   .config = jz4740_pwm_config,
> > +   .enable = jz4740_pwm_enable,
> > +   .disable = jz4740_pwm_disable,
> 
> .owner = THIS_MODULE,

Yes, I forgot that one.

> > +};
> > +
> > +static int jz4740_pwm_probe(struct platform_device *pdev)
> __devinit

Yes, I'll add that.

> > +{
> > +   struct jz4740_pwm_chip *jz4740;
> > +   int ret = 0;
> 
> The '= 0' is not really necessary since it will be overwritten anyway.

Right, I'll drop it.

> > +static int jz4740_pwm_remove(struct platform_device *pdev)
> __devexit

Can do.

> > +{
> > +   struct jz4740_pwm_chip *jz4740 = platform_get_drvdata(pdev);
> > +   int ret;
> > +
> > +   ret = pwmchip_remove(&jz4740->chip);
> > +   if (ret < 0)
> > +   return ret;
> 
> remove is not really allowed to fail, the return value is never really tested
> and the device is removed nevertheless. But this seems to be a problem with 
> the
> PWM API. It should be possible to remove a PWM chip even if it is currently in
> use and after a PWM chip has been removed all calls to a pwm_device of that
> chip it should return an error. This will require reference counting for the
> pwm_device struct though. E.g. by adding a 'struct device' to it.

I beg to differ. It shouldn't be possible to remove a PWM chip that
provides requested PWM devices. All other drivers do the same here.

> > +
> > +   clk_put(jz4740->clk);
> > +
> > +   return 0;
> > +}
> > +
> > +static struct platform_driver jz4740_pwm

Re: [PATCH 02/13] perf tools: update types definitions for Android

2012-09-02 Thread Irina Tirdea
> This https://lkml.org/lkml/2012/8/29/150 should fix the netinet/in.h build
> problem.

Thanks! I'll change this patch and resubmit.

Irina
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v6 1/3] spi/pl022: Add chip select handling via GPIO

2012-09-02 Thread Roland Stigge
Hi Shiraz,

On 01/09/12 13:14, shiraz hashim wrote:
> On Wed, Aug 22, 2012 at 7:19 PM, Roland Stigge  wrote:
>> @@ -2016,6 +2030,8 @@ pl022_probe(struct amba_device *adev, co
>> pl022->master_info = platform_info;
>> pl022->adev = adev;
>> pl022->vendor = id->data;
>> +   /* Point chipselects to allocated memory beyond the main struct */
>> +   pl022->chipselects = (int *) pl022 + sizeof(struct pl022);
> 
> This is going beyond memory allocated for chipselects
> as it adds 4 * sizeof(struct pl022) bytes to pl022.
> 
> pl022->chipselects = (int *) &pl022[1];

Correct. Thanks for the heads up!

Funnily, my previous proposal way actually like you just proposed, but
we took the other one since it looked "better". ;-)

I'll provide an incremental bugfix patch since Mark already has the
commit in his misc.git tree.

Thanks again,

Roland
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   >