Re: [PATCH 1/8] ntp: Fix STA_INS/DEL clearing bug

2012-07-12 Thread Ingo Molnar

* John Stultz  wrote:

> From: John Stultz 
> 
> In commit 6b43ae8a619d17c4935c3320d2ef9e92bdeed05d, I
> introduced a bug that kept the STA_INS or STA_DEL bit
> from being cleared from time_status via adjtimex()
> without forcing STA_PLL first.
> 
> Usually once the STA_INS is set, it isn't cleared
> until the leap second is applied, so its unlikely this
> affected anyone. However during testing I noticed it
> took some effort to cancel a leap second once STA_INS
> was set.
> 
> This issue affects 3.4 and up.
> 
> Since this isn't urgent (issue is only observed in testing,
> the behavior doesn't affect ntpd, nor is a leapsecond due
> for at least ~6 months), and we're late in the 3.5-rc
> cycle, I'm holding this off for 3.6 merge window,
> where I'll then backport to 3.5-stable and 3.4-stable.

> CC: sta...@vger.kernel.org

We generally don't do such a workflow. Either it's valid for 
tip:timers/urgent and it can have a -stable tag, or it should 
not be backported, and not have a -stable tag.

The rule is: if it's important enough for -stable then it's 
doubly important for the current -rc kernel!

Thanks,

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


Re: [PATCH 5/8] time: Refactor accumulation of nsecs to secs

2012-07-12 Thread Ingo Molnar

* John Stultz  wrote:

> We do the exact same logic moving nsecs to secs in the
> timekeeper in multiple places, so condense this into a
> single function.
> 
> CC: Ingo Molnar 
> CC: Peter Zijlstra 
> CC: Richard Cochran 
> CC: Prarit Bhargava 
> CC: Thomas Gleixner 

Please make that Cc:, not CC:.

Thanks,

Ingo
--
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: How to use the generic thermal sysfs.

2012-07-12 Thread R, Durgadoss
> -Original Message-
> From: Alex Courbot [mailto:acour...@nvidia.com]
> Sent: Friday, July 13, 2012 11:19 AM
> To: R, Durgadoss
> Cc: Wei Ni; Zhang, Rui; Brown, Len; a...@linux-foundation.org; khali@linux-
> fr.org; j...@perches.com; linux-kernel@vger.kernel.org; linux-
> te...@ger.kernel.org
> Subject: Re: How to use the generic thermal sysfs.
> 
> On 07/12/2012 07:54 PM, R, Durgadoss wrote:
> > We are working on a notification API from any generic sensor driver to
> > the thermal framework.
> > Please have a look at the 'notify_thermal_framework' API in the patch here:
> > http://www.spinics.net/lists/linux-acpi/msg36049.html
> 
> At first sight these patches look close to what we need as well. Are you
> considering to support the definitions of thermal zones using the device
> tree? Is there a public git tree where we can pull the latest version of
> this code in order to keep in sync with you guys?

As of now, we are getting the definitions done through the platform layer
data. Considerations for device tree .. yes.. but I do not have any sample
implementation..

On the public tree:
Rui is trying to get a public tree from where we can pull Thermal subsystem
changes; and submit patches against this tree.

I hope Rui will publish the link very soon :-)

Thanks,
Durga


Re: [PATCH net-next 4/8] wireless: Use eth_random_addr

2012-07-12 Thread Hin-Tak Leung
--- On Fri, 13/7/12, Joe Perches  wrote:

> From: Joe Perches 
> Subject: [PATCH net-next 4/8] wireless: Use eth_random_addr
> To: "David Miller" , "John W. Linville" 
> , "Christian Lamparter" , 
> "Ivo van Doorn" , "Gertjan van Wingerde" 
> , "Helmut Schaa" , "Herton 
> Ronaldo Krzesinski" , "Hin-Tak Leung" 
> , "Larry Finger" 
> Cc: "Johannes Berg" , 
> linux-wirel...@vger.kernel.org, net...@vger.kernel.org, 
> linux-kernel@vger.kernel.org, us...@rt2x00.serialmonkey.com
> Date: Friday, 13 July, 2012, 6:33
> Convert the existing uses of
> random_ether_addr to
> the new eth_random_addr.
> 
> Signed-off-by: Joe Perches 

Acked-by: Hin-Tak Leung 

Would it make sense to have a "check & set" macro? 

> ---
>  drivers/net/wireless/adm8211.c       
>      |    2 +-
>  drivers/net/wireless/p54/eeprom.c     
>     |    2 +-
>  drivers/net/wireless/rt2x00/rt2400pci.c   
> |    2 +-
>  drivers/net/wireless/rt2x00/rt2500pci.c   
> |    2 +-
>  drivers/net/wireless/rt2x00/rt2500usb.c   
> |    2 +-
>  drivers/net/wireless/rt2x00/rt2800lib.c   
> |    2 +-
>  drivers/net/wireless/rt2x00/rt61pci.c     
> |    2 +-
>  drivers/net/wireless/rt2x00/rt73usb.c     
> |    2 +-
>  drivers/net/wireless/rtl818x/rtl8180/dev.c |    2
> +-
>  drivers/net/wireless/rtl818x/rtl8187/dev.c |    2
> +-
>  10 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/wireless/adm8211.c
> b/drivers/net/wireless/adm8211.c
> index 97afcec..689a71c 100644
> --- a/drivers/net/wireless/adm8211.c
> +++ b/drivers/net/wireless/adm8211.c
> @@ -1854,7 +1854,7 @@ static int __devinit
> adm8211_probe(struct pci_dev *pdev,
>      if (!is_valid_ether_addr(perm_addr)) {
>          printk(KERN_WARNING
> "%s (adm8211): Invalid hwaddr in EEPROM!\n",
>             
>    pci_name(pdev));
> -       
> random_ether_addr(perm_addr);
> +       
> eth_random_addr(perm_addr);
>      }
>      SET_IEEE80211_PERM_ADDR(dev,
> perm_addr);
>  
> diff --git a/drivers/net/wireless/p54/eeprom.c
> b/drivers/net/wireless/p54/eeprom.c
> index 636daf2..1403709 100644
> --- a/drivers/net/wireless/p54/eeprom.c
> +++ b/drivers/net/wireless/p54/eeprom.c
> @@ -857,7 +857,7 @@ good_eeprom:
>  
>         
> wiphy_warn(dev->wiphy,
>             
>    "Invalid hwaddr! Using randomly generated
> MAC addr\n");
> -       
> random_ether_addr(perm_addr);
> +       
> eth_random_addr(perm_addr);
>         
> SET_IEEE80211_PERM_ADDR(dev, perm_addr);
>      }
>  
> diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c
> b/drivers/net/wireless/rt2x00/rt2400pci.c
> index 5e6b501..8b9dbd7 100644
> --- a/drivers/net/wireless/rt2x00/rt2400pci.c
> +++ b/drivers/net/wireless/rt2x00/rt2400pci.c
> @@ -1455,7 +1455,7 @@ static int
> rt2400pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
>   */
>      mac = rt2x00_eeprom_addr(rt2x00dev,
> EEPROM_MAC_ADDR_0);
>      if (!is_valid_ether_addr(mac)) {
> -       
> random_ether_addr(mac);
> +       
> eth_random_addr(mac);
>          EEPROM(rt2x00dev,
> "MAC: %pM\n", mac);
>      }
>  
> diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c
> b/drivers/net/wireless/rt2x00/rt2500pci.c
> index 136b849..d2cf8a4 100644
> --- a/drivers/net/wireless/rt2x00/rt2500pci.c
> +++ b/drivers/net/wireless/rt2x00/rt2500pci.c
> @@ -1585,7 +1585,7 @@ static int
> rt2500pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
>   */
>      mac = rt2x00_eeprom_addr(rt2x00dev,
> EEPROM_MAC_ADDR_0);
>      if (!is_valid_ether_addr(mac)) {
> -       
> random_ether_addr(mac);
> +       
> eth_random_addr(mac);
>          EEPROM(rt2x00dev,
> "MAC: %pM\n", mac);
>      }
>  
> diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c
> b/drivers/net/wireless/rt2x00/rt2500usb.c
> index 669aecd..3aae36b 100644
> --- a/drivers/net/wireless/rt2x00/rt2500usb.c
> +++ b/drivers/net/wireless/rt2x00/rt2500usb.c
> @@ -1352,7 +1352,7 @@ static int
> rt2500usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
>   */
>      mac = rt2x00_eeprom_addr(rt2x00dev,
> EEPROM_MAC_ADDR_0);
>      if (!is_valid_ether_addr(mac)) {
> -       
> random_ether_addr(mac);
> +       
> eth_random_addr(mac);
>          EEPROM(rt2x00dev,
> "MAC: %pM\n", mac);
>      }
>  
> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c
> b/drivers/net/wireless/rt2x00/rt2800lib.c
> index 068276e..d857d55 100644
> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
> @@ -4340,7 +4340,7 @@ int rt2800_validate_eeprom(struct
> rt2x00_dev *rt2x00dev)
>   */
>      mac = rt2x00_eeprom_addr(rt2x00dev,
> EEPROM_MAC_ADDR_0);
>      if (!is_valid_ether_addr(mac)) {
> -       
> random_ether_addr(mac);
> +       
> eth_random_addr(mac);
>          EEPROM(rt2x00dev,
> "MAC: %pM\n", mac);
>      }
>  
> diff --git a/drivers/net/wireless/rt2x00/rt61pci.c
> b/drivers/net/wireless/rt2x00/rt61pci.c
> index ee22bd7..f322596 100644
> --- a/drivers/net/wireless/rt2x00/rt61pci.c
> +++ b/drivers/net/wireless/rt2x00/rt61pci.c
> @@ -2415,7 +2415,7 @@ static int
> 

Re: [PATCH 0/3] fs/ufs: stop using write_supers and s_dirt

2012-07-12 Thread Artem Bityutskiy
On Thu, 2012-07-12 at 22:45 -0700, Andrew Morton wrote:
> checkpatch does not report on context lines - only on added lines.

Hmm, I think I saw it ding this in the past. Anyway, I have no problems
cleaning at lease white-spaces in UFS globally separately.

-- 
Best Regards,
Artem Bityutskiy


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


linux-next: Tree for July 13

2012-07-12 Thread Stephen Rothwell
Hi all,

Changes since 20120712:

The ext4 tree still has its build failure so I used the version from
next-20120709.

The tty tree gained a build failure, so I used the version from
next-20120712.

I have still reverted 3 commits from the signal tree at the request of the
arm maintainer.

The arm-soc tree lost a conflict.
 
The clk tree gained a conflict against the arm-soc tree.



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

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

Below is a summary of the state of the merge.

We are up to 197 trees (counting Linus' and 26 trees of patches pending
for Linus' tree), more are welcome (even if they are currently empty).
Thanks to those who have contributed, and to those who haven't, please do.

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

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

There is a wiki covering stuff to do with linux-next at
http://linux.f-seidel.de/linux-next/pmwiki/ .  Thanks to Frank Seidel.

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

$ git checkout master
$ git reset --hard stable
Merging origin/master (918227b Merge tag 'fbdev-fixes-for-3.5-2' of 
git://github.com/schandinat/linux-2.6)
Merging fixes/master (9023a40 Merge tag 'mmc-fixes-for-3.5-rc4' of 
git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc)
Merging kbuild-current/rc-fixes (f8f5701 Linux 3.5-rc1)
Merging arm-current/fixes (ff081e0 ARM: 7457/1: smp: Fix suspicious RCU 
originating from cpu_die())
Merging m68k-current/for-linus (d8ce726 m68k: Use generic strncpy_from_user(), 
strlen_user(), and strnlen_user())
Merging powerpc-merge/merge (50fb31c tty/hvc_opal: Fix debug function name)
Merging sparc/master (d55de60 sparc64: remove unused function 
straddles_64bit_va_hole())
Merging net/master (7ac2908 sch_sfb: Fix missing NULL check)
Merging sound-current/for-linus (9e9b594 ALSA: usb-audio: Fix the first PCM 
interface assignment)
Merging pci-current/for-linus (314489b Merge tag 'fixes-for-linus' of 
git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc)
Merging wireless/master (8a70e7f NFC: NCI module license 'unspecified' taints 
kernel)
Merging driver-core.current/driver-core-linus (5becfb1 kmsg: merge continuation 
records while printing)
Merging tty.current/tty-linus (6b16351 Linux 3.5-rc4)
Merging usb.current/usb-linus (dbf0e4c PCI: EHCI: fix crash during suspend on 
ASUS computers)
Merging staging.current/staging-linus (6887a41 Linux 3.5-rc5)
Merging char-misc.current/char-misc-linus (16a50b1 mei: pci_resume: set 
IRQF_ONESHOT for msi request_threaded_irq)
Merging input-current/for-linus (cc71a7e Input: xpad - add signature for Razer 
Onza Tournament Edition)
Merging md-current/for-linus (1068411 md/raid10: fix careless build error)
Merging audit-current/for-linus (c158a35 audit: no leading space in 
audit_log_d_path prefix)
Merging crypto-current/master (c475c06 hwrng: atmel-rng - fix data valid check)
Merging ide/master (39a50b4 Merge branch 'hfsplus')
Merging dwmw2/master (244dc4e Merge 
git://git.infradead.org/users/dwmw2/random-2.6)
Merging sh-current/sh-fixes-for-linus (4403310 SH: Convert out[bwl] macros to 
inline functions)
Merging irqdomain-current/irqdomain/merge (15e06bf irqdomain: Fix debugfs 
formatting)
Merging devicetree-current/devicetree/merge (4e8383b of: release node fix for 
of_parse_phandle_with_args)
Merging spi-current/spi/merge (d1c185b of/spi: Fix SPI module loading by using 
proper "spi:" modalias prefixes.)
Merging gpio-current/gpio/merge (96b7064 gpio/tca6424: merge I2C transactions, 
remove cast)
Merging arm/for-next (dea2ea3 Merge branches 'audit', 'delay', 'dmaengine', 
'fixes', 'misc' and 'sta2x11' into for-next)
Merging arm-perf/for-next/perf (dee8c1b ARM:

Re: How to use the generic thermal sysfs.

2012-07-12 Thread Alex Courbot

On 07/12/2012 07:54 PM, R, Durgadoss wrote:

We are working on a notification API from any generic sensor driver to
the thermal framework.
Please have a look at the 'notify_thermal_framework' API in the patch here:
http://www.spinics.net/lists/linux-acpi/msg36049.html


At first sight these patches look close to what we need as well. Are you 
considering to support the definitions of thermal zones using the device 
tree? Is there a public git tree where we can pull the latest version of 
this code in order to keep in sync with you guys?


Thanks,
Alex.
--
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: [PATCHv3 0/4] hfsplus: stop using write_supers and s_dirt

2012-07-12 Thread Artem Bityutskiy
On Thu, 2012-07-12 at 16:09 -0700, Andrew Morton wrote:
> I really do dislike dropping patches and replacing them.  For a whole
> bunch of reasons.  One of which is that a wholesale replacement
> requires a full re-review.  Another is that wholesale replacement makes
> it hard to see what was changed.

I will keep this in mind and in future will send you incremental changes
instead. Apologies Andrew.

> This latest patchset is identical to the code which is presently in -mm.

I am now away and cannot easily send you a diff between v2 and v3, but
it really does have changes - exactly as I described - checkpatch.pl
fixes (spaces replaced by tabs) and one line removed. Sorry for
confusion, I really should have sent an incremental patch.

-- 
Best Regards,
Artem Bityutskiy


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


Re: [PATCH 2/2] dma: tegra: fix residual calculation for cyclic case

2012-07-12 Thread Laxman Dewangan

On Friday 13 July 2012 08:45 AM, Vinod Koul wrote:

On Mon, 2012-07-02 at 10:02 -0600, Stephen Warren wrote:

On 07/02/2012 02:22 AM, Laxman Dewangan wrote:

In cyclic mode of DMA, the byte transferred can be more
than the requested size and in this case, calculating
residuals based on the current position of DMA transfer to
bytes requested i.e. bytes required to transfer to reach
bytes requested from current DMA position.

Signed-off-by: Laxman Dewangan

This makes sense to me, although I wonder if details like this aren't
something that the dmaengine core should be handling.

No core doesn't know anything about the how much you are transferring
and where you are. That is the driver to calculate and provide.


Just for confirmation, are you going to apply this patch or do I need to 
do anything here.


Thanks,
Laxman

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


RE: [PATCH v2 1/3] regulator: tps65217: Add device tree support

2012-07-12 Thread AnilKumar, Chimata
Hi Mark,

On Thu, Jul 12, 2012 at 22:58:37, Mark Brown wrote:
> On Tue, Jul 10, 2012 at 04:39:42PM +0530, AnilKumar Ch wrote:
> > This commit adds device tree support for tps65217 pmic. And usage
> > details are added to device tree documentation. Driver is tested
> > by using kernel module with regulator set and get APIs.
> 
> Applied, thanks.

Thanks much, are you going to push reset of the patches in this series?

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


Re: [PATCH 0/3] fs/ufs: stop using write_supers and s_dirt

2012-07-12 Thread Andrew Morton
On Fri, 13 Jul 2012 08:34:44 +0300 Artem Bityutskiy  wrote:

> On Thu, 2012-07-12 at 15:58 -0700, Andrew Morton wrote:
> > Just fix them up as you go - the code is already a mixture of "right"
> > and "wrong" (a consequence of a lot of it being "wrong") - we might as
> > well tip it further in the "right" direction. 
> 
> Yeah, but I'd say 80% of it has its own "wrong" coding style, so fixing
> it is a separate patch-set. Simply because when I partially fix it,
> there are almost always context lines which upset checkpatch.pl, so I
> would need to fix it all. I can easily clean it up a bit separately,
> just let me know if you want me to do this.

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


Re: [PATCH 0/3] fs/ufs: stop using write_supers and s_dirt

2012-07-12 Thread Artem Bityutskiy
On Thu, 2012-07-12 at 15:58 -0700, Andrew Morton wrote:
> Just fix them up as you go - the code is already a mixture of "right"
> and "wrong" (a consequence of a lot of it being "wrong") - we might as
> well tip it further in the "right" direction. 

Yeah, but I'd say 80% of it has its own "wrong" coding style, so fixing
it is a separate patch-set. Simply because when I partially fix it,
there are almost always context lines which upset checkpatch.pl, so I
would need to fix it all. I can easily clean it up a bit separately,
just let me know if you want me to do this.

Thanks!

-- 
Best Regards,
Artem Bityutskiy


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


Re: [Xen-devel] [PATCH] xen: populate correct number of pages when across mem boundary

2012-07-12 Thread zhenzhong.duan



于 2012-07-12 22:55, David Vrabel 写道:

On 04/07/12 07:49, zhenzhong.duan wrote:

When populate pages across a mem boundary at bootup, the page count
populated isn't correct. This is due to mem populated to non-mem
region and ignored.

Pfn range is also wrongly aligned when mem boundary isn't page aligned.

Also need consider the rare case when xen_do_chunk fail(populate).

For a dom0 booted with dom_mem=3368952K(0xcd9ff000-4k) dmesg diff is:
  [0.00] Freeing 9e-100 pfn range: 98 pages freed
  [0.00] 1-1 mapping on 9e->100
  [0.00] 1-1 mapping on cd9ff->10
  [0.00] Released 98 pages of unused memory
  [0.00] Set 206435 page(s) to 1-1 mapping
-[0.00] Populating cd9fe-cda00 pfn range: 1 pages added
+[0.00] Populating cd9fe-cd9ff pfn range: 1 pages added
+[0.00] Populating 10-100061 pfn range: 97 pages added
  [0.00] BIOS-provided physical RAM map:
  [0.00] Xen:  - 0009e000 (usable)
  [0.00] Xen: 000a - 0010 (reserved)
  [0.00] Xen: 0010 - cd9ff000 (usable)
  [0.00] Xen: cd9ffc00 - cda53c00 (ACPI NVS)
...
  [0.00] Xen: 0001 - 000100061000 (usable)
  [0.00] Xen: 000100061000 - 00012c00 (unusable)
...
  [0.00] MEMBLOCK configuration:
...
-[0.00]  reserved[0x4]   [0x00cd9ff000-0x00cd9ffbff], 0xc00 
bytes
-[0.00]  reserved[0x5]   [0x01-0x0100060fff], 
0x61000 bytes

Related xen memory layout:
(XEN) Xen-e820 RAM map:
(XEN)   - 0009ec00 (usable)
(XEN)  000f - 0010 (reserved)
(XEN)  0010 - cd9ffc00 (usable)

Signed-off-by: Zhenzhong Duan
---
  arch/x86/xen/setup.c |   24 +++-
  1 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index a4790bf..bd78773 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -157,50 +157,48 @@ static unsigned long __init xen_populate_chunk(
unsigned long dest_pfn;

for (i = 0, entry = list; i<  map_size; i++, entry++) {
-   unsigned long credits = credits_left;
unsigned long s_pfn;
unsigned long e_pfn;
unsigned long pfns;
long capacity;

-   if (credits<= 0)
+   if (credits_left<= 0)
break;

if (entry->type != E820_RAM)
continue;

-   e_pfn = PFN_UP(entry->addr + entry->size);
+   e_pfn = PFN_DOWN(entry->addr + entry->size);

Ok.



/* We only care about E820 after the xen_start_info->nr_pages */
if (e_pfn<= max_pfn)
continue;

-   s_pfn = PFN_DOWN(entry->addr);
+   s_pfn = PFN_UP(entry->addr);

Ok.


/* If the E820 falls within the nr_pages, we want to start
 * at the nr_pages PFN.
 * If that would mean going past the E820 entry, skip it
 */
+again:
if (s_pfn<= max_pfn) {
capacity = e_pfn - max_pfn;
dest_pfn = max_pfn;
} else {
-   /* last_pfn MUST be within E820_RAM regions */
-   if (*last_pfn&&  e_pfn>= *last_pfn)
-   s_pfn = *last_pfn;
capacity = e_pfn - s_pfn;
dest_pfn = s_pfn;
}
-   /* If we had filled this E820_RAM entry, go to the next one. */
-   if (capacity<= 0)
-   continue;

-   if (credits>  capacity)
-   credits = capacity;
+   if (credits_left<  capacity)
+   capacity = credits_left;

-   pfns = xen_do_chunk(dest_pfn, dest_pfn + credits, false);
+   pfns = xen_do_chunk(dest_pfn, dest_pfn + capacity, false);
done += pfns;
credits_left -= pfns;
*last_pfn = (dest_pfn + pfns);
+   if (credits_left>  0&&  *last_pfn<  e_pfn) {
+   s_pfn = *last_pfn;
+   goto again;
+   }

This looks like it will loop forever if xen_do_chunk() repeatedly fails
because Xen is out of pages.  I think if xen_do_chunk() cannot get a
page from Xen the repopulation process should stop -- aborting this
chunk and any others.  This will allow the guest to continue to boot
just with less memory than expected.

David

Ok, I'll update the patch, loop forever isn't a good idea.
Originally, I considered the case there is dynamic memory control 
functionality in the system.

thanks for comment.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the 

[PATCH net-next 8/8] arch: Use eth_random_addr

2012-07-12 Thread Joe Perches
Convert the existing uses of random_ether_addr to
the new eth_random_addr.

Signed-off-by: Joe Perches 
---
 arch/blackfin/mach-bf537/boards/stamp.c |2 +-
 arch/c6x/kernel/soc.c   |2 +-
 arch/mips/ar7/platform.c|4 ++--
 arch/mips/powertv/powertv_setup.c   |6 +++---
 arch/um/drivers/net_kern.c  |2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/blackfin/mach-bf537/boards/stamp.c 
b/arch/blackfin/mach-bf537/boards/stamp.c
index c9d9473..5ed654a 100644
--- a/arch/blackfin/mach-bf537/boards/stamp.c
+++ b/arch/blackfin/mach-bf537/boards/stamp.c
@@ -873,7 +873,7 @@ static struct adf702x_platform_data adf7021_platform_data = 
{
 };
 static inline void adf702x_mac_init(void)
 {
-   random_ether_addr(adf7021_platform_data.mac_addr);
+   eth_random_addr(adf7021_platform_data.mac_addr);
 }
 #else
 static inline void adf702x_mac_init(void) {}
diff --git a/arch/c6x/kernel/soc.c b/arch/c6x/kernel/soc.c
index 0748c94..3ac7408 100644
--- a/arch/c6x/kernel/soc.c
+++ b/arch/c6x/kernel/soc.c
@@ -80,7 +80,7 @@ int soc_mac_addr(unsigned int index, u8 *addr)
if (have_fuse_mac)
memcpy(addr, c6x_fuse_mac, 6);
else
-   random_ether_addr(addr);
+   eth_random_addr(addr);
}
 
/* adjust for specific EMAC device */
diff --git a/arch/mips/ar7/platform.c b/arch/mips/ar7/platform.c
index 1a24d31..1bbc24b 100644
--- a/arch/mips/ar7/platform.c
+++ b/arch/mips/ar7/platform.c
@@ -310,10 +310,10 @@ static void __init cpmac_get_mac(int instance, unsigned 
char *dev_addr)
_addr[4], _addr[5]) != 6) {
pr_warning("cannot parse mac address, "
"using random address\n");
-   random_ether_addr(dev_addr);
+   eth_random_addr(dev_addr);
}
} else
-   random_ether_addr(dev_addr);
+   eth_random_addr(dev_addr);
 }
 
 /*
diff --git a/arch/mips/powertv/powertv_setup.c 
b/arch/mips/powertv/powertv_setup.c
index 3933c37..820b848 100644
--- a/arch/mips/powertv/powertv_setup.c
+++ b/arch/mips/powertv/powertv_setup.c
@@ -254,7 +254,7 @@ early_param("rfmac", rfmac_param);
  * Generates an Ethernet MAC address that is highly likely to be unique for
  * this particular system on a network with other systems of the same type.
  *
- * The problem we are solving is that, when random_ether_addr() is used to
+ * The problem we are solving is that, when eth_random_addr() is used to
  * generate MAC addresses at startup, there isn't much entropy for the random
  * number generator to use and the addresses it produces are fairly likely to
  * be the same as those of other identical systems on the same local network.
@@ -269,7 +269,7 @@ early_param("rfmac", rfmac_param);
  * Still, this does give us something to work with.
  *
  * The approach we take is:
- * 1.  If we can't get the RF MAC Address, just call random_ether_addr.
+ * 1.  If we can't get the RF MAC Address, just call eth_random_addr.
  * 2.  Use the 24-bit NIC-specific bits of the RF MAC address as the last 24
  * bits of the new address. This is very likely to be unique, except for
  * the current box.
@@ -299,7 +299,7 @@ void platform_random_ether_addr(u8 addr[ETH_ALEN])
if (!have_rfmac) {
pr_warning("rfmac not available on command line; "
"generating random MAC address\n");
-   random_ether_addr(addr);
+   eth_random_addr(addr);
}
 
else {
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index 0d60c56..458d324 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -339,7 +339,7 @@ static int setup_etheraddr(char *str, unsigned char *addr, 
char *name)
 random:
printk(KERN_INFO
   "Choosing a random ethernet address for device %s\n", name);
-   random_ether_addr(addr);
+   eth_random_addr(addr);
return 1;
 }
 
-- 
1.7.8.111.gad25c.dirty

--
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 net-next 7/8] usb: Use eth_random_addr

2012-07-12 Thread Joe Perches
Convert the existing uses of random_ether_addr to
the new eth_random_addr.

Signed-off-by: Joe Perches 
---
 drivers/usb/atm/xusbatm.c|4 ++--
 drivers/usb/gadget/u_ether.c |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/atm/xusbatm.c b/drivers/usb/atm/xusbatm.c
index 14ec9f0..b3b1bb7 100644
--- a/drivers/usb/atm/xusbatm.c
+++ b/drivers/usb/atm/xusbatm.c
@@ -20,7 +20,7 @@
  
**/
 
 #include 
-#include  /* for random_ether_addr() */
+#include  /* for eth_random_addr() */
 
 #include "usbatm.h"
 
@@ -163,7 +163,7 @@ static int xusbatm_atm_start(struct usbatm_data *usbatm,
atm_dbg(usbatm, "%s entered\n", __func__);
 
/* use random MAC as we've no way to get it from the device */
-   random_ether_addr(atm_dev->esi);
+   eth_random_addr(atm_dev->esi);
 
return 0;
 }
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 47cf48b..b9e1925 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -724,7 +724,7 @@ static int get_ether_addr(const char *str, u8 *dev_addr)
if (is_valid_ether_addr(dev_addr))
return 0;
}
-   random_ether_addr(dev_addr);
+   eth_random_addr(dev_addr);
return 1;
 }
 
-- 
1.7.8.111.gad25c.dirty

--
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 net-next 6/8] s390: Use eth_random_addr

2012-07-12 Thread Joe Perches
Convert the existing uses of random_ether_addr to
the new eth_random_addr.

Signed-off-by: Joe Perches 
---
 drivers/s390/net/qeth_l2_main.c |2 +-
 drivers/s390/net/qeth_l3_main.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index 4269865..b09355c 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -647,7 +647,7 @@ static int qeth_l2_request_initial_mac(struct qeth_card 
*card)
}
QETH_DBF_HEX(SETUP, 2, card->dev->dev_addr, OSA_ADDR_LEN);
} else {
-   random_ether_addr(card->dev->dev_addr);
+   eth_random_addr(card->dev->dev_addr);
memcpy(card->dev->dev_addr, vendor_pre, 3);
}
return 0;
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 73ac63d..bada7f6 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -1473,7 +1473,7 @@ static int qeth_l3_iqd_read_initial_mac_cb(struct 
qeth_card *card,
memcpy(card->dev->dev_addr,
cmd->data.create_destroy_addr.unique_id, ETH_ALEN);
else
-   random_ether_addr(card->dev->dev_addr);
+   eth_random_addr(card->dev->dev_addr);
 
return 0;
 }
-- 
1.7.8.111.gad25c.dirty

--
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 net-next 5/8] drivers/net: Use eth_random_addr

2012-07-12 Thread Joe Perches
Convert the existing uses of random_ether_addr to
the new eth_random_addr.

Signed-off-by: Joe Perches 
---
 drivers/net/tun.c |2 +-
 drivers/net/wimax/i2400m/driver.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 987aeef..961fad1 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -22,7 +22,7 @@
  *Add TUNSETLINK ioctl to set the link encapsulation
  *
  *  Mark Smith 
- *Use random_ether_addr() for tap MAC address.
+ *Use eth_random_addr() for tap MAC address.
  *
  *  Harald Roelle   2004/04/20
  *Fixes in packet dropping, queue length setting and queue wakeup.
diff --git a/drivers/net/wimax/i2400m/driver.c 
b/drivers/net/wimax/i2400m/driver.c
index 47cae71..01d400d 100644
--- a/drivers/net/wimax/i2400m/driver.c
+++ b/drivers/net/wimax/i2400m/driver.c
@@ -897,7 +897,7 @@ int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri 
bm_flags)
result = i2400m_read_mac_addr(i2400m);
if (result < 0)
goto error_read_mac_addr;
-   random_ether_addr(i2400m->src_mac_addr);
+   eth_random_addr(i2400m->src_mac_addr);
 
