Re: [PATCH v17 0/10] Add 32 bit VDSO time function support

2014-02-15 Thread Stefani Seibold
Am Samstag, den 15.02.2014, 20:14 -0800 schrieb H. Peter Anvin:
> On 02/15/2014 08:32 AM, Stefani Seibold wrote:
> > This patch add the functions vdso_gettimeofday(), vdso_clock_gettime()
> > and vdso_time() to the 32 bit VDSO.
> 
> x86-64 allyesconfig:
> 
>   AS  arch/x86/vdso/vdso32/int80.o
> /home/hpa/kernel/distwork/arch/x86/vdso/vdso32/../vclock_gettime.c:128:4: 
> warning:
> symbol 'hpet_page' was not declared
> . Should it be static?
> /home/hpa/kernel/distwork/arch/x86/vdso/vdso32/../vclock_gettime.c:134:33:
> warning: incorrect type in argument 1 (diff
> erent address spaces)
> /home/hpa/kernel/distwork/arch/x86/vdso/vdso32/../vclock_gettime.c:134:33:
>expected void const volatile [noderef] <
> asn:2>*addr
> /home/hpa/kernel/distwork/arch/x86/vdso/vdso32/../vclock_gettime.c:134:33:
>got unsigned char [toplevel] *
> /home/hpa/kernel/distwork/arch/x86/vdso/vdso32/../vclock_gettime.c:294:13:
> warning: symbol '__vdso_clock_gettime' was
> not declared. Should it be static?
> /home/hpa/kernel/distwork/arch/x86/vdso/vdso32/../vclock_gettime.c:322:13:
> warning: symbol '__vdso_gettimeofday' was n
> ot declared. Should it be static?
> /home/hpa/kernel/distwork/arch/x86/vdso/vdso32/../vclock_gettime.c:343:16:
> warning: symbol '__vdso_time' was not decla
> red. Should it be static?
>   CC  arch/x86/vdso/vdso32/vclock_gettime.o
> /home/hpa/kernel/distwork/arch/x86/vdso/vdso32/vclock_gettime.c:1:0:
> sorry, unimplemented: -mfentry isn’t supported fo
> r 32-bit in combination with -fpic
>  #define BUILD_VDSO32
>  ^
> make[4]: *** [arch/x86/vdso/vdso32/vclock_gettime.o] Error 1
> 
> 
> My patience is wearing really thin.  If I get another patchset that
> doesn't compile in allyesconfig, allmodconfig, allnoconfig and defconfig
> on both i386 and x86-64, I will put this patchset at the very bottom of
> my priority list.
> 
> I strongly suggest also installing sparse and compiling with C=1 and
> fixing all *those* warnings.
> 
> 

I am sorry to stress you patience, but i did not realized what you expected.

I will run with C=1 and fix all warnings.

- Stefani


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 6/6] mailbox: move the internal definitions into a private file

2014-02-15 Thread Jassi Brar
On Sun, Feb 16, 2014 at 12:46 AM, Greg KH  wrote:
> On Sat, Feb 15, 2014 at 11:57:02PM +0530, Jassi Brar wrote:
>> From: Suman Anna 
>>
>> This is needed for extracting the omap_mbox. The OMAP mailbox
>> code has a need for exporting some pre-existing API to not
>> break the current clients.
>>
>> Signed-off-by: Suman Anna 
>> ---
>>  drivers/mailbox/mailbox.c  | 62 +-
>>  drivers/mailbox/mailbox_internal.h | 77 
>> ++
>>  2 files changed, 78 insertions(+), 61 deletions(-)
>>  create mode 100644 drivers/mailbox/mailbox_internal.h
>
> Also, this patch doesn't seem to be needed at all here, nothing breaks
> without it, so why include it in this series?
>
Suman had to segregate the definitions temporarily while the TI
drivers were sorted out. I hope Suman says the patch isn't needed
anymore :)

Thanks,
Jassi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 2/6] mailbox: Introduce a new common API

2014-02-15 Thread Jassi Brar
[merging replies in one post]

On Sun, Feb 16, 2014 at 12:45 AM, Greg KH  wrote:
> On Sat, Feb 15, 2014 at 11:55:27PM +0530, Jassi Brar wrote:
>> +/*
>> + * Call for IPC controller drivers to register a controller, adding
>> + * its channels/mailboxes to the global pool.
>> + */
>> +int ipc_links_register(struct ipc_controller *ipc)
>> +{
>> + int i, num_links, txdone;
>> + struct ipc_chan *chan;
>> + struct ipc_con *con;
>> +
>> + /* Sanity check */
>> + if (!ipc || !ipc->ops)
>> + return -EINVAL;
>> +
>> + for (i = 0; ipc->links[i]; i++)
>> + ;
>> + if (!i)
>> + return -EINVAL;
>
> So you have to have links?  You should document this in the function
> definition.  Actually, why no kerneldoc for the public functions?
>
Yes a controller registers a bunch of links/mailboxes that can be used
by client drivers to send/recv messages. I'll add kerneldoc for the
api as well.

>> + num_links = i;
>> +
>> + mutex_lock(_mutex);
>> + /* Check if already populated */
>> + list_for_each_entry(con, _cons, node)
>> + if (!strcmp(ipc->controller_name, con->name)) {
>> + mutex_unlock(_mutex);
>> + return -EINVAL;
>> + }
>> + mutex_unlock(_mutex);
>
> Why drop the lock here?  Shouldn't you grab it for the whole function,
> as this could race if two callers want to register the same name.
>
Yes, thanks.

>> + con = kzalloc(sizeof(*con) + sizeof(*chan) * num_links, GFP_KERNEL);
>
> Are you ok with structures on unaligned boundries?  That might really
> slow down some processors if your pointers are unaligned...
>
OK, I'll align allocation.

>> + if (!con)
>> + return -ENOMEM;
>> +
>> + INIT_LIST_HEAD(>channels);
>> + snprintf(con->name, 16, "%s", ipc->controller_name);
>
> Magic name size :(
>
Yeah I know. I tried to keep the implementation simple.

>> +
>> + if (ipc->txdone_irq)
>> + txdone = TXDONE_BY_IRQ;
>> + else if (ipc->txdone_poll)
>> + txdone = TXDONE_BY_POLL;
>> + else /* It has to be ACK then */
>> + txdone = TXDONE_BY_ACK;
>> +
>> + if (txdone == TXDONE_BY_POLL) {
>> + con->period = ipc->txpoll_period;
>> + con->poll.function = _txdone;
>> + con->poll.data = (unsigned long)con;
>> + init_timer(>poll);
>> + }
>> +
>> + chan = (void *)con + sizeof(*con);
>> + for (i = 0; i < num_links; i++) {
>> + chan[i].con = con;
>> + chan[i].assigned = false;
>> + chan[i].link_ops = ipc->ops;
>> + chan[i].link = ipc->links[i];
>> + chan[i].txdone_method = txdone;
>> + chan[i].link->api_priv = [i];
>> + spin_lock_init([i].lock);
>> + BLOCKING_INIT_NOTIFIER_HEAD([i].avail);
>> + list_add_tail([i].node, >channels);
>> + snprintf(chan[i].name, 16, "%s", ipc->links[i]->link_name);
>
> Magic name size :(
>
"Controller:Link" specify the 32byte identity of a link.
I haven't yet opened the can of worms that is generic naming/identity
scheme like DMAEngine. Because the local controller and the remote f/w
together represents an entity that the local client driver deals
with so many common client drivers.are unlikely.

>> +
>> + return 0;
>> +}
>> +EXPORT_SYMBOL(ipc_links_register);
>> +
>> +void ipc_links_unregister(struct ipc_controller *ipc)
>> +{
>> + struct ipc_con *t, *con = NULL;
>> + struct ipc_chan *chan;
>> +
>> + mutex_lock(_mutex);
>> +
>> + list_for_each_entry(t, _cons, node)
>> + if (!strcmp(ipc->controller_name, t->name)) {
>> + con = t;
>> + break;
>> + }
>> +
>> + if (con)
>> + list_del(>node);
>> +
>> + mutex_unlock(_mutex);
>> +
>> + if (!con)
>> + return;
>> +
>> + list_for_each_entry(chan, >channels, node)
>> + ipc_free_channel((void *)chan);
>
> Why does this function take a void *?  Shouldn't it take a "real"
> structure pointer?
>
ipc_request/free_channel() is the api for client drivers. I have tried
to make the return channel opaque object to the clients and yet be
able to reuse the object within the api implementation. For that
reason we have mailbox_client.h and mailbox_controller.h so no side
can abuse what's on the other side. Only the api(mailbox.c) includes
both the headers.

>> +
>> + del_timer_sync(>poll);
>> +
>> + kfree(con);
>> +}
>> +EXPORT_SYMBOL(ipc_links_unregister);
>
>> +struct ipc_client {
>> + char *chan_name;
>> + void *cl_id;
>
> Why a void *?  Can't you have a "real" type here?
>
That is for client driver to specify how the controller driver is to
behave  the api simply passes it on to the underlying controller
driver. We couldn't have defined some global real type because the
same controller behaves differently if the remote f/w 

Re: [RFC PATCH] mm/vmscan: remove two un-needed mem_cgroup_page_lruvec() call

2014-02-15 Thread Hugh Dickins
On Sun, 16 Feb 2014, Weijie Yang wrote:
> On Sun, Feb 16, 2014 at 12:00 PM, Hugh Dickins  wrote:
> > On Sun, 16 Feb 2014, Weijie Yang wrote:
> >
> >> In putback_inactive_pages() and move_active_pages_to_lru(),
> >> lruvec is already an input parameter and pages are all from this lruvec,
> >> therefore there is no need to call mem_cgroup_page_lruvec() in loop.
> >>
> >> Signed-off-by: Weijie Yang 
> >
> > Looks plausible but I believe it's incorrect.  The lruvec passed in
> > is the one we took the pages from, but there's a small but real chance
> > that the page has become uncharged meanwhile, and should now be put back
> > on the root_mem_cgroup's lruvec instead of the original memcg's lruvec.
> 
> Hi Hugh,
> 
> Thanks for your review.
> Frankly speaking, I am not very sure about it, that is why I add a RFC tag 
> here.
> So,  do we need update the reclaim_stat meanwhile as we change the lruvec?

No, it's not worth bothering about, it's only for stats and this is an
unlikely case; whereas wrong memcg can be a significant correctness issue.

Hugh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 v6 2/8] clk: sunxi: Implement MMC phase control

2014-02-15 Thread David Lanzendörfer
From: Emilio López 

Signed-off-by: Emilio López 
---
 drivers/clk/sunxi/clk-sunxi.c |   35 +++
 1 file changed, 35 insertions(+)

diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index abb6c5a..33b9977 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -377,6 +377,41 @@ static void sun7i_a20_get_out_factors(u32 *freq, u32 
parent_rate,
 
 
 /**
+ * clk_sunxi_mmc_phase_control() - configures MMC clock phase control
+ */
+
+void clk_sunxi_mmc_phase_control(struct clk_hw *hw, u8 sample, u8 output)
+{
+   #define to_clk_composite(_hw) container_of(_hw, struct clk_composite, 
hw)
+   #define to_clk_factors(_hw) container_of(_hw, struct clk_factors, hw)
+
+   struct clk_composite *composite = to_clk_composite(hw);
+   struct clk_hw *rate_hw = composite->rate_hw;
+   struct clk_factors *factors = to_clk_factors(rate_hw);
+   unsigned long flags = 0;
+   u32 reg;
+
+   if (factors->lock)
+   spin_lock_irqsave(factors->lock, flags);
+
+   reg = readl(factors->reg);
+
+   /* set sample clock phase control */
+   reg &= ~(0x7 << 20);
+   reg |= ((sample & 0x7) << 20);
+
+   /* set output clock phase control */
+   reg &= ~(0x7 << 8);
+   reg |= ((output & 0x7) << 8);
+
+   writel(reg, factors->reg);
+
+   if (factors->lock)
+   spin_unlock_irqrestore(factors->lock, flags);
+}
+
+
+/**
  * sunxi_factors_clk_setup() - Setup function for factor clocks
  */
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 v6 5/8] ARM: dts: sun7i: Add support for mmc

2014-02-15 Thread David Lanzendörfer
Signed-off-by: David Lanzendörfer 
Signed-off-by: Hans de Goede 
---
 arch/arm/boot/dts/sun7i-a20-cubieboard2.dts |8 +++
 arch/arm/boot/dts/sun7i-a20-cubietruck.dts  |8 +++
 arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts |   23 +
 arch/arm/boot/dts/sun7i-a20.dtsi|   61 +++
 4 files changed, 100 insertions(+)

diff --git a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
index 5c51cb8..ae800b6 100644
--- a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
+++ b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
@@ -34,6 +34,14 @@
};
};
 
+   mmc0: mmc@01c0f000 {
+   pinctrl-names = "default", "default";
+   pinctrl-0 = <_pins_a>;
+   pinctrl-1 = <_cd_pin_reference_design>;
+   cd-gpios = < 7 1 0>; /* PH1 */
+   status = "okay";
+   };
+
pinctrl@01c20800 {
led_pins_cubieboard2: led_pins@0 {
allwinner,pins = "PH20", "PH21";
diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
index f9dcb61..370cef84 100644
--- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
+++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
@@ -19,6 +19,14 @@
compatible = "cubietech,cubietruck", "allwinner,sun7i-a20";
 
soc@01c0 {
+   mmc0: mmc@01c0f000 {
+   pinctrl-names = "default", "default";
+   pinctrl-0 = <_pins_a>;
+   pinctrl-1 = <_cd_pin_reference_design>;
+   cd-gpios = < 7 1 0>; /* PH1 */
+   status = "okay";
+   };
+
pinctrl@01c20800 {
led_pins_cubietruck: led_pins@0 {
allwinner,pins = "PH7", "PH11", "PH20", "PH21";
diff --git a/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts 
b/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts
index ead3013..685ec06 100644
--- a/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts
+++ b/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts
@@ -34,7 +34,30 @@
};
};
 
+   mmc0: mmc@01c0f000 {
+   pinctrl-names = "default", "default";
+   pinctrl-0 = <_pins_a>;
+   pinctrl-1 = <_cd_pin_reference_design>;
+   cd-gpios = < 7 1 0>; /* PH1 */
+   status = "okay";
+   };
+
+   mmc3: mmc@01c12000 {
+   pinctrl-names = "default", "default";
+   pinctrl-0 = <_pins_a>;
+   pinctrl-1 = <_cd_pin_olinuxinom>;
+   cd-gpios = < 7 11 0>; /* PH11 */
+   status = "okay";
+   };
+
pinctrl@01c20800 {
+   mmc3_cd_pin_olinuxinom: mmc3_cd_pin@0 {
+   allwinner,pins = "PH11";
+   allwinner,function = "gpio_in";
+   allwinner,drive = <0>;
+   allwinner,pull = <1>;
+   };
+
led_pins_olinuxino: led_pins@0 {
allwinner,pins = "PH2";
allwinner,function = "gpio_out";
diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi
index 9ff0948..5b55414 100644
--- a/arch/arm/boot/dts/sun7i-a20.dtsi
+++ b/arch/arm/boot/dts/sun7i-a20.dtsi
@@ -355,6 +355,46 @@
#size-cells = <0>;
};
 
+   mmc0: mmc@01c0f000 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c0f000 0x1000>;
+   clocks = <_gates 8>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <0 32 4>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
+   mmc1: mmc@01c1 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c1 0x1000>;
+   clocks = <_gates 9>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <0 33 4>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
+   mmc2: mmc@01c11000 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c11000 0x1000>;
+   clocks = <_gates 10>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <0 34 4>;
+   bus-width = <4>;
+   status = "disabled";
+  

[PATCH v6 4/8] ARM: sunxi: Add driver for SD/MMC hosts found on Allwinner sunxi SoCs

2014-02-15 Thread David Lanzendörfer
This is based on the driver Allwinner ships in their Android kernel sources.

Initial porting to upstream kernels done by David Lanzendörfer, additional
fixes and cleanups by Hans de Goede.

It uses dma in bus-master mode using a built-in designware idmac controller,
which is identical to the one found in the mmc-dw hosts.
The rest of the host is not identical to mmc-dw.

Signed-off-by: David Lanzendörfer 
Signed-off-by: Hans de Goede 
---
 drivers/mmc/host/Kconfig |7 
 drivers/mmc/host/Makefile|2 
 drivers/mmc/host/sunxi-mmc.c |  876 ++
 drivers/mmc/host/sunxi-mmc.h |  239 +++
 4 files changed, 1124 insertions(+)
 create mode 100644 drivers/mmc/host/sunxi-mmc.c
 create mode 100644 drivers/mmc/host/sunxi-mmc.h

diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 1384f67..7caf266 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -689,3 +689,10 @@ config MMC_REALTEK_PCI
help
  Say Y here to include driver code to support SD/MMC card interface
  of Realtek PCI-E card reader
+
+config MMC_SUNXI
+   tristate "Allwinner sunxi SD/MMC Host Controller support"
+   depends on ARCH_SUNXI
+   help
+ This selects support for the SD/MMC Host Controller on
+ Allwinner sunxi SoCs.
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index 3483b6b..f3c7c243 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -54,6 +54,8 @@ obj-$(CONFIG_MMC_WMT) += wmt-sdmmc.o
 
 obj-$(CONFIG_MMC_REALTEK_PCI)  += rtsx_pci_sdmmc.o
 
+obj-$(CONFIG_MMC_SUNXI)+= sunxi-mmc.o
+
 obj-$(CONFIG_MMC_SDHCI_PLTFM)  += sdhci-pltfm.o
 obj-$(CONFIG_MMC_SDHCI_CNS3XXX)+= sdhci-cns3xxx.o
 obj-$(CONFIG_MMC_SDHCI_ESDHC_IMX)  += sdhci-esdhc-imx.o
diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
new file mode 100644
index 000..2dc446c
--- /dev/null
+++ b/drivers/mmc/host/sunxi-mmc.c
@@ -0,0 +1,876 @@
+/*
+ * Driver for sunxi SD/MMC host controllers
+ * (C) Copyright 2014-2015 Reuuimlla Technology Co., Ltd.
+ * (C) Copyright 2014-2015 Aaron Maoye 
+ * (C) Copyright 2014-2015 O2S GmbH 
+ * (C) Copyright 2014-2015 David Lanzend�rfer 
+ * (C) Copyright 2014-2015 Hans de Goede 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "sunxi-mmc.h"
+
+static int sunxi_mmc_init_host(struct mmc_host *mmc)
+{
+   u32 rval;
+   struct sunxi_mmc_host *smc_host = mmc_priv(mmc);
+   int ret;
+
+   ret =  clk_prepare_enable(smc_host->clk_ahb);
+   if (ret) {
+   dev_err(mmc_dev(smc_host->mmc), "AHB clk err %d\n", ret);
+   return ret;
+   }
+   ret =  clk_prepare_enable(smc_host->clk_mod);
+   if (ret) {
+   dev_err(mmc_dev(smc_host->mmc), "MOD clk err %d\n", ret);
+   clk_disable_unprepare(smc_host->clk_ahb);
+   return ret;
+   }
+
+   /* reset controller */
+   rval = mci_readl(smc_host, REG_GCTRL) | SDXC_HARDWARE_RESET;
+   mci_writel(smc_host, REG_GCTRL, rval);
+
+   mci_writel(smc_host, REG_FTRGL, 0x20070008);
+   mci_writel(smc_host, REG_TMOUT, 0x);
+   mci_writel(smc_host, REG_IMASK, smc_host->sdio_imask);
+   mci_writel(smc_host, REG_RINTR, 0x);
+   mci_writel(smc_host, REG_DBGC, 0xdeb);
+   mci_writel(smc_host, REG_FUNS, 0xceaa);
+   mci_writel(smc_host, REG_DLBA, smc_host->sg_dma);
+   rval = mci_readl(smc_host, REG_GCTRL)|SDXC_INTERRUPT_ENABLE_BIT;
+   rval &= ~SDXC_ACCESS_DONE_DIRECT;
+   mci_writel(smc_host, REG_GCTRL, rval);
+
+   return 0;
+}
+
+static void sunxi_mmc_exit_host(struct sunxi_mmc_host *smc_host)
+{
+   mci_writel(smc_host, REG_GCTRL, SDXC_HARDWARE_RESET);
+   clk_disable_unprepare(smc_host->clk_ahb);
+   clk_disable_unprepare(smc_host->clk_mod);
+}
+
+/* /\* UHS-I Operation Modes */
+/*  * DS   25MHz   12.5MB/s3.3V */
+/*  * HS   50MHz   25MB/s  3.3V */
+/*  * SDR1225MHz   12.5MB/s1.8V */
+/*  * SDR2550MHz   25MB/s  1.8V */
+/*  * SDR50100MHz  50MB/s  1.8V */
+/*  * SDR104   208MHz  104MB/s 1.8V */
+/*  * DDR5050MHz   50MB/s  1.8V */
+/*  * MMC Operation Modes */
+/*  * DS   26MHz   26MB/s  3/1.8/1.2V */
+/*  * HS   52MHz   52MB/s  3/1.8/1.2V */

[PATCH v6 3/8] ARM: sunxi: clk: export clk_sunxi_mmc_phase_control

2014-02-15 Thread David Lanzendörfer
From: Hans de Goede 

Signed-off-by: Hans de Goede 
---
 include/linux/clk/sunxi.h |   22 ++
 1 file changed, 22 insertions(+)
 create mode 100644 include/linux/clk/sunxi.h

diff --git a/include/linux/clk/sunxi.h b/include/linux/clk/sunxi.h
new file mode 100644
index 000..1ef5c89
--- /dev/null
+++ b/include/linux/clk/sunxi.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2013 - Hans de Goede 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __LINUX_CLK_SUNXI_H_
+#define __LINUX_CLK_SUNXI_H_
+
+#include 
+
+void clk_sunxi_mmc_phase_control(struct clk_hw *hw, u8 sample, u8 output);
+
+#endif

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


[PATCH v6 7/8] ARM: dts: sun5i: Add support for mmc

2014-02-15 Thread David Lanzendörfer
Signed-off-by: David Lanzendörfer 
Signed-off-by: Hans de Goede 
---
 arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts |   30 +++
 arch/arm/boot/dts/sun5i-a10s.dtsi|   44 ++
 arch/arm/boot/dts/sun5i-a13-olinuxino-micro.dts  |   15 
 arch/arm/boot/dts/sun5i-a13-olinuxino.dts|   15 
 arch/arm/boot/dts/sun5i-a13.dtsi |   37 +++
 5 files changed, 141 insertions(+)

diff --git a/arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts 
b/arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts
index 3c9f8b3..5c7b454 100644
--- a/arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts
+++ b/arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts
@@ -34,7 +34,37 @@
};
};
 
+   mmc0: mmc@01c0f000 {
+   pinctrl-names = "default", "default";
+   pinctrl-0 = <_pins_a>;
+   pinctrl-1 = <_cd_pin_olinuxino_micro>;
+   cd-gpios = < 6 1 0>; /* PG1 */
+   status = "okay";
+   };
+
+   mmc1: mmc@01c1 {
+   pinctrl-names = "default", "default";
+   pinctrl-0 = <_pins_a>;
+   pinctrl-1 = <_cd_pin_olinuxino_micro>;
+   cd-gpios = < 6 13 0>; /* PG13 */
+   status = "okay";
+   };
+
pinctrl@01c20800 {
+   mmc0_cd_pin_olinuxino_micro: mmc0_cd_pin@0 {
+   allwinner,pins = "PG1";
+   allwinner,function = "gpio_in";
+   allwinner,drive = <0>;
+   allwinner,pull = <1>;
+   };
+
+   mmc1_cd_pin_olinuxino_micro: mmc1_cd_pin@0 {
+   allwinner,pins = "PG13";
+   allwinner,function = "gpio_in";
+   allwinner,drive = <0>;
+   allwinner,pull = <1>;
+   };
+
led_pins_olinuxino: led_pins@0 {
allwinner,pins = "PE3";
allwinner,function = "gpio_out";
diff --git a/arch/arm/boot/dts/sun5i-a10s.dtsi 
b/arch/arm/boot/dts/sun5i-a10s.dtsi
index 327e87b..b6d1de0 100644
--- a/arch/arm/boot/dts/sun5i-a10s.dtsi
+++ b/arch/arm/boot/dts/sun5i-a10s.dtsi
@@ -293,6 +293,36 @@
#size-cells = <0>;
};
 
+   mmc0: mmc@01c0f000 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c0f000 0x1000>;
+   clocks = <_gates 8>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <32>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
+   mmc1: mmc@01c1 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c1 0x1000>;
+   clocks = <_gates 9>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <33>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
+   mmc2: mmc@01c11000 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c11000 0x1000>;
+   clocks = <_gates 10>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <34>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
intc: interrupt-controller@01c20400 {
compatible = "allwinner,sun4i-ic";
reg = <0x01c20400 0x400>;
@@ -363,6 +393,20 @@
allwinner,drive = <0>;
allwinner,pull = <0>;
};
+
+   mmc0_pins_a: mmc0@0 {
+   allwinner,pins = 
"PF0","PF1","PF2","PF3","PF4","PF5";
+   allwinner,function = "mmc0";
+   allwinner,drive = <3>;
+   allwinner,pull = <0>;
+   };
+
+   mmc1_pins_a: mmc1@0 {
+   allwinner,pins = 
"PG3","PG4","PG5","PG6","PG7","PG8";
+   allwinner,function = "mmc1";
+   allwinner,drive = <3>;
+   allwinner,pull = <0>;
+   };
};
 
timer@01c20c00 {
diff --git a/arch/arm/boot/dts/sun5i-a13-olinuxino-micro.dts 
b/arch/arm/boot/dts/sun5i-a13-olinuxino-micro.dts
index fe2ce0a..2f08bb2 100644
--- 

[PATCH v6 8/8] ARM: sunxi: Add documentation for driver for SD/MMC hosts found on Allwinner sunxi SoCs

2014-02-15 Thread David Lanzendörfer
Signed-off-by: David Lanzendörfer 
---
 .../devicetree/bindings/mmc/sunxi-mmc.txt  |   32 
 1 file changed, 32 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/sunxi-mmc.txt

diff --git a/Documentation/devicetree/bindings/mmc/sunxi-mmc.txt 
b/Documentation/devicetree/bindings/mmc/sunxi-mmc.txt
new file mode 100644
index 000..5ce8c5e
--- /dev/null
+++ b/Documentation/devicetree/bindings/mmc/sunxi-mmc.txt
@@ -0,0 +1,32 @@
+* Allwinner sunxi MMC controller
+
+The highspeed MMC host controller on Allwinner SoCs provides an interface
+for MMC, SD and SDIO types of memory cards.
+
+Supported maximum speeds are the ones of the eMMC standard 4.5 as well
+as the speed of SD standard 3.0.
+Absolute maximum transfer rate is 200MB/s
+
+Required properties:
+- compatible: Should be "allwinner,--mmc".
+  The supported chips include a10, a10s, 13, a20 and a31.
+- base registers are 0x1000 appart, so the base of mmc1
+  would be 0x01c0f000+0x1000=0x01c1(see example)
+  and so on.
+- clocks requires the reference at the ahb clock gate
+  with the correct index (mmc0 -> 8, mmc1 -> 9, and so on)
+  as well as the reference to the correct mod0 clock.
+- interrupts requires the correct IRQ line
+  (mmc0 -> 32, mmc1 -> 33, and so on)
+
+Examples:
+
+mmc0: mmc@01c0f000 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c0f000 0x1000>;
+   clocks = <_gates 8>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <0 32 4>;
+   bus-width = <4>;
+   status = "disabled";
+};

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 v6 6/8] ARM: dts: sun4i: Add support for mmc

2014-02-15 Thread David Lanzendörfer
Signed-off-by: David Lanzendörfer 
Signed-off-by: Hans de Goede 
---
 arch/arm/boot/dts/sun4i-a10-a1000.dts  |8 
 arch/arm/boot/dts/sun4i-a10-cubieboard.dts |8 
 arch/arm/boot/dts/sun4i-a10.dtsi   |   54 
 3 files changed, 70 insertions(+)

diff --git a/arch/arm/boot/dts/sun4i-a10-a1000.dts 
b/arch/arm/boot/dts/sun4i-a10-a1000.dts
index d4b081d..a879ef3 100644
--- a/arch/arm/boot/dts/sun4i-a10-a1000.dts
+++ b/arch/arm/boot/dts/sun4i-a10-a1000.dts
@@ -35,6 +35,14 @@
};
};
 
+   mmc0: mmc@01c0f000 {
+   pinctrl-names = "default", "default";
+   pinctrl-0 = <_pins_a>;
+   pinctrl-1 = <_cd_pin_reference_design>;
+   cd-gpios = < 7 1 0>; /* PH1 */
+   status = "okay";
+   };
+
pinctrl@01c20800 {
emac_power_pin_a1000: emac_power_pin@0 {
allwinner,pins = "PH15";
diff --git a/arch/arm/boot/dts/sun4i-a10-cubieboard.dts 
b/arch/arm/boot/dts/sun4i-a10-cubieboard.dts
index b139ee6..20b976a 100644
--- a/arch/arm/boot/dts/sun4i-a10-cubieboard.dts
+++ b/arch/arm/boot/dts/sun4i-a10-cubieboard.dts
@@ -33,6 +33,14 @@
};
};
 
+   mmc0: mmc@01c0f000 {
+   pinctrl-names = "default", "default";
+   pinctrl-0 = <_pins_a>;
+   pinctrl-1 = <_cd_pin_reference_design>;
+   cd-gpios = < 7 1 0>; /* PH1 */
+   status = "okay";
+   };
+
pinctrl@01c20800 {
led_pins_cubieboard: led_pins@0 {
allwinner,pins = "PH20", "PH21";
diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
index 9044c53..cd14961 100644
--- a/arch/arm/boot/dts/sun4i-a10.dtsi
+++ b/arch/arm/boot/dts/sun4i-a10.dtsi
@@ -330,6 +330,46 @@
#size-cells = <0>;
};
 
+   mmc0: mmc@01c0f000 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c0f000 0x1000>;
+   clocks = <_gates 8>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <32>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
+   mmc1: mmc@01c1 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c1 0x1000>;
+   clocks = <_gates 9>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <33>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
+   mmc2: mmc@01c11000 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c11000 0x1000>;
+   clocks = <_gates 10>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <34>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
+   mmc3: mmc@01c12000 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c12000 0x1000>;
+   clocks = <_gates 11>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <35>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
intc: interrupt-controller@01c20400 {
compatible = "allwinner,sun4i-ic";
reg = <0x01c20400 0x400>;
@@ -400,6 +440,20 @@
allwinner,drive = <0>;
allwinner,pull = <0>;
};
+
+   mmc0_pins_a: mmc0@0 {
+   allwinner,pins = 
"PF0","PF1","PF2","PF3","PF4","PF5";
+   allwinner,function = "mmc0";
+   allwinner,drive = <3>;
+   allwinner,pull = <0>;
+   };
+
+   mmc0_cd_pin_reference_design: mmc0_cd_pin@0 {
+   allwinner,pins = "PH1";
+   allwinner,function = "gpio_in";
+   allwinner,drive = <0>;
+   allwinner,pull = <1>;
+   };
};
 
