Re: [PATCH 2/2] memory-hotplug: remove reset_node_managed_pages() and reset_node_managed_pages() in hotadd_new_pgdat()

2015-08-24 Thread Xishi Qiu
On 2015/8/24 17:39, Tang Chen wrote:

> 
> On 08/24/2015 05:17 PM, Xishi Qiu wrote:
>> On 2015/8/23 18:28, Tang Chen wrote:
>>
>>> Hi Shi,
>>>
>>> Sorry for the late reply. I hope it won't be too late.
>>>
>>> NON-ACK by me, I think.
>>>
>>> I noticed that your first has been merged. But it won't fix the problem
>>> these code intended to fix.
>>>
>>> After your patch 1, zone's spanned/present won't be set to 0 because:
>>>
>>> free_area_init_node()
>>>   |--> get_pfn_range_for_nid(_pfn, _pfn)
>>>   |--> calculate_node_totalpages(pgdat, start_pfn, end_pfn, ...)
>>>   | --> zone_spanned_pages_in_node()
>>>| --> if (!node_start_pfn && !node_end_pfn) return 0;
>>> false, won't return 0
>>>   | --> zone_absent_pages_in_node()
>>>| --> if (!node_start_pfn && !node_end_pfn) return 0;
>>> false, won't return 0
>>>
>> Hi Tang,
>>
>> Thank you for your reply. When we add a new node, it is not included in the
>> memblock, I have no idea why zone_spanned_pages_in_node() and 
>> zone_absent_pages_in_node()
>> won't return 0. Do you add some debug code and print it?
> 
> Sorry, I didn't say it clearly since I was in a hurry.
> 
> If we move memblock_add_node() forward before hotadd_new_pgdat(),
> then node_start_pfn and node_end_pfn won't be 0. And
> zone_spanned_pages_in_node() and zone_absent_pages_in_node() won't
> return 0.
> 
> In your patch, they will return 0. And that leads to the print problem.
> 
>>
>>> This is caused by a little bug in your patch 1.
>>>
>>> You should put memblock_add_node(start, size, nid) before hotadd_new_pgdat()
>>> because:
>>>
>> My patch is just add an empty node first, later __add_zone() will update the 
>> size.
>> But it is all right put here, and it can fix the print bug.
> 
> Yes. I just found this bug in the log.
> 
>>
>>> hotadd_new_pgdat()
>>>   | --> free_area_init_node()
>>>| --> get_pfn_range_for_nid()
>>> | --> find memory ranges in memblock.
>>>
>>> | --> memblock_add_node(start, size, nid) ---if you add 
>>> it here, it doesn't work.
>>>
>>> The result will be like below if we hotadd node 5.
>>> [ 2007.577000] Initmem setup node 5 [mem 
>>> 0x-0x]
>> pr_info("Initmem setup node %d [mem %#018Lx-%#018Lx]\n", nid,
>> (u64)start_pfn << PAGE_SHIFT, ((u64)end_pfn << PAGE_SHIFT) - 1);
>> start_pfn and end_pfn are both 0, and 0-1 -> 0x, right?
> 
> Yes.
> 
>>
>>> [ 2007.584000] On node 5 totalpages: 0
>>> [ 2007.585000] Built 5 zonelists in Node order, mobility grouping on.  
>>> Total pages: 32588823
>>> [ 2007.594000] Policy zone: Normal
>>> [ 2007.598000] init_memory_mapping: [mem 0x600-0x607]
>>>
>>>
>>> And also, if we merge this patch, /sys/devices/system/node/nodeX/meminfo 
>>> will break.
>>>
>> trigger call trace?
> 
> No. There is no error output. But if you see 
> /sys/devices/system/node/nodeX/meminfo,
> memory size will double because totalpages is calculated once here, and one 
> more time
> when onlining memory.
> 

Hi Tang,

Do you mean si_meminfo_node() -> val->totalram = managed_pages; will be added 
double?
But my patch will keep it 0 in hotadd_new_pgdat(), so it will not be double, 
right?

Thanks,
Xishi Qiu

> I think reset it to 0 in add_memory() is just a temporary solution. Will 
> improve it in the
> future.
> 
> Thanks.
> 
>>
>>> Since this patch is not merged, I think let's just drop it.
>>>
>>> And about the little bug in your patch 1, since I'm in a hurry, I have 
>>> already send a patch to fix it.
>>>
>>>
>>> Thanks. :)
>>>
>>>
>>> On 08/11/2015 03:33 PM, Xishi Qiu wrote:
 After hotadd_new_pgdat()->free_area_init_node(), the pgdat and zone's 
 spanned/present
 are both 0, so remove reset_node_managed_pages() and 
 reset_node_managed_pages().

 Signed-off-by: Xishi Qiu 
 ---
mm/memory_hotplug.c | 25 -
1 file changed, 25 deletions(-)

 diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
 index 11f26cc..997dfad 100644
 --- a/mm/memory_hotplug.c
 +++ b/mm/memory_hotplug.c
 @@ -1065,16 +1065,6 @@ int __ref online_pages(unsigned long pfn, unsigned 
 long nr_pages, int online_typ
}
#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
-static void reset_node_present_pages(pg_data_t *pgdat)
 -{
 -struct zone *z;
 -
 -for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
 -z->present_pages = 0;
 -
 -pgdat->node_present_pages = 0;
 -}
 -
/* we are OK calling __meminit stuff here - we have 
 CONFIG_MEMORY_HOTPLUG */
static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start)
{
 @@ -1109,21 +1099,6 @@ static pg_data_t __ref *hotadd_new_pgdat(int nid, 
 u64 start)
build_all_zonelists(pgdat, NULL);

Re: [PATCH] mm: mmap: Check all failures before set values

2015-08-24 Thread Michal Hocko
On Mon 24-08-15 00:59:39, gang.chen.5...@qq.com wrote:
> From: Chen Gang 
> 
> When failure occurs and return, vma->vm_pgoff is already set, which is
> not a good idea.

Why? The vma is not inserted anywhere and the failure path is supposed
to simply free the vma.

> Signed-off-by: Chen Gang 
> ---
>  mm/mmap.c | 13 +++--
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 8e0366e..b5a6f09 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -2878,6 +2878,13 @@ int insert_vm_struct(struct mm_struct *mm, struct 
> vm_area_struct *vma)
>   struct vm_area_struct *prev;
>   struct rb_node **rb_link, *rb_parent;
>  
> + if (find_vma_links(mm, vma->vm_start, vma->vm_end,
> +, _link, _parent))
> + return -ENOMEM;
> + if ((vma->vm_flags & VM_ACCOUNT) &&
> +  security_vm_enough_memory_mm(mm, vma_pages(vma)))
> + return -ENOMEM;
> +
>   /*
>* The vm_pgoff of a purely anonymous vma should be irrelevant
>* until its first write fault, when page's anon_vma and index
> @@ -2894,12 +2901,6 @@ int insert_vm_struct(struct mm_struct *mm, struct 
> vm_area_struct *vma)
>   BUG_ON(vma->anon_vma);
>   vma->vm_pgoff = vma->vm_start >> PAGE_SHIFT;
>   }
> - if (find_vma_links(mm, vma->vm_start, vma->vm_end,
> -, _link, _parent))
> - return -ENOMEM;
> - if ((vma->vm_flags & VM_ACCOUNT) &&
> -  security_vm_enough_memory_mm(mm, vma_pages(vma)))
> - return -ENOMEM;
>  
>   vma_link(mm, vma, prev, rb_link, rb_parent);
>   return 0;
> -- 
> 1.9.3

-- 
Michal Hocko
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] x86/calling.h: remove unused SAVE_ALL/RESTORE_ALL macros for !CONFIG_x86_64

2015-08-24 Thread Alexander Kuleshov
SAVE_ALL and RESTORE_ALL macros for !CONFIG_X86_64 were introduced in the
1a338ac32 commit (sched, x86: Optimize the preempt_schedule() call) and
were used in the ___preempt_schedule and ___preempt_schedule_context from
the  arch/x86/kernel/preempt.S. But the arch/x86/kernel/preempt.S was
removed in the 0ad6e3c5 commit (x86: Speed up ___preempt_schedule*() by
using THUNK helpers) and ___preempt_schedule/___preempt_schedule_context
are reimplemeted and not used SAVE_ALL/RESTORE_ALL anymore.

These macros have no users anymore, so we can remove it.

Changelog:

v2: Check of the CONFIG_x86_64 returned as  provides
functionality only for the x86_64.

Signed-off-by: Alexander Kuleshov 
---
 arch/x86/entry/calling.h | 33 -
 1 file changed, 33 deletions(-)

diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h
index f4e6308..c009cee 100644
--- a/arch/x86/entry/calling.h
+++ b/arch/x86/entry/calling.h
@@ -207,37 +207,4 @@ For 32-bit we have the following conventions - kernel is 
built with
.macro icebp
.byte 0xf1
.endm
-
-#else /* CONFIG_X86_64 */
-
-/*
- * For 32bit only simplified versions of SAVE_ALL/RESTORE_ALL. These
- * are different from the entry_32.S versions in not changing the segment
- * registers. So only suitable for in kernel use, not when transitioning
- * from or to user space. The resulting stack frame is not a standard
- * pt_regs frame. The main use case is calling C code from assembler
- * when all the registers need to be preserved.
- */
-
-   .macro SAVE_ALL
-   pushl %eax
-   pushl %ebp
-   pushl %edi
-   pushl %esi
-   pushl %edx
-   pushl %ecx
-   pushl %ebx
-   .endm
-
-   .macro RESTORE_ALL
-   popl %ebx
-   popl %ecx
-   popl %edx
-   popl %esi
-   popl %edi
-   popl %ebp
-   popl %eax
-   .endm
-
 #endif /* CONFIG_X86_64 */
-
-- 
2.5.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] IGMP: Inhibit reports for local multicast groups

2015-08-24 Thread Philip Downey
The range of addresses between 224.0.0.0 and 224.0.0.255 inclusive, is
reserved for the use of routing protocols and other low-level topology
discovery or maintenance protocols, such as gateway discovery and
group membership reporting.  Multicast routers should not forward any
multicast datagram with destination addresses in this range,
regardless of its TTL.

Currently, IGMP reports are generated for this reserved range of
addresses even though a router will ignore this information since it
has no purpose.  However, the presence of reserved group addresses in
an IGMP membership report uses up network bandwidth and can also
obscure addresses of interest when inspecting membership reports using
packet inspection or debug messages.

Although the RFCs for the various version of IGMP (e.g.RFC 3376 for
v3) do not specify that the reserved addresses be excluded from
membership reports, it should do no harm in doing so.  In particular
there should be no adverse effect in any IGMP snooping functionality
since 224.0.0.x is specifically excluded as per RFC 4541 (IGMP and MLD
Snooping Switches Considerations) section 2.1.2. Data Forwarding
Rules:

2) Packets with a destination IP (DIP) address in the 224.0.0.X
   range which are not IGMP must be forwarded on all ports.

IGMP reports for local multicast groups can now be optionally
inhibited by means of a system control variable (by setting the value
to zero) e.g.:
echo 0 > /proc/sys/net/ipv4/igmp_link_local_reports

To retain backwards compatibility the previous behaviour is retained
by default on system boot or reverted by setting the value back to
non-zero e.g.:
echo 1 >  /proc/sys/net/ipv4/igmp_link_local_reports

Signed-off-by: Philip Downey 
---
 include/linux/igmp.h   |1 +
 net/ipv4/igmp.c|   29 -
 net/ipv4/sysctl_net_ipv4.c |7 +++
 3 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/include/linux/igmp.h b/include/linux/igmp.h
index 193ad48..e3e0dae 100644
--- a/include/linux/igmp.h
+++ b/include/linux/igmp.h
@@ -37,6 +37,7 @@ static inline struct igmpv3_query *
return (struct igmpv3_query *)skb_transport_header(skb);
 }
 
+extern int sysctl_igmp_link_local_reports;
 extern int sysctl_igmp_max_memberships;
 extern int sysctl_igmp_max_msf;
 extern int sysctl_igmp_qrv;
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 9fdfd9d..a3df89d 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -110,6 +110,15 @@
 #define IP_MAX_MEMBERSHIPS 20
 #define IP_MAX_MSF 10
 
+/* IGMP reports for link-local multicast groups are enabled by default */
+#define IGMP_ENABLE_LLM 1
+
+int sysctl_igmp_link_local_reports __read_mostly = IGMP_ENABLE_LLM;
+
+#define IGMP_INHIBIT_LINK_LOCAL_REPORTS(_ipaddr) \
+   (ipv4_is_local_multicast(_ipaddr) && \
+(sysctl_igmp_link_local_reports == 0))
+
 #ifdef CONFIG_IP_MULTICAST
 /* Parameter names and values are taken from igmp-v2-06 draft */
 
@@ -437,6 +446,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct 
ip_mc_list *pmc,
 
if (pmc->multiaddr == IGMP_ALL_HOSTS)
return skb;
+   if (IGMP_INHIBIT_LINK_LOCAL_REPORTS(pmc->multiaddr))
+   return skb;
 
isquery = type == IGMPV3_MODE_IS_INCLUDE ||
  type == IGMPV3_MODE_IS_EXCLUDE;