i2400m->pm_notifier.notifier_call = i2400m_pm_notifier;
register_pm_notifier(>pm_notifier);
-- 
1.7.8.111.gad25c.dirty

--
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 net-next 4/8] wireless: Use eth_random_addr

2012-07-12 Thread Joe Perches
Convert the existing uses of random_ether_addr to
the new eth_random_addr.

Signed-off-by: Joe Perches 
---
 drivers/net/wireless/adm8211.c |2 +-
 drivers/net/wireless/p54/eeprom.c  |2 +-
 drivers/net/wireless/rt2x00/rt2400pci.c|2 +-
 drivers/net/wireless/rt2x00/rt2500pci.c|2 +-
 drivers/net/wireless/rt2x00/rt2500usb.c|2 +-
 drivers/net/wireless/rt2x00/rt2800lib.c|2 +-
 drivers/net/wireless/rt2x00/rt61pci.c  |2 +-
 drivers/net/wireless/rt2x00/rt73usb.c  |2 +-
 drivers/net/wireless/rtl818x/rtl8180/dev.c |2 +-
 drivers/net/wireless/rtl818x/rtl8187/dev.c |2 +-
 10 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c
index 97afcec..689a71c 100644
--- a/drivers/net/wireless/adm8211.c
+++ b/drivers/net/wireless/adm8211.c
@@ -1854,7 +1854,7 @@ static int __devinit adm8211_probe(struct pci_dev *pdev,
if (!is_valid_ether_addr(perm_addr)) {
printk(KERN_WARNING "%s (adm8211): Invalid hwaddr in EEPROM!\n",
   pci_name(pdev));
-   random_ether_addr(perm_addr);
+   eth_random_addr(perm_addr);
}
SET_IEEE80211_PERM_ADDR(dev, perm_addr);
 
diff --git a/drivers/net/wireless/p54/eeprom.c 
b/drivers/net/wireless/p54/eeprom.c
index 636daf2..1403709 100644
--- a/drivers/net/wireless/p54/eeprom.c
+++ b/drivers/net/wireless/p54/eeprom.c
@@ -857,7 +857,7 @@ good_eeprom:
 
wiphy_warn(dev->wiphy,
   "Invalid hwaddr! Using randomly generated MAC 
addr\n");
-   random_ether_addr(perm_addr);
+   eth_random_addr(perm_addr);
SET_IEEE80211_PERM_ADDR(dev, perm_addr);
}
 
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c 
b/drivers/net/wireless/rt2x00/rt2400pci.c
index 5e6b501..8b9dbd7 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -1455,7 +1455,7 @@ static int rt2400pci_validate_eeprom(struct rt2x00_dev 
*rt2x00dev)
 */
mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
if (!is_valid_ether_addr(mac)) {
-   random_ether_addr(mac);
+   eth_random_addr(mac);
EEPROM(rt2x00dev, "MAC: %pM\n", mac);
}
 
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c 
b/drivers/net/wireless/rt2x00/rt2500pci.c
index 136b849..d2cf8a4 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -1585,7 +1585,7 @@ static int rt2500pci_validate_eeprom(struct rt2x00_dev 
*rt2x00dev)
 */
mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
if (!is_valid_ether_addr(mac)) {
-   random_ether_addr(mac);
+   eth_random_addr(mac);
EEPROM(rt2x00dev, "MAC: %pM\n", mac);
}
 
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c 
b/drivers/net/wireless/rt2x00/rt2500usb.c
index 669aecd..3aae36b 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -1352,7 +1352,7 @@ static int rt2500usb_validate_eeprom(struct rt2x00_dev 
*rt2x00dev)
 */
mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
if (!is_valid_ether_addr(mac)) {
-   random_ether_addr(mac);
+   eth_random_addr(mac);
EEPROM(rt2x00dev, "MAC: %pM\n", mac);
}
 
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c 
b/drivers/net/wireless/rt2x00/rt2800lib.c
index 068276e..d857d55 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -4340,7 +4340,7 @@ int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 */
mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
if (!is_valid_ether_addr(mac)) {
-   random_ether_addr(mac);
+   eth_random_addr(mac);
EEPROM(rt2x00dev, "MAC: %pM\n", mac);
}
 
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c 
b/drivers/net/wireless/rt2x00/rt61pci.c
index ee22bd7..f322596 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -2415,7 +2415,7 @@ static int rt61pci_validate_eeprom(struct rt2x00_dev 
*rt2x00dev)
 */
mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
if (!is_valid_ether_addr(mac)) {
-   random_ether_addr(mac);
+   eth_random_addr(mac);
EEPROM(rt2x00dev, "MAC: %pM\n", mac);
}
 
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c 
b/drivers/net/wireless/rt2x00/rt73usb.c
index 77ccbbc..ba6e434 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -1770,7 +1770,7 @@ static int rt73usb_validate_eeprom(struct rt2x00_dev 
*rt2x00dev)
 */
mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);

[PATCH net-next 3/8] net: usb: Use eth_random_addr

2012-07-12 Thread Joe Perches
Convert the existing uses of random_ether_addr to
the new eth_random_addr.

Signed-off-by: Joe Perches 
---
 drivers/net/usb/smsc75xx.c |2 +-
 drivers/net/usb/smsc95xx.c |2 +-
 drivers/net/usb/usbnet.c   |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 1c6e515..6c0c5b7 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -616,7 +616,7 @@ static void smsc75xx_init_mac_address(struct usbnet *dev)
 
/* no eeprom, or eeprom values are invalid. generate random MAC */
eth_hw_addr_random(dev->net);
-   netif_dbg(dev, ifup, dev->net, "MAC address set to random_ether_addr");
+   netif_dbg(dev, ifup, dev->net, "MAC address set to eth_random_addr");
 }
 
 static int smsc75xx_set_mac_address(struct usbnet *dev)
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index bd7cbaa..25cc3a1 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -647,7 +647,7 @@ static void smsc95xx_init_mac_address(struct usbnet *dev)
 
/* no eeprom, or eeprom values are invalid. generate random MAC */
eth_hw_addr_random(dev->net);
-   netif_dbg(dev, ifup, dev->net, "MAC address set to 
random_ether_addr\n");
+   netif_dbg(dev, ifup, dev->net, "MAC address set to eth_random_addr\n");
 }
 
 static int smsc95xx_set_mac_address(struct usbnet *dev)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index e92c057..8531c1c 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1593,7 +1593,7 @@ static int __init usbnet_init(void)
BUILD_BUG_ON(
FIELD_SIZEOF(struct sk_buff, cb) < sizeof(struct skb_data));
 
-   random_ether_addr(node_id);
+   eth_random_addr(node_id);
return 0;
 }
 module_init(usbnet_init);
-- 
1.7.8.111.gad25c.dirty

--
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 net-next 2/8] ethernet: Use eth_random_addr

2012-07-12 Thread Joe Perches
Convert the existing uses of random_ether_addr to
the new eth_random_addr.

Signed-off-by: Joe Perches 
---
 drivers/net/ethernet/atheros/atl1c/atl1c_hw.c |2 +-
 drivers/net/ethernet/atheros/atlx/atl1.c  |2 +-
 drivers/net/ethernet/atheros/atlx/atl2.c  |2 +-
 drivers/net/ethernet/ethoc.c  |2 +-
 drivers/net/ethernet/intel/igb/igb_main.c |4 ++--
 drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c|2 +-
 drivers/net/ethernet/lantiq_etop.c|2 +-
 drivers/net/ethernet/micrel/ks8851.c  |2 +-
 drivers/net/ethernet/micrel/ks8851_mll.c  |2 +-
 drivers/net/ethernet/smsc/smsc911x.c  |2 +-
 drivers/net/ethernet/ti/cpsw.c|2 +-
 drivers/net/ethernet/tile/tilegx.c|2 +-
 drivers/net/ethernet/wiznet/w5100.c   |2 +-
 drivers/net/ethernet/wiznet/w5300.c   |2 +-
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c |2 +-
 15 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_hw.c 
b/drivers/net/ethernet/atheros/atl1c/atl1c_hw.c
index 801f012..21e261f 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c_hw.c
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c_hw.c
@@ -199,7 +199,7 @@ int atl1c_read_mac_addr(struct atl1c_hw *hw)
 
err = atl1c_get_permanent_address(hw);
if (err)
-   random_ether_addr(hw->perm_mac_addr);
+   eth_random_addr(hw->perm_mac_addr);
 
memcpy(hw->mac_addr, hw->perm_mac_addr, sizeof(hw->perm_mac_addr));
return err;
diff --git a/drivers/net/ethernet/atheros/atlx/atl1.c 
b/drivers/net/ethernet/atheros/atlx/atl1.c
index f2402f3..7bae2ad 100644
--- a/drivers/net/ethernet/atheros/atlx/atl1.c
+++ b/drivers/net/ethernet/atheros/atlx/atl1.c
@@ -538,7 +538,7 @@ static s32 atl1_read_mac_addr(struct atl1_hw *hw)
u16 i;
 
if (atl1_get_permanent_address(hw)) {
-   random_ether_addr(hw->perm_mac_addr);
+   eth_random_addr(hw->perm_mac_addr);
ret = 1;
}
 
diff --git a/drivers/net/ethernet/atheros/atlx/atl2.c 
b/drivers/net/ethernet/atheros/atlx/atl2.c
index 7c0b7e2..57d64b8 100644
--- a/drivers/net/ethernet/atheros/atlx/atl2.c
+++ b/drivers/net/ethernet/atheros/atlx/atl2.c
@@ -2346,7 +2346,7 @@ static s32 atl2_read_mac_addr(struct atl2_hw *hw)
 {
if (get_permanent_address(hw)) {
/* for test */
-   /* FIXME: shouldn't we use random_ether_addr() here? */
+   /* FIXME: shouldn't we use eth_random_addr() here? */
hw->perm_mac_addr[0] = 0x00;
hw->perm_mac_addr[1] = 0x13;
hw->perm_mac_addr[2] = 0x74;
diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 2029788..94b7bfc 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -1057,7 +1057,7 @@ static int __devinit ethoc_probe(struct platform_device 
*pdev)
/* Check the MAC again for validity, if it still isn't choose and
 * program a random one. */
if (!is_valid_ether_addr(netdev->dev_addr)) {
-   random_ether_addr(netdev->dev_addr);
+   eth_random_addr(netdev->dev_addr);
random_mac = true;
}
 
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c 
b/drivers/net/ethernet/intel/igb/igb_main.c
index 60e3075..8adeca9 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -5008,7 +5008,7 @@ static int igb_vf_configure(struct igb_adapter *adapter, 
int vf)
unsigned int device_id;
u16 thisvf_devfn;
 
-   random_ether_addr(mac_addr);
+   eth_random_addr(mac_addr);
igb_set_vf_mac(adapter, vf, mac_addr);
 
switch (adapter->hw.mac.type) {
@@ -5417,7 +5417,7 @@ static void igb_vf_reset_event(struct igb_adapter 
*adapter, u32 vf)
 
/* generate a new mac address as we were hotplug removed/added */
if (!(adapter->vf_data[vf].flags & IGB_VF_FLAG_PF_SET_MAC))
-   random_ether_addr(vf_mac);
+   eth_random_addr(vf_mac);
 
/* process remaining reset events */
igb_vf_reset(adapter, vf);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
index 2d971d1..eb3f67c 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
@@ -467,7 +467,7 @@ int ixgbe_vf_configuration(struct pci_dev *pdev, unsigned 
int event_mask)
bool enable = ((event_mask & 0x1000U) != 0);
 
if (enable) {
-   random_ether_addr(vf_mac_addr);
+   eth_random_addr(vf_mac_addr);
e_info(probe, "IOV: VF %d is enabled MAC %pM\n",
   vfn, vf_mac_addr);
/*
diff --git 

[PATCH net-next 1/8] etherdevice: Rename random_ether_addr to eth_random_addr

2012-07-12 Thread Joe Perches
Add some API symmetry to eth_broadcast_addr and
add a #define to the old name for backward compatibility.

Signed-off-by: Joe Perches 
---
 include/linux/etherdevice.h |   14 --
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 98a27cc..d426336 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -124,19 +124,21 @@ static inline bool is_valid_ether_addr(const u8 *addr)
 }
 
 /**
- * random_ether_addr - Generate software assigned random Ethernet address
+ * eth_random_addr - Generate software assigned random Ethernet address
  * @addr: Pointer to a six-byte array containing the Ethernet address
  *
  * Generate a random Ethernet address (MAC) that is not multicast
  * and has the local assigned bit set.
  */
-static inline void random_ether_addr(u8 *addr)
+static inline void eth_random_addr(u8 *addr)
 {
-   get_random_bytes (addr, ETH_ALEN);
-   addr [0] &= 0xfe;   /* clear multicast bit */
-   addr [0] |= 0x02;   /* set local assignment bit (IEEE802) */
+   get_random_bytes(addr, ETH_ALEN);
+   addr[0] &= 0xfe;/* clear multicast bit */
+   addr[0] |= 0x02;/* set local assignment bit (IEEE802) */
 }
 
+#define random_ether_addr(addr) eth_random_addr(addr)
+
 /**
  * eth_broadcast_addr - Assign broadcast address
  * @addr: Pointer to a six-byte array containing the Ethernet address
@@ -160,7 +162,7 @@ static inline void eth_broadcast_addr(u8 *addr)
 static inline void eth_hw_addr_random(struct net_device *dev)
 {
dev->addr_assign_type |= NET_ADDR_RANDOM;
-   random_ether_addr(dev->dev_addr);
+   eth_random_addr(dev->dev_addr);
 }
 
 /**
-- 
1.7.8.111.gad25c.dirty

--
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 net-next 0/8] etherdevice: Rename random_ether_addr to eth_random_addr

2012-07-12 Thread Joe Perches
net-next commit ad7eee98be ("etherdevice: introduce eth_broadcast_addr")
added a new style API.  Rename random_ether_addr to eth_random_addr to
create some API symmetry.

Joe Perches (8):
  etherdevice: Rename random_ether_addr to eth_random_addr
  ethernet: Use eth_random_addr
  net: usb: Use eth_random_addr
  wireless: Use eth_random_addr
  drivers/net: Use eth_random_addr
  s390: Use eth_random_addr
  usb: Use eth_random_addr
  arch: Use eth_random_addr

 arch/blackfin/mach-bf537/boards/stamp.c   |2 +-
 arch/c6x/kernel/soc.c |2 +-
 arch/mips/ar7/platform.c  |4 ++--
 arch/mips/powertv/powertv_setup.c |6 +++---
 arch/um/drivers/net_kern.c|2 +-
 drivers/net/ethernet/atheros/atl1c/atl1c_hw.c |2 +-
 drivers/net/ethernet/atheros/atlx/atl1.c  |2 +-
 drivers/net/ethernet/atheros/atlx/atl2.c  |2 +-
 drivers/net/ethernet/ethoc.c  |2 +-
 drivers/net/ethernet/intel/igb/igb_main.c |4 ++--
 drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c|2 +-
 drivers/net/ethernet/lantiq_etop.c|2 +-
 drivers/net/ethernet/micrel/ks8851.c  |2 +-
 drivers/net/ethernet/micrel/ks8851_mll.c  |2 +-
 drivers/net/ethernet/smsc/smsc911x.c  |2 +-
 drivers/net/ethernet/ti/cpsw.c|2 +-
 drivers/net/ethernet/tile/tilegx.c|2 +-
 drivers/net/ethernet/wiznet/w5100.c   |2 +-
 drivers/net/ethernet/wiznet/w5300.c   |2 +-
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c |2 +-
 drivers/net/tun.c |2 +-
 drivers/net/usb/smsc75xx.c|2 +-
 drivers/net/usb/smsc95xx.c|2 +-
 drivers/net/usb/usbnet.c  |2 +-
 drivers/net/wimax/i2400m/driver.c |2 +-
 drivers/net/wireless/adm8211.c|2 +-
 drivers/net/wireless/p54/eeprom.c |2 +-
 drivers/net/wireless/rt2x00/rt2400pci.c   |2 +-
 drivers/net/wireless/rt2x00/rt2500pci.c   |2 +-
 drivers/net/wireless/rt2x00/rt2500usb.c   |2 +-
 drivers/net/wireless/rt2x00/rt2800lib.c   |2 +-
 drivers/net/wireless/rt2x00/rt61pci.c |2 +-
 drivers/net/wireless/rt2x00/rt73usb.c |2 +-
 drivers/net/wireless/rtl818x/rtl8180/dev.c|2 +-
 drivers/net/wireless/rtl818x/rtl8187/dev.c|2 +-
 drivers/s390/net/qeth_l2_main.c   |2 +-
 drivers/s390/net/qeth_l3_main.c   |2 +-
 drivers/usb/atm/xusbatm.c |4 ++--
 drivers/usb/gadget/u_ether.c  |2 +-
 include/linux/etherdevice.h   |   14 --
 40 files changed, 52 insertions(+), 50 deletions(-)

-- 
1.7.8.111.gad25c.dirty

--
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 3/3] tegra: add pwm backlight device tree nodes

2012-07-12 Thread Alex Courbot

On 07/12/2012 11:27 PM, Simon Glass wrote

I agree the type strings are a problem in the current form - if we could get
constants in the device tree, that would be much better. Your way of
representing the sequences is interesting though, if we can solve the type
issue (and also evaluate its cost in terms of memory footprint), it would be
interesting to consider it as well.


At a guess:


+   power-on-sequence = "REGULATOR", "power", <1>,
+   "DELAY", <10>,
+   "PWM", "backlight", <1>,
+   "GPIO", "enable", <1>;


About 106 bytes I think


 step@0 { 16

 type = "regulator"; 24

phandle = <_reg>; 16
enable = <1>; 16
post-delay = <10>; 16
 }
 step@1 { 16

 type = "pwm"; 16

phandle = < 2 500>; 24
 }
 step@2 { 16

 type = "gpio"; 20

phandle = < 28 0>; 24
enable = <1>; 16
 }


220?


I compiled both versions to try it out. Your version was just 50 bytes 
larger than mine (I assumed that with yours, we would be able to remove 
the top-level pwm/regulator/gpio definitions that are referred by the 
sequence). The question here is do we want to have something more 
DT-ish, or are we trying to save every possible byte in the DT structure?


As Thierry also mentionned, we are trying to provide the same feature 
using the platform interface. I am not sure how we can elegantly support 
both ways through this.



 From my understanding mixing strings and numbers in a property is
frowned on though.


But doesn't it make sense in the current case? The power sequence is 
basically a program that is run by an interpreter. From this 
perspective, it makes more sense to me to have it as a binary field 
rather than a hierarchy of nodes and properties that will be harder to 
parse and will make error detection more complicated. I don't really see 
any practical benefit from turning the steps into sub-nodes, but then 
again I am not so familiar with the DT.


Alex.
--
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 7/8] time: Move xtime_nsec adjustment underflow handling timekeeping_adjust

2012-07-12 Thread John Stultz
When we make adjustments speeding up the clock, its possible
for xtime_nsec to underflow. We already handle this properly,
but we do so from update_wall_time() instead of the more logical
timekeeping_adjust(), where the possible underflow actually
occurs.

Thus, move the correction logic to the timekeeping_adjust, which
is the function that causes the issue. Making update_wall_time()
more readable.

CC: Ingo Molnar 
CC: Peter Zijlstra 
CC: Richard Cochran 
CC: Prarit Bhargava 
CC: Thomas Gleixner 
Signed-off-by: John Stultz 
---
 kernel/time/timekeeping.c |   42 +-
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index dd119355..4b76432 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -987,6 +987,27 @@ static void timekeeping_adjust(s64 offset)
timekeeper.xtime_nsec -= offset;
timekeeper.ntp_error -= (interval - offset) <<
timekeeper.ntp_error_shift;
+
+   /*
+* It may be possible that when we entered this function, xtime_nsec
+* was very small.  Further, if we're slightly speeding the clocksource
+* in the code above, its possible the required corrective factor to
+* xtime_nsec could cause it to underflow.
+*
+* Now, since we already accumulated the second, cannot simply roll
+* the accumulated second back, since the NTP subsystem has been
+* notified via second_overflow. So instead we push xtime_nsec forward
+* by the amount we underflowed, and add that amount into the error.
+*
+* We'll correct this error next time through this function, when
+* xtime_nsec is not as small.
+*/
+   if (unlikely((s64)timekeeper.xtime_nsec < 0)) {
+   s64 neg = -(s64)timekeeper.xtime_nsec;
+   timekeeper.xtime_nsec = 0;
+   timekeeper.ntp_error += neg << timekeeper.ntp_error_shift;
+   }
+
 }
 
 
@@ -1112,27 +1133,6 @@ static void update_wall_time(void)
/* correct the clock when NTP error is too big */
timekeeping_adjust(offset);
 
-   /*
-* Since in the loop above, we accumulate any amount of time
-* in xtime_nsec over a second into xtime.tv_sec, its possible for
-* xtime_nsec to be fairly small after the loop. Further, if we're
-* slightly speeding the clocksource up in timekeeping_adjust(),
-* its possible the required corrective factor to xtime_nsec could
-* cause it to underflow.
-*
-* Now, we cannot simply roll the accumulated second back, since
-* the NTP subsystem has been notified via second_overflow. So
-* instead we push xtime_nsec forward by the amount we underflowed,
-* and add that amount into the error.
-*
-* We'll correct this error next time through this function, when
-* xtime_nsec is not as small.
-*/
-   if (unlikely((s64)timekeeper.xtime_nsec < 0)) {
-   s64 neg = -(s64)timekeeper.xtime_nsec;
-   timekeeper.xtime_nsec = 0;
-   timekeeper.ntp_error += neg << timekeeper.ntp_error_shift;
-   }
 
/*
* Store only full nanoseconds into xtime_nsec after rounding
-- 
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 4/8] time: Condense timekeeper.xtime into xtime_sec

2012-07-12 Thread John Stultz
The timekeeper struct has a xtime_nsec, which keeps the
sub-nanosecond remainder.  This ends up being somewhat
duplicative of the timekeeper.xtime.tv_nsec value, and we
have to do extra work to keep them apart, copying the full
nsec portion out and back in over and over.

This patch simplifies some of the logic by taking the timekeeper
xtime value and splitting it into timekeeper.xtime_sec and
reuses the timekeeper.xtime_nsec for the sub-second portion
(stored in higher res shifted nanoseconds).

This simplifies some of the accumulation logic. And will
allow for more accurate timekeeping once the vsyscall code
is updated to use the shifted nanosecond remainder.

CC: Ingo Molnar 
CC: Peter Zijlstra 
CC: Richard Cochran 
CC: Prarit Bhargava 
CC: Thomas Gleixner 
Signed-off-by: John Stultz 
---
 kernel/time/timekeeping.c |  183 -
 1 file changed, 113 insertions(+), 70 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 4fd83df..80d0c78 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -38,8 +38,11 @@ struct timekeeper {
/* Raw nano seconds accumulated per NTP interval. */
u32 raw_interval;
 
-   /* Clock shifted nano seconds remainder not stored in xtime.tv_nsec. */
+   /* Current CLOCK_REALTIME time in seconds */
+   u64 xtime_sec;
+   /* Clock shifted nano seconds */
u64 xtime_nsec;
+
/* Difference between accumulated time and NTP time in ntp
 * shifted nano seconds. */
s64 ntp_error;
@@ -47,8 +50,6 @@ struct timekeeper {
 * ntp shifted nano seconds. */
u32 ntp_error_shift;
 
-   /* The current time */
-   struct timespec xtime;
/*
 * wall_to_monotonic is what we need to add to xtime (or xtime corrected
 * for sub jiffie times) to get to monotonic time.  Monotonic is pegged
@@ -89,6 +90,36 @@ __cacheline_aligned_in_smp DEFINE_SEQLOCK(xtime_lock);
 int __read_mostly timekeeping_suspended;
 
 
+static inline void tk_normalize_xtime(struct timekeeper *tk)
+{
+   while (tk->xtime_nsec >= ((u64)NSEC_PER_SEC << tk->shift)) {
+   tk->xtime_nsec -= (u64)NSEC_PER_SEC << tk->shift;
+   tk->xtime_sec++;
+   }
+}
+
+static struct timespec tk_xtime(struct timekeeper *tk)
+{
+   struct timespec ts;
+
+   ts.tv_sec = tk->xtime_sec;
+   ts.tv_nsec = (long)(tk->xtime_nsec >> tk->shift);
+   return ts;
+}
+
+static void tk_set_xtime(struct timekeeper *tk, const struct timespec *ts)
+{
+   tk->xtime_sec = ts->tv_sec;
+   tk->xtime_nsec = ts->tv_nsec << tk->shift;
+}
+
+
+static void tk_xtime_add(struct timekeeper *tk, const struct timespec *ts)
+{
+   tk->xtime_sec += ts->tv_sec;
+   tk->xtime_nsec += ts->tv_nsec << tk->shift;
+}
+
 
 /**
  * timekeeper_setup_internals - Set up internals to use clocksource clock.
@@ -104,7 +135,9 @@ static void timekeeper_setup_internals(struct clocksource 
*clock)
 {
cycle_t interval;
u64 tmp, ntpinterval;
+   struct clocksource *old_clock;
 
+   old_clock = timekeeper.clock;
timekeeper.clock = clock;
clock->cycle_last = clock->read(clock);
 
@@ -126,7 +159,14 @@ static void timekeeper_setup_internals(struct clocksource 
*clock)
timekeeper.raw_interval =
((u64) interval * clock->mult) >> clock->shift;
 
-   timekeeper.xtime_nsec = 0;
+/* if changing clocks, convert xtime_nsec shift units */
+   if (old_clock) {
+   int shift_change = clock->shift - old_clock->shift;
+   if (shift_change < 0)
+   timekeeper.xtime_nsec >>= -shift_change;
+   else
+   timekeeper.xtime_nsec <<= shift_change;
+   }
timekeeper.shift = clock->shift;
 
timekeeper.ntp_error = 0;
@@ -145,6 +185,7 @@ static inline s64 timekeeping_get_ns(void)
 {
cycle_t cycle_now, cycle_delta;
struct clocksource *clock;
+   s64 nsec;
 
/* read clocksource: */
clock = timekeeper.clock;
@@ -153,9 +194,8 @@ static inline s64 timekeeping_get_ns(void)
/* calculate the delta since the last update_wall_time: */
cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
 
-   /* return delta convert to nanoseconds using ntp adjusted mult. */
-   return clocksource_cyc2ns(cycle_delta, timekeeper.mult,
- timekeeper.shift);
+   nsec = cycle_delta * timekeeper.mult + timekeeper.xtime_nsec;
+   return nsec >> timekeeper.shift;
 }
 
 static inline s64 timekeeping_get_ns_raw(void)
@@ -185,12 +225,15 @@ static void update_rt_offset(void)
 /* must hold write on timekeeper.lock */
 static void timekeeping_update(bool clearntp)
 {
+   struct timespec xt;
+
if (clearntp) {

[PATCH 5/8] time: Refactor accumulation of nsecs to secs

2012-07-12 Thread John Stultz
We do the exact same logic moving nsecs to secs in the
timekeeper in multiple places, so condense this into a
single function.

CC: Ingo Molnar 
CC: Peter Zijlstra 
CC: Richard Cochran 
CC: Prarit Bhargava 
CC: Thomas Gleixner 
Signed-off-by: John Stultz 
---
 kernel/time/timekeeping.c |   54 +++--
 1 file changed, 32 insertions(+), 22 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 80d0c78..5ffb2b6 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -995,6 +995,35 @@ static void timekeeping_adjust(s64 offset)
 
 
 /**
+ * accumulate_nsecs_to_secs - Accumulates nsecs into secs
+ *
+ * Helper function that accumulates a the nsecs greater then a second
+ * from the xtime_nsec field to the xtime_secs field.
+ * It also calls into the NTP code to handle leapsecond processing.
+ *
+ */
+static inline void accumulate_nsecs_to_secs(struct timekeeper *tk)
+{
+   u64 nsecps = (u64)NSEC_PER_SEC << tk->shift;
+
+   while (tk->xtime_nsec >= nsecps) {
+   int leap;
+
+   tk->xtime_nsec -= nsecps;
+   tk->xtime_sec++;
+
+   /* Figure out if its a leap sec and apply if needed */
+   leap = second_overflow(tk->xtime_sec);
+   tk->xtime_sec += leap;
+   tk->wall_to_monotonic.tv_sec -= leap;
+   if (leap)
+   clock_was_set_delayed();
+
+   }
+}
+
+
+/**
  * logarithmic_accumulation - shifted accumulation of cycles
  *
  * This functions accumulates a shifted interval of cycles into
@@ -1005,7 +1034,6 @@ static void timekeeping_adjust(s64 offset)
  */
 static cycle_t logarithmic_accumulation(cycle_t offset, u32 shift)
 {
-   u64 nsecps = (u64)NSEC_PER_SEC << timekeeper.shift;
u64 raw_nsecs;
 
/* If the offset is smaller than a shifted interval, do nothing */
@@ -1017,16 +1045,8 @@ static cycle_t logarithmic_accumulation(cycle_t offset, 
u32 shift)
timekeeper.clock->cycle_last += timekeeper.cycle_interval << shift;
 
timekeeper.xtime_nsec += timekeeper.xtime_interval << shift;
-   while (timekeeper.xtime_nsec >= nsecps) {
-   int leap;
-   timekeeper.xtime_nsec -= nsecps;
-   timekeeper.xtime_sec++;
-   leap = second_overflow(timekeeper.xtime_sec);
-   timekeeper.xtime_sec += leap;
-   timekeeper.wall_to_monotonic.tv_sec -= leap;
-   if (leap)
-   clock_was_set_delayed();
-   }
+
+   accumulate_nsecs_to_secs();
 
/* Accumulate raw time */
raw_nsecs = timekeeper.raw_interval << shift;
@@ -1136,17 +1156,7 @@ static void update_wall_time(void)
 * Finally, make sure that after the rounding
 * xtime_nsec isn't larger than NSEC_PER_SEC
 */
-   if (unlikely(timekeeper.xtime_nsec >=
-   ((u64)NSEC_PER_SEC << timekeeper.shift))) {
-   int leap;
-   timekeeper.xtime_nsec -= (u64)NSEC_PER_SEC << timekeeper.shift;
-   timekeeper.xtime_sec++;
-   leap = second_overflow(timekeeper.xtime_sec);
-   timekeeper.xtime_sec += leap;
-   timekeeper.wall_to_monotonic.tv_sec -= leap;
-   if (leap)
-   clock_was_set_delayed();
-   }
+   accumulate_nsecs_to_secs();
 
timekeeping_update(false);
 
-- 
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 6/8] time: Move arch_gettimeoffset() usage into timekeeping_get_ns()

2012-07-12 Thread John Stultz
Since we call arch_gettimeoffset() in all the accessor
functions, move arch_gettimeoffset() calls into
timekeeping_get_ns() and timekeeping_get_ns_raw() to simplify
the code.

This also makes the code easier to maintain as we don't have to
worry about forgetting the arch_gettimeoffset() as has happened
in the past.

CC: Ingo Molnar 
CC: Peter Zijlstra 
CC: Richard Cochran 
CC: Prarit Bhargava 
CC: Thomas Gleixner 
Signed-off-by: John Stultz 
---
 kernel/time/timekeeping.c |   32 +---
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 5ffb2b6..dd119355 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -195,13 +195,18 @@ static inline s64 timekeeping_get_ns(void)
cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
 
nsec = cycle_delta * timekeeper.mult + timekeeper.xtime_nsec;
-   return nsec >> timekeeper.shift;
+   nsec >>= timekeeper.shift;
+
+   /* If arch requires, add in gettimeoffset() */
+   nsec += arch_gettimeoffset();
+   return nsec;
 }
 
 static inline s64 timekeeping_get_ns_raw(void)
 {
cycle_t cycle_now, cycle_delta;
struct clocksource *clock;
+   s64 nsec;
 
/* read clocksource: */
clock = timekeeper.clock;
@@ -210,8 +215,13 @@ static inline s64 timekeeping_get_ns_raw(void)
/* calculate the delta since the last update_wall_time: */
cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
 
-   /* return delta convert to nanoseconds. */
-   return clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift);
+   /* convert delta to nanoseconds. */
+   nsec = clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift);
+
+   /* If arch requires, add in gettimeoffset() */
+   nsec += arch_gettimeoffset();
+   return nsec;
+
 }
 
 static void update_rt_offset(void)
@@ -286,9 +296,6 @@ void getnstimeofday(struct timespec *ts)
ts->tv_sec = timekeeper.xtime_sec;
ts->tv_nsec = timekeeping_get_ns();
 
-   /* If arch requires, add in gettimeoffset() */
-   nsecs += arch_gettimeoffset();
-
} while (read_seqretry(, seq));
 
timespec_add_ns(ts, nsecs);
@@ -308,8 +315,6 @@ ktime_t ktime_get(void)
timekeeper.wall_to_monotonic.tv_sec;
nsecs = timekeeping_get_ns() +
timekeeper.wall_to_monotonic.tv_nsec;
-   /* If arch requires, add in gettimeoffset() */
-   nsecs += arch_gettimeoffset();
 
} while (read_seqretry(, seq));
/*
@@ -340,8 +345,6 @@ void ktime_get_ts(struct timespec *ts)
ts->tv_sec = timekeeper.xtime_sec;
ts->tv_nsec = timekeeping_get_ns();
tomono = timekeeper.wall_to_monotonic;
-   /* If arch requires, add in gettimeoffset() */
-   ts->tv_nsec += arch_gettimeoffset();
 
} while (read_seqretry(, seq));
 