timer@01c20c00 {

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

[PATCH v6 0/8] ARM: sunxi: Add driver for SD/MMC hosts found on allwinner sunxi SOCs

2014-02-15 Thread David Lanzendörfer
Hello
The following patchset adds support for the SD/MMC host found in the Allwinner 
SoCs.
It contains all the necessary modifications for clock environment and also the 
device
tree script modification which add it to all the boards using it.
The clock environment function needed for phase offset configuration has
been proposed and implemented by Emilio.
A lot of work and cleanup has been done by Hans de Goede. Special thanks to him!
This patchset is the 4th attempt to send this driver upstream.

Changes since v1:
-Using mmc_of_parse instead of diy dt parsing
-Adding nodes for all mmc controller to the dtsi files,
 including sofar unused controllers
-Using generic GPIO slot library for WP/CD
-Adding additional MMC device nodes into DTSI files

Changes since v2:
-Add missing Signed-off-by tags
-Stop using __raw_readl / __raw_writel so that barriers are properly used
-Adding missing new lines
-Adding missing patch for automatic reparenting of clocks

Changes since v3:
-Move clk_enable / disable into host_init / exit (Hans)
-Fix hang on boot caused by irq storm (Hans)

Changes since v4:
-moving sunxi-mci.{c/h} to sunxi-mmc.{c/h}
-removing camel cases from the defines in  sunxi-mmc.h
-moving defines out of the struct definition
 since this is bad coding style
-adding documentation for the device tree binding

Changes since v5:
-adding host initialization for when the sdio irq is enabled
 (just to make sure having a defined state at all time)
-add mmc support fixup: set pullup on cd pins
-fixup: Don't set MMC_CAP_NEEDS_POLL /  MMC_CAP_4_BIT_DATA

---

David Lanzendörfer (5):
  ARM: sunxi: Add driver for SD/MMC hosts found on Allwinner sunxi SoCs
  ARM: dts: sun7i: Add support for mmc
  ARM: dts: sun4i: Add support for mmc
  ARM: dts: sun5i: Add support for mmc
  ARM: sunxi: Add documentation for driver for SD/MMC hosts found on 
Allwinner sunxi SoCs

Emilio López (2):
  clk: sunxi: factors: automatic reparenting support
  clk: sunxi: Implement MMC phase control

Hans de Goede (1):
  ARM: sunxi: clk: export clk_sunxi_mmc_phase_control


 .../devicetree/bindings/mmc/sunxi-mmc.txt  |   32 +
 arch/arm/boot/dts/sun4i-a10-a1000.dts  |8 
 arch/arm/boot/dts/sun4i-a10-cubieboard.dts |8 
 arch/arm/boot/dts/sun4i-a10.dtsi   |   54 +
 arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts   |   30 +
 arch/arm/boot/dts/sun5i-a10s.dtsi  |   44 +
 arch/arm/boot/dts/sun5i-a13-olinuxino-micro.dts|   15 
 arch/arm/boot/dts/sun5i-a13-olinuxino.dts  |   15 
 arch/arm/boot/dts/sun5i-a13.dtsi   |   37 +
 arch/arm/boot/dts/sun7i-a20-cubieboard2.dts|8 
 arch/arm/boot/dts/sun7i-a20-cubietruck.dts |8 
 arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts|   23 +
 arch/arm/boot/dts/sun7i-a20.dtsi   |   61 +
 drivers/clk/sunxi/clk-factors.c|   36 +
 drivers/clk/sunxi/clk-sunxi.c  |   35 +
 drivers/mmc/host/Kconfig   |7 
 drivers/mmc/host/Makefile  |2 
 drivers/mmc/host/sunxi-mmc.c   |  876 
 drivers/mmc/host/sunxi-mmc.h   |  239 +
 include/linux/clk/sunxi.h  |   22 +
 20 files changed, 1560 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/sunxi-mmc.txt
 create mode 100644 drivers/mmc/host/sunxi-mmc.c
 create mode 100644 drivers/mmc/host/sunxi-mmc.h
 create mode 100644 include/linux/clk/sunxi.h

-- 
Signature
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 v6 1/8] clk: sunxi: factors: automatic reparenting support

2014-02-15 Thread David Lanzendörfer
From: Emilio López 

This commit implements .determine_rate, so that our factor clocks can be
reparented when needed.

Signed-off-by: Emilio López 
---
 drivers/clk/sunxi/clk-factors.c |   36 
 1 file changed, 36 insertions(+)

diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c
index 9e23264..3806d97 100644
--- a/drivers/clk/sunxi/clk-factors.c
+++ b/drivers/clk/sunxi/clk-factors.c
@@ -77,6 +77,41 @@ static long clk_factors_round_rate(struct clk_hw *hw, 
unsigned long rate,
return rate;
 }
 
