Re: [PATCH V3 1/2] i2c-designware: Add i2c bus locking support

2014-12-03 Thread Jarkko Nikula

Hi

On 12/02/2014 02:09 AM, David E. Box wrote:

Adds support for acquiring and releasing a hardware bus lock in the i2c
designware core transfer function. This is needed for i2c bus controllers
that are shared with but not controlled by the kernel.

Signed-off-by: David E. Box 
---
  drivers/i2c/busses/i2c-designware-core.c| 11 +++
  drivers/i2c/busses/i2c-designware-core.h|  6 ++
  drivers/i2c/busses/i2c-designware-platdrv.c | 18 +-
  3 files changed, 30 insertions(+), 5 deletions(-)


...

diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c 
b/drivers/i2c/busses/i2c-designware-platdrv.c
index a743115..afdff3b 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -261,10 +261,16 @@ static int dw_i2c_probe(struct platform_device *pdev)
return r;
}
  
-	pm_runtime_set_autosuspend_delay(>dev, 1000);

-   pm_runtime_use_autosuspend(>dev);
-   pm_runtime_set_active(>dev);
-   pm_runtime_enable(>dev);
+   i2c_dw_eval_lock_support(dev);

i2c_dw_eval_lock_support() is added in the next patch.

+
+   if (dev->pm_runtime_disabled) {
+   pm_runtime_forbid(>dev);
+   } else {
+   pm_runtime_set_autosuspend_delay(>dev, 1000);
+   pm_runtime_use_autosuspend(>dev);
+   pm_runtime_set_active(>dev);
+   pm_runtime_enable(>dev);
+   }
  
  	return 0;

  }
@@ -314,7 +320,9 @@ static int dw_i2c_resume(struct device *dev)
struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev);
  
  	clk_prepare_enable(i_dev->clk);

-   i2c_dw_init(i_dev);
+
+   if (!i_dev->pm_runtime_disabled)
+   i2c_dw_init(i_dev);
  
Should there be similar conditional call or locking around i2c_dw_init() 
and i2c_dw_disable_int() also in dw_i2c_probe()?


--
Jarkko
--
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: 3.12.33 - BUG xfrm_selector_match+0x25/0x2f6

2014-12-03 Thread Steffen Klassert
On Wed, Dec 03, 2014 at 03:55:30PM +0100, Smart Weblications GmbH - Florian 
Wiessner wrote:
> Hi list,
> 
> 
> 
> [16623.095403] BUG: unable to handle kernel paging request at 010600d0
> [16623.095445] IP: [] xfrm_selector_match+0x25/0x2f6
> [16623.095480] PGD aeaea067 PUD 85d95067 PMD 0
> [16623.095513] Oops:  [#1] SMP
> [16623.095543] Modules linked in: netconsole xt_nat xt_multiport veth ip_vs_rr
> nfsd lockd nfs_acl auth_rpcgss sunrpc oid_registry iptable_mangle xt_mark
> nf_conntrack_netlink nfnetlink ipt_MASQUERADE iptable_nat nf_nat_ipv4
> nf_conntrack_ipv4 nf_defrag_ipv4 ipt_REJECT xt_tcpudp iptable_filter ip_tables
> cpufreq_ondemand cpufreq_powersave cpufreq_conservative cpufreq_userspace
> ocfs2_stack_o2cb ocfs2_dlm bridge stp llc bonding fuse nf_conntrack_ftp 8021q
> openvswitch gre vxlan xt_conntrack x_tables ocfs2_dlmfs dlm sctp ocfs2
> ocfs2_nodemanager ocfs2_stackglue configfs rbd kvm_intel kvm coretemp 
> ip_vs_ftp
> ip_vs nf_nat nf_conntrack ctr twofish_generic twofish_x86_64 twofish_common
> camellia_generic serpent_generic blowfish_generic blowfish_common 
> cast5_generic
> cast_common xcbc sha512_generic crypto_null af_key xfrm_algo psmouse serio_raw
> i2c_i801 lpc_ich mfd_core evdev btrfs lzo_decompress lzo_compress
> [16623.096062] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.12.33 #1
> [16623.096091] Hardware name: Supermicro X9SCI/X9SCA/X9SCI/X9SCA, BIOS 1.1a
> 09/28/2011
> [16623.096137] task: 81804450 ti: 817f4000 task.ti: 
> 817f4000
> [16623.096182] RIP: 0010:[]  []
> xfrm_selector_match+0x25/0x2f6
> [16623.096233] RSP: 0018:88083fc03900  EFLAGS: 00010246
> [16623.096261] RAX: 0001 RBX: 88083fc03a20 RCX: 
> 880787fb1200
> [16623.096292] RDX: 0002 RSI: 88083fc03a20 RDI: 
> 010600a6
> [16623.096323] RBP: 010600a6 R08:  R09: 
> 88083fc039a0
> [16623.096353] R10:  R11: 0001 R12: 
> 88083fc03a20
> [16623.096383] R13: 0001 R14: 818a9700 R15: 
> a01c73e0
> [16623.096414] FS:  () GS:88083fc0()
> knlGS:
> [16623.096469] CS:  0010 DS:  ES:  CR0: 80050033
> [16623.096498] CR2: 010600d0 CR3: 85f0b000 CR4: 
> 000407f0
> [16623.096528] Stack:
> [16623.096550]   01060002 880787fb1200 
> 88083fc03a20
> [16623.096602]  0001 81547a7c  
> 8800baad5480
> [16623.096655]  81804450 818a9700 3c9041bc 
> 81547ef7
> [16623.096721] Call Trace:
> [16623.096744]  
> [16623.096749]  [] ? xfrm_sk_policy_lookup+0x44/0x9b
> [16623.096802]  [] ? xfrm_lookup+0x91/0x446
> [16623.096832]  [] ? ip_route_me_harder+0x150/0x1b0
> [16623.096865]  [] ? ip_vs_route_me_harder+0x86/0x91 [ip_vs]
> [16623.096899]  [] ? ip_vs_out+0x2d3/0x5bc [ip_vs]
> [16623.096930]  [] ? ip_rcv_finish+0x2b8/0x2b8

I really wonder why the xfrm_sk_policy_lookup codepath is taken here.
It looks like this is the processing of an inbound ipv4 packet that
is going to be rerouted to the output path by ipvs, so this packet
should not have socket context at all.

xfrm_sk_policy_lookup is called just if the packet has socket context
and the socket has an IPsec output policy configured. Do you use IPsec
socket policies?

> 
> This happens again and again with 3.12.33
> 
> 
> see also: http://www.spinics.net/lists/netdev/msg306283.html
> 
> is this already fixed somehow?
> 

You mentioned in the tread above that it does not happen with
3.17.4, so it should be fixed somehow. But I have no idea how
it was fixed.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/3] video: fbdev: vt8623fb: suppress build warning

2014-12-03 Thread Tomi Valkeinen
On 04/12/14 09:46, Sudip Mukherjee wrote:
> On Thu, Dec 04, 2014 at 09:05:46AM +0200, Tomi Valkeinen wrote:
>> On 03/12/14 20:29, Prabhakar Lad wrote:
>>> On Wed, Dec 3, 2014 at 11:49 AM, Tomi Valkeinen  
>>> wrote:
>>>> On 27/11/14 00:07, Lad, Prabhakar wrote:
>>>>> this patch fixes following build warning:
>>>>> drivers/video/fbdev/vt8623fb.c: In function ‘vt8623_pci_probe’:
>>>>> drivers/video/fbdev/vt8623fb.c:734:23: warning: cast to pointer from 
>>>>> integer of different size [-Wint-to-pointer-cast]
>>>>>   par->state.vgabase = (void __iomem *) vga_res.start;
>>>>>^
>>>>> Signed-off-by: Lad, Prabhakar 
>>>>> ---
>>>>>  drivers/video/fbdev/vt8623fb.c | 2 +-
>>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/drivers/video/fbdev/vt8623fb.c 
>>>>> b/drivers/video/fbdev/vt8623fb.c
>>>>> index 5c7cbc6..ea7f056 100644
>>>>> --- a/drivers/video/fbdev/vt8623fb.c
>>>>> +++ b/drivers/video/fbdev/vt8623fb.c
>>>>> @@ -731,7 +731,7 @@ static int vt8623_pci_probe(struct pci_dev *dev, 
>>>>> const struct pci_device_id *id)
>>>>>
>>>>>   pcibios_bus_to_resource(dev->bus, _res, _reg);
>>>>>
>>>>> - par->state.vgabase = (void __iomem *) vga_res.start;
>>>>> + par->state.vgabase = (void __iomem *) (unsigned long) vga_res.start;
>>>>
>>>> This does look quite ugly... Where does the warning come from in the
>>>> first place. Isn't vga_res.start (resource_size_t) the size of a pointer?
>>>>
>>> Yes looks ugly, I am not sure what you meant from 'where does this warning
>>> come from' its in the commit message.
>>
>> I meant why is there a warning at all. With a quick glance,
>> vga_res.start is the size of a pointer. So the sizes of the integer and
>> the pointer should be the same. But the warning still says "of different
>> size".
> 
> poking my nose into your discussion.
> I tried to see the warning, and I re-compiled like make W=1 
> M=drivers/video/fbdev/ (before that make clean M=drivers/video/fbdev was done)
> I can see warning with many other files, but drivers/video/fbdev/vt8623fb.o 
> was quiet and there was no warning.
> I tested with next=20141203.
> did i miss something in checking the warning ?

I don't see the warning either when compiling for arm or x86_64. On what
architecture do you see the warning?

 Tomi




signature.asc
Description: OpenPGP digital signature


Re: [PATCH 02/02] ARM: shmobile: marzen-reference: Remove IRLM workaround

2014-12-03 Thread Simon Horman
On Thu, Dec 04, 2014 at 04:33:25PM +0900, Magnus Damm wrote:
> Hi Simon,
> 
> On Thu, Dec 4, 2014 at 4:21 PM, Simon Horman  wrote:
> > Hi Magnus,
> >
> > On Wed, Dec 03, 2014 at 09:18:13PM +0900, Magnus Damm wrote:
> >> From: Magnus Damm 
> >>
> >> Adjust the r8a7779 SoC DTS and the Marzen Reference
> >> C board code to use DTS only for INTC-IRQPIN IRLM setup.
> >>
> >> Signed-off-by: Magnus Damm 
> >> ---
> >>
> >>  Written on top of renesas-devel-20141202-v3.18-rc7 and
> >>  [PATCH] ARM: shmobile: r8a7779 CCF DTS update
> >>
> >>  Has a runtime dependency on:
> >>  [PATCH 01/02] irqchip: renesas-intc-irqpin: r8a7779 IRLM setup support
> >>
> >>  arch/arm/boot/dts/r8a7779.dtsi  |5 +++--
> >>  arch/arm/mach-shmobile/board-marzen-reference.c |7 ---
> >>  2 files changed, 3 insertions(+), 9 deletions(-)
> >>
> >> --- 0002/arch/arm/boot/dts/r8a7779.dtsi
> >> +++ work/arch/arm/boot/dts/r8a7779.dtsi   2014-12-03 
> >> 20:27:49.0 +0900
> >> @@ -139,7 +139,7 @@
> >>   interrupt-controller;
> >>   };
> >>
> >> - irqpin0: irqpin@fe780010 {
> >> + irqpin0: irqpin@fe78 {
> >>   compatible = "renesas,intc-irqpin-r8a7779", 
> >> "renesas,intc-irqpin";
> >>   #interrupt-cells = <2>;
> >>   status = "disabled";
> >> @@ -148,7 +148,8 @@
> >>   <0xfe780010 4>,
> >>   <0xfe780024 4>,
> >>   <0xfe780044 4>,
> >> - <0xfe780064 4>;
> >> + <0xfe780064 4>,
> >> + <0xfe78 4>;
> >
> > Is there any order implied by the above list?
> > Naïvely I would expect it to be sorted numerically.
> 
> Yes, the driver assumes the register banks to be passed in a certain
> order. In the case of r8a7779 we add one more register bank at the end
> for IRLM setup. Register detail (base address, access size, order and
> bitfield width) varies with SoC version. So the IRLM register will be
> at different addresses depending on SoC, but the driver wants it at
> the end of the list.

Thanks, if it is intentional then that is fine by me.
--
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/02] irqchip: renesas-intc-irqpin: r8a7779 IRLM setup support

2014-12-03 Thread Simon Horman
On Thu, Dec 04, 2014 at 04:29:49PM +0900, Magnus Damm wrote:
> Hi Simon,
> 
> On Thu, Dec 4, 2014 at 4:18 PM, Simon Horman  wrote:
> > Hi Magnus,
> >
> > I see you have been busy with the marzen board.
> 
> Yes! =)
> 
> > On Wed, Dec 03, 2014 at 09:18:03PM +0900, Magnus Damm wrote:
> >> From: Magnus Damm 
> >>
> >> Add r8a7779 specific support for IRLM bit configuration
> >> in the INTC-IRQPIN driver. Without this code we need
> >> special workaround code in arch/arm/mach-shmobile.
> >>
> >> The IRLM bit for the INTC hardware exists on various
> >> older SH-based SoCs and is used to select between two
> >> modes for the external interrupt pins IRQ0 to IRQ3:
> >>
> >> IRLM = 0: (default from reset on r8a7779)
> >> In this mode the pins IRQ0 to IRQ3 are used together
> >> to give a value between 0 and 15 to the SoC. External
> >> logic is required for masking. This mode is not
> >> supported by the INTC-IRQPIN driver.
> >>
> >> IRLM = 1: (needs this patch or configuration elsewhere)
> >> In this mode IRQ0 to IRQ3 operate as 4 individual
> >> external interrupt pins. In this mode the SMSC ethernet
> >> chip can be used via IRQ1 on r8a7779 Marzen. This mode
> >> is the only supported mode by the INTC-IRQPIN driver.
> >>
> >> For this patch to work the r8a7779 DTS needs to pass
> >> the ICR0 register as the last register bank.
> >>
> >> Signed-off-by: Magnus Damm 
> >> ---
> >>
> >>  Written against renesas-devel-20141202-v3.18-rc7 which is
> >>  basically v3.18-rc7 plus latest arch/arm/mach-shmobile code.
> >>
> >>  
> >> Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.txt
> >>  |5 +
> >>  drivers/irqchip/irq-renesas-intc-irqpin.c 
> >>  |   50 --
> >>  2 files changed, 46 insertions(+), 9 deletions(-)
> >>
> >> --- 
> >> 0001/Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.txt
> >> +++ 
> >> work/Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.txt
> >>2014-12-03 20:25:13.0 +0900
> >> @@ -9,6 +9,11 @@ Required properties:
> >>  - "renesas,intc-irqpin-r8a7778" (R-Car M1A)
> >>  - "renesas,intc-irqpin-r8a7779" (R-Car H1)
> >>  - "renesas,intc-irqpin-sh73a0" (SH-Mobile AG5)
> >> +
> >> +- reg: Base address and length of each register bank used by the external
> >> +  IRQ pins driven by the interrupt controller hardware module. The base
> >> +  addresses, length and number of required register banks varies with 
> >> soctype.
> >> +
> >>  - #interrupt-cells: has to be <2>: an interrupt index and flags, as 
> >> defined in
> >>interrupts.txt in this directory
> >>
> >> --- 0001/drivers/irqchip/irq-renesas-intc-irqpin.c
> >> +++ work/drivers/irqchip/irq-renesas-intc-irqpin.c2014-12-03 
> >> 20:32:59.0 +0900
> >> @@ -30,6 +30,7 @@
> >>  #include 
> >>  #include 
> >>  #include 
> >> +#include 
> >>  #include 
> >>  #include 
> >>
> >> @@ -40,7 +41,9 @@
> >>  #define INTC_IRQPIN_REG_SOURCE 2 /* INTREQnn */
> >>  #define INTC_IRQPIN_REG_MASK 3 /* INTMSKnn */
> >>  #define INTC_IRQPIN_REG_CLEAR 4 /* INTMSKCLRnn */
> >> -#define INTC_IRQPIN_REG_NR 5
> >> +#define INTC_IRQPIN_REG_NR_MANDATORY 5
> >> +#define INTC_IRQPIN_REG_IRLM 5 /* ICR0 with IRLM bit (optional) */
> >> +#define INTC_IRQPIN_REG_NR 6
> >>
> >>  /* INTC external IRQ PIN hardware register access:
> >>   *
> >> @@ -82,6 +85,10 @@ struct intc_irqpin_priv {
> >>   u8 shared_irq_mask;
> >>  };
> >>
> >> +struct intc_irqpin_irlm_config {
> >> + unsigned int irlm_bit;
> >> +};
> >> +
> >>  static unsigned long intc_irqpin_read32(void __iomem *iomem)
> >>  {
> >>   return ioread32(iomem);
> >> @@ -345,10 +352,23 @@ static struct irq_domain_ops intc_irqpin
> >>   .xlate  = irq_domain_xlate_twocell,
> >>  };
> >>
> >> +static const struct intc_irqpin_irlm_config intc_irqpin_irlm_r8a7779 = {
> >> + .irlm_bit = 23, /* ICR0.IRLM0 */
> >> +};
> >> +
> >> +static const struct of_device_id intc_irqpin_dt_ids[] = {
> >> + { .compatible = "renesas,intc-irqpin", },
> >> + { .compatible = "renesas,intc-irqpin-r8a7779",
> >> +   .data = _irqpin_irlm_r8a7779 },
> >> + {},
> >> +};
> >> +MODULE_DEVICE_TABLE(of, intc_irqpin_dt_ids);
> >> +
> >>  static int intc_irqpin_probe(struct platform_device *pdev)
> >>  {
> >>   struct device *dev = >dev;
> >>   struct renesas_intc_irqpin_config *pdata = dev->platform_data;
> >> + const struct of_device_id *of_id;
> >>   struct intc_irqpin_priv *p;
> >>   struct intc_irqpin_iomem *i;
> >>   struct resource *io[INTC_IRQPIN_REG_NR];
> >> @@ -391,10 +411,11 @@ static int intc_irqpin_probe(struct plat
> >>   pm_runtime_enable(dev);
> >>   pm_runtime_get_sync(dev);
> >>
> >> - /* get hold of manadatory IOMEM */
> >> + /* get hold of register banks */
> >> + memset(io, 0, sizeof(io));
> >>   for (k = 0; k < INTC_IRQPIN_REG_NR; k++) {
> >>   io[k] = platform_get_resource(pdev, 

[PATCH] x86, mm: fix zone ranges print in boot

2014-12-03 Thread Xishi Qiu
This is the usual log without restrict memory.
...
[0.00] Zone ranges:
[0.00]   DMA  [mem 0x1000-0x00ff]
[0.00]   DMA32[mem 0x0100-0x]
[0.00]   Normal   [mem 0x1-0xc3fff]
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x1000-0x00099fff]
[0.00]   node   0: [mem 0x0010-0xbf78]
[0.00]   node   0: [mem 0x1-0x63fff]
[0.00]   node   1: [mem 0x64000-0xc3fff]
...

This is the log when set "mem=2G" in cmdline.
...
[0.00] Zone ranges:
[0.00]   DMA  [mem 0x1000-0x00ff]
[0.00]   DMA32[mem 0x0100-0x]  // should be 0x7fff, 
right?
[0.00]   Normal   empty
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x1000-0x00099fff]
[0.00]   node   0: [mem 0x0010-0x7fff]
...

This patch fix the print, the following log shows right ranges.
...
[0.00] Zone ranges:
[0.00]   DMA  [mem 0x1000-0x00ff]
[0.00]   DMA32[mem 0x0100-0x7fff]
[0.00]   Normal   empty
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x1000-0x00099fff]
[0.00]   node   0: [mem 0x0010-0x7fff]
...

Signed-off-by: Xishi Qiu 
---
 arch/x86/mm/init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 66dba36..07244aa 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -674,10 +674,10 @@ void __init zone_sizes_init(void)
memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 
 #ifdef CONFIG_ZONE_DMA
-   max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
+   max_zone_pfns[ZONE_DMA] = min(MAX_DMA_PFN, max_low_pfn);
 #endif
 #ifdef CONFIG_ZONE_DMA32
-   max_zone_pfns[ZONE_DMA32]   = MAX_DMA32_PFN;
+   max_zone_pfns[ZONE_DMA32]   = min(MAX_DMA32_PFN, max_low_pfn);
 #endif
max_zone_pfns[ZONE_NORMAL]  = max_low_pfn;
 #ifdef CONFIG_HIGHMEM
-- 
2.0.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 1/3] video: fbdev: vt8623fb: suppress build warning

2014-12-03 Thread Sudip Mukherjee
On Thu, Dec 04, 2014 at 09:05:46AM +0200, Tomi Valkeinen wrote:
> On 03/12/14 20:29, Prabhakar Lad wrote:
> > On Wed, Dec 3, 2014 at 11:49 AM, Tomi Valkeinen  
> > wrote:
> >> On 27/11/14 00:07, Lad, Prabhakar wrote:
> >>> this patch fixes following build warning:
> >>> drivers/video/fbdev/vt8623fb.c: In function ‘vt8623_pci_probe’:
> >>> drivers/video/fbdev/vt8623fb.c:734:23: warning: cast to pointer from 
> >>> integer of different size [-Wint-to-pointer-cast]
> >>>   par->state.vgabase = (void __iomem *) vga_res.start;
> >>>^
> >>> Signed-off-by: Lad, Prabhakar 
> >>> ---
> >>>  drivers/video/fbdev/vt8623fb.c | 2 +-
> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git a/drivers/video/fbdev/vt8623fb.c 
> >>> b/drivers/video/fbdev/vt8623fb.c
> >>> index 5c7cbc6..ea7f056 100644
> >>> --- a/drivers/video/fbdev/vt8623fb.c
> >>> +++ b/drivers/video/fbdev/vt8623fb.c
> >>> @@ -731,7 +731,7 @@ static int vt8623_pci_probe(struct pci_dev *dev, 
> >>> const struct pci_device_id *id)
> >>>
> >>>   pcibios_bus_to_resource(dev->bus, _res, _reg);
> >>>
> >>> - par->state.vgabase = (void __iomem *) vga_res.start;
> >>> + par->state.vgabase = (void __iomem *) (unsigned long) vga_res.start;
> >>
> >> This does look quite ugly... Where does the warning come from in the
> >> first place. Isn't vga_res.start (resource_size_t) the size of a pointer?
> >>
> > Yes looks ugly, I am not sure what you meant from 'where does this warning
> > come from' its in the commit message.
> 
> I meant why is there a warning at all. With a quick glance,
> vga_res.start is the size of a pointer. So the sizes of the integer and
> the pointer should be the same. But the warning still says "of different
> size".

poking my nose into your discussion.
I tried to see the warning, and I re-compiled like make W=1 
M=drivers/video/fbdev/ (before that make clean M=drivers/video/fbdev was done)
I can see warning with many other files, but drivers/video/fbdev/vt8623fb.o was 
quiet and there was no warning.
I tested with next=20141203.
did i miss something in checking the warning ?

thanks
sudip

> 
>  Tomi
> 
> 


--
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 4/5] ASoC: dwc: Add devicetree support for Designware I2S

2014-12-03 Thread rajeev kumar
Sorry for the last blank mail.

On Wed, Dec 3, 2014 at 10:09 PM, Andrew Jackson  wrote:
> Convert to driver to use either platform_data or device-tree for configuration
> of the device.  When using device-tree, the I2S block's configuration is read
> from the relevant registers: this reduces the amount of information required 
> in
> the device tree.
>
> Signed-off-by: Andrew Jackson 
> ---
>  .../devicetree/bindings/sound/designware-i2s.txt   |   32 +++
>  sound/soc/dwc/Kconfig  |1 +
>  sound/soc/dwc/designware_i2s.c |  238 
> 
>  3 files changed, 222 insertions(+), 49 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/sound/designware-i2s.txt
>
> diff --git a/Documentation/devicetree/bindings/sound/designware-i2s.txt 
> b/Documentation/devicetree/bindings/sound/designware-i2s.txt
> new file mode 100644
> index 000..cdee591
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/designware-i2s.txt
> @@ -0,0 +1,32 @@
> +DesignWare I2S controller
> +
> +Required properties:
> + - compatible : Must be "snps,designware-i2s"
> + - reg : Must contain I2S core's registers location and length
> + - clocks : Pairs of phandle and specifier referencing the controller's 
> clocks.
> +   The controller expects two clocks, the clock used for the APB interface 
> and
> +   the clock used as the sampling rate reference clock sample.
> + - clock-names : "apb_plck" for the clock to the APB interface, "i2sclk" for 
> the sample
> +   rate reference clock.
> + - dmas: Pairs of phandle and specifier for the DMA channels that are used by
> +   the core. The core expects one or two dma channels, one for transmit and 
> one for
> +   receive.
> + - dma-names : "tx" for the transmit channel, "rx" for the receive channel.
> +
> +For more details on the 'dma', 'dma-names', 'clock' and 'clock-names' 
> properties
> +please check:
> +   * resource-names.txt
> +   * clock/clock-bindings.txt
> +   * dma/dma.txt
> +
> +Example:
> +
> +   soc_i2s: i2s@7ff9 {
> +   compatible = "snps,designware-i2s";
> +   reg = <0x0 0x7ff9 0x0 0x1000>;
> +   clocks = <_i2sclk 0>, <_refclk100mhz>;
> +   clock-names = "i2sclk", "apb_pclk";
> +   #sound-dai-cells = <0>;
> +   dmas = < 5>;
> +   dma-names = "tx";
> +   };
> diff --git a/sound/soc/dwc/Kconfig b/sound/soc/dwc/Kconfig
> index e334900..d50e085 100644
> --- a/sound/soc/dwc/Kconfig
> +++ b/sound/soc/dwc/Kconfig
> @@ -1,6 +1,7 @@
>  config SND_DESIGNWARE_I2S
> tristate "Synopsys I2S Device Driver"
> depends on CLKDEV_LOOKUP
> +   select SND_SOC_GENERIC_DMAENGINE_PCM
> help
>  Say Y or M if you want to add support for I2S driver for
>  Synopsys desigwnware I2S device. The device supports upto
> diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c
> index c497ada..083779d 100644
> --- a/sound/soc/dwc/designware_i2s.c
> +++ b/sound/soc/dwc/designware_i2s.c
> @@ -22,6 +22,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  /* common register for all channel */
>  #define IER0x000
> @@ -54,19 +55,46 @@
>  #define I2S_COMP_VERSION   0x01F8
>  #define I2S_COMP_TYPE  0x01FC
>
> +/*
> + * Component parameter register fields - define the I2S block's
> + * configuration.
> + */
> +#defineCOMP1_TX_WORDSIZE_3(r)  (((r) & GENMASK(27, 25)) >> 25)
> +#defineCOMP1_TX_WORDSIZE_2(r)  (((r) & GENMASK(24, 22)) >> 22)
> +#defineCOMP1_TX_WORDSIZE_1(r)  (((r) & GENMASK(21, 19)) >> 19)
> +#defineCOMP1_TX_WORDSIZE_0(r)  (((r) & GENMASK(18, 16)) >> 16)
> +#defineCOMP1_TX_CHANNELS(r)(((r) & GENMASK(10, 9)) >> 9)
> +#defineCOMP1_RX_CHANNELS(r)(((r) & GENMASK(8, 7)) >> 7)
> +#defineCOMP1_RX_ENABLED(r) (((r) & BIT(6)) >> 6)
> +#defineCOMP1_TX_ENABLED(r) (((r) & BIT(5)) >> 5)
> +#defineCOMP1_MODE_EN(r)(((r) & BIT(4)) >> 4)
> +#defineCOMP1_FIFO_DEPTH_GLOBAL(r)  (((r) & GENMASK(3, 2)) >> 2)
> +#defineCOMP1_APB_DATA_WIDTH(r) (((r) & GENMASK(1, 0)) >> 0)
> +
> +#defineCOMP2_RX_WORDSIZE_3(r)  (((r) & GENMASK(12, 10)) >> 10)
> +#defineCOMP2_RX_WORDSIZE_2(r)  (((r) & GENMASK(9, 7)) >> 7)
> +#defineCOMP2_RX_WORDSIZE_1(r)  (((r) & GENMASK(5, 3)) >> 3)
> +#defineCOMP2_RX_WORDSIZE_0(r)  (((r) & GENMASK(2, 0)) >> 0)
> +
>  #define MAX_CHANNEL_NUM8
>  #define MIN_CHANNEL_NUM2
>
> +union snd_dma_data {
> +   struct i2s_dma_data pd;
> +   struct snd_dmaengine_dai_dma_data dt;
> +};
> +
>  struct dw_i2s_dev {
> void __iomem *i2s_base;
> struct clk *clk;
> int active;
> unsigned int capability;
> struct device *dev;
> +   bool using_pd;
>
> /* data related to DMA transfers b/w i2s and DMAC */
> - 

Re: [PATCH v3] staging: rtl8192u: fix sparse warnings

2014-12-03 Thread Sudip Mukherjee
On Thu, Dec 04, 2014 at 10:50:43AM +0800, Fred Chou wrote:
> From: Fred Chou 
> 
> Fixed the following warnings in sparse:
> 
> drivers/staging/rtl8192u/r8192U_core.c:670:6: warning:
>   symbol 'dump_eprom' was not declared.
>   Should it be static?
> drivers/staging/rtl8192u/r8192U_core.c:1489:5: warning:
>   symbol 'ComputeTxTime' was not declared.
>   Should it be static?
> drivers/staging/rtl8192u/r8192U_core.c:1556:14: warning:
>   symbol 'txqueue2outpipe' was not declared.
>   Should it be static?
> drivers/staging/rtl8192u/r8192U_core.c:4876:5: warning:
>   symbol 'GetRxPacketShiftBytes819xUsb' was not declared.
>   Should it be static?
> 
> Signed-off-by: Fred Chou 
> 
> ---
> change in v3: fixed alignment to match open parenthesis 
have u fixed?
your v2 was having one problem of alignment, but v3 is again having 3 problems.

and your patch doesnot apply to next-20141203

sudip

> 
>  drivers/staging/rtl8192u/r8192U_core.c | 12 +++-
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192u/r8192U_core.c 
> b/drivers/staging/rtl8192u/r8192U_core.c
> index 7640386..2c61801 100644
> --- a/drivers/staging/rtl8192u/r8192U_core.c
> +++ b/drivers/staging/rtl8192u/r8192U_core.c
> @@ -667,7 +667,7 @@ static void tx_timeout(struct net_device *dev)
>  
>  
>  /* this is only for debug */
> -void dump_eprom(struct net_device *dev)
> +static void dump_eprom(struct net_device *dev)
>  {
>   int i;
>   for (i = 0; i < 63; i++)
> @@ -1486,8 +1486,8 @@ inline u8 rtl8192_IsWirelessBMode(u16 rate)
>  
>  u16 N_DBPSOfRate(u16 DataRate);
>  
> -u16 ComputeTxTime(u16 FrameLength, u16 DataRate, u8 bManagementFrame,
> -   u8 bShortPreamble)
> +static u16 ComputeTxTime(u16 FrameLength, u16 DataRate, u8 bManagementFrame,
> +   u8 bShortPreamble)
>  {
>   u16 FrameTime;
>   u16 N_DBPS;
> @@ -1553,7 +1553,8 @@ u16 N_DBPSOfRate(u16 DataRate)
>   return N_DBPS;
>  }
>  
> -unsigned int txqueue2outpipe(struct r8192_priv *priv, unsigned int tx_queue)
> +static unsigned int txqueue2outpipe(struct r8192_priv *priv,
> +  unsigned int tx_queue)
>  {
>   if (tx_queue >= 9) {
>   RT_TRACE(COMP_ERR, "%s():Unknown queue ID!!!\n", __func__);
> @@ -4873,7 +4874,8 @@ static void query_rxdesc_status(struct sk_buff *skb,
>  
>  }
>  
> -u32 GetRxPacketShiftBytes819xUsb(struct ieee80211_rx_stats  *Status, bool 
> bIsRxAggrSubframe)
> +static u32 GetRxPacketShiftBytes819xUsb(struct ieee80211_rx_stats  *Status,
> +  bool bIsRxAggrSubframe)
>  {
>  #ifdef USB_RX_AGGREGATION_SUPPORT
>   if (bIsRxAggrSubframe)
> -- 
> 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/
--
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 02/02] ARM: shmobile: marzen-reference: Remove IRLM workaround

2014-12-03 Thread Magnus Damm
Hi Simon,

On Thu, Dec 4, 2014 at 4:21 PM, Simon Horman  wrote:
> Hi Magnus,
>
> On Wed, Dec 03, 2014 at 09:18:13PM +0900, Magnus Damm wrote:
>> From: Magnus Damm 
>>
>> Adjust the r8a7779 SoC DTS and the Marzen Reference
>> C board code to use DTS only for INTC-IRQPIN IRLM setup.
>>
>> Signed-off-by: Magnus Damm 
>> ---
>>
>>  Written on top of renesas-devel-20141202-v3.18-rc7 and
>>  [PATCH] ARM: shmobile: r8a7779 CCF DTS update
>>
>>  Has a runtime dependency on:
>>  [PATCH 01/02] irqchip: renesas-intc-irqpin: r8a7779 IRLM setup support
>>
>>  arch/arm/boot/dts/r8a7779.dtsi  |5 +++--
>>  arch/arm/mach-shmobile/board-marzen-reference.c |7 ---
>>  2 files changed, 3 insertions(+), 9 deletions(-)
>>
>> --- 0002/arch/arm/boot/dts/r8a7779.dtsi
>> +++ work/arch/arm/boot/dts/r8a7779.dtsi   2014-12-03 20:27:49.0 
>> +0900
>> @@ -139,7 +139,7 @@
>>   interrupt-controller;
>>   };
>>
>> - irqpin0: irqpin@fe780010 {
>> + irqpin0: irqpin@fe78 {
>>   compatible = "renesas,intc-irqpin-r8a7779", 
>> "renesas,intc-irqpin";
>>   #interrupt-cells = <2>;
>>   status = "disabled";
>> @@ -148,7 +148,8 @@
>>   <0xfe780010 4>,
>>   <0xfe780024 4>,
>>   <0xfe780044 4>,
>> - <0xfe780064 4>;
>> + <0xfe780064 4>,
>> + <0xfe78 4>;
>
> Is there any order implied by the above list?
> Naïvely I would expect it to be sorted numerically.

Yes, the driver assumes the register banks to be passed in a certain
order. In the case of r8a7779 we add one more register bank at the end
for IRLM setup. Register detail (base address, access size, order and
bitfield width) varies with SoC version. So the IRLM register will be
at different addresses depending on SoC, but the driver wants it at
the end of the list.

Cheers,

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


Re: [PATCH v6 0/7] ARM: shmobile: R-Mobile: DT PM domain support

2014-12-03 Thread Simon Horman
On Wed, Dec 03, 2014 at 02:41:40PM +0100, Geert Uytterhoeven wrote:
>   Hi Simon, Magnus,
> 
> This patch series enables DT support for PM domains on Renesas R-Mobile SoCs.
> 
> Currently it's limited to R-Mobile A1 (r8a7740), but given the similarity of
> the SYSC System-Controller on the various SH-Mobile/R-Mobile SoCs, and the
> abstraction of PM domains in DT, it should be sufficiently generic to handle
> other SoCs in the future (e.g. SH-Mobile AP4 (sh7372), SH-Mobile AG5 (sh73a0),
> R-Mobile APE6 (r8a73a4)). In fact preliminary patches for SH-Mobile AG5
> (sh73a0) that build on top of this have been posted before.
> 
> Functionality-wise, this behaves the same as the legacy (non-DT) version
> (modulo missing DT support in some device drivers).
> 
> Please apply, thanks!

Thanks, I have done so.

> 
> Dependencies:
>   - This is based on Simon Horman's renesas-devel-20141202-v3.18-rc7.
> 
> Changes compared to v5:
>   - Drop bindings and code for power-on/off latencies. They can be handled
> later.  This means the whole series can go through Simon's tree now.
> 
> Changes compared to v4:
>   - Update for {at,de}tach_dev() taking a generic_pm_domain pointer
> again,
> 
> Changes compared to v3 (more detailed changelogs in the individual patches):
>   - I dropped the patch to add preliminary PM domain latencies, as I want to 
> do
> more measurements for PM domains that are currently never powered off.
> Values seem to range between 8.5 and 26 us, depending on the PM domain.
>   - I dropped all patches related to QoS device latencies, as these need more
> discussion,
>   - The power-{on,off}-latency properties have been changed from a single 
> value
> to a list,
>   - Device save/restore state latencies have been dropped, as they're Linux
> driver-specific, and thus don't belong in DT,
>   - Use proper pm_clk_create()/pm_clk_destroy(), and update for attach_dev()
> returning an error code again,
>   - New patch to enable module clocks if !CONFIG_PM_RUNTIME,
>   - Always keep D4 powered, until the new Coresight code handles runtime
> PM,
>   - Remove bogus power-domains properties from clock nodes, as these will not
> be instantiated as platform devices,
>   - Add power-domains properties to the recently added TMU nodes,
>   - Added Acked-by, Reviewed-by.
> 
> Changes compared to v2 (more detailed changelogs in the individual patches):
>   - Minor changes to attach/detach callbacks,
>   - Really add the A4MP and D4 PM domains, as fixes are available (see
> dependencies below),
>   - Scan DT topology to identify special PM domains (CPUs and console),
>   - Move PM domain power-on/off latencies to a separate patch.
> 
> Changes compared to v1 (more detailed changelogs in the individual patches):
>   - Several new patches: PM QoS device latencies in DT, attach/detach
> callbacks,
>   - Run-Time management of the module clocks, making the hack in
> drivers/sh/pm_runtime.c obsolete for DT platforms using genpd,
>   - Addition of PM QoS device latencies, specified from DT,
>   - Addition of build glue, so this builds and runs without additional
> changes, incl. s2ram.
> 
> Geert Uytterhoeven (7):
>   PM / Domains: Add DT bindings for the R-Mobile System Controller
>   ARM: shmobile: R-Mobile: Use generic_pm_domain.attach_dev() for pm_clk
> setup
>   ARM: shmobile: R-Mobile: Enable module clocks if !CONFIG_PM_RUNTIME
>   ARM: shmobile: R-Mobile: Store SYSC base address in rmobile_pm_domain
>   ARM: shmobile: R-Mobile: Add DT support for PM domains
>   ARM: shmobile: r8a7740 dtsi: Add PM domain support
>   drivers: sh: Disable PM runtime for multi-platform r8a7740 with genpd
> 
>  .../bindings/power/renesas,sysc-rmobile.txt|  98 +++
>  arch/arm/boot/dts/r8a7740.dtsi |  99 
>  arch/arm/mach-shmobile/Kconfig |   3 +-
>  arch/arm/mach-shmobile/pm-r8a7740.c|  14 +
>  arch/arm/mach-shmobile/pm-rmobile.c| 281 
> +++--
>  arch/arm/mach-shmobile/pm-rmobile.h|   3 +-
>  arch/arm/mach-shmobile/pm-sh7372.c |  11 +
>  drivers/sh/pm_runtime.c|   2 +
>  8 files changed, 494 insertions(+), 17 deletions(-)
>  create mode 100644 
> Documentation/devicetree/bindings/power/renesas,sysc-rmobile.txt
> 
> -- 
> 1.9.1
> 
> 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  

Re: [PATCH 01/02] irqchip: renesas-intc-irqpin: r8a7779 IRLM setup support

2014-12-03 Thread Magnus Damm
Hi Simon,

On Thu, Dec 4, 2014 at 4:18 PM, Simon Horman  wrote:
> Hi Magnus,
>
> I see you have been busy with the marzen board.

Yes! =)

> On Wed, Dec 03, 2014 at 09:18:03PM +0900, Magnus Damm wrote:
>> From: Magnus Damm 
>>
>> Add r8a7779 specific support for IRLM bit configuration
>> in the INTC-IRQPIN driver. Without this code we need
>> special workaround code in arch/arm/mach-shmobile.
>>
>> The IRLM bit for the INTC hardware exists on various
>> older SH-based SoCs and is used to select between two
>> modes for the external interrupt pins IRQ0 to IRQ3:
>>
>> IRLM = 0: (default from reset on r8a7779)
>> In this mode the pins IRQ0 to IRQ3 are used together
>> to give a value between 0 and 15 to the SoC. External
>> logic is required for masking. This mode is not
>> supported by the INTC-IRQPIN driver.
>>
>> IRLM = 1: (needs this patch or configuration elsewhere)
>> In this mode IRQ0 to IRQ3 operate as 4 individual
>> external interrupt pins. In this mode the SMSC ethernet
>> chip can be used via IRQ1 on r8a7779 Marzen. This mode
>> is the only supported mode by the INTC-IRQPIN driver.
>>
>> For this patch to work the r8a7779 DTS needs to pass
>> the ICR0 register as the last register bank.
>>
>> Signed-off-by: Magnus Damm 
>> ---
>>
>>  Written against renesas-devel-20141202-v3.18-rc7 which is
>>  basically v3.18-rc7 plus latest arch/arm/mach-shmobile code.
>>
>>  
>> Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.txt
>>  |5 +
>>  drivers/irqchip/irq-renesas-intc-irqpin.c   
>>|   50 --
>>  2 files changed, 46 insertions(+), 9 deletions(-)
>>
>> --- 
>> 0001/Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.txt
>> +++ 
>> work/Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.txt
>>2014-12-03 20:25:13.0 +0900
>> @@ -9,6 +9,11 @@ Required properties:
>>  - "renesas,intc-irqpin-r8a7778" (R-Car M1A)
>>  - "renesas,intc-irqpin-r8a7779" (R-Car H1)
>>  - "renesas,intc-irqpin-sh73a0" (SH-Mobile AG5)
>> +
>> +- reg: Base address and length of each register bank used by the external
>> +  IRQ pins driven by the interrupt controller hardware module. The base
>> +  addresses, length and number of required register banks varies with 
>> soctype.
>> +
>>  - #interrupt-cells: has to be <2>: an interrupt index and flags, as defined 
>> in
>>interrupts.txt in this directory
>>
>> --- 0001/drivers/irqchip/irq-renesas-intc-irqpin.c
>> +++ work/drivers/irqchip/irq-renesas-intc-irqpin.c2014-12-03 
>> 20:32:59.0 +0900
>> @@ -30,6 +30,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>
>> @@ -40,7 +41,9 @@
>>  #define INTC_IRQPIN_REG_SOURCE 2 /* INTREQnn */
>>  #define INTC_IRQPIN_REG_MASK 3 /* INTMSKnn */
>>  #define INTC_IRQPIN_REG_CLEAR 4 /* INTMSKCLRnn */
>> -#define INTC_IRQPIN_REG_NR 5
>> +#define INTC_IRQPIN_REG_NR_MANDATORY 5
>> +#define INTC_IRQPIN_REG_IRLM 5 /* ICR0 with IRLM bit (optional) */
>> +#define INTC_IRQPIN_REG_NR 6
>>
>>  /* INTC external IRQ PIN hardware register access:
>>   *
>> @@ -82,6 +85,10 @@ struct intc_irqpin_priv {
>>   u8 shared_irq_mask;
>>  };
>>
>> +struct intc_irqpin_irlm_config {
>> + unsigned int irlm_bit;
>> +};
>> +
>>  static unsigned long intc_irqpin_read32(void __iomem *iomem)
>>  {
>>   return ioread32(iomem);
>> @@ -345,10 +352,23 @@ static struct irq_domain_ops intc_irqpin
>>   .xlate  = irq_domain_xlate_twocell,
>>  };
>>
>> +static const struct intc_irqpin_irlm_config intc_irqpin_irlm_r8a7779 = {
>> + .irlm_bit = 23, /* ICR0.IRLM0 */
>> +};
>> +
>> +static const struct of_device_id intc_irqpin_dt_ids[] = {
>> + { .compatible = "renesas,intc-irqpin", },
>> + { .compatible = "renesas,intc-irqpin-r8a7779",
>> +   .data = _irqpin_irlm_r8a7779 },
>> + {},
>> +};
>> +MODULE_DEVICE_TABLE(of, intc_irqpin_dt_ids);
>> +
>>  static int intc_irqpin_probe(struct platform_device *pdev)
>>  {
>>   struct device *dev = >dev;
>>   struct renesas_intc_irqpin_config *pdata = dev->platform_data;
>> + const struct of_device_id *of_id;
>>   struct intc_irqpin_priv *p;
>>   struct intc_irqpin_iomem *i;
>>   struct resource *io[INTC_IRQPIN_REG_NR];
>> @@ -391,10 +411,11 @@ static int intc_irqpin_probe(struct plat
>>   pm_runtime_enable(dev);
>>   pm_runtime_get_sync(dev);
>>
>> - /* get hold of manadatory IOMEM */
>> + /* get hold of register banks */
>> + memset(io, 0, sizeof(io));
>>   for (k = 0; k < INTC_IRQPIN_REG_NR; k++) {
>>   io[k] = platform_get_resource(pdev, IORESOURCE_MEM, k);
>> - if (!io[k]) {
>> + if (!io[k] && k < INTC_IRQPIN_REG_NR_MANDATORY) {
>>   dev_err(dev, "not enough IOMEM resources\n");
>>   ret = -EINVAL;
>>   goto err0;
>> @@ -422,6 +443,10 @@ static int intc_irqpin_probe(struct plat
>> 

[PATCH v3 4/4] powernv: powerpc: Add winkle support for offline cpus

2014-12-03 Thread Shreyas B. Prabhu
Winkle is a deep idle state supported in power8 chips. A core enters
winkle when all the threads of the core enter winkle. In this state
power supply to the entire chiplet i.e core, private L2 and private L3
is turned off. As a result it gives higher powersavings compared to
sleep.

But entering winkle results in a total hypervisor state loss. Hence the
hypervisor context has to be preserved before entering winkle and
restored upon wake up.

Power-on Reset Engine (PORE) is a dedicated engine which is responsible
for powering on the chiplet during wake up. It can be programmed to
restore the register contests of a few specific registers. This patch
uses PORE to restore register state wherever possible and uses stack to
save and restore rest of the necessary registers.

With hypervisor state restore things fall under three categories-
per-core state, per-subcore state and per-thread state. To manage this,
extend the infrastructure introduced for sleep. Mainly we add a paca
variable subcore_sibling_mask. Using this and the core_idle_state we can
distingush first thread in core and subcore.

Signed-off-by: Shreyas B. Prabhu 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: linuxppc-...@lists.ozlabs.org
---
 arch/powerpc/include/asm/opal.h|   3 +
 arch/powerpc/include/asm/paca.h|   2 +
 arch/powerpc/include/asm/ppc-opcode.h  |   2 +
 arch/powerpc/include/asm/processor.h   |   1 +
 arch/powerpc/include/asm/reg.h |   2 +
 arch/powerpc/kernel/asm-offsets.c  |   2 +
 arch/powerpc/kernel/exceptions-64s.S   |  16 ++-
 arch/powerpc/kernel/idle_power7.S  | 151 +++--
 arch/powerpc/platforms/powernv/opal-wrappers.S |   1 +
 arch/powerpc/platforms/powernv/setup.c |  73 
 arch/powerpc/platforms/powernv/smp.c   |   4 +-
 arch/powerpc/platforms/powernv/subcore.c   |  34 ++
 arch/powerpc/platforms/powernv/subcore.h   |   1 +
 13 files changed, 280 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index bef7fbc..f0ca2d9 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -153,6 +153,7 @@ struct opal_sg_list {
 #define OPAL_PCI_EEH_FREEZE_SET97
 #define OPAL_HANDLE_HMI98
 #define OPAL_CONFIG_CPU_IDLE_STATE 99
+#define OPAL_SLW_SET_REG   100
 #define OPAL_REGISTER_DUMP_REGION  101
 #define OPAL_UNREGISTER_DUMP_REGION102
 
@@ -163,6 +164,7 @@ struct opal_sg_list {
  */
 #define OPAL_PM_NAP_ENABLED0x0001
 #define OPAL_PM_SLEEP_ENABLED  0x0002
+#define OPAL_PM_WINKLE_ENABLED 0x0004
 #define OPAL_PM_SLEEP_ENABLED_ER1  0x0008
 
 #ifndef __ASSEMBLY__
@@ -972,6 +974,7 @@ int64_t opal_sensor_read(uint32_t sensor_hndl, int token, 
__be32 *sensor_data);
 int64_t opal_handle_hmi(void);
 int64_t opal_register_dump_region(uint32_t id, uint64_t start, uint64_t end);
 int64_t opal_unregister_dump_region(uint32_t id);
+int64_t opal_slw_set_reg(uint64_t cpu_pir, uint64_t sprn, uint64_t val);
 int64_t opal_pci_set_phb_cxl_mode(uint64_t phb_id, uint64_t mode, uint64_t 
pe_number);
 
 /* Internal functions */
diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h
index e4578c3..e89f4a4 100644
--- a/arch/powerpc/include/asm/paca.h
+++ b/arch/powerpc/include/asm/paca.h
@@ -164,6 +164,8 @@ struct paca_struct {
u8 thread_idle_state;   /* ~Idle[0]/Nap[1]/Sleep[2]/Winkle[3] */
/* Mask to indicate thread id in core */
u8 thread_mask;
+   /* Mask to denote subcore sibling threads */
+   u8 subcore_sibling_mask;
 #endif
 #ifdef CONFIG_PPC_BOOK3S_64
/* Exclusive emergency stack pointer for machine check exception. */
diff --git a/arch/powerpc/include/asm/ppc-opcode.h 
b/arch/powerpc/include/asm/ppc-opcode.h
index 6f85362..5155be7 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -194,6 +194,7 @@
 
 #define PPC_INST_NAP   0x4c000364
 #define PPC_INST_SLEEP 0x4c0003a4
+#define PPC_INST_WINKLE0x4c0003e4
 
 /* A2 specific instructions */
 #define PPC_INST_ERATWE0x7c0001a6
@@ -374,6 +375,7 @@
 
 #define PPC_NAPstringify_in_c(.long PPC_INST_NAP)
 #define PPC_SLEEP  stringify_in_c(.long PPC_INST_SLEEP)
+#define PPC_WINKLE stringify_in_c(.long PPC_INST_WINKLE)
 
 /* BHRB instructions */
 #define PPC_CLRBHRBstringify_in_c(.long PPC_INST_CLRBHRB)
diff --git a/arch/powerpc/include/asm/processor.h 
b/arch/powerpc/include/asm/processor.h
index dda7ac4..c076842 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -453,6 +453,7 @@ enum idle_boot_override 

[PATCH v3 1/4] powerpc: powernv: Switch off MMU before entering nap/sleep/rvwinkle mode

2014-12-03 Thread Shreyas B. Prabhu
From: Paul Mackerras 

Currently, when going idle, we set the flag indicating that we are in
nap mode (paca->kvm_hstate.hwthread_state) and then execute the nap
(or sleep or rvwinkle) instruction, all with the MMU on.  This is bad
for two reasons: (a) the architecture specifies that those instructions
must be executed with the MMU off, and in fact with only the SF, HV, ME
and possibly RI bits set, and (b) this introduces a race, because as
soon as we set the flag, another thread can switch the MMU to a guest
context.  If the race is lost, this thread will typically start looping
on relocation-on ISIs at 0xc...4400.

This fixes it by setting the MSR as required by the architecture before
setting the flag or executing the nap/sleep/rvwinkle instruction.

[ shre...@linux.vnet.ibm.com: Edited to handle LE ]
Signed-off-by: Paul Mackerras 
Signed-off-by: Shreyas B. Prabhu 
Cc: Benjamin Herrenschmidt 
Cc: Michael Ellerman 
Cc: linuxppc-...@lists.ozlabs.org
---
 arch/powerpc/include/asm/reg.h|  2 ++
 arch/powerpc/kernel/idle_power7.S | 18 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index c998279..a68ee15 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -118,8 +118,10 @@
 #define __MSR  (MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_ISF |MSR_HV)
 #ifdef __BIG_ENDIAN__
 #define MSR_   __MSR
+#define MSR_IDLE   (MSR_ME | MSR_SF | MSR_HV)
 #else
 #define MSR_   (__MSR | MSR_LE)
+#define MSR_IDLE   (MSR_ME | MSR_SF | MSR_HV | MSR_LE)
 #endif
 #define MSR_KERNEL (MSR_ | MSR_64BIT)
 #define MSR_USER32 (MSR_ | MSR_PR | MSR_EE)
diff --git a/arch/powerpc/kernel/idle_power7.S 
b/arch/powerpc/kernel/idle_power7.S
index c0754bb..283c603 100644
--- a/arch/powerpc/kernel/idle_power7.S
+++ b/arch/powerpc/kernel/idle_power7.S
@@ -101,7 +101,23 @@ _GLOBAL(power7_powersave_common)
std r9,_MSR(r1)
std r1,PACAR1(r13)
 
-_GLOBAL(power7_enter_nap_mode)
+   /*
+* Go to real mode to do the nap, as required by the architecture.
+* Also, we need to be in real mode before setting hwthread_state,
+* because as soon as we do that, another thread can switch
+* the MMU context to the guest.
+*/
+   LOAD_REG_IMMEDIATE(r5, MSR_IDLE)
+   li  r6, MSR_RI
+   andcr6, r9, r6
+   LOAD_REG_ADDR(r7, power7_enter_nap_mode)
+   mtmsrd  r6, 1   /* clear RI before setting SRR0/1 */
+   mtspr   SPRN_SRR0, r7
+   mtspr   SPRN_SRR1, r5
+   rfid
+
+   .globl  power7_enter_nap_mode
+power7_enter_nap_mode:
 #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
/* Tell KVM we're napping */
li  r4,KVM_HWTHREAD_IN_NAP
-- 
1.9.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 v3 2/4] powerpc/powernv: Enable Offline CPUs to enter deep idle states

2014-12-03 Thread Shreyas B. Prabhu
From: "Preeti U. Murthy" 

The secondary threads should enter deep idle states so as to gain maximum
powersavings when the entire core is offline. To do so the offline path
must be made aware of the available deepest idle state. Hence probe the
device tree for the possible idle states in powernv core code and
expose the deepest idle state through flags.

Since the  device tree is probed by the cpuidle driver as well, move
the parameters required to discover the idle states into an appropriate
common place to both the driver and the powernv core code.

Another point is that fastsleep idle state may require workarounds in
the kernel to function properly. This workaround is introduced in the
subsequent patches. However neither the cpuidle driver or the hotplug
path need be bothered about this workaround.

They will be taken care of by the core powernv code.

Originally-by: Srivatsa S. Bhat 
Signed-off-by: Preeti U. Murthy 
Signed-off-by: Shreyas B. Prabhu 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Rafael J. Wysocki 
Cc: linux...@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
---
 arch/powerpc/include/asm/opal.h  |  8 ++
 arch/powerpc/platforms/powernv/powernv.h |  2 ++
 arch/powerpc/platforms/powernv/setup.c   | 49 
 arch/powerpc/platforms/powernv/smp.c |  7 -
 drivers/cpuidle/cpuidle-powernv.c|  9 ++
 5 files changed, 68 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index 9124b0e..f8b95c0 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -155,6 +155,14 @@ struct opal_sg_list {
 #define OPAL_REGISTER_DUMP_REGION  101
 #define OPAL_UNREGISTER_DUMP_REGION102
 
+/* Device tree flags */
+
+/* Flags set in power-mgmt nodes in device tree if
+ * respective idle states are supported in the platform.
+ */
+#define OPAL_PM_NAP_ENABLED0x0001
+#define OPAL_PM_SLEEP_ENABLED  0x0002
+
 #ifndef __ASSEMBLY__
 
 #include 
diff --git a/arch/powerpc/platforms/powernv/powernv.h 
b/arch/powerpc/platforms/powernv/powernv.h
index 6c8e2d1..604c48e 100644
--- a/arch/powerpc/platforms/powernv/powernv.h
+++ b/arch/powerpc/platforms/powernv/powernv.h
@@ -29,6 +29,8 @@ static inline u64 pnv_pci_dma_get_required_mask(struct 
pci_dev *pdev)
 }
 #endif
 
+extern u32 pnv_get_supported_cpuidle_states(void);
+
 extern void pnv_lpc_init(void);
 
 bool cpu_core_split_required(void);
diff --git a/arch/powerpc/platforms/powernv/setup.c 
b/arch/powerpc/platforms/powernv/setup.c
index 3f9546d..34c6665 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -290,6 +290,55 @@ static void __init pnv_setup_machdep_rtas(void)
 }
 #endif /* CONFIG_PPC_POWERNV_RTAS */
 
+static u32 supported_cpuidle_states;
+
+u32 pnv_get_supported_cpuidle_states(void)
+{
+   return supported_cpuidle_states;
+}
+
+static int __init pnv_init_idle_states(void)
+{
+   struct device_node *power_mgt;
+   int dt_idle_states;
+   const __be32 *idle_state_flags;
+   u32 len_flags, flags;
+   int i;
+
+   supported_cpuidle_states = 0;
+
+   if (cpuidle_disable != IDLE_NO_OVERRIDE)
+   return 0;
+
+   if (!firmware_has_feature(FW_FEATURE_OPALv3))
+   return 0;
+
+   power_mgt = of_find_node_by_path("/ibm,opal/power-mgt");
+   if (!power_mgt) {
+   pr_warn("opal: PowerMgmt Node not found\n");
+   return 0;
+   }
+
+   idle_state_flags = of_get_property(power_mgt,
+   "ibm,cpu-idle-state-flags", _flags);
+   if (!idle_state_flags) {
+   pr_warn("DT-PowerMgmt: missing ibm,cpu-idle-state-flags\n");
+   return 0;
+   }
+
+   dt_idle_states = len_flags / sizeof(u32);
+
+   for (i = 0; i < dt_idle_states; i++) {
+   flags = be32_to_cpu(idle_state_flags[i]);
+   supported_cpuidle_states |= flags;
+   }
+
+   return 0;
+}
+
+subsys_initcall(pnv_init_idle_states);
+
+
 static int __init pnv_probe(void)
 {
unsigned long root = of_get_flat_dt_root();
diff --git a/arch/powerpc/platforms/powernv/smp.c 
b/arch/powerpc/platforms/powernv/smp.c
index 4753958..3dc4cec 100644
--- a/arch/powerpc/platforms/powernv/smp.c
+++ b/arch/powerpc/platforms/powernv/smp.c
@@ -149,6 +149,7 @@ static int pnv_smp_cpu_disable(void)
 static void pnv_smp_cpu_kill_self(void)
 {
unsigned int cpu;
+   u32 idle_states;
 
/* Standard hot unplug procedure */
local_irq_disable();
@@ -159,13 +160,17 @@ static void pnv_smp_cpu_kill_self(void)
generic_set_cpu_dead(cpu);
smp_wmb();
 
+   idle_states = pnv_get_supported_cpuidle_states();
/* We don't want to take decrementer interrupts while we are offline,
 * so clear LPCR:PECE1. We keep PECE2 enabled.
 */
mtspr(SPRN_LPCR, 

[PATCH v3 3/4] powernv: cpuidle: Redesign idle states management

2014-12-03 Thread Shreyas B. Prabhu
Deep idle states like sleep and winkle are per core idle states. A core
enters these states only when all the threads enter either the
particular idle state or a deeper one. There are tasks like fastsleep
hardware bug workaround and hypervisor core state save which have to be
done only by the last thread of the core entering deep idle state and
similarly tasks like timebase resync, hypervisor core register restore
that have to be done only by the first thread waking up from these
state.

The current idle state management does not have a way to distinguish the
first/last thread of the core waking/entering idle states. Tasks like
timebase resync are done for all the threads. This is not only is
suboptimal, but can cause functionality issues when subcores and kvm is
involved.

This patch adds the necessary infrastructure to track idle states of
threads in a per-core structure. It uses this info to perform tasks like
fastsleep workaround and timebase resync only once per core.

Signed-off-by: Shreyas B. Prabhu 
Originally-by: Preeti U. Murthy 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Rafael J. Wysocki 
Cc: linux...@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
---
 arch/powerpc/include/asm/cpuidle.h |  20 +++
 arch/powerpc/include/asm/opal.h|   2 +
 arch/powerpc/include/asm/paca.h|   6 +
 arch/powerpc/kernel/asm-offsets.c  |   6 +
 arch/powerpc/kernel/exceptions-64s.S   |  24 ++--
 arch/powerpc/kernel/idle_power7.S  | 188 +++--
 arch/powerpc/platforms/powernv/opal-wrappers.S |  37 +
 arch/powerpc/platforms/powernv/setup.c |  47 ++-
 arch/powerpc/platforms/powernv/smp.c   |   3 +-
 drivers/cpuidle/cpuidle-powernv.c  |   3 +-
 10 files changed, 277 insertions(+), 59 deletions(-)
 create mode 100644 arch/powerpc/include/asm/cpuidle.h

diff --git a/arch/powerpc/include/asm/cpuidle.h 
b/arch/powerpc/include/asm/cpuidle.h
new file mode 100644
index 000..d2f99ca
--- /dev/null
+++ b/arch/powerpc/include/asm/cpuidle.h
@@ -0,0 +1,20 @@
+#ifndef _ASM_POWERPC_CPUIDLE_H
+#define _ASM_POWERPC_CPUIDLE_H
+
+#ifdef CONFIG_PPC_POWERNV
+/* Used in powernv idle state management */
+#define PNV_THREAD_RUNNING  0
+#define PNV_THREAD_NAP  1
+#define PNV_THREAD_SLEEP2
+#define PNV_THREAD_WINKLE   3
+#define PNV_CORE_IDLE_LOCK_BIT  0x100
+#define PNV_CORE_IDLE_THREAD_BITS   0x0FF
+
+#ifndef __ASSEMBLY__
+extern u32 pnv_fastsleep_workaround_at_entry[];
+extern u32 pnv_fastsleep_workaround_at_exit[];
+#endif
+
+#endif
+
+#endif
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index f8b95c0..bef7fbc 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -152,6 +152,7 @@ struct opal_sg_list {
 #define OPAL_PCI_ERR_INJECT96
 #define OPAL_PCI_EEH_FREEZE_SET97
 #define OPAL_HANDLE_HMI98
+#define OPAL_CONFIG_CPU_IDLE_STATE 99
 #define OPAL_REGISTER_DUMP_REGION  101
 #define OPAL_UNREGISTER_DUMP_REGION102
 
@@ -162,6 +163,7 @@ struct opal_sg_list {
  */
 #define OPAL_PM_NAP_ENABLED0x0001
 #define OPAL_PM_SLEEP_ENABLED  0x0002
+#define OPAL_PM_SLEEP_ENABLED_ER1  0x0008
 
 #ifndef __ASSEMBLY__
 
diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h
index a5139ea..e4578c3 100644
--- a/arch/powerpc/include/asm/paca.h
+++ b/arch/powerpc/include/asm/paca.h
@@ -158,6 +158,12 @@ struct paca_struct {
 * early exception handler for use by high level C handler
 */
struct opal_machine_check_event *opal_mc_evt;
+
+   /* Per-core mask tracking idle threads and a lock bit-[L][] */
+   u32 *core_idle_state_ptr;
+   u8 thread_idle_state;   /* ~Idle[0]/Nap[1]/Sleep[2]/Winkle[3] */
+   /* Mask to indicate thread id in core */
+   u8 thread_mask;
 #endif
 #ifdef CONFIG_PPC_BOOK3S_64
/* Exclusive emergency stack pointer for machine check exception. */
diff --git a/arch/powerpc/kernel/asm-offsets.c 
b/arch/powerpc/kernel/asm-offsets.c
index 9d7dede..3bc0352 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -731,6 +731,12 @@ int main(void)
DEFINE(OPAL_MC_SRR0, offsetof(struct opal_machine_check_event, srr0));
DEFINE(OPAL_MC_SRR1, offsetof(struct opal_machine_check_event, srr1));
DEFINE(PACA_OPAL_MC_EVT, offsetof(struct paca_struct, opal_mc_evt));
+   DEFINE(PACA_CORE_IDLE_STATE_PTR,
+   offsetof(struct paca_struct, core_idle_state_ptr));
+   DEFINE(PACA_THREAD_IDLE_STATE,
+   offsetof(struct paca_struct, thread_idle_state));
+   DEFINE(PACA_THREAD_MASK,
+   offsetof(struct paca_struct, thread_mask));
 #endif
 
 

Re: [RFC 0/6] zsmalloc support compaction

2014-12-03 Thread 박승호/책임연구원/SW Platform(연)AOT팀(seungho1.p...@lge.com)

Hi, Minchan.

I got it. Thank u :).

Seungho.

2014-12-04 오후 4:20에 Minchan Kim 이(가) 쓴 글:

Hey Seungho,

On Thu, Dec 04, 2014 at 03:49:21PM +0900, "박승호/책임연구원/SW 
Platform(연)AOT팀(seungho1.p...@lge.com)" wrote:

Hi, Minchan.

I have a question.
The problem mentioned can't be resolved with compaction?
Is there any reason that zsmalloc pages can't be moved by compaction
operation in direct reclaim?

Currently, zsmalloc doesn't request movable page to page allocator
since compaction is not aware of zram pages(ie, PageZram(page)).
IOW, compaction cannot migrate zram pages at the moment.
As I described, it's final destination we should go but I think
we need more thinking to generalize such special pages handling
(ex, balloon, zswap, zram and so on for future) in compaction logic.

Now, I want to merge basic primitive functions in zsmalloc to
support zspage migration, which will be used as basic utility functions
for supporting compaction-aware zspage migration.

In addition, even we need manual opeartion logic to trigger
compaction for zsmalloc like /proc/sys/vm/compact_memory.


2014-12-02 오전 11:49에 Minchan Kim 이(가) 쓴 글:

Recently, there was issue about zsmalloc fragmentation and
I got a report from Juno that new fork failed although there
are plenty of free pages in the system.
His investigation revealed zram is one of the culprit to make
heavy fragmentation so there was no more contiguous 16K page
for pgd to fork in the ARM.

This patchset implement *basic* zsmalloc compaction support
and zram utilizes it so admin can do
"echo 1 > /sys/block/zram0/compact"

Actually, ideal is that mm migrate code is aware of zram pages and
migrate them out automatically without admin's manual opeartion
when system is out of contiguous page. Howver, we need more thinking
before adding more hooks to migrate.c. Even though we implement it,
we need manual trigger mode, too so I hope we could enhance
zram migration stuff based on this primitive functions in future.

I just tested it on only x86 so need more testing on other arches.
Additionally, I should have a number for zsmalloc regression
caused by indirect layering. Unfortunately, I don't have any
ARM test machine on my desk. I will get it soon and test it.
Anyway, before further work, I'd like to hear opinion.

Pathset is based on v3.18-rc6-mmotm-2014-11-26-15-45.

Thanks.

Minchan Kim (6):
   zsmalloc: expand size class to support sizeof(unsigned long)
   zsmalloc: add indrection layer to decouple handle from object
   zsmalloc: implement reverse mapping
   zsmalloc: encode alloced mark in handle object
   zsmalloc: support compaction
   zram: support compaction

  drivers/block/zram/zram_drv.c |  24 ++
  drivers/block/zram/zram_drv.h |   1 +
  include/linux/zsmalloc.h  |   1 +
  mm/zsmalloc.c | 596 +-
  4 files changed, 552 insertions(+), 70 deletions(-)


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majord...@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: mailto:"d...@kvack.org;> em...@kvack.org 


--
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 0/4] powernv: cpuidle: Redesign idle states management

2014-12-03 Thread Shreyas B. Prabhu
Deep idle states like sleep and winkle are per core idle states. A core
enters these states only when all the threads enter either the particular
idle state or a deeper one. There are tasks like fastsleep hardware bug
workaround and hypervisor core state save which have to be done only by
the last thread of the core entering deep idle state and similarly tasks
like timebase resync, hypervisor core register restore that have to be
done only by the first thread waking up from these states. 

The current idle state management does not have a way to distinguish the
first/last thread of the core waking/entering idle states. Tasks like
timebase resync are done for all the threads. This is not only is suboptimal,
but can cause functionality issues when subcores are involved.

Winkle is deeper idle state compared to fastsleep. In this state the power
supply to the chiplet, i.e core, private L2 and private L3 is turned off.
This results in a total hypervisor state loss. This patch set adds support
for winkle and provides a way to track the idle states of the threads of the
core and use it for idle state management of idle states sleep and winkle.

TBD:

- Remove duplication of branching to kvm code. 

Changes in v3:
-
- Added barriers after lock
- Added a paca field to that stores thread mask. 
- Changed code structure around fastsleep workaround, to allow for manual
  patching out if the platform does not require it. 
- Threads waiting on core_idle_state lock now loop in HMT_LOW
- Using NV CRs to avoid save/restore of CR while making OPAL calls.
- Fixed couple of flow issues in path where fastsleep workaround was not needed
- Using PPC_LR_STKOFF instead of _LINK in opal_call_realmode
- Restoring WORT and WORC

Changes in v2:
--
-Using PNV_THREAD_NAP/SLEEP defines while calling power7_powersave_common
-Comment changes based on review
-Rebased on top of 3.18-rc6


Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Rafael J. Wysocki 
Cc: linux...@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: Vaidyanathan Srinivasan 
Cc: Preeti U Murthy 

Paul Mackerras (1):
  powerpc: powernv: Switch off MMU before entering nap/sleep/rvwinkle
mode

Preeti U. Murthy (1):
  powerpc/powernv: Enable Offline CPUs to enter deep idle states

Shreyas B. Prabhu (2):
  powernv: cpuidle: Redesign idle states management
  powernv: powerpc: Add winkle support for offline cpus

 arch/powerpc/include/asm/cpuidle.h |  14 ++
 arch/powerpc/include/asm/opal.h|  13 +
 arch/powerpc/include/asm/paca.h|   6 +
 arch/powerpc/include/asm/ppc-opcode.h  |   2 +
 arch/powerpc/include/asm/processor.h   |   1 +
 arch/powerpc/include/asm/reg.h |   4 +
 arch/powerpc/kernel/asm-offsets.c  |   6 +
 arch/powerpc/kernel/cpu_setup_power.S  |   4 +
 arch/powerpc/kernel/exceptions-64s.S   |  30 ++-
 arch/powerpc/kernel/idle_power7.S  | 332 +
 arch/powerpc/platforms/powernv/opal-wrappers.S |  39 +++
 arch/powerpc/platforms/powernv/powernv.h   |   2 +
 arch/powerpc/platforms/powernv/setup.c | 160 
 arch/powerpc/platforms/powernv/smp.c   |  10 +-
 arch/powerpc/platforms/powernv/subcore.c   |  34 +++
 arch/powerpc/platforms/powernv/subcore.h   |   1 +
 drivers/cpuidle/cpuidle-powernv.c  |  10 +-
 17 files changed, 608 insertions(+), 60 deletions(-)
 create mode 100644 arch/powerpc/include/asm/cpuidle.h

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


Re: [PATCH V3] MIPS: BCM47XX: Move NVRAM driver to the drivers/soc/

2014-12-03 Thread Rafał Miłecki
On 4 December 2014 at 07:43, Paul Walmsley  wrote:
> Hello Rafał,
>
> On Fri, 28 Nov 2014, Paul Walmsley wrote:
>
>> On Thu, 27 Nov 2014, Rafał Miłecki wrote:
>>
>> > I'm pretty sure you look at some old version of arch/bcm47xx/nvram.c.
>> > I wouldn't dare to move such a MIPS-focused driver to some common
>> > place ;)
>> >
>> > Please check for the version of nvram.c in Ralf's upstream-sfr tree. I
>> > think you'll like it much more. Hopefully you will even consider it
>> > ready for moving to the drivers/firmware/ or whatever :)
>>
>> OK I will take a look at this, and will either send comments, or will
>> send a Reviewed-By:.
>
> I had the chance to take a brief look at this file, and you are right: I
> like your newer version better than the older one :-)
>
> It is too bad that it seems this flash area has to be accessed very early
> in boot.  That certainly makes it more difficult to write something
> particularly elegant.  It is also a pity that it is unknown how to verify
> that the flash MMIO window has been configured before reading from these
> areas of the address space.  But under the circumstances, calling
> bcm47xx_nvram_init_from_mem() with the appropriate addresses from the bus
> code during early init, as you did, seems rather reasonable.  I also like
> the code that you added to read the flash data from MTD later in boot.
>
> Here are a few very minor comments that you are welcome to take or leave
> as you wish.

Thanks for your comments! I'll address them before (trying) moving
driver to the drivers/firmware/. Appreciate your review.
--
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] Add TI CDCE925 I2C controlled clock synthesizer driver

2014-12-03 Thread Mike Looijmans
This driver supports the TI CDCE925 programmable clock synthesizer.
The chip contains two PLLs with spread-spectrum clocking support and
five output dividers. The driver only supports the following setup,
and uses a fixed setting for the output muxes:
  Y1 is derived from the input clock
  Y2 and Y3 derive from PLL1
  Y4 and Y5 derive from PLL2
Given a target output frequency, the driver will set the PLL and
divider to best approximate the desired output.

Signed-off-by: Mike Looijmans 
---

v2: Coding style check
Add devicetree binding documentation

 .../devicetree/bindings/clock/cdce925.txt  |   61 ++
 drivers/clk/Kconfig|   17 +
 drivers/clk/Makefile   |1 +
 drivers/clk/clk-cdce925.c  |  792 
 4 files changed, 871 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/cdce925.txt
 create mode 100644 drivers/clk/clk-cdce925.c

diff --git a/Documentation/devicetree/bindings/clock/cdce925.txt 
b/Documentation/devicetree/bindings/clock/cdce925.txt
new file mode 100644
index 000..0eac770
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/cdce925.txt
@@ -0,0 +1,61 @@
+Binding for TO CDCE925 programmable I2C clock synthesizers.
+
+Reference
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+[2] http://www.ti.com/product/cdce925
+
+Required properties:
+ - compatible: Shall be one of "cdce925", "cdce925pw",
+ - reg: I2C device address.
+ - clocks: Points to a fixed parent clock that provides the input frequency.
+ - #clock-cells: From common clock bindings: Shall be 1.
+
+Optional properties:
+ - xtal-load-pf: Crystal load-capacitor value to fine-tune performance on a
+ board, or to compensate for external influences.
+
+
+For each connected output Y1 through Y5, a child node should be provided. Each
+child node must have the following properties:
+ - #clock-cells: From common clock bindings: Shall be 0.
+Optional properties for the output nodes:
+ - clock-frequency: Output frequency to generate. This defines the output
+   frequency set during boot. It can be reprogrammed during
+   runtime through the common clock framework.
+
+For both PLL1 and PLL2 an optional child node can be used to specify spread
+spectrum clocking parameters.
+  - spread-spectrum: SSC mode as defined in the data sheet.
+  - spread-spectrum-center: Use "centered" mode instead of "max" mode. When 
this
+is present, the clock runs at the requested frequency on average.
+
+
+Example:
+
+   clockgen: cdce925pw@64 {
+   compatible = "cdce925";
+   reg = <0x64>;
+   clocks = <_27Mhz>;
+   xtal-load-pf = <5>;
+   #clock-cells = <1>;
+   /* PLL options to get SSC 1% centered */
+   PLL2 {
+   spread-spectrum = <4>;
+   spread-spectrum-center;
+   };
+   /* Outputs calculate mux and divider settings */
+   Y1 {
+   #clock-cells = <0>;
+   clock-frequency = <27000>;
+   };
+   audio_clock: Y2 {
+   #clock-cells = <0>;
+   clock-frequency = <12288000>; /* SPDIF audio */
+   };
+   hdmi_pixel_clock: Y4 {
+   #clock-cells = <0>;
+   clock-frequency = <14850>; /* HD-video */
+   };
+   };
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 455fd17..4e474b3 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -77,6 +77,23 @@ config COMMON_CLK_SI570
  This driver supports Silicon Labs 570/571/598/599 programmable
  clock generators.
 
+config COMMON_CLK_CDCE925
+   tristate "Clock driver for TI CDCE925 devices"
+   depends on I2C
+   depends on OF
+   select REGMAP_I2C
+   help
+   ---help---
+ This driver supports the TI CDCE925 programmable clock synthesizer.
+ The chip contains two PLLs with spread-spectrum clocking support and
+ five output dividers. The driver only supports the following setup,
+ and uses a fixed setting for the output muxes.
+ Y1 is derived from the input clock
+ Y2 and Y3 derive from PLL1
+ Y4 and Y5 derive from PLL2
+ Given a target output frequency, the driver will set the PLL and
+ divider to best approximate the desired output.
+
 config COMMON_CLK_S2MPS11
tristate "Clock driver for S2MPS1X/S5M8767 MFD"
depends on MFD_SEC_CORE
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index d5fba5b..c476066 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -35,6 +35,7 @@ obj-$(CONFIG_COMMON_CLK_RK808)+= clk-rk808.o
 

[PATCH md] lib: raid: raid_cauchy_init() can be static

2014-12-03 Thread kbuild test robot
lib/raid/module.c:417:12: sparse: symbol 'raid_cauchy_init' was not declared. 
Should it be static?
lib/raid/raid.c:156:9: sparse: symbol 'raid_zero_block' was not declared. 
Should it be static?

Signed-off-by: Fengguang Wu 
---
 module.c |2 +-
 raid.c   |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/raid/module.c b/lib/raid/module.c
index 8d45ab4..37962b0 100644
--- a/lib/raid/module.c
+++ b/lib/raid/module.c
@@ -414,7 +414,7 @@ int raid_speedtest(int displacement)
 #ifdef __KERNEL__ /* to build the user mode test */
 static int speedtest;
 
-int __init raid_cauchy_init(void)
+static int __init raid_cauchy_init(void)
 {
int ret;
 
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index e1b1660..c662f97 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -153,7 +153,7 @@
 /**
  * Buffer filled with 0 used in recovering.
  */
-uint8_t raid_zero_block[PAGE_SIZE] __aligned(256);
+static uint8_t raid_zero_block[PAGE_SIZE] __aligned(256);
 
 #ifdef RAID_USE_XOR_BLOCKS
 /*
--
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] optimize ktime_divns for constant divisors

2014-12-03 Thread Nicolas Pitre
On Wed, 3 Dec 2014, Arnd Bergmann wrote:

> On Wednesday 03 December 2014 14:43:06 Nicolas Pitre wrote:
> > At least on ARM, do_div() is optimized to turn constant divisors into
> > an inline multiplication by the reciprocal value at compile time. 
> > However this optimization is missed entirely whenever ktime_divns() is
> > used and the slow out-of-line division code is used all the time.
> > 
> > Let ktime_divns() use do_div() inline whenever the divisor is constant
> > and small enough.  This will make things like ktime_to_us() and 
> > ktime_to_ms() much faster.
> > 
> > Signed-off-by: Nicolas Pitre 
> 
> Very cool. I've been thinking about doing something similar for the
> general case but couldn't get the math to work.
> 
> Can you think of an architecture-independent way to ktime_to_sec,
> ktime_to_ms, and ktime_to_us efficiently based on what you did for
> the ARM do_div implementation?

Sure.  gcc generates rather shitty code on ARM compared to the output 
from my do_div() implementation. But here it is:

u64 ktime_to_us(ktime_t kt)
{
u64 ns = ktime_to_ns(kt);
u32 x_lo, x_hi, y_lo, y_hi;
u64 res, carry;

x_hi = ns >> 32;
x_lo = ns;
y_hi = 0x83126e97;
y_lo = 0x8d4fdf3b;

res = (u64)x_lo * y_lo;
carry = (u64)(u32)res + y_lo;
res = (res >> 32) + (carry >> 32);

res += (u64)x_lo * y_hi;
carry = (u64)(u32)res + (u64)x_hi * y_lo;
res = (res >> 32) + (carry >> 32);

res += (u64)x_hi * y_hi;
return res >> 9;
}

For ktime_to_ms() the constants would be as follows:

y_hi = 0x8637bd05;
y_lo = 0xaf6c69b5;
final shift = 19

For ktime_to_sec() that would be:

y_hi = 0x89705f41;
y_lo = 0x36b4a597;
final shift = 29


Nicolas
--
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: [RESEND PATCH v5 3/5] acerhdf: Use bang-bang thermal governor

2014-12-03 Thread Peter Feuerer

Hi again,

Peter Feuerer writes:


Hi Darren,

thank you very much for your reply.


Darren Hart writes:


On Fri, Nov 28, 2014 at 03:20:50PM +0100, Peter Feuerer wrote:

acerhdf has been doing an on-off fan control using hysteresis by
post-manipulating the outcome of thermal subsystem trip point handling.
This patch enables acerhdf to use the bang-bang governor, which is
intended for on-off controlled fans.

Cc: platform-driver-...@vger.kernel.org
Cc: Darren Hart 
Cc: Andrew Morton 
CC: Zhang Rui 
Cc: Andreas Mohr 
Cc: Javi Merino 
Acked-and-tested-by: Borislav Petkov 
Signed-off-by: Peter Feuerer 
---
 drivers/platform/x86/Kconfig   |  3 ++-
 drivers/platform/x86/acerhdf.c | 36 +++-
 2 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index a2eabe6..c173266 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -38,7 +38,8 @@ config ACER_WMI
 
 config ACERHDF

tristate "Acer Aspire One temperature and fan driver"
-   depends on THERMAL && ACPI
+   select THERMAL_GOV_BANG_BANG


So we use select sparingly as it does implicit things.

I checked the THERMAL_GOV_BANG_BANG Kconfig entry, and the help says acerhdf
already depends on it (which it doesn't appear to). Any particular reason to add
select here instead of adding it as a depends.

Why did you drop THERMAL?


I had it like this in my first version of patches:
+ depends on THERMAL && ACPI && THERMAL_GOV_BANG_BANG

But after some discussion with lkml community we ended up with the select 
line and dropped THERMAL dependency, as it is implied by 
THEMAL_GOV_BANG_BANG.  I'm not so experienced with Kconfig, so I must rely 
on the statements of the community in this case.


Just found the link about this discussion I had with Rui and Boris:
http://linux-kernel.2935.n7.nabble.com/PATCH-0-4-acerhdf-thermal-adding-new-models-and-appropriate-governor-tp848572p908256.html

[...]

--
kind regards,
--peter;
--
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 02/02] ARM: shmobile: marzen-reference: Remove IRLM workaround

2014-12-03 Thread Simon Horman
Hi Magnus,

On Wed, Dec 03, 2014 at 09:18:13PM +0900, Magnus Damm wrote:
> From: Magnus Damm 
> 
> Adjust the r8a7779 SoC DTS and the Marzen Reference
> C board code to use DTS only for INTC-IRQPIN IRLM setup.
> 
> Signed-off-by: Magnus Damm 
> ---
> 
>  Written on top of renesas-devel-20141202-v3.18-rc7 and
>  [PATCH] ARM: shmobile: r8a7779 CCF DTS update
> 
>  Has a runtime dependency on:
>  [PATCH 01/02] irqchip: renesas-intc-irqpin: r8a7779 IRLM setup support
> 
>  arch/arm/boot/dts/r8a7779.dtsi  |5 +++--
>  arch/arm/mach-shmobile/board-marzen-reference.c |7 ---
>  2 files changed, 3 insertions(+), 9 deletions(-)
> 
> --- 0002/arch/arm/boot/dts/r8a7779.dtsi
> +++ work/arch/arm/boot/dts/r8a7779.dtsi   2014-12-03 20:27:49.0 
> +0900
> @@ -139,7 +139,7 @@
>   interrupt-controller;
>   };
>  
> - irqpin0: irqpin@fe780010 {
> + irqpin0: irqpin@fe78 {
>   compatible = "renesas,intc-irqpin-r8a7779", 
> "renesas,intc-irqpin";
>   #interrupt-cells = <2>;
>   status = "disabled";
> @@ -148,7 +148,8 @@
>   <0xfe780010 4>,
>   <0xfe780024 4>,
>   <0xfe780044 4>,
> - <0xfe780064 4>;
> + <0xfe780064 4>,
> + <0xfe78 4>;

Is there any order implied by the above list?
Naïvely I would expect it to be sorted numerically.

>   interrupts = <0 27 IRQ_TYPE_LEVEL_HIGH
> 0 28 IRQ_TYPE_LEVEL_HIGH
> 0 29 IRQ_TYPE_LEVEL_HIGH
> --- 0001/arch/arm/mach-shmobile/board-marzen-reference.c
> +++ work/arch/arm/mach-shmobile/board-marzen-reference.c  2014-12-03 
> 20:28:37.0 +0900
> @@ -32,12 +32,6 @@ static void __init marzen_init_timer(voi
>   clocksource_of_init();
>  }
>  
> -static void __init marzen_init(void)
> -{
> - of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> - r8a7779_init_irq_extpin_dt(1); /* IRQ1 as individual interrupt */
> -}
> -
>  static const char *marzen_boards_compat_dt[] __initdata = {
>   "renesas,marzen",
>   "renesas,marzen-reference",
> @@ -50,7 +44,6 @@ DT_MACHINE_START(MARZEN, "marzen")
>   .init_early = shmobile_init_delay,
>   .init_time  = marzen_init_timer,
>   .init_irq   = r8a7779_init_irq_dt,
> - .init_machine   = marzen_init,
>   .init_late  = shmobile_init_late,
>   .dt_compat  = marzen_boards_compat_dt,
>  MACHINE_END
> 
--
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 0/6] zsmalloc support compaction

2014-12-03 Thread 박승호/책임연구원/SW Platform(연)AOT팀(seungho1.p...@lge.com)

Hi, Minchan.

Sorry, I got it. You made zsmalloc pages movable.
forget it.

Seungho.

2014-12-04 오후 3:49에 "박승호/책임연구원/SW Platform(연)AOT팀 
(seungho1.p...@lge.com)" 이(가) 쓴 글:

Hi, Minchan.

I have a question.
The problem mentioned can't be resolved with compaction?
Is there any reason that zsmalloc pages can't be moved by compaction
operation in direct reclaim?

2014-12-02 오전 11:49에 Minchan Kim 이(가) 쓴 글:

Recently, there was issue about zsmalloc fragmentation and
I got a report from Juno that new fork failed although there
are plenty of free pages in the system.
His investigation revealed zram is one of the culprit to make
heavy fragmentation so there was no more contiguous 16K page
for pgd to fork in the ARM.

This patchset implement *basic* zsmalloc compaction support
and zram utilizes it so admin can do
"echo 1 > /sys/block/zram0/compact"

Actually, ideal is that mm migrate code is aware of zram pages and
migrate them out automatically without admin's manual opeartion
when system is out of contiguous page. Howver, we need more thinking
before adding more hooks to migrate.c. Even though we implement it,
we need manual trigger mode, too so I hope we could enhance
zram migration stuff based on this primitive functions in future.

I just tested it on only x86 so need more testing on other arches.
Additionally, I should have a number for zsmalloc regression
caused by indirect layering. Unfortunately, I don't have any
ARM test machine on my desk. I will get it soon and test it.
Anyway, before further work, I'd like to hear opinion.

Pathset is based on v3.18-rc6-mmotm-2014-11-26-15-45.

Thanks.

Minchan Kim (6):
   zsmalloc: expand size class to support sizeof(unsigned long)
   zsmalloc: add indrection layer to decouple handle from object
   zsmalloc: implement reverse mapping
   zsmalloc: encode alloced mark in handle object
   zsmalloc: support compaction
   zram: support compaction

  drivers/block/zram/zram_drv.c |  24 ++
  drivers/block/zram/zram_drv.h |   1 +
  include/linux/zsmalloc.h  |   1 +
  mm/zsmalloc.c | 596 
+-

  4 files changed, 552 insertions(+), 70 deletions(-)





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


Re: [RFC 0/6] zsmalloc support compaction

2014-12-03 Thread Minchan Kim
Hey Seungho,

On Thu, Dec 04, 2014 at 03:49:21PM +0900, "박승호/책임연구원/SW 
Platform(연)AOT팀(seungho1.p...@lge.com)" wrote:
> Hi, Minchan.
> 
> I have a question.
> The problem mentioned can't be resolved with compaction?
> Is there any reason that zsmalloc pages can't be moved by compaction
> operation in direct reclaim?

Currently, zsmalloc doesn't request movable page to page allocator
since compaction is not aware of zram pages(ie, PageZram(page)).
IOW, compaction cannot migrate zram pages at the moment.
As I described, it's final destination we should go but I think
we need more thinking to generalize such special pages handling
(ex, balloon, zswap, zram and so on for future) in compaction logic.

Now, I want to merge basic primitive functions in zsmalloc to
support zspage migration, which will be used as basic utility functions
for supporting compaction-aware zspage migration.

In addition, even we need manual opeartion logic to trigger
compaction for zsmalloc like /proc/sys/vm/compact_memory.

> 
> 2014-12-02 오전 11:49에 Minchan Kim 이(가) 쓴 글:
> >Recently, there was issue about zsmalloc fragmentation and
> >I got a report from Juno that new fork failed although there
> >are plenty of free pages in the system.
> >His investigation revealed zram is one of the culprit to make
> >heavy fragmentation so there was no more contiguous 16K page
> >for pgd to fork in the ARM.
> >
> >This patchset implement *basic* zsmalloc compaction support
> >and zram utilizes it so admin can do
> > "echo 1 > /sys/block/zram0/compact"
> >
> >Actually, ideal is that mm migrate code is aware of zram pages and
> >migrate them out automatically without admin's manual opeartion
> >when system is out of contiguous page. Howver, we need more thinking
> >before adding more hooks to migrate.c. Even though we implement it,
> >we need manual trigger mode, too so I hope we could enhance
> >zram migration stuff based on this primitive functions in future.
> >
> >I just tested it on only x86 so need more testing on other arches.
> >Additionally, I should have a number for zsmalloc regression
> >caused by indirect layering. Unfortunately, I don't have any
> >ARM test machine on my desk. I will get it soon and test it.
> >Anyway, before further work, I'd like to hear opinion.
> >
> >Pathset is based on v3.18-rc6-mmotm-2014-11-26-15-45.
> >
> >Thanks.
> >
> >Minchan Kim (6):
> >   zsmalloc: expand size class to support sizeof(unsigned long)
> >   zsmalloc: add indrection layer to decouple handle from object
> >   zsmalloc: implement reverse mapping
> >   zsmalloc: encode alloced mark in handle object
> >   zsmalloc: support compaction
> >   zram: support compaction
> >
> >  drivers/block/zram/zram_drv.c |  24 ++
> >  drivers/block/zram/zram_drv.h |   1 +
> >  include/linux/zsmalloc.h  |   1 +
> >  mm/zsmalloc.c | 596 
> > +-
> >  4 files changed, 552 insertions(+), 70 deletions(-)
> >
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majord...@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: mailto:"d...@kvack.org;> em...@kvack.org 

-- 
Kind regards,
Minchan Kim
--
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/02] irqchip: renesas-intc-irqpin: r8a7779 IRLM setup support

2014-12-03 Thread Simon Horman
Hi Magnus,

I see you have been busy with the marzen board.

On Wed, Dec 03, 2014 at 09:18:03PM +0900, Magnus Damm wrote:
> From: Magnus Damm 
> 
> Add r8a7779 specific support for IRLM bit configuration
> in the INTC-IRQPIN driver. Without this code we need
> special workaround code in arch/arm/mach-shmobile.
> 
> The IRLM bit for the INTC hardware exists on various
> older SH-based SoCs and is used to select between two
> modes for the external interrupt pins IRQ0 to IRQ3:
> 
> IRLM = 0: (default from reset on r8a7779)
> In this mode the pins IRQ0 to IRQ3 are used together
> to give a value between 0 and 15 to the SoC. External
> logic is required for masking. This mode is not
> supported by the INTC-IRQPIN driver.
> 
> IRLM = 1: (needs this patch or configuration elsewhere)
> In this mode IRQ0 to IRQ3 operate as 4 individual
> external interrupt pins. In this mode the SMSC ethernet
> chip can be used via IRQ1 on r8a7779 Marzen. This mode
> is the only supported mode by the INTC-IRQPIN driver.
> 
> For this patch to work the r8a7779 DTS needs to pass
> the ICR0 register as the last register bank.
> 
> Signed-off-by: Magnus Damm 
> ---
> 
>  Written against renesas-devel-20141202-v3.18-rc7 which is
>  basically v3.18-rc7 plus latest arch/arm/mach-shmobile code.
>  
>  
> Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.txt
>  |5 +
>  drivers/irqchip/irq-renesas-intc-irqpin.c
>   |   50 --
>  2 files changed, 46 insertions(+), 9 deletions(-)
> 
> --- 
> 0001/Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.txt
> +++ 
> work/Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.txt
>2014-12-03 20:25:13.0 +0900
> @@ -9,6 +9,11 @@ Required properties:
>  - "renesas,intc-irqpin-r8a7778" (R-Car M1A)
>  - "renesas,intc-irqpin-r8a7779" (R-Car H1)
>  - "renesas,intc-irqpin-sh73a0" (SH-Mobile AG5)
> +
> +- reg: Base address and length of each register bank used by the external
> +  IRQ pins driven by the interrupt controller hardware module. The base
> +  addresses, length and number of required register banks varies with 
> soctype.
> +
>  - #interrupt-cells: has to be <2>: an interrupt index and flags, as defined 
> in
>interrupts.txt in this directory
>  
> --- 0001/drivers/irqchip/irq-renesas-intc-irqpin.c
> +++ work/drivers/irqchip/irq-renesas-intc-irqpin.c2014-12-03 
> 20:32:59.0 +0900
> @@ -30,6 +30,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> @@ -40,7 +41,9 @@
>  #define INTC_IRQPIN_REG_SOURCE 2 /* INTREQnn */
>  #define INTC_IRQPIN_REG_MASK 3 /* INTMSKnn */
>  #define INTC_IRQPIN_REG_CLEAR 4 /* INTMSKCLRnn */
> -#define INTC_IRQPIN_REG_NR 5
> +#define INTC_IRQPIN_REG_NR_MANDATORY 5
> +#define INTC_IRQPIN_REG_IRLM 5 /* ICR0 with IRLM bit (optional) */
> +#define INTC_IRQPIN_REG_NR 6
>  
>  /* INTC external IRQ PIN hardware register access:
>   *
> @@ -82,6 +85,10 @@ struct intc_irqpin_priv {
>   u8 shared_irq_mask;
>  };
>  
> +struct intc_irqpin_irlm_config {
> + unsigned int irlm_bit;
> +};
> +
>  static unsigned long intc_irqpin_read32(void __iomem *iomem)
>  {
>   return ioread32(iomem);
> @@ -345,10 +352,23 @@ static struct irq_domain_ops intc_irqpin
>   .xlate  = irq_domain_xlate_twocell,
>  };
>  
> +static const struct intc_irqpin_irlm_config intc_irqpin_irlm_r8a7779 = {
> + .irlm_bit = 23, /* ICR0.IRLM0 */
> +};
> +
> +static const struct of_device_id intc_irqpin_dt_ids[] = {
> + { .compatible = "renesas,intc-irqpin", },
> + { .compatible = "renesas,intc-irqpin-r8a7779",
> +   .data = _irqpin_irlm_r8a7779 },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, intc_irqpin_dt_ids);
> +
>  static int intc_irqpin_probe(struct platform_device *pdev)
>  {
>   struct device *dev = >dev;
>   struct renesas_intc_irqpin_config *pdata = dev->platform_data;
> + const struct of_device_id *of_id;
>   struct intc_irqpin_priv *p;
>   struct intc_irqpin_iomem *i;
>   struct resource *io[INTC_IRQPIN_REG_NR];
> @@ -391,10 +411,11 @@ static int intc_irqpin_probe(struct plat
>   pm_runtime_enable(dev);
>   pm_runtime_get_sync(dev);
>  
> - /* get hold of manadatory IOMEM */
> + /* get hold of register banks */
> + memset(io, 0, sizeof(io));
>   for (k = 0; k < INTC_IRQPIN_REG_NR; k++) {
>   io[k] = platform_get_resource(pdev, IORESOURCE_MEM, k);
> - if (!io[k]) {
> + if (!io[k] && k < INTC_IRQPIN_REG_NR_MANDATORY) {
>   dev_err(dev, "not enough IOMEM resources\n");
>   ret = -EINVAL;
>   goto err0;
> @@ -422,6 +443,10 @@ static int intc_irqpin_probe(struct plat
>   for (k = 0; k < INTC_IRQPIN_REG_NR; k++) {
>   i = >iomem[k];
>  
> + /* handle optional registers */
> + if (!io[k])
> + 

Re: [PATCH v2 0/4] clk: mediatek: Add common clock support for Mediatek MT8135.

2014-12-03 Thread James Liao
Hi,

On Thu, 2014-12-04 at 14:52 +0800, James Liao wrote:
> This patchset contains the initial common clock support for Mediatek SoCs.
> Mediatek SoC's clock architecture comprises of various PLLs, dividers,
> muxes and clock gates.
> 
> This patchset also contains a basic clock support for Mediatek MT8135.
> 
> This driver is based on 3.18-rc1 + MT8135 basic support.
> 

Changein v2:
- Re-ordered patchset. Fold include/dt-bindings and DT document in 1st
patch.



--
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: [RESEND PATCH v5 3/5] acerhdf: Use bang-bang thermal governor

2014-12-03 Thread Peter Feuerer

Hi Darren,

thank you very much for your reply.


Darren Hart writes:


On Fri, Nov 28, 2014 at 03:20:50PM +0100, Peter Feuerer wrote:

acerhdf has been doing an on-off fan control using hysteresis by
post-manipulating the outcome of thermal subsystem trip point handling.
This patch enables acerhdf to use the bang-bang governor, which is
intended for on-off controlled fans.

Cc: platform-driver-...@vger.kernel.org
Cc: Darren Hart 
Cc: Andrew Morton 
CC: Zhang Rui 
Cc: Andreas Mohr 
Cc: Javi Merino 
Acked-and-tested-by: Borislav Petkov 
Signed-off-by: Peter Feuerer 
---
 drivers/platform/x86/Kconfig   |  3 ++-
 drivers/platform/x86/acerhdf.c | 36 +++-
 2 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index a2eabe6..c173266 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -38,7 +38,8 @@ config ACER_WMI
 
 config ACERHDF

tristate "Acer Aspire One temperature and fan driver"
-   depends on THERMAL && ACPI
+   select THERMAL_GOV_BANG_BANG


So we use select sparingly as it does implicit things.

I checked the THERMAL_GOV_BANG_BANG Kconfig entry, and the help says acerhdf
already depends on it (which it doesn't appear to). Any particular reason to add
select here instead of adding it as a depends.

Why did you drop THERMAL?


I had it like this in my first version of patches:
+ depends on THERMAL && ACPI && THERMAL_GOV_BANG_BANG

But after some discussion with lkml community we ended up with the select line 
and dropped THERMAL dependency, as it is implied by THEMAL_GOV_BANG_BANG.  I'm 
not so experienced with Kconfig, so I must rely on the statements of the 
community in this case.



+   depends on ACPI
---help---
  This is a driver for Acer Aspire One netbooks. It allows to access
  the temperature sensor and to control the fan.
diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index f30767f..7fe7dbf 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -50,7 +50,7 @@
  */
 #undef START_IN_KERNEL_MODE
 
-#define DRV_VER "0.5.30"

+#define DRV_VER "0.7.0"
 
 /*

  * According to the Atom N270 datasheet,
@@ -258,6 +258,14 @@ static const struct bios_settings_t bios_tbl[] = {
 
 static const struct bios_settings_t *bios_cfg __read_mostly;
 
+/*

+ * this struct is used to instruct thermal layer to use bang_bang instead of
+ * default governor for acerhdf


Please use sentence punctuation, particularly for block comments.


ok.




/*
 * This struct...
 * default ... for acerhdf.
 */


+ */
+static struct thermal_zone_params acerhdf_zone_params = {
+   .governor_name = "bang_bang",
+};
+
 static int acerhdf_get_temp(int *temp)
 {
u8 read_temp;
@@ -439,6 +447,17 @@ static int acerhdf_get_trip_type(struct 
thermal_zone_device *thermal, int trip,
return 0;
 }
 
+static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int trip,

+unsigned long *temp)
+{
+   if (trip != 0)
+   return -EINVAL;
+
+   *temp = fanon - fanoff;
+
+   return 0;
+}
+
 static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
 unsigned long *temp)
 {
@@ -463,6 +482,7 @@ static struct thermal_zone_device_ops acerhdf_dev_ops = {
.get_mode = acerhdf_get_mode,
.set_mode = acerhdf_set_mode,
.get_trip_type = acerhdf_get_trip_type,
+   .get_trip_hyst = acerhdf_get_trip_hyst,
.get_trip_temp = acerhdf_get_trip_temp,
.get_crit_temp = acerhdf_get_crit_temp,
 };
@@ -515,9 +535,7 @@ static int acerhdf_set_cur_state(struct 
thermal_cooling_device *cdev,
}
 
 	if (state == 0) {

-   /* turn fan off only if below fanoff temperature */
-   if ((cur_state == ACERHDF_FAN_AUTO) &&
-   (cur_temp < fanoff))
+   if (cur_state == ACERHDF_FAN_AUTO)
acerhdf_change_fanstate(ACERHDF_FAN_OFF);
} else {
if (cur_state == ACERHDF_FAN_OFF)
@@ -696,11 +714,19 @@ static int acerhdf_register_thermal(void)
return -EINVAL;
 
 	thz_dev = thermal_zone_device_register("acerhdf", 1, 0, NULL,

- _dev_ops, NULL, 0,
+ _dev_ops,
+ _zone_params, 0,
  (kernelmode) ? interval*1000 : 0);
if (IS_ERR(thz_dev))
return -EINVAL;
 
+	if (strcmp(thz_dev->governor->name,

+   acerhdf_zone_params.governor_name)) {
+   pr_err("Didn't get thermal governor %s, perhaps not compiled into 
thermal subsystem.\n",
+   acerhdf_zone_params.governor_name);


We've ensured it has to be compiled in, so that 

Re: [PATCH 1/3] video: fbdev: vt8623fb: suppress build warning

2014-12-03 Thread Tomi Valkeinen
On 03/12/14 20:29, Prabhakar Lad wrote:
> On Wed, Dec 3, 2014 at 11:49 AM, Tomi Valkeinen  wrote:
>> On 27/11/14 00:07, Lad, Prabhakar wrote:
>>> this patch fixes following build warning:
>>> drivers/video/fbdev/vt8623fb.c: In function ‘vt8623_pci_probe’:
>>> drivers/video/fbdev/vt8623fb.c:734:23: warning: cast to pointer from 
>>> integer of different size [-Wint-to-pointer-cast]
>>>   par->state.vgabase = (void __iomem *) vga_res.start;
>>>^
>>> Signed-off-by: Lad, Prabhakar 
>>> ---
>>>  drivers/video/fbdev/vt8623fb.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/video/fbdev/vt8623fb.c b/drivers/video/fbdev/vt8623fb.c
>>> index 5c7cbc6..ea7f056 100644
>>> --- a/drivers/video/fbdev/vt8623fb.c
>>> +++ b/drivers/video/fbdev/vt8623fb.c
>>> @@ -731,7 +731,7 @@ static int vt8623_pci_probe(struct pci_dev *dev, const 
>>> struct pci_device_id *id)
>>>
>>>   pcibios_bus_to_resource(dev->bus, _res, _reg);
>>>
>>> - par->state.vgabase = (void __iomem *) vga_res.start;
>>> + par->state.vgabase = (void __iomem *) (unsigned long) vga_res.start;
>>
>> This does look quite ugly... Where does the warning come from in the
>> first place. Isn't vga_res.start (resource_size_t) the size of a pointer?
>>
> Yes looks ugly, I am not sure what you meant from 'where does this warning
> come from' its in the commit message.

I meant why is there a warning at all. With a quick glance,
vga_res.start is the size of a pointer. So the sizes of the integer and
the pointer should be the same. But the warning still says "of different
size".

 Tomi




signature.asc
Description: OpenPGP digital signature


Re: [PATCH 4/5] ASoC: dwc: Add devicetree support for Designware I2S

2014-12-03 Thread rajeev kumar
On Wed, Dec 3, 2014 at 10:09 PM, Andrew Jackson  wrote:
> Convert to driver to use either platform_data or device-tree for configuration
> of the device.  When using device-tree, the I2S block's configuration is read
> from the relevant registers: this reduces the amount of information required 
> in
> the device tree.
>
> Signed-off-by: Andrew Jackson 
> ---
>  .../devicetree/bindings/sound/designware-i2s.txt   |   32 +++
>  sound/soc/dwc/Kconfig  |1 +
>  sound/soc/dwc/designware_i2s.c |  238 
> 
>  3 files changed, 222 insertions(+), 49 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/sound/designware-i2s.txt
>
> diff --git a/Documentation/devicetree/bindings/sound/designware-i2s.txt 
> b/Documentation/devicetree/bindings/sound/designware-i2s.txt
> new file mode 100644
> index 000..cdee591
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/designware-i2s.txt
> @@ -0,0 +1,32 @@
> +DesignWare I2S controller
> +
> +Required properties:
> + - compatible : Must be "snps,designware-i2s"
> + - reg : Must contain I2S core's registers location and length
> + - clocks : Pairs of phandle and specifier referencing the controller's 
> clocks.
> +   The controller expects two clocks, the clock used for the APB interface 
> and
> +   the clock used as the sampling rate reference clock sample.
> + - clock-names : "apb_plck" for the clock to the APB interface, "i2sclk" for 
> the sample
> +   rate reference clock.
> + - dmas: Pairs of phandle and specifier for the DMA channels that are used by
> +   the core. The core expects one or two dma channels, one for transmit and 
> one for
> +   receive.
> + - dma-names : "tx" for the transmit channel, "rx" for the receive channel.
> +
> +For more details on the 'dma', 'dma-names', 'clock' and 'clock-names' 
> properties
> +please check:
> +   * resource-names.txt
> +   * clock/clock-bindings.txt
> +   * dma/dma.txt
> +
> +Example:
> +
> +   soc_i2s: i2s@7ff9 {
> +   compatible = "snps,designware-i2s";
> +   reg = <0x0 0x7ff9 0x0 0x1000>;
> +   clocks = <_i2sclk 0>, <_refclk100mhz>;
> +   clock-names = "i2sclk", "apb_pclk";
> +   #sound-dai-cells = <0>;
> +   dmas = < 5>;
> +   dma-names = "tx";
> +   };
> diff --git a/sound/soc/dwc/Kconfig b/sound/soc/dwc/Kconfig
> index e334900..d50e085 100644
> --- a/sound/soc/dwc/Kconfig
> +++ b/sound/soc/dwc/Kconfig
> @@ -1,6 +1,7 @@
>  config SND_DESIGNWARE_I2S
> tristate "Synopsys I2S Device Driver"
> depends on CLKDEV_LOOKUP
> +   select SND_SOC_GENERIC_DMAENGINE_PCM
> help
>  Say Y or M if you want to add support for I2S driver for
>  Synopsys desigwnware I2S device. The device supports upto
> diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c
> index c497ada..083779d 100644
> --- a/sound/soc/dwc/designware_i2s.c
> +++ b/sound/soc/dwc/designware_i2s.c
> @@ -22,6 +22,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  /* common register for all channel */
>  #define IER0x000
> @@ -54,19 +55,46 @@
>  #define I2S_COMP_VERSION   0x01F8
>  #define I2S_COMP_TYPE  0x01FC
>
> +/*
> + * Component parameter register fields - define the I2S block's
> + * configuration.
> + */
> +#defineCOMP1_TX_WORDSIZE_3(r)  (((r) & GENMASK(27, 25)) >> 25)
> +#defineCOMP1_TX_WORDSIZE_2(r)  (((r) & GENMASK(24, 22)) >> 22)
> +#defineCOMP1_TX_WORDSIZE_1(r)  (((r) & GENMASK(21, 19)) >> 19)
> +#defineCOMP1_TX_WORDSIZE_0(r)  (((r) & GENMASK(18, 16)) >> 16)
> +#defineCOMP1_TX_CHANNELS(r)(((r) & GENMASK(10, 9)) >> 9)
> +#defineCOMP1_RX_CHANNELS(r)(((r) & GENMASK(8, 7)) >> 7)
> +#defineCOMP1_RX_ENABLED(r) (((r) & BIT(6)) >> 6)
> +#defineCOMP1_TX_ENABLED(r) (((r) & BIT(5)) >> 5)
> +#defineCOMP1_MODE_EN(r)(((r) & BIT(4)) >> 4)
> +#defineCOMP1_FIFO_DEPTH_GLOBAL(r)  (((r) & GENMASK(3, 2)) >> 2)
> +#defineCOMP1_APB_DATA_WIDTH(r) (((r) & GENMASK(1, 0)) >> 0)
> +
> +#defineCOMP2_RX_WORDSIZE_3(r)  (((r) & GENMASK(12, 10)) >> 10)
> +#defineCOMP2_RX_WORDSIZE_2(r)  (((r) & GENMASK(9, 7)) >> 7)
> +#defineCOMP2_RX_WORDSIZE_1(r)  (((r) & GENMASK(5, 3)) >> 3)
> +#defineCOMP2_RX_WORDSIZE_0(r)  (((r) & GENMASK(2, 0)) >> 0)
> +
>  #define MAX_CHANNEL_NUM8
>  #define MIN_CHANNEL_NUM2
>
> +union snd_dma_data {
> +   struct i2s_dma_data pd;
> +   struct snd_dmaengine_dai_dma_data dt;
> +};
> +
>  struct dw_i2s_dev {
> void __iomem *i2s_base;
> struct clk *clk;
> int active;
> unsigned int capability;
> struct device *dev;
> +   bool using_pd;
>
> /* data related to DMA transfers b/w i2s and DMAC */
> -   struct i2s_dma_data 

Re: [PATCH RFC] locking: Add volatile to arch_spinlock_t structures

2014-12-03 Thread Paul E. McKenney
On Wed, Dec 03, 2014 at 10:40:45PM -0800, Linus Torvalds wrote:
> On Dec 3, 2014 10:31 PM, "Linus Torvalds" 
> wrote:
> >
> > So no, no, no. C got this wrong. Volatile data structures are a
> fundamental mistake and a bug.
> 
> BTW, I'm not at all interested in language lawyering and people who say
> "but but we can do x". A compiler that modifies adjacent fields because the
> standard leaves is open is a crap compiler, and we won't use it, or disable
> the broken optimization. It is wrong from a concurrency standpoint anyway,
> and adding broken volatiles is just making things worse.

Understood, for example, adjacent fields protected by different locks
as one example, where adjacent-field overwriting completely breaks even
very conservatively designed code.  Should be entertaining!  ;-)

Thanx, Paul

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


Re: [PATCH RFC] locking: Add volatile to arch_spinlock_t structures

2014-12-03 Thread Paul E. McKenney
One point of the patch is "one more thing to watch for" in generated code,
namely temporary clobbering of synchronization variables, locks included,
due to overzealous optimization.  If this happens to the kernel, I guess
that the other quick workaround is to add alignment directives or padding.
(And yes, I have seen reports of non-kernel examples where gcc actually
does this sort of thing.)

But I don't feel strongly about this patch, not yet anyway, so will set
it aside for the time being.

Thanx, Paul

On Wed, Dec 03, 2014 at 10:31:06PM -0800, Linus Torvalds wrote:
> NAK. Volatile on data structures (as opposed to in code) is a disease. This
> is wrong.
> 
> We very much pass spinlock values around. They aren't volatile. The only
> thing volatile is when you load the value from the lock itself. See for
> example the stuff we do when we load a reflock from memory. Once we've
> loaded the value into registers it's no longer volatile, and putting
> violators into the data structures is actively *wrong*.
> 
> So no, no, no. C got this wrong. Volatile data structures are a fundamental
> mistake and a bug. The only good volatile is in an access (ie like
> ACCESS_ONCE() and anything else is making things worse.
> 
> We're not catering to crazy compiler people that can't understand that
> fact. I'm not even seeing the point of your patch, since it seems to be
> entirely about "let's make excuses for crap compilers"
> 
>Linus
> On Dec 3, 2014 10:20 PM, "Paul E. McKenney" 
> wrote:
> 
> > More concern about compilers...
> >
> > Most architectures mark the fields in their arch_spinlock_t structures
> > as volatile, which forces the compiler to respect the integrity of
> > those fields.  Without volatile markings, the compiler is within its
> > rights to overwrite these fields, for example, by using a wide store
> > to update an adjacent field as long as it fixes them up later.  This
> > sort of thing could come as a rather nasty surprise to any task attempting
> > to concurrently acquire that lock.
> >
> > For example, on x86 for smallish NR_CPUS, arch_spinlock_t is 16 bits wide.
> > If there were three adjacent 16-bit fields in the structure containing
> > the arch_spinlock_t, a compiler might reasonably use 64-bit accesses
> > for those three fields.  After a 64-bit load, the arch_spinlock_t's
> > value would be available in a register, so that the compiler might use
> > a 64-bit store followed by a 16-bit fixup store to update the three
> > adjacent 16-bit fields.
> >
> > This commit therefore adds volatile to the arch_spinlock_t and
> > arch_rwlock_t fields that don't already have them.
> >
> > Signed-off-by: Paul E. McKenney 
> > Cc: linux-a...@vger.kernel.org
> > Cc: Dmitry Vyukov 
> > Cc: Davidlohr Bueso 
> > Cc: Ingo Molnar 
> > Cc: Peter Zijlstra 
> > Cc: Linus Torvalds 
> >
> > diff --git a/arch/arm/include/asm/spinlock_types.h
> > b/arch/arm/include/asm/spinlock_types.h
> > index 47663fcb10ad..7d3b6ecb5301 100644
> > --- a/arch/arm/include/asm/spinlock_types.h
> > +++ b/arch/arm/include/asm/spinlock_types.h
> > @@ -9,14 +9,14 @@
> >
> >  typedef struct {
> > union {
> > -   u32 slock;
> > +   volatile u32 slock;
> > struct __raw_tickets {
> >  #ifdef __ARMEB__
> > -   u16 next;
> > -   u16 owner;
> > +   volatile u16 next;
> > +   volatile u16 owner;
> >  #else
> > -   u16 owner;
> > -   u16 next;
> > +   volatile u16 owner;
> > +   volatile u16 next;
> >  #endif
> > } tickets;
> > };
> > @@ -25,7 +25,7 @@ typedef struct {
> >  #define __ARCH_SPIN_LOCK_UNLOCKED  { { 0 } }
> >
> >  typedef struct {
> > -   u32 lock;
> > +   volatile u32 lock;
> >  } arch_rwlock_t;
> >
> >  #define __ARCH_RW_LOCK_UNLOCKED{ 0 }
> > diff --git a/arch/arm64/include/asm/spinlock_types.h
> > b/arch/arm64/include/asm/spinlock_types.h
> > index b8d383665f56..0f841378f0f3 100644
> > --- a/arch/arm64/include/asm/spinlock_types.h
> > +++ b/arch/arm64/include/asm/spinlock_types.h
> > @@ -24,11 +24,11 @@
> >
> >  typedef struct {
> >  #ifdef __AARCH64EB__
> > -   u16 next;
> > -   u16 owner;
> > +   volatile u16 next;
> > +   volatile u16 owner;
> >  #else
> > -   u16 owner;
> > -   u16 next;
> > +   volatile u16 owner;
> > +   volatile u16 next;
> >  #endif
> >  } __aligned(4) arch_spinlock_t;
> >
> > diff --git a/arch/mips/include/asm/spinlock_types.h
> > b/arch/mips/include/asm/spinlock_types.h
> > index 9b2528e612c0..10f04a0482dd 100644
> > --- a/arch/mips/include/asm/spinlock_types.h
> > +++ b/arch/mips/include/asm/spinlock_types.h
> > @@ -14,14 +14,14 @@ typedef union {
> >  * bits  0..15 : serving_now
> >  * bits 16..31 : ticket
> >  */
> > -   u32 

RE: [RFC] fdt:free the fdt reserved memory

2014-12-03 Thread Wang, Yalin
> -Original Message-
> From: Grant Likely [mailto:glik...@secretlab.ca] On Behalf Of Grant Likely
> Sent: Wednesday, September 24, 2014 10:45 PM
> To: Wang, Yalin; 'robh...@kernel.org'; 'devicet...@vger.kernel.org';
> 'pawel.m...@arm.com'; 'mark.rutl...@arm.com';
> 'ijc+devicet...@hellion.org.uk'; 'linux-kernel@vger.kernel.org'
> Subject: Re: [RFC] fdt:free the fdt reserved memory
> 
> On Thu, 18 Sep 2014 17:25:12 +0800, "Wang, Yalin"
>  wrote:
> > This patch make some change to unflatten_dt_node(), make sure the
> > device_node don't reference to fdt raw blob memory, so that we can
> > free the raw blob reserved memory after initcalls.
> >
> > Signed-off-by: Yalin Wang 
> 
> Do you have any measurements showing a change in available memory before
> and after the patch?
> 
Does anyone have a look at this patch?
It can save 12K on my platform,
My dtb is 164K

Thanks

> 
> > ---
> >  drivers/of/fdt.c   | 27 +++
> >  include/linux/of_fdt.h |  2 ++
> >  2 files changed, 25 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index
> > 79cb831..e891ef6 100644
> > --- a/drivers/of/fdt.c
> > +++ b/drivers/of/fdt.c
> > @@ -240,6 +240,7 @@ static void * unflatten_dt_node(void *blob,
> >  (offset = fdt_next_property_offset(blob, offset))) {
> > const char *pname;
> > u32 sz;
> > +   int name_len;
> >
> > if (!(p = fdt_getprop_by_offset(blob, offset, , ))) {
> > offset = -FDT_ERR_INTERNAL;
> > @@ -250,10 +251,12 @@ static void * unflatten_dt_node(void *blob,
> > pr_info("Can't find property name in list !\n");
> > break;
> > }
> > +   name_len = strlen(pname);
> > if (strcmp(pname, "name") == 0)
> > has_name = 1;
> > -   pp = unflatten_dt_alloc(, sizeof(struct property),
> > -   __alignof__(struct property));
> > +   pp = unflatten_dt_alloc(,
> > +   ALIGN(sizeof(struct property) + name_len + 1, 4)
> > +   + sz, __alignof__(struct property));
> > if (allnextpp) {
> > /* We accept flattened tree phandles either in
> >  * ePAPR-style "phandle" properties, or the @@ -270,9
> +273,11 @@
> > static void * unflatten_dt_node(void *blob,
> >  * stuff */
> > if (strcmp(pname, "ibm,phandle") == 0)
> > np->phandle = be32_to_cpup(p);
> > -   pp->name = (char *)pname;
> > +   pp->name = (char *)memcpy(pp + 1, pname, name_len + 1);
> > pp->length = sz;
> > -   pp->value = (__be32 *)p;
> > +   pp->value = (__be32 *)memcpy((void *)pp +
> > +   ALIGN(sizeof(struct property) +
> > +   name_len + 1, 4), p, sz);
> > *prev_pp = pp;
> > prev_pp = >next;
> > }
> > @@ -564,6 +569,20 @@ void __init early_init_fdt_scan_reserved_mem(void)
> > fdt_init_reserved_mem();
> >  }
> >
> > +void __init free_early_init_fdt_scan_reserved_mem(void)
> > +{
> > +   unsigned long start, end, size;
> > +   if (!initial_boot_params)
> > +   return;
> > +
> > +   size = fdt_totalsize(initial_boot_params);
> > +   memblock_free(__pa(initial_boot_params), size);
> > +   start = round_down((unsigned long)initial_boot_params, PAGE_SIZE);
> > +   end = round_up((unsigned long)initial_boot_params + size, PAGE_SIZE);
> > +   free_reserved_area((void *)start, (void *)end, 0, "fdt");
> > +   initial_boot_params = 0;
> > +}
> > +
> >  /**
> >   * of_scan_flat_dt - scan flattened tree blob and call callback on each.
> >   * @it: callback function
> > diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index
> > 0ff360d..21d51ce 100644
> > --- a/include/linux/of_fdt.h
> > +++ b/include/linux/of_fdt.h
> > @@ -62,6 +62,7 @@ extern int early_init_dt_scan_chosen(unsigned long
> > node, const char *uname,  extern int early_init_dt_scan_memory(unsigned
> long node, const char *uname,
> >  int depth, void *data);
> >  extern void early_init_fdt_scan_reserved_mem(void);
> > +extern void free_early_init_fdt_scan_reserved_mem(void);
> >  extern void early_init_dt_add_memory_arch(u64 base, u64 size);
> > extern int early_init_dt_reserve_memory_arch(phys_addr_t base,
> phys_addr_t size,
> >  bool no_map);
> > @@ -89,6 +90,7 @@ extern u64 fdt_translate_address(const void *blob,
> > int node_offset);  extern void of_fdt_limit_memory(int limit);  #else
> > /* CONFIG_OF_FLATTREE */  static inline void
> > early_init_fdt_scan_reserved_mem(void) {}
> > +static inline void free_early_init_fdt_scan_reserved_mem(void) {}
> >  static inline const char 

Re: [PATCH 3/5] ASoC: dwc: Iterate over all channels

2014-12-03 Thread rajeev kumar
On Wed, Dec 3, 2014 at 10:59 PM, Mark Brown  wrote:
> On Wed, Dec 03, 2014 at 04:39:01PM +, Andrew Jackson wrote:
>
>> + /* Iterate over set of channels - independently controlled.
>> +  */
>> + do {
>> + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
>> + i2s_write_reg(dev->i2s_base, TCR(ch_reg),
>> +   xfer_resolution);
>> + i2s_write_reg(dev->i2s_base, TFCR(ch_reg), 0x02);
>> + irq = i2s_read_reg(dev->i2s_base, IMR(ch_reg));
>> + i2s_write_reg(dev->i2s_base, IMR(ch_reg), irq & ~0x30);
>> + i2s_write_reg(dev->i2s_base, TER(ch_reg), 1);
>> + } else {
>> + i2s_write_reg(dev->i2s_base, RCR(ch_reg),
>> +   xfer_resolution);
>> + i2s_write_reg(dev->i2s_base, RFCR(ch_reg), 0x07);
>> + irq = i2s_read_reg(dev->i2s_base, IMR(ch_reg));
>> + i2s_write_reg(dev->i2s_base, IMR(ch_reg), irq & ~0x03);
>> + i2s_write_reg(dev->i2s_base, RER(ch_reg), 1);
>> + }
>> + } while (ch_reg-- > 0);
>
> The normal way to write an iteration would be with a for loop - why are
> we not doing that?
>
> Also I see that you've not sent these as a single thread - please use
> --thread.

designware i2s has individual register for channel support. It is like
TCR(0), TCR(1) and so on.. So a macro is defined to capture these
please check below #define

#define TCR(x)  (0x40 * x + 0x034)

and the same is true for capture also. So there is no need for
iteration. Only writing to the particular register will do the work.

~Rajeev
--
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 6/8] mm/page_owner: keep track of page owners

2014-12-03 Thread Joonsoo Kim
On Wed, Dec 03, 2014 at 06:54:08PM +0530, Chintan Pandya wrote:
> Hi Kim,

Hello, Chintan.

> 
> This is really useful stuff that you are doing. And the runtime
> allocation for storing page owner stack is a good call.
> 
> Along with that, we also use extended version of the original
> page_owner patch. The extension is, to store stack trace at the time
> of freeing the page. That will indeed eat up space like anything
> (just double of original page_owner) but it helps in debugging some
> crucial issues. Like, illegitimate free, finding leaked pages (if we

Sound really interesting. I hope to see it.

> store their time stamps) etc. The same has been useful in finding
> double-free cases in drivers. But we have never got a chance to
> upstream that. Now that these patches are being discussed again, do
> you think it would be good idea to integrate in the same league of
> patches ?

Good to hear. I think that you can upstream it separately. If you send
the patch, I will review it and help to merge it.

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


[PATCH] sound/soc/adi/axi-spdif.c: Support programmable master clock

2014-12-03 Thread Mike Looijmans
If the master clock supports programmable rates, program it to generate
the desired frequency. Only apply constraints when the clock is fixed.
This allows proper clock generation for both 44100 and 48000 Hz based
sampling rates if the platform supports it.

The clock frequency must be set before enabling it. Enabling the clock
was done in "startup", but that occurs before "hw_params" where the rate
is known. Move the clock start to the hw_params routine, and keep track
of whether the clock has been started, because shutdown may be called
without having called hw_params first.

Starting the clock and enabling the SPDIF output AFTER programming the
dividers is a more logical order anyway.

Signed-off-by: Mike Looijmans 
---
 sound/soc/adi/axi-spdif.c |   56 -
 1 file changed, 35 insertions(+), 21 deletions(-)

diff --git a/sound/soc/adi/axi-spdif.c b/sound/soc/adi/axi-spdif.c
index 198e3a4..d67e010 100644
--- a/sound/soc/adi/axi-spdif.c
+++ b/sound/soc/adi/axi-spdif.c
@@ -4,7 +4,6 @@
  *
  * Licensed under the GPL-2.
  */
-
 #include 
 #include 
 #include 
@@ -44,6 +43,8 @@ struct axi_spdif {
 
struct snd_ratnum ratnum;
struct snd_pcm_hw_constraint_ratnums rate_constraints;
+
+   bool clk_ref_running;
 };
 
 static int axi_spdif_trigger(struct snd_pcm_substream *substream, int cmd,
@@ -79,6 +80,7 @@ static int axi_spdif_hw_params(struct snd_pcm_substream 
*substream,
struct axi_spdif *spdif = snd_soc_dai_get_drvdata(dai);
unsigned int rate = params_rate(params);
unsigned int clkdiv, stat;
+   int ret;
 
switch (params_rate(params)) {
case 32000:
@@ -95,6 +97,9 @@ static int axi_spdif_hw_params(struct snd_pcm_substream 
*substream,
break;
}
 
+   /* Try to set the master clock */
+   clk_set_rate(spdif->clk_ref, rate * 128);
+
clkdiv = DIV_ROUND_CLOSEST(clk_get_rate(spdif->clk_ref),
rate * 64 * 2) - 1;
clkdiv <<= AXI_SPDIF_CTRL_CLKDIV_OFFSET;
@@ -103,6 +108,14 @@ static int axi_spdif_hw_params(struct snd_pcm_substream 
*substream,
regmap_update_bits(spdif->regmap, AXI_SPDIF_REG_CTRL,
AXI_SPDIF_CTRL_CLKDIV_MASK, clkdiv);
 
+   ret = clk_prepare_enable(spdif->clk_ref);
+   if (ret)
+   return ret;
+   spdif->clk_ref_running = true;
+
+   regmap_update_bits(spdif->regmap, AXI_SPDIF_REG_CTRL,
+   AXI_SPDIF_CTRL_TXEN, AXI_SPDIF_CTRL_TXEN);
+
return 0;
 }
 
@@ -121,18 +134,13 @@ static int axi_spdif_startup(struct snd_pcm_substream 
*substream,
struct axi_spdif *spdif = snd_soc_dai_get_drvdata(dai);
int ret;
 
-   ret = snd_pcm_hw_constraint_ratnums(substream->runtime, 0,
-  SNDRV_PCM_HW_PARAM_RATE,
-  >rate_constraints);
-   if (ret)
-   return ret;
-
-   ret = clk_prepare_enable(spdif->clk_ref);
-   if (ret)
-   return ret;
-
-   regmap_update_bits(spdif->regmap, AXI_SPDIF_REG_CTRL,
-   AXI_SPDIF_CTRL_TXEN, AXI_SPDIF_CTRL_TXEN);
+   if (spdif->rate_constraints.nrats) {
+   ret = snd_pcm_hw_constraint_ratnums(substream->runtime, 0,
+   SNDRV_PCM_HW_PARAM_RATE,
+   >rate_constraints);
+   if (ret)
+   return ret;
+   }
 
return 0;
 }
@@ -145,7 +153,10 @@ static void axi_spdif_shutdown(struct snd_pcm_substream 
*substream,
regmap_update_bits(spdif->regmap, AXI_SPDIF_REG_CTRL,
AXI_SPDIF_CTRL_TXEN, 0);
 
-   clk_disable_unprepare(spdif->clk_ref);
+   if (spdif->clk_ref_running) {
+   clk_disable_unprepare(spdif->clk_ref);
+   spdif->clk_ref_running = false;
+   }
 }
 
 static const struct snd_soc_dai_ops axi_spdif_dai_ops = {
@@ -216,14 +227,17 @@ static int axi_spdif_probe(struct platform_device *pdev)
spdif->dma_data.addr_width = 4;
spdif->dma_data.maxburst = 1;
 
-   spdif->ratnum.num = clk_get_rate(spdif->clk_ref) / 128;
-   spdif->ratnum.den_step = 1;
-   spdif->ratnum.den_min = 1;
-   spdif->ratnum.den_max = 64;
-
-   spdif->rate_constraints.rats = >ratnum;
-   spdif->rate_constraints.nrats = 1;
+   /* Determine if the clock rate is fixed. If it cannot change frequency,
+* it returns an error here. */
+   if (clk_round_rate(spdif->clk_ref, 128 * 44100) < 0) {
+   spdif->ratnum.num = clk_get_rate(spdif->clk_ref) / 128;
+   spdif->ratnum.den_step = 1;
+   spdif->ratnum.den_min = 1;
+   spdif->ratnum.den_max = 64;
 
+   spdif->rate_constraints.rats = >ratnum;
+   spdif->rate_constraints.nrats = 1;
+   }
ret = devm_snd_soc_register_component(>dev, _spdif_component,
 _spdif_dai, 1);
if (ret)
-- 

Re: [RFC 0/6] zsmalloc support compaction

2014-12-03 Thread 박승호/책임연구원/SW Platform(연)AOT팀(seungho1.p...@lge.com)

Hi, Minchan.

I have a question.
The problem mentioned can't be resolved with compaction?
Is there any reason that zsmalloc pages can't be moved by compaction
operation in direct reclaim?

2014-12-02 오전 11:49에 Minchan Kim 이(가) 쓴 글:

Recently, there was issue about zsmalloc fragmentation and
I got a report from Juno that new fork failed although there
are plenty of free pages in the system.
His investigation revealed zram is one of the culprit to make
heavy fragmentation so there was no more contiguous 16K page
for pgd to fork in the ARM.

This patchset implement *basic* zsmalloc compaction support
and zram utilizes it so admin can do
"echo 1 > /sys/block/zram0/compact"

Actually, ideal is that mm migrate code is aware of zram pages and
migrate them out automatically without admin's manual opeartion
when system is out of contiguous page. Howver, we need more thinking
before adding more hooks to migrate.c. Even though we implement it,
we need manual trigger mode, too so I hope we could enhance
zram migration stuff based on this primitive functions in future.

I just tested it on only x86 so need more testing on other arches.
Additionally, I should have a number for zsmalloc regression
caused by indirect layering. Unfortunately, I don't have any
ARM test machine on my desk. I will get it soon and test it.
Anyway, before further work, I'd like to hear opinion.

Pathset is based on v3.18-rc6-mmotm-2014-11-26-15-45.

Thanks.

Minchan Kim (6):
   zsmalloc: expand size class to support sizeof(unsigned long)
   zsmalloc: add indrection layer to decouple handle from object
   zsmalloc: implement reverse mapping
   zsmalloc: encode alloced mark in handle object
   zsmalloc: support compaction
   zram: support compaction

  drivers/block/zram/zram_drv.c |  24 ++
  drivers/block/zram/zram_drv.h |   1 +
  include/linux/zsmalloc.h  |   1 +
  mm/zsmalloc.c | 596 +-
  4 files changed, 552 insertions(+), 70 deletions(-)



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


Re: [PATCH 2/5] ASoC: dwc: Don't allow negative use counts

2014-12-03 Thread rajeev kumar
On Thu, Dec 4, 2014 at 12:10 PM, rajeev kumar
 wrote:
> On Wed, Dec 3, 2014 at 10:55 PM, Mark Brown  wrote:
>> On Wed, Dec 03, 2014 at 04:38:55PM +, Andrew Jackson wrote:
>>
>>>   case SNDRV_PCM_TRIGGER_STOP:
>>>   case SNDRV_PCM_TRIGGER_SUSPEND:
>>>   case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
>>> - dev->active--;
>>> + if (dev->active > 0)
>>> + dev->active--;
>>
>> How is this triggering - this sounds like you're papering over some
>> other bug somewhere?

This check can be removed as it is not going to triggered.

B'rgds
~Rajeev
--
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 2/3] toshiba_acpi: Change notify funtion to handle more events

2014-12-03 Thread Azael Avalos
Currently the function toshiba_acpi_notify only takes care of hotkeys,
however, the TOS devices receive more events that can be useful.

This patch changes the function to be able to handle more events,
and in the process, move all hotkey related code residing in it to
a new function called toshiba_acpi_process_hotkeys.

Signed-off-by: Azael Avalos 
---
 drivers/platform/x86/toshiba_acpi.c | 86 ++---
 1 file changed, 52 insertions(+), 34 deletions(-)

diff --git a/drivers/platform/x86/toshiba_acpi.c 
b/drivers/platform/x86/toshiba_acpi.c
index 8bb07c7..21ac11f 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -1657,6 +1657,43 @@ static void toshiba_acpi_report_hotkey(struct 
toshiba_acpi_dev *dev,
pr_info("Unknown key %x\n", scancode);
 }
 
+static void toshiba_acpi_process_hotkeys(struct toshiba_acpi_dev *dev)
+{
+   u32 hci_result, value;
+   int retries = 3;
+   int scancode;
+
+   if (dev->info_supported) {
+   scancode = toshiba_acpi_query_hotkey(dev);
+   if (scancode < 0)
+   pr_err("Failed to query hotkey event\n");
+   else if (scancode != 0)
+   toshiba_acpi_report_hotkey(dev, scancode);
+   } else if (dev->system_event_supported) {
+   do {
+   hci_result = hci_read1(dev, HCI_SYSTEM_EVENT, );
+   switch (hci_result) {
+   case TOS_SUCCESS:
+   toshiba_acpi_report_hotkey(dev, (int)value);
+   break;
+   case TOS_NOT_SUPPORTED:
+   /*
+* This is a workaround for an unresolved
+* issue on some machines where system events
+* sporadically become disabled.
+*/
+   hci_result =
+   hci_write1(dev, HCI_SYSTEM_EVENT, 1);
+   pr_notice("Re-enabled hotkeys\n");
+   /* fall through */
+   default:
+   retries--;
+   break;
+   }
+   } while (retries && hci_result != TOS_FIFO_EMPTY);
+   }
+}
+
 static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
 {
acpi_handle ec_handle;
@@ -1971,41 +2008,22 @@ error:
 static void toshiba_acpi_notify(struct acpi_device *acpi_dev, u32 event)
 {
struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev);
-   u32 hci_result, value;
-   int retries = 3;
-   int scancode;
-
-   if (event != 0x80)
-   return;
+   int ret;
 
-   if (dev->info_supported) {
-   scancode = toshiba_acpi_query_hotkey(dev);
-   if (scancode < 0)
-   pr_err("Failed to query hotkey event\n");
-   else if (scancode != 0)
-   toshiba_acpi_report_hotkey(dev, scancode);
-   } else if (dev->system_event_supported) {
-   do {
-   hci_result = hci_read1(dev, HCI_SYSTEM_EVENT, );
-   switch (hci_result) {
-   case TOS_SUCCESS:
-   toshiba_acpi_report_hotkey(dev, (int)value);
-   break;
-   case TOS_NOT_SUPPORTED:
-   /*
-* This is a workaround for an unresolved
-* issue on some machines where system events
-* sporadically become disabled.
-*/
-   hci_result =
-   hci_write1(dev, HCI_SYSTEM_EVENT, 1);
-   pr_notice("Re-enabled hotkeys\n");
-   /* fall through */
-   default:
-   retries--;
-   break;
-   }
-   } while (retries && hci_result != TOS_FIFO_EMPTY);
+   switch (event) {
+   case 0x80: /* Hotkeys and some system events */
+   toshiba_acpi_process_hotkeys(dev);
+   break;
+   case 0x81: /* Unknown */
+   case 0x82: /* Unknown */
+   case 0x83: /* Unknown */
+   case 0x8c: /* Unknown */
+   case 0x8e: /* Unknown */
+   case 0x8f: /* Unknown */
+   case 0x90: /* Unknown */
+   default:
+   pr_info("Unknown event received %x\n", event);
+   break;
}
 }
 
-- 
2.1.2

--
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 V3] MIPS: BCM47XX: Move NVRAM driver to the drivers/soc/

2014-12-03 Thread Paul Walmsley
Hello Rafał,

On Fri, 28 Nov 2014, Paul Walmsley wrote:

> On Thu, 27 Nov 2014, Rafał Miłecki wrote:
> 
> > I'm pretty sure you look at some old version of arch/bcm47xx/nvram.c.
> > I wouldn't dare to move such a MIPS-focused driver to some common
> > place ;)
> > 
> > Please check for the version of nvram.c in Ralf's upstream-sfr tree. I
> > think you'll like it much more. Hopefully you will even consider it
> > ready for moving to the drivers/firmware/ or whatever :)
> 
> OK I will take a look at this, and will either send comments, or will 
> send a Reviewed-By:.

I had the chance to take a brief look at this file, and you are right: I
like your newer version better than the older one :-)

It is too bad that it seems this flash area has to be accessed very early 
in boot.  That certainly makes it more difficult to write something 
particularly elegant.  It is also a pity that it is unknown how to verify 
that the flash MMIO window has been configured before reading from these 
areas of the address space.  But under the circumstances, calling 
bcm47xx_nvram_init_from_mem() with the appropriate addresses from the bus 
code during early init, as you did, seems rather reasonable.  I also like 
the code that you added to read the flash data from MTD later in boot.

Here are a few very minor comments that you are welcome to take or leave 
as you wish.

1. In nvram_find_and_copy(), the flash header copy loop uses:

for (i = 0; i < sizeof(struct nvram_header); i += 4)
*dst++ = *src++;

Consider using either __raw_readl() to read from the MMIO window, or 
possibly memcpy_fromio().  In theory, all MMIO accesses should use 
functions like these.


2. In nvram_find_and_copy(), the flash payload copy loop uses:

for (; i < header->len && i < NVRAM_SPACE && i < size; i += 4)
*dst++ = le32_to_cpu(*src++);

Consider using readl() instead of the direct MMIO read & endianness 
conversion.  


3. In nvram_find_and_copy(), I don't believe that this is necessary:

memset(dst, 0x0, NVRAM_SPACE - i);

since nvram_buf[] is a file-static variable, and thus should have been
initialized to all zeroes.


4. As with #3 above, in nvram_init(), I don't believe that this is 
necessary:

memset(dst + bytes_read, 0x0, NVRAM_SPACE - bytes_read);


5. In bcm47xx_nvram_getenv(), this multiple assignment exists:

end[0] = end[1] = '\0';

Best to avoid multiple assignments, per Chapter 1 of 
Documentation/CodingStyle.  You might consider running checkpatch.pl on 
the file:

$ scripts/checkpatch.pl -f --strict arch/mips/bcm47xx/nvram.c
CHECK: No space is necessary after a cast
#101: FILE: arch/mips/bcm47xx/nvram.c:101:
+   src = (u32 *) header;

CHECK: No space is necessary after a cast
#102: FILE: arch/mips/bcm47xx/nvram.c:102:
+   dst = (u32 *) nvram_buf;

CHECK: multiple assignments should be avoided
#195: FILE: arch/mips/bcm47xx/nvram.c:195:
+   end[0] = end[1] = '\0';

CHECK: Alignment should match open parenthesis
#202: FILE: arch/mips/bcm47xx/nvram.c:202:
+   if ((eq - var) == strlen(name) &&
+   strncmp(var, name, (eq - var)) == 0) {


6. bcm47xx_nvram_getenv() calls strchr().  Perhaps it would be better to 
use strnchr(), in case the flash data is corrupted or in an invalid 
format?


7. There are a few magic numbers in this code, mostly in 
bcm47xx_nvram_gpio_pin().  It might be worth converting those to macros 
and documenting the expectations there in a comment above the macro.


8.  The way that bcm47xx_nvram_gpio_pin() calls bcm47xx_nvram_getenv() 
seems a bit inefficient.  It might be better to loop over all of the keys 
in the shadowed flash, looking for values that match "name".  Then if the 
key name matches "gpio" plus one or two digits, the code could just return 
the digits.  That way, only one pass is needed, rather than 32 (in the 
worst case).  Well, at least the reads should be coming from cached DRAM, 
rather than flash...

If you fix/address those (or correct my review ;-) ), then you're 
welcome to add my Reviewed-by: to a patch that moves this file out to 
drivers/firmware.


regards, 

- Paul

[PATCH v2 0/3] toshiba_acpi: Hotkeys and event handling changes

2014-12-03 Thread Azael Avalos
These patches change the current code to accomodate the handling
of more events, since so far, it only handles hotkey events (0x80),
move the hotkey enabling code to a sub function to avoid duplication,
and add event 0x92 which indicates a change in the keyboard backlight
mode.

Changes since V1:
- Split patch 02 in two patches
- Some misc changes in the description of the patches (a bit wider now)

Azael Avalos (3):
  toshiba_acpi: Move hotkey enabling code to own function
  toshiba_acpi: Change notify funtion to handle more events
  toshiba_acpi: Add keyboard backlight mode change event

 drivers/platform/x86/toshiba_acpi.c | 139 ++--
 1 file changed, 86 insertions(+), 53 deletions(-)

-- 
2.1.2

--
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 1/3] toshiba_acpi: Move hotkey enabling code to own function

2014-12-03 Thread Azael Avalos
The hotkey enabling code is being used by toshiba_acpi_setup_keyboard
and also by toshiba_acpi_resume.

This patch creates a new function called toshiba_acpi_enable_hotkeys
to be used by these two functions to avoid duplicating code.

Signed-off-by: Azael Avalos 
---
 drivers/platform/x86/toshiba_acpi.c | 40 +
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/drivers/platform/x86/toshiba_acpi.c 
b/drivers/platform/x86/toshiba_acpi.c
index a329469..8bb07c7 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -1573,6 +1573,28 @@ static umode_t toshiba_sysfs_is_visible(struct kobject 
*kobj,
return exists ? attr->mode : 0;
 }
 
+/*
+ * Hotkeys
+ */
+static int toshiba_acpi_enable_hotkeys(struct toshiba_acpi_dev *dev)
+{
+   acpi_status status;
+   u32 result;
+
+   status = acpi_evaluate_object(dev->acpi_dev->handle,
+ "ENAB", NULL, NULL);
+   if (ACPI_FAILURE(status))
+   return -ENODEV;
+
+   result = hci_write1(dev, HCI_HOTKEY_EVENT, HCI_HOTKEY_ENABLE);
+   if (result == TOS_FAILURE)
+   return -EIO;
+   else if (result == TOS_NOT_SUPPORTED)
+   return -ENODEV;
+
+   return 0;
+}
+
 static bool toshiba_acpi_i8042_filter(unsigned char data, unsigned char str,
  struct serio *port)
 {
@@ -1637,7 +1659,6 @@ static void toshiba_acpi_report_hotkey(struct 
toshiba_acpi_dev *dev,
 
 static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
 {
-   acpi_status status;
acpi_handle ec_handle;
int error;
u32 hci_result;
@@ -1664,7 +1685,6 @@ static int toshiba_acpi_setup_keyboard(struct 
toshiba_acpi_dev *dev)
 * supported, so if it's present set up an i8042 key filter
 * for this purpose.
 */
-   status = AE_ERROR;
ec_handle = ec_get_handle();
if (ec_handle && acpi_has_method(ec_handle, "NTFY")) {
INIT_WORK(>hotkey_work, toshiba_acpi_hotkey_work);
@@ -1695,10 +1715,9 @@ static int toshiba_acpi_setup_keyboard(struct 
toshiba_acpi_dev *dev)
goto err_remove_filter;
}
 
-   status = acpi_evaluate_object(dev->acpi_dev->handle, "ENAB", NULL, 
NULL);
-   if (ACPI_FAILURE(status)) {
+   error = toshiba_acpi_enable_hotkeys(dev);
+   if (error) {
pr_info("Unable to enable hotkeys\n");
-   error = -ENODEV;
goto err_remove_filter;
}
 
@@ -1708,7 +1727,6 @@ static int toshiba_acpi_setup_keyboard(struct 
toshiba_acpi_dev *dev)
goto err_remove_filter;
}
 
-   hci_result = hci_write1(dev, HCI_HOTKEY_EVENT, HCI_HOTKEY_ENABLE);
return 0;
 
  err_remove_filter:
@@ -2006,16 +2024,12 @@ static int toshiba_acpi_suspend(struct device *device)
 static int toshiba_acpi_resume(struct device *device)
 {
struct toshiba_acpi_dev *dev = acpi_driver_data(to_acpi_device(device));
-   u32 result;
-   acpi_status status;
+   int error;
 
if (dev->hotkey_dev) {
-   status = acpi_evaluate_object(dev->acpi_dev->handle, "ENAB",
-   NULL, NULL);
-   if (ACPI_FAILURE(status))
+   error = toshiba_acpi_enable_hotkeys(dev);
+   if (error)
pr_info("Unable to re-enable hotkeys\n");
-
-   result = hci_write1(dev, HCI_HOTKEY_EVENT, HCI_HOTKEY_ENABLE);
}
 
return 0;
-- 
2.1.2

--
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 3/3] toshiba_acpi: Add keyboard backlight mode change event

2014-12-03 Thread Azael Avalos
A previous patch added support to handle more events.

This patch adds support to update the sysfs group whenever we receive
a 0x92 event, which indicates a change in the keyboard backlight mode.

Signed-off-by: Azael Avalos 
---
 drivers/platform/x86/toshiba_acpi.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/platform/x86/toshiba_acpi.c 
b/drivers/platform/x86/toshiba_acpi.c
index 21ac11f..5e9b298 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -1393,12 +1393,6 @@ static ssize_t toshiba_kbd_bl_mode_store(struct device 
*dev,
if (ret)
return ret;
 
-   /* Update sysfs entries on successful mode change*/
-   ret = sysfs_update_group(>acpi_dev->dev.kobj,
-_attr_group);
-   if (ret)
-   return ret;
-
toshiba->kbd_mode = mode;
}
 
@@ -2014,6 +2008,13 @@ static void toshiba_acpi_notify(struct acpi_device 
*acpi_dev, u32 event)
case 0x80: /* Hotkeys and some system events */
toshiba_acpi_process_hotkeys(dev);
break;
+   case 0x92: /* Keyboard backlight mode changed */
+   /* Update sysfs entries */
+   ret = sysfs_update_group(_dev->dev.kobj,
+_attr_group);
+   if (ret)
+   pr_err("Unable to update sysfs entries\n");
+   break;
case 0x81: /* Unknown */
case 0x82: /* Unknown */
case 0x83: /* Unknown */
-- 
2.1.2

--
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 2/5] ASoC: dwc: Don't allow negative use counts

2014-12-03 Thread rajeev kumar
On Wed, Dec 3, 2014 at 10:55 PM, Mark Brown  wrote:
> On Wed, Dec 03, 2014 at 04:38:55PM +, Andrew Jackson wrote:
>
>>   case SNDRV_PCM_TRIGGER_STOP:
>>   case SNDRV_PCM_TRIGGER_SUSPEND:
>>   case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
>> - dev->active--;
>> + if (dev->active > 0)
>> + dev->active--;
>
> How is this triggering - this sounds like you're papering over some
> other bug somewhere?
--
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] arm64/include/asm: Fixed a warning about 'struct pt_regs'

2014-12-03 Thread Chunyan Zhang
If I include asm/irq.h on the top of my code, and set ARCH=arm64,
I'll get a compile warning, details are below:
warning: ‘struct pt_regs’
declared inside parameter list [enabled by default]

This patch is suggested by Arnd, see:
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-December/308270.html

Signed-off-by: Chunyan Zhang 
---
 arch/arm64/include/asm/irq.h |2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/include/asm/irq.h b/arch/arm64/include/asm/irq.h
index e1f7ecd..acedc7e 100644
--- a/arch/arm64/include/asm/irq.h
+++ b/arch/arm64/include/asm/irq.h
@@ -3,6 +3,8 @@
 
 #include 
 
+struct pt_regs;
+
 extern void (*handle_arch_irq)(struct pt_regs *);
 extern void migrate_irqs(void);
 extern void set_handle_irq(void (*handle_irq)(struct pt_regs *));
-- 
1.7.9.5

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


Re: [RFC PATCH v2] tinification: Introduce CONFIG_SRCU to make SRCU optional

2014-12-03 Thread Paul E. McKenney
On Wed, Dec 03, 2014 at 11:03:52PM -0500, Pranith Kumar wrote:
> (CC list trimmed since this is just for initial feedback)
> 
> SRCU is not necessary to be compiled by default in all cases. For tinification
> efforts not compiling SRCU unless necessary is desirable.
> 
> The current patch tries to make compiling SRCU optional by introducing a new
> Kconfig option CONFIG_SRCU which is selected when any of the components making
> use of SRCU are selected.
> 
> The current tinyconfig on x86 enables SRCU by default since x86 enables
> PERF_EVENTS which in-turn require SRCU support. If we disable
> PERF_EVENTS, we can disable compiling SRCU for tiny configs on x86 systems.
> 
> I tested this using randconfig and building about 15 kernels. This is 
> definitely
> not complete and could use more testing. Sticking it in next might help in 
> that
> regards.
> 
> Comments and suggestions are welcome. Please let me know if I should split up
> this patch.

For the moment, I applied this to -rcu against v3.18-rc6 to get some 0day
testing on it.

There are conflicts against the tip of my tree, but will worry about
that later.  I don't have a ready answer on whether or not this needs
to be split up -- in the worst case, we would add the SRCU Kconfig
parameter, add all the selects, then once they all hit mainline add the
Makefile change.

We will need stats on how much memory was saved, and a "size kernel/rcu/srcu.o"
after a UP/tiny build should do it.  Could you please add this to the
commit log?

Josh, and additional thoughts?

Thanx, Paul

> Signed-off-by: Pranith Kumar 
> CC: Paul McKenney 
> CC: Josh Triplett 
> ---
> v2:
>  - handle cpufreq, devfreq and notifier
>  - build tested tinyconfig on powerpc
> 
>  arch/arm/kvm/Kconfig |  1 +
>  arch/arm64/kvm/Kconfig   |  1 +
>  arch/ia64/kvm/Kconfig|  1 +
>  arch/mips/kvm/Kconfig|  1 +
>  arch/powerpc/kvm/Kconfig |  1 +
>  arch/s390/kvm/Kconfig|  1 +
>  arch/tile/kvm/Kconfig|  1 +
>  arch/x86/kvm/Kconfig |  1 +
>  drivers/clk/Kconfig  |  1 +
>  drivers/cpufreq/Kconfig  |  1 +
>  drivers/devfreq/Kconfig  |  1 +
>  drivers/md/Kconfig   |  1 +
>  drivers/net/Kconfig  |  1 +
>  fs/btrfs/Kconfig |  1 +
>  fs/notify/Kconfig|  1 +
>  init/Kconfig | 10 ++
>  kernel/notifier.c|  3 +++
>  kernel/rcu/Makefile  |  3 ++-
>  lib/Kconfig.debug|  1 +
>  mm/Kconfig   |  1 +
>  security/tomoyo/Kconfig  |  1 +
>  21 files changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
> index 466bd29..3afee5f 100644
> --- a/arch/arm/kvm/Kconfig
> +++ b/arch/arm/kvm/Kconfig
> @@ -23,6 +23,7 @@ config KVM
>   select HAVE_KVM_CPU_RELAX_INTERCEPT
>   select KVM_MMIO
>   select KVM_ARM_HOST
> + select SRCU
>   depends on ARM_VIRT_EXT && ARM_LPAE
>   ---help---
> Support hosting virtualized guest machines. You will also
> diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
> index 8ba85e9..b334084 100644
> --- a/arch/arm64/kvm/Kconfig
> +++ b/arch/arm64/kvm/Kconfig
> @@ -26,6 +26,7 @@ config KVM
>   select KVM_ARM_HOST
>   select KVM_ARM_VGIC
>   select KVM_ARM_TIMER
> + select SRCU
>   ---help---
> Support hosting virtualized guest machines.
> 
> diff --git a/arch/ia64/kvm/Kconfig b/arch/ia64/kvm/Kconfig
> index 3d50ea9..f7d380b 100644
> --- a/arch/ia64/kvm/Kconfig
> +++ b/arch/ia64/kvm/Kconfig
> @@ -29,6 +29,7 @@ config KVM
>   select HAVE_KVM_IRQ_ROUTING
>   select KVM_APIC_ARCHITECTURE
>   select KVM_MMIO
> + select SRCU
>   ---help---
> Support hosting fully virtualized guest machines using hardware
> virtualization extensions.  You will need a fairly recent
> diff --git a/arch/mips/kvm/Kconfig b/arch/mips/kvm/Kconfig
> index 30e334e..2ae1282 100644
> --- a/arch/mips/kvm/Kconfig
> +++ b/arch/mips/kvm/Kconfig
> @@ -20,6 +20,7 @@ config KVM
>   select PREEMPT_NOTIFIERS
>   select ANON_INODES
>   select KVM_MMIO
> + select SRCU
>   ---help---
> Support for hosting Guest kernels.
> Currently supported on MIPS32 processors.
> diff --git a/arch/powerpc/kvm/Kconfig b/arch/powerpc/kvm/Kconfig
> index 602eb51..af18e0f 100644
> --- a/arch/powerpc/kvm/Kconfig
> +++ b/arch/powerpc/kvm/Kconfig
> @@ -21,6 +21,7 @@ config KVM
>   select PREEMPT_NOTIFIERS
>   select ANON_INODES
>   select HAVE_KVM_EVENTFD
> + select SRCU
> 
>  config KVM_BOOK3S_HANDLER
>   bool
> diff --git a/arch/s390/kvm/Kconfig b/arch/s390/kvm/Kconfig
> index 646db9c..5fce52c 100644
> --- a/arch/s390/kvm/Kconfig
> +++ b/arch/s390/kvm/Kconfig
> @@ -28,6 +28,7 @@ config KVM
>   select HAVE_KVM_IRQCHIP
>   select HAVE_KVM_IRQFD
>   select HAVE_KVM_IRQ_ROUTING
> + select SRCU
>   ---help---
> Support hosting paravirtualized guest machines using the SIE
>  

[PATCH v2] arm: omap3: twl: remove usb phy init data

2014-12-03 Thread Kishon Vijay Abraham I
From: Heikki Krogerus 

commit dbc98635e0d4 ("phy: remove the old lookup method") removes
struct phy_consumer but twl-common.c still uses the "phy_consumer"
structure resulting in the following compilation warning.

arch/arm/mach-omap2/twl-common.c:94:21: error: array type has
incomplete element type
 struct phy_consumer consumers[] = {

Removed using phy_consumer since twl4030 uses the new lookup
method.

Signed-off-by: Heikki Krogerus 
Signed-off-by: Kishon Vijay Abraham I 
---
Changes from v1:
Fixed the commit log.
 arch/arm/mach-omap2/twl-common.c |   12 +---
 include/linux/i2c/twl.h  |2 --
 2 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c
index b0d54da..4457e73 100644
--- a/arch/arm/mach-omap2/twl-common.c
+++ b/arch/arm/mach-omap2/twl-common.c
@@ -91,18 +91,8 @@ void __init omap_pmic_late_init(void)
 }
 
 #if defined(CONFIG_ARCH_OMAP3)
-struct phy_consumer consumers[] = {
-   PHY_CONSUMER("musb-hdrc.0", "usb"),
-};
-
-struct phy_init_data init_data = {
-   .consumers = consumers,
-   .num_consumers = ARRAY_SIZE(consumers),
-};
-
 static struct twl4030_usb_data omap3_usb_pdata = {
-   .usb_mode   = T2_USB_MODE_ULPI,
-   .init_data  = _data,
+   .usb_mode = T2_USB_MODE_ULPI,
 };
 
 static int omap3_batt_table[] = {
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index 8cfb50f..0bc03f1 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -26,7 +26,6 @@
 #define __TWL_H_
 
 #include 
-#include 
 #include 
 
 /*
@@ -634,7 +633,6 @@ enum twl4030_usb_mode {
 struct twl4030_usb_data {
enum twl4030_usb_mode   usb_mode;
unsigned long   features;
-   struct phy_init_data*init_data;
 
int (*phy_init)(struct device *dev);
int (*phy_exit)(struct device *dev);
-- 
1.7.9.5

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


[PATCH RFC] locking: Add volatile to arch_spinlock_t structures

2014-12-03 Thread Paul E. McKenney
More concern about compilers...

Most architectures mark the fields in their arch_spinlock_t structures
as volatile, which forces the compiler to respect the integrity of
those fields.  Without volatile markings, the compiler is within its
rights to overwrite these fields, for example, by using a wide store
to update an adjacent field as long as it fixes them up later.  This
sort of thing could come as a rather nasty surprise to any task attempting
to concurrently acquire that lock.

For example, on x86 for smallish NR_CPUS, arch_spinlock_t is 16 bits wide.
If there were three adjacent 16-bit fields in the structure containing
the arch_spinlock_t, a compiler might reasonably use 64-bit accesses
for those three fields.  After a 64-bit load, the arch_spinlock_t's
value would be available in a register, so that the compiler might use
a 64-bit store followed by a 16-bit fixup store to update the three
adjacent 16-bit fields.

This commit therefore adds volatile to the arch_spinlock_t and
arch_rwlock_t fields that don't already have them.

Signed-off-by: Paul E. McKenney 
Cc: linux-a...@vger.kernel.org
Cc: Dmitry Vyukov 
Cc: Davidlohr Bueso 
Cc: Ingo Molnar 
Cc: Peter Zijlstra 
Cc: Linus Torvalds 

diff --git a/arch/arm/include/asm/spinlock_types.h 
b/arch/arm/include/asm/spinlock_types.h
index 47663fcb10ad..7d3b6ecb5301 100644
--- a/arch/arm/include/asm/spinlock_types.h
+++ b/arch/arm/include/asm/spinlock_types.h
@@ -9,14 +9,14 @@
 
 typedef struct {
union {
-   u32 slock;
+   volatile u32 slock;
struct __raw_tickets {
 #ifdef __ARMEB__
-   u16 next;
-   u16 owner;
+   volatile u16 next;
+   volatile u16 owner;
 #else
-   u16 owner;
-   u16 next;
+   volatile u16 owner;
+   volatile u16 next;
 #endif
} tickets;
};
@@ -25,7 +25,7 @@ typedef struct {
 #define __ARCH_SPIN_LOCK_UNLOCKED  { { 0 } }
 
 typedef struct {
-   u32 lock;
+   volatile u32 lock;
 } arch_rwlock_t;
 
 #define __ARCH_RW_LOCK_UNLOCKED{ 0 }
diff --git a/arch/arm64/include/asm/spinlock_types.h 
b/arch/arm64/include/asm/spinlock_types.h
index b8d383665f56..0f841378f0f3 100644
--- a/arch/arm64/include/asm/spinlock_types.h
+++ b/arch/arm64/include/asm/spinlock_types.h
@@ -24,11 +24,11 @@
 
 typedef struct {
 #ifdef __AARCH64EB__
-   u16 next;
-   u16 owner;
+   volatile u16 next;
+   volatile u16 owner;
 #else
-   u16 owner;
-   u16 next;
+   volatile u16 owner;
+   volatile u16 next;
 #endif
 } __aligned(4) arch_spinlock_t;
 
diff --git a/arch/mips/include/asm/spinlock_types.h 
b/arch/mips/include/asm/spinlock_types.h
index 9b2528e612c0..10f04a0482dd 100644
--- a/arch/mips/include/asm/spinlock_types.h
+++ b/arch/mips/include/asm/spinlock_types.h
@@ -14,14 +14,14 @@ typedef union {
 * bits  0..15 : serving_now
 * bits 16..31 : ticket
 */
-   u32 lock;
+   volatile u32 lock;
struct {
 #ifdef __BIG_ENDIAN
-   u16 ticket;
-   u16 serving_now;
+   volatile u16 ticket;
+   volatile u16 serving_now;
 #else
-   u16 serving_now;
-   u16 ticket;
+   volatile u16 serving_now;
+   volatile u16 ticket;
 #endif
} h;
 } arch_spinlock_t;
diff --git a/arch/mn10300/include/asm/spinlock_types.h 
b/arch/mn10300/include/asm/spinlock_types.h
index 653dc519b405..04fd2c622f81 100644
--- a/arch/mn10300/include/asm/spinlock_types.h
+++ b/arch/mn10300/include/asm/spinlock_types.h
@@ -6,13 +6,13 @@
 #endif
 
 typedef struct arch_spinlock {
-   unsigned int slock;
+   volatile unsigned int slock;
 } arch_spinlock_t;
 
 #define __ARCH_SPIN_LOCK_UNLOCKED  { 0 }
 
 typedef struct {
-   unsigned int lock;
+   volatile unsigned int lock;
 } arch_rwlock_t;
 
 #define __ARCH_RW_LOCK_UNLOCKED{ RW_LOCK_BIAS }
diff --git a/arch/s390/include/asm/spinlock_types.h 
b/arch/s390/include/asm/spinlock_types.h
index d84b6939237c..0ccdda3b6842 100644
--- a/arch/s390/include/asm/spinlock_types.h
+++ b/arch/s390/include/asm/spinlock_types.h
@@ -6,14 +6,14 @@
 #endif
 
 typedef struct {
-   unsigned int lock;
+   volatile unsigned int lock;
 } __attribute__ ((aligned (4))) arch_spinlock_t;
 
 #define __ARCH_SPIN_LOCK_UNLOCKED { .lock = 0, }
 
 typedef struct {
-   unsigned int lock;
-   unsigned int owner;
+   volatile unsigned int lock;
+   volatile unsigned int owner;
 } arch_rwlock_t;
 
 #define __ARCH_RW_LOCK_UNLOCKED{ 0 }
diff --git a/arch/tile/include/asm/spinlock_types.h 
b/arch/tile/include/asm/spinlock_types.h
index a71f59b49c50..29f70a14b979 100644
--- a/arch/tile/include/asm/spinlock_types.h
+++ b/arch/tile/include/asm/spinlock_types.h
@@ -23,14 +23,14 @@
 
 /* Low 15 bits are 

Re: [PATCH 1/2] toshiba_acpi: Move hotkey enabling code to own function

2014-12-03 Thread Darren Hart
On Tue, Dec 02, 2014 at 10:36:31PM -0700, Azael Avalos wrote:
> The hotkey enabling code is being used by
> *_setup_keyboard and also by *_resume.
> 
> This patch creates a new function called
> toshiba_acpi_enable_hotkeys to be used by
> these two functions to avoid duplicating
> code.

42 is a little bit narrow, even for us kernel types :-) 72 characters wide is
fine.

Patch is fine, but since I had some questions on your others, please correct in
V2.

Thanks,

-- 
Darren Hart
Intel Open Source Technology Center
--
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 2/2] toshiba_acpi: Change notify funtion to handle more events

2014-12-03 Thread Darren Hart
On Tue, Dec 02, 2014 at 10:36:32PM -0700, Azael Avalos wrote:
> Currently the function toshiba_acpi_notify only
> takes care of hotkeys, however, the TOS
> devices receive more events that can be useful.
> 
> This patch changes the function to be able to
> handle more events, and in the process, move all
> hotkey related code residing in it to a new
> function called toshiba_acpi_process_hotkeys,
> and also update the sysfs group whenever we
> receive a 0x92 event, which indicates a change
> in the keyboard backlight mode.

This would be better as two patches. One for process_hotkeys, and another for
the (smaller) kbd backlight sysfs update.

-- 
Darren Hart
Intel Open Source Technology Center
--
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: use 'unsigned long' type for 'zero' variable

2014-12-03 Thread Manfred Spraul

Hi Andrew,

On 12/04/2014 12:25 AM, Andrew Morton wrote:

On Wed, 03 Dec 2014 15:41:21 +0300 Andrey Ryabinin  
wrote:


Use the 'unsigned long' type for 'zero' variable to fix this.
Changing type to 'unsigned long' shouldn't affect any other users
of this variable.

Reported-by: Dmitry Vyukov 
Fixes: ed4d4902ebdd ("mm, hugetlb: remove hugetlb_zero and hugetlb_infinity")
Signed-off-by: Andrey Ryabinin 
---
  kernel/sysctl.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 15f2511..45c45c9 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -120,7 +120,7 @@ static int sixty = 60;
  
  static int __maybe_unused neg_one = -1;
  
-static int zero;

+static unsigned long zero;
  static int __maybe_unused one = 1;
  static int __maybe_unused two = 2;
  static int __maybe_unused four = 4;

Yeah, this is ghastly.

Look at

{
.procname   = "numa_balancing",
.data   = NULL, /* filled in by handler */
.maxlen = sizeof(unsigned int),
.mode   = 0644,
.proc_handler   = sysctl_numa_balancing,
.extra1 = ,
.extra2 = ,
},

Now extra1 points at a long and extra2 points at an int.
sysctl_numa_balancing() calls proc_dointvec_minmax() and I think your
patch just broke big-endian 64-bit machines.  "sched_autogroup_enabled"
breaks as well.
What about getting rid of "extra1" and "extra2" as well and replace it 
with "min" and "max"?

I've attached an idea


and change proc_dointvec_minmax() and a million other functions to take
`union sysctl_payload *' arguments.  But I haven't thought about it much.

Another idea: why do we pass "int *" instead of "int"?

With "int", we could use
.int_min = 0;
.int_max = 1;


--
Manfred
>From 7a210bec3d9dc3382ef0d6809a7742856373bbee Mon Sep 17 00:00:00 2001
From: Manfred Spraul 
Date: Thu, 4 Dec 2014 07:03:39 +0100
Subject: [PATCH] Allow type safe & documented sysctl

Idea from Andrew:
- add a union into struct ctl_table instead of the void *
- further idea: replace "extra1" and "extra2" with min/max
- use it for ipc

Notes:
- not tested
- not coding style reviewed
- open FIXME in ipc_sysctl.c

Signed-off-by: Manfred Spraul 
---
 include/linux/sysctl.h | 16 ++--
 ipc/ipc_sysctl.c   | 34 ++
 2 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index b7361f8..acc7581 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -111,8 +111,20 @@ struct ctl_table
 	struct ctl_table *child;	/* Deprecated */
 	proc_handler *proc_handler;	/* Callback for text formatting */
 	struct ctl_table_poll *poll;
-	void *extra1;
-	void *extra2;
+	union {
+		void *extra1;
+		int *int_min;
+		long *long_min;
+		unsigned int *uint_min;
+		unsigned long *ulong_min;
+	};
+	union {
+		void *extra2;
+		int *int_max;
+		long *long_max;
+		unsigned int *uint_max;
+		unsigned long *ulong_max;
+	};
 };
 
 struct ctl_node {
diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
index c3f0326..50a6e1c 100644
--- a/ipc/ipc_sysctl.c
+++ b/ipc/ipc_sysctl.c
@@ -167,6 +167,7 @@ static struct ctl_table ipc_kern_table[] = {
 		.maxlen		= sizeof(init_ipc_ns.shm_ctlmax),
 		.mode		= 0644,
 		.proc_handler	= proc_ipc_doulongvec_minmax,
+		/* FIXME: Why no ulong_min & ulong_max ?? */
 	},
 	{
 		.procname	= "shmall",
@@ -174,6 +175,7 @@ static struct ctl_table ipc_kern_table[] = {
 		.maxlen		= sizeof(init_ipc_ns.shm_ctlall),
 		.mode		= 0644,
 		.proc_handler	= proc_ipc_doulongvec_minmax,
+		/* FIXME: Why no ulong_min & ulong_max ?? */
 	},
 	{
 		.procname	= "shmmni",
@@ -188,8 +190,8 @@ static struct ctl_table ipc_kern_table[] = {
 		.maxlen		= sizeof(init_ipc_ns.shm_rmid_forced),
 		.mode		= 0644,
 		.proc_handler	= proc_ipc_dointvec_minmax_orphans,
-		.extra1		= ,
-		.extra2		= ,
+		.int_min	= ,
+		.int_max	= ,
 	},
 	{
 		.procname	= "msgmax",
@@ -197,8 +199,8 @@ static struct ctl_table ipc_kern_table[] = {
 		.maxlen		= sizeof(init_ipc_ns.msg_ctlmax),
 		.mode		= 0644,
 		.proc_handler	= proc_ipc_dointvec_minmax,
-		.extra1		= ,
-		.extra2		= _max,
+		.int_min	= ,
+		.int_max	= _max,
 	},
 	{
 		.procname	= "msgmni",
@@ -206,8 +208,8 @@ static struct ctl_table ipc_kern_table[] = {
 		.maxlen		= sizeof(init_ipc_ns.msg_ctlmni),
 		.mode		= 0644,
 		.proc_handler	= proc_ipc_callback_dointvec_minmax,
-		.extra1		= ,
-		.extra2		= _max,
+		.int_min	= ,
+		.int_max	= _max,
 	},
 	{
 		.procname	=  "msgmnb",
@@ -215,8 +217,8 @@ static struct ctl_table ipc_kern_table[] = {
 		.maxlen		= sizeof(init_ipc_ns.msg_ctlmnb),
 		.mode		= 0644,
 		.proc_handler	= proc_ipc_dointvec_minmax,
-		.extra1		= ,
-		.extra2		= _max,
+		.int_min	= ,
+		.int_max	= _max,
 	},
 	{
 		.procname	= "sem",
@@ -231,8 +233,8 @@ static struct ctl_table ipc_kern_table[] = {
 		.maxlen		= sizeof(int),
 		.mode		= 0644,

RE: [RFC V2] mm:add zero_page _mapcount when mapped into user space

2014-12-03 Thread Wang, Yalin
> -Original Message-
> From: Kirill A. Shutemov [mailto:kir...@shutemov.name]
> Sent: Tuesday, December 02, 2014 7:30 PM
> To: Wang, Yalin
> Cc: 'linux-kernel@vger.kernel.org'; 'linux...@kvack.org'; 'linux-arm-
> ker...@lists.infradead.org'
> Subject: Re: [RFC V2] mm:add zero_page _mapcount when mapped into user
> space
> 
> On Tue, Dec 02, 2014 at 05:27:36PM +0800, Wang, Yalin wrote:
> > This patch add/dec zero_page's _mapcount to make sure the mapcount is
> > correct for zero_page, so that when read from /proc/kpagecount,
> > zero_page's mapcount is also correct, userspace process like procrank
> > can calculate PSS correctly.
> 
> I don't have specific code path to point to, but I would expect zero page
> with non-zero mapcount would cause a problem with rmap.
> 
> How do you test the change?
> 
I just test it to see the mapcount from /proc/pid/pagemap  and /proc/kpagecount 
,
It works well,
The problem is that when I see /proc/pid/smaps ,
The Rss / Pss don't calculate zero_page map,
Because smaps_pte_entry() --> vm_normal_page( ),
Will return NULL for zero_page,

But when userspace process cat /proc/pid/pagemap  ,
It will see zero_page mapped,
And will treat as Rss ,  
This is weird, should we also omit zero_page in /proc/pid/pagemap ?
Or add zero_page as Rss in /proc/pid/smaps ? 

I think we should add zero_page into Rss ,
Because it is really mapped into userspace address space.
And will let userspace memory analysis more accurate .

Thanks





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


Re: [RESEND PATCH v5 4/5] acerhdf: added critical trip point

2014-12-03 Thread Darren Hart
On Fri, Nov 28, 2014 at 03:20:51PM +0100, Peter Feuerer wrote:
> added critical trip point which represents the temperature limit.

Nitpic, Add ^

> Added return -EINVAL in case wrong trip point is provided.

Add (we are going to add it with this patch, it wasn't added previously). It's a
nitpic. But this is more consistent with typical commit message language.

I might normally just fix that upon commit, but since I had a few questions on
the last one, if that results in a V2, please correct this as well.

> 
> Cc: platform-driver-...@vger.kernel.org
> Cc: Darren Hart 
> Cc: Andrew Morton 
> Cc: Andreas Mohr 
> Cc: Borislav Petkov 
> Cc: Javi Merino 
> Signed-off-by: Peter Feuerer 
> ---
>  drivers/platform/x86/acerhdf.c | 10 +-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
> index 7fe7dbf..91b16c8 100644
> --- a/drivers/platform/x86/acerhdf.c
> +++ b/drivers/platform/x86/acerhdf.c
> @@ -443,6 +443,10 @@ static int acerhdf_get_trip_type(struct 
> thermal_zone_device *thermal, int trip,
>  {
>   if (trip == 0)
>   *type = THERMAL_TRIP_ACTIVE;
> + else if (trip == 1)
> + *type = THERMAL_TRIP_CRITICAL;
> + else
> + return -EINVAL;
>  
>   return 0;
>  }
> @@ -463,6 +467,10 @@ static int acerhdf_get_trip_temp(struct 
> thermal_zone_device *thermal, int trip,
>  {
>   if (trip == 0)
>   *temp = fanon;
> + else if (trip == 1)
> + *temp = ACERHDF_TEMP_CRIT;
> + else
> + return -EINVAL;
>  
>   return 0;
>  }
> @@ -713,7 +721,7 @@ static int acerhdf_register_thermal(void)
>   if (IS_ERR(cl_dev))
>   return -EINVAL;
>  
> - thz_dev = thermal_zone_device_register("acerhdf", 1, 0, NULL,
> + thz_dev = thermal_zone_device_register("acerhdf", 2, 0, NULL,
> _dev_ops,
> _zone_params, 0,
> (kernelmode) ? interval*1000 : 0);
> -- 
> 2.1.3
> 
> 

-- 
Darren Hart
Intel Open Source Technology Center
--
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 v9 0/8] TPM 2.0 support

2014-12-03 Thread Jarkko Sakkinen
Please ignore this one. Sent another one with v9 prefixes. Sorry!

/Jarkko

On Thu, Dec 04, 2014 at 07:49:19AM +0200, Jarkko Sakkinen wrote:
> This patch set enables TPM2 protocol and provides drivers for FIFO and
> CRB interfaces. This patch set does not export any sysfs attributes for
> TPM 2.0 because existing sysfs attributes have three non-trivial issues:
> 
> - They are associated with the platform device instead of character
>   device.
> - They are are not trivial key-value pairs but contain text that is
>   not easily parsed by a computer.
> - Raciness as described in
>   http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly/
> 
> This is too big effort to be included into this patch set and requires
> more discussion.
> 
> v2:
> - Improved struct tpm_chip life-cycle by taking advantage of devres
>   API.
> - Refined sysfs attributes as simple key-values thereby not repeating
>   mistakes in TPM1 sysfs attributes.
> - Documented functions in tpm-chip.c and tpm2-cmd.c.
> - Documented sysfs attributes.
> 
> v3:
> - Lots of fixes in calling order in device drivers (thanks to Jason
>   Gunthorpe for pointing these out!).
> - Attach sysfs attributes to the misc device because it represents
>   TPM device to the user space.
> 
> v4:
> - Disable sysfs attibutes for TPM 2.0 for until we can sort out the 
>   best approach for them.
> - Fixed all the style issues found with checkpatch.pl.
> 
> v5:
> - missing EXPORT_SYMBOL_GPL()
> - own class for TPM devices used for TPM 2.0 devices and onwards.
> 
> v6:
> - Non-racy initialization for sysfs attributes using struct device's
>   groups field.
> - The class 'tpm' is used now for all TPM devices. For the first device
>   node major MISC_MAJOR and minor TPM_MINOR is used in order to retain
>   backwards compatability.
> 
> v7:
> - Release device number and free struct tpm_chip memory inside
>   tpm_dev_release callback.
> - Moved code from tpm-interface.c and tpm_dev.c to tpm-chip.c.
> 
> v8:
> - Cleaned up unneeded cast from tpm_transmit_cmd().
> - Cleaned up redundant PPI_VERSION_LEN constant from tpm_ppi.c.
> - Fixed tpm_tis to use tpm2_calc_ordinal_duration() for TPM2 devices.
> - tpm_crb: in crb_recv, check that count can hold the TPM header at
>   minimum.
> - tpm_crb: add enumerations for bit flags in start and cancel fields
>   of the control area.
> - tpm_crb: use ioremap() for command and response buffer because
>   they might be anywhere.
> - tpm_crb: use IO access functions for reading ioremapped buffers
>   because using direct pointers is not portable.
> - tpm_crb: only apply ACPI start if start method reported by the
>   TPM2 ACPI table allows it.
> - In tpm2_pcr_read() just calculate index and bit and get rid of
>   hacky loop.
> - Do not add sysfs attributes for TPM 2.0 devices.
> 
> v9:
> - Fixed compilation issues in v8 (sorry for not using the correct
>   tree).
> - Just do "return tpm_chip_register();" instead of copying return
>   value to a variable.
> - Removed unused tpm2_startup().
> - In the CRB driver ACPI TPM2 table could contain platform specific
>   and therefore inequality test does not work. Changed check whether
>   buffer size is less than mandatory fields in the ACPI TPM2 table.
> 
> Jarkko Sakkinen (7):
>   tpm: merge duplicate transmit_cmd() functions
>   tpm: two-phase chip management functions
>   tpm: fix raciness of PPI interface lookup
>   tpm: rename chip->dev to chip->pdev
>   tpm: device class for tpm
>   tpm: TPM 2.0 baseline support
>   tpm: TPM 2.0 CRB Interface
> 
> Will Arthur (1):
>   tpm: TPM 2.0 FIFO Interface
> 
>  drivers/char/tpm/Kconfig|   9 +
>  drivers/char/tpm/Makefile   |   3 +-
>  drivers/char/tpm/tpm-chip.c | 251 +
>  drivers/char/tpm/tpm-dev.c  |  42 +--
>  drivers/char/tpm/tpm-interface.c| 261 ++---
>  drivers/char/tpm/tpm-sysfs.c|  29 +-
>  drivers/char/tpm/tpm.h  | 107 +--
>  drivers/char/tpm/tpm2-cmd.c | 542 
> 
>  drivers/char/tpm/tpm_atmel.c|  25 +-
>  drivers/char/tpm/tpm_crb.c  | 356 +++
>  drivers/char/tpm/tpm_i2c_atmel.c|  55 ++--
>  drivers/char/tpm/tpm_i2c_infineon.c |  43 +--
>  drivers/char/tpm/tpm_i2c_nuvoton.c  |  71 ++---
>  drivers/char/tpm/tpm_i2c_stm_st33.c |  28 +-
>  drivers/char/tpm/tpm_ibmvtpm.c  |  17 +-
>  drivers/char/tpm/tpm_infineon.c |  51 ++--
>  drivers/char/tpm/tpm_nsc.c  |  34 ++-
>  drivers/char/tpm/tpm_ppi.c  | 137 +
>  drivers/char/tpm/tpm_tis.c  | 192 -
>  drivers/char/tpm/xen-tpmfront.c |  14 +-
>  20 files changed, 1689 insertions(+), 578 deletions(-)
>  create mode 100644 drivers/char/tpm/tpm-chip.c
>  create mode 100644 drivers/char/tpm/tpm2-cmd.c
>  create mode 100644 drivers/char/tpm/tpm_crb.c
> 
> -- 
> 2.1.0
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a 

[PATCH v9 5/8] tpm: device class for tpm

2014-12-03 Thread Jarkko Sakkinen
Added own device class for TPM. Uses MISC_MAJOR:TPM_MINOR for the
first character device in order to retain backwards compatibility.
Added tpm_dev_release() back attached to the character device.

Signed-off-by: Jarkko Sakkinen 
---
 drivers/char/tpm/tpm-chip.c| 72 --
 drivers/char/tpm/tpm-dev.c | 36 ++-
 drivers/char/tpm/tpm-interface.c   | 29 +++
 drivers/char/tpm/tpm.h | 12 ---
 drivers/char/tpm/tpm_i2c_nuvoton.c |  2 +-
 drivers/char/tpm/tpm_tis.c |  4 +--
 6 files changed, 105 insertions(+), 50 deletions(-)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index c584161..7741e28 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "tpm.h"
 #include "tpm_eventlog.h"
 
@@ -32,6 +33,9 @@ static DECLARE_BITMAP(dev_mask, TPM_NUM_DEVICES);
 static LIST_HEAD(tpm_chip_list);
 static DEFINE_SPINLOCK(driver_lock);
 
+struct class *tpm_class;
+dev_t tpm_devt;
+
 /*
  * tpm_chip_find_get - return tpm_chip for a given chip number
  * @chip_num the device number for the chip
@@ -55,16 +59,14 @@ struct tpm_chip *tpm_chip_find_get(int chip_num)
 }
 
 /**
- * tpmm_chip_remove() - free chip memory and device number
- * @data: points to struct tpm_chip instance
+ * tpm_dev_release() - free chip memory and the device number
+ * @dev: the character device for the TPM chip
  *
- * This is used internally by tpmm_chip_alloc() and called by devres
- * when the device is released. This function does the opposite of
- * tpmm_chip_alloc() freeing memory and the device number.
+ * This is used as the release function for the character device.
  */
-static void tpmm_chip_remove(void *data)
+static void tpm_dev_release(struct device *dev)
 {
-   struct tpm_chip *chip = (struct tpm_chip *) data;
+   struct tpm_chip *chip = container_of(dev, struct tpm_chip, dev);
 
spin_lock(_lock);
clear_bit(chip->dev_num, dev_mask);
@@ -111,18 +113,68 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,
scnprintf(chip->devname, sizeof(chip->devname), "tpm%d", chip->dev_num);
 
chip->pdev = dev;
-   devm_add_action(dev, tpmm_chip_remove, chip);
+
dev_set_drvdata(dev, chip);
 
+   chip->dev.class = tpm_class;
+   chip->dev.release = tpm_dev_release;
+   chip->dev.parent = chip->pdev;
+
+   if (chip->dev_num == 0)
+   chip->dev.devt = MKDEV(MISC_MAJOR, TPM_MINOR);
+   else
+   chip->dev.devt = MKDEV(MAJOR(tpm_devt), chip->dev_num);
+
+   dev_set_name(>dev, chip->devname);
+
+   device_initialize(>dev);
+
+   chip->cdev.owner = chip->pdev->driver->owner;
+   cdev_init(>cdev, _fops);
+
return chip;
 }
 EXPORT_SYMBOL_GPL(tpmm_chip_alloc);
 
+static int tpm_dev_add_device(struct tpm_chip *chip)
+{
+   int rc;
+
+   rc = device_add(>dev);
+   if (rc) {
+   dev_err(>dev,
+   "unable to device_register() %s, major %d, minor %d, 
err=%d\n",
+   chip->devname, MAJOR(chip->dev.devt),
+   MINOR(chip->dev.devt), rc);
+
+   return rc;
+   }
+
+   rc = cdev_add(>cdev, chip->dev.devt, 1);
+   if (rc) {
+   dev_err(>dev,
+   "unable to cdev_add() %s, major %d, minor %d, err=%d\n",
+   chip->devname, MAJOR(chip->dev.devt),
+   MINOR(chip->dev.devt), rc);
+
+   device_unregister(>dev);
+   return rc;
+   }
+
+   return rc;
+}
+
+static void tpm_dev_del_device(struct tpm_chip *chip)
+{
+   cdev_del(>cdev);
+   device_unregister(>dev);
+}
+
 /*
- * tpm_chip_register() - create a misc driver for the TPM chip
+ * tpm_chip_register() - create a character device for the TPM chip
  * @chip: TPM chip to use.
  *
- * Creates a misc driver for the TPM chip and adds sysfs interfaces for
+ * Creates a character device for the TPM chip and adds sysfs interfaces for
  * the device, PPI and TCPA. As the last step this function adds the
  * chip to the list of TPM chips available for use.
  *
diff --git a/drivers/char/tpm/tpm-dev.c b/drivers/char/tpm/tpm-dev.c
index 3568321..de0337e 100644
--- a/drivers/char/tpm/tpm-dev.c
+++ b/drivers/char/tpm/tpm-dev.c
@@ -17,7 +17,6 @@
  * License.
  *
  */
-#include 
 #include 
 #include 
 #include "tpm.h"
@@ -54,9 +53,8 @@ static void timeout_work(struct work_struct *work)
 
 static int tpm_open(struct inode *inode, struct file *file)
 {
-   struct miscdevice *misc = file->private_data;
-   struct tpm_chip *chip = container_of(misc, struct tpm_chip,
-vendor.miscdev);
+   struct tpm_chip *chip =
+   container_of(inode->i_cdev, struct tpm_chip, cdev);
struct file_priv *priv;
 
/* It's assured that the chip will 

[PATCH v9 3/8] tpm: fix raciness of PPI interface lookup

2014-12-03 Thread Jarkko Sakkinen
Traversal of the ACPI device tree was not done right. PPI interface
should be looked up only from the ACPI device that is the platform
device for the TPM. This could cause problems with systems with
two TPM chips such as 4th gen Intel systems.

In addition, added the missing license and copyright platter to
the tpm_ppi.c.

Signed-off-by: Jarkko Sakkinen 
---
 drivers/char/tpm/tpm-chip.c |   2 +-
 drivers/char/tpm/tpm.h  |  16 --
 drivers/char/tpm/tpm_ppi.c  | 137 +++-
 drivers/char/tpm/tpm_tis.c  |  14 +++--
 4 files changed, 106 insertions(+), 63 deletions(-)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index 35aca12..543939b 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -147,7 +147,7 @@ int tpm_chip_register(struct tpm_chip *chip)
if (rc)
goto del_misc;
 
-   rc = tpm_add_ppi(>dev->kobj);
+   rc = tpm_add_ppi(chip);
if (rc)
goto del_sysfs;
 
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 9880681..69f4003 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 enum tpm_const {
TPM_MINOR = 224,/* officially assigned */
@@ -94,6 +95,8 @@ struct tpm_vendor_specific {
 #define TPM_VID_WINBOND  0x1050
 #define TPM_VID_STM  0x104A
 
+#define TPM_PPI_VERSION_LEN3
+
 struct tpm_chip {
struct device *dev; /* Device stuff */
const struct tpm_class_ops *ops;
@@ -109,6 +112,11 @@ struct tpm_chip {
 
struct dentry **bios_dir;
 
+#ifdef CONFIG_ACPI
+   acpi_handle acpi_dev_handle;
+   char ppi_version[TPM_PPI_VERSION_LEN + 1];
+#endif /* CONFIG_ACPI */
+
struct list_head list;
 };
 
@@ -340,15 +348,15 @@ void tpm_sysfs_del_device(struct tpm_chip *chip);
 int tpm_pcr_read_dev(struct tpm_chip *chip, int pcr_idx, u8 *res_buf);
 
 #ifdef CONFIG_ACPI
-extern int tpm_add_ppi(struct kobject *);
-extern void tpm_remove_ppi(struct kobject *);
+extern int tpm_add_ppi(struct tpm_chip *chip);
+extern void tpm_remove_ppi(struct tpm_chip *chip);
 #else
-static inline int tpm_add_ppi(struct kobject *parent)
+static inline int tpm_add_ppi(struct tpm_chip *chip)
 {
return 0;
 }
 
-static inline void tpm_remove_ppi(struct kobject *parent)
+static inline void tpm_remove_ppi(struct tpm_chip *chip)
 {
 }
 #endif
diff --git a/drivers/char/tpm/tpm_ppi.c b/drivers/char/tpm/tpm_ppi.c
index 61dcc80..6652025 100644
--- a/drivers/char/tpm/tpm_ppi.c
+++ b/drivers/char/tpm/tpm_ppi.c
@@ -1,3 +1,22 @@
+/*
+ * Copyright (C) 2012-2014 Intel Corporation
+ *
+ * Authors:
+ * Xiaoyan Zhang 
+ * Jiang Liu 
+ * Jarkko Sakkinen 
+ *
+ * Maintained by: 
+ *
+ * This file contains implementation of the sysfs interface for PPI.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ */
+
+
 #include 
 #include "tpm.h"
 
@@ -12,7 +31,6 @@
 #define PPI_TPM_REQ_MAX22
 #define PPI_VS_REQ_START   128
 #define PPI_VS_REQ_END 255
-#define PPI_VERSION_LEN3
 
 static const u8 tpm_ppi_uuid[] = {
0xA6, 0xFA, 0xDD, 0x3D,
@@ -22,45 +40,22 @@ static const u8 tpm_ppi_uuid[] = {
0x8D, 0x10, 0x08, 0x9D, 0x16, 0x53
 };
 
-static char tpm_ppi_version[PPI_VERSION_LEN + 1];
-static acpi_handle tpm_ppi_handle;
-
-static acpi_status ppi_callback(acpi_handle handle, u32 level, void *context,
-   void **return_value)
-{
-   union acpi_object *obj;
-
-   if (!acpi_check_dsm(handle, tpm_ppi_uuid, TPM_PPI_REVISION_ID,
-   1 << TPM_PPI_FN_VERSION))
-   return AE_OK;
-
-   /* Cache version string */
-   obj = acpi_evaluate_dsm_typed(handle, tpm_ppi_uuid,
- TPM_PPI_REVISION_ID, TPM_PPI_FN_VERSION,
- NULL, ACPI_TYPE_STRING);
-   if (obj) {
-   strlcpy(tpm_ppi_version, obj->string.pointer,
-   PPI_VERSION_LEN + 1);
-   ACPI_FREE(obj);
-   }
-
-   *return_value = handle;
-
-   return AE_CTRL_TERMINATE;
-}
-
 static inline union acpi_object *
-tpm_eval_dsm(int func, acpi_object_type type, union acpi_object *argv4)
+tpm_eval_dsm(acpi_handle ppi_handle, int func, acpi_object_type type,
+union acpi_object *argv4)
 {
-   BUG_ON(!tpm_ppi_handle);
-   return acpi_evaluate_dsm_typed(tpm_ppi_handle, tpm_ppi_uuid,
-  TPM_PPI_REVISION_ID, func, argv4, type);
+   BUG_ON(!ppi_handle);
+   return acpi_evaluate_dsm_typed(ppi_handle, tpm_ppi_uuid,
+  TPM_PPI_REVISION_ID,
+  func, argv4, type);
 }
 
 static ssize_t 

[PATCH v9 6/8] tpm: TPM 2.0 baseline support

2014-12-03 Thread Jarkko Sakkinen
TPM 2.0 devices are separated by adding a field 'flags' to struct
tpm_chip and defining a flag TPM_CHIP_FLAG_TPM2 for tagging them.

This patch adds the following internal functions:

- tpm2_get_random()
- tpm2_get_tpm_pt()
- tpm2_pcr_extend()
- tpm2_pcr_read()
- tpm2_startup()

Additionally, the following exported functions are implemented for
implementing TPM 2.0 device drivers:

- tpm2_do_selftest()
- tpm2_calc_ordinal_durations()
- tpm2_gen_interrupt()

The existing functions that are exported for the use for existing
subsystems have been changed to check the flags field in struct
tpm_chip and use appropriate TPM 2.0 counterpart if
TPM_CHIP_FLAG_TPM2 is est.

The code for tpm2_calc_ordinal_duration() and tpm2_startup() were
originally written by Will Arthur.

Signed-off-by: Jarkko Sakkinen 
Signed-off-by: Will Arthur 
---
 drivers/char/tpm/Makefile|   2 +-
 drivers/char/tpm/tpm-chip.c  |  27 +-
 drivers/char/tpm/tpm-interface.c |  24 +-
 drivers/char/tpm/tpm.h   |  61 +
 drivers/char/tpm/tpm2-cmd.c  | 542 +++
 5 files changed, 641 insertions(+), 15 deletions(-)
 create mode 100644 drivers/char/tpm/tpm2-cmd.c

diff --git a/drivers/char/tpm/Makefile b/drivers/char/tpm/Makefile
index c715596..88848ed 100644
--- a/drivers/char/tpm/Makefile
+++ b/drivers/char/tpm/Makefile
@@ -2,7 +2,7 @@
 # Makefile for the kernel tpm device drivers.
 #
 obj-$(CONFIG_TCG_TPM) += tpm.o
-tpm-y := tpm-interface.o tpm-dev.o tpm-sysfs.o tpm-chip.o
+tpm-y := tpm-interface.o tpm-dev.o tpm-sysfs.o tpm-chip.o tpm2-cmd.o
 tpm-$(CONFIG_ACPI) += tpm_ppi.o
 
 ifdef CONFIG_ACPI
diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index 7741e28..3f3f2de 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -195,15 +195,18 @@ int tpm_chip_register(struct tpm_chip *chip)
if (rc)
return rc;
 
-   rc = tpm_sysfs_add_device(chip);
-   if (rc)
-   goto del_misc;
+   /* Populate sysfs for TPM1 devices. */
+   if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) {
+   rc = tpm_sysfs_add_device(chip);
+   if (rc)
+   goto del_misc;
 
-   rc = tpm_add_ppi(chip);
-   if (rc)
-   goto del_sysfs;
+   rc = tpm_add_ppi(chip);
+   if (rc)
+   goto del_sysfs;
 
-   chip->bios_dir = tpm_bios_log_setup(chip->devname);
+   chip->bios_dir = tpm_bios_log_setup(chip->devname);
+   }
 
/* Make the chip available. */
spin_lock(_lock);
@@ -236,10 +239,12 @@ void tpm_chip_unregister(struct tpm_chip *chip)
spin_unlock(_lock);
synchronize_rcu();
 
-   if (chip->bios_dir)
-   tpm_bios_log_teardown(chip->bios_dir);
-   tpm_remove_ppi(chip);
-   tpm_sysfs_del_device(chip);
+   if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) {
+   if (chip->bios_dir)
+   tpm_bios_log_teardown(chip->bios_dir);
+   tpm_remove_ppi(chip);
+   tpm_sysfs_del_device(chip);
+   }
 
tpm_dev_del_device(chip);
 }
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index b6f6b17..8a14887 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -360,7 +360,10 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char 
*buf,
if (chip->vendor.irq)
goto out_recv;
 
-   stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal);
+   if (chip->flags & TPM_CHIP_FLAG_TPM2)
+   stop = jiffies + tpm2_calc_ordinal_duration(chip, ordinal);
+   else
+   stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal);
do {
u8 status = chip->ops->status(chip);
if ((status & chip->ops->req_complete_mask) ==
@@ -483,7 +486,7 @@ static const struct tpm_input_header tpm_startup_header = {
 static int tpm_startup(struct tpm_chip *chip, __be16 startup_type)
 {
struct tpm_cmd_t start_cmd;
-   start_cmd.header.in = tpm_startup_header;
+
start_cmd.params.startup_in.startup_type = startup_type;
return tpm_transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
"attempting to start the TPM");
@@ -680,7 +683,10 @@ int tpm_pcr_read(u32 chip_num, int pcr_idx, u8 *res_buf)
chip = tpm_chip_find_get(chip_num);
if (chip == NULL)
return -ENODEV;
-   rc = tpm_pcr_read_dev(chip, pcr_idx, res_buf);
+   if (chip->flags & TPM_CHIP_FLAG_TPM2)
+   rc = tpm2_pcr_read(chip, pcr_idx, res_buf);
+   else
+   rc = tpm_pcr_read_dev(chip, pcr_idx, res_buf);
tpm_chip_put(chip);
return rc;
 }
@@ -714,6 +720,12 @@ int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 
*hash)
if (chip == NULL)
return -ENODEV;
 
+   if (chip->flags & 

[PATCH v9 8/8] tpm: TPM 2.0 FIFO Interface

2014-12-03 Thread Jarkko Sakkinen
From: Will Arthur 

Detect TPM 2.0 by using the extended STS (STS3) register. For TPM 2.0,
instead of calling tpm_get_timeouts(), assign duration and timeout
values defined in the TPM 2.0 PTP specification.

Signed-off-by: Will Arthur 
Signed-off-by: Jarkko Sakkinen 
---
 drivers/char/tpm/tpm_tis.c | 80 ++
 1 file changed, 67 insertions(+), 13 deletions(-)

diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 89e1abb..71cbb2d 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2005, 2006 IBM Corporation
+ * Copyright (C) 2014 Intel Corporation
  *
  * Authors:
  * Leendert van Doorn 
@@ -44,6 +45,10 @@ enum tis_status {
TPM_STS_DATA_EXPECT = 0x08,
 };
 
+enum tis_status3 {
+   TPM_STS3_TPM2_FAM = 0x04,
+};
+
 enum tis_int_flags {
TPM_GLOBAL_INT_ENABLE = 0x8000,
TPM_INTF_BURST_COUNT_STATIC = 0x100,
@@ -70,6 +75,7 @@ enum tis_defaults {
 #defineTPM_INT_STATUS(l)   (0x0010 | ((l) << 12))
 #defineTPM_INTF_CAPS(l)(0x0014 | ((l) << 12))
 #defineTPM_STS(l)  (0x0018 | ((l) << 12))
+#defineTPM_STS3(l) (0x001b | ((l) << 12))
 #defineTPM_DATA_FIFO(l)(0x0024 | ((l) << 12))
 
 #defineTPM_DID_VID(l)  (0x0F00 | ((l) << 12))
@@ -363,6 +369,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8 
*buf, size_t len)
 {
int rc;
u32 ordinal;
+   unsigned long dur;
 
rc = tpm_tis_send_data(chip, buf, len);
if (rc < 0)
@@ -374,9 +381,14 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8 
*buf, size_t len)
 
if (chip->vendor.irq) {
ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
+
+   if (chip->flags & TPM_CHIP_FLAG_TPM2)
+   dur = tpm2_calc_ordinal_duration(chip, ordinal);
+   else
+   dur = tpm_calc_ordinal_duration(chip, ordinal);
+
if (wait_for_tpm_stat
-   (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID,
-tpm_calc_ordinal_duration(chip, ordinal),
+   (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID, dur,
 >vendor.read_queue, false) < 0) {
rc = -ETIME;
goto out_err;
@@ -588,6 +600,7 @@ static int tpm_tis_init(struct device *dev, acpi_handle 
acpi_dev_handle,
int rc, i, irq_s, irq_e, probe;
struct tpm_chip *chip;
struct priv_data *priv;
+   u8 sts3;
 
priv = devm_kzalloc(dev, sizeof(struct priv_data), GFP_KERNEL);
if (priv == NULL)
@@ -604,11 +617,28 @@ static int tpm_tis_init(struct device *dev, acpi_handle 
acpi_dev_handle,
if (!chip->vendor.iobase)
return -EIO;
 
+   sts3 = ioread8(chip->vendor.iobase + TPM_STS3(1));
+   if ((sts3 & TPM_STS3_TPM2_FAM) == TPM_STS3_TPM2_FAM)
+   chip->flags = TPM_CHIP_FLAG_TPM2;
+
/* Default timeouts */
-   chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
-   chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
-   chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
-   chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+   if (chip->flags & TPM_CHIP_FLAG_TPM2) {
+   chip->vendor.timeout_a = usecs_to_jiffies(TPM2_TIMEOUT_A);
+   chip->vendor.timeout_b = usecs_to_jiffies(TPM2_TIMEOUT_B);
+   chip->vendor.timeout_c = usecs_to_jiffies(TPM2_TIMEOUT_C);
+   chip->vendor.timeout_d = usecs_to_jiffies(TPM2_TIMEOUT_D);
+   chip->vendor.duration[TPM_SHORT] =
+   usecs_to_jiffies(TPM2_DURATION_SHORT);
+   chip->vendor.duration[TPM_MEDIUM] =
+   usecs_to_jiffies(TPM2_DURATION_MEDIUM);
+   chip->vendor.duration[TPM_LONG] =
+   usecs_to_jiffies(TPM2_DURATION_LONG);
+   } else {
+   chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+   chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
+   chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+   chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+   }
 
if (wait_startup(chip, 0) != 0) {
rc = -ENODEV;
@@ -623,8 +653,8 @@ static int tpm_tis_init(struct device *dev, acpi_handle 
acpi_dev_handle,
vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0));
chip->vendor.manufacturer_id = vendor;
 
-   dev_info(dev,
-"1.2 TPM (device-id 0x%X, rev-id %d)\n",
+   dev_info(dev, "%s TPM (device-id 0x%X, rev-id %d)\n",
+(chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2",
 vendor >> 16, ioread8(chip->vendor.iobase + TPM_RID(0)));
 
  

[PATCH v9 4/8] tpm: rename chip->dev to chip->pdev

2014-12-03 Thread Jarkko Sakkinen
Rename chip->dev to chip->pdev to make it explicit that this not the
character device but actually represents the platform device.

Signed-off-by: Jarkko Sakkinen 
---
 drivers/char/tpm/tpm-chip.c |  4 ++--
 drivers/char/tpm/tpm-dev.c  | 10 +-
 drivers/char/tpm/tpm-interface.c| 29 +++--
 drivers/char/tpm/tpm-sysfs.c|  6 +++---
 drivers/char/tpm/tpm.h  |  4 ++--
 drivers/char/tpm/tpm_atmel.c| 14 +++---
 drivers/char/tpm/tpm_i2c_atmel.c| 16 
 drivers/char/tpm/tpm_i2c_infineon.c |  6 +++---
 drivers/char/tpm/tpm_i2c_nuvoton.c  | 22 +++---
 drivers/char/tpm/tpm_i2c_stm_st33.c | 14 +++---
 drivers/char/tpm/tpm_infineon.c | 22 +++---
 drivers/char/tpm/tpm_nsc.c  | 20 ++--
 drivers/char/tpm/tpm_ppi.c  |  4 ++--
 drivers/char/tpm/tpm_tis.c  | 14 +++---
 14 files changed, 93 insertions(+), 92 deletions(-)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index 543939b..c584161 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -45,7 +45,7 @@ struct tpm_chip *tpm_chip_find_get(int chip_num)
if (chip_num != TPM_ANY_NUM && chip_num != pos->dev_num)
continue;
 
-   if (try_module_get(pos->dev->driver->owner)) {
+   if (try_module_get(pos->pdev->driver->owner)) {
chip = pos;
break;
}
@@ -110,7 +110,7 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,
 
scnprintf(chip->devname, sizeof(chip->devname), "tpm%d", chip->dev_num);
 
-   chip->dev = dev;
+   chip->pdev = dev;
devm_add_action(dev, tpmm_chip_remove, chip);
dev_set_drvdata(dev, chip);
 
diff --git a/drivers/char/tpm/tpm-dev.c b/drivers/char/tpm/tpm-dev.c
index d9b774e..3568321 100644
--- a/drivers/char/tpm/tpm-dev.c
+++ b/drivers/char/tpm/tpm-dev.c
@@ -63,7 +63,7 @@ static int tpm_open(struct inode *inode, struct file *file)
 * by the check of is_open variable, which is protected
 * by driver_lock. */
if (test_and_set_bit(0, >is_open)) {
-   dev_dbg(chip->dev, "Another process owns this TPM\n");
+   dev_dbg(chip->pdev, "Another process owns this TPM\n");
return -EBUSY;
}
 
@@ -81,7 +81,7 @@ static int tpm_open(struct inode *inode, struct file *file)
INIT_WORK(>work, timeout_work);
 
file->private_data = priv;
-   get_device(chip->dev);
+   get_device(chip->pdev);
return 0;
 }
 
@@ -168,7 +168,7 @@ static int tpm_release(struct inode *inode, struct file 
*file)
file->private_data = NULL;
atomic_set(>data_pending, 0);
clear_bit(0, >chip->is_open);
-   put_device(priv->chip->dev);
+   put_device(priv->chip->pdev);
kfree(priv);
return 0;
 }
@@ -193,12 +193,12 @@ int tpm_dev_add_device(struct tpm_chip *chip)
chip->vendor.miscdev.minor = MISC_DYNAMIC_MINOR;
 
chip->vendor.miscdev.name = chip->devname;
-   chip->vendor.miscdev.parent = chip->dev;
+   chip->vendor.miscdev.parent = chip->pdev;
 
rc = misc_register(>vendor.miscdev);
if (rc) {
chip->vendor.miscdev.name = NULL;
-   dev_err(chip->dev,
+   dev_err(chip->pdev,
"unable to misc_register %s, minor %d err=%d\n",
chip->vendor.miscdev.name,
chip->vendor.miscdev.minor, rc);
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 4dbed1e..e2af28f 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -343,7 +343,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
if (count == 0)
return -ENODATA;
if (count > bufsiz) {
-   dev_err(chip->dev,
+   dev_err(chip->pdev,
"invalid count value %x %zx\n", count, bufsiz);
return -E2BIG;
}
@@ -352,7 +352,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
 
rc = chip->ops->send(chip, (u8 *) buf, count);
if (rc < 0) {
-   dev_err(chip->dev,
+   dev_err(chip->pdev,
"tpm_transmit: tpm_send: error %zd\n", rc);
goto out;
}
@@ -368,7 +368,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
goto out_recv;
 
if (chip->ops->req_canceled(chip, status)) {
-   dev_err(chip->dev, "Operation Canceled\n");
+   dev_err(chip->pdev, "Operation Canceled\n");
rc = -ECANCELED;
goto out;
}
@@ -378,14 +378,14 @@ ssize_t tpm_transmit(struct tpm_chip *chip, 

[PATCH v9 7/8] tpm: TPM 2.0 CRB Interface

2014-12-03 Thread Jarkko Sakkinen
tpm_crb is a driver for TPM 2.0 Command Response Buffer (CRB) Interface
as defined in PC Client Platform TPM Profile (PTP) Specification.

Only polling and single locality is supported as these are the limitations
of the available hardware, Platform Trust Techonlogy (PTT) in Haswell
CPUs.

The driver always applies CRB with ACPI start because PTT reports using
only ACPI start as start method but as a result of my testing it requires
also CRB start.

Signed-off-by: Jarkko Sakkinen 
---
 drivers/char/tpm/Kconfig   |   9 ++
 drivers/char/tpm/Makefile  |   1 +
 drivers/char/tpm/tpm_crb.c | 356 +
 3 files changed, 366 insertions(+)
 create mode 100644 drivers/char/tpm/tpm_crb.c

diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig
index 3d0873b..9d4e375 100644
--- a/drivers/char/tpm/Kconfig
+++ b/drivers/char/tpm/Kconfig
@@ -122,4 +122,13 @@ config TCG_XEN
  To compile this driver as a module, choose M here; the module
  will be called xen-tpmfront.
 
+config TCG_CRB
+   tristate "TPM 2.0 CRB Interface"
+   depends on X86 && ACPI
+   ---help---
+ If you have a TPM security chip that is compliant with the
+ TCG CRB 2.0 TPM specification say Yes and it will be accessible
+ from within Linux.  To compile this driver as a module, choose
+ M here; the module will be called tpm_crb.
+
 endif # TCG_TPM
diff --git a/drivers/char/tpm/Makefile b/drivers/char/tpm/Makefile
index 88848ed..990cf18 100644
--- a/drivers/char/tpm/Makefile
+++ b/drivers/char/tpm/Makefile
@@ -22,3 +22,4 @@ obj-$(CONFIG_TCG_INFINEON) += tpm_infineon.o
 obj-$(CONFIG_TCG_IBMVTPM) += tpm_ibmvtpm.o
 obj-$(CONFIG_TCG_TIS_I2C_ST33) += tpm_i2c_stm_st33.o
 obj-$(CONFIG_TCG_XEN) += xen-tpmfront.o
+obj-$(CONFIG_TCG_CRB) += tpm_crb.o
diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
new file mode 100644
index 000..eb78f93
--- /dev/null
+++ b/drivers/char/tpm/tpm_crb.c
@@ -0,0 +1,356 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * Authors:
+ * Jarkko Sakkinen 
+ *
+ * Maintained by: 
+ *
+ * This device driver implements the TPM interface as defined in
+ * the TCG CRB 2.0 TPM specification.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "tpm.h"
+
+#define ACPI_SIG_TPM2 "TPM2"
+
+static const u8 CRB_ACPI_START_UUID[] = {
+   /*  */ 0xAB, 0x6C, 0xBF, 0x6B, 0x63, 0x54, 0x14, 0x47,
+   /* 0008 */ 0xB7, 0xCD, 0xF0, 0x20, 0x3C, 0x03, 0x68, 0xD4
+};
+
+enum crb_defaults {
+   CRB_ACPI_START_REVISION_ID = 1,
+   CRB_ACPI_START_INDEX = 1,
+};
+
+enum crb_start_method {
+   CRB_SM_ACPI_START = 2,
+   CRB_SM_CRB = 7,
+   CRB_SM_CRB_WITH_ACPI_START = 8,
+};
+
+struct acpi_tpm2 {
+   struct acpi_table_header hdr;
+   u16 platform_class;
+   u16 reserved;
+   u64 control_area_pa;
+   u32 start_method;
+} __packed;
+
+enum crb_ca_request {
+   CRB_CA_REQ_GO_IDLE  = BIT(0),
+   CRB_CA_REQ_CMD_READY= BIT(1),
+};
+
+enum crb_ca_status {
+   CRB_CA_STS_ERROR= BIT(0),
+   CRB_CA_STS_TPM_IDLE = BIT(1),
+};
+
+enum crb_start {
+   CRB_START_INVOKE= BIT(0),
+};
+
+enum crb_cancel {
+   CRB_CANCEL_INVOKE   = BIT(0),
+};
+
+struct crb_control_area {
+   u32 req;
+   u32 sts;
+   u32 cancel;
+   u32 start;
+   u32 int_enable;
+   u32 int_sts;
+   u32 cmd_size;
+   u64 cmd_pa;
+   u32 rsp_size;
+   u64 rsp_pa;
+} __packed;
+
+enum crb_status {
+   CRB_STS_COMPLETE= BIT(0),
+};
+
+enum crb_flags {
+   CRB_FL_ACPI_START   = BIT(0),
+   CRB_FL_CRB_START= BIT(1),
+};
+
+struct crb_priv {
+   unsigned int flags;
+   struct crb_control_area *cca;
+   u8 *cmd;
+   u8 *rsp;
+};
+
+#ifdef CONFIG_PM_SLEEP
+int crb_suspend(struct device *dev)
+{
+   return 0;
+}
+
+static int crb_resume(struct device *dev)
+{
+   struct tpm_chip *chip = dev_get_drvdata(dev);
+
+   (void) tpm2_do_selftest(chip);
+
+   return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(crb_pm, crb_suspend, crb_resume);
+
+static u8 crb_status(struct tpm_chip *chip)
+{
+   struct crb_priv *priv = chip->vendor.priv;
+   u8 sts = 0;
+
+   if ((le32_to_cpu(ioread32(>cca->start)) & CRB_START_INVOKE) !=
+   CRB_START_INVOKE)
+   sts |= CRB_STS_COMPLETE;
+
+   return sts;
+}
+
+static int crb_recv(struct tpm_chip *chip, u8 *buf, size_t count)
+{
+   struct crb_priv *priv = chip->vendor.priv;
+   unsigned int expected;
+
+   /* sanity check */
+   if (count < 6)
+   return -EIO;
+
+   if (le32_to_cpu(ioread32(>cca->sts)) & CRB_CA_STS_ERROR)
+   return -EIO;
+
+   

[PATCH v9 2/8] tpm: two-phase chip management functions

2014-12-03 Thread Jarkko Sakkinen
tpm_register_hardware() and tpm_remove_hardware() are called often
before initializing the device. The problem is that the device might
not be fully initialized when it comes visible to the user space.

This patch resolves the issue by diving initialization into two
parts:

- tpmm_chip_alloc() creates struct tpm_chip.

- tpm_chip_register() sets up the character device and sysfs
  attributes.

The framework takes care of freeing struct tpm_chip by using the devres
API. The broken release callback has been wiped. ACPI drivers do not
ever get this callback.

Regards to Jason Gunthorpe for carefully reviewing this part of the
code.

Signed-off-by: Jarkko Sakkinen 
---
 drivers/char/tpm/Makefile   |   2 +-
 drivers/char/tpm/tpm-chip.c | 194 
 drivers/char/tpm/tpm-interface.c| 148 +--
 drivers/char/tpm/tpm.h  |  11 +-
 drivers/char/tpm/tpm_atmel.c|  11 +-
 drivers/char/tpm/tpm_i2c_atmel.c|  39 ++--
 drivers/char/tpm/tpm_i2c_infineon.c |  37 ++-
 drivers/char/tpm/tpm_i2c_nuvoton.c  |  47 +++--
 drivers/char/tpm/tpm_i2c_stm_st33.c |  14 +--
 drivers/char/tpm/tpm_ibmvtpm.c  |  17 ++--
 drivers/char/tpm/tpm_infineon.c |  29 +++---
 drivers/char/tpm/tpm_nsc.c  |  14 ++-
 drivers/char/tpm/tpm_tis.c  |  80 ++-
 drivers/char/tpm/xen-tpmfront.c |  14 +--
 14 files changed, 319 insertions(+), 338 deletions(-)
 create mode 100644 drivers/char/tpm/tpm-chip.c

diff --git a/drivers/char/tpm/Makefile b/drivers/char/tpm/Makefile
index 7f54dae..c715596 100644
--- a/drivers/char/tpm/Makefile
+++ b/drivers/char/tpm/Makefile
@@ -2,7 +2,7 @@
 # Makefile for the kernel tpm device drivers.
 #
 obj-$(CONFIG_TCG_TPM) += tpm.o
-tpm-y := tpm-interface.o tpm-dev.o tpm-sysfs.o
+tpm-y := tpm-interface.o tpm-dev.o tpm-sysfs.o tpm-chip.o
 tpm-$(CONFIG_ACPI) += tpm_ppi.o
 
 ifdef CONFIG_ACPI
diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
new file mode 100644
index 000..35aca12
--- /dev/null
+++ b/drivers/char/tpm/tpm-chip.c
@@ -0,0 +1,194 @@
+/*
+ * Copyright (C) 2004 IBM Corporation
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * Authors:
+ * Jarkko Sakkinen 
+ * Leendert van Doorn 
+ * Dave Safford 
+ * Reiner Sailer 
+ * Kylene Hall 
+ *
+ * Maintained by: 
+ *
+ * TPM chip management routines.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, version 2 of the
+ * License.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "tpm.h"
+#include "tpm_eventlog.h"
+
+static DECLARE_BITMAP(dev_mask, TPM_NUM_DEVICES);
+static LIST_HEAD(tpm_chip_list);
+static DEFINE_SPINLOCK(driver_lock);
+
+/*
+ * tpm_chip_find_get - return tpm_chip for a given chip number
+ * @chip_num the device number for the chip
+ */
+struct tpm_chip *tpm_chip_find_get(int chip_num)
+{
+   struct tpm_chip *pos, *chip = NULL;
+
+   rcu_read_lock();
+   list_for_each_entry_rcu(pos, _chip_list, list) {
+   if (chip_num != TPM_ANY_NUM && chip_num != pos->dev_num)
+   continue;
+
+   if (try_module_get(pos->dev->driver->owner)) {
+   chip = pos;
+   break;
+   }
+   }
+   rcu_read_unlock();
+   return chip;
+}
+
+/**
+ * tpmm_chip_remove() - free chip memory and device number
+ * @data: points to struct tpm_chip instance
+ *
+ * This is used internally by tpmm_chip_alloc() and called by devres
+ * when the device is released. This function does the opposite of
+ * tpmm_chip_alloc() freeing memory and the device number.
+ */
+static void tpmm_chip_remove(void *data)
+{
+   struct tpm_chip *chip = (struct tpm_chip *) data;
+
+   spin_lock(_lock);
+   clear_bit(chip->dev_num, dev_mask);
+   spin_unlock(_lock);
+   kfree(chip);
+}
+
+/**
+ * tpmm_chip_alloc() - allocate a new struct tpm_chip instance
+ * @dev: device to which the chip is associated
+ * @ops: struct tpm_class_ops instance
+ *
+ * Allocates a new struct tpm_chip instance and assigns a free
+ * device number for it. Caller does not have to worry about
+ * freeing the allocated resources. When the devices is removed
+ * devres calls tpmm_chip_remove() to do the job.
+ */
+struct tpm_chip *tpmm_chip_alloc(struct device *dev,
+const struct tpm_class_ops *ops)
+{
+   struct tpm_chip *chip;
+
+   chip = kzalloc(sizeof(*chip), GFP_KERNEL);
+   if (chip == NULL)
+   return ERR_PTR(-ENOMEM);
+
+   mutex_init(>tpm_mutex);
+   INIT_LIST_HEAD(>list);
+
+   chip->ops = ops;
+
+   spin_lock(_lock);
+   chip->dev_num = find_first_zero_bit(dev_mask, TPM_NUM_DEVICES);
+   spin_unlock(_lock);
+
+   if (chip->dev_num >= TPM_NUM_DEVICES) {
+   dev_err(dev, "No available 

Re: [RESEND PATCH v5 3/5] acerhdf: Use bang-bang thermal governor

2014-12-03 Thread Darren Hart
On Fri, Nov 28, 2014 at 03:20:50PM +0100, Peter Feuerer wrote:
> acerhdf has been doing an on-off fan control using hysteresis by
> post-manipulating the outcome of thermal subsystem trip point handling.
> This patch enables acerhdf to use the bang-bang governor, which is
> intended for on-off controlled fans.
> 
> Cc: platform-driver-...@vger.kernel.org
> Cc: Darren Hart 
> Cc: Andrew Morton 
> CC: Zhang Rui 
> Cc: Andreas Mohr 
> Cc: Javi Merino 
> Acked-and-tested-by: Borislav Petkov 
> Signed-off-by: Peter Feuerer 
> ---
>  drivers/platform/x86/Kconfig   |  3 ++-
>  drivers/platform/x86/acerhdf.c | 36 +++-
>  2 files changed, 33 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
> index a2eabe6..c173266 100644
> --- a/drivers/platform/x86/Kconfig
> +++ b/drivers/platform/x86/Kconfig
> @@ -38,7 +38,8 @@ config ACER_WMI
>  
>  config ACERHDF
>   tristate "Acer Aspire One temperature and fan driver"
> - depends on THERMAL && ACPI
> + select THERMAL_GOV_BANG_BANG

So we use select sparingly as it does implicit things.

I checked the THERMAL_GOV_BANG_BANG Kconfig entry, and the help says acerhdf
already depends on it (which it doesn't appear to). Any particular reason to add
select here instead of adding it as a depends.

Why did you drop THERMAL?

> + depends on ACPI
>   ---help---
> This is a driver for Acer Aspire One netbooks. It allows to access
> the temperature sensor and to control the fan.
> diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
> index f30767f..7fe7dbf 100644
> --- a/drivers/platform/x86/acerhdf.c
> +++ b/drivers/platform/x86/acerhdf.c
> @@ -50,7 +50,7 @@
>   */
>  #undef START_IN_KERNEL_MODE
>  
> -#define DRV_VER "0.5.30"
> +#define DRV_VER "0.7.0"
>  
>  /*
>   * According to the Atom N270 datasheet,
> @@ -258,6 +258,14 @@ static const struct bios_settings_t bios_tbl[] = {
>  
>  static const struct bios_settings_t *bios_cfg __read_mostly;
>  
> +/*
> + * this struct is used to instruct thermal layer to use bang_bang instead of
> + * default governor for acerhdf

Please use sentence punctuation, particularly for block comments.

/*
 * This struct...
 * default ... for acerhdf.
 */

> + */
> +static struct thermal_zone_params acerhdf_zone_params = {
> + .governor_name = "bang_bang",
> +};
> +
>  static int acerhdf_get_temp(int *temp)
>  {
>   u8 read_temp;
> @@ -439,6 +447,17 @@ static int acerhdf_get_trip_type(struct 
> thermal_zone_device *thermal, int trip,
>   return 0;
>  }
>  
> +static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int 
> trip,
> +  unsigned long *temp)
> +{
> + if (trip != 0)
> + return -EINVAL;
> +
> + *temp = fanon - fanoff;
> +
> + return 0;
> +}
> +
>  static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int 
> trip,
>unsigned long *temp)
>  {
> @@ -463,6 +482,7 @@ static struct thermal_zone_device_ops acerhdf_dev_ops = {
>   .get_mode = acerhdf_get_mode,
>   .set_mode = acerhdf_set_mode,
>   .get_trip_type = acerhdf_get_trip_type,
> + .get_trip_hyst = acerhdf_get_trip_hyst,
>   .get_trip_temp = acerhdf_get_trip_temp,
>   .get_crit_temp = acerhdf_get_crit_temp,
>  };
> @@ -515,9 +535,7 @@ static int acerhdf_set_cur_state(struct 
> thermal_cooling_device *cdev,
>   }
>  
>   if (state == 0) {
> - /* turn fan off only if below fanoff temperature */
> - if ((cur_state == ACERHDF_FAN_AUTO) &&
> - (cur_temp < fanoff))
> + if (cur_state == ACERHDF_FAN_AUTO)
>   acerhdf_change_fanstate(ACERHDF_FAN_OFF);
>   } else {
>   if (cur_state == ACERHDF_FAN_OFF)
> @@ -696,11 +714,19 @@ static int acerhdf_register_thermal(void)
>   return -EINVAL;
>  
>   thz_dev = thermal_zone_device_register("acerhdf", 1, 0, NULL,
> -   _dev_ops, NULL, 0,
> +   _dev_ops,
> +   _zone_params, 0,
> (kernelmode) ? interval*1000 : 0);
>   if (IS_ERR(thz_dev))
>   return -EINVAL;
>  
> + if (strcmp(thz_dev->governor->name,
> + acerhdf_zone_params.governor_name)) {
> + pr_err("Didn't get thermal governor %s, perhaps not compiled 
> into thermal subsystem.\n",
> + acerhdf_zone_params.governor_name);

We've ensured it has to be compiled in, so that really can't be it. Right?

> + return -EINVAL;
> + }
> +
>   return 0;
>  }
>  
> -- 
> 2.1.3
> 
> 

-- 
Darren Hart
Intel Open Source Technology Center
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to 

[PATCH v9 1/8] tpm: merge duplicate transmit_cmd() functions

2014-12-03 Thread Jarkko Sakkinen
Merged transmit_cmd() functions in tpm-interface.c and tpm-sysfs.c.
Added "tpm_" prefix for consistency sake. Changed cmd parameter as
opaque. This enables to use separate command structures for TPM1
and TPM2 commands in future. Loose coupling works fine here.

Signed-off-by: Jarkko Sakkinen 
---
 drivers/char/tpm/tpm-interface.c | 49 +---
 drivers/char/tpm/tpm-sysfs.c | 23 ++-
 drivers/char/tpm/tpm.h   |  3 ++-
 3 files changed, 30 insertions(+), 45 deletions(-)

diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index cfb9089..c17aa45 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -398,9 +398,10 @@ out:
 #define TPM_DIGEST_SIZE 20
 #define TPM_RET_CODE_IDX 6
 
-static ssize_t transmit_cmd(struct tpm_chip *chip, struct tpm_cmd_t *cmd,
-   int len, const char *desc)
+ssize_t tpm_transmit_cmd(struct tpm_chip *chip, void *cmd,
+int len, const char *desc)
 {
+   struct tpm_output_header *header;
int err;
 
len = tpm_transmit(chip, (u8 *) cmd, len);
@@ -409,7 +410,9 @@ static ssize_t transmit_cmd(struct tpm_chip *chip, struct 
tpm_cmd_t *cmd,
else if (len < TPM_HEADER_SIZE)
return -EFAULT;
 
-   err = be32_to_cpu(cmd->header.out.return_code);
+   header = cmd;
+
+   err = be32_to_cpu(header->return_code);
if (err != 0 && desc)
dev_err(chip->dev, "A TPM error (%d) occurred %s\n", err, desc);
 
@@ -448,7 +451,7 @@ ssize_t tpm_getcap(struct device *dev, __be32 subcap_id, 
cap_t *cap,
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
tpm_cmd.params.getcap_in.subcap = subcap_id;
}
-   rc = transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE, desc);
+   rc = tpm_transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE, desc);
if (!rc)
*cap = tpm_cmd.params.getcap_out.cap;
return rc;
@@ -464,8 +467,8 @@ void tpm_gen_interrupt(struct tpm_chip *chip)
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
 
-   rc = transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
-   "attempting to determine the timeouts");
+   rc = tpm_transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
+ "attempting to determine the timeouts");
 }
 EXPORT_SYMBOL_GPL(tpm_gen_interrupt);
 
@@ -484,8 +487,8 @@ static int tpm_startup(struct tpm_chip *chip, __be16 
startup_type)
struct tpm_cmd_t start_cmd;
start_cmd.header.in = tpm_startup_header;
start_cmd.params.startup_in.startup_type = startup_type;
-   return transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
-   "attempting to start the TPM");
+   return tpm_transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
+   "attempting to start the TPM");
 }
 
 int tpm_get_timeouts(struct tpm_chip *chip)
@@ -500,7 +503,7 @@ int tpm_get_timeouts(struct tpm_chip *chip)
tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
-   rc = transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE, NULL);
+   rc = tpm_transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE, NULL);
 
if (rc == TPM_ERR_INVALID_POSTINIT) {
/* The TPM is not started, we are the first to talk to it.
@@ -513,7 +516,7 @@ int tpm_get_timeouts(struct tpm_chip *chip)
tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
-   rc = transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
+   rc = tpm_transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
  NULL);
}
if (rc) {
@@ -575,8 +578,8 @@ duration:
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_DURATION;
 
-   rc = transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
-   "attempting to determine the durations");
+   rc = tpm_transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
+ "attempting to determine the durations");
if (rc)
return rc;
 
@@ -631,8 +634,8 @@ static int tpm_continue_selftest(struct tpm_chip *chip)
struct tpm_cmd_t cmd;
 
cmd.header.in = continue_selftest_header;
-   rc = transmit_cmd(chip, , CONTINUE_SELFTEST_RESULT_SIZE,
- "continue selftest");
+   rc = tpm_transmit_cmd(chip, , CONTINUE_SELFTEST_RESULT_SIZE,
+ "continue selftest");
return rc;
 

[PATCH v9 0/8] TPM 2.0 support

2014-12-03 Thread Jarkko Sakkinen
This patch set enables TPM2 protocol and provides drivers for FIFO and
CRB interfaces. This patch set does not export any sysfs attributes for
TPM 2.0 because existing sysfs attributes have three non-trivial issues:

- They are associated with the platform device instead of character
  device.
- They are are not trivial key-value pairs but contain text that is
  not easily parsed by a computer.
- Raciness as described in
  http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly/

This is too big effort to be included into this patch set and requires
more discussion.

v2:
- Improved struct tpm_chip life-cycle by taking advantage of devres
  API.
- Refined sysfs attributes as simple key-values thereby not repeating
  mistakes in TPM1 sysfs attributes.
- Documented functions in tpm-chip.c and tpm2-cmd.c.
- Documented sysfs attributes.

v3:
- Lots of fixes in calling order in device drivers (thanks to Jason
  Gunthorpe for pointing these out!).
- Attach sysfs attributes to the misc device because it represents
  TPM device to the user space.

v4:
- Disable sysfs attibutes for TPM 2.0 for until we can sort out the 
  best approach for them.
- Fixed all the style issues found with checkpatch.pl.

v5:
- missing EXPORT_SYMBOL_GPL()
- own class for TPM devices used for TPM 2.0 devices and onwards.

v6:
- Non-racy initialization for sysfs attributes using struct device's
  groups field.
- The class 'tpm' is used now for all TPM devices. For the first device
  node major MISC_MAJOR and minor TPM_MINOR is used in order to retain
  backwards compatability.

v7:
- Release device number and free struct tpm_chip memory inside
  tpm_dev_release callback.
- Moved code from tpm-interface.c and tpm_dev.c to tpm-chip.c.

v8:
- Cleaned up unneeded cast from tpm_transmit_cmd().
- Cleaned up redundant PPI_VERSION_LEN constant from tpm_ppi.c.
- Fixed tpm_tis to use tpm2_calc_ordinal_duration() for TPM2 devices.
- tpm_crb: in crb_recv, check that count can hold the TPM header at
  minimum.
- tpm_crb: add enumerations for bit flags in start and cancel fields
  of the control area.
- tpm_crb: use ioremap() for command and response buffer because
  they might be anywhere.
- tpm_crb: use IO access functions for reading ioremapped buffers
  because using direct pointers is not portable.
- tpm_crb: only apply ACPI start if start method reported by the
  TPM2 ACPI table allows it.
- In tpm2_pcr_read() just calculate index and bit and get rid of
  hacky loop.
- Do not add sysfs attributes for TPM 2.0 devices.

v9:
- Fixed compilation issues in v8 (sorry for not using the correct
  tree).
- Just do "return tpm_chip_register();" instead of copying return
  value to a variable.
- Removed unused tpm2_startup().
- In the CRB driver ACPI TPM2 table could contain platform specific
  and therefore inequality test does not work. Fixed in this patch
  set.

Jarkko Sakkinen (7):
  tpm: merge duplicate transmit_cmd() functions
  tpm: two-phase chip management functions
  tpm: fix raciness of PPI interface lookup
  tpm: rename chip->dev to chip->pdev
  tpm: device class for tpm
  tpm: TPM 2.0 baseline support
  tpm: TPM 2.0 CRB Interface

Will Arthur (1):
  tpm: TPM 2.0 FIFO Interface

 drivers/char/tpm/Kconfig|   9 +
 drivers/char/tpm/Makefile   |   3 +-
 drivers/char/tpm/tpm-chip.c | 251 +
 drivers/char/tpm/tpm-dev.c  |  42 +--
 drivers/char/tpm/tpm-interface.c| 261 ++---
 drivers/char/tpm/tpm-sysfs.c|  29 +-
 drivers/char/tpm/tpm.h  | 107 +--
 drivers/char/tpm/tpm2-cmd.c | 542 
 drivers/char/tpm/tpm_atmel.c|  25 +-
 drivers/char/tpm/tpm_crb.c  | 356 +++
 drivers/char/tpm/tpm_i2c_atmel.c|  55 ++--
 drivers/char/tpm/tpm_i2c_infineon.c |  43 +--
 drivers/char/tpm/tpm_i2c_nuvoton.c  |  71 ++---
 drivers/char/tpm/tpm_i2c_stm_st33.c |  28 +-
 drivers/char/tpm/tpm_ibmvtpm.c  |  17 +-
 drivers/char/tpm/tpm_infineon.c |  51 ++--
 drivers/char/tpm/tpm_nsc.c  |  34 ++-
 drivers/char/tpm/tpm_ppi.c  | 137 +
 drivers/char/tpm/tpm_tis.c  | 192 -
 drivers/char/tpm/xen-tpmfront.c |  14 +-
 20 files changed, 1689 insertions(+), 578 deletions(-)
 create mode 100644 drivers/char/tpm/tpm-chip.c
 create mode 100644 drivers/char/tpm/tpm2-cmd.c
 create mode 100644 drivers/char/tpm/tpm_crb.c

-- 
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 v12 01/19] input: cyapa: modify code to following kernel code style

2014-12-03 Thread Dudley Du
Jeremiah,

I didn't submitted this fix patch, but Dmitry has been helping apply the fix 
patch quickly, maybe todoay or tommorrow.

For the pathces that I made were worked based off of kernel mainline.

Thanks,
Dudley

> -Original Message-
> From: Jeremiah Mahler [mailto:jmmah...@gmail.com]
> Sent: 2014?12?4? 12:58
> To: Dudley Du
> Cc: linux-kernel@vger.kernel.org; dmitry.torok...@gmail.com
> Subject: Re: [PATCH v12 01/19] input: cyapa: modify code to following kernel 
> code
> style
>
> Dudley,
>
> On Wed, Dec 03, 2014 at 05:30:07PM +0800, Dudley Du wrote:
> > This patch modified the code to fix the patch check warning issue with 
> > latest
> > checkpatch.sh tool, and also changed the return variable name from "ret" to
> > "error" when there is only one error path to follow code style.
> > TEST=test on Chromebooks.
> >
> > Signed-off-by: Dudley Du 
> > ---
> >  drivers/input/mouse/cyapa.c | 162 
> > ++--
> >  1 file changed, 80 insertions(+), 82 deletions(-)
> >
> > diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
> > index b409c3d..c9fdf6d 100644
> > --- a/drivers/input/mouse/cyapa.c
> > +++ b/drivers/input/mouse/cyapa.c
> [...]
>
> I was hoping to test out your patchset since the patch for the touchpad
> problem [1] still has not appeared in linux-next as of 20141203.
> Unfortunately your patchset does not apply so I can't test it.  Which
> kernel is your work based off of?
>
>   [1]: https://lkml.org/lkml/2014/11/27/684
>
> --
> - Jeremiah Mahler

This message and any attachments may contain Cypress (or its subsidiaries) 
confidential information. If it has been received in error, please advise the 
sender and immediately delete this message.
--
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 v8 0/8] TPM 2.0 support

2014-12-03 Thread Jarkko Sakkinen
On Wed, Dec 03, 2014 at 12:16:19AM +0100, Peter Hüwe wrote:
> [SNIP]
> 
> When applying to linux-v3.18-rc6 I get this new coccinelle warning:
> drivers/char/tpm/tpm_i2c_nuvoton.c:607:1-3: WARNING: end returns can be 
> simpified
> 
> 
> make -C ../../../linux/ M=$(pwd) coccicheck

Not a huge problem but I've been only been able to run coccicheck
globally to the whole kernel tree. If I try what you put, it will
just print the usage information of spatch couple of times...

> Peter

/Jarkko
--
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 v8 8/8] tpm: TPM 2.0 FIFO Interface

2014-12-03 Thread Jarkko Sakkinen
From: Will Arthur 

Detect TPM 2.0 by using the extended STS (STS3) register. For TPM 2.0,
instead of calling tpm_get_timeouts(), assign duration and timeout
values defined in the TPM 2.0 PTP specification.

Signed-off-by: Will Arthur 
Signed-off-by: Jarkko Sakkinen 
---
 drivers/char/tpm/tpm_tis.c | 80 ++
 1 file changed, 67 insertions(+), 13 deletions(-)

diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 89e1abb..71cbb2d 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2005, 2006 IBM Corporation
+ * Copyright (C) 2014 Intel Corporation
  *
  * Authors:
  * Leendert van Doorn 
@@ -44,6 +45,10 @@ enum tis_status {
TPM_STS_DATA_EXPECT = 0x08,
 };
 
+enum tis_status3 {
+   TPM_STS3_TPM2_FAM = 0x04,
+};
+
 enum tis_int_flags {
TPM_GLOBAL_INT_ENABLE = 0x8000,
TPM_INTF_BURST_COUNT_STATIC = 0x100,
@@ -70,6 +75,7 @@ enum tis_defaults {
 #defineTPM_INT_STATUS(l)   (0x0010 | ((l) << 12))
 #defineTPM_INTF_CAPS(l)(0x0014 | ((l) << 12))
 #defineTPM_STS(l)  (0x0018 | ((l) << 12))
+#defineTPM_STS3(l) (0x001b | ((l) << 12))
 #defineTPM_DATA_FIFO(l)(0x0024 | ((l) << 12))
 
 #defineTPM_DID_VID(l)  (0x0F00 | ((l) << 12))
@@ -363,6 +369,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8 
*buf, size_t len)
 {
int rc;
u32 ordinal;
+   unsigned long dur;
 
rc = tpm_tis_send_data(chip, buf, len);
if (rc < 0)
@@ -374,9 +381,14 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8 
*buf, size_t len)
 
if (chip->vendor.irq) {
ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
+
+   if (chip->flags & TPM_CHIP_FLAG_TPM2)
+   dur = tpm2_calc_ordinal_duration(chip, ordinal);
+   else
+   dur = tpm_calc_ordinal_duration(chip, ordinal);
+
if (wait_for_tpm_stat
-   (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID,
-tpm_calc_ordinal_duration(chip, ordinal),
+   (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID, dur,
 >vendor.read_queue, false) < 0) {
rc = -ETIME;
goto out_err;
@@ -588,6 +600,7 @@ static int tpm_tis_init(struct device *dev, acpi_handle 
acpi_dev_handle,
int rc, i, irq_s, irq_e, probe;
struct tpm_chip *chip;
struct priv_data *priv;
+   u8 sts3;
 
priv = devm_kzalloc(dev, sizeof(struct priv_data), GFP_KERNEL);
if (priv == NULL)
@@ -604,11 +617,28 @@ static int tpm_tis_init(struct device *dev, acpi_handle 
acpi_dev_handle,
if (!chip->vendor.iobase)
return -EIO;
 
+   sts3 = ioread8(chip->vendor.iobase + TPM_STS3(1));
+   if ((sts3 & TPM_STS3_TPM2_FAM) == TPM_STS3_TPM2_FAM)
+   chip->flags = TPM_CHIP_FLAG_TPM2;
+
/* Default timeouts */
-   chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
-   chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
-   chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
-   chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+   if (chip->flags & TPM_CHIP_FLAG_TPM2) {
+   chip->vendor.timeout_a = usecs_to_jiffies(TPM2_TIMEOUT_A);
+   chip->vendor.timeout_b = usecs_to_jiffies(TPM2_TIMEOUT_B);
+   chip->vendor.timeout_c = usecs_to_jiffies(TPM2_TIMEOUT_C);
+   chip->vendor.timeout_d = usecs_to_jiffies(TPM2_TIMEOUT_D);
+   chip->vendor.duration[TPM_SHORT] =
+   usecs_to_jiffies(TPM2_DURATION_SHORT);
+   chip->vendor.duration[TPM_MEDIUM] =
+   usecs_to_jiffies(TPM2_DURATION_MEDIUM);
+   chip->vendor.duration[TPM_LONG] =
+   usecs_to_jiffies(TPM2_DURATION_LONG);
+   } else {
+   chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+   chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
+   chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+   chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+   }
 
if (wait_startup(chip, 0) != 0) {
rc = -ENODEV;
@@ -623,8 +653,8 @@ static int tpm_tis_init(struct device *dev, acpi_handle 
acpi_dev_handle,
vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0));
chip->vendor.manufacturer_id = vendor;
 
-   dev_info(dev,
-"1.2 TPM (device-id 0x%X, rev-id %d)\n",
+   dev_info(dev, "%s TPM (device-id 0x%X, rev-id %d)\n",
+(chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2",
 vendor >> 16, ioread8(chip->vendor.iobase + TPM_RID(0)));
 
  

[PATCH v8 4/8] tpm: rename chip->dev to chip->pdev

2014-12-03 Thread Jarkko Sakkinen
Rename chip->dev to chip->pdev to make it explicit that this not the
character device but actually represents the platform device.

Signed-off-by: Jarkko Sakkinen 
---
 drivers/char/tpm/tpm-chip.c |  4 ++--
 drivers/char/tpm/tpm-dev.c  | 10 +-
 drivers/char/tpm/tpm-interface.c| 29 +++--
 drivers/char/tpm/tpm-sysfs.c|  6 +++---
 drivers/char/tpm/tpm.h  |  4 ++--
 drivers/char/tpm/tpm_atmel.c| 14 +++---
 drivers/char/tpm/tpm_i2c_atmel.c| 16 
 drivers/char/tpm/tpm_i2c_infineon.c |  6 +++---
 drivers/char/tpm/tpm_i2c_nuvoton.c  | 22 +++---
 drivers/char/tpm/tpm_i2c_stm_st33.c | 14 +++---
 drivers/char/tpm/tpm_infineon.c | 22 +++---
 drivers/char/tpm/tpm_nsc.c  | 20 ++--
 drivers/char/tpm/tpm_ppi.c  |  4 ++--
 drivers/char/tpm/tpm_tis.c  | 14 +++---
 14 files changed, 93 insertions(+), 92 deletions(-)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index 543939b..c584161 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -45,7 +45,7 @@ struct tpm_chip *tpm_chip_find_get(int chip_num)
if (chip_num != TPM_ANY_NUM && chip_num != pos->dev_num)
continue;
 
-   if (try_module_get(pos->dev->driver->owner)) {
+   if (try_module_get(pos->pdev->driver->owner)) {
chip = pos;
break;
}
@@ -110,7 +110,7 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,
 
scnprintf(chip->devname, sizeof(chip->devname), "tpm%d", chip->dev_num);
 
-   chip->dev = dev;
+   chip->pdev = dev;
devm_add_action(dev, tpmm_chip_remove, chip);
dev_set_drvdata(dev, chip);
 
diff --git a/drivers/char/tpm/tpm-dev.c b/drivers/char/tpm/tpm-dev.c
index d9b774e..3568321 100644
--- a/drivers/char/tpm/tpm-dev.c
+++ b/drivers/char/tpm/tpm-dev.c
@@ -63,7 +63,7 @@ static int tpm_open(struct inode *inode, struct file *file)
 * by the check of is_open variable, which is protected
 * by driver_lock. */
if (test_and_set_bit(0, >is_open)) {
-   dev_dbg(chip->dev, "Another process owns this TPM\n");
+   dev_dbg(chip->pdev, "Another process owns this TPM\n");
return -EBUSY;
}
 
@@ -81,7 +81,7 @@ static int tpm_open(struct inode *inode, struct file *file)
INIT_WORK(>work, timeout_work);
 
file->private_data = priv;
-   get_device(chip->dev);
+   get_device(chip->pdev);
return 0;
 }
 
@@ -168,7 +168,7 @@ static int tpm_release(struct inode *inode, struct file 
*file)
file->private_data = NULL;
atomic_set(>data_pending, 0);
clear_bit(0, >chip->is_open);
-   put_device(priv->chip->dev);
+   put_device(priv->chip->pdev);
kfree(priv);
return 0;
 }
@@ -193,12 +193,12 @@ int tpm_dev_add_device(struct tpm_chip *chip)
chip->vendor.miscdev.minor = MISC_DYNAMIC_MINOR;
 
chip->vendor.miscdev.name = chip->devname;
-   chip->vendor.miscdev.parent = chip->dev;
+   chip->vendor.miscdev.parent = chip->pdev;
 
rc = misc_register(>vendor.miscdev);
if (rc) {
chip->vendor.miscdev.name = NULL;
-   dev_err(chip->dev,
+   dev_err(chip->pdev,
"unable to misc_register %s, minor %d err=%d\n",
chip->vendor.miscdev.name,
chip->vendor.miscdev.minor, rc);
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 4dbed1e..e2af28f 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -343,7 +343,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
if (count == 0)
return -ENODATA;
if (count > bufsiz) {
-   dev_err(chip->dev,
+   dev_err(chip->pdev,
"invalid count value %x %zx\n", count, bufsiz);
return -E2BIG;
}
@@ -352,7 +352,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
 
rc = chip->ops->send(chip, (u8 *) buf, count);
if (rc < 0) {
-   dev_err(chip->dev,
+   dev_err(chip->pdev,
"tpm_transmit: tpm_send: error %zd\n", rc);
goto out;
}
@@ -368,7 +368,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
goto out_recv;
 
if (chip->ops->req_canceled(chip, status)) {
-   dev_err(chip->dev, "Operation Canceled\n");
+   dev_err(chip->pdev, "Operation Canceled\n");
rc = -ECANCELED;
goto out;
}
@@ -378,14 +378,14 @@ ssize_t tpm_transmit(struct tpm_chip *chip, 

[PATCH v8 7/8] tpm: TPM 2.0 CRB Interface

2014-12-03 Thread Jarkko Sakkinen
tpm_crb is a driver for TPM 2.0 Command Response Buffer (CRB) Interface
as defined in PC Client Platform TPM Profile (PTP) Specification.

Only polling and single locality is supported as these are the limitations
of the available hardware, Platform Trust Techonlogy (PTT) in Haswell
CPUs.

The driver always applies CRB with ACPI start because PTT reports using
only ACPI start as start method but as a result of my testing it requires
also CRB start.

Signed-off-by: Jarkko Sakkinen 
---
 drivers/char/tpm/Kconfig   |   9 ++
 drivers/char/tpm/Makefile  |   1 +
 drivers/char/tpm/tpm_crb.c | 356 +
 3 files changed, 366 insertions(+)
 create mode 100644 drivers/char/tpm/tpm_crb.c

diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig
index 3d0873b..9d4e375 100644
--- a/drivers/char/tpm/Kconfig
+++ b/drivers/char/tpm/Kconfig
@@ -122,4 +122,13 @@ config TCG_XEN
  To compile this driver as a module, choose M here; the module
  will be called xen-tpmfront.
 
+config TCG_CRB
+   tristate "TPM 2.0 CRB Interface"
+   depends on X86 && ACPI
+   ---help---
+ If you have a TPM security chip that is compliant with the
+ TCG CRB 2.0 TPM specification say Yes and it will be accessible
+ from within Linux.  To compile this driver as a module, choose
+ M here; the module will be called tpm_crb.
+
 endif # TCG_TPM
diff --git a/drivers/char/tpm/Makefile b/drivers/char/tpm/Makefile
index 88848ed..990cf18 100644
--- a/drivers/char/tpm/Makefile
+++ b/drivers/char/tpm/Makefile
@@ -22,3 +22,4 @@ obj-$(CONFIG_TCG_INFINEON) += tpm_infineon.o
 obj-$(CONFIG_TCG_IBMVTPM) += tpm_ibmvtpm.o
 obj-$(CONFIG_TCG_TIS_I2C_ST33) += tpm_i2c_stm_st33.o
 obj-$(CONFIG_TCG_XEN) += xen-tpmfront.o
+obj-$(CONFIG_TCG_CRB) += tpm_crb.o
diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
new file mode 100644
index 000..eb78f93
--- /dev/null
+++ b/drivers/char/tpm/tpm_crb.c
@@ -0,0 +1,356 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * Authors:
+ * Jarkko Sakkinen 
+ *
+ * Maintained by: 
+ *
+ * This device driver implements the TPM interface as defined in
+ * the TCG CRB 2.0 TPM specification.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "tpm.h"
+
+#define ACPI_SIG_TPM2 "TPM2"
+
+static const u8 CRB_ACPI_START_UUID[] = {
+   /*  */ 0xAB, 0x6C, 0xBF, 0x6B, 0x63, 0x54, 0x14, 0x47,
+   /* 0008 */ 0xB7, 0xCD, 0xF0, 0x20, 0x3C, 0x03, 0x68, 0xD4
+};
+
+enum crb_defaults {
+   CRB_ACPI_START_REVISION_ID = 1,
+   CRB_ACPI_START_INDEX = 1,
+};
+
+enum crb_start_method {
+   CRB_SM_ACPI_START = 2,
+   CRB_SM_CRB = 7,
+   CRB_SM_CRB_WITH_ACPI_START = 8,
+};
+
+struct acpi_tpm2 {
+   struct acpi_table_header hdr;
+   u16 platform_class;
+   u16 reserved;
+   u64 control_area_pa;
+   u32 start_method;
+} __packed;
+
+enum crb_ca_request {
+   CRB_CA_REQ_GO_IDLE  = BIT(0),
+   CRB_CA_REQ_CMD_READY= BIT(1),
+};
+
+enum crb_ca_status {
+   CRB_CA_STS_ERROR= BIT(0),
+   CRB_CA_STS_TPM_IDLE = BIT(1),
+};
+
+enum crb_start {
+   CRB_START_INVOKE= BIT(0),
+};
+
+enum crb_cancel {
+   CRB_CANCEL_INVOKE   = BIT(0),
+};
+
+struct crb_control_area {
+   u32 req;
+   u32 sts;
+   u32 cancel;
+   u32 start;
+   u32 int_enable;
+   u32 int_sts;
+   u32 cmd_size;
+   u64 cmd_pa;
+   u32 rsp_size;
+   u64 rsp_pa;
+} __packed;
+
+enum crb_status {
+   CRB_STS_COMPLETE= BIT(0),
+};
+
+enum crb_flags {
+   CRB_FL_ACPI_START   = BIT(0),
+   CRB_FL_CRB_START= BIT(1),
+};
+
+struct crb_priv {
+   unsigned int flags;
+   struct crb_control_area *cca;
+   u8 *cmd;
+   u8 *rsp;
+};
+
+#ifdef CONFIG_PM_SLEEP
+int crb_suspend(struct device *dev)
+{
+   return 0;
+}
+
+static int crb_resume(struct device *dev)
+{
+   struct tpm_chip *chip = dev_get_drvdata(dev);
+
+   (void) tpm2_do_selftest(chip);
+
+   return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(crb_pm, crb_suspend, crb_resume);
+
+static u8 crb_status(struct tpm_chip *chip)
+{
+   struct crb_priv *priv = chip->vendor.priv;
+   u8 sts = 0;
+
+   if ((le32_to_cpu(ioread32(>cca->start)) & CRB_START_INVOKE) !=
+   CRB_START_INVOKE)
+   sts |= CRB_STS_COMPLETE;
+
+   return sts;
+}
+
+static int crb_recv(struct tpm_chip *chip, u8 *buf, size_t count)
+{
+   struct crb_priv *priv = chip->vendor.priv;
+   unsigned int expected;
+
+   /* sanity check */
+   if (count < 6)
+   return -EIO;
+
+   if (le32_to_cpu(ioread32(>cca->sts)) & CRB_CA_STS_ERROR)
+   return -EIO;
+
+   

[PATCH v8 1/8] tpm: merge duplicate transmit_cmd() functions

2014-12-03 Thread Jarkko Sakkinen
Merged transmit_cmd() functions in tpm-interface.c and tpm-sysfs.c.
Added "tpm_" prefix for consistency sake. Changed cmd parameter as
opaque. This enables to use separate command structures for TPM1
and TPM2 commands in future. Loose coupling works fine here.

Signed-off-by: Jarkko Sakkinen 
---
 drivers/char/tpm/tpm-interface.c | 49 +---
 drivers/char/tpm/tpm-sysfs.c | 23 ++-
 drivers/char/tpm/tpm.h   |  3 ++-
 3 files changed, 30 insertions(+), 45 deletions(-)

diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index cfb9089..c17aa45 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -398,9 +398,10 @@ out:
 #define TPM_DIGEST_SIZE 20
 #define TPM_RET_CODE_IDX 6
 
-static ssize_t transmit_cmd(struct tpm_chip *chip, struct tpm_cmd_t *cmd,
-   int len, const char *desc)
+ssize_t tpm_transmit_cmd(struct tpm_chip *chip, void *cmd,
+int len, const char *desc)
 {
+   struct tpm_output_header *header;
int err;
 
len = tpm_transmit(chip, (u8 *) cmd, len);
@@ -409,7 +410,9 @@ static ssize_t transmit_cmd(struct tpm_chip *chip, struct 
tpm_cmd_t *cmd,
else if (len < TPM_HEADER_SIZE)
return -EFAULT;
 
-   err = be32_to_cpu(cmd->header.out.return_code);
+   header = cmd;
+
+   err = be32_to_cpu(header->return_code);
if (err != 0 && desc)
dev_err(chip->dev, "A TPM error (%d) occurred %s\n", err, desc);
 
@@ -448,7 +451,7 @@ ssize_t tpm_getcap(struct device *dev, __be32 subcap_id, 
cap_t *cap,
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
tpm_cmd.params.getcap_in.subcap = subcap_id;
}
-   rc = transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE, desc);
+   rc = tpm_transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE, desc);
if (!rc)
*cap = tpm_cmd.params.getcap_out.cap;
return rc;
@@ -464,8 +467,8 @@ void tpm_gen_interrupt(struct tpm_chip *chip)
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
 
-   rc = transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
-   "attempting to determine the timeouts");
+   rc = tpm_transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
+ "attempting to determine the timeouts");
 }
 EXPORT_SYMBOL_GPL(tpm_gen_interrupt);
 
@@ -484,8 +487,8 @@ static int tpm_startup(struct tpm_chip *chip, __be16 
startup_type)
struct tpm_cmd_t start_cmd;
start_cmd.header.in = tpm_startup_header;
start_cmd.params.startup_in.startup_type = startup_type;
-   return transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
-   "attempting to start the TPM");
+   return tpm_transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
+   "attempting to start the TPM");
 }
 
 int tpm_get_timeouts(struct tpm_chip *chip)
@@ -500,7 +503,7 @@ int tpm_get_timeouts(struct tpm_chip *chip)
tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
-   rc = transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE, NULL);
+   rc = tpm_transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE, NULL);
 
if (rc == TPM_ERR_INVALID_POSTINIT) {
/* The TPM is not started, we are the first to talk to it.
@@ -513,7 +516,7 @@ int tpm_get_timeouts(struct tpm_chip *chip)
tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
-   rc = transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
+   rc = tpm_transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
  NULL);
}
if (rc) {
@@ -575,8 +578,8 @@ duration:
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_DURATION;
 
-   rc = transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
-   "attempting to determine the durations");
+   rc = tpm_transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
+ "attempting to determine the durations");
if (rc)
return rc;
 
@@ -631,8 +634,8 @@ static int tpm_continue_selftest(struct tpm_chip *chip)
struct tpm_cmd_t cmd;
 
cmd.header.in = continue_selftest_header;
-   rc = transmit_cmd(chip, , CONTINUE_SELFTEST_RESULT_SIZE,
- "continue selftest");
+   rc = tpm_transmit_cmd(chip, , CONTINUE_SELFTEST_RESULT_SIZE,
+ "continue selftest");
return rc;
 

[PATCH v8 2/8] tpm: two-phase chip management functions

2014-12-03 Thread Jarkko Sakkinen
tpm_register_hardware() and tpm_remove_hardware() are called often
before initializing the device. The problem is that the device might
not be fully initialized when it comes visible to the user space.

This patch resolves the issue by diving initialization into two
parts:

- tpmm_chip_alloc() creates struct tpm_chip.

- tpm_chip_register() sets up the character device and sysfs
  attributes.

The framework takes care of freeing struct tpm_chip by using the devres
API. The broken release callback has been wiped. ACPI drivers do not
ever get this callback.

Regards to Jason Gunthorpe for carefully reviewing this part of the
code.

Signed-off-by: Jarkko Sakkinen 
---
 drivers/char/tpm/Makefile   |   2 +-
 drivers/char/tpm/tpm-chip.c | 194 
 drivers/char/tpm/tpm-interface.c| 148 +--
 drivers/char/tpm/tpm.h  |  11 +-
 drivers/char/tpm/tpm_atmel.c|  11 +-
 drivers/char/tpm/tpm_i2c_atmel.c|  39 ++--
 drivers/char/tpm/tpm_i2c_infineon.c |  37 ++-
 drivers/char/tpm/tpm_i2c_nuvoton.c  |  47 +++--
 drivers/char/tpm/tpm_i2c_stm_st33.c |  14 +--
 drivers/char/tpm/tpm_ibmvtpm.c  |  17 ++--
 drivers/char/tpm/tpm_infineon.c |  29 +++---
 drivers/char/tpm/tpm_nsc.c  |  14 ++-
 drivers/char/tpm/tpm_tis.c  |  80 ++-
 drivers/char/tpm/xen-tpmfront.c |  14 +--
 14 files changed, 319 insertions(+), 338 deletions(-)
 create mode 100644 drivers/char/tpm/tpm-chip.c

diff --git a/drivers/char/tpm/Makefile b/drivers/char/tpm/Makefile
index 7f54dae..c715596 100644
--- a/drivers/char/tpm/Makefile
+++ b/drivers/char/tpm/Makefile
@@ -2,7 +2,7 @@
 # Makefile for the kernel tpm device drivers.
 #
 obj-$(CONFIG_TCG_TPM) += tpm.o
-tpm-y := tpm-interface.o tpm-dev.o tpm-sysfs.o
+tpm-y := tpm-interface.o tpm-dev.o tpm-sysfs.o tpm-chip.o
 tpm-$(CONFIG_ACPI) += tpm_ppi.o
 
 ifdef CONFIG_ACPI
diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
new file mode 100644
index 000..35aca12
--- /dev/null
+++ b/drivers/char/tpm/tpm-chip.c
@@ -0,0 +1,194 @@
+/*
+ * Copyright (C) 2004 IBM Corporation
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * Authors:
+ * Jarkko Sakkinen 
+ * Leendert van Doorn 
+ * Dave Safford 
+ * Reiner Sailer 
+ * Kylene Hall 
+ *
+ * Maintained by: 
+ *
+ * TPM chip management routines.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, version 2 of the
+ * License.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "tpm.h"
+#include "tpm_eventlog.h"
+
+static DECLARE_BITMAP(dev_mask, TPM_NUM_DEVICES);
+static LIST_HEAD(tpm_chip_list);
+static DEFINE_SPINLOCK(driver_lock);
+
+/*
+ * tpm_chip_find_get - return tpm_chip for a given chip number
+ * @chip_num the device number for the chip
+ */
+struct tpm_chip *tpm_chip_find_get(int chip_num)
+{
+   struct tpm_chip *pos, *chip = NULL;
+
+   rcu_read_lock();
+   list_for_each_entry_rcu(pos, _chip_list, list) {
+   if (chip_num != TPM_ANY_NUM && chip_num != pos->dev_num)
+   continue;
+
+   if (try_module_get(pos->dev->driver->owner)) {
+   chip = pos;
+   break;
+   }
+   }
+   rcu_read_unlock();
+   return chip;
+}
+
+/**
+ * tpmm_chip_remove() - free chip memory and device number
+ * @data: points to struct tpm_chip instance
+ *
+ * This is used internally by tpmm_chip_alloc() and called by devres
+ * when the device is released. This function does the opposite of
+ * tpmm_chip_alloc() freeing memory and the device number.
+ */
+static void tpmm_chip_remove(void *data)
+{
+   struct tpm_chip *chip = (struct tpm_chip *) data;
+
+   spin_lock(_lock);
+   clear_bit(chip->dev_num, dev_mask);
+   spin_unlock(_lock);
+   kfree(chip);
+}
+
+/**
+ * tpmm_chip_alloc() - allocate a new struct tpm_chip instance
+ * @dev: device to which the chip is associated
+ * @ops: struct tpm_class_ops instance
+ *
+ * Allocates a new struct tpm_chip instance and assigns a free
+ * device number for it. Caller does not have to worry about
+ * freeing the allocated resources. When the devices is removed
+ * devres calls tpmm_chip_remove() to do the job.
+ */
+struct tpm_chip *tpmm_chip_alloc(struct device *dev,
+const struct tpm_class_ops *ops)
+{
+   struct tpm_chip *chip;
+
+   chip = kzalloc(sizeof(*chip), GFP_KERNEL);
+   if (chip == NULL)
+   return ERR_PTR(-ENOMEM);
+
+   mutex_init(>tpm_mutex);
+   INIT_LIST_HEAD(>list);
+
+   chip->ops = ops;
+
+   spin_lock(_lock);
+   chip->dev_num = find_first_zero_bit(dev_mask, TPM_NUM_DEVICES);
+   spin_unlock(_lock);
+
+   if (chip->dev_num >= TPM_NUM_DEVICES) {
+   dev_err(dev, "No available 

[PATCH v8 3/8] tpm: fix raciness of PPI interface lookup

2014-12-03 Thread Jarkko Sakkinen
Traversal of the ACPI device tree was not done right. PPI interface
should be looked up only from the ACPI device that is the platform
device for the TPM. This could cause problems with systems with
two TPM chips such as 4th gen Intel systems.

In addition, added the missing license and copyright platter to
the tpm_ppi.c.

Signed-off-by: Jarkko Sakkinen 
---
 drivers/char/tpm/tpm-chip.c |   2 +-
 drivers/char/tpm/tpm.h  |  16 --
 drivers/char/tpm/tpm_ppi.c  | 137 +++-
 drivers/char/tpm/tpm_tis.c  |  14 +++--
 4 files changed, 106 insertions(+), 63 deletions(-)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index 35aca12..543939b 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -147,7 +147,7 @@ int tpm_chip_register(struct tpm_chip *chip)
if (rc)
goto del_misc;
 
-   rc = tpm_add_ppi(>dev->kobj);
+   rc = tpm_add_ppi(chip);
if (rc)
goto del_sysfs;
 
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 9880681..69f4003 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 enum tpm_const {
TPM_MINOR = 224,/* officially assigned */
@@ -94,6 +95,8 @@ struct tpm_vendor_specific {
 #define TPM_VID_WINBOND  0x1050
 #define TPM_VID_STM  0x104A
 
+#define TPM_PPI_VERSION_LEN3
+
 struct tpm_chip {
struct device *dev; /* Device stuff */
const struct tpm_class_ops *ops;
@@ -109,6 +112,11 @@ struct tpm_chip {
 
struct dentry **bios_dir;
 
+#ifdef CONFIG_ACPI
+   acpi_handle acpi_dev_handle;
+   char ppi_version[TPM_PPI_VERSION_LEN + 1];
+#endif /* CONFIG_ACPI */
+
struct list_head list;
 };
 
@@ -340,15 +348,15 @@ void tpm_sysfs_del_device(struct tpm_chip *chip);
 int tpm_pcr_read_dev(struct tpm_chip *chip, int pcr_idx, u8 *res_buf);
 
 #ifdef CONFIG_ACPI
-extern int tpm_add_ppi(struct kobject *);
-extern void tpm_remove_ppi(struct kobject *);
+extern int tpm_add_ppi(struct tpm_chip *chip);
+extern void tpm_remove_ppi(struct tpm_chip *chip);
 #else
-static inline int tpm_add_ppi(struct kobject *parent)
+static inline int tpm_add_ppi(struct tpm_chip *chip)
 {
return 0;
 }
 
-static inline void tpm_remove_ppi(struct kobject *parent)
+static inline void tpm_remove_ppi(struct tpm_chip *chip)
 {
 }
 #endif
diff --git a/drivers/char/tpm/tpm_ppi.c b/drivers/char/tpm/tpm_ppi.c
index 61dcc80..6652025 100644
--- a/drivers/char/tpm/tpm_ppi.c
+++ b/drivers/char/tpm/tpm_ppi.c
@@ -1,3 +1,22 @@
+/*
+ * Copyright (C) 2012-2014 Intel Corporation
+ *
+ * Authors:
+ * Xiaoyan Zhang 
+ * Jiang Liu 
+ * Jarkko Sakkinen 
+ *
+ * Maintained by: 
+ *
+ * This file contains implementation of the sysfs interface for PPI.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ */
+
+
 #include 
 #include "tpm.h"
 
@@ -12,7 +31,6 @@
 #define PPI_TPM_REQ_MAX22
 #define PPI_VS_REQ_START   128
 #define PPI_VS_REQ_END 255
-#define PPI_VERSION_LEN3
 
 static const u8 tpm_ppi_uuid[] = {
0xA6, 0xFA, 0xDD, 0x3D,
@@ -22,45 +40,22 @@ static const u8 tpm_ppi_uuid[] = {
0x8D, 0x10, 0x08, 0x9D, 0x16, 0x53
 };
 
-static char tpm_ppi_version[PPI_VERSION_LEN + 1];
-static acpi_handle tpm_ppi_handle;
-
-static acpi_status ppi_callback(acpi_handle handle, u32 level, void *context,
-   void **return_value)
-{
-   union acpi_object *obj;
-
-   if (!acpi_check_dsm(handle, tpm_ppi_uuid, TPM_PPI_REVISION_ID,
-   1 << TPM_PPI_FN_VERSION))
-   return AE_OK;
-
-   /* Cache version string */
-   obj = acpi_evaluate_dsm_typed(handle, tpm_ppi_uuid,
- TPM_PPI_REVISION_ID, TPM_PPI_FN_VERSION,
- NULL, ACPI_TYPE_STRING);
-   if (obj) {
-   strlcpy(tpm_ppi_version, obj->string.pointer,
-   PPI_VERSION_LEN + 1);
-   ACPI_FREE(obj);
-   }
-
-   *return_value = handle;
-
-   return AE_CTRL_TERMINATE;
-}
-
 static inline union acpi_object *
-tpm_eval_dsm(int func, acpi_object_type type, union acpi_object *argv4)
+tpm_eval_dsm(acpi_handle ppi_handle, int func, acpi_object_type type,
+union acpi_object *argv4)
 {
-   BUG_ON(!tpm_ppi_handle);
-   return acpi_evaluate_dsm_typed(tpm_ppi_handle, tpm_ppi_uuid,
-  TPM_PPI_REVISION_ID, func, argv4, type);
+   BUG_ON(!ppi_handle);
+   return acpi_evaluate_dsm_typed(ppi_handle, tpm_ppi_uuid,
+  TPM_PPI_REVISION_ID,
+  func, argv4, type);
 }
 
 static ssize_t 

[PATCH v8 6/8] tpm: TPM 2.0 baseline support

2014-12-03 Thread Jarkko Sakkinen
TPM 2.0 devices are separated by adding a field 'flags' to struct
tpm_chip and defining a flag TPM_CHIP_FLAG_TPM2 for tagging them.

This patch adds the following internal functions:

- tpm2_get_random()
- tpm2_get_tpm_pt()
- tpm2_pcr_extend()
- tpm2_pcr_read()
- tpm2_startup()

Additionally, the following exported functions are implemented for
implementing TPM 2.0 device drivers:

- tpm2_do_selftest()
- tpm2_calc_ordinal_durations()
- tpm2_gen_interrupt()

The existing functions that are exported for the use for existing
subsystems have been changed to check the flags field in struct
tpm_chip and use appropriate TPM 2.0 counterpart if
TPM_CHIP_FLAG_TPM2 is est.

The code for tpm2_calc_ordinal_duration() and tpm2_startup() were
originally written by Will Arthur.

Signed-off-by: Jarkko Sakkinen 
Signed-off-by: Will Arthur 
---
 drivers/char/tpm/Makefile|   2 +-
 drivers/char/tpm/tpm-chip.c  |  27 +-
 drivers/char/tpm/tpm-interface.c |  24 +-
 drivers/char/tpm/tpm.h   |  61 +
 drivers/char/tpm/tpm2-cmd.c  | 542 +++
 5 files changed, 641 insertions(+), 15 deletions(-)
 create mode 100644 drivers/char/tpm/tpm2-cmd.c

diff --git a/drivers/char/tpm/Makefile b/drivers/char/tpm/Makefile
index c715596..88848ed 100644
--- a/drivers/char/tpm/Makefile
+++ b/drivers/char/tpm/Makefile
@@ -2,7 +2,7 @@
 # Makefile for the kernel tpm device drivers.
 #
 obj-$(CONFIG_TCG_TPM) += tpm.o
-tpm-y := tpm-interface.o tpm-dev.o tpm-sysfs.o tpm-chip.o
+tpm-y := tpm-interface.o tpm-dev.o tpm-sysfs.o tpm-chip.o tpm2-cmd.o
 tpm-$(CONFIG_ACPI) += tpm_ppi.o
 
 ifdef CONFIG_ACPI
diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index 7741e28..3f3f2de 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -195,15 +195,18 @@ int tpm_chip_register(struct tpm_chip *chip)
if (rc)
return rc;
 
-   rc = tpm_sysfs_add_device(chip);
-   if (rc)
-   goto del_misc;
+   /* Populate sysfs for TPM1 devices. */
+   if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) {
+   rc = tpm_sysfs_add_device(chip);
+   if (rc)
+   goto del_misc;
 
-   rc = tpm_add_ppi(chip);
-   if (rc)
-   goto del_sysfs;
+   rc = tpm_add_ppi(chip);
+   if (rc)
+   goto del_sysfs;
 
-   chip->bios_dir = tpm_bios_log_setup(chip->devname);
+   chip->bios_dir = tpm_bios_log_setup(chip->devname);
+   }
 
/* Make the chip available. */
spin_lock(_lock);
@@ -236,10 +239,12 @@ void tpm_chip_unregister(struct tpm_chip *chip)
spin_unlock(_lock);
synchronize_rcu();
 
-   if (chip->bios_dir)
-   tpm_bios_log_teardown(chip->bios_dir);
-   tpm_remove_ppi(chip);
-   tpm_sysfs_del_device(chip);
+   if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) {
+   if (chip->bios_dir)
+   tpm_bios_log_teardown(chip->bios_dir);
+   tpm_remove_ppi(chip);
+   tpm_sysfs_del_device(chip);
+   }
 
tpm_dev_del_device(chip);
 }
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index b6f6b17..8a14887 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -360,7 +360,10 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char 
*buf,
if (chip->vendor.irq)
goto out_recv;
 
-   stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal);
+   if (chip->flags & TPM_CHIP_FLAG_TPM2)
+   stop = jiffies + tpm2_calc_ordinal_duration(chip, ordinal);
+   else
+   stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal);
do {
u8 status = chip->ops->status(chip);
if ((status & chip->ops->req_complete_mask) ==
@@ -483,7 +486,7 @@ static const struct tpm_input_header tpm_startup_header = {
 static int tpm_startup(struct tpm_chip *chip, __be16 startup_type)
 {
struct tpm_cmd_t start_cmd;
-   start_cmd.header.in = tpm_startup_header;
+
start_cmd.params.startup_in.startup_type = startup_type;
return tpm_transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
"attempting to start the TPM");
@@ -680,7 +683,10 @@ int tpm_pcr_read(u32 chip_num, int pcr_idx, u8 *res_buf)
chip = tpm_chip_find_get(chip_num);
if (chip == NULL)
return -ENODEV;
-   rc = tpm_pcr_read_dev(chip, pcr_idx, res_buf);
+   if (chip->flags & TPM_CHIP_FLAG_TPM2)
+   rc = tpm2_pcr_read(chip, pcr_idx, res_buf);
+   else
+   rc = tpm_pcr_read_dev(chip, pcr_idx, res_buf);
tpm_chip_put(chip);
return rc;
 }
@@ -714,6 +720,12 @@ int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 
*hash)
if (chip == NULL)
return -ENODEV;
 
+   if (chip->flags & 

[PATCH v8 5/8] tpm: device class for tpm

2014-12-03 Thread Jarkko Sakkinen
Added own device class for TPM. Uses MISC_MAJOR:TPM_MINOR for the
first character device in order to retain backwards compatibility.
Added tpm_dev_release() back attached to the character device.

Signed-off-by: Jarkko Sakkinen 
---
 drivers/char/tpm/tpm-chip.c| 72 --
 drivers/char/tpm/tpm-dev.c | 36 ++-
 drivers/char/tpm/tpm-interface.c   | 29 +++
 drivers/char/tpm/tpm.h | 12 ---
 drivers/char/tpm/tpm_i2c_nuvoton.c |  2 +-
 drivers/char/tpm/tpm_tis.c |  4 +--
 6 files changed, 105 insertions(+), 50 deletions(-)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index c584161..7741e28 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "tpm.h"
 #include "tpm_eventlog.h"
 
@@ -32,6 +33,9 @@ static DECLARE_BITMAP(dev_mask, TPM_NUM_DEVICES);
 static LIST_HEAD(tpm_chip_list);
 static DEFINE_SPINLOCK(driver_lock);
 
+struct class *tpm_class;
+dev_t tpm_devt;
+
 /*
  * tpm_chip_find_get - return tpm_chip for a given chip number
  * @chip_num the device number for the chip
@@ -55,16 +59,14 @@ struct tpm_chip *tpm_chip_find_get(int chip_num)
 }
 
 /**
- * tpmm_chip_remove() - free chip memory and device number
- * @data: points to struct tpm_chip instance
+ * tpm_dev_release() - free chip memory and the device number
+ * @dev: the character device for the TPM chip
  *
- * This is used internally by tpmm_chip_alloc() and called by devres
- * when the device is released. This function does the opposite of
- * tpmm_chip_alloc() freeing memory and the device number.
+ * This is used as the release function for the character device.
  */
-static void tpmm_chip_remove(void *data)
+static void tpm_dev_release(struct device *dev)
 {
-   struct tpm_chip *chip = (struct tpm_chip *) data;
+   struct tpm_chip *chip = container_of(dev, struct tpm_chip, dev);
 
spin_lock(_lock);
clear_bit(chip->dev_num, dev_mask);
@@ -111,18 +113,68 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,
scnprintf(chip->devname, sizeof(chip->devname), "tpm%d", chip->dev_num);
 
chip->pdev = dev;
-   devm_add_action(dev, tpmm_chip_remove, chip);
+
dev_set_drvdata(dev, chip);
 
+   chip->dev.class = tpm_class;
+   chip->dev.release = tpm_dev_release;
+   chip->dev.parent = chip->pdev;
+
+   if (chip->dev_num == 0)
+   chip->dev.devt = MKDEV(MISC_MAJOR, TPM_MINOR);
+   else
+   chip->dev.devt = MKDEV(MAJOR(tpm_devt), chip->dev_num);
+
+   dev_set_name(>dev, chip->devname);
+
+   device_initialize(>dev);
+
+   chip->cdev.owner = chip->pdev->driver->owner;
+   cdev_init(>cdev, _fops);
+
return chip;
 }
 EXPORT_SYMBOL_GPL(tpmm_chip_alloc);
 
+static int tpm_dev_add_device(struct tpm_chip *chip)
+{
+   int rc;
+
+   rc = device_add(>dev);
+   if (rc) {
+   dev_err(>dev,
+   "unable to device_register() %s, major %d, minor %d, 
err=%d\n",
+   chip->devname, MAJOR(chip->dev.devt),
+   MINOR(chip->dev.devt), rc);
+
+   return rc;
+   }
+
+   rc = cdev_add(>cdev, chip->dev.devt, 1);
+   if (rc) {
+   dev_err(>dev,
+   "unable to cdev_add() %s, major %d, minor %d, err=%d\n",
+   chip->devname, MAJOR(chip->dev.devt),
+   MINOR(chip->dev.devt), rc);
+
+   device_unregister(>dev);
+   return rc;
+   }
+
+   return rc;
+}
+
+static void tpm_dev_del_device(struct tpm_chip *chip)
+{
+   cdev_del(>cdev);
+   device_unregister(>dev);
+}
+
 /*
- * tpm_chip_register() - create a misc driver for the TPM chip
+ * tpm_chip_register() - create a character device for the TPM chip
  * @chip: TPM chip to use.
  *
- * Creates a misc driver for the TPM chip and adds sysfs interfaces for
+ * Creates a character device for the TPM chip and adds sysfs interfaces for
  * the device, PPI and TCPA. As the last step this function adds the
  * chip to the list of TPM chips available for use.
  *
diff --git a/drivers/char/tpm/tpm-dev.c b/drivers/char/tpm/tpm-dev.c
index 3568321..de0337e 100644
--- a/drivers/char/tpm/tpm-dev.c
+++ b/drivers/char/tpm/tpm-dev.c
@@ -17,7 +17,6 @@
  * License.
  *
  */
-#include 
 #include 
 #include 
 #include "tpm.h"
@@ -54,9 +53,8 @@ static void timeout_work(struct work_struct *work)
 
 static int tpm_open(struct inode *inode, struct file *file)
 {
-   struct miscdevice *misc = file->private_data;
-   struct tpm_chip *chip = container_of(misc, struct tpm_chip,
-vendor.miscdev);
+   struct tpm_chip *chip =
+   container_of(inode->i_cdev, struct tpm_chip, cdev);
struct file_priv *priv;
 
/* It's assured that the chip will 

Re: frequent lockups in 3.18rc4

2014-12-03 Thread Linus Torvalds
On Wed, Dec 3, 2014 at 7:15 PM, Chris Mason  wrote:
>
> One guess is that trinity is generating a huge number of tlb
> invalidations over sparse and horrible ranges.  Perhaps the old code was
> falling back to full tlb flushes before Dave Hansen's string of fixes?

Hmm. I agree that we've had some of the backtraces look like TLB
flushing might be involved. Not all, though. And I'm not seeing where
a loop over up to 33 pages should matter over doing a full TLB flush.

What *might* matter is if we somehow get that number wrong, and the loops like

addr = f->flush_start;
while (addr < f->flush_end) {
__flush_tlb_single(addr);
addr += PAGE_SIZE;
}

ends up looping a *lot* due to some bug, and then the IPI itself would
take so long that the watchdog could trigger.

But I do not see how that could actually happen. As far as I can tell,
either the number of pages is limited to less than 33, or we have that
 TLB_FLUSH_ALL case.

Do  you see something I don't?

  Linus
--
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 v9 0/8] TPM 2.0 support

2014-12-03 Thread Jarkko Sakkinen
This patch set enables TPM2 protocol and provides drivers for FIFO and
CRB interfaces. This patch set does not export any sysfs attributes for
TPM 2.0 because existing sysfs attributes have three non-trivial issues:

- They are associated with the platform device instead of character
  device.
- They are are not trivial key-value pairs but contain text that is
  not easily parsed by a computer.
- Raciness as described in
  http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly/

This is too big effort to be included into this patch set and requires
more discussion.

v2:
- Improved struct tpm_chip life-cycle by taking advantage of devres
  API.
- Refined sysfs attributes as simple key-values thereby not repeating
  mistakes in TPM1 sysfs attributes.
- Documented functions in tpm-chip.c and tpm2-cmd.c.
- Documented sysfs attributes.

v3:
- Lots of fixes in calling order in device drivers (thanks to Jason
  Gunthorpe for pointing these out!).
- Attach sysfs attributes to the misc device because it represents
  TPM device to the user space.

v4:
- Disable sysfs attibutes for TPM 2.0 for until we can sort out the 
  best approach for them.
- Fixed all the style issues found with checkpatch.pl.

v5:
- missing EXPORT_SYMBOL_GPL()
- own class for TPM devices used for TPM 2.0 devices and onwards.

v6:
- Non-racy initialization for sysfs attributes using struct device's
  groups field.
- The class 'tpm' is used now for all TPM devices. For the first device
  node major MISC_MAJOR and minor TPM_MINOR is used in order to retain
  backwards compatability.

v7:
- Release device number and free struct tpm_chip memory inside
  tpm_dev_release callback.
- Moved code from tpm-interface.c and tpm_dev.c to tpm-chip.c.

v8:
- Cleaned up unneeded cast from tpm_transmit_cmd().
- Cleaned up redundant PPI_VERSION_LEN constant from tpm_ppi.c.
- Fixed tpm_tis to use tpm2_calc_ordinal_duration() for TPM2 devices.
- tpm_crb: in crb_recv, check that count can hold the TPM header at
  minimum.
- tpm_crb: add enumerations for bit flags in start and cancel fields
  of the control area.
- tpm_crb: use ioremap() for command and response buffer because
  they might be anywhere.
- tpm_crb: use IO access functions for reading ioremapped buffers
  because using direct pointers is not portable.
- tpm_crb: only apply ACPI start if start method reported by the
  TPM2 ACPI table allows it.
- In tpm2_pcr_read() just calculate index and bit and get rid of
  hacky loop.
- Do not add sysfs attributes for TPM 2.0 devices.

v9:
- Fixed compilation issues in v8 (sorry for not using the correct
  tree).
- Just do "return tpm_chip_register();" instead of copying return
  value to a variable.
- Removed unused tpm2_startup().
- In the CRB driver ACPI TPM2 table could contain platform specific
  and therefore inequality test does not work. Changed check whether
  buffer size is less than mandatory fields in the ACPI TPM2 table.

Jarkko Sakkinen (7):
  tpm: merge duplicate transmit_cmd() functions
  tpm: two-phase chip management functions
  tpm: fix raciness of PPI interface lookup
  tpm: rename chip->dev to chip->pdev
  tpm: device class for tpm
  tpm: TPM 2.0 baseline support
  tpm: TPM 2.0 CRB Interface

Will Arthur (1):
  tpm: TPM 2.0 FIFO Interface

 drivers/char/tpm/Kconfig|   9 +
 drivers/char/tpm/Makefile   |   3 +-
 drivers/char/tpm/tpm-chip.c | 251 +
 drivers/char/tpm/tpm-dev.c  |  42 +--
 drivers/char/tpm/tpm-interface.c| 261 ++---
 drivers/char/tpm/tpm-sysfs.c|  29 +-
 drivers/char/tpm/tpm.h  | 107 +--
 drivers/char/tpm/tpm2-cmd.c | 542 
 drivers/char/tpm/tpm_atmel.c|  25 +-
 drivers/char/tpm/tpm_crb.c  | 356 +++
 drivers/char/tpm/tpm_i2c_atmel.c|  55 ++--
 drivers/char/tpm/tpm_i2c_infineon.c |  43 +--
 drivers/char/tpm/tpm_i2c_nuvoton.c  |  71 ++---
 drivers/char/tpm/tpm_i2c_stm_st33.c |  28 +-
 drivers/char/tpm/tpm_ibmvtpm.c  |  17 +-
 drivers/char/tpm/tpm_infineon.c |  51 ++--
 drivers/char/tpm/tpm_nsc.c  |  34 ++-
 drivers/char/tpm/tpm_ppi.c  | 137 +
 drivers/char/tpm/tpm_tis.c  | 192 -
 drivers/char/tpm/xen-tpmfront.c |  14 +-
 20 files changed, 1689 insertions(+), 578 deletions(-)
 create mode 100644 drivers/char/tpm/tpm-chip.c
 create mode 100644 drivers/char/tpm/tpm2-cmd.c
 create mode 100644 drivers/char/tpm/tpm_crb.c

-- 
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 v12 3/7] ARM: kprobes: collects stack consumption for store instructions

2014-12-03 Thread Wang Nan
This patch uses the previously introduced checker functionality on
store instructions to record their stack consumption information to
arch_probes_insn.

Signed-off-by: Wang Nan 
Signed-off-by: Jon Medhurst 
Reviewed-by: Jon Medhurst 

---
v1 -> v2:
 - Bugfix and code improvements following Tixy's suggestion. See:
   http://www.spinics.net/lists/arm-kernel/msg372912.html

v2 -> v3:
 - Totaly reconstructed following Tixy' instruction. See:
   https://lkml.org/lkml/2014/10/27/662 .
   Add his SOB.

v3 -> v4:
 - Commit message improvements.
 - Comments improvements and code cleanup.
 - A bug is found and fixed in decode table in arm_check_stack().

v4 -> v5:
 - Bugs in thumb2 decoding table is found by Tixy and fixed.

v5 -> v6:
 - Move to arch/arm/probes/ .
---
 arch/arm/include/asm/probes.h |   1 +
 arch/arm/probes/decode.c  |  10 +++
 arch/arm/probes/kprobes/Makefile  |   6 +-
 arch/arm/probes/kprobes/actions-arm.c |   3 +-
 arch/arm/probes/kprobes/actions-thumb.c   |   5 +-
 arch/arm/probes/kprobes/checkers-arm.c|  99 +++
 arch/arm/probes/kprobes/checkers-common.c | 101 +++
 arch/arm/probes/kprobes/checkers-thumb.c  | 110 ++
 arch/arm/probes/kprobes/checkers.h|  54 +++
 9 files changed, 383 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/probes/kprobes/checkers-arm.c
 create mode 100644 arch/arm/probes/kprobes/checkers-common.c
 create mode 100644 arch/arm/probes/kprobes/checkers-thumb.c
 create mode 100644 arch/arm/probes/kprobes/checkers.h

diff --git a/arch/arm/include/asm/probes.h b/arch/arm/include/asm/probes.h
index 806cfe6..ccf9af3 100644
--- a/arch/arm/include/asm/probes.h
+++ b/arch/arm/include/asm/probes.h
@@ -38,6 +38,7 @@ struct arch_probes_insn {
probes_check_cc *insn_check_cc;
probes_insn_singlestep_t*insn_singlestep;
probes_insn_fn_t*insn_fn;
+   int stack_space;
 };
 
 #endif
diff --git a/arch/arm/probes/decode.c b/arch/arm/probes/decode.c
index c7d4420..f9d7c42 100644
--- a/arch/arm/probes/decode.c
+++ b/arch/arm/probes/decode.c
@@ -425,6 +425,16 @@ probes_decode_insn(probes_opcode_t insn, struct 
arch_probes_insn *asi,
 */
probes_opcode_t origin_insn = insn;
 
+   /*
+* stack_space is initialized to 0 here. Checker functions
+* should update is value if they find this is a stack store
+* instruction: positive value means bytes of stack usage,
+* negitive value means unable to determine stack usage
+* statically. For instruction doesn't store to stack, checker
+* do nothing with it.
+*/
+   asi->stack_space = 0;
+
if (emulate)
insn = prepare_emulated_insn(insn, asi, thumb);
 
diff --git a/arch/arm/probes/kprobes/Makefile b/arch/arm/probes/kprobes/Makefile
index eb38a42..bc8d504 100644
--- a/arch/arm/probes/kprobes/Makefile
+++ b/arch/arm/probes/kprobes/Makefile
@@ -1,11 +1,11 @@
-obj-$(CONFIG_KPROBES)  += core.o actions-common.o
+obj-$(CONFIG_KPROBES)  += core.o actions-common.o checkers-common.o
 obj-$(CONFIG_ARM_KPROBES_TEST) += test-kprobes.o
 test-kprobes-objs  := test-core.o
 
 ifdef CONFIG_THUMB2_KERNEL
-obj-$(CONFIG_KPROBES)  += actions-thumb.o
+obj-$(CONFIG_KPROBES)  += actions-thumb.o checkers-thumb.o
 test-kprobes-objs  += test-thumb.o
 else
-obj-$(CONFIG_KPROBES)  += actions-arm.o
+obj-$(CONFIG_KPROBES)  += actions-arm.o checkers-arm.o
 test-kprobes-objs  += test-arm.o
 endif
diff --git a/arch/arm/probes/kprobes/actions-arm.c 
b/arch/arm/probes/kprobes/actions-arm.c
index 3c3afa4..1e67839 100644
--- a/arch/arm/probes/kprobes/actions-arm.c
+++ b/arch/arm/probes/kprobes/actions-arm.c
@@ -64,6 +64,7 @@
 
 #include "../decode-arm.h"
 #include "core.h"
+#include "checkers.h"
 
 #if  __LINUX_ARM_ARCH__ >= 6
 #define BLX(reg)   "blx"reg"   \n\t"
@@ -342,4 +343,4 @@ const union decode_action 
kprobes_arm_actions[NUM_PROBES_ARM_ACTIONS] = {
[PROBES_LDMSTM] = {.decoder = kprobe_decode_ldmstm}
 };
 
-const struct decode_checker *kprobes_arm_checkers[] = {NULL};
+const struct decode_checker *kprobes_arm_checkers[] = {arm_stack_checker, 
NULL};
diff --git a/arch/arm/probes/kprobes/actions-thumb.c 
b/arch/arm/probes/kprobes/actions-thumb.c
index 2796121..07cfd9b 100644
--- a/arch/arm/probes/kprobes/actions-thumb.c
+++ b/arch/arm/probes/kprobes/actions-thumb.c
@@ -15,6 +15,7 @@
 
 #include "../decode-thumb.h"
 #include "core.h"
+#include "checkers.h"
 
 /* These emulation encodings are functionally equivalent... */
 #define t32_emulate_rd8rn16rm0ra12_noflags \
@@ -665,5 +666,5 @@ const union decode_action 
kprobes_t32_actions[NUM_PROBES_T32_ACTIONS] = {
.handler = t32_emulate_rdlo12rdhi8rn16rm0_noflags},
 };
 
-const struct decode_checker 

[PATCH v12 4/7] ARM: kprobes: disallow probing stack consuming instructions

2014-12-03 Thread Wang Nan
This patch prohibits probing instructions for which the stack
requirements are unable to be determined statically. Some test cases
are found not work again after the modification, this patch also
removes them.

Signed-off-by: Wang Nan 
Reviewed-by: Jon Medhurst 

---
v1 -> v2:
 - Use MAX_STACK_SIZE macro instead of hard coded stack size.

v2 -> v3:
 - Commit message improvements.

v3 -> v4:
 - Commit message improvements.

v4 -> v5:
 - Move to arch/arm/probes.
---
 arch/arm/include/asm/kprobes.h |  1 -
 arch/arm/include/asm/probes.h  | 12 
 arch/arm/kernel/entry-armv.S   |  3 ++-
 arch/arm/probes/kprobes/core.c |  9 +
 arch/arm/probes/kprobes/test-arm.c | 16 ++--
 5 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/arch/arm/include/asm/kprobes.h b/arch/arm/include/asm/kprobes.h
index 49fa0df..56f9ac6 100644
--- a/arch/arm/include/asm/kprobes.h
+++ b/arch/arm/include/asm/kprobes.h
@@ -22,7 +22,6 @@
 
 #define __ARCH_WANT_KPROBES_INSN_SLOT
 #define MAX_INSN_SIZE  2
-#define MAX_STACK_SIZE 64  /* 32 would probably be OK */
 
 #define flush_insn_slot(p) do { } while (0)
 #define kretprobe_blacklist_size   0
diff --git a/arch/arm/include/asm/probes.h b/arch/arm/include/asm/probes.h
index ccf9af3..f0a1ee8 100644
--- a/arch/arm/include/asm/probes.h
+++ b/arch/arm/include/asm/probes.h
@@ -19,6 +19,8 @@
 #ifndef _ASM_PROBES_H
 #define _ASM_PROBES_H
 
+#ifndef __ASSEMBLY__
+
 typedef u32 probes_opcode_t;
 
 struct arch_probes_insn;
@@ -41,4 +43,14 @@ struct arch_probes_insn {
int stack_space;
 };
 
+#endif /* __ASSEMBLY__ */
+
+/*
+ * We assume one instruction can consume at most 64 bytes stack, which is
+ * 'push {r0-r15}'. Instructions consume more or unknown stack space like
+ * 'str r0, [sp, #-80]' and 'str r0, [sp, r1]' should be prohibit to probe.
+ * Both kprobe and jprobe use this macro.
+ */
+#define MAX_STACK_SIZE 64
+
 #endif
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 2fd..672b219 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -31,6 +31,7 @@
 
 #include "entry-header.S"
 #include 
+#include 
 
 /*
  * Interrupt handling.
@@ -249,7 +250,7 @@ __und_svc:
@ If a kprobe is about to simulate a "stmdb sp..." instruction,
@ it obviously needs free stack space which then will belong to
@ the saved context.
-   svc_entry 64
+   svc_entry MAX_STACK_SIZE
 #else
svc_entry
 #endif
diff --git a/arch/arm/probes/kprobes/core.c b/arch/arm/probes/kprobes/core.c
index 74f3dc3..3a58db4 100644
--- a/arch/arm/probes/kprobes/core.c
+++ b/arch/arm/probes/kprobes/core.c
@@ -115,6 +115,15 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
break;
}
 
+   /*
+* Never instrument insn like 'str r0, [sp, +/-r1]'. Also, insn likes
+* 'str r0, [sp, #-68]' should also be prohibited.
+* See __und_svc.
+*/
+   if ((p->ainsn.stack_space < 0) ||
+   (p->ainsn.stack_space > MAX_STACK_SIZE))
+   return -EINVAL;
+
return 0;
 }
 
diff --git a/arch/arm/probes/kprobes/test-arm.c 
b/arch/arm/probes/kprobes/test-arm.c
index d9a1255..fdeb300 100644
--- a/arch/arm/probes/kprobes/test-arm.c
+++ b/arch/arm/probes/kprobes/test-arm.c
@@ -476,7 +476,8 @@ void kprobe_arm_test_cases(void)
TEST_GROUP("Extra load/store instructions")
 
TEST_RPR(  "strhr",0, VAL1,", [r",1, 48,", -r",2, 24,"]")
-   TEST_RPR(  "streqh  r",14,VAL2,", [r",13,0, ", r",12, 48,"]")
+   TEST_RPR(  "streqh  r",14,VAL2,", [r",11,0, ", r",12, 48,"]")
+   TEST_UNSUPPORTED(  "streqh  r14, [r13, r12]")
TEST_RPR(  "strhr",1, VAL1,", [r",2, 24,", r",3,  48,"]!")
TEST_RPR(  "strneh  r",12,VAL2,", [r",11,48,", -r",10,24,"]!")
TEST_RPR(  "strhr",2, VAL1,", [r",3, 24,"], r",4, 48,"")
@@ -565,7 +566,8 @@ void kprobe_arm_test_cases(void)
 
 #if __LINUX_ARM_ARCH__ >= 5
TEST_RPR(  "strdr",0, VAL1,", [r",1, 48,", -r",2,24,"]")
-   TEST_RPR(  "strccd  r",8, VAL2,", [r",13,0, ", r",12,48,"]")
+   TEST_RPR(  "strccd  r",8, VAL2,", [r",11,0, ", r",12,48,"]")
+   TEST_UNSUPPORTED(  "strccd r8, [r13, r12]")
TEST_RPR(  "strdr",4, VAL1,", [r",2, 24,", r",3, 48,"]!")
TEST_RPR(  "strcsd  r",12,VAL2,", [r",11,48,", -r",10,24,"]!")
TEST_RPR(  "strdr",2, VAL1,", [r",5, 24,"], r",4,48,"")
@@ -638,13 +640,15 @@ void kprobe_arm_test_cases(void)
TEST_RP( "str"byte" r",2, VAL1,", [r",3, 24,"], #48")   
\
TEST_RP( "str"byte" r",10,VAL2,", [r",9, 64,"], #-48")  
\
TEST_RPR("str"byte" r",0, VAL1,", [r",1, 48,", -r",2, 24,"]")   
\
-   TEST_RPR("str"byte" r",14,VAL2,", [r",13,0, ", r",12, 48,"]")   
\
+   TEST_RPR("str"byte"

[PATCH v12 6/7] kprobes: Pass the original kprobe for preparing optimized kprobe

2014-12-03 Thread Wang Nan
From: Masami Hiramatsu 

Pass the original kprobe for preparing an optimized kprobe arch-dep
part, since for some architecture (e.g. ARM32) requires the information
in original kprobe.

Signed-off-by: Masami Hiramatsu 
Cc: Wang Nan 
---
 arch/x86/kernel/kprobes/opt.c | 3 ++-
 include/linux/kprobes.h   | 3 ++-
 kernel/kprobes.c  | 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
index f1314d0..7028296 100644
--- a/arch/x86/kernel/kprobes/opt.c
+++ b/arch/x86/kernel/kprobes/opt.c
@@ -320,7 +320,8 @@ void arch_remove_optimized_kprobe(struct optimized_kprobe 
*op)
  * Target instructions MUST be relocatable (checked inside)
  * This is called when new aggr(opt)probe is allocated or reused.
  */
-int arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
+int arch_prepare_optimized_kprobe(struct optimized_kprobe *op,
+ struct kprobe *__unused)
 {
u8 *buf;
int ret;
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index f7296e5..7ab2c93 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -308,7 +308,8 @@ struct optimized_kprobe {
 /* Architecture dependent functions for direct jump optimization */
 extern int arch_prepared_optinsn(struct arch_optimized_insn *optinsn);
 extern int arch_check_optimized_kprobe(struct optimized_kprobe *op);
-extern int arch_prepare_optimized_kprobe(struct optimized_kprobe *op);
+extern int arch_prepare_optimized_kprobe(struct optimized_kprobe *op,
+struct kprobe *orig);
 extern void arch_remove_optimized_kprobe(struct optimized_kprobe *op);
 extern void arch_optimize_kprobes(struct list_head *oplist);
 extern void arch_unoptimize_kprobes(struct list_head *oplist,
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 3995f54..9f28aa7 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -717,7 +717,7 @@ static void prepare_optimized_kprobe(struct kprobe *p)
struct optimized_kprobe *op;
 
op = container_of(p, struct optimized_kprobe, kp);
-   arch_prepare_optimized_kprobe(op);
+   arch_prepare_optimized_kprobe(op, p);
 }
 
 /* Allocate new optimized_kprobe and try to prepare optimized instructions */
@@ -731,7 +731,7 @@ static struct kprobe *alloc_aggr_kprobe(struct kprobe *p)
 
INIT_LIST_HEAD(>list);
op->kp.addr = p->addr;
-   arch_prepare_optimized_kprobe(op);
+   arch_prepare_optimized_kprobe(op, p);
 
return >kp;
 }
-- 
1.8.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 v12 7/7] ARM: kprobes: enable OPTPROBES for ARM 32

2014-12-03 Thread Wang Nan
This patch introduce kprobeopt for ARM 32.

Limitations:
 - Currently only kernel compiled with ARM ISA is supported.

 - Offset between probe point and optinsn slot must not larger than
   32MiB. Masami Hiramatsu suggests replacing 2 words, it will make
   things complex. Futher patch can make such optimization.

Kprobe opt on ARM is relatively simpler than kprobe opt on x86 because
ARM instruction is always 4 bytes aligned and 4 bytes long. This patch
replace probed instruction by a 'b', branch to trampoline code and then
calls optimized_callback(). optimized_callback() calls opt_pre_handler()
to execute kprobe handler. It also emulate/simulate replaced instruction.

When unregistering kprobe, the deferred manner of unoptimizer may leave
branch instruction before optimizer is called. Different from x86_64,
which only copy the probed insn after optprobe_template_end and
reexecute them, this patch call singlestep to emulate/simulate the insn
directly. Futher patch can optimize this behavior.

Signed-off-by: Wang Nan 
Acked-by: Masami Hiramatsu 
Cc: Jon Medhurst (Tixy) 
Cc: Russell King - ARM Linux 
Cc: Will Deacon 

v1 -> v2:
 - Improvement: if replaced instruction is conditional, generate a
   conditional branch instruction for it;
 - Introduces RELATIVEJUMP_OPCODES due to ARM kprobe_opcode_t is 4
   bytes;
 - Removes size field in struct arch_optimized_insn;
 - Use arm_gen_branch() to generate branch instruction;
 - Remove all recover logic: ARM doesn't use tail buffer, no need
   recover replaced instructions like x86;
 - Remove incorrect CONFIG_THUMB checking;
 - can_optimize() always returns true if address is well aligned;
 - Improve optimized_callback: using opt_pre_handler();
 - Bugfix: correct range checking code and improve comments;
 - Fix commit message.

v2 -> v3:
 - Rename RELATIVEJUMP_OPCODES to MAX_COPIED_INSNS;
 - Remove unneeded checking:
  arch_check_optimized_kprobe(), can_optimize();
 - Add missing flush_icache_range() in arch_prepare_optimized_kprobe();
 - Remove unneeded 'return;'.

v3 -> v4:
 - Use __mem_to_opcode_arm() to translate copied_insn to ensure it
   works in big endian kernel;
 - Replace 'nop' placeholder in trampoline code template with
   '.long 0' to avoid confusion: reader may regard 'nop' as an
   instruction, but it is value in fact.

v4 -> v5:
 - Don't optimize stack store operations.
 - Introduce prepared field to arch_optimized_insn to indicate whether
   it is prepared. Similar to size field with x86. See v1 -> v2.

v5 -> v6:
 - Dynamically reserve stack according to instruction.
 - Rename: kprobes-opt.c -> kprobes-opt-arm.c.
 - Set op->optinsn.insn after all works are done.

v6 -> v7:
  - Using checker to check stack consumption.

v7 -> v8:
  - Small code adjustments.

v8 -> v9:
  - Utilize original kprobe passed to arch_prepare_optimized_kprobe()
to avoid copy ainsn twice.
  - A bug in arch_prepare_optimized_kprobe() is found and fixed.

v9 -> v10:
  - Commit message improvements.

v10 -> v11:
  - Move to arch/arm/probes/, insn.h is moved to arch/arm/include/asm.
  - Code cleanup.
  - Bugfix based on Tixy's test result:
- Trampoline deal with ARM -> Thumb transision instructions and
  AEABI stack alignment requirement correctly.
- Trampoline code buffer should start at 4 byte aligned address.
  We enforces it in this series by using macro to wrap 'code' var.

v11 -> v12:
  - Remove trampoline code stack trick and use r4 to save original
stack.
  - Remove trampoline code buffer alignment trick.
  - Names of files are changed.
---
 arch/arm/Kconfig|   1 +
 arch/arm/{kernel => include/asm}/insn.h |   0
 arch/arm/include/asm/kprobes.h  |  34 
 arch/arm/kernel/Makefile|   2 +-
 arch/arm/kernel/ftrace.c|   3 +-
 arch/arm/kernel/jump_label.c|   3 +-
 arch/arm/probes/kprobes/Makefile|   1 +
 arch/arm/probes/kprobes/core.c  |   1 +
 arch/arm/probes/kprobes/opt-arm.c   | 322 
 9 files changed, 362 insertions(+), 5 deletions(-)
 rename arch/arm/{kernel => include/asm}/insn.h (100%)
 create mode 100644 arch/arm/probes/kprobes/opt-arm.c

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 89c4b5c..8281cea 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -59,6 +59,7 @@ config ARM
select HAVE_MEMBLOCK
select HAVE_MOD_ARCH_SPECIFIC if ARM_UNWIND
select HAVE_OPROFILE if (HAVE_PERF_EVENTS)
+   select HAVE_OPTPROBES if (!THUMB2_KERNEL)
select HAVE_PERF_EVENTS
select HAVE_PERF_REGS
select HAVE_PERF_USER_STACK_DUMP
diff --git a/arch/arm/kernel/insn.h b/arch/arm/include/asm/insn.h
similarity index 100%
rename from arch/arm/kernel/insn.h
rename to arch/arm/include/asm/insn.h
diff --git a/arch/arm/include/asm/kprobes.h b/arch/arm/include/asm/kprobes.h
index 56f9ac6..5574008 100644
--- a/arch/arm/include/asm/kprobes.h
+++ b/arch/arm/include/asm/kprobes.h
@@ -50,5 

[PATCH v12 2/7] ARM: kprobes: introduces checker

2014-12-03 Thread Wang Nan
This patch introdces 'checker' to decoding phase, and calls checkers
when instruction decoding. This allows further decoding for specific
instructions.  This patch introduces a stub call of checkers in kprobe
arch_prepare_kprobe() as an example and for further expansion.

Signed-off-by: Wang Nan 
Reviewed-by: Jon Medhurst 
Reviewed-by: Masami Hiramatsu 

---
v1 -> v2:
 - kprobe checker stubs are introduced in this patch.

v2 -> v3:
 - Code cleanups following Masami Hiramatsu and Tixy's advises.
 - Commit message improvements.

v3 -> v4:
 - Move to arch/arm/probes.
---
 arch/arm/probes/decode-arm.c|  5 +--
 arch/arm/probes/decode-arm.h|  3 +-
 arch/arm/probes/decode-thumb.c  | 10 +++---
 arch/arm/probes/decode-thumb.h  |  6 ++--
 arch/arm/probes/decode.c| 60 +
 arch/arm/probes/decode.h| 11 +-
 arch/arm/probes/kprobes/actions-arm.c   |  2 ++
 arch/arm/probes/kprobes/actions-thumb.c |  3 ++
 arch/arm/probes/kprobes/core.c  |  6 +++-
 arch/arm/probes/kprobes/core.h  |  7 ++--
 arch/arm/probes/uprobes/core.c  |  2 +-
 11 files changed, 95 insertions(+), 20 deletions(-)

diff --git a/arch/arm/probes/decode-arm.c b/arch/arm/probes/decode-arm.c
index e39cc75..f46d8fc 100644
--- a/arch/arm/probes/decode-arm.c
+++ b/arch/arm/probes/decode-arm.c
@@ -726,10 +726,11 @@ static void __kprobes arm_singlestep(probes_opcode_t insn,
  */
 enum probes_insn __kprobes
 arm_probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi,
-  bool emulate, const union decode_action *actions)
+  bool emulate, const union decode_action *actions,
+  const struct decode_checker *checkers[])
 {
asi->insn_singlestep = arm_singlestep;
asi->insn_check_cc = probes_condition_checks[insn>>28];
return probes_decode_insn(insn, asi, probes_decode_arm_table, false,
- emulate, actions);
+ emulate, actions, checkers);
 }
diff --git a/arch/arm/probes/decode-arm.h b/arch/arm/probes/decode-arm.h
index 9c56b40..a7b0398 100644
--- a/arch/arm/probes/decode-arm.h
+++ b/arch/arm/probes/decode-arm.h
@@ -70,6 +70,7 @@ extern const union decode_item probes_decode_arm_table[];
 
 enum probes_insn arm_probes_decode_insn(probes_opcode_t,
struct arch_probes_insn *, bool emulate,
-   const union decode_action *actions);
+   const union decode_action *actions,
+   const struct decode_checker *checkers[]);
 
 #endif
diff --git a/arch/arm/probes/decode-thumb.c b/arch/arm/probes/decode-thumb.c
index 2f0453a..985e7dd 100644
--- a/arch/arm/probes/decode-thumb.c
+++ b/arch/arm/probes/decode-thumb.c
@@ -863,20 +863,22 @@ static void __kprobes thumb32_singlestep(probes_opcode_t 
opcode,
 
 enum probes_insn __kprobes
 thumb16_probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi,
-  bool emulate, const union decode_action *actions)
+  bool emulate, const union decode_action *actions,
+  const struct decode_checker *checkers[])
 {
asi->insn_singlestep = thumb16_singlestep;
asi->insn_check_cc = thumb_check_cc;
return probes_decode_insn(insn, asi, probes_decode_thumb16_table, true,
- emulate, actions);
+ emulate, actions, checkers);
 }
 
 enum probes_insn __kprobes
 thumb32_probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi,
-  bool emulate, const union decode_action *actions)
+  bool emulate, const union decode_action *actions,
+  const struct decode_checker *checkers[])
 {
asi->insn_singlestep = thumb32_singlestep;
asi->insn_check_cc = thumb_check_cc;
return probes_decode_insn(insn, asi, probes_decode_thumb32_table, true,
- emulate, actions);
+ emulate, actions, checkers);
 }
diff --git a/arch/arm/probes/decode-thumb.h b/arch/arm/probes/decode-thumb.h
index 039013c..8457add 100644
--- a/arch/arm/probes/decode-thumb.h
+++ b/arch/arm/probes/decode-thumb.h
@@ -91,9 +91,11 @@ extern const union decode_item probes_decode_thumb16_table[];
 
 enum probes_insn __kprobes
 thumb16_probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi,
-   bool emulate, const union decode_action *actions);
+   bool emulate, const union decode_action *actions,
+   const struct decode_checker *checkers[]);
 enum probes_insn __kprobes
 thumb32_probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi,
-   bool emulate, const union decode_action *actions);
+   bool emulate, const union decode_action *actions,
+   const struct 

[PATCH v12 5/7] ARM: kprobes: Add test cases for stack consuming instructions

2014-12-03 Thread Wang Nan
These have extra 'checker' functions associated with them so
lets make sure those get covered by testing.

Signed-off-by: Jon Medhurst 
Signed-off-by: Wang Nan 

---
v1 -> v2:
 - Move to arch/arm/probes/ .
---
 arch/arm/probes/kprobes/test-arm.c   | 17 +++--
 arch/arm/probes/kprobes/test-thumb.c | 12 
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/arch/arm/probes/kprobes/test-arm.c 
b/arch/arm/probes/kprobes/test-arm.c
index fdeb300..9b3b1b4 100644
--- a/arch/arm/probes/kprobes/test-arm.c
+++ b/arch/arm/probes/kprobes/test-arm.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "test-core.h"
 
@@ -478,6 +479,7 @@ void kprobe_arm_test_cases(void)
TEST_RPR(  "strhr",0, VAL1,", [r",1, 48,", -r",2, 24,"]")
TEST_RPR(  "streqh  r",14,VAL2,", [r",11,0, ", r",12, 48,"]")
TEST_UNSUPPORTED(  "streqh  r14, [r13, r12]")
+   TEST_UNSUPPORTED(  "streqh  r14, [r12, r13]")
TEST_RPR(  "strhr",1, VAL1,", [r",2, 24,", r",3,  48,"]!")
TEST_RPR(  "strneh  r",12,VAL2,", [r",11,48,", -r",10,24,"]!")
TEST_RPR(  "strhr",2, VAL1,", [r",3, 24,"], r",4, 48,"")
@@ -502,6 +504,9 @@ void kprobe_arm_test_cases(void)
TEST_RP(   "strplh  r",12,VAL2,", [r",11,24,", #-4]!")
TEST_RP(   "strhr",2, VAL1,", [r",3, 24,"], #48")
TEST_RP(   "strhr",10,VAL2,", [r",9, 64,"], #-48")
+   TEST_RP(   "strhr",3, VAL1,", [r",13,TEST_MEMORY_SIZE,", 
#-"__stringify(MAX_STACK_SIZE)"]!")
+   TEST_UNSUPPORTED("strh r3, [r13, #-"__stringify(MAX_STACK_SIZE)"-8]!")
+   TEST_RP(   "strhr",4, VAL1,", [r",14,TEST_MEMORY_SIZE,", 
#-"__stringify(MAX_STACK_SIZE)"-8]!")
TEST_UNSUPPORTED(__inst_arm(0xe1efc3b0) "   @ strh r12, [pc, #48]!")
TEST_UNSUPPORTED(__inst_arm(0xe0c9f3b0) "   @ strh pc, [r9], #48")
 
@@ -568,6 +573,7 @@ void kprobe_arm_test_cases(void)
TEST_RPR(  "strdr",0, VAL1,", [r",1, 48,", -r",2,24,"]")
TEST_RPR(  "strccd  r",8, VAL2,", [r",11,0, ", r",12,48,"]")
TEST_UNSUPPORTED(  "strccd r8, [r13, r12]")
+   TEST_UNSUPPORTED(  "strccd r8, [r12, r13]")
TEST_RPR(  "strdr",4, VAL1,", [r",2, 24,", r",3, 48,"]!")
TEST_RPR(  "strcsd  r",12,VAL2,", [r",11,48,", -r",10,24,"]!")
TEST_RPR(  "strdr",2, VAL1,", [r",5, 24,"], r",4,48,"")
@@ -591,6 +597,9 @@ void kprobe_arm_test_cases(void)
TEST_RP(   "strvcd  r",12,VAL2,", [r",11,24,", #-16]!")
TEST_RP(   "strdr",2, VAL1,", [r",4, 24,"], #48")
TEST_RP(   "strdr",10,VAL2,", [r",9, 64,"], #-48")
+   TEST_RP(   "strdr",6, VAL1,", [r",13,TEST_MEMORY_SIZE,", 
#-"__stringify(MAX_STACK_SIZE)"]!")
+   TEST_UNSUPPORTED("strd r6, [r13, #-"__stringify(MAX_STACK_SIZE)"-8]!")
+   TEST_RP(   "strdr",4, VAL1,", [r",12,TEST_MEMORY_SIZE,", 
#-"__stringify(MAX_STACK_SIZE)"-8]!")
TEST_UNSUPPORTED(__inst_arm(0xe1efc3f0) "   @ strd r12, [pc, #48]!")
 
TEST_P("ldrdr0, [r",0, 24,", #-8]")
@@ -639,16 +648,20 @@ void kprobe_arm_test_cases(void)
TEST_RP( "str"byte" r",12,VAL2,", [r",11,24,", #-4]!")  
\
TEST_RP( "str"byte" r",2, VAL1,", [r",3, 24,"], #48")   
\
TEST_RP( "str"byte" r",10,VAL2,", [r",9, 64,"], #-48")  
\
+   TEST_RP( "str"byte" r",3, VAL1,", [r",13,TEST_MEMORY_SIZE,", 
#-"__stringify(MAX_STACK_SIZE)"]!") \
+   TEST_UNSUPPORTED("str"byte" r3, [r13, 
#-"__stringify(MAX_STACK_SIZE)"-8]!") \
+   TEST_RP( "str"byte" r",4, VAL1,", [r",10,TEST_MEMORY_SIZE,", 
#-"__stringify(MAX_STACK_SIZE)"-8]!") \
TEST_RPR("str"byte" r",0, VAL1,", [r",1, 48,", -r",2, 24,"]")   
\
TEST_RPR("str"byte" r",14,VAL2,", [r",11,0, ", r",12, 48,"]")   
\
-   TEST_UNSUPPORTED("str"byte" r14, [r13, r12]")   \
+   TEST_UNSUPPORTED("str"byte" r14, [r13, r12]")   
\
+   TEST_UNSUPPORTED("str"byte" r14, [r12, r13]")   
\
TEST_RPR("str"byte" r",1, VAL1,", [r",2, 24,", r",3,  48,"]!")  
\
TEST_RPR("str"byte" r",12,VAL2,", [r",11,48,", -r",10,24,"]!")  
\
TEST_RPR("str"byte" r",2, VAL1,", [r",3, 24,"], r",4, 48,"")
\
TEST_RPR("str"byte" r",10,VAL2,", [r",9, 48,"], -r",11,24,"")   
\
TEST_RPR("str"byte" r",0, VAL1,", [r",1, 24,", r",2,  32,", asl 
#1]")\
TEST_RPR("str"byte" r",14,VAL2,", [r",11,0, ", r",12, 32,", lsr 
#2]")\
-   TEST_UNSUPPORTED("str"byte" r14, [r13, r12, lsr #2]")\
+   TEST_UNSUPPORTED("str"byte" r14, [r13, r12, lsr #2]")   
\
TEST_RPR("str"byte" r",1, VAL1,", [r",2, 24,", r",3,  32,", asr 
#3]!")\
TEST_RPR("str"byte" r",12,VAL2,", [r",11,24,", r",10, 4,", ror 
#31]!")\
   

[PATCH v12 1/7] ARM: probes: move all probe code to dedicate directory

2014-12-03 Thread Wang Nan
In discussion on LKML (https://lkml.org/lkml/2014/11/28/158), Russell
King suggests to move all probe related code to arch/arm/probes. This
patch does the work. Due to dependency on 'arch/arm/kernel/patch.h', this
patch also moves patch.h to 'arch/arm/include/asm/patch.h', and related
'#include' directives are also midified to '#include '.

Following is an overview of this patch:

 ./arch/arm/kernel/   ./arch/arm/probes/
 |-- Makefile |-- Makefile
 |-- probes-arm.c  ==>|-- decode-arm.c
 |-- probes-arm.h  ==>|-- decode-arm.h
 |-- probes-thumb.c==>|-- decode-thumb.c
 |-- probes-thumb.h==>|-- decode-thumb.h
 |-- probes.c  ==>|-- decode.c
 |-- probes.h  ==>|-- decode.h
 ||-- kprobes
 ||   |-- Makefile
 |-- kprobes-arm.c ==>|   |-- actions-arm.c
 |-- kprobes-common.c  ==>|   |-- actions-common.c
 |-- kprobes-thumb.c   ==>|   |-- actions-thumb.c
 |-- kprobes.c ==>|   |-- core.c
 |-- kprobes.h ==>|   |-- core.h
 |-- kprobes-test-arm.c==>|   |-- test-arm.c
 |-- kprobes-test.c==>|   |-- test-core.c
 |-- kprobes-test.h==>|   |-- test-core.h
 |-- kprobes-test-thumb.c  ==>|   `-- test-thumb.c
 |`-- uprobes
 ||-- Makefile
 |-- uprobes-arm.c ==>|-- actions-arm.c
 |-- uprobes.c ==>|-- core.c
 |-- uprobes.h ==>`-- core.h
 |
 `-- patch.h   ==>arch/arm/include/asm/patch.h

Signed-off-by: Wang Nan 

---

v1 -> v2:
 - Rename source files to describe their functions.
 - Add Makefiles in kprobes and uprobes directories.
---
 arch/arm/Makefile|  1 +
 arch/arm/{kernel => include/asm}/patch.h |  0
 arch/arm/kernel/Makefile | 16 ++--
 arch/arm/kernel/jump_label.c |  2 +-
 arch/arm/kernel/patch.c  |  3 +--
 arch/arm/probes/Makefile |  7 +++
 arch/arm/{kernel/probes-arm.c => probes/decode-arm.c}|  7 ---
 arch/arm/{kernel/probes-arm.h => probes/decode-arm.h}|  4 +++-
 .../arm/{kernel/probes-thumb.c => probes/decode-thumb.c} |  6 +++---
 .../arm/{kernel/probes-thumb.h => probes/decode-thumb.h} |  4 +++-
 arch/arm/{kernel/probes.c => probes/decode.c}|  4 ++--
 arch/arm/{kernel/probes.h => probes/decode.h}|  2 +-
 arch/arm/probes/kprobes/Makefile | 11 +++
 .../kprobes-arm.c => probes/kprobes/actions-arm.c}   |  6 +++---
 .../kprobes-common.c => probes/kprobes/actions-common.c} |  4 ++--
 .../kprobes-thumb.c => probes/kprobes/actions-thumb.c}   |  6 +++---
 arch/arm/{kernel/kprobes.c => probes/kprobes/core.c} |  8 
 arch/arm/{kernel/kprobes.h => probes/kprobes/core.h} |  3 ++-
 .../kprobes-test-arm.c => probes/kprobes/test-arm.c} |  2 +-
 .../kprobes-test.c => probes/kprobes/test-core.c}|  8 
 .../kprobes-test.h => probes/kprobes/test-core.h}|  2 +-
 .../kprobes-test-thumb.c => probes/kprobes/test-thumb.c} |  4 ++--
 arch/arm/probes/uprobes/Makefile |  2 ++
 .../uprobes-arm.c => probes/uprobes/actions-arm.c}   |  6 +++---
 arch/arm/{kernel/uprobes.c => probes/uprobes/core.c} |  6 +++---
 arch/arm/{kernel/uprobes.h => probes/uprobes/core.h} |  0
 26 files changed, 69 insertions(+), 55 deletions(-)
 rename arch/arm/{kernel => include/asm}/patch.h (100%)
 create mode 100644 arch/arm/probes/Makefile
 rename arch/arm/{kernel/probes-arm.c => probes/decode-arm.c} (99%)
 rename arch/arm/{kernel/probes-arm.h => probes/decode-arm.h} (97%)
 rename arch/arm/{kernel/probes-thumb.c => probes/decode-thumb.c} (99%)
 rename arch/arm/{kernel/probes-thumb.h => probes/decode-thumb.h} (97%)
 rename arch/arm/{kernel/probes.c => probes/decode.c} (99%)
 rename arch/arm/{kernel/probes.h => probes/decode.h} (99%)
 create mode 100644 arch/arm/probes/kprobes/Makefile
 rename arch/arm/{kernel/kprobes-arm.c => probes/kprobes/actions-arm.c} (99%)
 rename arch/arm/{kernel/kprobes-common.c => probes/kprobes/actions-common.c} 
(98%)
 rename arch/arm/{kernel/kprobes-thumb.c => probes/kprobes/actions-thumb.c} 
(99%)
 rename arch/arm/{kernel/kprobes.c => probes/kprobes/core.c} (99%)
 rename arch/arm/{kernel/kprobes.h => probes/kprobes/core.h} (96%)
 rename arch/arm/{kernel/kprobes-test-arm.c => probes/kprobes/test-arm.c} (99%)
 rename arch/arm/{kernel/kprobes-test.c => probes/kprobes/test-core.c} (99%)
 rename arch/arm/{kernel/kprobes-test.h => probes/kprobes/test-core.h} (99%)
 rename arch/arm/{kernel/kprobes-test-thumb.c => probes/kprobes/test-thumb.c} 
(99%)
 create mode 100644 arch/arm/probes/uprobes/Makefile
 rename 

[PATCH v12 0/7] ARM: kprobes: OPTPROBES and other improvements.

2014-12-03 Thread Wang Nan
This is v12 of optprobe related patch series. In this series, code in
optprobe is improvemented; the kprobe related files names are changed
to represent their functions.

Patch 1/7 moves all ARM probe related code to arch/arm/probes according
to suggestion from Russell King and Masami Hiramatsu.

Patch 2/7 - 5/7 introduce checker framework and use it to detect stack
consumption for each probed instructions.

Patch 6/7 and 7/7 are for real optprobe work.

Previous discussion can be found from:

https://lkml.org/lkml/2014/11/22/18
https://lkml.org/lkml/2014/11/21/55
https://lkml.org/lkml/2014/11/18/26
https://lkml.org/lkml/2014/11/19/31
https://lkml.org/lkml/2014/11/18/41
https://lkml.org/lkml/2014/10/25/48
https://lkml.org/lkml/2014/10/22/254
https://lkml.org/lkml/2014/8/27/255
https://lkml.org/lkml/2014/8/12/12
https://lkml.org/lkml/2014/8/8/992
https://lkml.org/lkml/2014/8/8/5
https://lkml.org/lkml/2014/8/5/63

Masami Hiramatsu (1):
  kprobes: Pass the original kprobe for preparing optimized kprobe

Wang Nan (6):
  ARM: probes: move all probe code to dedicate directory
  ARM: kprobes: introduces checker
  ARM: kprobes: collects stack consumption for store instructions
  ARM: kprobes: disallow probing stack consuming instructions
  ARM: kprobes: Add test cases for stack consuming instructions
  ARM: kprobes: enable OPTPROBES for ARM 32

 arch/arm/Kconfig   |   1 +
 arch/arm/Makefile  |   1 +
 arch/arm/{kernel => include/asm}/insn.h|   0
 arch/arm/include/asm/kprobes.h |  35 ++-
 arch/arm/{kernel => include/asm}/patch.h   |   0
 arch/arm/include/asm/probes.h  |  13 +
 arch/arm/kernel/Makefile   |  16 +-
 arch/arm/kernel/entry-armv.S   |   3 +-
 arch/arm/kernel/ftrace.c   |   3 +-
 arch/arm/kernel/jump_label.c   |   5 +-
 arch/arm/kernel/patch.c|   3 +-
 arch/arm/probes/Makefile   |   7 +
 .../{kernel/probes-arm.c => probes/decode-arm.c}   |  12 +-
 .../{kernel/probes-arm.h => probes/decode-arm.h}   |   7 +-
 .../probes-thumb.c => probes/decode-thumb.c}   |  16 +-
 .../probes-thumb.h => probes/decode-thumb.h}   |  10 +-
 arch/arm/{kernel/probes.c => probes/decode.c}  |  74 -
 arch/arm/{kernel/probes.h => probes/decode.h}  |  13 +-
 arch/arm/probes/kprobes/Makefile   |  12 +
 .../kprobes-arm.c => probes/kprobes/actions-arm.c} |   9 +-
 .../kprobes/actions-common.c}  |   4 +-
 .../kprobes/actions-thumb.c}   |  10 +-
 arch/arm/probes/kprobes/checkers-arm.c |  99 +++
 arch/arm/probes/kprobes/checkers-common.c  | 101 +++
 arch/arm/probes/kprobes/checkers-thumb.c   | 110 +++
 arch/arm/probes/kprobes/checkers.h |  54 
 .../{kernel/kprobes.c => probes/kprobes/core.c}|  24 +-
 .../{kernel/kprobes.h => probes/kprobes/core.h}|  10 +-
 arch/arm/probes/kprobes/opt-arm.c  | 322 +
 .../kprobes/test-arm.c}|  31 +-
 .../kprobes-test.c => probes/kprobes/test-core.c}  |   8 +-
 .../kprobes-test.h => probes/kprobes/test-core.h}  |   2 +-
 .../kprobes/test-thumb.c}  |  16 +-
 arch/arm/probes/uprobes/Makefile   |   2 +
 .../uprobes-arm.c => probes/uprobes/actions-arm.c} |   6 +-
 .../{kernel/uprobes.c => probes/uprobes/core.c}|   8 +-
 .../{kernel/uprobes.h => probes/uprobes/core.h}|   0
 arch/x86/kernel/kprobes/opt.c  |   3 +-
 include/linux/kprobes.h|   3 +-
 kernel/kprobes.c   |   4 +-
 40 files changed, 966 insertions(+), 91 deletions(-)
 rename arch/arm/{kernel => include/asm}/insn.h (100%)
 rename arch/arm/{kernel => include/asm}/patch.h (100%)
 create mode 100644 arch/arm/probes/Makefile
 rename arch/arm/{kernel/probes-arm.c => probes/decode-arm.c} (99%)
 rename arch/arm/{kernel/probes-arm.h => probes/decode-arm.h} (93%)
 rename arch/arm/{kernel/probes-thumb.c => probes/decode-thumb.c} (98%)
 rename arch/arm/{kernel/probes-thumb.h => probes/decode-thumb.h} (90%)
 rename arch/arm/{kernel/probes.c => probes/decode.c} (85%)
 rename arch/arm/{kernel/probes.h => probes/decode.h} (97%)
 create mode 100644 arch/arm/probes/kprobes/Makefile
 rename arch/arm/{kernel/kprobes-arm.c => probes/kprobes/actions-arm.c} (98%)
 rename arch/arm/{kernel/kprobes-common.c => probes/kprobes/actions-common.c} 
(98%)
 rename arch/arm/{kernel/kprobes-thumb.c => probes/kprobes/actions-thumb.c} 
(98%)
 create mode 100644 arch/arm/probes/kprobes/checkers-arm.c
 create mode 100644 arch/arm/probes/kprobes/checkers-common.c
 create mode 100644 arch/arm/probes/kprobes/checkers-thumb.c
 create mode 100644 arch/arm/probes/kprobes/checkers.h
 rename 

Re: [PATCH v5 6/6] powerpc/perf/hv-24x7: Document sysfs event description entries

2014-12-03 Thread Cody P Schafer
> diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7 
> b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
> index 32f3f5f..cf70084 100644
> --- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
> +++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
> @@ -21,3 +21,25 @@ Contact: Linux on PowerPC Developer List 
> 
> +Contact:   Cody P Schafer 

Probably want someone else to be the contact here.
--
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] platform: x86: dell-laptop: Add support for keyboard backlight

2014-12-03 Thread Darren Hart
On Sun, Nov 23, 2014 at 03:50:45PM +0100, Pali Rohár wrote:
> This patch adds support for configuring keyboard backlight settings on 
> supported
> Dell laptops. It exports kernel leds interface and uses Dell SMBIOS tokens or
> keyboard class interface.
> 
> With this patch it is possible to set:
> * keyboard backlight level
> * timeout after which will be backlight automatically turned off
> * input activity triggers (keyboard, touchpad, mouse) which enable backlight
> * ambient light settings
> 
> Settings are exported via sysfs:
> /sys/class/leds/dell::kbd_backlight/
> 
> Code is based on newly released documentation by Dell in libsmbios project.
> 

Hi Pali,

I would really like to see this broken up. Possibly adding levels and timeouts
as separate patches for example. It is quite difficult to review this all at
once in a reasonable amount of time.

During this review I caught a few more CodingStyle violations, and raised some
questions about the timeout and levels mechanisms.

> @@ -62,6 +71,10 @@ struct calling_interface_structure {
>  
>  struct quirk_entry {
>   u8 touchpad_led;
> +
> + /* Ordered list of timeouts expressed in seconds.
> +  * The list must end with -1 */

Despite other instances in this file, block comments are documented in
CodingStyle as:

/*
 * Comment text.
 */

The old ones should be cleaned up eventually, but new ones need to be done
according to CodingStyle. Please correct throughout.

> + int kbd_timeouts[];
>  };
>  
>  static struct quirk_entry *quirks;
> @@ -76,6 +89,10 @@ static int __init dmi_matched(const struct dmi_system_id 
> *dmi)
>   return 1;
>  }
>  
> +static struct quirk_entry quirk_dell_xps13_9333 = {
> + .kbd_timeouts = { 0, 5, 15, 60, 5*60, 15*60, -1 },

Where did these values come from? Were they documented in the libsmbios project?
Can you provide a URL to that? These really should be described by the firmware,
but if they aren't, nothing we can do about it.

> @@ -790,6 +842,964 @@ static void touchpad_led_exit(void)
>   led_classdev_unregister(_led);
>  }
>  
> +/* Derived from information in smbios-keyboard-ctl:

See block comment above.

> +
> + cbClass 4
> + cbSelect 11
> + Keyboar illumination

Keyboard

> + cbArg1 determines the function to be performed
> +
> + cbArg1 0x0 = Get Feature Information
> +  cbRES1 Standard return codes (0, -1, -2)
> +  cbRES2, word0  Bitmap of user-selectable modes
> + bit 0 Always off (All systems)
> + bit 1 Always on (Travis ATG, Siberia)
> + bit 2 Auto: ALS-based On; ALS-based Off (Travis ATG)
> + bit 3 Auto: ALS- and input-activity-based On; input-activity based 
> Off
> + bit 4 Auto: Input-activity-based On; input-activity based Off
> + bit 5 Auto: Input-activity-based On (illumination level 25%); 
> input-activity based Off
> + bit 6 Auto: Input-activity-based On (illumination level 50%); 
> input-activity based Off
> + bit 7 Auto: Input-activity-based On (illumination level 75%); 
> input-activity based Off
> + bit 8 Auto: Input-activity-based On (illumination level 100%); 
> input-activity based Off
> + bits 9-15 Reserved for future use
> +  cbRES2, byte2  Reserved for future use
> +  cbRES2, byte3  Keyboard illumination type
> + 0 Reserved
> + 1 Tasklight
> + 2 Backlight
> + 3-255 Reserved for future use
> +  cbRES3, byte0  Supported auto keyboard illumination trigger bitmap.
> + bit 0 Any keystroke
> + bit 1 Touchpad activity
> + bit 2 Pointing stick
> + bit 3 Any mouse
> + bits 4-7  Reserved for future use
> +  cbRES3, byte1  Supported timeout unit bitmap
> + bit 0 Seconds
> + bit 1 Minutes
> + bit 2 Hours
> + bit 3 Days
> + bits 4-7  Reserved for future use
> +  cbRES3, byte2  Number of keyboard light brightness levels
> +  cbRES4, byte0  Maximum acceptable seconds value (0 if seconds not 
> supported).
> +  cbRES4, byte1  Maximum acceptable minutes value (0 if minutes not 
> supported).
> +  cbRES4, byte2  Maximum acceptable hours value (0 if hours not supported).
> +  cbRES4, byte3  Maxiomum acceptable days value (0 if days not supported)

Maximum ^

This interface appears to define all possible values for the timeout between
cbRES3[1] and cbRES4[*]. Why is the kbd_timeouts[] array a quirk with fixed
values? It seems it could indeed be dynamically determined.

> +
> +struct kbd_info {
> + u16 modes;
> + u8 type;
> + u8 triggers;
> + u8 levels;
> + u8 seconds;
> + u8 minutes;
> + u8 hours;
> + u8 days;
> +};
> +
> +
> +static u8 kbd_mode_levels[16];
> +static int kbd_mode_levels_count;

I'm confused by these. How are they different from kbd_info.levels?

We seem to check the latter first and fall back to these if that is 0 why?

> +static int kbd_get_info(struct kbd_info *info)
> +{
> + u8 units;
> + int ret;
> +
> + 

Re: [PATCH v4 1/2] soc: samsung: add exynos chipid driver support

2014-12-03 Thread Pankaj Dubey

Hi Arnd,

On Wednesday 03 December 2014 04:13 PM, Arnd Bergmann wrote:

Exynos SoCs have Chipid, for identification of product IDs
and SoC revisions. This patch intendes to provide initialization
code for all these functionalites, at the same time it provides some
sysfs entries for accessing these information to userspace.

This driver usese existing binding for exnos-chipid.


Nice!


Thanks for review.



On Wednesday 03 December 2014 13:47:37 Pankaj Dubey wrote:


+   soc_dev_attr->soc_id = exynos_product_id_to_name(soc_product_id);
+
+   soc_dev = soc_device_register(soc_dev_attr);
+   if (IS_ERR(soc_dev))
+   goto free_rev;
+
+   device_create_file(soc_device_to_device(soc_dev), _product_attr);
+   device_create_file(soc_device_to_device(soc_dev),
+   _main_rev_attr);
+   device_create_file(soc_device_to_device(soc_dev), _sub_rev_attr);
+


I don't like the idea of having three extra nonstandard properties here,
especially when you are not using the machine field for anything useful.



I did not get you here. Any suggestions how we can use 'machine' field 
more useful way.



Also, all three of these just come from the same register, why expose
them all as the machine and revision standard properties.



Agreed. These properties are basically giving same information but with 
small modification.
As you said these are getting exposed via standard properties as well, 
so I have no issue to drop them. Just waiting for more review from 
Samsung folks, will take care of this in next version.



Thanks,
Pankaj Dubey

Arnd


--
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: 3.18 nohz + audit regression (Re: [PATCH] context_tracking: Restore previous state in schedule_user)

2014-12-03 Thread Linus Torvalds
On Wed, Dec 3, 2014 at 5:29 PM, Andy Lutomirski  wrote:
>
> So, to summarize the choices for 3.18:
>
> 4. This patch.

I've applied it. The alternatives look worse, and the patch doesn't
look bad. In many ways it looks better than the old user_exit/enter
pair, although obviously the "schedule_user()" name is kind of odd
now. Whatever.

   Linus
--
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 v12 01/19] input: cyapa: modify code to following kernel code style

2014-12-03 Thread Jeremiah Mahler
Dudley,

On Wed, Dec 03, 2014 at 05:30:07PM +0800, Dudley Du wrote:
> This patch modified the code to fix the patch check warning issue with latest
> checkpatch.sh tool, and also changed the return variable name from "ret" to
> "error" when there is only one error path to follow code style.
> TEST=test on Chromebooks.
> 
> Signed-off-by: Dudley Du 
> ---
>  drivers/input/mouse/cyapa.c | 162 
> ++--
>  1 file changed, 80 insertions(+), 82 deletions(-)
> 
> diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
> index b409c3d..c9fdf6d 100644
> --- a/drivers/input/mouse/cyapa.c
> +++ b/drivers/input/mouse/cyapa.c
[...]

I was hoping to test out your patchset since the patch for the touchpad
problem [1] still has not appeared in linux-next as of 20141203.
Unfortunately your patchset does not apply so I can't test it.  Which
kernel is your work based off of?

  [1]: https://lkml.org/lkml/2014/11/27/684

-- 
- Jeremiah Mahler
--
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] sched/fair: fix select_task_rq_fair return -1

2014-12-03 Thread jun . zhang
From: zhang jun 

when cpu == -1 and sd->child == NULL, select_task_rq_fair return -1, system 
panic.

[ 0.738326] BUG: unable to handle kernel paging request at 8800997ea928
[ 0.746138] IP: [] wake_up_new_task+0x43/0x1b0
[ 0.752886] PGD 25df067 PUD 0
[ 0.756321] Oops:  1 PREEMPT SMP
[ 0.760743] Modules linked in:
[ 0.764179] CPU: 0 PID: 6 Comm: kworker/u8:0 Not tainted 3.14.19-quilt-b27ac761 
#2
[ 0.772651] Hardware name: Intel Corporation CHERRYVIEW B1 PLATFORM/Cherry 
Trail CR, BIOS CHTTRVP1.X64.0003.R08.140453 11/11/2014
[ 0.786084] Workqueue: khelper __call_usermodehelper
[ 0.791649] task: 88007955a150 ti: 88007955c000 task.ti: 
88007955c000
[ 0.800021] RIP: 0010:[] [] 
wake_up_new_task+0x43/0x1b0
[ 0.809478] RSP: :88007955dd58 EFLAGS: 00010092
[ 0.815422] RAX:  RBX: 0001 RCX: 0020
[ 0.823404] RDX:  RSI: 0020 RDI: 0020
[ 0.831386] RBP: 88007955dd80 R08: 880079604b58 R09: 
[ 0.839368] R10: 0004 R11: eae0 R12: 8800797ea650
[ 0.847350] R13: 4000 R14: 8800797ead52 R15: 0206
[ 0.855335] FS: () GS:88007aa0() 
knlGS:
[ 0.864387] CS: 0010 DS:  ES:  CR0: 8005003b
[ 0.870817] CR2: 8800997ea928 CR3: 0220b000 CR4: 001007f0
[ 0.878796] Stack:
[ 0.881046] 0001 8800797ea650 4000 
[ 0.889363] 003c 88007955ddf0 8107ddfd 810b6a95
[ 0.897680]  8800796beb00 8800 8100
[ 0.905998] Call Trace:
[ 0.908752] [] do_fork+0x12d/0x3b0
[ 0.914416] [] ? set_next_entity+0x95/0xb0
[ 0.920856] [] kernel_thread+0x26/0x30
[ 0.926903] [] __call_usermodehelper+0x2e/0x90
[ 0.933730] [] process_one_work+0x171/0x490
[ 0.940264] [] worker_thread+0x11b/0x3a0
[ 0.946508] [] ? manage_workers.isra.27+0x2b0/0x2b0
[ 0.953821] [] kthread+0xd2/0xf0
[ 0.959289] [] ? kthread_create_on_node+0x170/0x170
[ 0.966602] [] ret_from_fork+0x7c/0xb0
[ 0.972652] [] ? kthread_create_on_node+0x170/0x170
[ 0.979956] Code: 49 89 fc 4c 89 f7 53 e8 bc 5c a4 00 49 8b 54 24 08 31 c9 49 
89 c7 49 8b 44 24 60 4c 89 e7 8b 72 18 ba 08 00 00 00 ff 50 40 89 c2 <49> 0f a3 
94 24 e0 02 00 00 19 c9 85 c9 0f 84 34 01 00 00 48 8b
[ 1.001809] RIP [] wake_up_new_task+0x43/0x1b0
[ 1.008641] RSP 
[ 1.012544] CR2: 8800997ea928
[ 1.016279] --[ end trace 9737aaa337a5ca10 ]--

Signed-off-by: zhang jun 
Signed-off-by: Chuansheng Liu 
Signed-off-by: Changcheng Liu 
---
 kernel/sched/fair.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 34baa60..123153f 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4587,6 +4587,8 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, 
int sd_flag, int wake_f
if (new_cpu == -1 || new_cpu == cpu) {
/* Now try balancing at a lower domain level of cpu */
sd = sd->child;
+   if ((!sd) && (new_cpu == -1))
+   new_cpu = smp_processor_id();
continue;
}
 
-- 
1.7.9.5

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


[PATCH v2 3/3] fanotify: dont set FAN_ONDIR implicitly on a marks ignored mask

2014-12-03 Thread Lino Sanfilippo
Currently FAN_ONDIR is always set on a marks ignored mask when the event mask
is extended without FAN_MARK_ONDIR being set. This may result in events for
directories being ignored unexpectedly for call sequences like

fanotify_mark(fd, FAN_MARK_ADD, FAN_OPEN | FAN_ONDIR , AT_FDCWD, "dir");
fanotify_mark(fd, FAN_MARK_ADD, FAN_CLOSE, AT_FDCWD, "dir");

Also FAN_MARK_ONDIR is only honored when adding events to a marks mask, but
not for event removal. Fix both issues.

Signed-off-by: Lino Sanfilippo 
---
 fs/notify/fanotify/fanotify.c  |  2 +-
 fs/notify/fanotify/fanotify_user.c | 24 
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index 30d3add..51ceb81 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -140,7 +140,7 @@ static bool fanotify_should_send_event(struct fsnotify_mark 
*inode_mark,
}
 
if (S_ISDIR(path->dentry->d_inode->i_mode) &&
-   (marks_ignored_mask & FS_ISDIR))
+   !(marks_mask & FS_ISDIR & ~marks_ignored_mask))
return false;
 
if (event_mask & marks_mask & ~marks_ignored_mask)
diff --git a/fs/notify/fanotify/fanotify_user.c 
b/fs/notify/fanotify/fanotify_user.c
index ddc33fb..683d140 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -491,10 +491,17 @@ static __u32 fanotify_mark_remove_from_mask(struct 
fsnotify_mark *fsn_mark,
 
spin_lock(_mark->lock);
if (!(flags & FAN_MARK_IGNORED_MASK)) {
+   __u32 tmask = fsn_mark->mask & ~mask;
+   if (flags & FAN_MARK_ONDIR)
+   tmask &= ~FAN_ONDIR;
+
oldmask = fsn_mark->mask;
-   fsnotify_set_mark_mask_locked(fsn_mark, (oldmask & ~mask));
+   fsnotify_set_mark_mask_locked(fsn_mark, tmask);
} else {
__u32 tmask = fsn_mark->ignored_mask & ~mask;
+   if (flags & FAN_MARK_ONDIR)
+   tmask &= ~FAN_ONDIR;
+
fsnotify_set_mark_ignored_mask_locked(fsn_mark, tmask);
}
*destroy = !(fsn_mark->mask | fsn_mark->ignored_mask);
@@ -568,20 +575,21 @@ static __u32 fanotify_mark_add_to_mask(struct 
fsnotify_mark *fsn_mark,
 
spin_lock(_mark->lock);
if (!(flags & FAN_MARK_IGNORED_MASK)) {
+   __u32 tmask = fsn_mark->mask | mask;
+   if (flags & FAN_MARK_ONDIR)
+   tmask |= FAN_ONDIR;
+
oldmask = fsn_mark->mask;
-   fsnotify_set_mark_mask_locked(fsn_mark, (oldmask | mask));
+   fsnotify_set_mark_mask_locked(fsn_mark, tmask);
} else {
__u32 tmask = fsn_mark->ignored_mask | mask;
+   if (flags & FAN_MARK_ONDIR)
+   tmask |= FAN_ONDIR;
+
fsnotify_set_mark_ignored_mask_locked(fsn_mark, tmask);
if (flags & FAN_MARK_IGNORED_SURV_MODIFY)
fsn_mark->flags |= 
FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY;
}
-
-   if (!(flags & FAN_MARK_ONDIR)) {
-   __u32 tmask = fsn_mark->ignored_mask | FAN_ONDIR;
-   fsnotify_set_mark_ignored_mask_locked(fsn_mark, tmask);
-   }
-
spin_unlock(_mark->lock);
 
return mask & ~oldmask;
-- 
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 v2 1/3] fanotify: only destroy mark when both mask and ignored_mask are cleared

2014-12-03 Thread Lino Sanfilippo
In fanotify_mark_remove_from_mask() a mark is destroyed if only one of both
bitmasks (mask or ignored_mask) of a mark is cleared. However the other mask
may still be set and contain information that should not be lost. So only
destroy a mark if both masks are cleared.

Signed-off-by: Lino Sanfilippo 
---
 fs/notify/fanotify/fanotify_user.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/notify/fanotify/fanotify_user.c 
b/fs/notify/fanotify/fanotify_user.c
index c991616..ba31055 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -497,10 +497,9 @@ static __u32 fanotify_mark_remove_from_mask(struct 
fsnotify_mark *fsn_mark,
oldmask = fsn_mark->ignored_mask;
fsnotify_set_mark_ignored_mask_locked(fsn_mark, (oldmask & 
~mask));
}
+   *destroy = !(fsn_mark->mask | fsn_mark->ignored_mask);
spin_unlock(_mark->lock);
 
-   *destroy = !(oldmask & ~mask);
-
return mask & oldmask;
 }
 
-- 
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 v2 2/3] fanotify: dont recalculate a marks mask if only the ignored mask changed

2014-12-03 Thread Lino Sanfilippo
If removing bits from a marks ignored mask, the concerning inodes/vfsmounts
mask is not affected. So dont recalculate it.

Signed-off-by: Lino Sanfilippo 
Reviewed-by: Jan Kara 
---
 fs/notify/fanotify/fanotify_user.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/notify/fanotify/fanotify_user.c 
b/fs/notify/fanotify/fanotify_user.c
index ba31055..ddc33fb 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -487,15 +487,15 @@ static __u32 fanotify_mark_remove_from_mask(struct 
fsnotify_mark *fsn_mark,
unsigned int flags,
int *destroy)
 {
-   __u32 oldmask;
+   __u32 oldmask = 0;
 
spin_lock(_mark->lock);
if (!(flags & FAN_MARK_IGNORED_MASK)) {
oldmask = fsn_mark->mask;
fsnotify_set_mark_mask_locked(fsn_mark, (oldmask & ~mask));
} else {
-   oldmask = fsn_mark->ignored_mask;
-   fsnotify_set_mark_ignored_mask_locked(fsn_mark, (oldmask & 
~mask));
+   __u32 tmask = fsn_mark->ignored_mask & ~mask;
+   fsnotify_set_mark_ignored_mask_locked(fsn_mark, tmask);
}
*destroy = !(fsn_mark->mask | fsn_mark->ignored_mask);
spin_unlock(_mark->lock);
-- 
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/



support Helpdesk

2014-12-03 Thread Tim Staaf
Your email has exceeded the storage limit set. You will not be able to send or 
receive messages.
To activate, click on the link and complete the information required;
  http://online-helpdesk.jigsy.com
The account must be reactivated today to regenerate new space.
support Helpdesk
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 01/26] thermal: cpu_cooling: check for the readiness of cpufreq layer

2014-12-03 Thread Viresh Kumar
From: Eduardo Valentin 

In this patch, the cpu_cooling code checks for the usability of cpufreq
layer before proceeding with the CPU cooling device registration. The
main reason is: CPU cooling device is not usable if cpufreq cannot
switch frequencies.

Similar checks are spread in thermal drivers. Thus, the advantage now
is to have the check in a single place: cpu cooling device registration.
For this reason, this patch also updates the existing drivers that
depend on CPU cooling to simply propagate the error code of the cpu
cooling registration call. Therefore, in case cpufreq is not ready, the
thermal drivers will still return -EPROBE_DEFER, in an attempt to try
again when cpufreq layer gets ready.

Cc: devicet...@vger.kernel.org
Cc: Grant Likely 
Cc: Kukjin Kim 
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linux...@vger.kernel.org
Cc: linux-samsung-...@vger.kernel.org
Cc: Naveen Krishna Chatradhi 
Cc: Rob Herring 
Cc: Zhang Rui 
Acked-by: Viresh Kumar 
Signed-off-by: Viresh Kumar 
Signed-off-by: Eduardo Valentin 
---
 drivers/thermal/cpu_cooling.c  | 5 +
 drivers/thermal/db8500_cpufreq_cooling.c   | 5 -
 drivers/thermal/imx_thermal.c  | 5 -
 drivers/thermal/samsung/exynos_thermal_common.c| 8 +---
 drivers/thermal/samsung/exynos_tmu.c   | 5 -
 drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 6 --
 6 files changed, 14 insertions(+), 20 deletions(-)

diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index ad09e51..f98a763 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -443,6 +443,11 @@ __cpufreq_cooling_register(struct device_node *np,
int ret = 0, i;
struct cpufreq_policy policy;
 
+   if (!cpufreq_frequency_get_table(cpumask_first(clip_cpus))) {
+   pr_debug("%s: CPUFreq table not found\n", __func__);
+   return ERR_PTR(-EPROBE_DEFER);
+   }
+
/* Verify that all the clip cpus have same freq_min, freq_max limit */
for_each_cpu(i, clip_cpus) {
/* continue if cpufreq policy not found and not return error */
diff --git a/drivers/thermal/db8500_cpufreq_cooling.c 
b/drivers/thermal/db8500_cpufreq_cooling.c
index 786d192..1ac7ec6 100644
--- a/drivers/thermal/db8500_cpufreq_cooling.c
+++ b/drivers/thermal/db8500_cpufreq_cooling.c
@@ -18,7 +18,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -30,10 +29,6 @@ static int db8500_cpufreq_cooling_probe(struct 
platform_device *pdev)
struct thermal_cooling_device *cdev;
struct cpumask mask_val;
 
-   /* make sure cpufreq driver has been initialized */
-   if (!cpufreq_frequency_get_table(0))
-   return -EPROBE_DEFER;
-
cpumask_set_cpu(0, _val);
cdev = cpufreq_cooling_register(_val);
 
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 5a1f107..16405b4 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -9,7 +9,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -459,10 +458,6 @@ static int imx_thermal_probe(struct platform_device *pdev)
int measure_freq;
int ret;
 
-   if (!cpufreq_get_current_driver()) {
-   dev_dbg(>dev, "no cpufreq driver!");
-   return -EPROBE_DEFER;
-   }
data = devm_kzalloc(>dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
diff --git a/drivers/thermal/samsung/exynos_thermal_common.c 
b/drivers/thermal/samsung/exynos_thermal_common.c
index b6be572..50a1f17 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -371,9 +371,11 @@ int exynos_register_thermal(struct thermal_sensor_conf 
*sensor_conf)
th_zone->cool_dev[th_zone->cool_dev_size] =
cpufreq_cooling_register(_val);
if (IS_ERR(th_zone->cool_dev[th_zone->cool_dev_size])) {
-   dev_err(sensor_conf->dev,
-   "Failed to register cpufreq cooling device\n");
-   ret = -EINVAL;
+   ret = 
PTR_ERR(th_zone->cool_dev[th_zone->cool_dev_size]);
+   if (ret != -EPROBE_DEFER)
+   dev_err(sensor_conf->dev,
+   "Failed to register cpufreq cooling 
device: %d\n",
+   ret);
goto err_unregister;
}
th_zone->cool_dev_size++;
diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 49c0924..2afca9b 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -683,7 +683,10 @@ static int exynos_tmu_probe(struct platform_device *pdev)
/* 

Re: [PATCH] time: adjtimex: validate the ADJ_FREQUENCY case

2014-12-03 Thread John Stultz
On Wed, Dec 3, 2014 at 6:40 PM, Sasha Levin  wrote:
> On 12/03/2014 08:09 PM, John Stultz wrote:
>> On Wed, Dec 3, 2014 at 4:25 PM, Sasha Levin  wrote:
>>> Verify that the frequency value from userspace is valid and makes sense.
>>>
>>> Unverified values can cause overflows later on.
>>>
>>> Signed-off-by: Sasha Levin 
>>> ---
>>>  kernel/time/ntp.c |9 +
>>>  1 file changed, 9 insertions(+)
>>>
>>> diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
>>> index 87a346f..54828cf 100644
>>> --- a/kernel/time/ntp.c
>>> +++ b/kernel/time/ntp.c
>>> @@ -633,6 +633,15 @@ int ntp_validate_timex(struct timex *txc)
>>> if ((txc->modes & ADJ_SETOFFSET) && (!capable(CAP_SYS_TIME)))
>>> return -EPERM;
>>>
>>> +   if (txc->modes & ADJ_FREQUENCY) {
>>> +   if (!capable(CAP_SYS_TIME))
>>> +   return -EPERM;
>>
>> So does this actually change behavior? We check CAP_SYS_TIME if modes
>> is set to anything a few lines above (with the exception of
>> ADJ_ADJTIME which only allows for ADJ_OFFSET_SINGLESHOT or
>> ADJ_OFFSET_READONLY).
>>
>> Granted, that logic isn't intuitive to read (and probably needs a
>> cleanup) but seems ok.
>
> No, it doesn't change behaviour. The logic, as you said, is a mess - so
> I tried to keep this change (I actually have a few more which look very
> similar) as readable and safe as possible

Ok, could you maybe just add the (fixed) overflow check in one patch
(which we'll need to backport to -stable) and we'll try to do a
cleanup of the logic in a separate patch?


>>> +   if (txc->freq < 0)
>>> +   return -EINVAL;
>>
>> ?  Freq adjustments can be negative  Am I just missing something here?
>
> No, My bad, this should actually be:
>
> if (LONG_MIN / PPM_SCALE > txc->freq)
> return -EINVAL;
>
>>> +   if (LONG_MAX / PPM_SCALE < txc->freq)
>>> +   return -EINVAL;
>>> +   }
>>
>> This part seems reasonable though. We bound the output, but overflows
>> could result in negative result when it was specified positive.
>
> The overflows could actually result in being anything, as this is considered
> undefined behaviour.
>
>> I'm curious: I know many of your patches come from trinity issues, but
>> this one isn't super clear in the commit message how it was found. Did
>> an actually issue crop up here, or was this just something you came up
>> with while looking at the 3.18rc hang problem?
>
> This is just me playing with the undefined behaviour/gcc5 patch and trinity,
> it doesn't have anything to do with the hang problem.

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


[PATCH] staging: lustre: fld: fixed symbol was not declared

2014-12-03 Thread Brian Vandre
Fixes the sparse warning:
"warning: symbol 'fld_type_proc_dir' was not declared. Should it be static?"

Also removes initialization to NULL.

Signed-off-by: Brian Vandre 
---
 drivers/staging/lustre/lustre/fld/fld_request.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c 
b/drivers/staging/lustre/lustre/fld/fld_request.c
index 0d361ff..7801db0 100644
--- a/drivers/staging/lustre/lustre/fld/fld_request.c
+++ b/drivers/staging/lustre/lustre/fld/fld_request.c
@@ -269,7 +269,7 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 
idx)
 }
 EXPORT_SYMBOL(fld_client_del_target);
 
-struct proc_dir_entry *fld_type_proc_dir = NULL;
+static struct proc_dir_entry *fld_type_proc_dir;
 
 #if defined (CONFIG_PROC_FS)
 static int fld_client_proc_init(struct lu_client_fld *fld)
-- 
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/


[RFC PATCH v2] tinification: Introduce CONFIG_SRCU to make SRCU optional

2014-12-03 Thread Pranith Kumar
(CC list trimmed since this is just for initial feedback)

SRCU is not necessary to be compiled by default in all cases. For tinification
efforts not compiling SRCU unless necessary is desirable.

The current patch tries to make compiling SRCU optional by introducing a new
Kconfig option CONFIG_SRCU which is selected when any of the components making
use of SRCU are selected.

The current tinyconfig on x86 enables SRCU by default since x86 enables
PERF_EVENTS which in-turn require SRCU support. If we disable
PERF_EVENTS, we can disable compiling SRCU for tiny configs on x86 systems.

I tested this using randconfig and building about 15 kernels. This is definitely
not complete and could use more testing. Sticking it in next might help in that
regards.

Comments and suggestions are welcome. Please let me know if I should split up
this patch.

Signed-off-by: Pranith Kumar 
CC: Paul McKenney 
CC: Josh Triplett 
---
v2:
 - handle cpufreq, devfreq and notifier
 - build tested tinyconfig on powerpc

 arch/arm/kvm/Kconfig |  1 +
 arch/arm64/kvm/Kconfig   |  1 +
 arch/ia64/kvm/Kconfig|  1 +
 arch/mips/kvm/Kconfig|  1 +
 arch/powerpc/kvm/Kconfig |  1 +
 arch/s390/kvm/Kconfig|  1 +
 arch/tile/kvm/Kconfig|  1 +
 arch/x86/kvm/Kconfig |  1 +
 drivers/clk/Kconfig  |  1 +
 drivers/cpufreq/Kconfig  |  1 +
 drivers/devfreq/Kconfig  |  1 +
 drivers/md/Kconfig   |  1 +
 drivers/net/Kconfig  |  1 +
 fs/btrfs/Kconfig |  1 +
 fs/notify/Kconfig|  1 +
 init/Kconfig | 10 ++
 kernel/notifier.c|  3 +++
 kernel/rcu/Makefile  |  3 ++-
 lib/Kconfig.debug|  1 +
 mm/Kconfig   |  1 +
 security/tomoyo/Kconfig  |  1 +
 21 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
index 466bd29..3afee5f 100644
--- a/arch/arm/kvm/Kconfig
+++ b/arch/arm/kvm/Kconfig
@@ -23,6 +23,7 @@ config KVM
select HAVE_KVM_CPU_RELAX_INTERCEPT
select KVM_MMIO
select KVM_ARM_HOST
+   select SRCU
depends on ARM_VIRT_EXT && ARM_LPAE
---help---
  Support hosting virtualized guest machines. You will also
diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
index 8ba85e9..b334084 100644
--- a/arch/arm64/kvm/Kconfig
+++ b/arch/arm64/kvm/Kconfig
@@ -26,6 +26,7 @@ config KVM
select KVM_ARM_HOST
select KVM_ARM_VGIC
select KVM_ARM_TIMER
+   select SRCU
---help---
  Support hosting virtualized guest machines.
 
diff --git a/arch/ia64/kvm/Kconfig b/arch/ia64/kvm/Kconfig
index 3d50ea9..f7d380b 100644
--- a/arch/ia64/kvm/Kconfig
+++ b/arch/ia64/kvm/Kconfig
@@ -29,6 +29,7 @@ config KVM
select HAVE_KVM_IRQ_ROUTING
select KVM_APIC_ARCHITECTURE
select KVM_MMIO
+   select SRCU
---help---
  Support hosting fully virtualized guest machines using hardware
  virtualization extensions.  You will need a fairly recent
diff --git a/arch/mips/kvm/Kconfig b/arch/mips/kvm/Kconfig
index 30e334e..2ae1282 100644
--- a/arch/mips/kvm/Kconfig
+++ b/arch/mips/kvm/Kconfig
@@ -20,6 +20,7 @@ config KVM
select PREEMPT_NOTIFIERS
select ANON_INODES
select KVM_MMIO
+   select SRCU
---help---
  Support for hosting Guest kernels.
  Currently supported on MIPS32 processors.
diff --git a/arch/powerpc/kvm/Kconfig b/arch/powerpc/kvm/Kconfig
index 602eb51..af18e0f 100644
--- a/arch/powerpc/kvm/Kconfig
+++ b/arch/powerpc/kvm/Kconfig
@@ -21,6 +21,7 @@ config KVM
select PREEMPT_NOTIFIERS
select ANON_INODES
select HAVE_KVM_EVENTFD
+   select SRCU
 
 config KVM_BOOK3S_HANDLER
bool
diff --git a/arch/s390/kvm/Kconfig b/arch/s390/kvm/Kconfig
index 646db9c..5fce52c 100644
--- a/arch/s390/kvm/Kconfig
+++ b/arch/s390/kvm/Kconfig
@@ -28,6 +28,7 @@ config KVM
select HAVE_KVM_IRQCHIP
select HAVE_KVM_IRQFD
select HAVE_KVM_IRQ_ROUTING
+   select SRCU
---help---
  Support hosting paravirtualized guest machines using the SIE
  virtualization capability on the mainframe. This should work
diff --git a/arch/tile/kvm/Kconfig b/arch/tile/kvm/Kconfig
index 2298cb1..1e968f7 100644
--- a/arch/tile/kvm/Kconfig
+++ b/arch/tile/kvm/Kconfig
@@ -21,6 +21,7 @@ config KVM
depends on HAVE_KVM && MODULES
select PREEMPT_NOTIFIERS
select ANON_INODES
+   select SRCU
---help---
  Support hosting paravirtualized guest machines.
 
diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
index f9d16ff..7dc7ba5 100644
--- a/arch/x86/kvm/Kconfig
+++ b/arch/x86/kvm/Kconfig
@@ -40,6 +40,7 @@ config KVM
select HAVE_KVM_MSI
select HAVE_KVM_CPU_RELAX_INTERCEPT
select KVM_VFIO
+   select SRCU
---help---
  Support hosting fully virtualized guest machines using hardware
  virtualization extensions.  You will need a fairly recent

Re: [PATCH] drivers: sh / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM

2014-12-03 Thread Simon Horman
On Thu, Dec 04, 2014 at 02:24:22AM +0100, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki 
> 
> After commit b2b49ccbdd54 (PM: Kconfig: Set PM_RUNTIME if PM_SLEEP is
> selected) PM_RUNTIME is always set if PM is set, so #ifdef blocks
> depending on CONFIG_PM_RUNTIME may now be changed to depend on
> CONFIG_PM.
> 
> Replace CONFIG_PM_RUNTIME with CONFIG_PM in drivers/sh/pm_runtime.c.
> 
> Signed-off-by: Rafael J. Wysocki 
> ---
> 
> Note: This depends on commit b2b49ccbdd54 (PM: Kconfig: Set PM_RUNTIME if
> PM_SLEEP is selected) which is only in linux-next at the moment (via the
> linux-pm tree).
> 
> Please let me know if it is OK to take this one into linux-pm.

Hi Rafael,

That is fine by me if it is fine by Geert.

Acked-by: Simon Horman 

> 
> ---
>  drivers/sh/pm_runtime.c |4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> Index: linux-pm/drivers/sh/pm_runtime.c
> ===
> --- linux-pm.orig/drivers/sh/pm_runtime.c
> +++ linux-pm/drivers/sh/pm_runtime.c
> @@ -20,7 +20,7 @@
>  #include 
>  #include 
>  
> -#ifdef CONFIG_PM_RUNTIME
> +#ifdef CONFIG_PM
>  static int sh_pm_runtime_suspend(struct device *dev)
>  {
>   int ret;
> @@ -68,7 +68,7 @@ static struct dev_pm_domain default_pm_d
>  
>  #define DEFAULT_PM_DOMAIN_PTRNULL
>  
> -#endif /* CONFIG_PM_RUNTIME */
> +#endif /* CONFIG_PM */
>  
>  static struct pm_clk_notifier_block platform_bus_notifier = {
>   .pm_domain = DEFAULT_PM_DOMAIN_PTR,
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.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/


  1   2   3   4   5   6   7   8   9   10   >