@@ -369,8 +372,6 @@ void getnstime_raw_and_real(struct timespec *ts_raw, struct 
timespec *ts_real)
WARN_ON_ONCE(timekeeping_suspended);
 
do {
-   u32 arch_offset;
-
seq = read_seqbegin();
 
*ts_raw = timekeeper.raw_time;
@@ -380,11 +381,6 @@ void getnstime_raw_and_real(struct timespec *ts_raw, 
struct timespec *ts_real)
nsecs_raw = timekeeping_get_ns_raw();
nsecs_real = timekeeping_get_ns();
 
-   /* If arch requires, add in gettimeoffset() */
-   arch_offset = arch_gettimeoffset();
-   nsecs_raw += arch_offset;
-   nsecs_real += arch_offset;
-
} while (read_seqretry(, seq));
 
timespec_add_ns(ts_raw, nsecs_raw);
@@ -1342,8 +1338,6 @@ ktime_t ktime_get_update_offsets(ktime_t *offs_real, 
ktime_t *offs_boot)
 
secs = timekeeper.xtime_sec;
nsecs = timekeeping_get_ns();
-   /* If arch requires, add in gettimeoffset() */
-   nsecs += arch_gettimeoffset();
 
*offs_real = timekeeper.offs_real;
*offs_boot = timekeeper.offs_boot;
-- 
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 8/8] time: Rework timekeeping functions to take timekeeper ptr as argument

2012-07-12 Thread John Stultz
As part of cleaning up the timekeeping code, this patch converts
a number of internal functions to takei a timekeeper ptr as an
argument, so that the internal functions don't access the global
timekeeper structure directly. This allows for further optimizations
to reduce lock hold time later.

This patch has been updated to include more consistent usage of the
timekeeper value, by making sure it is always passed as a argument
to non top-level functions.

CC: Ingo Molnar 
CC: Peter Zijlstra 
CC: Richard Cochran 
CC: Prarit Bhargava 
CC: Thomas Gleixner 
Signed-off-by: John Stultz 
---
 kernel/time/timekeeping.c |  210 ++---
 1 file changed, 104 insertions(+), 106 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 4b76432..7f08972 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -122,7 +122,7 @@ static void tk_xtime_add(struct timekeeper *tk, const 
struct timespec *ts)
 
 
 /**
- * timekeeper_setup_internals - Set up internals to use clocksource clock.
+ * tk_setup_internals - Set up internals to use clocksource clock.
  *
  * @clock: Pointer to clocksource.
  *
@@ -131,14 +131,14 @@ static void tk_xtime_add(struct timekeeper *tk, const 
struct timespec *ts)
  *
  * Unless you're the timekeeping code, you should not be using this!
  */
-static void timekeeper_setup_internals(struct clocksource *clock)
+static void tk_setup_internals(struct timekeeper *tk, struct clocksource 
*clock)
 {
cycle_t interval;
u64 tmp, ntpinterval;
struct clocksource *old_clock;
 
-   old_clock = timekeeper.clock;
-   timekeeper.clock = clock;
+   old_clock = tk->clock;
+   tk->clock = clock;
clock->cycle_last = clock->read(clock);
 
/* Do the ns -> cycle conversion first, using original mult */
@@ -151,65 +151,65 @@ static void timekeeper_setup_internals(struct clocksource 
*clock)
tmp = 1;
 
interval = (cycle_t) tmp;
-   timekeeper.cycle_interval = interval;
+   tk->cycle_interval = interval;
 
/* Go back from cycles -> shifted ns */
-   timekeeper.xtime_interval = (u64) interval * clock->mult;
-   timekeeper.xtime_remainder = ntpinterval - timekeeper.xtime_interval;
-   timekeeper.raw_interval =
+   tk->xtime_interval = (u64) interval * clock->mult;
+   tk->xtime_remainder = ntpinterval - tk->xtime_interval;
+   tk->raw_interval =
((u64) interval * clock->mult) >> clock->shift;
 
 /* if changing clocks, convert xtime_nsec shift units */
if (old_clock) {
int shift_change = clock->shift - old_clock->shift;
if (shift_change < 0)
-   timekeeper.xtime_nsec >>= -shift_change;
+   tk->xtime_nsec >>= -shift_change;
else
-   timekeeper.xtime_nsec <<= shift_change;
+   tk->xtime_nsec <<= shift_change;
}
-   timekeeper.shift = clock->shift;
+   tk->shift = clock->shift;
 
-   timekeeper.ntp_error = 0;
-   timekeeper.ntp_error_shift = NTP_SCALE_SHIFT - clock->shift;
+   tk->ntp_error = 0;
+   tk->ntp_error_shift = NTP_SCALE_SHIFT - clock->shift;
 
/*
 * The timekeeper keeps its own mult values for the currently
 * active clocksource. These value will be adjusted via NTP
 * to counteract clock drifting.
 */
-   timekeeper.mult = clock->mult;
+   tk->mult = clock->mult;
 }
 
 /* Timekeeper helper functions. */
-static inline s64 timekeeping_get_ns(void)
+static inline s64 timekeeping_get_ns(struct timekeeper *tk)
 {
cycle_t cycle_now, cycle_delta;
struct clocksource *clock;
s64 nsec;
 
/* read clocksource: */
-   clock = timekeeper.clock;
+   clock = tk->clock;
cycle_now = clock->read(clock);
 
/* calculate the delta since the last update_wall_time: */
cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
 
-   nsec = cycle_delta * timekeeper.mult + timekeeper.xtime_nsec;
-   nsec >>= timekeeper.shift;
+   nsec = cycle_delta * tk->mult + tk->xtime_nsec;
+   nsec >>= tk->shift;
 
/* If arch requires, add in gettimeoffset() */
nsec += arch_gettimeoffset();
return nsec;
 }
 
-static inline s64 timekeeping_get_ns_raw(void)
+static inline s64 timekeeping_get_ns_raw(struct timekeeper *tk)
 {
cycle_t cycle_now, cycle_delta;
struct clocksource *clock;
s64 nsec;
 
/* read clocksource: */
-   clock = timekeeper.clock;
+   clock = tk->clock;
cycle_now = clock->read(clock);
 
/* calculate the delta since the last update_wall_time: */
@@ -224,27 +224,26 @@ static inline s64 timekeeping_get_ns_raw(void)
 
 }
 
-static void update_rt_offset(void)
+static void update_rt_offset(struct timekeeper *tk)
 {
-   struct timespec 

[PATCH 2/8] time: Whitespace cleanups per Ingo's requests

2012-07-12 Thread John Stultz
Ingo noted a number of places where there is inconsistent
use of whitespace. This patch tries to address the main
culprits.

CC: Ingo Molnar 
CC: Peter Zijlstra 
CC: Richard Cochran 
CC: Prarit Bhargava 
CC: Thomas Gleixner 
Signed-off-by: John Stultz 
---
 kernel/time/timekeeping.c |   39 ++-
 1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 269b1fe..c2f12aa 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -24,32 +24,31 @@
 /* Structure holding internal timekeeping values. */
 struct timekeeper {
/* Current clocksource used for timekeeping. */
-   struct clocksource *clock;
+   struct clocksource  *clock;
/* NTP adjusted clock multiplier */
-   u32 mult;
+   u32 mult;
/* The shift value of the current clocksource. */
-   int shift;
-
+   int shift;
/* Number of clock cycles in one NTP interval. */
-   cycle_t cycle_interval;
+   cycle_t cycle_interval;
/* Number of clock shifted nano seconds in one NTP interval. */
-   u64 xtime_interval;
+   u64 xtime_interval;
/* shifted nano seconds left over when rounding cycle_interval */
-   s64 xtime_remainder;
+   s64 xtime_remainder;
/* Raw nano seconds accumulated per NTP interval. */
-   u32 raw_interval;
+   u32 raw_interval;
 
/* Clock shifted nano seconds remainder not stored in xtime.tv_nsec. */
-   u64 xtime_nsec;
+   u64 xtime_nsec;
/* Difference between accumulated time and NTP time in ntp
 * shifted nano seconds. */
-   s64 ntp_error;
+   s64 ntp_error;
/* Shift conversion between clock shifted nano seconds and
 * ntp shifted nano seconds. */
-   int ntp_error_shift;
+   int ntp_error_shift;
 
/* The current time */
-   struct timespec xtime;
+   struct timespec xtime;
/*
 * wall_to_monotonic is what we need to add to xtime (or xtime corrected
 * for sub jiffie times) to get to monotonic time.  Monotonic is pegged
@@ -64,20 +63,17 @@ struct timekeeper {
 * - wall_to_monotonic is no longer the boot time, getboottime must be
 * used instead.
 */
-   struct timespec wall_to_monotonic;
+   struct timespec wall_to_monotonic;
/* time spent in suspend */
-   struct timespec total_sleep_time;
+   struct timespec total_sleep_time;
/* The raw monotonic time for the CLOCK_MONOTONIC_RAW posix clock. */
-   struct timespec raw_time;
-
+   struct timespec raw_time;
/* Offset clock monotonic -> clock realtime */
-   ktime_t offs_real;
-
+   ktime_t offs_real;
/* Offset clock monotonic -> clock boottime */
-   ktime_t offs_boot;
-
+   ktime_t offs_boot;
/* Seqlock for all timekeeper values */
-   seqlock_t lock;
+   seqlock_t   lock;
 };
 
 static struct timekeeper timekeeper;
@@ -547,6 +543,7 @@ u64 timekeeping_max_deferment(void)
 {
unsigned long seq;
u64 ret;
+
do {
seq = read_seqbegin();
 
-- 
1.7.9.5

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


[PATCH 1/8] ntp: Fix STA_INS/DEL clearing bug

2012-07-12 Thread John Stultz
From: John Stultz 

In commit 6b43ae8a619d17c4935c3320d2ef9e92bdeed05d, I
introduced a bug that kept the STA_INS or STA_DEL bit
from being cleared from time_status via adjtimex()
without forcing STA_PLL first.

Usually once the STA_INS is set, it isn't cleared
until the leap second is applied, so its unlikely this
affected anyone. However during testing I noticed it
took some effort to cancel a leap second once STA_INS
was set.

This issue affects 3.4 and up.

Since this isn't urgent (issue is only observed in testing,
the behavior doesn't affect ntpd, nor is a leapsecond due
for at least ~6 months), and we're late in the 3.5-rc
cycle, I'm holding this off for 3.6 merge window,
where I'll then backport to 3.5-stable and 3.4-stable.

CC: Ingo Molnar 
CC: Peter Zijlstra 
CC: Richard Cochran 
CC: Prarit Bhargava 
CC: Thomas Gleixner 
CC: sta...@vger.kernel.org
Signed-off-by: John Stultz 
---
 kernel/time/ntp.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 70b33ab..b7fbadc 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -409,7 +409,9 @@ int second_overflow(unsigned long secs)
time_state = TIME_DEL;
break;
case TIME_INS:
-   if (secs % 86400 == 0) {
+   if (!(time_status & STA_INS))
+   time_state = TIME_OK;
+   else if (secs % 86400 == 0) {
leap = -1;
time_state = TIME_OOP;
time_tai++;
@@ -418,7 +420,9 @@ int second_overflow(unsigned long secs)
}
break;
case TIME_DEL:
-   if ((secs + 1) % 86400 == 0) {
+   if (!(time_status & STA_DEL))
+   time_state = TIME_OK;
+   else if ((secs + 1) % 86400 == 0) {
leap = 1;
time_tai--;
time_state = TIME_WAIT;
-- 
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 3/8] time: Explicitly use u32 instead of int for shift values

2012-07-12 Thread John Stultz
Ingo noted that using a u32 instead of int for shift values
would be better to make sure the compiler doesn't unnecessarily
use complex signed arithmetic.

CC: Ingo Molnar 
CC: Peter Zijlstra 
CC: Richard Cochran 
CC: Prarit Bhargava 
CC: Thomas Gleixner 
Signed-off-by: John Stultz 
---
 kernel/time/timekeeping.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index c2f12aa..4fd83df 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -28,7 +28,7 @@ struct timekeeper {
/* NTP adjusted clock multiplier */
u32 mult;
/* The shift value of the current clocksource. */
-   int shift;
+   u32 shift;
/* Number of clock cycles in one NTP interval. */
cycle_t cycle_interval;
/* Number of clock shifted nano seconds in one NTP interval. */
@@ -45,7 +45,7 @@ struct timekeeper {
s64 ntp_error;
/* Shift conversion between clock shifted nano seconds and
 * ntp shifted nano seconds. */
-   int ntp_error_shift;
+   u32 ntp_error_shift;
 
/* The current time */
struct timespec xtime;
@@ -960,7 +960,7 @@ static void timekeeping_adjust(s64 offset)
  *
  * Returns the unconsumed cycles.
  */
-static cycle_t logarithmic_accumulation(cycle_t offset, int shift)
+static cycle_t logarithmic_accumulation(cycle_t offset, u32 shift)
 {
u64 nsecps = (u64)NSEC_PER_SEC << timekeeper.shift;
u64 raw_nsecs;
-- 
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 0/8] Time fixes and cleanups for 3.6

2012-07-12 Thread John Stultz
Hey Thomas,
Since you're offline next week, I wanted to send you my updated
queue for the 3.6 merge window.

These are mostly the same changes I sent you with my earlier 3.6 pull
request mid-last month, but reordered and trimmed down to focus on
cleanups (no new features).

There is one NTP bug fix, from a change in 3.4, but given its non critical
and we're late in the 3.5-rc cycle, I wanted to hold it off for 3.6 and
backport it once merged.

Since these expect the leapsecond hrtimer/time changes currently in
tip/timers/urgent, it is based off of that branch, rather then
tip/timers/core. Although  tip/timers/core merges fairly cleanly (there's
only a minor collision with already upstream 3.5 changes).

Let me know if these look ok. With the exception of the NTP fix, the rest
can wait till 3.7 if you'd prefer, so they're nothing urgent.

thanks
-john

CC: Ingo Molnar 
CC: Peter Zijlstra 
CC: Richard Cochran 
CC: Prarit Bhargava 
CC: Thomas Gleixner 

If you want to git pull:
The following changes since commit 5baefd6d84163443215f4a99f6a20f054ef11236:

  hrtimer: Update hrtimer base offsets each hrtimer_interrupt (2012-07-11 
23:34:39 +0200)

are available in the git repository at:

  git://git.linaro.org/people/jstultz/linux.git fortglx/3.6/time

for you to fetch changes up to 96dbf98929ac690a7d0d0ad54cf24631763da16c:

  time: Rework timekeeping functions to take timekeeper ptr as argument 
(2012-07-13 01:15:46 -0400)


John Stultz (8):
  ntp: Fix STA_INS/DEL clearing bug
  time: Whitespace cleanups per Ingo's requests
  time: Explicitly use u32 instead of int for shift values
  time: Condense timekeeper.xtime into xtime_sec
  time: Refactor accumulation of nsecs to secs
  time: Move arch_gettimeoffset() usage into timekeeping_get_ns()
  time: Move xtime_nsec adjustment underflow handling timekeeping_adjust
  time: Rework timekeeping functions to take timekeeper ptr as argument

 kernel/time/ntp.c |8 +-
 kernel/time/timekeeping.c |  492 -
 2 files changed, 273 insertions(+), 227 deletions(-)

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


[PATCH] x86/vsyscall: allow seccomp filter in vsyscall=emulate

2012-07-12 Thread Will Drewry
If a seccomp filter program is installed, older static binaries and
distributions with older libc implementations (glibc 2.13 and earlier)
that rely on vsyscall use will be terminated regardless of the filter
program policy when executing time, gettimeofday, or getcpu.  This is
only the case when vsyscall emulation is in use (vsyscall=emulate is the
default).

This patch emulates system call entry inside a vsyscall=emulate trap
such that seccomp can properly evaluate the system call.

Reported-by: Owen Kibel 
Signed-off-by: Will Drewry 
---
 arch/x86/kernel/vsyscall_64.c |   29 ++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
index 7515cf0..433545f 100644
--- a/arch/x86/kernel/vsyscall_64.c
+++ b/arch/x86/kernel/vsyscall_64.c
@@ -139,6 +139,14 @@ static int addr_to_vsyscall_nr(unsigned long addr)
return nr;
 }
 
+static int vsyscall_seccomp(struct task_struct *tsk, int syscall_nr)
+{
+   if (!seccomp_mode(>seccomp))
+   return 0;
+   task_pt_regs(tsk)->orig_ax = syscall_nr;
+   return __secure_computing(syscall_nr);
+}
+
 static bool write_ok_or_segv(unsigned long ptr, size_t size)
 {
/*
@@ -174,6 +182,7 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long 
address)
int vsyscall_nr;
int prev_sig_on_uaccess_error;
long ret;
+   int skip;
 
/*
 * No point in checking CS -- the only way to get here is a user mode
@@ -205,9 +214,6 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long 
address)
}
 
tsk = current;
-   if (seccomp_mode(>seccomp))
-   do_exit(SIGKILL);
-
/*
 * With a real vsyscall, page faults cause SIGSEGV.  We want to
 * preserve that behavior to make writing exploits harder.
@@ -222,8 +228,13 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long 
address)
 * address 0".
 */
ret = -EFAULT;
+   skip = 0;
switch (vsyscall_nr) {
case 0:
+   skip = vsyscall_seccomp(tsk, __NR_gettimeofday);
+   if (skip)
+   break;
+
if (!write_ok_or_segv(regs->di, sizeof(struct timeval)) ||
!write_ok_or_segv(regs->si, sizeof(struct timezone)))
break;
@@ -234,6 +245,10 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long 
address)
break;
 
case 1:
+   skip = vsyscall_seccomp(tsk, __NR_time);
+   if (skip)
+   break;
+
if (!write_ok_or_segv(regs->di, sizeof(time_t)))
break;
 
@@ -241,6 +256,10 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long 
address)
break;
 
case 2:
+   skip = vsyscall_seccomp(tsk, __NR_getcpu);
+   if (skip)
+   break;
+
if (!write_ok_or_segv(regs->di, sizeof(unsigned)) ||
!write_ok_or_segv(regs->si, sizeof(unsigned)))
break;
@@ -253,6 +272,9 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long 
address)
 
current_thread_info()->sig_on_uaccess_error = prev_sig_on_uaccess_error;
 
+   if (skip)
+   goto do_ret;
+
if (ret == -EFAULT) {
/* Bad news -- userspace fed a bad pointer to a vsyscall. */
warn_bad_vsyscall(KERN_INFO, regs,
@@ -271,6 +293,7 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long 
address)
 
regs->ax = ret;
 
+do_ret:
/* Emulate a ret instruction. */
regs->ip = caller;
regs->sp += 8;
-- 
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/


linux-next: manual merge of the clk tree with the arm-soc tree

2012-07-12 Thread Stephen Rothwell
Hi Mike,

Today's linux-next merge of the clk tree got a conflict in
drivers/clk/Makefile between commit 4a31bd28e86a ("ARM: nomadik: convert
to generic clock") from the arm-soc tree and commit 8d4d9f52081c ("clk:
add highbank clock support") from the clk tree.

Just context changes.  I fixed it up (see below) and can carry the fix as
necessary.
-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc drivers/clk/Makefile
index 26b6b92,02ffdf6..000
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@@ -3,6 -3,11 +3,12 @@@ obj-$(CONFIG_CLKDEV_LOOKUP)+= clkdev.
  obj-$(CONFIG_COMMON_CLK)  += clk.o clk-fixed-rate.o clk-gate.o \
   clk-mux.o clk-divider.o clk-fixed-factor.o
  # SoCs specific
 +obj-$(CONFIG_ARCH_NOMADIK)+= clk-nomadik.o
+ obj-$(CONFIG_ARCH_HIGHBANK)   += clk-highbank.o
  obj-$(CONFIG_ARCH_MXS)+= mxs/
  obj-$(CONFIG_PLAT_SPEAR)  += spear/
+ obj-$(CONFIG_ARCH_U300)   += clk-u300.o
+ obj-$(CONFIG_ARCH_INTEGRATOR) += versatile/
+ 
+ # Chip specific
+ obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o


pgpd4JbK4jA6M.pgp
Description: PGP signature


Re: [RFC PATCH v3 3/13] memory-hotplug : unify argument of firmware_map_add_early/hotplug

2012-07-12 Thread Yasuaki Ishimatsu
Hi Dave,

2012/07/12 22:40, Dave Hansen wrote:
> On 07/11/2012 09:52 PM, Yasuaki Ishimatsu wrote:
>> Does the following patch include your comment? If O.K., I will separate
>> the patch from the series and send it for bug fix.
> 
> Looks sane to me.  It does now mean that the calling conventions for
> some of the other firmware_map*() functions are different, but I think
> that's OK since they're only used internally to memmap.c.

Can I add "Reviewed-by: Dave Hansen" to the patch?

Thanks,
Yasuaki Ishimatsu

> --
> 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] leds/leds-s3c24xx: use devm_gpio_request

2012-07-12 Thread devendra.aaru
On Fri, Jul 13, 2012 at 9:12 AM, Bryan Wu  wrote:
> On Wed, Jul 11, 2012 at 5:50 PM, Devendra Naga  
> wrote:
>> Bryan,
>>
>> This patch is not even compile tested, since my machine crashed, and
>> didn't have the ARM toolchain, sorry ..
>>
>
> Thanks, I built it successfully. It looks fine to me. I will apply
> this to my for-next branch.
>
> -Bryan
>
Thank Bryan, I  will set up my cross-toolchain soon.. sorry for not
compiling it.
--
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: [ 000/187] 3.4.5-stable review

2012-07-12 Thread Sven Joachim
On 2012-07-12 21:24 +0200, Greg KH wrote:

> This is the start of the stable review cycle for the 3.4.5 release.
> There are 187 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.

As has been noted already, some of the patches are actually missing.

> The whole patch series can be found in one patch at:
>   kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.4.5-rc1.gz

Seems it's not there?

Cheers,
   Sven
--
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 v3 3/13] memory-hotplug : unify argument of firmware_map_add_early/hotplug

2012-07-12 Thread Yasuaki Ishimatsu
Hi Dave,

2012/07/12 22:40, Dave Hansen wrote:
> On 07/11/2012 09:52 PM, Yasuaki Ishimatsu wrote:
>> Does the following patch include your comment? If O.K., I will separate
>> the patch from the series and send it for bug fix.
> 
> Looks sane to me.  It does now mean that the calling conventions for
> some of the other firmware_map*() functions are different, but I think
> that's OK since they're only used internally to memmap.c.

Thank you for reviewing my patch.
I'll send the patch.

Thanks,
Yasuaki Ishimatsu

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


linux-next: build failure after merge of the tty tree

2012-07-12 Thread Stephen Rothwell
Hi Greg,

After merging the tty tree, today's linux-next build (x86_64 allmodconfig)
failed like this:

drivers/char/mwave/mwavedd.c: In function 'register_serial_portandirq':
drivers/char/mwave/mwavedd.c:472:2: error: implicit declaration of function 
'serial8250_register_port' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors
drivers/misc/ibmasm/uart.c: In function 'ibmasm_register_uart':
drivers/misc/ibmasm/uart.c:57:2: error: implicit declaration of function 
'serial8250_register_port' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors

Caused by commit 2655a2c76f80 ("8250: use the 8250 register interface not
the legacy one").  Grep is your friend.

I have used the tty tree from next-20120712 for today.
-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au


pgpt5WoBhJpNL.pgp
Description: PGP signature


RE: 82571EB: Detected Hardware Unit Hang

2012-07-12 Thread Dave, Tushar N
>-Original Message-
>From: Joe Jin [mailto:joe@oracle.com]
>Sent: Thursday, July 12, 2012 4:46 PM
>To: Dave, Tushar N
>Cc: e1000-de...@lists.sf.net; net...@vger.kernel.org; linux-
>ker...@vger.kernel.org
>Subject: Re: 82571EB: Detected Hardware Unit Hang
>
Thanks for sending full dmesg log. I am still investigating. I think this issue 
can occur if two PCIe link partner *i.e pcie bridge and pcie device do not have 
same max payload size.
I need 2 more info. 
1) PBA number of the card.
2) full lspci -vvv output of entire system 'after you have changed max payload 
size to 128'.

Thanks.

-Tushar
--
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] MPILIB: Provide count_leading/trailing_zeros() based on arch functions

2012-07-12 Thread James Morris
On Fri, 6 Jul 2012, David Howells wrote:

> Provide count_leading/trailing_zeros() macros based on extant arch bit 
> scanning
> functions rather than reimplementing from scratch in MPILIB.
> 
> Whilst we're at it, turn count_foo_zeros(n, x) into n = count_foo_zeros(x).
> 
> Also move the definition to asm-generic as other people may be interested in
> using it.

Please rebase this against
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git next


-- 
James Morris

--
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/9 v3] dmaengine: add an shdma-base library

2012-07-12 Thread Vinod Koul
On Mon, 2012-07-02 at 22:28 +0200, Guennadi Liakhovetski wrote:
> Hi Vinod
> 
> On Thu, 28 Jun 2012, Guennadi Liakhovetski wrote:
> 
> > Hi Vinod
> > 
> > On Fri, 25 May 2012, Guennadi Liakhovetski wrote:
> > 
> > > Hi Vinod
> > > 
> > > On Fri, 25 May 2012, Vinod Koul wrote:
> > 
> > [snip]
> > 
> > > > Let me know if you plan to fixing them or I will queue these up for 3.6
> > > 
> > > Please, queue these patches for the next merge window, we will work on 
> > > improving the driver after this split.
> > 
> > It's been a month since this mail - do I see it right, that these patches 
> > are still not in your slave-dma tree? Having them there would (1) get them 
> > some exposure and testing and (2) eventually speed up building on top of 
> > them and fixing existing driver's shortcomings. Any approximate idea when 
> > you'd be able to pull them in?
Sorry my bad, I missed them afterwards.

I will try them now. I assumed the two series I have in my inbox in on
top of these 9 patches.

> An update to this patch series: unfortunately, I forgot to include the 
> very first patch in this series. I'll send it as a reply to this mail.

-- 
~Vinod

--
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 V3 2/3] kvm: Note down when cpu relax intercepted or pause loop exited

2012-07-12 Thread Raghavendra K T

On 07/13/2012 01:32 AM, Christian Borntraeger wrote:

On 12/07/12 21:18, Raghavendra K T wrote:

+#ifdef CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT

[...]

+   struct {
+   bool cpu_relax_intercepted;
+   bool dy_eligible;
+   } ple;
+#endif

[...]

}
vcpu->run = page_address(page);
+   vcpu->ple.cpu_relax_intercepted = false;
+   vcpu->ple.dy_eligible = false;


This struct is only defined if CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT is set, but 
here it
is always accessed. Will break on !x86&&  !s390.


Yes! I forgot about archs in init function.
How about having
#ifdef CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT
vcpu->ple.cpu_relax_intercepted = false;
vcpu->ple.dy_eligible = false;
#endif

This would solve all the problem.



r = kvm_arch_vcpu_init(vcpu);
if (r<  0)
@@ -1577,6 +1579,7 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *me)
int pass;
int i;

+   me->ple.cpu_relax_intercepted = true;


dito


currently vcpu_on_spin is used only by x86 and s390. so if some other
arch in future uses vcpu_on_spin, I believe they also have to enable
CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT
what do you think?

otherwise we have to add hook everywhere