@@ -545,6 +556,8 @@ static int igmpv3_send_report(struct in_device *in_dev, 
struct ip_mc_list *pmc)
for_each_pmc_rcu(in_dev, pmc) {
if (pmc->multiaddr == IGMP_ALL_HOSTS)
continue;
+   if (IGMP_INHIBIT_LINK_LOCAL_REPORTS(pmc->multiaddr))
+   continue;
spin_lock_bh(>lock);
if (pmc->sfcount[MCAST_EXCLUDE])
type = IGMPV3_MODE_IS_EXCLUDE;
@@ -678,7 +691,11 @@ static int igmp_send_report(struct in_device *in_dev, 
struct ip_mc_list *pmc,
 
if (type == IGMPV3_HOST_MEMBERSHIP_REPORT)
return igmpv3_send_report(in_dev, pmc);
-   else if (type == IGMP_HOST_LEAVE_MESSAGE)
+
+   if (IGMP_INHIBIT_LINK_LOCAL_REPORTS(group))
+   return 0;
+
+   if (type == IGMP_HOST_LEAVE_MESSAGE)
dst = IGMP_ALL_ROUTER;
else
dst = group;
@@ -851,6 +868,8 @@ static bool igmp_heard_report(struct in_device *in_dev, 
__be32 group)
 
if (group == IGMP_ALL_HOSTS)
return false;
+   if (IGMP_INHIBIT_LINK_LOCAL_REPORTS(group))
+   return false;
 
rcu_read_lock();
for_each_pmc_rcu(in_dev, im) {
@@ -957,6 +976,8 @@ static bool igmp_heard_query(struct in_device *in_dev, 
struct sk_buff *skb,
continue;
if (im->multiaddr == IGMP_ALL_HOSTS)
continue;
+   if (IGMP_INHIBIT_LINK_LOCAL_REPORTS(im->multiaddr))
+   continue;
   

Re: [PATCH/RFC v6 01/36] leds: Add brightness_set_blocking op

2015-08-24 Thread Pavel Machek
On Thu 2015-08-20 16:43:31, Jacek Anaszewski wrote:
> This patch adds a new brightness_set_blocking op to the LED subsystem.
> The op is intended for drivers that set brightness in a blocking way,
> i.e. they either can sleep or use delays while setting brightness.
> 
> Signed-off-by: Jacek Anaszewski 
> Cc: Andrew Lunn 
> Cc: Sakari Ailus 

Acked-by: Pavel Machek 

Thanks!
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
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 v1 3/3] arm64: dts: add Hi6220 mailbox node

2015-08-24 Thread Leif Lindholm
On Mon, Aug 24, 2015 at 06:19:56PM +0800, Haojian Zhuang wrote:
> > If your EFI memory map describes the memory as mappable, it is wrong.
> 
> When kernel is working, kernel will create its own page table based on
> UEFI memory map. Since it's reserved in DTS file as Leo's patch, it'll
> be moved to reserved memblock. Why is it wrong?
> 
> In the second, UEFI is firmware. When it's stable, nobody should change
> it without any reason.

Much like the memory map.

> These reserved memory are used in mailbox driver.
> Look. It's driver, so it could be changed at any time.

No, it is a set of regions of memory set aside for use by a different
master in the system as well as communications with that master.

The fact that there is a driver somewhere that is aware of this is
entirely beside the point. All agents in the system must adher to this
protocol.

> Why do you want
> to UEFI knowing this memory range? Do you hope UEFI to change when
> mailbox driver is changed?

Yes.

UEFI is a runtime environment. Having random magic areas not to be
touched will cause random pieces of software running under it to break
horribly or break other things horribly.
Unless you mark them as reserved in the UEFI memory map.
At which point the Linux kernel will automatically ignore them, and
the proposed patch is redundant.

So, yes, if you want a system that can boot reliably, run testsuites
(like SCT or FWTS), run applications (like fastboot ... or the EFI
stub kernel itself), then any memory regions that is reserved for
mailbox communication (or other masters in the system) _must_ be
marked in the EFI memory map.

/
Leif
--
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 v4 1/4] mfd: max77686: Don't suggest in binding to use a deprecated property

2015-08-24 Thread Lee Jones
On Mon, 24 Aug 2015, Javier Martinez Canillas wrote:

> The regulator-compatible property from the regulator DT binding was
> deprecated. But the max77686 DT binding doc still suggest to use it
> instead of the regulator node name's which is the correct approach.
> 
> Signed-off-by: Javier Martinez Canillas 
> Reviewed-by: Krzysztof Kozlowski 
> Acked-by: Lee Jones 
> 
> ---
> 
> Changes in v4:
> - Add Lee Jones Acked-by tag to patch #1.
> 
> Changes in v3: None
> Changes in v2:
> - Add Krzysztof Kozlowski Reviewed-by tag to patch #1.
> 
>  Documentation/devicetree/bindings/mfd/max77686.txt | 11 ---
>  1 file changed, 4 insertions(+), 7 deletions(-)

Applied, thanks.

> diff --git a/Documentation/devicetree/bindings/mfd/max77686.txt 
> b/Documentation/devicetree/bindings/mfd/max77686.txt
> index 163bd81a4607..8221102d3fc2 100644
> --- a/Documentation/devicetree/bindings/mfd/max77686.txt
> +++ b/Documentation/devicetree/bindings/mfd/max77686.txt
> @@ -26,7 +26,7 @@ Optional node:
>   };
>   refer Documentation/devicetree/bindings/regulator/regulator.txt
>  
> -  The regulator-compatible property of regulator should initialized with 
> string
> +  The regulator node's name should be initialized with a string
>  to get matched with their hardware counterparts as follow:
>  
>   -LDOn   :   for LDOs, where n can lie in range 1 to 26.
> @@ -55,16 +55,14 @@ Example:
>   reg = <0x09>;
>  
>   voltage-regulators {
> - ldo11_reg {
> - regulator-compatible = "LDO11";
> + ldo11_reg: LDO11 {
>   regulator-name = "vdd_ldo11";
>   regulator-min-microvolt = <190>;
>   regulator-max-microvolt = <190>;
>   regulator-always-on;
>   };
>  
> - buck1_reg {
> - regulator-compatible = "BUCK1";
> + buck1_reg: BUCK1 {
>   regulator-name = "vdd_mif";
>   regulator-min-microvolt = <95>;
>   regulator-max-microvolt = <130>;
> @@ -72,8 +70,7 @@ Example:
>   regulator-boot-on;
>   };
>  
> - buck9_reg {
> - regulator-compatible = "BUCK9";
> + buck9_reg: BUCK9 {
>   regulator-name = "CAM_ISP_CORE_1.2V";
>   regulator-min-microvolt = <100>;
>   regulator-max-microvolt = <120>;

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
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 v4 2/4] mfd: max77686: Use a generic name for the PMIC node in the example

2015-08-24 Thread Lee Jones
On Mon, 24 Aug 2015, Javier Martinez Canillas wrote:

> The ePAPR standard says that: "the name of a node should be somewhat
> generic, reflecting the function of the device and not its precise
> programming model."
> 
> So, change the max77686 binding document example to use a generic
> node name instead of using the chip's name.
> 
> Suggested-by: Sergei Shtylyov 
> Signed-off-by: Javier Martinez Canillas 
> Acked-by: Lee Jones 
> 
> ---
> 
> Changes in v4:
> - Add Lee Jones Acked-by tag to patch #2.
> 
> Changes in v3:
> - Fix typo in ePAPR document name. Suggested by Sergei Shtylyov
> 
> Changes in v2: None
> 
>  Documentation/devicetree/bindings/mfd/max77686.txt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

> diff --git a/Documentation/devicetree/bindings/mfd/max77686.txt 
> b/Documentation/devicetree/bindings/mfd/max77686.txt
> index 8221102d3fc2..d2ed3c20a5c3 100644
> --- a/Documentation/devicetree/bindings/mfd/max77686.txt
> +++ b/Documentation/devicetree/bindings/mfd/max77686.txt
> @@ -48,7 +48,7 @@ to get matched with their hardware counterparts as follow:
>  
>  Example:
>  
> - max77686@09 {
> + max77686: pmic@09 {
>   compatible = "maxim,max77686";
>   interrupt-parent = <_eint>;
>   interrupts = <26 0>;

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
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 v5 6/8] iio: gyro: bmg160: optimize i2c transfers in trigger handler

2015-08-24 Thread Wolfram Sang

> Do we want to insist on a much larger change (conversion to regmap)
> when if this in place, a simple single functional call change will do the
> job?

I'd assume that regmap conversion will happen later quite likely anyhow.
Most of those devices will have I2C/SPI dual interfaces; or people will
find out that caching registers can reduce the bus load, etc...

That being said, I'll keep Irina's patches for the next merge window.
But we should keep an eye how/if the new function is used. Kernel
growth is an issue at times...

Thanks,

   Wolfram



signature.asc
Description: Digital signature


Re: [PATCH v4 4/4] mfd: max77686: Split out regulator part from the DT binding

2015-08-24 Thread Lee Jones
On Mon, 24 Aug 2015, Javier Martinez Canillas wrote:

> The Maxim MAX77686 PMIC is a multi-function device with regulators,
> clocks and a RTC. The DT bindings for the clocks are in a separate
> file but the bindings for the regulators are inside the mfd part.
> 
> To make it consistent with the clocks portion of the binding and
> because is more natural to look for regulator bindings under the
> bindings/regulator sub-directory, split the regulator portion of
> the DT binding and add it as a separate file.
> 
> Signed-off-by: Javier Martinez Canillas 
> Reviewed-by: Krzysztof Kozlowski 
> Acked-by: Lee Jones 
> 
> ---
> 
> Changes in v4: None
> Changes in v3:
> - Add Krzysztof Kozlowski Reviewed-by tag to patch #4.
> - Add Lee Jones Acked-by tag to patch #4.
> 
> Changes in v2:
> - Use a generic name for the max77686 node in the regulator example.
> 
>  Documentation/devicetree/bindings/mfd/max77686.txt | 60 ++
>  .../devicetree/bindings/regulator/max77686.txt | 71 
> ++
>  2 files changed, 75 insertions(+), 56 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/regulator/max77686.txt

Applied, thanks.

> diff --git a/Documentation/devicetree/bindings/mfd/max77686.txt 
> b/Documentation/devicetree/bindings/mfd/max77686.txt
> index d2ed3c20a5c3..741e76688cf2 100644
> --- a/Documentation/devicetree/bindings/mfd/max77686.txt
> +++ b/Documentation/devicetree/bindings/mfd/max77686.txt
> @@ -7,8 +7,9 @@ different i2c slave address,presently for which we are 
> statically creating i2c
>  client while probing.This document describes the binding for mfd device and
>  PMIC submodule.
>  
> -Binding for the built-in 32k clock generator block is defined separately
> -in bindings/clk/maxim,max77686.txt file.
> +Bindings for the built-in 32k clock generator block and
> +regulators are defined in ../clk/maxim,max77686.txt and
> +../regulator/max77686.txt respectively.
>  
>  Required properties:
>  - compatible : Must be "maxim,max77686";
> @@ -16,36 +17,6 @@ Required properties:
>  - interrupts : This i2c device has an IRQ line connected to the main SoC.
>  - interrupt-parent : The parent interrupt controller.
>  
> -Optional node:
> -- voltage-regulators : The regulators of max77686 have to be instantiated
> -  under subnode named "voltage-regulators" using the following format.
> -
> - regulator_name {
> - regulator-compatible = LDOn/BUCKn
> - standard regulator constraints
> - };
> - refer Documentation/devicetree/bindings/regulator/regulator.txt
> -
> -  The regulator node's name should be initialized with a string
> -to get matched with their hardware counterparts as follow:
> -
> - -LDOn   :   for LDOs, where n can lie in range 1 to 26.
> - example: LDO1, LDO2, LDO26.
> - -BUCKn  :   for BUCKs, where n can lie in range 1 to 9.
> - example: BUCK1, BUCK5, BUCK9.
> -
> -  Regulators which can be turned off during system suspend:
> - -LDOn   :   2, 6-8, 10-12, 14-16,
> - -BUCKn  :   1-4.
> -  Use standard regulator bindings for it ('regulator-off-in-suspend').
> -
> -  LDO20, LDO21, LDO22, BUCK8 and BUCK9 can be configured to GPIO enable
> -  control. To turn this feature on this property must be added to the 
> regulator
> -  sub-node:
> - - maxim,ena-gpios : one GPIO specifier enable control (the gpio
> - flags are actually ignored and always
> - ACTIVE_HIGH is used)
> -
>  Example:
>  
>   max77686: pmic@09 {
> @@ -53,27 +24,4 @@ Example:
>   interrupt-parent = <_eint>;
>   interrupts = <26 0>;
>   reg = <0x09>;
> -
> - voltage-regulators {
> - ldo11_reg: LDO11 {
> - regulator-name = "vdd_ldo11";
> - regulator-min-microvolt = <190>;
> - regulator-max-microvolt = <190>;
> - regulator-always-on;
> - };
> -
> - buck1_reg: BUCK1 {
> - regulator-name = "vdd_mif";
> - regulator-min-microvolt = <95>;
> - regulator-max-microvolt = <130>;
> - regulator-always-on;
> - regulator-boot-on;
> - };
> -
> - buck9_reg: BUCK9 {
> - regulator-name = "CAM_ISP_CORE_1.2V";
> - regulator-min-microvolt = <100>;
> - regulator-max-microvolt = <120>;
> - maxim,ena-gpios = < 3 GPIO_ACTIVE_HIGH>;
> - };
> - }
> + };
> diff --git a/Documentation/devicetree/bindings/regulator/max77686.txt 
> b/Documentation/devicetree/bindings/regulator/max77686.txt
> new 

Re: [PATCH v4 3/4] mfd: Add DT binding for Maxim MAX77802 IC

2015-08-24 Thread Lee Jones
On Mon, 24 Aug 2015, Javier Martinez Canillas wrote:

> The MAX77802 is a chip that contains regulators, 2 32kHz clocks,
> a RTC and an I2C interface to program the individual components.
> 
> The are already DT bindings for the regulators and clocks and
> these reference to a bindings/mfd/max77802.txt file, that didn't
> exist, for the details about the PMIC.
> 
> Signed-off-by: Javier Martinez Canillas 
> Reviewed-by: Krzysztof Kozlowski 
> 
> ---
> 
> Changes in v4:
> - Reword section about max77802 clock and regulator DT binding docs.
>   Suggested by Lee Jones.
> - Align max77802 mfd required properties. Suggested by Lee Jones.
> 
> Changes in v3:
> - Add Krzysztof Kozlowski Reviewed-by tag to patch #3.
> - Capitalise all acronyms. Suggested by Lee Jones.
> - Use relative path to refer other bindings. Suggested by Lee Jones.
> - Use IRQ_TYPE_NONE instead of 0 in example. Suggested by Lee Jones.
> 
> Changes in v2:
> - Use the correct "maxim,max77802" compatible string.
>   Suggested by Krzysztof Kozlowski
> - Use a pmic generic node name for the max77802 node example.
>   Suggested by Sergei Shtylyov.
> 
>  Documentation/devicetree/bindings/mfd/max77802.txt | 26 
> ++
>  1 file changed, 26 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/max77802.txt

Applied, thanks.

> diff --git a/Documentation/devicetree/bindings/mfd/max77802.txt 
> b/Documentation/devicetree/bindings/mfd/max77802.txt
> new file mode 100644
> index ..51fc1a60caa5
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/max77802.txt
> @@ -0,0 +1,26 @@
> +Maxim MAX77802 multi-function device
> +
> +The Maxim MAX77802 is a Power Management IC (PMIC) that contains 10 high
> +efficiency Buck regulators, 32 Low-DropOut (LDO) regulators used to power
> +up application processors and peripherals, a 2-channel 32kHz clock outputs,
> +a Real-Time-Clock (RTC) and a I2C interface to program the individual
> +regulators, clocks outputs and the RTC.
> +
> +Bindings for the built-in 32k clock generator block and
> +regulators are defined in ../clk/maxim,max77802.txt and
> +../regulator/max77802.txt respectively.
> +
> +Required properties:
> +- compatible : Must be "maxim,max77802"
> +- reg: Specifies the I2C slave address of PMIC block.
> +- interrupts : I2C device IRQ line connected to the main SoC.
> +- interrupt-parent   : The parent interrupt controller.
> +
> +Example:
> +
> + max77802: pmic@09 {
> + compatible = "maxim,max77802";
> + interrupt-parent = <>;
> + interrupts = <26 IRQ_TYPE_NONE>;
> + reg = <0x09>;
> + };

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
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/


linux-next: Tree for Aug 24

2015-08-24 Thread Stephen Rothwell
Hi all,

Changes since 20150821:

New tree: rockchip

The arm-soc tree gained a conflict against Linus' tree.

The powerpc tree lost its build failure.

The xtensa tree gained a conflict againste the arm64 and tip trees.

The btrfs tree lost its build failure.

The nfs tree still had its build failure for which I disabled a staging
driver.

The net-next tree gained a build failure so I used the verison from
next-20150821.

The block tree gained conflicts against the btrfs tree.

The spi tree lost its build failure.

The kvm-ppc tree gained a conflict against the tip tree.

The tty tree still had its build failure for which I reverted part of
a commit.

The char-misc tree gained a conflict against the tip tree.

The akpm-current tree gained a conflict against the omap_dss2 tree.

Non-merge commits (relative to Linus' tree): 9385
 8226 files changed, 502992 insertions(+), 198015 deletions(-)



I have created today's linux-next tree at
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
(patches at http://www.kernel.org/pub/linux/kernel/next/ ).  If you
are tracking the linux-next tree using git, you should not use "git pull"
to do so as that will try to merge the new linux-next release with the
old one.  You should use "git fetch" and checkout or reset to the new
master.

You can see which trees have been included by looking in the Next/Trees
file in the source.  There are also quilt-import.log and merge.log
files in the Next directory.  Between each merge, the tree was built
with a ppc64_defconfig for powerpc and an allmodconfig for x86_64,
a multi_v7_defconfig for arm and a native build of tools/perf. After
the final fixups (if any), it is also built with powerpc allnoconfig
(32 and 64 bit), ppc44x_defconfig and allyesconfig (this fails its final
link) and i386, sparc, sparc64 and arm defconfig.

Below is a summary of the state of the merge.

I am currently merging 225 trees (counting Linus' and 33 trees of patches
pending for Linus' tree).

Stats about the size of the tree over time can be seen at
http://neuling.org/linux-next-size.html .

Status of my local build tests will be at
http://kisskb.ellerman.id.au/linux-next .  If maintainers want to give
advice about cross compilers/configs that work, we are always open to add
more builds.

Thanks to Randy Dunlap for doing many randconfig builds.  And to Paul
Gortmaker for triage and bug fixes.

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

$ git checkout master
$ git reset --hard stable
Merging origin/master (eb63b34bdfbd Merge branch 'upstream' of 
git://git.linux-mips.org/pub/scm/ralf/upstream-linus)
Merging fixes/master (c7e9ad7da219 Merge branch 'perf-urgent-for-linus' of 
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip)
Merging kbuild-current/rc-fixes (3d1450d54a4f Makefile: Force gzip and xz on 
module install)
Merging arc-current/for-curr (e4140819dadc ARC: signal handling robustify)
Merging arm-current/fixes (3939f3345050 ARM: 8418/1: add boot image 
dependencies to not generate invalid images)
Merging m68k-current/for-linus (1214c525484c m68k: Use for_each_sg())
Merging metag-fixes/fixes (0164a711c97b metag: Fix ioremap_wc/ioremap_cached 
build errors)
Merging mips-fixes/mips-fixes (1795cd9b3a91 Linux 3.16-rc5)
Merging powerpc-fixes/fixes (f7644cbfcdf0 Linux 4.2-rc6)
Merging powerpc-merge-mpe/fixes (bc0195aad0da Linux 4.2-rc2)
Merging sparc/master (73958c651fbf sparc64: use ENTRY/ENDPROC in VISsave)
Merging net/master (c953e23936f9 netlink: mmap: fix tx type check)
Merging ipsec/master (158cd4af8ded packet: missing dev_put() in 
packet_do_bind())
Merging sound-current/for-linus (f6b28e4ded45 ALSA: hda - Shutdown CX20722 on 
reboot/free to avoid spurious noises)
Merging pci-current/for-linus (45ea2a5fed6d PCI: Don't use 64-bit bus addresses 
on PA-RISC)
Merging wireless-drivers/master (741e3b9902d1 rtlwifi: rtl8723be: Add module 
parameter for MSI interrupts)
Merging driver-core.current/driver-core-linus (cbfe8fa6cd67 Linux 4.2-rc4)
Merging tty.current/tty-linus (cbfe8fa6cd67 Linux 4.2-rc4)
Merging usb.current/usb-linus (f7644cbfcdf0 Linux 4.2-rc6)
Merging usb-gadget-fixes/fixes (c93e64e91248 usb: udc: core: add device_del() 
call to error pathway)
Merging usb-serial-fixes/usb-linus (d071a3cdd2e1 USB: qcserial: add HP lt4111 
LTE/EV-DO/HSPA+ Gobi 4G Module)
Merging staging.current/staging-linus (f7644cbfcdf0 Linux 4.2-rc6)
Merging char-misc.current/char-misc-linus (f7644cbfcdf0 Linux 4.2-rc6)
Merging input-current/for-linus (1ae5ddb6f883 Input: gpio_keys_polled - request 
GPIO pin as input.)
Merging crypto-current/master (b310c178e6d8 crypto: caam - fix memory 
corruption in ahash_final_ctx)
Merging ide/master (d681f1166919 ide: remove deprecated use of pci api)
Merging devicetree-current/devicetree/merge (f76502aa9140 of/dynamic: Fix test 
for PPC_PSERIES)
Merging rr-fixes/fixes (d65d31f17b5b module: Fix locking in 

[PATCH v2] mm: use only per-device readahead limit

2015-08-24 Thread Roman Gushchin
Maximal readahead size is limited now by two values:
1) by global 2Mb constant (MAX_READAHEAD in max_sane_readahead())
2) by configurable per-device value* (bdi->ra_pages)

There are devices, which require custom readahead limit.
For instance, for RAIDs it's calculated as number of devices
multiplied by chunk size times 2.

Readahead size can never be larger than bdi->ra_pages * 2 value
(POSIX_FADV_SEQUNTIAL doubles readahead size).

If so, why do we need two limits?
I suggest to completely remove this max_sane_readahead() stuff and
use per-device readahead limit everywhere.

Also, using right readahead size for RAID disks can significantly
increase i/o performance:

before:
dd if=/dev/md2 of=/dev/null bs=100M count=100
100+0 records in
100+0 records out
1048576 bytes (10 GB) copied, 12.9741 s, 808 MB/s

after:
$ dd if=/dev/md2 of=/dev/null bs=100M count=100
100+0 records in
100+0 records out
1048576 bytes (10 GB) copied, 8.91317 s, 1.2 GB/s

(It's an 8-disks RAID5 storage).

This patch doesn't change sys_readahead and madvise(MADV_WILLNEED)
behavior introduced by commit
6d2be915e589b58cb11418cbe1f22ff90732b6ac ("mm/readahead.c: fix
readahead failure for memoryless NUMA nodes and limit readahead pages").

V2:
Konstantin Khlebnikov noticed, that if readahead is completely
disabled, force_page_cache_readahead() will not read anything.
This function is used for sync reads (if FMODE_RANDOM flag is set).
So, to guarantee read progress it's necessary to read at least 1 page.

Signed-off-by: Roman Gushchin 
Cc: Linus Torvalds 
Cc: Raghavendra K T 
Cc: Jan Kara 
Cc: Wu Fengguang 
Cc: David Rientjes 
Cc: Andrew Morton 
Cc: Konstantin Khlebnikov 
---
 include/linux/mm.h |  2 --
 mm/filemap.c   |  8 +++-
 mm/readahead.c | 18 ++
 3 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 2e872f9..a62abdd 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1942,8 +1942,6 @@ void page_cache_async_readahead(struct address_space 
*mapping,
pgoff_t offset,
unsigned long size);
 
-unsigned long max_sane_readahead(unsigned long nr);
-
 /* Generic expand stack which grows the stack according to GROWS{UP,DOWN} */
 extern int expand_stack(struct vm_area_struct *vma, unsigned long address);
 
diff --git a/mm/filemap.c b/mm/filemap.c
index 1283fc8..0e1ebef 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1807,7 +1807,6 @@ static void do_sync_mmap_readahead(struct vm_area_struct 
*vma,
   struct file *file,
   pgoff_t offset)
 {
-   unsigned long ra_pages;
struct address_space *mapping = file->f_mapping;
 
/* If we don't want any read-ahead, don't bother */
@@ -1836,10 +1835,9 @@ static void do_sync_mmap_readahead(struct vm_area_struct 
*vma,
/*
 * mmap read-around
 */
-   ra_pages = max_sane_readahead(ra->ra_pages);
-   ra->start = max_t(long, 0, offset - ra_pages / 2);
-   ra->size = ra_pages;
-   ra->async_size = ra_pages / 4;
+   ra->start = max_t(long, 0, offset - ra->ra_pages / 2);
+   ra->size = ra->ra_pages;
+   ra->async_size = ra->ra_pages / 4;
ra_submit(ra, mapping, file);
 }
 
diff --git a/mm/readahead.c b/mm/readahead.c
index 60cd846..7eb844c 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -213,7 +213,11 @@ int force_page_cache_readahead(struct address_space 
*mapping, struct file *filp,
if (unlikely(!mapping->a_ops->readpage && !mapping->a_ops->readpages))
return -EINVAL;
 
-   nr_to_read = max_sane_readahead(nr_to_read);
+   /*
+* Read at least 1 page, even if readahead is completely disabled.
+*/
+   nr_to_read = min(nr_to_read, max(inode_to_bdi(mapping->host)->ra_pages,
+1ul));
while (nr_to_read) {
int err;
 
@@ -232,16 +236,6 @@ int force_page_cache_readahead(struct address_space 
*mapping, struct file *filp,
return 0;
 }
 
-#define MAX_READAHEAD   ((512*4096)/PAGE_CACHE_SIZE)
-/*
- * Given a desired number of PAGE_CACHE_SIZE readahead pages, return a
- * sensible upper limit.
- */
-unsigned long max_sane_readahead(unsigned long nr)
-{
-   return min(nr, MAX_READAHEAD);
-}
-
 /*
  * Set the initial window size, round to next power of 2 and square
  * for small size, x 4 for medium, and x 2 for large
@@ -380,7 +374,7 @@ ondemand_readahead(struct address_space *mapping,
   bool hit_readahead_marker, pgoff_t offset,
   unsigned long req_size)
 {
-   unsigned long max = max_sane_readahead(ra->ra_pages);
+   unsigned long max = ra->ra_pages;
pgoff_t prev_offset;
 
/*
-- 
2.4.3

--
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  

Re: [PATCH] HID: quirks: add QUIRK_NOGET for an other TPV touchscreen

2015-08-24 Thread Jiri Kosina
On Fri, 21 Aug 2015, Benjamin Tissoires wrote:

> Looks like 0x8882 needs the same quirk than 0x8883.
> Given that both devices claim they are "TPV OpticalTouchScreen" rename
> the 0x8883 to add its PID in the #define.
> 
> Reported-by: Blaine Lee 
> Signed-off-by: Benjamin Tissoires 

Applied to for-4.3/upstream. 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] gpio: gpiolib: use devm_* API to simplify driver code

2015-08-24 Thread Peng Fan
Use devm_* API to simplify driver code.

Signed-off-by: Peng Fan 
Cc: Linus Walleij 
Cc: Alexandre Courbot 
---
 drivers/gpio/gpiolib.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 6bc612b..f9470b0 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -243,7 +243,8 @@ int gpiochip_add(struct gpio_chip *chip)
int base = chip->base;
struct gpio_desc *descs;
 
-   descs = kcalloc(chip->ngpio, sizeof(descs[0]), GFP_KERNEL);
+   descs = devm_kcalloc(chip->dev, chip->ngpio, sizeof(descs[0]),
+GFP_KERNEL);
if (!descs)
return -ENOMEM;
 
@@ -254,7 +255,7 @@ int gpiochip_add(struct gpio_chip *chip)
if (base < 0) {
status = base;
spin_unlock_irqrestore(_lock, flags);
-   goto err_free_descs;
+   goto err_descs;
}
chip->base = base;
}
@@ -262,7 +263,7 @@ int gpiochip_add(struct gpio_chip *chip)
status = gpiochip_add_to_list(chip);
if (status) {
spin_unlock_irqrestore(_lock, flags);
-   goto err_free_descs;
+   goto err_descs;
}
 
for (id = 0; id < chip->ngpio; id++) {
@@ -308,9 +309,7 @@ err_remove_chip:
list_del(>list);
spin_unlock_irqrestore(_lock, flags);
chip->desc = NULL;
-err_free_descs:
-   kfree(descs);
-
+err_descs:
/* failures here can mean systems won't boot... */
pr_err("%s: GPIOs %d..%d (%s) failed to register\n", __func__,
chip->base, chip->base + chip->ngpio - 1,
-- 
1.8.4.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: [x86] copy_from{to}_user question

2015-08-24 Thread Jeff Epler
On Mon, Aug 24, 2015 at 03:52:11PM +0800, yalin wang wrote:
> i am not clear about what is STAC / SMAP ?
> could you give me a link for understanding ?

the first item I found by googling was
https://lwn.net/Articles/517251/

Jeff
--
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: [RFC 4/8] jbd, jbd2: Do not fail journal because of frozen_buffer allocation failure

2015-08-24 Thread Michal Hocko
Hi Ted,

On Sat 15-08-15 09:54:22, Theodore Ts'o wrote:
> On Wed, Aug 12, 2015 at 11:14:11AM +0200, Michal Hocko wrote:
> > > Is this "if (!committed_data) {" check now dead code?
> > > 
> > > I also see other similar suspected dead sites in the rest of the series.
> > 
> > You are absolutely right. I have updated the patches.
> 
> Have you sent out an updated version of these patches?  Maybe I missed
> it, but I don't think I saw them.

would you be interested in these two patches sent with rephrased
changelog to not depend on the patch which allows GFP_NOFS to fail? The
way this has been handled for btrfs...
-- 
Michal Hocko
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] input: gpio-keys: report error when invalid key number

2015-08-24 Thread Peng Fan
When the input key number is not valid one of
'/sys/devices/soc0/gpio-keys/keys', need to report
an error, but not continue.

See the following example:
root@yocto:/sys/devices/soc0/gpio-keys# cat keys
114-116
root@yocto:/sys/devices/soc0/gpio-keys# echo 77 > keys
root@yocto:/sys/devices/soc0/gpio-keys#

we want 'echo 77 > keys' to report an error, but not
silence to give us an fake illusion that all is 'ok'.

Signed-off-by: Peng Fan 
Cc: Dmitry Torokhov 
Cc: Linus Walleij 
Cc: Alexander Stein 
Cc: Tejun Heo 
Cc: Andrew Morton 
Cc: Wolfram Sang 
Cc: Fabio Estevam 
---
 drivers/input/keyboard/gpio_keys.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/input/keyboard/gpio_keys.c 
b/drivers/input/keyboard/gpio_keys.c
index ddf4045..b98f3b4 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -239,6 +239,11 @@ static ssize_t gpio_keys_attr_store_helper(struct 
gpio_keys_drvdata *ddata,
}
}
 
+   if (i == ddata->pdata->nbuttons) {
+   error = -EINVAL;
+   goto out;
+   }
+
mutex_lock(>disable_lock);
 
for (i = 0; i < ddata->pdata->nbuttons; i++) {
-- 
1.8.4.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 03/12] mm, page_alloc: Remove unnecessary taking of a seqlock when cpusets are disabled

2015-08-24 Thread Mel Gorman
There is a seqcounter that protects against spurious allocation failures
when a task is changing the allowed nodes in a cpuset. There is no need
to check the seqcounter until a cpuset exists.

Signed-off-by: Mel Gorman 
Acked-by: Christoph Lameter 
Acked-by: David Rientjes 
Acked-by: Vlastimil Babka 
---
 include/linux/cpuset.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 1b357997cac5..6eb27cb480b7 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -104,6 +104,9 @@ extern void cpuset_print_task_mems_allowed(struct 
task_struct *p);
  */
 static inline unsigned int read_mems_allowed_begin(void)
 {
+   if (!cpusets_enabled())
+   return 0;
+
return read_seqcount_begin(>mems_allowed_seq);
 }
 
@@ -115,6 +118,9 @@ static inline unsigned int read_mems_allowed_begin(void)
  */
 static inline bool read_mems_allowed_retry(unsigned int seq)
 {
+   if (!cpusets_enabled())
+   return false;
+
return read_seqcount_retry(>mems_allowed_seq, seq);
 }
 
-- 
2.4.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 09/12] mm, page_alloc: Delete the zonelist_cache

2015-08-24 Thread Mel Gorman
The zonelist cache (zlc) was introduced to skip over zones that were
recently known to be full. This avoided expensive operations such as the
cpuset checks, watermark calculations and zone_reclaim. The situation
today is different and the complexity of zlc is harder to justify.

1) The cpuset checks are no-ops unless a cpuset is active and in general are
   a lot cheaper.

2) zone_reclaim is now disabled by default and I suspect that was a large
   source of the cost that zlc wanted to avoid. When it is enabled, it's
   known to be a major source of stalling when nodes fill up and it's
   unwise to hit every other user with the overhead.

3) Watermark checks are expensive to calculate for high-order
   allocation requests. Later patches in this series will reduce the cost
   of the watermark checking.

4) The most important issue is that in the current implementation it
   is possible for a failed THP allocation to mark a zone full for order-0
   allocations and cause a fallback to remote nodes.

The last issue could be addressed with additional complexity but as the
benefit of zlc is questionable, it is better to remove it.  If stalls
due to zone_reclaim are ever reported then an alternative would be to
introduce deferring logic based on a timeout inside zone_reclaim itself
and leave the page allocator fast paths alone.

The impact on page-allocator microbenchmarks is negligible as they don't
hit the paths where the zlc comes into play. Most page-reclaim related
workloads showed no noticable difference as a result of the removal.

The impact was noticeable in a workload called "stutter". One part uses a
lot of anonymous memory, a second measures mmap latency and a third copies
a large file. In an ideal world the latency application would not notice
the mmap latency.  On a 2-node machine the results of this patch are

2-node machine stutter
 4.2.0-rc7 4.2.0-rc7
   vanillanozlc-v3r8
Min mmap 21.2266 (  0.00%) 21.0431 (  0.86%)
1st-qrtle   mmap 24.3096 (  0.00%) 28.6013 (-17.65%)
2nd-qrtle   mmap 28.5789 (  0.00%) 29.2909 ( -2.49%)
3rd-qrtle   mmap 29.1970 (  0.00%) 29.9426 ( -2.55%)
Max-90% mmap 33.6982 (  0.00%) 34.0195 ( -0.95%)
Max-93% mmap 34.1751 (  0.00%) 34.3753 ( -0.59%)
Max-95% mmap 38.7323 (  0.00%) 35.0257 (  9.57%)
Max-99% mmap 93.7964 (  0.00%) 89.8644 (  4.19%)
Max mmap 494274.6891 (  0.00%)  47520.4050 ( 90.39%)
Meanmmap 48.2708 (  0.00%) 46.5963 (  3.47%)
Best99%Mean mmap 29.0087 (  0.00%) 30.2834 ( -4.39%)
Best95%Mean mmap 27.3926 (  0.00%) 29.2582 ( -6.81%)
Best90%Mean mmap 27.0060 (  0.00%) 28.9746 ( -7.29%)
Best50%Mean mmap 24.9743 (  0.00%) 27.8092 (-11.35%)
Best10%Mean mmap 22.9546 (  0.00%) 24.7627 ( -7.88%)
Best5%Mean  mmap 21.9682 (  0.00%) 23.3681 ( -6.37%)
Best1%Mean  mmap 21.3082 (  0.00%) 21.2479 (  0.28%)

Note that the maximum stall latency went from 494 seconds to 47 seconds
which is still awful but an improvement. The milage here varies considerably
as a 4-node machine that tested an earlier version of this patch went from
a worst case stall time of 6 seconds to 67ms. The nature of the benchmark
is inherently unpredictable as it is hammering the system and the milage
will vary between machines.

There is a secondary impact with potentially more direct reclaim because
zones are now being considered instead of being skipped by zlc. In this
particular test run it did not occur so will not be described. However,
in at least one test the following was observed

1. Direct reclaim rates were higher. This was likely due to direct reclaim
  being entered instead of the zlc disabling a zone and busy looping.
  Busy looping may have the effect of allowing kswapd to make more
  progress and in some cases may be better overall. If this is found then
  the correct action is to put direct reclaimers to sleep on a waitqueue
  and allow kswapd make forward progress. Busy looping on the zlc is even
  worse than when the allocator used to blindly call congestion_wait().

2. There was higher swap activity as direct reclaim was active.

3. Direct reclaim efficiency was lower. This is related to 1 as more
  scanning activity also encountered more pages that could not be
  immediately reclaimed

In that case, the direct page scan and reclaim rates are noticeable but
it is not considered a problem for a few reasons

1. The test is primarily concerned with latency. The mmap attempts are also
   faulted which means there are THP allocation requests. The ZLC could
   cause zones to be disabled causing the process to busy loop instead
   of reclaiming.  This looks like elevated direct reclaim activity but
   it's the correct action to take based on what processes requested.

2. The test hammers reclaim and compaction heavily. The number of successful
   THP 

[PATCH 01/12] mm, page_alloc: Remove unnecessary parameter from zone_watermark_ok_safe

2015-08-24 Thread Mel Gorman
No user of zone_watermark_ok_safe() specifies alloc_flags. This patch
removes the unnecessary parameter.

Signed-off-by: Mel Gorman 
Acked-by: David Rientjes 
Acked-by: Vlastimil Babka 
Acked-by: Michal Hocko 
Reviewed-by: Christoph Lameter 
---
 include/linux/mmzone.h | 2 +-
 mm/page_alloc.c| 5 +++--
 mm/vmscan.c| 4 ++--
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 754c25966a0a..99cf4209cd45 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -802,7 +802,7 @@ void wakeup_kswapd(struct zone *zone, int order, enum 
zone_type classzone_idx);
 bool zone_watermark_ok(struct zone *z, unsigned int order,
unsigned long mark, int classzone_idx, int alloc_flags);
 bool zone_watermark_ok_safe(struct zone *z, unsigned int order,
-   unsigned long mark, int classzone_idx, int alloc_flags);
+   unsigned long mark, int classzone_idx);
 enum memmap_context {
MEMMAP_EARLY,
MEMMAP_HOTPLUG,
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index df959b7d6085..9b6bae688db8 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2224,6 +2224,7 @@ static bool __zone_watermark_ok(struct zone *z, unsigned 
int order,
min -= min / 2;
if (alloc_flags & ALLOC_HARDER)
min -= min / 4;
+
 #ifdef CONFIG_CMA
/* If allocation can't use CMA areas don't use free CMA pages */
if (!(alloc_flags & ALLOC_CMA))
@@ -2253,14 +2254,14 @@ bool zone_watermark_ok(struct zone *z, unsigned int 
order, unsigned long mark,
 }
 
 bool zone_watermark_ok_safe(struct zone *z, unsigned int order,
-   unsigned long mark, int classzone_idx, int alloc_flags)
+   unsigned long mark, int classzone_idx)
 {
long free_pages = zone_page_state(z, NR_FREE_PAGES);
 
if (z->percpu_drift_mark && free_pages < z->percpu_drift_mark)
free_pages = zone_page_state_snapshot(z, NR_FREE_PAGES);
 
-   return __zone_watermark_ok(z, order, mark, classzone_idx, alloc_flags,
+   return __zone_watermark_ok(z, order, mark, classzone_idx, 0,
free_pages);
 }
 
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 8286938c70de..e950134c4b9a 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2450,7 +2450,7 @@ static inline bool compaction_ready(struct zone *zone, 
int order)
balance_gap = min(low_wmark_pages(zone), DIV_ROUND_UP(
zone->managed_pages, KSWAPD_ZONE_BALANCE_GAP_RATIO));
watermark = high_wmark_pages(zone) + balance_gap + (2UL << order);
-   watermark_ok = zone_watermark_ok_safe(zone, 0, watermark, 0, 0);
+   watermark_ok = zone_watermark_ok_safe(zone, 0, watermark, 0);
 
/*
 * If compaction is deferred, reclaim up to a point where
@@ -2933,7 +2933,7 @@ static bool zone_balanced(struct zone *zone, int order,
  unsigned long balance_gap, int classzone_idx)
 {
if (!zone_watermark_ok_safe(zone, order, high_wmark_pages(zone) +
-   balance_gap, classzone_idx, 0))
+   balance_gap, classzone_idx))
return false;
 
if (IS_ENABLED(CONFIG_COMPACTION) && order && compaction_suitable(zone,
-- 
2.4.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 08/12] mm, page_alloc: Rename __GFP_WAIT to __GFP_RECLAIM

2015-08-24 Thread Mel Gorman
__GFP_WAIT was used to signal that the caller was in atomic context and
could not sleep.  Now it is possible to distinguish between true atomic
context and callers that are not willing to sleep. The latter should clear
__GFP_DIRECT_RECLAIM so kswapd will still wake. As clearing __GFP_WAIT
behaves differently, there is a risk that people will clear the wrong
flags. This patch renames __GFP_WAIT to __GFP_RECLAIM to clearly indicate
what it does -- setting it allows all reclaim activity, clearing them
prevents it.

Signed-off-by: Mel Gorman 
Acked-by: Michal Hocko 
---
 block/blk-mq.c   |  2 +-
 block/scsi_ioctl.c   |  6 +++---
 drivers/block/drbd/drbd_bitmap.c |  2 +-
 drivers/block/mtip32xx/mtip32xx.c|  2 +-
 drivers/block/nvme-core.c|  4 ++--
 drivers/block/paride/pd.c|  2 +-
 drivers/block/pktcdvd.c  |  4 ++--
 drivers/gpu/drm/i915/i915_gem.c  |  2 +-
 drivers/ide/ide-atapi.c  |  2 +-
 drivers/ide/ide-cd.c |  2 +-
 drivers/ide/ide-cd_ioctl.c   |  2 +-
 drivers/ide/ide-devsets.c|  2 +-
 drivers/ide/ide-disk.c   |  2 +-
 drivers/ide/ide-ioctls.c |  4 ++--
 drivers/ide/ide-park.c   |  2 +-
 drivers/ide/ide-pm.c |  4 ++--
 drivers/ide/ide-tape.c   |  4 ++--
 drivers/ide/ide-taskfile.c   |  4 ++--
 drivers/infiniband/hw/ipath/ipath_file_ops.c |  2 +-
 drivers/infiniband/hw/qib/qib_init.c |  2 +-
 drivers/misc/vmw_balloon.c   |  2 +-
 drivers/scsi/scsi_error.c|  2 +-
 drivers/scsi/scsi_lib.c  |  4 ++--
 fs/cachefiles/internal.h |  2 +-
 fs/direct-io.c   |  2 +-
 fs/nilfs2/mdt.h  |  2 +-
 include/linux/gfp.h  | 16 
 kernel/power/swap.c  | 14 +++---
 lib/percpu_ida.c |  2 +-
 mm/failslab.c|  8 
 mm/filemap.c |  2 +-
 mm/huge_memory.c |  2 +-
 mm/migrate.c |  2 +-
 mm/page_alloc.c  | 10 +-
 security/integrity/ima/ima_crypto.c  |  2 +-
 35 files changed, 64 insertions(+), 64 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 7d80379d7a38..16feffc93489 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1221,7 +1221,7 @@ static struct request *blk_mq_map_request(struct 
request_queue *q,
ctx = blk_mq_get_ctx(q);
hctx = q->mq_ops->map_queue(q, ctx->cpu);
blk_mq_set_alloc_data(_data, q,
-   __GFP_WAIT|__GFP_HIGH, false, ctx, hctx);
+   __GFP_RECLAIM|__GFP_HIGH, false, ctx, hctx);
rq = __blk_mq_alloc_request(_data, rw);
ctx = alloc_data.ctx;
hctx = alloc_data.hctx;
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index dda653ce7b24..0774799942e0 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -444,7 +444,7 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk 
*disk, fmode_t mode,
 
}
 
-   rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_WAIT);
+   rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_RECLAIM);
if (IS_ERR(rq)) {
err = PTR_ERR(rq);
goto error_free_buffer;
@@ -495,7 +495,7 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk 
*disk, fmode_t mode,
break;
}
 
-   if (bytes && blk_rq_map_kern(q, rq, buffer, bytes, __GFP_WAIT)) {
+   if (bytes && blk_rq_map_kern(q, rq, buffer, bytes, __GFP_RECLAIM)) {
err = DRIVER_ERROR << 24;
goto error;
}
@@ -536,7 +536,7 @@ static int __blk_send_generic(struct request_queue *q, 
struct gendisk *bd_disk,
struct request *rq;
int err;
 
-   rq = blk_get_request(q, WRITE, __GFP_WAIT);
+   rq = blk_get_request(q, WRITE, __GFP_RECLAIM);
if (IS_ERR(rq))
return PTR_ERR(rq);
blk_rq_set_block_pc(rq);
diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c
index 434c77dcc99e..2940da0011e0 100644
--- a/drivers/block/drbd/drbd_bitmap.c
+++ b/drivers/block/drbd/drbd_bitmap.c
@@ -1016,7 +1016,7 @@ static void bm_page_io_async(struct drbd_bm_aio_ctx *ctx, 
int page_nr) __must_ho
bm_set_page_unchanged(b->bm_pages[page_nr]);
 
if (ctx->flags & BM_AIO_COPY_PAGES) {
-   page = mempool_alloc(drbd_md_io_page_pool, 
__GFP_HIGHMEM|__GFP_WAIT);
+   page = mempool_alloc(drbd_md_io_page_pool, 

[PATCH 06/12] mm, page_alloc: Use masks and shifts when converting GFP flags to migrate types

2015-08-24 Thread Mel Gorman
This patch redefines which GFP bits are used for specifying mobility and
the order of the migrate types. Once redefined it's possible to convert
GFP flags to a migrate type with a simple mask and shift. The only downside
is that readers of OOM kill messages and allocation failures may have been
used to the existing values but scripts/gfp-translate will help.

Signed-off-by: Mel Gorman 
---
 include/linux/gfp.h| 12 +++-
 include/linux/mmzone.h |  2 +-
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index ad35f300b9a4..a10347ca5053 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -14,7 +14,7 @@ struct vm_area_struct;
 #define ___GFP_HIGHMEM 0x02u
 #define ___GFP_DMA32   0x04u
 #define ___GFP_MOVABLE 0x08u
-#define ___GFP_WAIT0x10u
+#define ___GFP_RECLAIMABLE 0x10u
 #define ___GFP_HIGH0x20u
 #define ___GFP_IO  0x40u
 #define ___GFP_FS  0x80u
@@ -29,7 +29,7 @@ struct vm_area_struct;
 #define ___GFP_NOMEMALLOC  0x1u
 #define ___GFP_HARDWALL0x2u
 #define ___GFP_THISNODE0x4u
-#define ___GFP_RECLAIMABLE 0x8u
+#define ___GFP_WAIT0x8u
 #define ___GFP_NOACCOUNT   0x10u
 #define ___GFP_NOTRACK 0x20u
 #define ___GFP_NO_KSWAPD   0x40u
@@ -123,6 +123,7 @@ struct vm_area_struct;
 
 /* This mask makes up all the page movable related flags */
 #define GFP_MOVABLE_MASK (__GFP_RECLAIMABLE|__GFP_MOVABLE)
+#define GFP_MOVABLE_SHIFT 3
 
 /* Control page allocator reclaim behavior */
 #define GFP_RECLAIM_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS|\
@@ -149,14 +150,15 @@ struct vm_area_struct;
 /* Convert GFP flags to their corresponding migrate type */
 static inline int gfpflags_to_migratetype(const gfp_t gfp_flags)
 {
-   WARN_ON((gfp_flags & GFP_MOVABLE_MASK) == GFP_MOVABLE_MASK);
+   VM_WARN_ON((gfp_flags & GFP_MOVABLE_MASK) == GFP_MOVABLE_MASK);
+   BUILD_BUG_ON((1UL << GFP_MOVABLE_SHIFT) != ___GFP_MOVABLE);
+   BUILD_BUG_ON((___GFP_MOVABLE >> GFP_MOVABLE_SHIFT) != MIGRATE_MOVABLE);
 
if (unlikely(page_group_by_mobility_disabled))
return MIGRATE_UNMOVABLE;
 
/* Group based on mobility */
-   return (((gfp_flags & __GFP_MOVABLE) != 0) << 1) |
-   ((gfp_flags & __GFP_RECLAIMABLE) != 0);
+   return (gfp_flags & GFP_MOVABLE_MASK) >> GFP_MOVABLE_SHIFT;
 }
 
 #ifdef CONFIG_HIGHMEM
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 99cf4209cd45..fc0457d005f8 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -37,8 +37,8 @@
 
 enum {
MIGRATE_UNMOVABLE,
-   MIGRATE_RECLAIMABLE,
MIGRATE_MOVABLE,
+   MIGRATE_RECLAIMABLE,
MIGRATE_PCPTYPES,   /* the number of types on the pcp lists */
MIGRATE_RESERVE = MIGRATE_PCPTYPES,
 #ifdef CONFIG_CMA
-- 
2.4.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 02/12] mm, page_alloc: Remove unnecessary recalculations for dirty zone balancing

2015-08-24 Thread Mel Gorman
File-backed pages that will be immediately written are balanced between
zones.  This heuristic tries to avoid having a single zone filled with
recently dirtied pages but the checks are unnecessarily expensive. Move
consider_zone_balanced into the alloc_context instead of checking bitmaps
multiple times. The patch also gives the parameter a more meaningful name.

Signed-off-by: Mel Gorman 
Acked-by: David Rientjes 
Acked-by: Michal Hocko 
Acked-by: Vlastimil Babka 
---
 mm/internal.h   |  1 +
 mm/page_alloc.c | 11 +++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/mm/internal.h b/mm/internal.h
index 36b23f1e2ca6..9331f802a067 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -129,6 +129,7 @@ struct alloc_context {
int classzone_idx;
int migratetype;
enum zone_type high_zoneidx;
+   bool spread_dirty_pages;
 };
 
 /*
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 9b6bae688db8..62ae28d8ae8d 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2453,8 +2453,6 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int 
order, int alloc_flags,
nodemask_t *allowednodes = NULL;/* zonelist_cache approximation */
int zlc_active = 0; /* set if using zonelist_cache */
int did_zlc_setup = 0;  /* just call zlc_setup() one time */
-   bool consider_zone_dirty = (alloc_flags & ALLOC_WMARK_LOW) &&
-   (gfp_mask & __GFP_WRITE);
int nr_fair_skipped = 0;
bool zonelist_rescan;
 
@@ -2509,14 +2507,14 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int 
order, int alloc_flags,
 *
 * XXX: For now, allow allocations to potentially
 * exceed the per-zone dirty limit in the slowpath
-* (ALLOC_WMARK_LOW unset) before going into reclaim,
+* (spread_dirty_pages unset) before going into reclaim,
 * which is important when on a NUMA setup the allowed
 * zones are together not big enough to reach the
 * global limit.  The proper fix for these situations
 * will require awareness of zones in the
 * dirty-throttling and the flusher threads.
 */
-   if (consider_zone_dirty && !zone_dirty_ok(zone))
+   if (ac->spread_dirty_pages && !zone_dirty_ok(zone))
continue;
 
mark = zone->watermark[alloc_flags & ALLOC_WMARK_MASK];
@@ -3202,6 +3200,10 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int 
order,
 
/* We set it here, as __alloc_pages_slowpath might have changed it */
ac.zonelist = zonelist;
+
+   /* Dirty zone balancing only done in the fast path */
+   ac.spread_dirty_pages = (gfp_mask & __GFP_WRITE);
+
/* The preferred zone is used for statistics later */
preferred_zoneref = first_zones_zonelist(ac.zonelist, ac.high_zoneidx,
ac.nodemask ? : _current_mems_allowed,
@@ -3220,6 +3222,7 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order,
 * complete.
 */
alloc_mask = memalloc_noio_flags(gfp_mask);
+   ac.spread_dirty_pages = false;
 
page = __alloc_pages_slowpath(alloc_mask, order, );
}
-- 
2.4.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 00/12] Remove zonelist cache and high-order watermark checking v3

2015-08-24 Thread Mel Gorman
Changelog since V3
o Covered cases where __GFP_KSWAPD_RECLAIM is needed(vbabka)
o Cleaned up trailing references to zlc (vbabka)
o Fixed a subtle problem with GFP_TRANSHUGE checks  (vbabka)
o Split out an unrelated change to its own patch(vbabka)
o Reordered series to put GFP flag modifications at start   (mhocko)
o Added a number of clarifications on reclaim modifications (mhocko)
o Only check cpusets when one exists that can limit memory  (rientjes)
o Applied acks

Changelog since V2
o Improve cpusets checks as suggested   (rientjes)
o Add various acks and reviewed-bys
o Rebase to 4.2-rc6

Changelog since V1
o Rebase to 4.2-rc5
o Distinguish between high priority callers and callers that avoid sleep
o Remove jump label related damage patches

Overall, the intent of this series is to remove the zonelist cache which
was introduced to avoid high overhead in the page allocator. Once this is
done, it is necessary to reduce the cost of watermark checks.

The series starts with minor micro-optimisations.

Next it notes that GFP flags that affect watermark checks are
bused. __GFP_WAIT historically identified callers that could not sleep and
could access reserves. This was later abused to identify callers that simply
prefer to avoid sleeping and have other options. A patch distinguishes
between atomic callers, high-priority callers and those that simply wish
to avoid sleep.

The zonelist cache has been around for a long time but it is of dubious
merit with a lot of complexity and some issues that are explained.
The most important issue is that a failed THP allocation can cause a
zone to be treated as "full". This potentially causes unnecessary stalls,
reclaim activity or remote fallbacks. The issues could be fixed but it's
not worth it. The series places a small number of other micro-optimisations
on top before examining GFP flags watermarks.

High-order watermarks enforcement can cause high-order allocations to fail
even though pages are free. The watermark checks both protect high-order
atomic allocations and make kswapd aware of high-order pages but there is
a much better way that can be handled using migrate types. This series uses
page grouping by mobility to reserve pageblocks for high-order allocations
with the size of the reservation depending on demand. kswapd awareness
is maintained by examining the free lists. By patch 12 in this series,
there are no high-order watermark checks while preserving the properties
that motivated the introduction of the watermark checks.

 Documentation/vm/balance   |  14 +-
 arch/arm/mm/dma-mapping.c  |   4 +-
 arch/arm/xen/mm.c  |   2 +-
 arch/arm64/mm/dma-mapping.c|   4 +-
 arch/x86/kernel/pci-dma.c  |   2 +-
 block/bio.c|  26 +-
 block/blk-core.c   |  16 +-
 block/blk-ioc.c|   2 +-
 block/blk-mq-tag.c |   2 +-
 block/blk-mq.c |   8 +-
 block/cfq-iosched.c|   4 +-
 block/scsi_ioctl.c |   6 +-
 drivers/block/drbd/drbd_bitmap.c   |   2 +-
 drivers/block/drbd/drbd_receiver.c |   3 +-
 drivers/block/mtip32xx/mtip32xx.c  |   2 +-
 drivers/block/nvme-core.c  |   4 +-
 drivers/block/osdblk.c |   2 +-
 drivers/block/paride/pd.c  |   2 +-
 drivers/block/pktcdvd.c|   4 +-
 drivers/connector/connector.c  |   3 +-
 drivers/firewire/core-cdev.c   |   2 +-
 drivers/gpu/drm/i915/i915_gem.c|   4 +-
 drivers/ide/ide-atapi.c|   2 +-
 drivers/ide/ide-cd.c   |   2 +-
 drivers/ide/ide-cd_ioctl.c |   2 +-
 drivers/ide/ide-devsets.c  |   2 +-
 drivers/ide/ide-disk.c |   2 +-
 drivers/ide/ide-ioctls.c   |   4 +-
 drivers/ide/ide-park.c |   2 +-
 drivers/ide/ide-pm.c   |   4 +-
 drivers/ide/ide-tape.c |   4 +-
 drivers/ide/ide-taskfile.c |   4 +-
 drivers/infiniband/core/sa_query.c |   2 +-
 drivers/infiniband/hw/ipath/ipath_file_ops.c   |   2 +-
 drivers/infiniband/hw/qib/qib_init.c   |   2 +-
 drivers/iommu/amd_iommu.c  |   2 +-
 drivers/iommu/intel-iommu.c|   2 +-
 drivers/md/dm-crypt.c  |   6 +-
 drivers/md/dm-kcopyd.c |   2 +-
 

[PATCH 07/12] mm, page_alloc: Distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd

2015-08-24 Thread Mel Gorman
__GFP_WAIT has been used to identify atomic context in callers that hold
spinlocks or are in interrupts. They are expected to be high priority and
have access one of two watermarks lower than "min" which can be referred
to as the "atomic reserve". __GFP_HIGH users get access to the first lower
watermark and can be called the "high priority reserve".

Over time, callers had a requirement to not block when fallback options
were available. Some have abused __GFP_WAIT leading to a situation where
an optimisitic allocation with a fallback option can access atomic reserves.

This patch uses __GFP_ATOMIC to identify callers that are truely atomic,
cannot sleep and have no alternative. High priority users continue to use
__GFP_HIGH. __GFP_DIRECT_RECLAIM identifies callers that can sleep and are
willing to enter direct reclaim. __GFP_KSWAPD_RECLAIM to identify callers
that want to wake kswapd for background reclaim. __GFP_WAIT is redefined
as a caller that is willing to enter direct reclaim and wake kswapd for
background reclaim.

This patch then converts a number of sites

o __GFP_ATOMIC is used by callers that are high priority and have memory
  pools for those requests. GFP_ATOMIC uses this flag.

o Callers that have a limited mempool to guarantee forward progress use
  __GFP_DIRECT_RECLAIM. bio allocations fall into this category where
  kswapd will still be woken but atomic reserves are not used as there
  is a one-entry mempool to guarantee progress.

o Callers that are checking if they are non-blocking should use the
  helper gfpflags_allow_blocking() where possible. This is because
  checking for __GFP_WAIT as was done historically now can trigger false
  positives. Some exceptions like dm-crypt.c exist where the code intent
  is clearer if __GFP_DIRECT_RECLAIM is used instead of the helper due to
  flag manipulations.

o Callers that built their own GFP flags instead of starting with GFP_KERNEL
  and friends now also need to specify __GFP_KSWAPD_RECLAIM.

The first key hazard to watch out for is callers that removed __GFP_WAIT
and was depending on access to atomic reserves for inconspicuous reasons.
In some cases it may be appropriate for them to use __GFP_HIGH.

The second key hazard is callers that assembled their own combination of
GFP flags instead of starting with something like GFP_KERNEL. They may
now wish to specify __GFP_KSWAPD_RECLAIM. It's almost certainly harmless
if it's missed in most cases as other activity will wake kswapd.

Signed-off-by: Mel Gorman 
---
 Documentation/vm/balance   | 14 ---
 arch/arm/mm/dma-mapping.c  |  4 +-
 arch/arm/xen/mm.c  |  2 +-
 arch/arm64/mm/dma-mapping.c|  4 +-
 arch/x86/kernel/pci-dma.c  |  2 +-
 block/bio.c| 26 ++--
 block/blk-core.c   | 16 
 block/blk-ioc.c|  2 +-
 block/blk-mq-tag.c |  2 +-
 block/blk-mq.c |  8 ++--
 block/cfq-iosched.c|  4 +-
 drivers/block/drbd/drbd_receiver.c |  3 +-
 drivers/block/osdblk.c |  2 +-
 drivers/connector/connector.c  |  3 +-
 drivers/firewire/core-cdev.c   |  2 +-
 drivers/gpu/drm/i915/i915_gem.c|  2 +-
 drivers/infiniband/core/sa_query.c |  2 +-
 drivers/iommu/amd_iommu.c  |  2 +-
 drivers/iommu/intel-iommu.c|  2 +-
 drivers/md/dm-crypt.c  |  6 +--
 drivers/md/dm-kcopyd.c |  2 +-
 drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c |  2 +-
 drivers/media/pci/solo6x10/solo6x10-v4l2.c |  2 +-
 drivers/media/pci/tw68/tw68-video.c|  2 +-
 drivers/mtd/mtdcore.c  |  3 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c|  2 +-
 drivers/staging/android/ion/ion_system_heap.c  |  2 +-
 .../lustre/include/linux/libcfs/libcfs_private.h   |  2 +-
 drivers/usb/host/u132-hcd.c|  2 +-
 drivers/video/fbdev/vermilion/vermilion.c  |  2 +-
 fs/btrfs/disk-io.c |  2 +-
 fs/btrfs/extent_io.c   | 14 +++
 fs/btrfs/volumes.c |  4 +-
 fs/ext3/super.c|  2 +-
 fs/ext4/super.c|  2 +-
 fs/fscache/cookie.c|  2 +-
 fs/fscache/page.c  |  6 +--
 fs/jbd/transaction.c   |  4 +-
 fs/jbd2/transaction.c  |  4 +-
 fs/nfs/file.c  |  6 +--
 fs/xfs/xfs_qm.c

[PATCH 04/12] mm, page_alloc: Only check cpusets when one exists that can be mem-controlled

2015-08-24 Thread Mel Gorman
David Rientjes correctly pointed out that the "root cpuset may not exclude
mems on the system so, even if mounted, there's no need to check or be
worried about concurrent change when there is only one cpuset".

The three checks for cpusets_enabled() care whether a cpuset exists that
can limit memory, not that cpuset is enabled as such. This patch replaces
cpusets_enabled() with cpusets_mems_enabled() which checks if at least one
cpuset exists that can limit memory and updates the appropriate call sites.

Signed-off-by: Mel Gorman 
---
 include/linux/cpuset.h | 16 +---
 mm/page_alloc.c|  2 +-
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 6eb27cb480b7..1e823870987e 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -17,10 +17,6 @@
 #ifdef CONFIG_CPUSETS
 
 extern struct static_key cpusets_enabled_key;
-static inline bool cpusets_enabled(void)
-{
-   return static_key_false(_enabled_key);
-}
 
 static inline int nr_cpusets(void)
 {
@@ -28,6 +24,12 @@ static inline int nr_cpusets(void)
return static_key_count(_enabled_key) + 1;
 }
 
+/* Returns true if a cpuset exists that can set cpuset.mems */
+static inline bool cpusets_mems_enabled(void)
+{
+   return nr_cpusets() > 1;
+}
+
 static inline void cpuset_inc(void)
 {
static_key_slow_inc(_enabled_key);
@@ -104,7 +106,7 @@ extern void cpuset_print_task_mems_allowed(struct 
task_struct *p);
  */
 static inline unsigned int read_mems_allowed_begin(void)
 {
-   if (!cpusets_enabled())
+   if (!cpusets_mems_enabled())
return 0;
 
return read_seqcount_begin(>mems_allowed_seq);
@@ -118,7 +120,7 @@ static inline unsigned int read_mems_allowed_begin(void)
  */
 static inline bool read_mems_allowed_retry(unsigned int seq)
 {
-   if (!cpusets_enabled())
+   if (!cpusets_mems_enabled())
return false;
 
return read_seqcount_retry(>mems_allowed_seq, seq);
@@ -139,7 +141,7 @@ static inline void set_mems_allowed(nodemask_t nodemask)
 
 #else /* !CONFIG_CPUSETS */
 
-static inline bool cpusets_enabled(void) { return false; }
+static inline bool cpusets_mems_enabled(void) { return false; }
 
 static inline int cpuset_init(void) { return 0; }
 static inline void cpuset_init_smp(void) {}
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 62ae28d8ae8d..2c1c3bf54d15 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2470,7 +2470,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int 
order, int alloc_flags,
if (IS_ENABLED(CONFIG_NUMA) && zlc_active &&
!zlc_zone_worth_trying(zonelist, z, allowednodes))
continue;
-   if (cpusets_enabled() &&
+   if (cpusets_mems_enabled() &&
(alloc_flags & ALLOC_CPUSET) &&
!cpuset_zone_allowed(zone, gfp_mask))
continue;
-- 
2.4.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 05/12] mm, page_alloc: Remove unecessary recheck of nodemask

2015-08-24 Thread Mel Gorman
An allocation request will either use the given nodemask or the cpuset
current tasks mems_allowed. A cpuset retry will recheck the callers nodemask
and while it's trivial overhead during an extremely rare operation, also
unnecessary. This patch fixes it.

Signed-off-by: Mel Gorman 
---
 mm/page_alloc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2c1c3bf54d15..32d1cec124bc 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3171,7 +3171,7 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order,
gfp_t alloc_mask; /* The gfp_t that was actually used for allocation */
struct alloc_context ac = {
.high_zoneidx = gfp_zone(gfp_mask),
-   .nodemask = nodemask,
+   .nodemask = nodemask ? : _current_mems_allowed,
.migratetype = gfpflags_to_migratetype(gfp_mask),
};
 
@@ -3206,8 +3206,7 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order,
 
/* The preferred zone is used for statistics later */
preferred_zoneref = first_zones_zonelist(ac.zonelist, ac.high_zoneidx,
-   ac.nodemask ? : _current_mems_allowed,
-   _zone);
+   ac.nodemask, _zone);
if (!ac.preferred_zone)
goto out;
ac.classzone_idx = zonelist_zone_idx(preferred_zoneref);
-- 
2.4.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/


Re: [PATCH] phy: rcar-gen3-usb2: Add R-Car Gen3 USB2 PHY driver

2015-08-24 Thread Geert Uytterhoeven
Hi Shimoda-san,

On Thu, Aug 20, 2015 at 8:28 AM, Yoshihiro Shimoda
 wrote:
> This patch adds support for R-Car generation 3 USB2 PHY driver.
> This SoC has 3 EHCI/OHCI channels, and the channel 0 is shared
> with the HSUSB (USB2.0 peripheral) device.
>
> So, the purpose of this driver is:
>  1) initializes some registers of SoC specific to use the
> {ehci,ohci}-platform driver.
>
>  2) detects id pin to select host or peripheral on the channel 0.
>
> For now, this driver only supports 1) above.

Thanks for your patch!

> --- /dev/null
> +++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> @@ -0,0 +1,37 @@
> +* Renesas R-Car generation 3 USB 2.0 PHY
> +
> +This file provides information on what the device node for the R-Car 
> generation
> +3 USB 2.0 PHY contains.
> +
> +Required properties:
> +- compatible: "renesas,usb2-phy-r8a7795" if the device is a part of R8A7795 
> SoC.

"an R8A7795 SoC".

> +- reg: offset and length of the USB2.0 host register block.
> +- reg-names: must be "usb2".
> +- clocks: clock phandle and specifier pair.

"pair(s)."

> +- clock-names: string, clock input name, must be "usb2", and optional 
> "hsusb".

names

> +- #phy-cells: see phy-bindings.txt in the same directory, must be <0>.
> +
> +Optional proparies:

properties

> +To use a USB channel which EHCI/OHCI and HSUSB are combined, the device tree

s/which/where/

> +node should set HSUSB proparies to reg and reg-names proparies:

properties (x2)

> +- reg: offset and length of the HSUSB register block.
> +- reg-names: must be "hsusb".
> +
> +Example (R-Car H3):
> +
> +   usb-phy@ee080200 {
> +   compatible = "renesas,usb2-phy-r8a7795";
> +   reg = <0 0xee080200 0 0x6ff>, <0 0xe6590100 0 0x100>;
> +   reg-names = "usb2", "hsusb";
> +   clocks = <_clks R8A7795_CLK_EHCI0>,
> +<_clks R8A7795_CLK_HSUSB>;

If you ever want to enable Runtime PM, do you want the first MSTP clock to be
managed automatically?
What about the second optional clock?

> +   clock-names = "usb2", "hsusb";
> +   };
> +
> +   usb-phy@ee0a0200 {
> +   compatible = "renesas,usb2-phy-r8a7795";
> +   reg = <0 0xee0a0200 0 0x6ff>;
> +   reg-names = "usb2";
> +   clocks = <_clks R8A7795_CLK_EHCI0>;
> +   clock-names = "usb2";
> +   };

> --- /dev/null
> +++ b/drivers/phy/phy-rcar-gen3-usb2.c

> +static int rcar_gen3_phy_usb2_init(struct phy *p)
> +{
> +   struct rcar_gen3_phy_usb2_channel *channel = phy_get_drvdata(p);
> +   unsigned long flags;
> +   void __iomem *usb2_base = channel->usb2.base;
> +   void __iomem *hsusb_base = channel->hsusb.base;
> +   u32 tmp;
> +
> +   /* Since ops->init() is called once, this driver enables both clocks 
> */
> +   clk_prepare_enable(channel->usb2.clk);
> +   clk_prepare_enable(channel->hsusb.clk);

So this driver manages its clock(s) itself, and doesn't support Runtime PM.

> +static int rcar_gen3_phy_usb2_exit(struct phy *p)
> +{
> +   struct rcar_gen3_phy_usb2_channel *channel = phy_get_drvdata(p);
> +
> +   writel(0, channel->usb2.base + USB2_INT_ENABLE);
> +
> +   clk_disable_unprepare(channel->hsusb.clk);
> +   clk_disable_unprepare(channel->usb2.clk);
> +
> +   return 0;
> +}

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/


Re: [PATCH 10/11] ah6: fix error return code

2015-08-24 Thread Herbert Xu
On Sun, Aug 23, 2015 at 02:11:21AM +0200, Julia Lawall wrote:
> Return a negative error code on failure.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
> 
> // 
> @@
> identifier ret; expression e1,e2;
> @@
> (
> if (\(ret < 0\|ret != 0\))
>  { ... return ret; }
> |
> ret = 0
> )
> ... when != ret = e1
> when != 
> *if(...)
> {
>   ... when != ret = e2
>   when forall
>  return ret;
> }
> // 
> 
> Signed-off-by: Julia Lawall 

Acked-by: Herbert Xu 

This problem exists in net/ipv4/ah4.c too, right?

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
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 5/6] i2c: Replace I2C_CROS_EC_TUNNEL dependency

2015-08-24 Thread Wolfram Sang
On Wed, Aug 19, 2015 at 01:19:57PM +0200, Javier Martinez Canillas wrote:
> The ChromeOS EC tunnel I2C bus driver depend on CROS_EC_PROTO but
> MFD_CROS_EC select CROS_EC_PROTO instead. Mixing select and depends
> on is bad practice as it may lead to circular Kconfig dependencies.
> 
> Since the platform device that is matched with the I2C bus driver
> is registered by the ChromeOS EC mfd driver, I2C_CROS_EC_TUNNEL
> really depends on MFD_CROS_EC. And because this config option
> selects CROS_EC_PROTO, that dependency is met as well. So make the
> driver to depend on MFD_CROS_EC instead of CROS_EC_PROTO.
> 
> Signed-off-by: Javier Martinez Canillas 
> 

Applied to for-next, thanks!



signature.asc
Description: Digital signature


Re: [PATCH] usbnet: Fix two races between usbnet_stop() and the BH

2015-08-24 Thread Eugene Shatokhin

19.08.2015 15:31, Bjørn Mork пишет:

Eugene Shatokhin  writes:


The problem is not in the reordering but rather in the fact that
"dev->flags = 0" is not necessarily atomic
w.r.t. "clear_bit(EVENT_RX_KILL, >flags)", and vice versa.

So the following might be possible, although unlikely:

CPU0 CPU1
  clear_bit: read dev->flags
  clear_bit: clear EVENT_RX_KILL in the read value

dev->flags=0;

  clear_bit: write updated dev->flags

As a result, dev->flags may become non-zero again.


Ah, right.  Thanks for explaining.


I cannot prove yet that this is an impossible situation. If anyone
can, please explain. If so, this part of the patch will not be needed.


I wonder if we could simply move the dev->flags = 0 down a few lines to
fix both issues?  It doesn't seem to do anything useful except for
resetting the flags to a sane initial state after the device is down.

Stopping the tasklet rescheduling etc depends only on netif_running(),
which will be false when usbnet_stop is called.  There is no need to
touch dev->flags for this to happen.


That was one of the first ideas we discussed here. Unfortunately, it is 
probably not so simple.


Setting dev->flags to 0 makes some delayed operations do nothing and, 
among other things, not to reschedule usbnet_bh().


As you can see in drivers/net/usb/usbnet.c, usbnet_bh() can be called as 
a tasklet function and as a timer function in a number of situations 
(look for the usage of dev->bh and dev->delay there).


netif_running() is indeed false when usbnet_stop() runs, usbnet_stop() 
also disables Tx. This seems to be enough for many cases where 
usbnet_bh() is scheduled, but I am not so sure about the remaining ones, 
namely:


1. A work function, usbnet_deferred_kevent(), may reschedule 
usbnet_bh(). Looks like the workqueue is only stopped in 
usbnet_disconnect(), so a work item might be processed while 
usbnet_stop() works. Setting dev->flags to 0 makes the work function do 
nothing, by the way. See also the comment in usbnet_stop() about this.


A work item may be placed to this workqueue in a number of ways, by both 
usbnet module and the mini-drivers. It is not too easy to track all 
these situations.


2. rx_complete() and tx_complete() may schedule execution of usbnet_bh() 
as a tasklet or a timer function. These two are URB completion callbacks.


It seems, new Rx and Tx URBs cannot be submitted when usbnet_stop() 
clears dev->flags, indeed. But it does not prevent the completion 
handlers for the previously submitted URBs from running concurrently 
with usbnet_stop(). The latter waits for them to complete (via 
usbnet_terminate_urbs(dev)) but only if FLAG_AVOID_UNLINK_URBS is not 
set in info->flags. rndis_wlan, however, sets this flag for a few 
hardware models. So - no guarantees here as well.


If someone could list the particular bits of dev->flags that should be 
cleared to make sure no deferred call could reschedule usbnet_bh(), 
etc... Well, it would be enough to clear these first and use dev->flags 
= 0 later, after tasklet_kill() and del_timer_sync(). I cannot point out 
these particular bits now.


Besides, it is possible, although unlikely, that new event bits will be 
added to dev->flags in the future. And one will need to keep track of 
these to see if they should be cleared as well. I'd prever to play safer 
for now and clear them all.





The EVENT_NO_RUNTIME_PM bug should definitely be fixed.  Please split
that out as a separate fix.  It's a separate issue, and should be
backported to all maintained stable releases it applies to (anything
from v3.8 and newer)


Yes, that makes sense. However, this fix was originally provided by
Oliver Neukum rather than me, so I would like to hear his opinion as
well first.


If what I write above is correct (please help me verify...), then maybe
it does make sense to do these together anyway.


I think, your suggestion to make it a separate patch is right. Will do 
it in the next version of the patchset, hopefully soon.


Regards,
Eugene

--
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] kernel/sysctl.c: If "count" including the terminating byte '\0' the write system call should retrun success.

2015-08-24 Thread Eric W. Biederman


On August 24, 2015 1:56:13 AM PDT, Sean Fu  wrote:
>when the input argument "count" including the terminating byte "\0",
>The write system call return EINVAL on proc file.
>But it return success on regular file.

Nonsense.  It will write the '\0' to a regular file because it is just data.

Integers in proc are more than data.

So I see no justification for this change.


Eric

>E.g. Writting two bytes ("1\0") to
>"/proc/sys/net/ipv4/conf/eth0/rp_filter".
>write(fd, "1\0", 2) return EINVAL.
>
>Signed-off-by: Sean Fu 
>---
> kernel/sysctl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/kernel/sysctl.c b/kernel/sysctl.c
>index 19b62b5..c2b0594 100644
>--- a/kernel/sysctl.c
>+++ b/kernel/sysctl.c
>@@ -2004,7 +2004,7 @@ static int do_proc_dointvec_conv(bool *negp,
>unsigned long *lvalp,
>return 0;
> }
>
>-static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
>+static const char proc_wspace_sep[] = { ' ', '\t', '\n', '\0' };
>
> static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
>  int write, void __user *buffer,

--
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/


[char-misc 1/2] mei: Fix debugfs filename in error output

2015-08-24 Thread Tomas Winkler
From: "Signed-off-by: Alexander Kuleshov" 

Signed-off-by: Alexander Kuleshov 
Signed-off-by: Tomas Winkler 
---
 drivers/misc/mei/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/mei/debugfs.c b/drivers/misc/mei/debugfs.c
index 4b469cf9e60f..c157f0ba575c 100644
--- a/drivers/misc/mei/debugfs.c
+++ b/drivers/misc/mei/debugfs.c
@@ -213,7 +213,7 @@ int mei_dbgfs_register(struct mei_device *dev, const char 
*name)
f = debugfs_create_file("active", S_IRUSR, dir,
dev, _dbgfs_fops_active);
if (!f) {
-   dev_err(dev->dev, "meclients: registration failed\n");
+   dev_err(dev->dev, "active: registration failed\n");
goto err;
}
f = debugfs_create_file("devstate", S_IRUSR, dir,
-- 
2.4.3

--
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 10/12] mm, page_alloc: Remove MIGRATE_RESERVE

2015-08-24 Thread Mel Gorman
MIGRATE_RESERVE preserves an old property of the buddy allocator that existed
prior to fragmentation avoidance -- min_free_kbytes worth of pages tended to
remain contiguous until the only alternative was to fail the allocation. At the
time it was discovered that high-order atomic allocations relied on this
property so MIGRATE_RESERVE was introduced. A later patch will introduce
an alternative MIGRATE_HIGHATOMIC so this patch deletes MIGRATE_RESERVE
and supporting code so it'll be easier to review. Note that this patch
in isolation may look like a false regression if someone was bisecting
high-order atomic allocation failures.

Signed-off-by: Mel Gorman 
Acked-by: Vlastimil Babka 
---
 include/linux/mmzone.h |  10 +---
 mm/huge_memory.c   |   2 +-
 mm/page_alloc.c| 148 +++--
 mm/vmstat.c|   1 -
 4 files changed, 11 insertions(+), 150 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index aef62cc11c80..cf643539d640 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -39,8 +39,6 @@ enum {
MIGRATE_UNMOVABLE,
MIGRATE_MOVABLE,
MIGRATE_RECLAIMABLE,
-   MIGRATE_PCPTYPES,   /* the number of types on the pcp lists */
-   MIGRATE_RESERVE = MIGRATE_PCPTYPES,
 #ifdef CONFIG_CMA
/*
 * MIGRATE_CMA migration type is designed to mimic the way
@@ -63,6 +61,8 @@ enum {
MIGRATE_TYPES
 };
 
+#define MIGRATE_PCPTYPES (MIGRATE_RECLAIMABLE+1)
+
 #ifdef CONFIG_CMA
 #  define is_migrate_cma(migratetype) unlikely((migratetype) == MIGRATE_CMA)
 #else
@@ -425,12 +425,6 @@ struct zone {
 
const char  *name;
 
-   /*
-* Number of MIGRATE_RESERVE page block. To maintain for just
-* optimization. Protected by zone->lock.
-*/
-   int nr_migrate_reserve_block;
-
 #ifdef CONFIG_MEMORY_ISOLATION
/*
 * Number of isolated pageblock. It is used to solve incorrect
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 36efda9ff8f1..56cfb17169d2 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -113,7 +113,7 @@ static int set_recommended_min_free_kbytes(void)
for_each_populated_zone(zone)
nr_zones++;
 
-   /* Make sure at least 2 hugepages are free for MIGRATE_RESERVE */
+   /* Ensure 2 pageblocks are free to assist fragmentation avoidance */
recommended_min = pageblock_nr_pages * nr_zones * 2;
 
/*
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index aa52a91a7d44..d5ce050ebe4f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -792,7 +792,6 @@ static void free_pcppages_bulk(struct zone *zone, int count,
if (unlikely(has_isolate_pageblock(zone)))
mt = get_pageblock_migratetype(page);
 
-   /* MIGRATE_MOVABLE list may include MIGRATE_RESERVEs */
__free_one_page(page, page_to_pfn(page), zone, 0, mt);
trace_mm_page_pcpu_drain(page, 0, mt);
} while (--to_free && --batch_free && !list_empty(list));
@@ -1390,15 +1389,14 @@ struct page *__rmqueue_smallest(struct zone *zone, 
unsigned int order,
  * the free lists for the desirable migrate type are depleted
  */
 static int fallbacks[MIGRATE_TYPES][4] = {
-   [MIGRATE_UNMOVABLE]   = { MIGRATE_RECLAIMABLE, MIGRATE_MOVABLE, 
MIGRATE_RESERVE },
-   [MIGRATE_RECLAIMABLE] = { MIGRATE_UNMOVABLE,   MIGRATE_MOVABLE, 
MIGRATE_RESERVE },
-   [MIGRATE_MOVABLE] = { MIGRATE_RECLAIMABLE, MIGRATE_UNMOVABLE,   
MIGRATE_RESERVE },
+   [MIGRATE_UNMOVABLE]   = { MIGRATE_RECLAIMABLE, MIGRATE_MOVABLE,   
MIGRATE_TYPES },
+   [MIGRATE_RECLAIMABLE] = { MIGRATE_UNMOVABLE,   MIGRATE_MOVABLE,   
MIGRATE_TYPES },
+   [MIGRATE_MOVABLE] = { MIGRATE_RECLAIMABLE, MIGRATE_UNMOVABLE, 
MIGRATE_TYPES },
 #ifdef CONFIG_CMA
-   [MIGRATE_CMA] = { MIGRATE_RESERVE }, /* Never used */
+   [MIGRATE_CMA] = { MIGRATE_TYPES }, /* Never used */
 #endif
-   [MIGRATE_RESERVE] = { MIGRATE_RESERVE }, /* Never used */
 #ifdef CONFIG_MEMORY_ISOLATION
-   [MIGRATE_ISOLATE] = { MIGRATE_RESERVE }, /* Never used */
+   [MIGRATE_ISOLATE] = { MIGRATE_TYPES }, /* Never used */
 #endif
 };
 
@@ -1572,7 +1570,7 @@ int find_suitable_fallback(struct free_area *area, 
unsigned int order,
*can_steal = false;
for (i = 0;; i++) {
fallback_mt = fallbacks[migratetype][i];
-   if (fallback_mt == MIGRATE_RESERVE)
+   if (fallback_mt == MIGRATE_TYPES)
break;
 
if (list_empty(>free_list[fallback_mt]))
@@ -1651,25 +1649,13 @@ static struct page *__rmqueue(struct zone *zone, 
unsigned int order,
 {
struct page *page;
 
-retry_reserve:
page = __rmqueue_smallest(zone, order, migratetype);
-
-   if (unlikely(!page) && migratetype != 

[char-misc 2/2] mei: fix debugfs files leak on error path

2015-08-24 Thread Tomas Winkler
if dbgfs_dir is not set then debugfs_remove_recursive
is not called on the error path

Signed-off-by: Tomas Winkler 
---
 drivers/misc/mei/debugfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/mei/debugfs.c b/drivers/misc/mei/debugfs.c
index c157f0ba575c..a138d8a27ab5 100644
--- a/drivers/misc/mei/debugfs.c
+++ b/drivers/misc/mei/debugfs.c
@@ -204,6 +204,8 @@ int mei_dbgfs_register(struct mei_device *dev, const char 
*name)
if (!dir)
return -ENOMEM;
 
+   dev->dbgfs_dir = dir;
+
f = debugfs_create_file("meclients", S_IRUSR, dir,
dev, _dbgfs_fops_meclients);
if (!f) {
@@ -228,7 +230,6 @@ int mei_dbgfs_register(struct mei_device *dev, const char 
*name)
dev_err(dev->dev, "allow_fixed_address: registration failed\n");
goto err;
}
-   dev->dbgfs_dir = dir;
return 0;
 err:
mei_dbgfs_deregister(dev);
-- 
2.4.3

--
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 11/12] mm, page_alloc: Reserve pageblocks for high-order atomic allocations on demand

2015-08-24 Thread Mel Gorman
High-order watermark checking exists for two reasons --  kswapd high-order
awareness and protection for high-order atomic requests. Historically the
kernel depended on MIGRATE_RESERVE to preserve min_free_kbytes as high-order
free pages for as long as possible. This patch introduces MIGRATE_HIGHATOMIC
that reserves pageblocks for high-order atomic allocations on demand and
avoids using those blocks for order-0 allocations. This is more flexible
and reliable than MIGRATE_RESERVE was.

A MIGRATE_HIGHORDER pageblock is created when a high-order allocation
request steals a pageblock but limits the total number to 1% of the zone.
Callers that speculatively abuse atomic allocations for long-lived
high-order allocations to access the reserve will quickly fail. Note that
SLUB is currently not such an abuser as it reclaims at least once.  It is
possible that the pageblock stolen has few suitable high-order pages and
will need to steal again in the near future but there would need to be
strong justification to search all pageblocks for an ideal candidate.

The pageblocks are unreserved if an allocation fails after a direct
reclaim attempt.

The watermark checks account for the reserved pageblocks when the allocation
request is not a high-order atomic allocation.

The reserved pageblocks can not be used for order-0 allocations. This may
allow temporary wastage until a failed reclaim reassigns the pageblock. This
is deliberate as the intent of the reservation is to satisfy a limited
number of atomic high-order short-lived requests if the system requires them.

The stutter benchmark was used to evaluate this but while it was running
there was a systemtap script that randomly allocated between 1 high-order
page and 12.5% of memory's worth of order-3 pages using GFP_ATOMIC. This
is much larger than the potential reserve and it does not attempt to be
realistic.  It is intended to stress random high-order allocations from
an unknown source, show that there is a reduction in failures without
introducing an anomaly where atomic allocations are more reliable than
regular allocations.  The amount of memory reserved varied throughout the
workload as reserves were created and reclaimed under memory pressure. The
allocation failures once the workload warmed up were as follows;

4.2-rc5-vanilla 70%
4.2-rc5-atomic-reserve  56%

The failure rate was also measured while building multiple kernels. The
failure rate was 14% but is 6% with this patch applied.

Overall, this is a small reduction but the reserves are small relative to the
number of allocation requests. In early versions of the patch, the failure
rate reduced by a much larger amount but that required much larger reserves
and perversely made atomic allocations seem more reliable than regular 
allocations.

Signed-off-by: Mel Gorman 
---
 include/linux/mmzone.h |   6 ++-
 mm/page_alloc.c| 117 ++---
 mm/vmstat.c|   1 +
 3 files changed, 116 insertions(+), 8 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index cf643539d640..a9805a85940a 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -39,6 +39,8 @@ enum {
MIGRATE_UNMOVABLE,
MIGRATE_MOVABLE,
MIGRATE_RECLAIMABLE,
+   MIGRATE_PCPTYPES,   /* the number of types on the pcp lists */
+   MIGRATE_HIGHATOMIC = MIGRATE_PCPTYPES,
 #ifdef CONFIG_CMA
/*
 * MIGRATE_CMA migration type is designed to mimic the way
@@ -61,8 +63,6 @@ enum {
MIGRATE_TYPES
 };
 
-#define MIGRATE_PCPTYPES (MIGRATE_RECLAIMABLE+1)
-
 #ifdef CONFIG_CMA
 #  define is_migrate_cma(migratetype) unlikely((migratetype) == MIGRATE_CMA)
 #else
@@ -330,6 +330,8 @@ struct zone {
/* zone watermarks, access with *_wmark_pages(zone) macros */
unsigned long watermark[NR_WMARK];
 
+   unsigned long nr_reserved_highatomic;
+
/*
 * We don't know if the memory that we're going to allocate will be 
freeable
 * or/and it will be released eventually, so to avoid totally wasting 
several
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index d5ce050ebe4f..2415f882b89c 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1589,6 +1589,86 @@ int find_suitable_fallback(struct free_area *area, 
unsigned int order,
return -1;
 }
 
+/*
+ * Reserve a pageblock for exclusive use of high-order atomic allocations if
+ * there are no empty page blocks that contain a page with a suitable order
+ */
+static void reserve_highatomic_pageblock(struct page *page, struct zone *zone,
+   unsigned int alloc_order)
+{
+   int mt = get_pageblock_migratetype(page);
+   unsigned long max_managed, flags;
+
+   if (mt == MIGRATE_HIGHATOMIC)
+   return;
+
+   /*
+* Limit the number reserved to 1 pageblock or roughly 1% of a zone.
+* Check is race-prone but harmless.
+*/
+   max_managed = 

Re: [PATCH] irqchip, gicv3-its, numa: Workaround for Cavium ThunderX erratum 23144

2015-08-24 Thread Ganapatrao Kulkarni
Hi Marc,

thanks for the review comments.

On Mon, Aug 24, 2015 at 3:47 PM, Marc Zyngier  wrote:
> Hi Robert,
>
> Just came back from the Seattle madness, so picking up patches in
> reverse order... ;-)
>
> On 22/08/15 14:10, Robert Richter wrote:
>> The patch below adds a workaround for gicv3 in a numa environment. It
>> is on top of my recent gicv3 errata patch submission v4 and Ganapat's
>> arm64 numa patches for devicetree v5.
>>
>> Please comment.
>>
>> Thanks,
>>
>> -Robert
>>
>>
>>
>> From c432820451a46b8d1e299b8bfbfcdcb3b75340e7 Mon Sep 17 00:00:00 2001
>> From: Ganapatrao Kulkarni 
>> Date: Wed, 19 Aug 2015 23:40:05 +0530
>> Subject: [PATCH] irqchip, gicv3-its, numa: Workaround for Cavium ThunderX 
>> erratum
>>  23144
>>
>> This implements a workaround for gicv3-its erratum 23144 applicable
>> for Cavium's ThunderX multinode systems.
>>
>> The erratum fixes the hang of ITS SYNC command by avoiding inter node
>> io and collections/cpu mapping. This fix is only applicable for
>> Cavium's ThunderX dual-socket platforms.
>
> Can you please elaborate on this? I can't see any reference to the SYNC
> command there. Is that a case of an ITS not being able to route LPIs to
> cores on another socket?
we were seeing mapc command failing when we were mapping its of node0
with collections of node1(vice-versa).
we found sync was timing out, which is issued post mapc(also for mapvi
and movi).
Yes this errata limits the routing of inter-node LPIs.

>
> I really need more details to understand this patch (please use short
> sentences, I'm still in a different time zone).
>
>>
>> Signed-off-by: Ganapatrao Kulkarni 
>> [ rric: Reworked errata code, added helper functions, updated commit
>>   message. ]
>>
>> Signed-off-by: Robert Richter 
>> ---
>>  arch/arm64/Kconfig   | 14 +++
>>  drivers/irqchip/irq-gic-common.c |  5 ++--
>>  drivers/irqchip/irq-gic-v3-its.c | 54 
>> ++--
>>  3 files changed, 64 insertions(+), 9 deletions(-)
>>
>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>> index 3809187ed653..b92b7b70b29b 100644
>> --- a/arch/arm64/Kconfig
>> +++ b/arch/arm64/Kconfig
>> @@ -421,6 +421,20 @@ config ARM64_ERRATUM_845719
>>
>> If unsure, say Y.
>>
>> +config CAVIUM_ERRATUM_22375
>> + bool "Cavium erratum 22375, 24313"
>> + depends on NUMA
>> + default y
>> + help
>> + Enable workaround for erratum 22375, 24313.
>> +
>> +config CAVIUM_ERRATUM_23144
>> + bool "Cavium erratum 23144"
>> + depends on NUMA
>> + default y
>> + help
>> + Enable workaround for erratum 23144.
>> +
>>  config CAVIUM_ERRATUM_23154
>>   bool "Cavium erratum 23154: Access to ICC_IAR1_EL1 is not sync'ed"
>>   depends on ARCH_THUNDER
>> diff --git a/drivers/irqchip/irq-gic-common.c 
>> b/drivers/irqchip/irq-gic-common.c
>> index ee789b07f2d1..1dfce64dbdac 100644
>> --- a/drivers/irqchip/irq-gic-common.c
>> +++ b/drivers/irqchip/irq-gic-common.c
>> @@ -24,11 +24,12 @@
>>  void gic_check_capabilities(u32 iidr, const struct gic_capabilities *cap,
>>   void *data)
>>  {
>> - for (; cap->desc; cap++) {
>> + for (; cap->init; cap++) {
>>   if (cap->iidr != (cap->mask & iidr))
>>   continue;
>>   cap->init(data);
>> - pr_info("%s\n", cap->desc);
>> + if (cap->desc)
>> + pr_info("%s\n", cap->desc);
>
> No. I really want to see what errata are applied when I look at a kernel
> log.
sorry, did not understood your comment, it is still printed using cap->desc.
>
>>   }
>>  }
>>
>> diff --git a/drivers/irqchip/irq-gic-v3-its.c 
>> b/drivers/irqchip/irq-gic-v3-its.c
>> index 4bb135721e72..666be39f13a9 100644
>> --- a/drivers/irqchip/irq-gic-v3-its.c
>> +++ b/drivers/irqchip/irq-gic-v3-its.c
>> @@ -43,7 +43,8 @@
>>  #include "irqchip.h"
>>
>>  #define ITS_FLAGS_CMDQ_NEEDS_FLUSHING(1ULL << 0)
>> -#define ITS_FLAGS_CAVIUM_THUNDERX(1ULL << 1)
>> +#define ITS_WORKAROUND_CAVIUM_22375  (1ULL << 1)
>> +#define ITS_WORKAROUND_CAVIUM_23144  (1ULL << 2)
>>
>>  #define RDIST_FLAGS_PROPBASE_NEEDS_FLUSHING  (1 << 0)
>>
>> @@ -76,6 +77,7 @@ struct its_node {
>>   struct list_headits_device_list;
>>   u64 flags;
>>   u32 ite_size;
>> + int numa_node;
>>  };
>>
>>  #define ITS_ITT_ALIGNSZ_256
>> @@ -609,11 +611,18 @@ static void its_eoi_irq(struct irq_data *d)
>>  static int its_set_affinity(struct irq_data *d, const struct cpumask 
>> *mask_val,
>>   bool force)
>>  {
>> - unsigned int cpu = cpumask_any_and(mask_val, cpu_online_mask);
>> + unsigned int cpu;
>>   struct its_device *its_dev = irq_data_get_irq_chip_data(d);
>>   struct its_collection *target_col;
>>   u32 id = its_get_event_id(d);
>>
>> + if (its_dev->its->flags & 

[PATCH 12/12] mm, page_alloc: Only enforce watermarks for order-0 allocations

2015-08-24 Thread Mel Gorman
The primary purpose of watermarks is to ensure that reclaim can always
make forward progress in PF_MEMALLOC context (kswapd and direct reclaim).
These assume that order-0 allocations are all that is necessary for
forward progress.

High-order watermarks serve a different purpose. Kswapd had no high-order
awareness before they were introduced (https://lkml.org/lkml/2004/9/5/9).
This was particularly important when there were high-order atomic requests.
The watermarks both gave kswapd awareness and made a reserve for those
atomic requests.

There are two important side-effects of this. The most important is that
a non-atomic high-order request can fail even though free pages are available
and the order-0 watermarks are ok. The second is that high-order watermark
checks are expensive as the free list counts up to the requested order must
be examined.

With the introduction of MIGRATE_HIGHATOMIC it is no longer necessary to
have high-order watermarks. Kswapd and compaction still need high-order
awareness which is handled by checking that at least one suitable high-order
page is free.

With the patch applied, there was little difference in the allocation
failure rates as the atomic reserves are small relative to the number of
allocation attempts. The expected impact is that there will never be an
allocation failure report that shows suitable pages on the free lists.

The one potential side-effect of this is that in a vanilla kernel, the
watermark checks may have kept a free page for an atomic allocation. Now,
we are 100% relying on the HighAtomic reserves and an early allocation to
have allocated them.  If the first high-order atomic allocation is after
the system is already heavily fragmented then it'll fail.

Signed-off-by: Mel Gorman 
---
 mm/page_alloc.c | 38 --
 1 file changed, 24 insertions(+), 14 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2415f882b89c..35dc578730d1 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2280,8 +2280,10 @@ static inline bool should_fail_alloc_page(gfp_t 
gfp_mask, unsigned int order)
 #endif /* CONFIG_FAIL_PAGE_ALLOC */
 
 /*
- * Return true if free pages are above 'mark'. This takes into account the 
order
- * of the allocation.
+ * Return true if free base pages are above 'mark'. For high-order checks it
+ * will return true of the order-0 watermark is reached and there is at least
+ * one free page of a suitable size. Checking now avoids taking the zone lock
+ * to check in the allocation paths if no pages are free.
  */
 static bool __zone_watermark_ok(struct zone *z, unsigned int order,
unsigned long mark, int classzone_idx, int alloc_flags,
@@ -2289,7 +2291,7 @@ static bool __zone_watermark_ok(struct zone *z, unsigned 
int order,
 {
long min = mark;
int o;
-   long free_cma = 0;
+   const bool atomic = (alloc_flags & ALLOC_HARDER);
 
/* free_pages may go negative - that's OK */
free_pages -= (1 << order) - 1;
@@ -2301,7 +2303,7 @@ static bool __zone_watermark_ok(struct zone *z, unsigned 
int order,
 * If the caller is not atomic then discount the reserves. This will
 * over-estimate how the atomic reserve but it avoids a search
 */
-   if (likely(!(alloc_flags & ALLOC_HARDER)))
+   if (likely(!atomic))
free_pages -= z->nr_reserved_highatomic;
else
min -= min / 4;
@@ -2309,22 +2311,30 @@ static bool __zone_watermark_ok(struct zone *z, 
unsigned int order,
 #ifdef CONFIG_CMA
/* If allocation can't use CMA areas don't use free CMA pages */
if (!(alloc_flags & ALLOC_CMA))
-   free_cma = zone_page_state(z, NR_FREE_CMA_PAGES);
+   free_pages -= zone_page_state(z, NR_FREE_CMA_PAGES);
 #endif
 
-   if (free_pages - free_cma <= min + z->lowmem_reserve[classzone_idx])
+   if (free_pages <= min + z->lowmem_reserve[classzone_idx])
return false;
-   for (o = 0; o < order; o++) {
-   /* At the next order, this order's pages become unavailable */
-   free_pages -= z->free_area[o].nr_free << o;
 
-   /* Require fewer higher order pages to be free */
-   min >>= 1;
+   /* order-0 watermarks are ok */
+   if (!order)
+   return true;
+
+   /* Check at least one high-order page is free */
+   for (o = order; o < MAX_ORDER; o++) {
+   struct free_area *area = >free_area[o];
+   int mt;
+
+   if (atomic && area->nr_free)
+   return true;
 
-   if (free_pages <= min)
-   return false;
+   for (mt = 0; mt < MIGRATE_PCPTYPES; mt++) {
+   if (!list_empty(>free_list[mt]))
+   return true;
+   }
}
-   return true;
+   return false;
 }
 
 bool zone_watermark_ok(struct zone *z, unsigned 

Re: [PATCH v3 1/1] USB:option:add ZTE PIDs

2015-08-24 Thread Johan Hovold
On Mon, Aug 24, 2015 at 09:51:33AM +0200, Bjørn Mork wrote:
> Johan Hovold  writes:
> > On Wed, Aug 19, 2015 at 08:51:17AM -0700, Liu.Zhao wrote:
> >> 
> >>  #define BENQ_VENDOR_ID0x04a5
> >>  #define BENQ_PRODUCT_H10  0x4068
> >> @@ -544,6 +548,14 @@ static const struct option_blacklist_info 
> >> zte_mc2716_z_blacklist = {
> >>.sendsetup = BIT(1) | BIT(2) | BIT(3),
> >>  };
> >>  
> >> +static const struct option_blacklist_info 
> >> zte_me3620andzm8620_xl_blacklist = {
> >> +  .reserved = BIT(3) | BIT(4) | BIT(5),
> >> +};
> >
> > Use two structs for this: zte_me3620_blacklist and zm8620_xl_blacklist
> > even if they reserve the same ports.
> 
> Why?

To avoid including every device family in the symbol name (and we
already have duplicate blacklist definitions).

> Wouldn't it be better to merge all identical lists and give them
> structured names describing their contents instead?

It certainly would.

> E.g.
> 
>  static const struct option_blacklist_info bi_s0001_r = {
> .sendsetup = BIT(0) | BIT(1),
>  };
> 
>  static const struct option_blacklist_info bi_s0001_r04 = {
> .sendsetup = BIT(0) | BIT(1),
> .reserved = BIT(4),
>  };
> 
>  static const struct option_blacklist_info bi_s_r030405 =  {
>   .reserved = BIT(3) | BIT(4) | BIT(5),
>  };
> 
> 
> etc.  Or some other naming scheme.

Perhaps bi_s_r (e.g. bi_s3_r0, bi_s3_r10, and
bi_s0_r38 for the above) would be too compact?

> I don't see the point of having lots of identical structs just to be
> able to name them after some rarely meaningful marketing name.  Many
> vendors recycle their pids, making this completely futile.

I agree. Let's just decide on a naming scheme first.

Johan
--
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/1] of: to support binding numa node to root subnode(non-bus)

2015-08-24 Thread Zhen Lei
If use of_platform_populate to scan dt-nodes and add devices, the
subnode of root(such as /smmu), when being scanned and invoke
of_device_add, the ofdev->dev.parent is always equal _bus. So
that, function set_dev_node will not be called. And in device_add,
dev_to_node(parent) always return NUMA_NO_NODE.

Signed-off-by: Zhen Lei 
---
 drivers/base/core.c | 2 +-
 drivers/of/device.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index dafae6d..5df4f46b 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1017,7 +1017,7 @@ int device_add(struct device *dev)
dev->kobj.parent = kobj;

/* use parent numa_node */
-   if (parent)
+   if (parent && (parent != _bus))
set_dev_node(dev, dev_to_node(parent));

/* first, register with generic layer. */
diff --git a/drivers/of/device.c b/drivers/of/device.c
index 8b91ea2..96ebece 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -63,7 +63,7 @@ int of_device_add(struct platform_device *ofdev)
/* device_add will assume that this device is on the same node as
 * the parent. If there is no parent defined, set the node
 * explicitly */
-   if (!ofdev->dev.parent)
+   if (!ofdev->dev.parent || (ofdev->dev.parent == _bus))
set_dev_node(>dev, of_node_to_nid(ofdev->dev.of_node));

return device_add(>dev);
--
2.5.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] i2c: allow specifying separate wakeup interrupt in device tree

2015-08-24 Thread Wolfram Sang

> > When reviewing V2, I wasn't comfortable with just guessing what the old
> > code means. So, I did some digging and found:
> >
> > https://lkml.org/lkml/2008/8/10/204
> >
> > Quoting the interesting paragraph from David Brownell:
> >
> > ===
> >
> > Better would be to preserve any existing settings:
> >
> > if (!device_can_wakeup(>dev))
> > device_init_wakeup(...)
> > That way the userspace policy setting is preserved unless the
> > device itself gets removed ... instead of being clobbered by
> > the simple act of (re)probing a driver.
> >
> >> > +   device_init_wakeup(>dev, client->flags &
> >> > I2C_CLIENT_WAKE);
> >
> > ===
> >
> > I have to admit that I am not familiar with device wakeup handling and
> > especially its userspace policies. Can you double check that your V2
> > meets the above intention?
> 
> No it does not; it explicitly resets the wakeup flag. Note that the
> original code was not quite right in that regard either: it would
> preserve wakeup flag set by userspace upon driver rebinding; but it
> would re-arm the wakeup flag if it was disabled by userspace.
> 
> I believe that resetting the flag upon re-binding the driver is proper
> behavior as the driver is responsible for setting up and handling
> wakeups.

Okay, that meets my idea of how this should work. I rephrased the above
paragraph slightly and added it to the commit message of V2.

Thanks,

   Wolfram



signature.asc
Description: Digital signature


Re: [PATCH v2] i2c: allow specifying separate wakeup interrupt in device tree

2015-08-24 Thread Wolfram Sang
On Mon, Aug 17, 2015 at 11:52:51PM -0700, Dmitry Torokhov wrote:
> Instead of having each i2c driver individually parse device tree data in
> case it or platform supports separate wakeup interrupt, and handle
> enabling and disabling wakeup interrupts in their power management
> routines, let's have i2c core do that for us.
> 
> Platforms wishing to specify separate wakeup interrupt for the device
> should use named interrupt syntax in their DTSes:
> 
>   interrupt-parent = <>;
>   interrupts = <5 0>, <6 0>;
>   interrupt-names = "irq", "wakeup";
> 
> This patch is inspired by work done by Vignesh R  for
> pixcir_i2c_ts driver.
> 
> Signed-off-by: Dmitry Torokhov 

Applied to for-next, thanks!



signature.asc
Description: Digital signature


Re: [PATCH 04/12] mm, page_alloc: Only check cpusets when one exists that can be mem-controlled

2015-08-24 Thread Vlastimil Babka

On 08/24/2015 02:09 PM, Mel Gorman wrote:

David Rientjes correctly pointed out that the "root cpuset may not exclude
mems on the system so, even if mounted, there's no need to check or be
worried about concurrent change when there is only one cpuset".

The three checks for cpusets_enabled() care whether a cpuset exists that
can limit memory, not that cpuset is enabled as such. This patch replaces
cpusets_enabled() with cpusets_mems_enabled() which checks if at least one
cpuset exists that can limit memory and updates the appropriate call sites.

Signed-off-by: Mel Gorman 
---
  include/linux/cpuset.h | 16 +---
  mm/page_alloc.c|  2 +-
  2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 6eb27cb480b7..1e823870987e 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -17,10 +17,6 @@
  #ifdef CONFIG_CPUSETS

  extern struct static_key cpusets_enabled_key;
-static inline bool cpusets_enabled(void)
-{
-   return static_key_false(_enabled_key);
-}

  static inline int nr_cpusets(void)
  {
@@ -28,6 +24,12 @@ static inline int nr_cpusets(void)
return static_key_count(_enabled_key) + 1;
  }

+/* Returns true if a cpuset exists that can set cpuset.mems */
+static inline bool cpusets_mems_enabled(void)
+{
+   return nr_cpusets() > 1;
+}
+


Hm, but this loses the benefits of static key branches?
How about something like:

  if (static_key_false(_enabled_key))
return nr_cpusets() > 1
  else
return false;




  static inline void cpuset_inc(void)
  {
static_key_slow_inc(_enabled_key);
@@ -104,7 +106,7 @@ extern void cpuset_print_task_mems_allowed(struct 
task_struct *p);
   */
  static inline unsigned int read_mems_allowed_begin(void)
  {
-   if (!cpusets_enabled())
+   if (!cpusets_mems_enabled())
return 0;

return read_seqcount_begin(>mems_allowed_seq);
@@ -118,7 +120,7 @@ static inline unsigned int read_mems_allowed_begin(void)
   */
  static inline bool read_mems_allowed_retry(unsigned int seq)
  {
-   if (!cpusets_enabled())
+   if (!cpusets_mems_enabled())
return false;


Actually I doubt it's much of benefit for these usages, even if the 
static key benefits are restored. If there's a single root cpuset, we 
would check the seqlock prior to this patch, now we'll check static key 
value (which should have the same cost?). With >1 cpusets, we would 
check seqlock prior to this patch, now we'll check static key value 
*and* the seqlock...




return read_seqcount_retry(>mems_allowed_seq, seq);
@@ -139,7 +141,7 @@ static inline void set_mems_allowed(nodemask_t nodemask)

  #else /* !CONFIG_CPUSETS */

-static inline bool cpusets_enabled(void) { return false; }
+static inline bool cpusets_mems_enabled(void) { return false; }

  static inline int cpuset_init(void) { return 0; }
  static inline void cpuset_init_smp(void) {}
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 62ae28d8ae8d..2c1c3bf54d15 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2470,7 +2470,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int 
order, int alloc_flags,
if (IS_ENABLED(CONFIG_NUMA) && zlc_active &&
!zlc_zone_worth_trying(zonelist, z, allowednodes))
continue;
-   if (cpusets_enabled() &&
+   if (cpusets_mems_enabled() &&
(alloc_flags & ALLOC_CPUSET) &&
!cpuset_zone_allowed(zone, gfp_mask))
continue;


Here the benefits are less clear. I guess cpuset_zone_allowed() is 
potentially costly...


Heck, shouldn't we just start the static key on -1 (if possible), so 
that it's enabled only when there's 2+ cpusets?

--
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 01/10] irqchip: irq-mips-gic: export gic_send_ipi

2015-08-24 Thread Qais Yousef
Some drivers might require to send ipi to other cores. So export it.
This will be used later by AXD driver.

Signed-off-by: Qais Yousef 
Cc: Thomas Gleixner 
Cc: Jason Cooper 
Cc: Marc Zyngier 
Cc: linux-kernel@vger.kernel.org
Cc: linux-m...@linux-mips.org
---
 drivers/irqchip/irq-mips-gic.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c
index ff4be0515a0d..fc6fd506cd7e 100644
--- a/drivers/irqchip/irq-mips-gic.c
+++ b/drivers/irqchip/irq-mips-gic.c
@@ -227,6 +227,7 @@ void gic_send_ipi(unsigned int intr)
 {
gic_write(GIC_REG(SHARED, GIC_SH_WEDGE), GIC_SH_WEDGE_SET(intr));
 }
+EXPORT_SYMBOL(gic_send_ipi);
 
 int gic_get_c0_compare_int(void)
 {
-- 
2.1.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 00/10] Add support for img AXD audio hardware decoder

2015-08-24 Thread Qais Yousef
This patch series adds AXD Alsa Compress Offload SoC driver.

AXD is an audio hardware based on MIPS architecture that supports decoding,
encoding, GEQ, resampling, mixing and synchronisation. At the moment only
decoding support is added in hope to add the rest of the functionality on
top of that once this is accepted.

I divided the files into separate patches by functionality in hope it'll
make the reviewing process easier. Worth noting that a lot of the cmd interface
helper funtions in patch 7 are not used yet but will be as support for more
functionality is added later.

At the moment this code has been tested on Pistachio SoC using gstreamer patched
with the code in this link

https://bugzilla.gnome.org/show_bug.cgi?id=743192

Qais Yousef (10):
  irqchip: irq-mips-gic: export gic_send_ipi
  dt: add img,axd.txt device tree binding document
  ALSA: add AXD Audio Processing IP alsa driver
  ALSA: axd: add fw binary header manipulation files
  ALSA: axd: add buffers manipulation files
  ALSA: axd: add basic files for sending/receiving axd cmds
  ALSA: axd: add cmd interface helper functions
  ALSA: axd: add low level AXD platform setup files
  ALSA: axd: add alsa compress offload operations
  ALSA: axd: add Makefile

 .../devicetree/bindings/sound/img,axd.txt  |   34 +
 drivers/irqchip/irq-mips-gic.c |1 +
 sound/soc/Kconfig  |1 +
 sound/soc/Makefile |1 +
 sound/soc/img/Kconfig  |   11 +
 sound/soc/img/Makefile |1 +
 sound/soc/img/axd/Makefile |   13 +
 sound/soc/img/axd/axd_alsa_ops.c   |  211 ++
 sound/soc/img/axd/axd_api.h|  649 
 sound/soc/img/axd/axd_buffers.c|  243 ++
 sound/soc/img/axd/axd_buffers.h|   74 +
 sound/soc/img/axd/axd_cmds.c   |  102 +
 sound/soc/img/axd/axd_cmds.h   |  532 
 sound/soc/img/axd/axd_cmds_config.c| 1235 
 sound/soc/img/axd/axd_cmds_decoder_config.c|  422 +++
 sound/soc/img/axd/axd_cmds_info.c  | 1249 
 sound/soc/img/axd/axd_cmds_internal.c  | 3264 
 sound/soc/img/axd/axd_cmds_internal.h  |  317 ++
 sound/soc/img/axd/axd_cmds_pipes.c | 1387 +
 sound/soc/img/axd/axd_hdr.c|   64 +
 sound/soc/img/axd/axd_hdr.h|   24 +
 sound/soc/img/axd/axd_module.c |  742 +
 sound/soc/img/axd/axd_module.h |   83 +
 sound/soc/img/axd/axd_platform.h   |   35 +
 sound/soc/img/axd/axd_platform_mips.c  |  416 +++
 25 files changed, 1 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/img,axd.txt
 create mode 100644 sound/soc/img/Kconfig
 create mode 100644 sound/soc/img/Makefile
 create mode 100644 sound/soc/img/axd/Makefile
 create mode 100644 sound/soc/img/axd/axd_alsa_ops.c
 create mode 100644 sound/soc/img/axd/axd_api.h
 create mode 100644 sound/soc/img/axd/axd_buffers.c
 create mode 100644 sound/soc/img/axd/axd_buffers.h
 create mode 100644 sound/soc/img/axd/axd_cmds.c
 create mode 100644 sound/soc/img/axd/axd_cmds.h
 create mode 100644 sound/soc/img/axd/axd_cmds_config.c
 create mode 100644 sound/soc/img/axd/axd_cmds_decoder_config.c
 create mode 100644 sound/soc/img/axd/axd_cmds_info.c
 create mode 100644 sound/soc/img/axd/axd_cmds_internal.c
 create mode 100644 sound/soc/img/axd/axd_cmds_internal.h
 create mode 100644 sound/soc/img/axd/axd_cmds_pipes.c
 create mode 100644 sound/soc/img/axd/axd_hdr.c
 create mode 100644 sound/soc/img/axd/axd_hdr.h
 create mode 100644 sound/soc/img/axd/axd_module.c
 create mode 100644 sound/soc/img/axd/axd_module.h
 create mode 100644 sound/soc/img/axd/axd_platform.h
 create mode 100644 sound/soc/img/axd/axd_platform_mips.c

Cc: Thomas Gleixner 
Cc: Jason Cooper 
Cc: Marc Zyngier 
Cc: linux-kernel@vger.kernel.org
Cc: linux-m...@linux-mips.org
Cc: Rob Herring 
Cc: Pawel Moll 
Cc: Mark Rutland 
Cc: Ian Campbell 
Cc: Kumar Gala 
Cc: devicet...@vger.kernel.org
Cc: Liam Girdwood 
Cc: Mark Brown 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
-- 
2.1.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 02/10] dt: add img,axd.txt device tree binding document

2015-08-24 Thread Qais Yousef
Signed-off-by: Qais Yousef 
Cc: Rob Herring 
Cc: Pawel Moll 
Cc: Mark Rutland 
Cc: Ian Campbell 
Cc: Kumar Gala 
Cc: devicet...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 .../devicetree/bindings/sound/img,axd.txt  | 34 ++
 1 file changed, 34 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/img,axd.txt

diff --git a/Documentation/devicetree/bindings/sound/img,axd.txt 
b/Documentation/devicetree/bindings/sound/img,axd.txt
new file mode 100644
index ..6a8764a79d01
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/img,axd.txt
@@ -0,0 +1,34 @@
+* AXD Audio Processing IP Binding *
+
+Required properties:
+- compatible: "img,axd"
+- clocks: phandle for the clock that drives AXD.
+- interrupts: the GIC interrupt where AXD is connected
+- gic-irq: it takes two non-zero values, the first one is the host hwirq and
+   the second one is AXD's. Host's hwirq should match the value in
+   interrupts.
+
+Optional properties:
+- vpe: VPE number on which AXD should start. Must be provided if AXD is
+   running as a single VPE along Linux on the same core.
+   It can't be VPE0.
+   The VPE will be offlined before AXD is loaded.
+- inbuf-size: size of shared input buffers area. By default it's 0x7800 bytes.
+- outbuf-size: size of shared output buffers area. By default it's 0x3c000 
bytes.
+
+
+Example:
+
+   axdclk: axdclk@400M {
+   #clock-cells = <0>;
+   compatible = "fixed-clock";
+   clock-frequency = <4>;
+   };
+
+   axd {
+   compatible = "img,axd";
+   clocks = <>;
+   interrupts = <36 IRQ_TYPE_EDGE_RISING>;
+   gic-irq = <36 37>;
+   vpe = <1>;
+   };
-- 
2.1.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 03/10] ALSA: add AXD Audio Processing IP alsa driver

2015-08-24 Thread Qais Yousef
AXD is Audio Processing IP by Imagination Technologies that can
decode multiple file formats and play them back.
We use alsa compress offload API to represent our audio driver.

This patch adds defs and initialisation files.

Signed-off-by: Qais Yousef 
Cc: Liam Girdwood 
Cc: Mark Brown 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: linux-kernel@vger.kernel.org
---
 sound/soc/img/axd/axd_api.h| 649 +++
 sound/soc/img/axd/axd_module.c | 742 +
 sound/soc/img/axd/axd_module.h |  83 +
 3 files changed, 1474 insertions(+)
 create mode 100644 sound/soc/img/axd/axd_api.h
 create mode 100644 sound/soc/img/axd/axd_module.c
 create mode 100644 sound/soc/img/axd/axd_module.h

diff --git a/sound/soc/img/axd/axd_api.h b/sound/soc/img/axd/axd_api.h
new file mode 100644
index ..316b7bcf8626
--- /dev/null
+++ b/sound/soc/img/axd/axd_api.h
@@ -0,0 +1,649 @@
+/*
+ *  Copyright (C) 2011-2015 Imagination Technologies Ltd.
+ *
+ * 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.
+ *
+ *  Main API to the AXD for access from the host.
+ */
+#ifndef AXD_API_H_
+#define AXD_API_H_
+
+#include 
+
+
+#define THREAD_COUNT 4
+#define AXD_MAX_PIPES 3
+
+
+#define AXD_DESCRIPTOR_READY_BIT   0x8000
+#define AXD_DESCRIPTOR_INUSE_BIT   0x4000
+#define AXD_DESCRIPTOR_EOS_BIT 0x2000
+#define AXD_DESCRIPTOR_SIZE_MASK   0x
+
+struct axd_buffer_desc {
+   uint32_t status_size;
+   uint32_t data_ptr;
+   uint32_t pts_high;
+   uint32_t pts_low;
+};
+
+#define AXD_INPUT_DESCRIPTORS 10
+struct axd_input {
+   struct axd_buffer_desc descriptors[AXD_INPUT_DESCRIPTORS];
+};
+
+#define AXD_OUTPUT_DESCRIPTORS 10
+struct axd_output {
+   struct axd_buffer_desc descriptors[AXD_OUTPUT_DESCRIPTORS];
+};
+
+struct axd_ctrlbuf_item {
+   uint32_t reg;
+   uint32_t val;
+};
+
+/**
+ * struct axd_memory_map - axd memory mapped region
+ * @kick:  kick register holds the type of kick to process
+ * @int_status:interrupt status register
+ * @int_mask:  interrupt mask register
+ * @in_kick_count: array of number of input kicks to process
+ * @in_int_count:  array of number of input interrupts to process
+ * @out_kick_count:array of number of output kicks to process
+ * @out_int_count: array of number of output interrupts to process
+ * @control_command:   this register contains the command type to process
+ * @control_data:  this register contains the command data to process
+ * @pc:starting pc value of each hardware thread
+ * @error: last error value
+ * @gic_irq:   which gic irqs to use for host and axd in this format:
+ * host_gic_irq[31:16]:axd_gic_irq[15:0]
+ * @freq:  count/compare clock frequency in MHz
+ * @input: array of struct axd_input which holds the descriptors
+ * @output:array of struct axd_output which holds the descriptors
+ * @ctrlbuf_size:  size of control buffer used to group multiple
+ * configurations changes into a single request
+ * @ctrlbuf_ctrl:  position of ctrlbuf requests
+ * @ctrlbuf:   the actual control buffer used to group requests
+ * size of which is defined by the firmware
+ */
+struct axd_memory_map {
+   uint32_t kick;
+   uint32_t int_status;
+   uint32_t int_mask;
+   uint32_t in_kick_count[AXD_MAX_PIPES];
+   uint32_t in_int_count[AXD_MAX_PIPES];
+   uint32_t out_kick_count[AXD_MAX_PIPES];
+   uint32_t out_int_count[AXD_MAX_PIPES];
+   uint32_t control_command;
+   uint32_t control_data;
+   uint32_t pc[THREAD_COUNT];
+   uint32_t error;
+   uint32_t gic_irq;
+   uint32_t freq;
+   uint32_t reserved01[0x04];
+   struct axd_input input[AXD_MAX_PIPES];
+   struct axd_output output[AXD_MAX_PIPES];
+   uint32_t reserved02[40];
+   uint32_t reserved03[12];
+   uint32_t ctrlbuf_size;
+   uint32_t ctrlbuf_ctrl;
+   struct axd_ctrlbuf_item ctrlbuf[];
+};
+
+#define AXD_ANY_KICK_BIT   0x8000
+#define AXD_KICK_MASK  0x000F
+#define AXD_KICK_CTRL_BIT  0x0001
+#define AXD_KICK_DATA_IN_BIT   0x0002
+#define AXD_KICK_DATA_OUT_BIT  0x0004
+
+#define AXD_INT_KICK_DONE  0x0001
+#define AXD_INT_DATAIN 0x0002
+#define AXD_INT_DATAOUT0x0004
+#define AXD_INT_CTRL   0x0008
+#define AXD_INT_ERROR  0x0010
+
+enum 

[PATCH 09/10] ALSA: axd: add alsa compress offload operations

2015-08-24 Thread Qais Yousef
Add implementation of alsa compress offload operations.
At the moment we only support playback only.

Signed-off-by: Qais Yousef 
Cc: Liam Girdwood 
Cc: Mark Brown 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: linux-kernel@vger.kernel.org
---
 sound/soc/img/axd/axd_alsa_ops.c | 211 +++
 1 file changed, 211 insertions(+)
 create mode 100644 sound/soc/img/axd/axd_alsa_ops.c

diff --git a/sound/soc/img/axd/axd_alsa_ops.c b/sound/soc/img/axd/axd_alsa_ops.c
new file mode 100644
index ..91e17119b306
--- /dev/null
+++ b/sound/soc/img/axd/axd_alsa_ops.c
@@ -0,0 +1,211 @@
+/*
+ * Copyright (C) 2015 Imagination Technologies Ltd.
+ *
+ * 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.
+ *
+ * AXD ALSA Compressed ops
+ */
+#include 
+#include 
+
+#include "axd_cmds.h"
+#include "axd_module.h"
+
+static struct axd_dev *get_axd_from_cstream(struct snd_compr_stream *cstream)
+{
+   struct snd_soc_pcm_runtime *rtd = cstream->private_data;
+   return snd_soc_platform_get_drvdata(rtd->platform);
+}
+
+static int copied_total;
+
+static int axd_compr_open(struct snd_compr_stream *cstream)
+{
+   struct axd_dev *axd = get_axd_from_cstream(cstream);
+
+   axd_cmd_output_set_sink(>cmd, 0, 1);
+   return axd_cmd_inpipe_start(>cmd, 0);
+}
+
+static int axd_compr_free(struct snd_compr_stream *cstream)
+{
+   struct axd_dev *axd = get_axd_from_cstream(cstream);
+
+   axd_cmd_inpipe_stop(>cmd, 0);
+   copied_total = 0;
+
+   return 0;
+}
+
+static int axd_compr_set_params(struct snd_compr_stream *cstream,
+   struct snd_compr_params *params)
+{
+   int ret;
+   struct axd_dev *axd = get_axd_from_cstream(cstream);
+
+   ret = axd_cmd_input_set_decoder_params(>cmd, 0, >codec);
+   if (ret)
+   return -EINVAL;
+   return 0;
+}
+
+static int axd_compr_get_params(struct snd_compr_stream *cstream,
+   struct snd_codec *params)
+{
+   int ret;
+   struct axd_dev *axd = get_axd_from_cstream(cstream);
+
+   ret = axd_cmd_input_get_decoder_params(>cmd, 0, params);
+   if (ret)
+   return -EIO;
+   return 0;
+}
+
+static int axd_compr_trigger(struct snd_compr_stream *cstream, int cmd)
+{
+   struct axd_dev *axd = get_axd_from_cstream(cstream);
+
+   if (cmd == SND_COMPR_TRIGGER_PARTIAL_DRAIN ||
+   cmd == SND_COMPR_TRIGGER_DRAIN) {
+   /* stop to send EOS which will cause the stream to be drained */
+   axd_cmd_inpipe_stop(>cmd, 0);
+
+   /*
+* start again, repeating if EAGAIN is returned meaning we're
+* being drained
+*/
+   while (axd_cmd_inpipe_start(>cmd, 0) == -EAGAIN)
+   cpu_relax();
+
+   copied_total = 0;
+   }
+   return 0;
+}
+
+static int axd_compr_pointer(struct snd_compr_stream *cstream,
+struct snd_compr_tstamp *tstamp)
+{
+   tstamp->copied_total = copied_total;
+   return 0;
+}
+
+static int axd_compr_copy(struct snd_compr_stream *cstream, char __user *buf,
+ size_t count)
+{
+   struct axd_dev *axd = get_axd_from_cstream(cstream);
+   int ret;
+
+   ret = axd_cmd_send_buffer(>cmd, 0, buf, count);
+   if (ret < 0) {
+   dev_err(axd->dev, "failed to write buffer %d\n", ret);
+   return ret;
+   }
+   copied_total += ret;
+
+   return ret;
+}
+
+static int axd_compr_get_caps(struct snd_compr_stream *cstream,
+ struct snd_compr_caps *caps)
+{
+   struct axd_dev *axd = get_axd_from_cstream(cstream);
+
+   caps->min_fragment_size = 1024*2;
+   caps->max_fragment_size = 1024*2;
+   caps->min_fragments= 1;
+   caps->max_fragments= 5;
+
+   axd_cmd_get_decoders(>cmd, caps);
+
+   return 0;
+}
+
+static int axd_compr_get_codec_caps(struct snd_compr_stream *cstream,
+   struct snd_compr_codec_caps *codec)
+{
+   switch (codec->codec) {
+   case SND_AUDIOCODEC_PCM:
+   codec->num_descriptors = 1;
+   codec->descriptor[0].max_ch = 2;
+   codec->descriptor[0].sample_rates[0] = 96000;
+   codec->descriptor[0].sample_rates[1] = 64000;
+   codec->descriptor[0].sample_rates[2] = 48000;
+   codec->descriptor[0].sample_rates[3] = 44100;
+   codec->descriptor[0].sample_rates[4] = 32000;
+   

[PATCH 04/10] ALSA: axd: add fw binary header manipulation files

2015-08-24 Thread Qais Yousef
These files provide functions to get information from the fw binary
header.

Signed-off-by: Qais Yousef 
Cc: Liam Girdwood 
Cc: Mark Brown 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: linux-kernel@vger.kernel.org
---
 sound/soc/img/axd/axd_hdr.c | 64 +
 sound/soc/img/axd/axd_hdr.h | 24 +
 2 files changed, 88 insertions(+)
 create mode 100644 sound/soc/img/axd/axd_hdr.c
 create mode 100644 sound/soc/img/axd/axd_hdr.h

diff --git a/sound/soc/img/axd/axd_hdr.c b/sound/soc/img/axd/axd_hdr.c
new file mode 100644
index ..7be3d11df120
--- /dev/null
+++ b/sound/soc/img/axd/axd_hdr.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2011-2015 Imagination Technologies Ltd.
+ *
+ * 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.
+ *
+ * Helper functions to parse AXD Header in the firmware binary.
+ */
+#include 
+
+#include "axd_api.h"
+#include "axd_hdr.h"
+
+static struct axd_hdr *hdr;
+
+static void dump_hdr(void)
+{
+   unsigned int offset = 0;
+   unsigned long address = (unsigned long)hdr;
+
+   pr_debug("header <0x%08lX>:\n", address);
+   while (offset <= sizeof(*hdr)) {
+   pr_debug("0x%08X\t", *(unsigned int *)(address+offset));
+   offset += 4;
+   if ((offset % (4*4)) == 0)
+   pr_debug("\n");
+   }
+   pr_debug("\n");
+}
+
+void axd_hdr_init(unsigned long address)
+{
+   hdr = (struct axd_hdr *)address;
+   dump_hdr();
+}
+
+unsigned long axd_hdr_get_pc(unsigned int thread)
+{
+   if (thread >= THREAD_COUNT)
+   return -1;
+   return hdr->thread_pc[thread];
+}
+
+unsigned long axd_hdr_get_cmdblock_offset(void)
+{
+   pr_debug("cmdblock_offset = 0x%08X\n", hdr->cmd_block_offset);
+   return hdr->cmd_block_offset;
+}
+
+char *axd_hdr_get_build_str(void)
+{
+   return hdr->build_str;
+}
+
+unsigned long axd_hdr_get_log_offset(void)
+{
+   return hdr->log_offset;
+}
diff --git a/sound/soc/img/axd/axd_hdr.h b/sound/soc/img/axd/axd_hdr.h
new file mode 100644
index ..dc0b1e3be5a2
--- /dev/null
+++ b/sound/soc/img/axd/axd_hdr.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2011-2015 Imagination Technologies Ltd.
+ *
+ * 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.
+ *
+ * Helper functions to parse AXD Header in the firmware binary
+ */
+#ifndef AXD_HDR_H_
+#define AXD_HDR_H_
+
+void axd_hdr_init(unsigned long address);
+unsigned long axd_hdr_get_pc(unsigned int thread);
+unsigned long axd_hdr_get_cmdblock_offset(void);
+char *axd_hdr_get_build_str(void);
+unsigned long axd_hdr_get_log_offset(void);
+
+#endif /* AXD_HDR_H_ */
-- 
2.1.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 08/10] ALSA: axd: add low level AXD platform setup files

2015-08-24 Thread Qais Yousef
At the moment AXD runs on MIPS cores only. These files provide
basic functionality to prepare AXD f/w to bootstrap itself and
do low level interrupt/kick when being initialised from a mips
core.

Signed-off-by: Qais Yousef 
Cc: Liam Girdwood 
Cc: Mark Brown 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: linux-kernel@vger.kernel.org
---
 sound/soc/img/axd/axd_platform.h  |  35 +++
 sound/soc/img/axd/axd_platform_mips.c | 416 ++
 2 files changed, 451 insertions(+)
 create mode 100644 sound/soc/img/axd/axd_platform.h
 create mode 100644 sound/soc/img/axd/axd_platform_mips.c

diff --git a/sound/soc/img/axd/axd_platform.h b/sound/soc/img/axd/axd_platform.h
new file mode 100644
index ..f9cc3c308a4a
--- /dev/null
+++ b/sound/soc/img/axd/axd_platform.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2011-2015 Imagination Technologies Ltd.
+ *
+ * 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.
+ *
+ * Platform Specific helper functions.
+ */
+#ifndef AXD_PLATFORM_H_
+#define AXD_PLATFORM_H_
+#include "axd_module.h"
+
+void axd_platform_init(struct axd_dev *axd);
+void axd_platform_set_pc(unsigned long pc);
+int axd_platform_start(void);
+void axd_platform_stop(void);
+unsigned int axd_platform_num_threads(void);
+void axd_platform_kick(void);
+void axd_platform_irq_ack(void);
+void axd_platform_print_regs(void);
+
+/*
+ * protect against simultaneous access to shared memory mapped registers area
+ * between axd and the host
+ */
+unsigned long axd_platform_lock(void);
+void axd_platform_unlock(unsigned long flags);
+
+#endif /* AXD_PLATFORM_H_ */
diff --git a/sound/soc/img/axd/axd_platform_mips.c 
b/sound/soc/img/axd/axd_platform_mips.c
new file mode 100644
index ..ac1cf5eb8a64
--- /dev/null
+++ b/sound/soc/img/axd/axd_platform_mips.c
@@ -0,0 +1,416 @@
+/*
+ * Copyright (C) 2011-2015 Imagination Technologies Ltd.
+ *
+ * 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.
+ *
+ * This file implements running AXD as a single VPE along side linux on the 
same
+ * core.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "axd_module.h"
+#include "axd_platform.h"
+
+
+static unsigned int axd_irqnum;
+static unsigned int axd_irq;
+static unsigned int axd_vpe;
+static spinlock_t lock;
+static unsigned long smpirqflags;
+
+
+static void _axd_platform_init(void *info)
+{
+   unsigned int val;
+   unsigned long irqflags;
+   unsigned long mtflags;
+
+   /*
+* make sure nothing else on this vpe or another vpe can try to modify
+* any of the shared registers below
+*/
+   local_irq_save(irqflags);
+   mtflags = dvpe();
+
+   /* EVP = 0, VPC = 1 */
+   val = read_c0_mvpcontrol();
+   val &= ~MVPCONTROL_EVP;
+   val |= MVPCONTROL_VPC;
+   write_c0_mvpcontrol(val);
+   instruction_hazard();
+
+   /* prepare TC for setting up */
+   settc(axd_vpe);
+   write_tc_c0_tchalt(1);
+
+   /* make sure no interrupts are pending and exceptions bits are clear */
+   write_vpe_c0_cause(0);
+   write_vpe_c0_status(0);
+
+   /* bind TC to VPE */
+   val = read_tc_c0_tcbind();
+   val |= (axd_vpe << TCBIND_CURTC_SHIFT) | (axd_vpe << 
TCBIND_CURVPE_SHIFT);
+   write_tc_c0_tcbind(val);
+
+   /* VPA = 1, MVP = 1 */
+   val = read_vpe_c0_vpeconf0();
+   val |= VPECONF0_MVP;
+   val |= VPECONF0_VPA;
+   write_vpe_c0_vpeconf0(val);
+
+   /* A = 1, IXMT = 0 */
+   val = read_tc_c0_tcstatus();
+   val &= ~TCSTATUS_IXMT;
+   val |= TCSTATUS_A;
+   write_tc_c0_tcstatus(val);
+
+   /* TE = 1 */
+   val = read_vpe_c0_vpecontrol();
+   val |= VPECONTROL_TE;
+   write_vpe_c0_vpecontrol(val);
+
+   /* EVP = 1, VPC = 0 */
+   val = read_c0_mvpcontrol();
+   val |= MVPCONTROL_EVP;
+   val &= ~MVPCONTROL_VPC;
+   write_c0_mvpcontrol(val);
+   instruction_hazard();
+
+   evpe(mtflags);
+   local_irq_restore(irqflags);
+}
+
+void axd_platform_init(struct axd_dev *axd)
+{
+   struct cpumask cpumask;
+
+   axd_irqnum = axd->irqnum;
+   axd_irq = axd->axd_irq;
+   

[PATCH 05/10] ALSA: axd: add buffers manipulation files

2015-08-24 Thread Qais Yousef
These files support initilising and managing access to the shared
buffers area in memory that is used to exchange data between AXD
and linux.

Signed-off-by: Qais Yousef 
Cc: Liam Girdwood 
Cc: Mark Brown 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: linux-kernel@vger.kernel.org
---
 sound/soc/img/axd/axd_buffers.c | 243 
 sound/soc/img/axd/axd_buffers.h |  74 
 2 files changed, 317 insertions(+)
 create mode 100644 sound/soc/img/axd/axd_buffers.c
 create mode 100644 sound/soc/img/axd/axd_buffers.h

diff --git a/sound/soc/img/axd/axd_buffers.c b/sound/soc/img/axd/axd_buffers.c
new file mode 100644
index ..891344a806f6
--- /dev/null
+++ b/sound/soc/img/axd/axd_buffers.c
@@ -0,0 +1,243 @@
+/*
+ * Copyright (C) 2011-2015 Imagination Technologies Ltd.
+ *
+ * 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.
+ *
+ * AXD generic buffer management API.
+ */
+#include 
+#include 
+
+#include "axd_buffers.h"
+
+/**
+ * axd_buffer_init - sets up axd buffer as a pool of fixed sized buffers.
+ * @address: starting address of the buffer as set up in the system
+ * @total_size: total size of available buffer
+ * @element_size: size of each buffer element
+ *
+ * axd_buffer_t *buffer is a memory pool of size @element_size and starting at
+ * address @address and of @total_size size.
+ */
+static int bufferq_init(struct axd_bufferq *bufferq, const char *name,
+   char *address, unsigned int num_elements,
+   unsigned int element_size, unsigned int nonblock)
+{
+   int i;
+   char **queue;
+   unsigned int *size;
+
+   strncpy(bufferq->name, name, 16);
+   bufferq->stride = element_size;
+   bufferq->max = num_elements;
+   bufferq->rd_idx = 0;
+   bufferq->wr_idx = 0;
+   bufferq->nonblock = nonblock;
+   queue = kcalloc(num_elements, sizeof(char *), GFP_KERNEL);
+   if (!queue)
+   return -ENOMEM;
+   bufferq->queue = queue;
+   size = kcalloc(num_elements, sizeof(unsigned int), GFP_KERNEL);
+   if (!size) {
+   kfree(queue);
+   bufferq->queue = NULL;
+   return -ENOMEM;
+   }
+   bufferq->size = size;
+   /*
+* setup the queue with all available buffer addresses if the base
+* address is passed. Set it up as emptry if base address is NULL.
+*/
+   if (address) {
+   for (i = 0; i < num_elements; i++) {
+   queue[i] = address + (element_size * i);
+   size[i] = element_size;
+   }
+   sema_init(>rd_sem, num_elements);
+   sema_init(>wr_sem, 0);
+   } else {
+   for (i = 0; i < num_elements; i++) {
+   queue[i] = NULL;
+   size[i] = element_size;
+   }
+   sema_init(>rd_sem, 0);
+   sema_init(>wr_sem, num_elements);
+   }
+   spin_lock_init(>q_rdlock);
+   spin_lock_init(>q_wrlock);
+   pr_debug("Initialized %s of %d elements of size %d bytes\n",
+   name, num_elements, element_size);
+   pr_debug("Address of %s: 0x%08X\n", name, (unsigned int)bufferq);
+   return 0;
+}
+
+int axd_bufferq_init(struct axd_bufferq *bufferq, const char *name,
+   char *address, unsigned int num_elements,
+   unsigned int element_size, unsigned int nonblock)
+{
+   return bufferq_init(bufferq,
+   name, address, num_elements, element_size, nonblock);
+}
+
+int axd_bufferq_init_empty(struct axd_bufferq *bufferq, const char *name,
+   unsigned int num_elements, unsigned int element_size,
+   unsigned int nonblock)
+{
+   return bufferq_init(bufferq,
+   name, NULL, num_elements, element_size, nonblock);
+}
+
+void axd_bufferq_clear(struct axd_bufferq *bufferq)
+{
+   kfree(bufferq->queue);
+   kfree(bufferq->size);
+   bufferq->queue = NULL;
+   bufferq->size = NULL;
+}
+
+/**
+ * axd_buffer_take - returns a valid buffer pointer
+ * @buffer: the buffers pool to be accessed
+ *
+ * This function will go into interruptible sleep if the pool is empty.
+ */
+char *axd_bufferq_take(struct axd_bufferq *bufferq, int *buf_size)
+{
+   char *buf;
+   int ret;
+
+   if (!bufferq->queue)
+   return NULL;
+
+   pr_debug("--(%s)-- taking new buffer\n", bufferq->name);
+   if (bufferq->nonblock) {
+   ret = 

[PATCH-v3 1/2] mfd: devicetree: bindings: 88pm800: Add DT property for dual phase enable

2015-08-24 Thread Vaibhav Hiremath
88PM860 family of device supports dual phase mode on BUCK1 supply
providing total 6A capacity.
Note that by default they operate independently with 3A capacity.

This patch updates the devicetree binding with DT property
to enable dual-phase mode on BUCK1.

Signed-off-by: Vaibhav Hiremath 
---
 Documentation/devicetree/bindings/mfd/88pm800.txt | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/88pm800.txt 
b/Documentation/devicetree/bindings/mfd/88pm800.txt
index dec842f..2c82fcb 100644
--- a/Documentation/devicetree/bindings/mfd/88pm800.txt
+++ b/Documentation/devicetree/bindings/mfd/88pm800.txt
@@ -9,6 +9,12 @@ Required parent device properties:
 - #interrupt-cells : should be 1.
  The cell is the 88pm80x local IRQ number
 
+Optional properties :
+- marvell,88pm860-buck1-dualphase-en  : If set, enable dual phase on BUCK1,
+  providing 6A capacity.
+  Without this both BUCK1A and BUCK1B operates independently with 3A capacity.
+  (This property is only applicable to 88PM860)
+
 88pm80x family of devices consists of varied group of sub-devices:
 
 Device Supply Names Description
-- 
1.9.1

--
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] mm: use only per-device readahead limit

2015-08-24 Thread Konstantin Khlebnikov

On 24.08.2015 14:57, Roman Gushchin wrote:

Maximal readahead size is limited now by two values:
1) by global 2Mb constant (MAX_READAHEAD in max_sane_readahead())
2) by configurable per-device value* (bdi->ra_pages)

There are devices, which require custom readahead limit.
For instance, for RAIDs it's calculated as number of devices
multiplied by chunk size times 2.

Readahead size can never be larger than bdi->ra_pages * 2 value
(POSIX_FADV_SEQUNTIAL doubles readahead size).

If so, why do we need two limits?
I suggest to completely remove this max_sane_readahead() stuff and
use per-device readahead limit everywhere.

Also, using right readahead size for RAID disks can significantly
increase i/o performance:

before:
dd if=/dev/md2 of=/dev/null bs=100M count=100
100+0 records in
100+0 records out
1048576 bytes (10 GB) copied, 12.9741 s, 808 MB/s

after:
$ dd if=/dev/md2 of=/dev/null bs=100M count=100
100+0 records in
100+0 records out
1048576 bytes (10 GB) copied, 8.91317 s, 1.2 GB/s

(It's an 8-disks RAID5 storage).

This patch doesn't change sys_readahead and madvise(MADV_WILLNEED)
behavior introduced by commit
6d2be915e589b58cb11418cbe1f22ff90732b6ac ("mm/readahead.c: fix
readahead failure for memoryless NUMA nodes and limit readahead pages").

V2:
Konstantin Khlebnikov noticed, that if readahead is completely
disabled, force_page_cache_readahead() will not read anything.
This function is used for sync reads (if FMODE_RANDOM flag is set).
So, to guarantee read progress it's necessary to read at least 1 page.


After second thought: this isn't important. V1 is fine.

page_cache_sync_readahead checks "if (!ra->ra_pages)" before and
never calls force_page_cache_readahead if readahead is disabled.

Anyway, this function doesn't return references to pages. All
users must be ready to handle non-present or non-uptodate pages.
But this probably never happened before so all callsites should
be reviewed: for example splice always re-lookups pages after
->readpage() (I guess page can be truncated here) while some
other users use the same page reference.



Signed-off-by: Roman Gushchin 
Cc: Linus Torvalds 
Cc: Raghavendra K T 
Cc: Jan Kara 
Cc: Wu Fengguang 
Cc: David Rientjes 
Cc: Andrew Morton 
Cc: Konstantin Khlebnikov 
---
  include/linux/mm.h |  2 --
  mm/filemap.c   |  8 +++-
  mm/readahead.c | 18 ++
  3 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 2e872f9..a62abdd 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1942,8 +1942,6 @@ void page_cache_async_readahead(struct address_space 
*mapping,
pgoff_t offset,
unsigned long size);

-unsigned long max_sane_readahead(unsigned long nr);
-
  /* Generic expand stack which grows the stack according to GROWS{UP,DOWN} */
  extern int expand_stack(struct vm_area_struct *vma, unsigned long address);

diff --git a/mm/filemap.c b/mm/filemap.c
index 1283fc8..0e1ebef 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1807,7 +1807,6 @@ static void do_sync_mmap_readahead(struct vm_area_struct 
*vma,
   struct file *file,
   pgoff_t offset)
  {
-   unsigned long ra_pages;
struct address_space *mapping = file->f_mapping;

/* If we don't want any read-ahead, don't bother */
@@ -1836,10 +1835,9 @@ static void do_sync_mmap_readahead(struct vm_area_struct 
*vma,
/*
 * mmap read-around
 */
-   ra_pages = max_sane_readahead(ra->ra_pages);
-   ra->start = max_t(long, 0, offset - ra_pages / 2);
-   ra->size = ra_pages;
-   ra->async_size = ra_pages / 4;
+   ra->start = max_t(long, 0, offset - ra->ra_pages / 2);
+   ra->size = ra->ra_pages;
+   ra->async_size = ra->ra_pages / 4;
ra_submit(ra, mapping, file);
  }

diff --git a/mm/readahead.c b/mm/readahead.c
index 60cd846..7eb844c 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -213,7 +213,11 @@ int force_page_cache_readahead(struct address_space 
*mapping, struct file *filp,
if (unlikely(!mapping->a_ops->readpage && !mapping->a_ops->readpages))
return -EINVAL;

-   nr_to_read = max_sane_readahead(nr_to_read);
+   /*
+* Read at least 1 page, even if readahead is completely disabled.
+*/
+   nr_to_read = min(nr_to_read, max(inode_to_bdi(mapping->host)->ra_pages,
+1ul));
while (nr_to_read) {
int err;

@@ -232,16 +236,6 @@ int force_page_cache_readahead(struct address_space 
*mapping, struct file *filp,
return 0;
  }

-#define MAX_READAHEAD   ((512*4096)/PAGE_CACHE_SIZE)
-/*
- * Given a desired number of PAGE_CACHE_SIZE readahead pages, return a
- * sensible upper limit.
- */
-unsigned long max_sane_readahead(unsigned long nr)
-{
-   return min(nr, MAX_READAHEAD);
-}
-
  /*
   * Set the initial 

[PATCH 06/10] ALSA: axd: add basic files for sending/receiving axd cmds

2015-08-24 Thread Qais Yousef
These files do the important part of talking with AXD to send and
receive data buffers.

Signed-off-by: Qais Yousef 
Cc: Liam Girdwood 
Cc: Mark Brown 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: linux-kernel@vger.kernel.org
---
 sound/soc/img/axd/axd_cmds.c   |  102 +++
 sound/soc/img/axd/axd_cmds.h   |  532 ++
 sound/soc/img/axd/axd_cmds_pipes.c | 1387 
 3 files changed, 2021 insertions(+)
 create mode 100644 sound/soc/img/axd/axd_cmds.c
 create mode 100644 sound/soc/img/axd/axd_cmds.h
 create mode 100644 sound/soc/img/axd/axd_cmds_pipes.c

diff --git a/sound/soc/img/axd/axd_cmds.c b/sound/soc/img/axd/axd_cmds.c
new file mode 100644
index ..eb160f46489b
--- /dev/null
+++ b/sound/soc/img/axd/axd_cmds.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2011-2015 Imagination Technologies Ltd.
+ *
+ * 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.
+ *
+ * AXD Commands API - generic setup functions.
+ */
+#include "axd_api.h"
+#include "axd_cmds.h"
+#include "axd_cmds_internal.h"
+#include "axd_module.h"
+
+static unsigned long __io_address;
+static unsigned long __phys_address;
+
+void axd_cmd_init(struct axd_cmd *cmd, unsigned long cmd_address,
+   unsigned long io_address, unsigned long phys_address)
+{
+   int i;
+
+   cmd->message = (struct axd_memory_map __iomem *)cmd_address;
+   mutex_init(>cm_lock);
+   init_waitqueue_head(>wait);
+   axd_set_flag(>response_flg, 0);
+   axd_set_flag(>fw_stopped_flg, 0);
+   for (i = 0; i < AXD_MAX_PIPES; i++) {
+   axd_cmd_inpipe_init(cmd, i);
+   axd_cmd_outpipe_init(cmd, i);
+   }
+   __io_address = io_address;
+   __phys_address = phys_address;
+   cmd->watchdogenabled = 1;
+   /*
+* By default, always discard any pending buffers if an output device is
+* closed before EOS is reached.
+* This behaviour can be changed through kcontrol. If discard is 
disabled,
+* then upon closing an output device before EOS is reached, it'll
+* resume from where it stopped.
+*/
+   axd_set_flag(>discard_flg, 1);
+   axd_set_flag(>ctrlbuf_active_flg, 0);
+}
+
+int axd_cmd_set_pc(struct axd_cmd *cmd, unsigned int thread, unsigned long pc)
+{
+   if (thread >= THREAD_COUNT)
+   return -1;
+   iowrite32(pc, >message->pc[thread]);
+   return 0;
+}
+
+unsigned long  axd_cmd_get_datain_address(struct axd_cmd *cmd)
+{
+   struct axd_dev *axd = container_of(cmd, struct axd_dev, cmd);
+
+   return (unsigned long) axd->buf_base_m;
+}
+
+unsigned long  axd_cmd_get_datain_size(struct axd_cmd *cmd)
+{
+   struct axd_dev *axd = container_of(cmd, struct axd_dev, cmd);
+
+   return axd->inbuf_size;
+}
+
+unsigned long  axd_cmd_get_dataout_address(struct axd_cmd *cmd)
+{
+   struct axd_dev *axd = container_of(cmd, struct axd_dev, cmd);
+
+   return ((unsigned long) axd->buf_base_m) + axd->inbuf_size;
+}
+
+unsigned long  axd_cmd_get_dataout_size(struct axd_cmd *cmd)
+{
+   struct axd_dev *axd = container_of(cmd, struct axd_dev, cmd);
+
+   return axd->outbuf_size;
+}
+
+/*
+ * The driver understands IO address, while f/w understands physical addresses.
+ * A couple of helper functions to aid in converting when exchanging buffers.
+ *
+ * NOTE:
+ * buf must NOT be NULL - we want this as fast as possible, so omit the check
+ * for NULLl
+ */
+inline char *axd_io_2_phys(const char *buf)
+{
+   return (char *)(buf - __io_address + __phys_address);
+}
+inline char *axd_phys_2_io(const char *buf)
+{
+   return (char *)(buf - __phys_address + __io_address);
+}
diff --git a/sound/soc/img/axd/axd_cmds.h b/sound/soc/img/axd/axd_cmds.h
new file mode 100644
index ..d8f3db29eea3
--- /dev/null
+++ b/sound/soc/img/axd/axd_cmds.h
@@ -0,0 +1,532 @@
+/*
+ * Copyright (C) 2011-2015 Imagination Technologies Ltd.
+ *
+ * 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.
+ *
+ * AXD API commands Helper functions.
+ */
+#ifndef AXD_CMDS_H_
+#define AXD_CMDS_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "linux/workqueue.h"
+#include 
+#include 

[PATCH-v3 0/2] regulator: 88pm800: Add dual phase mode support on BUCK1

2015-08-24 Thread Vaibhav Hiremath
88PM860 device supports dual phase mode on BUCK1 output.
In normal usecase, BUCK1A and BUCK1B operates independently with 3A
capacity. And they both can work as a dual phase providing 6A capacity.

This patch series is subset of earlier patch-series
Link to earlier series - https://lkml.org/lkml/2015/7/16/722

Except PATCH[5/5], all other patches in the series are accepted and
queued up for next merge window.
And based on discussion on the list, creating DT property to enable
dual-phase mode on BUCK1.

Testing:
 - Tested on 88PM860 based platform
 - Boot tested 
 - Tested with & without DT property being set
 - Read register value before and after probe to make sure that
   value has been set.

V2 => V3:

 - Based on discussion on earlier patch-series,
   (comments from Krzysztof Kozlowski)
   Dynamically controlled current capacity and registration of BUCK1B,
   in case of BUCK1 dual phase mode enabled.
   Now, if BUCK1 dual phase is enabled, current capacity is set to 6A,
   and, BUCK1B will not be registered to regulator framework.

V1 => V2:

 - This is new patch-series, where, all accepted patches dropped.
   Upgraded Patch version, to ease review.
 - Based on Mark Brown's comment, we should use DT property of its own.
   using set_current_limit() is not right way here.
   So, created DT property for Dual phase mode enable.
 - Updated binding for new DT property


Vaibhav Hiremath (2):
  mfd: devicetree: bindings: 88pm800: Add DT property for dual phase
enable
  regulator: 88pm800: Add support for configuration of dual phase on
BUCK1

 Documentation/devicetree/bindings/mfd/88pm800.txt |  6 
 drivers/regulator/88pm800.c   | 40 +++
 include/linux/mfd/88pm80x.h   |  3 ++
 3 files changed, 49 insertions(+)

-- 
1.9.1

--
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 2/2] regulator: 88pm800: Add support for configuration of dual phase on BUCK1

2015-08-24 Thread Vaibhav Hiremath
88PM860 device supports dual phase mode on BUCK1 output.
In normal usecase, BUCK1A and BUCK1B operates independently with 3A
capacity. And they both can work as a dual phase providing 6A capacity.

This patch updates the regulator driver to read the respective
DT property and enable dual-phase mode on BUCK1.
Note that if dual phase mode is enabled, then BUCK1B will not be
registered to the regulator framework and the current capacity of
BUCK1(A) would be set to 6A [3A of BUCK1A + 3A of BUCK1B].

Signed-off-by: Vaibhav Hiremath 
---
 drivers/regulator/88pm800.c | 40 
 include/linux/mfd/88pm80x.h |  3 +++
 2 files changed, 43 insertions(+)

diff --git a/drivers/regulator/88pm800.c b/drivers/regulator/88pm800.c
index 365a154..7aca6d17 100644
--- a/drivers/regulator/88pm800.c
+++ b/drivers/regulator/88pm800.c
@@ -267,6 +267,37 @@ static struct pm800_regulator_info pm860_regulator_info[] 
= {
PM800_LDO(ldo20, LDO20, LDO_ENA1_3, 3, 1, ldo_volt_table2),
 };
 
+static int pm800_regulator_init(struct platform_device *pdev,
+   struct pm800_regulator_info *info)
+{
+   struct pm800_regulators *pm800_data = platform_get_drvdata(pdev);
+   struct pm80x_chip *chip = pm800_data->chip;
+   int ret = 0;
+
+   /* Currently only supported on 88pm860 device */
+   if (chip->type != CHIP_PM860)
+   return 0;
+
+   if (of_property_read_bool(pdev->dev.of_node,
+   "marvell,88pm860-buck1-dualphase-en")) {
+   /* Update the constraint  to [3A (BUCK1A) + 3A (BUCK1B)] */
+   info[PM800_ID_BUCK1].max_ua = 600;
+   /* Remove BUCK1B from the list, as we are in dual phase mode */
+   memset([PM800_ID_BUCK1B], 0, sizeof(*info));
+   /* Enable dual phase mode */
+   ret = regmap_update_bits(chip->subchip->regmap_power,
+   PM860_BUCK1_MISC,
+   BUCK1_DUAL_PHASE_SEL,
+   BUCK1_DUAL_PHASE_SEL);
+   if (ret) {
+   dev_err(chip->dev, "failed to set dual-pase mode %d\n", 
ret);
+   return ret;
+   }
+   }
+
+   return ret;
+}
+
 static int pm800_regulator_probe(struct platform_device *pdev)
 {
struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent);
@@ -311,11 +342,20 @@ static int pm800_regulator_probe(struct platform_device 
*pdev)
return -ENODEV;
}
 
+   ret = pm800_regulator_init(pdev, info);
+   if (ret) {
+   dev_err(>dev, "failed to init 88pm800 regulator 
device\n");
+   return ret;
+   }
+
config.dev = chip->dev;
config.regmap = pm800_data->map;
for (i = 0; i < PM800_ID_RG_MAX; i++) {
struct regulator_dev *regulator;
 
+   if (!info[i].desc.name)
+   continue;
+
if (pdata && pdata->num_regulators) {
init_data = pdata->regulators[i];
if (!init_data)
diff --git a/include/linux/mfd/88pm80x.h b/include/linux/mfd/88pm80x.h
index a92d173..122cfd2 100644
--- a/include/linux/mfd/88pm80x.h
+++ b/include/linux/mfd/88pm80x.h
@@ -295,6 +295,9 @@ enum {
 #define PM860_BUCK4_MISC2  (0x82)
 #define PM860_BUCK4_FULL_DRV   BIT(2)
 
+#define PM860_BUCK1_MISC   0x8E
+#define BUCK1_DUAL_PHASE_SEL   BIT(2)
+
 struct pm80x_rtc_pdata {
int vrtc;
int rtc_wakeup;
-- 
1.9.1

--
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 10/10] ALSA: axd: add Makefile

2015-08-24 Thread Qais Yousef
Now all necessary files are added, allow axd to be selected through Kconfig and
compiled.

Signed-off-by: Qais Yousef 
Cc: Liam Girdwood 
Cc: Mark Brown 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: linux-kernel@vger.kernel.org
---
 sound/soc/Kconfig  |  1 +
 sound/soc/Makefile |  1 +
 sound/soc/img/Kconfig  | 11 +++
 sound/soc/img/Makefile |  1 +
 sound/soc/img/axd/Makefile | 13 +
 5 files changed, 27 insertions(+)
 create mode 100644 sound/soc/img/Kconfig
 create mode 100644 sound/soc/img/Makefile
 create mode 100644 sound/soc/img/axd/Makefile

diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
index 2ae9619443d1..8f29af1d397e 100644
--- a/sound/soc/Kconfig
+++ b/sound/soc/Kconfig
@@ -44,6 +44,7 @@ source "sound/soc/jz4740/Kconfig"
 source "sound/soc/nuc900/Kconfig"
 source "sound/soc/omap/Kconfig"
 source "sound/soc/kirkwood/Kconfig"
+source "sound/soc/img/Kconfig"
 source "sound/soc/intel/Kconfig"
 source "sound/soc/mediatek/Kconfig"
 source "sound/soc/mxs/Kconfig"
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index e189903fabf4..c6a1c04b8e39 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_SND_SOC) += davinci/
 obj-$(CONFIG_SND_SOC)  += dwc/
 obj-$(CONFIG_SND_SOC)  += fsl/
 obj-$(CONFIG_SND_SOC)  += jz4740/
+obj-$(CONFIG_SND_SOC)  += img/
 obj-$(CONFIG_SND_SOC)  += intel/
 obj-$(CONFIG_SND_SOC)  += mediatek/
 obj-$(CONFIG_SND_SOC)  += mxs/
diff --git a/sound/soc/img/Kconfig b/sound/soc/img/Kconfig
new file mode 100644
index ..5a089b7d4929
--- /dev/null
+++ b/sound/soc/img/Kconfig
@@ -0,0 +1,11 @@
+config SND_SOC_IMG_AXD
+   tristate "Imagination AXD Audio Processing IP"
+   depends on MIPS && COMMON_CLK && CMA
+   ---help---
+ Say Y or M here if you to add support for AXD Audio Processing IP.
+
+config SND_SOC_IMG_AXD_DEBUGFS
+   bool "AXD debugfs support"
+   depends on SND_SOC_IMG_AXD && DEBUG_FS
+   ---help---
+ Say Y if you want to create AXD debugfs nodes
diff --git a/sound/soc/img/Makefile b/sound/soc/img/Makefile
new file mode 100644
index ..189abf5d927c
--- /dev/null
+++ b/sound/soc/img/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_SND_SOC_IMG_AXD) += axd/
diff --git a/sound/soc/img/axd/Makefile b/sound/soc/img/axd/Makefile
new file mode 100644
index ..cfa1f412bf19
--- /dev/null
+++ b/sound/soc/img/axd/Makefile
@@ -0,0 +1,13 @@
+obj-$(CONFIG_SND_SOC_IMG_AXD) := axd.o
+
+axd-objs = axd_alsa_ops.o \
+  axd_buffers.o \
+  axd_cmds.o \
+  axd_cmds_config.o \
+  axd_cmds_decoder_config.o \
+  axd_cmds_info.o \
+  axd_cmds_internal.o \
+  axd_cmds_pipes.o \
+  axd_hdr.o \
+  axd_module.o \
+  axd_platform_$(ARCH).o \
-- 
2.1.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] irqchip, gicv3-its, numa: Workaround for Cavium ThunderX erratum 23144

2015-08-24 Thread Marc Zyngier
On 24/08/15 13:30, Ganapatrao Kulkarni wrote:
> Hi Marc,
> 
> thanks for the review comments.
> 
> On Mon, Aug 24, 2015 at 3:47 PM, Marc Zyngier  wrote:
>> Hi Robert,
>>
>> Just came back from the Seattle madness, so picking up patches in
>> reverse order... ;-)
>>
>> On 22/08/15 14:10, Robert Richter wrote:
>>> The patch below adds a workaround for gicv3 in a numa environment. It
>>> is on top of my recent gicv3 errata patch submission v4 and Ganapat's
>>> arm64 numa patches for devicetree v5.
>>>
>>> Please comment.
>>>
>>> Thanks,
>>>
>>> -Robert
>>>
>>>
>>>
>>> From c432820451a46b8d1e299b8bfbfcdcb3b75340e7 Mon Sep 17 00:00:00 2001
>>> From: Ganapatrao Kulkarni 
>>> Date: Wed, 19 Aug 2015 23:40:05 +0530
>>> Subject: [PATCH] irqchip, gicv3-its, numa: Workaround for Cavium ThunderX 
>>> erratum
>>>  23144
>>>
>>> This implements a workaround for gicv3-its erratum 23144 applicable
>>> for Cavium's ThunderX multinode systems.
>>>
>>> The erratum fixes the hang of ITS SYNC command by avoiding inter node
>>> io and collections/cpu mapping. This fix is only applicable for
>>> Cavium's ThunderX dual-socket platforms.
>>
>> Can you please elaborate on this? I can't see any reference to the SYNC
>> command there. Is that a case of an ITS not being able to route LPIs to
>> cores on another socket?
> we were seeing mapc command failing when we were mapping its of node0
> with collections of node1(vice-versa).

There is no such thing as "collection of node1". There are collections
mapped to redistributors.

> we found sync was timing out, which is issued post mapc(also for mapvi
> and movi).
> Yes this errata limits the routing of inter-node LPIs.

Please update the commit message to reflect the actual issue.

> 
>>
>> I really need more details to understand this patch (please use short
>> sentences, I'm still in a different time zone).
>>
>>>
>>> Signed-off-by: Ganapatrao Kulkarni 
>>> [ rric: Reworked errata code, added helper functions, updated commit
>>>   message. ]
>>>
>>> Signed-off-by: Robert Richter 
>>> ---
>>>  arch/arm64/Kconfig   | 14 +++
>>>  drivers/irqchip/irq-gic-common.c |  5 ++--
>>>  drivers/irqchip/irq-gic-v3-its.c | 54 
>>> ++--
>>>  3 files changed, 64 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>>> index 3809187ed653..b92b7b70b29b 100644
>>> --- a/arch/arm64/Kconfig
>>> +++ b/arch/arm64/Kconfig
>>> @@ -421,6 +421,20 @@ config ARM64_ERRATUM_845719
>>>
>>> If unsure, say Y.
>>>
>>> +config CAVIUM_ERRATUM_22375
>>> + bool "Cavium erratum 22375, 24313"
>>> + depends on NUMA
>>> + default y
>>> + help
>>> + Enable workaround for erratum 22375, 24313.
>>> +
>>> +config CAVIUM_ERRATUM_23144
>>> + bool "Cavium erratum 23144"
>>> + depends on NUMA
>>> + default y
>>> + help
>>> + Enable workaround for erratum 23144.
>>> +
>>>  config CAVIUM_ERRATUM_23154
>>>   bool "Cavium erratum 23154: Access to ICC_IAR1_EL1 is not sync'ed"
>>>   depends on ARCH_THUNDER
>>> diff --git a/drivers/irqchip/irq-gic-common.c 
>>> b/drivers/irqchip/irq-gic-common.c
>>> index ee789b07f2d1..1dfce64dbdac 100644
>>> --- a/drivers/irqchip/irq-gic-common.c
>>> +++ b/drivers/irqchip/irq-gic-common.c
>>> @@ -24,11 +24,12 @@
>>>  void gic_check_capabilities(u32 iidr, const struct gic_capabilities *cap,
>>>   void *data)
>>>  {
>>> - for (; cap->desc; cap++) {
>>> + for (; cap->init; cap++) {
>>>   if (cap->iidr != (cap->mask & iidr))
>>>   continue;
>>>   cap->init(data);
>>> - pr_info("%s\n", cap->desc);
>>> + if (cap->desc)
>>> + pr_info("%s\n", cap->desc);
>>
>> No. I really want to see what errata are applied when I look at a kernel
>> log.
> sorry, did not understood your comment, it is still printed using cap->desc.

Yes, but you are making desc optional, and I don't want it to be
optional. I want the kernel to scream that we're using an erratum
workaround so that we can understand what is happening when reading a
kernel log.

>>>   }
>>>  }
>>>
>>> diff --git a/drivers/irqchip/irq-gic-v3-its.c 
>>> b/drivers/irqchip/irq-gic-v3-its.c
>>> index 4bb135721e72..666be39f13a9 100644
>>> --- a/drivers/irqchip/irq-gic-v3-its.c
>>> +++ b/drivers/irqchip/irq-gic-v3-its.c
>>> @@ -43,7 +43,8 @@
>>>  #include "irqchip.h"
>>>
>>>  #define ITS_FLAGS_CMDQ_NEEDS_FLUSHING(1ULL << 0)
>>> -#define ITS_FLAGS_CAVIUM_THUNDERX(1ULL << 1)
>>> +#define ITS_WORKAROUND_CAVIUM_22375  (1ULL << 1)
>>> +#define ITS_WORKAROUND_CAVIUM_23144  (1ULL << 2)
>>>
>>>  #define RDIST_FLAGS_PROPBASE_NEEDS_FLUSHING  (1 << 0)
>>>
>>> @@ -76,6 +77,7 @@ struct its_node {
>>>   struct list_headits_device_list;
>>>   u64 flags;
>>>   u32 ite_size;
>>> + int 

Re: [PATCH v1 3/3] arm64: dts: add Hi6220 mailbox node

2015-08-24 Thread Mark Rutland
> > > > I don't see why you need reserved-memory here, given you're not 
> > > > referring to
> > > > these regions by phandle anyway.
> > > 
> > > - Now we have enabled EFI_STUB, so the memory node will be removed in
> > >   kernel:
> > > efi_entry()
> > >   \-> allocate_new_fdt_and_exit_boot()
> > > \-> update_fdt();
> > > 
> > >   Finally in kernel it cannot use memory node to carve out reseved
> > >   memory regions.
> > > 
> > > - On the other hand, DTS's the memory node is to "describes the
> > >   physical memory layout for the system"; so it's better to use it only
> > >   to describe the hardware info for memory. We can use reserved-memory
> > >   to help manage the memory regions which are reserved from software
> > >   perspective.
> > 
> > The fact that you have no-map means that the memory should not be
> > described to the kernel as mappable in the first place. It's wrong to
> > place such memory in the memory node, even if listed in reserved-memory.
> > 
> > If your EFI memory map describes the memory as mappable, it is wrong.
> 
> When kernel is working, kernel will create its own page table based on
> UEFI memory map. Since it's reserved in DTS file as Leo's patch, it'll
> be moved to reserved memblock. Why is it wrong?

That is a _Linux_ detail, not a _UEFI_ detail.

Anything which only handles UEFI and knows nothing of reserved-memory
(e.g. GRUB) will be broken and/or break the Linux use of the region, as
it will happily try to allocate memory in the region (and could even
decide to reserve it permanently for its own usage).

If the memory is truly specific to the mailbox, then UEFI needs to know
that it is reserved as such. If it is not, then it need not be described
in the DT and can be allocated dynamically by the kernel.

> In the second, UEFI is firmware. When it's stable, nobody should change
> it without any reason. These reserved memory are used in mailbox driver.
> Look. It's driver, so it could be changed at any time. Why do you want
> to UEFI knowing this memory range? Do you hope UEFI to change when
> mailbox driver is changed?

It shouldn't need to change if that memory is truly reserved for the
sole use of the mailbox. If that's not the case then we have a different
issue.

If the memory range to use can be allocated by the driver, then I don't
see why it should be described in reserved-memory. It certainly should
not require a no-map attribute.

Additionally, the driver needs to ensure that the requisite cache
maintenance takes place prior to the use of the memory region given
prior agents may have ampped it as cacheable, leaving stale (perhaps
dirty) lines in the caches.

> > > According to upper info, we still need to use reserved-memory node to
> > > depict the reserved memory regions. i have no knowledge about EFI_STUB,
> > > so please confirm or correct as needed.
> > 
> > If the memory shouldn't be mapped, it should neither be in the memory
> > node nor EFI memory map (with attributes allowing it to be mapped) to
> > begin with.
> 
> As I said above, kernel will create its own page table. When kernel's
> page table is working, UEFI's page table is destroying. So the memory
> won't be mapped twice at the same time. What's wrong?
> > 
> > As far as I can see you do not need to use reserved-memory.
> 
> 1. Are we talking on the same thing? Leo already mentioned that all
> memory node in DTB will be destroyed by kernel when EFI_STUB is enabled
> on arm. Did you read the source code after his reply?
> And you suggested that Leo to use discrete memory region in DTB. It is
> really wrong. Kernel only gets memory map information from UEFI, not
> DTB.

I did _not_ suggest that Leo use discrete memory. I suggested that
reserved regions should not be described in the memory node (the same
premise applying to the UEFI memory map).

w.r.t. UEFI, please see my comments above. If you're using the UEFI
memory map, you have to use the UEFI memory map, not the UEFI memory map
with additional (non-UEFI) caveats applied atop.

> 2. The working flow is in below.
>a. Kernel gets memory map information from UEFI.
>b. Kernel loads the memory reserved information from DTB.

This relies on Linux, and ignores other UEFI clients.

> 3. Do you mean the reserved-memory is totally wrong? If it's wrong,
> please submit patches to remove all reserved-memory in linux kernel
> first.

I did not say that.

I said that describing some memory in a memory node, then also
describing that in reserved-memory with a no-map property was wrong. If
it's never meant to be mapped then there's no reason for it to be in the
memory node.

> 4. Again and again. Memory node should be only used to describe the
> RAM information.

The memory node describes the memory available to the OS. There are some
caveats w.r.t. /memreserve/, regions which may be mapped but remain
unused and so on, but the memory node does generally encode a policy
that the memory may be used.

Describing unusable memory 

Re: [PATCH v3 06/14] Documentation: drm/bridge: add document for analogix_dp

2015-08-24 Thread Yakir Yang

Hi Krzysztof,

在 08/24/2015 12:20 PM, Krzysztof Kozlowski 写道:

On 24.08.2015 11:42, Yakir Yang wrote:

Hi Krzysztof,

在 08/23/2015 07:43 PM, Krzysztof Kozlowski 写道:

2015-08-24 8:23 GMT+09:00 Rob Herring :

On Wed, Aug 19, 2015 at 9:50 AM, Yakir Yang  wrote:

Analogix dp driver is split from exynos dp driver, so we just
make an copy of exynos_dp.txt, and then simplify exynos_dp.txt

Beside update some exynos dtsi file with the latest change
according to the devicetree binding documents.

You can't just change the exynos bindings and break compatibility. Is
there some agreement with exynos folks to do this?

No, there is no agreement. This wasn't even sent to Exynos maintainers.

Sorry about this one, actually I have add Exynos maintainers in version
1 & version 2,
but lose some maintainers in version 3, I would fix it in bellow versions.


Additionally the patchset did not look interesting to me because of
misleading subject - Documentation instead of "ARM: dts:".

Yakir, please:
1. Provide backward compatibility. Mark old properties as deprecated
but still support them.

Do you mean that I should keep the old properties declare in exynos-dp.txt,
but just mark them as deprecated flag.

That is one of ways how to do this. However more important is that
driver should still support old bindings so such code:
-   if (of_property_read_u32(dp_node, "samsung,color-space",
+   if (of_property_read_u32(dp_node, "analogix,color-space",

is probably wrong. Will the driver support old DTB in the same way as it
was supporting before the change?


Okay, I got your means. So document is not the focus, the most important 
is that
driver should support the old dts prop. If so the new analogix dp driver 
should keep

the "samsung,color-space", rather then just mark it with [DEPRECATED] flag.

But from your follow suggest, I think you agree to update driver code, 
and just mark

old prop with deprecated flag. If so I think such code would not be wrong

-   if (of_property_read_u32(dp_node, "samsung,color-space",
+  if (of_property_read_u32(dp_node, "analogix,color-space",

And actually @Rob have suggest me to remove the prefix, just use 
"color-space" here.





Let me show same examples, make
me understand your suggest rightly.

exynos-dp already contains deprecated properties. Other ways of doing
this would be:
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
Documentation/devicetree/bindings/rtc/s3c-rtc.txt

It depends up to you. The "touchscreen" looks good because it organizes
old properties in a common section. In case of exynos-dp.txt you can add
at beginning of file information about new bindings and mark everything
deprecated.


Whoops, thanks for your remind, I prefer the "touchscreen" style.


1. "samsung,ycbcr-coeff" is abandoned in latest analogix-dp driver,
absolutely
 I should not carry this to analogix-dp.txt document. But I should
keep this in
 exynos-dp.txt document, and mark them with an little "deprecated" flag.

[Documentation/devicetree/bindings/video/exynos_dp.txt]
Required properties for dp-controller:
[...]
 -samsung,ycbcr-coeff (DEPRECATED):
 YCbCr co-efficients for input video.
 COLOR_YCBCR601 = 0, COLOR_YCBCR709 = 1

Is it right ?

Yes, this is right.


2. Separate all DTS changes to a separate patch, unless bisectability
would be hurt. Anyway you should prepare it in a such way that
separation would be possible without breaking bisectability.

So I should separate this patch into two parts, one is name "Document:",
the other is "ARM: dts: ".

Yes.


Honestly, I don't understand what the "bisectability" means in this case.

I was referring to bisectability in general. The patchset should be
fully bisectable which means that it does not introduce any issues
during "git bisect". This effectively means that at each intermediate
step (after applying each patch, one by one) every existing stuff works
the same as previously without any regression. Including booting with
old DTB.


Oh, thanks for your careful explain, so I guess your first comment is 
talking about
the "bisectability" that if I only apply the 01 - 05 patches, kernel 
could not bootup
normally, cause driver need "analogix,color-space" but DTB only have 
"samsung,color-space".





3. Use proper subject for the patch changing DTS. This is not
documentation change!

Hmm... when I separate this patch into two parts, I though I can keep
"Documentation" proper subject in this patch, and the other is the "ARM:
dts"
proper subject. Am I right ?

Yes, you're right.


4. Please use script get_maintainers to obtain list of valid
maintainers and CC-them with at least cover letter and patches
requiring their attention.

Yeah, thanks.

Sure. Now I found older versions of the patchset but previously there
were no changes to the bindings. Again the prefix in subject is
important to easily filter out and find necessary emails.

BTW, I like the patchset because I like in general 

Re: [PATCH 01/10] irqchip: irq-mips-gic: export gic_send_ipi

2015-08-24 Thread Thomas Gleixner
On Mon, 24 Aug 2015, Qais Yousef wrote:

> Some drivers might require to send ipi to other cores. So export it.

Which IPIs do you need to send from a driver which are not exposed by
the SMP functions already?

> This will be used later by AXD driver.

That smells fishy and it wants a proper explanation WHY and not just a
sloppy statement that it will be used later. I can figure that out
myself as exporting a function without using it does not make any sense.

Thanks,

tglx
--
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 linux-next v4 5/5] mtd: atmel-quadspi: add driver for Atmel QSPI controller

2015-08-24 Thread Russell King - ARM Linux
On Mon, Aug 24, 2015 at 01:03:51PM +0200, Marek Vasut wrote:
> These are functions, not macros :)
> 
> btw is there any reason for these ? I'd say, just put the read*() and
> write*() functions directly into the code and be done with it, it is
> much less confusing.
> 
> Also, why do you use the _relaxed() versions of the functions ?

Now that the _relaxed() accessors are available throughout the kernel,
everyone should be using the _relaxed() versions unless they need the
properties of the non-relaxed versions.  Remember that the non-relaxed
versions are rather expensive on ARM due to the need to go all the way
out to the L2 cache - it at least doubles the number of accesses for
every read*/write*().

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
--
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] watchdog: sunxi: fix activation of system reset

2015-08-24 Thread Guenter Roeck

On 08/24/2015 02:25 AM, Chen-Yu Tsai wrote:

Hi,

On Mon, Jul 27, 2015 at 3:32 AM, Maxime Ripard
 wrote:

On Sat, Jul 25, 2015 at 08:25:18AM +0200, Francesco Lavra wrote:

Commit f2147de33470 ("watchdog: sunxi: support parameterized compatible
strings") introduced a regression in sunxi_wdt_start(), by which
the system reset function of the watchdog is not enabled upon
starting the watchdog. As a result, the system is not reset when the
watchdog expires. Fix it.

Signed-off-by: Francesco Lavra 
Reviewed-by: Guenter Roeck 
Fixes: f2147de33470 ("watchdog: sunxi: support parameterized compatible 
strings")
Cc: sta...@vger.kernel.org


Acked-by: Maxime Ripard 


What tree should this go in through?
Guenter, are you still taking watchdog patches?



The patch is included in the pull request I sent to Wim last week [1].

Guenter

---
[1] http://www.spinics.net/lists/linux-watchdog/msg07219.html

--
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/


[GIT PULL] Move cert handling to certs/ directory

2015-08-24 Thread David Howells
Hi James,

Sorry for the late request, but can you pull this please?  It's a set of
commits that puts a bit of polish on the previous module signing patches.
It moves the certificate handling to its own directory rather than sharing
in the kernel/ directory.  It then moves key generation into the certs/
directory rather than doing it in the root.

This allows us to simplify the kernel/Makefile and slightly simplify the
new certs/Makefile.  It also keeps the various generated files in the same
place to make them easier to find and clean up.

David
---
The following changes since commit 0e38c35815f50e5a347977d76fb5eb4c3bf020b5:

  Merge branch 'smack-for-4.3' of https://github.com/cschaufler/smack-next into 
next (2015-08-14 17:35:10 +1000)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git 
tags/modsign-pkcs7-20150814

for you to fetch changes up to 3ee550f12c1529a023f71c9b5becb3351911047b:

  modsign: Handle signing key in source tree (2015-08-14 16:32:52 +0100)


Module signing with PKCS#7


David Howells (1):
  Move certificate handling to its own directory

David Woodhouse (2):
  modsign: Use if_changed rule for extracting cert from module signing key
  modsign: Handle signing key in source tree

 Documentation/module-signing.txt|  18 ++--
 MAINTAINERS |   9 ++
 Makefile|   9 +-
 certs/Kconfig   |  42 ++
 certs/Makefile  |  94 +
 {kernel => certs}/system_certificates.S |   4 +-
 {kernel => certs}/system_keyring.c  |   0
 crypto/Kconfig  |   1 +
 init/Kconfig|  39 -
 kernel/Makefile | 143 
 scripts/Kbuild.include  |  51 
 11 files changed, 212 insertions(+), 198 deletions(-)
 create mode 100644 certs/Kconfig
 create mode 100644 certs/Makefile
 rename {kernel => certs}/system_certificates.S (86%)
 rename {kernel => certs}/system_keyring.c (100%)
--
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/


kernel 3.13-61/62 /cpu1/cpufreq/stats

2015-08-24 Thread Ludwig Petrosyan
Hello

we have problem boot kernel 3.13-61/62 on the MTCA crate, some time it
boots some time no.
In the kernel log we found this problem:

[   16.168871] [ cut here ]
[   16.173513] WARNING: CPU: 0 PID: 4 at
/build/linux-lts-trusty-G19QHO/linux-lts-trusty-3.13.0/fs/sysfs/dir.c:486 
sysfs_warn_dup+0x91/0xb0()
[   16.185967] sysfs: cannot create duplicate filename
'/devices/system/cpu/cpu1/cpufreq/stats'

we found out thid peoblen is solved in the kernel 3.14 (file
linux/drivers/cpufreq/cpufreq.c), is there some way to solve it for
kernel 3.13-61/62
(some boot parameters ...) ?

The older kernel 3.13-55 runs fine on the same CPU.


with best regards

Ludwig Petrosyan
DESY

--
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/3] KVM: make halt_poll_ns per-VCPU

2015-08-24 Thread Wanpeng Li
Change halt_poll_ns into per-VCPU variable, seeded from module parameter,
to allow greater flexibility.

Signed-off-by: Wanpeng Li 
---
 include/linux/kvm_host.h | 1 +
 virt/kvm/kvm_main.c  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 81089cf..1bef9e2 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -242,6 +242,7 @@ struct kvm_vcpu {
int sigset_active;
sigset_t sigset;
struct kvm_vcpu_stat stat;
+   unsigned int halt_poll_ns;
 
 #ifdef CONFIG_HAS_IOMEM
int mmio_needed;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index d8db2f8f..a122b52 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -217,6 +217,7 @@ int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, 
unsigned id)
vcpu->kvm = kvm;
vcpu->vcpu_id = id;
vcpu->pid = NULL;
+   vcpu->halt_poll_ns = halt_poll_ns;
init_waitqueue_head(>wq);
kvm_async_pf_vcpu_init(vcpu);
 
-- 
1.9.1

--
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] KVM: trace kvm_halt_poll_ns grow/shrink

2015-08-24 Thread Wanpeng Li
Tracepoint for dynamic halt_pool_ns, fired on every potential change.

Signed-off-by: Wanpeng Li 
---
 include/trace/events/kvm.h | 30 ++
 virt/kvm/kvm_main.c|  8 
 2 files changed, 38 insertions(+)

diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h
index a44062d..75ddf80 100644
--- a/include/trace/events/kvm.h
+++ b/include/trace/events/kvm.h
@@ -356,6 +356,36 @@ TRACE_EVENT(
  __entry->address)
 );
 
+TRACE_EVENT(kvm_halt_poll_ns,
+   TP_PROTO(bool grow, unsigned int vcpu_id, int new, int old),
+   TP_ARGS(grow, vcpu_id, new, old),
+
+   TP_STRUCT__entry(
+   __field(bool, grow)
+   __field(unsigned int, vcpu_id)
+   __field(int, new)
+   __field(int, old)
+   ),
+
+   TP_fast_assign(
+   __entry->grow   = grow;
+   __entry->vcpu_id= vcpu_id;
+   __entry->new= new;
+   __entry->old= old;
+   ),
+
+   TP_printk("vcpu %u: halt_pool_ns %d (%s %d)",
+   __entry->vcpu_id,
+   __entry->new,
+   __entry->grow ? "grow" : "shrink",
+   __entry->old)
+);
+
+#define trace_kvm_halt_poll_ns_grow(vcpu_id, new, old) \
+   trace_kvm_halt_poll_ns(true, vcpu_id, new, old)
+#define trace_kvm_halt_poll_ns_shrink(vcpu_id, new, old) \
+   trace_kvm_halt_poll_ns(false, vcpu_id, new, old)
+
 #endif
 
 #endif /* _TRACE_KVM_MAIN_H */
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index bcfbd35..65e3631 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1959,13 +1959,21 @@ static unsigned int __shrink_halt_poll_ns(int val, int 
modifier, int minimum)
 
 static void grow_halt_poll_ns(struct kvm_vcpu *vcpu)
 {
+   int old = vcpu->halt_poll_ns;
+
vcpu->halt_poll_ns = __grow_halt_poll_ns(vcpu->halt_poll_ns);
+
+   trace_kvm_halt_poll_ns_grow(vcpu->vcpu_id, vcpu->halt_poll_ns, old);
 }
 
 static void shrink_halt_poll_ns(struct kvm_vcpu *vcpu)
 {
+   int old = vcpu->halt_poll_ns;
+
vcpu->halt_poll_ns = __shrink_halt_poll_ns(vcpu->halt_poll_ns,
halt_poll_ns_shrink, halt_poll_ns);
+
+   trace_kvm_halt_poll_ns_shrink(vcpu->vcpu_id, vcpu->halt_poll_ns, old);
 }
 
 /*
-- 
1.9.1

--
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] KVM: Dynamic halt_poll_ns

2015-08-24 Thread Wanpeng Li
There is a downside of halt_poll_ns since poll is still happen for idle 
VCPU which can waste cpu usage. This patchset add the ability to adjust 
halt_poll_ns dynamically, grows halt_poll_ns if an interrupt arrives and 
shrinks halt_poll_ns when idle VCPU is detected.

There are two new kernel parameters for changing the halt_poll_ns:
halt_poll_ns_grow and halt_poll_ns_shrink. halt_poll_ns_grow affects 
halt_poll_ns when an interrupt arrives and halt_poll_ns_shrink
does it when idle VCPU is detected. 

  halt_poll_ns_shrink/ |
  halt_poll_ns_grow| interrupt arrives| idle VCPU is detected
  -+--+---
  < 1  |  = halt_poll_ns  |  = 0 
  < halt_poll_ns   | *= halt_poll_ns_grow | /= halt_poll_ns_shrink
  otherwise| += halt_poll_ns_grow | -= halt_poll_ns_shrink

A third new parameter, halt_poll_ns_max, controls the maximal halt_poll_ns;
it is internally rounded down to a closest multiple of halt_poll_ns_grow.

Wanpeng Li (3):
  KVM: make halt_poll_ns per-VCPU
  KVM: dynamise halt_poll_ns adjustment 
  KVM: trace kvm_halt_poll_ns grow/shrink 

 include/linux/kvm_host.h   |  1 +
 include/trace/events/kvm.h | 30 
 virt/kvm/kvm_main.c| 90 +-
 3 files changed, 120 insertions(+), 1 deletion(-)

-- 
1.9.1

--
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] KVM: dynamise halt_poll_ns adjustment

2015-08-24 Thread Wanpeng Li
There are two new kernel parameters for changing the halt_poll_ns:
halt_poll_ns_grow and halt_poll_ns_shrink. halt_poll_ns_grow affects 
halt_poll_ns when an interrupt arrives and halt_poll_ns_shrink
does it when idle VCPU is detected. 

  halt_poll_ns_shrink/ |
  halt_poll_ns_grow| interrupt arrives| idle VCPU is detected
  -+--+---
  < 1  |  = halt_poll_ns  |  = 0 
  < halt_poll_ns   | *= halt_poll_ns_grow | /= halt_poll_ns_shrink
  otherwise| += halt_poll_ns_grow | -= halt_poll_ns_shrink

A third new parameter, halt_poll_ns_max, controls the maximal halt_poll_ns;
it is internally rounded down to a closest multiple of halt_poll_ns_grow.

Signed-off-by: Wanpeng Li 
---
 virt/kvm/kvm_main.c | 81 -
 1 file changed, 80 insertions(+), 1 deletion(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index a122b52..bcfbd35 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -66,9 +66,28 @@
 MODULE_AUTHOR("Qumranet");
 MODULE_LICENSE("GPL");
 
-static unsigned int halt_poll_ns;
+#define KVM_HALT_POLL_NS  50
+#define KVM_HALT_POLL_NS_GROW   2
+#define KVM_HALT_POLL_NS_SHRINK 0
+#define KVM_HALT_POLL_NS_MAX \
+   INT_MAX / KVM_HALT_POLL_NS_GROW
+
+static unsigned int halt_poll_ns = KVM_HALT_POLL_NS;
 module_param(halt_poll_ns, uint, S_IRUGO | S_IWUSR);
 
+/* Default doubles per-vcpu halt_poll_ns. */
+static int halt_poll_ns_grow = KVM_HALT_POLL_NS_GROW;
+module_param(halt_poll_ns_grow, int, S_IRUGO);
+
+/* Default resets per-vcpu halt_poll_ns . */
+int halt_poll_ns_shrink = KVM_HALT_POLL_NS_SHRINK;
+module_param(halt_poll_ns_shrink, int, S_IRUGO);
+
+/* Default is to compute the maximum so we can never overflow. */
+unsigned int halt_poll_ns_actual_max = KVM_HALT_POLL_NS_MAX;
+unsigned int halt_poll_ns_max = KVM_HALT_POLL_NS_MAX;
+module_param(halt_poll_ns_max, int, S_IRUGO);
+
 /*
  * Ordering of locks:
  *
@@ -1907,6 +1926,62 @@ void kvm_vcpu_mark_page_dirty(struct kvm_vcpu *vcpu, 
gfn_t gfn)
 }
 EXPORT_SYMBOL_GPL(kvm_vcpu_mark_page_dirty);
 
+static unsigned int __grow_halt_poll_ns(unsigned int val)
+{
+   if (halt_poll_ns_grow < 1)
+   return halt_poll_ns;
+
+   val = min(val, halt_poll_ns_actual_max);
+
+   if (val == 0)
+   return halt_poll_ns;
+
+   if (halt_poll_ns_grow < halt_poll_ns)
+   val *= halt_poll_ns_grow;
+   else
+   val += halt_poll_ns_grow;
+
+   return val;
+}
+
+static unsigned int __shrink_halt_poll_ns(int val, int modifier, int minimum)
+{
+   if (modifier < 1)
+   return 0;
+
+   if (modifier < halt_poll_ns)
+   val /= modifier;
+   else
+   val -= modifier;
+
+   return val;
+}
+
+static void grow_halt_poll_ns(struct kvm_vcpu *vcpu)
+{
+   vcpu->halt_poll_ns = __grow_halt_poll_ns(vcpu->halt_poll_ns);
+}
+
+static void shrink_halt_poll_ns(struct kvm_vcpu *vcpu)
+{
+   vcpu->halt_poll_ns = __shrink_halt_poll_ns(vcpu->halt_poll_ns,
+   halt_poll_ns_shrink, halt_poll_ns);
+}
+
+/*
+ * halt_poll_ns_actual_max is computed to be one grow_halt_poll_ns() below
+ * halt_poll_ns_max. (See __grow_halt_poll_ns for the reason.)
+ * This prevents overflows, because ple_halt_poll_ns is int.
+ * halt_poll_ns_max effectively rounded down to a multiple of 
halt_poll_ns_grow in
+ * this process.
+ */
+static void update_halt_poll_ns_actual_max(void)
+{
+   halt_poll_ns_actual_max =
+   __shrink_halt_poll_ns(max(halt_poll_ns_max, halt_poll_ns),
+   halt_poll_ns_grow, INT_MIN);
+}
+
 static int kvm_vcpu_check_block(struct kvm_vcpu *vcpu)
 {
if (kvm_arch_vcpu_runnable(vcpu)) {
@@ -1941,6 +2016,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
 */
if (kvm_vcpu_check_block(vcpu) < 0) {
++vcpu->stat.halt_successful_poll;
+   grow_halt_poll_ns(vcpu);
goto out;
}
cur = ktime_get();
@@ -1954,6 +2030,8 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
break;
 
waited = true;
+   if (halt_poll_ns)
+   shrink_halt_poll_ns(vcpu);
schedule();
}
 
@@ -2950,6 +3028,7 @@ static void hardware_enable_nolock(void *junk)
cpumask_set_cpu(cpu, cpus_hardware_enabled);
 
r = kvm_arch_hardware_enable();
+   update_halt_poll_ns_actual_max();
 
if (r) {
cpumask_clear_cpu(cpu, cpus_hardware_enabled);
-- 
1.9.1

--
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  

Re: [PATCH 3/3 v5] mm/vmalloc: Cache the vmalloc memory info

2015-08-24 Thread George Spelvin
(I hope I'm not annoying you by bikeshedding this too much, although I
think this is improving.)

You've sort of re-invented spinlocks, but after thinking a bit,
it all works.

Rather than using a single word, which is incremented to an odd number
at the start of an update and an even number at the end, there are
two.  An update is in progress when they're unequal.

vmap_info_gen is incremented early, when the cache needs updating, and
read late (after the cache is copied).

vmap_info_cache_gen is incremented after the cache is updated, and read
early (before the cache is copied).


This is logically equivalent to my complicated scheme with atomic updates
to various bits in a single generation word, but greatly simplified by
having two separate words.  In particular, there's no longer a need to
distinguish "vmap has updated list" from "calc_vmalloc_info in progress".

I particularly like the "gen - vmap_info_cache_gen > 0" test.
You *must* test for inequality to prevent tearing of a valid cache
(...grr...English heteronyms...), and given that, might as well
require it be fresher.


Anyway, suggested changes for v6 (sigh...):

First: you do a second read of vmap_info_gen to optimize out the copy
of vmalloc_info if it's easily seen as pointless, but given how small
vmalloc_info is (two words!), i'd be inclined to omit that optimization.

Copy always, *then* see if it's worth keeping.  Smaller code, faster
fast path, and is barely noticeable on the slow path.


Second, and this is up to you, I'd be inclined to go fully non-blocking and
only spin_trylock().  If that fails, just skip the cache update.


Third, ANSI C rules allow a compiler to assume that signed integer
overflow does not occur.  That means that gcc is allowed to optimize
"if (x - y > 0)" to "if (x > y)".

Given that gcc has annoyed us by using this optimization in other
contexts, It might be safer to make them unsigned (which is required to
wrap properly) and cast to integer after subtraction.


Basically, the following (untested, but pretty damn simple):

+/*
+ * Return a consistent snapshot of the current vmalloc allocation
+ * statistics, for /proc/meminfo:
+ */
+void get_vmalloc_info(struct vmalloc_info *vmi)
+{
+   unsigned gen, cache_gen = READ_ONCE(vmap_info_cache_gen);
+
+   /*
+* The two read barriers make sure that we read
+* 'cache_gen', 'vmap_info_cache' and 'gen' in
+* precisely that order:
+*/
+   smp_rmb();
+   *vmi = vmap_info_cache;
+
+   smp_rmb();
+   gen = READ_ONCE(vmap_info_gen);
+
+   /*
+* If the generation counter of the cache matches that of
+* the vmalloc generation counter then return the cache:
+*/
+   if (gen == cache_gen)
+   return;
+
+   /* Make sure 'gen' is read before the vmalloc info */
+   smp_rmb();
+   calc_vmalloc_info(vmi);
+
+   /*
+* All updates to vmap_info_cache_gen go through this spinlock,
+* so when the cache got invalidated, we'll only mark it valid
+* again if we first fully write the new vmap_info_cache.
+*
+* This ensures that partial results won't be used.
+*/
+   if (spin_trylock(_info_lock)) {
+   if ((int)(gen - vmap_info_cache_gen) > 0) {
+   vmap_info_cache = *vmi;
+   /*
+* Make sure the new cached data is visible before
+* the generation counter update:
+*/
+   smp_wmb();
+   WRITE_ONCE(vmap_info_cache_gen, gen);
+   }
+   spin_unlock(_info_lock);
+   }
+}
+
+#endif /* CONFIG_PROC_FS */

The only remaining *very small* nit is that this function is a mix of
"return early" and "wrap it in an if()" style.  If you want to make that
"if (!spin_trylock(...)) return;", I leave that you your esthetic judgement.
--
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 06/14] Documentation: drm/bridge: add document for analogix_dp

2015-08-24 Thread Yakir Yang

Hi Jingoo,

在 08/24/2015 03:40 PM, Jingoo Han 写道:

On 2015. 8. 24., at AM 9:43, Krzysztof Kozlowski  
wrote:

2015-08-24 8:23 GMT+09:00 Rob Herring :

On Wed, Aug 19, 2015 at 9:50 AM, Yakir Yang  wrote:
Analogix dp driver is split from exynos dp driver, so we just
make an copy of exynos_dp.txt, and then simplify exynos_dp.txt

Beside update some exynos dtsi file with the latest change
according to the devicetree binding documents.

You can't just change the exynos bindings and break compatibility. Is
there some agreement with exynos folks to do this?

No, there is no agreement. This wasn't even sent to Exynos maintainers.
Additionally the patchset did not look interesting to me because of
misleading subject - Documentation instead of "ARM: dts:".

Yakir, please:
1. Provide backward compatibility. Mark old properties as deprecated
but still support them.
2. Separate all DTS changes to a separate patch, unless bisectability
would be hurt. Anyway you should prepare it in a such way that
separation would be possible without breaking bisectability.
3. Use proper subject for the patch changing DTS. This is not
documentation change!
4. Please use script get_maintainers to obtain list of valid
maintainers and CC-them with at least cover letter and patches
requiring their attention.

To Yakir Yang,

Please be careful when you CC people.

I don't find the reason why you CC'ed the following people. Of course, they
look to be one of the talented developers. However, they look to be
unrelated to your patchset.

  Takashi Iwai
  Vincent Palatin
  Fabio Estevam
  Philipp Zabel


Yeah, actually I just got those people from patman tools. Thanks for your
remind, I would pay more attention in next version :-)



Also, please add Exynos Architecture maintainers to CC list. I don't understand
why you removed them from CC list.
  Kukjin Kim
  Krzysztof Kozlowski

Without their Ack, you will not change the codes of ARM Exynos Architecture.


Wow, thanks a lot, it's a serious mistaken  ;)

Thanks,
- Yakir


Best regards,
Jingoo Han


Best regards,
Krzysztof





Signed-off-by: Yakir Yang 
---
Changes in v3:
- Take Heiko suggest, add devicetree binding documents.
- Take Thierry Reding suggest, remove sync pol & colorimetry properies
  from the new analogix dp driver devicetree binding.
- Update the exist exynos dtsi file with the latest DP DT properies.

Changes in v2: None

.../devicetree/bindings/drm/bridge/analogix_dp.txt | 70 ++
.../devicetree/bindings/video/exynos_dp.txt| 50 ++--
arch/arm/boot/dts/exynos5250-arndale.dts   | 10 ++--
arch/arm/boot/dts/exynos5250-smdk5250.dts  | 10 ++--
arch/arm/boot/dts/exynos5250-snow.dts  | 12 ++--
arch/arm/boot/dts/exynos5250-spring.dts| 12 ++--
arch/arm/boot/dts/exynos5420-peach-pit.dts | 12 ++--
arch/arm/boot/dts/exynos5420-smdk5420.dts  | 10 ++--
arch/arm/boot/dts/exynos5800-peach-pi.dts  | 12 ++--
9 files changed, 119 insertions(+), 79 deletions(-)
create mode 100644 Documentation/devicetree/bindings/drm/bridge/analogix_dp.txt

diff --git a/Documentation/devicetree/bindings/drm/bridge/analogix_dp.txt 
b/Documentation/devicetree/bindings/drm/bridge/analogix_dp.txt
new file mode 100644
index 000..6127018
--- /dev/null
+++ b/Documentation/devicetree/bindings/drm/bridge/analogix_dp.txt
@@ -0,0 +1,70 @@
+Analogix Display Port bridge bindings
+
+Required properties for dp-controller:
+   -compatible:
+   platform specific such as:
+* "samsung,exynos5-dp"
+* "rockchip,rk3288-dp"
+   -reg:
+   physical base address of the controller and length
+   of memory mapped region.
+   -interrupts:
+   interrupt combiner values.
+   -clocks:
+   from common clock binding: handle to dp clock.
+   -clock-names:
+   from common clock binding: Shall be "dp".
+   -interrupt-parent:
+   phandle to Interrupt combiner node.
+   -phys:
+   from general PHY binding: the phandle for the PHY device.
+   -phy-names:
+   from general PHY binding: Should be "dp".
+   -analogix,color-space:
+   input video data format.
+   COLOR_RGB = 0, COLOR_YCBCR422 = 1, COLOR_YCBCR444 = 2
+   -analogix,color-depth:
+   number of bits per colour component.
+   COLOR_6 = 0, COLOR_8 = 1, COLOR_10 = 2, COLOR_12 = 3

This seems pretty generic. Just use 6, 8, 10, or 12 for values. And
drop the vendor prefix.


+   -analogix,link-rate:
+   max link rate supported by the eDP controller.
+   LINK_RATE_1_62GBPS = 0x6, LINK_RATE_2_70GBPS = 0x0A,
+   LINK_RATE_5_40GBPS = 0x14

Same here. I'd rather see something like "link-rate-mbps" and use the
actual rate.


+   -analogix,lane-count:
+   max number of lanes supported by the 

[PATCH RESEND 2/2] ovl: free lower_mnt array in ovl_put_super

2015-08-24 Thread Konstantin Khlebnikov
This fixes memory leak after umount.

Kmemleak report:

unreferenced object 0x8800ba791010 (size 8):
  comm "mount", pid 2394, jiffies 4294996294 (age 53.920s)
  hex dump (first 8 bytes):
20 1c 13 02 00 88 ff ff   ...
  backtrace:
[] create_object+0x124/0x2c0
[] kmemleak_alloc+0x7b/0xc0
[] __kmalloc+0x106/0x340
[] ovl_fill_super+0x55c/0x9b0 [overlay]
[] mount_nodev+0x54/0xa0
[] ovl_mount+0x18/0x20 [overlay]
[] mount_fs+0x43/0x170
[] vfs_kern_mount+0x74/0x170
[] do_mount+0x22d/0xdf0
[] SyS_mount+0x7b/0xc0
[] entry_SYSCALL_64_fastpath+0x12/0x76
[] 0x

Signed-off-by: Konstantin Khlebnikov 
Fixes: dd662667e6d3 ("ovl: add mutli-layer infrastructure")
Cc: sta...@vger.kernel.org # v4.0
---
 fs/overlayfs/super.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 3f90c43c3c4a..8d04b86e0680 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -544,6 +544,7 @@ static void ovl_put_super(struct super_block *sb)
mntput(ufs->upper_mnt);
for (i = 0; i < ufs->numlower; i++)
mntput(ufs->lower_mnt[i]);
+   kfree(ufs->lower_mnt);
 
kfree(ufs->config.lowerdir);
kfree(ufs->config.upperdir);

--
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 RESEND 1/2] ovl: free stack of paths in ovl_fill_super

2015-08-24 Thread Konstantin Khlebnikov
This fixes small memory leak after mount.

Kmemleak report:

unreferenced object 0x88003683fe00 (size 16):
  comm "mount", pid 2029, jiffies 4294909563 (age 33.380s)
  hex dump (first 16 bytes):
20 27 1f bb 00 88 ff ff 40 4b 0f 36 02 88 ff ff   '..@K.6
  backtrace:
[] create_object+0x124/0x2c0
[] kmemleak_alloc+0x7b/0xc0
[] __kmalloc+0x106/0x340
[] ovl_fill_super+0x389/0x9a0 [overlay]
[] mount_nodev+0x54/0xa0
[] ovl_mount+0x18/0x20 [overlay]
[] mount_fs+0x43/0x170
[] vfs_kern_mount+0x74/0x170
[] do_mount+0x22d/0xdf0
[] SyS_mount+0x7b/0xc0
[] entry_SYSCALL_64_fastpath+0x12/0x76
[] 0x

Signed-off-by: Konstantin Khlebnikov 
Fixes: a78d9f0d5d5c ("ovl: support multiple lower layers")
Cc: sta...@vger.kernel.org # v4.0
---
 fs/overlayfs/super.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 7466ff339c66..3f90c43c3c4a 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -1048,6 +1048,7 @@ static int ovl_fill_super(struct super_block *sb, void 
*data, int silent)
oe->lowerstack[i].dentry = stack[i].dentry;
oe->lowerstack[i].mnt = ufs->lower_mnt[i];
}
+   kfree(stack);
 
root_dentry->d_fsdata = oe;
 

--
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 06/14] Documentation: drm/bridge: add document for analogix_dp

2015-08-24 Thread Russell King - ARM Linux
On Sun, Aug 23, 2015 at 06:23:14PM -0500, Rob Herring wrote:
> On Wed, Aug 19, 2015 at 9:50 AM, Yakir Yang  wrote:
> > +   -analogix,color-depth:
> > +   number of bits per colour component.
> > +   COLOR_6 = 0, COLOR_8 = 1, COLOR_10 = 2, COLOR_12 = 3
> 
> This seems pretty generic. Just use 6, 8, 10, or 12 for values. And
> drop the vendor prefix.

Please think about this some more.  What does "color-depth" mean?  Does it
mean the number of bits per colour _component_, or does it mean the total
number of bits to represent a particular colour.  It's confusing as it
stands.

> > +Optional properties for dp-controller:
> > +   -analogix,hpd-gpio:
> > +   Hotplug detect GPIO.
> > +   Indicates which GPIO should be used for hotplug
> > +   detection
> 
> We should align with "hpd-gpios" used by HDMI connector binding. Or do
> we need a DP connector binding that this should be defined in?
> Probably so.
> 
> The DRM related bindings are such a cluster f*ck with everyone picking
> their own way to do things. Just grep hpd in bindings for starters.
> That is just the tip.

I'm not surprised one iota that DRM bindings are a mess.  There's no one
overlooking the adoption of DRM bindings, so surprise surprise, everyone
does their own thing.  This is exactly what happens every time in that
scenario.  It's not a new problem.

When we adopted the graph bindings for iMX DRM, I thought exactly at that
time "it would be nice if this could become the standard for binding DRM
components together" but I don't have the authority from either the DT
perspective or the DRM perspective to mandate that.  Neither does anyone
else.  That's the _real_ problem here.

I've seen several DRM bindings go by which don't use the of-graph stuff,
which means that they'll never be compatible with generic components
which do use the of-graph stuff.

Like you say, it's a mess, but it's a mess of our own making, because no
one has the authority to regulate this.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
--
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 1/2] mfd: devicetree: bindings: 88pm800: Add DT property for dual phase enable

2015-08-24 Thread Lee Jones
On Mon, 24 Aug 2015, Vaibhav Hiremath wrote:

> 88PM860 family of device supports dual phase mode on BUCK1 supply
> providing total 6A capacity.
> Note that by default they operate independently with 3A capacity.
> 
> This patch updates the devicetree binding with DT property
> to enable dual-phase mode on BUCK1.
> 
> Signed-off-by: Vaibhav Hiremath 
> ---
>  Documentation/devicetree/bindings/mfd/88pm800.txt | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/88pm800.txt 
> b/Documentation/devicetree/bindings/mfd/88pm800.txt
> index dec842f..2c82fcb 100644
> --- a/Documentation/devicetree/bindings/mfd/88pm800.txt
> +++ b/Documentation/devicetree/bindings/mfd/88pm800.txt
> @@ -9,6 +9,12 @@ Required parent device properties:
>  - #interrupt-cells   : should be 1.
> The cell is the 88pm80x local IRQ number
>  
> +Optional properties :
> +- marvell,88pm860-buck1-dualphase-en  : If set, enable dual phase on BUCK1,
> +  providing 6A capacity.
> +  Without this both BUCK1A and BUCK1B operates independently with 3A 
> capacity.
> +  (This property is only applicable to 88PM860)

This will require a Regulator Ack.

My suggestion would be to remove the 'buck' number, as the same
property could be used on any Buck, and remove the '-en' part, as
this is implied.

>  88pm80x family of devices consists of varied group of sub-devices:
>  
>  Device   Supply Names Description

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
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: fbtft: Removed a space before comma

2015-08-24 Thread Sudip Mukherjee
On Thu, Aug 20, 2015 at 08:57:57PM +0530, Aparna Karuthodi wrote:
> Removed a space before coma to remove a coding style error detected by
> checkpatch.
> The error is given below:
> drivers/staging/fbtft/fb_ili9340.c:47: ERROR: space prohibited before
> that ',' (ctx:WxW)
> 
> Signed-off-by: Aparna Karuthodi 
> ---
I think you need to update your tree. This has already been done by:
43da0d92ab7d ("staging: fbtft: fix space prohibited before that ','")

regards
sudip
--
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 01/10] irqchip: irq-mips-gic: export gic_send_ipi

2015-08-24 Thread Qais Yousef

On 08/24/2015 01:49 PM, Thomas Gleixner wrote:

On Mon, 24 Aug 2015, Qais Yousef wrote:


Some drivers might require to send ipi to other cores. So export it.

Which IPIs do you need to send from a driver which are not exposed by
the SMP functions already?


It's not an SMP IPI. We use GIC to exchange interrupts between AXD and 
the host system since AXD is another MIPS core in the cluster.



This will be used later by AXD driver.

That smells fishy and it wants a proper explanation WHY and not just a
sloppy statement that it will be used later. I can figure that out
myself as exporting a function without using it does not make any sense.


Sorry for the terse explanation. As pointed above AXD uses GIC to send 
and receive interrupts to the host core. Without this change I can't 
compile the driver as a driver module because the symbol is not exported.


Does this make things clearer?

Thanks,
Qais



Thanks,

tglx


--
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 06/14] Documentation: drm/bridge: add document for analogix_dp

2015-08-24 Thread Heiko Stuebner
Hi Yakir,

Am Montag, 24. August 2015, 20:48:01 schrieb Yakir Yang:
> 在 08/24/2015 12:20 PM, Krzysztof Kozlowski 写道:
> > On 24.08.2015 11:42, Yakir Yang wrote:
> >> Hi Krzysztof,
> >> 
> >> 在 08/23/2015 07:43 PM, Krzysztof Kozlowski 写道:
> >>> 2015-08-24 8:23 GMT+09:00 Rob Herring :
>  On Wed, Aug 19, 2015 at 9:50 AM, Yakir Yang  wrote:
> > Analogix dp driver is split from exynos dp driver, so we just
> > make an copy of exynos_dp.txt, and then simplify exynos_dp.txt
> > 
> > Beside update some exynos dtsi file with the latest change
> > according to the devicetree binding documents.
>  
>  You can't just change the exynos bindings and break compatibility. Is
>  there some agreement with exynos folks to do this?
> >>> 
> >>> No, there is no agreement. This wasn't even sent to Exynos maintainers.
> >> 
> >> Sorry about this one, actually I have add Exynos maintainers in version
> >> 1 & version 2,
> >> but lose some maintainers in version 3, I would fix it in bellow
> >> versions.
> >> 
> >>> Additionally the patchset did not look interesting to me because of
> >>> misleading subject - Documentation instead of "ARM: dts:".
> >>> 
> >>> Yakir, please:
> >>> 1. Provide backward compatibility. Mark old properties as deprecated
> >>> but still support them.
> >> 
> >> Do you mean that I should keep the old properties declare in
> >> exynos-dp.txt,
> >> but just mark them as deprecated flag.
> > 
> > That is one of ways how to do this. However more important is that
> > driver should still support old bindings so such code:
> > -   if (of_property_read_u32(dp_node, "samsung,color-space",
> > +   if (of_property_read_u32(dp_node, "analogix,color-space",
> > 
> > is probably wrong. Will the driver support old DTB in the same way as it
> > was supporting before the change?
> 
> Okay, I got your means. So document is not the focus, the most important
> is that
> driver should support the old dts prop. If so the new analogix dp driver
> should keep
> the "samsung,color-space", rather then just mark it with [DEPRECATED] flag.
> 
> But from your follow suggest, I think you agree to update driver code,
> and just mark
> old prop with deprecated flag. If so I think such code would not be wrong
> 
> -   if (of_property_read_u32(dp_node, "samsung,color-space",
> +  if (of_property_read_u32(dp_node, "analogix,color-space",

In a generic driver, the property should have either none, or the analogix 
prefix. But DT-properties need to be backwards compatible, meaning an older 
Exynos devicetree should run unmodified with a newer kernel.

So the common course of action is to mark the old one as deprecated but still 
test for both, so something like:

   if (of_property_read_u32(dp_node, "analogix,color-space",
 _video_config->color_space))
   if (of_property_read_u32(dp_node, "samsung,color-space",
 _video_config->color_space)) {

dev_err(dev, "failed to get color-space\n");
return ERR_PTR(-EINVAL);
}




--
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 5/5] arm64: add KASan support

2015-08-24 Thread Linus Walleij
On Wed, Aug 19, 2015 at 4:51 PM, Andrey Ryabinin  wrote:
> On 08/19/2015 03:14 PM, Linus Walleij wrote:

>> Integrator/AP (ARMv5):
>>
>> This one mounted with an ARMv5 ARM926 tile. It boots nicely
>> (but takes forever) with KASan and run all test cases (!) just like
>> for the other platforms but before reaching userspace this happens:
>
> THREAD_SIZE hardcoded in act_mm macro.
>
> This hack should help:
>
> diff --git a/arch/arm/mm/proc-macros.S b/arch/arm/mm/proc-macros.S
> index c671f34..b1765f2 100644
> --- a/arch/arm/mm/proc-macros.S
> +++ b/arch/arm/mm/proc-macros.S
> @@ -32,6 +32,9 @@
> .macro  act_mm, rd
> bic \rd, sp, #8128
> bic \rd, \rd, #63
> +#ifdef CONFIG_KASAN
> +   bic \rd, \rd, #8192
> +#endif
> ldr \rd, [\rd, #TI_TASK]
> ldr \rd, [\rd, #TSK_ACTIVE_MM]
> .endm

Yes this work, thanks! I now get to userspace.
Tested-by: Linus Walleij 

I have compiled Trinity and running some stress on different boards.
The ARMv7 seems to rather die from random nasty stuff from the
syscall or OOM rather than any KASan-detected bugs, but I'll
keep hammering at it a big.

I have some odd patch I'll pass along.

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] staging: fbtft: Removed space before parenthesis

2015-08-24 Thread Sudip Mukherjee
On Fri, Aug 21, 2015 at 09:05:47PM +0530, Aparna Karuthodi wrote:
> Removed space before parenthesis in two different lines to remove coding
> style errors detected by checkpatch.
> The errors are given below:
> drivers/staging/fbtft/fbtft-bus.c:73: ERROR: space prohibited before
> that close parenthesis ')'
> drivers/staging/fbtft/fbtft-bus.c:75: ERROR: space prohibited before
> that close parenthesis ')'
> 
> Signed-off-by: Aparna Karuthodi 
> ---
>  drivers/staging/fbtft/fbtft-bus.c |4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/fbtft/fbtft-bus.c 
> b/drivers/staging/fbtft/fbtft-bus.c
> index b3cddb0..791fab3 100644
> --- a/drivers/staging/fbtft/fbtft-bus.c
> +++ b/drivers/staging/fbtft/fbtft-bus.c
> @@ -70,9 +70,9 @@ void func(struct fbtft_par *par, int len, ...)  
>   \
>  }
>  \
>  EXPORT_SYMBOL(func);
>  
> -define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, )
> +define_fbtft_write_reg(fbtft_write_reg8_bus8, u8)
>  define_fbtft_write_reg(fbtft_write_reg16_bus8, u16, cpu_to_be16)
> -define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, )
> +define_fbtft_write_reg(fbtft_write_reg16_bus16, u16)
Did you build test it?
You have removed ',' while removing the space and that breaks the build.

regards
sudip
--
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 5/9] x86/intel_rdt: Add new cgroup and Class of service management

2015-08-24 Thread Marcelo Tosatti
On Sun, Aug 23, 2015 at 11:47:49AM -0700, Vikas Shivappa wrote:
> 
> 
> On Fri, 21 Aug 2015, Marcelo Tosatti wrote:
> 
> >On Thu, Aug 20, 2015 at 05:06:51PM -0700, Vikas Shivappa wrote:
> >>
> >>
> >>On Mon, 17 Aug 2015, Marcelo Tosatti wrote:
> >>
> >>>Vikas, Tejun,
> >>>
> >>>This is an updated interface. It addresses all comments made
> >>>so far and also covers all use-cases the cgroup interface
> >>>covers.
> >>>
> >>>Let me know what you think. I'll proceed to writing
> >>>the test applications.
> >>>
> >>>Usage model:
> >>>
> >>>
> >>>This document details how CAT technology is
> >>>exposed to userspace.
> >>>
> >>>Each task has a list of task cache reservation entries (TCRE list).
> >>>
> >>>The init process is created with empty TCRE list.
> >>>
> >>>There is a system-wide unique ID space, each TCRE is assigned
> >>>an ID from this space. ID's can be reused (but no two TCREs
> >>>have the same ID at one time).
> >>>
> >>>The interface accomodates transient and independent cache allocation
> >>>adjustments from applications, as well as static cache partitioning
> >>>schemes.
> >>>
> >>>Allocation:
> >>>Usage of the system calls require CAP_SYS_CACHE_RESERVATION capability.
> >>>
> >>>A configurable percentage is reserved to tasks with empty TCRE list.
> >
> >Hi Vikas,
> >
> >>And how do you think you will do this without a system controlled
> >>mechanism ?
> >>Everytime in your proposal you include these caveats
> >>which actually mean to include a system controlled interface in the
> >>background ,
> >>and your below interfaces make no mention of this really ! Why do we
> >>want to confuse ourselves like this ?
> >>syscall only interface does not seem to work on its own for the
> >>cache allocation scenario. This can only be a nice to have interface
> >>on top of a system controlled mechanism like cgroup interface. Sure
> >>you can do all the things you did with cgroup with the same with
> >>syscall interface but the point is what are the use cases that cant
> >>be done with this syscall only interface. (ex: to deal with cases
> >>you brought up earlier like when an app does cache intensive work
> >>for some time and later changes - it could use the syscall interface
> >>to quickly reqlinquish the cache lines or change a clos associated
> >>with it)
> >
> >All use cases can be covered with the syscall interface.
> >
> >* How to convert from cgroups interface to syscall interface:
> >Cgroup: Partition cache in cgroups, add tasks to cgroups.
> >Syscall: Partition cache in TCRE, add TCREs to tasks.
> >
> >You build the same structure (task <--> CBM) either via syscall
> >or via cgroups.
> >
> >Please be more specific, can't really see any problem.
> 
> Well at first you mentioned that the cgroup does not support
> specifying size in bytes and percentage and then you eventually
> agreed to my explanation that you can easily write a bash script to
> do the same with cgroup bitmasks. (although i had to go through the
> pain of reading all the proposals you sent without giving a chance
> to explain how it can be used or so). 

Yes we could write the (bytes --to--> cacheways) convertion in
userspace. But since we are going for a different interface, can also
fix that problem as well in the kernel.

> Then you had a confusion in
> how I explained the co mounting of the cpuset and intel_rdt and
> instead of asking a question or pointing out issue, you go ahead and
> write a whole proposal and in the end even say will cook a patch
> before I even try to explain you.

The syscall interface is more flexible.

Why not use a more flexible interface if possible?

> And then you send proposals after proposals 
> which varied from
> modifying the cgroup interface itself to slightly modifying cgroups

Yes, trying to solve the problems our customers will be facing in the field.
So, this proposals are not coming out of thin air.

> and adding syscalls and then also automatically controlling the
> cache alloc (with all your extend mask capabilities) without
> understanding what the framework is meant to do or just asking or
> specifically pointing out any issues in the patch. 

There is a practical problem the "extension" of mask capabilities is 
solving. Check item 6 of the attached text document.

> You had been
> reviewing the cgroup pathes for many versions unlike others who
> accepted they need time to think about it or accepted that they
> maynot understand the feature yet.
> So what is that changed in the patches that is not acceptable now ?

Tejun proposed a syscall interface. He is a right, a syscall interface
is much more flexible. Blame him.

> Many things have been bought up multiple times even after you agreed
> to a solution already proposed. I was only suggesting that this can
> be better and less confusing if you point out the exact issue in the
> patch just like how Thomas or all of the reviewers have been doing.
>
> With the rest of the reviewers I either fix the issue or point out a
> 

Re: [PATCH] staging: fbtft: Made into two lines

2015-08-24 Thread Sudip Mukherjee
On Fri, Aug 21, 2015 at 06:38:39PM +0530, Aparna Karuthodi wrote:
> Made the comment into a new lineto remove a coding style error detected
> by checkpatch.
> The warning is given below:
> drivers/staging/fbtft/fb_pcd8544.c:37: WARNING: line over 80 characters
> 
> Signed-off-by: Aparna Karuthodi 
> ---
Please update your tree. This will also not apply for:
4178549e4c47 ("Staging: fbtft: fb_pcd8544: Fix comments style")

regards
sudip
--
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] nfs:Fix deadlock occurrence issue on error path in the function nfs_vm_page_mkwrite

2015-08-24 Thread Trond Myklebust
On Sat, Aug 22, 2015 at 9:17 PM, Nicholas Krause  wrote:
>
> This fixes a possible deadlock occurrence issue on the error path
> in the function nfs_vm_page_mkwrite for checking if the calls to
> the functions nfs_flus_incompatible and nfs_updatepage have failed
> by incorrectly not jumping to the correct goto label out_unlock
> for unlocking the locked structure page pointer thus causing a
> deadlock due to not correctly unlocking the internal structure
> page pointer used by the function nfs_vm_page_mkwrite that had
> been previously locked with the function lock_page. Further more
> we also remove the goto label out as no error paths in this function
> now use this label and this label should be removed to avoid build
> warnings related to having a undefined label.
>
> Signed-off-by: Nicholas Krause 
> ---
>  fs/nfs/file.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/nfs/file.c b/fs/nfs/file.c
> index cc4fa1e..fe68ecc 100644
> --- a/fs/nfs/file.c
> +++ b/fs/nfs/file.c
> @@ -629,12 +629,11 @@ static int nfs_vm_page_mkwrite(struct vm_area_struct 
> *vma, struct vm_fault *vmf)
> ret = VM_FAULT_LOCKED;
> if (nfs_flush_incompatible(filp, page) == 0 &&
> nfs_updatepage(filp, page, 0, pagelen) == 0)
> -   goto out;
> +   goto out_unlock;
>
> ret = VM_FAULT_SIGBUS;
>  out_unlock:
> unlock_page(page);
> -out:
> return ret;
>  }
>
>

That's the success path that you are modifying, not the error path.
Furthermore, the return value is still VM_FAULT_LOCKED, which means
the caller expects the page to be returned in the locked state.

So NACK

Trond
--
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 linux-next v4 5/5] mtd: atmel-quadspi: add driver for Atmel QSPI controller

2015-08-24 Thread Marek Vasut
On Monday, August 24, 2015 at 02:49:24 PM, Russell King - ARM Linux wrote:

Hi Russell,

> On Mon, Aug 24, 2015 at 01:03:51PM +0200, Marek Vasut wrote:
> > These are functions, not macros :)
> > 
> > btw is there any reason for these ? I'd say, just put the read*() and
> > write*() functions directly into the code and be done with it, it is
> > much less confusing.
> > 
> > Also, why do you use the _relaxed() versions of the functions ?
> 
> Now that the _relaxed() accessors are available throughout the kernel,
> everyone should be using the _relaxed() versions unless they need the
> properties of the non-relaxed versions.

You mean the memory barrier, right ?

> Remember that the non-relaxed
> versions are rather expensive on ARM due to the need to go all the way
> out to the L2 cache - it at least doubles the number of accesses for
> every read*/write*().

I think in case of this driver, we don't need the non-relaxed version
anywhere, right ? Thanks for the educational writeup :)

btw. is [1] still the current study material on the I/O accessor best
practices please ?

[1] http://permalink.gmane.org/gmane.linux.ports.arm.kernel/117644

Best regards,
Marek Vasut
--
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 5/5] arm64: add KASan support

2015-08-24 Thread Russell King - ARM Linux
On Tue, Jul 21, 2015 at 11:27:56PM +0200, Linus Walleij wrote:
> On Tue, Jul 21, 2015 at 4:27 PM, Andrey Ryabinin  
> wrote:
> 
> > I used vexpress. Anyway, it doesn't matter now, since I have an update
> > with a lot of stuff fixed, and it works on hardware.
> > I still need to do some work on it and tomorrow, probably, I will share.
> 
> Ah awesome. I have a stash of ARM boards so I can test it on a
> range of hardware once you feel it's ready.
> 
> Sorry for pulling stuff out of your hands, people are excited about
> KASan ARM32 as it turns out.

People may be excited about it because it's a new feature, but we really
need to consider whether gobbling up 512MB of userspace for it is a good
idea or not.  There are programs around which like to map large amounts
of memory into their process space, and the more we steal from them, the
more likely these programs are to fail.

The other thing which I'm not happy about is having a 16K allocation per
thread - the 16K allocation for the PGD is already prone to invoking the
OOM killer after memory fragmentation has set in, we don't need another
16K allocation.  We're going from one 16K allocation per process to that
_and_ one 16K allocation per thread.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
--
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 04/12] mm, page_alloc: Only check cpusets when one exists that can be mem-controlled

2015-08-24 Thread Mel Gorman
On Mon, Aug 24, 2015 at 02:37:41PM +0200, Vlastimil Babka wrote:
> >
> >+/* Returns true if a cpuset exists that can set cpuset.mems */
> >+static inline bool cpusets_mems_enabled(void)
> >+{
> >+return nr_cpusets() > 1;
> >+}
> >+
> 
> Hm, but this loses the benefits of static key branches?
> How about something like:
> 
>   if (static_key_false(_enabled_key))
>   return nr_cpusets() > 1
>   else
>   return false;
> 

Will do.

> 
> 
> >  static inline void cpuset_inc(void)
> >  {
> > static_key_slow_inc(_enabled_key);
> >@@ -104,7 +106,7 @@ extern void cpuset_print_task_mems_allowed(struct 
> >task_struct *p);
> >   */
> >  static inline unsigned int read_mems_allowed_begin(void)
> >  {
> >-if (!cpusets_enabled())
> >+if (!cpusets_mems_enabled())
> > return 0;
> >
> > return read_seqcount_begin(>mems_allowed_seq);
> >@@ -118,7 +120,7 @@ static inline unsigned int read_mems_allowed_begin(void)
> >   */
> >  static inline bool read_mems_allowed_retry(unsigned int seq)
> >  {
> >-if (!cpusets_enabled())
> >+if (!cpusets_mems_enabled())
> > return false;
> 
> Actually I doubt it's much of benefit for these usages, even if the static
> key benefits are restored. If there's a single root cpuset, we would check
> the seqlock prior to this patch, now we'll check static key value (which
> should have the same cost?). With >1 cpusets, we would check seqlock prior
> to this patch, now we'll check static key value *and* the seqlock...
> 

If the cpuset is enabled between the check, it still should retry.
Anyway, special casing this is overkill. It's a small
micro-optimisation.

> >
> > return read_seqcount_retry(>mems_allowed_seq, seq);
> >@@ -139,7 +141,7 @@ static inline void set_mems_allowed(nodemask_t nodemask)
> >
> >  #else /* !CONFIG_CPUSETS */
> >
> >-static inline bool cpusets_enabled(void) { return false; }
> >+static inline bool cpusets_mems_enabled(void) { return false; }
> >
> >  static inline int cpuset_init(void) { return 0; }
> >  static inline void cpuset_init_smp(void) {}
> >diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> >index 62ae28d8ae8d..2c1c3bf54d15 100644
> >--- a/mm/page_alloc.c
> >+++ b/mm/page_alloc.c
> >@@ -2470,7 +2470,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int 
> >order, int alloc_flags,
> > if (IS_ENABLED(CONFIG_NUMA) && zlc_active &&
> > !zlc_zone_worth_trying(zonelist, z, allowednodes))
> > continue;
> >-if (cpusets_enabled() &&
> >+if (cpusets_mems_enabled() &&
> > (alloc_flags & ALLOC_CPUSET) &&
> > !cpuset_zone_allowed(zone, gfp_mask))
> > continue;
> 
> Here the benefits are less clear. I guess cpuset_zone_allowed() is
> potentially costly...
> 
> Heck, shouldn't we just start the static key on -1 (if possible), so that
> it's enabled only when there's 2+ cpusets?

It's overkill for the amount of benefit.

-- 
Mel Gorman
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] nfs:Fix error handling in the function nfs_vm_page_mkwrite

2015-08-24 Thread Trond Myklebust
On Sat, Aug 22, 2015 at 6:34 PM, Nicholas Krause  wrote:
> This fixes error handling in the function nfs_vm_page_mkwrite to
> properly check if the function wait_on_bit_action returned something
> other then zero as if so return to the caller of nfs_vm_page_mkwrite
> to signal that a internal failure has occurred when calling this
> function and should be handled by the caller.
>
> Signed-off-by: Nicholas Krause 
> ---
>  fs/nfs/file.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/fs/nfs/file.c b/fs/nfs/file.c
> index cc4fa1e..698851a 100644
> --- a/fs/nfs/file.c
> +++ b/fs/nfs/file.c
> @@ -612,8 +612,10 @@ static int nfs_vm_page_mkwrite(struct vm_area_struct 
> *vma, struct vm_fault *vmf)
> /* make sure the cache has finished storing the page */
> nfs_fscache_wait_on_page_write(NFS_I(inode), page);
>
> -   wait_on_bit_action(_I(inode)->flags, NFS_INO_INVALIDATING,
> -   nfs_wait_bit_killable, TASK_KILLABLE);
> +   ret = wait_on_bit_action(_I(inode)->flags, NFS_INO_INVALIDATING,
> +nfs_wait_bit_killable, TASK_KILLABLE);
> +   if (ret)
> +   goto out;
>
> lock_page(page);
> mapping = page_file_mapping(page);
> --
> 2.1.4
>

nfs_vm_page_mkwrite() is only allowed to return the value '0' or one
or more of the VM_FAULT_* flags. It may not return kernel error
values.

Trond
--
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 02/13] usb: otg-fsm: support multiple instances

2015-08-24 Thread Roger Quadros
Move the state_changed variable into struct otg_fsm
so that we can support multiple instances.

Signed-off-by: Roger Quadros 
---
 drivers/usb/common/usb-otg-fsm.c | 10 --
 include/linux/usb/otg-fsm.h  |  1 +
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/common/usb-otg-fsm.c b/drivers/usb/common/usb-otg-fsm.c
index 61d538a..32862a4 100644
--- a/drivers/usb/common/usb-otg-fsm.c
+++ b/drivers/usb/common/usb-otg-fsm.c
@@ -61,8 +61,6 @@ static int otg_set_protocol(struct otg_fsm *fsm, int protocol)
return 0;
 }
 
-static int state_changed;
-
 /* Called when leaving a state.  Do state clean up jobs here */
 static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state)
 {
@@ -123,7 +121,6 @@ static void otg_leave_state(struct otg_fsm *fsm, enum 
usb_otg_state old_state)
 /* Called when entering a state */
 static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
 {
-   state_changed = 1;
if (fsm->otg->state == new_state)
return 0;
VDBG("Set state: %s\n", usb_otg_state_string(new_state));
@@ -237,6 +234,7 @@ static int otg_set_state(struct otg_fsm *fsm, enum 
usb_otg_state new_state)
}
 
fsm->otg->state = new_state;
+   fsm->state_changed = 1;
return 0;
 }
 
@@ -248,7 +246,7 @@ int otg_statemachine(struct otg_fsm *fsm)
mutex_lock(>lock);
 
state = fsm->otg->state;
-   state_changed = 0;
+   fsm->state_changed = 0;
/* State machine state change judgement */
 
switch (state) {
@@ -361,7 +359,7 @@ int otg_statemachine(struct otg_fsm *fsm)
}
mutex_unlock(>lock);
 
-   VDBG("quit statemachine, changed = %d\n", state_changed);
-   return state_changed;
+   VDBG("quit statemachine, changed = %d\n", fsm->state_changed);
+   return fsm->state_changed;
 }
 EXPORT_SYMBOL_GPL(otg_statemachine);
diff --git a/include/linux/usb/otg-fsm.h b/include/linux/usb/otg-fsm.h
index fc5b4d9..20c8219 100644
--- a/include/linux/usb/otg-fsm.h
+++ b/include/linux/usb/otg-fsm.h
@@ -195,6 +195,7 @@ struct otg_fsm {
/* Current usb protocol used: 0:undefine; 1:host; 2:client */
int protocol;
struct mutex lock;
+   bool state_changed;
 };
 
 struct otg_fsm_ops {
-- 
2.1.4

--
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 05/13] usb: hcd.h: Add OTG to HCD interface

2015-08-24 Thread Roger Quadros
The OTG core will use struct otg_hcd_ops to
add/remove the HCD controller.

The main purpose of this interface is to avoid directly
calling usb_add/remove_hcd() from the OTG core as they
wouldn't be defined in the built-in symbol table if
CONFIG_USB is m.

Signed-off-by: Roger Quadros 
Reviewed-by: Peter Chen 
---
 include/linux/usb/hcd.h | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index d2784c1..27d78b1 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -386,6 +386,20 @@ struct hc_driver {
 
 };
 
+/**
+ * struct otg_hcd_ops - Interface between OTG core and HCD
+ *
+ * Provided by the HCD core to allow the OTG core to start/stop the HCD
+ *
+ * @add: function to add the HCD
+ * @remove: function to remove the HCD
+ */
+struct otg_hcd_ops {
+   int (*add)(struct usb_hcd *hcd,
+  unsigned int irqnum, unsigned long irqflags);
+   void (*remove)(struct usb_hcd *hcd);
+};
+
 static inline int hcd_giveback_urb_in_bh(struct usb_hcd *hcd)
 {
return hcd->driver->flags & HCD_BH;
-- 
2.1.4

--
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 v4 3/6] power: Add support for DA9150 Fuel-Gauge

2015-08-24 Thread Opensource [Adam Thomson]
On August 04, 2015 17:17, Adam Thomson wrote:

> This adds power supply driver support for the Fuel-Gauge part of
> the DA9150 combined Charger and Fuel-Gauge device.
> 
> Signed-off-by: Adam Thomson 
> ---

Hi Sebastian,

Just wondered when you might be able to review the power-supply parts of this
patch? Lee has Acked the MFD patches, so it's just these left.

Thanks
Adam
N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�:+v���zZ+��+zf���h���~i���z��w���?�&�)ߢf��^jǫy�m��@A�a���
0��h���i

[PATCH v4 13/13] usb: otg: Add dual-role device (DRD) support

2015-08-24 Thread Roger Quadros
DRD mode is a reduced functionality OTG mode. In this mode
we don't support SRP, HNP and dynamic role-swap.

In DRD operation, the controller mode (Host or Peripheral)
is decided based on the ID pin status. Once a cable plug (Type-A
or Type-B) is attached the controller selects the state
and doesn't change till the cable in unplugged and a different
cable type is inserted.

As we don't need most of the complex OTG states and OTG timers
we implement a lean DRD state machine in usb-otg.c.
The DRD state machine is only interested in 2 hardware inputs
'id' and 'b_sess_vld'.

Signed-off-by: Roger Quadros 
---
 drivers/usb/common/usb-otg.c | 178 +--
 include/linux/usb/otg-fsm.h  |   5 ++
 include/linux/usb/otg.h  |   2 +
 3 files changed, 177 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/common/usb-otg.c b/drivers/usb/common/usb-otg.c
index 930c2fe..44b5577 100644
--- a/drivers/usb/common/usb-otg.c
+++ b/drivers/usb/common/usb-otg.c
@@ -519,14 +519,165 @@ int usb_otg_start_gadget(struct otg_fsm *fsm, int on)
 }
 EXPORT_SYMBOL_GPL(usb_otg_start_gadget);
 
+/* Change USB protocol when there is a protocol change */
+static int drd_set_protocol(struct otg_fsm *fsm, int protocol)
+{
+   struct usb_otg *otgd = container_of(fsm, struct usb_otg, fsm);
+   int ret = 0;
+
+   if (fsm->protocol != protocol) {
+   dev_dbg(otgd->dev, "otg: changing role fsm->protocol= %d; new 
protocol= %d\n",
+   fsm->protocol, protocol);
+   /* stop old protocol */
+   if (fsm->protocol == PROTO_HOST)
+   ret = otg_start_host(fsm, 0);
+   else if (fsm->protocol == PROTO_GADGET)
+   ret = otg_start_gadget(fsm, 0);
+   if (ret)
+   return ret;
+
+   /* start new protocol */
+   if (protocol == PROTO_HOST)
+   ret = otg_start_host(fsm, 1);
+   else if (protocol == PROTO_GADGET)
+   ret = otg_start_gadget(fsm, 1);
+   if (ret)
+   return ret;
+
+   fsm->protocol = protocol;
+   return 0;
+   }
+
+   return 0;
+}
+
+/* Called when entering a DRD state */
+static void drd_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
+{
+   struct usb_otg *otgd = container_of(fsm, struct usb_otg, fsm);
+
+   if (fsm->otg->state == new_state)
+   return;
+
+   fsm->state_changed = 1;
+   dev_dbg(otgd->dev, "otg: set state: %s\n",
+   usb_otg_state_string(new_state));
+   switch (new_state) {
+   case OTG_STATE_B_IDLE:
+   drd_set_protocol(fsm, PROTO_UNDEF);
+   break;
+   case OTG_STATE_B_PERIPHERAL:
+   drd_set_protocol(fsm, PROTO_GADGET);
+   break;
+   case OTG_STATE_A_HOST:
+   drd_set_protocol(fsm, PROTO_HOST);
+   break;
+   case OTG_STATE_UNDEFINED:
+   case OTG_STATE_B_SRP_INIT:
+   case OTG_STATE_B_WAIT_ACON:
+   case OTG_STATE_B_HOST:
+   case OTG_STATE_A_IDLE:
+   case OTG_STATE_A_WAIT_VRISE:
+   case OTG_STATE_A_WAIT_BCON:
+   case OTG_STATE_A_SUSPEND:
+   case OTG_STATE_A_PERIPHERAL:
+   case OTG_STATE_A_WAIT_VFALL:
+   case OTG_STATE_A_VBUS_ERR:
+   default:
+   dev_warn(otgd->dev, "%s: otg: invalid state: %s\n",
+__func__, usb_otg_state_string(new_state));
+   break;
+   }
+
+   fsm->otg->state = new_state;
+}
+
 /**
- * OTG FSM work function
+ * DRD state change judgement
+ *
+ * For DRD we're only interested in some of the OTG states
+ * i.e. OTG_STATE_B_IDLE: both peripheral and host are stopped
+ * OTG_STATE_B_PERIPHERAL: peripheral active
+ * OTG_STATE_A_HOST: host active
+ * we're only interested in the following inputs
+ * fsm->id, fsm->b_sess_vld
+ */
+static int drd_statemachine(struct otg_fsm *fsm)
+{
+   struct usb_otg *otgd = container_of(fsm, struct usb_otg, fsm);
+   enum usb_otg_state state;
+
+   mutex_lock(>lock);
+
+   state = fsm->otg->state;
+
+   switch (state) {
+   case OTG_STATE_UNDEFINED:
+   if (!fsm->id)
+   drd_set_state(fsm, OTG_STATE_A_HOST);
+   else if (fsm->id && fsm->b_sess_vld)
+   drd_set_state(fsm, OTG_STATE_B_PERIPHERAL);
+   else
+   drd_set_state(fsm, OTG_STATE_B_IDLE);
+   break;
+   case OTG_STATE_B_IDLE:
+   if (!fsm->id)
+   drd_set_state(fsm, OTG_STATE_A_HOST);
+   else if (fsm->b_sess_vld)
+   drd_set_state(fsm, OTG_STATE_B_PERIPHERAL);
+   break;
+   case OTG_STATE_B_PERIPHERAL:
+   if (!fsm->id)
+   drd_set_state(fsm, OTG_STATE_A_HOST);
+   else if 

Re: [RFC PATCH 1/7] DMA: tegra-apb: Correct runtime-pm usage

2015-08-24 Thread Jon Hunter

On 24/08/15 10:22, Vinod Koul wrote:
> On Mon, Aug 24, 2015 at 09:47:13AM +0100, Jon Hunter wrote:
>>
>> On 23/08/15 15:17, Vinod Koul wrote:
>>> On Tue, Aug 18, 2015 at 02:49:09PM +0100, Jon Hunter wrote:
>>>
 @@ -1543,7 +1531,7 @@ static int tegra_dma_pm_suspend(struct device *dev)
int ret;
  
/* Enable clock before accessing register */
 -  ret = tegra_dma_runtime_resume(dev);
 +  ret = pm_runtime_get_sync(dev);
>>>
>>> why is this required ?
>>
>> Because the clock could be disabled when this function is called. This
>> function saves the DMA context so that if the context is lost during
>> suspend, it can be restored.
> 
> Have you verified this? Coz my understanding is that when PM does suspend it
> will esnure you are runtime resume if runtime suspended and then will do
> suspend.
> So you do not need to do above

I see what you are saying. I did some testing with ftrace today to trace
rpm and suspend/resume calls. If the dma controller is runtime suspended
and I do not call pm_runtime_get_sync() above then I do not see any
runtime resume of the dma controller prior to suspend. Now I was hoping
that this would cause a complete kernel crash but it did not and so the
DMA clock did not appear to be needed here (at least on the one board I
tested). However, I would not go as far as to remove this and prefer to
keep as above.

Furthermore, other drivers do similar things, including the sirf dma
controller (see sirf-dma.c).

Cheers
Jon

--
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 07/13] usb: otg: add OTG core

2015-08-24 Thread Roger Quadros
The OTG core instantiates the OTG Finite State Machine
per OTG controller and manages starting/stopping the
host and gadget controllers based on the bus state.

It provides APIs for the following tasks

- Registering an OTG capable controller
- Registering Host and Gadget controllers to OTG core
- Providing inputs to and kicking the OTG state machine

Signed-off-by: Roger Quadros 
---
 MAINTAINERS  |4 +-
 drivers/usb/Kconfig  |2 +-
 drivers/usb/Makefile |1 +
 drivers/usb/common/Makefile  |3 +-
 drivers/usb/common/usb-otg.c | 1061 ++
 drivers/usb/common/usb-otg.h |   71 +++
 drivers/usb/core/Kconfig |   11 +-
 include/linux/usb/otg.h  |  189 +++-
 8 files changed, 1321 insertions(+), 21 deletions(-)
 create mode 100644 drivers/usb/common/usb-otg.c
 create mode 100644 drivers/usb/common/usb-otg.h

diff --git a/MAINTAINERS b/MAINTAINERS
index a9ae6c1..4bc1279 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10667,12 +10667,14 @@ S:Maintained
 F: Documentation/usb/ohci.txt
 F: drivers/usb/host/ohci*
 
-USB OTG FSM (Finite State Machine)
+USB OTG/DRD core and FSM (Finite State Machine)
 M: Peter Chen 
+M: Roger Quadros 
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb.git
 L: linux-...@vger.kernel.org
 S: Maintained
 F: drivers/usb/common/usb-otg-fsm.c
+F: drivers/usb/common/usb-otg.c
 
 USB OVER IP DRIVER
 M: Valentina Manea 
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 8ed451d..5b625e2 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -32,7 +32,7 @@ if USB_SUPPORT
 config USB_COMMON
tristate
default y
-   depends on USB || USB_GADGET
+   depends on USB || USB_GADGET || USB_OTG
 
 config USB_ARCH_HAS_HCD
def_bool y
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index d8926c6..769d13b 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -60,5 +60,6 @@ obj-$(CONFIG_USB_RENESAS_USBHS)   += renesas_usbhs/
 obj-$(CONFIG_USB_GADGET)   += gadget/
 
 obj-$(CONFIG_USB_COMMON)   += common/
+obj-$(CONFIG_USB_OTG)  += common/
 
 obj-$(CONFIG_USBIP_CORE)   += usbip/
diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
index 6bbb3ec..730d928 100644
--- a/drivers/usb/common/Makefile
+++ b/drivers/usb/common/Makefile
@@ -6,5 +6,6 @@ obj-$(CONFIG_USB_COMMON)  += usb-common.o
 usb-common-y += common.o
 usb-common-$(CONFIG_USB_LED_TRIG) += led.o
 
-obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o
 obj-$(CONFIG_USB_ULPI_BUS) += ulpi.o
+usbotg-y   := usb-otg.o usb-otg-fsm.o
+obj-$(CONFIG_USB_OTG)  += usbotg.o
diff --git a/drivers/usb/common/usb-otg.c b/drivers/usb/common/usb-otg.c
new file mode 100644
index 000..930c2fe
--- /dev/null
+++ b/drivers/usb/common/usb-otg.c
@@ -0,0 +1,1061 @@
+/**
+ * drivers/usb/common/usb-otg.c - USB OTG core
+ *
+ * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com
+ * Author: Roger Quadros 
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include  /* enum usb_otg_state */
+#include 
+#include 
+
+#include "usb-otg.h"
+
+struct otg_gcd {
+   struct usb_gadget *gadget;
+   struct otg_gadget_ops *ops;
+};
+
+/* OTG device list */
+LIST_HEAD(otg_list);
+static DEFINE_MUTEX(otg_list_mutex);
+
+/* Hosts and Gadgets waiting for OTG controller */
+struct otg_wait_data {
+   struct device *dev; /* OTG controller device */
+
+   struct otg_hcd primary_hcd;
+   struct otg_hcd shared_hcd;
+   struct otg_gcd gcd;
+   struct list_head list;
+};
+
+LIST_HEAD(wait_list);
+static DEFINE_MUTEX(wait_list_mutex);
+
+static int usb_otg_hcd_is_primary_hcd(struct usb_hcd *hcd)
+{
+   if (!hcd->primary_hcd)
+   return 1;
+   return hcd == hcd->primary_hcd;
+}
+
+/**
+ * Check if the OTG device is in our wait list and return
+ * otg_wait_data, else NULL.
+ *
+ * wait_list_mutex must be held.
+ */
+static struct otg_wait_data *usb_otg_get_wait(struct device *otg_dev)
+{
+   struct otg_wait_data *wait;
+
+   if (!otg_dev)
+   return NULL;
+
+   /* is there an entry for this otg_dev ?*/
+   list_for_each_entry(wait, _list, list) {
+   if (wait->dev == otg_dev)
+   return wait;
+   }
+
+   return NULL;
+}
+
+/**
+ * Add the hcd to our wait list
+ */
+static int 

[PATCH v4 06/13] usb: gadget.h: Add OTG to gadget interface

2015-08-24 Thread Roger Quadros
The OTG core will use struct otg_gadget_ops to
start/stop the gadget controller.

The main purpose of this interface is to avoid directly
calling usb_gadget_start/stop() from the OTG core as they
wouldn't be defined in the built-in symbol table if
CONFIG_USB_GADGET is m.

Signed-off-by: Roger Quadros 
Reviewed-by: Peter Chen 
---
 include/linux/usb/gadget.h | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index c14a69b..c019242 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -1052,6 +1052,20 @@ struct usb_gadget_driver {
 };
 
 
+/*-*/
+
+/**
+ * struct otg_gadget_ops - Interface between OTG core and gadget
+ *
+ * Provided by the gadget core to allow the OTG core to start/stop the gadget
+ *
+ * @start: function to start the gadget
+ * @stop: function to stop the gadget
+ */
+struct otg_gadget_ops {
+   int (*start)(struct usb_gadget *gadget);
+   int (*stop)(struct usb_gadget *gadget);
+};
 
 /*-*/
 
-- 
2.1.4

--
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 11/13] usb: core: hub: Notify OTG fsm when A device sets b_hnp_enable

2015-08-24 Thread Roger Quadros
This is the a_set_b_hnp_enable flag in the OTG state machine
diagram and must be set when the A-Host has successfully set
the b_hnp_enable feature of the OTG-B-Peripheral attached to it.

When this bit changes we kick our OTG FSM to make note of the
change and act accordingly.

Signed-off-by: Roger Quadros 
---
 drivers/usb/core/hub.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 431839b..3993168 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2271,6 +2271,9 @@ static int usb_enumerate_device_otg(struct usb_device 
*udev)
"can't set HNP mode: %d\n",
err);
bus->b_hnp_enable = 0;
+   } else {
+   /* notify OTG fsm about 
a_set_b_hnp_enable */
+   usb_otg_kick_fsm(udev->bus->controller);
}
}
}
@@ -4238,8 +4241,13 @@ hub_port_init (struct usb_hub *hub, struct usb_device 
*udev, int port1,
 */
if (!hdev->parent) {
delay = HUB_ROOT_RESET_TIME;
-   if (port1 == hdev->bus->otg_port)
+   if (port1 == hdev->bus->otg_port) {
hdev->bus->b_hnp_enable = 0;
+#ifdef CONFIG_USB_OTG
+   /* notify OTG fsm about a_set_b_hnp_enable change */
+   usb_otg_kick_fsm(hdev->bus->controller);
+#endif
+   }
}
 
/* Some low speed devices have problems with the quick delay, so */
-- 
2.1.4

--
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 10/13] usb: hcd: Adapt to OTG core

2015-08-24 Thread Roger Quadros
The existing usb_add/remove_hcd() functionality
remains unchanged for non-OTG devices. For OTG
devices they only register the HCD with the OTG core.

Introduce usb_otg_add/remove_hcd() for use by OTG core.
These functions actually add/remove the HCD.

Signed-off-by: Roger Quadros 
---
 drivers/usb/core/hcd.c | 55 +-
 1 file changed, 50 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index c0fd1f6..4851682 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -46,6 +46,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "usb.h"
 
@@ -2625,8 +2626,8 @@ static void usb_put_invalidate_rhdev(struct usb_hcd *hcd)
  * buffers of consistent memory, register the bus, request the IRQ line,
  * and call the driver's reset() and start() routines.
  */
-int usb_add_hcd(struct usb_hcd *hcd,
-   unsigned int irqnum, unsigned long irqflags)
+static int usb_otg_add_hcd(struct usb_hcd *hcd,
+  unsigned int irqnum, unsigned long irqflags)
 {
int retval;
struct usb_device *rhdev;
@@ -2839,17 +2840,16 @@ err_phy:
}
return retval;
 }
-EXPORT_SYMBOL_GPL(usb_add_hcd);
 
 /**
- * usb_remove_hcd - shutdown processing for generic HCDs
+ * usb_otg_remove_hcd - shutdown processing for generic HCDs
  * @hcd: the usb_hcd structure to remove
  * Context: !in_interrupt()
  *
  * Disconnects the root hub, then reverses the effects of usb_add_hcd(),
  * invoking the HCD's stop() method.
  */
-void usb_remove_hcd(struct usb_hcd *hcd)
+static void usb_otg_remove_hcd(struct usb_hcd *hcd)
 {
struct usb_device *rhdev = hcd->self.root_hub;
 
@@ -2923,6 +2923,51 @@ void usb_remove_hcd(struct usb_hcd *hcd)
 
usb_put_invalidate_rhdev(hcd);
 }
+
+static struct otg_hcd_ops otg_hcd_intf = {
+   .add = usb_otg_add_hcd,
+   .remove = usb_otg_remove_hcd,
+};
+
+/**
+ * usb_add_hcd - finish generic HCD structure initialization and register
+ * @hcd: the usb_hcd structure to initialize
+ * @irqnum: Interrupt line to allocate
+ * @irqflags: Interrupt type flags
+ *
+ * Finish the remaining parts of generic HCD initialization: allocate the
+ * buffers of consistent memory, register the bus, request the IRQ line,
+ * and call the driver's reset() and start() routines.
+ * If it is an OTG device then it only registers the HCD with OTG core.
+ *
+ */
+int usb_add_hcd(struct usb_hcd *hcd,
+   unsigned int irqnum, unsigned long irqflags)
+{
+   /* If OTG device, OTG core takes care of adding HCD */
+   if (usb_otg_register_hcd(hcd, irqnum, irqflags, _hcd_intf))
+   return usb_otg_add_hcd(hcd, irqnum, irqflags);
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(usb_add_hcd);
+
+/**
+ * usb_remove_hcd - shutdown processing for generic HCDs
+ * @hcd: the usb_hcd structure to remove
+ * Context: !in_interrupt()
+ *
+ * Disconnects the root hub, then reverses the effects of usb_add_hcd(),
+ * invoking the HCD's stop() method.
+ * If it is an OTG device then it unregisters the HCD from OTG core
+ * as well.
+ */
+void usb_remove_hcd(struct usb_hcd *hcd)
+{
+   /* If OTG device, OTG core takes care of stopping HCD */
+   if (usb_otg_unregister_hcd(hcd))
+   usb_otg_remove_hcd(hcd);
+}
 EXPORT_SYMBOL_GPL(usb_remove_hcd);
 
 void
-- 
2.1.4

--
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 12/13] usb: gadget: udc: adapt to OTG core

2015-08-24 Thread Roger Quadros
The OTG state machine needs a mechanism to start and
stop the gadget controller. Add usb_gadget_start()
and usb_gadget_stop().

Register with OTG core when gadget function driver
is available and unregister when function driver is unbound.

We need to unlock the usb_lock mutexbefore calling
usb_otg_register_gadget() in udc_bind_to_driver() and
usb_gadget_remove_driver() else it will cause a circular
locking dependency.

Ignore softconnect sysfs control when we're in OTG
mode as OTG FSM takes care of gadget softconnect using
the b_bus_req mechanism.

Signed-off-by: Roger Quadros 
---
 drivers/usb/gadget/udc/udc-core.c | 124 +++---
 1 file changed, 114 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/udc/udc-core.c 
b/drivers/usb/gadget/udc/udc-core.c
index f660afb..e961668 100644
--- a/drivers/usb/gadget/udc/udc-core.c
+++ b/drivers/usb/gadget/udc/udc-core.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /**
  * struct usb_udc - describes one usb device controller
@@ -37,6 +38,7 @@
  * @list - for use by the udc class driver
  * @vbus - for udcs who care about vbus status, this value is real vbus status;
  * for udcs who do not care about vbus status, this value is always true
+ * @is_otg - we're registered with OTG core and it takes care of UDC start/stop
  *
  * This represents the internal data structure which is used by the UDC-class
  * to hold information about udc driver and gadget together.
@@ -47,6 +49,7 @@ struct usb_udc {
struct device   dev;
struct list_headlist;
boolvbus;
+   boolis_otg;
 };
 
 static struct class *udc_class;
@@ -300,6 +303,7 @@ EXPORT_SYMBOL_GPL(usb_gadget_udc_reset);
  */
 static inline int usb_gadget_udc_start(struct usb_udc *udc)
 {
+   dev_dbg(>dev, "%s\n", __func__);
return udc->gadget->ops->udc_start(udc->gadget, udc->driver);
 }
 
@@ -317,10 +321,81 @@ static inline int usb_gadget_udc_start(struct usb_udc 
*udc)
  */
 static inline void usb_gadget_udc_stop(struct usb_udc *udc)
 {
+   dev_dbg(>dev, "%s\n", __func__);
udc->gadget->ops->udc_stop(udc->gadget);
 }
 
 /**
+ * usb_gadget_start - start the usb gadget controller and connect to bus
+ * @gadget: the gadget device to start
+ *
+ * This is external API for use by OTG core.
+ *
+ * Start the usb device controller and connect to bus (enable pull).
+ */
+static int usb_gadget_start(struct usb_gadget *gadget)
+{
+   int ret;
+   struct usb_udc *udc = NULL;
+
+   dev_dbg(>dev, "%s\n", __func__);
+   mutex_lock(_lock);
+   list_for_each_entry(udc, _list, list)
+   if (udc->gadget == gadget)
+   goto found;
+
+   dev_err(gadget->dev.parent, "%s: gadget not registered.\n",
+   __func__);
+   mutex_unlock(_lock);
+   return -EINVAL;
+
+found:
+   ret = usb_gadget_udc_start(udc);
+   if (ret)
+   dev_err(>dev, "USB Device Controller didn't start: %d\n",
+   ret);
+   else
+   usb_udc_connect_control(udc);
+
+   mutex_unlock(_lock);
+
+   return ret;
+}
+
+/**
+ * usb_gadget_stop - disconnect from bus and stop the usb gadget
+ * @gadget: The gadget device we want to stop
+ *
+ * This is external API for use by OTG core.
+ *
+ * Disconnect from the bus (disable pull) and stop the
+ * gadget controller.
+ */
+static int usb_gadget_stop(struct usb_gadget *gadget)
+{
+   struct usb_udc *udc = NULL;
+
+   dev_dbg(>dev, "%s\n", __func__);
+   mutex_lock(_lock);
+   list_for_each_entry(udc, _list, list)
+   if (udc->gadget == gadget)
+   goto found;
+
+   dev_err(gadget->dev.parent, "%s: gadget not registered.\n",
+   __func__);
+   mutex_unlock(_lock);
+   return -EINVAL;
+
+found:
+   usb_gadget_disconnect(udc->gadget);
+   udc->driver->disconnect(udc->gadget);
+   usb_gadget_udc_stop(udc);
+   mutex_unlock(_lock);
+
+   return 0;
+}
+
+/**
  * usb_udc_release - release the usb_udc struct
  * @dev: the dev member within usb_udc
  *
@@ -438,6 +513,7 @@ int usb_add_gadget_udc(struct device *parent, struct 
usb_gadget *gadget)
 }
 EXPORT_SYMBOL_GPL(usb_add_gadget_udc);
 
+/* udc_lock must be held */
 static void usb_gadget_remove_driver(struct usb_udc *udc)
 {
dev_dbg(>dev, "unregistering UDC driver [%s]\n",
@@ -445,10 +521,18 @@ static void usb_gadget_remove_driver(struct usb_udc *udc)
 
kobject_uevent(>dev.kobj, KOBJ_CHANGE);
 
-   usb_gadget_disconnect(udc->gadget);
-   udc->driver->disconnect(udc->gadget);
+   /* If OTG, the otg core ensures UDC is stopped on unregister */
+   if (udc->is_otg) {
+   mutex_unlock(_lock);
+   usb_otg_unregister_gadget(udc->gadget);
+   mutex_lock(_lock);
+   } else {
+   

[PATCH v4 08/13] usb: doc: dt-binding: Add otg-controller property

2015-08-24 Thread Roger Quadros
The otg-controller property is used to link the host/gadget
controllers to the otg controller. otg-controller property must
contain the phandle of the otg controller.

The otg core uses this property to tie the host/gadget
controllres to the correct otg controller.

Signed-off-by: Roger Quadros 
---
 Documentation/devicetree/bindings/usb/generic.txt | 5 +
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/generic.txt 
b/Documentation/devicetree/bindings/usb/generic.txt
index bba8257..5a457bc 100644
--- a/Documentation/devicetree/bindings/usb/generic.txt
+++ b/Documentation/devicetree/bindings/usb/generic.txt
@@ -24,6 +24,11 @@ Optional properties:
optional for OTG device.
  - adp-disable: tells OTG controllers we want to disable OTG ADP, ADP is
optional for OTG device.
+ - otg-controller: phandle to otg controller. Host or gadget controllers can
+   contain this property to link it to a particular otg
+   controller. If this property is not present then otg
+   core assumes that host and gadget controllers are
+   children of the otg controller.
 
 This is an attribute to a USB controller such as:
 
-- 
2.1.4

--
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 09/13] usb: chipidea: move from CONFIG_USB_OTG_FSM to CONFIG_USB_OTG

2015-08-24 Thread Roger Quadros
CONFIG_USB_OTG_FSM no longer exists and the OTG FSM
is available if CONFIG_USB_OTG is defined so move
to using CONFIG_USB_OTG.

Signed-off-by: Roger Quadros 
---
 Documentation/usb/chipidea.txt | 2 +-
 drivers/usb/chipidea/Makefile  | 2 +-
 drivers/usb/chipidea/ci.h  | 2 +-
 drivers/usb/chipidea/otg_fsm.h | 2 +-
 drivers/usb/phy/Kconfig| 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/Documentation/usb/chipidea.txt b/Documentation/usb/chipidea.txt
index 3f848c1..e7f97da 100644
--- a/Documentation/usb/chipidea.txt
+++ b/Documentation/usb/chipidea.txt
@@ -5,7 +5,7 @@ with 2 Freescale i.MX6Q sabre SD boards.
 
 1.1 How to enable OTG FSM in menuconfig
 ---
-Select CONFIG_USB_OTG_FSM, rebuild kernel Image and modules.
+Select CONFIG_USB_OTG, rebuild kernel Image and modules.
 If you want to check some internal variables for otg fsm,
 select CONFIG_USB_CHIPIDEA_DEBUG, there are 2 files which
 can show otg fsm variables and some controller registers value:
diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index 4decb12..63f2394 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -6,7 +6,7 @@ ci_hdrc-y   := core.o otg.o
 ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC) += udc.o
 ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST)+= host.o
 ci_hdrc-$(CONFIG_USB_CHIPIDEA_DEBUG)   += debug.o
-ci_hdrc-$(CONFIG_USB_OTG_FSM)  += otg_fsm.o
+ci_hdrc-$(CONFIG_USB_OTG)  += otg_fsm.o
 
 # Glue/Bridge layers go here
 
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 41d7cf6..438818c 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -407,7 +407,7 @@ static inline u32 hw_test_and_write(struct ci_hdrc *ci, 
enum ci_hw_regs reg,
  */
 static inline bool ci_otg_is_fsm_mode(struct ci_hdrc *ci)
 {
-#ifdef CONFIG_USB_OTG_FSM
+#ifdef CONFIG_USB_OTG
struct usb_otg_caps *otg_caps = >platdata->ci_otg_caps;
 
return ci->is_otg && ci->roles[CI_ROLE_HOST] &&
diff --git a/drivers/usb/chipidea/otg_fsm.h b/drivers/usb/chipidea/otg_fsm.h
index 2689375..fb66695 100644
--- a/drivers/usb/chipidea/otg_fsm.h
+++ b/drivers/usb/chipidea/otg_fsm.h
@@ -62,7 +62,7 @@
 /* SSEND time before SRP */
 #define TB_SSEND_SRP (1500)/* minimum 1.5 sec, section:5.1.2 */
 
-#ifdef CONFIG_USB_OTG_FSM
+#ifdef CONFIG_USB_OTG
 
 int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci);
 int ci_otg_fsm_work(struct ci_hdrc *ci);
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 7d3beee..664cacb 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -20,7 +20,7 @@ config AB8500_USB
 
 config FSL_USB2_OTG
bool "Freescale USB OTG Transceiver Driver"
-   depends on USB_EHCI_FSL && USB_FSL_USB2 && USB_OTG_FSM && PM
+   depends on USB_EHCI_FSL && USB_FSL_USB2 && PM
select USB_OTG
select USB_PHY
help
-- 
2.1.4

--
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/


<    8   9   10   11   12   13   14   15   16   17   >