+static long clk_factors_determine_rate(struct clk_hw *hw, unsigned long rate,
+  unsigned long *best_parent_rate,
+  struct clk **best_parent_p)
+{
+   struct clk *clk = hw->clk, *parent, *best_parent = NULL;
+   int i, num_parents;
+   unsigned long parent_rate, best = 0, child_rate, best_child_rate = 0;
+
+   /* find the parent that can help provide the fastest rate <= rate */
+   num_parents = __clk_get_num_parents(clk);
+   for (i = 0; i < num_parents; i++) {
+   parent = clk_get_parent_by_index(clk, i);
+   if (!parent)
+   continue;
+   if (__clk_get_flags(clk) & CLK_SET_RATE_PARENT)
+   parent_rate = __clk_round_rate(parent, rate);
+   else
+   parent_rate = __clk_get_rate(parent);
+
+   child_rate = clk_factors_round_rate(hw, rate, _rate);
+
+   if (child_rate <= rate && child_rate > best_child_rate) {
+   best_parent = parent;
+   best = parent_rate;
+   best_child_rate = child_rate;
+   }
+   }
+
+   if (best_parent)
+   *best_parent_p = best_parent;
+   *best_parent_rate = best;
+
+   return best_child_rate;
+}
+
 static int clk_factors_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
 {
@@ -113,6 +148,7 @@ static int clk_factors_set_rate(struct clk_hw *hw, unsigned 
long rate,
 }
 
 const struct clk_ops clk_factors_ops = {
+   .determine_rate = clk_factors_determine_rate,
.recalc_rate = clk_factors_recalc_rate,
.round_rate = clk_factors_round_rate,
.set_rate = clk_factors_set_rate,

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] mm/vmscan: remove two un-needed mem_cgroup_page_lruvec() call

2014-02-15 Thread Weijie Yang
On Sun, Feb 16, 2014 at 12:00 PM, Hugh Dickins  wrote:
> On Sun, 16 Feb 2014, Weijie Yang wrote:
>
>> In putback_inactive_pages() and move_active_pages_to_lru(),
>> lruvec is already an input parameter and pages are all from this lruvec,
>> therefore there is no need to call mem_cgroup_page_lruvec() in loop.
>>
>> Signed-off-by: Weijie Yang 
>
> Looks plausible but I believe it's incorrect.  The lruvec passed in
> is the one we took the pages from, but there's a small but real chance
> that the page has become uncharged meanwhile, and should now be put back
> on the root_mem_cgroup's lruvec instead of the original memcg's lruvec.

Hi Hugh,

Thanks for your review.
Frankly speaking, I am not very sure about it, that is why I add a RFC tag here.
So,  do we need update the reclaim_stat meanwhile as we change the lruvec?

Regards,

> Hugh
>
>> ---
>>  mm/vmscan.c |3 ---
>>  1 file changed, 3 deletions(-)
>>
>> diff --git a/mm/vmscan.c b/mm/vmscan.c
>> index a9c74b4..4804fdb 100644
>> --- a/mm/vmscan.c
>> +++ b/mm/vmscan.c
>> @@ -1393,8 +1393,6 @@ putback_inactive_pages(struct lruvec *lruvec, struct 
>> list_head *page_list)
>>   continue;
>>   }
>>
>> - lruvec = mem_cgroup_page_lruvec(page, zone);
>> -
>>   SetPageLRU(page);
>>   lru = page_lru(page);
>>   add_page_to_lru_list(page, lruvec, lru);
>> @@ -1602,7 +1600,6 @@ static void move_active_pages_to_lru(struct lruvec 
>> *lruvec,
>>
>>   while (!list_empty(list)) {
>>   page = lru_to_page(list);
>> - lruvec = mem_cgroup_page_lruvec(page, zone);
>>
>>   VM_BUG_ON_PAGE(PageLRU(page), page);
>>   SetPageLRU(page);
>> --
>> 1.7.10.4
>>
>>
>> --
>> To unsubscribe, send a message with 'unsubscribe linux-mm' in
>> the body to majord...@kvack.org.  For more info on Linux MM,
>> see: http://www.linux-mm.org/ .
>> Don't email: mailto:"d...@kvack.org;> em...@kvack.org 
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Openipmi-developer] [PATCH] ipmi: fix BT reset for a while when cmd timeout

2014-02-15 Thread Corey Minyard
I don't really understand the error that is happening.  I see that it
continues to time out, but I don't know why.  If you can get in to this
situation here, it makes me worried that there is some other issue. 
issuing the warm reset, even if the command is not supported, should be
harmless.  Maybe the warm reset actually happens and it takes longer
than 5 seconds?

The following patch is certainly not the right fix.  I would actually
prefer to just remove the reset operation from the driver, but I'd
really like to fix the fundamental issue.  To me this looks like a bug
in the BMC.

I'm copying Rocky Craig, who wrote this state machine.

-corey

On 02/11/2014 04:26 AM, Xie XiuQi wrote:
> I fould a problem: when a cmd timeout and just
> in that time bt->seq < 2, system will alway keep
> retrying and we can't send any cmd to bmc.
>
> the error message is like this:
> [  530.908621] IPMI BT: timeout in RD_WAIT [ ] 1 retries left
> [  582.661329] IPMI BT: timeout in RD_WAIT [ ]
> [  582.661334] failed 2 retries, sending error response
> [  582.661337] IPMI: BT reset (takes 5 secs)
> [  693.335307] IPMI BT: timeout in RD_WAIT [ ]
> [  693.335312] failed 2 retries, sending error response
> [  693.335315] IPMI: BT reset (takes 5 secs)
> [  804.825161] IPMI BT: timeout in RD_WAIT [ ]
> [  804.825166] failed 2 retries, sending error response
> [  804.825169] IPMI: BT reset (takes 5 secs)
> ...
>
> When BT reset, a cmd "warm reset" will be sent to bmc, but this cmd
> is Optional in spec(refer to ipmi-interface-spec-v2). Some machines
> don't support this cmd.
>
> So, bt->init is introduced. Only during insmod, we do BT reset when
> response timeout to avoid system crash.
>
> Reported-by: Hu Shiyuan 
> Signed-off-by: Xie XiuQi 
> Cc: sta...@vger.kernel.org# 3.4+
> ---
>  drivers/char/ipmi/ipmi_bt_sm.c | 9 +++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c
> index a22a7a5..b4a7b2a 100644
> --- a/drivers/char/ipmi/ipmi_bt_sm.c
> +++ b/drivers/char/ipmi/ipmi_bt_sm.c
> @@ -107,6 +107,7 @@ struct si_sm_data {
>   int BT_CAP_outreqs;
>   longBT_CAP_req2rsp;
>   int BT_CAP_retries; /* Recommended retries */
> + int init;
>  };
>
>  #define BT_CLR_WR_PTR0x01/* See IPMI 1.5 table 11.6.4 */
> @@ -438,8 +439,8 @@ static enum si_sm_result error_recovery(struct si_sm_data 
> *bt,
>   if (!bt->nonzero_status)
>   printk(KERN_ERR "IPMI BT: stuck, try power cycle\n");
>
> - /* this is most likely during insmod */
> - else if (bt->seq <= (unsigned char)(bt->BT_CAP_retries & 0xFF)) {
> + /* only during insmod */
> + else if (!bt->init) {
>   printk(KERN_WARNING "IPMI: BT reset (takes 5 secs)\n");
>   bt->state = BT_STATE_RESET1;
>   return SI_SM_CALL_WITHOUT_DELAY;
> @@ -589,6 +590,10 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, 
> long time)
>   BT_STATE_CHANGE(BT_STATE_READ_WAIT,
>   SI_SM_CALL_WITHOUT_DELAY);
>   bt->state = bt->complete;
> +
> + if (!bt->init && bt->seq)
> + bt->init = 1;
> +
>   return bt->state == BT_STATE_IDLE ? /* where to next? */
>   SI_SM_TRANSACTION_COMPLETE :/* normal */
>   SI_SM_CALL_WITHOUT_DELAY;   /* Startup magic */

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 v17 0/10] Add 32 bit VDSO time function support

2014-02-15 Thread H. Peter Anvin
On 02/15/2014 08:32 AM, Stefani Seibold wrote:
> This patch add the functions vdso_gettimeofday(), vdso_clock_gettime()
> and vdso_time() to the 32 bit VDSO.

x86-64 allyesconfig:

  AS  arch/x86/vdso/vdso32/int80.o
/home/hpa/kernel/distwork/arch/x86/vdso/vdso32/../vclock_gettime.c:128:4: 
warning:
symbol 'hpet_page' was not declared
. Should it be static?
/home/hpa/kernel/distwork/arch/x86/vdso/vdso32/../vclock_gettime.c:134:33:
warning: incorrect type in argument 1 (diff
erent address spaces)
/home/hpa/kernel/distwork/arch/x86/vdso/vdso32/../vclock_gettime.c:134:33:
   expected void const volatile [noderef] <
asn:2>*addr
/home/hpa/kernel/distwork/arch/x86/vdso/vdso32/../vclock_gettime.c:134:33:
   got unsigned char [toplevel] *
/home/hpa/kernel/distwork/arch/x86/vdso/vdso32/../vclock_gettime.c:294:13:
warning: symbol '__vdso_clock_gettime' was
not declared. Should it be static?
/home/hpa/kernel/distwork/arch/x86/vdso/vdso32/../vclock_gettime.c:322:13:
warning: symbol '__vdso_gettimeofday' was n
ot declared. Should it be static?
/home/hpa/kernel/distwork/arch/x86/vdso/vdso32/../vclock_gettime.c:343:16:
warning: symbol '__vdso_time' was not decla
red. Should it be static?
  CC  arch/x86/vdso/vdso32/vclock_gettime.o
/home/hpa/kernel/distwork/arch/x86/vdso/vdso32/vclock_gettime.c:1:0:
sorry, unimplemented: -mfentry isn’t supported fo
r 32-bit in combination with -fpic
 #define BUILD_VDSO32
 ^
make[4]: *** [arch/x86/vdso/vdso32/vclock_gettime.o] Error 1


My patience is wearing really thin.  If I get another patchset that
doesn't compile in allyesconfig, allmodconfig, allnoconfig and defconfig
on both i386 and x86-64, I will put this patchset at the very bottom of
my priority list.

I strongly suggest also installing sparse and compiling with C=1 and
fixing all *those* warnings.

Sorry.

-hpa

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] mm/vmscan: remove two un-needed mem_cgroup_page_lruvec() call

2014-02-15 Thread Hugh Dickins
On Sun, 16 Feb 2014, Weijie Yang wrote:

> In putback_inactive_pages() and move_active_pages_to_lru(),
> lruvec is already an input parameter and pages are all from this lruvec,
> therefore there is no need to call mem_cgroup_page_lruvec() in loop.
> 
> Signed-off-by: Weijie Yang 

Looks plausible but I believe it's incorrect.  The lruvec passed in
is the one we took the pages from, but there's a small but real chance
that the page has become uncharged meanwhile, and should now be put back
on the root_mem_cgroup's lruvec instead of the original memcg's lruvec.

Hugh

> ---
>  mm/vmscan.c |3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index a9c74b4..4804fdb 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1393,8 +1393,6 @@ putback_inactive_pages(struct lruvec *lruvec, struct 
> list_head *page_list)
>   continue;
>   }
>  
> - lruvec = mem_cgroup_page_lruvec(page, zone);
> -
>   SetPageLRU(page);
>   lru = page_lru(page);
>   add_page_to_lru_list(page, lruvec, lru);
> @@ -1602,7 +1600,6 @@ static void move_active_pages_to_lru(struct lruvec 
> *lruvec,
>  
>   while (!list_empty(list)) {
>   page = lru_to_page(list);
> - lruvec = mem_cgroup_page_lruvec(page, zone);
>  
>   VM_BUG_ON_PAGE(PageLRU(page), page);
>   SetPageLRU(page);
> -- 
> 1.7.10.4
> 
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majord...@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: mailto:"d...@kvack.org;> em...@kvack.org 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Updated Link-Time-Optimization patchkit

2014-02-15 Thread Andi Kleen
On Sat, Feb 15, 2014 at 10:24:43PM +0100, Sam Ravnborg wrote:
> Hi Andi.
> 
> On Sat, Feb 15, 2014 at 06:44:24PM +0100, Andi Kleen wrote:
> > On Sat, Feb 15, 2014 at 02:38:14PM +0100, Markus Trippelsdorf wrote:
> > > On 2014.02.14 at 22:21 +0100, Andi Kleen wrote:
> > > > This is the updated LTO patchkit for 3.14-rc2.  LTO allows
> > > > the compiler to do global optimization over the whole kernel.
> > > 
> > > It is mildly annoying that one couldn't use vanilla binutils. Have you
> > > already opened bugs on sourceware.org/bugzilla/ to get this fixed for
> > > gold and ld.bfd?
> > 
> > The problem is supporting "pass through" of both pure (.S) assembler code 
> > and
> > LTO through ld -r, because the kernel makefiles use ld -r heavily.
> > Standard binutils would throw all the assembler away when in plugin LTO
> > mode.
> 
> Long time ago I looked at eliminating the use of -r in the kernel build.
> I lost the patch - but the attached patch managed to build
> a "make defconfig; make" kernel.
> 
> I have not event tried boot with this - it only managed to build!
> 
> What the patch does is for each directory visited a built-in.link file is 
> created
> which is really a linker script.
> It uses INPUT (file file file) to specify all the object files.
> And in the final link the files are all read and the link is performed.
> 
> This limit the depth to 10 levels due to a restriction in ld.
> The binutils people have suggested some other methods that I did not look 
> into.
> 
> Half of the patch is fixes to the security makefiles which I
> will submit anyway as this needs to be cleaned up indendent on
> this patch.
> 
> The patch drops $(cmd_secanalysis) because I did not look into this.
> 
> If this could make it easier to enable LTO then this would be
> a nice win.

I gave it a quick try and it failed like below with LTO

Right now using the Linux binutils is ok for me.

-Andi


+ ld -m elf_x86_64 -r -o vmlinux.o arch/x86/kernel/head_64.o
arch/x86/kernel/head64.o arch/x86/kernel/head.o init/built-in.link
--start-group usr/built-in.link arch/x86/built-in.link
kernel/built-in.link mm/built-in.link fs/built-in.link ipc/built-in.link
security/built-in.link crypto/built-in.link block/built-in.link
lib/lib.a arch/x86/lib/lib.a lib/built-in.link
arch/x86/lib/built-in.link drivers/built-in.link sound/built-in.link
firmware/built-in.link arch/x86/pci/built-in.link
arch/x86/oprofile/built-in.link arch/x86/power/built-in.link
arch/x86/video/built-in.link net/built-in.link --end-group
lib/lib.a: could not read symbols: Bad value

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


[RFC PATCH] mm/vmscan: remove two un-needed mem_cgroup_page_lruvec() call

2014-02-15 Thread Weijie Yang
In putback_inactive_pages() and move_active_pages_to_lru(),
lruvec is already an input parameter and pages are all from this lruvec,
therefore there is no need to call mem_cgroup_page_lruvec() in loop.

Signed-off-by: Weijie Yang 
---
 mm/vmscan.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index a9c74b4..4804fdb 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1393,8 +1393,6 @@ putback_inactive_pages(struct lruvec *lruvec, struct 
list_head *page_list)
continue;
}
 
-   lruvec = mem_cgroup_page_lruvec(page, zone);
-
SetPageLRU(page);
lru = page_lru(page);
add_page_to_lru_list(page, lruvec, lru);
@@ -1602,7 +1600,6 @@ static void move_active_pages_to_lru(struct lruvec 
*lruvec,
 
while (!list_empty(list)) {
page = lru_to_page(list);
-   lruvec = mem_cgroup_page_lruvec(page, zone);
 
VM_BUG_ON_PAGE(PageLRU(page), page);
SetPageLRU(page);
-- 
1.7.10.4


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


[PATCH] perf: tools: fix missing casts for printf arguments.

2014-02-15 Thread Adam Borowski
Because of -Werror, they caused build failure at least on x32, as time_t
is of different size than "unsigned long".  In another place, __suseconds_t
is not compatible with "long int".

Signed-off-by: Adam Borowski 
---
 tools/perf/bench/sched-messaging.c | 4 ++--
 tools/perf/bench/sched-pipe.c  | 4 ++--
 tools/perf/builtin-kvm.c   | 2 +-
 tools/perf/builtin-stat.c  | 3 ++-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/tools/perf/bench/sched-messaging.c 
b/tools/perf/bench/sched-messaging.c
index cc1190a..6595e2f 100644
--- a/tools/perf/bench/sched-messaging.c
+++ b/tools/perf/bench/sched-messaging.c
@@ -318,11 +318,11 @@ int bench_sched_messaging(int argc, const char **argv,
   num_groups, num_groups * 2 * num_fds,
   thread_mode ? "threads" : "processes");
printf(" %14s: %lu.%03lu [sec]\n", "Total time",
-  diff.tv_sec,
+  (unsigned long) diff.tv_sec,
   (unsigned long) (diff.tv_usec/1000));
break;
case BENCH_FORMAT_SIMPLE:
-   printf("%lu.%03lu\n", diff.tv_sec,
+   printf("%lu.%03lu\n", (unsigned long) diff.tv_sec,
   (unsigned long) (diff.tv_usec/1000));
break;
default:
diff --git a/tools/perf/bench/sched-pipe.c b/tools/perf/bench/sched-pipe.c
index 07a8d76..d7c1df4 100644
--- a/tools/perf/bench/sched-pipe.c
+++ b/tools/perf/bench/sched-pipe.c
@@ -157,7 +157,7 @@ int bench_sched_pipe(int argc, const char **argv, const 
char *prefix __maybe_unu
result_usec += diff.tv_usec;
 
printf(" %14s: %lu.%03lu [sec]\n\n", "Total time",
-  diff.tv_sec,
+  (unsigned long) diff.tv_sec,
   (unsigned long) (diff.tv_usec/1000));
 
printf(" %14lf usecs/op\n",
@@ -169,7 +169,7 @@ int bench_sched_pipe(int argc, const char **argv, const 
char *prefix __maybe_unu
 
case BENCH_FORMAT_SIMPLE:
printf("%lu.%03lu\n",
-  diff.tv_sec,
+  (unsigned long) diff.tv_sec,
   (unsigned long) (diff.tv_usec / 1000));
break;
 
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index a735051..b470f0f 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -730,7 +730,7 @@ static void show_timeofday(void)
gettimeofday(, NULL);
if (localtime_r(_sec, )) {
strftime(date, sizeof(date), "%H:%M:%S", );
-   pr_info("%s.%06ld", date, tv.tv_usec);
+   pr_info("%s.%06ld", date, (long int) tv.tv_usec);
} else
pr_info("00:00:00.00");
 
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 8b0e1c9..26cfc12 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -455,7 +455,8 @@ static void print_interval(void)
 
clock_gettime(CLOCK_MONOTONIC, );
diff_timespec(, , _time);
-   sprintf(prefix, "%6lu.%09lu%s", rs.tv_sec, rs.tv_nsec, csv_sep);
+   sprintf(prefix, "%6lu.%09lu%s", (unsigned long) rs.tv_sec,
+   (unsigned long) rs.tv_nsec, csv_sep);
 
if (num_print_interval == 0 && !csv_output) {
switch (aggr_mode) {
-- 
1.9.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] vt: detect and ignore OSC codes.

2014-02-15 Thread Adam Borowski
On Thu, Feb 13, 2014 at 10:39:12AM -0800, Greg Kroah-Hartman wrote:
> On Wed, Jan 15, 2014 at 07:21:04AM +0100, Adam Borowski wrote:
> > These can be used to send commands consisting of an arbitrary string to the
> > terminal, most often used to set a terminal's window title or to redefine
> > the colour palette.  Our console doesn't use OSC, unlike everything else,
> > which can lead to junk being displayed if a process sends such a code
> > unconditionally.
> > 
> > Not following Ecma-48, this commit recognizes 7-bit forms (ESC ] ... 0x07,
> > ESC ] .. ESC \) but not 8-bit (0x9D ... 0x9C).
> > 
> > Signed-off-by: Adam Borowski 
> 
> Where is this documented?

It's a mix of Ecma-48 and undocumented practice.  Ecma-48 says:

# 8.3.89
#   OSC - OPERATING SYSTEM COMMAND
#   Notation: (C1)
#   Representation: 0x9D or ESC 0x5D (])
#
#   OSC is used as the opening delimiter of a control string for operating
#   system use.  The command string following may consist of a sequence of
#   bit combinations in the range 0x08 to 0x0D and 0x20 to 0x7E.  The
#   control string is closed by the terminating delimiter STRING TERMINATOR
#   (ST).  The interpretation of the command string depends on the relevant
#   operating system.

# 8.3.143
#   ST - STRING TERMINATOR
#   Notation: (C1)
#   Representation: 0x9C or ESC 0x5C (\)
#
#   ST is used as the closing delimiter of a control string opened by
#   APPLICATION PROGRAM COMMAND (APC), DEVICE CONTROL STRING (DCS),
#   OPERATING SYSTEM COMMAND (OSC), PRIVACY MESSAGE (PM), or START OF STRING
#   (SOS).

... which doesn't define the behaviour for characters 0x00..0x07, 0x0E..0x1F
or 0x7F..0xFF.  Somehow, using 0x07 for termination became a widespread
idiom, used more often than proper ESC \.  For this reason, implementations
I know all recognize 0x07 as a terminator.  The behaviour for other
characters differs, ie, is truly undefined.

As, unlike what Ecma-48 says, using 8-bit characters in a window title is a
reasonable thing to do, I'd allow 0x80..0xFF as non-terminators.  I have no
idea what to do with remaining control characters: the current patch allows
them to be interpreted, as it's usually the case for control characters
inside terminal codes.  I did not research other implementation here.

I did not recognize 0x9C as ST for two reasons: 1. it'd break non-ASCII
characters that happen to include this byte, and 2. Linux already fails to
recognize 8-bit control codes (with one exception: 0x9B stands for ESC [).


Should I put the above explanation somewhere?  As a comment?  In the commit
message?  Or does it need to be elaborated even further?

> > ---
> >  drivers/tty/vt/vt.c | 14 +++---
> >  1 file changed, 11 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
> > index 61b1137..0377c52 100644
> > --- a/drivers/tty/vt/vt.c
> > +++ b/drivers/tty/vt/vt.c
> > @@ -1590,7 +1590,7 @@ static void restore_cur(struct vc_data *vc)
> >  
> >  enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey,
> > EShash, ESsetG0, ESsetG1, ESpercent, ESignore, ESnonstd,
> > -   ESpalette };
> > +   ESpalette, ESosc };
> >  
> >  /* console_lock is held (except via vc_init()) */
> >  static void reset_terminal(struct vc_data *vc, int do_clear)
> > @@ -1650,11 +1650,15 @@ static void do_con_trol(struct tty_struct *tty, 
> > struct vc_data *vc, int c)
> >  *  Control characters can be used in the _middle_
> >  *  of an escape sequence.
> >  */
> > +   if (vc->vc_state == ESosc && c>=8 && c<=13) /* ... except for OSC */
> > +   return;
> > switch (c) {
> > case 0:
> > return;
> > case 7:
> > -   if (vc->vc_bell_duration)
> > +   if (vc->vc_state == ESosc)
> > +   vc->vc_state = ESnormal;
> > +   else if (vc->vc_bell_duration)
> > kd_mksound(vc->vc_bell_pitch, vc->vc_bell_duration);
> > return;
> > case 8:
> > @@ -1765,7 +1769,9 @@ static void do_con_trol(struct tty_struct *tty, 
> > struct vc_data *vc, int c)
> > } else if (c=='R') {   /* reset palette */
> > reset_palette(vc);
> > vc->vc_state = ESnormal;
> > -   } else
> > +   } else if (c>='0' && c<='9')
> > +   vc->vc_state = ESosc;
> > +   else
> > vc->vc_state = ESnormal;
> > return;
> > case ESpalette:
> > @@ -2023,6 +2029,8 @@ static void do_con_trol(struct tty_struct *tty, 
> > struct vc_data *vc, int c)
> > return;
> > default:
> > vc->vc_state = ESnormal;
> > +   case ESosc:
> > +   return;
> 
> Why below the default: case?

Just to shave a line and a return statement.  From your objection, I guess
this goes against the coding standards, right?


Meow!
-- 
A tit a day keeps the vet away.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to 

[PATCH 1/1] fs/mpage.c: forgotten WRITE_SYNC in case of data integrity write

2014-02-15 Thread Roman Pen
In case of wbc->sync_mode == WB_SYNC_ALL we need to do data integrity write,
thus mark request as WRITE_SYNC.

Signed-off-by: Roman Pen 
CC: Alexander Viro 
CC: linux-fsde...@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 fs/mpage.c | 23 +++
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/fs/mpage.c b/fs/mpage.c
index 4979ffa..4e0af5a 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -462,6 +462,7 @@ static int __mpage_writepage(struct page *page, struct 
writeback_control *wbc,
struct buffer_head map_bh;
loff_t i_size = i_size_read(inode);
int ret = 0;
+   int wr = (wbc->sync_mode == WB_SYNC_ALL ?  WRITE_SYNC : WRITE);
 
if (page_has_buffers(page)) {
struct buffer_head *head = page_buffers(page);
@@ -570,7 +571,7 @@ page_is_mapped:
 * This page will go to BIO.  Do we need to send this BIO off first?
 */
if (bio && mpd->last_block_in_bio != blocks[0] - 1)
-   bio = mpage_bio_submit(WRITE, bio);
+   bio = mpage_bio_submit(wr, bio);
 
 alloc_new:
if (bio == NULL) {
@@ -587,7 +588,7 @@ alloc_new:
 */
length = first_unmapped << blkbits;
if (bio_add_page(bio, page, length, 0) < length) {
-   bio = mpage_bio_submit(WRITE, bio);
+   bio = mpage_bio_submit(wr, bio);
goto alloc_new;
}
 
@@ -620,7 +621,7 @@ alloc_new:
set_page_writeback(page);
unlock_page(page);
if (boundary || (first_unmapped != blocks_per_page)) {
-   bio = mpage_bio_submit(WRITE, bio);
+   bio = mpage_bio_submit(wr, bio);
if (boundary_block) {
write_boundary_block(boundary_bdev,
boundary_block, 1 << blkbits);
@@ -632,7 +633,7 @@ alloc_new:
 
 confused:
if (bio)
-   bio = mpage_bio_submit(WRITE, bio);
+   bio = mpage_bio_submit(wr, bio);
 
if (mpd->use_writepage) {
ret = mapping->a_ops->writepage(page, wbc);
@@ -688,8 +689,11 @@ mpage_writepages(struct address_space *mapping,
};
 
ret = write_cache_pages(mapping, wbc, __mpage_writepage, );
-   if (mpd.bio)
-   mpage_bio_submit(WRITE, mpd.bio);
+   if (mpd.bio) {
+   int wr = (wbc->sync_mode == WB_SYNC_ALL ?
+ WRITE_SYNC : WRITE);
+   mpage_bio_submit(wr, mpd.bio);
+   }
}
blk_finish_plug();
return ret;
@@ -706,8 +710,11 @@ int mpage_writepage(struct page *page, get_block_t 
get_block,
.use_writepage = 0,
};
int ret = __mpage_writepage(page, wbc, );
-   if (mpd.bio)
-   mpage_bio_submit(WRITE, mpd.bio);
+   if (mpd.bio) {
+   int wr = (wbc->sync_mode == WB_SYNC_ALL ?
+ WRITE_SYNC : WRITE);
+   mpage_bio_submit(wr, mpd.bio);
+   }
return ret;
 }
 EXPORT_SYMBOL(mpage_writepage);
-- 
1.8.5.2

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


Re: [PATCH 2/2] memcg: barriers to see memcgs as fully initialized

2014-02-15 Thread Hugh Dickins
On Thu, 13 Feb 2014, Michal Hocko wrote:
> On Wed 12-02-14 17:29:09, Hugh Dickins wrote:
> > Commit d8ad30559715 ("mm/memcg: iteration skip memcgs not yet fully
> > initialized") is not bad, but Greg Thelen asks "Are barriers needed?"
> > 
> > Yes, I'm afraid so: this makes it a little heavier than the original,
> > but there's no point in guaranteeing that mem_cgroup_iter() returns only
> > fully initialized memcgs, if we don't guarantee that the initialization
> > is visible.
> > 
> > If we move online_css()'s setting CSS_ONLINE after rcu_assign_pointer()
> > (I don't see why not), we can reasonably rely on the smp_wmb() in that.
> > But I can't find a pre-existing barrier at the mem_cgroup_iter() end,
> > so add an smp_rmb() where __mem_cgroup_iter_next() returns non-NULL.
> > 
> > Fixes: d8ad30559715 ("mm/memcg: iteration skip memcgs not yet fully 
> > initialized")
> > Signed-off-by: Hugh Dickins 
> > Cc: sta...@vger.kernel.org # 3.12+
> > ---
> > I'd have been happier not to have to add this patch: maybe you can see
> > a better placement, or a way we can avoid this altogether.
> 
> I don't know. I have thought about this again and I really do not see
> why we have to provide such a guarantee, to be honest.
> 
> Such a half initialized memcg wouldn't see its hierarchical parent
> properly (including inheritted attributes) and it wouldn't have kmem
> fully initialized. But it also wouldn't have any tasks in it IIRC so it
> shouldn't matter much.
> 
> So I really don't know whether this all is worth all the troubles. 
> I am not saying your patch is wrong (although I am not sure whether
> css->flags vs. subsystem css association ordering is relevant and
> ae7f164a09408 changelog didn't help me much) and it made sense when
> you proposed it back then but the additional ordering requirements
> complicates the thing.

Your feelings match mine exactly: nice enough when it was just a matter
of testing a flag, but rather a bore to have to go adding barriers.
And Tejun didn't like it either, would prefer the barriers to be
internal to memcg, if we really need them.

No surprise: it's why I made it an easily skippable 2/2.
Let's forget this patch - but I still don't want to remove the
CSS_ONLINE check, not yet anyway.

At the time I added that check, I only had out-of-tree changes
and lockdep weirdness in support of it.  I did spend a little time
yesterday looking to see if there's a stronger case, thought I'd
found one, but looking again don't see it - I think I was muddling
stats with RES_USAGE.

The kind of case I was looking for was stats gathering doing a
res_counter_read_u64() inside a for_each_mem_cgroup() loop.  On
a 32-bit kernel, res_counter_read_u64() has to use the spinlock
which is not initialized until mem_cgroup_css_online().  Which
it should manage with unadorned ticket lock, but then the unlock
might race with its initialization (I'm not sure how that will
then behave).  But actually I don't think stats gathering ever
does iterative res_counter_reads (and there may be good design
reasons why that would never make sense).

Now I do see the existing mem_cgroup_soft_reclaim() doing a 
res_counter_soft_limit_excess() in a mem_cgroup_iter() loop:
I guess that is vulnerable, even on 64-bit, and a lot safer
with the CSS_ONLINE check, even lacking barriers.

I'm thinking that we'd be safer if those res_counters
initialized in mem_cgroup_css_online() could be initialized in
mem_cgroup_css_alloc(), then updated in mem_cgroup_css_online();
but I don't think res_counter.c offers that option today,
not to change parent (or could parent be set from the start?
maybe that gets into races with setting use_hierarchy).

I haven't looked into what memcg_init_kmem() gets up to,
and whether that's safe before it's initialized.

Not something urgent I'm intending to rush into, and please don't
feel you need rush to respond, these are just thoughts for later:
let's move away from the CSS_ONLINE check and barriers, and
towards having the struct mem_cgroup sensibly initialized earlier.

Hugh

> 
> I will keep thinking about that.
> 
> >  kernel/cgroup.c |8 +++-
> >  mm/memcontrol.c |   11 +--
> >  2 files changed, 16 insertions(+), 3 deletions(-)
> > 
> > --- 3.14-rc2+/kernel/cgroup.c   2014-02-02 18:49:07.737302111 -0800
> > +++ linux/kernel/cgroup.c   2014-02-12 11:59:52.804041895 -0800
> > @@ -4063,9 +4063,15 @@ static int online_css(struct cgroup_subs
> > if (ss->css_online)
> > ret = ss->css_online(css);
> > if (!ret) {
> > -   css->flags |= CSS_ONLINE;
> > css->cgroup->nr_css++;
> > rcu_assign_pointer(css->cgroup->subsys[ss->subsys_id], css);
> > +   /*
> > +* Set CSS_ONLINE after rcu_assign_pointer(), so that its
> > +* smp_wmb() will guarantee that those seeing CSS_ONLINE
> > +* can see the initialization done in ss->css_online() - if
> > +* they provide an smp_rmb(), as in 

Re: [BUG] unable to handle kernel NULL pointer dereference

2014-02-15 Thread John




- Original Message -
> From: Borislav Petkov <>
> Sent: Saturday, February 15, 2014 6:25 PM
> Subject: Re: [BUG] unable to handle kernel NULL pointer dereference
> 
> On Sat, Feb 15, 2014 at 01:04:22PM -0800, John wrote:
>>  Thanks for the reply, Boris.  The .config is unmodified
>>  from the Arch Distro default for 3.13.3-1 which can be found
>>  here: http://pastebin.com/LPGZ8ZqA
> 
> Yep, it is that struct net *net argument to put_pipe_version() which is NULL:
> 
>   12:   55                      push   %ebp
>   13:   89 e5                   mov    %esp,%ebp
>   15:   56                      push   %esi
>   16:   53                      push   %ebx
>   17:   3e 8d 74 26 00          lea    %ds:0x0(%esi,%eiz,1),%esi
>   1c:   8b 1d 28 e9 a3 f8       mov    0xf8a3e928,%ebx
>   22:   89 c6                   mov    %eax,%esi
>   24:   e8 59 64 5f c8          call   0xc85f6482
>   29:   85 db                   test   %ebx,%ebx
>   2b:*  8b 86 58 08 00 00       mov    0x858(%esi),%eax         <-- trapping 
> instruction
> 
> put_pipe_version:
>     pushl    %ebp    #
>     movl    %esp, %ebp    #,
>     pushl    %esi    #
>     pushl    %ebx    #
>     call    mcount
>     movl    sunrpc_net_id, %ebx    # sunrpc_net_id, sunrpc_net_id.130
>     movl    %eax, %esi    # net, net
>     call    __rcu_read_lock    #
>     testl    %ebx, %ebx    # sunrpc_net_id.130
>     movl    2136(%esi), %eax    # MEM[(struct net_generic * const *)net_4(D) 
> + 
> 2136B], ng <-- trapping insn
> 
> 
>     [ 137.689996] ESI:  EDI: f56efc00 EBP: f568fee8 ESP: f568fee0
>                
> 
> Here's the c/asm interleaved version:
> 
> static void put_pipe_version(struct net *net)
> {
>      d80:       55                      push   %ebp
>      d81:       89 e5                   mov    %esp,%ebp
>      d83:       56                      push   %esi
>      d84:       53                      push   %ebx
>      d85:       e8 fc ff ff ff          call   d86 
>                         d86: R_386_PC32 mcount
>         struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
>      d8a:       8b 1d 00 00 00 00       mov    0x0,%ebx
>                         d8c: R_386_32   sunrpc_net_id
>         spin_unlock(_version_lock);
>         return ret;
> }
> 
> static void put_pipe_version(struct net *net)
> {
>      d90:       89 c6                   mov    %eax,%esi
> * block, but only when acquiring spinlocks that are subject to priority
> * inheritance.
> */
> static inline void rcu_read_lock(void)
> {
>         __rcu_read_lock();
>      d92:       e8 fc ff ff ff          call   d93 
>                         d93: R_386_PC32 __rcu_read_lock
>         struct net_generic *ng;
>         void *ptr;
> 
>         rcu_read_lock();
>         ng = rcu_dereference(net->gen);
>         BUG_ON(id == 0 || id > ng->len);
>      d97:       85 db                   test   %ebx,%ebx
> {
>         struct net_generic *ng;
>         void *ptr;
> 
>         rcu_read_lock();
>         ng = rcu_dereference(net->gen);
>      d99:       8b 86 58 08 00 00       mov    0x858(%esi),%eax            
> <-- trapping insn
> 
> 
> I guess you could avoid the crash if you did
> 
>     if (!net)
>         return;
> 
> in put_pipe_version() but this hardly is the right solution. Someone
> else has to make sense of this thing, not me. :-)
> 
> HTH.


I copy someone you cc'ed on this understands it.  I have no idea what you wrote 
:)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 1/3] regmap: Separate regmap dev initialization

2014-02-15 Thread Mark Brown
On Mon, Feb 10, 2014 at 04:22:33PM +0100, Michal Simek wrote:
> Create special function regmap_attach_dev
> which can be called separately out of regmap_init.

Applied, thanks.  I've pushed a signed tag too so dependencies can pull
this in:

  git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git tags/nodev

When sending things like this that add new functionality it's often
helpful to send the patches adding users to review along with the core
patch since this helps to review if the usage is actually sane and
sensible.  From a purely regmap point of view this seems OK but...


signature.asc
Description: Digital signature


Re: [PATCH 05/11] vfs: Add a function to lazily unmount all mounts from any dentry.

2014-02-15 Thread Eric W. Biederman
ebied...@xmission.com (Eric W. Biederman) writes:

> v2: Always drop the lock when exiting early.
> v3: Make detach_mounts robust about freeing several
> mounts on the same mountpoint at one time, and remove
> the unneeded mnt_list list test.
> v4: Document the purpose of detach_mounts and why new_mountpoint is
> safe to call.
>
> Signed-off-by: Eric W. Biederman 
> ---
>  fs/mount.h |2 ++
>  fs/namespace.c |   39 +++
>  2 files changed, 41 insertions(+), 0 deletions(-)
>
> diff --git a/fs/mount.h b/fs/mount.h
> index 50a72d46e7a6..2b470f34e665 100644
> --- a/fs/mount.h
> +++ b/fs/mount.h
> @@ -84,6 +84,8 @@ extern struct mount *__lookup_mnt_last(struct vfsmount *, 
> struct dentry *);
>  
>  extern bool legitimize_mnt(struct vfsmount *, unsigned);
>  
> +extern void detach_mounts(struct dentry *dentry);

After Linus's rant about performance I took a second look, and lo and
behold there is a significant optimization oppportunity missed here.

This should almost certainly be:

extern void __detach_mounts(struct dentry *dentry);

static inline void detach_mounts(struct dentry *dentry)
{
if (unlikely(d_mountpoint(dentry)))
return;
__detach_mounts(dentry);
}

Just so I don't take the namespace lock when not necessary.

Although wether this should be inline or at the start of detach_mounts
and out of line I don't know.  Sigh.  I will have to play with this
detail a bit more.

Eric



>  static inline void get_mnt_ns(struct mnt_namespace *ns)
>  {
>   atomic_inc(>count);
> diff --git a/fs/namespace.c b/fs/namespace.c
> index 33db9e95bd5c..7abbf722ce18 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -1359,6 +1359,45 @@ static int do_umount(struct mount *mnt, int flags)
>   return retval;
>  }
>  
> +/*
> + * detach_mounts - lazily unmount all mounts on the specified dentry
> + *
> + * During unlink, rmdir, and d_drop it is possible to loose the path
> + * to an existing mountpoint, and wind up leaking the mount.
> + * detach_mounts allows lazily unmounting those mounts instead of
> + * leaking them.
> + * 
> + * The caller may hold dentry->d_inode->i_mutex.
> + */
> +void detach_mounts(struct dentry *dentry)
> +{
> + struct mountpoint *mp;
> + struct mount *mnt;
> +
> + namespace_lock();
> + if (!d_mountpoint(dentry))
> + goto out_unlock;
> +
> + /* 
> +  * The namespace lock and d_mountpoint being set guarantees
> +  * that new_mountpoint will just be a lookup of the existing
> +  * mountpoint structure.
> +  */
> + mp = new_mountpoint(dentry);
> + if (IS_ERR(mp))
> + goto out_unlock;
> +
> + lock_mount_hash();
> + while (!list_empty(>m_list)) {
> + mnt = list_first_entry(>m_list, struct mount, mnt_mp_list);
> + umount_tree(mnt, 1);
> + }
> + unlock_mount_hash();
> + put_mountpoint(mp);
> +out_unlock:
> + namespace_unlock();
> +}
> +
>  /* 
>   * Is the caller allowed to modify his namespace?
>   */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[GIT PULL] DeviceTree fixes for 3.14

2014-02-15 Thread Rob Herring
Linus,

Please pull another set of DT fixes to fix booting on some PPC boards.

Rob


The following changes since commit 860a445c25aa2f99aa5881603a1f4ed2cec64025:

  DT: Add vendor prefix for Spansion Inc. (2014-02-05 10:39:17 -0600)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git
tags/dt-fixes-for-3.14

for you to fetch changes up to 06b29e76a74b2373e6f8b5a7938b3630b9ae98b2:

  of: search the best compatible match first in __of_match_node()
(2014-02-15 18:51:17 -0600)


DeviceTree fixes for 3.14:

- Fix booting on PPC boards. Changes to of_match_node matching caused
  the serial port on some PPC boards to stop working. Reverted the
  change and reimplement to split matching between new style compatible
  only matching and fallback to old matching algorithm.


Kevin Hao (2):
  Revert "OF: base: match each node compatible against all given
matches first"
  of: search the best compatible match first in __of_match_node()

 drivers/of/base.c | 88 ++-
 1 file changed, 54 insertions(+), 34 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 02/11] vfs: More precise tests in d_invalidate

2014-02-15 Thread Eric W. Biederman
Linus Torvalds  writes:

> On Sat, Feb 15, 2014 at 3:23 PM, Eric W. Biederman
>  wrote:
>>
>> Except that today d_invalidate drops the dcache lock and
>> calls shrink_dcache_parent.  Which gets you into exactly the same
>> complex "walk parents and check all siblings" code.
>
> Hmm. It only does that for directories that have sub-entries, though.
>
> I think you may care just about directories (because that's what your
> series is about), but d_invalidate() is used for other cases too,
> notably d_revalidate() (ie things like stale NFS lookups of normal
> files).
>
> That said, I'll have to think about this more. If d_subdir is empty, I
> guess d_walk() will be fairly cheap. It's very different, but maybe
> not as disastrous as I thought.

Thank you for taking the time to look.

It is also very true that I have been mostly focusing on the semantics
and correctness rather than on the performance of these changes.

I did keep a weather eye on the performance impact of these changes
though and as long as we can stand a slow down in the rare case where
mount points are present my changes should be fine.

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


Re: [PATCH 02/11] vfs: More precise tests in d_invalidate

2014-02-15 Thread Linus Torvalds
On Sat, Feb 15, 2014 at 3:23 PM, Eric W. Biederman
 wrote:
>
> Except that today d_invalidate drops the dcache lock and
> calls shrink_dcache_parent.  Which gets you into exactly the same
> complex "walk parents and check all siblings" code.

Hmm. It only does that for directories that have sub-entries, though.

I think you may care just about directories (because that's what your
series is about), but d_invalidate() is used for other cases too,
notably d_revalidate() (ie things like stale NFS lookups of normal
files).

That said, I'll have to think about this more. If d_subdir is empty, I
guess d_walk() will be fairly cheap. It's very different, but maybe
not as disastrous as I thought.

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


[PATCH net-next 4/4] bonding: Convert memcpy(foo, bar, ETH_ALEN) to ether_addr_copy(foo, bar)

2014-02-15 Thread Joe Perches
ether_addr_copy is smaller and faster for some architectures.

This relies on a stack frame being at least __aligned(2)
for one use of an Ethernet address on the stack.

Signed-off-by: Joe Perches 
---
 drivers/net/bonding/bond_3ad.c  |  8 
 drivers/net/bonding/bond_alb.c  | 30 +++---
 drivers/net/bonding/bond_main.c | 12 ++--
 3 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index f6eda2d..e9edd84 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -768,11 +768,11 @@ static int ad_lacpdu_send(struct port *port)
 
lacpdu_header = (struct lacpdu_header *)skb_put(skb, length);
 
-   memcpy(lacpdu_header->hdr.h_dest, lacpdu_mcast_addr, ETH_ALEN);
+   ether_addr_copy(lacpdu_header->hdr.h_dest, lacpdu_mcast_addr);
/* Note: source address is set to be the member's PERMANENT address,
 * because we use it to identify loopback lacpdus in receive.
 */
-   memcpy(lacpdu_header->hdr.h_source, slave->perm_hwaddr, ETH_ALEN);
+   ether_addr_copy(lacpdu_header->hdr.h_source, slave->perm_hwaddr);
lacpdu_header->hdr.h_proto = PKT_TYPE_LACPDU;
 
lacpdu_header->lacpdu = port->lacpdu;
@@ -810,11 +810,11 @@ static int ad_marker_send(struct port *port, struct 
bond_marker *marker)
 
marker_header = (struct bond_marker_header *)skb_put(skb, length);
 
-   memcpy(marker_header->hdr.h_dest, lacpdu_mcast_addr, ETH_ALEN);
+   ether_addr_copy(marker_header->hdr.h_dest, lacpdu_mcast_addr);
/* Note: source address is set to be the member's PERMANENT address,
 * because we use it to identify loopback MARKERs in receive.
 */
-   memcpy(marker_header->hdr.h_source, slave->perm_hwaddr, ETH_ALEN);
+   ether_addr_copy(marker_header->hdr.h_source, slave->perm_hwaddr);
marker_header->hdr.h_proto = PKT_TYPE_LACPDU;
 
marker_header->marker = *marker;
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index e9f0a98..538913e 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -333,7 +333,7 @@ static void rlb_update_entry_from_arp(struct bonding *bond, 
struct arp_pkt *arp)
(client_info->ip_dst == arp->ip_src) &&
(!ether_addr_equal_64bits(client_info->mac_dst, arp->mac_src))) {
/* update the clients MAC address */
-   memcpy(client_info->mac_dst, arp->mac_src, ETH_ALEN);
+   ether_addr_copy(client_info->mac_dst, arp->mac_src);
client_info->ntt = 1;
bond_info->rx_ntt = 1;
}
@@ -669,9 +669,9 @@ static struct slave *rlb_choose_channel(struct sk_buff 
*skb, struct bonding *bon
/* the entry is already assigned to this client */
if (!ether_addr_equal_64bits(arp->mac_dst, mac_bcast)) {
/* update mac address from arp */
-   memcpy(client_info->mac_dst, arp->mac_dst, 
ETH_ALEN);
+   ether_addr_copy(client_info->mac_dst, 
arp->mac_dst);
}
-   memcpy(client_info->mac_src, arp->mac_src, ETH_ALEN);
+   ether_addr_copy(client_info->mac_src, arp->mac_src);
 
assigned_slave = client_info->slave;
if (assigned_slave) {
@@ -711,8 +711,8 @@ static struct slave *rlb_choose_channel(struct sk_buff 
*skb, struct bonding *bon
 * will be updated with clients actual unicast mac address
 * upon receiving an arp reply.
 */
-   memcpy(client_info->mac_dst, arp->mac_dst, ETH_ALEN);
-   memcpy(client_info->mac_src, arp->mac_src, ETH_ALEN);
+   ether_addr_copy(client_info->mac_dst, arp->mac_dst);
+   ether_addr_copy(client_info->mac_src, arp->mac_src);
client_info->slave = assigned_slave;
 
if (!ether_addr_equal_64bits(client_info->mac_dst, mac_bcast)) {
@@ -763,7 +763,7 @@ static struct slave *rlb_arp_xmit(struct sk_buff *skb, 
struct bonding *bond)
*/
tx_slave = rlb_choose_channel(skb, bond);
if (tx_slave)
-   memcpy(arp->mac_src, tx_slave->dev->dev_addr, ETH_ALEN);
+   ether_addr_copy(arp->mac_src, tx_slave->dev->dev_addr);
pr_debug("Server sent ARP Reply packet\n");
} else if (arp->op_code == htons(ARPOP_REQUEST)) {
/* Create an entry in the rx_hashtbl for this client as a
@@ -1003,8 +1003,8 @@ static void alb_send_lp_vid(struct slave *slave, u8 
mac_addr[],
char *data;
 
memset(, 0, size);
-   memcpy(pkt.mac_dst, mac_addr, ETH_ALEN);
-   memcpy(pkt.mac_src, mac_addr, ETH_ALEN);
+   ether_addr_copy(pkt.mac_dst, mac_addr);

[PATCH net-next 3/4] bonding: Convert c99 comments

2014-02-15 Thread Joe Perches
Neatening only.

Signed-off-by: Joe Perches 
---
 drivers/net/bonding/bond_3ad.h | 175 -
 1 file changed, 87 insertions(+), 88 deletions(-)

diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h
index 13dc9d3..3b97fe48 100644
--- a/drivers/net/bonding/bond_3ad.h
+++ b/drivers/net/bonding/bond_3ad.h
@@ -28,7 +28,7 @@
 #include 
 #include 
 
-// General definitions
+/* General definitions */
 #define PKT_TYPE_LACPDU cpu_to_be16(ETH_P_SLOW)
 #define AD_TIMER_INTERVAL   100 /*msec*/
 
@@ -47,54 +47,54 @@ enum {
BOND_AD_COUNT = 2,
 };
 
-// rx machine states(43.4.11 in the 802.3ad standard)
+/* rx machine states(43.4.11 in the 802.3ad standard) */
 typedef enum {
AD_RX_DUMMY,
-   AD_RX_INITIALIZE, // rx Machine
-   AD_RX_PORT_DISABLED,  // rx Machine
-   AD_RX_LACP_DISABLED,  // rx Machine
-   AD_RX_EXPIRED,// rx Machine
-   AD_RX_DEFAULTED,  // rx Machine
-   AD_RX_CURRENT // rx Machine
+   AD_RX_INITIALIZE,   /* rx Machine */
+   AD_RX_PORT_DISABLED,/* rx Machine */
+   AD_RX_LACP_DISABLED,/* rx Machine */
+   AD_RX_EXPIRED,  /* rx Machine */
+   AD_RX_DEFAULTED,/* rx Machine */
+   AD_RX_CURRENT   /* rx Machine */
 } rx_states_t;
 
-// periodic machine states(43.4.12 in the 802.3ad standard)
+/* periodic machine states(43.4.12 in the 802.3ad standard) */
 typedef enum {
AD_PERIODIC_DUMMY,
-   AD_NO_PERIODIC,// periodic machine
-   AD_FAST_PERIODIC,  // periodic machine
-   AD_SLOW_PERIODIC,  // periodic machine
-   AD_PERIODIC_TX // periodic machine
+   AD_NO_PERIODIC, /* periodic machine */
+   AD_FAST_PERIODIC,   /* periodic machine */
+   AD_SLOW_PERIODIC,   /* periodic machine */
+   AD_PERIODIC_TX  /* periodic machine */
 } periodic_states_t;
 
-// mux machine states(43.4.13 in the 802.3ad standard)
+/* mux machine states(43.4.13 in the 802.3ad standard) */
 typedef enum {
AD_MUX_DUMMY,
-   AD_MUX_DETACHED,   // mux machine
-   AD_MUX_WAITING,// mux machine
-   AD_MUX_ATTACHED,   // mux machine
-   AD_MUX_COLLECTING_DISTRIBUTING // mux machine
+   AD_MUX_DETACHED,/* mux machine */
+   AD_MUX_WAITING, /* mux machine */
+   AD_MUX_ATTACHED,/* mux machine */
+   AD_MUX_COLLECTING_DISTRIBUTING  /* mux machine */
 } mux_states_t;
 
-// tx machine states(43.4.15 in the 802.3ad standard)
+/* tx machine states(43.4.15 in the 802.3ad standard) */
 typedef enum {
AD_TX_DUMMY,
-   AD_TRANSMIT// tx Machine
+   AD_TRANSMIT /* tx Machine */
 } tx_states_t;
 
-// rx indication types
+/* rx indication types */
 typedef enum {
-   AD_TYPE_LACPDU = 1,// type lacpdu
-   AD_TYPE_MARKER // type marker
+   AD_TYPE_LACPDU = 1, /* type lacpdu */
+   AD_TYPE_MARKER  /* type marker */
 } pdu_type_t;
 
-// rx marker indication types
+/* rx marker indication types */
 typedef enum {
-   AD_MARKER_INFORMATION_SUBTYPE = 1, // marker imformation subtype
-   AD_MARKER_RESPONSE_SUBTYPE // marker response subtype
+   AD_MARKER_INFORMATION_SUBTYPE = 1,  /* marker imformation subtype */
+   AD_MARKER_RESPONSE_SUBTYPE  /* marker response subtype */
 } bond_marker_subtype_t;
 
-// timers types(43.4.9 in the 802.3ad standard)
+/* timers types(43.4.9 in the 802.3ad standard) */
 typedef enum {
AD_CURRENT_WHILE_TIMER,
AD_ACTOR_CHURN_TIMER,
@@ -105,35 +105,35 @@ typedef enum {
 
 #pragma pack(1)
 
-// Link Aggregation Control Protocol(LACP) data unit structure(43.4.2.2 in the 
802.3ad standard)
+/* Link Aggregation Control Protocol(LACP) data unit structure(43.4.2.2 in the 
802.3ad standard) */
 typedef struct lacpdu {
-   u8 subtype;  // = LACP(= 0x01)
+   u8 subtype; /* = LACP(= 0x01) */
u8 version_number;
-   u8 tlv_type_actor_info;   // = actor information(type/length/value)
-   u8 actor_information_length; // = 20
+   u8 tlv_type_actor_info; /* = actor information(type/length/value) */
+   u8 actor_information_length;/* = 20 */
__be16 actor_system_priority;
struct mac_addr actor_system;
__be16 actor_key;
__be16 actor_port_priority;
__be16 actor_port;
u8 actor_state;
-   u8 reserved_3_1[3];  // = 0
-   u8 tlv_type_partner_info; // = partner information
-   u8 partner_information_length;   // = 20
+   u8 reserved_3_1[3]; /* = 0 */
+   u8 tlv_type_partner_info;   /* = partner information */
+   u8 partner_information_length;  /* = 20 */
__be16 partner_system_priority;
struct mac_addr partner_system;
__be16 partner_key;
__be16 partner_port_priority;
__be16 

[PATCH net-next 2/4] bonding: Neaten pr_

2014-02-15 Thread Joe Perches
Add missing terminating newlines.
Convert uses of pr_info to pr_cont in bond_check_params.
Standardize upper/lower case styles.
Typo fixes, remove unnecessary parentheses and periods.
Alignment neatening.

Signed-off-by: Joe Perches 
---
 drivers/net/bonding/bond_3ad.c |  11 ++--
 drivers/net/bonding/bond_main.c| 103 ++---
 drivers/net/bonding/bond_netlink.c |   6 +--
 drivers/net/bonding/bond_options.c | 102 +---
 drivers/net/bonding/bond_procfs.c  |   2 +-
 drivers/net/bonding/bond_sysfs.c   |   8 +--
 6 files changed, 110 insertions(+), 122 deletions(-)

diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index cce1f1b..f6eda2d 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -1079,7 +1079,8 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct 
port *port)
/* detect loopback situation */
if (MAC_ADDRESS_EQUAL(&(lacpdu->actor_system),
  &(port->actor_system))) {
-   pr_err("%s: An illegal loopback occurred on 
adapter (%s).\nCheck the configuration to verify that all adapters are 
connected to 802.3ad compliant switch ports\n",
+   pr_err("%s: An illegal loopback occurred on 
adapter (%s)\n"
+  "Check the configuration to verify that 
all adapters are connected to 802.3ad compliant switch ports\n",
   port->slave->bond->dev->name,
   port->slave->dev->name);
return;
@@ -1950,7 +1951,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
 * new aggregator
 */
if ((new_aggregator) && ((!new_aggregator->lag_ports) 
|| ((new_aggregator->lag_ports == port) && 
!new_aggregator->lag_ports->next_port_in_aggregator))) {
-   pr_debug("Some port(s) related to LAG %d - 
replaceing with LAG %d\n",
+   pr_debug("Some port(s) related to LAG %d - 
replacing with LAG %d\n",
 aggregator->aggregator_identifier,
 new_aggregator->aggregator_identifier);
 
@@ -2300,9 +2301,9 @@ void bond_3ad_handle_link_change(struct slave *slave, 
char link)
port->actor_oper_port_key = (port->actor_admin_port_key &=
 ~AD_SPEED_KEY_BITS);
}
-   pr_debug("Port %d changed link status to %s",
-   port->actor_port_number,
-   (link == BOND_LINK_UP) ? "UP" : "DOWN");
+   pr_debug("Port %d changed link status to %s\n",
+port->actor_port_number,
+link == BOND_LINK_UP ? "UP" : "DOWN");
/* there is no need to reselect a new aggregator, just signal the
 * state machines to reinitialize
 */
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 1d4dfc9..90994ed 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -802,7 +802,7 @@ void bond_change_active_slave(struct bonding *bond, struct 
slave *new_active)
 
if (new_active->link == BOND_LINK_BACK) {
if (USES_PRIMARY(bond->params.mode)) {
-   pr_info("%s: making interface %s the new active 
one %d ms earlier.\n",
+   pr_info("%s: making interface %s the new active 
one %d ms earlier\n",
bond->dev->name, new_active->dev->name,
(bond->params.updelay - 
new_active->delay) * bond->params.miimon);
}
@@ -817,7 +817,7 @@ void bond_change_active_slave(struct bonding *bond, struct 
slave *new_active)
bond_alb_handle_link_change(bond, new_active, 
BOND_LINK_UP);
} else {
if (USES_PRIMARY(bond->params.mode)) {
-   pr_info("%s: making interface %s the new active 
one.\n",
+   pr_info("%s: making interface %s the new active 
one\n",
bond->dev->name, new_active->dev->name);
}
}
@@ -906,7 +906,7 @@ void bond_select_active_slave(struct bonding *bond)
pr_info("%s: first active interface up!\n",
bond->dev->name);
} else {
-   pr_info("%s: now running without any active interface 
!\n",
+   pr_info("%s: now running without any active 
interface!\n",
bond->dev->name);
}
}
@@ -1189,7 +1189,7 @@ int bond_enslave(struct 

[PATCH 1/4] bonding: Convert pr_warning to pr_warn, neatening

2014-02-15 Thread Joe Perches
Use more current logging style.

Coalesce formats, realign arguments, drop unnecessary periods.

Signed-off-by: Joe Perches 
---
 drivers/net/bonding/bond_alb.c |   6 +-
 drivers/net/bonding/bond_debugfs.c |  10 ++--
 drivers/net/bonding/bond_main.c| 116 ++---
 drivers/net/bonding/bond_procfs.c  |   8 +--
 4 files changed, 67 insertions(+), 73 deletions(-)

diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index a212860..e9f0a98 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -1243,9 +1243,9 @@ static int alb_handle_addr_collision_on_attach(struct 
bonding *bond, struct slav
if (free_mac_slave) {
alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr);
 
-   pr_warning("%s: Warning: the hw address of slave %s is in use 
by the bond; giving it the hw address of %s\n",
-  bond->dev->name, slave->dev->name,
-  free_mac_slave->dev->name);
+   pr_warn("%s: Warning: the hw address of slave %s is in use by 
the bond; giving it the hw address of %s\n",
+   bond->dev->name, slave->dev->name,
+   free_mac_slave->dev->name);
 
} else if (has_bond_addr) {
pr_err("%s: Error: the hw address of slave %s is in use by the 
bond; couldn't find a slave with a free hw address to give it (this should not 
have happened)\n",
diff --git a/drivers/net/bonding/bond_debugfs.c 
b/drivers/net/bonding/bond_debugfs.c
index 5fc4c23..2d3f7fa 100644
--- a/drivers/net/bonding/bond_debugfs.c
+++ b/drivers/net/bonding/bond_debugfs.c
@@ -69,7 +69,7 @@ void bond_debug_register(struct bonding *bond)
debugfs_create_dir(bond->dev->name, bonding_debug_root);
 
if (!bond->debug_dir) {
-   pr_warning("%s: Warning: failed to register to debugfs\n",
+   pr_warn("%s: Warning: failed to register to debugfs\n",
bond->dev->name);
return;
}
@@ -98,9 +98,8 @@ void bond_debug_reregister(struct bonding *bond)
if (d) {
bond->debug_dir = d;
} else {
-   pr_warning("%s: Warning: failed to reregister, "
-   "so just unregister old one\n",
-   bond->dev->name);
+   pr_warn("%s: Warning: failed to reregister, so just unregister 
old one\n",
+   bond->dev->name);
bond_debug_unregister(bond);
}
 }
@@ -110,8 +109,7 @@ void bond_create_debugfs(void)
bonding_debug_root = debugfs_create_dir("bonding", NULL);
 
if (!bonding_debug_root) {
-   pr_warning("Warning: Cannot create bonding directory"
-   " in debugfs\n");
+   pr_warn("Warning: Cannot create bonding directory in 
debugfs\n");
}
 }
 
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 58aa531..1d4dfc9 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1183,8 +1183,8 @@ int bond_enslave(struct net_device *bond_dev, struct 
net_device *slave_dev)
if (!bond->params.use_carrier &&
slave_dev->ethtool_ops->get_link == NULL &&
slave_ops->ndo_do_ioctl == NULL) {
-   pr_warning("%s: Warning: no link monitoring support for %s\n",
-  bond_dev->name, slave_dev->name);
+   pr_warn("%s: Warning: no link monitoring support for %s\n",
+   bond_dev->name, slave_dev->name);
}
 
/* already enslaved */
@@ -1202,9 +1202,9 @@ int bond_enslave(struct net_device *bond_dev, struct 
net_device *slave_dev)
   bond_dev->name, slave_dev->name, bond_dev->name);
return -EPERM;
} else {
-   pr_warning("%s: Warning: enslaved VLAN challenged slave 
%s. Adding VLANs will be blocked as long as %s is part of bond %s\n",
-  bond_dev->name, slave_dev->name,
-  slave_dev->name, bond_dev->name);
+   pr_warn("%s: Warning: enslaved VLAN challenged slave 
%s. Adding VLANs will be blocked as long as %s is part of bond %s\n",
+   bond_dev->name, slave_dev->name,
+   slave_dev->name, bond_dev->name);
}
} else {
pr_debug("%s: ! NETIF_F_VLAN_CHALLENGED\n", slave_dev->name);
@@ -1419,12 +1419,12 @@ int bond_enslave(struct net_device *bond_dev, struct 
net_device *slave_dev)
 * supported); thus, we don't need to change
 * the messages for netif_carrier.
 */
-   pr_warning("%s: Warning: MII and ETHTOOL support not 
available for interface %s, and 

[PATCH net-next 0/4] bonding cleaning

2014-02-15 Thread Joe Perches
Miscellaneous cleanups

Joe Perches (4):
  bonding: Convert pr_warning to pr_warn, neatening
  bonding: Neaten pr_
  bonding: Convert c99 comments
  bonding: Convert memcpy(foo, bar, ETH_ALEN) to ether_addr_copy(foo, bar)

 drivers/net/bonding/bond_3ad.c |  19 +--
 drivers/net/bonding/bond_3ad.h | 175 ++--
 drivers/net/bonding/bond_alb.c |  36 +++---
 drivers/net/bonding/bond_debugfs.c |  10 +-
 drivers/net/bonding/bond_main.c| 231 ++---
 drivers/net/bonding/bond_netlink.c |   6 +-
 drivers/net/bonding/bond_options.c | 102 
 drivers/net/bonding/bond_procfs.c  |   8 +-
 drivers/net/bonding/bond_sysfs.c   |   8 +-
 9 files changed, 288 insertions(+), 307 deletions(-)

-- 
1.8.1.2.459.gbcd45b4.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: [PATCH] swapoff tmpfs radix_tree: remember to rcu_read_unlock

2014-02-15 Thread Hugh Dickins
On Thu, 13 Feb 2014, Andrew Morton wrote:
> On Wed, 12 Feb 2014 18:45:07 -0800 (PST) Hugh Dickins  
> wrote:
> 
> > Running fsx on tmpfs with concurrent memhog-swapoff-swapon, lots of
> > 
> > BUG: sleeping function called from invalid context at kernel/fork.c:606
> > in_atomic(): 0, irqs_disabled(): 0, pid: 1394, name: swapoff
> > 1 lock held by swapoff/1394:
> >  #0:  (rcu_read_lock){.+.+.+}, at: [] 
> > radix_tree_locate_item+0x1f/0x2b6
> > followed by
> > 
> > [ BUG: lock held when returning to user space! ]
> > 3.14.0-rc1 #3 Not tainted
> > 
> > swapoff/1394 is leaving the kernel with locks still held!
> > 1 lock held by swapoff/1394:
> >  #0:  (rcu_read_lock){.+.+.+}, at: [] 
> > radix_tree_locate_item+0x1f/0x2b6
> > after which the system recovered nicely.
> > 
> > Whoops, I long ago forgot the rcu_read_unlock() on one unlikely branch.
> > 
> > Fixes: e504f3fdd63d ("tmpfs radix_tree: locate_item to speed up swapoff")
> 
> huh.  Venerable.  I'm surprised that such an obvious blooper wasn't
> spotted at review.  Why didn't anyone else hit this.

No surprise that it missed review, obvious though it is in the fix.

And not much surprise that noone else hit this: for most people, even
those using tmpfs and pushing out to swap, swapoff is just something
that happens shortly before the screen goes blank when you shutdown
(and, I haven't noticed how distros order it these days, but swapoff
is anyway better done after unmounting tmpfss, to avoid its slowness).

And it does need the swapped tmpfs file to be truncated or unlinked
while swapoff is searching through it racily with RCU lookups.

What puzzled me more was, why hadn't I seen it before?  I don't run
that fsx test particularly often, but have certainly run it dozens
of times between then and now.  I think the answer must be where I
said "after which the system recovered nicely": I probably did hit
it before, but wasn't attending to the screen at the time, the
warnings got scrolled off by timestamps I was printing, and I
failed to check dmesg or /var/log/messages afterwards.

> 
> 
> > Of course, the truth is that I had been hoping to break Johannes's
> > patchset in mmotm, was thrilled to get this on that, then despondent
> > to realize that the only bug I had found was mine.  Surprised I've
> > not seen it before in 2.5 years: tried again on 3.14-rc1, got the
> > same after 25 minutes.  Probably not serious enough for -stable,
> > but please can we slip the fix into 3.14 - sorry, Johannes's
> > mm-keep-page-cache-radix-tree-nodes-in-check.patch will need a refresh.
> 
> I fixed it up.

Thanks!

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


Re: [PATCH v5 1/6] spmi: Linux driver framework for SPMI

2014-02-15 Thread Felipe Balbi
Hi,

On Mon, Feb 03, 2014 at 05:05:33PM -0600, Josh Cartwright wrote:

[ snip ]

> +#ifdef CONFIG_PM_RUNTIME
> +static int spmi_runtime_suspend(struct device *dev)
> +{
> + struct spmi_device *sdev = to_spmi_device(dev);
> + int err;
> +
> + err = pm_generic_runtime_suspend(dev);
> + if (err)
> + return err;
> +
> + return spmi_command_sleep(sdev);

shouldn't this too calls be swapped ? I mean, some pm_runtime
implementations could be gating clocks at the driver's
->runtime_suspend() callback.

-- 
balbi


signature.asc
Description: Digital signature


Re: 3.14-rc2 XFS backtrace because irqs_disabled.

2014-02-15 Thread Linus Torvalds
[ Added linux-mm to the participants list ]

On Thu, Feb 13, 2014 at 4:24 PM, Dave Chinner  wrote:
>
> Dave, the patch below should chop off the stack usage from
> xfs_log_force_lsn() issuing IO by deferring it to the CIL workqueue.
> Can you given this a run?

Ok, so DaveJ confirmed that DaveC's patch fixes his issue (damn,
people, your parents were some seriously boring people, were they not?
We've got too many Dave's around), but DaveC earlier pointed out that
pretty much any memory allocation path can end up using 3kB of stack
even without XFS being involved.

Which does bring up the question whether we should look (once more) at
the VM direct-reclaim path, and try to avoid GFP_FS/IO direct
reclaim..

Direct reclaim historically used to be an important throttling
mechanism, and I used to not be a fan of trying to avoid direct
reclaim. But the stack depth issue really looks to be pretty bad, and
I think we've gotten better at throttling explicitly, so..

I *think* we already limit filesystem writeback to just kswapd (in
shrink_page_list()), but DaveC posted a backtrace that goes through
do_try_to_free_pages() to shrink_slab(), and through there to the
filesystem and then IO. That looked like a disaster.

And that's because (if I read things right) shrink_page_list() limits
filesystem page writeback to kswapd, but not swap pages. Which I think
probably made more sense back in the days than it does now (I
certainly *hope* that swapping is less important today than it was,
say, ten years ago)

So I'm wondering whether we should remove that page_is_file_cache()
check from shrink_page_list()?

And then there is that whole shrink_slab() case...

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


Re: [PATCH 02/11] vfs: More precise tests in d_invalidate

2014-02-15 Thread Eric W. Biederman
ebied...@xmission.com (Eric W. Biederman) writes:

> But when shrink_dcache_parent and check_submounts_and_drop are
> effectiely the same function I can't possibly see how you can argue how
> the locking has changed or that I am trying to hide things.

And in particular the only locking change that I can see at all is that
d_walk takes read_seqbegin_or_lock before checking the if the d_subdirs
list is empty, which is just an extra cache line read.

Which in practical terms appears like I have removed unnecessary special
cases in favor less code.  Which I think if anything should perform
better just because there is less code to run, and what is happening is
less obfuscated.

Eric

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 v6 1/8] clk: sunxi: factors: automatic reparenting support

2014-02-15 Thread David Lanzendörfer
From: Emilio López 

This commit implements .determine_rate, so that our factor clocks can be
reparented when needed.

Signed-off-by: Emilio López 
---
 drivers/clk/sunxi/clk-factors.c |   36 
 1 file changed, 36 insertions(+)

diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c
index 9e23264..3806d97 100644
--- a/drivers/clk/sunxi/clk-factors.c
+++ b/drivers/clk/sunxi/clk-factors.c
@@ -77,6 +77,41 @@ static long clk_factors_round_rate(struct clk_hw *hw, 
unsigned long rate,
return rate;
 }
 
+static long clk_factors_determine_rate(struct clk_hw *hw, unsigned long rate,
+  unsigned long *best_parent_rate,
+  struct clk **best_parent_p)
+{
+   struct clk *clk = hw->clk, *parent, *best_parent = NULL;
+   int i, num_parents;
+   unsigned long parent_rate, best = 0, child_rate, best_child_rate = 0;
+
+   /* find the parent that can help provide the fastest rate <= rate */
+   num_parents = __clk_get_num_parents(clk);
+   for (i = 0; i < num_parents; i++) {
+   parent = clk_get_parent_by_index(clk, i);
+   if (!parent)
+   continue;
+   if (__clk_get_flags(clk) & CLK_SET_RATE_PARENT)
+   parent_rate = __clk_round_rate(parent, rate);
+   else
+   parent_rate = __clk_get_rate(parent);
+
+   child_rate = clk_factors_round_rate(hw, rate, _rate);
+
+   if (child_rate <= rate && child_rate > best_child_rate) {
+   best_parent = parent;
+   best = parent_rate;
+   best_child_rate = child_rate;
+   }
+   }
+
+   if (best_parent)
+   *best_parent_p = best_parent;
+   *best_parent_rate = best;
+
+   return best_child_rate;
+}
+
 static int clk_factors_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
 {
@@ -113,6 +148,7 @@ static int clk_factors_set_rate(struct clk_hw *hw, unsigned 
long rate,
 }
 
 const struct clk_ops clk_factors_ops = {
+   .determine_rate = clk_factors_determine_rate,
.recalc_rate = clk_factors_recalc_rate,
.round_rate = clk_factors_round_rate,
.set_rate = clk_factors_set_rate,

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 v6 2/8] clk: sunxi: Implement MMC phase control

2014-02-15 Thread David Lanzendörfer
From: Emilio López 

Signed-off-by: Emilio López 
---
 drivers/clk/sunxi/clk-sunxi.c |   35 +++
 1 file changed, 35 insertions(+)

diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index abb6c5a..33b9977 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -377,6 +377,41 @@ static void sun7i_a20_get_out_factors(u32 *freq, u32 
parent_rate,
 
 
 /**
+ * clk_sunxi_mmc_phase_control() - configures MMC clock phase control
+ */
+
+void clk_sunxi_mmc_phase_control(struct clk_hw *hw, u8 sample, u8 output)
+{
+   #define to_clk_composite(_hw) container_of(_hw, struct clk_composite, 
hw)
+   #define to_clk_factors(_hw) container_of(_hw, struct clk_factors, hw)
+
+   struct clk_composite *composite = to_clk_composite(hw);
+   struct clk_hw *rate_hw = composite->rate_hw;
+   struct clk_factors *factors = to_clk_factors(rate_hw);
+   unsigned long flags = 0;
+   u32 reg;
+
+   if (factors->lock)
+   spin_lock_irqsave(factors->lock, flags);
+
+   reg = readl(factors->reg);
+
+   /* set sample clock phase control */
+   reg &= ~(0x7 << 20);
+   reg |= ((sample & 0x7) << 20);
+
+   /* set output clock phase control */
+   reg &= ~(0x7 << 8);
+   reg |= ((output & 0x7) << 8);
+
+   writel(reg, factors->reg);
+
+   if (factors->lock)
+   spin_unlock_irqrestore(factors->lock, flags);
+}
+
+
+/**
  * sunxi_factors_clk_setup() - Setup function for factor clocks
  */
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 v6 6/8] ARM: dts: sun4i: Add support for mmc

2014-02-15 Thread David Lanzendörfer
Signed-off-by: David Lanzendörfer 
Signed-off-by: Hans de Goede 
---
 arch/arm/boot/dts/sun4i-a10-a1000.dts  |8 
 arch/arm/boot/dts/sun4i-a10-cubieboard.dts |8 
 arch/arm/boot/dts/sun4i-a10.dtsi   |   54 
 3 files changed, 70 insertions(+)

diff --git a/arch/arm/boot/dts/sun4i-a10-a1000.dts 
b/arch/arm/boot/dts/sun4i-a10-a1000.dts
index d4b081d..a879ef3 100644
--- a/arch/arm/boot/dts/sun4i-a10-a1000.dts
+++ b/arch/arm/boot/dts/sun4i-a10-a1000.dts
@@ -35,6 +35,14 @@
};
};
 
+   mmc0: mmc@01c0f000 {
+   pinctrl-names = "default", "default";
+   pinctrl-0 = <_pins_a>;
+   pinctrl-1 = <_cd_pin_reference_design>;
+   cd-gpios = < 7 1 0>; /* PH1 */
+   status = "okay";
+   };
+
pinctrl@01c20800 {
emac_power_pin_a1000: emac_power_pin@0 {
allwinner,pins = "PH15";
diff --git a/arch/arm/boot/dts/sun4i-a10-cubieboard.dts 
b/arch/arm/boot/dts/sun4i-a10-cubieboard.dts
index b139ee6..20b976a 100644
--- a/arch/arm/boot/dts/sun4i-a10-cubieboard.dts
+++ b/arch/arm/boot/dts/sun4i-a10-cubieboard.dts
@@ -33,6 +33,14 @@
};
};
 
+   mmc0: mmc@01c0f000 {
+   pinctrl-names = "default", "default";
+   pinctrl-0 = <_pins_a>;
+   pinctrl-1 = <_cd_pin_reference_design>;
+   cd-gpios = < 7 1 0>; /* PH1 */
+   status = "okay";
+   };
+
pinctrl@01c20800 {
led_pins_cubieboard: led_pins@0 {
allwinner,pins = "PH20", "PH21";
diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
index 9044c53..cd14961 100644
--- a/arch/arm/boot/dts/sun4i-a10.dtsi
+++ b/arch/arm/boot/dts/sun4i-a10.dtsi
@@ -330,6 +330,46 @@
#size-cells = <0>;
};
 
+   mmc0: mmc@01c0f000 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c0f000 0x1000>;
+   clocks = <_gates 8>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <32>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
+   mmc1: mmc@01c1 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c1 0x1000>;
+   clocks = <_gates 9>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <33>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
+   mmc2: mmc@01c11000 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c11000 0x1000>;
+   clocks = <_gates 10>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <34>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
+   mmc3: mmc@01c12000 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c12000 0x1000>;
+   clocks = <_gates 11>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <35>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
intc: interrupt-controller@01c20400 {
compatible = "allwinner,sun4i-ic";
reg = <0x01c20400 0x400>;
@@ -400,6 +440,20 @@
allwinner,drive = <0>;
allwinner,pull = <0>;
};
+
+   mmc0_pins_a: mmc0@0 {
+   allwinner,pins = 
"PF0","PF1","PF2","PF3","PF4","PF5";
+   allwinner,function = "mmc0";
+   allwinner,drive = <3>;
+   allwinner,pull = <0>;
+   };
+
+   mmc0_cd_pin_reference_design: mmc0_cd_pin@0 {
+   allwinner,pins = "PH1";
+   allwinner,function = "gpio_in";
+   allwinner,drive = <0>;
+   allwinner,pull = <1>;
+   };
};
 
timer@01c20c00 {

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

[PATCH v6 8/8] ARM: sunxi: Add documentation for driver for SD/MMC hosts found on Allwinner sunxi SoCs

2014-02-15 Thread David Lanzendörfer
Signed-off-by: David Lanzendörfer 
---
 .../devicetree/bindings/mmc/sunxi-mmc.txt  |   32 
 1 file changed, 32 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/sunxi-mmc.txt

diff --git a/Documentation/devicetree/bindings/mmc/sunxi-mmc.txt 
b/Documentation/devicetree/bindings/mmc/sunxi-mmc.txt
new file mode 100644
index 000..5ce8c5e
--- /dev/null
+++ b/Documentation/devicetree/bindings/mmc/sunxi-mmc.txt
@@ -0,0 +1,32 @@
+* Allwinner sunxi MMC controller
+
+The highspeed MMC host controller on Allwinner SoCs provides an interface
+for MMC, SD and SDIO types of memory cards.
+
+Supported maximum speeds are the ones of the eMMC standard 4.5 as well
+as the speed of SD standard 3.0.
+Absolute maximum transfer rate is 200MB/s
+
+Required properties:
+- compatible: Should be "allwinner,--mmc".
+  The supported chips include a10, a10s, 13, a20 and a31.
+- base registers are 0x1000 appart, so the base of mmc1
+  would be 0x01c0f000+0x1000=0x01c1(see example)
+  and so on.
+- clocks requires the reference at the ahb clock gate
+  with the correct index (mmc0 -> 8, mmc1 -> 9, and so on)
+  as well as the reference to the correct mod0 clock.
+- interrupts requires the correct IRQ line
+  (mmc0 -> 32, mmc1 -> 33, and so on)
+
+Examples:
+
+mmc0: mmc@01c0f000 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c0f000 0x1000>;
+   clocks = <_gates 8>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <0 32 4>;
+   bus-width = <4>;
+   status = "disabled";
+};

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 v6 3/8] ARM: sunxi: clk: export clk_sunxi_mmc_phase_control

2014-02-15 Thread David Lanzendörfer
From: Hans de Goede 

Signed-off-by: Hans de Goede 
---
 include/linux/clk/sunxi.h |   22 ++
 1 file changed, 22 insertions(+)
 create mode 100644 include/linux/clk/sunxi.h

diff --git a/include/linux/clk/sunxi.h b/include/linux/clk/sunxi.h
new file mode 100644
index 000..1ef5c89
--- /dev/null
+++ b/include/linux/clk/sunxi.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2013 - Hans de Goede 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __LINUX_CLK_SUNXI_H_
+#define __LINUX_CLK_SUNXI_H_
+
+#include 
+
+void clk_sunxi_mmc_phase_control(struct clk_hw *hw, u8 sample, u8 output);
+
+#endif

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


[PATCH v6 7/8] ARM: dts: sun5i: Add support for mmc

2014-02-15 Thread David Lanzendörfer
Signed-off-by: David Lanzendörfer 
Signed-off-by: Hans de Goede 
---
 arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts |   30 +++
 arch/arm/boot/dts/sun5i-a10s.dtsi|   44 ++
 arch/arm/boot/dts/sun5i-a13-olinuxino-micro.dts  |   15 
 arch/arm/boot/dts/sun5i-a13-olinuxino.dts|   15 
 arch/arm/boot/dts/sun5i-a13.dtsi |   37 +++
 5 files changed, 141 insertions(+)

diff --git a/arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts 
b/arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts
index 3c9f8b3..5c7b454 100644
--- a/arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts
+++ b/arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts
@@ -34,7 +34,37 @@
};
};
 
+   mmc0: mmc@01c0f000 {
+   pinctrl-names = "default", "default";
+   pinctrl-0 = <_pins_a>;
+   pinctrl-1 = <_cd_pin_olinuxino_micro>;
+   cd-gpios = < 6 1 0>; /* PG1 */
+   status = "okay";
+   };
+
+   mmc1: mmc@01c1 {
+   pinctrl-names = "default", "default";
+   pinctrl-0 = <_pins_a>;
+   pinctrl-1 = <_cd_pin_olinuxino_micro>;
+   cd-gpios = < 6 13 0>; /* PG13 */
+   status = "okay";
+   };
+
pinctrl@01c20800 {
+   mmc0_cd_pin_olinuxino_micro: mmc0_cd_pin@0 {
+   allwinner,pins = "PG1";
+   allwinner,function = "gpio_in";
+   allwinner,drive = <0>;
+   allwinner,pull = <1>;
+   };
+
+   mmc1_cd_pin_olinuxino_micro: mmc1_cd_pin@0 {
+   allwinner,pins = "PG13";
+   allwinner,function = "gpio_in";
+   allwinner,drive = <0>;
+   allwinner,pull = <1>;
+   };
+
led_pins_olinuxino: led_pins@0 {
allwinner,pins = "PE3";
allwinner,function = "gpio_out";
diff --git a/arch/arm/boot/dts/sun5i-a10s.dtsi 
b/arch/arm/boot/dts/sun5i-a10s.dtsi
index 327e87b..b6d1de0 100644
--- a/arch/arm/boot/dts/sun5i-a10s.dtsi
+++ b/arch/arm/boot/dts/sun5i-a10s.dtsi
@@ -293,6 +293,36 @@
#size-cells = <0>;
};
 
+   mmc0: mmc@01c0f000 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c0f000 0x1000>;
+   clocks = <_gates 8>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <32>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
+   mmc1: mmc@01c1 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c1 0x1000>;
+   clocks = <_gates 9>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <33>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
+   mmc2: mmc@01c11000 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c11000 0x1000>;
+   clocks = <_gates 10>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <34>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
intc: interrupt-controller@01c20400 {
compatible = "allwinner,sun4i-ic";
reg = <0x01c20400 0x400>;
@@ -363,6 +393,20 @@
allwinner,drive = <0>;
allwinner,pull = <0>;
};
+
+   mmc0_pins_a: mmc0@0 {
+   allwinner,pins = 
"PF0","PF1","PF2","PF3","PF4","PF5";
+   allwinner,function = "mmc0";
+   allwinner,drive = <3>;
+   allwinner,pull = <0>;
+   };
+
+   mmc1_pins_a: mmc1@0 {
+   allwinner,pins = 
"PG3","PG4","PG5","PG6","PG7","PG8";
+   allwinner,function = "mmc1";
+   allwinner,drive = <3>;
+   allwinner,pull = <0>;
+   };
};
 
timer@01c20c00 {
diff --git a/arch/arm/boot/dts/sun5i-a13-olinuxino-micro.dts 
b/arch/arm/boot/dts/sun5i-a13-olinuxino-micro.dts
index fe2ce0a..2f08bb2 100644
--- 

[PATCH v6 5/8] ARM: dts: sun7i: Add support for mmc

2014-02-15 Thread David Lanzendörfer
Signed-off-by: David Lanzendörfer 
Signed-off-by: Hans de Goede 
---
 arch/arm/boot/dts/sun7i-a20-cubieboard2.dts |8 +++
 arch/arm/boot/dts/sun7i-a20-cubietruck.dts  |8 +++
 arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts |   23 +
 arch/arm/boot/dts/sun7i-a20.dtsi|   61 +++
 4 files changed, 100 insertions(+)

diff --git a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
index 5c51cb8..ae800b6 100644
--- a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
+++ b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
@@ -34,6 +34,14 @@
};
};
 
+   mmc0: mmc@01c0f000 {
+   pinctrl-names = "default", "default";
+   pinctrl-0 = <_pins_a>;
+   pinctrl-1 = <_cd_pin_reference_design>;
+   cd-gpios = < 7 1 0>; /* PH1 */
+   status = "okay";
+   };
+
pinctrl@01c20800 {
led_pins_cubieboard2: led_pins@0 {
allwinner,pins = "PH20", "PH21";
diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
index f9dcb61..370cef84 100644
--- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
+++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
@@ -19,6 +19,14 @@
compatible = "cubietech,cubietruck", "allwinner,sun7i-a20";
 
soc@01c0 {
+   mmc0: mmc@01c0f000 {
+   pinctrl-names = "default", "default";
+   pinctrl-0 = <_pins_a>;
+   pinctrl-1 = <_cd_pin_reference_design>;
+   cd-gpios = < 7 1 0>; /* PH1 */
+   status = "okay";
+   };
+
pinctrl@01c20800 {
led_pins_cubietruck: led_pins@0 {
allwinner,pins = "PH7", "PH11", "PH20", "PH21";
diff --git a/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts 
b/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts
index ead3013..685ec06 100644
--- a/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts
+++ b/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts
@@ -34,7 +34,30 @@
};
};
 
+   mmc0: mmc@01c0f000 {
+   pinctrl-names = "default", "default";
+   pinctrl-0 = <_pins_a>;
+   pinctrl-1 = <_cd_pin_reference_design>;
+   cd-gpios = < 7 1 0>; /* PH1 */
+   status = "okay";
+   };
+
+   mmc3: mmc@01c12000 {
+   pinctrl-names = "default", "default";
+   pinctrl-0 = <_pins_a>;
+   pinctrl-1 = <_cd_pin_olinuxinom>;
+   cd-gpios = < 7 11 0>; /* PH11 */
+   status = "okay";
+   };
+
pinctrl@01c20800 {
+   mmc3_cd_pin_olinuxinom: mmc3_cd_pin@0 {
+   allwinner,pins = "PH11";
+   allwinner,function = "gpio_in";
+   allwinner,drive = <0>;
+   allwinner,pull = <1>;
+   };
+
led_pins_olinuxino: led_pins@0 {
allwinner,pins = "PH2";
allwinner,function = "gpio_out";
diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi
index 9ff0948..5b55414 100644
--- a/arch/arm/boot/dts/sun7i-a20.dtsi
+++ b/arch/arm/boot/dts/sun7i-a20.dtsi
@@ -355,6 +355,46 @@
#size-cells = <0>;
};
 
+   mmc0: mmc@01c0f000 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c0f000 0x1000>;
+   clocks = <_gates 8>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <0 32 4>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
+   mmc1: mmc@01c1 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c1 0x1000>;
+   clocks = <_gates 9>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <0 33 4>;
+   bus-width = <4>;
+   status = "disabled";
+   };
+
+   mmc2: mmc@01c11000 {
+   compatible = "allwinner,sun5i-a13-mmc";
+   reg = <0x01c11000 0x1000>;
+   clocks = <_gates 10>, <_clk>;
+   clock-names = "ahb", "mod";
+   interrupts = <0 34 4>;
+   bus-width = <4>;
+   status = "disabled";
+  

[PATCH v6 4/8] ARM: sunxi: Add driver for SD/MMC hosts found on Allwinner sunxi SoCs

2014-02-15 Thread David Lanzendörfer
This is based on the driver Allwinner ships in their Android kernel sources.

Initial porting to upstream kernels done by David Lanzendörfer, additional
fixes and cleanups by Hans de Goede.

It uses dma in bus-master mode using a built-in designware idmac controller,
which is identical to the one found in the mmc-dw hosts.
The rest of the host is not identical to mmc-dw.

Signed-off-by: David Lanzendörfer 
Signed-off-by: Hans de Goede 
---
 drivers/mmc/host/Kconfig |7 
 drivers/mmc/host/Makefile|2 
 drivers/mmc/host/sunxi-mmc.c |  876 ++
 drivers/mmc/host/sunxi-mmc.h |  239 +++
 4 files changed, 1124 insertions(+)
 create mode 100644 drivers/mmc/host/sunxi-mmc.c
 create mode 100644 drivers/mmc/host/sunxi-mmc.h

diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 1384f67..7caf266 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -689,3 +689,10 @@ config MMC_REALTEK_PCI
help
  Say Y here to include driver code to support SD/MMC card interface
  of Realtek PCI-E card reader
+
+config MMC_SUNXI
+   tristate "Allwinner sunxi SD/MMC Host Controller support"
+   depends on ARCH_SUNXI
+   help
+ This selects support for the SD/MMC Host Controller on
+ Allwinner sunxi SoCs.
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index 3483b6b..f3c7c243 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -54,6 +54,8 @@ obj-$(CONFIG_MMC_WMT) += wmt-sdmmc.o
 
 obj-$(CONFIG_MMC_REALTEK_PCI)  += rtsx_pci_sdmmc.o
 
+obj-$(CONFIG_MMC_SUNXI)+= sunxi-mmc.o
+
 obj-$(CONFIG_MMC_SDHCI_PLTFM)  += sdhci-pltfm.o
 obj-$(CONFIG_MMC_SDHCI_CNS3XXX)+= sdhci-cns3xxx.o
 obj-$(CONFIG_MMC_SDHCI_ESDHC_IMX)  += sdhci-esdhc-imx.o
diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
new file mode 100644
index 000..2dc446c
--- /dev/null
+++ b/drivers/mmc/host/sunxi-mmc.c
@@ -0,0 +1,876 @@
+/*
+ * Driver for sunxi SD/MMC host controllers
+ * (C) Copyright 2014-2015 Reuuimlla Technology Co., Ltd.
+ * (C) Copyright 2014-2015 Aaron Maoye 
+ * (C) Copyright 2014-2015 O2S GmbH 
+ * (C) Copyright 2014-2015 David Lanzend�rfer 
+ * (C) Copyright 2014-2015 Hans de Goede 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "sunxi-mmc.h"
+
+static int sunxi_mmc_init_host(struct mmc_host *mmc)
+{
+   u32 rval;
+   struct sunxi_mmc_host *smc_host = mmc_priv(mmc);
+   int ret;
+
+   ret =  clk_prepare_enable(smc_host->clk_ahb);
+   if (ret) {
+   dev_err(mmc_dev(smc_host->mmc), "AHB clk err %d\n", ret);
+   return ret;
+   }
+   ret =  clk_prepare_enable(smc_host->clk_mod);
+   if (ret) {
+   dev_err(mmc_dev(smc_host->mmc), "MOD clk err %d\n", ret);
+   clk_disable_unprepare(smc_host->clk_ahb);
+   return ret;
+   }
+
+   /* reset controller */
+   rval = mci_readl(smc_host, REG_GCTRL) | SDXC_HARDWARE_RESET;
+   mci_writel(smc_host, REG_GCTRL, rval);
+
+   mci_writel(smc_host, REG_FTRGL, 0x20070008);
+   mci_writel(smc_host, REG_TMOUT, 0x);
+   mci_writel(smc_host, REG_IMASK, smc_host->sdio_imask);
+   mci_writel(smc_host, REG_RINTR, 0x);
+   mci_writel(smc_host, REG_DBGC, 0xdeb);
+   mci_writel(smc_host, REG_FUNS, 0xceaa);
+   mci_writel(smc_host, REG_DLBA, smc_host->sg_dma);
+   rval = mci_readl(smc_host, REG_GCTRL)|SDXC_INTERRUPT_ENABLE_BIT;
+   rval &= ~SDXC_ACCESS_DONE_DIRECT;
+   mci_writel(smc_host, REG_GCTRL, rval);
+
+   return 0;
+}
+
+static void sunxi_mmc_exit_host(struct sunxi_mmc_host *smc_host)
+{
+   mci_writel(smc_host, REG_GCTRL, SDXC_HARDWARE_RESET);
+   clk_disable_unprepare(smc_host->clk_ahb);
+   clk_disable_unprepare(smc_host->clk_mod);
+}
+
+/* /\* UHS-I Operation Modes */
+/*  * DS   25MHz   12.5MB/s3.3V */
+/*  * HS   50MHz   25MB/s  3.3V */
+/*  * SDR1225MHz   12.5MB/s1.8V */
+/*  * SDR2550MHz   25MB/s  1.8V */
+/*  * SDR50100MHz  50MB/s  1.8V */
+/*  * SDR104   208MHz  104MB/s 1.8V */
+/*  * DDR5050MHz   50MB/s  1.8V */
+/*  * MMC Operation Modes */
+/*  * DS   26MHz   26MB/s  3/1.8/1.2V */
+/*  * HS   52MHz   52MB/s  3/1.8/1.2V */

[PATCH v6 0/8]

2014-02-15 Thread David Lanzendörfer
Hello
The following patchset adds support for the SD/MMC host found in the Allwinner 
SoCs.
It contains all the necessary modifications for clock environment and also the 
device
tree script modification which add it to all the boards using it.
The clock environment function needed for phase offset configuration has
been proposed and implemented by Emilio.
A lot of work and cleanup has been done by Hans de Goede. Special thanks to him!
This patchset is the 4th attempt to send this driver upstream.

Changes since v1:
-Using mmc_of_parse instead of diy dt parsing
-Adding nodes for all mmc controller to the dtsi files,
 including sofar unused controllers
-Using generic GPIO slot library for WP/CD
-Adding additional MMC device nodes into DTSI files

Changes since v2:
-Add missing Signed-off-by tags
-Stop using __raw_readl / __raw_writel so that barriers are properly used
-Adding missing new lines
-Adding missing patch for automatic reparenting of clocks

Changes since v3:
-Move clk_enable / disable into host_init / exit (Hans)
-Fix hang on boot caused by irq storm (Hans)

Changes since v4:
-moving sunxi-mci.{c/h} to sunxi-mmc.{c/h}
-removing camel cases from the defines in  sunxi-mmc.h
-moving defines out of the struct definition
 since this is bad coding style
-adding documentation for the device tree binding

Changes since v5:
-adding host initialization for when the sdio irq is enabled
 (just to make sure having a defined state at all time)
-add mmc support fixup: set pullup on cd pins
-fixup: Don't set MMC_CAP_NEEDS_POLL /  MMC_CAP_4_BIT_DATA

---

David Lanzendörfer (5):
  ARM: sunxi: Add driver for SD/MMC hosts found on Allwinner sunxi SoCs
  ARM: dts: sun7i: Add support for mmc
  ARM: dts: sun4i: Add support for mmc
  ARM: dts: sun5i: Add support for mmc
  ARM: sunxi: Add documentation for driver for SD/MMC hosts found on 
Allwinner sunxi SoCs

Emilio López (2):
  clk: sunxi: factors: automatic reparenting support
  clk: sunxi: Implement MMC phase control

Hans de Goede (1):
  ARM: sunxi: clk: export clk_sunxi_mmc_phase_control


 .../devicetree/bindings/mmc/sunxi-mmc.txt  |   32 +
 arch/arm/boot/dts/sun4i-a10-a1000.dts  |8 
 arch/arm/boot/dts/sun4i-a10-cubieboard.dts |8 
 arch/arm/boot/dts/sun4i-a10.dtsi   |   54 +
 arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts   |   30 +
 arch/arm/boot/dts/sun5i-a10s.dtsi  |   44 +
 arch/arm/boot/dts/sun5i-a13-olinuxino-micro.dts|   15 
 arch/arm/boot/dts/sun5i-a13-olinuxino.dts  |   15 
 arch/arm/boot/dts/sun5i-a13.dtsi   |   37 +
 arch/arm/boot/dts/sun7i-a20-cubieboard2.dts|8 
 arch/arm/boot/dts/sun7i-a20-cubietruck.dts |8 
 arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts|   23 +
 arch/arm/boot/dts/sun7i-a20.dtsi   |   61 +
 drivers/clk/sunxi/clk-factors.c|   36 +
 drivers/clk/sunxi/clk-sunxi.c  |   35 +
 drivers/mmc/host/Kconfig   |7 
 drivers/mmc/host/Makefile  |2 
 drivers/mmc/host/sunxi-mmc.c   |  876 
 drivers/mmc/host/sunxi-mmc.h   |  239 +
 include/linux/clk/sunxi.h  |   22 +
 20 files changed, 1560 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/sunxi-mmc.txt
 create mode 100644 drivers/mmc/host/sunxi-mmc.c
 create mode 100644 drivers/mmc/host/sunxi-mmc.h
 create mode 100644 include/linux/clk/sunxi.h

-- 
Signature
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: sched: fair: NULL ptr deref in check_preempt_wakeup

2014-02-15 Thread Sasha Levin

On 02/15/2014 06:27 PM, Sasha Levin wrote:

Hi folks,

While fuzzing with trinity inside a KVM tools guest running latest -next 
kernel, I've
stumbled on the following:


As soon as I've finished writing that mail I've hit it again, with a different (but similar) stack 
trace.


[  770.993016] BUG: unable to handle kernel NULL pointer dereference at 
0150
[  770.993865] IP: [] pick_next_task_fair+0x109/0x290
[  770.994531] PGD 1addee067 PUD 1addef067 PMD 0
[  770.995018] Oops:  [#1] PREEMPT SMP
[  770.995573] Dumping ftrace buffer:
[  770.995928](ftrace buffer empty)
[  770.996304] Modules linked in:
[  770.996661] CPU: 0 PID: 13754 Comm: trinity-c155 Not tainted 
3.14.0-rc2-next-20140214
[  770.997646] task: 88021151b000 ti: 88016b9f4000 task.ti: 
88016b9f4000
[  770.998384] RIP: 0010:[]  [] 
pick_next_task_fair+
[  770.999254] RSP: 0018:88016b9f5bc8  EFLAGS: 00010097
[  770.999787] RAX: 4caed01b RBX: 880226fd79c0 RCX: 0004ccca
[  771.35] RDX: 00a7076b RSI: 880060ff8028 RDI: 88008b998078
[  771.35] RBP: 88016b9f5c08 R08:  R09: 0001
[  771.35] R10:  R11:  R12: 88008b998000
[  771.35] R13:  R14: 880226fd7a88 R15: 880060ffb7c8
[  771.35] FS:  7f6e01002700() GS:880226e0() 
knlGS:0
[  771.35] CS:  0010 DS:  ES:  CR0: 80050033
[  771.35] CR2: 0150 CR3: 0001feeef000 CR4: 06f0
[  771.35] DR0: 7f6e009b2000 DR1:  DR2: 
[  771.35] DR3:  DR6: 4ff0 DR7: 0600
[  771.35] Stack:
[  771.35]  88010001 0001 88016b9f5c08 
880226fd79c0
[  771.35]   88021151b990 0282 

[  771.35]  88016b9f5c88 8438ef35 88016b9f5c78 
811a19a5
[  771.35] Call Trace:
[  771.35]  [] __schedule+0x2a5/0x840
[  771.35]  [] ? __lock_contended+0x205/0x240
[  771.35]  [] schedule+0x65/0x70
[  771.35]  [] schedule_preempt_disabled+0x13/0x20
[  771.35]  [] mutex_lock_nested+0x2ad/0x510
[  771.35]  [] ? lookup_slow+0x46/0xd0
[  771.35]  [] ? unlazy_walk+0x16d/0x1e0
[  771.35]  [] ? lookup_slow+0x46/0xd0
[  771.35]  [] lookup_slow+0x46/0xd0
[  771.35]  [] path_lookupat+0xe5/0x660
[  771.35]  [] ? kmem_cache_alloc+0x1fa/0x300
[  771.35]  [] ? getname_flags+0x57/0x1c0
[  771.35]  [] filename_lookup+0x2f/0xd0
[  771.35]  [] user_path_at_empty+0x6c/0xb0
[  771.35]  [] ? context_tracking_user_exit+0x185/0x1c0
[  771.35]  [] ? trace_hardirqs_on+0xd/0x10
[  771.35]  [] user_path_at+0xc/0x10
[  771.35]  [] do_sys_truncate+0x43/0xc0
[  771.35]  [] SyS_truncate+0x9/0x10
[  771.35]  [] tracesys+0xdd/0xe2
[  771.35] Code: 4d 8b ad 48 01 00 00 39 c2 7c 19 4d 8b b7 50 01 00 00 4c 89 fe 4c 89 f7 e8 55 
98 ff ff 4d 8b bf 48 01 00 00 4d 8b b7 50 01 00 00 <49> 8b bd 50 01 00 00 49 39 fe 75 a3 4d 85 f6 74 
9e 4c 89 ee 4c

[  771.35] RIP  [] pick_next_task_fair+0x109/0x290
[  771.35]  RSP 
[  771.35] CR2: 0150
[  771.35] ---[ end trace 408e14968ec7dd7a ]---


Thanks,
Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] initramfs: Debug detected compression method

2014-02-15 Thread Daniel M. Weeks
This can greatly aid in narrowing down the real source of initramfs
problems such as failures related to the compression of the in-kernel
initramfs when an external initramfs is in use as well. Existing errors
are ambiguous as to which initramfs is a problem and why.

Signed-off-by: Daniel M. Weeks 
---
 init/initramfs.c | 1 +
 lib/decompress.c | 4 
 2 files changed, 5 insertions(+)

diff --git a/init/initramfs.c b/init/initramfs.c
index 93b6139..25d88b1 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -455,6 +455,7 @@ static char * __init unpack_to_rootfs(char *buf, unsigned 
len)
}
this_header = 0;
decompress = decompress_method(buf, len, _name);
+   printk(KERN_DEBUG "Detected %s compressed data\n", 
compress_name);
if (decompress) {
res = decompress(buf, len, NULL, flush_buffer, NULL,
   _inptr, error);
diff --git a/lib/decompress.c b/lib/decompress.c
index 4d1cd03..fc508fd 100644
--- a/lib/decompress.c
+++ b/lib/decompress.c
@@ -17,6 +17,8 @@
 #include 
 #include 
 
+#include 
+
 #ifndef CONFIG_DECOMPRESS_GZIP
 # define gunzip NULL
 #endif
@@ -61,6 +63,8 @@ decompress_fn __init decompress_method(const unsigned char 
*inbuf, int len,
if (len < 2)
return NULL;/* Need at least this much... */
 
+   printk(KERN_DEBUG "Compressed data magic: %#.2x %#.2x\n", inbuf[0], 
inbuf[1]);
+
for (cf = compressed_formats; cf->name; cf++) {
if (!memcmp(inbuf, cf->magic, 2))
break;
-- 
Daniel M. Weeks
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: KSM on Android

2014-02-15 Thread Hugh Dickins
On Thu, 13 Feb 2014, Pradeep Sawlani wrote:
> Re-sending this in plain text format (Apologies)
> 
> Hello,
> 
> In pursuit of saving memory on Android, I started experimenting with
> Kernel Same Page Merging(KSM).
> Number of pages shared because of KSM is reported by
> /sys/kernel/mm/pages_sharing.
> Documentation/vm/ksm.txt explains this as:
> 
> "pages_sharing- how many more sites are sharing them i.e. how much saved"
> 
> After enabling KSM on Android device, this number was reported as 19666 pages.
> Obvious optimization is to find out source of sharing and see if we
> can avoid duplicate pages at first place.
> In order to collect the data needed, It needed few
> modifications(trace_printk) statement in mm/ksm.c.
> Data should be collected from second cycle because that's when ksm
> starts merging
> pages. First KSM cycle is only used to calculate the checksum, pages
> are added to
> unstable tree and eventually moved to stable tree after this.
> 
> After analyzing data from second KSM cycle, few things which stood out:
> 1.  In the same cycle, KSM can scan same page multiple times. Scanning
> a page involves
> comparing page with pages in stable tree, if no match is found
> checksum is calculated.
> From the look of it, it seems to be cpu intensive operation and
> impacts dcache as well.

Yes.

Of course you can adjust /sys/kernel/mm/ksm tunables to make it more
or less cpu and dcache intensive, and correspondingly more or less
effective in combining memory; but that's not really your interest.

> 
> 2.  Same page which is already shared by multiple process can be
> replaced by KSM page.
> In this case, let say a particular page is mapped 24 times and is
> replaced by KSM page then
> eventually all 24 entries will point to KSM page. pages_sharing
> will account for all 24 pages.
> so pages _sharing does not actually report amount of memory saved.
> From the above example actual
> savings is one page.

Yes.

KSM was created mainly to support KVM, where forking is not an issue,
I think.  I do remember fixing it early on, to stop it from converting
every forked page to a KSM page.  But you're right that once there is
a stable KSM page of particular content, forked instances of a page of
the same content will be peeled off one by one to be shared with the
KSM page, and the pages_sharing count claim more has been saved than
is actually so.

The easy fix to that is to remove "i.e. how much saved" from the
Documentation, or better, to qualify it by your point on forking.
But again, that's not really your interest.

Coming up with a supportable alternative or fix to pages_sharing:
it's not obvious to me how to go about that - whether or not to
decrement the count once a write COWs off an instance of the page.
Presumably it could be done, but at cost of recording more info in the
rmap_items: I doubt it would be worth the extra memory and processing.

Easier and less consuming might be to provide a running statistic of
the average page_mapcount of pages being shared into stable.  Or even
a tunable to refuse sharing into stable above a certain mapcount,
which could be set to 1 or something higher (or 0 for no limit).

> 
> Both cases happen very often with Android because of its architecture
> - Zygote spawning(fork) multiple
> applications. To calculate actual savings, we should account for same
> page(pfn)replaced by same KSM page only once.
> In the case 2 example, page_sharing should account only one page.
> After recalculating memory saving comes out to be 8602 pages (~34MB).
> 
> I am trying to find out right solution to fix pages_sharing and
> eventually optimize KSM to scan page
> once even if it is mapped multiple times.

To scan page once (each cycle) even if it is mapped multiple times:
that does sound a useful enhancement to make for the Android case
you describe.  I see two sides to that.

One is mapping the replacement page into all sites at the same time.
That sounds doable, but without actually attempting to do it, I'm
not at all sure.  It's interesting that try_to_merge_with_ksm_page()
works on one rmap_item and down_reads the corresponding mmap_sem,
but try_to_merge_one_page() itself does not use the rmap_item.
Lots to think about there: most particularly, what is that mmap_sem
protecting here?  Because it would not be protecting the other
instances that you replace.

Something it does protect is VM_MERGEABLE in vma->vm_flags: it's
a nuisance that VM_MERGEABLE might not be set in some of the vmas
sharing this page.

(By the way, if break_cow() poses a problem for you - break_cow()
being KSM's easy answer for backtracking, just COW back to ordinary
anon page if something goes wrong - and I've a feeling it might,
I do have a patch from a year ago which I never had time to write
up and complete testing on, which eliminates its use.)

The other side is cmp_and_merge_page() skipping a page which has
already been scanned this cycle via another mapping.  I think
the 

sched: fair: NULL ptr deref in check_preempt_wakeup

2014-02-15 Thread Sasha Levin

Hi folks,

While fuzzing with trinity inside a KVM tools guest running latest -next 
kernel, I've
stumbled on the following:

[  522.645288] BUG: unable to handle kernel NULL pointer dereference at 
0150
[  522.646271] IP: [] check_preempt_wakeup+0x11f/0x210
[  522.646976] PGD b0a79067 PUD ae9cf067 PMD 0
[  522.647494] Oops:  [#1] PREEMPT SMP
[  522.648000] Dumping ftrace buffer:
[  522.648380](ftrace buffer empty)
[  522.648775] Modules linked in:
[  522.649125] CPU: 0 PID: 11735 Comm: trinity-c50 Not tainted 
3.14.0-rc2-next-20140214-sasha-8-g95d9d16-dirty #85

[  522.650021] task: 8800c00bb000 ti: 88007fdb8000 task.ti: 
88007fdb8000
[  522.650021] RIP: 0010:[]  [] 
check_preempt_wakeup+0x11f/0x210
[  522.650021] RSP: 0018:880226e03ba8  EFLAGS: 00010046
[  522.650021] RAX:  RBX: 880226fd79c0 RCX: 0008
[  522.650021] RDX:  RSI: 880211313000 RDI: 000c
[  522.650021] RBP: 880226e03be8 R08:  R09: b4bb
[  522.650021] R10:  R11:  R12: 
[  522.650021] R13: 880211313068 R14: 8800c00bb000 R15: 
[  522.650021] FS:  7f435269f700() GS:880226e0() 
knlGS:
[  522.650021] CS:  0010 DS:  ES:  CR0: 8005003b
[  522.650021] CR2: 0150 CR3: abd2c000 CR4: 06f0
[  522.650021] DR0: 00995750 DR1:  DR2: 
[  522.650021] DR3:  DR6: 4ff0 DR7: 0600
[  522.650021] Stack:
[  522.650021]  880211313000 01ff880226fd79c0 880211313000 
880226fd79c0
[  522.650021]  880226fd79c0 880211313000  
880226e0
[  522.650021]  880226e03c08 8117361d 880226fd79c0 
880226fd79c0
[  522.650021] Call Trace:
[  522.650021]  
[  522.650021]  [] check_preempt_curr+0x3d/0xb0
[  522.650021]  [] ttwu_do_wakeup+0x18/0x130
[  522.650021]  [] T.2248+0x44/0x50
[  522.650021]  [] ttwu_queue+0xae/0xd0
[  522.650021]  [] ? try_to_wake_up+0x34/0x2a0
[  522.650021]  [] try_to_wake_up+0x264/0x2a0
[  522.650021]  [] ? __lock_acquired+0x2a2/0x2e0
[  522.650021]  [] default_wake_function+0xd/0x10
[  522.650021]  [] autoremove_wake_function+0x18/0x40
[  522.650021]  [] __wake_up_common+0x52/0x90
[  522.650021]  [] ? __wake_up+0x2d/0x70
[  522.650021]  [] __wake_up+0x43/0x70
[  522.650021]  [] p9_client_cb+0x43/0x70
[  522.650021]  [] req_done+0x105/0x110
[  522.650021]  [] vring_interrupt+0x86/0xa0
[  522.650021]  [] ? handle_irq_event+0x38/0x70
[  522.650021]  [] handle_irq_event_percpu+0x129/0x3a0
[  522.650021]  [] handle_irq_event+0x43/0x70
[  522.650021]  [] handle_edge_irq+0xe8/0x120
[  522.650021]  [] handle_irq+0x164/0x180
[  522.650021]  [] ? vtime_account_system+0x79/0x90
[  522.650021]  [] ? vtime_common_account_irq_enter+0x55/0x60
[  522.650021]  [] do_IRQ+0x59/0x100
[  522.650021]  [] common_interrupt+0x72/0x72
[  522.650021]  
[  522.650021]  [] ? context_tracking_user_exit+0x1a5/0x1c0
[  522.650021]  [] syscall_trace_enter+0x2d/0x280
[  522.650021]  [] tracesys+0x7e/0xe2
[  522.650021] Code: 0f 1f 40 00 ff c8 4d 8b ad 48 01 00 00 39 d0 7f f3 eb 18 66 0f 1f 84 00 00 00 
00 00 4d 8b a4 24 48 01 00 00 4d 8b ad 48 01 00 00 <49> 8b bc 24 50 01 00 00 49 3b bd 50 01 00 00 75 
e0 48 85 ff 74

[  522.650021] RIP  [] check_preempt_wakeup+0x11f/0x210
[  522.650021]  RSP 
[  522.650021] CR2: 0150
[  522.650021] ---[ end trace adce75aec8b1b32f ]---

Since it's pretty inlined, the code points to:

check_preempt_wakeup()
find_matching_se()
find_matching_se()
check_preempt_wakeup()


static inline struct cfs_rq *
is_same_group(struct sched_entity *se, struct sched_entity *pse)
{
if (se->cfs_rq == pse->cfs_rq)<=== HERE
return se->cfs_rq;

return NULL;
}


Thanks,
Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: [BUG] unable to handle kernel NULL pointer dereference

2014-02-15 Thread Borislav Petkov
On Sat, Feb 15, 2014 at 01:04:22PM -0800, John wrote:
> Thanks for the reply, Boris.  The .config is unmodified
> from the Arch Distro default for 3.13.3-1 which can be found
> here: http://pastebin.com/LPGZ8ZqA

Yep, it is that struct net *net argument to put_pipe_version() which is NULL:

  12:   55  push   %ebp
  13:   89 e5   mov%esp,%ebp
  15:   56  push   %esi
  16:   53  push   %ebx
  17:   3e 8d 74 26 00  lea%ds:0x0(%esi,%eiz,1),%esi
  1c:   8b 1d 28 e9 a3 f8   mov0xf8a3e928,%ebx
  22:   89 c6   mov%eax,%esi
  24:   e8 59 64 5f c8  call   0xc85f6482
  29:   85 db   test   %ebx,%ebx
  2b:*  8b 86 58 08 00 00   mov0x858(%esi),%eax <-- trapping 
instruction

put_pipe_version:
pushl   %ebp#
movl%esp, %ebp  #,
pushl   %esi#
pushl   %ebx#
callmcount
movlsunrpc_net_id, %ebx # sunrpc_net_id, sunrpc_net_id.130
movl%eax, %esi  # net, net
call__rcu_read_lock #
testl   %ebx, %ebx  # sunrpc_net_id.130
movl2136(%esi), %eax# MEM[(struct net_generic * const 
*)net_4(D) + 2136B], ng <-- trapping insn


[ 137.689996] ESI:  EDI: f56efc00 EBP: f568fee8 ESP: f568fee0
   

Here's the c/asm interleaved version:

static void put_pipe_version(struct net *net)
{
 d80:   55  push   %ebp
 d81:   89 e5   mov%esp,%ebp
 d83:   56  push   %esi
 d84:   53  push   %ebx
 d85:   e8 fc ff ff ff  call   d86 
d86: R_386_PC32 mcount
struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
 d8a:   8b 1d 00 00 00 00   mov0x0,%ebx
d8c: R_386_32   sunrpc_net_id
spin_unlock(_version_lock);
return ret;
}

static void put_pipe_version(struct net *net)
{
 d90:   89 c6   mov%eax,%esi
 * block, but only when acquiring spinlocks that are subject to priority
 * inheritance.
 */
static inline void rcu_read_lock(void)
{
__rcu_read_lock();
 d92:   e8 fc ff ff ff  call   d93 
d93: R_386_PC32 __rcu_read_lock
struct net_generic *ng;
void *ptr;

rcu_read_lock();
ng = rcu_dereference(net->gen);
BUG_ON(id == 0 || id > ng->len);
 d97:   85 db   test   %ebx,%ebx
{
struct net_generic *ng;
void *ptr;

rcu_read_lock();
ng = rcu_dereference(net->gen);
 d99:   8b 86 58 08 00 00   mov0x858(%esi),%eax 
<-- trapping insn


I guess you could avoid the crash if you did

if (!net)
return;

in put_pipe_version() but this hardly is the right solution. Someone
else has to make sense of this thing, not me. :-)

HTH.

-- 
Regards/Gruss,
Boris.

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


Re: [PATCH 02/11] vfs: More precise tests in d_invalidate

2014-02-15 Thread Eric W. Biederman
Linus Torvalds  writes:

> On Sat, Feb 15, 2014 at 2:51 PM, Linus Torvalds
>  wrote:
>>
>> the whole check_submounts_and_drop thing walks the parent chain and
>> locks each parent with the renamelock held for writing.
>
> Oops, my bad about the write lock, brainfart due to grepping and
> reading the wrong context...
>
> check_submounts_and_drop() doesn't do the parent walk with the rename
> lock held for writing, it just holds it for reading.
>
> But it does do that very complex "walk parents and check all siblings"
> and locks them, so the rest of the commentary was correct.

Except that today d_invalidate drops the dcache lock and
calls shrink_dcache_parent.  Which gets you into exactly the same
complex "walk parents and check all siblings" code.

The only difference between the shrink_dcache_parent and
check_submounts_and_drop (not counting the final drop)
is that check_submounts_and_drop aborts when it encounters a dentry
with d_mountpoint set.


So no I am not trying to hide something.  I called out that I changed
this logic in particular and this particular patch all I am doing is
killing the enforcing of 2.2 era logic.  Further I front loaded this
change so I bisect could point it's fingers at this before any other
substantial changes were made if this is indeed a problem.

Beyond that check_submounts_and_drop is what well maintained distributed
filesystems are calling from d_revalidate.


Now I would not be surprised if this change to d_invalidate is a
challenge to get your head around.  It took me a while of reading the
code to realize (a) how the code makes some degree of sense today,
and (b) that the change is semantically safe.


But when shrink_dcache_parent and check_submounts_and_drop are
effectiely the same function I can't possibly see how you can argue how
the locking has changed or that I am trying to hide things.

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


RE: [PATCH V6 1/1] Drivers: hv: Implement the file copy service

2014-02-15 Thread KY Srinivasan


> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Saturday, February 15, 2014 12:08 PM
> To: KY Srinivasan
> Cc: linux-kernel@vger.kernel.org; de...@linuxdriverproject.org; 
> o...@aepfle.de;
> a...@canonical.com; jasow...@redhat.com
> Subject: Re: [PATCH V6 1/1] Drivers: hv: Implement the file copy service
> 
> On Wed, Feb 12, 2014 at 10:14:03AM -0800, K. Y. Srinivasan wrote:
> > Implement the file copy service for Linux guests on Hyper-V. This permits 
> > the
> > host to copy a file (over VMBUS) into the guest. This facility is part of
> > "guest integration services" supported on the Windows platform.
> > Here is a link that provides additional details on this functionality:
> >
> > http://technet.microsoft.com/en-us/library/dn464282.aspx
> >
> > In V1 version of the patch I have addressed comments from
> > Olaf Hering  and Dan Carpenter
> 
> >
> > In V2 version of this patch I did some minor cleanup (making some globals
> > static). In V4 version of the patch I have addressed all of Olaf's
> > most recent set of comments/concerns.
> >
> > In V5 version of the patch I had addressed Greg's most recent comments.
> > I would like to thank Greg for suggesting that I use misc device; it has
> > significantly simplified the code.
> >
> > In this version of the patch I have cleaned up error message based on Olaf's
> > comments. I have also rebased the patch based on the current tip.
> >
> > Signed-off-by: K. Y. Srinivasan 
> > ---
> >  drivers/hv/Makefile |2 +-
> >  drivers/hv/hv_fcopy.c   |  388
> +++
> >  drivers/hv/hv_util.c|   10 +
> >  include/linux/hyperv.h  |   16 ++-
> >  include/uapi/linux/hyperv.h |   46 +
> >  tools/hv/hv_fcopy_daemon.c  |  195 ++
> >  6 files changed, 655 insertions(+), 2 deletions(-)
> >  create mode 100644 drivers/hv/hv_fcopy.c
> >  create mode 100644 tools/hv/hv_fcopy_daemon.c
> >
> > diff --git a/drivers/hv/Makefile b/drivers/hv/Makefile
> > index 0a74b56..5e4dfa4 100644
> > --- a/drivers/hv/Makefile
> > +++ b/drivers/hv/Makefile
> > @@ -5,4 +5,4 @@ obj-$(CONFIG_HYPERV_BALLOON)+= hv_balloon.o
> >  hv_vmbus-y := vmbus_drv.o \
> >  hv.o connection.o channel.o \
> >  channel_mgmt.o ring_buffer.o
> > -hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o
> > +hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o hv_fcopy.o
> > diff --git a/drivers/hv/hv_fcopy.c b/drivers/hv/hv_fcopy.c
> > new file mode 100644
> > index 000..15cf35c
> > --- /dev/null
> > +++ b/drivers/hv/hv_fcopy.c
> > @@ -0,0 +1,388 @@
> > +/*
> > + * An implementation of file copy service.
> > + *
> > + * Copyright (C) 2014, Microsoft, Inc.
> > + *
> > + * Author : K. Y. Srinivasan 
> > + *
> > + * This program is free software; you can redistribute it and/or modify it
> > + * under the terms of the GNU General Public License version 2 as published
> > + * by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it will be useful, but
> > + * WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE
> or
> > + * NON INFRINGEMENT.  See the GNU General Public License for more
> > + * details.
> > + *
> > + */
> > +
> > +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#define WIN8_SRV_MAJOR 1
> > +#define WIN8_SRV_MINOR 1
> > +#define WIN8_SRV_VERSION   (WIN8_SRV_MAJOR << 16 |
> WIN8_SRV_MINOR)
> > +
> > +/*
> > + * Global state maintained for transaction that is being processed.
> > + * For a class of integration services, including the "file copy service",
> > + * the specified protocol is a "request/response" protocol which means that
> > + * there can only be single outstanding transaction from the host at any
> > + * given point in time. We use this to simplify memory management in this
> > + * driver - we cache and process only one message at a time.
> > + *
> > + * While the request/response protocol is guaranteed by the host, we 
> > further
> > + * ensure this by serializing packet processing in this driver - we do not
> > + * read additional packets from the VMBUs until the current packet is fully
> > + * handled.
> > + *
> > + * The transaction "active" state is set when we receive a request from the
> > + * host and we cleanup this state when the transaction is completed - when
> we
> > + * respond to the host with our response. When the transaction active 
> > state is
> > + * set, we defer handling incoming packets.
> > + */
> > +
> > +static struct {
> > +   bool active; /* transaction status - active or not */
> > +   int recv_len; /* number of bytes received. */
> > +   struct hv_fcopy_hdr  *fcopy_msg; /* current message */
> > +   struct hv_start_fcopy  message; /*  

[PATCH] Fix flags for initramfs LZ4 compression

2014-02-15 Thread Daniel M. Weeks
LZ4 as implemented in the kernel differs from the default method now
used by the reference implementation of LZ4. Until the in-kernel method
is updated to support the new default, passing the legacy flag (-l) to
the compressor is necessary. Without this flag the kernel-generated,
LZ4-compressed initramfs is junk.

Signed-off-by: Daniel M. Weeks 
---
 scripts/gen_initramfs_list.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
index ef47409..17fa901 100644
--- a/scripts/gen_initramfs_list.sh
+++ b/scripts/gen_initramfs_list.sh
@@ -257,7 +257,7 @@ case "$arg" in
 && compr="lzop -9 -f"
echo "$output_file" | grep -q "\.lz4$" \
 && [ -x "`which lz4 2> /dev/null`" ] \
-&& compr="lz4 -9 -f"
+&& compr="lz4 -l -9 -f"
echo "$output_file" | grep -q "\.cpio$" && compr="cat"
shift
;;
-- 
Daniel M. Weeks
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: [CRIU] [PATCH 1/3] prctl: reduce permissions to change boundaries of data, brk and stack

2014-02-15 Thread Eric W. Biederman
Andrey Wagin  writes:

> 2014-02-14 23:16 GMT+04:00 Eric W. Biederman :
>>
>> Hmm.  Let me rewind this a little bit.
>>
>> I want to be very stupid and ask the following.
>>
>> Why can't you have the process of interest do:
>> ptrace(PTRACE_ATTACHME);
>> execve(executable, args, ...);
>>
>> /* Have the ptracer inject the recovery/fixup code */
>> /* Fix up the mostly correct process to look like it has been
>>  * executing for a while.
>>  */
>>
>> That should work, set all of the interesting fields, and works as
>> non-root today.  My gut feel says do that and we can just
>> deprecate/remove prctl_set_mm.
>
> start_brk and start_stack are randomized each time. I don't understand
> how execve() can restore the origin values of attributes.

As is the location of the vdso and there isn't a way to set that.

So perhaps what we want to do is to change the randomization with
mremap(old_addr, size, size, MREMAP_MAYMOVE | MREMAP_FIXED, new_addr)
and just have the kernel update all of the addresses in bulk when we
move the location.

I don't know what the folks who are worried about losing tampering
evidence will think but as a targeted special case it may not be at all
crazy.

Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: [CRIU] [PATCH 1/3] prctl: reduce permissions to change boundaries of data, brk and stack

2014-02-15 Thread Eric W. Biederman
Cyrill Gorcunov  writes:

> On Fri, Feb 14, 2014 at 12:18:46PM -0800, Eric W. Biederman wrote:
>> >> > 
>> >> > Why can't you have the process of interest do:
>> >> > ptrace(PTRACE_ATTACHME);
>> >> > execve(executable, args, ...);
>> >> > 
>> >> > /* Have the ptracer inject the recovery/fixup code */
>> >> > /* Fix up the mostly correct process to look like it has 
>> >> > been
>> >> >  * executing for a while.
>> >> >  */
>> >
>> > Erik, it seems I don't understand how it will help us to restore
>> > the mm fields mentioned above?
>> 
>> Because exec is how those mm fields are set when you don't use
>> prctl_set_mm.  So execpt for the stack and the brk limits that
>> will simply result in the values being set to what the usually
>> would be set to.
>
> Yes, all these fields are set up by kernel's elf loader but this
> routine is a way more time consuming than a clone call. But gimme
> some time to examine all possible problems we might have with such
> approach and if there a way to solve them.

Sure.

The really useful observation in all of this is that with exec we have
methods where we allow unprivileged setting of these fields already.  So
it is essentially concerns about applictions being stupid (resource
control) and applications being compromised with evil code and the trace
evidence being hidden that we are trying to protect by limiting changes
to these fields.

So if we can come up with a method that doesn't violate those
invariants, and doesn't lead to massive code maintenance we should be
good.  Reusing exec is just the easiest way to get there.

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


Re: [PATCH 02/11] vfs: More precise tests in d_invalidate

2014-02-15 Thread Linus Torvalds
On Sat, Feb 15, 2014 at 2:51 PM, Linus Torvalds
 wrote:
>
> the whole check_submounts_and_drop thing walks the parent chain and
> locks each parent with the renamelock held for writing.

Oops, my bad about the write lock, brainfart due to grepping and
reading the wrong context...

check_submounts_and_drop() doesn't do the parent walk with the rename
lock held for writing, it just holds it for reading.

But it does do that very complex "walk parents and check all siblings"
and locks them, so the rest of the commentary was correct.

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


Re: [PATCH] kbuild: unconditionally clobber include/linux/version.h on distclean

2014-02-15 Thread David Howells
Paul Gortmaker  wrote:

> As of v3.7, the UAPI changes relocated headers around such that the
> kernel version header lived in a new place.
> 
> If a person is bisecting and if you go back to pre-UAPI days,
> you will create an include/linux/version.h  -- then if you checkout a
> post-UAPI kernel, and even run "make distclean" it still won't delete
> that old version file.  So you get a situation like this:
> 
> $ grep -R LINUX_VERSION_CODE include/
> include/generated/uapi/linux/version.h:#define LINUX_VERSION_CODE 200192
> include/linux/version.h:#define LINUX_VERSION_CODE 132646
> 
> The value in that second line is representative of a v2.6.38 version.
> And it will be sourced/used, hence leading to strange behaviours, such
> as drivers/staging content (which typically hasn't been purged of version
> ifdefs) failing to build.
> 
> Since it is a subtle mode of failure, lets always clobber the old
> file when doing a distclean.
> 
> Cc: Michal Marek 
> Cc: David Howells 
> Signed-off-by: Paul Gortmaker 

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


Re: [PATCH 02/11] vfs: More precise tests in d_invalidate

2014-02-15 Thread Linus Torvalds
On Sat, Feb 15, 2014 at 1:36 PM, Eric W. Biederman
 wrote:
>
> The one difference between d_invalidate and check_submounts_and_drop
> is that d_invalidate must respect it when a d_revalidate method has
> earlier called d_drop so preserve the d_unhashed check in
> d_invalidate.

What?

There's another *huge* difference, namely locking. Your change has
huge detrimental effects wrt d_lock - not only do you drop it for the
local dentry (to then re-take it in check_submounts_and_drop()), but
the whole check_submounts_and_drop thing walks the parent chain and
locks each parent with the renamelock held for writing.

So NAK on this patch, if for no other reason that you are not talking
about the *huge* locking changes at all, and apparently completely
ignored them.

It's possible that you can argue that performance doesn't matter, and
that all the extra huge locking overhead is immaterial because this is
not commonly called, but no way in hell can I accept a patch with a
commit message that basically lies by omission about what it is doing.

This kills the whole series for me. I'm not going to bother trying to
review the rest of the patches when the second patch already makes me
go "Eric is trying to hide things". Because the locking changes aren't
obvious in the patch without knowing what else is going on, and they
certainly aren't mentioned in the commit message.

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


Re: 3.14-rc2 XFS backtrace because irqs_disabled.

2014-02-15 Thread Linus Torvalds
On Sat, Feb 15, 2014 at 2:28 PM, Dave Jones  wrote:
>
> I've got a shitload of debug options enabled, which may explain it.
> Or perhaps that new STACK_PROTECTOR_STRONG stuff ?

Well, a lot of it is just the callee-saved registers. The compiler
will tend to preferentially allocate registers in the callee-trashed
registers, but if the function isn't a leaf function, any registers
that are live around a function call will have to be saved somewhere -
either explicitly around the function call, or - more likely - in
callee-saved registers that then get saved in the prologue/epilogue of
the function. And this will happen even in leaf functions when there
is enough register pressure that the callee-trashed registers aren't
sufficient (which is pretty common).

So saving 5-6 registers on the stack (in addition to any actual stack
frame) is pretty much the norm for anything but the very simplest
cases.

But yeah, I'm sure some config options make it worse.
STACK_PROTECTOR_STRONG could easily be one of those.

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


Re: [PATCH v2] Bluetooth: Add hci_h4p driver

2014-02-15 Thread Pavel Machek
Hi!

> > >> > Firmware files are available for download from nemo project:
> > >> >
> > >> > https://api.merproject.org/public/source/nemo:devel:hw:ti:om
> > >> > ap3:n900/bcm-bt-firmware/bcm-bt-firmware-0.21rc3.tar.bz2
> > >> > https://api.merproject.org/public/source/nemo:devel:hw:ti:o
> > >> > map3:n950-n9/ti-wl1273-bt-firmware/bt-firmware-ti1273_0.23+0
> > >> > m6.tar.gz
> > >>
> > >> Would be nice to have them added to the linux-firmware.git.
> > >
> > Now when driver is queued for staging, can somebody add firmware files
> > to linux-firmware repository? Note that without firmware files, driver
> > not working...
> 
> I just had a look at the file for the Nokia N900
> (bcm-bt-firmware-0.21rc3.tar.bz2) and I think the license is too
> restrictive for linux-firmware.git. Actually I can't see any
> statement allowing redistribution. For reference this is the license
> text:
> 
> Copyright (c) Nokia Corporation 2010
> All Rights Reserved.
> 
> This material, including documentation and any related computer programs, is
> protected by copyright controlled by Nokia Corporation. All rights are
> reserved. Modifying, adapting and/or translating, any or all of this material
> requires the prior written consent of Nokia. Distribution for commercial
> purposes not allowed without prior written approval from Nokia.

With my lingvistics hat on, this says "distribution for non-commercial
purposes is ok". (Because otherwise, they would say "Distribution not
allowed without ...") 
Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: 3.14-rc2 XFS backtrace because irqs_disabled.

2014-02-15 Thread Dave Jones
On Sun, Feb 16, 2014 at 09:23:56AM +1100, Dave Chinner wrote:
 
 > There's a pretty massive difference between the actual stack usage
 > of the local variables and the amount of stack being used by the
 > compiled code.
 > 
 > What it appears to be is that the compiler is pushing 6-10 registers
 > to the stack on every function call. So a function that only has 3
 > local variables and does very little but allocate a structure and
 > call other functions saves an 6 registers to the stack before it
 > starts:

I've got a shitload of debug options enabled, which may explain it.
Or perhaps that new STACK_PROTECTOR_STRONG stuff ?

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


Re: 3.14-rc2 XFS backtrace because irqs_disabled.

2014-02-15 Thread Dave Chinner
On Fri, Feb 14, 2014 at 11:01:23AM -0500, Dave Jones wrote:
> On Fri, Feb 14, 2014 at 11:24:27AM +1100, Dave Chinner wrote:
>  
>  > > I can fix this one easily - we already have a workqueue for doing
>  > > async log pushes (will split the stack between xlog_cil_force_lsn
>  > > and xlog_cil_push), but the reason we haven't used it for synchronous
>  > > log forces is that screws up fsync performance on CFQ. We don't
>  > > recommend CFQ with XFS anyway, so I think I'll make this change
>  > > anyway.
>  > 
>  > Dave, the patch below should chop off the stack usage from
>  > xfs_log_force_lsn() issuing IO by deferring it to the CIL workqueue.
>  > Can you given this a run?
> 
> Looks like it's survived an overnight run..

Great.

One thing that has been puzzling me is why I'm seeing stack usage
reported that is way above what we declare locally on the stack.
e.g.

 29) 2048 224   xfs_da_grow_inode_int+0xbb/0x340
 30) 1824  96   xfs_dir2_grow_inode+0x63/0x110
 31) 1728 208   xfs_dir2_sf_to_block+0xe7/0x5e0
 32) 1520 144   xfs_dir2_sf_addname+0x115/0x5c0
 33) 1376  96   xfs_dir_createname+0x164/0x1a0
 34) 1280 224   xfs_create+0x536/0x660
 35) 1056 128   xfs_vn_mknod+0xc8/0x1d0

I pulled 128 bytes out of xfs_dir_createname by allocating the
xfs_da_args structure, but I still couldn't reconcile the amount of
stack use being reported with the amount used by locally declared
variables (even considering in-lined leaf functions). For example:

Locally
DeclaredUsed   function
  88 224   xfs_da_grow_inode_int
  32  96   xfs_dir2_grow_inode
 168 208   xfs_dir2_sf_to_block
  56 144   xfs_dir2_sf_addname
  16  96   xfs_dir_createname
 120 224   xfs_create
  52 128   xfs_vn_mknod

There's a pretty massive difference between the actual stack usage
of the local variables and the amount of stack being used by the
compiled code.

What it appears to be is that the compiler is pushing 6-10 registers
to the stack on every function call. So a function that only has 3
local variables and does very little but allocate a structure and
call other functions saves an 6 registers to the stack before it
starts:

Dump of assembler code for function xfs_dir_createname:
214 {
   0x814d7380 <+0>: callq  0x81cf0940
   0x814d7385 <+5>: push   %rbp
   0x814d7386 <+6>: mov%rsp,%rbp
   0x814d7389 <+9>: sub$0x50,%rsp
   0x814d738d <+13>:mov%rbx,-0x28(%rbp)
   0x814d7391 <+17>:mov%rdi,%rbx
   0x814d7394 <+20>:mov%r12,-0x20(%rbp)
   0x814d7398 <+24>:mov%rcx,%r12
   0x814d739b <+27>:mov%r13,-0x18(%rbp)
   0x814d739f <+31>:mov%rsi,%r13
   0x814d73a5 <+37>:mov%r14,-0x10(%rbp)
   0x814d73a9 <+41>:mov%rdx,%r14
   0x814d73ac <+44>:mov%r15,-0x8(%rbp)
   0x814d73b0 <+48>:mov%r8,%r15
   0x814d73b7 <+55>:mov%r9,-0x48(%rbp)
.

If this is typical across the call chain (appears to be from my
quick survey) then we are averaging 40-50 bytes of stack per
call for saved registers. That's a lot of stack space we can't
directly control the usage of, especially when we are talking about
call chains that can get 50+ functions deep...

Cheers,

Dave.
-- 
Dave Chinner
da...@fromorbit.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/


[PATCH 11/11] proc: Update proc_flush_task_mnt to use d_invalidate

2014-02-15 Thread Eric W. Biederman

Now that d_invalidate always succeeds and flushes mount points use
it in stead of a combination of shrink_dcache_parent and d_drop
in proc_flush_task_mnt.  This removes the danger of a mount point
under /proc//... becoming unreachable after the d_drop.

Signed-off-by: "Eric W. Biederman" 
---
 fs/proc/base.c |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index aa62b37f1303..40d97e576d32 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2700,8 +2700,7 @@ static void proc_flush_task_mnt(struct vfsmount *mnt, 
pid_t pid, pid_t tgid)
/* no ->d_hash() rejects on procfs */
dentry = d_hash_and_lookup(mnt->mnt_root, );
if (dentry) {
-   shrink_dcache_parent(dentry);
-   d_drop(dentry);
+   d_invalidate(dentry);
dput(dentry);
}
 
@@ -2721,8 +2720,7 @@ static void proc_flush_task_mnt(struct vfsmount *mnt, 
pid_t pid, pid_t tgid)
name.len = snprintf(buf, sizeof(buf), "%d", pid);
dentry = d_hash_and_lookup(dir, );
if (dentry) {
-   shrink_dcache_parent(dentry);
-   d_drop(dentry);
+   d_invalidate(dentry);
dput(dentry);
}
 
-- 
1.7.5.4

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


[PATCH 10/11] vfs: Remove d_drop calls from d_revalidate implementations

2014-02-15 Thread Eric W. Biederman

Now that d_invalidate always succeeds it is not longer necessary or
desirable to hard code d_drop calls into filesystem specific
d_revalidate implementations.

Remove the unnecessary d_drop calls and rely on d_invalidate
to drop the dentries.  Using d_invalidate ensures that paths
to mount points will not be dropped.

Signed-off-by: "Eric W. Biederman" 
---
 fs/ceph/dir.c  |1 -
 fs/proc/base.c |4 
 fs/proc/fd.c   |2 --
 3 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 6da4df84ba30..ecd2402739e2 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -1052,7 +1052,6 @@ static int ceph_d_revalidate(struct dentry *dentry, 
unsigned int flags)
ceph_dentry_lru_touch(dentry);
} else {
ceph_dir_clear_complete(dir);
-   d_drop(dentry);
}
iput(dir);
return valid;
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 51507065263b..aa62b37f1303 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1654,7 +1654,6 @@ int pid_revalidate(struct dentry *dentry, unsigned int 
flags)
put_task_struct(task);
return 1;
}
-   d_drop(dentry);
return 0;
 }
 
@@ -1791,9 +1790,6 @@ out:
put_task_struct(task);
 
 out_notask:
-   if (status <= 0)
-   d_drop(dentry);
-
return status;
 }
 
diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index 985ea881b5bc..7e4f04ccab31 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -127,8 +127,6 @@ static int tid_fd_revalidate(struct dentry *dentry, 
unsigned int flags)
}
put_task_struct(task);
}
-
-   d_drop(dentry);
return 0;
 }
 
-- 
1.7.5.4

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


[PATCH 09/11] vfs: Make d_invalidate return void

2014-02-15 Thread Eric W. Biederman

Now that d_invalidate can no longer fail, stop returning a useless
return code.  For the few callers that checked the return code update
remove the handling of d_invalidate failure.

Signed-off-by: "Eric W. Biederman" 
---
 fs/btrfs/ioctl.c   |5 +
 fs/cifs/readdir.c  |6 +-
 fs/dcache.c|   12 +++-
 fs/fuse/dir.c  |4 +---
 fs/namei.c |   10 +-
 fs/nfs/dir.c   |3 +--
 include/linux/dcache.h |2 +-
 7 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index b0134892dc70..349848bd54e2 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2229,9 +2229,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file 
*file,
}
 
mutex_lock(>i_mutex);
-   err = d_invalidate(dentry);
-   if (err)
-   goto out_unlock;
+   d_invalidate(dentry);
 
down_write(>fs_info->subvol_sem);
 
@@ -2316,7 +2314,6 @@ out_release:
btrfs_subvolume_release_metadata(root, _rsv, qgroup_reserved);
 out_up_write:
up_write(>fs_info->subvol_sem);
-out_unlock:
mutex_unlock(>i_mutex);
if (!err) {
shrink_dcache_sb(root->fs_info->sb);
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index b15862e0f68c..d0e9d0169b37 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -87,8 +87,6 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,
return;
 
if (dentry) {
-   int err;
-
inode = dentry->d_inode;
if (inode) {
/*
@@ -105,10 +103,8 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,
goto out;
}
}
-   err = d_invalidate(dentry);
+   d_invalidate(dentry);
dput(dentry);
-   if (err)
-   return;
}
 
/*
diff --git a/fs/dcache.c b/fs/dcache.c
index 5b41205cbf33..5b78bd98649c 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1377,27 +1377,21 @@ static void check_and_drop(void *_data)
  * d_invalidate - detach submounts, prune dcache, and drop
  * @dentry: dentry to invalidate (aka detach, prune and drop)
  *
- * Try to invalidate the dentry if it turns out to be
- * possible. If there are reasons not to delete it
- * return -EBUSY. On success return 0.
- *
  * no dcache lock.
  *
  * The final d_drop is done as an atomic operation relative to
  * rename_lock ensuring there are no races with d_set_mounted.  This
  * ensures there are no unhashed dentries on the path to a mountpoint.
  */
-int d_invalidate(struct dentry *dentry)
+void d_invalidate(struct dentry *dentry)
 {
-   int ret = 0;
-
/*
 * If it's already been dropped, return OK.
 */
spin_lock(>d_lock);
if (d_unhashed(dentry)) {
spin_unlock(>d_lock);
-   return 0;
+   return;
}
spin_unlock(>d_lock);
 
@@ -1432,7 +1426,7 @@ int d_invalidate(struct dentry *dentry)
}
 
 out:
-   return ret;
+   return;
 }
 EXPORT_SYMBOL(d_invalidate);
 
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 5192d0a04d20..6e920fadb45d 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1225,9 +1225,7 @@ static int fuse_direntplus_link(struct file *file,
d_drop(dentry);
} else if (get_node_id(inode) != o->nodeid ||
   ((o->attr.mode ^ inode->i_mode) & S_IFMT)) {
-   err = d_invalidate(dentry);
-   if (err)
-   goto out;
+   d_invalidate(dentry);
} else if (is_bad_inode(inode)) {
err = -EIO;
goto out;
diff --git a/fs/namei.c b/fs/namei.c
index 3fca30cd448b..384fcc6a5606 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1259,7 +1259,8 @@ static struct dentry *lookup_dcache(struct qstr *name, 
struct dentry *dir,
if (error < 0) {
dput(dentry);
return ERR_PTR(error);
-   } else if (!d_invalidate(dentry)) {
+   } else {
+   d_invalidate(dentry);
dput(dentry);
dentry = NULL;
}
@@ -1391,10 +1392,9 @@ unlazy:
dput(dentry);
return status;
}
-   if (!d_invalidate(dentry)) {
-   dput(dentry);
-   goto need_lookup;
-   }
+   d_invalidate(dentry);
+   dput(dentry);
+   goto need_lookup;
}
 
path->mnt = mnt;
diff --git 

inotify cookie regression/info leak in latest mainline

2014-02-15 Thread Vegard Nossum

Hi,

It would seem that

commit 7053aee26a3548ebaba046ae2e52396ccf56ac6c
Author: Jan Kara 
Date:   Tue Jan 21 15:48:14 2014 -0800

fsnotify: do not share events between notification groups

introduced a bug where the cookie field of struct inotify_event never 
gets initialised. In particular, it used to be initialised when 
send_to_group() called fsnotify_create_event(), but that no longer 
happens, and the 'cookie' parameter of send_to_group() never gets used.


The problem manifests itself in copy_event_to_user() where the cookie 
field is copied to userspace without being initialised.


I tested this with a simple userspace program, I seem to get mostly 
0x8800 in the cookie field for non-move events (which should always 
have 0 here).



Vegard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 07/11] vfs: Remove unnecessary calls of check_submounts_and_drop

2014-02-15 Thread Eric W. Biederman

Now that check_submounts_and_drop can not fail and is called from
d_invalidate there is no longer a need to call check_submounts_and_drom
from filesystem d_revalidate methods so remove it.

Signed-off-by: "Eric W. Biederman" 
---
 fs/afs/dir.c |5 -
 fs/fuse/dir.c|3 ---
 fs/gfs2/dentry.c |3 ---
 fs/kernfs/dir.c  |   11 ---
 fs/nfs/dir.c |4 
 5 files changed, 0 insertions(+), 26 deletions(-)

diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 529300327f45..a1645b88fe8a 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -669,7 +669,6 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned 
int flags)
 
 out_valid:
dentry->d_fsdata = dir_version;
-out_skip:
dput(parent);
key_put(key);
_leave(" = 1 [valid]");
@@ -682,10 +681,6 @@ not_found:
spin_unlock(>d_lock);
 
 out_bad:
-   /* don't unhash if we have submounts */
-   if (check_submounts_and_drop(dentry) != 0)
-   goto out_skip;
-
_debug("dropping dentry %s/%s",
   parent->d_name.name, dentry->d_name.name);
dput(parent);
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 1d1292c581c3..5192d0a04d20 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -273,9 +273,6 @@ out:
 
 invalid:
ret = 0;
-
-   if (!(flags & LOOKUP_RCU) && check_submounts_and_drop(entry) != 0)
-   ret = 1;
goto out;
 }
 
diff --git a/fs/gfs2/dentry.c b/fs/gfs2/dentry.c
index d3a5d4e29ba5..589f4ea9381c 100644
--- a/fs/gfs2/dentry.c
+++ b/fs/gfs2/dentry.c
@@ -93,9 +93,6 @@ invalid_gunlock:
if (!had_lock)
gfs2_glock_dq_uninit(_gh);
 invalid:
-   if (check_submounts_and_drop(dentry) != 0)
-   goto valid;
-
dput(parent);
return 0;
 
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 5104cf5d25c5..43d5ab905238 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -296,21 +296,10 @@ static int kernfs_dop_revalidate(struct dentry *dentry, 
unsigned int flags)
goto out_bad;
 
mutex_unlock(_mutex);
-out_valid:
return 1;
 out_bad:
mutex_unlock(_mutex);
 out_bad_unlocked:
-   /*
-* @dentry doesn't match the underlying kernfs node, drop the
-* dentry and force lookup.  If we have submounts we must allow the
-* vfs caches to lie about the state of the filesystem to prevent
-* leaks and other nasty things, so use check_submounts_and_drop()
-* instead of d_drop().
-*/
-   if (check_submounts_and_drop(dentry) != 0)
-   goto out_valid;
-
return 0;
 }
 
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index be38b573495a..a8a2f7f86c45 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1143,10 +1143,6 @@ out_zap_parent:
if (IS_ROOT(dentry))
goto out_valid;
}
-   /* If we have submounts, don't unhash ! */
-   if (check_submounts_and_drop(dentry) != 0)
-   goto out_valid;
-
dput(parent);
dfprintk(LOOKUPCACHE, "NFS: %s(%pd2) is invalid\n",
__func__, dentry);
-- 
1.7.5.4

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


Re: [PATCH 03/19] lto: Make asmlinkage __visible

2014-02-15 Thread Sam Ravnborg
On Fri, Feb 14, 2014 at 10:21:27PM +0100, Andi Kleen wrote:
> From: Andi Kleen 
> 
> Note this causes warnings for static asmlinkage, which
> is used in some places. These can be later cleaned up.
> static asmlinkage usually makes no sense.
> 

Reading the above changelog - it does not justify *why* asmlinkage
is made visible.

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


[PATCH 08/11] vfs: Merge check_submounts_and_drop and d_invalidate

2014-02-15 Thread Eric W. Biederman

Now that d_invalidate is the only caller of check_submounts_and_drop,
expand check_submounts_and_drop inline in d_invalidate.

Signed-off-by: "Eric W. Biederman" 
---
 fs/dcache.c|   55 +++
 include/linux/dcache.h |1 -
 2 files changed, 22 insertions(+), 34 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 27585b1dd6f1..5b41205cbf33 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -608,32 +608,6 @@ kill_it:
 }
 EXPORT_SYMBOL(dput);
 
-/**
- * d_invalidate - invalidate a dentry
- * @dentry: dentry to invalidate
- *
- * Try to invalidate the dentry if it turns out to be
- * possible. If there are reasons not to delete it
- * return -EBUSY. On success return 0.
- *
- * no dcache lock.
- */
- 
-int d_invalidate(struct dentry * dentry)
-{
-   /*
-* If it's already been dropped, return OK.
-*/
-   spin_lock(>d_lock);
-   if (d_unhashed(dentry)) {
-   spin_unlock(>d_lock);
-   return 0;
-   }
-   spin_unlock(>d_lock);
-
-   return check_submounts_and_drop(dentry);
-}
-EXPORT_SYMBOL(d_invalidate);
 
 /* This must be called with d_lock held */
 static inline void __dget_dlock(struct dentry *dentry)
@@ -1175,7 +1149,7 @@ EXPORT_SYMBOL(have_submounts);
  * reachable (e.g. NFS can unhash a directory dentry and then the complete
  * subtree can become unreachable).
  *
- * Only one of check_submounts_and_drop() and d_set_mounted() must succeed.  
For
+ * Only one of d_invalidate() and d_set_mounted() must succeed.  For
  * this reason take rename_lock and d_lock on dentry and ancestors.
  */
 int d_set_mounted(struct dentry *dentry)
@@ -1184,7 +1158,7 @@ int d_set_mounted(struct dentry *dentry)
int ret = -ENOENT;
write_seqlock(_lock);
for (p = dentry->d_parent; !IS_ROOT(p); p = p->d_parent) {
-   /* Need exclusion wrt. check_submounts_and_drop() */
+   /* Need exclusion wrt. d_invalidate() */
spin_lock(>d_lock);
if (unlikely(d_unhashed(p))) {
spin_unlock(>d_lock);
@@ -1400,18 +1374,33 @@ static void check_and_drop(void *_data)
 }
 
 /**
- * check_submounts_and_drop - detach submounts, prune dcache, and drop
+ * d_invalidate - detach submounts, prune dcache, and drop
+ * @dentry: dentry to invalidate (aka detach, prune and drop)
+ *
+ * Try to invalidate the dentry if it turns out to be
+ * possible. If there are reasons not to delete it
+ * return -EBUSY. On success return 0.
+ *
+ * no dcache lock.
  *
  * The final d_drop is done as an atomic operation relative to
  * rename_lock ensuring there are no races with d_set_mounted.  This
  * ensures there are no unhashed dentries on the path to a mountpoint.
- *
- * @dentry: dentry to detach, prune and drop
  */
-int check_submounts_and_drop(struct dentry *dentry)
+int d_invalidate(struct dentry *dentry)
 {
int ret = 0;
 
+   /*
+* If it's already been dropped, return OK.
+*/
+   spin_lock(>d_lock);
+   if (d_unhashed(dentry)) {
+   spin_unlock(>d_lock);
+   return 0;
+   }
+   spin_unlock(>d_lock);
+
/* Negative dentries can be dropped without further checks */
if (!dentry->d_inode) {
d_drop(dentry);
@@ -1445,7 +1434,7 @@ int check_submounts_and_drop(struct dentry *dentry)
 out:
return ret;
 }
-EXPORT_SYMBOL(check_submounts_and_drop);
+EXPORT_SYMBOL(d_invalidate);
 
 /**
  * __d_alloc   -   allocate a dcache entry
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index bf72e9ac6de0..ae77222c3e86 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -265,7 +265,6 @@ extern void d_prune_aliases(struct inode *);
 
 /* test whether we have any submounts in a subdir tree */
 extern int have_submounts(struct dentry *);
-extern int check_submounts_and_drop(struct dentry *);
 
 /*
  * This adds the entry to the hash queues.
-- 
1.7.5.4

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


[PATCH 06/11] vfs: Lazily remove mounts on unlinked files and directories.

2014-02-15 Thread Eric W. Biederman

With the introduction of mount namespaces and bind mounts it became
possible to access files and directories that on some paths are mount
points but are not mount points on other paths.  It is very confusing
when rm -rf somedir returns -EBUSY simply because somedir is mounted
somewhere else.  With the addition of user namespaces allowing
unprivileged mounts this condition has gone from annoying to allowing
a DOS attack on other users in the system.

The possibility for mischief is removed by updating the vfs to support
rename, unlink and rmdir on a dentry that is a mountpoint and by
lazily unmounting mountpoints on deleted dentries.

In particular this change allows rename, unlink and rmdir system calls
on a dentry without a mountpoint in the current mount namespace to
succeed, and it allows rename, unlink, and rmdir performed on a
distributed filesystem to update the vfs cache even if when there is a
mount in some namespace on the original dentry.

There are two common patterns of maintaining mounts: Mounts on trusted
paths with the parent directory of the mount point and all ancestory
directories up to / owned by root and modifiable only by root
(i.e. /media/xxx, /dev, /dev/pts, /proc, /sys, /sys/fs/cgroup/{cpu,
cpuacct, ...}, /usr, /usr/local).  Mounts on unprivileged directories
maintained by fusermount.

In the case of mounts in trusted directories owned by root and
modifiable only by root the current parent directory permissions are
sufficient to ensure a mount point on a trusted path is not removed
or renamed by anyone other than root, even if there is a context
where the there are no mount points to prevent this.

In the case of mounts in directories owned by less privileged users
races with users modifying the path of a mount point are already a
danger.  fusermount already uses a combination of chdir,
/proc//fd/NNN, and UMOUNT_NOFOLLOW to prevent these races.  The
removable of global rename, unlink, and rmdir protection really adds
nothing new to consider only a widening of the attack window, and
fusermount is already safe against unprivileged users modifying the
directory simultaneously.

In principle for perfect userspace programs returning -EBUSY for
unlink, rmdir, and rename of dentires that have mounts in the local
namespace is actually unnecessary.  Unfortunately not all userspace
programs are perfect so retaining -EBUSY for unlink, rmdir and rename
of dentries that have mounts in the current mount namespace plays an
important role of maintaining consistency with historical behavior and
making imperfect userspace applications hard to exploit.

v2: Remove spurious old_dentry.
v3: Optimized shrink_submounts_and_drop
Removed unsued afs label
v4: Simplified the changes to check_submounts_and_drop
Do not rename check_submounts_and_drop shrink_submounts_and_drop
Document what why we need atomicity in check_submounts_and_drop
Rely on the parent inode mutex to make d_revalidate and d_invalidate
an atomic unit.
v5: Refcount the mountpoint to detach in case of simultaneous
renames.

Signed-off-by: "Eric W. Biederman" 
---
 fs/dcache.c |   60 --
 fs/namei.c  |   18 
 2 files changed, 42 insertions(+), 36 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index b0add629f5fe..27585b1dd6f1 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1374,36 +1374,39 @@ void shrink_dcache_for_umount(struct super_block *sb)
}
 }
 
-static enum d_walk_ret check_and_collect(void *_data, struct dentry *dentry)
+struct detach_data {
+   struct select_data select;
+   struct dentry *mountpoint;
+};
+static enum d_walk_ret detach_and_collect(void *_data, struct dentry *dentry)
 {
-   struct select_data *data = _data;
+   struct detach_data *data = _data;
 
if (d_mountpoint(dentry)) {
-   data->found = -EBUSY;
+   __dget_dlock(dentry);
+   data->mountpoint = dentry;
return D_WALK_QUIT;
}
 
-   return select_collect(_data, dentry);
+   return select_collect(>select, dentry);
 }
 
 static void check_and_drop(void *_data)
 {
-   struct select_data *data = _data;
+   struct detach_data *data = _data;
 
-   if (d_mountpoint(data->start))
-   data->found = -EBUSY;
-   if (!data->found)
-   __d_drop(data->start);
+   if (!data->mountpoint && !data->select.found)
+   __d_drop(data->select.start);
 }
 
 /**
- * check_submounts_and_drop - prune dcache, check for submounts and drop
+ * check_submounts_and_drop - detach submounts, prune dcache, and drop
  *
- * All done as a single atomic operation relative to has_unlinked_ancestor().
- * Returns 0 if successfully unhashed @parent.  If there were submounts then
- * return -EBUSY.
+ * The final d_drop is done as an atomic operation relative to
+ * rename_lock ensuring there are no races with d_set_mounted.  This
+ * ensures there are no 

[PATCH 05/11] vfs: Add a function to lazily unmount all mounts from any dentry.

2014-02-15 Thread Eric W. Biederman

v2: Always drop the lock when exiting early.
v3: Make detach_mounts robust about freeing several
mounts on the same mountpoint at one time, and remove
the unneeded mnt_list list test.
v4: Document the purpose of detach_mounts and why new_mountpoint is
safe to call.

Signed-off-by: Eric W. Biederman 
---
 fs/mount.h |2 ++
 fs/namespace.c |   39 +++
 2 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/fs/mount.h b/fs/mount.h
index 50a72d46e7a6..2b470f34e665 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -84,6 +84,8 @@ extern struct mount *__lookup_mnt_last(struct vfsmount *, 
struct dentry *);
 
 extern bool legitimize_mnt(struct vfsmount *, unsigned);
 
+extern void detach_mounts(struct dentry *dentry);
+
 static inline void get_mnt_ns(struct mnt_namespace *ns)
 {
atomic_inc(>count);
diff --git a/fs/namespace.c b/fs/namespace.c
index 33db9e95bd5c..7abbf722ce18 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1359,6 +1359,45 @@ static int do_umount(struct mount *mnt, int flags)
return retval;
 }
 
+/*
+ * detach_mounts - lazily unmount all mounts on the specified dentry
+ *
+ * During unlink, rmdir, and d_drop it is possible to loose the path
+ * to an existing mountpoint, and wind up leaking the mount.
+ * detach_mounts allows lazily unmounting those mounts instead of
+ * leaking them.
+ * 
+ * The caller may hold dentry->d_inode->i_mutex.
+ */
+void detach_mounts(struct dentry *dentry)
+{
+   struct mountpoint *mp;
+   struct mount *mnt;
+
+   namespace_lock();
+   if (!d_mountpoint(dentry))
+   goto out_unlock;
+
+   /* 
+* The namespace lock and d_mountpoint being set guarantees
+* that new_mountpoint will just be a lookup of the existing
+* mountpoint structure.
+*/
+   mp = new_mountpoint(dentry);
+   if (IS_ERR(mp))
+   goto out_unlock;
+
+   lock_mount_hash();
+   while (!list_empty(>m_list)) {
+   mnt = list_first_entry(>m_list, struct mount, mnt_mp_list);
+   umount_tree(mnt, 1);
+   }
+   unlock_mount_hash();
+   put_mountpoint(mp);
+out_unlock:
+   namespace_unlock();
+}
+
 /* 
  * Is the caller allowed to modify his namespace?
  */
-- 
1.7.5.4

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


Re: [PATCH 08/19] Kbuild, lto, workaround: Don't warn for initcall_reference in modpost

2014-02-15 Thread Sam Ravnborg
On Fri, Feb 14, 2014 at 10:21:32PM +0100, Andi Kleen wrote:
> From: Andi Kleen 
> 
> This reference is discarded, but can cause warnings when it refers to
> exit. Ignore for now.
> 
> This is a workaround and can be removed once we get rid of
> -fno-toplevel-reorder
> 
> Signed-off-by: Andi Kleen 
> ---
>  scripts/mod/modpost.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index 4061098..1f1b154 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -1455,6 +1455,10 @@ static void check_section_mismatch(const char 
> *modname, struct elf_info *elf,
>   to = find_elf_symbol(elf, r->r_addend, sym);
>   tosym = sym_name(elf, to);
>  
> + if (!strncmp(fromsym, "reference___initcall",
> + sizeof("reference___initcall")-1))

Please use spaces around "-"

Sam
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 04/11] vfs: Keep a list of mounts on a mount point

2014-02-15 Thread Eric W. Biederman

To spot any possible problems call BUG if a mountpoint
is put when it's list of mounts is not empty.

Signed-off-by: Eric W. Biederman 
---
 fs/mount.h |2 ++
 fs/namespace.c |6 ++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/fs/mount.h b/fs/mount.h
index 17d913d86add..50a72d46e7a6 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -21,6 +21,7 @@ struct mnt_pcp {
 struct mountpoint {
struct list_head m_hash;
struct dentry *m_dentry;
+   struct list_head m_list;
int m_count;
 };
 
@@ -48,6 +49,7 @@ struct mount {
struct mount *mnt_master;   /* slave is on master->mnt_slave_list */
struct mnt_namespace *mnt_ns;   /* containing namespace */
struct mountpoint *mnt_mp;  /* where is it mounted */
+   struct list_head mnt_mp_list;   /* list mounts with the same mountpoint 
*/
 #ifdef CONFIG_FSNOTIFY
struct hlist_head mnt_fsnotify_marks;
__u32 mnt_fsnotify_mask;
diff --git a/fs/namespace.c b/fs/namespace.c
index 6dc23614d44d..33db9e95bd5c 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -195,6 +195,7 @@ static struct mount *alloc_vfsmnt(const char *name)
INIT_LIST_HEAD(>mnt_share);
INIT_LIST_HEAD(>mnt_slave_list);
INIT_LIST_HEAD(>mnt_slave);
+   INIT_LIST_HEAD(>mnt_mp_list);
 #ifdef CONFIG_FSNOTIFY
INIT_HLIST_HEAD(>mnt_fsnotify_marks);
 #endif
@@ -695,6 +696,7 @@ static struct mountpoint *new_mountpoint(struct dentry 
*dentry)
mp->m_dentry = dentry;
mp->m_count = 1;
list_add(>m_hash, chain);
+   INIT_LIST_HEAD(>m_list);
return mp;
 }
 
@@ -702,6 +704,7 @@ static void put_mountpoint(struct mountpoint *mp)
 {
if (!--mp->m_count) {
struct dentry *dentry = mp->m_dentry;
+   BUG_ON(!list_empty(>m_list));
spin_lock(>d_lock);
dentry->d_flags &= ~DCACHE_MOUNTED;
spin_unlock(>d_lock);
@@ -748,6 +751,7 @@ static void detach_mnt(struct mount *mnt, struct path 
*old_path)
mnt->mnt_mountpoint = mnt->mnt.mnt_root;
list_del_init(>mnt_child);
list_del_init(>mnt_hash);
+   list_del_init(>mnt_mp_list);
put_mountpoint(mnt->mnt_mp);
mnt->mnt_mp = NULL;
 }
@@ -764,6 +768,7 @@ void mnt_set_mountpoint(struct mount *mnt,
child_mnt->mnt_mountpoint = dget(mp->m_dentry);
child_mnt->mnt_parent = mnt;
child_mnt->mnt_mp = mp;
+   list_add_tail(_mnt->mnt_mp_list, >m_list);
 }
 
 /*
@@ -1246,6 +1251,7 @@ void umount_tree(struct mount *mnt, int how)
p->mnt.mnt_flags |= MNT_SYNC_UMOUNT;
list_del_init(>mnt_child);
if (mnt_has_parent(p)) {
+   list_del_init(>mnt_mp_list);
put_mountpoint(p->mnt_mp);
/* move the reference to mountpoint into 
->mnt_ex_mountpoint */
p->mnt_ex_mountpoint.dentry = p->mnt_mountpoint;
-- 
1.7.5.4

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


[PATCH 03/11] vfs: Don't allow overwriting mounts in the current mount namespace

2014-02-15 Thread Eric W. Biederman

In preparation for allowing mountpoints to be renamed and unlinked
in remote filesystems and in other mount namespaces test if on a dentry
there is a mount in the local mount namespace before allowing it to
be renamed or unlinked.

The primary motivation here are old versions of fusermount unmount
which is not safe if the a path can be renamed or unlinked while it is
verifying the mount is safe to unmount.  More recent versions are simpler
and safer by simply using UMOUNT_NOFOLLOW when unmounting a mount
in a directory owned by an arbitrary user.

Miklos Szeredi  reports this is approach is good
enough to remove concerns about new kernels mixed with old versions
of fusermount.

A secondary motivation for restrictions here is that it removing empty
directories that have non-empty mount points on them appears to
violate the rule that rmdir can not remove empty directories.  As
Linus Torvalds pointed out this is useful for programs (like git) that
test if a directory is empty with rmdir.

Therefore this patch arranges to enforce the existing mount point
semantics for local mount namespace.

v2: Rewrote the test to be a drop in replacement for d_mountpoint

Signed-off-by: "Eric W. Biederman" 
---
 fs/mount.h |9 +
 fs/namei.c |8 +++-
 fs/namespace.c |   35 +++
 3 files changed, 51 insertions(+), 1 deletions(-)

diff --git a/fs/mount.h b/fs/mount.h
index a17458ca6f29..17d913d86add 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -109,3 +109,12 @@ struct proc_mounts {
 #define proc_mounts(p) (container_of((p), struct proc_mounts, m))
 
 extern const struct seq_operations mounts_op;
+
+extern int __is_local_mountpoint(struct dentry *dentry);
+static inline int is_local_mountpoint(struct dentry *dentry)
+{
+   if (!d_mountpoint(dentry))
+   return 0;
+
+   return __is_local_mountpoint(dentry);
+}
diff --git a/fs/namei.c b/fs/namei.c
index d580df2e6804..4e6fe16ef488 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3507,6 +3507,8 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
mutex_lock(>d_inode->i_mutex);
 
error = -EBUSY;
+   if (is_local_mountpoint(dentry))
+   goto out;
if (d_mountpoint(dentry))
goto out;
 
@@ -3622,7 +3624,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry, 
struct inode **delegate
return -EPERM;
 
mutex_lock(>i_mutex);
-   if (d_mountpoint(dentry))
+   if (is_local_mountpoint(dentry) || d_mountpoint(dentry))
error = -EBUSY;
else {
error = security_inode_unlink(dir, dentry);
@@ -4001,6 +4003,8 @@ static int vfs_rename_dir(struct inode *old_dir, struct 
dentry *old_dentry,
mutex_lock(>i_mutex);
 
error = -EBUSY;
+   if (is_local_mountpoint(old_dentry) || is_local_mountpoint(new_dentry))
+   goto out;
if (d_mountpoint(old_dentry) || d_mountpoint(new_dentry))
goto out;
 
@@ -4045,6 +4049,8 @@ static int vfs_rename_other(struct inode *old_dir, struct 
dentry *old_dentry,
lock_two_nondirectories(source, target);
 
error = -EBUSY;
+   if (is_local_mountpoint(old_dentry) || is_local_mountpoint(new_dentry))
+   goto out;
if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry))
goto out;
 
diff --git a/fs/namespace.c b/fs/namespace.c
index 22e536705c45..6dc23614d44d 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -631,6 +631,41 @@ struct vfsmount *lookup_mnt(struct path *path)
return m;
 }
 
+/*
+ * __is_local_mountpoint - Test to see if dentry is a mountpoint in the
+ * current mount namespace.
+ *
+ * The common case is dentries are not mountpoints at all and that
+ * test is handled inline.  For the slow case when we are actually
+ * dealing with a mountpoint of some kind, walk through all of the
+ * mounts in the current mount namespace and test to see if the dentry
+ * is a mountpoint.
+ *
+ * The mount_hashtable is not usable in the context because we
+ * need to identify all mounts that may be in the current mount
+ * namespace not just a mount that happens to have some specified
+ * parent mount.
+ */
+int __is_local_mountpoint(struct dentry *dentry)
+{
+   struct mnt_namespace *ns = current->nsproxy->mnt_ns;
+   struct mount *mnt;
+   int is_covered = 0;
+
+   if (!d_mountpoint(dentry))
+   goto out;
+
+   down_read(_sem);
+   list_for_each_entry(mnt, >list, mnt_list) {
+   is_covered = (mnt->mnt_mountpoint == dentry);
+   if (is_covered)
+   break;
+   }
+   up_read(_sem);
+out:
+   return is_covered;
+}
+
 static struct mountpoint *new_mountpoint(struct dentry *dentry)
 {
struct list_head *chain = mountpoint_hashtable + hash(NULL, dentry);
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe 

[PATCH 02/11] vfs: More precise tests in d_invalidate

2014-02-15 Thread Eric W. Biederman

The current comments in d_invalidate about what and why it is doing
what it is doing are wildly off-base.  Which is not surprising as
the comments date back to last minute bug fix of the 2.2 kernel.

The big fat lie of a comment said: If it's a directory, we can't drop
it for fear of somebody re-populating it with children (even though
dropping it would make it unreachable from that root, we still might
repopulate it if it was a working directory or similar).

The truth is that for remote filesystems the failure of d_revalidate
and d_weak_revalidate prevents us from populating or otherwise
inappropriately using a directory.  For local filesystems and for
local directory removals the setting of S_DEAD prevents us from
populating or otherwise inappropriate using a directory.

The current rules are:
- To prevent mount point leaks dentries that are mount points or that
  have childrent that are mount points may not be be unhashed.
- All dentries may be unhashed.
- Directories may be rehashed with d_materialise_unique

check_submounts_and_drop implements this already for well maintained
remote filesystems so implement the current rules in d_invalidate
by just calling check_submounts_and_drop.

The one difference between d_invalidate and check_submounts_and_drop
is that d_invalidate must respect it when a d_revalidate method has
earlier called d_drop so preserve the d_unhashed check in
d_invalidate.

Signed-off-by: "Eric W. Biederman" 
---
 fs/dcache.c |   38 --
 1 files changed, 4 insertions(+), 34 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index c71c86f7780e..b0add629f5fe 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -613,9 +613,8 @@ EXPORT_SYMBOL(dput);
  * @dentry: dentry to invalidate
  *
  * Try to invalidate the dentry if it turns out to be
- * possible. If there are other dentries that can be
- * reached through this one we can't delete it and we
- * return -EBUSY. On success we return 0.
+ * possible. If there are reasons not to delete it
+ * return -EBUSY. On success return 0.
  *
  * no dcache lock.
  */
@@ -630,38 +629,9 @@ int d_invalidate(struct dentry * dentry)
spin_unlock(>d_lock);
return 0;
}
-   /*
-* Check whether to do a partial shrink_dcache
-* to get rid of unused child entries.
-*/
-   if (!list_empty(>d_subdirs)) {
-   spin_unlock(>d_lock);
-   shrink_dcache_parent(dentry);
-   spin_lock(>d_lock);
-   }
-
-   /*
-* Somebody else still using it?
-*
-* If it's a directory, we can't drop it
-* for fear of somebody re-populating it
-* with children (even though dropping it
-* would make it unreachable from the root,
-* we might still populate it if it was a
-* working directory or similar).
-* We also need to leave mountpoints alone,
-* directory or not.
-*/
-   if (dentry->d_lockref.count > 1 && dentry->d_inode) {
-   if (S_ISDIR(dentry->d_inode->i_mode) || d_mountpoint(dentry)) {
-   spin_unlock(>d_lock);
-   return -EBUSY;
-   }
-   }
-
-   __d_drop(dentry);
spin_unlock(>d_lock);
-   return 0;
+
+   return check_submounts_and_drop(dentry);
 }
 EXPORT_SYMBOL(d_invalidate);
 
-- 
1.7.5.4

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


Re: [PATCH 14/19] Kbuild, lto: Handle basic LTO in modpost

2014-02-15 Thread Sam Ravnborg
On Fri, Feb 14, 2014 at 10:21:38PM +0100, Andi Kleen wrote:
> From: Andi Kleen 
> 
> - Don't warn about LTO marker symbols. modpost runs before
> the linker, so the module is not necessarily LTOed yet.
> - Don't complain about .gnu.lto* sections
> 
> Signed-off-by: Andi Kleen 
> ---
>  scripts/mod/modpost.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index f91dd45..63804a1 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -623,7 +623,10 @@ static void handle_modversions(struct module *mod, 
> struct elf_info *info,
>  
>   switch (sym->st_shndx) {
>   case SHN_COMMON:
> - warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name);
> + if (!strncmp(symname, "__gnu_lto_", sizeof("__gnu_lto_")-1)) {

Please use space around "-".

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


[PATCH 01/11] vfs: Document the effect of d_revalidate on d_find_alias

2014-02-15 Thread Eric W. Biederman

d_drop or check_submounts_and_drop called from d_revalidate can result
in renamed directories with child dentries being unhashed.  These
renamed and drop directory dentries can be rehashed after
d_materialise_unique uses d_find_alias to find them.

Signed-off-by: "Eric W. Biederman" 
---
 fs/dcache.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 265e0ce9769c..c71c86f7780e 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -726,7 +726,8 @@ EXPORT_SYMBOL(dget_parent);
  * acquire the reference to alias and return it. Otherwise return NULL.
  * Notice that if inode is a directory there can be only one alias and
  * it can be unhashed only if it has no children, or if it is the root
- * of a filesystem.
+ * of a filesystem, or if the directory was renamed and d_revalidate
+ * was the first vfs operation to notice.
  *
  * If the inode has an IS_ROOT, DCACHE_DISCONNECTED alias, then prefer
  * any other hashed alias over that one unless @want_discon is set,
-- 
1.7.5.4

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


[PATCH 0/11] Detaching mounts on unlink

2014-02-15 Thread Eric W. Biederman

The last round of this patchset the semantics of dropping mounts on
unlink were agreed upon so long as we preserve the current semantics in
a single mount namespace.

There are two big changes with this version of the patchset.
1) The test for a mount in the current mount namespace has been
   rewritten so that it is actually correct and is now a drop in
   replacement for d_mountpoint.  Removing the need for code changes
   that could cause unitended regressions.

2) This work has been comprehensivly extend to d_revalidate and
   d_invalidate allowing some long standing bugs to be fixed at the end
   of this patch series.

In net this should result in a kernel that is more comprehensible and
maintainble as well as fixing some possible mount leaks, and removing
the possibility of DOS attacks from evily placed mount points, in other
mount namespaces.

Eric W. Biederman (11):
  vfs: Document the effect of d_revalidate on d_find_alias
  vfs: More precise tests in d_invalidate
  vfs: Don't allow overwriting mounts in the current mount namespace
  vfs: Keep a list of mounts on a mount point
  vfs: Add a function to lazily unmount all mounts from any dentry.
  vfs: Lazily remove mounts on unlinked files and directories.
  vfs: Remove unnecessary calls of check_submounts_and_drop
  vfs: Merge check_submounts_and_drop and d_invalidate
  vfs: Make d_invalidate return void
  vfs: Remove d_drop calls from d_revalidate implementations
  proc: Update proc_flush_task_mnt to use d_invalidate

 fs/afs/dir.c   |5 --
 fs/btrfs/ioctl.c   |5 +--
 fs/ceph/dir.c  |1 -
 fs/cifs/readdir.c  |6 +--
 fs/dcache.c|  140 +---
 fs/fuse/dir.c  |7 +--
 fs/gfs2/dentry.c   |3 -
 fs/kernfs/dir.c|   11 
 fs/mount.h |   13 +
 fs/namei.c |   28 ++
 fs/namespace.c |   80 +++
 fs/nfs/dir.c   |7 +--
 fs/proc/base.c |   10 +---
 fs/proc/fd.c   |2 -
 include/linux/dcache.h |3 +-
 15 files changed, 167 insertions(+), 154 deletions(-)

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


Re: [PATCH 10/19] Kbuild, lto: add ld-version and ld-ifversion macros

2014-02-15 Thread Sam Ravnborg
On Fri, Feb 14, 2014 at 10:21:34PM +0100, Andi Kleen wrote:
> From: Andi Kleen 
> 
> To check the linker version. Used by the LTO makefile.

Everything in Kbuild.include is supposed to be documented in 
Documentation/kbuild/*
Please add documentation too.

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


Re: [PATCH 01/19] x86, lto: Disable LTO for the x86 VDSO

2014-02-15 Thread Sam Ravnborg
On Fri, Feb 14, 2014 at 10:21:25PM +0100, Andi Kleen wrote:
> From: Andi Kleen 
> 
> The VDSO does not play well with LTO, so just disable LTO for it.
> Also pass a 32bit linker flag for the 32bit version.
> 
> Cc: x...@kernel.org
> Signed-off-by: Andi Kleen 
> ---
>  arch/x86/vdso/Makefile | 10 +++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
> index fd14be1..598f163 100644
> --- a/arch/x86/vdso/Makefile
> +++ b/arch/x86/vdso/Makefile
> @@ -2,6 +2,8 @@
>  # Building vDSO images for x86.
>  #
>  
> +KBUILD_CFLAGS += ${DISABLE_LTO}
> +
In kbuild files $() is usally preferred.

Sam
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: Updated Link-Time-Optimization patchkit

2014-02-15 Thread Sam Ravnborg
Hi Andi.

On Sat, Feb 15, 2014 at 06:44:24PM +0100, Andi Kleen wrote:
> On Sat, Feb 15, 2014 at 02:38:14PM +0100, Markus Trippelsdorf wrote:
> > On 2014.02.14 at 22:21 +0100, Andi Kleen wrote:
> > > This is the updated LTO patchkit for 3.14-rc2.  LTO allows
> > > the compiler to do global optimization over the whole kernel.
> > 
> > It is mildly annoying that one couldn't use vanilla binutils. Have you
> > already opened bugs on sourceware.org/bugzilla/ to get this fixed for
> > gold and ld.bfd?
> 
> The problem is supporting "pass through" of both pure (.S) assembler code and
> LTO through ld -r, because the kernel makefiles use ld -r heavily.
> Standard binutils would throw all the assembler away when in plugin LTO
> mode.

Long time ago I looked at eliminating the use of -r in the kernel build.
I lost the patch - but the attached patch managed to build
a "make defconfig; make" kernel.

I have not event tried boot with this - it only managed to build!

What the patch does is for each directory visited a built-in.link file is 
created
which is really a linker script.
It uses INPUT (file file file) to specify all the object files.
And in the final link the files are all read and the link is performed.

This limit the depth to 10 levels due to a restriction in ld.
The binutils people have suggested some other methods that I did not look into.

Half of the patch is fixes to the security makefiles which I
will submit anyway as this needs to be cleaned up indendent on
this patch.

The patch drops $(cmd_secanalysis) because I did not look into this.

If this could make it easier to enable LTO then this would be
a nice win.

Sam



diff --git a/Makefile b/Makefile
index 933e1de..204ee3c 100644
--- a/Makefile
+++ b/Makefile
@@ -788,12 +788,12 @@ vmlinux-alldirs   := $(sort $(vmlinux-dirs) $(patsubst 
%/,%,$(filter %/, \
 $(core-n) $(core-) $(drivers-n) $(drivers-) \
 $(net-n)  $(net-)  $(libs-n)$(libs-
 
-init-y := $(patsubst %/, %/built-in.o, $(init-y))
-core-y := $(patsubst %/, %/built-in.o, $(core-y))
-drivers-y  := $(patsubst %/, %/built-in.o, $(drivers-y))
-net-y  := $(patsubst %/, %/built-in.o, $(net-y))
+init-y := $(patsubst %/, %/built-in.link, $(init-y))
+core-y := $(patsubst %/, %/built-in.link, $(core-y))
+drivers-y  := $(patsubst %/, %/built-in.link, $(drivers-y))
+net-y  := $(patsubst %/, %/built-in.link, $(net-y))
 libs-y1:= $(patsubst %/, %/lib.a, $(libs-y))
-libs-y2:= $(patsubst %/, %/built-in.o, $(libs-y))
+libs-y2:= $(patsubst %/, %/built-in.link, $(libs-y))
 libs-y := $(libs-y1) $(libs-y2)
 
 # Externally visible symbols (used by link-vmlinux.sh)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index d5d859c..6f01526 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -135,7 +135,7 @@ lib-target := $(obj)/lib.a
 endif
 
 ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-) $(subdir-m) $(lib-target)),)
-builtin-target := $(obj)/built-in.o
+builtin-target := $(obj)/built-in.link
 endif
 
 modorder-target := $(obj)/modules.order
@@ -378,10 +378,7 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ;
 ifdef builtin-target
 quiet_cmd_link_o_target = LD  $@
 # If the list of objects to link is empty, just create an empty built-in.o
-cmd_link_o_target = $(if $(strip $(obj-y)),\
- $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \
- $(cmd_secanalysis),\
- rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@)
+cmd_link_o_target = $(if $(filter $(obj-y), $^), echo INPUT\($(filter 
$(obj-y), $^)\) > $@, echo "/* empty */" > $@)
 
 $(builtin-target): $(obj-y) FORCE
$(call if_changed,link_o_target)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 49392ec..3ea37c2 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -39,7 +39,7 @@ __subdir-y:= $(patsubst %/,%,$(filter %/, $(obj-y)))
 subdir-y   += $(__subdir-y)
 __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
 subdir-m   += $(__subdir-m)
-obj-y  := $(patsubst %/, %/built-in.o, $(obj-y))
+obj-y  := $(patsubst %/, %/built-in.link, $(obj-y))
 obj-m  := $(filter-out %/, $(obj-m))
 
 # Subdirectories we need to descend into
@@ -60,7 +60,7 @@ multi-objs   := $(multi-objs-y) $(multi-objs-m)
 
 # $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to
 # tell kbuild to descend
-subdir-obj-y := $(filter %/built-in.o, $(obj-y))
+subdir-obj-y := $(filter %/built-in.link, $(obj-y))
 
 # $(obj-dirs) is a list of directories that contain object files
 obj-dirs := $(dir $(multi-objs) $(obj-y))
diff --git a/security/Makefile b/security/Makefile
index a5918e0..05f1c93 100644
--- a/security/Makefile
+++ b/security/Makefile
@@ -16,14 +16,14 @@ obj-$(CONFIG_MMU)   += min_addr.o
 # Object file lists
 obj-$(CONFIG_SECURITY) += 

Re: [BUG] unable to handle kernel NULL pointer dereference

2014-02-15 Thread John


- Original Message -
> From: Borislav Petkov <>
> Sent: Saturday, February 15, 2014 3:30 PM
> Subject: Re: [BUG] unable to handle kernel NULL pointer dereference
> 
> If I'd have to guess, that's trying to rcu deref that struct net_generic
> *ng in net_generic() but this is only guesswork as I don't have your
> .config.
> 
> Anyway, adding some more people to CC.
> 


Thanks for the reply, Boris.  The .config is unmodified from the Arch Distro 
default for 3.13.3-1 which can be found here: http://pastebin.com/LPGZ8ZqA
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 39/48] powerpc: Replace __get_cpu_var uses

2014-02-15 Thread Benjamin Herrenschmidt

On Sun, 2014-02-16 at 07:32 +1100, Benjamin Herrenschmidt wrote:

> > But even that looks like it should be considered a bug. Please file in
> > GNOME bugzilla.
> 
> In my case it doesn't have an inline part. I only get an attachment,
> 
> I'll file it in gnome bz.

Hah, story of my life: 3.8.x is marked "obsolete" in gnome BZ :)

I suppose that's the price for using Ubuntu, the version of evolution is
always just old enough that nobody cares about bugs in it anymore :-)

Anyway, gnome3 PPA gave me 3.10.3 and the problem is still there, filing
as https://bugzilla.gnome.org/show_bug.cgi?id=724437

Cheers,
Ben.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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/3] staging: r8188eu: delete unnecessary field initialization

2014-02-15 Thread Greg Kroah-Hartman
On Sat, Feb 15, 2014 at 08:36:12AM +0100, Julia Lawall wrote:
> From: Julia Lawall 
> 
> On success, the function netdev_alloc_skb initializes the dev field of its
> result to its first argument, so this doesn't have to be done in the
> calling context.
> 
> The semantic patch that fixes this problem is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // 
> @@
> expression skb,privn,e;
> @@
> 
> skb = netdev_alloc_skb(privn,...);
> ... when strict
> (
> -skb->dev = privn;
> |
> ?skb = e
> )
> // 
> 
> Signed-off-by: Julia Lawall 
> 
> ---
>  drivers/staging/rtl8188eu/hal/usb_ops_linux.c |1 -
>  1 file changed, 1 deletion(-)

No longer applies to my tree :(

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


[PULL REQUEST] i2c for 3.14

2014-02-15 Thread Wolfram Sang
Linus,

i2c has a bugfix and documentation improvements for you. Please pull.

Thanks,

   Wolfram


The following changes since commit b28a960c42fcd9cfc987441fa6d1c1a471f0f9ed:

  Linux 3.14-rc2 (2014-02-09 18:15:47 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-current

for you to fetch changes up to fde1e418ab2c4269035f7f576e678b6ad3117d7d:

  Documentation: i2c: mention ACPI method for instantiating devices (2014-02-15 
19:46:34 +0100)


Wolfram Sang (3):
  i2c: mv64xxx: refactor message start to ensure proper initialization
  Documentation: i2c: describe devicetree method for instantiating devices
  Documentation: i2c: mention ACPI method for instantiating devices

 Documentation/i2c/instantiating-devices | 41 +++--
 drivers/i2c/busses/i2c-mv64xxx.c| 33 +++---
 2 files changed, 53 insertions(+), 21 deletions(-)


signature.asc
Description: Digital signature


Re: [PATCH 39/48] powerpc: Replace __get_cpu_var uses

2014-02-15 Thread Benjamin Herrenschmidt
On Sat, 2014-02-15 at 18:12 +, David Woodhouse wrote:
> On Sat, 2014-02-15 at 16:45 +0100, Peter Zijlstra wrote:
> > 
> > David; in particular; quilt mail adds "Content-Disposition: inline"
> > headers and Evo, in its infinite wisdom, makes the entire body into an
> > attachment.
> 
> Hm, looking at the original email I see it as an inline part, displayed
> by default. I can read it, select parts of it and hit 'reply' to cite
> only the selected part... everything I can do with a normal email.
> 
> Ben, what precisely is it that makes it hard to read and review? All I
> can see is a trivial cosmetic issue; it's a few pixels down and right
> from where it would normally be.
> 
> But even that looks like it should be considered a bug. Please file in
> GNOME bugzilla.

In my case it doesn't have an inline part. I only get an attachment,

I'll file it in gnome bz.

Cheers,
Ben.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: [BUG] unable to handle kernel NULL pointer dereference

2014-02-15 Thread Borislav Petkov
If I'd have to guess, that's trying to rcu deref that struct net_generic
*ng in net_generic() but this is only guesswork as I don't have your
.config.

Anyway, adding some more people to CC.

[ 137.689996] Code: f8 e8 4f b8 9a c8 31 c0 eb c6 90 8d b4 26 00 00 00 00 55 89 
e5 56 53 3e 8d 74 26 00 8b 1d 28 e9 a3 f8 89 c6 e8 59 64 5f c8 85 db <8b> 86 58 
08 00 00 74 3a 3b 18 77 36 8b 5c 98 08 e8 32 66 5f c8
All code

   0:   f8  clc
   1:   e8 4f b8 9a c8  call   0xc89ab855
   6:   31 c0   xor%eax,%eax
   8:   eb c6   jmp0xffd0
   a:   90  nop
   b:   8d b4 26 00 00 00 00lea0x0(%esi,%eiz,1),%esi
  12:   55  push   %ebp
  13:   89 e5   mov%esp,%ebp
  15:   56  push   %esi
  16:   53  push   %ebx
  17:   3e 8d 74 26 00  lea%ds:0x0(%esi,%eiz,1),%esi
  1c:   8b 1d 28 e9 a3 f8   mov0xf8a3e928,%ebx
  22:   89 c6   mov%eax,%esi
  24:   e8 59 64 5f c8  call   0xc85f6482
  29:   85 db   test   %ebx,%ebx
  2b:*  8b 86 58 08 00 00   mov0x858(%esi),%eax <-- trapping 
instruction
  31:   74 3a   je 0x6d
  33:   3b 18   cmp(%eax),%ebx
  35:   77 36   ja 0x6d
  37:   8b 5c 98 08 mov0x8(%eax,%ebx,4),%ebx
  3b:   e8 32 66 5f c8  call   0xc85f6672

Code starting with the faulting instruction
===
   0:   8b 86 58 08 00 00   mov0x858(%esi),%eax
   6:   74 3a   je 0x42
   8:   3b 18   cmp(%eax),%ebx
   a:   77 36   ja 0x42
   c:   8b 5c 98 08 mov0x8(%eax,%ebx,4),%ebx
  10:   e8 32 66 5f c8  call   0xc85f6647


On Sat, Feb 15, 2014 at 12:08:37PM -0800, John wrote:
> > When booting into linux v3.13.3, I am unable to mount an nfs share on this 
> 
> > particular hardware.  I get the same problem using v3.12.11.  Only the 
> > 3.10.x 
> > series allows normal operation.  Partial dmesg output shown inline, 
> > additional 
> > logs available upon request.
> > 
> > PLEASE cc me on my replies as I am not subscribed to lkml.
> > 
> > Hardware: Athlon XP 3200+ on an NVIDIA nForce2 Ultra 400 motherboard.
> > Distro: Arch Linux i686.
> > 
> > % dmesg
> > ...
> > [ 137.616014] NFS: Registering the id_resolver key type
> > [ 137.616036] Key type id_resolver registered
> > [ 137.616038] Key type id_legacy registered
> > [ 137.686758] BUG: unable to handle kernel NULL pointer dereference at 
> > 0858
> > [ 137.689996] IP: [] put_pipe_version+0x19/0x60 [auth_rpcgss]
> > [ 137.689996] *pde =  
> > [ 137.689996] Oops:  [#1] PREEMPT SMP 
> > [ 137.689996] Modules linked in: rpcsec_gss_krb5 auth_rpcgss oid_registry 
> > nfsv4 
> > asb100 hwmon_vid snd_wavefront ir_mce_kbd_decoder ir_lirc_codec 
> > ir_rc5_sz_decoder ir_sony_decoder lirc_dev ir_rc5_decoder ir_jvc_decoder 
> > ir_sanyo_decoder ir_rc6_decoder ir_nec_decoder rc_streamzap streamzap 
> > mousedev 
> > snd_cs4236 rc_core snd_intel8x0 snd_wss_lib snd_opl3_lib snd_hwdep 
> > snd_ac97_codec evdev snd_mpu401 ac97_bus snd_mpu401_uart snd_pcm 
> > snd_rawmidi 
> > snd_page_alloc snd_seq_device snd_timer snd pcspkr skge shpchp i2c_nforce2 
> > i2c_core soundcore ns558 gameport processor button nvidia_agp agpgart nfs 
> > lockd 
> > sunrpc fscache ext4 crc16 mbcache jbd2 hid_generic usbhid hid sr_mod cdrom 
> > sd_mod ata_generic pata_acpi sata_sil pata_amd libata ehci_pci ohci_pci 
> > ohci_hcd 
> > ehci_hcd scsi_mod usbcore usb_common
> > [ 137.689996] CPU: 0 PID: 534 Comm: rpc.gssd Not tainted 3.13.3-1-ARCH #1
> > [ 137.689996] Hardware name: ASUSTeK Computer INC. A7N8X-E/A7N8X-E, BIOS 
> > ASUS 
> > A7N8X-E Deluxe ACPI BIOS Rev 1013 11/12/2004
> > [ 137.689996] task: f4633210 ti: f568e000 task.ti: f568e000
> > [ 137.689996] EIP: 0060:[] EFLAGS: 00010202 CPU: 0
> > [ 137.689996] EIP is at put_pipe_version+0x19/0x60 [auth_rpcgss]
> > [ 137.689996] EAX: f4633210 EBX: 0001 ECX: f56efca8 EDX: 0296
> > [ 137.689996] ESI:  EDI: f56efc00 EBP: f568fee8 ESP: f568fee0
> > [ 137.689996] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
> > [ 137.689996] CR0: 8005003b CR2: 0858 CR3: 34523000 CR4: 07d0
> > [ 137.689996] Stack:
> > [ 137.689996] f56efc00 f6c64f78 f568fef4 f8aa2e05 0010 f568ff40 
> > f8aa3b38 
> > 0374
> > [ 137.689996] 0080 b74dde40 f4644a80 f568ff30 0246 f8ac1080 
> > 41c9 
> > f6c64f78
> > [ 137.689996] fff3 0010 f4460140 f44d5820 f44d5810 f53df7ec 
> > f57595a0 
> > f8aa93e8
> > [ 137.689996] Call Trace:
> > [ 137.689996] [] gss_release_msg+0x25/0x70 [auth_rpcgss]
> > [ 137.689996] [] gss_pipe_downcall+0x208/0x4b0 [auth_rpcgss]
> > [ 137.689996] [] rpc_pipe_write+0x3b/0x60 [sunrpc]
> > [ 137.689996] [] ? rpc_pipe_poll+0x90/0x90 [sunrpc]
> > [ 

[PATCH 1/2] rtc: rtc-ds1307: fix sysfs wakealarm attribute creation

2014-02-15 Thread Simon Guinot
In order to allow the creation of the sysfs attribute wakealarm, this
patch moves the device_set_wakeup_capable() call above the RTC device
registration.

Signed-off-by: Simon Guinot 
---
 drivers/rtc/rtc-ds1307.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 4e75345a559a..8c70b2238e88 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -927,6 +927,7 @@ read_rtc:
bin2bcd(tmp));
}
 
+   device_set_wakeup_capable(>dev, want_irq);
ds1307->rtc = devm_rtc_device_register(>dev, client->name,
_rtc_ops, THIS_MODULE);
if (IS_ERR(ds1307->rtc)) {
@@ -945,7 +946,6 @@ read_rtc:
goto exit;
}
 
-   device_set_wakeup_capable(>dev, 1);
set_bit(HAS_ALARM, >flags);
dev_dbg(>dev, "got IRQ %d\n", client->irq);
}
-- 
1.8.5.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 2/2] rtc: rtc-ds1307: add alarm support for mcp7941x chips

2014-02-15 Thread Simon Guinot
This patch adds alarm support for the Microchip RTC devices MCP794xx.
Note that two programmable alarms are provided by the chip but only one
is used by the driver.

Signed-off-by: Simon Guinot 
---
 drivers/rtc/rtc-ds1307.c | 183 ++-
 1 file changed, 182 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 8c70b2238e88..580379a97f0c 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -154,6 +154,7 @@ static const struct chip_desc chips[last_ds_type] = {
.alarm  = 1,
},
[mcp7941x] = {
+   .alarm  = 1,
/* this is battery backed SRAM */
.nvram_offset   = 0x20,
.nvram_size = 0x40,
@@ -606,6 +607,178 @@ static const struct rtc_class_ops ds13xx_rtc_ops = {
 
 /*--*/
 
+/*
+ * Alarm support for mcp7941x devices.
+ */
+
+#define MCP7941X_REG_CONTROL   0x07
+#  define MCP7941X_BIT_ALM0_EN 0x10
+#  define MCP7941X_BIT_ALM1_EN 0x20
+#define MCP7941X_REG_ALARM0_BASE   0x0a
+#define MCP7941X_REG_ALARM0_CTRL   0x0d
+#define MCP7941X_REG_ALARM1_BASE   0x11
+#define MCP7941X_REG_ALARM1_CTRL   0x14
+#  define MCP7941X_BIT_ALMX_IF (1 << 3)
+#  define MCP7941X_BIT_ALMX_C0 (1 << 4)
+#  define MCP7941X_BIT_ALMX_C1 (1 << 5)
+#  define MCP7941X_BIT_ALMX_C2 (1 << 6)
+#  define MCP7941X_BIT_ALMX_POL(1 << 7)
+#  define MCP7941X_MSK_ALMX_MATCH  (MCP7941X_BIT_ALMX_C0 | \
+MCP7941X_BIT_ALMX_C1 | \
+MCP7941X_BIT_ALMX_C2)
+
+static void mcp7941x_work(struct work_struct *work)
+{
+   struct ds1307 *ds1307 = container_of(work, struct ds1307, work);
+   struct i2c_client *client = ds1307->client;
+   int reg, ret;
+
+   mutex_lock(>rtc->ops_lock);
+
+   /* Check and clear alarm 0 interrupt flag. */
+   reg = i2c_smbus_read_byte_data(client, MCP7941X_REG_ALARM0_CTRL);
+   if (reg < 0)
+   goto out;
+   if (!(reg & MCP7941X_BIT_ALMX_IF))
+   goto out;
+   reg &= ~MCP7941X_BIT_ALMX_IF;
+   ret = i2c_smbus_write_byte_data(client, MCP7941X_REG_ALARM0_CTRL, reg);
+   if (ret < 0)
+   goto out;
+
+   /* Disable alarm 0. */
+   reg = i2c_smbus_read_byte_data(client, MCP7941X_REG_CONTROL);
+   if (reg < 0)
+   goto out;
+   reg &= ~MCP7941X_BIT_ALM0_EN;
+   ret = i2c_smbus_write_byte_data(client, MCP7941X_REG_CONTROL, reg);
+   if (ret < 0)
+   goto out;
+
+   rtc_update_irq(ds1307->rtc, 1, RTC_AF | RTC_IRQF);
+
+out:
+   if (test_bit(HAS_ALARM, >flags))
+   enable_irq(client->irq);
+   mutex_unlock(>rtc->ops_lock);
+}
+
+static int mcp7941x_read_alarm(struct device *dev, struct rtc_wkalrm *t)
+{
+   struct i2c_client *client = to_i2c_client(dev);
+   struct ds1307 *ds1307 = i2c_get_clientdata(client);
+   u8 *regs = ds1307->regs;
+   int ret;
+
+   if (!test_bit(HAS_ALARM, >flags))
+   return -EINVAL;
+
+   /* Read control and alarm 0 registers. */
+   ret = ds1307->read_block_data(client, MCP7941X_REG_CONTROL, 10, regs);
+   if (ret < 0)
+   return ret;
+
+   t->enabled = !!(regs[0] & MCP7941X_BIT_ALM0_EN);
+
+   /* Report alarm 0 time assuming 24-hour and day-of-month modes. */
+   t->time.tm_sec = bcd2bin(ds1307->regs[3] & 0x7f);
+   t->time.tm_min = bcd2bin(ds1307->regs[4] & 0x7f);
+   t->time.tm_hour = bcd2bin(ds1307->regs[5] & 0x3f);
+   t->time.tm_wday = bcd2bin(ds1307->regs[6] & 0x7) - 1;
+   t->time.tm_mday = bcd2bin(ds1307->regs[7] & 0x3f);
+   t->time.tm_mon = bcd2bin(ds1307->regs[8] & 0x1f) - 1;
+   t->time.tm_year = -1;
+   t->time.tm_yday = -1;
+   t->time.tm_isdst = -1;
+
+   dev_dbg(dev, "%s, sec=%d min=%d hour=%d wday=%d mday=%d mon=%d "
+   "enabled=%d polarity=%d irq=%d match=%d\n", __func__,
+   t->time.tm_sec, t->time.tm_min, t->time.tm_hour,
+   t->time.tm_wday, t->time.tm_mday, t->time.tm_mon, t->enabled,
+   !!(ds1307->regs[6] & MCP7941X_BIT_ALMX_POL),
+   !!(ds1307->regs[6] & MCP7941X_BIT_ALMX_IF),
+   (ds1307->regs[6] & MCP7941X_MSK_ALMX_MATCH) >> 4);
+
+   return 0;
+}
+
+static int mcp7941x_set_alarm(struct device *dev, struct rtc_wkalrm *t)
+{
+   struct i2c_client *client = to_i2c_client(dev);
+   struct ds1307 *ds1307 = i2c_get_clientdata(client);
+   unsigned char *regs = ds1307->regs;
+   int ret;
+
+   if (!test_bit(HAS_ALARM, >flags))
+   return -EINVAL;
+
+   dev_dbg(dev, "%s, sec=%d min=%d hour=%d wday=%d mday=%d mon=%d "
+   "enabled=%d pending=%d\n", __func__,
+   

[PATCH 0/2] Add alarm suport for the Microchip RTC devices MCP794xx

2014-02-15 Thread Simon Guinot
Hello,

This patch series adds alarm support for the Microchip RTC devices
MCP794xx. A such compatible RTC (MCP7940NT) is embedded on the Seagate
boards n090x01 (based on the Armada-370 SoC).

Regards,

Simon

Simon Guinot (2):
  rtc: rtc-ds1307: fix sysfs wakealarm attribute creation
  rtc: rtc-ds1307: add alarm support for mcp7941x chips

 drivers/rtc/rtc-ds1307.c | 185 ++-
 1 file changed, 183 insertions(+), 2 deletions(-)

-- 
1.8.5.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: [cgroups] BUG: unable to handle kernel NULL pointer dereference at 0000003c

2014-02-15 Thread Li Zefan
于 2014年02月15日 20:42, Fengguang Wu 写道:
> Greetings,
> 
> I got the below dmesg and the first bad commit is
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git for-next
> commit de00ffa56ea3132c6013fc8f07133b8a1014cf53
> Author: Tejun Heo 
> AuthorDate: Tue Feb 11 11:52:48 2014 -0500
> Commit: Tejun Heo 
> CommitDate: Tue Feb 11 11:52:48 2014 -0500
> 
> cgroup: make cgroup_subsys->base_cftypes use cgroup_add_cftypes()
> 
> Currently, cgroup_subsys->base_cftypes registration is different from
> dynamic cftypes registartion.  Instead of going through
> cgroup_add_cftypes(), cgroup_init_subsys() invokes
> cgroup_init_cftsets() which makes use of cgroup_subsys->base_cftset
> which doesn't involve dynamic allocation.
> 
> While avoiding dynamic allocation is somewhat nice, having two
> separate paths for cftypes registration is nasty, especially as we're
> planning to add more operations during cftypes registration.
> 
> This patch drops cgroup_init_cftsets() and cgroup_subsys->base_cftset
> and registers base_cftypes using cgroup_add_cftypes().  This is done
> as a separate step in cgroup_init() instead of a part of
> cgroup_init_subsys().  This is because cgroup_init_subsys() can be
> called very early during boot when kmalloc() isn't available yet.
> 
> Signed-off-by: Tejun Heo 
> Acked-by: Li Zefan 
> 
> [0.02] Calibrating delay loop (skipped) preset value.. 5786.00 
> BogoMIPS (lpj=2893)
> [0.02] pid_max: default: 32768 minimum: 301
> [0.02] Mount-cache hash table entries: 512
> [0.02] BUG: unable to handle kernel NULL pointer dereference at 
> 003c
> [0.02] IP: [] cgroup_cfts_commit+0x27/0x1c1
> [0.02] *pdpt =  *pde = f000ff53f000ff53 
> [0.02] Oops:  [#1] SMP 
> [0.02] Modules linked in:
> [0.02] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 
> 3.14.0-rc2-next-20140212-02521-g4602175 #1
> [0.02] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
> [0.02] task: cd497910 ti: cd492000 task.ti: cd492000
> [0.02] EIP: 0060:[] EFLAGS: 00210282 CPU: 0
> [0.02] EIP is at cgroup_cfts_commit+0x27/0x1c1
> [0.02] EAX: cd4b1d0c EBX: cf004fa0 ECX: 0001 EDX: 0001
> [0.02] ESI:  EDI: cd9820d4 EBP: cd493fa4 ESP: cd493f70
> [0.02]  DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
> [0.02] CR0: 8005003b CR2: 003c CR3: 0d96e000 CR4: 06b0
> [0.02] Stack:
> [0.02]  cf004fa0 cd4b1d4c 00200246 cd9820d4 cc9d1129 0190c691 
> 000c 80d0
> [0.02]  cd493f90 cd493f90 cf004fa0 cd9820d4 cd4accc4 cd493fbc 
> cc90c6fc 
> [0.02]    cd970800 cd493fcc cd78b646  
> 00020800 cd493fe8
> [0.02] Call Trace:
> [0.02]  [] ? kmem_cache_alloc_trace+0x33f/0x3b7
> [0.02]  [] cgroup_add_cftypes+0x8f/0xca
> [0.02]  [] cgroup_init+0x6a/0x26a
> [0.02]  [] start_kernel+0x4d7/0x57a
> [0.02]  [] i386_start_kernel+0x92/0x96
> [0.02] Code: 5e 5f 5d c3 55 89 e5 57 56 53 83 ec 28 e8 94 ab 71 00 89 
> c7 8b 77 50 89 45 d8 8d 45 ec 89 45 ec 89 45 f0 b8 0c 1d 4b cd 88 55 e3 <8b> 
> 5e 3c e8 c9 4d 71 00 85 ff 74 0e 31 c0 81 7e 3c c8 43 ec cd
> [0.02] EIP: [] cgroup_cfts_commit+0x27/0x1c1 SS:ESP 
> 0068:cd493f70
> [0.02] CR2: 003c
> [0.02] ---[ end trace fd4743fe17bdbf8e ]---
> [0.02] Kernel panic - not syncing: Fatal exception
> 

This is a corner case. If CGROUP_SCHED=y but FAIR_GROUP_SCHED=n && 
CFS_BANDWIDTH=n &&
RT_GROUP_SCHED=n:

static struct cftype cpu_files[] = {
{ } /* terminate */
};

Should be fixed by the following change. Will test it and send out a formal
patch on Monday.

It's 4 a.m on Sunday, and I lose sleep. :(

---
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 851251b..fa393d84 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2348,6 +2348,9 @@ int cgroup_add_cftypes(struct cgroup_subsys *ss, struct 
cftype *cfts)
 {
int ret;
 
+   if (!cfts || cfts[0].name[0] == '\0')
+   return 0;
+
ret = cgroup_init_cftypes(ss, cfts);
if (ret)
return ret;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 03/11] sysfs: create bin_attributes under the requested group

2014-02-15 Thread Greg Kroah-Hartman
On Fri, Feb 14, 2014 at 02:02:07PM -0800, Cody P Schafer wrote:
> bin_attributes created/updated in create_files() (such as those listed
> via (struct device).attribute_groups) were not placed under the
> specified group, and instead appeared in the base kobj directory.
> 
> Fix this by making bin_attributes use creating code similar to normal
> attributes.
> 
> A quick grep shows that no one is using bin_attrs in a named attribute
> group yet, so we can do this without breaking anything in usespace.
> 
> Note that I do not add is_visible() support to
> bin_attributes, though that could be done as well.

is_visible() support would be nice to add if you get a chance.

thanks,

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: [BUG] unable to handle kernel NULL pointer dereference

2014-02-15 Thread John
> When booting into linux v3.13.3, I am unable to mount an nfs share on this 

> particular hardware.  I get the same problem using v3.12.11.  Only the 3.10.x 
> series allows normal operation.  Partial dmesg output shown inline, 
> additional 
> logs available upon request.
> 
> PLEASE cc me on my replies as I am not subscribed to lkml.
> 
> Hardware: Athlon XP 3200+ on an NVIDIA nForce2 Ultra 400 motherboard.
> Distro: Arch Linux i686.
> 
> % dmesg
> ...
> [ 137.616014] NFS: Registering the id_resolver key type
> [ 137.616036] Key type id_resolver registered
> [ 137.616038] Key type id_legacy registered
> [ 137.686758] BUG: unable to handle kernel NULL pointer dereference at 
> 0858
> [ 137.689996] IP: [] put_pipe_version+0x19/0x60 [auth_rpcgss]
> [ 137.689996] *pde =  
> [ 137.689996] Oops:  [#1] PREEMPT SMP 
> [ 137.689996] Modules linked in: rpcsec_gss_krb5 auth_rpcgss oid_registry 
> nfsv4 
> asb100 hwmon_vid snd_wavefront ir_mce_kbd_decoder ir_lirc_codec 
> ir_rc5_sz_decoder ir_sony_decoder lirc_dev ir_rc5_decoder ir_jvc_decoder 
> ir_sanyo_decoder ir_rc6_decoder ir_nec_decoder rc_streamzap streamzap 
> mousedev 
> snd_cs4236 rc_core snd_intel8x0 snd_wss_lib snd_opl3_lib snd_hwdep 
> snd_ac97_codec evdev snd_mpu401 ac97_bus snd_mpu401_uart snd_pcm snd_rawmidi 
> snd_page_alloc snd_seq_device snd_timer snd pcspkr skge shpchp i2c_nforce2 
> i2c_core soundcore ns558 gameport processor button nvidia_agp agpgart nfs 
> lockd 
> sunrpc fscache ext4 crc16 mbcache jbd2 hid_generic usbhid hid sr_mod cdrom 
> sd_mod ata_generic pata_acpi sata_sil pata_amd libata ehci_pci ohci_pci 
> ohci_hcd 
> ehci_hcd scsi_mod usbcore usb_common
> [ 137.689996] CPU: 0 PID: 534 Comm: rpc.gssd Not tainted 3.13.3-1-ARCH #1
> [ 137.689996] Hardware name: ASUSTeK Computer INC. A7N8X-E/A7N8X-E, BIOS ASUS 
> A7N8X-E Deluxe ACPI BIOS Rev 1013 11/12/2004
> [ 137.689996] task: f4633210 ti: f568e000 task.ti: f568e000
> [ 137.689996] EIP: 0060:[] EFLAGS: 00010202 CPU: 0
> [ 137.689996] EIP is at put_pipe_version+0x19/0x60 [auth_rpcgss]
> [ 137.689996] EAX: f4633210 EBX: 0001 ECX: f56efca8 EDX: 0296
> [ 137.689996] ESI:  EDI: f56efc00 EBP: f568fee8 ESP: f568fee0
> [ 137.689996] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
> [ 137.689996] CR0: 8005003b CR2: 0858 CR3: 34523000 CR4: 07d0
> [ 137.689996] Stack:
> [ 137.689996] f56efc00 f6c64f78 f568fef4 f8aa2e05 0010 f568ff40 f8aa3b38 
> 0374
> [ 137.689996] 0080 b74dde40 f4644a80 f568ff30 0246 f8ac1080 41c9 
> f6c64f78
> [ 137.689996] fff3 0010 f4460140 f44d5820 f44d5810 f53df7ec f57595a0 
> f8aa93e8
> [ 137.689996] Call Trace:
> [ 137.689996] [] gss_release_msg+0x25/0x70 [auth_rpcgss]
> [ 137.689996] [] gss_pipe_downcall+0x208/0x4b0 [auth_rpcgss]
> [ 137.689996] [] rpc_pipe_write+0x3b/0x60 [sunrpc]
> [ 137.689996] [] ? rpc_pipe_poll+0x90/0x90 [sunrpc]
> [ 137.689996] [] vfs_write+0x95/0x1c0
> [ 137.689996] [] SyS_write+0x51/0x90
> [ 137.689996] [] sysenter_do_call+0x12/0x28
> [ 137.689996] Code: f8 e8 4f b8 9a c8 31 c0 eb c6 90 8d b4 26 00 00 00 00 55 
> 89 
> e5 56 53 3e 8d 74 26 00 8b 1d 28 e9 a3 f8 89 c6 e8 59 64 5f c8 85 db <8b> 
> 86 58 08 00 00 74 3a 3b 18 77 36 8b 5c 98 08 e8 32 66 5f c8
> [ 137.689996] EIP: [] put_pipe_version+0x19/0x60 [auth_rpcgss] 
> SS:ESP 0068:f568fee0
> [ 137.689996] CR2: 0858
> [ 138.578433] ---[ end trace 3dcb8d5c35b64fbd ]---
> [ 142.979263] type=1006 audit(1392415950.632:4): pid=540 uid=0 old 
> auid=4294967295 new auid=1000 old ses=4294967295 new ses=3 res=1


I should add that if I test the same kernel version (v3.13.3 compiled for i686) 
on a similar machine of the same vintage, there is not a problem.  When I 
looked into the `lspci -v` output on the machine that has the problems, I found 
that it seems to be related to the skge driver as shown below; the similar 
machine that does not have the problem is using the forcedeth driver so I am 
hypothesizing that the error is with the skge driver.

01:04.0 Ethernet controller: Marvell Technology Group Ltd. 88E8001 Gigabit 
Ethernet Controller (rev 13)
        Subsystem: ASUSTeK Computer Inc. Marvell 88E8001 Gigabit Ethernet 
Controller (Asus)
        Flags: bus master, 66MHz, medium devsel, latency 32, IRQ 17
        Memory at d500 (32-bit, non-prefetchable) [size=16K]
        I/O ports at a000 [size=256]
        [virtual] Expansion ROM at 8008 [disabled] [size=128K]
        Capabilities: [48] Power Management version 2
        Capabilities: [50] Vital Product Data
        Kernel driver in use: skge
        Kernel modules: skge

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


Re: [PATCH V6 1/1] Drivers: hv: Implement the file copy service

2014-02-15 Thread Greg KH
On Wed, Feb 12, 2014 at 10:14:03AM -0800, K. Y. Srinivasan wrote:
> Implement the file copy service for Linux guests on Hyper-V. This permits the
> host to copy a file (over VMBUS) into the guest. This facility is part of
> "guest integration services" supported on the Windows platform.
> Here is a link that provides additional details on this functionality:
> 
> http://technet.microsoft.com/en-us/library/dn464282.aspx
> 
> In V1 version of the patch I have addressed comments from
> Olaf Hering  and Dan Carpenter 
> 
> In V2 version of this patch I did some minor cleanup (making some globals
> static). In V4 version of the patch I have addressed all of Olaf's
> most recent set of comments/concerns.
> 
> In V5 version of the patch I had addressed Greg's most recent comments.
> I would like to thank Greg for suggesting that I use misc device; it has
> significantly simplified the code.
> 
> In this version of the patch I have cleaned up error message based on Olaf's
> comments. I have also rebased the patch based on the current tip.
> 
> Signed-off-by: K. Y. Srinivasan 
> ---
>  drivers/hv/Makefile |2 +-
>  drivers/hv/hv_fcopy.c   |  388 
> +++
>  drivers/hv/hv_util.c|   10 +
>  include/linux/hyperv.h  |   16 ++-
>  include/uapi/linux/hyperv.h |   46 +
>  tools/hv/hv_fcopy_daemon.c  |  195 ++
>  6 files changed, 655 insertions(+), 2 deletions(-)
>  create mode 100644 drivers/hv/hv_fcopy.c
>  create mode 100644 tools/hv/hv_fcopy_daemon.c
> 
> diff --git a/drivers/hv/Makefile b/drivers/hv/Makefile
> index 0a74b56..5e4dfa4 100644
> --- a/drivers/hv/Makefile
> +++ b/drivers/hv/Makefile
> @@ -5,4 +5,4 @@ obj-$(CONFIG_HYPERV_BALLOON)  += hv_balloon.o
>  hv_vmbus-y := vmbus_drv.o \
>hv.o connection.o channel.o \
>channel_mgmt.o ring_buffer.o
> -hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o
> +hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o hv_fcopy.o
> diff --git a/drivers/hv/hv_fcopy.c b/drivers/hv/hv_fcopy.c
> new file mode 100644
> index 000..15cf35c
> --- /dev/null
> +++ b/drivers/hv/hv_fcopy.c
> @@ -0,0 +1,388 @@
> +/*
> + * An implementation of file copy service.
> + *
> + * Copyright (C) 2014, Microsoft, Inc.
> + *
> + * Author : K. Y. Srinivasan 
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License version 2 as published
> + * by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
> + * NON INFRINGEMENT.  See the GNU General Public License for more
> + * details.
> + *
> + */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define WIN8_SRV_MAJOR   1
> +#define WIN8_SRV_MINOR   1
> +#define WIN8_SRV_VERSION (WIN8_SRV_MAJOR << 16 | WIN8_SRV_MINOR)
> +
> +/*
> + * Global state maintained for transaction that is being processed.
> + * For a class of integration services, including the "file copy service",
> + * the specified protocol is a "request/response" protocol which means that
> + * there can only be single outstanding transaction from the host at any
> + * given point in time. We use this to simplify memory management in this
> + * driver - we cache and process only one message at a time.
> + *
> + * While the request/response protocol is guaranteed by the host, we further
> + * ensure this by serializing packet processing in this driver - we do not
> + * read additional packets from the VMBUs until the current packet is fully
> + * handled.
> + *
> + * The transaction "active" state is set when we receive a request from the
> + * host and we cleanup this state when the transaction is completed - when we
> + * respond to the host with our response. When the transaction active state 
> is
> + * set, we defer handling incoming packets.
> + */
> +
> +static struct {
> + bool active; /* transaction status - active or not */
> + int recv_len; /* number of bytes received. */
> + struct hv_fcopy_hdr  *fcopy_msg; /* current message */
> + struct hv_start_fcopy  message; /*  sent to daemon */
> + struct vmbus_channel *recv_channel; /* chn we got the request */
> + u64 recv_req_id; /* request ID. */
> + void *fcopy_context; /* for the channel callback */
> + struct semaphore read_sema;
> +} fcopy_transaction;
> +
> +static bool opened; /* currently device opened */
> +
> +/*
> + * Before we can accept copy messages from the host, we need
> + * to handshake with the user level daemon. This state tracks
> + * if we are in the handshake phase.
> + */
> +static bool in_hand_shake = true;
> +static void fcopy_send_data(void);
> 

Re: [PATCH v6 0/6] Add support for the System Power Management Interface (SPMI)

2014-02-15 Thread Greg Kroah-Hartman
On Wed, Feb 12, 2014 at 01:44:21PM -0600, Josh Cartwright wrote:
> Hey Greg-
> 
> Is it possible for you to pick this up for 3.15?  It'd be nice if we could get
> an Ack from devicetree folks on patches 2 and 5, but there has been many 
> months
> worth of opportunity for that.

All now applied to my tree.

thanks,

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: [PATCH] Drivers: net: wireless: mac80211_hwim fixed coding style issues

2014-02-15 Thread Antonio Quartulli
On 15/02/14 19:13, Johannes Berg wrote:
> On Sat, 2014-02-15 at 12:55 +0100, Justin van Wijngaarden wrote:
> 
>> @@ -1,19 +1,17 @@
>> -/*
>> - * mac80211_hwsim - software simulator of 802.11 radio(s) for mac80211
>> +/* mac80211_hwsim - software simulator of 802.11 radio(s) for mac80211
> 
> I don't see any point in this - lots of code exists both ways, that's
> really just fluff. The difference isn't even interesting enough to be
> worth fixing up.

This is how David S. Miller wants multiline comments to start in files
within the networking subsystem..but I know you don't like it ;)
(I just wanted to justify Justin).


Cheers,

-- 
Antonio Quartulli



signature.asc
Description: OpenPGP digital signature


[GIT PULL] x86 EFI fixes for v3.14-rc3

2014-02-15 Thread H. Peter Anvin
Hi Linus,

A few more EFI-related fixes.

The following changes since commit 4640c7ee9b8953237d05a61ea3ea93981d1bc961:

  x86, smap: smap_violation() is bogus if CONFIG_X86_SMAP is off (2014-02-13 
08:40:52 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-urgent-for-linus

for you to fetch changes up to 31fce91e7afc25c666276f65f019bc13fd27e216:

  Merge remote-tracking branch 'efi/urgent' into x86/urgent (2014-02-14 
11:11:18 -0800)



Borislav Petkov (1):
  x86/efi: Fix 32-bit fallout

H. Peter Anvin (1):
  Merge remote-tracking branch 'efi/urgent' into x86/urgent

Matt Fleming (1):
  x86/efi: Check status field to validate BGRT header

 arch/x86/include/asm/efi.h   | 2 ++
 arch/x86/platform/efi/efi-bgrt.c | 2 +-
 arch/x86/platform/efi/efi.c  | 5 ++---
 arch/x86/platform/efi/efi_32.c   | 6 ++
 arch/x86/platform/efi/efi_64.c   | 9 +
 5 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
index 3b978c472d08..3d6b9f81cc68 100644
--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -132,6 +132,8 @@ extern void __init efi_map_region_fixed(efi_memory_desc_t 
*md);
 extern void efi_sync_low_kernel_mappings(void);
 extern void efi_setup_page_tables(void);
 extern void __init old_map_region(efi_memory_desc_t *md);
+extern void __init runtime_code_page_mkexec(void);
+extern void __init efi_runtime_mkexec(void);
 
 struct efi_setup_data {
u64 fw_vendor;
diff --git a/arch/x86/platform/efi/efi-bgrt.c b/arch/x86/platform/efi/efi-bgrt.c
index 4df9591eadad..f15103dff4b4 100644
--- a/arch/x86/platform/efi/efi-bgrt.c
+++ b/arch/x86/platform/efi/efi-bgrt.c
@@ -42,7 +42,7 @@ void __init efi_bgrt_init(void)
 
if (bgrt_tab->header.length < sizeof(*bgrt_tab))
return;
-   if (bgrt_tab->version != 1)
+   if (bgrt_tab->version != 1 || bgrt_tab->status != 1)
return;
if (bgrt_tab->image_type != 0 || !bgrt_tab->image_address)
return;
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index d62ec87a2b26..1a201ac7cef8 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -792,7 +792,7 @@ void __init efi_set_executable(efi_memory_desc_t *md, bool 
executable)
set_memory_nx(addr, npages);
 }
 
-static void __init runtime_code_page_mkexec(void)
+void __init runtime_code_page_mkexec(void)
 {
efi_memory_desc_t *md;
void *p;
@@ -1069,8 +1069,7 @@ void __init efi_enter_virtual_mode(void)
efi.update_capsule = virt_efi_update_capsule;
efi.query_capsule_caps = virt_efi_query_capsule_caps;
 
-   if (efi_enabled(EFI_OLD_MEMMAP) && (__supported_pte_mask & _PAGE_NX))
-   runtime_code_page_mkexec();
+   efi_runtime_mkexec();
 
kfree(new_memmap);
 
diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
index 249b183cf417..0b74cdf7f816 100644
--- a/arch/x86/platform/efi/efi_32.c
+++ b/arch/x86/platform/efi/efi_32.c
@@ -77,3 +77,9 @@ void efi_call_phys_epilog(void)
 
local_irq_restore(efi_rt_eflags);
 }
+
+void __init efi_runtime_mkexec(void)
+{
+   if (__supported_pte_mask & _PAGE_NX)
+   runtime_code_page_mkexec();
+}
diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index 6284f158a47d..0c2a234fef1e 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -233,3 +233,12 @@ void __init parse_efi_setup(u64 phys_addr, u32 data_len)
 {
efi_setup = phys_addr + sizeof(struct setup_data);
 }
+
+void __init efi_runtime_mkexec(void)
+{
+   if (!efi_enabled(EFI_OLD_MEMMAP))
+   return;
+
+   if (__supported_pte_mask & _PAGE_NX)
+   runtime_code_page_mkexec();
+}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] lib: Fix some sparse warnings in devres.c

2014-02-15 Thread Greg Kroah-Hartman
On Thu, Feb 06, 2014 at 11:13:46AM -0500, Steven Rostedt wrote:
> Having a discussion about sparse warnings in the kernel, and that we
> should clean them up, I decided to pick a random file to do so. This
> happened to be devres.c which gives the following warnings:
> 
>   CHECK   lib/devres.c
> lib/devres.c:83:9: warning: cast removes address space of expression
> lib/devres.c:117:31: warning: incorrect type in return expression (different 
> address spaces)
> lib/devres.c:117:31:expected void [noderef] *
> lib/devres.c:117:31:got void *
> lib/devres.c:125:31: warning: incorrect type in return expression (different 
> address spaces)
> lib/devres.c:125:31:expected void [noderef] *
> lib/devres.c:125:31:got void *
> lib/devres.c:136:26: warning: incorrect type in assignment (different address 
> spaces)
> lib/devres.c:136:26:expected void [noderef] *[assigned] dest_ptr
> lib/devres.c:136:26:got void *
> lib/devres.c:226:9: warning: cast removes address space of expression
> 
> Mostly it's just the use of typecasting to void * without adding
> __force, or returning ERR_PTR(-ESOMEERR) without typecasting to a
> __iomem type.
> 
> I added a helper macro IOMEM_ERR_PTR() that does the typecast to make
> the code a little nicer than adding ugly typecasts to the code.
> 
> This is applied against linux-next.
> 
> Signed-off-by: Steven Rostedt 

Acked-by: Greg Kroah-Hartman 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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   >