/*
 * We boost the priority of a VCPU that is runnable but not
 * currently running, because it got preempted by something
@@ -1602,6 +1605,7 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *me)
}
}
}
+   me->ple.cpu_relax_intercepted = false;


again.

maybe define static inline access functions in kvm_host.h that are no-ops
if CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT is not set.



--
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 v3 5/13] memory-hotplug : does not release memory region in PAGES_PER_SECTION chunks

2012-07-12 Thread Wen Congyang
At 07/09/2012 06:26 PM, Yasuaki Ishimatsu Wrote:
> Since applying a patch(de7f0cba96786c), release_mem_region() has been changed
> as called in PAGES_PER_SECTION chunks because register_memory_resource() is
> called in PAGES_PER_SECTION chunks by add_memory(). But it seems firmware
> dependency. If CRS are written in the PAGES_PER_SECTION chunks in ACPI DSDT
> Table, register_memory_resource() is called in PAGES_PER_SECTION chunks.
> But if CRS are written in the DIMM unit in ACPI DSDT Table,
> register_memory_resource() is called in DIMM unit. So release_mem_region()
> should not be called in PAGES_PER_SECTION chunks. The patch fixes it.
> 
> CC: David Rientjes 
> CC: Jiang Liu 
> CC: Len Brown 
> CC: Benjamin Herrenschmidt 
> CC: Paul Mackerras 
> CC: Christoph Lameter 
> Cc: Minchan Kim 
> CC: Andrew Morton 
> CC: KOSAKI Motohiro 
> CC: Wen Congyang 
> Signed-off-by: Yasuaki Ishimatsu 
> 
> ---
>  arch/powerpc/platforms/pseries/hotplug-memory.c |   13 +
>  mm/memory_hotplug.c |4 ++--
>  2 files changed, 11 insertions(+), 6 deletions(-)
> 
> Index: linux-3.5-rc4/mm/memory_hotplug.c
> ===
> --- linux-3.5-rc4.orig/mm/memory_hotplug.c2012-07-03 14:22:03.549198802 
> +0900
> +++ linux-3.5-rc4/mm/memory_hotplug.c 2012-07-03 14:22:05.919169458 +0900
> @@ -358,11 +358,11 @@ int __remove_pages(struct zone *zone, un
>   BUG_ON(phys_start_pfn & ~PAGE_SECTION_MASK);
>   BUG_ON(nr_pages % PAGES_PER_SECTION);
> 
> + release_mem_region(phys_start_pfn << PAGE_SHIFT,  nr_pages * PAGE_SIZE);
> +
>   sections_to_remove = nr_pages / PAGES_PER_SECTION;
>   for (i = 0; i < sections_to_remove; i++) {
>   unsigned long pfn = phys_start_pfn + i*PAGES_PER_SECTION;
> - release_mem_region(pfn << PAGE_SHIFT,
> -PAGES_PER_SECTION << PAGE_SHIFT);
>   ret = __remove_section(zone, __pfn_to_section(pfn));
>   if (ret)
>   break;
> Index: linux-3.5-rc4/arch/powerpc/platforms/pseries/hotplug-memory.c
> ===
> --- linux-3.5-rc4.orig/arch/powerpc/platforms/pseries/hotplug-memory.c
> 2012-07-03 14:21:45.641422678
> +0900

Hmm, I think you should change your mail client's config.

Thanks
Wen Congyang

> +++ linux-3.5-rc4/arch/powerpc/platforms/pseries/hotplug-memory.c 
> 2012-07-03 14:22:05.920169437 +0900
> @@ -77,7 +77,8 @@ static int pseries_remove_memblock(unsig
>  {
>   unsigned long start, start_pfn;
>   struct zone *zone;
> - int ret;
> + int i, ret;
> + int sections_to_remove;
> 
>   start_pfn = base >> PAGE_SHIFT;
> 
> @@ -97,9 +98,13 @@ static int pseries_remove_memblock(unsig
>* to sysfs "state" file and we can't remove sysfs entries
>* while writing to it. So we have to defer it to here.
>*/
> - ret = __remove_pages(zone, start_pfn, memblock_size >> PAGE_SHIFT);
> - if (ret)
> - return ret;
> + sections_to_remove = (memblock_size >> PAGE_SHIFT) / PAGES_PER_SECTION;
> + for (i = 0; i < sections_to_remove; i++) {
> + unsigned long pfn = start_pfn + i * PAGES_PER_SECTION;
> + ret = __remove_pages(zone, start_pfn,  PAGES_PER_SECTION);
> + if (ret)
> + return ret;
> + }
> 
>   /*
>* Update memory regions for memory remove
> 
> --
> 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 1/2] dma: tegra: rename driver and compatible to match with dts

2012-07-12 Thread Vinod Koul
On Mon, 2012-07-02 at 13:52 +0530, Laxman Dewangan wrote:
> Rename the compatible name and driver name to match with
> tegra dts file and as per clock driver.
> 
> Signed-off-by: Laxman Dewangan 
Applied both, Thanks

-- 
~Vinod

--
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 v3 2/13] memory-hotplug : add physical memory hotplug code to acpi_memory_device_remove

2012-07-12 Thread Wen Congyang
At 07/09/2012 06:24 PM, Yasuaki Ishimatsu Wrote:
> acpi_memory_device_remove() has been prepared to remove physical memory.
> But, the function only frees acpi_memory_device currentlry.
> 
> The patch adds following functions into acpi_memory_device_remove():
>   - offline memory
>   - remove physical memory (only return -EBUSY)
>   - free acpi_memory_device
> 
> CC: David Rientjes 
> CC: Jiang Liu 
> CC: Len Brown 
> CC: Benjamin Herrenschmidt 
> CC: Paul Mackerras 
> CC: Christoph Lameter 
> Cc: Minchan Kim 
> CC: Andrew Morton 
> CC: KOSAKI Motohiro 
> CC: Wen Congyang 
> Signed-off-by: Yasuaki Ishimatsu 
> 
> ---
>  drivers/acpi/acpi_memhotplug.c |   26 +-
>  drivers/base/memory.c  |   39 +++
>  include/linux/memory.h |5 +
>  include/linux/memory_hotplug.h |1 +
>  mm/memory_hotplug.c|8 
>  5 files changed, 78 insertions(+), 1 deletion(-)
> 
> Index: linux-3.5-rc6/drivers/acpi/acpi_memhotplug.c
> ===
> --- linux-3.5-rc6.orig/drivers/acpi/acpi_memhotplug.c 2012-07-09 
> 18:08:29.946888653 +0900
> +++ linux-3.5-rc6/drivers/acpi/acpi_memhotplug.c  2012-07-09 
> 18:08:43.470719531 +0900
> @@ -29,6 +29,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -452,12 +453,35 @@ static int acpi_memory_device_add(struct
>  static int acpi_memory_device_remove(struct acpi_device *device, int type)
>  {
>   struct acpi_memory_device *mem_device = NULL;
> -
> + struct acpi_memory_info *info, *tmp;
> + int result;
> + int node;
> 
>   if (!device || !acpi_driver_data(device))
>   return -EINVAL;
> 
>   mem_device = acpi_driver_data(device);
> +
> + node = acpi_get_node(mem_device->device->handle);
> +
> + list_for_each_entry_safe(info, tmp, _device->res_list, list) {
> + if (!info->enabled)
> + continue;
> +
> + if (!is_memblk_offline(info->start_addr, info->length)) {
> + result = offline_memory(info->start_addr, info->length);
> + if (result)
> + return result;
> + }
> +
> + result = remove_memory(node, info->start_addr, info->length);

The user may online the memory between offline_memory() and remove_memory().
So I think we should lock memory hotplug before check the memory's status
and release it after remove_memory().

Thanks
Wen Congyang

> + if (result)
> + return result;
> +
> + list_del(>list);
> + kfree(info);
> + }
> +
>   kfree(mem_device);
> 
>   return 0;
> Index: linux-3.5-rc6/include/linux/memory_hotplug.h
> ===
> --- linux-3.5-rc6.orig/include/linux/memory_hotplug.h 2012-07-09 
> 18:08:29.955888542 +0900
> +++ linux-3.5-rc6/include/linux/memory_hotplug.h  2012-07-09 
> 18:08:43.471719518 +0900
> @@ -233,6 +233,7 @@ static inline int is_mem_section_removab
>  extern int mem_online_node(int nid);
>  extern int add_memory(int nid, u64 start, u64 size);
>  extern int arch_add_memory(int nid, u64 start, u64 size);
> +extern int remove_memory(int nid, u64 start, u64 size);
>  extern int offline_memory(u64 start, u64 size);
>  extern int sparse_add_one_section(struct zone *zone, unsigned long start_pfn,
>   int nr_pages);
> Index: linux-3.5-rc6/mm/memory_hotplug.c
> ===
> --- linux-3.5-rc6.orig/mm/memory_hotplug.c2012-07-09 18:08:29.953888567 
> +0900
> +++ linux-3.5-rc6/mm/memory_hotplug.c 2012-07-09 18:08:43.476719455 +0900
> @@ -659,6 +659,14 @@ out:
>  }
>  EXPORT_SYMBOL_GPL(add_memory);
> 
> +int remove_memory(int nid, u64 start, u64 size)
> +{
> + return -EBUSY;
> +
> +}
> +EXPORT_SYMBOL_GPL(remove_memory);
> +
> +
>  #ifdef CONFIG_MEMORY_HOTREMOVE
>  /*
>   * A free page on the buddy free lists (not the per-cpu lists) has PageBuddy
> Index: linux-3.5-rc6/drivers/base/memory.c
> ===
> --- linux-3.5-rc6.orig/drivers/base/memory.c  2012-07-09 18:08:29.947888640 
> +0900
> +++ linux-3.5-rc6/drivers/base/memory.c   2012-07-09 18:10:54.880076739 
> +0900
> @@ -70,6 +70,45 @@ void unregister_memory_isolate_notifier(
>  }
>  EXPORT_SYMBOL(unregister_memory_isolate_notifier);
> 
> +bool is_memblk_offline(unsigned long start, unsigned long size)
> +{
> + struct memory_block *mem = NULL;
> + struct mem_section *section;
> + unsigned long start_pfn, end_pfn;
> + unsigned long pfn, section_nr;
> +
> + start_pfn = PFN_DOWN(start);
> + end_pfn = start_pfn + PFN_DOWN(start);
> +
> + for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
> +  

Re: [PATCH 2/2] dma: tegra: fix residual calculation for cyclic case

2012-07-12 Thread Vinod Koul
On Mon, 2012-07-02 at 10:02 -0600, Stephen Warren wrote:
> On 07/02/2012 02:22 AM, Laxman Dewangan wrote:
> > In cyclic mode of DMA, the byte transferred can be more
> > than the requested size and in this case, calculating
> > residuals based on the current position of DMA transfer to
> > bytes requested i.e. bytes required to transfer to reach
> > bytes requested from current DMA position.
> > 
> > Signed-off-by: Laxman Dewangan 
> 
> This makes sense to me, although I wonder if details like this aren't
> something that the dmaengine core should be handling.
No core doesn't know anything about the how much you are transferring
and where you are. That is the driver to calculate and provide.

-- 
~Vinod

--
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] leds/leds-s3c24xx: use devm_gpio_request

2012-07-12 Thread Bryan Wu
On Wed, Jul 11, 2012 at 5:50 PM, Devendra Naga  wrote:
> why?
> because if the led_classdev_register fails we wont do gpio free
> because using devm_ functions, there is no need for error paths
>
> Signed-off-by: Devendra Naga 
> ---
> Bryan,
>
> This patch is not even compile tested, since my machine crashed, and
> didn't have the ARM toolchain, sorry ..
>

Thanks, I built it successfully. It looks fine to me. I will apply
this to my for-next branch.

-Bryan

> And i think this patch is legit not as that pci_set_drvdata one :(
>  drivers/leds/leds-s3c24xx.c |3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/leds/leds-s3c24xx.c b/drivers/leds/leds-s3c24xx.c
> index e120640..942f0ea 100644
> --- a/drivers/leds/leds-s3c24xx.c
> +++ b/drivers/leds/leds-s3c24xx.c
> @@ -65,7 +65,6 @@ static int s3c24xx_led_remove(struct platform_device *dev)
> struct s3c24xx_gpio_led *led = pdev_to_gpio(dev);
>
> led_classdev_unregister(>cdev);
> -   gpio_free(led->pdata->gpio);
>
> return 0;
>  }
> @@ -92,7 +91,7 @@ static int s3c24xx_led_probe(struct platform_device *dev)
>
> led->pdata = pdata;
>
> -   ret = gpio_request(pdata->gpio, "S3C24XX_LED");
> +   ret = devm_gpio_request(>dev, pdata->gpio, "S3C24XX_LED");
> if (ret < 0)
> return ret;
>
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-leds" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Bryan Wu 
Kernel Developer+86.186-168-78255 Mobile
Canonical Ltd.  www.canonical.com
Ubuntu - Linux for human beings | www.ubuntu.com
--
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] Made core dump functionality optional

2012-07-12 Thread Cong Wang
On Thu, 2012-07-12 at 13:22 -0700, Alex Kelly wrote:
> Sorry it took me so long to reply to this:
> 
> 1. *Should* I change the option to CONFIG_CORE_DUMP ? I agree with Josh
> that in terms of the existing codebase, either way makes sense, but I'll
> defer to your judgment if you think I should change it.

Yeah, I agree.

> 
> 2. Is there a particular maintainer I should send this to if I hope to get
> it pushed upstream?
> 

I think Andrew Morton will take the patch.

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: [RFC PATCH v3 2/13] memory-hotplug : add physical memory hotplug code to acpi_memory_device_remove

2012-07-12 Thread Wen Congyang
At 07/09/2012 06:24 PM, Yasuaki Ishimatsu Wrote:
> acpi_memory_device_remove() has been prepared to remove physical memory.
> But, the function only frees acpi_memory_device currentlry.
> 
> The patch adds following functions into acpi_memory_device_remove():
>   - offline memory
>   - remove physical memory (only return -EBUSY)
>   - free acpi_memory_device
> 
> CC: David Rientjes 
> CC: Jiang Liu 
> CC: Len Brown 
> CC: Benjamin Herrenschmidt 
> CC: Paul Mackerras 
> CC: Christoph Lameter 
> Cc: Minchan Kim 
> CC: Andrew Morton 
> CC: KOSAKI Motohiro 
> CC: Wen Congyang 
> Signed-off-by: Yasuaki Ishimatsu 
> 
> ---
>  drivers/acpi/acpi_memhotplug.c |   26 +-
>  drivers/base/memory.c  |   39 +++
>  include/linux/memory.h |5 +
>  include/linux/memory_hotplug.h |1 +
>  mm/memory_hotplug.c|8 
>  5 files changed, 78 insertions(+), 1 deletion(-)
> 
> Index: linux-3.5-rc6/drivers/acpi/acpi_memhotplug.c
> ===
> --- linux-3.5-rc6.orig/drivers/acpi/acpi_memhotplug.c 2012-07-09 
> 18:08:29.946888653 +0900
> +++ linux-3.5-rc6/drivers/acpi/acpi_memhotplug.c  2012-07-09 
> 18:08:43.470719531 +0900
> @@ -29,6 +29,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -452,12 +453,35 @@ static int acpi_memory_device_add(struct
>  static int acpi_memory_device_remove(struct acpi_device *device, int type)
>  {
>   struct acpi_memory_device *mem_device = NULL;
> -
> + struct acpi_memory_info *info, *tmp;
> + int result;
> + int node;
> 
>   if (!device || !acpi_driver_data(device))
>   return -EINVAL;
> 
>   mem_device = acpi_driver_data(device);
> +
> + node = acpi_get_node(mem_device->device->handle);
> +
> + list_for_each_entry_safe(info, tmp, _device->res_list, list) {
> + if (!info->enabled)
> + continue;
> +
> + if (!is_memblk_offline(info->start_addr, info->length)) {
> + result = offline_memory(info->start_addr, info->length);
> + if (result)
> + return result;
> + }
> +
> + result = remove_memory(node, info->start_addr, info->length);
> + if (result)
> + return result;
> +
> + list_del(>list);
> + kfree(info);
> + }
> +
>   kfree(mem_device);
> 
>   return 0;
> Index: linux-3.5-rc6/include/linux/memory_hotplug.h
> ===
> --- linux-3.5-rc6.orig/include/linux/memory_hotplug.h 2012-07-09 
> 18:08:29.955888542 +0900
> +++ linux-3.5-rc6/include/linux/memory_hotplug.h  2012-07-09 
> 18:08:43.471719518 +0900
> @@ -233,6 +233,7 @@ static inline int is_mem_section_removab
>  extern int mem_online_node(int nid);
>  extern int add_memory(int nid, u64 start, u64 size);
>  extern int arch_add_memory(int nid, u64 start, u64 size);
> +extern int remove_memory(int nid, u64 start, u64 size);


Here should be:
#ifdef CONFIG_MEMORY_HOTREMOVE
extern int remove_memory(int nid, u64 start, u64 size);
#else
static int inline remove_memory(int nid, u64 start, u64 size)
{
return -EBUSY;
}
#endif

>  extern int offline_memory(u64 start, u64 size);
>  extern int sparse_add_one_section(struct zone *zone, unsigned long start_pfn,
>   int nr_pages);
> Index: linux-3.5-rc6/mm/memory_hotplug.c
> ===
> --- linux-3.5-rc6.orig/mm/memory_hotplug.c2012-07-09 18:08:29.953888567 
> +0900
> +++ linux-3.5-rc6/mm/memory_hotplug.c 2012-07-09 18:08:43.476719455 +0900
> @@ -659,6 +659,14 @@ out:
>  }
>  EXPORT_SYMBOL_GPL(add_memory);
> 
> +int remove_memory(int nid, u64 start, u64 size)
> +{
> + return -EBUSY;
> +
> +}
> +EXPORT_SYMBOL_GPL(remove_memory);

We only need to implement this function when CONFIG_MEMORY_HOTREMOVE
is defined here.

Thanks
Wen Congyang

> +
> +
>  #ifdef CONFIG_MEMORY_HOTREMOVE
>  /*
>   * A free page on the buddy free lists (not the per-cpu lists) has PageBuddy
> Index: linux-3.5-rc6/drivers/base/memory.c
> ===
> --- linux-3.5-rc6.orig/drivers/base/memory.c  2012-07-09 18:08:29.947888640 
> +0900
> +++ linux-3.5-rc6/drivers/base/memory.c   2012-07-09 18:10:54.880076739 
> +0900
> @@ -70,6 +70,45 @@ void unregister_memory_isolate_notifier(
>  }
>  EXPORT_SYMBOL(unregister_memory_isolate_notifier);
> 
> +bool is_memblk_offline(unsigned long start, unsigned long size)
> +{
> + struct memory_block *mem = NULL;
> + struct mem_section *section;
> + unsigned long start_pfn, end_pfn;
> + unsigned long pfn, section_nr;
> +
> + start_pfn = PFN_DOWN(start);
> + end_pfn = start_pfn + 

Re: linux-next: manual merge of the slave-dma tree with the arm tree

2012-07-12 Thread Vinod Koul
On Mon, 2012-07-02 at 13:16 +1000, Stephen Rothwell wrote:
> Hi Vinod,
> 
> Today's linux-next merge of the slave-dma tree got conflicts in
> drivers/dma/Kconfig and drivers/dma/Makefile between commit 06dba53e6fcf
> ("dmaengine: add OMAP DMA engine driver") from the arm tree and commit
> c6da0ba8dfc8 ("dmaengine: mmp_tdma: add mmp tdma support") from the
> slave-dma tree.
Thanks, Looks like Russell has merged the OMAP changes into his tree?


-- 
~Vinod

--
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 1/1] clk: add DT support for clock gating control

2012-07-12 Thread Rob Herring
On 07/12/2012 08:08 AM, Sebastian Hesselbarh wrote:
> On 07/12/2012 02:14 PM, Rob Herring wrote:
>>> +Required child properties:
>>> +- reg : should contain the individual bit and polarity to control
>>> +the clock gate. A polarity of 0 means that by setting the
>>> +bit to 1 the clock passes through the clock gate while
>>> +setting the bit to 0 disables the clock. Any other value
>>> + for polarity inverts the meaning of the control bit.
>>
>> This is a bit of overloading reg to specify the polarity.
> 
> Well, yes it is overloading but still matches reg somehow, as the
> extra information is required to access the resource. But I agree,
> expecially wrt more-than-one-bit clk-gate (see below).
> 

You can define your own property names.

>>> +/* SATA clock gate with different parent clock */
>>> +cg_sata: clockgate@3 {
>>> +reg =<3 0>; /* register bit 3, normal polarity */
>>> +clocks =<_clk>;
>>> +};
>>
>> I'm not sure I like the node per bit. What about a bit mask for valid
>> bits and polarities. Then add a clock cell to specify the bit or index.
>>
>> i.MX has 2-bit enable fields for its leaf clocks, so how and if you
>> would support that is something to think about.
> 
> Yeah, I thought of "what if the clk_gate needs to be enabled with more
> than 1 bit" already. But this is a short-comming of the current clk-gate
> implementation.

What's implemented in Linux should not define the binding. The binding
should describe the hardware.

> Just to get it right, i.MX requires to set more than one bit to change
> the state of the gate for one leaf clock?

It's basically ON, OFF, and "ON in run/OFF in wfi".

Perhaps the iMX case is unique enough we don't try to make it use a
common binding.

> If this is true, that would require a change of the generic clk-gate
> anyway.

True, but not your problem to implement. A binding doesn't necessarily
mean there is a full Linux implementation. We just don't want to create
something only to find others need something completely different.

Rob

> I had a look at pinctrl-bindings.txt maybe this is the way to go for
> clock gating control, too. That would require clk-gate to handle an
> 'active' and 'gated' state and leave it to a clock gate control to
> actually set the required bits in any registers. This would allow
> other special implementations of clock gating controllers to reuse
> clk-gate DT description. Additionally, there could be a
> simple-clock-gating-control that can set states by reg address and
> for each controlled gate a mask, enable value, and disable value.
> 
> Sebastian


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


RE: [PATCH net-next] r8169: Remove rtl_ocpdr_cond

2012-07-12 Thread hayeswang
 Francois Romieu [mailto:rom...@fr.zoreil.com] 
[...]
> 
> W/o firmware does not seem to make a difference.
> 
> # ping -qf -l 4 -s 81 -c 60 10.0.3.1
> PING 10.0.3.1 (10.0.3.1) 81(109) bytes of data.
> 
> --- 10.0.3.1 ping statistics ---
> 60 packets transmitted, 60 received, 0% packet loss, time 153ms
> rtt min/avg/max/mdev = 0.047/0.064/0.117/0.016 ms, pipe 4, 
> ipg/ewma 2.607/0.058 ms

# ping -qf -l 4 -s 81 -c 60 192.168.94.20
PING 192.168.94.20 (192.168.94.20) 81(109) bytes of data.

--- 192.168.94.20 ping statistics ---
60 packets transmitted, 57 received, 5% packet loss, time 1ms
rtt min/avg/max/mdev = 0.028/0.040/0.101/0.011 ms, pipe 4, ipg/ewma 0.021/0.035
ms

> # ping -qf -l 4 -s 82 -c 60 10.0.3.1  
>
> PING 10.0.3.1 (10.0.3.1) 82(110) bytes of data.
> 
> --- 10.0.3.1 ping statistics ---
> 60 packets transmitted, 60 received, 0% packet loss, time 3ms
> rtt min/avg/max/mdev = 0.195/0.210/0.281/0.018 ms, pipe 4, 
> ipg/ewma 0.057/0.205 ms

# ping -qf -l 4 -s 82 -c 60 192.168.94.20
PING 192.168.94.20 (192.168.94.20) 82(110) bytes of data.

--- 192.168.94.20 ping statistics ---
60 packets transmitted, 60 received, 0% packet loss, time 2ms
rtt min/avg/max/mdev = 0.151/0.173/0.247/0.020 ms, pipe 4, ipg/ewma 0.048/0.168
ms

> It would translate into a 127/128 cutoff after inclusion of the FCS.
> 
> Any idea ?
> 

The attatched file is my log. It seems fine.


a.log
Description: Binary data


Re: feature-removal-schedule entry from 2009

2012-07-12 Thread Theodore Ts'o
On Wed, Jul 11, 2012 at 11:15:20AM -0500, Rob Landley wrote:
> IRQF_SAMPLE_RANDOM is 3 years past its sell-by date in
> feature-removal-schedule:
> 
> What:   IRQF_SAMPLE_RANDOM
> Check:  IRQF_SAMPLE_RANDOM
> When:   July 2009
> 
> Why:Many of IRQF_SAMPLE_RANDOM users are technically bogus as
> entropy sources in the kernel's current entropy model. To
> resolve this, every input point to the kernel's entropy pool
> needs to better document the type of entropy source it actually
> is. This will be replaced with additional add_*_randomness
> functions in drivers/char/random.c
> 
> Who:Robin Getz 
> & Matt Mackall 
> 
> There are 12 remaining uses under drivers/ and 14 more under arch/, the
> rest of the hits look like infrastructure implementing it.
> 
> Should I run those files through bother-maintainer.pl and try to get
> people to stop it, or is there a plan underway I don't know about?

I was going to deal with that in the new /dev/random tree; once those
changes go in, IRQF_SAMPLE_RANDOM effectively becomes a no-op.  But
I'd prefer that the ordering be that we get the new
sample_interrupt_randomness() changes in first, and then remove the
IRQF_SAMPLE_RANDOM.

I've just been slammed with work, processing patches for the ext4
merge window, and kernel summit planning, and quite frankly, I
considered this to be relatively low priority --- especially since we
no shortage of IRQF_* flag bits, and once the new
sample_interrupt_randomness() goes in, the flag is a complete no-op.

- Ted
--
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] usb/host/ehci-hub: Fix the issue EG20T USB host controller has long resuming time, when pen drive is attached.

2012-07-12 Thread Tomoya MORINAGA
Intel EG20T USB host controller does not send SOF in resuming time after
suspending, if the FLR bit was not cleared. When pen drive is attached,
the controller has a long resuming time to try re-connect it.
This patch clear the FLR bit in suspending time for fixing the issue.

Signed-off-by: Tomoya MORINAGA 
---
v3: Update comments from Alan Stern
Add comment in the source code.

v2: Update comments from Alan Stern
Add patch description
Always clear the STS_FLR flag.
---
 drivers/usb/host/ehci-hub.c |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index fc9e7cc..278b589 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -318,6 +318,13 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
ehci_readl(ehci, >regs->intr_enable);
 
ehci->next_statechange = jiffies + msecs_to_jiffies(10);
+
+   /* Intel EG20T USB host controller does not send SOF
+* in resuming time after suspending, if the FLR bit was not cleared.
+* Therefore clear the FLR bit in here.
+*/
+   ehci_writel(ehci, STS_FLR, >regs->status);
+
spin_unlock_irq (>lock);
 
/* ehci_work() may have re-enabled the watchdog timer, which we do not
-- 
1.7.4.4

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


Re: ARM mini-summit

2012-07-12 Thread Olof Johansson
On Wed, Jul 11, 2012 at 4:28 AM, Arnd Bergmann  wrote:
> On Wednesday 11 July 2012, James Bottomley wrote:
>> Hi All,
>>
>> We have set aside the second day of the kernel summit (Tuesday 28
>> August) as mini-summit day.  So far we have only the PCI mini summit on
>> this day, so if you can think of other topics, please send them to the
>> kernel summit discuss list:
>>
>> ksummit-2012-disc...@lists.linux-foundation.org
>>
>> Looking at the available rooms, we think we can run about four or five
>> mini summits.
>>
>> As an added incentive, mini summit organisers get to pick who they
>> invite and all the people they pick will get an automatic invitation to
>> the third day of the kernel summit (but not the core first day) and the
>> evening events.
>
> There is a lot of interest in having another ARM mini-summit, as we had last
> year. Previously, Grant Likely organized this with Olof and me, but right now
> Grant is in an extended offline period and Olof is currently on vacation
> as well. Will Deacon already contacted me and he is interested in helping
> out with organizing the mini-summit, so the two of us could be the primary
> contacts, with Grant and Olof joining in as time permits.

ACK. I'll be back home next week and should have more time to spend on
it from there on out.


-Olof
--
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] staging: sbe-2t3e3: Remove code that will never execute

2012-07-12 Thread Marcos Paulo de Souza
This patch removes all references of "if 0" blocks in the sbe-2t3e3 driver.

Signed-off-by: Marcos Paulo de Souza 
---
 drivers/staging/sbe-2t3e3/2t3e3.h|3 --
 drivers/staging/sbe-2t3e3/cpld.c |   15 -
 drivers/staging/sbe-2t3e3/ctrl.c |   19 +++
 drivers/staging/sbe-2t3e3/dc.c   |   17 --
 drivers/staging/sbe-2t3e3/exar7250.c |   40 +++
 drivers/staging/sbe-2t3e3/exar7300.c |   17 --
 drivers/staging/sbe-2t3e3/intr.c |   60 ++
 drivers/staging/sbe-2t3e3/io.c   |   21 
 8 files changed, 10 insertions(+), 182 deletions(-)

diff --git a/drivers/staging/sbe-2t3e3/2t3e3.h 
b/drivers/staging/sbe-2t3e3/2t3e3.h
index fe9f086..383f2cf 100644
--- a/drivers/staging/sbe-2t3e3/2t3e3.h
+++ b/drivers/staging/sbe-2t3e3/2t3e3.h

Just fix the commit message fo sbr-2t3e3 to sbe-2t3e3.

@@ -801,9 +801,6 @@ u32 cpld_read(struct channel *sc, u32 reg);
 void cpld_set_crc(struct channel *, u32);
 void cpld_start_intr(struct channel *);
 void cpld_stop_intr(struct channel *);
-#if 0
-void cpld_led_onoff(struct channel *, u32, u32, u32, u32);
-#endif
 void cpld_set_clock(struct channel *sc, u32 mode);
 void cpld_set_scrambler(struct channel *, u32);
 void cpld_select_panel(struct channel *, u32);
diff --git a/drivers/staging/sbe-2t3e3/cpld.c b/drivers/staging/sbe-2t3e3/cpld.c
index b0fc2dd..cc2b54d 100644
--- a/drivers/staging/sbe-2t3e3/cpld.c
+++ b/drivers/staging/sbe-2t3e3/cpld.c
@@ -41,14 +41,6 @@ static inline void cpld_clear_bit(struct channel *channel, 
unsigned reg, u32 bit
 void cpld_init(struct channel *sc)
 {
u32 val;
-#if 0
-   /* reset LIU and Framer */
-   val = cpld_val_map[SBE_2T3E3_CPLD_VAL_LIU_FRAMER_RESET][sc->h.slot];
-   cpld_write(sc, SBE_2T3E3_CPLD_REG_STATIC_RESET, val);
-   udelay(1); /* TODO - how long? */
-   val = 0;
-   cpld_write(sc, SBE_2T3E3_CPLD_REG_STATIC_RESET, val);
-#endif
 
/* PCRA */
val = SBE_2T3E3_CPLD_VAL_CRC32 |
@@ -109,13 +101,6 @@ void cpld_start_intr(struct channel *sc)
val = SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_ETHERNET_ENABLE |
SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_FRAMER_ENABLE;
cpld_write(sc, SBE_2T3E3_CPLD_REG_PIER, val);
-#if 0
-   /*
- do you want to hang up your computer?
- ENABLE REST OF INTERRUPTS !!!
- you have been warned :).
-   */
-#endif
 }
 
 void cpld_stop_intr(struct channel *sc)
diff --git a/drivers/staging/sbe-2t3e3/ctrl.c b/drivers/staging/sbe-2t3e3/ctrl.c
index d9dd216..a5825d7 100644
--- a/drivers/staging/sbe-2t3e3/ctrl.c
+++ b/drivers/staging/sbe-2t3e3/ctrl.c
@@ -230,11 +230,9 @@ void t3e3_port_get_stats(struct channel *sc,
result = exar7250_read(sc, 
SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2);
sc->s.LOF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_LOF ? 1 : 0;
sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0;
-#if 0
-   sc->s.LOS = result & SBE_2T3E3_FRAMER_VAL_E3_RX_LOS ? 1 : 0;
-#else
+
cpld_LOS_update(sc);
-#endif
+
sc->s.AIS = result & SBE_2T3E3_FRAMER_VAL_E3_RX_AIS ? 1 : 0;
sc->s.FERF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_FERF ? 1 : 0;
break;
@@ -243,11 +241,9 @@ void t3e3_port_get_stats(struct channel *sc,
case SBE_2T3E3_FRAME_TYPE_T3_M13:
result = exar7250_read(sc, 
SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS);
sc->s.AIS = result & SBE_2T3E3_FRAMER_VAL_T3_RX_AIS ? 1 : 0;
-#if 0
-   sc->s.LOS = result & SBE_2T3E3_FRAMER_VAL_T3_RX_LOS ? 1 : 0;
-#else
+
cpld_LOS_update(sc);
-#endif
+
sc->s.IDLE = result & SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE ? 1 : 0;
sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0;
 
@@ -322,10 +318,6 @@ void t3e3_if_config(struct channel *sc, u32 cmd, char *set,
*rlen = sizeof(ret->u.data);
break;
case SBE_2T3E3_PORT_WRITE_REGS:
-#if 0
-   printk(KERN_DEBUG "SBE_2T3E3_PORT_WRITE_REGS, 0x%x, 0x%x, 
0x%x\n",
-  ((int*)data)[0], ((int*)data)[1], ((int*)data)[2]);
-#endif
t3e3_reg_write(sc, data);
*rlen = 0;
break;
@@ -336,9 +328,6 @@ void t3e3_if_config(struct channel *sc, u32 cmd, char *set,
*rlen = 0;
break;
}
-
-   /* turn on interrupt */
-   /* cpld_start_intr(sc); */
 }
 
 void t3e3_sc_init(struct channel *sc)
diff --git a/drivers/staging/sbe-2t3e3/dc.c b/drivers/staging/sbe-2t3e3/dc.c
index e897a43..9e81d90 100644
--- a/drivers/staging/sbe-2t3e3/dc.c
+++ b/drivers/staging/sbe-2t3e3/dc.c
@@ -63,14 +63,6 @@ void dc_init(struct channel *sc)
if (sc->p.loopback == SBE_2T3E3_LOOPBACK_ETHERNET)
sc->p.loopback = SBE_2T3E3_LOOPBACK_NONE;
 
-#if 0 /* No need to clear this register - and 

[PATCH] staging: sbe-2t3e3: Remove code that will never execute

2012-07-12 Thread Marcos Paulo de Souza
This patch removes all references of "if 0" blocks in the sbr-2t3e3.

Signed-off-by: Marcos Paulo de Souza 
---
 drivers/staging/sbe-2t3e3/2t3e3.h|3 --
 drivers/staging/sbe-2t3e3/cpld.c |   15 -
 drivers/staging/sbe-2t3e3/ctrl.c |   19 +++
 drivers/staging/sbe-2t3e3/dc.c   |   17 --
 drivers/staging/sbe-2t3e3/exar7250.c |   40 +++
 drivers/staging/sbe-2t3e3/exar7300.c |   17 --
 drivers/staging/sbe-2t3e3/intr.c |   60 ++
 drivers/staging/sbe-2t3e3/io.c   |   21 
 8 files changed, 10 insertions(+), 182 deletions(-)

diff --git a/drivers/staging/sbe-2t3e3/2t3e3.h 
b/drivers/staging/sbe-2t3e3/2t3e3.h
index fe9f086..383f2cf 100644
--- a/drivers/staging/sbe-2t3e3/2t3e3.h
+++ b/drivers/staging/sbe-2t3e3/2t3e3.h
@@ -801,9 +801,6 @@ u32 cpld_read(struct channel *sc, u32 reg);
 void cpld_set_crc(struct channel *, u32);
 void cpld_start_intr(struct channel *);
 void cpld_stop_intr(struct channel *);
-#if 0
-void cpld_led_onoff(struct channel *, u32, u32, u32, u32);
-#endif
 void cpld_set_clock(struct channel *sc, u32 mode);
 void cpld_set_scrambler(struct channel *, u32);
 void cpld_select_panel(struct channel *, u32);
diff --git a/drivers/staging/sbe-2t3e3/cpld.c b/drivers/staging/sbe-2t3e3/cpld.c
index b0fc2dd..cc2b54d 100644
--- a/drivers/staging/sbe-2t3e3/cpld.c
+++ b/drivers/staging/sbe-2t3e3/cpld.c
@@ -41,14 +41,6 @@ static inline void cpld_clear_bit(struct channel *channel, 
unsigned reg, u32 bit
 void cpld_init(struct channel *sc)
 {
u32 val;
-#if 0
-   /* reset LIU and Framer */
-   val = cpld_val_map[SBE_2T3E3_CPLD_VAL_LIU_FRAMER_RESET][sc->h.slot];
-   cpld_write(sc, SBE_2T3E3_CPLD_REG_STATIC_RESET, val);
-   udelay(1); /* TODO - how long? */
-   val = 0;
-   cpld_write(sc, SBE_2T3E3_CPLD_REG_STATIC_RESET, val);
-#endif
 
/* PCRA */
val = SBE_2T3E3_CPLD_VAL_CRC32 |
@@ -109,13 +101,6 @@ void cpld_start_intr(struct channel *sc)
val = SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_ETHERNET_ENABLE |
SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_FRAMER_ENABLE;
cpld_write(sc, SBE_2T3E3_CPLD_REG_PIER, val);
-#if 0
-   /*
- do you want to hang up your computer?
- ENABLE REST OF INTERRUPTS !!!
- you have been warned :).
-   */
-#endif
 }
 
 void cpld_stop_intr(struct channel *sc)
diff --git a/drivers/staging/sbe-2t3e3/ctrl.c b/drivers/staging/sbe-2t3e3/ctrl.c
index d9dd216..a5825d7 100644
--- a/drivers/staging/sbe-2t3e3/ctrl.c
+++ b/drivers/staging/sbe-2t3e3/ctrl.c
@@ -230,11 +230,9 @@ void t3e3_port_get_stats(struct channel *sc,
result = exar7250_read(sc, 
SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2);
sc->s.LOF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_LOF ? 1 : 0;
sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0;
-#if 0
-   sc->s.LOS = result & SBE_2T3E3_FRAMER_VAL_E3_RX_LOS ? 1 : 0;
-#else
+
cpld_LOS_update(sc);
-#endif
+
sc->s.AIS = result & SBE_2T3E3_FRAMER_VAL_E3_RX_AIS ? 1 : 0;
sc->s.FERF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_FERF ? 1 : 0;
break;
@@ -243,11 +241,9 @@ void t3e3_port_get_stats(struct channel *sc,
case SBE_2T3E3_FRAME_TYPE_T3_M13:
result = exar7250_read(sc, 
SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS);
sc->s.AIS = result & SBE_2T3E3_FRAMER_VAL_T3_RX_AIS ? 1 : 0;
-#if 0
-   sc->s.LOS = result & SBE_2T3E3_FRAMER_VAL_T3_RX_LOS ? 1 : 0;
-#else
+
cpld_LOS_update(sc);
-#endif
+
sc->s.IDLE = result & SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE ? 1 : 0;
sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0;
 
@@ -322,10 +318,6 @@ void t3e3_if_config(struct channel *sc, u32 cmd, char *set,
*rlen = sizeof(ret->u.data);
break;
case SBE_2T3E3_PORT_WRITE_REGS:
-#if 0
-   printk(KERN_DEBUG "SBE_2T3E3_PORT_WRITE_REGS, 0x%x, 0x%x, 
0x%x\n",
-  ((int*)data)[0], ((int*)data)[1], ((int*)data)[2]);
-#endif
t3e3_reg_write(sc, data);
*rlen = 0;
break;
@@ -336,9 +328,6 @@ void t3e3_if_config(struct channel *sc, u32 cmd, char *set,
*rlen = 0;
break;
}
-
-   /* turn on interrupt */
-   /* cpld_start_intr(sc); */
 }
 
 void t3e3_sc_init(struct channel *sc)
diff --git a/drivers/staging/sbe-2t3e3/dc.c b/drivers/staging/sbe-2t3e3/dc.c
index e897a43..9e81d90 100644
--- a/drivers/staging/sbe-2t3e3/dc.c
+++ b/drivers/staging/sbe-2t3e3/dc.c
@@ -63,14 +63,6 @@ void dc_init(struct channel *sc)
if (sc->p.loopback == SBE_2T3E3_LOOPBACK_ETHERNET)
sc->p.loopback = SBE_2T3E3_LOOPBACK_NONE;
 
-#if 0 /* No need to clear this register - and it may be in use */
-   /*
-* 

[PATCH] regulator: s2mps11: Use array to save pointer to rdev

2012-07-12 Thread Axel Lin
The number of regulator is known at compile time, use array to save pointer to
rdev makes the code simpler.

Signed-off-by: Axel Lin 
---
 drivers/regulator/s2mps11.c |   27 ---
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index 4669dc9..926f9c8 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -24,7 +24,7 @@
 #include 
 
 struct s2mps11_info {
-   struct regulator_dev **rdev;
+   struct regulator_dev *rdev[S2MPS11_REGULATOR_MAX];
 
int ramp_delay2;
int ramp_delay34;
@@ -236,9 +236,8 @@ static __devinit int s2mps11_pmic_probe(struct 
platform_device *pdev)
struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
struct sec_platform_data *pdata = dev_get_platdata(iodev->dev);
struct regulator_config config = { };
-   struct regulator_dev **rdev;
struct s2mps11_info *s2mps11;
-   int i, ret, size;
+   int i, ret;
unsigned char ramp_enable, ramp_reg = 0;
 
if (!pdata) {
@@ -251,13 +250,6 @@ static __devinit int s2mps11_pmic_probe(struct 
platform_device *pdev)
if (!s2mps11)
return -ENOMEM;
 
-   size = sizeof(struct regulator_dev *) * S2MPS11_REGULATOR_MAX;
-   s2mps11->rdev = devm_kzalloc(>dev, size, GFP_KERNEL);
-   if (!s2mps11->rdev) {
-   return -ENOMEM;
-   }
-
-   rdev = s2mps11->rdev;
platform_set_drvdata(pdev, s2mps11);
 
s2mps11->ramp_delay2 = pdata->buck2_ramp_delay;
@@ -297,12 +289,12 @@ static __devinit int s2mps11_pmic_probe(struct 
platform_device *pdev)
config.init_data = pdata->regulators[i].initdata;
config.driver_data = s2mps11;
 
-   rdev[i] = regulator_register([i], );
-   if (IS_ERR(rdev[i])) {
-   ret = PTR_ERR(rdev[i]);
+   s2mps11->rdev[i] = regulator_register([i], );
+   if (IS_ERR(s2mps11->rdev[i])) {
+   ret = PTR_ERR(s2mps11->rdev[i]);
dev_err(>dev, "regulator init failed for %d\n",
i);
-   rdev[i] = NULL;
+   s2mps11->rdev[i] = NULL;
goto err;
}
}
@@ -310,8 +302,7 @@ static __devinit int s2mps11_pmic_probe(struct 
platform_device *pdev)
return 0;
 err:
for (i = 0; i < S2MPS11_REGULATOR_MAX; i++)
-   if (rdev[i])
-   regulator_unregister(rdev[i]);
+   regulator_unregister(s2mps11->rdev[i]);
 
return ret;
 }
@@ -319,12 +310,10 @@ err:
 static int __devexit s2mps11_pmic_remove(struct platform_device *pdev)
 {
struct s2mps11_info *s2mps11 = platform_get_drvdata(pdev);
-   struct regulator_dev **rdev = s2mps11->rdev;
int i;
 
for (i = 0; i < S2MPS11_REGULATOR_MAX; i++)
-   if (rdev[i])
-   regulator_unregister(rdev[i]);
+   regulator_unregister(s2mps11->rdev[i]);
 
return 0;
 }
-- 
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: How to use the generic thermal sysfs.

2012-07-12 Thread Zhang Rui
On 四, 2012-07-12 at 04:54 -0600, R, Durgadoss wrote:
> Hi,
> 
> > -Original Message-
> > From: Wei Ni [mailto:w...@nvidia.com]
> > Sent: Thursday, July 12, 2012 3:53 PM
> > To: Zhang, Rui; Brown, Len; a...@linux-foundation.org; kh...@linux-fr.org;
> > j...@perches.com; R, Durgadoss
> > Cc: linux-kernel@vger.kernel.org; linux-te...@ger.kernel.org;
> > acour...@nvidia.com
> > Subject: How to use the generic thermal sysfs.
> > 
> > Hi, all
> > I'm working on the tegra thermal throttling upstream issue.
> > The tegra30 board use the nct1008 as the thermal sensor, and the lm90 is
> > the sensor driver. We want to use the generic thermal sysfs.
> > 
> > My question is where should we register the thermal zone device? We may
> > have two place to do it:
> > 1. register it in the sensor driver, such as lm90.c
> > In this way, the sensor driver doesn't need to export any APIs, such as
> > get_temp.
> 
> This approach is preferred.
> 
> > 2. register in my tegra thermal framework.
> > In this way, the sensor driver need to export some APIs, which are used
> > to register the ops and do any other things.
> 
> What do you mean by "my tegra thermal framework" ? Where does the source
> file for this sit in the mainline kernel ?
> 
I have the same question.
It sounds like that you want to use the tegra thermal framework to do
thermal management instead of the generic thermal layer, right?

IMO, the purpose of the generic thermal layer is
1) do kernel thermal management
2) export unique sysfs I/F to userspace so that users/userspace
applications can take over the thermal management.

what is the benefit to have another driver to do thermal management in
kernel?
If the current thermal management in the generic thermal layer can not
work well on your platform, it is a good chance to enhance the kernel
thermal manager. :)

thanks,
rui

> > 
> > How should I do it?
> > 
> > And in current codes, there have the event notification, in the form of
> > a netlink event. But it's difficult to be used in the kernel, it's
> > normally for the communication with user-space. How about to add a
> > notify call chain for it? So when the sensor has irq alert, it can send
> > a notify to my thermal framework in kernel.
> 
> We are working on a notification API from any generic sensor driver to
> the thermal framework.
> Please have a look at the 'notify_thermal_framework' API in the patch here:
> http://www.spinics.net/lists/linux-acpi/msg36049.html
> 
> Thanks,
> Durga
> 


--
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: [ 22/68] ath9k_hw: avoid possible infinite loop in ar9003_get_pll_sqsum_dvc

2012-07-12 Thread Greg Kroah-Hartman
On Thu, Jul 12, 2012 at 10:38:35PM -0300, Herton Ronaldo Krzesinski wrote:
> On Thu, Jul 12, 2012 at 04:01:56PM -0700, Greg Kroah-Hartman wrote:
> > From: Greg KH 
> > 
> > 3.0-stable review patch.  If anyone has any objections, please let me know.
> > 
> > --
> > 
> > From: Mohammed Shafi Shajakhan 
> > 
> > commit f18e3c6b67f448ec47b3a5b242789bd3d5644879 upstream.
> > 
> > "ath9k: Fix softlockup in AR9485" with commit id
> > 64bc1239c790e051ff677e023435d770d2ffa174 fixed the reported
> > issue, yet its better to avoid the possible infinite loop
> > in ar9003_get_pll_sqsum_dvc by having a timeout as suggested
> > by ath9k maintainers.
> > http://www.spinics.net/lists/linux-wireless/msg92126.html.
> > Based on my testing PLL's locking measurement is done in
> > ~200us (2 iterations).
> 
> Missing the rest of the patch here.

Yeah, quilt went crazy and messed things up, the originals are fine,
but something went really wrong when the mbox was created, sorry.  A
number of different patches didn't go through properly.

greg k-h
--
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: [ 66/68] mm: Hold a file reference in madvise_remove

2012-07-12 Thread Herton Ronaldo Krzesinski
On Thu, Jul 12, 2012 at 04:02:40PM -0700, Greg Kroah-Hartman wrote:
> From: Greg KH 
> 
> 3.0-stable review patch.  If anyone has any objections, please let me know.
> 
> --
> 
> From: Andy Lutomirski 
> 
> commit 9ab4233dd08036fe34a89c7dc6f47a8bf2eb29eb upstream.
> 
> Otherwise the code races with munmap (causing a use-after-free
> of the vma) or with close (causing a use-after-free of the struct
> file).
> 
> The bug was introduced by commit 90ed52ebe481 ("[PATCH] holepunch: fix
> mmap_sem i_mutex deadlock")
> 
> [bwh: Backported to 3.2:
>  - Adjust context
>  - madvise_remove() calls vmtruncate_range(), not do_fallocate()]
> [luto: Backported to 3.0: Adjust context]

Didn't want to be annoying, but as I went looking sequentially,
I found missing diffs one by one... anyway this should be the last.

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

-- 
[]'s
Herton
--
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: [ 54/68] tracing: change CPU ring buffer state from tracing_cpumask

2012-07-12 Thread Herton Ronaldo Krzesinski
On Thu, Jul 12, 2012 at 04:02:28PM -0700, Greg Kroah-Hartman wrote:
> From: Greg KH 
> 
> 3.0-stable review patch.  If anyone has any objections, please let me know.
> 
> --
> 
> From: Vaibhav Nagarnaik 
> 
> commit 71babb2705e2203a64c27ede13ae3508a0d2c16c upstream.
> 
> According to Documentation/trace/ftrace.txt:
> 
> tracing_cpumask:
> 
> This is a mask that lets the user only trace
> on specified CPUS. The format is a hex string
> representing the CPUS.
> 
> The tracing_cpumask currently doesn't affect the tracing state of
> per-CPU ring buffers.
> 
> This patch enables/disables CPU recording as its corresponding bit in
> tracing_cpumask is set/unset.
> 
> Link: 
> http://lkml.kernel.org/r/1336096792-25373-3-git-send-email-vnagarn...@google.com

Missing patch.

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

-- 
[]'s
Herton
--
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: [ 51/68] PCI: EHCI: fix crash during suspend on ASUS computers

2012-07-12 Thread Herton Ronaldo Krzesinski
On Thu, Jul 12, 2012 at 04:02:25PM -0700, Greg Kroah-Hartman wrote:
> From: Greg KH 
> 
> 3.0-stable review patch.  If anyone has any objections, please let me know.
> 
> --

Missing also the diff/"signoff area" on this one.

> 
> From: Alan Stern 
> 
> commit dbf0e4c7257f8d684ec1a3c919853464293de66e upstream.
> 
> Quite a few ASUS computers experience a nasty problem, related to the
> EHCI controllers, when going into system suspend.  It was observed
> that the problem didn't occur if the controllers were not put into the
> D3 power state before starting the suspend, and commit
> 151b61284776be2d6f02d48c23c3625678960b97 (USB: EHCI: fix crash during
> suspend on ASUS computers) was created to do this.
> 
> It turned out this approach messed up other computers that didn't have
> the problem -- it prevented USB wakeup from working.  Consequently
> commit c2fb8a3fa25513de8fedb38509b1f15a5bbee47b (USB: add
> NO_D3_DURING_SLEEP flag and revert 151b61284776be2) was merged; it
> reverted the earlier commit and added a whitelist of known good board
> names.
> 
> Now we know the actual cause of the problem.  Thanks to AceLan Kao for
> tracking it down.
> 
> According to him, an engineer at ASUS explained that some of their
> BIOSes contain a bug that was added in an attempt to work around a
> problem in early versions of Windows.  When the computer goes into S3
> suspend, the BIOS tries to verify that the EHCI controllers were first
> quiesced by the OS.  Nothing's wrong with this, but the BIOS does it
> by checking that the PCI COMMAND registers contain 0 without checking
> the controllers' power state.  If the register isn't 0, the BIOS
> assumes the controller needs to be quiesced and tries to do so.  This
> involves making various MMIO accesses to the controller, which don't
> work very well if the controller is already in D3.  The end result is
> a system hang or memory corruption.
> 
> Since the value in the PCI COMMAND register doesn't matter once the
> controller has been suspended, and since the value will be restored
> anyway when the controller is resumed, we can work around the BIOS bug
> simply by setting the register to 0 during system suspend.  This patch
> (as1590) does so and also reverts the second commit mentioned above,
> which is now unnecessary.
> 
> In theory we could do this for every PCI device.  However to avoid
> introducing new problems, the patch restricts itself to EHCI host
> controllers.
> 
> Finally the affected systems can suspend with USB wakeup working
> properly.
> 
> --
> To unsubscribe from this list: send the line "unsubscribe stable" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

-- 
[]'s
Herton
--
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: [ 22/68] ath9k_hw: avoid possible infinite loop in ar9003_get_pll_sqsum_dvc

2012-07-12 Thread Herton Ronaldo Krzesinski
On Thu, Jul 12, 2012 at 04:01:56PM -0700, Greg Kroah-Hartman wrote:
> From: Greg KH 
> 
> 3.0-stable review patch.  If anyone has any objections, please let me know.
> 
> --
> 
> From: Mohammed Shafi Shajakhan 
> 
> commit f18e3c6b67f448ec47b3a5b242789bd3d5644879 upstream.
> 
> "ath9k: Fix softlockup in AR9485" with commit id
> 64bc1239c790e051ff677e023435d770d2ffa174 fixed the reported
> issue, yet its better to avoid the possible infinite loop
> in ar9003_get_pll_sqsum_dvc by having a timeout as suggested
> by ath9k maintainers.
> http://www.spinics.net/lists/linux-wireless/msg92126.html.
> Based on my testing PLL's locking measurement is done in
> ~200us (2 iterations).

Missing the rest of the patch here.

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

-- 
[]'s
Herton
--
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/5] aio: Export symbols and struct kiocb_batch for in kernel aio usage

2012-07-12 Thread Asias He

Hi James,

On 07/13/2012 01:50 AM, James Bottomley wrote:

On Thu, 2012-07-12 at 23:35 +0800, Asias He wrote:

This is useful for people who want to use aio in kernel, e.g. vhost-blk.

Signed-off-by: Asias He 
---
  fs/aio.c|   37 ++---
  include/linux/aio.h |   21 +
  2 files changed, 39 insertions(+), 19 deletions(-)


Um, I think you don't quite understand how aio in the kernel would work;
it's not as simple as just exporting the interfaces.  There's already a
(very long) patch set from oracle to do this so loop can use aio:

http://marc.info/?l=linux-fsdevel=133312234313122


Oh, I did not see this patch set. Thanks for pointing it out! This bit 
hasn't merged, right? I'd love to use the aio_kernel_() interface if it 
is merged. It will simply vhost-blk. Due to lack of better kernel aio 
interface, we are currently doing io_setup, io_submit, etc. in vhost-blk 
on our own.


--
Asias


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


Linux 3.2.23

2012-07-12 Thread Ben Hutchings
I'm announcing the release of the 3.2.23 kernel.

All users of the 3.2 kernel series should upgrade.

The updated 3.2.y git tree can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git 
linux-3.2.y
and can be browsed at the normal kernel.org git web browser:
http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git

Ben.



 Makefile   |2 +-
 arch/arm/kernel/smp.c  |   10 +-
 arch/powerpc/kvm/book3s_hv_rmhandlers.S|2 +-
 arch/powerpc/xmon/xmon.c   |2 +-
 drivers/block/umem.c   |   40 
 drivers/gpu/drm/i915/i915_dma.c|   37 +--
 drivers/md/persistent-data/dm-space-map-checker.c  |   54 ++-
 drivers/md/persistent-data/dm-space-map-disk.c |   11 ++-
 .../md/persistent-data/dm-transaction-manager.c|   11 ++-
 drivers/md/raid10.c|   12 ++-
 drivers/md/raid5.c |   10 +-
 drivers/mtd/nand/cafe_nand.c   |2 +-
 drivers/net/bonding/bond_main.c|9 +-
 drivers/net/dummy.c|5 +-
 drivers/net/ethernet/emulex/benet/be_main.c|5 +-
 drivers/net/ethernet/marvell/sky2.c|   10 +-
 drivers/net/wireless/ath/ath.h |1 +
 drivers/net/wireless/ath/ath9k/hw.c|2 +-
 drivers/net/wireless/ath/ath9k/recv.c  |3 +-
 drivers/net/wireless/ath/key.c |4 +
 drivers/net/wireless/mwifiex/11n_rxreorder.c   |5 +-
 drivers/net/wireless/mwifiex/11n_rxreorder.h   |7 ++
 drivers/net/wireless/mwifiex/cfg80211.c|   21 ++--
 drivers/net/wireless/mwifiex/wmm.c |   12 ++-
 drivers/net/wireless/rtlwifi/rtl8192cu/sw.c|3 +
 drivers/target/tcm_fc/tfc_sess.c   |3 +-
 fs/btrfs/tree-log.c|6 ++
 fs/cifs/connect.c  |9 +-
 fs/ocfs2/file.c|4 +-
 fs/open.c  |6 +-
 fs/splice.c|   35 ---
 fs/udf/super.c |  102 
 include/linux/aio.h|1 +
 include/linux/splice.h |8 +-
 include/net/cipso_ipv4.h   |   29 +-
 include/net/sch_generic.h  |7 +-
 kernel/relay.c |5 +-
 kernel/trace/trace.c   |8 +-
 mm/madvise.c   |   16 ++-
 mm/shmem.c |3 +-
 net/bridge/br_if.c |1 +
 net/bridge/br_netlink.c|2 +-
 net/bridge/br_private.h|1 +
 net/core/ethtool.c |1 +
 net/core/netpoll.c |   11 ++-
 net/core/skbuff.c  |3 +-
 net/core/sock.c|7 +-
 net/ipv6/route.c   |   41 ++--
 net/l2tp/l2tp_eth.c|2 +
 net/l2tp/l2tp_ip.c |9 +-
 net/mac80211/rx.c  |5 +-
 net/nfc/nci/ntf.c  |4 +-
 net/nfc/rawsock.c  |5 +-
 sound/pci/hda/patch_sigmatel.c |4 +-
 sound/soc/codecs/tlv320aic3x.c |4 +-
 sound/soc/codecs/tlv320aic3x.h |1 +
 56 files changed, 439 insertions(+), 184 deletions(-)

Andy Lutomirski (1):
  mm: Hold a file reference in madvise_remove

Anton Blanchard (1):
  powerpc/xmon: Use cpumask iterator to avoid warning

Ben Hutchings (1):
  Linux 3.2.23

Bing Zhao (1):
  mwifiex: fix wrong return values in add_virtual_intf() error cases

Chris Mason (1):
  Btrfs: run delayed directory updates during log replay

Dan Carpenter (1):
  mtd: cafe_nand: fix an & vs | mistake

Dan Rosenberg (1):
  NFC: Prevent multiple buffer overflows in NCI

Daniel Vetter (1):
  drm/i915: kick any firmware framebuffers before claiming the gtt

Eric Dumazet (8):
  splice: fix racy pipe->buffers uses
  NFC: Return from rawsock_release when sk is NULL
  net: l2tp_eth: fix kernel panic on rmmod l2tp_eth
  l2tp: fix a race in l2tp_ip_sendmsg()
  be2net: fix a race in be_xmit()
  dummy: fix rcu_sched self-detected stalls
  bonding: Fix corrupted queue_mapping
  netpoll: fix netpoll_send_udp() bugs

Felix Fietkau (1):
  ath9k: fix dynamic WEP 

Re: [PATCH 0/5] Add vhost-blk support

2012-07-12 Thread Asias He

Hello Jeff,

On 07/13/2012 12:06 AM, Jeff Moyer wrote:

Asias He  writes:


Hi folks,

This patchset adds vhost-blk support. vhost-blk is a in kernel virito-blk
device accelerator. Compared to userspace virtio-blk implementation, vhost-blk
gives about 5% to 15% performance improvement.

Asias He (5):
   aio: Export symbols and struct kiocb_batch for in kernel aio usage
   eventfd: Export symbol eventfd_file_create()
   vhost: Make vhost a separate module
   vhost-net: Use VHOST_NET_FEATURES for vhost-net
   vhost-blk: Add vhost-blk support


I only saw patches 0 and 1.  Where are the other 4?  If the answer is,
"not on lkml," then please resend them, CC'ing lkml.


I did send all the 0-5 patches to lkml, but I somehow messed up the 
thread. Will CC you next time.



I'd like to be able to see the usage of the aio routines.


OK. It'd be nice if you could review. Thanks.

--
Asias


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


Re: [PATCH 3/3 v3] memory-hotplug: fix kswapd looping forever problem

2012-07-12 Thread Minchan Kim
On Thu, Jul 12, 2012 at 02:01:54PM -0700, Andrew Morton wrote:
> On Thu, 12 Jul 2012 11:50:49 +0900
> Minchan Kim  wrote:
> 
> > When hotplug offlining happens on zone A, it starts to mark freed page
> > as MIGRATE_ISOLATE type in buddy for preventing further allocation.
> > (MIGRATE_ISOLATE is very irony type because it's apparently on buddy
> > but we can't allocate them).
> > When the memory shortage happens during hotplug offlining,
> > current task starts to reclaim, then wake up kswapd.
> > Kswapd checks watermark, then go sleep because current 
> > zone_watermark_ok_safe
> > doesn't consider MIGRATE_ISOLATE freed page count.
> > Current task continue to reclaim in direct reclaim path without kswapd's 
> > helping.
> > The problem is that zone->all_unreclaimable is set by only kswapd
> > so that current task would be looping forever like below.
> > 
> > __alloc_pages_slowpath
> > restart:
> > wake_all_kswapd
> > rebalance:
> > __alloc_pages_direct_reclaim
> > do_try_to_free_pages
> > if global_reclaim && !all_unreclaimable
> > return 1; /* It means we did did_some_progress 
> > */
> > skip __alloc_pages_may_oom
> > should_alloc_retry
> > goto rebalance;
> > 
> > If we apply KOSAKI's patch[1] which doesn't depends on kswapd
> > about setting zone->all_unreclaimable, we can solve this problem
> > by killing some task in direct reclaim path. But it doesn't wake up kswapd, 
> > still.
> > It could be a problem still if other subsystem needs GFP_ATOMIC request.
> > So kswapd should consider MIGRATE_ISOLATE when it calculate free pages
> > BEFORE going sleep.
> > 
> > This patch counts the number of MIGRATE_ISOLATE page block and
> > zone_watermark_ok_safe will consider it if the system has such blocks
> > (fortunately, it's very rare so no problem in POV overhead and kswapd is 
> > never
> > hotpath).
> > 
> > Copy/modify from Mel's quote
> > "
> > Ideal solution would be "allocating" the pageblock.
> > It would keep the free space accounting as it is but historically,
> > memory hotplug didn't allocate pages because it would be difficult to
> > detect if a pageblock was isolated or if part of some balloon.
> > Allocating just full pageblocks would work around this, However,
> > it would play very badly with CMA.
> > "
> > 
> > [1] http://lkml.org/lkml/2012/6/14/74
> >
> > ...
> >
> > +#ifdef CONFIG_MEMORY_ISOLATION
> > +static inline unsigned long nr_zone_isolate_freepages(struct zone *zone)
> > +{
> > +   unsigned long nr_pages = 0;
> > +
> > +   if (unlikely(zone->nr_pageblock_isolate)) {
> > +   nr_pages = zone->nr_pageblock_isolate * pageblock_nr_pages;
> > +   }
> > +   return nr_pages;
> > +}
> 
> That's pretty verbose.  I couldn't resist fiddling with it ;)
> 
> > +#else
> > +static inline unsigned long nr_zone_isolate_freepages(struct zone *zone)
> > +{
> > +   return 0;
> > +}
> > +#endif
> > +
> >  bool zone_watermark_ok(struct zone *z, int order, unsigned long mark,
> >   int classzone_idx, int alloc_flags)
> >  {
> > @@ -1633,6 +1655,14 @@ bool zone_watermark_ok_safe(struct zone *z, int 
> > order, unsigned long mark,
> > if (z->percpu_drift_mark && free_pages < z->percpu_drift_mark)
> > free_pages = zone_page_state_snapshot(z, NR_FREE_PAGES);
> >  
> > +   /*
> > +* If the zone has MIGRATE_ISOLATE type free page,
> > +* we should consider it. nr_zone_isolate_freepages is never
> > +* accurate so kswapd might not sleep although she can.
> > +* But it's more desirable for memory hotplug rather than
> > +* forever sleep which cause livelock in direct reclaim path.
> > +*/
> 
> I had a go at clarifying this comment.  Please review the result.
> 
> > +   free_pages -= nr_zone_isolate_freepages(z);
> > return __zone_watermark_ok(z, order, mark, classzone_idx, alloc_flags,
> > free_pages);
> >  }
> > @@ -4397,6 +4427,7 @@ static void __paginginit free_area_init_core(struct 
> > pglist_data *pgdat,
> > lruvec_init(>lruvec, zone);
> > zap_zone_vm_stats(zone);
> > zone->flags = 0;
> > +   zone->nr_pageblock_isolate = 0;
> > if (!size)
> > continue;
> >  
> > diff --git a/mm/page_isolation.c b/mm/page_isolation.c
> > index fb482cf..64abb33 100644
> > --- a/mm/page_isolation.c
> > +++ b/mm/page_isolation.c
> > @@ -8,6 +8,31 @@
> >  #include 
> >  #include "internal.h"
> >  
> > +/* called by holding zone->lock */
> > +static void set_pageblock_isolate(struct zone *zone, struct page *page)
> > +{
> > +   BUG_ON(page_zone(page) != zone);
> 
> Well.  If this is the case then why not eliminate this function's
> `zone' argument?
> 
> > +   if (get_pageblock_migratetype(page) == MIGRATE_ISOLATE)
> > +   return;
> > +
> > +   set_pageblock_migratetype(page, MIGRATE_ISOLATE);
> > +   zone->nr_pageblock_isolate++;
> 

[PATCH 1/2] staging: comedi: dt282x: remove the outw wrapper macros

2012-07-12 Thread H Hartley Sweeten
The macros 'update_dacsr', 'update_adcsr', and 'update_supcsr' all use
the 'devpriv' macro which uses a local variable of a specific name and
yeilds a pointer derived from that name. They are also just wrappers
around simple 'outw' calls. Remove the macros.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/dt282x.c | 55 +
 1 file changed, 29 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/comedi/drivers/dt282x.c 
b/drivers/staging/comedi/drivers/dt282x.c
index 4af3343..1f0b40e 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/staging/comedi/drivers/dt282x.c
@@ -255,11 +255,8 @@ struct dt282x_private {
  *Some useless abstractions
  */
 #define chan_to_DAC(a) ((a)&1)
-#define update_dacsr(a)outw(devpriv->dacsr|(a), 
dev->iobase+DT2821_DACSR)
-#define update_adcsr(a)outw(devpriv->adcsr|(a), 
dev->iobase+DT2821_ADCSR)
 #define mux_busy() (inw(dev->iobase+DT2821_ADCSR)_MUXBUSY)
 #define ad_done() (inw(dev->iobase+DT2821_ADCSR)_ADDONE)
-#define update_supcsr(a) outw(devpriv->supcsr|(a), dev->iobase+DT2821_SUPCSR)
 
 /*
  *danger! macro abuse... a is the expression to wait on, and b is
@@ -317,7 +314,7 @@ static void dt282x_ao_dma_interrupt(struct comedi_device 
*dev)
int i;
struct comedi_subdevice *s = dev->subdevices + 1;
 
-   update_supcsr(DT2821_CLRDMADNE);
+   outw(devpriv->supcsr | DT2821_CLRDMADNE, dev->iobase + DT2821_SUPCSR);
 
if (!s->async->prealloc_buf) {
printk(KERN_ERR "async->data disappeared.  dang!\n");
@@ -350,7 +347,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device 
*dev)
int ret;
struct comedi_subdevice *s = dev->subdevices;
 
-   update_supcsr(DT2821_CLRDMADNE);
+   outw(devpriv->supcsr | DT2821_CLRDMADNE, dev->iobase + DT2821_SUPCSR);
 
if (!s->async->prealloc_buf) {
printk(KERN_ERR "async->data disappeared.  dang!\n");
@@ -387,7 +384,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device 
*dev)
/* XXX probably wrong */
if (!devpriv->ntrig) {
devpriv->supcsr &= ~(DT2821_DDMA);
-   update_supcsr(0);
+   outw(devpriv->supcsr, dev->iobase + DT2821_SUPCSR);
}
 #endif
/* restart the channel */
@@ -513,7 +510,8 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
s->async->events |= COMEDI_CB_EOA;
} else {
if (supcsr & DT2821_SCDN)
-   update_supcsr(DT2821_STRIG);
+   outw(devpriv->supcsr | DT2821_STRIG,
+   dev->iobase + DT2821_SUPCSR);
}
handled = 1;
}
@@ -534,7 +532,8 @@ static void dt282x_load_changain(struct comedi_device *dev, 
int n,
for (i = 0; i < n; i++) {
chan = CR_CHAN(chanlist[i]);
range = CR_RANGE(chanlist[i]);
-   update_adcsr((range << 4) | (chan));
+   outw(devpriv->adcsr | (range << 4) | chan,
+   dev->iobase + DT2821_ADCSR);
}
outw(n - 1, dev->iobase + DT2821_CHANCSR);
 }
@@ -553,15 +552,16 @@ static int dt282x_ai_insn_read(struct comedi_device *dev,
 
/* XXX should we really be enabling the ad clock here? */
devpriv->adcsr = DT2821_ADCLK;
-   update_adcsr(0);
+   outw(devpriv->adcsr, dev->iobase + DT2821_ADCSR);
 
dt282x_load_changain(dev, 1, >chanspec);
 
-   update_supcsr(DT2821_PRLD);
+   outw(devpriv->supcsr | DT2821_PRLD, dev->iobase + DT2821_SUPCSR);
wait_for(!mux_busy(), comedi_error(dev, "timeout\n"); return -ETIME;);
 
for (i = 0; i < insn->n; i++) {
-   update_supcsr(DT2821_STRIG);
+   outw(devpriv->supcsr | DT2821_STRIG,
+   dev->iobase + DT2821_SUPCSR);
wait_for(ad_done(), comedi_error(dev, "timeout\n");
 return -ETIME;);
 
@@ -718,7 +718,8 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct 
comedi_subdevice *s)
/* external trigger */
devpriv->supcsr = DT2821_ERRINTEN | DT2821_DS0 | DT2821_DS1;
}
-   update_supcsr(DT2821_CLRDMADNE | DT2821_BUFFB | DT2821_ADCINIT);
+   outw(devpriv->supcsr | DT2821_CLRDMADNE | DT2821_BUFFB | DT2821_ADCINIT,
+   dev->iobase + DT2821_SUPCSR);
 
devpriv->ntrig = cmd->stop_arg * cmd->scan_end_arg;
devpriv->nread = devpriv->ntrig;
@@ -729,7 +730,7 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct 
comedi_subdevice *s)
if (devpriv->ntrig) {
prep_ai_dma(dev, 1, 0);
devpriv->supcsr |= DT2821_DDMA;
-   update_supcsr(0);
+   outw(devpriv->supcsr, dev->iobase + DT2821_SUPCSR);
}
 
devpriv->adcsr = 0;
@@ 

[PATCH 0/2] staging: comedi: remove the devpriv and thisboard macros

2012-07-12 Thread H Hartley Sweeten
The macros 'devpriv' and 'thisboard' rely on a local variable having
a specific name and yeild pointers derived from that variable. Replace
the macros with local variables where used and use to comedi_board()
helper to get the 'thisboard' pointer.

The dt282x driver needs some initial cleanup to remove some macros that
use the 'devpriv' macro.

There are still a couple comedi drivers that have the macros but they are
pretty tangled up and require a bit more work.

Unfortunately this patch adds quite a few lines-of-code to the drivers.
But, it cleans up the CodingStyle issue pointed out in Chapter 12:

2) macros that depend on having a local variable with a magic name:

#define FOO(val) bar(index, val)

might look like a good thing, but it's confusing as hell when one reads the
code and it's prone to breakage from seemingly innocent changes.

H Hartley Sweeten (2):
  staging: comedi: dt282x: remove the outw wrapper macros
  staging: comedi: remove the devpriv and thisboard macros

 .../staging/comedi/drivers/addi-data/addi_common.c |  19 +++-
 .../staging/comedi/drivers/addi-data/addi_eeprom.c |   2 +
 .../comedi/drivers/addi-data/hwdrv_apci035.c   |  14 +++
 .../comedi/drivers/addi-data/hwdrv_apci1032.c  |  11 +-
 .../comedi/drivers/addi-data/hwdrv_apci1500.c  |  21 +++-
 .../comedi/drivers/addi-data/hwdrv_apci1516.c  |  17 ++-
 .../comedi/drivers/addi-data/hwdrv_apci1564.c  |  16 +++
 .../comedi/drivers/addi-data/hwdrv_apci16xx.c  |   8 ++
 .../comedi/drivers/addi-data/hwdrv_apci2016.c  |  12 ++
 .../comedi/drivers/addi-data/hwdrv_apci2032.c  |  14 +++
 .../comedi/drivers/addi-data/hwdrv_apci2200.c  |  19 +++-
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  |  42 +--
 .../comedi/drivers/addi-data/hwdrv_apci3200.c  |  27 -
 .../comedi/drivers/addi-data/hwdrv_apci3501.c  |  18 +++
 .../comedi/drivers/addi-data/hwdrv_apci3xxx.c  |  18 +++
 drivers/staging/comedi/drivers/adl_pci9111.c   |  36 --
 drivers/staging/comedi/drivers/adl_pci9118.c   |  55 +-
 drivers/staging/comedi/drivers/adq12b.c|  10 +-
 drivers/staging/comedi/drivers/adv_pci1710.c   |  45 +++-
 drivers/staging/comedi/drivers/adv_pci1723.c   |  20 ++--
 drivers/staging/comedi/drivers/adv_pci_dio.c   |  22 +++-
 drivers/staging/comedi/drivers/aio_aio12_8.c   |   8 +-
 drivers/staging/comedi/drivers/aio_iiro_16.c   |  11 --
 drivers/staging/comedi/drivers/amplc_dio200.c  |  10 +-
 drivers/staging/comedi/drivers/amplc_pc236.c   |  12 +-
 drivers/staging/comedi/drivers/amplc_pc263.c   |  11 +-
 drivers/staging/comedi/drivers/amplc_pci224.c  |   9 +-
 drivers/staging/comedi/drivers/amplc_pci230.c  |   3 +-
 drivers/staging/comedi/drivers/cb_das16_cs.c   |   4 +-
 drivers/staging/comedi/drivers/cb_pcidas.c |   2 +-
 drivers/staging/comedi/drivers/cb_pcidda.c |  27 ++---
 drivers/staging/comedi/drivers/cb_pcidio.c |  11 +-
 drivers/staging/comedi/drivers/cb_pcimdas.c|  23 ++--
 drivers/staging/comedi/drivers/cb_pcimdda.c|  29 +++--
 drivers/staging/comedi/drivers/comedi_bond.c   |  26 ++---
 drivers/staging/comedi/drivers/comedi_parport.c|  16 ++-
 drivers/staging/comedi/drivers/comedi_test.c   |  17 ++-
 drivers/staging/comedi/drivers/contec_pci_dio.c|   6 +-
 drivers/staging/comedi/drivers/daqboard2000.c  |  27 -
 drivers/staging/comedi/drivers/das08.c |   8 +-
 drivers/staging/comedi/drivers/das08_cs.c  |   4 +-
 drivers/staging/comedi/drivers/das16.c |  19 +++-
 drivers/staging/comedi/drivers/das16m1.c   |  14 ++-
 drivers/staging/comedi/drivers/das1800.c   |  41 +--
 drivers/staging/comedi/drivers/das6402.c   |  11 +-
 drivers/staging/comedi/drivers/das800.c|  29 +++--
 drivers/staging/comedi/drivers/dt2801.c|  28 +++--
 drivers/staging/comedi/drivers/dt2811.c|   9 +-
 drivers/staging/comedi/drivers/dt2814.c|   8 +-
 drivers/staging/comedi/drivers/dt2815.c|   8 +-
 drivers/staging/comedi/drivers/dt282x.c| 122 +
 drivers/staging/comedi/drivers/dt3000.c|  28 -
 drivers/staging/comedi/drivers/dt9812.c|  13 ++-
 drivers/staging/comedi/drivers/dyna_pci10xx.c  |  18 ++-
 drivers/staging/comedi/drivers/fl512.c |   9 +-
 drivers/staging/comedi/drivers/icp_multi.c |  36 --
 drivers/staging/comedi/drivers/ii_pci20kc.c|  10 +-
 drivers/staging/comedi/drivers/jr3_pci.c   |   5 +-
 drivers/staging/comedi/drivers/me4000.c|  55 --
 drivers/staging/comedi/drivers/me4000.h|   4 -
 drivers/staging/comedi/drivers/me_daq.c|  27 +++--
 drivers/staging/comedi/drivers/mpc624.c|   6 +-
 drivers/staging/comedi/drivers/mpc8260cpm.c|  11 --
 drivers/staging/comedi/drivers/multiq3.c   

Re: [PATCH 0/6] Fix for leapsecond caused hrtimer/futex issue (updated)

2012-07-12 Thread John Stultz

On 07/10/2012 04:00 PM, John Stultz wrote:

On 07/10/2012 03:43 PM, John Stultz wrote:

Over the weekend, Thomas got a chance to review the leap second fix
in more detail and had a few additional changes he wanted to make
to improve performance as well as style.

So this iteration includes his modifications.

Once merged, I'll be working to get the backports finished as quickly
as I can and sent to -stable.



Once again, here's the test case I've been using to stress test 
leapsecond insertion/deletion (the deletion testing is new since last 
round).


Prarit noticed a small bug with the test case. We're not initializing 
the timespec tv_nsec value before sleeping, so in some cases 
clock_nanosleep will return -EINVAL.


This version fixes this and cleans up some of the timespec/timeval usage.

thanks
-john

/* Leap second stress test
 *  by: john stultz (johns...@us.ibm.com)
 *  (C) Copyright IBM 2012
 *  Licensed under the GPLv2
 *
 *  This test signals the kernel to insert a leap second
 *  every day at midnight GMT. This allows for stessing the
 *  kernel's leap-second behavior, as well as how well applications
 *  handle the leap-second discontinuity.
 *
 *  Usage: leap-a-day [-s]
 *
 *  Options:
 *	-s:	Each iteration, set the date to 10 seconds before midnight GMT.
 *		This speeds up the number of leapsecond transitions tested,
 *		but because it calls settimeofday frequently, advancing the
 *		time by 24 hours every ~16 seconds, it may cause application
 *		disruption.
 *
 *  Other notes: Disabling NTP prior to running this is advised, as the two
 *		 may conflict in thier commands to the kernel.
 *
 *  To build:
 *	$ gcc leap-a-day.c -o leap-a-day -lrt
 */



#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define NSEC_PER_SEC 10ULL

/* returns 1 if a <= b, 0 otherwise */
static inline int in_order(struct timespec a, struct timespec b)
{
if(a.tv_sec < b.tv_sec)
return 1;
if(a.tv_sec > b.tv_sec)
return 0;
if(a.tv_nsec > b.tv_nsec)
return 0;
return 1;
}

struct timespec timespec_add(struct timespec ts, unsigned long long ns)
{
	ts.tv_nsec += ns;
	while(ts.tv_nsec >= NSEC_PER_SEC) {
		ts.tv_nsec -= NSEC_PER_SEC;
		ts.tv_sec++;
	}
	return ts;
}


char* time_state_str(int state)
{
	switch (state) {
		case TIME_OK:	return "TIME_OK";
		case TIME_INS:	return "TIME_INS";
		case TIME_DEL:	return "TIME_DEL";
		case TIME_OOP:	return "TIME_OOP";
		case TIME_WAIT:	return "TIME_WAIT";
		case TIME_BAD:	return "TIME_BAD";
	}
	return "ERROR"; 
}

/* clear NTP time_status & time_state */
void clear_time_state(void)
{
	struct timex tx;
	int ret;

	/*
	 * XXX - The fact we have to call this twice seems
	 * to point to a slight issue in the kernel's ntp state
	 * managment. Needs to be investigated further.
	 */

	tx.modes = ADJ_STATUS;
	tx.status = STA_PLL;
	ret = adjtimex();

	tx.modes = ADJ_STATUS;
	tx.status = 0;
	ret = adjtimex();
}

/* Make sure we cleanup on ctrl-c */
void handler(int unused)
{
	clear_time_state();
	exit(0);
}


/* Test for known hrtimer failure */
void test_hrtimer_failure(void)
{
	struct timespec now, target;

	clock_gettime(CLOCK_REALTIME, );
	target = timespec_add(now, NSEC_PER_SEC/2);
	clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, , NULL);
	clock_gettime(CLOCK_REALTIME, );

	if (!in_order(target, now)) {
		printf("Note: hrtimer early expiration failure observed.\n");
	}

}



int main(int argc, char** argv) 
{
	int settime = 0;
	int insert = 1;

	signal(SIGINT, handler);
	signal(SIGKILL, handler);
	printf("This runs continuously. Press ctrl-c to stop\n");


	/* Process arguments */
	if (argc > 1) {
		if (!strncmp(argv[1], "-s", 2)) {
			printf("Setting time to speed up testing\n");
			settime = 1;
		} else {
			printf("Usage: %s [-s]\n", argv[0]);
			printf("	-s: Set time to right before leap second each iteration\n");
		}
	}

	printf("\n");
	while (1) {
		int ret;
		struct timespec ts;
		struct timex tx;
		time_t now, next_leap;

		/* Get the current time */
		clock_gettime(CLOCK_REALTIME, );

		/* Calculate the next possible leap second 23:59:60 GMT */
		next_leap = ts.tv_sec;
		next_leap += 86400 - (next_leap % 86400);


		if (settime) {
			struct timeval tv;
			tv.tv_sec = next_leap - 10;
			tv.tv_usec = 0;
			settimeofday(, NULL);
			printf("Setting time to %s", ctime(_sec));
		}

		/* Reset NTP time state */
		clear_time_state();

		/* Set the leap second insert flag */
		tx.modes = ADJ_STATUS;
		if (insert) 
			tx.status = STA_INS;
		else
			tx.status = STA_DEL;
		ret = adjtimex();
		if (ret < 0 ) {
			printf("Error: Problem setting STA_INS/STA_DEL!: %s\n",
			time_state_str(ret));
			return -1;
		}

		/* Validate STA_INS was set */
		ret = adjtimex();
		if (tx.status != STA_INS && tx.status != STA_DEL) {
			printf("Error: STA_INS/STA_DEL not set!: %s\n",
			time_state_str(ret));
			return -1;
		}

		printf("Scheduling leap 

Re: [PATCH 00/13] rbtree updates

2012-07-12 Thread Michel Lespinasse
On Thu, Jul 12, 2012 at 7:12 AM, Peter Zijlstra  wrote:
> On Wed, 2012-07-11 at 18:12 -0700, Michel Lespinasse wrote:
>>
>> In __rb_erase_color(), some of the cases are more complicated than you drew 
>> however, because some node colors aren't known.
>
> Right, the wikipedia article draws them blank, I couldn't come up with a
> 3rd case, although maybe we can annotate them like (P) to mean blank..

Ah, good idea, I adopted that :)

> Yes, very nice.. someday when I'm bored I might expand the comments with
> the reason why we're doing the given operation.

There is a brief comment at the start of the loop that indicates which
rbtree invariants might be violated at that point; so someone could
deduce that we're trying to either fix these or move towards the root
until they get fixed. But yeah, this is never explicitly explained.

> Also, I was sorely tempted to rename your tmp1,tmp2 variables to sl and
> sr.

This could be done, but you'd *still* need one extra temporary, so
you'd end up with sl, sr and tmp. Which is fine, I guess, but I
preferred to have one less variable around.

-- 
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 06/12] rbtree: break out of rb_insert_color loop after tree rotation

2012-07-12 Thread Michel Lespinasse
It is a well known property of rbtrees that insertion never requires
more than two tree rotations.  In our implementation, after one loop
iteration identified one or two necessary tree rotations, we would iterate
and look for more.  However at that point the node's parent would always
be black, which would cause us to exit the loop.

We can make the code flow more obvious by just adding a break statement
after the tree rotations, where we know we are done.  Additionally, in the
cases where two tree rotations are necessary, we don't have to update the
'node' pointer as it wouldn't be used until the next loop iteration, which
we now avoid due to this break statement.

Signed-off-by: Michel Lespinasse 
---
 lib/rbtree.c |   14 --
 1 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/lib/rbtree.c b/lib/rbtree.c
index ccada9a..12abb8a 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -109,18 +109,15 @@ void rb_insert_color(struct rb_node *node, struct rb_root 
*root)
}
}
 
-   if (parent->rb_right == node)
-   {
-   register struct rb_node *tmp;
+   if (parent->rb_right == node) {
__rb_rotate_left(parent, root);
-   tmp = parent;
parent = node;
-   node = tmp;
}
 
rb_set_black(parent);
rb_set_red(gparent);
__rb_rotate_right(gparent, root);
+   break;
} else {
{
register struct rb_node *uncle = 
gparent->rb_left;
@@ -134,18 +131,15 @@ void rb_insert_color(struct rb_node *node, struct rb_root 
*root)
}
}
 
-   if (parent->rb_left == node)
-   {
-   register struct rb_node *tmp;
+   if (parent->rb_left == node) {
__rb_rotate_right(parent, root);
-   tmp = parent;
parent = node;
-   node = tmp;
}
 
rb_set_black(parent);
rb_set_red(gparent);
__rb_rotate_left(gparent, root);
+   break;
}
}
 
-- 
1.7.7.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 v2 07/12] rbtree: adjust root color in rb_insert_color() only when necessary

2012-07-12 Thread Michel Lespinasse
The root node of an rbtree must always be black. However, rb_insert_color()
only needs to maintain this invariant when it has been broken - that is,
when it exits the loop due to the current (red) node being the root.
In all other cases (exiting after tree rotations, or exiting due to
an existing black parent) the invariant is already satisfied, so there
is no need to adjust the root node color.

Signed-off-by: Michel Lespinasse 
---
 lib/rbtree.c |   19 +++
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/lib/rbtree.c b/lib/rbtree.c
index 12abb8a..d0be5fc 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -91,8 +91,21 @@ void rb_insert_color(struct rb_node *node, struct rb_root 
*root)
 {
struct rb_node *parent, *gparent;
 
-   while ((parent = rb_parent(node)) && rb_is_red(parent))
-   {
+   while (true) {
+   /*
+* Loop invariant: node is red
+*
+* If there is a black parent, we are done.
+* Otherwise, take some corrective action as we don't
+* want a red root or two consecutive red nodes.
+*/
+   parent = rb_parent(node);
+   if (!parent) {
+   rb_set_black(node);
+   break;
+   } else if (rb_is_black(parent))
+   break;
+
gparent = rb_parent(parent);
 
if (parent == gparent->rb_left)
@@ -142,8 +155,6 @@ void rb_insert_color(struct rb_node *node, struct rb_root 
*root)
break;
}
}
-
-   rb_set_black(root->rb_node);
 }
 EXPORT_SYMBOL(rb_insert_color);
 
-- 
1.7.7.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 v2 08/12] rbtree: low level optimizations in rb_insert_color()

2012-07-12 Thread Michel Lespinasse
- Use the newly introduced rb_set_parent_color() function to flip the color
  of nodes whose parent is already known.
- Optimize rb_parent() when the node is known to be red - there is no need
  to mask out the color in that case.
- Flipping gparent's color to red requires us to fetch its rb_parent_color
  field, so we can reuse it as the parent value for the next loop iteration.
- Do not use __rb_rotate_left() and __rb_rotate_right() to handle tree
  rotations: we already have pointers to all relevant nodes, and know their
  colors (either because we want to adjust it, or because we've tested it,
  or we can deduce it as black due to the node proximity to a known red node).
  So we can generate more efficient code by making use of the node pointers
  we already have, and setting both the parent and color attributes for
  nodes all at once. Also in Case 2, some node attributes don't have to
  be set because we know another tree rotation (Case 3) will always follow
  and override them.

Signed-off-by: Michel Lespinasse 
---
 lib/rbtree.c |  166 +
 1 files changed, 131 insertions(+), 35 deletions(-)

diff --git a/lib/rbtree.c b/lib/rbtree.c
index d0be5fc..41cf19b 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -23,6 +23,25 @@
 #include 
 #include 
 
+/*
+ * red-black trees properties:  http://en.wikipedia.org/wiki/Rbtree
+ *
+ *  1) A node is either red or black
+ *  2) The root is black
+ *  3) All leaves (NULL) are black
+ *  4) Both children of every red node are black
+ *  5) Every simple path from root to leaves contains the same number
+ * of black nodes.
+ *
+ *  4 and 5 give the O(log n) guarantee, since 4 implies you cannot have two
+ *  consecutive red nodes in a path and every red node is therefore followed by
+ *  a black. So if B is the number of black nodes on every simple path (as per
+ *  5), then the longest possible path due to 4 is 2B.
+ *
+ *  We shall indicate color with case, where black nodes are uppercase and red
+ *  nodes will be lowercase.
+ */
+
 #defineRB_RED  0
 #defineRB_BLACK1
 
@@ -41,6 +60,17 @@ static inline void rb_set_color(struct rb_node *rb, int 
color)
rb->__rb_parent_color = (rb->__rb_parent_color & ~1) | color;
 }
 
+static inline void rb_set_parent_color(struct rb_node *rb,
+  struct rb_node *p, int color)
+{
+   rb->__rb_parent_color = (unsigned long)p | color;
+}
+
+static inline struct rb_node *rb_red_parent(struct rb_node *red)
+{
+   return (struct rb_node *)red->__rb_parent_color;
+}
+
 static void __rb_rotate_left(struct rb_node *node, struct rb_root *root)
 {
struct rb_node *right = node->rb_right;
@@ -87,9 +117,30 @@ static void __rb_rotate_right(struct rb_node *node, struct 
rb_root *root)
rb_set_parent(node, left);
 }
 
+/*
+ * Helper function for rotations:
+ * - old's parent and color get assigned to new
+ * - old gets assigned new as a parent and 'color' as a color.
+ */
+static inline void
+__rb_rotate_set_parents(struct rb_node *old, struct rb_node *new,
+   struct rb_root *root, int color)
+{
+   struct rb_node *parent = rb_parent(old);
+   new->__rb_parent_color = old->__rb_parent_color;
+   rb_set_parent_color(old, new, color);
+   if (parent) {
+   if (parent->rb_left == old)
+   parent->rb_left = new;
+   else
+   parent->rb_right = new;
+   } else
+   root->rb_node = new;
+}
+
 void rb_insert_color(struct rb_node *node, struct rb_root *root)
 {
-   struct rb_node *parent, *gparent;
+   struct rb_node *parent = rb_red_parent(node), *gparent, *tmp;
 
while (true) {
/*
@@ -99,59 +150,104 @@ void rb_insert_color(struct rb_node *node, struct rb_root 
*root)
 * Otherwise, take some corrective action as we don't
 * want a red root or two consecutive red nodes.
 */
-   parent = rb_parent(node);
if (!parent) {
-   rb_set_black(node);
+   rb_set_parent_color(node, NULL, RB_BLACK);
break;
} else if (rb_is_black(parent))
break;
 
-   gparent = rb_parent(parent);
-
-   if (parent == gparent->rb_left)
-   {
-   {
-   register struct rb_node *uncle = 
gparent->rb_right;
-   if (uncle && rb_is_red(uncle))
-   {
-   rb_set_black(uncle);
-   rb_set_black(parent);
-   rb_set_red(gparent);
-   node = gparent;
-   continue;
-   }
+  

[PATCH v2 09/12] rbtree: adjust node color in __rb_erase_color() only when necessary

2012-07-12 Thread Michel Lespinasse
In __rb_erase_color(), we were always setting a node to black after
exiting the main loop. And in one case, after fixing up the tree to
satisfy all rbtree invariants, we were setting the current node to root
just to guarantee a loop exit, at which point the root would be set to
black. However this is not necessary, as the root of an rbtree is already
known to be black. The only case where the color flip is required is when
we exit the loop due to the current node being red, and it's easiest to
just do the flip at that point instead of doing it after the loop.

Signed-off-by: Michel Lespinasse 
---
 lib/rbtree.c |   28 +---
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/lib/rbtree.c b/lib/rbtree.c
index 41cf19b..baf7c83 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -259,10 +259,22 @@ static void __rb_erase_color(struct rb_node *node, struct 
rb_node *parent,
 {
struct rb_node *other;
 
-   while ((!node || rb_is_black(node)) && node != root->rb_node)
-   {
-   if (parent->rb_left == node)
-   {
+   while (true) {
+   /*
+* Loop invariant: all leaf paths going through node have a
+* black node count that is 1 lower than other leaf paths.
+*
+* If node is red, we can flip it to black to adjust.
+* If node is the root, all leaf paths go through it.
+* Otherwise, we need to adjust the tree through color flips
+* and tree rotations as per one of the 4 cases below.
+*/
+   if (node && rb_is_red(node)) {
+   rb_set_black(node);
+   break;
+   } else if (!parent) {
+   break;
+   } else if (parent->rb_left == node) {
other = parent->rb_right;
if (rb_is_red(other))
{
@@ -291,12 +303,9 @@ static void __rb_erase_color(struct rb_node *node, struct 
rb_node *parent,
rb_set_black(parent);
rb_set_black(other->rb_right);
__rb_rotate_left(parent, root);
-   node = root->rb_node;
break;
}
-   }
-   else
-   {
+   } else {
other = parent->rb_left;
if (rb_is_red(other))
{
@@ -325,13 +334,10 @@ static void __rb_erase_color(struct rb_node *node, struct 
rb_node *parent,
rb_set_black(parent);
rb_set_black(other->rb_left);
__rb_rotate_right(parent, root);
-   node = root->rb_node;
break;
}
}
}
-   if (node)
-   rb_set_black(node);
 }
 
 void rb_erase(struct rb_node *node, struct rb_root *root)
-- 
1.7.7.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 v2 11/12] rbtree: low level optimizations in __rb_erase_color()

2012-07-12 Thread Michel Lespinasse
In __rb_erase_color(), we often already have pointers to the nodes
being rotated and/or know what their colors must be, so we can
generate more efficient code than the generic __rb_rotate_left()
and __rb_rotate_right() functions.

Also when the current node is red or when flipping the sibling's color,
the parent is already known so we can use the more efficient
rb_set_parent_color() function to set the desired color.

Signed-off-by: Michel Lespinasse 
---
 lib/rbtree.c |  208 --
 1 files changed, 115 insertions(+), 93 deletions(-)

diff --git a/lib/rbtree.c b/lib/rbtree.c
index eb823a3..a38e473 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -39,7 +39,8 @@
  *  5), then the longest possible path due to 4 is 2B.
  *
  *  We shall indicate color with case, where black nodes are uppercase and red
- *  nodes will be lowercase.
+ *  nodes will be lowercase. Unknown color nodes shall be drawn as red within
+ *  parentheses and have some accompanying text comment.
  */
 
 #defineRB_RED  0
@@ -48,17 +49,11 @@
 #define rb_color(r)   ((r)->__rb_parent_color & 1)
 #define rb_is_red(r)   (!rb_color(r))
 #define rb_is_black(r) rb_color(r)
-#define rb_set_red(r)  do { (r)->__rb_parent_color &= ~1; } while (0)
-#define rb_set_black(r)  do { (r)->__rb_parent_color |= 1; } while (0)
 
 static inline void rb_set_parent(struct rb_node *rb, struct rb_node *p)
 {
rb->__rb_parent_color = rb_color(rb) | (unsigned long)p;
 }
-static inline void rb_set_color(struct rb_node *rb, int color)
-{
-   rb->__rb_parent_color = (rb->__rb_parent_color & ~1) | color;
-}
 
 static inline void rb_set_parent_color(struct rb_node *rb,
   struct rb_node *p, int color)
@@ -71,52 +66,6 @@ static inline struct rb_node *rb_red_parent(struct rb_node 
*red)
return (struct rb_node *)red->__rb_parent_color;
 }
 
-static void __rb_rotate_left(struct rb_node *node, struct rb_root *root)
-{
-   struct rb_node *right = node->rb_right;
-   struct rb_node *parent = rb_parent(node);
-
-   if ((node->rb_right = right->rb_left))
-   rb_set_parent(right->rb_left, node);
-   right->rb_left = node;
-
-   rb_set_parent(right, parent);
-
-   if (parent)
-   {
-   if (node == parent->rb_left)
-   parent->rb_left = right;
-   else
-   parent->rb_right = right;
-   }
-   else
-   root->rb_node = right;
-   rb_set_parent(node, right);
-}
-
-static void __rb_rotate_right(struct rb_node *node, struct rb_root *root)
-{
-   struct rb_node *left = node->rb_left;
-   struct rb_node *parent = rb_parent(node);
-
-   if ((node->rb_left = left->rb_right))
-   rb_set_parent(left->rb_right, node);
-   left->rb_right = node;
-
-   rb_set_parent(left, parent);
-
-   if (parent)
-   {
-   if (node == parent->rb_right)
-   parent->rb_right = left;
-   else
-   parent->rb_left = left;
-   }
-   else
-   root->rb_node = left;
-   rb_set_parent(node, left);
-}
-
 /*
  * Helper function for rotations:
  * - old's parent and color get assigned to new
@@ -257,7 +206,7 @@ EXPORT_SYMBOL(rb_insert_color);
 static void __rb_erase_color(struct rb_node *node, struct rb_node *parent,
 struct rb_root *root)
 {
-   struct rb_node *other;
+   struct rb_node *sibling, *tmp1, *tmp2;
 
while (true) {
/*
@@ -270,63 +219,136 @@ static void __rb_erase_color(struct rb_node *node, 
struct rb_node *parent,
 * and tree rotations as per one of the 4 cases below.
 */
if (node && rb_is_red(node)) {
-   rb_set_black(node);
+   rb_set_parent_color(node, parent, RB_BLACK);
break;
} else if (!parent) {
break;
} else if (parent->rb_left == node) {
-   other = parent->rb_right;
-   if (rb_is_red(other))
-   {
-   rb_set_black(other);
-   rb_set_red(parent);
-   __rb_rotate_left(parent, root);
-   other = parent->rb_right;
+   sibling = parent->rb_right;
+   if (rb_is_red(sibling)) {
+   /*
+* Case 1 - left rotate at parent
+*
+* P   S
+*/ \ / \
+*   N   s-->p   Sr
+*  / \ / \
+* Sl  Sr  N   Sl
+ 

[PATCH v2 05/12] rbtree: performance and correctness test

2012-07-12 Thread Michel Lespinasse
This small module helps measure the performance of rbtree insert and erase.

Additionally, we run a few correctness tests to check that the rbtrees have
all desired properties:
- contains the right number of nodes in the order desired,
- never two consecutive red nodes on any path,
- all paths to leaf nodes have the same number of black nodes,
- root node is black

Signed-off-by: Michel Lespinasse 
---
 Makefile|2 +-
 lib/Kconfig.debug   |1 +
 tests/Kconfig   |   18 +++
 tests/Makefile  |1 +
 tests/rbtree_test.c |  135 +++
 5 files changed, 156 insertions(+), 1 deletions(-)
 create mode 100644 tests/Kconfig
 create mode 100644 tests/Makefile
 create mode 100644 tests/rbtree_test.c

diff --git a/Makefile b/Makefile
index a687963..7bef085 100644
--- a/Makefile
+++ b/Makefile
@@ -708,7 +708,7 @@ export mod_strip_cmd
 
 
 ifeq ($(KBUILD_EXTMOD),)
-core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
+core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ tests/
 
 vmlinux-dirs   := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 6777153..b148fa1 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1144,6 +1144,7 @@ config LATENCYTOP
 
 source mm/Kconfig.debug
 source kernel/trace/Kconfig
+source tests/Kconfig
 
 config PROVIDE_OHCI1394_DMA_INIT
bool "Remote debugging over FireWire early on boot"
diff --git a/tests/Kconfig b/tests/Kconfig
new file mode 100644
index 000..ceca7ba
--- /dev/null
+++ b/tests/Kconfig
@@ -0,0 +1,18 @@
+menuconfig BENCHMARKS
+   bool "In kernel benchmarks"
+   def_bool n
+   help
+ Includes in kernel benchmark modules in the build. These modules can
+ be loaded later to trigger benchmarking kernel subsystems.
+ Output will be generated in the system log.
+
+if BENCHMARKS
+
+config BENCHMARK_RBTREE
+   tristate "Red Black Tree Benchmark"
+   depends on m
+   default m
+   help
+ A benchmark measuring the performance of the rbtree library.
+
+endif # BENCHMARKS
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 000..440b77c
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_BENCHMARK_RBTREE) += rbtree_test.o
diff --git a/tests/rbtree_test.c b/tests/rbtree_test.c
new file mode 100644
index 000..4c6d250
--- /dev/null
+++ b/tests/rbtree_test.c
@@ -0,0 +1,135 @@
+#include 
+#include 
+#include 
+#include 
+
+#define NODES   100
+#define PERF_LOOPS  10
+#define CHECK_LOOPS 100
+
+struct test_node {
+   struct rb_node rb;
+   u32 key;
+};
+
+static struct rb_root root = RB_ROOT;
+static struct test_node nodes[NODES];
+
+static struct rnd_state rnd;
+
+static void insert(struct test_node *node, struct rb_root *root)
+{
+   struct rb_node **new = >rb_node, *parent = NULL;
+
+   while (*new) {
+   parent = *new;
+   if (node->key < rb_entry(parent, struct test_node, rb)->key)
+   new = >rb_left;
+   else
+   new = >rb_right;
+   }
+
+   rb_link_node(>rb, parent, new);
+   rb_insert_color(>rb, root);
+}
+
+static inline void erase(struct test_node *node, struct rb_root *root)
+{
+   rb_erase(>rb, root);
+}
+
+static void init(void)
+{
+   int i;
+   for (i = 0; i < NODES; i++)
+   nodes[i].key = prandom32();
+}
+
+static bool is_red(struct rb_node *rb)
+{
+   return !(rb->__rb_parent_color & 1);
+}
+
+static int black_path_count(struct rb_node *rb)
+{
+   int count;
+   for (count = 0; rb; rb = rb_parent(rb))
+   count += !is_red(rb);
+   return count;
+}
+
+static void check(int nr_nodes)
+{
+   struct rb_node *rb;
+   int count = 0;
+   int blacks;
+   u32 prev_key = 0;
+
+   for (rb = rb_first(); rb; rb = rb_next(rb)) {
+   struct test_node *node = rb_entry(rb, struct test_node, rb);
+   WARN_ON_ONCE(node->key < prev_key);
+   WARN_ON_ONCE(is_red(rb) &&
+(!rb_parent(rb) || is_red(rb_parent(rb;
+   if (!count)
+   blacks = black_path_count(rb);
+   else
+   WARN_ON_ONCE((!rb->rb_left || !rb->rb_right) &&
+blacks != black_path_count(rb));
+   prev_key = node->key;
+   count++;
+   }
+   WARN_ON_ONCE(count != nr_nodes);
+}
+
+static int rbtree_test_init(void)
+{
+   int i, j;
+   cycles_t time1, time2, time;
+
+   printk(KERN_ALERT "rbtree testing");
+
+   prandom32_seed(, 3141592653589793238);
+   init();
+
+   time1 = get_cycles();
+
+   for (i = 0; i < PERF_LOOPS; i++) {
+   for (j = 0; j < NODES; j++)
+   

[PATCH v2 04/12] rbtree: move some implementation details from rbtree.h to rbtree.c

2012-07-12 Thread Michel Lespinasse
rbtree users must use the documented APIs to manipulate the tree
structure.  Low-level helpers to manipulate node colors and parenthood
are not part of that API, so move them to lib/rbtree.c

Signed-off-by: Michel Lespinasse 
---
 include/linux/rbtree.h |   34 +-
 lib/rbtree.c   |   20 +++-
 2 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index 2049087..bf836a2 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -32,37 +32,19 @@
 #include 
 #include 
 
-struct rb_node
-{
-   unsigned long  rb_parent_color;
-#defineRB_RED  0
-#defineRB_BLACK1
+struct rb_node {
+   unsigned long  __rb_parent_color;
struct rb_node *rb_right;
struct rb_node *rb_left;
 } __attribute__((aligned(sizeof(long;
 /* The alignment might seem pointless, but allegedly CRIS needs it */
 
-struct rb_root
-{
+struct rb_root {
struct rb_node *rb_node;
 };
 
 
-#define rb_parent(r)   ((struct rb_node *)((r)->rb_parent_color & ~3))
-#define rb_color(r)   ((r)->rb_parent_color & 1)
-#define rb_is_red(r)   (!rb_color(r))
-#define rb_is_black(r) rb_color(r)
-#define rb_set_red(r)  do { (r)->rb_parent_color &= ~1; } while (0)
-#define rb_set_black(r)  do { (r)->rb_parent_color |= 1; } while (0)
-
-static inline void rb_set_parent(struct rb_node *rb, struct rb_node *p)
-{
-   rb->rb_parent_color = (rb->rb_parent_color & 3) | (unsigned long)p;
-}
-static inline void rb_set_color(struct rb_node *rb, int color)
-{
-   rb->rb_parent_color = (rb->rb_parent_color & ~1) | color;
-}
+#define rb_parent(r)   ((struct rb_node *)((r)->__rb_parent_color & ~3))
 
 #define RB_ROOT(struct rb_root) { NULL, }
 #definerb_entry(ptr, type, member) container_of(ptr, type, member)
@@ -70,8 +52,10 @@ static inline void rb_set_color(struct rb_node *rb, int 
color)
 #define RB_EMPTY_ROOT(root)  ((root)->rb_node == NULL)
 
 /* 'empty' nodes are nodes that are known not to be inserted in an rbree */
-#define RB_EMPTY_NODE(node)  ((node)->rb_parent_color == (unsigned long)(node))
-#define RB_CLEAR_NODE(node)  ((node)->rb_parent_color = (unsigned long)(node))
+#define RB_EMPTY_NODE(node)  \
+   ((node)->__rb_parent_color == (unsigned long)(node))
+#define RB_CLEAR_NODE(node)  \
+   ((node)->__rb_parent_color = (unsigned long)(node))
 
 
 extern void rb_insert_color(struct rb_node *, struct rb_root *);
@@ -98,7 +82,7 @@ extern void rb_replace_node(struct rb_node *victim, struct 
rb_node *new,
 static inline void rb_link_node(struct rb_node * node, struct rb_node * parent,
struct rb_node ** rb_link)
 {
-   node->rb_parent_color = (unsigned long )parent;
+   node->__rb_parent_color = (unsigned long)parent;
node->rb_left = node->rb_right = NULL;
 
*rb_link = node;
diff --git a/lib/rbtree.c b/lib/rbtree.c
index fe43c8c..ccada9a 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -23,6 +23,24 @@
 #include 
 #include 
 
+#defineRB_RED  0
+#defineRB_BLACK1
+
+#define rb_color(r)   ((r)->__rb_parent_color & 1)
+#define rb_is_red(r)   (!rb_color(r))
+#define rb_is_black(r) rb_color(r)
+#define rb_set_red(r)  do { (r)->__rb_parent_color &= ~1; } while (0)
+#define rb_set_black(r)  do { (r)->__rb_parent_color |= 1; } while (0)
+
+static inline void rb_set_parent(struct rb_node *rb, struct rb_node *p)
+{
+   rb->__rb_parent_color = rb_color(rb) | (unsigned long)p;
+}
+static inline void rb_set_color(struct rb_node *rb, int color)
+{
+   rb->__rb_parent_color = (rb->__rb_parent_color & ~1) | color;
+}
+
 static void __rb_rotate_left(struct rb_node *node, struct rb_root *root)
 {
struct rb_node *right = node->rb_right;
@@ -255,7 +273,7 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
rb_set_parent(old->rb_right, node);
}
 
-   node->rb_parent_color = old->rb_parent_color;
+   node->__rb_parent_color = old->__rb_parent_color;
node->rb_left = old->rb_left;
rb_set_parent(old->rb_left, node);
 
-- 
1.7.7.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 v2 03/12] rbtree: fix incorrect rbtree node insertion in fs/proc/proc_sysctl.c

2012-07-12 Thread Michel Lespinasse
The recently added code to use rbtrees in sysctl did not follow the proper
rbtree interface on insertion - it was calling rb_link_node() which
inserts a new node into the binary tree, but missed the call to
rb_insert_color() which properly balances the rbtree and establishes all
expected rbtree invariants.

I found out about this only because faulty commit also used rb_init_node(),
which I am removing within this patchset. But I think it's an easy mistake
to make, and it makes me wonder if we should change the rbtree API so that
insertions would be done with a single rb_insert() call (even if its
implementation could still inline the rb_link_node() part and call
a private __rb_insert_color function to do the rebalancing).

Signed-off-by: Michel Lespinasse 
---
 fs/proc/proc_sysctl.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 33aea86..77602c1a 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -142,6 +142,7 @@ static int insert_entry(struct ctl_table_header *head, 
struct ctl_table *entry)
}
 
rb_link_node(node, parent, p);
+   rb_insert_color(node, >parent->root);
return 0;
 }
 
-- 
1.7.7.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 v2 12/12] rbtree: coding style adjustments

2012-07-12 Thread Michel Lespinasse
Set comment and indentation style to be consistent with linux coding style
and the rest of the file, as suggested by Peter Zijlstra

Signed-off-by: Michel Lespinasse 
---
 lib/rbtree.c |   42 +++---
 1 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/lib/rbtree.c b/lib/rbtree.c
index a38e473..0892670 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -363,8 +363,7 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
child = node->rb_right;
else if (!node->rb_right)
child = node->rb_left;
-   else
-   {
+   else {
struct rb_node *old = node, *left;
 
node = node->rb_right;
@@ -406,17 +405,15 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
 
if (child)
rb_set_parent(child, parent);
-   if (parent)
-   {
+   if (parent) {
if (parent->rb_left == node)
parent->rb_left = child;
else
parent->rb_right = child;
-   }
-   else
+   } else
root->rb_node = child;
 
- color:
+color:
if (color == RB_BLACK)
__rb_erase_color(child, parent, root);
 }
@@ -529,8 +526,10 @@ struct rb_node *rb_next(const struct rb_node *node)
if (RB_EMPTY_NODE(node))
return NULL;
 
-   /* If we have a right-hand child, go down and then left as far
-  as we can. */
+   /*
+* If we have a right-hand child, go down and then left as far
+* as we can.
+*/
if (node->rb_right) {
node = node->rb_right; 
while (node->rb_left)
@@ -538,12 +537,13 @@ struct rb_node *rb_next(const struct rb_node *node)
return (struct rb_node *)node;
}
 
-   /* No right-hand children.  Everything down and left is
-  smaller than us, so any 'next' node must be in the general
-  direction of our parent. Go up the tree; any time the
-  ancestor is a right-hand child of its parent, keep going
-  up. First time it's a left-hand child of its parent, said
-  parent is our 'next' node. */
+   /*
+* No right-hand children. Everything down and left is smaller than us,
+* so any 'next' node must be in the general direction of our parent.
+* Go up the tree; any time the ancestor is a right-hand child of its
+* parent, keep going up. First time it's a left-hand child of its
+* parent, said parent is our 'next' node.
+*/
while ((parent = rb_parent(node)) && node == parent->rb_right)
node = parent;
 
@@ -558,8 +558,10 @@ struct rb_node *rb_prev(const struct rb_node *node)
if (RB_EMPTY_NODE(node))
return NULL;
 
-   /* If we have a left-hand child, go down and then right as far
-  as we can. */
+   /*
+* If we have a left-hand child, go down and then right as far
+* as we can.
+*/
if (node->rb_left) {
node = node->rb_left; 
while (node->rb_right)
@@ -567,8 +569,10 @@ struct rb_node *rb_prev(const struct rb_node *node)
return (struct rb_node *)node;
}
 
-   /* No left-hand children. Go up till we find an ancestor which
-  is a right-hand child of its parent */
+   /*
+* No left-hand children. Go up till we find an ancestor which
+* is a right-hand child of its parent.
+*/
while ((parent = rb_parent(node)) && node == parent->rb_left)
node = parent;
 
-- 
1.7.7.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 v2 10/12] rbtree: optimize case selection logic in __rb_erase_color()

2012-07-12 Thread Michel Lespinasse
In __rb_erase_color(), we have to select one of 3 cases depending on the
color on the 'other' node children. If both children are black, we flip
a few node colors and iterate. Otherwise, we do either one or two
tree rotations, depending on the color of the 'other' child opposite
to 'node', and then we are done.

The corresponding logic had duplicate checks for the color of the 'other'
child opposite to 'node'. It was checking it first to determine if both
children are black, and then to determine how many tree rotations are
required. Rearrange the logic to avoid that extra check.

Signed-off-by: Michel Lespinasse 
---
 lib/rbtree.c |   68 +
 1 files changed, 30 insertions(+), 38 deletions(-)

diff --git a/lib/rbtree.c b/lib/rbtree.c
index baf7c83..eb823a3 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -283,28 +283,24 @@ static void __rb_erase_color(struct rb_node *node, struct 
rb_node *parent,
__rb_rotate_left(parent, root);
other = parent->rb_right;
}
-   if ((!other->rb_left || rb_is_black(other->rb_left)) &&
-   (!other->rb_right || rb_is_black(other->rb_right)))
-   {
-   rb_set_red(other);
-   node = parent;
-   parent = rb_parent(node);
-   }
-   else
-   {
-   if (!other->rb_right || 
rb_is_black(other->rb_right))
-   {
-   rb_set_black(other->rb_left);
+   if (!other->rb_right || rb_is_black(other->rb_right)) {
+   if (!other->rb_left ||
+   rb_is_black(other->rb_left)) {
rb_set_red(other);
-   __rb_rotate_right(other, root);
-   other = parent->rb_right;
+   node = parent;
+   parent = rb_parent(node);
+   continue;
}
-   rb_set_color(other, rb_color(parent));
-   rb_set_black(parent);
-   rb_set_black(other->rb_right);
-   __rb_rotate_left(parent, root);
-   break;
+   rb_set_black(other->rb_left);
+   rb_set_red(other);
+   __rb_rotate_right(other, root);
+   other = parent->rb_right;
}
+   rb_set_color(other, rb_color(parent));
+   rb_set_black(parent);
+   rb_set_black(other->rb_right);
+   __rb_rotate_left(parent, root);
+   break;
} else {
other = parent->rb_left;
if (rb_is_red(other))
@@ -314,28 +310,24 @@ static void __rb_erase_color(struct rb_node *node, struct 
rb_node *parent,
__rb_rotate_right(parent, root);
other = parent->rb_left;
}
-   if ((!other->rb_left || rb_is_black(other->rb_left)) &&
-   (!other->rb_right || rb_is_black(other->rb_right)))
-   {
-   rb_set_red(other);
-   node = parent;
-   parent = rb_parent(node);
-   }
-   else
-   {
-   if (!other->rb_left || 
rb_is_black(other->rb_left))
-   {
-   rb_set_black(other->rb_right);
+   if (!other->rb_left || rb_is_black(other->rb_left)) {
+   if (!other->rb_right ||
+   rb_is_black(other->rb_right)) {
rb_set_red(other);
-   __rb_rotate_left(other, root);
-   other = parent->rb_left;
+   node = parent;
+   parent = rb_parent(node);
+   continue;
}
-   rb_set_color(other, rb_color(parent));
-   rb_set_black(parent);
-   rb_set_black(other->rb_left);
-   __rb_rotate_right(parent, root);
-   

[PATCH v2 02/12] rbtree: empty nodes have no color

2012-07-12 Thread Michel Lespinasse
Empty nodes have no color.  We can make use of this property to
simplify the code emitted by the RB_EMPTY_NODE and RB_CLEAR_NODE
macros.  Also, we can get rid of the rb_init_node function which had
been introduced by commit 88d19cf37952a7e1e38b2bf87a00f0e857e63180
to avoid some issue with the empty node's color not being initialized.

I'm not sure what the RB_EMPTY_NODE checks in rb_prev() / rb_next()
are doing there, though. axboe introduced them in commit 10fd48f2376d.
The way I see it, the 'empty node' abstraction is only used by rbtree
users to flag nodes that they haven't inserted in any rbtree, so asking
the predecessor or successor of such nodes doesn't make any sense.

One final rb_init_node() caller was recently added in sysctl code
to implement faster sysctl name lookups. This code doesn't make use
of RB_EMPTY_NODE at all, and from what I could see it only called
rb_init_node() under the mistaken assumption that such initialization
was required before node insertion.

Signed-off-by: Michel Lespinasse 
---
 fs/proc/proc_sysctl.c  |4 +---
 include/linux/rbtree.h |   15 +--
 include/linux/timerqueue.h |2 +-
 lib/rbtree.c   |4 ++--
 4 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 21d836f..33aea86 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -168,10 +168,8 @@ static void init_header(struct ctl_table_header *head,
head->node = node;
if (node) {
struct ctl_table *entry;
-   for (entry = table; entry->procname; entry++, node++) {
-   rb_init_node(>node);
+   for (entry = table; entry->procname; entry++, node++)
node->header = head;
-   }
}
 }
 
diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index e6a8077..2049087 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -67,17 +67,12 @@ static inline void rb_set_color(struct rb_node *rb, int 
color)
 #define RB_ROOT(struct rb_root) { NULL, }
 #definerb_entry(ptr, type, member) container_of(ptr, type, member)
 
-#define RB_EMPTY_ROOT(root)((root)->rb_node == NULL)
-#define RB_EMPTY_NODE(node)(rb_parent(node) == node)
-#define RB_CLEAR_NODE(node)(rb_set_parent(node, node))
+#define RB_EMPTY_ROOT(root)  ((root)->rb_node == NULL)
+
+/* 'empty' nodes are nodes that are known not to be inserted in an rbree */
+#define RB_EMPTY_NODE(node)  ((node)->rb_parent_color == (unsigned long)(node))
+#define RB_CLEAR_NODE(node)  ((node)->rb_parent_color = (unsigned long)(node))
 
-static inline void rb_init_node(struct rb_node *rb)
-{
-   rb->rb_parent_color = 0;
-   rb->rb_right = NULL;
-   rb->rb_left = NULL;
-   RB_CLEAR_NODE(rb);
-}
 
 extern void rb_insert_color(struct rb_node *, struct rb_root *);
 extern void rb_erase(struct rb_node *, struct rb_root *);
diff --git a/include/linux/timerqueue.h b/include/linux/timerqueue.h
index 5088727..a520fd7 100644
--- a/include/linux/timerqueue.h
+++ b/include/linux/timerqueue.h
@@ -39,7 +39,7 @@ struct timerqueue_node *timerqueue_getnext(struct 
timerqueue_head *head)
 
 static inline void timerqueue_init(struct timerqueue_node *node)
 {
-   rb_init_node(>node);
+   RB_CLEAR_NODE(>node);
 }
 
 static inline void timerqueue_init_head(struct timerqueue_head *head)
diff --git a/lib/rbtree.c b/lib/rbtree.c
index d417556..fe43c8c 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -387,7 +387,7 @@ struct rb_node *rb_next(const struct rb_node *node)
 {
struct rb_node *parent;
 
-   if (rb_parent(node) == node)
+   if (RB_EMPTY_NODE(node))
return NULL;
 
/* If we have a right-hand child, go down and then left as far
@@ -416,7 +416,7 @@ struct rb_node *rb_prev(const struct rb_node *node)
 {
struct rb_node *parent;
 
-   if (rb_parent(node) == node)
+   if (RB_EMPTY_NODE(node))
return NULL;
 
/* If we have a left-hand child, go down and then right as far
-- 
1.7.7.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 v2 01/12] rbtree: reference Documentation/rbtree.txt for usage instructions

2012-07-12 Thread Michel Lespinasse
include/linux/rbtree.h included some basic usage instructions, while
Documentation/rbtree.txt had some more complete and easier to follow
instructions.  Replacing the former with a reference to the latter.

Signed-off-by: Michel Lespinasse 
---
 include/linux/rbtree.h |   67 +---
 1 files changed, 1 insertions(+), 66 deletions(-)

diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index 033b507..e6a8077 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -23,72 +23,7 @@
   I know it's not the cleaner way,  but in C (not in C++) to get
   performances and genericity...
 
-  Some example of insert and search follows here. The search is a plain
-  normal search over an ordered tree. The insert instead must be implemented
-  in two steps: First, the code must insert the element in order as a red leaf
-  in the tree, and then the support library function rb_insert_color() must
-  be called. Such function will do the not trivial work to rebalance the
-  rbtree, if necessary.
-

-static inline struct page * rb_search_page_cache(struct inode * inode,
-unsigned long offset)
-{
-   struct rb_node * n = inode->i_rb_page_cache.rb_node;
-   struct page * page;
-
-   while (n)
-   {
-   page = rb_entry(n, struct page, rb_page_cache);
-
-   if (offset < page->offset)
-   n = n->rb_left;
-   else if (offset > page->offset)
-   n = n->rb_right;
-   else
-   return page;
-   }
-   return NULL;
-}
-
-static inline struct page * __rb_insert_page_cache(struct inode * inode,
-  unsigned long offset,
-  struct rb_node * node)
-{
-   struct rb_node ** p = >i_rb_page_cache.rb_node;
-   struct rb_node * parent = NULL;
-   struct page * page;
-
-   while (*p)
-   {
-   parent = *p;
-   page = rb_entry(parent, struct page, rb_page_cache);
-
-   if (offset < page->offset)
-   p = &(*p)->rb_left;
-   else if (offset > page->offset)
-   p = &(*p)->rb_right;
-   else
-   return page;
-   }
-
-   rb_link_node(node, parent, p);
-
-   return NULL;
-}
-
-static inline struct page * rb_insert_page_cache(struct inode * inode,
-unsigned long offset,
-struct rb_node * node)
-{
-   struct page * ret;
-   if ((ret = __rb_insert_page_cache(inode, offset, node)))
-   goto out;
-   rb_insert_color(node, >i_rb_page_cache);
- out:
-   return ret;
-}

+  See Documentation/rbtree.txt for documentation and samples.
 */
 
 #ifndef_LINUX_RBTREE_H
-- 
1.7.7.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 v2 00/12] rbtree updates

2012-07-12 Thread Michel Lespinasse
Change log since v1:
- Added tree graphs as comments as suggested by Peter
- Fixed coding style in rest of lib/rbtree.c as suggested by Peter
- made clear rb_parent_color is private, not to be directly accessed,
  by renaming it to __rb_parent_color
- collapsed some low level optimization patches instead of splitting out
  the parts that were related to tree rotatoins from the parts that were
  related to color flips.
- Added build system support in patch 5

These are quite minor changes against v1, which already got good reviews
from Peter, so I think all that is required now is for Andrea to say he
doesn't oppose this.

--

I recently started looking at the rbtree code (with an eye towards
improving the augmented rbtree support, but I haven't gotten there
yet). I noticed a lot of possible speed improvements, which I am now
proposing in this patch set.

Patches 1-4 are preparatory: remove internal functions from rbtree.h
so that users won't be tempted to use them instead of the documented
APIs, clean up some incorrect usages I've noticed (in particular, with
the recently added fs/proc/proc_sysctl.c rbtree usage), reference the
documentation so that people have one less excuse to miss it, etc.

Patch 5 is a small module I wrote to check the rbtree performance.
It creates 100 nodes with random keys and repeatedly inserts and erases
them from an rbtree. Additionally, it has code to check for rbtree
invariants after each insert or erase operation.

Patches 6-12 is where the rbtree optimizations are done, and they touch
only that one file, lib/rbtree.c . I am getting good results out of these -
in my small benchmark doing rbtree insertion (including search) and erase,
I'm seeing a 30% runtime reduction on Sandybridge E5, which is more than
I initially thought would be possible. (the results aren't as impressive
on my two other test hosts though, AMD barcelona and Intel Westmere, where
I am seeing 14% runtime reduction only). The code size - both source
(ommiting comments) and compiled - is also shorter after these changes.
However, I do admit that the updated code is more arduous to read - one
big reason for that is the removal of the tree rotation helpers, which
added some overhead but also made it easier to reason about things locally.
Overall, I believe this is an acceptable compromise, given that this code
doesn't get modified very often, and that I have good tests for it.

Upon Peter's suggestion, I added comments showing the rtree configuration
before every rotation. I think they help; however it's still best to have
a copy of the cormen/leiserson/rivest book when digging into this code.

This patchset is against v3.4. This code doesn't change very often, so
the patchset should apply to the latest and greatest too.

My proposal would be for this to go in -mm tree to be used as a base to add
on the augmented rbtree support enhancements, which I am already working on.

Michel Lespinasse (12):
  rbtree: reference Documentation/rbtree.txt for usage instructions
  rbtree: empty nodes have no color
  rbtree: fix incorrect rbtree node insertion in fs/proc/proc_sysctl.c
  rbtree: move some implementation details from rbtree.h to rbtree.c
  rbtree: performance and correctness test
  rbtree: break out of rb_insert_color loop after tree rotation
  rbtree: adjust root color in rb_insert_color() only when necessary
  rbtree: low level optimizations in rb_insert_color()
  rbtree: adjust node color in __rb_erase_color() only when necessary
  rbtree: optimize case selection logic in __rb_erase_color()
  rbtree: low level optimizations in __rb_erase_color()
  rbtree: coding style adjustments

 Makefile   |2 +-
 fs/proc/proc_sysctl.c  |5 +-
 include/linux/rbtree.h |  112 ++-
 include/linux/timerqueue.h |2 +-
 lib/Kconfig.debug  |1 +
 lib/rbtree.c   |  487 
 tests/Kconfig  |   18 ++
 tests/Makefile |1 +
 tests/rbtree_test.c|  135 
 9 files changed, 487 insertions(+), 276 deletions(-)
 create mode 100644 tests/Kconfig
 create mode 100644 tests/Makefile
 create mode 100644 tests/rbtree_test.c

-- 
1.7.7.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 0/6] Fix for leapsecond caused hrtimer/futex issue (updated)

2012-07-12 Thread John Stultz

On 07/12/2012 03:43 PM, Jiri Bohac wrote:

On Tue, Jul 10, 2012 at 03:53:59PM -0700, John Stultz wrote:

On 07/10/2012 03:43 PM, John Stultz wrote:

Over the weekend, Thomas got a chance to review the leap second fix
in more detail and had a few additional changes he wanted to make
to improve performance as well as style.

So this iteration includes his modifications.

Once merged, I'll be working to get the backports finished as quickly
as I can and sent to -stable.

looking at the proposed 2.6.32.y stable patch at:
http://git.linaro.org/gitweb?p=people/jstultz/linux.git;a=commitdiff;h=18d208632bf17aed56c581b882868b2be44be71e;hp=6d224606bb8eec78027522d6dd5abfea8108c41a
Is this the final version you are about to send to -stable?
No, this isn't what I'm sending to -stable.  That was my backport that 
was done was prior to merging Thomas' modifications from over the 
weekend. Having, so far, done this backporting 3 times or so,  I figured 
I'd just wait until something got committed upstream before trying to 
backport it again. :)




In 2.6.32 timekeeping_leap_insert() is not called from the timer
interrupt, but from the leap_timer hrtimer.

I think the new clock_was_set_timer will thus not be called by
irq_exit() because TIMER_SOFTIRQ has not been raised. Unless
TIMER_SOFTIRQ is raised, clock_was_set() will not be called until
the next periodic timer interrupt, correct?

Wouldn't the original schedule_work() approach work better for
2.6.32?

Or do you plan backporting the most recent version to 2.6.32?


I'll be backporting & testing the most recent version once it is 
committed upstream.


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/


Re: UIO: missing resource mapping

2012-07-12 Thread Michael S. Tsirkin
On Fri, Jul 13, 2012 at 01:40:11AM +0200, Hans J. Koch wrote:
> On Fri, Jul 13, 2012 at 02:16:32AM +0300, Michael S. Tsirkin wrote:
> > On Thu, Jul 12, 2012 at 09:44:33PM +0200, Hans J. Koch wrote:
> > > > Looking further at the code, I cannot see where the mem fields are
> > > > being filled at all.
> > > > Which code is supposed to write the struct uio_mem?
> > > 
> > > In my opinion, the driver should. However, Michael's idea is to use
> > > /sys/bus/pci/devices/XresourceX for mapping purposes.
> > > 
> > > That is of course also possible, but obviously it leads to confusion.
> > > We already had a long thread about this:
> > > 
> > > http://www.spinics.net/lists/kvm/msg73837.html
> > > 
> > > Michael, can we change the driver to offer all available PCI BARs in the
> > > normal UIO way? I'm afraid otherwise we'll have the same discussion over
> > > and over again.
> > > 
> > > Thanks,
> > > Hans
> > 
> > My concern was people will ask for more and more stuff that pci
> > sysfs already has.
> > If we do add these is there a way to not duplicate code from pci?
> > Export pci_mmap_resource and use it? Or make the uio attributes
> > softlinks to pci sysfs somehow?
> 
> I understand your concern. Of course I'm also not in favor of duplicating
> code, but I don't think there's much overhead. PCI already exports all
> information needed by pci_resource_start(dev, bar) and
> pci_resource_len(dev, bar). Have a look at other UIO PCI drivers like
> uio_cif.c or uio_netx.c to see how it works. It's just a few more lines
> of code to loop through all BARs and add the to info->mem[i].
> 
> By the way, the current size of the info->mem[] array was exactly made
> with PCI in mind...
> 
> Thanks,
> Hans

Well we also need to check resource type and probably iomem_is_exclusive.

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


[ 010/187] ARM: SAMSUNG: Fix for S3C2412 EBI memory mapping

2012-07-12 Thread Greg Kroah-Hartman
From: Greg KH 

3.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Jose Miguel Goncalves 

commit 3dca938656c7b0ff6b0717a5dde0f5f45e592be5 upstream.

While upgrading the kernel on a S3C2412 based board I've noted
that it was impossible to boot the board with a 2.6.32 or upper
kernel. I've tracked down the problem to the EBI virtual memory
mapping that is in conflict with the IO mapping definition in
arch/arm/mach-s3c24xx/s3c2412.c.

Signed-off-by: Jose Miguel Goncalves 
Signed-off-by: Kukjin Kim 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/arm/plat-samsung/include/plat/map-s3c.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/arm/plat-samsung/include/plat/map-s3c.h
+++ b/arch/arm/plat-samsung/include/plat/map-s3c.h
@@ -22,7 +22,7 @@
 #define S3C24XX_VA_WATCHDOGS3C_VA_WATCHDOG
 
 #define S3C2412_VA_SSMCS3C_ADDR_CPU(0x)
-#define S3C2412_VA_EBI S3C_ADDR_CPU(0x0001)
+#define S3C2412_VA_EBI S3C_ADDR_CPU(0x0010)
 
 #define S3C2410_PA_UART(0x5000)
 #define S3C24XX_PA_UARTS3C2410_PA_UART


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


[ 012/187] ARM: 7438/1: fill possible PMD empty section gaps

2012-07-12 Thread Greg Kroah-Hartman
From: Greg KH 

3.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Nicolas Pitre 

commit 19b52abe3c5d759661500a1dc810924369b2ad46 upstream.

On ARM with the 2-level page table format, a PMD entry is represented by
two consecutive section entries covering 2MB of virtual space.

However, static mappings always were allowed to use separate 1MB section
entries.  This means in practice that a static mapping may create half
populated PMDs via create_mapping().

Since commit 0536bdf33f (ARM: move iotable mappings within the vmalloc
region) those static mappings are located in the vmalloc area. We must
ensure no such half populated PMDs are accessible once vmalloc() or
ioremap() start looking at the vmalloc area for nearby free virtual
address ranges, or various things leading to a kernel crash will happen.

Signed-off-by: Nicolas Pitre 
Reported-by: Santosh Shilimkar 
Tested-by: "R, Sricharan" 
Reviewed-by: Catalin Marinas 
Signed-off-by: Russell King 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/arm/mm/mmu.c |   74 ++
 1 file changed, 74 insertions(+)

--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -783,6 +783,79 @@ void __init iotable_init(struct map_desc
}
 }
 
+#ifndef CONFIG_ARM_LPAE
+
+/*
+ * The Linux PMD is made of two consecutive section entries covering 2MB
+ * (see definition in include/asm/pgtable-2level.h).  However a call to
+ * create_mapping() may optimize static mappings by using individual
+ * 1MB section mappings.  This leaves the actual PMD potentially half
+ * initialized if the top or bottom section entry isn't used, leaving it
+ * open to problems if a subsequent ioremap() or vmalloc() tries to use
+ * the virtual space left free by that unused section entry.
+ *
+ * Let's avoid the issue by inserting dummy vm entries covering the unused
+ * PMD halves once the static mappings are in place.
+ */
+
+static void __init pmd_empty_section_gap(unsigned long addr)
+{
+   struct vm_struct *vm;
+
+   vm = early_alloc_aligned(sizeof(*vm), __alignof__(*vm));
+   vm->addr = (void *)addr;
+   vm->size = SECTION_SIZE;
+   vm->flags = VM_IOREMAP | VM_ARM_STATIC_MAPPING;
+   vm->caller = pmd_empty_section_gap;
+   vm_area_add_early(vm);
+}
+
+static void __init fill_pmd_gaps(void)
+{
+   struct vm_struct *vm;
+   unsigned long addr, next = 0;
+   pmd_t *pmd;
+
+   /* we're still single threaded hence no lock needed here */
+   for (vm = vmlist; vm; vm = vm->next) {
+   if (!(vm->flags & VM_ARM_STATIC_MAPPING))
+   continue;
+   addr = (unsigned long)vm->addr;
+   if (addr < next)
+   continue;
+
+   /*
+* Check if this vm starts on an odd section boundary.
+* If so and the first section entry for this PMD is free
+* then we block the corresponding virtual address.
+*/
+   if ((addr & ~PMD_MASK) == SECTION_SIZE) {
+   pmd = pmd_off_k(addr);
+   if (pmd_none(*pmd))
+   pmd_empty_section_gap(addr & PMD_MASK);
+   }
+
+   /*
+* Then check if this vm ends on an odd section boundary.
+* If so and the second section entry for this PMD is empty
+* then we block the corresponding virtual address.
+*/
+   addr += vm->size;
+   if ((addr & ~PMD_MASK) == SECTION_SIZE) {
+   pmd = pmd_off_k(addr) + 1;
+   if (pmd_none(*pmd))
+   pmd_empty_section_gap(addr);
+   }
+
+   /* no need to look at any vm entry until we hit the next PMD */
+   next = (addr + PMD_SIZE - 1) & PMD_MASK;
+   }
+}
+
+#else
+#define fill_pmd_gaps() do { } while (0)
+#endif
+
 static void * __initdata vmalloc_min =
(void *)(VMALLOC_END - (240 << 20) - VMALLOC_OFFSET);
 
@@ -1064,6 +1137,7 @@ static void __init devicemaps_init(struc
 */
if (mdesc->map_io)
mdesc->map_io();
+   fill_pmd_gaps();
 
/*
 * Finally flush the caches and tlb to ensure that we're in a


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


[ 015/187] media: smsusb: add autodetection support for USB ID 2040:f5a0

2012-07-12 Thread Greg Kroah-Hartman
From: Greg KH 

3.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Michael Krufky 

commit 3e1141e2ce5667301a74ca2ef396d9bd5e995f7f upstream.

Signed-off-by: Michael Krufky 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/media/dvb/siano/smsusb.c |2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/media/dvb/siano/smsusb.c
+++ b/drivers/media/dvb/siano/smsusb.c
@@ -544,6 +544,8 @@ static const struct usb_device_id smsusb
.driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
{ USB_DEVICE(0x2040, 0xc0a0),
.driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
+   { USB_DEVICE(0x2040, 0xf5a0),
+   .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
{ } /* Terminating entry */
};
 


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


[ 017/187] bql: Avoid unneeded limit decrement.

2012-07-12 Thread Greg Kroah-Hartman
From: Greg KH 

3.4-stable review patch.  If anyone has any objections, please let me know.

--


From: Hiroaki SHIMODA 

[ Upstream commit 25426b794efdc70dde7fd3134dc56fac3e7d562d ]

When below pattern is observed,

   TIME
   dql_queued() dql_completed() |
  a) initial state  |
|
  b) X bytes queued V

  c) Y bytes queued
   d) X bytes completed
  e) Z bytes queued
   f) Y bytes completed

a) dql->limit has already some value and there is no in-flight packet.
b) X bytes queued.
c) Y bytes queued and excess limit.
d) X bytes completed and dql->prev_ovlimit is set and also
   dql->prev_num_queued is set Y.
e) Z bytes queued.
f) Y bytes completed. inprogress and prev_inprogress are true.

At f), according to the comment, all_prev_completed becomes
true and limit should be increased. But POSDIFF() ignores
(completed == dql->prev_num_queued) case, so limit is decreased.

Signed-off-by: Hiroaki SHIMODA 
Cc: Tom Herbert 
Cc: Eric Dumazet 
Cc: Denys Fedoryshchenko 
Acked-by: Eric Dumazet 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 lib/dynamic_queue_limits.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/lib/dynamic_queue_limits.c
+++ b/lib/dynamic_queue_limits.c
@@ -11,12 +11,14 @@
 #include 
 
 #define POSDIFF(A, B) ((int)((A) - (B)) > 0 ? (A) - (B) : 0)
+#define AFTER_EQ(A, B) ((int)((A) - (B)) >= 0)
 
 /* Records completed count and recalculates the queue limit */
 void dql_completed(struct dql *dql, unsigned int count)
 {
unsigned int inprogress, prev_inprogress, limit;
-   unsigned int ovlimit, all_prev_completed, completed;
+   unsigned int ovlimit, completed;
+   bool all_prev_completed;
 
/* Can't complete more than what's in queue */
BUG_ON(count > dql->num_queued - dql->num_completed);
@@ -26,7 +28,7 @@ void dql_completed(struct dql *dql, unsi
ovlimit = POSDIFF(dql->num_queued - dql->num_completed, limit);
inprogress = dql->num_queued - completed;
prev_inprogress = dql->prev_num_queued - dql->num_completed;
-   all_prev_completed = POSDIFF(completed, dql->prev_num_queued);
+   all_prev_completed = AFTER_EQ(completed, dql->prev_num_queued);
 
if ((ovlimit && !inprogress) ||
(dql->prev_ovlimit && all_prev_completed)) {


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


[ 013/187] powerpc/kvm: sldi should be sld

2012-07-12 Thread Greg Kroah-Hartman
From: Greg KH 

3.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Michael Neuling 

commit 2f584a146a2965b82fce89b8d2f95dc5cfe468d0 upstream.

Since we are taking a registers, this should never have been an sldi.
Talking to paulus offline, this is the correct fix.

Was introduced by:
 commit 19ccb76a1938ab364a412253daec64613acbf3df
 Author: Paul Mackerras 
 Date:   Sat Jul 23 17:42:46 2011 +1000

Talking to paulus, this shouldn't be a literal.

Signed-off-by: Michael Neuling 
Signed-off-by: Benjamin Herrenschmidt 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/powerpc/kvm/book3s_hv_rmhandlers.S |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -776,7 +776,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201)
lwz r3,VCORE_NAPPING_THREADS(r5)
lwz r4,VCPU_PTID(r9)
li  r0,1
-   sldir0,r0,r4
+   sld r0,r0,r4
andc.   r3,r3,r0/* no sense IPI'ing ourselves */
beq 43f
mulli   r4,r4,PACA_SIZE /* get paca for thread 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/


[ 022/187] drop_monitor: dont sleep in atomic context

2012-07-12 Thread Greg Kroah-Hartman
From: Greg KH 

3.4-stable review patch.  If anyone has any objections, please let me know.

--


From: Eric Dumazet 

[ Upstream commit bec4596b4e6770c7037f21f6bd27567b152dc0d6 ]

drop_monitor calls several sleeping functions while in atomic context.

 BUG: sleeping function called from invalid context at mm/slub.c:943
 in_atomic(): 1, irqs_disabled(): 0, pid: 2103, name: kworker/0:2
 Pid: 2103, comm: kworker/0:2 Not tainted 3.5.0-rc1+ #55
 Call Trace:
  [] __might_sleep+0xca/0xf0
  [] kmem_cache_alloc_node+0x1b3/0x1c0
  [] ? queue_delayed_work_on+0x11c/0x130
  [] __alloc_skb+0x4b/0x230
  [] ? reset_per_cpu_data+0x160/0x160 [drop_monitor]
  [] reset_per_cpu_data+0x2f/0x160 [drop_monitor]
  [] send_dm_alert+0x4b/0xb0 [drop_monitor]
  [] process_one_work+0x130/0x4c0
  [] worker_thread+0x159/0x360
  [] ? manage_workers.isra.27+0x240/0x240
  [] kthread+0x93/0xa0
  [] kernel_thread_helper+0x4/0x10
  [] ? kthread_freezable_should_stop+0x80/0x80
  [] ? gs_change+0xb/0xb

Rework the logic to call the sleeping functions in right context.

Use standard timer/workqueue api to let system chose any cpu to perform
the allocation and netlink send.

Also avoid a loop if reset_per_cpu_data() cannot allocate memory :
use mod_timer() to wait 1/10 second before next try.

Signed-off-by: Eric Dumazet 
Cc: Neil Horman 
Reviewed-by: Neil Horman 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 net/core/drop_monitor.c |  102 +++-
 1 file changed, 33 insertions(+), 69 deletions(-)

--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -33,9 +33,6 @@
 #define TRACE_ON 1
 #define TRACE_OFF 0
 
-static void send_dm_alert(struct work_struct *unused);
-
-
 /*
  * Globals, our netlink socket pointer
  * and the work handle that will send up
@@ -45,11 +42,10 @@ static int trace_state = TRACE_OFF;
 static DEFINE_MUTEX(trace_state_mutex);
 
 struct per_cpu_dm_data {
-   struct work_struct dm_alert_work;
-   struct sk_buff __rcu *skb;
-   atomic_t dm_hit_count;
-   struct timer_list send_timer;
-   int cpu;
+   spinlock_t  lock;
+   struct sk_buff  *skb;
+   struct work_struct  dm_alert_work;
+   struct timer_list   send_timer;
 };
 
 struct dm_hw_stat_delta {
@@ -75,13 +71,13 @@ static int dm_delay = 1;
 static unsigned long dm_hw_check_delta = 2*HZ;
 static LIST_HEAD(hw_stats_list);
 
-static void reset_per_cpu_data(struct per_cpu_dm_data *data)
+static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
 {
size_t al;
struct net_dm_alert_msg *msg;
struct nlattr *nla;
struct sk_buff *skb;
-   struct sk_buff *oskb = rcu_dereference_protected(data->skb, 1);
+   unsigned long flags;
 
al = sizeof(struct net_dm_alert_msg);
al += dm_hit_limit * sizeof(struct net_dm_drop_point);
@@ -96,65 +92,40 @@ static void reset_per_cpu_data(struct pe
  sizeof(struct net_dm_alert_msg));
msg = nla_data(nla);
memset(msg, 0, al);
-   } else
-   schedule_work_on(data->cpu, >dm_alert_work);
-
-   /*
-* Don't need to lock this, since we are guaranteed to only
-* run this on a single cpu at a time.
-* Note also that we only update data->skb if the old and new skb
-* pointers don't match.  This ensures that we don't continually call
-* synchornize_rcu if we repeatedly fail to alloc a new netlink message.
-*/
-   if (skb != oskb) {
-   rcu_assign_pointer(data->skb, skb);
-
-   synchronize_rcu();
-
-   atomic_set(>dm_hit_count, dm_hit_limit);
+   } else {
+   mod_timer(>send_timer, jiffies + HZ / 10);
}
 
+   spin_lock_irqsave(>lock, flags);
+   swap(data->skb, skb);
+   spin_unlock_irqrestore(>lock, flags);
+
+   return skb;
 }
 
-static void send_dm_alert(struct work_struct *unused)
+static void send_dm_alert(struct work_struct *work)
 {
struct sk_buff *skb;
-   struct per_cpu_dm_data *data = _cpu_var(dm_cpu_data);
+   struct per_cpu_dm_data *data;
 
-   WARN_ON_ONCE(data->cpu != smp_processor_id());
+   data = container_of(work, struct per_cpu_dm_data, dm_alert_work);
 
-   /*
-* Grab the skb we're about to send
-*/
-   skb = rcu_dereference_protected(data->skb, 1);
+   skb = reset_per_cpu_data(data);
 
-   /*
-* Replace it with a new one
-*/
-   reset_per_cpu_data(data);
-
-   /*
-* Ship it!
-*/
if (skb)
genlmsg_multicast(skb, 0, NET_DM_GRP_ALERT, GFP_KERNEL);
-
-   put_cpu_var(dm_cpu_data);
 }
 
 /*
  * This is the timer function to delay the sending of an alert
  * in the event that more drops will arrive during the
- * hysteresis period.  Note that it operates under the timer interrupt
- * so we don't need to 

[ 023/187] inetpeer: fix a race in inetpeer_gc_worker()

2012-07-12 Thread Greg Kroah-Hartman
From: Greg KH 

3.4-stable review patch.  If anyone has any objections, please let me know.

--


From: Eric Dumazet 

[ Upstream commit 55432d2b543a4b6dfae54f5c432a566877a85d90 ]

commit 5faa5df1fa2024 (inetpeer: Invalidate the inetpeer tree along with
the routing cache) added a race :

Before freeing an inetpeer, we must respect a RCU grace period, and make
sure no user will attempt to increase refcnt.

inetpeer_invalidate_tree() waits for a RCU grace period before inserting
inetpeer tree into gc_list and waking the worker. At that time, no
concurrent lookup can find a inetpeer in this tree.

Signed-off-by: Eric Dumazet 
Cc: Steffen Klassert 
Acked-by: Steffen Klassert 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 include/net/inetpeer.h |5 -
 net/ipv4/inetpeer.c|   16 
 2 files changed, 16 insertions(+), 5 deletions(-)

--- a/include/net/inetpeer.h
+++ b/include/net/inetpeer.h
@@ -40,7 +40,10 @@ struct inet_peer {
u32 pmtu_orig;
u32 pmtu_learned;
struct inetpeer_addr_base redirect_learned;
-   struct list_headgc_list;
+   union {
+   struct list_headgc_list;
+   struct rcu_head gc_rcu;
+   };
/*
 * Once inet_peer is queued for deletion (refcnt == -1), following 
fields
 * are not available: rid, ip_id_count, tcp_ts, tcp_ts_stamp
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -560,6 +560,17 @@ bool inet_peer_xrlim_allow(struct inet_p
 }
 EXPORT_SYMBOL(inet_peer_xrlim_allow);
 
+static void inetpeer_inval_rcu(struct rcu_head *head)
+{
+   struct inet_peer *p = container_of(head, struct inet_peer, gc_rcu);
+
+   spin_lock_bh(_lock);
+   list_add_tail(>gc_list, _list);
+   spin_unlock_bh(_lock);
+
+   schedule_delayed_work(_work, gc_delay);
+}
+
 void inetpeer_invalidate_tree(int family)
 {
struct inet_peer *old, *new, *prev;
@@ -576,10 +587,7 @@ void inetpeer_invalidate_tree(int family
prev = cmpxchg(>root, old, new);
if (prev == old) {
base->total = 0;
-   spin_lock(_lock);
-   list_add_tail(>gc_list, _list);
-   spin_unlock(_lock);
-   schedule_delayed_work(_work, gc_delay);
+   call_rcu(>gc_rcu, inetpeer_inval_rcu);
}
 
 out:


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


[ 025/187] l2tp: fix a race in l2tp_ip_sendmsg()

2012-07-12 Thread Greg Kroah-Hartman
From: Greg KH 

3.4-stable review patch.  If anyone has any objections, please let me know.

--


From: Eric Dumazet 

[ Upstream commit 4399a4df98a63e30fd16e9d0cecc46ea92269e8f ]

Commit 081b1b1bb27f (l2tp: fix l2tp_ip_sendmsg() route handling) added
a race, in case IP route cache is disabled.

In this case, we should not do the dst_release(>dst), since it'll
free the dst immediately, instead of waiting a RCU grace period.

Signed-off-by: Eric Dumazet 
Cc: James Chapman 
Cc: Denys Fedoryshchenko 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 net/l2tp/l2tp_ip.c |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

--- a/net/l2tp/l2tp_ip.c
+++ b/net/l2tp/l2tp_ip.c
@@ -516,10 +516,12 @@ static int l2tp_ip_sendmsg(struct kiocb
   sk->sk_bound_dev_if);
if (IS_ERR(rt))
goto no_route;
-   if (connected)
+   if (connected) {
sk_setup_caps(sk, >dst);
-   else
-   dst_release(>dst); /* safe since we hold 
rcu_read_lock */
+   } else {
+   skb_dst_set(skb, >dst);
+   goto xmit;
+   }
}
 
/* We dont need to clone dst here, it is guaranteed to not disappear.
@@ -527,6 +529,7 @@ static int l2tp_ip_sendmsg(struct kiocb
 */
skb_dst_set_noref(skb, >dst);
 
+xmit:
/* Queue the packet to IP for output */
rc = ip_queue_xmit(skb, >cork.fl);
rcu_read_unlock();


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


[ 027/187] lpc_eth: fix tx completion

2012-07-12 Thread Greg Kroah-Hartman
From: Greg KH 

3.4-stable review patch.  If anyone has any objections, please let me know.

--


From: Eric Dumazet 

[ Upstream commit 3f16da51b0e533871d22a29682f3c3969d4f7e22 ]

__lpc_handle_xmit() has two bugs :

1) It can leak skbs in case TXSTATUS_ERROR is set

2) It can wake up txqueue while no slot was freed.

Signed-off-by: Eric Dumazet 
Reported-by: Roland Stigge 
Tested-by: Roland Stigge 
Cc: Kevin Wells 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/net/ethernet/nxp/lpc_eth.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -936,16 +936,16 @@ static void __lpc_handle_xmit(struct net
/* Update stats */
ndev->stats.tx_packets++;
ndev->stats.tx_bytes += skb->len;
-
-   /* Free buffer */
-   dev_kfree_skb_irq(skb);
}
+   dev_kfree_skb_irq(skb);
 
txcidx = readl(LPC_ENET_TXCONSUMEINDEX(pldat->net_base));
}
 
-   if (netif_queue_stopped(ndev))
-   netif_wake_queue(ndev);
+   if (pldat->num_used_tx_buffs <= ENET_TX_DESC/2) {
+   if (netif_queue_stopped(ndev))
+   netif_wake_queue(ndev);
+   }
 }
 
 static int __lpc_handle_recv(struct net_device *ndev, int budget)


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


[ 030/187] ipv6: Move ipv6 proc file registration to end of init order

2012-07-12 Thread Greg Kroah-Hartman
From: Greg KH 

3.4-stable review patch.  If anyone has any objections, please let me know.

--


From: Thomas Graf 

[ Upstream commit d189634ecab947c10f6f832258b103d0bbfe73cc ]

/proc/net/ipv6_route reflects the contents of fib_table_hash. The proc
handler is installed in ip6_route_net_init() whereas fib_table_hash is
allocated in fib6_net_init() _after_ the proc handler has been installed.

This opens up a short time frame to access fib_table_hash with its pants
down.

Move the registration of the proc files to a later point in the init
order to avoid the race.

Tested :-)

Signed-off-by: Thomas Graf 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 net/ipv6/route.c |   41 +++--
 1 file changed, 31 insertions(+), 10 deletions(-)

--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2953,10 +2953,6 @@ static int __net_init ip6_route_net_init
net->ipv6.sysctl.ip6_rt_mtu_expires = 10*60*HZ;
net->ipv6.sysctl.ip6_rt_min_advmss = IPV6_MIN_MTU - 20 - 40;
 
-#ifdef CONFIG_PROC_FS
-   proc_net_fops_create(net, "ipv6_route", 0, _route_proc_fops);
-   proc_net_fops_create(net, "rt6_stats", S_IRUGO, _stats_seq_fops);
-#endif
net->ipv6.ip6_rt_gc_expire = 30*HZ;
 
ret = 0;
@@ -2977,10 +2973,6 @@ out_ip6_dst_ops:
 
 static void __net_exit ip6_route_net_exit(struct net *net)
 {
-#ifdef CONFIG_PROC_FS
-   proc_net_remove(net, "ipv6_route");
-   proc_net_remove(net, "rt6_stats");
-#endif
kfree(net->ipv6.ip6_null_entry);
 #ifdef CONFIG_IPV6_MULTIPLE_TABLES
kfree(net->ipv6.ip6_prohibit_entry);
@@ -2989,11 +2981,33 @@ static void __net_exit ip6_route_net_exi
dst_entries_destroy(>ipv6.ip6_dst_ops);
 }
 
+static int __net_init ip6_route_net_init_late(struct net *net)
+{
+#ifdef CONFIG_PROC_FS
+   proc_net_fops_create(net, "ipv6_route", 0, _route_proc_fops);
+   proc_net_fops_create(net, "rt6_stats", S_IRUGO, _stats_seq_fops);
+#endif
+   return 0;
+}
+
+static void __net_exit ip6_route_net_exit_late(struct net *net)
+{
+#ifdef CONFIG_PROC_FS
+   proc_net_remove(net, "ipv6_route");
+   proc_net_remove(net, "rt6_stats");
+#endif
+}
+
 static struct pernet_operations ip6_route_net_ops = {
.init = ip6_route_net_init,
.exit = ip6_route_net_exit,
 };
 
+static struct pernet_operations ip6_route_net_late_ops = {
+   .init = ip6_route_net_init_late,
+   .exit = ip6_route_net_exit_late,
+};
+
 static struct notifier_block ip6_route_dev_notifier = {
.notifier_call = ip6_route_dev_notify,
.priority = 0,
@@ -3043,19 +3057,25 @@ int __init ip6_route_init(void)
if (ret)
goto xfrm6_init;
 
+   ret = register_pernet_subsys(_route_net_late_ops);
+   if (ret)
+   goto fib6_rules_init;
+
ret = -ENOBUFS;
if (__rtnl_register(PF_INET6, RTM_NEWROUTE, inet6_rtm_newroute, NULL, 
NULL) ||
__rtnl_register(PF_INET6, RTM_DELROUTE, inet6_rtm_delroute, NULL, 
NULL) ||
__rtnl_register(PF_INET6, RTM_GETROUTE, inet6_rtm_getroute, NULL, 
NULL))
-   goto fib6_rules_init;
+   goto out_register_late_subsys;
 
ret = register_netdevice_notifier(_route_dev_notifier);
if (ret)
-   goto fib6_rules_init;
+   goto out_register_late_subsys;
 
 out:
return ret;
 
+out_register_late_subsys:
+   unregister_pernet_subsys(_route_net_late_ops);
 fib6_rules_init:
fib6_rules_cleanup();
 xfrm6_init:
@@ -3074,6 +3094,7 @@ out_kmem_cache:
 void ip6_route_cleanup(void)
 {
unregister_netdevice_notifier(_route_dev_notifier);
+   unregister_pernet_subsys(_route_net_late_ops);
fib6_rules_cleanup();
xfrm6_fini();
fib6_gc_cleanup();


--
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] extcon: Remove CONFIG_EXTCON_MODULE config to fix build break

2012-07-12 Thread Chanwoo Choi
On 07/13/2012 01:16 AM, Mark Brown wrote:

> On Thu, Jul 12, 2012 at 01:32:27PM +0900, Chanwoo Choi wrote:
>> This patch modify 'Kconfig' of EXTCON Subsystem to support either
>> active or inactive of EXTCON Subsystem. The various subsystem refer
>> to EXTCON subsystem for controlling external connector, so core class
>> of EXTCON should be included in kernel image. If EXTCON subsystem is
>> builded with MODULE, other subsystem have build break because of
>> linking the core class of EXTCON.
> 
> By this logic very little in the kernel should be a module.  We usually
> only force things to be built in if there's a technical need for it like
> init ordering constraints.  Generally this is just a case of making sure
> the Kconfig stuff is set up with appropriate dependencies.


As you said, I will fix it.

Thank you,
Chanwoo Choi
--
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 6/6] workqueue: reimplement WQ_HIGHPRI using a separate worker_pool

2012-07-12 Thread Tony Luck
On Thu, Jul 12, 2012 at 4:36 PM, Tejun Heo  wrote:
> The debug patch didn't do anything for the bug itself.  I suppose it's
> timing dependent and doesn't always happen (it never reproduces here
> for some reason).  Can you please repeat several times and see whether
> the warning can be triggered?

Still hasn't come back in three reboots.  I have to leave now, can continue
tomorrow.

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