Re: linux-next: build warning after merge of the drm-panel tree

2015-03-31 Thread Thierry Reding
On Tue, Mar 31, 2015 at 11:03:55PM +1100, Stephen Rothwell wrote:
> Hi all,
> 
> On Wed, 25 Mar 2015 17:20:56 +1100 Stephen Rothwell  
> wrote:
> >
> > After merging the drm-panel tree, today's linux-next build (powerpc
> > ppc64_defconfig) produced this warning:
> > 
> > drivers/video/fbdev/Kconfig:5:error: recursive dependency detected!
> > drivers/video/fbdev/Kconfig:5:  symbol FB is selected by 
> > DRM_KMS_FB_HELPER
> > drivers/gpu/drm/Kconfig:34: symbol DRM_KMS_FB_HELPER depends on 
> > DRM_KMS_HELPER
> > drivers/gpu/drm/Kconfig:28: symbol DRM_KMS_HELPER is selected by DRM_PTN3460
> > drivers/gpu/drm/bridge/Kconfig:6:   symbol DRM_PTN3460 depends on GPIOLIB
> > drivers/gpio/Kconfig:34:symbol GPIOLIB is selected by 
> > ARCH_REQUIRE_GPIOLIB
> > drivers/gpio/Kconfig:23:symbol ARCH_REQUIRE_GPIOLIB is selected by 
> > MCU_MPC8349EMITX
> > arch/powerpc/platforms/Kconfig:350: symbol MCU_MPC8349EMITX depends on I2C
> > drivers/i2c/Kconfig:7:  symbol I2C is selected by FB_DDC
> > drivers/video/fbdev/Kconfig:59: symbol FB_DDC is selected by 
> > FB_CYBER2000_DDC
> > drivers/video/fbdev/Kconfig:374:symbol FB_CYBER2000_DDC depends on 
> > FB_CYBER2000
> > drivers/video/fbdev/Kconfig:362:symbol FB_CYBER2000 depends on FB
> > 
> > Introduced by commit 6a43766f6ef3 ("drm/bridge: ps8622 and ptn3460
> > depend on gpiolib").
> 
> This is still going on ...

I tried turning the 'select I2C' from FB_DDC into a "depends on I2C",
which seems like the more appropriate type of dependency, but that
causes a slew of new warnings because now all of a sudden some symbols
have unmet direct dependencies.

This is really quite messy. The only solution I can think of would be to
provide stubs for all of the GPIO API so that the dependency can be
dropped again. That's a little extreme and shouldn't be necessary, but I
don't see any other way to untangle this mess, I'm afraid.

Arnd, any ideas?

Thierry


pgp0GG79mcsTw.pgp
Description: PGP signature


RE: [PATCH] x86/quark: Run IMR self-test on IMR capble hw only

2015-03-31 Thread Ong, Boon Leong
Looks good to me. Thanks

>-Original Message-
>From: Bryan O'Donoghue [mailto:pure.lo...@nexus-software.ie]
>Sent: Tuesday, March 31, 2015 7:16 PM
>To: pure.lo...@nexus-software.ie; mi...@redhat.com; t...@linutronix.de;
>h...@zytor.com; x...@kernel.org; Huang, Ying; huang.ying.cari...@gmail.com;
>Shevchenko, Andriy; Ong, Boon Leong; dvh...@linux.intel.com; linux-
>ker...@vger.kernel.org
>Subject: [PATCH] x86/quark: Run IMR self-test on IMR capble hw only
>
>Automated testing with LKP shows IMR self test code running and printing
>error messages on QEMU hardware lacking IMR support.
>
>Update IMR self-test code to run only when IMR hardware should be present.
>Tested on Quark X1000 and QEMU.
>
>Signed-off-by: Bryan O'Donoghue 
Acked-by: Ong Boon Leong 

>---
> arch/x86/platform/intel-quark/imr_selftest.c | 11 ++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
>diff --git a/arch/x86/platform/intel-quark/imr_selftest.c
>b/arch/x86/platform/intel-quark/imr_selftest.c
>index c9a0838..5e6c055 100644
>--- a/arch/x86/platform/intel-quark/imr_selftest.c
>+++ b/arch/x86/platform/intel-quark/imr_selftest.c
>@@ -11,6 +11,7 @@
>  */
>
> #include 
>+#include 
> #include 
> #include 
> #include 
>@@ -101,6 +102,13 @@ static void __init imr_self_test(void)
>   }
> }
>
>+static const struct x86_cpu_id imr_ids[] __initconst = {
>+  { X86_VENDOR_INTEL, 5, 9 }, /* Intel Quark SoC X1000. */
>+  {}
>+};
>+MODULE_DEVICE_TABLE(x86cpu, imr_ids);
>+
>+
> /**
>  * imr_self_test_init - entry point for IMR driver.
>  *
>@@ -108,7 +116,8 @@ static void __init imr_self_test(void)
>  */
> static int __init imr_self_test_init(void)  {
>-  imr_self_test();
>+  if (x86_match_cpu(imr_ids))
>+  imr_self_test();
>   return 0;
> }
>
>--
>1.9.1

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


Re: [PATCH 4/4] Documentation: extcon: usb-gpio: update usb-gpio binding description

2015-03-31 Thread Robert Baldyga
Hi,

On 03/31/2015 12:20 PM, Roger Quadros wrote:
> On 31/03/15 10:46, Robert Baldyga wrote:
>> Add information about VBUS pin detection support, 'debounce' property
>> and some other details.
>>
>> Signed-off-by: Robert Baldyga 
>> ---
>>  .../devicetree/bindings/extcon/extcon-usb-gpio.txt | 23 
>> --
>>  1 file changed, 21 insertions(+), 2 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt 
>> b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
>> index af0b903..d3fcf8b 100644
>> --- a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
>> +++ b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
>> @@ -1,16 +1,35 @@
>>  USB GPIO Extcon device
>>  
>> -This is a virtual device used to generate USB cable states from the USB ID 
>> pin
>> -connected to a GPIO pin.
>> +This is a virtual device used to generate USB cable states from the USB
>> +ID and VBUS signals connected to a GPIO pins.
> 
> s/to a GPIO/to GPIO/
> 
>> +
>> +Some devices has only one of these GPIO pins, so we support cases when
> s/has/have/
> 
>> +only one of them is present. Hence properties 'id-gpio' and 'vbus-gpio'
>> +are described as optional, but at least one of them has to be present
>> +in extcon-usb-gpio node.
>> +
>> +In general we have three cases:
>> + 1. We have both VBUS and ID pin detection - we can detect USB, USB-HOST
>> +and cable disconnection.
> 
> The interpretation of "cable disconnect" might not be always true.
> ID may be 1 and VBUS 0 but cable might still not be disconnected.
> e.g. if both are OTG devices.
> That's why we have ADP to detect cable connect/disconnect status for OTG case.
> 
> So let's leave cable disconnection interpretation to the USB stack and
> just deal with passing ID/VBUS status. I must admit that the extcon cable
> state names are misleading. They should really have been named
> USB-ID and USB-VBUS :).

I thought the same.

Chanwoo, what do you think about such naming convention change? USB
cable detection in general is needed mainly for OTG, so having cable
state names clearly related to OTG statemachine states seems to be good
idea.

> 
> The driver doesn't do connect/disconnect detection but only infers the other
> pin state if only one of the ID/VBUS is available.
> 
>> + 2. We have only VBUS detection - we can detect USB and cable disconnection.
>> + 3. We have ID pin only - we can distinguish between USB and USB-HOST
>> +but without ability to detect cable disconnection.
> 
> how about rewording these 3 points like so with a short header about
> clarification of extcon USB/USB_HOST states.
> 
> The extcon cable states USB and USB_HOST are actually VBUS and (inverted) ID
> pin states and do not indicate what mode the USB needs to operate in.
> That decision is done by the USB stack.
> 
> 1. If VBUS and ID gpios are present we pass them as is
>   USB-HOST = !ID, USB = VBUS
> 2. If only VBUS gpio is present we assume that ID pin is always High.
>   USB-HOST = false, USB = VBUS.
> 3. If only ID pin is available we infer the VBUS pin states based on ID.
>   USB-HOST = !ID, USB = ID
> 

Thanks for comments. I will try to fix it up.

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


Re: linux-next: build warning after merge of the drm-panel tree

2015-03-31 Thread Stephen Rothwell
Hi all,

On Wed, 25 Mar 2015 17:20:56 +1100 Stephen Rothwell  
wrote:
>
> After merging the drm-panel tree, today's linux-next build (powerpc
> ppc64_defconfig) produced this warning:
> 
> drivers/video/fbdev/Kconfig:5:error: recursive dependency detected!
> drivers/video/fbdev/Kconfig:5:symbol FB is selected by 
> DRM_KMS_FB_HELPER
> drivers/gpu/drm/Kconfig:34:   symbol DRM_KMS_FB_HELPER depends on 
> DRM_KMS_HELPER
> drivers/gpu/drm/Kconfig:28:   symbol DRM_KMS_HELPER is selected by DRM_PTN3460
> drivers/gpu/drm/bridge/Kconfig:6: symbol DRM_PTN3460 depends on GPIOLIB
> drivers/gpio/Kconfig:34:  symbol GPIOLIB is selected by 
> ARCH_REQUIRE_GPIOLIB
> drivers/gpio/Kconfig:23:  symbol ARCH_REQUIRE_GPIOLIB is selected by 
> MCU_MPC8349EMITX
> arch/powerpc/platforms/Kconfig:350:   symbol MCU_MPC8349EMITX depends on I2C
> drivers/i2c/Kconfig:7:symbol I2C is selected by FB_DDC
> drivers/video/fbdev/Kconfig:59:   symbol FB_DDC is selected by 
> FB_CYBER2000_DDC
> drivers/video/fbdev/Kconfig:374:  symbol FB_CYBER2000_DDC depends on 
> FB_CYBER2000
> drivers/video/fbdev/Kconfig:362:  symbol FB_CYBER2000 depends on FB
> 
> Introduced by commit 6a43766f6ef3 ("drm/bridge: ps8622 and ptn3460
> depend on gpiolib").

This is still going on ...

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


pgpErYR1TOaE2.pgp
Description: OpenPGP digital signature


[PATCH v1 3/3] mfd: Add support for Intel Sunrisepoint LPSS devices

2015-03-31 Thread Andy Shevchenko
The new coming Intel platforms such as Skylake will contain Sunrisepoint PCH.
The main difference to the previous platforms is that the LPSS devices are
compound devices where usually main (SPI, HSUART, or I2C) and DMA IPs are
present.

This patch brings the driver for such devices found on Sunrisepoint PCH.

Signed-off-by: Mika Westerberg 
Signed-off-by: Andy Shevchenko 
---
 drivers/mfd/Kconfig   |  24 ++
 drivers/mfd/Makefile  |   3 +
 drivers/mfd/intel-lpss-acpi.c |  84 +++
 drivers/mfd/intel-lpss-pci.c  | 106 +
 drivers/mfd/intel-lpss.c  | 523 ++
 drivers/mfd/intel-lpss.h  |  62 +
 6 files changed, 802 insertions(+)
 create mode 100644 drivers/mfd/intel-lpss-acpi.c
 create mode 100644 drivers/mfd/intel-lpss-pci.c
 create mode 100644 drivers/mfd/intel-lpss.c
 create mode 100644 drivers/mfd/intel-lpss.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index d5ad04d..b1a6778 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -325,6 +325,30 @@ config INTEL_SOC_PMIC
  thermal, charger and related power management functions
  on these systems.
 
+config MFD_INTEL_LPSS
+   tristate "Intel Low Power Subsystem support"
+   depends on X86
+   select COMMON_CLK
+   select MFD_CORE
+   help
+ This driver provides necessary plumbing for Intel Low Power
+ Subsystem (LPSS) devices such as I2C, SPI and HS-UART starting
+ from Intel Sunrisepoint (Intel Skylake PCH) and newer chipsets.
+
+config MFD_INTEL_LPSS_ACPI
+   tristate "Intel Low Power Subsystem support in ACPI mode"
+   depends on MFD_INTEL_LPSS && ACPI
+   help
+ This driver support Intel Low Power Subsystem devices in ACPI
+ mode.
+
+config MFD_INTEL_LPSS_PCI
+   tristate "Intel Low Power Subsystem support in PCI mode"
+   depends on MFD_INTEL_LPSS && PCI
+   help
+ This driver support Intel Low Power Subsystem devices in PCI
+ mode.
+
 config MFD_INTEL_MSIC
bool "Intel MSIC"
depends on INTEL_SCU_IPC
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 0e5cfeb..cdf29b9 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -161,6 +161,9 @@ obj-$(CONFIG_TPS65911_COMPARATOR)   += tps65911-comparator.o
 obj-$(CONFIG_MFD_TPS65090) += tps65090.o
 obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o
 obj-$(CONFIG_MFD_ATMEL_HLCDC)  += atmel-hlcdc.o
+obj-$(CONFIG_MFD_INTEL_LPSS)   += intel-lpss.o
+obj-$(CONFIG_MFD_INTEL_LPSS_PCI)   += intel-lpss-pci.o
+obj-$(CONFIG_MFD_INTEL_LPSS_ACPI)  += intel-lpss-acpi.o
 obj-$(CONFIG_MFD_INTEL_MSIC)   += intel_msic.o
 obj-$(CONFIG_MFD_PALMAS)   += palmas.o
 obj-$(CONFIG_MFD_VIPERBOARD)+= viperboard.o
diff --git a/drivers/mfd/intel-lpss-acpi.c b/drivers/mfd/intel-lpss-acpi.c
new file mode 100644
index 000..0d92d73
--- /dev/null
+++ b/drivers/mfd/intel-lpss-acpi.c
@@ -0,0 +1,84 @@
+/*
+ * Intel LPSS ACPI support.
+ *
+ * Copyright (C) 2015, Intel Corporation
+ *
+ * Authors: Andy Shevchenko 
+ *  Mika Westerberg 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "intel-lpss.h"
+
+static const struct intel_lpss_platform_info spt_info = {
+   .clk_rate = 12000,
+};
+
+static const struct acpi_device_id intel_lpss_acpi_ids[] = {
+   /* SPT */
+   { "INT3446", (kernel_ulong_t)_info },
+   { "INT3447", (kernel_ulong_t)_info },
+   { }
+};
+MODULE_DEVICE_TABLE(acpi, intel_lpss_acpi_ids);
+
+static int intel_lpss_acpi_probe(struct platform_device *pdev)
+{
+   struct intel_lpss_platform_info *info;
+   const struct acpi_device_id *id;
+
+   id = acpi_match_device(intel_lpss_acpi_ids, >dev);
+   if (!id)
+   return -ENODEV;
+
+   info = devm_kmemdup(>dev, (void *)id->driver_data, sizeof(*info),
+   GFP_KERNEL);
+   if (!info)
+   return -ENOMEM;
+
+   info->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   info->irq = platform_get_irq(pdev, 0);
+
+   pm_runtime_set_active(>dev);
+   pm_runtime_enable(>dev);
+
+   return intel_lpss_probe(>dev, info);
+}
+
+static int intel_lpss_acpi_remove(struct platform_device *pdev)
+{
+   intel_lpss_remove(>dev);
+   pm_runtime_disable(>dev);
+
+   return 0;
+}
+
+static INTEL_LPSS_PM_OPS(intel_lpss_acpi_pm_ops);
+
+static struct platform_driver intel_lpss_acpi_driver = {
+   .probe = intel_lpss_acpi_probe,
+   .remove = intel_lpss_acpi_remove,
+   .driver = {
+   .name = "intel-lpss",
+   .acpi_match_table = intel_lpss_acpi_ids,
+   .pm = _lpss_acpi_pm_ops,
+   },
+};
+

[PATCH v1 1/3] PM / QoS: Make it possible to expose device latency tolerance to userspace

2015-03-31 Thread Andy Shevchenko
From: Mika Westerberg 

Typically when a device is created the bus core it belongs to (for example
PCI) does not know if the device supports things like latency tolerance.
This is left to the driver that binds to the device in question. However,
at that time the device has already been created and there is no way to set
its dev->power.set_latency_tolerance anymore.

So follow what has been done for other PM QoS attributes as well and allow
drivers to expose and hide latency tolerance from userspace, if the device
supports it.

Signed-off-by: Mika Westerberg 
Signed-off-by: Andy Shevchenko 
---
 drivers/base/power/power.h |  2 ++
 drivers/base/power/qos.c   | 37 +
 drivers/base/power/sysfs.c | 11 +++
 include/linux/pm_qos.h |  5 +
 4 files changed, 55 insertions(+)

diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index b6b8a27..0e62fb2 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -33,6 +33,8 @@ extern int pm_qos_sysfs_add_resume_latency(struct device 
*dev);
 extern void pm_qos_sysfs_remove_resume_latency(struct device *dev);
 extern int pm_qos_sysfs_add_flags(struct device *dev);
 extern void pm_qos_sysfs_remove_flags(struct device *dev);
+extern int pm_qos_sysfs_add_latency_tolerance(struct device *dev);
+extern void pm_qos_sysfs_remove_latency_tolerance(struct device *dev);
 
 #else /* CONFIG_PM */
 
diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c
index e56d538..7f3646e 100644
--- a/drivers/base/power/qos.c
+++ b/drivers/base/power/qos.c
@@ -883,3 +883,40 @@ int dev_pm_qos_update_user_latency_tolerance(struct device 
*dev, s32 val)
mutex_unlock(_pm_qos_mtx);
return ret;
 }
+
+/**
+ * dev_pm_qos_expose_latency_tolerance - Expose latency tolerance to userspace
+ * @dev: Device whose latency tolerance to expose
+ */
+int dev_pm_qos_expose_latency_tolerance(struct device *dev)
+{
+   int ret;
+
+   if (!dev->power.set_latency_tolerance)
+   return -EINVAL;
+
+   mutex_lock(_pm_qos_sysfs_mtx);
+   ret = pm_qos_sysfs_add_latency_tolerance(dev);
+   mutex_unlock(_pm_qos_sysfs_mtx);
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(dev_pm_qos_expose_latency_tolerance);
+
+/**
+ * dev_pm_qos_hide_latency_tolerance - Hide latency tolerance from userspace
+ * @dev: Device whose latency tolerance to hide
+ */
+void dev_pm_qos_hide_latency_tolerance(struct device *dev)
+{
+   mutex_lock(_pm_qos_sysfs_mtx);
+   pm_qos_sysfs_remove_latency_tolerance(dev);
+   mutex_unlock(_pm_qos_sysfs_mtx);
+
+   /* Remove the request from user space now */
+   pm_runtime_get_sync(dev);
+   dev_pm_qos_update_user_latency_tolerance(dev,
+   PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT);
+   pm_runtime_put(dev);
+}
+EXPORT_SYMBOL_GPL(dev_pm_qos_hide_latency_tolerance);
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index d2be3f9..a7b4679 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -738,6 +738,17 @@ void pm_qos_sysfs_remove_flags(struct device *dev)
sysfs_unmerge_group(>kobj, _qos_flags_attr_group);
 }
 
+int pm_qos_sysfs_add_latency_tolerance(struct device *dev)
+{
+   return sysfs_merge_group(>kobj,
+_qos_latency_tolerance_attr_group);
+}
+
+void pm_qos_sysfs_remove_latency_tolerance(struct device *dev)
+{
+   sysfs_unmerge_group(>kobj, _qos_latency_tolerance_attr_group);
+}
+
 void rpm_sysfs_remove(struct device *dev)
 {
sysfs_unmerge_group(>kobj, _runtime_attr_group);
diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h
index 7b3ae0c..0f65d36 100644
--- a/include/linux/pm_qos.h
+++ b/include/linux/pm_qos.h
@@ -161,6 +161,8 @@ void dev_pm_qos_hide_flags(struct device *dev);
 int dev_pm_qos_update_flags(struct device *dev, s32 mask, bool set);
 s32 dev_pm_qos_get_user_latency_tolerance(struct device *dev);
 int dev_pm_qos_update_user_latency_tolerance(struct device *dev, s32 val);
+int dev_pm_qos_expose_latency_tolerance(struct device *dev);
+void dev_pm_qos_hide_latency_tolerance(struct device *dev);
 
 static inline s32 dev_pm_qos_requested_resume_latency(struct device *dev)
 {
@@ -229,6 +231,9 @@ static inline s32 
dev_pm_qos_get_user_latency_tolerance(struct device *dev)
{ return PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT; }
 static inline int dev_pm_qos_update_user_latency_tolerance(struct device *dev, 
s32 val)
{ return 0; }
+static inline int dev_pm_qos_expose_latency_tolerance(struct device *dev)
+   { return 0; }
+static inline void dev_pm_qos_hide_latency_tolerance(struct device *dev) {}
 
 static inline s32 dev_pm_qos_requested_resume_latency(struct device *dev) { 
return 0; }
 static inline s32 dev_pm_qos_requested_flags(struct device *dev) { return 0; }
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body 

[PATCH v1 2/3] ACPI / PM: Attach ACPI power domain only once

2015-03-31 Thread Andy Shevchenko
From: Mika Westerberg 

Some devices, like MFD subdevices, share a single ACPI companion device so
that they are able to access their resources and children. However,
currently all these subdevices are attached to the ACPI power domain and
this might cause that the power methods for the companion device get called
more than once.

In order to solve this we attach the ACPI power domain only to the first
physical device that is bound to the ACPI companion device. In case of MFD
devices, this is the parent MFD device itself.

Signed-off-by: Mika Westerberg 
Signed-off-by: Andy Shevchenko 
---
 drivers/acpi/device_pm.c |  8 
 drivers/acpi/internal.h  |  2 ++
 drivers/acpi/scan.c  | 46 --
 3 files changed, 42 insertions(+), 14 deletions(-)

diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 735db11..7d0c7e9 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -1103,6 +1103,14 @@ int acpi_dev_pm_attach(struct device *dev, bool power_on)
if (dev->pm_domain)
return -EEXIST;
 
+   /*
+* Only attach the power domain to the first device if the
+* companion is shared by multiple. This is to prevent doing power
+* management twice.
+*/
+   if (!acpi_device_is_first_physical_node(adev, dev))
+   return -EBUSY;
+
acpi_add_pm_notifier(adev, dev, acpi_pm_notify_work_func);
dev->pm_domain = _general_pm_domain;
if (power_on) {
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 56b321a..2aa8430 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -96,6 +96,8 @@ void acpi_device_add_finalize(struct acpi_device *device);
 void acpi_free_pnp_ids(struct acpi_device_pnp *pnp);
 bool acpi_device_is_present(struct acpi_device *adev);
 bool acpi_device_is_battery(struct acpi_device *adev);
+bool acpi_device_is_first_physical_node(struct acpi_device *adev,
+   const struct device *dev);
 
 /* --
   Power Resource
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index bbca783..1beef99 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -188,6 +188,37 @@ static int create_modalias(struct acpi_device *acpi_dev, 
char *modalias,
return len;
 }
 
+/**
+ * acpi_device_is_first_physical_node - Is given dev first physical node
+ * @adev: ACPI companion device
+ * @dev: Physical device to check
+ *
+ * Function checks if given @dev is the first physical devices attached to
+ * the ACPI companion device. This distinction is needed in some cases
+ * where the same companion device is shared between many physical devices.
+ *
+ * Note that the caller have to provide valid @adev pointer.
+ */
+bool acpi_device_is_first_physical_node(struct acpi_device *adev,
+   const struct device *dev)
+{
+   bool ret;
+
+   mutex_lock(>physical_node_lock);
+   if (list_empty(>physical_node_list)) {
+   ret = false;
+   } else {
+   const struct acpi_device_physical_node *node;
+
+   node = list_first_entry(>physical_node_list,
+   struct acpi_device_physical_node, node);
+   ret = node->dev == dev;
+   }
+   mutex_unlock(>physical_node_lock);
+
+   return ret;
+}
+
 /*
  * acpi_companion_match() - Can we match via ACPI companion device
  * @dev: Device in question
@@ -211,7 +242,6 @@ static int create_modalias(struct acpi_device *acpi_dev, 
char *modalias,
 static bool acpi_companion_match(const struct device *dev)
 {
struct acpi_device *adev;
-   bool ret;
 
adev = ACPI_COMPANION(dev);
if (!adev)
@@ -220,19 +250,7 @@ static bool acpi_companion_match(const struct device *dev)
if (list_empty(>pnp.ids))
return false;
 
-   mutex_lock(>physical_node_lock);
-   if (list_empty(>physical_node_list)) {
-   ret = false;
-   } else {
-   const struct acpi_device_physical_node *node;
-
-   node = list_first_entry(>physical_node_list,
-   struct acpi_device_physical_node, node);
-   ret = node->dev == dev;
-   }
-   mutex_unlock(>physical_node_lock);
-
-   return ret;
+   return acpi_device_is_first_physical_node(adev, dev);
 }
 
 /*
-- 
2.1.4

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


[PATCH v1 0/3] mfd: introduce a driver for LPSS devices on SPT

2015-03-31 Thread Andy Shevchenko
The new coming Intel platforms such as Skylake will contain Sunrisepoint PCH.
This patch brings the driver for such devices found on Sunrisepoint PCH.

The patch depends on published earlier [1] "clkdev: prevent potential memory
leak when used in modules".

[1] http://www.spinics.net/lists/kernel/msg1950939.html

Andy Shevchenko (1):
  mfd: Add support for Intel Sunrisepoint LPSS devices

Mika Westerberg (2):
  PM / QoS: Make it possible to expose device latency tolerance to
userspace
  ACPI / PM: Attach ACPI power domain only once

 drivers/acpi/device_pm.c  |   8 +
 drivers/acpi/internal.h   |   2 +
 drivers/acpi/scan.c   |  46 ++--
 drivers/base/power/power.h|   2 +
 drivers/base/power/qos.c  |  37 +++
 drivers/base/power/sysfs.c|  11 +
 drivers/mfd/Kconfig   |  24 ++
 drivers/mfd/Makefile  |   3 +
 drivers/mfd/intel-lpss-acpi.c |  84 +++
 drivers/mfd/intel-lpss-pci.c  | 106 +
 drivers/mfd/intel-lpss.c  | 523 ++
 drivers/mfd/intel-lpss.h  |  62 +
 include/linux/pm_qos.h|   5 +
 13 files changed, 899 insertions(+), 14 deletions(-)
 create mode 100644 drivers/mfd/intel-lpss-acpi.c
 create mode 100644 drivers/mfd/intel-lpss-pci.c
 create mode 100644 drivers/mfd/intel-lpss.c
 create mode 100644 drivers/mfd/intel-lpss.h

-- 
2.1.4

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


[PATCH] virtio: drop a useless config read

2015-03-31 Thread Michael S. Tsirkin
commit d71de9ec6ba806104439d3a669befda84757b5af
"virtio: core support for config generation"
fixed reading up 64 bit values, adding generation
checks for such reads.

By mistake, it left an explicit get call in place
as well. the result is that the value is read twice,
the first result is discarded.

Not a big deal since this only happens with virtio
blk and only on boot ATM, so performance isn't
affected, but let's clean it up.

Signed-off-by: Michael S. Tsirkin 
---
 include/linux/virtio_config.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index ca3ed78..ed1e0d5 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -374,7 +374,6 @@ static inline u64 virtio_cread64(struct virtio_device *vdev,
 unsigned int offset)
 {
u64 ret;
-   vdev->config->get(vdev, offset, , sizeof(ret));
__virtio_cread_many(vdev, offset, , 1, sizeof(ret));
return virtio64_to_cpu(vdev, (__force __virtio64)ret);
 }
-- 
MST
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] fs: direct-io: increase bio refcount as batch

2015-03-31 Thread Ming Lei
Each bio is always submitted to block device one by one,
so it isn't necessary to increase the bio refcount by one
each time with holding dio->bio_lock.

Signed-off-by: Ming Lei 
---
 fs/direct-io.c |   27 +--
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/fs/direct-io.c b/fs/direct-io.c
index 6fb00e3..57b8e73 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -79,6 +79,8 @@ struct dio_submit {
get_block_t *get_block; /* block mapping function */
dio_submit_t *submit_io;/* IO submition function */
 
+   longsubmitted_bio;
+
loff_t logical_offset_in_bio;   /* current first logical block in bio */
sector_t final_block_in_bio;/* current final block in bio + 1 */
sector_t next_block_for_io; /* next block to be put under IO,
@@ -121,7 +123,7 @@ struct dio {
int is_async;   /* is IO async ? */
bool defer_completion;  /* defer AIO completion to workqueue? */
int io_error;   /* IO error in completion path */
-   unsigned long refcount; /* direct_io_worker() and bios */
+   long refcount;  /* direct_io_worker() and bios */
struct bio *bio_list;   /* singly linked via bi_private */
struct task_struct *waiter; /* waiting task (NULL if none) */
 
@@ -383,14 +385,9 @@ dio_bio_alloc(struct dio *dio, struct dio_submit *sdio,
 static inline void dio_bio_submit(struct dio *dio, struct dio_submit *sdio)
 {
struct bio *bio = sdio->bio;
-   unsigned long flags;
 
bio->bi_private = dio;
 
-   spin_lock_irqsave(>bio_lock, flags);
-   dio->refcount++;
-   spin_unlock_irqrestore(>bio_lock, flags);
-
if (dio->is_async && dio->rw == READ)
bio_set_pages_dirty(bio);
 
@@ -403,15 +400,26 @@ static inline void dio_bio_submit(struct dio *dio, struct 
dio_submit *sdio)
sdio->bio = NULL;
sdio->boundary = 0;
sdio->logical_offset_in_bio = 0;
+   sdio->submitted_bio++;
 }
 
 /*
  * Release any resources in case of a failure
  */
-static inline void dio_cleanup(struct dio *dio, struct dio_submit *sdio)
+static inline void dio_cleanup(struct dio *dio, struct dio_submit *sdio,
+   bool commit_refcount)
 {
+   unsigned long flags;
+
while (sdio->head < sdio->tail)
page_cache_release(dio->pages[sdio->head++]);
+
+   if (!commit_refcount)
+   return;
+
+   spin_lock_irqsave(>bio_lock, flags);
+   dio->refcount += (sdio->submitted_bio + 1);
+   spin_unlock_irqrestore(>bio_lock, flags);
 }
 
 /*
@@ -1215,7 +1223,6 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct 
inode *inode,
dio->i_size = i_size_read(inode);
 
spin_lock_init(>bio_lock);
-   dio->refcount = 1;
 
sdio.iter = iter;
sdio.final_block_in_request =
@@ -1234,7 +1241,7 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct 
inode *inode,
 
retval = do_direct_IO(dio, , _bh);
if (retval)
-   dio_cleanup(dio, );
+   dio_cleanup(dio, , false);
 
if (retval == -ENOTBLK) {
/*
@@ -1267,7 +1274,7 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct 
inode *inode,
 * It is possible that, we return short IO due to end of file.
 * In that case, we need to release all the pages we got hold on.
 */
-   dio_cleanup(dio, );
+   dio_cleanup(dio, , true);
 
/*
 * All block lookups have been performed. For READ requests
-- 
1.7.9.5

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


Re: [PATCH v5 2/3] I2C: mediatek: Add driver for MediaTek I2C controller

2015-03-31 Thread Eddie Huang
Hi Sascha,

On Tue, 2015-03-31 at 15:08 +0800, Eddie Huang wrote:
> Hi Sascha,
> 
> On Mon, 2015-03-30 at 19:23 +0200, Sascha Hauer wrote:
> > On Mon, Mar 30, 2015 at 04:14:12PM +0800, Eddie Huang wrote:
> > > Hi Sascha,
> > >
> > > >
> > > > [...]
> > > >
> > > > > +   if (i2c->speed_hz > 40)
> > > > > +   control_reg |= I2C_CONTROL_RS;
> > > > > +   if (i2c->op == I2C_MASTER_WRRD)
> > > > > +   control_reg |= I2C_CONTROL_DIR_CHANGE | 
> > > > > I2C_CONTROL_RS;
> > > > > +   mtk_i2c_writew(control_reg, i2c, OFFSET_CONTROL);
> > > > > +
> > > > > +   /* set start condition */
> > > > > +   if (i2c->speed_hz <= 10)
> > > > > +   mtk_i2c_writew(I2C_ST_START_CON, i2c, 
> > > > > OFFSET_EXT_CONF);
> > > > > +   else
> > > > > +   mtk_i2c_writew(I2C_FS_START_CON, i2c, 
> > > > > OFFSET_EXT_CONF);
> > > > > +
> > > > > +   if (~control_reg & I2C_CONTROL_RS)
> > > > > +   mtk_i2c_writew(I2C_DELAY_LEN, i2c, OFFSET_DELAY_LEN);
> > > >
> > > > speed <= 40 here to make this more obvious?
> > > There are two cases, not only speed<=40, but I2C_MASTER_WRRD. I tend
> > > to keep it.
> >
> > Still it looks strange. You only ever write this default value to the
> > register. Putting this register write under an if() seems bogus since
> > the same value will be in the register the next time this code is
> > executed. It looks like you should move this register write to some
> > initialization function.
> OK, move to mtk_i2c_init_hw function
> 
Sorry for my negligence. Write-then-read (I2C_MASTER_WRRD) decides
according to each I2C transfer, so I still need to judge whether set
I2C_CONTROL_RS and DELAY_LEN here. Other control setting can move to
init function.

Eddie



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


Re: [PATCH 0/3] sysctl: detect overflows when setting integers

2015-03-31 Thread Alexey Dobriyan
On Mon, Mar 30, 2015 at 8:37 PM, Heinrich Schuchardt  wrote:
> Hello Alexey,
>
> thank you for reviewing.
>
> On 30.03.2015 14:34, Alexey Dobriyan wrote:
>>> Unfortunately functions simple_strtoul and simple_strtoull cannot
>>> be replaced by kstrtoul and kstrtoull in some places, because they
>>> expect a zero terminated string instead of returning a pointer to
>>> the character after the last digit.
>>>
>>> This patch introduces two new functions kstrtoul_e and kstrtoull_e
>>> which fill this gap.
>>
>> Well, there were two ideas:
>> a) to convert first, see what's left and generalize it,
>> b) kstrtox() should be used only in one place --
>>parsing integers in proc/sysfs files.
>
> Neither a) nor b) are mentioned in your patch
> https://lkml.org/lkml/2011/2/26/52.
>
> How does a) apply to my patch series?

Conversion is far from finished, so people do not see clearly what
interface they want.

> The patch series is about parsing integers inside the /proc mount so
> what is the conflict with b)?
>
> vsprintf.c has the following comment for simple_strtol:
> * This function is obsolete. Please use kstrtol instead.
>
> Could you, please, elaborate why kstrox.c should not be used in other
> places? Should we duplicate these functions instead of reusing them?
>
>>
>> The functions can probably be replaced by sscanf() (I didn't look closely).
>
> No. sscanf does not return the end of the parsed string. It requires to
> know beforehand if the string contains a octal, decimal or hexadecimal
> number.

Explicit base is good point.
As for knowing end of string, how often do you really want to know it?

>> I hate "_e" suffix with passion.
>
> Which names would you appreciate?

parse_integer() :-)

>> C in 2015 doesn't have this arcane concept known as optional
>> parameters so I'd suggest to hack around with always returning
>> number of OK characters
>
> Which functions should return the number of OK characters?

kstrto*() family can return positive amount or new interface.
Obvious question -- what to do with newline.

>> OR add one (just one) more separate
>> interface
>>
>>unsigned int parse_integer(const char *s, unsigned int base, T *p);
>
> Why would you call this function parse_integer and not kstrtox?

Because C style is horrible: atoi, atol, atoll, strtol, stroll,
strtoul, strtoull, ...
Embedding type into name, meh.

>> and dispatching with __builtin_choose_expr().
>
> https://gcc.gnu.org/onlinedocs/gcc-3.4.5/gcc/Other-Builtins.html
> describes how to use __builtin_types_compatible_p together with
> __builtin_choose_expr().
>
> I do not understand how to avoid exposing the interfaces of the
> functions actually called by a parse_integer function multiplexer.

Well, there is one advertised interface -- parse_integer() and
2x(char, short, int, long, long long) = 12 technically public
but not advertised interfaces.

>> Of course if someone rewrites that abomination called
>> sysctl parsing from scratch, maybe none of this will be needed!
>
> Unfortunately you are very vague about what you dislike in sysctl.

It makes sense for proc_get_long() mentioned on one of your patches
to know length of parsed string only when sysctl is an array of integers
not just one integer. But most of the sysctls are just simple values.

Again, no one looked at what is really needed and you adding
"char **endp" because manpage says so just proves the point.

I suggest to scrap libc-style integer parsing and do it right.
Namely:

  int parse_integer(const char *s, unsigned int base, T *val);

returns -E on error/overflow
returns (positive) number of character consumed otherwise.
*val is written only if there were no errors
accepts whitespace (space, tab only), sign '+', sign '-'.

Error checking can still remain

  rv = parse_integer(...);
  if (rv < 0)
   ...

because if very first character is invalid, -EINVAL is still returned.

Parsing multiple values becomes:

  rv = parse_integer(s, base, );
  if (rv < 0)
return rv;
  s += rv;
  rv = parse_integer(s, base, );
  if (rv < 0);

OpenBSD people came up with strtonum() at some point
http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man3/strtonum.3?query=strtonum=i386
pandora box "errstr" and missing ULL parsing are obvious.

Maybe Plan 9 got it right?
Well, no, they are still in "multiplication overflow" phase:
http://plan9.bell-labs.com/sources/plan9/sys/src/ape/lib/ap/gen/strtoul.c
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 V7 02/25] perf evlist: Add initial support for mmapping an AUX area buffer

2015-03-31 Thread Adrian Hunter
This patch anticipates the addition to the kernel
of an "aux" buffer that can be mmapped separately
from the perf-events buffer.

The expectation is that this buffer can be configured
to contain hardware-produced trace information.
The first implementation will support Intel BTS and
Intel PT.

One auxtrace buffer is mmapped per perf-events buffer.
If the requested auxtrace buffer size is zero, which
it will be until further support is added, then
no auxtrace mmapping is attempted.

Signed-off-by: Adrian Hunter 
---
 tools/perf/util/Build  |   1 +
 tools/perf/util/auxtrace.c | 108 +
 tools/perf/util/auxtrace.h |  97 
 tools/perf/util/evlist.c   |  61 +++--
 tools/perf/util/evlist.h   |   5 +++
 5 files changed, 269 insertions(+), 3 deletions(-)
 create mode 100644 tools/perf/util/auxtrace.c
 create mode 100644 tools/perf/util/auxtrace.h

diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 797490a..b6c3f39 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -74,6 +74,7 @@ libperf-y += data.o
 libperf-$(CONFIG_X86) += tsc.o
 libperf-y += cloexec.o
 libperf-y += thread-stack.o
+libperf-y += auxtrace.o
 
 libperf-$(CONFIG_LIBELF) += symbol-elf.o
 libperf-$(CONFIG_LIBELF) += probe-event.o
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
new file mode 100644
index 000..75419a5
--- /dev/null
+++ b/tools/perf/util/auxtrace.c
@@ -0,0 +1,108 @@
+/*
+ * auxtrace.c: AUX area trace support
+ * Copyright (c) 2013-2015, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../perf.h"
+#include "util.h"
+#include "evlist.h"
+#include "cpumap.h"
+#include "thread_map.h"
+#include "asm/bug.h"
+#include "auxtrace.h"
+
+int auxtrace_mmap__mmap(struct auxtrace_mmap *mm,
+   struct auxtrace_mmap_params *mp,
+   void *userpg, int fd)
+{
+#if BITS_PER_LONG != 64 && !defined(HAVE_SYNC_COMPARE_AND_SWAP_SUPPORT)
+   pr_err("Cannot use AUX area tracing mmaps\n");
+   return -1;
+#endif
+
+   WARN_ONCE(mm->base, "Uninitialized auxtrace_mmap\n");
+
+   mm->userpg = userpg;
+   mm->mask = mp->mask;
+   mm->len = mp->len;
+   mm->prev = 0;
+   mm->idx = mp->idx;
+   mm->tid = mp->tid;
+   mm->cpu = mp->cpu;
+
+   if (!mp->len) {
+   mm->base = NULL;
+   return 0;
+   }
+
+   mm->base = mmap(NULL, mp->len, mp->prot, MAP_SHARED, fd, mp->offset);
+   if (mm->base == MAP_FAILED) {
+   pr_debug2("failed to mmap AUX area\n");
+   mm->base = NULL;
+   return -1;
+   }
+
+   return 0;
+}
+
+void auxtrace_mmap__munmap(struct auxtrace_mmap *mm)
+{
+   if (mm->base) {
+   munmap(mm->base, mm->len);
+   mm->base = NULL;
+   }
+}
+
+void auxtrace_mmap_params__init(struct auxtrace_mmap_params *mp,
+   off_t auxtrace_offset,
+   unsigned int auxtrace_pages,
+   bool auxtrace_overwrite)
+{
+   if (auxtrace_pages) {
+   mp->offset = auxtrace_offset;
+   mp->len = auxtrace_pages * (size_t)page_size;
+   mp->mask = is_power_of_2(mp->len) ? mp->len - 1 : 0;
+   mp->prot = PROT_READ | (auxtrace_overwrite ? 0 : PROT_WRITE);
+   pr_debug2("AUX area mmap length %zu\n", mp->len);
+   } else {
+   mp->len = 0;
+   }
+}
+
+void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,
+  struct perf_evlist *evlist, int idx,
+  bool per_cpu)
+{
+   mp->idx = idx;
+
+   if (per_cpu) {
+   mp->cpu = evlist->cpus->map[idx];
+   if (evlist->threads)
+   mp->tid = evlist->threads->map[0];
+   else
+   mp->tid = -1;
+   } else {
+   mp->cpu = -1;
+   mp->tid = evlist->threads->map[idx];
+   }
+}
diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
new file mode 100644
index 000..735ca2a
--- /dev/null
+++ b/tools/perf/util/auxtrace.h
@@ -0,0 +1,97 @@
+/*
+ * auxtrace.h: AUX area trace support
+ * Copyright (c) 2013-2015, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under 

[PATCH v1 1/1] mfd: lpc_ich: sort IDs (part 2)

2015-03-31 Thread Andy Shevchenko
The patch sorts IDs in the table for easier maintenance. There is no functional
change.

Signed-off-by: Andy Shevchenko 
---
 drivers/mfd/lpc_ich.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/lpc_ich.c b/drivers/mfd/lpc_ich.c
index 8bd370a..12d960a 100644
--- a/drivers/mfd/lpc_ich.c
+++ b/drivers/mfd/lpc_ich.c
@@ -616,11 +616,11 @@ static const struct pci_device_id lpc_ich_ids[] = {
{ PCI_VDEVICE(INTEL, 0x2420), LPC_ICH0},
{ PCI_VDEVICE(INTEL, 0x2440), LPC_ICH2},
{ PCI_VDEVICE(INTEL, 0x244c), LPC_ICH2M},
+   { PCI_VDEVICE(INTEL, 0x2450), LPC_CICH},
{ PCI_VDEVICE(INTEL, 0x2480), LPC_ICH3},
{ PCI_VDEVICE(INTEL, 0x248c), LPC_ICH3M},
{ PCI_VDEVICE(INTEL, 0x24c0), LPC_ICH4},
{ PCI_VDEVICE(INTEL, 0x24cc), LPC_ICH4M},
-   { PCI_VDEVICE(INTEL, 0x2450), LPC_CICH},
{ PCI_VDEVICE(INTEL, 0x24d0), LPC_ICH5},
{ PCI_VDEVICE(INTEL, 0x25a1), LPC_6300ESB},
{ PCI_VDEVICE(INTEL, 0x2640), LPC_ICH6},
@@ -642,26 +642,26 @@ static const struct pci_device_id lpc_ich_ids[] = {
{ PCI_VDEVICE(INTEL, 0x267d), LPC_631XESB},
{ PCI_VDEVICE(INTEL, 0x267e), LPC_631XESB},
{ PCI_VDEVICE(INTEL, 0x267f), LPC_631XESB},
-   { PCI_VDEVICE(INTEL, 0x27b8), LPC_ICH7},
{ PCI_VDEVICE(INTEL, 0x27b0), LPC_ICH7DH},
+   { PCI_VDEVICE(INTEL, 0x27b8), LPC_ICH7},
{ PCI_VDEVICE(INTEL, 0x27b9), LPC_ICH7M},
-   { PCI_VDEVICE(INTEL, 0x27bd), LPC_ICH7MDH},
{ PCI_VDEVICE(INTEL, 0x27bc), LPC_NM10},
+   { PCI_VDEVICE(INTEL, 0x27bd), LPC_ICH7MDH},
{ PCI_VDEVICE(INTEL, 0x2810), LPC_ICH8},
+   { PCI_VDEVICE(INTEL, 0x2811), LPC_ICH8ME},
{ PCI_VDEVICE(INTEL, 0x2812), LPC_ICH8DH},
{ PCI_VDEVICE(INTEL, 0x2814), LPC_ICH8DO},
{ PCI_VDEVICE(INTEL, 0x2815), LPC_ICH8M},
-   { PCI_VDEVICE(INTEL, 0x2811), LPC_ICH8ME},
-   { PCI_VDEVICE(INTEL, 0x2918), LPC_ICH9},
-   { PCI_VDEVICE(INTEL, 0x2916), LPC_ICH9R},
{ PCI_VDEVICE(INTEL, 0x2912), LPC_ICH9DH},
{ PCI_VDEVICE(INTEL, 0x2914), LPC_ICH9DO},
-   { PCI_VDEVICE(INTEL, 0x2919), LPC_ICH9M},
+   { PCI_VDEVICE(INTEL, 0x2916), LPC_ICH9R},
{ PCI_VDEVICE(INTEL, 0x2917), LPC_ICH9ME},
-   { PCI_VDEVICE(INTEL, 0x3a18), LPC_ICH10},
+   { PCI_VDEVICE(INTEL, 0x2918), LPC_ICH9},
+   { PCI_VDEVICE(INTEL, 0x2919), LPC_ICH9M},
+   { PCI_VDEVICE(INTEL, 0x3a14), LPC_ICH10DO},
{ PCI_VDEVICE(INTEL, 0x3a16), LPC_ICH10R},
+   { PCI_VDEVICE(INTEL, 0x3a18), LPC_ICH10},
{ PCI_VDEVICE(INTEL, 0x3a1a), LPC_ICH10D},
-   { PCI_VDEVICE(INTEL, 0x3a14), LPC_ICH10DO},
{ PCI_VDEVICE(INTEL, 0x3b00), LPC_PCH},
{ PCI_VDEVICE(INTEL, 0x3b01), LPC_PCHM},
{ PCI_VDEVICE(INTEL, 0x3b02), LPC_P55},
-- 
2.1.4

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


[PATCH V7 03/25] perf tools: Add user events for AUX area tracing

2015-03-31 Thread Adrian Hunter
Add two user events for AUX area tracing.

PERF_RECORD_AUXTRACE_INFO contains metadata,
consisting primarily the type of the
AUX area tracing data plus some amount
of architecture-specific information.
There should be only one
PERF_RECORD_AUXTRACE_INFO event.

PERF_RECORD_AUXTRACE identifies AUX area
tracing data copied from the mmapped
AUX area tracing region.  The actual
data is not part of the event but
immediately follows it.

Signed-off-by: Adrian Hunter 
---
 tools/perf/util/event.c   |  2 ++
 tools/perf/util/event.h   | 22 +++
 tools/perf/util/session.c | 69 +++
 tools/perf/util/tool.h|  9 ++-
 4 files changed, 101 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index d5efa50..cbf3775 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -29,6 +29,8 @@ static const char *perf_event__names[] = {
[PERF_RECORD_HEADER_BUILD_ID]   = "BUILD_ID",
[PERF_RECORD_FINISHED_ROUND]= "FINISHED_ROUND",
[PERF_RECORD_ID_INDEX]  = "ID_INDEX",
+   [PERF_RECORD_AUXTRACE_INFO] = "AUXTRACE_INFO",
+   [PERF_RECORD_AUXTRACE]  = "AUXTRACE",
 };
 
 const char *perf_event__name(unsigned int id)
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index c4ffe2b..5dc9329 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -215,6 +215,8 @@ enum perf_user_event_type { /* above any possible kernel 
type */
PERF_RECORD_HEADER_BUILD_ID = 67,
PERF_RECORD_FINISHED_ROUND  = 68,
PERF_RECORD_ID_INDEX= 69,
+   PERF_RECORD_AUXTRACE_INFO   = 70,
+   PERF_RECORD_AUXTRACE= 71,
PERF_RECORD_HEADER_MAX
 };
 
@@ -281,6 +283,24 @@ struct id_index_event {
struct id_index_entry entries[0];
 };
 
+struct auxtrace_info_event {
+   struct perf_event_header header;
+   u32 type;
+   u32 reserved__; /* For alignment */
+   u64 priv[];
+};
+
+struct auxtrace_event {
+   struct perf_event_header header;
+   u64 size;
+   u64 offset;
+   u64 reference;
+   u32 idx;
+   u32 tid;
+   u32 cpu;
+   u32 reserved__; /* For alignment */
+};
+
 union perf_event {
struct perf_event_headerheader;
struct mmap_event   mmap;
@@ -296,6 +316,8 @@ union perf_event {
struct tracing_data_event   tracing_data;
struct build_id_event   build_id;
struct id_index_event   id_index;
+   struct auxtrace_info_event  auxtrace_info;
+   struct auxtrace_event   auxtrace;
 };
 
 void perf_event__print_totals(void);
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index adf0740..a8c67cb 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -254,6 +254,40 @@ static int process_id_index_stub(struct perf_tool *tool 
__maybe_unused,
return 0;
 }
 
+static int process_event_auxtrace_info_stub(struct perf_tool *tool 
__maybe_unused,
+   union perf_event *event __maybe_unused,
+   struct perf_session *session __maybe_unused)
+{
+   dump_printf(": unhandled!\n");
+   return 0;
+}
+
+static int skipn(int fd, off_t n)
+{
+   char buf[4096];
+   ssize_t ret;
+
+   while (n > 0) {
+   ret = read(fd, buf, MIN(n, sizeof(buf)));
+   if (ret <= 0)
+   return ret;
+   n -= ret;
+   }
+
+   return 0;
+}
+
+static s64 process_event_auxtrace_stub(struct perf_tool *tool __maybe_unused,
+  union perf_event *event,
+  struct perf_session *session
+  __maybe_unused)
+{
+   dump_printf(": unhandled!\n");
+   if (perf_data_file__is_pipe(session->file))
+   skipn(perf_data_file__fd(session->file), event->auxtrace.size);
+   return event->auxtrace.size;
+}
+
 void perf_tool__fill_defaults(struct perf_tool *tool)
 {
if (tool->sample == NULL)
@@ -290,6 +324,10 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
}
if (tool->id_index == NULL)
tool->id_index = process_id_index_stub;
+   if (tool->auxtrace_info == NULL)
+   tool->auxtrace_info = process_event_auxtrace_info_stub;
+   if (tool->auxtrace == NULL)
+   tool->auxtrace = process_event_auxtrace_stub;
 }
 
 static void swap_sample_id_all(union perf_event *event, void *data)
@@ -470,6 +508,29 @@ static void perf_event__tracing_data_swap(union perf_event 
*event,
event->tracing_data.size = bswap_32(event->tracing_data.size);
 }
 
+static void perf_event__auxtrace_info_swap(union perf_event *event,
+  bool sample_id_all 

[PATCH V7 08/25] perf session: Add hooks to allow transparent decoding of AUX area tracing data

2015-03-31 Thread Adrian Hunter
Hook into session processing so that AUX area decoding can
synthesize events transparently to the tools.

The advantages of transparent decoding are that tools can be used
directly with perf.data files containing AUX area tracing data,
which is easier for the user and more efficient than having a
separate decoding tool.

This will work as follows:
1. Tools will feed auxtrace events to the decoder using
perf_tool->auxtrace() (support for that still to come).
2. The decoder can process side-band events as needed due
to the auxtrace->process_event() hook.
3. The decoder can deliver synthesized events into the
event stream using perf_session__deliver_synth_event().

Note the expectation is that decoding will work on data that is
time-ordered with respect to the per-cpu or per-thread contexts
that were recorded.

Signed-off-by: Adrian Hunter 
---
 tools/perf/util/auxtrace.h | 55 
 tools/perf/util/session.c  | 70 +++---
 tools/perf/util/session.h  |  3 ++
 3 files changed, 111 insertions(+), 17 deletions(-)

diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
index e00f426..8c47aeb 100644
--- a/tools/perf/util/auxtrace.h
+++ b/tools/perf/util/auxtrace.h
@@ -23,6 +23,7 @@
 #include 
 
 #include "../perf.h"
+#include "session.h"
 
 union perf_event;
 struct perf_session;
@@ -32,6 +33,24 @@ struct record_opts;
 struct auxtrace_info_event;
 
 /**
+ * struct auxtrace - session callbacks to allow AUX area data decoding.
+ * @process_event: lets the decoder see all session events
+ * @flush_events: process any remaining data
+ * @free_events: free resources associated with event processing
+ * @free: free resources associated with the session
+ */
+struct auxtrace {
+   int (*process_event)(struct perf_session *session,
+union perf_event *event,
+struct perf_sample *sample,
+struct perf_tool *tool);
+   int (*flush_events)(struct perf_session *session,
+   struct perf_tool *tool);
+   void (*free_events)(struct perf_session *session);
+   void (*free)(struct perf_session *session);
+};
+
+/**
  * struct auxtrace_mmap - records an mmap of the auxtrace buffer.
  * @base: address of mapped area
  * @userpg: pointer to buffer's perf_event_mmap_page
@@ -148,4 +167,40 @@ int perf_event__synthesize_auxtrace_info(struct 
auxtrace_record *itr,
 struct perf_session *session,
 perf_event__handler_t process);
 
+static inline int auxtrace__process_event(struct perf_session *session,
+ union perf_event *event,
+ struct perf_sample *sample,
+ struct perf_tool *tool)
+{
+   if (!session->auxtrace)
+   return 0;
+
+   return session->auxtrace->process_event(session, event, sample, tool);
+}
+
+static inline int auxtrace__flush_events(struct perf_session *session,
+struct perf_tool *tool)
+{
+   if (!session->auxtrace)
+   return 0;
+
+   return session->auxtrace->flush_events(session, tool);
+}
+
+static inline void auxtrace__free_events(struct perf_session *session)
+{
+   if (!session->auxtrace)
+   return;
+
+   return session->auxtrace->free_events(session);
+}
+
+static inline void auxtrace__free(struct perf_session *session)
+{
+   if (!session->auxtrace)
+   return;
+
+   return session->auxtrace->free(session);
+}
+
 #endif
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index b4cac8b..918554d 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -15,12 +15,7 @@
 #include "cpumap.h"
 #include "perf_regs.h"
 #include "asm/bug.h"
-
-static int machines__deliver_event(struct machines *machines,
-  struct perf_evlist *evlist,
-  union perf_event *event,
-  struct perf_sample *sample,
-  struct perf_tool *tool, u64 file_offset);
+#include "auxtrace.h"
 
 static int perf_session__open(struct perf_session *session)
 {
@@ -92,13 +87,9 @@ static void perf_session__set_comm_exec(struct perf_session 
*session)
machines__set_comm_exec(>machines, comm_exec);
 }
 
-static int ordered_events__deliver_event(struct ordered_events *oe,
-struct ordered_event *event,
-struct perf_sample *sample)
-{
-   return machines__deliver_event(oe->machines, oe->evlist, event->event,
-  sample, oe->tool, event->file_offset);
-}
+static int perf_session__deliver_ordered_event(struct ordered_events *oe,
+

[PATCH V7 12/25] perf auxtrace: Add a heap for sorting AUX area tracing queues

2015-03-31 Thread Adrian Hunter
In order to process AUX area tracing
data in time order, the queue with data
with the lowest timestamp must be
processed first.  Provide a heap to
keep track of which queue that is.

As with the queues, a decoder does not have
to use the heap, but Intel BTS and Intel PT
will use it.

Signed-off-by: Adrian Hunter 
---
 tools/perf/util/auxtrace.c | 85 ++
 tools/perf/util/auxtrace.h | 29 
 2 files changed, 114 insertions(+)

diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index afcb09d..215f38e 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -356,6 +356,91 @@ void auxtrace_queues__free(struct auxtrace_queues *queues)
queues->nr_queues = 0;
 }
 
+static void auxtrace_heapify(struct auxtrace_heap_item *heap_array,
+unsigned int pos, unsigned int queue_nr,
+u64 ordinal)
+{
+   unsigned int parent;
+
+   while (pos) {
+   parent = (pos - 1) >> 1;
+   if (heap_array[parent].ordinal <= ordinal)
+   break;
+   heap_array[pos] = heap_array[parent];
+   pos = parent;
+   }
+   heap_array[pos].queue_nr = queue_nr;
+   heap_array[pos].ordinal = ordinal;
+}
+
+int auxtrace_heap__add(struct auxtrace_heap *heap, unsigned int queue_nr,
+  u64 ordinal)
+{
+   struct auxtrace_heap_item *heap_array;
+
+   if (queue_nr >= heap->heap_sz) {
+   unsigned int heap_sz = AUXTRACE_INIT_NR_QUEUES;
+
+   while (heap_sz <= queue_nr)
+   heap_sz <<= 1;
+   heap_array = realloc(heap->heap_array,
+heap_sz * sizeof(struct 
auxtrace_heap_item));
+   if (!heap_array)
+   return -ENOMEM;
+   heap->heap_array = heap_array;
+   heap->heap_sz = heap_sz;
+   }
+
+   auxtrace_heapify(heap->heap_array, heap->heap_cnt++, queue_nr, ordinal);
+
+   return 0;
+}
+
+void auxtrace_heap__free(struct auxtrace_heap *heap)
+{
+   zfree(>heap_array);
+   heap->heap_cnt = 0;
+   heap->heap_sz = 0;
+}
+
+void auxtrace_heap__pop(struct auxtrace_heap *heap)
+{
+   unsigned int pos, last, heap_cnt = heap->heap_cnt;
+   struct auxtrace_heap_item *heap_array;
+
+   if (!heap_cnt)
+   return;
+
+   heap->heap_cnt -= 1;
+
+   heap_array = heap->heap_array;
+
+   pos = 0;
+   while (1) {
+   unsigned int left, right;
+
+   left = (pos << 1) + 1;
+   if (left >= heap_cnt)
+   break;
+   right = left + 1;
+   if (right >= heap_cnt) {
+   heap_array[pos] = heap_array[left];
+   return;
+   }
+   if (heap_array[left].ordinal < heap_array[right].ordinal) {
+   heap_array[pos] = heap_array[left];
+   pos = left;
+   } else {
+   heap_array[pos] = heap_array[right];
+   pos = right;
+   }
+   }
+
+   last = heap_cnt - 1;
+   auxtrace_heapify(heap_array, pos, heap_array[last].queue_nr,
+heap_array[last].ordinal);
+}
+
 size_t auxtrace_record__info_priv_size(struct auxtrace_record *itr)
 {
if (itr)
diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
index 8849bc0..cdf5f51 100644
--- a/tools/perf/util/auxtrace.h
+++ b/tools/perf/util/auxtrace.h
@@ -168,6 +168,29 @@ struct auxtrace_queues {
 };
 
 /**
+ * struct auxtrace_heap_item - element of struct auxtrace_heap.
+ * @queue_nr: queue number
+ * @ordinal: value used for sorting (lowest ordinal is top of the heap) 
expected
+ *   to be a timestamp
+ */
+struct auxtrace_heap_item {
+   unsigned intqueue_nr;
+   u64 ordinal;
+};
+
+/**
+ * struct auxtrace_heap - a heap suitable for sorting AUX area tracing queues.
+ * @heap_array: the heap
+ * @heap_cnt: the number of elements in the heap
+ * @heap_sz: maximum number of elements (grows as needed)
+ */
+struct auxtrace_heap {
+   struct auxtrace_heap_item   *heap_array;
+   unsigned intheap_cnt;
+   unsigned intheap_sz;
+};
+
+/**
  * struct auxtrace_mmap - records an mmap of the auxtrace buffer.
  * @base: address of mapped area
  * @userpg: pointer to buffer's perf_event_mmap_page
@@ -277,6 +300,12 @@ void *auxtrace_buffer__get_data(struct auxtrace_buffer 
*buffer, int fd);
 void auxtrace_buffer__put_data(struct auxtrace_buffer *buffer);
 void auxtrace_buffer__drop_data(struct auxtrace_buffer *buffer);
 void auxtrace_buffer__free(struct auxtrace_buffer *buffer);
+
+int auxtrace_heap__add(struct auxtrace_heap *heap, unsigned int queue_nr,
+  u64 ordinal);
+void 

[PATCH V7 11/25] perf auxtrace: Add helpers for queuing AUX area tracing data

2015-03-31 Thread Adrian Hunter
Provide functions to queue AUX area tracing data
buffers for processing.  A AUX area decoder
need not use the queues, however Intel BTS and Intel PT
will use them.

There is one queue for each of the mmap buffers that
were used for recording.  Because those mmaps were
associated with per-cpu or per-thread contexts, the
data is time-ordered with respect to those contexts.

Signed-off-by: Adrian Hunter 
---
 tools/perf/util/auxtrace.c | 305 +
 tools/perf/util/auxtrace.h |  87 +
 2 files changed, 392 insertions(+)

diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index a1f0eef..afcb09d 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -22,11 +22,15 @@
 #include 
 #include 
 #include 
+#include 
 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 
 #include "../perf.h"
 #include "util.h"
@@ -117,6 +121,241 @@ void auxtrace_mmap_params__set_idx(struct 
auxtrace_mmap_params *mp,
}
 }
 
+#define AUXTRACE_INIT_NR_QUEUES32
+
+static struct auxtrace_queue *auxtrace_alloc_queue_array(unsigned int 
nr_queues)
+{
+   struct auxtrace_queue *queue_array;
+   unsigned int max_nr_queues, i;
+
+   max_nr_queues = MIN(UINT_MAX, SIZE_MAX) / sizeof(struct auxtrace_queue);
+   if (nr_queues > max_nr_queues)
+   return NULL;
+
+   queue_array = calloc(nr_queues, sizeof(struct auxtrace_queue));
+   if (!queue_array)
+   return NULL;
+
+   for (i = 0; i < nr_queues; i++) {
+   INIT_LIST_HEAD(_array[i].head);
+   queue_array[i].priv = NULL;
+   }
+
+   return queue_array;
+}
+
+int auxtrace_queues__init(struct auxtrace_queues *queues)
+{
+   queues->nr_queues = AUXTRACE_INIT_NR_QUEUES;
+   queues->queue_array = auxtrace_alloc_queue_array(queues->nr_queues);
+   if (!queues->queue_array)
+   return -ENOMEM;
+   return 0;
+}
+
+static int auxtrace_queues__grow(struct auxtrace_queues *queues,
+unsigned int new_nr_queues)
+{
+   unsigned int nr_queues = queues->nr_queues;
+   struct auxtrace_queue *queue_array;
+   unsigned int i;
+
+   if (!nr_queues)
+   nr_queues = AUXTRACE_INIT_NR_QUEUES;
+
+   while (nr_queues && nr_queues < new_nr_queues)
+   nr_queues <<= 1;
+
+   if (nr_queues < queues->nr_queues || nr_queues < new_nr_queues)
+   return -EINVAL;
+
+   queue_array = auxtrace_alloc_queue_array(nr_queues);
+   if (!queue_array)
+   return -ENOMEM;
+
+   for (i = 0; i < queues->nr_queues; i++) {
+   list_splice_tail(>queue_array[i].head,
+_array[i].head);
+   queue_array[i].priv = queues->queue_array[i].priv;
+   }
+
+   queues->nr_queues = nr_queues;
+   queues->queue_array = queue_array;
+
+   return 0;
+}
+
+static void *auxtrace_copy_data(u64 size, struct perf_session *session)
+{
+   int fd = perf_data_file__fd(session->file);
+   void *p;
+   ssize_t ret;
+
+   if (size > SSIZE_MAX)
+   return NULL;
+
+   p = malloc(size);
+   if (!p)
+   return NULL;
+
+   ret = readn(fd, p, size);
+   if (ret != (ssize_t)size) {
+   free(p);
+   return NULL;
+   }
+
+   return p;
+}
+
+static int auxtrace_queues__add_buffer(struct auxtrace_queues *queues,
+  unsigned int idx,
+  struct auxtrace_buffer *buffer)
+{
+   struct auxtrace_queue *queue;
+   int err;
+
+   if (idx >= queues->nr_queues) {
+   err = auxtrace_queues__grow(queues, idx + 1);
+   if (err)
+   return err;
+   }
+
+   queue = >queue_array[idx];
+
+   if (!queue->set) {
+   queue->set = true;
+   queue->tid = buffer->tid;
+   queue->cpu = buffer->cpu;
+   } else if (buffer->cpu != queue->cpu || buffer->tid != queue->tid) {
+   pr_err("auxtrace queue conflict: cpu %d, tid %d vs cpu %d, tid 
%d\n",
+  queue->cpu, queue->tid, buffer->cpu, buffer->tid);
+   return -EINVAL;
+   }
+
+   buffer->buffer_nr = queues->next_buffer_nr++;
+
+   list_add_tail(>list, >head);
+
+   queues->new_data = true;
+   queues->populated = true;
+
+   return 0;
+}
+
+/* Limit buffers to 32MiB on 32-bit */
+#define BUFFER_LIMIT_FOR_32_BIT (32 * 1024 * 1024)
+
+static int auxtrace_queues__split_buffer(struct auxtrace_queues *queues,
+unsigned int idx,
+struct auxtrace_buffer *buffer)
+{
+   u64 sz = buffer->size;
+   bool consecutive = false;
+   struct auxtrace_buffer *b;
+   int err;
+
+   while (sz > BUFFER_LIMIT_FOR_32_BIT) {
+ 

[PATCH V7 16/25] perf script: Add Instruction Tracing support

2015-03-31 Thread Adrian Hunter
Add support for decoding an AUX area assuming
it contains instruction tracing data.

Signed-off-by: Adrian Hunter 
---
 tools/perf/Documentation/perf-script.txt | 28 
 tools/perf/builtin-script.c  | 11 +++
 2 files changed, 39 insertions(+)

diff --git a/tools/perf/Documentation/perf-script.txt 
b/tools/perf/Documentation/perf-script.txt
index 7944575..0befc9c 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -221,6 +221,34 @@ OPTIONS
 --header-only
Show only perf.data header.
 
+-Z::
+--itrace::
+   Options for decoding instruction tracing data. The options are:
+
+   i   synthesize instructions events
+   b   synthesize branches events
+   c   synthesize branches events (calls only)
+   r   synthesize branches events (returns only)
+   e   synthesize error events
+   d   create a debug log
+   g   synthesize a call chain for instructions events
+
+   The default is all events i.e. the same as -Zibe
+
+   In addition, the period (default 10) for instructions events
+   can be specified in units of:
+
+   i   instructions
+   t   ticks
+   ms  milliseconds
+   us  microseconds
+   ns  nanoseconds (default)
+
+   Also the call chain size (default 16, max. 1024) for instructions
+   events can be specified.
+
+   To disable decoding entirely, use --no-itrace.
+
 SEE ALSO
 
 linkperf:perf-record[1], linkperf:perf-script-perl[1],
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 662366c..c571223 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -16,6 +16,7 @@
 #include "util/evsel.h"
 #include "util/sort.h"
 #include "util/data.h"
+#include "util/auxtrace.h"
 #include 
 
 static char const  *script_name;
@@ -1505,6 +1506,7 @@ int cmd_script(int argc, const char **argv, const char 
*prefix __maybe_unused)
char *rec_script_path = NULL;
char *rep_script_path = NULL;
struct perf_session *session;
+   struct itrace_synth_opts itrace_synth_opts = {0};
char *script_path = NULL;
const char **__argv;
int i, j, err = 0;
@@ -1519,6 +1521,10 @@ int cmd_script(int argc, const char **argv, const char 
*prefix __maybe_unused)
.attr= process_attr,
.tracing_data= perf_event__process_tracing_data,
.build_id= perf_event__process_build_id,
+   .id_index= perf_event__process_id_index,
+   .auxtrace_info   = perf_event__process_auxtrace_info,
+   .auxtrace= perf_event__process_auxtrace,
+   .auxtrace_error  = perf_event__process_auxtrace_error,
.ordered_events  = true,
.ordering_requires_timestamps = true,
},
@@ -1574,6 +1580,9 @@ int cmd_script(int argc, const char **argv, const char 
*prefix __maybe_unused)
"Show the fork/comm/exit events"),
OPT_BOOLEAN('\0', "show-mmap-events", _mmap_events,
"Show the mmap events"),
+   OPT_CALLBACK_OPTARG('Z', "itrace", _synth_opts, NULL, "opts",
+   "Instruction Tracing options",
+   itrace_parse_synth_opts),
OPT_END()
};
const char * const script_subcommands[] = { "record", "report", NULL };
@@ -1772,6 +1781,8 @@ int cmd_script(int argc, const char **argv, const char 
*prefix __maybe_unused)
 
script.session = session;
 
+   session->itrace_synth_opts = _synth_opts;
+
if (cpu_list) {
err = perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap);
if (err < 0)
-- 
1.9.1

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


[PATCH V7 07/25] perf tools: Add a user event for AUX area tracing errors

2015-03-31 Thread Adrian Hunter
Errors encountered when decoding an AUX area
trace need to be reported to the user. However
the "user" might be a script or another tool,
so provide a new user event to capture those
errors.

Signed-off-by: Adrian Hunter 
---
 tools/perf/util/event.c   |  1 +
 tools/perf/util/event.h   | 16 
 tools/perf/util/session.c | 25 +
 tools/perf/util/tool.h|  3 ++-
 4 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index cbf3775..6bde493 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -31,6 +31,7 @@ static const char *perf_event__names[] = {
[PERF_RECORD_ID_INDEX]  = "ID_INDEX",
[PERF_RECORD_AUXTRACE_INFO] = "AUXTRACE_INFO",
[PERF_RECORD_AUXTRACE]  = "AUXTRACE",
+   [PERF_RECORD_AUXTRACE_ERROR]= "AUXTRACE_ERROR",
 };
 
 const char *perf_event__name(unsigned int id)
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 5dc9329..02327bb 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -217,6 +217,7 @@ enum perf_user_event_type { /* above any possible kernel 
type */
PERF_RECORD_ID_INDEX= 69,
PERF_RECORD_AUXTRACE_INFO   = 70,
PERF_RECORD_AUXTRACE= 71,
+   PERF_RECORD_AUXTRACE_ERROR  = 72,
PERF_RECORD_HEADER_MAX
 };
 
@@ -301,6 +302,20 @@ struct auxtrace_event {
u32 reserved__; /* For alignment */
 };
 
+#define MAX_AUXTRACE_ERROR_MSG 64
+
+struct auxtrace_error_event {
+   struct perf_event_header header;
+   u32 type;
+   u32 code;
+   u32 cpu;
+   u32 pid;
+   u32 tid;
+   u32 reserved__; /* For alignment */
+   u64 ip;
+   char msg[MAX_AUXTRACE_ERROR_MSG];
+};
+
 union perf_event {
struct perf_event_headerheader;
struct mmap_event   mmap;
@@ -318,6 +333,7 @@ union perf_event {
struct id_index_event   id_index;
struct auxtrace_info_event  auxtrace_info;
struct auxtrace_event   auxtrace;
+   struct auxtrace_error_event auxtrace_error;
 };
 
 void perf_event__print_totals(void);
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index a8c67cb..b4cac8b 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -288,6 +288,15 @@ static s64 process_event_auxtrace_stub(struct perf_tool 
*tool __maybe_unused,
return event->auxtrace.size;
 }
 
+static
+int process_event_auxtrace_error_stub(struct perf_tool *tool __maybe_unused,
+ union perf_event *event __maybe_unused,
+ struct perf_session *session 
__maybe_unused)
+{
+   dump_printf(": unhandled!\n");
+   return 0;
+}
+
 void perf_tool__fill_defaults(struct perf_tool *tool)
 {
if (tool->sample == NULL)
@@ -328,6 +337,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
tool->auxtrace_info = process_event_auxtrace_info_stub;
if (tool->auxtrace == NULL)
tool->auxtrace = process_event_auxtrace_stub;
+   if (tool->auxtrace_error == NULL)
+   tool->auxtrace_error = process_event_auxtrace_error_stub;
 }
 
 static void swap_sample_id_all(union perf_event *event, void *data)
@@ -531,6 +542,17 @@ static void perf_event__auxtrace_swap(union perf_event 
*event,
event->auxtrace.cpu   = bswap_32(event->auxtrace.cpu);
 }
 
+static void perf_event__auxtrace_error_swap(union perf_event *event,
+   bool sample_id_all __maybe_unused)
+{
+   event->auxtrace_error.type = bswap_32(event->auxtrace_error.type);
+   event->auxtrace_error.code = bswap_32(event->auxtrace_error.code);
+   event->auxtrace_error.cpu  = bswap_32(event->auxtrace_error.cpu);
+   event->auxtrace_error.pid  = bswap_32(event->auxtrace_error.pid);
+   event->auxtrace_error.tid  = bswap_32(event->auxtrace_error.tid);
+   event->auxtrace_error.ip   = bswap_64(event->auxtrace_error.ip);
+}
+
 typedef void (*perf_event__swap_op)(union perf_event *event,
bool sample_id_all);
 
@@ -552,6 +574,7 @@ static perf_event__swap_op perf_event__swap_ops[] = {
[PERF_RECORD_ID_INDEX]= perf_event__all64_swap,
[PERF_RECORD_AUXTRACE_INFO]   = perf_event__auxtrace_info_swap,
[PERF_RECORD_AUXTRACE]= perf_event__auxtrace_swap,
+   [PERF_RECORD_AUXTRACE_ERROR]  = perf_event__auxtrace_error_swap,
[PERF_RECORD_HEADER_MAX]  = NULL,
 };
 
@@ -1041,6 +1064,8 @@ static s64 perf_session__process_user_event(struct 
perf_session *session,
/* setup for reading amidst mmap */
lseek(fd, file_offset + event->header.size, SEEK_SET);
return tool->auxtrace(tool, event, 

[PATCH V7 13/25] perf auxtrace: Add processing for AUX area tracing events

2015-03-31 Thread Adrian Hunter
Provide hooks so that an AUX area
decoder can process AUX area tracing
events.

Signed-off-by: Adrian Hunter 
---
 tools/perf/util/auxtrace.c | 52 +-
 tools/perf/util/auxtrace.h | 13 
 2 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index 215f38e..4c7c3dd 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -610,6 +610,53 @@ out_free:
return err;
 }
 
+static bool auxtrace__dont_decode(struct perf_session *session)
+{
+   return !session->itrace_synth_opts ||
+  session->itrace_synth_opts->dont_decode;
+}
+
+int perf_event__process_auxtrace_info(struct perf_tool *tool __maybe_unused,
+ union perf_event *event,
+ struct perf_session *session 
__maybe_unused)
+{
+   enum auxtrace_type type = event->auxtrace_info.type;
+
+   if (dump_trace)
+   fprintf(stdout, " type: %u\n", type);
+
+   switch (type) {
+   case PERF_AUXTRACE_UNKNOWN:
+   default:
+   return -EINVAL;
+   }
+}
+
+s64 perf_event__process_auxtrace(struct perf_tool *tool,
+union perf_event *event,
+struct perf_session *session)
+{
+   s64 err;
+
+   if (dump_trace)
+   fprintf(stdout, " size: %#"PRIx64"  offset: %#"PRIx64"  ref: 
%#"PRIx64"  idx: %u  tid: %d  cpu: %d\n",
+   event->auxtrace.size, event->auxtrace.offset,
+   event->auxtrace.reference, event->auxtrace.idx,
+   event->auxtrace.tid, event->auxtrace.cpu);
+
+   if (auxtrace__dont_decode(session))
+   return event->auxtrace.size;
+
+   if (!session->auxtrace || event->header.type != PERF_RECORD_AUXTRACE)
+   return -EINVAL;
+
+   err = session->auxtrace->process_auxtrace_event(session, event, tool);
+   if (err < 0)
+   return err;
+
+   return event->auxtrace.size;
+}
+
 #define PERF_ITRACE_DEFAULT_PERIOD_TYPE
PERF_ITRACE_PERIOD_NANOSECS
 #define PERF_ITRACE_DEFAULT_PERIOD 10
 #define PERF_ITRACE_DEFAULT_CALLCHAIN_SZ   16
@@ -791,8 +838,11 @@ void events_stats__auxtrace_error_warn(const struct 
events_stats *stats)
 
 int perf_event__process_auxtrace_error(struct perf_tool *tool __maybe_unused,
   union perf_event *event,
-  struct perf_session *session 
__maybe_unused)
+  struct perf_session *session)
 {
+   if (auxtrace__dont_decode(session))
+   return 0;
+
perf_event__fprintf_auxtrace_error(event, stdout);
return 0;
 }
diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
index cdf5f51..d83cb9b 100644
--- a/tools/perf/util/auxtrace.h
+++ b/tools/perf/util/auxtrace.h
@@ -36,6 +36,10 @@ struct record_opts;
 struct auxtrace_info_event;
 struct events_stats;
 
+enum auxtrace_type {
+   PERF_AUXTRACE_UNKNOWN,
+};
+
 enum itrace_period_type {
PERF_ITRACE_PERIOD_INSTRUCTIONS,
PERF_ITRACE_PERIOD_TICKS,
@@ -87,6 +91,9 @@ struct auxtrace {
 union perf_event *event,
 struct perf_sample *sample,
 struct perf_tool *tool);
+   int (*process_auxtrace_event)(struct perf_session *session,
+ union perf_event *event,
+ struct perf_tool *tool);
int (*flush_events)(struct perf_session *session,
struct perf_tool *tool);
void (*free_events)(struct perf_session *session);
@@ -328,6 +335,12 @@ int perf_event__synthesize_auxtrace_info(struct 
auxtrace_record *itr,
 struct perf_tool *tool,
 struct perf_session *session,
 perf_event__handler_t process);
+int perf_event__process_auxtrace_info(struct perf_tool *tool,
+ union perf_event *event,
+ struct perf_session *session);
+s64 perf_event__process_auxtrace(struct perf_tool *tool,
+union perf_event *event,
+struct perf_session *session);
 int perf_event__process_auxtrace_error(struct perf_tool *tool,
   union perf_event *event,
   struct perf_session *session);
-- 
1.9.1

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


[PATCH V7 15/25] perf tools: Add member to struct dso for an instruction cache

2015-03-31 Thread Adrian Hunter
Add a member to struct dso that can be used by Instruction
Trace implementations to hold a cache for decoded instructions.

Signed-off-by: Adrian Hunter 
---
 tools/perf/util/dso.c | 2 ++
 tools/perf/util/dso.h | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index fc0ddd5..13d9ae0 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -4,6 +4,7 @@
 #include "symbol.h"
 #include "dso.h"
 #include "machine.h"
+#include "auxtrace.h"
 #include "util.h"
 #include "debug.h"
 
@@ -961,6 +962,7 @@ void dso__delete(struct dso *dso)
}
 
dso__data_close(dso);
+   auxtrace_cache__free(dso->auxtrace_cache);
dso_cache__free(>data.cache);
dso__free_a2l(dso);
zfree(>symsrc_filename);
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index e0901b4..3d79c74 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -126,6 +126,8 @@ struct dsos {
struct rb_root   root;  /* rbtree root sorted by long name */
 };
 
+struct auxtrace_cache;
+
 struct dso {
struct list_head node;
struct rb_node   rb_node;   /* rbtree node sorted by long name */
@@ -156,6 +158,7 @@ struct dso {
u16  long_name_len;
u16  short_name_len;
void*dwfl;  /* DWARF debug info */
+   struct auxtrace_cache *auxtrace_cache;
 
/* dso data file */
struct {
-- 
1.9.1

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


[PATCH V7 06/25] perf record: Extend -m option for AUX area tracing mmap pages

2015-03-31 Thread Adrian Hunter
Extend the -m option so that the number
of mmap pages for AUX area tracing
can be specified by adding a comma followed
by the number of pages.

Signed-off-by: Adrian Hunter 
---
 tools/perf/Documentation/perf-record.txt |  2 ++
 tools/perf/builtin-record.c  | 49 ++--
 tools/perf/util/evlist.c | 10 +--
 tools/perf/util/evlist.h |  1 +
 4 files changed, 56 insertions(+), 6 deletions(-)

diff --git a/tools/perf/Documentation/perf-record.txt 
b/tools/perf/Documentation/perf-record.txt
index 355c4f5..e78dd80 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -108,6 +108,8 @@ OPTIONS
Number of mmap data pages (must be a power of two) or size
specification with appended unit character - B/K/M/G. The
size is rounded up to have nearest pages power of two value.
+   Also, by adding a comma, the number of mmap pages for AUX
+   area tracing can be specified.
 
 --group::
Put all events in a single event group.  This precedes the --event
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 0de9432..56502e5 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -771,6 +771,49 @@ static int perf_record_config(const char *var, const char 
*value, void *cb)
return perf_default_config(var, value, cb);
 }
 
+static int record__parse_mmap_pages(const struct option *opt,
+   const char *str,
+   int unset __maybe_unused)
+{
+   struct record_opts *opts = opt->value;
+   char *s, *p;
+   unsigned int mmap_pages;
+   int ret;
+
+   if (!str)
+   return -EINVAL;
+
+   s = strdup(str);
+   if (!s)
+   return -ENOMEM;
+
+   p = strchr(s, ',');
+   if (p)
+   *p = '\0';
+
+   if (*s) {
+   ret = __perf_evlist__parse_mmap_pages(_pages, s);
+   if (ret)
+   goto out_free;
+   opts->mmap_pages = mmap_pages;
+   }
+
+   if (!p) {
+   ret = 0;
+   goto out_free;
+   }
+
+   ret = __perf_evlist__parse_mmap_pages(_pages, p + 1);
+   if (ret)
+   goto out_free;
+
+   opts->auxtrace_mmap_pages = mmap_pages;
+
+out_free:
+   free(s);
+   return ret;
+}
+
 static const char * const __record_usage[] = {
"perf record [] []",
"perf record [] --  []",
@@ -851,9 +894,9 @@ struct option __record_options[] = {
_inherit_set,
"child tasks do not inherit counters"),
OPT_UINTEGER('F', "freq", _freq, "profile at this 
frequency"),
-   OPT_CALLBACK('m', "mmap-pages", _pages, "pages",
-"number of mmap data pages",
-perf_evlist__parse_mmap_pages),
+   OPT_CALLBACK('m', "mmap-pages", , "pages[,pages]",
+"number of mmap data pages and AUX area tracing mmap 
pages",
+record__parse_mmap_pages),
OPT_BOOLEAN(0, "group", ,
"put the counters into a counter group"),
OPT_CALLBACK_NOOPT('g', NULL, ,
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 3481265..9a2243f 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1000,10 +1000,8 @@ static long parse_pages_arg(const char *str, unsigned 
long min,
return pages;
 }
 
-int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str,
- int unset __maybe_unused)
+int __perf_evlist__parse_mmap_pages(unsigned int *mmap_pages, const char *str)
 {
-   unsigned int *mmap_pages = opt->value;
unsigned long max = UINT_MAX;
long pages;
 
@@ -1020,6 +1018,12 @@ int perf_evlist__parse_mmap_pages(const struct option 
*opt, const char *str,
return 0;
 }
 
+int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str,
+ int unset __maybe_unused)
+{
+   return __perf_evlist__parse_mmap_pages(opt->value, str);
+}
+
 /**
  * perf_evlist__mmap_ex - Create mmaps to receive events.
  * @evlist: list of events
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index beed571..221ac3d 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -124,6 +124,7 @@ int perf_evlist__start_workload(struct perf_evlist *evlist);
 
 struct option;
 
+int __perf_evlist__parse_mmap_pages(unsigned int *mmap_pages, const char *str);
 int perf_evlist__parse_mmap_pages(const struct option *opt,
  const char *str,
  int unset);
-- 
1.9.1

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

[PATCH V7 05/25] perf record: Add basic AUX area tracing support

2015-03-31 Thread Adrian Hunter
Amend the perf record tool to read the
AUX area tracing mmap and synthesize
AUX area tracing events.

Signed-off-by: Adrian Hunter 
---
 tools/perf/builtin-record.c | 81 ++---
 1 file changed, 77 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 18aad239..0de9432 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -27,6 +27,7 @@
 #include "util/cpumap.h"
 #include "util/thread_map.h"
 #include "util/data.h"
+#include "util/auxtrace.h"
 
 #include 
 #include 
@@ -38,6 +39,7 @@ struct record {
struct record_opts  opts;
u64 bytes_written;
struct perf_data_file   file;
+   struct auxtrace_record  *itr;
struct perf_evlist  *evlist;
struct perf_session *session;
const char  *progname;
@@ -110,6 +112,44 @@ out:
return rc;
 }
 
+static int record__process_auxtrace(struct perf_tool *tool,
+   union perf_event *event, void *data1,
+   size_t len1, void *data2, size_t len2)
+{
+   struct record *rec = container_of(tool, struct record, tool);
+   size_t padding;
+   u8 pad[8] = {0};
+
+   /* event.auxtrace.size includes padding, see __auxtrace_mmap__read() */
+   padding = (len1 + len2) & 7;
+   if (padding)
+   padding = 8 - padding;
+
+   record__write(rec, event, event->header.size);
+   record__write(rec, data1, len1);
+   if (len2)
+   record__write(rec, data2, len2);
+   record__write(rec, , padding);
+
+   return 0;
+}
+
+static int record__auxtrace_mmap_read(struct record *rec,
+ struct auxtrace_mmap *mm)
+{
+   int ret;
+
+   ret = auxtrace_mmap__read(mm, rec->itr, >tool,
+ record__process_auxtrace);
+   if (ret < 0)
+   return ret;
+
+   if (ret)
+   rec->samples++;
+
+   return 0;
+}
+
 static volatile int done = 0;
 static volatile int signr = -1;
 static volatile int child_finished = 0;
@@ -169,13 +209,15 @@ try_again:
goto out;
}
 
-   if (perf_evlist__mmap(evlist, opts->mmap_pages, false) < 0) {
+   if (perf_evlist__mmap_ex(evlist, opts->mmap_pages, false,
+opts->auxtrace_mmap_pages, false) < 0) {
if (errno == EPERM) {
pr_err("Permission error mapping pages.\n"
   "Consider increasing "
   "/proc/sys/kernel/perf_event_mlock_kb,\n"
   "or try again with a smaller value of 
-m/--mmap_pages.\n"
-  "(current value: %u)\n", opts->mmap_pages);
+  "(current value: %u,%u)\n",
+  opts->mmap_pages, opts->auxtrace_mmap_pages);
rc = -errno;
} else {
pr_err("failed to mmap with %d (%s)\n", errno,
@@ -270,12 +312,20 @@ static int record__mmap_read_all(struct record *rec)
int rc = 0;
 
for (i = 0; i < rec->evlist->nr_mmaps; i++) {
+   struct auxtrace_mmap *mm = >evlist->mmap[i].auxtrace_mmap;
+
if (rec->evlist->mmap[i].base) {
if (record__mmap_read(rec, i) != 0) {
rc = -1;
goto out;
}
}
+
+   if (mm->base &&
+   record__auxtrace_mmap_read(rec, mm) != 0) {
+   rc = -1;
+   goto out;
+   }
}
 
/*
@@ -305,6 +355,9 @@ static void record__init_features(struct record *rec)
 
if (!rec->opts.branch_stack)
perf_header__clear_feat(>header, HEADER_BRANCH_STACK);
+
+   if (!rec->opts.full_auxtrace)
+   perf_header__clear_feat(>header, HEADER_AUXTRACE);
 }
 
 static volatile int workload_exec_errno;
@@ -421,6 +474,13 @@ static int __cmd_record(struct record *rec, int argc, 
const char **argv)
}
}
 
+   if (rec->opts.full_auxtrace) {
+   err = perf_event__synthesize_auxtrace_info(rec->itr, tool,
+   session, process_synthesized_event);
+   if (err)
+   goto out_delete_session;
+   }
+
err = perf_event__synthesize_kernel_mmap(tool, 
process_synthesized_event,
 machine);
if (err < 0)
@@ -553,7 +613,7 @@ out_child:
if (!err && !quiet) {
char samples[128];
 
-   if (rec->samples)
+   if (rec->samples && !rec->opts.full_auxtrace)
scnprintf(samples, sizeof(samples),
  

[PATCH V7 04/25] perf tools: Add support for AUX area recording

2015-03-31 Thread Adrian Hunter
Add support for reading from the AUX area
tracing mmap and synthesizing AUX area
tracing events.

This patch introduces an abstraction for recording
AUX area data.  Recording is initialized
by auxtrace_record__init() which is a weak function
to be implemented by the architecture to provide
recording callbacks.  Recording is mainly handled
by auxtrace_mmap__read() and
perf_event__synthesize_auxtrace() but there are
callbacks for miscellaneous needs including
validating and processing user options, populating
private data in auxtrace_info_event, and freeing
the structure when finished.

Signed-off-by: Adrian Hunter 
---
 tools/perf/perf.h  |   2 +
 tools/perf/util/auxtrace.c | 176 +
 tools/perf/util/auxtrace.h |  56 ++-
 tools/perf/util/record.c   |  11 ++-
 4 files changed, 243 insertions(+), 2 deletions(-)

diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index c38a085..95a3bd4 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -54,8 +54,10 @@ struct record_opts {
bool period;
bool sample_intr_regs;
bool running_time;
+   bool full_auxtrace;
unsigned int freq;
unsigned int mmap_pages;
+   unsigned int auxtrace_mmap_pages;
unsigned int user_freq;
u64  branch_stack;
u64  default_interval;
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index 75419a5..b3ed200 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -23,6 +23,10 @@
 #include 
 #include 
 
+#include 
+#include 
+#include 
+
 #include "../perf.h"
 #include "util.h"
 #include "evlist.h"
@@ -31,6 +35,9 @@
 #include "asm/bug.h"
 #include "auxtrace.h"
 
+#include "event.h"
+#include "debug.h"
+
 int auxtrace_mmap__mmap(struct auxtrace_mmap *mm,
struct auxtrace_mmap_params *mp,
void *userpg, int fd)
@@ -106,3 +113,172 @@ void auxtrace_mmap_params__set_idx(struct 
auxtrace_mmap_params *mp,
mp->tid = evlist->threads->map[idx];
}
 }
+
+size_t auxtrace_record__info_priv_size(struct auxtrace_record *itr)
+{
+   if (itr)
+   return itr->info_priv_size(itr);
+   return 0;
+}
+
+static int auxtrace_not_supported(void)
+{
+   pr_err("AUX area tracing is not supported on this architecture\n");
+   return -EINVAL;
+}
+
+int auxtrace_record__info_fill(struct auxtrace_record *itr,
+  struct perf_session *session,
+  struct auxtrace_info_event *auxtrace_info,
+  size_t priv_size)
+{
+   if (itr)
+   return itr->info_fill(itr, session, auxtrace_info, priv_size);
+   return auxtrace_not_supported();
+}
+
+void auxtrace_record__free(struct auxtrace_record *itr)
+{
+   if (itr)
+   itr->free(itr);
+}
+
+int auxtrace_record__options(struct auxtrace_record *itr,
+struct perf_evlist *evlist,
+struct record_opts *opts)
+{
+   if (itr)
+   return itr->recording_options(itr, evlist, opts);
+   return 0;
+}
+
+u64 auxtrace_record__reference(struct auxtrace_record *itr)
+{
+   if (itr)
+   return itr->reference(itr);
+   return 0;
+}
+
+struct auxtrace_record *__weak
+auxtrace_record__init(struct perf_evlist *evlist __maybe_unused, int *err)
+{
+   *err = 0;
+   return NULL;
+}
+
+int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr,
+struct perf_tool *tool,
+struct perf_session *session,
+perf_event__handler_t process)
+{
+   union perf_event *ev;
+   size_t priv_size;
+   int err;
+
+   pr_debug2("Synthesizing auxtrace information\n");
+   priv_size = auxtrace_record__info_priv_size(itr);
+   ev = zalloc(sizeof(struct auxtrace_info_event) + priv_size);
+   if (!ev)
+   return -ENOMEM;
+
+   ev->auxtrace_info.header.type = PERF_RECORD_AUXTRACE_INFO;
+   ev->auxtrace_info.header.size = sizeof(struct auxtrace_info_event) +
+   priv_size;
+   err = auxtrace_record__info_fill(itr, session, >auxtrace_info,
+priv_size);
+   if (err)
+   goto out_free;
+
+   err = process(tool, ev, NULL, NULL);
+out_free:
+   free(ev);
+   return err;
+}
+
+int auxtrace_mmap__read(struct auxtrace_mmap *mm, struct auxtrace_record *itr,
+   struct perf_tool *tool, process_auxtrace_t fn)
+{
+   u64 head = auxtrace_mmap__read_head(mm);
+   u64 old = mm->prev, offset, ref;
+   unsigned char *data = mm->base;
+   size_t size, head_off, old_off, len1, len2, padding;
+   union perf_event ev;
+   void *data1, *data2;
+
+   if 

[PATCH V7 09/25] perf session: Add instruction tracing options

2015-03-31 Thread Adrian Hunter
It is assumed that AUX area decoding will
synthesize events for consumption by other tools.
At this time, the main use of AUX area tracing will be
to capture instruction trace (aka processor trace) data.
The nature of instruction tracing suggests the
initial inclusion of options for "instructions"
and "branches" events, but more could be added
as needed.

Signed-off-by: Adrian Hunter 
---
 tools/perf/util/auxtrace.c | 131 +
 tools/perf/util/auxtrace.h |  43 +++
 tools/perf/util/session.h  |   2 +
 3 files changed, 176 insertions(+)

diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index b3ed200..759f1bc6 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -37,6 +37,7 @@
 
 #include "event.h"
 #include "debug.h"
+#include "parse-options.h"
 
 int auxtrace_mmap__mmap(struct auxtrace_mmap *mm,
struct auxtrace_mmap_params *mp,
@@ -195,6 +196,136 @@ out_free:
return err;
 }
 
+#define PERF_ITRACE_DEFAULT_PERIOD_TYPE
PERF_ITRACE_PERIOD_NANOSECS
+#define PERF_ITRACE_DEFAULT_PERIOD 10
+#define PERF_ITRACE_DEFAULT_CALLCHAIN_SZ   16
+#define PERF_ITRACE_MAX_CALLCHAIN_SZ   1024
+
+void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts)
+{
+   synth_opts->instructions = true;
+   synth_opts->branches = true;
+   synth_opts->errors = true;
+   synth_opts->period_type = PERF_ITRACE_DEFAULT_PERIOD_TYPE;
+   synth_opts->period = PERF_ITRACE_DEFAULT_PERIOD;
+   synth_opts->callchain_sz = PERF_ITRACE_DEFAULT_CALLCHAIN_SZ;
+}
+
+int itrace_parse_synth_opts(const struct option *opt, const char *str,
+   int unset)
+{
+   struct itrace_synth_opts *synth_opts = opt->value;
+   const char *p;
+   char *endptr;
+
+   synth_opts->set = true;
+
+   if (unset) {
+   synth_opts->dont_decode = true;
+   return 0;
+   }
+
+   if (!str) {
+   itrace_synth_opts__set_default(synth_opts);
+   return 0;
+   }
+
+   for (p = str; *p;) {
+   switch (*p++) {
+   case 'i':
+   synth_opts->instructions = true;
+   while (*p == ' ' || *p == ',')
+   p += 1;
+   if (isdigit(*p)) {
+   synth_opts->period = strtoull(p, , 10);
+   p = endptr;
+   while (*p == ' ' || *p == ',')
+   p += 1;
+   switch (*p++) {
+   case 'i':
+   synth_opts->period_type =
+   PERF_ITRACE_PERIOD_INSTRUCTIONS;
+   break;
+   case 't':
+   synth_opts->period_type =
+   PERF_ITRACE_PERIOD_TICKS;
+   break;
+   case 'm':
+   synth_opts->period *= 1000;
+   /* Fall through */
+   case 'u':
+   synth_opts->period *= 1000;
+   /* Fall through */
+   case 'n':
+   if (*p++ != 's')
+   goto out_err;
+   synth_opts->period_type =
+   PERF_ITRACE_PERIOD_NANOSECS;
+   break;
+   case '\0':
+   goto out;
+   default:
+   goto out_err;
+   }
+   }
+   break;
+   case 'b':
+   synth_opts->branches = true;
+   break;
+   case 'e':
+   synth_opts->errors = true;
+   break;
+   case 'd':
+   synth_opts->log = true;
+   break;
+   case 'c':
+   synth_opts->branches = true;
+   synth_opts->calls = true;
+   break;
+   case 'r':
+   synth_opts->branches = true;
+   synth_opts->returns = true;
+   break;
+   case 'g':
+   synth_opts->instructions = true;
+   synth_opts->callchain = true;
+   synth_opts->callchain_sz =
+   

[PATCH V7 19/25] perf inject: Re-pipe AUX area tracing events

2015-03-31 Thread Adrian Hunter
New AUX area tracing events must be re-piped by default.

Signed-off-by: Adrian Hunter 
---
 tools/perf/builtin-inject.c | 63 +
 1 file changed, 58 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index ea46df25..1f35e3d 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -38,14 +38,11 @@ struct event_entry {
union perf_event event[0];
 };
 
-static int perf_event__repipe_synth(struct perf_tool *tool,
-   union perf_event *event)
+static int output_bytes(struct perf_inject *inject, void *buf, size_t sz)
 {
-   struct perf_inject *inject = container_of(tool, struct perf_inject, 
tool);
ssize_t size;
 
-   size = perf_data_file__write(>output, event,
-event->header.size);
+   size = perf_data_file__write(>output, buf, sz);
if (size < 0)
return -errno;
 
@@ -53,6 +50,34 @@ static int perf_event__repipe_synth(struct perf_tool *tool,
return 0;
 }
 
+static int copy_bytes(struct perf_inject *inject, int fd, off_t size)
+{
+   char buf[4096];
+   ssize_t ssz;
+   int ret;
+
+   while (size > 0) {
+   ssz = read(fd, buf, MIN(size, sizeof(buf)));
+   if (ssz < 0)
+   return -errno;
+   ret = output_bytes(inject, buf, ssz);
+   if (ret)
+   return ret;
+   size -= ssz;
+   }
+
+   return 0;
+}
+
+static int perf_event__repipe_synth(struct perf_tool *tool,
+   union perf_event *event)
+{
+   struct perf_inject *inject = container_of(tool, struct perf_inject,
+ tool);
+
+   return output_bytes(inject, event, event->header.size);
+}
+
 static int perf_event__repipe_oe_synth(struct perf_tool *tool,
   union perf_event *event,
   struct ordered_events *oe __maybe_unused)
@@ -86,6 +111,31 @@ static int perf_event__repipe_attr(struct perf_tool *tool,
return perf_event__repipe_synth(tool, event);
 }
 
+static s64 perf_event__repipe_auxtrace(struct perf_tool *tool,
+  union perf_event *event,
+  struct perf_session *session
+  __maybe_unused)
+{
+   struct perf_inject *inject = container_of(tool, struct perf_inject,
+ tool);
+   int ret;
+
+   if (perf_data_file__is_pipe(session->file) || !session->one_mmap) {
+   ret = output_bytes(inject, event, event->header.size);
+   if (ret < 0)
+   return ret;
+   ret = copy_bytes(inject, perf_data_file__fd(session->file),
+event->auxtrace.size);
+   } else {
+   ret = output_bytes(inject, event,
+  event->header.size + event->auxtrace.size);
+   }
+   if (ret < 0)
+   return ret;
+
+   return event->auxtrace.size;
+}
+
 static int perf_event__repipe(struct perf_tool *tool,
  union perf_event *event,
  struct perf_sample *sample __maybe_unused,
@@ -413,6 +463,9 @@ int cmd_inject(int argc, const char **argv, const char 
*prefix __maybe_unused)
.unthrottle = perf_event__repipe,
.attr   = perf_event__repipe_attr,
.tracing_data   = perf_event__repipe_op2_synth,
+   .auxtrace_info  = perf_event__repipe_op2_synth,
+   .auxtrace   = perf_event__repipe_auxtrace,
+   .auxtrace_error = perf_event__repipe_op2_synth,
.finished_round = perf_event__repipe_oe_synth,
.build_id   = perf_event__repipe_op2_synth,
.id_index   = perf_event__repipe_op2_synth,
-- 
1.9.1

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


[PATCH V7 17/25] perf script: Always allow fields 'addr' and 'cpu' for auxtrace

2015-03-31 Thread Adrian Hunter
If a file contains AUX area tracing data then always allow
fields 'addr' and 'cpu' to be selected as options for perf
script.  This is necessary because AUX area decoding
may synthesize events with that information.

Signed-off-by: Adrian Hunter 
---
 tools/perf/builtin-script.c | 29 ++---
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index c571223..5bedfda 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -147,9 +147,10 @@ static const char *output_field2str(enum perf_output_field 
field)
 
 #define PRINT_FIELD(x)  (output[attr->type].fields & PERF_OUTPUT_##x)
 
-static int perf_evsel__check_stype(struct perf_evsel *evsel,
-  u64 sample_type, const char *sample_msg,
-  enum perf_output_field field)
+static int perf_evsel__do_check_stype(struct perf_evsel *evsel,
+ u64 sample_type, const char *sample_msg,
+ enum perf_output_field field,
+ bool allow_user_set)
 {
struct perf_event_attr *attr = >attr;
int type = attr->type;
@@ -159,6 +160,8 @@ static int perf_evsel__check_stype(struct perf_evsel *evsel,
return 0;
 
if (output[type].user_set) {
+   if (allow_user_set)
+   return 0;
evname = perf_evsel__name(evsel);
pr_err("Samples for '%s' event do not have %s attribute set. "
   "Cannot print '%s' field.\n",
@@ -176,10 +179,22 @@ static int perf_evsel__check_stype(struct perf_evsel 
*evsel,
return 0;
 }
 
+static int perf_evsel__check_stype(struct perf_evsel *evsel,
+  u64 sample_type, const char *sample_msg,
+  enum perf_output_field field)
+{
+   return perf_evsel__do_check_stype(evsel, sample_type, sample_msg, field,
+ false);
+}
+
 static int perf_evsel__check_attr(struct perf_evsel *evsel,
  struct perf_session *session)
 {
struct perf_event_attr *attr = >attr;
+   bool allow_user_set;
+
+   allow_user_set = perf_header__has_feat(>header,
+  HEADER_AUXTRACE);
 
if (PRINT_FIELD(TRACE) &&
!perf_session__has_traces(session, "record -R"))
@@ -192,8 +207,8 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
}
 
if (PRINT_FIELD(ADDR) &&
-   perf_evsel__check_stype(evsel, PERF_SAMPLE_ADDR, "ADDR",
-   PERF_OUTPUT_ADDR))
+   perf_evsel__do_check_stype(evsel, PERF_SAMPLE_ADDR, "ADDR",
+  PERF_OUTPUT_ADDR, allow_user_set))
return -EINVAL;
 
if (PRINT_FIELD(SYM) && !PRINT_FIELD(IP) && !PRINT_FIELD(ADDR)) {
@@ -230,8 +245,8 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
return -EINVAL;
 
if (PRINT_FIELD(CPU) &&
-   perf_evsel__check_stype(evsel, PERF_SAMPLE_CPU, "CPU",
-   PERF_OUTPUT_CPU))
+   perf_evsel__do_check_stype(evsel, PERF_SAMPLE_CPU, "CPU",
+  PERF_OUTPUT_CPU, allow_user_set))
return -EINVAL;
 
if (PRINT_FIELD(PERIOD) &&
-- 
1.9.1

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


Re: [RFT PATCHv2] drm/exynos: Enable DP clock to fix display on Exynos5250 and other

2015-03-31 Thread Andreas Färber
Am 27.03.2015 um 20:21 schrieb Javier Martinez Canillas:
> Hello Krzysztof,
> 
> On 03/27/2015 05:08 PM, Krzysztof Kozlowski wrote:
>> After adding display power domain for Exynos5250 in commit
>> 2d2c9a8d0a4f ("ARM: dts: add display power domain for exynos5250") the
>> display on Chromebook Snow and others stopped working after boot.
>>
>> The reason for this suggested Andrzej Hajda: the DP clock was disabled.
>> This clock is required by Display Port and is enabled by bootloader.
>> However when FIMD driver probing was deferred, the display power domain
>> was turned off. This effectively reset the value of DP clock enable
>> register.
>>
>> When exynos-dp is later probed, the clock is not enabled and display is
>> not properly configured:
>>
>> exynos-dp 145b.dp-controller: Timeout of video streamclk ok
>> exynos-dp 145b.dp-controller: unable to config video
>>
>> Signed-off-by: Krzysztof Kozlowski 
>> Reported-by: Javier Martinez Canillas 
>> Fixes: 2d2c9a8d0a4f ("ARM: dts: add display power domain for exynos5250")
>> Cc: 
>>
>> ---
>>
>> This should fix issue reported by Javier [1][2].
>>
> 
> I tested this patch and does indeed solves both issues I reported
> The exynos-dp probe deferral does not make the display to not be
> working and also disabling and enabling the display with:
> 
> with /sys/devices/platform/exynos-drm/graphics/fb0/blank works.
> 
> Thanks a lot for fixing this issue.
> 
> On an Exynos5250 Snow Chromebook:
> 
> Tested-by: Javier Martinez Canillas 

Seems to fix Spring Chromebook as well,

Tested-by: Andreas Färber 

Thanks a lot,

Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 V7 20/25] perf inject: Add Instruction Tracing support

2015-03-31 Thread Adrian Hunter
Add support for decoding an AUX area assuming
it contains instruction tracing data.  The
AUX area tracing events are stripped and replaced
by synthesized events.

Signed-off-by: Adrian Hunter 
---
 tools/perf/Documentation/perf-inject.txt | 27 
 tools/perf/builtin-inject.c  | 71 +++-
 2 files changed, 96 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-inject.txt 
b/tools/perf/Documentation/perf-inject.txt
index dc7442c..4465519 100644
--- a/tools/perf/Documentation/perf-inject.txt
+++ b/tools/perf/Documentation/perf-inject.txt
@@ -44,6 +44,33 @@ OPTIONS
 --kallsyms=::
kallsyms pathname
 
+-Z::
+--itrace::
+   Decode Instruction Tracing data, replacing it with synthesized events.
+   Options are:
+
+   i   synthesize instructions events
+   b   synthesize branches events
+   c   synthesize branches events (calls only)
+   r   synthesize branches events (returns only)
+   e   synthesize error events
+   d   create a debug log
+   g   synthesize a call chain for instructions events
+
+   The default is all events i.e. the same as -Zibe
+
+   In addition, the period (default 10) for instructions events
+   can be specified in units of:
+
+   i   instructions
+   t   ticks
+   ms  milliseconds
+   us  microseconds
+   ns  nanoseconds (default)
+
+   Also the call chain size (default 16, max. 1024) for instructions
+   events can be specified.
+
 SEE ALSO
 
 linkperf:perf-record[1], linkperf:perf-report[1], linkperf:perf-archive[1]
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 1f35e3d..3a36c7b 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -16,6 +16,7 @@
 #include "util/debug.h"
 #include "util/build-id.h"
 #include "util/data.h"
+#include "util/auxtrace.h"
 
 #include "util/parse-options.h"
 
@@ -30,6 +31,7 @@ struct perf_inject {
struct perf_data_file   output;
u64 bytes_written;
struct list_headsamples;
+   struct itrace_synth_opts itrace_synth_opts;
 };
 
 struct event_entry {
@@ -205,6 +207,32 @@ static int perf_event__repipe_fork(struct perf_tool *tool,
return err;
 }
 
+static int perf_event__repipe_comm(struct perf_tool *tool,
+  union perf_event *event,
+  struct perf_sample *sample,
+  struct machine *machine)
+{
+   int err;
+
+   err = perf_event__process_comm(tool, event, sample, machine);
+   perf_event__repipe(tool, event, sample, machine);
+
+   return err;
+}
+
+static int perf_event__repipe_exit(struct perf_tool *tool,
+  union perf_event *event,
+  struct perf_sample *sample,
+  struct machine *machine)
+{
+   int err;
+
+   err = perf_event__process_exit(tool, event, sample, machine);
+   perf_event__repipe(tool, event, sample, machine);
+
+   return err;
+}
+
 static int perf_event__repipe_tracing_data(struct perf_tool *tool,
   union perf_event *event,
   struct perf_session *session)
@@ -217,6 +245,18 @@ static int perf_event__repipe_tracing_data(struct 
perf_tool *tool,
return err;
 }
 
+static int perf_event__repipe_id_index(struct perf_tool *tool,
+  union perf_event *event,
+  struct perf_session *session)
+{
+   int err;
+
+   perf_event__repipe_synth(tool, event);
+   err = perf_event__process_id_index(tool, event, session);
+
+   return err;
+}
+
 static int dso__read_build_id(struct dso *dso)
 {
if (dso->has_build_id)
@@ -401,16 +441,20 @@ static int __cmd_inject(struct perf_inject *inject)
struct perf_session *session = inject->session;
struct perf_data_file *file_out = >output;
int fd = perf_data_file__fd(file_out);
+   u64 output_data_offset;
 
signal(SIGINT, sig_handler);
 
-   if (inject->build_ids || inject->sched_stat) {
+   if (inject->build_ids || inject->sched_stat ||
+   inject->itrace_synth_opts.set) {
inject->tool.mmap = perf_event__repipe_mmap;
inject->tool.mmap2= perf_event__repipe_mmap2;
inject->tool.fork = perf_event__repipe_fork;
inject->tool.tracing_data = perf_event__repipe_tracing_data;
}
 
+   output_data_offset = session->header.data_offset;
+
if (inject->build_ids) {
inject->tool.sample = perf_event__inject_buildid;
} else if 

[PATCH V7 23/25] perf tools: Add build option NO_AUXTRACE to exclude AUX area tracing

2015-03-31 Thread Adrian Hunter
Add build option NO_AUXTRACE to exclude compiling support
for AUX area tracing. Support for both recording and
processing is excluded and by implication any future
additions such as Intel PT and Intel BTS will also not
be compiled in with this option.

Signed-off-by: Adrian Hunter 
---
 tools/perf/Makefile.perf|   2 +
 tools/perf/builtin-inject.c |  53 +++---
 tools/perf/builtin-record.c |  13 +
 tools/perf/config/Makefile  |   5 ++
 tools/perf/tests/make   |   2 +
 tools/perf/util/Build   |   2 +-
 tools/perf/util/auxtrace.h  | 128 
 7 files changed, 185 insertions(+), 20 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index c43a205..03409cc 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -73,6 +73,8 @@ include config/utilities.mak
 # for CTF data format.
 #
 # Define NO_LZMA if you do not want to support compressed (xz) kernel modules
+#
+# Define NO_AUXTRACE if you do not want AUX area tracing support
 
 ifeq ($(srctree),)
 srctree := $(patsubst %/,%,$(dir $(shell pwd)))
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index d26a052..1639a83 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -53,25 +53,6 @@ static int output_bytes(struct perf_inject *inject, void 
*buf, size_t sz)
return 0;
 }
 
-static int copy_bytes(struct perf_inject *inject, int fd, off_t size)
-{
-   char buf[4096];
-   ssize_t ssz;
-   int ret;
-
-   while (size > 0) {
-   ssz = read(fd, buf, MIN(size, sizeof(buf)));
-   if (ssz < 0)
-   return -errno;
-   ret = output_bytes(inject, buf, ssz);
-   if (ret)
-   return ret;
-   size -= ssz;
-   }
-
-   return 0;
-}
-
 static int perf_event__repipe_synth(struct perf_tool *tool,
union perf_event *event)
 {
@@ -114,6 +95,27 @@ static int perf_event__repipe_attr(struct perf_tool *tool,
return perf_event__repipe_synth(tool, event);
 }
 
+#ifdef HAVE_AUXTRACE_SUPPORT
+
+static int copy_bytes(struct perf_inject *inject, int fd, off_t size)
+{
+   char buf[4096];
+   ssize_t ssz;
+   int ret;
+
+   while (size > 0) {
+   ssz = read(fd, buf, MIN(size, sizeof(buf)));
+   if (ssz < 0)
+   return -errno;
+   ret = output_bytes(inject, buf, ssz);
+   if (ret)
+   return ret;
+   size -= ssz;
+   }
+
+   return 0;
+}
+
 static s64 perf_event__repipe_auxtrace(struct perf_tool *tool,
   union perf_event *event,
   struct perf_session *session
@@ -153,6 +155,19 @@ static s64 perf_event__repipe_auxtrace(struct perf_tool 
*tool,
return event->auxtrace.size;
 }
 
+#else
+
+static s64
+perf_event__repipe_auxtrace(struct perf_tool *tool __maybe_unused,
+   union perf_event *event __maybe_unused,
+   struct perf_session *session __maybe_unused)
+{
+   pr_err("AUX area tracing not supported\n");
+   return -EINVAL;
+}
+
+#endif
+
 static int perf_event__repipe(struct perf_tool *tool,
  union perf_event *event,
  struct perf_sample *sample __maybe_unused,
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index f4d8252..001e732 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -112,6 +112,8 @@ out:
return rc;
 }
 
+#ifdef HAVE_AUXTRACE_SUPPORT
+
 static int record__process_auxtrace(struct perf_tool *tool,
union perf_event *event, void *data1,
size_t len1, void *data2, size_t len2)
@@ -165,6 +167,17 @@ static int record__auxtrace_mmap_read(struct record *rec,
return 0;
 }
 
+#else
+
+static inline
+int record__auxtrace_mmap_read(struct record *rec __maybe_unused,
+  struct auxtrace_mmap *mm __maybe_unused)
+{
+   return 0;
+}
+
+#endif
+
 static volatile int done = 0;
 static volatile int signr = -1;
 static volatile int child_finished = 0;
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 59a98c6..435b6ca 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -610,6 +610,11 @@ ifdef LIBBABELTRACE
   endif
 endif
 
+ifndef NO_AUXTRACE
+  $(call detected,CONFIG_AUXTRACE)
+  CFLAGS += -DHAVE_AUXTRACE_SUPPORT
+endif
+
 # Among the variables below, these:
 #   perfexecdir
 #   template_dir
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index bff8532..363fcd7 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -32,6 +32,7 @@ make_no_backtrace   := NO_BACKTRACE=1
 make_no_libnuma := NO_LIBNUMA=1
 make_no_libaudit:= 

[PATCH V7 24/25] perf auxtrace: Add option to synthesize events for transactions

2015-03-31 Thread Adrian Hunter
Add AUX area tracing option 'x' to synthesize events for
transactions. This will be used by Intel PT to synthesize
an event record for each TSX start, commit or abort.

Signed-off-by: Adrian Hunter 
---
 tools/perf/Documentation/perf-report.txt | 9 +
 tools/perf/Documentation/perf-script.txt | 9 +
 tools/perf/util/auxtrace.c   | 5 -
 tools/perf/util/auxtrace.h   | 2 ++
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/tools/perf/Documentation/perf-report.txt 
b/tools/perf/Documentation/perf-report.txt
index 66e3df3..f626fb2 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -331,11 +331,12 @@ OPTIONS
b   synthesize branches events
c   synthesize branches events (calls only)
r   synthesize branches events (returns only)
+   x   synthesize transactions events
e   synthesize error events
d   create a debug log
-   g   synthesize a call chain for instructions events
+   g   synthesize a call chain (use with i or x)
 
-   The default is all events i.e. the same as -Zibe
+   The default is all events i.e. the same as -Zibxe
 
In addition, the period (default 10) for instructions events
can be specified in units of:
@@ -346,8 +347,8 @@ OPTIONS
us  microseconds
ns  nanoseconds (default)
 
-   Also the call chain size (default 16, max. 1024) for instructions
-   events can be specified.
+   Also the call chain size (default 16, max. 1024) for instructions or
+   transactions events can be specified.
 
To disable decoding entirely, use --no-itrace.
 
diff --git a/tools/perf/Documentation/perf-script.txt 
b/tools/perf/Documentation/perf-script.txt
index 0befc9c..8ea300d 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -229,11 +229,12 @@ OPTIONS
b   synthesize branches events
c   synthesize branches events (calls only)
r   synthesize branches events (returns only)
+   x   synthesize transactions events
e   synthesize error events
d   create a debug log
-   g   synthesize a call chain for instructions events
+   g   synthesize a call chain (use with i or x)
 
-   The default is all events i.e. the same as -Zibe
+   The default is all events i.e. the same as -Zibxe
 
In addition, the period (default 10) for instructions events
can be specified in units of:
@@ -244,8 +245,8 @@ OPTIONS
us  microseconds
ns  nanoseconds (default)
 
-   Also the call chain size (default 16, max. 1024) for instructions
-   events can be specified.
+   Also the call chain size (default 16, max. 1024) for instructions or
+   transactions events can be specified.
 
To disable decoding entirely, use --no-itrace.
 
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index fb68551..c04c374 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -884,6 +884,7 @@ void itrace_synth_opts__set_default(struct 
itrace_synth_opts *synth_opts)
 {
synth_opts->instructions = true;
synth_opts->branches = true;
+   synth_opts->transactions = true;
synth_opts->errors = true;
synth_opts->period_type = PERF_ITRACE_DEFAULT_PERIOD_TYPE;
synth_opts->period = PERF_ITRACE_DEFAULT_PERIOD;
@@ -951,6 +952,9 @@ int itrace_parse_synth_opts(const struct option *opt, const 
char *str,
case 'b':
synth_opts->branches = true;
break;
+   case 'x':
+   synth_opts->transactions = true;
+   break;
case 'e':
synth_opts->errors = true;
break;
@@ -966,7 +970,6 @@ int itrace_parse_synth_opts(const struct option *opt, const 
char *str,
synth_opts->returns = true;
break;
case 'g':
-   synth_opts->instructions = true;
synth_opts->callchain = true;
synth_opts->callchain_sz =
PERF_ITRACE_DEFAULT_CALLCHAIN_SZ;
diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
index 670271b..4e1651c 100644
--- a/tools/perf/util/auxtrace.h
+++ b/tools/perf/util/auxtrace.h
@@ -54,6 +54,7 @@ enum itrace_period_type {
  *  because 'perf inject' will write it out
  * @instructions: whether to synthesize 'instructions' events
  * @branches: whether to synthesize 'branches' events
+ * @transactions: whether to synthesize events 

[PATCH V7 10/25] perf auxtrace: Add helpers for AUX area tracing errors

2015-03-31 Thread Adrian Hunter
Add functions to synthesize, count and print
AUX area tracing error events.

Signed-off-by: Adrian Hunter 
---
 tools/perf/util/auxtrace.c | 81 ++
 tools/perf/util/auxtrace.h | 14 
 tools/perf/util/event.h|  6 
 tools/perf/util/session.c  |  3 ++
 4 files changed, 104 insertions(+)

diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index 759f1bc6..a1f0eef 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -24,6 +24,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 
@@ -36,6 +37,7 @@
 #include "auxtrace.h"
 
 #include "event.h"
+#include "session.h"
 #include "debug.h"
 #include "parse-options.h"
 
@@ -167,6 +169,28 @@ auxtrace_record__init(struct perf_evlist *evlist 
__maybe_unused, int *err)
return NULL;
 }
 
+void auxtrace_synth_error(struct auxtrace_error_event *auxtrace_error, int 
type,
+ int code, int cpu, pid_t pid, pid_t tid, u64 ip,
+ const char *msg)
+{
+   size_t size;
+
+   memset(auxtrace_error, 0, sizeof(struct auxtrace_error_event));
+
+   auxtrace_error->header.type = PERF_RECORD_AUXTRACE_ERROR;
+   auxtrace_error->type = type;
+   auxtrace_error->code = code;
+   auxtrace_error->cpu = cpu;
+   auxtrace_error->pid = pid;
+   auxtrace_error->tid = tid;
+   auxtrace_error->ip = ip;
+   strlcpy(auxtrace_error->msg, msg, MAX_AUXTRACE_ERROR_MSG);
+
+   size = (void *)auxtrace_error->msg - (void *)auxtrace_error +
+  strlen(auxtrace_error->msg) + 1;
+   auxtrace_error->header.size = PERF_ALIGN(size, sizeof(u64));
+}
+
 int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr,
 struct perf_tool *tool,
 struct perf_session *session,
@@ -326,6 +350,63 @@ out_err:
return -EINVAL;
 }
 
+static const char * const auxtrace_error_type_name[] = {
+   [PERF_AUXTRACE_ERROR_ITRACE] = "instruction trace",
+};
+
+static const char *auxtrace_error_name(int type)
+{
+   const char *error_type_name = NULL;
+
+   if (type < PERF_AUXTRACE_ERROR_MAX)
+   error_type_name = auxtrace_error_type_name[type];
+   if (!error_type_name)
+   error_type_name = "unknown AUX";
+   return error_type_name;
+}
+
+size_t perf_event__fprintf_auxtrace_error(union perf_event *event, FILE *fp)
+{
+   struct auxtrace_error_event *e = >auxtrace_error;
+   int ret;
+
+   ret = fprintf(fp, " %s error type %u",
+ auxtrace_error_name(e->type), e->type);
+   ret += fprintf(fp, " cpu %d pid %d tid %d ip %#"PRIx64" code %u: %s\n",
+  e->cpu, e->pid, e->tid, e->ip, e->code, e->msg);
+   return ret;
+}
+
+void perf_session__auxtrace_error_inc(struct perf_session *session,
+ union perf_event *event)
+{
+   struct auxtrace_error_event *e = >auxtrace_error;
+
+   if (e->type < PERF_AUXTRACE_ERROR_MAX)
+   session->evlist->stats.nr_auxtrace_errors[e->type] += 1;
+}
+
+void events_stats__auxtrace_error_warn(const struct events_stats *stats)
+{
+   int i;
+
+   for (i = 0; i < PERF_AUXTRACE_ERROR_MAX; i++) {
+   if (!stats->nr_auxtrace_errors[i])
+   continue;
+   ui__warning("%u %s errors\n",
+   stats->nr_auxtrace_errors[i],
+   auxtrace_error_name(i));
+   }
+}
+
+int perf_event__process_auxtrace_error(struct perf_tool *tool __maybe_unused,
+  union perf_event *event,
+  struct perf_session *session 
__maybe_unused)
+{
+   perf_event__fprintf_auxtrace_error(event, stdout);
+   return 0;
+}
+
 int auxtrace_mmap__read(struct auxtrace_mmap *mm, struct auxtrace_record *itr,
struct perf_tool *tool, process_auxtrace_t fn)
 {
diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
index 3a7468d..a7dfb97 100644
--- a/tools/perf/util/auxtrace.h
+++ b/tools/perf/util/auxtrace.h
@@ -23,6 +23,7 @@
 #include 
 
 #include "../perf.h"
+#include "event.h"
 #include "session.h"
 
 union perf_event;
@@ -32,6 +33,7 @@ struct perf_tool;
 struct option;
 struct record_opts;
 struct auxtrace_info_event;
+struct events_stats;
 
 enum itrace_period_type {
PERF_ITRACE_PERIOD_INSTRUCTIONS,
@@ -202,14 +204,26 @@ int auxtrace_record__info_fill(struct auxtrace_record 
*itr,
 void auxtrace_record__free(struct auxtrace_record *itr);
 u64 auxtrace_record__reference(struct auxtrace_record *itr);
 
+void auxtrace_synth_error(struct auxtrace_error_event *auxtrace_error, int 
type,
+ int code, int cpu, pid_t pid, pid_t tid, u64 ip,
+ const char *msg);
+
 int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr,
  

[PATCH V7 21/25] perf tools: Add AUX area tracing index

2015-03-31 Thread Adrian Hunter
Add an index of AUX area tracing events within
a perf.data file.

perf record uses a special user event
PERF_RECORD_FINISHED_ROUND to enable sorting of
events in chunks instead of having to sort all
events altogether.

AUX area tracing events contain data that can
span back to the very beginning of the recording
period. i.e. they do not obey the rules of
PERF_RECORD_FINISHED_ROUND.

By adding an index, AUX area tracing events
can be found in advance and the
PERF_RECORD_FINISHED_ROUND approach works as
usual.

The index is recorded with the auxtrace feature
in the perf.data file.  A session reads the index
but does not process it.  An AUX area
decoder can queue all the AUX area data
in advance using auxtrace_queues__process_index()
or otherwise process the index in some custom
manner.

Signed-off-by: Adrian Hunter 
---
 tools/perf/builtin-inject.c |  15 +++
 tools/perf/builtin-record.c |  15 +++
 tools/perf/util/auxtrace.c  | 216 
 tools/perf/util/auxtrace.h  |  35 +++
 tools/perf/util/header.c|  31 ++-
 tools/perf/util/session.c   |   2 +
 tools/perf/util/session.h   |   1 +
 7 files changed, 311 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 3a36c7b..c7b429e 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -122,6 +122,18 @@ static s64 perf_event__repipe_auxtrace(struct perf_tool 
*tool,
  tool);
int ret;
 
+   if (!inject->output.is_pipe) {
+   off_t offset;
+
+   offset = lseek(inject->output.fd, 0, SEEK_CUR);
+   if (offset == -1)
+   return -errno;
+   ret = auxtrace_index__auxtrace_event(>auxtrace_index,
+event, offset);
+   if (ret < 0)
+   return ret;
+   }
+
if (perf_data_file__is_pipe(session->file) || !session->one_mmap) {
ret = output_bytes(inject, event, event->header.size);
if (ret < 0)
@@ -487,6 +499,9 @@ static int __cmd_inject(struct perf_inject *inject)
output_data_offset = 4096;
}
 
+   if (!inject->itrace_synth_opts.set)
+   auxtrace_index__free(>auxtrace_index);
+
if (!file_out->is_pipe)
lseek(fd, output_data_offset, SEEK_SET);
 
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 56502e5..5aa210e 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -117,9 +117,24 @@ static int record__process_auxtrace(struct perf_tool *tool,
size_t len1, void *data2, size_t len2)
 {
struct record *rec = container_of(tool, struct record, tool);
+   struct perf_data_file *file = >file;
size_t padding;
u8 pad[8] = {0};
 
+   if (!perf_data_file__is_pipe(file)) {
+   off_t file_offset;
+   int fd = perf_data_file__fd(file);
+   int err;
+
+   file_offset = lseek(fd, 0, SEEK_CUR);
+   if (file_offset == -1)
+   return -1;
+   err = 
auxtrace_index__auxtrace_event(>session->auxtrace_index,
+event, file_offset);
+   if (err)
+   return err;
+   }
+
/* event.auxtrace.size includes padding, see __auxtrace_mmap__read() */
padding = (len1 + len2) & 7;
if (padding)
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index 01ea9cd..fb68551 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -339,6 +339,33 @@ out_err:
return err;
 }
 
+static int auxtrace_queues__add_indexed_event(struct auxtrace_queues *queues,
+ struct perf_session *session,
+ off_t file_offset, size_t sz)
+{
+   union perf_event *event;
+   int err;
+   char buf[PERF_SAMPLE_MAX_SIZE];
+
+   err = perf_session__peek_event(session, file_offset, buf,
+  PERF_SAMPLE_MAX_SIZE, , NULL);
+   if (err)
+   return err;
+
+   if (event->header.type == PERF_RECORD_AUXTRACE) {
+   if (event->header.size != sizeof(struct auxtrace_event) ||
+   event->header.size != sz) {
+   err = -EINVAL;
+   goto out;
+   }
+   file_offset += event->header.size;
+   err = auxtrace_queues__add_event(queues, session, event,
+file_offset, NULL);
+   }
+out:
+   return err;
+}
+
 void auxtrace_queues__free(struct auxtrace_queues *queues)
 {
unsigned int i;
@@ -495,6 +522,195 @@ auxtrace_record__init(struct perf_evlist *evlist 

[PATCH V7 18/25] perf report: Add Instruction Tracing support

2015-03-31 Thread Adrian Hunter
Add support for decoding an AUX area assuming
it contains instruction tracing data.

Signed-off-by: Adrian Hunter 
---
 tools/perf/Documentation/perf-report.txt | 28 
 tools/perf/builtin-report.c  | 11 +++
 2 files changed, 39 insertions(+)

diff --git a/tools/perf/Documentation/perf-report.txt 
b/tools/perf/Documentation/perf-report.txt
index 4879cf6..66e3df3 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -323,6 +323,34 @@ OPTIONS
 --header-only::
Show only perf.data header (forces --stdio).
 
+-Z::
+--itrace::
+   Options for decoding AUX area tracing data. The options are:
+
+   i   synthesize instructions events
+   b   synthesize branches events
+   c   synthesize branches events (calls only)
+   r   synthesize branches events (returns only)
+   e   synthesize error events
+   d   create a debug log
+   g   synthesize a call chain for instructions events
+
+   The default is all events i.e. the same as -Zibe
+
+   In addition, the period (default 10) for instructions events
+   can be specified in units of:
+
+   i   instructions
+   t   ticks
+   ms  milliseconds
+   us  microseconds
+   ns  nanoseconds (default)
+
+   Also the call chain size (default 16, max. 1024) for instructions
+   events can be specified.
+
+   To disable decoding entirely, use --no-itrace.
+
 SEE ALSO
 
 linkperf:perf-stat[1], linkperf:perf-annotate[1]
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index b5b2ad4..f607466 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -36,6 +36,8 @@
 #include "util/data.h"
 #include "arch/common.h"
 
+#include "util/auxtrace.h"
+
 #include 
 #include 
 
@@ -585,6 +587,7 @@ parse_percent_limit(const struct option *opt, const char 
*str,
 int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 {
struct perf_session *session;
+   struct itrace_synth_opts itrace_synth_opts = {0};
struct stat st;
bool has_br_stack = false;
int branch_mode = -1;
@@ -607,6 +610,9 @@ int cmd_report(int argc, const char **argv, const char 
*prefix __maybe_unused)
.attr= perf_event__process_attr,
.tracing_data= perf_event__process_tracing_data,
.build_id= perf_event__process_build_id,
+   .id_index= perf_event__process_id_index,
+   .auxtrace_info   = perf_event__process_auxtrace_info,
+   .auxtrace= perf_event__process_auxtrace,
.ordered_events  = true,
.ordering_requires_timestamps = true,
},
@@ -717,6 +723,9 @@ int cmd_report(int argc, const char **argv, const char 
*prefix __maybe_unused)
 "Don't show entries under that percent", 
parse_percent_limit),
OPT_CALLBACK(0, "percentage", NULL, "relative|absolute",
 "how to display percentage of filtered entries", 
parse_filter_percentage),
+   OPT_CALLBACK_OPTARG('Z', "itrace", _synth_opts, NULL, "opts",
+   "Instruction Tracing options",
+   itrace_parse_synth_opts),
OPT_END()
};
struct perf_data_file file = {
@@ -761,6 +770,8 @@ repeat:
   report.queue_size);
}
 
+   session->itrace_synth_opts = _synth_opts;
+
report.session = session;
 
has_br_stack = perf_header__has_feat(>header,
-- 
1.9.1

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


[PATCH V7 22/25] perf tools: Hit all build ids when AUX area tracing

2015-03-31 Thread Adrian Hunter
We need to include all buildids when a perf.data
file contains AUX area tracing data because we
do not decode the trace for that purpose because
it would take too long.

Signed-off-by: Adrian Hunter 
---
 tools/perf/builtin-buildid-list.c |  9 +
 tools/perf/builtin-inject.c   |  8 +++-
 tools/perf/builtin-record.c   | 10 +-
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-buildid-list.c 
b/tools/perf/builtin-buildid-list.c
index feb420f..9fe93c8 100644
--- a/tools/perf/builtin-buildid-list.c
+++ b/tools/perf/builtin-buildid-list.c
@@ -69,6 +69,15 @@ static int perf_session__list_build_ids(bool force, bool 
with_hits)
session = perf_session__new(, false, _id__mark_dso_hit_ops);
if (session == NULL)
return -1;
+
+   /*
+* We take all buildids when the file contains AUX area tracing data
+* because we do not decode the trace because it would take too long.
+*/
+   if (!perf_data_file__is_pipe() &&
+   perf_header__has_feat(>header, HEADER_AUXTRACE))
+   with_hits = false;
+
/*
 * in pipe-mode, the only way to get the buildids is to parse
 * the record stream. Buildids are stored as RECORD_HEADER_BUILD_ID
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index c7b429e..d26a052 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -27,6 +27,7 @@ struct perf_inject {
struct perf_session *session;
boolbuild_ids;
boolsched_stat;
+   boolhave_auxtrace;
const char  *input_name;
struct perf_data_file   output;
u64 bytes_written;
@@ -122,6 +123,8 @@ static s64 perf_event__repipe_auxtrace(struct perf_tool 
*tool,
  tool);
int ret;
 
+   inject->have_auxtrace = true;
+
if (!inject->output.is_pipe) {
off_t offset;
 
@@ -508,9 +511,12 @@ static int __cmd_inject(struct perf_inject *inject)
ret = perf_session__process_events(session);
 
if (!file_out->is_pipe) {
-   if (inject->build_ids)
+   if (inject->build_ids) {
perf_header__set_feat(>header,
  HEADER_BUILD_ID);
+   if (inject->have_auxtrace)
+   dsos__hit_all(session);
+   }
/*
 * The AUX areas have been removed and replaced with
 * synthesized hardware events, so clear the feature flag.
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 5aa210e..f4d8252 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -620,8 +620,16 @@ out_child:
if (!err && !file->is_pipe) {
rec->session->header.data_size += rec->bytes_written;
 
-   if (!rec->no_buildid)
+   if (!rec->no_buildid) {
process_buildids(rec);
+   /*
+* We take all buildids when the file contains
+* AUX area tracing data because we do not decode the
+* trace because it would take too long.
+*/
+   if (rec->opts.full_auxtrace)
+   dsos__hit_all(rec->session);
+   }
perf_session__write_header(rec->session, rec->evlist, fd, true);
}
 
-- 
1.9.1

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


[PATCH V7 25/25] perf script: Add field option 'flags' to print sample flags

2015-03-31 Thread Adrian Hunter
Instruction tracing will typically have access to information
about the instruction being executed for a particular ip sample.
Some of that information will be available in the 'flags' member
of struct perf_sample.

With the addition of transactions events synthesis to Instruction
Tracing options, there is a need to be able easily to see the
flags because they show whether the ip is at the start, commit or
abort of a tranasaction.

Consequently add an option to display the flags.

The flags are "bcrosyiABEx" which stand for branch, call, return,
conditional, system, asynchronous, interrupt, transaction abort,
trace begin, trace end, and in transaction, respectively.

Example using Intel PT:

perf script -fip,time,event,sym,addr,flags

...
 1288.721584105: branches:u:   bo  401146 main =>   401152 
main
 1288.721584105: transactions:   x   0   401164 main
 1288.721584105: branches:u:   bx  40117c main =>   40119b 
main
 1288.721584105: branches:u:   box 4011a4 main =>   40117e 
main
 1288.721584105: branches:u:   bcx 401187 main =>   401094 g
...
 1288.721591645: branches:u:   bx  4010c4 g =>   4010cb g
 1288.721591645: branches:u:   brx 4010cc g =>   401189 main
 1288.721591645: transactions:   0   4011a6 main
 1288.721593199: branches:u:   b   4011a9 main =>   4011af 
main
 1288.721593199: branches:u:   bo  4011bc main =>   40113e 
main
 1288.721593199: branches:u:   b   401150 main =>   40115a 
main
 1288.721593199: transactions:   x   0   401164 main
 1288.721593199: branches:u:   bx  40117c main =>   40119b 
main
 1288.721593199: branches:u:   box 4011a4 main =>   40117e 
main
 1288.721593199: branches:u:   bcx 401187 main =>   40105e f
...
 1288.722284747: branches:u:   brx 401093 f =>   401189 main
 1288.722284747: branches:u:   box 4011a4 main =>   40117e 
main
 1288.722284747: branches:u:   bcx 401187 main =>   40105e f
 1288.722285883: transactions:   bA  0   401071 f
 1288.722285883: branches:u:   bA  401071 f =>   40116a main
 1288.722285883: branches:u:   bE  40116a main =>0 
[unknown]
 1288.722297174: branches:u:   bB   0 [unknown] =>   
40116a main
...

Signed-off-by: Adrian Hunter 
---
 tools/perf/Documentation/perf-script.txt |  9 -
 tools/perf/builtin-script.c  | 34 +++-
 tools/perf/util/event.h  |  2 ++
 3 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/tools/perf/Documentation/perf-script.txt 
b/tools/perf/Documentation/perf-script.txt
index 8ea300d..576f9d4 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -115,7 +115,8 @@ OPTIONS
 -f::
 --fields::
 Comma separated list of fields to print. Options are:
-comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff, 
srcline, period.
+comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff,
+   srcline, period, flags.
 Field list can be prepended with the type, trace, sw or hw,
 to indicate to which event type the field list applies.
 e.g., -f sw:comm,tid,time,ip,sym  and -f trace:time,cpu,trace
@@ -165,6 +166,12 @@ OPTIONS
 
At this point usage is displayed, and perf-script exits.
 
+   The flags field is synthesized and may have a value when Instruction
+   Trace decoding. The flags are "bcrosyiABEx" which stand for branch,
+   call, return, conditional, system, asynchronous, interrupt,
+   transaction abort, trace begin, trace end, and in transaction,
+   respectively.
+
Finally, a user may not set fields to none for all event types.
i.e., -f "" is not allowed.
 
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 5bedfda..44ccea0 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -27,6 +27,7 @@ static u64nr_unordered;
 static boolno_callchain;
 static boollatency_format;
 static boolsystem_wide;
+static boolprint_flags;
 static const char  *cpu_list;
 static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
 
@@ -461,6 +462,25 @@ static void print_sample_bts(union perf_event *event,
printf("\n");
 }
 
+static void print_sample_flags(u32 flags)
+{
+   const char *chars = PERF_IP_FLAG_CHARS;
+   const int n = strlen(PERF_IP_FLAG_CHARS);
+   char str[33];
+   int i, pos = 0;
+
+   for (i = 0; i < n; i++, flags >>= 1) {
+   if (flags & 1)
+  

[PATCH V7 14/25] perf auxtrace: Add a hashtable for caching

2015-03-31 Thread Adrian Hunter
Decoding AUX area data may involve walking object
code.  Rather than repetitively decoding the same
instructions, a cache can be used to cache the results.

This patch implements a fairly generic hashtable
with a 32-bit key that could be used for other
purposes as well.

Signed-off-by: Adrian Hunter 
---
 tools/perf/util/auxtrace.c | 123 +
 tools/perf/util/auxtrace.h |  14 ++
 2 files changed, 137 insertions(+)

diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index 4c7c3dd..01ea9cd 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -40,6 +40,8 @@
 #include "asm/bug.h"
 #include "auxtrace.h"
 
+#include 
+
 #include "event.h"
 #include "session.h"
 #include "debug.h"
@@ -934,3 +936,124 @@ int auxtrace_mmap__read(struct auxtrace_mmap *mm, struct 
auxtrace_record *itr,
 
return 1;
 }
+
+/**
+ * struct auxtrace_cache - hash table to implement a cache
+ * @hashtable: the hashtable
+ * @sz: hashtable size (number of hlists)
+ * @entry_size: size of an entry
+ * @limit: limit the number of entries to this maximum, when reached the cache
+ * is dropped and caching begins again with an empty cache
+ * @cnt: current number of entries
+ * @bits: hashtable size (@sz = 2^@bits)
+ */
+struct auxtrace_cache {
+   struct hlist_head *hashtable;
+   size_t sz;
+   size_t entry_size;
+   size_t limit;
+   size_t cnt;
+   unsigned int bits;
+};
+
+struct auxtrace_cache *auxtrace_cache__new(unsigned int bits, size_t 
entry_size,
+  unsigned int limit_percent)
+{
+   struct auxtrace_cache *c;
+   struct hlist_head *ht;
+   size_t sz, i;
+
+   c = zalloc(sizeof(struct auxtrace_cache));
+   if (!c)
+   return NULL;
+
+   sz = 1UL << bits;
+
+   ht = calloc(sz, sizeof(struct hlist_head));
+   if (!ht)
+   goto out_free;
+
+   for (i = 0; i < sz; i++)
+   INIT_HLIST_HEAD([i]);
+
+   c->hashtable = ht;
+   c->sz = sz;
+   c->entry_size = entry_size;
+   c->limit = (c->sz * limit_percent) / 100;
+   c->bits = bits;
+
+   return c;
+
+out_free:
+   free(c);
+   return NULL;
+}
+
+static void auxtrace_cache__drop(struct auxtrace_cache *c)
+{
+   struct auxtrace_cache_entry *entry;
+   struct hlist_node *tmp;
+   size_t i;
+
+   if (!c)
+   return;
+
+   for (i = 0; i < c->sz; i++) {
+   hlist_for_each_entry_safe(entry, tmp, >hashtable[i], hash) {
+   hlist_del(>hash);
+   auxtrace_cache__free_entry(c, entry);
+   }
+   }
+
+   c->cnt = 0;
+}
+
+void auxtrace_cache__free(struct auxtrace_cache *c)
+{
+   if (!c)
+   return;
+
+   auxtrace_cache__drop(c);
+   free(c->hashtable);
+   free(c);
+}
+
+void *auxtrace_cache__alloc_entry(struct auxtrace_cache *c)
+{
+   return malloc(c->entry_size);
+}
+
+void auxtrace_cache__free_entry(struct auxtrace_cache *c __maybe_unused,
+   void *entry)
+{
+   free(entry);
+}
+
+int auxtrace_cache__add(struct auxtrace_cache *c, u32 key,
+   struct auxtrace_cache_entry *entry)
+{
+   if (c->limit && ++c->cnt > c->limit)
+   auxtrace_cache__drop(c);
+
+   entry->key = key;
+   hlist_add_head(>hash, >hashtable[hash_32(key, c->bits)]);
+
+   return 0;
+}
+
+void *auxtrace_cache__lookup(struct auxtrace_cache *c, u32 key)
+{
+   struct auxtrace_cache_entry *entry;
+   struct hlist_head *hlist;
+
+   if (!c)
+   return NULL;
+
+   hlist = >hashtable[hash_32(key, c->bits)];
+   hlist_for_each_entry(entry, hlist, hash) {
+   if (entry->key == key)
+   return entry;
+   }
+
+   return NULL;
+}
diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
index d83cb9b..3cfdd84 100644
--- a/tools/perf/util/auxtrace.h
+++ b/tools/perf/util/auxtrace.h
@@ -313,6 +313,20 @@ int auxtrace_heap__add(struct auxtrace_heap *heap, 
unsigned int queue_nr,
 void auxtrace_heap__pop(struct auxtrace_heap *heap);
 void auxtrace_heap__free(struct auxtrace_heap *heap);
 
+struct auxtrace_cache_entry {
+   struct hlist_node hash;
+   u32 key;
+};
+
+struct auxtrace_cache *auxtrace_cache__new(unsigned int bits, size_t 
entry_size,
+  unsigned int limit_percent);
+void auxtrace_cache__free(struct auxtrace_cache *auxtrace_cache);
+void *auxtrace_cache__alloc_entry(struct auxtrace_cache *c);
+void auxtrace_cache__free_entry(struct auxtrace_cache *c, void *entry);
+int auxtrace_cache__add(struct auxtrace_cache *c, u32 key,
+   struct auxtrace_cache_entry *entry);
+void *auxtrace_cache__lookup(struct auxtrace_cache *c, u32 key);
+
 struct auxtrace_record *auxtrace_record__init(struct perf_evlist *evlist,

[PATCH V7 01/25] perf header: Add AUX area tracing feature

2015-03-31 Thread Adrian Hunter
Add a feature to indicate that a perf.data file
contains AUX area data.

Signed-off-by: Adrian Hunter 
---
 tools/perf/util/header.c | 14 ++
 tools/perf/util/header.h |  1 +
 2 files changed, 15 insertions(+)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index fb43215..c6739dd 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -869,6 +869,13 @@ static int write_branch_stack(int fd __maybe_unused,
return 0;
 }
 
+static int write_auxtrace(int fd __maybe_unused,
+ struct perf_header *h __maybe_unused,
+ struct perf_evlist *evlist __maybe_unused)
+{
+   return 0;
+}
+
 static void print_hostname(struct perf_header *ph, int fd __maybe_unused,
   FILE *fp)
 {
@@ -1163,6 +1170,12 @@ static void print_branch_stack(struct perf_header *ph 
__maybe_unused,
fprintf(fp, "# contains samples with branch stack\n");
 }
 
+static void print_auxtrace(struct perf_header *ph __maybe_unused,
+  int fd __maybe_unused, FILE *fp)
+{
+   fprintf(fp, "# contains AUX area data (e.g. instruction trace)\n");
+}
+
 static void print_pmu_mappings(struct perf_header *ph, int fd __maybe_unused,
   FILE *fp)
 {
@@ -1873,6 +1886,7 @@ static const struct feature_ops 
feat_ops[HEADER_LAST_FEATURE] = {
FEAT_OPA(HEADER_BRANCH_STACK,   branch_stack),
FEAT_OPP(HEADER_PMU_MAPPINGS,   pmu_mappings),
FEAT_OPP(HEADER_GROUP_DESC, group_desc),
+   FEAT_OPA(HEADER_AUXTRACE,   auxtrace),
 };
 
 struct header_print_data {
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index 3bb90ac..d4d5796 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -30,6 +30,7 @@ enum {
HEADER_BRANCH_STACK,
HEADER_PMU_MAPPINGS,
HEADER_GROUP_DESC,
+   HEADER_AUXTRACE,
HEADER_LAST_FEATURE,
HEADER_FEAT_BITS= 256,
 };
-- 
1.9.1

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


[PATCH V7 00/25] perf tools: Introduce an abstraction for AUX Area and Instruction Tracing

2015-03-31 Thread Adrian Hunter
Hi

Here is V7 of some more preparatory patches for Intel PT
that introduce an abstraction for using the AUX area and
Instruction tracing.

The master branch of the tree:

git://git.infradead.org/users/ahunter/linux-perf.git

contains these patches and working Intel PT and Intel BTS.
Intel BTS can be used on most recent Intel CPUs. Intel PT
is available on Broadwell.

Examples:

Trace 'ls' with Intel BTS userspace only

perf record --per-thread -e intel_bts//u ls
perf report
perf script

Trace 'ls' with Intel BTS kernel and userspace

~/libexec/perf-core/perf-with-kcore record bts-ls --per-thread -e 
intel_bts// -- ls
~/libexec/perf-core/perf-with-kcore report bts-ls
~/libexec/perf-core/perf-with-kcore script bts-ls

Trace 'ls' with Intel PT userspace only

perf record -e intel_pt//u ls
perf report
perf script

Trace 'ls' with Intel PT kernel and userspace

~/libexec/perf-core/perf-with-kcore record pt-ls -e intel_pt// -- ls
~/libexec/perf-core/perf-with-kcore report pt-ls
~/libexec/perf-core/perf-with-kcore script pt-ls

Changes in V7:

Changes requested by Jiri:

perf evlist: Add initial support for mmapping an AUX area buffer
WARN_ONCE if mm->base is not NULL when mmapping

perf tools: Add support for AUX area recording
Use perf_can_sample_identifier() consistently
Drop unused function perf_event__synthesize_auxtrace()

perf record: Add basic AUX area tracing support
Check length before calling record__write a second time

perf record: Extend -m option for AUX area tracing mmap pages
Update change log with -m option change syntax

Changes in V6:

Renamed itrace to auxtrace to better reflect the use of the
AUX area. In some cases itrace was retained where it seemed
to relate exclusively to Instruction Tracing.

Print warnings for separate auxtrace error types

Re-based on Arnaldo's perf/core branch:

107eb964d8c04417e8bce9e9ec2ed61d9261aec6
Merge tag 'perf-core-for-mingo' of 
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core

Changes in V5:

perf tools: Add a user event for Instruction Tracing errors
Print error count from stats->nr_events

perf session: Add hooks to allow transparent decoding of Instruction 
Tracing data
Don't count Instruction Tracing errors (using stats->nr_events 
instead)

perf itrace: Add helpers for Instruction Tracing errors
Don't count Instruction Tracing errors (using stats->nr_events 
instead)

perf itrace: Add option to synthesize events for transactions
New patch

perf script: Add field option 'flags' to print sample flags
New patch

Re-based on tip perf/core branch:

94ac003b665fc04f13a7ab3b2be896b9b9503451
Merge tag 'perf-core-for-mingo' of 
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core

Changes in V4:

perf tools: Add build option NO_ITRACE to exclude Instruction Tracing
New patch

Re-based on Arnaldo's perf/core branch:

3dd417d4010c8e141b0f32121cdc8d82aa4a9c6a
perf tools: Remove some unused functions from color.c

Changes in V3:

perf tools: Add support for Instruction Trace recording
Added evsel as a parameter to itrace_record__init

perf record: Add basic Instruction Tracing support
Moved the call to itrace_record__init after parse
options so that evsel could be passed and the
selected events used to determine what kind of
Instruction Tracing to use e.g. Intel PT vs BTS

Re-based on Arnaldo's perf/core branch:

41e950c033b7df997d4b38653efe6554be9b96a7
Merge tag 'perf-core-for-mingo' of 
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent

Changes in V2:

Dropped patches already applied.

Re-based on Arnaldo's perf/core branch:

a84808083688d82d7f1e5786ccf5df0ff7d448cb
perf tools: Only override the default :tid comm entry


The abstraction has two separate aspects:
1. recording AUX area data
2. processing AUX area data

Recording consists of mmapping a separate buffer and copying
the data into the perf.data file.  The buffer is an AUX area
buffer although the details of the AUX area are not implemented
because the kernel support is pending.  The data is written
preceded by a new user event PERF_RECORD_AUXTRACE.  The data is
too big to fit in the event but follows immediately afterward.
Session processing has to skip to get to the next event header
in a 

Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check

2015-03-31 Thread Michael Wang
Hi, Tom

Thanks for the comments :-)

On 03/31/2015 01:19 PM, Tom Talpey wrote:
> [snip]
>
>>
>> Actually I'm thinking about Doug's idea to use rdma_transport_is_XX()
>> instead of the current basic helper, thus may be use 
>> rdma_transport_is_iwarp()
>> in here could be better, since it's actually a feature of iwarp tech
>> that RDMA Read only support one scatter-gather entry.
>
> No, you should expose an attribute to surface the maximum length of
> the remote gather list, which varies by adapter as well as protocol.
> The fact that iWARP is different from IB is not relevant, and conflates
> unrelated properties.

To be confirmed, so your point is that the max-read-sges will be different
even the transport is the same IWRAP, and that depends on the capability
of adapter, correct?

I currently only find this one place where infer max-read-sges from
transport type, it looks more like a special case to me rather than a generic
method we could exposed... and also  not very related with IB management
helper concept IMHO.

Regards,
Michael Wang

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] phy: driver for Conexant Digicolor internal USB PHY

2015-03-31 Thread Baruch Siach
Hi Marek,

On Sat, Mar 28, 2015 at 04:33:02PM +0100, Marek Vasut wrote:
> On Friday, March 27, 2015 at 05:36:29 AM, Baruch Siach wrote:
> > Add a driver for the USB PHY on the Conexant CX92755 SoC, from the
> > Digicolor series of SoCs. The PHY is connected to the on-chip chipidea
> > usb2 host.
> > 
> > The hardware is somewhat similar to the phy-mxs-usb.c usb_phy, but it is
> > different enough to merit its own driver. Also, this driver uses the
> > generic phy infrastructure.
> 
> the register set looks very similar to MXS one indeed. How is it different 
> please ?

Almost of the bits that are defined in the MXS USBPHY_CTRL register are not 
defined in the Digicolor one. Some have different meaning, and some are 
reserved. OTOH, the Digicolor USBPHY_CTRL register uses all bits in the 1-13 
range. Also, the Digicolor phy does not have anatop registers.

> The driver looks OK.

Thanks.

BTW, do you know why the phy-mxs-usb driver calls its init from 
postcore_initcall? Is there a special need to register the driver so early?

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 4/4] mm, mempool: poison elements backed by page allocator

2015-03-31 Thread Andrey Ryabinin
On 03/27/2015 01:50 AM, David Rientjes wrote:
> We don't have a need to set PAGE_EXT_DEBUG_POISON on these pages sitting 
> in the reserved pool, nor do we have a need to do kmap_atomic() since it's 
> already mapped and must be mapped to be on the reserved pool, which is 
> handled by mempool_free().
> 

Hmm.. I just realized that this statement might be wrong.
Why pages has to be mapped to be on reserved pool?
mempool could be used for highmem pages and there is no need to kmap()
until these pages will be used.

drbd (drivers/block/drbd) already uses mempool for highmem pages:

static int drbd_create_mempools(void)
{

drbd_md_io_page_pool = mempool_create_page_pool(DRBD_MIN_POOL_PAGES, 0);

}



static void bm_page_io_async(struct drbd_bm_aio_ctx *ctx, int page_nr) 
__must_hold(local)
{

page = mempool_alloc(drbd_md_io_page_pool, 
__GFP_HIGHMEM|__GFP_WAIT);
copy_highpage(page, b->bm_pages[page_nr]);


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


Re: [PATCH 1/3] timer: Allocate per-cpu tvec_base's statically

2015-03-31 Thread Viresh Kumar
On 31 March 2015 at 13:15, Ingo Molnar  wrote:
>
> * Viresh Kumar  wrote:
>
>> From: Peter Zijlstra 

>> + if (!boot_done) {
>> + boot_done = 1; /* skip the boot cpu */
>
> So it would be a lot more descriptive to name this flag
> 'boot_cpu_skipped'?

Yes.

> Also, I'd put a description about the PER_CPU background into comments
> as well, because it's not obvious at first sight at all what the whole
> (boot_tvec_bases, tvec_bases, __tvec_bases) dance does.

Yeah, so I did that with a one liner in the last patch, but that doesn't
look good enough. I will try to do something better in V2.

Thanks for your reviews.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check

2015-03-31 Thread Tom Talpey

On 3/31/2015 3:39 AM, Michael Wang wrote:

On 03/31/2015 12:35 AM, Jason Gunthorpe wrote:

On Mon, Mar 30, 2015 at 05:10:12PM +0200, Michael Wang wrote:

I found that actually we don't have to touch this one which
only used by HW driver currently.

I'm having a hard time understanding this, the code in question was in

net/sunrpc/xprtrdma/svc_rdma_recvfrom.c

Which is the NFS ULP, not a device driver.


I'm not familiar with this part too :-P but yes, it looks like an ulp
to support NFS.


It's the NFS server itself.



Actually I'm thinking about Doug's idea to use rdma_transport_is_XX()
instead of the current basic helper, thus may be use rdma_transport_is_iwarp()
in here could be better, since it's actually a feature of iwarp tech
that RDMA Read only support one scatter-gather entry.


No, you should expose an attribute to surface the maximum length of
the remote gather list, which varies by adapter as well as protocol.
The fact that iWARP is different from IB is not relevant, and conflates
unrelated properties.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] spi: xilinx: Use standard num-cs binding

2015-03-31 Thread Michal Simek
On 03/31/2015 01:16 PM, Mark Brown wrote:
> On Tue, Mar 31, 2015 at 10:16:57AM +0200, Michal Simek wrote:
>> On 03/31/2015 07:47 AM, Mark Brown wrote:
> 
>>> num-cs *is* a software setting.
> 
>> ok - what to do with that? Remove it because it shouldn't be passed via DT?
> 
> Well, there's a lot of existing users to check and clean up some of
> which currently rely on it which will take time to deal with.  Removing
> it while some drivers rely on using it isn't ideal.
> 

We have spi-cadence driver in the kernel which uses num-cs and also
is-decoded-cs and we can change it but the question still remains how
to do it better.

Thanks,
Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 5 1/7] kmod - add workqueue service thread store

2015-03-31 Thread Jeff Layton
On Tue, 31 Mar 2015 11:14:42 +0800
Ian Kent  wrote:

> From: Ian Kent 
> 
> Persistent use of process information is needed for contained
> execution in a namespace other than the root init namespace.
> 
> Use a simple random token as a key to create and store thread
> information in a hashed list for use by the usermode helper
> thread runner.
> 
> Signed-off-by: Ian Kent 
> Cc: Benjamin Coddington 
> Cc: Al Viro 
> Cc: J. Bruce Fields 
> Cc: David Howells 
> Cc: Trond Myklebust 
> Cc: Oleg Nesterov 
> Cc: Eric W. Biederman 
> Cc: Jeff Layton 
> ---
>  include/linux/kmod.h |3 +
>  kernel/kmod.c|  179 
> ++
>  2 files changed, 181 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/kmod.h b/include/linux/kmod.h
> index 0555cc6..fa46722 100644
> --- a/include/linux/kmod.h
> +++ b/include/linux/kmod.h
> @@ -66,6 +66,9 @@ struct subprocess_info {
>   void *data;
>  };
>  
> +extern int umh_wq_get_token(int token, const char *service);
> +extern void umh_wq_put_token(int token);
> +
>  extern int
>  call_usermodehelper(char *path, char **argv, char **envp, int wait);
>  
> diff --git a/kernel/kmod.c b/kernel/kmod.c
> index 2777f40..55d20ce 100644
> --- a/kernel/kmod.c
> +++ b/kernel/kmod.c
> @@ -40,13 +40,30 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
> +#include 
>  
>  #include 
>  
>  extern int max_threads;
>  
> +#define KHELPER  "khelper"
>  static struct workqueue_struct *khelper_wq;
>  
> +#define UMH_WQ_HASH_SHIFT  6
> +#define UMH_WQ_HASH_SIZE   1 << UMH_WQ_HASH_SHIFT
> +
> +struct umh_wq_entry {
> + int token;
> + unsigned int count;
> + struct workqueue_struct *wq;
> + struct hlist_node umh_wq_hlist;
> +};
> +
> +static DEFINE_SPINLOCK(umh_wq_hash_lock);
> +static struct hlist_head umh_wq_hash[UMH_WQ_HASH_SIZE];
> +
>  #define CAP_BSET (void *)1
>  #define CAP_PI   (void *)2
>  
> @@ -475,6 +492,165 @@ static void helper_unlock(void)
>   wake_up(_helpers_waitq);
>  }
>  
> +static void umh_wq_hash_init(void)
> +{
> + int i;
> +
> + for (i = 0; i < UMH_WQ_HASH_SIZE; i++)
> + INIT_HLIST_HEAD(_wq_hash[i]);
> +}
> +
> +static struct umh_wq_entry *umh_wq_find_entry(int token)
> +{
> + struct umh_wq_entry *this, *entry;
> + struct hlist_head *bucket;
> + unsigned int hash;
> +
> + hash = hash_32((unsigned long) token, UMH_WQ_HASH_SHIFT);
> + bucket = _wq_hash[hash];
> +
> + entry = ERR_PTR(-ENOENT);
> + if (hlist_empty(bucket))
> + goto out;
> +
> + hlist_for_each_entry(this, bucket, umh_wq_hlist) {
> + if (this->token == token) {
> + entry = this;
> + break;
> + }
> + }
> +out:
> + return entry;
> +}
> +
> +static struct workqueue_struct *umh_find_wq(int token, unsigned int nowait)

nit: there's no caller of this in this patch, but one is added in patch #2.

> +{
> + struct umh_wq_entry *entry;
> + unsigned long flags;
> +
> + if (!token)
> + return khelper_wq;
> +
> + if (nowait)
> + spin_lock_irqsave(_wq_hash_lock, flags);
> + else
> + spin_lock(_wq_hash_lock);
> + entry = umh_wq_find_entry(token);
> + if (nowait)
> + spin_unlock_irqrestore(_wq_hash_lock, flags);
> + else
> + spin_unlock(_wq_hash_lock);
> +
> + return entry->wq;
> +}
> +
> +/**
> + * umh_wq_get_token - create service thread and return an identifying token
> + * @token: token of an existing service thread or 0 to create a new
> + *  service thread.
> + * @name: service name to be appended to "khelper" for identification.
> + *
> + * Returns a token that used with calls to call_usermode_helper_service().
> + * If token corresponds to an existing service thread its reference count
> + * is increased and the token returned. On failure returns a negative errno.
> + */
> +int umh_wq_get_token(int token, const char *service)
> +{
> + struct workqueue_struct *wq;
> + char *wq_name;
> + int wq_name_len;
> + struct umh_wq_entry *entry;
> + struct hlist_head *bucket;
> + unsigned int hash;
> + unsigned int new_token;
> +
> + if (token) {
> + spin_lock(_wq_hash_lock);
> + entry = umh_wq_find_entry(token);
> + if (entry) {
> + entry->count++;
> + spin_unlock(_wq_hash_lock);
> + return token;
> + }
> + spin_unlock(_wq_hash_lock);
> + }
> +
> + if (!service)
> + return -EINVAL;
> +
> + wq_name_len = sizeof(KHELPER) + strlen(service) + 1;
> + wq_name = kmalloc(wq_name_len, GFP_KERNEL);
> + if (!wq_name)
> + return -ENOMEM;
> + strcpy(wq_name, "KHELPER-");
> + strcat(wq_name, service);
> +
> + entry = kzalloc(sizeof(struct umh_wq_entry), GFP_KERNEL);
> + if 

Re: [Qemu-devel] [PATCH v4 11/15] target-s390x: New QMP command query-cpu-model

2015-03-31 Thread Michael Mueller
On Mon, 30 Mar 2015 17:17:21 -0300
Eduardo Habkost  wrote:

> On Mon, Mar 30, 2015 at 04:28:24PM +0200, Michael Mueller wrote:
> > This patch implements a new QMP request named 'query-cpu-model'.
> > It returns the cpu model of cpu 0 and its backing accelerator.
> > 
> > request:
> >   {"execute" : "query-cpu-model" }
> > 
> > answer:
> >   {"return" : {"name": "2827-ga2", "accel": "kvm" }}
> 
> If you are returning information about an existing CPU, why not just
> extend the output of "query-cpus"?
> 
> (Existing qmp_query_cpus() calls cpu_synchronize_state(), which may be
> undesired. But in this case we could add an optional parameter to
> disable the return of data that requires stopping the VCPU).

Will the cpu_cpu_syncronize_state() really hurt in real life? query-cpus will 
be called only once
a while...

I will prepare the extension of query-cpus as an option but initially without 
the optional
parameter.

> 
> > 
> > Alias names are resolved to their respective machine type and GA names
> > already during cpu instantiation. Thus, also a cpu model like 'host'
> > which is implemented as alias will return its normalized cpu model name.
> > 
> > Furthermore the patch implements the following function:
> > 
> > - s390_cpu_models_used(), returns true if S390 cpu models are in use
> > 
> > Signed-off-by: Michael Mueller 
> [...]
> 

Thanks,
Michael


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] spi: xilinx: Use standard num-cs binding

2015-03-31 Thread Mark Brown
On Tue, Mar 31, 2015 at 10:16:57AM +0200, Michal Simek wrote:
> On 03/31/2015 07:47 AM, Mark Brown wrote:

> > num-cs *is* a software setting.

> ok - what to do with that? Remove it because it shouldn't be passed via DT?

Well, there's a lot of existing users to check and clean up some of
which currently rely on it which will take time to deal with.  Removing
it while some drivers rely on using it isn't ideal.


signature.asc
Description: Digital signature


[PATCH] x86/quark: Run IMR self-test on IMR capble hw only

2015-03-31 Thread Bryan O'Donoghue
Automated testing with LKP shows IMR self test code running and printing
error messages on QEMU hardware lacking IMR support.

Update IMR self-test code to run only when IMR hardware should be present.
Tested on Quark X1000 and QEMU.

Signed-off-by: Bryan O'Donoghue 
---
 arch/x86/platform/intel-quark/imr_selftest.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/x86/platform/intel-quark/imr_selftest.c 
b/arch/x86/platform/intel-quark/imr_selftest.c
index c9a0838..5e6c055 100644
--- a/arch/x86/platform/intel-quark/imr_selftest.c
+++ b/arch/x86/platform/intel-quark/imr_selftest.c
@@ -11,6 +11,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -101,6 +102,13 @@ static void __init imr_self_test(void)
}
 }
 
+static const struct x86_cpu_id imr_ids[] __initconst = {
+   { X86_VENDOR_INTEL, 5, 9 }, /* Intel Quark SoC X1000. */
+   {}
+};
+MODULE_DEVICE_TABLE(x86cpu, imr_ids);
+
+
 /**
  * imr_self_test_init - entry point for IMR driver.
  *
@@ -108,7 +116,8 @@ static void __init imr_self_test(void)
  */
 static int __init imr_self_test_init(void)
 {
-   imr_self_test();
+   if (x86_match_cpu(imr_ids))
+   imr_self_test();
return 0;
 }
 
-- 
1.9.1

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


[PATCH 1/2] iio: adc: ti_am335x_adc: refactor DT parsing into a function

2015-03-31 Thread Vignesh R
Refactor DT parsing into a separate function from probe() to
help addition of more DT parameters later.

No functional changes.

Signed-off-by: Vignesh R 
---
 drivers/iio/adc/ti_am335x_adc.c | 29 +++--
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index 2e5cc4409f78..2f818405ffbe 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -396,16 +396,30 @@ static const struct iio_info tiadc_info = {
.driver_module = THIS_MODULE,
 };
 
+static int tiadc_parse_dt(struct platform_device *pdev,
+ struct tiadc_device *adc_dev)
+{
+   struct device_node *node = pdev->dev.of_node;
+   struct property *prop;
+   const __be32 *cur;
+   int channels = 0;
+   u32 val;
+
+   of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) {
+   adc_dev->channel_line[channels] = val;
+   channels++;
+   }
+
+   adc_dev->channels = channels;
+   return 0;
+}
+
 static int tiadc_probe(struct platform_device *pdev)
 {
struct iio_dev  *indio_dev;
struct tiadc_device *adc_dev;
struct device_node  *node = pdev->dev.of_node;
-   struct property *prop;
-   const __be32*cur;
int err;
-   u32 val;
-   int channels = 0;
 
if (!node) {
dev_err(>dev, "Could not find valid DT data.\n");
@@ -421,12 +435,7 @@ static int tiadc_probe(struct platform_device *pdev)
adc_dev = iio_priv(indio_dev);
 
adc_dev->mfd_tscadc = ti_tscadc_dev_get(pdev);
-
-   of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) {
-   adc_dev->channel_line[channels] = val;
-   channels++;
-   }
-   adc_dev->channels = channels;
+   tiadc_parse_dt(pdev, adc_dev);
 
indio_dev->dev.parent = >dev;
indio_dev->name = dev_name(>dev);
-- 
1.9.1

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


[PATCH 2/2] iio: adc: ti_am335x_adc: make sample delay, open delay, averaging DT parameters

2015-03-31 Thread Vignesh R
Add optional DT properties to set open delay, sample delay and number
of averages per sample for each adc step. Open delay, sample delay
and averaging are some of the parameters that affect the sampling rate
and accuracy of the sample. Making these parameters configurable via
DT will help in balancing speed vs accuracy.

Signed-off-by: Vignesh R 
---
 .../bindings/input/touchscreen/ti-tsc-adc.txt  | 24 ++
 drivers/iio/adc/ti_am335x_adc.c| 54 +++---
 2 files changed, 72 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt 
b/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
index 6c4fb34823d3..8aafbe87f0eb 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
@@ -42,6 +42,27 @@ Optional properties:
 hardware knob for adjusting the amount of "settling
 time".
 
+- child "adc"
+   ti,chan-step-opendelay: List of open delays for each channel of
+   ADC in the order of ti,adc-channels. The
+   value corresponds to the number of ADC
+   clock cycles to wait after applying the
+   step configuration registers and before
+   sending the start of ADC conversion.
+   Maximum value is 0x3.
+   ti,chan-step-sampledelay: List of sample delays for each channel
+ of ADC in the order of ti,adc-channels.
+ The value corresponds to the number of
+ ADC clock cycles to sample (to hold
+ start of conversion high).
+ Maximum value is 0xFF.
+   ti,chan-step-avg: Number of averages to be performed for each
+ channel of ADC. If average is 16 then input
+ is sampled 16 times and averaged to get more
+ accurate value. This increases the time taken
+ by ADC to generate a sample. Valid range is 0
+ average to 16 averages. Maximum value is 16.
+
 Example:
tscadc: tscadc@44e0d000 {
compatible = "ti,am3359-tscadc";
@@ -55,5 +76,8 @@ Example:
 
adc {
ti,adc-channels = <4 5 6 7>;
+   ti,chan-step-opendelay = <0x098 0x3 0x098 0x0>;
+   ti,chan-step-sampledelay = <0xff 0x0 0xf 0x0>;
+   ti,chan-step-avg = <16 2 4 8>;
};
}
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index 2f818405ffbe..5ee597b4a1af 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -37,6 +37,7 @@ struct tiadc_device {
u8 channel_step[8];
int buffer_en_ch_steps;
u16 data[8];
+   u32 open_delay[8], sample_delay[8], step_avg[8];
 };
 
 static unsigned int tiadc_readl(struct tiadc_device *adc, unsigned int reg)
@@ -85,6 +86,7 @@ static u32 get_adc_step_bit(struct tiadc_device *adc_dev, int 
chan)
 static void tiadc_step_config(struct iio_dev *indio_dev)
 {
struct tiadc_device *adc_dev = iio_priv(indio_dev);
+   struct device *dev = adc_dev->mfd_tscadc->dev;
unsigned int stepconfig;
int i, steps = 0;
 
@@ -98,20 +100,47 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
 * needs to be given to ADC to digitalize data.
 */
 
-   if (iio_buffer_enabled(indio_dev))
-   stepconfig = STEPCONFIG_AVG_16 | STEPCONFIG_FIFO1
-   | STEPCONFIG_MODE_SWCNT;
-   else
-   stepconfig = STEPCONFIG_AVG_16 | STEPCONFIG_FIFO1;
 
for (i = 0; i < adc_dev->channels; i++) {
int chan;
 
chan = adc_dev->channel_line[i];
+
+   if (adc_dev->step_avg[i] > STEPCONFIG_AVG_16) {
+   dev_warn(dev, "chan %d step_avg truncating to %d\n",
+chan, STEPCONFIG_AVG_16);
+   adc_dev->step_avg[i] = STEPCONFIG_AVG_16;
+   }
+
+   if (adc_dev->step_avg[i])
+   stepconfig =
+   STEPCONFIG_AVG(ffs(adc_dev->step_avg[i]) - 1) |
+   STEPCONFIG_FIFO1;
+   else
+   stepconfig = STEPCONFIG_FIFO1;
+
+   if (iio_buffer_enabled(indio_dev))
+   stepconfig |= STEPCONFIG_MODE_SWCNT;
+
tiadc_writel(adc_dev, REG_STEPCONFIG(steps),
stepconfig | STEPCONFIG_INP(chan));
+
+   if (adc_dev->open_delay[i] > STEPDELAY_OPEN_MASK) {
+ 

[PATCH 0/2] iio: ti_am335x_adc: Add optional DT properties for tscadc

2015-03-31 Thread Vignesh R

Hi,

This patch adds optional DT properties for tscadc to set open delay,
sample delay and number of averages per sample for each adc channel.
Open delay, sample delay and averaging are some of the parameters that
affect the sampling rate and accuracy of the tscadc. Decreasing delays
and averaging helps to achieve higher sampling rates, while increasing
this parameters provides greater accuracy. Hence, this patch provides DT
properties to set the initial values for delays and number of averages
per sample. User space control via sysfs can be added later.


Vignesh R (2):
  iio: adc: ti_am335x_adc: refactor DT parsing into a function
  iio: adc: ti_am335x_adc: make sample delay, open delay, averaging DT
parameters

 .../bindings/input/touchscreen/ti-tsc-adc.txt  | 24 +++
 drivers/iio/adc/ti_am335x_adc.c| 83 +-
 2 files changed, 91 insertions(+), 16 deletions(-)

-- 
1.9.1

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


Re: [PATCH v2 1/2] spi: fsl-dspi: Fix clock rate scale values

2015-03-31 Thread Mark Brown
On Mon, Mar 30, 2015 at 10:49:15AM -0700, Aaron Brice wrote:
> Previous algorithm had an outer loop with the values {2,3,5,7} and an
> inner loop with {2,4,6,8,16,32,...,32768}, and would pick the first
> value over the required scaling value (where the total scale was the two
> numbers multiplied).

Applied, thanks.


signature.asc
Description: Digital signature


Re: [PATCH net-next] ethernet: Use bool function returns of true/false instead of 1/0

2015-03-31 Thread Michal Simek
On 03/30/2015 03:25 AM, Joe Perches wrote:
> Use bool constants as the return values instead of 1 and 0.
> 
> Signed-off-by: Joe Perches 
> ---
>> To be honest I'd might rather get bunches of these, there has to be a ton
>> of them, than a slow trickle of one every few weeks/days.
> 
> There aren't too many...
> 
>  drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 +-
>  drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 4 ++--
>  drivers/net/ethernet/xilinx/xilinx_emaclite.c| 2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c 
> b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
> index 039b0c1..9980912 100644
> --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
> +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
> @@ -11610,7 +11610,7 @@ static bool bnx2x_get_dropless_info(struct bnx2x *bp)
>   u32 cfg;
>  
>   if (IS_VF(bp))
> - return 0;
> + return false;
>  
>   if (IS_MF(bp) && !CHIP_IS_E1x(bp)) {
>   /* Take function: tmp = func */
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c 
> b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> index 02ffb30..ccaecb1 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> @@ -1351,7 +1351,7 @@ static bool reg_pattern_test(struct ixgbe_adapter 
> *adapter, u64 *data, int reg,
>  
>   if (ixgbe_removed(adapter->hw.hw_addr)) {
>   *data = 1;
> - return 1;
> + return true;
>   }
>   for (pat = 0; pat < ARRAY_SIZE(test_pattern); pat++) {
>   before = ixgbe_read_reg(>hw, reg);
> @@ -1376,7 +1376,7 @@ static bool reg_set_and_check(struct ixgbe_adapter 
> *adapter, u64 *data, int reg,
>  
>   if (ixgbe_removed(adapter->hw.hw_addr)) {
>   *data = 1;
> - return 1;
> + return true;
>   }
>   before = ixgbe_read_reg(>hw, reg);
>   ixgbe_write_reg(>hw, reg, write & mask);
> diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c 
> b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
> index 2111b91..6008eee 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
> +++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
> @@ -1062,7 +1062,7 @@ static bool get_bool(struct platform_device *ofdev, 
> const char *s)
>   } else {
>   dev_warn(>dev, "Parameter %s not found,"
>   "defaulting to false\n", s);
> - return 0;
> + return false;
>   }
>  }

Kernel-doc should be also fixed in spite of this whole function is just
broken and binding should be fixed to use of_property_read_bool for
these properties.

Thanks,
Michal

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform




signature.asc
Description: OpenPGP digital signature


Re: [PATCH v2 2/3] rtc: mediatek: Add MT6397 RTC driver

2015-03-31 Thread Tomasz Figa
Hi Eddie,

Please see my response inline.

On Tue, Mar 31, 2015 at 6:44 PM, Eddie Huang  wrote:

[snip]

>> > +   ret = mtk_rtc_read(rtc, RTC_BBPU, );
>> > +   if (ret < 0)
>> > +   goto exit;
>> > +
>> > +   while (data & RTC_BBPU_CBUSY) {
>> > +   cpu_relax();
>> > +   ret = mtk_rtc_read(rtc, RTC_BBPU, );
>> > +   if (ret < 0)
>> > +   goto exit;
>> > +   }
>>
>> The initial read and the loop could be folded into a do {} while loop?
>> Also it would be safer to have a timeout here.
> Because I need to check return value, so not put initial read in do { }.

Hmm, inside the loop you also check return value. Considering the fact
that cpu_relax() doesn't do anything interesting besides issuing a
memory barrier (and probably could be omitted here) I don't see why
this couldn't be made a do {} while loop. (Obviously this is a bit of
bikeshedding, but by the way of other changes this could be changed as
well.)

[snip]

>>
>> Also shouldn't the unused bits be masked out?
> Hardware return zero in unused bits. So I think it not necessary to add
> mask.
>

OK. Thanks for explaining this.

>>
>> > +
>> > +exit:
>> > +   mutex_unlock(>lock);
>> > +   return ret;
>> > +}
>> > +
>> > +static int mtk_rtc_read_time(struct device *dev, struct rtc_time *tm)
>> > +{
>> > +   time64_t time;
>> > +   struct mt6397_rtc *rtc = dev_get_drvdata(dev);
>> > +   int sec, ret;
>> > +
>> > +   do {
>> > +   ret = __mtk_rtc_read_time(rtc, tm, );
>> > +   if (ret < 0)
>> > +   goto exit;
>> > +   } while (sec < tm->tm_sec);
>>
>> Shouldn't this be while (sec > tm->tm_sec)?
> No, it should keep it as is, this is used to check whether second
> overflow (from 59 to 0). If yes, read time again.
>

Ah, right, of course, an overlooking on my side. Thanks for clarifying this.

[snip]

>> > +   mutex_lock(>lock);
>> > +   if (alm->enabled) {
>>
>> Is this possible that an alarm was already set? Is it okay to keep it
>> enabled while changing the alarm time to new one?
> It's ok because all alarm time register set to hardware after call
> mtk_rtc_write_trigger.
>

Fair enough. Thanks for explanation. Could you maybe add a comment
here saying that the new alarm setting will be committed after calling
mtk_rtc_write_trigger()?

[snip]

>> > +   res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
>> > +   rtc->irq = irq_create_mapping(mt6397_chip->irq_domain, res->start);
>> > +   if (rtc->irq <= 0)
>> > +   goto out_rtc;
>>
>> Just return an error code here directly. Which one is actually a good
>> question. Looks like existing code is using -EINVAL or -ENXIO. Any
>> ideas?
> I tend to use -EINVAL

SGTM.

[snip]

>> > +
>> > +out_rtc:
>> > +   rtc_device_unregister(rtc->rtc_dev);
>>
>> All references to this label are actually before rtc_device_register()
>> is even called. The proper thing to do here is to dispose the created
>> IRQ mapping.
> OK, will call irq_dispose_mapping and free_irq
>

OK, thanks. Please note that this will also mean changing
devm_request_threaded_irq() to normal request_threaded_irq().

Still, now as I think of it, I'm not sure if this driver is the right
place to call irq_create_mapping(). Instead, shouldn't the parent MFD
driver create the mapping and pass the final virtual IRQ number to
this driver through resources?

Lee, could you comment on this, please?

Best regards,
Tomasz
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 05/86] x86/gart: use uapi/linux/pci_ids.h directly

2015-03-31 Thread Michael S. Tsirkin
On Tue, Mar 31, 2015 at 11:51:06AM +0200, Ingo Molnar wrote:
> 
> * Michael S. Tsirkin  wrote:
> 
> > On Tue, Mar 31, 2015 at 10:34:45AM +0200, Ingo Molnar wrote:
> > > 
> > > * Michael S. Tsirkin  wrote:
> > > 
> > > > On Mon, Mar 30, 2015 at 07:29:36AM +0200, Ingo Molnar wrote:
> > > > > 
> > > > > * Michael S. Tsirkin  wrote:
> > > > > 
> > > > > > Header moved from linux/pci_ids.h to uapi/linux/pci_ids.h,
> > > > > > use the new header directly so we can drop
> > > > > > the wrapper in include/linux/pci_ids.h.
> > > > > > 
> > > > > > Signed-off-by: Michael S. Tsirkin 
> > > > > > ---
> > > > > >  arch/x86/kernel/aperture_64.c | 2 +-
> > > > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > > 
> > > > > > diff --git a/arch/x86/kernel/aperture_64.c 
> > > > > > b/arch/x86/kernel/aperture_64.c
> > > > > > index 76164e1..3b52a56 100644
> > > > > > --- a/arch/x86/kernel/aperture_64.c
> > > > > > +++ b/arch/x86/kernel/aperture_64.c
> > > > > > @@ -17,7 +17,7 @@
> > > > > >  #include 
> > > > > >  #include 
> > > > > >  #include 
> > > > > > -#include 
> > > > > > +#include 
> > > > > >  #include 
> > > > > >  #include 
> > > > > >  #include 
> > > > > > -- 
> > > > > > MST
> > > > > > 
> > > > > 
> > > > > NAK, it's absolutely ridiculous to send a 86 patches series for a 
> > > > > trivial change like this!
> > > > > 
> > > > > Just do the rename in a single patch and avoid the churn. Even if 
> > > > > there are conflicts, they are utmost trivial to fix up.
> > > > > 
> > > > > In fact the usual way to do such renames is to wait until the end of 
> > > > > -rc1, auto-generate it and send Linus the core patch with the trivial 
> > > > > renames straight away.
> > > > > 
> > > > > Thanks,
> > > > > 
> > > > >   Ingo
> > > > 
> > > > 
> > > > Unfortunately, vger mailing lists reject any email with more than 2k of
> > > > email headers.  This means if I do what you suggest I can't Cc all
> > > > maintainers for all affected files. [...]
> > > 
> > > You can Cc: linux-arch and lkml for tree-wide changes.
> > > 
> > > Also, since it's mostly trivial, there shouldn't be much (if any) 
> > > controversy about it, right?
> > 
> > I thought so, too. However, I was just proven wrong and the patchset 
> > was nacked. [...]
> 
> Well, I only NAK-ed its high-churn presentation, not the essence of it 
> which looks good to me.

Thanks! Another concern voiced was whether it's better to include uapi
files using #include  or #include .  Both
work - I thought #include  makes it easier to figure
out where the file is. James Bottomley (Cc'd) thought it's not worth the code
churn however, since if we ever add a file under linux/foo.h we'd need
to change users back.  He also noted that many headers are referenced
without the uapi/ prefix, if making the change, we'd have to change
them all.

OTOH if not, maybe we want to drop all '#include '
converting them to '#include ' (and same for asm),
except where it's linux/foo.h pulling in uapi/linux/foo.h.
That, at least, would make it all consistent.



> > [...] Would relevant people notice it if it's just linux-arch? IIUC 
> > most people don't read lkml.  I guess Linus would notice and reject 
> > it.
> 
> Just keep it in a clean, separate topic branch and point it out in the 
> pull request - there's no reason to reject good changes, plus with 
> this structure:
> 
> > > > [...]  I could just Cc all mailing lists I guess, but I really 
> > > > wasn't sure about some parts of the change, deferring it until end 
> > > > of -rc1 wouldn't be appropriate in this case, would it?
> > > 
> > > So since 90% of the patches are just a trivial:
> > > 
> > >   -#include 
> > >   +#include 
> > > 
> > > you can auto-generate that simple rename and file movement into a 
> > > single commit, at the end of -rc1, without affecting anyone, via 
> > > something like:
> > > 
> > >   sed -i 's/linux\/pci_ids.h/uapi\/linux\/pci_ids.h/g' $(git grep -l 
> > > linux/pci_ids.h)
> > >   git mv include/linux/pci_ids.h include/uapi/linux/pci_ids.h
> > >   git commit -a
> > > 
> > > (totally untested)
> > > 
> > > This should just work.
> > >
> > > Any other changes, as the removal of inclusions from files that 
> > > apparently don't need it, or cleanups like the changing of the guard 
> > > defines in pci_id.h, can be done on top of that - on a one patch per 
> > > change basis.
> > > 
> > > This should drastically remove the churn.
> 
> it's trivially correct.
> 
> I just tried the untested script above and it generates a commit and a 
> kernel that builds just fine.
> 
> So with that structure my high-churn complaint gets addressed and my 
> NAK turns into:
> 
>   Acked-by: Ingo Molnar 
> 
> Thanks,
> 
>   Ingo


If people agree one of the two changes (always, or never, referencing
uapi files directly) is worthwhile, I'll follow the procedure
you have outlined above.
Thanks a lot for the suggestions!

-- 
MST
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

Re: [PATCH v2 0/4] x86: pmc_atom: Add Cherrytrail support

2015-03-31 Thread Ingo Molnar

* Shevchenko, Andriy  wrote:

> On Mon, 2015-02-23 at 14:45 +0200, Andy Shevchenko wrote:
> > On Tue, 2015-01-20 at 23:49 +0200, Andy Shevchenko wrote:
> > > This is the reworked patch series which had been sent earlier [1] to 
> > > support
> > > Intel CherryTrail SoC.
> > > 
> > > The patches were tested on both BayTrail and CherryTrail SoCs.
> > > 
> > > [1] https://patchwork.kernel.org/patch/5235891/
> > 
> > Aubrey, is everything is clear for you now? Can I send v3 with your
> > Ack's?
> 
> So, what is the status of the review then? Do I have anything to
> improve / comment?

So the last review pass pointed out a few minor problems (and also 
generated a few acks), please propagate those into the series and 
resend the latestest so I can have a fresh look.

Thanks,

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


Re: [PATCH v2] MIPS: IP32: Add platform data hooks to use DS1685 driver

2015-03-31 Thread Ralf Baechle
On Thu, Feb 26, 2015 at 09:23:50PM -0500, Joshua Kinard wrote:

> This modifies the IP32 (SGI O2) platform and reset code to utilize the new
> rtc-ds1685 driver.  The old mc146818rtc.h header is removed and ip32_defconfig
> is updated as well.

In general - good cleanup.  But:

> index 511e9ff..ec9eb7f 100644
> --- a/arch/mips/sgi-ip32/ip32-platform.c
> +++ b/arch/mips/sgi-ip32/ip32-platform.c
[...]
>  MODULE_AUTHOR("Ralf Baechle ");
>  MODULE_LICENSE("GPL");
> -MODULE_DESCRIPTION("8250 UART probe driver for SGI IP32 aka O2");
> +MODULE_DESCRIPTION("IP32 platform setup for SGI IP32 aka O2");

This isn't even a kernel module so I've just nuked all these MODULE_*
calls.

> diff --git a/arch/mips/sgi-ip32/ip32-reset.c b/arch/mips/sgi-ip32/ip32-reset.c
> index 44b3470..ef21706 100644
> --- a/arch/mips/sgi-ip32/ip32-reset.c
> +++ b/arch/mips/sgi-ip32/ip32-reset.c
[...]
> -static void ip32_machine_restart(char *cmd)
> +static __noreturn void ip32_poweroff(void *data)
>  {
> - crime->control = CRIME_CONTROL_HARD_RESET;
> - while (1);
> -}
> + void (*poweroff_func)(struct platform_device *) =
> + symbol_get(ds1685_rtc_poweroff);
> +
> +#ifdef CONFIG_MODULES
> + /* If the first __symbol_get failed, our module wasn't loaded. */
> + if (!poweroff_func) {
> + request_module("rtc-ds1685");
> + poweroff_func = symbol_get(ds1685_rtc_poweroff);
> + }
> +#endif

symbol_get() calls are high on my list of items that indicate a piece of
code is probably ill-structured.

While RTCs often deal with power the RTC really only wants to deal with
time and so power stuff should rather go elsewhere.  I suggest to take a
look at drivers/power/reset/.  A small driver there could set pm_power_off
approriately.  drivers/power/reset/restart-poweroff.c is a very compact
example.

> - shuting_down = 1;
> + shutting_down = 1;

I'm amazed nobody of the church of speel patchology has caught this earlier.

> @@ -190,15 +141,12 @@ static __init int ip32_reboot_setup(void)
>  
>   _machine_restart = ip32_machine_restart;
>   _machine_halt = ip32_machine_halt;
> - pm_power_off = ip32_machine_power_off;
> + pm_power_off = ip32_machine_halt;

So halt and power_off no do the same?

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


[debug PATCHes] Re: smp_call_function_single lockups

2015-03-31 Thread Ingo Molnar

* Linus Torvalds  wrote:

> Ok, interesting. So the whole "we try to do an APIC ACK with the ISR 
> bit clear" seems to be a real issue.

It's interesting in particular when it happens with an edge-triggered 
interrupt source: it's much harder to miss level triggered IRQs, which 
stay around until actively handled. Edge triggered irqs are more 
fragile to loss of event processing.

> > Anyway, maybe this sheds some more light on this issue. I can 
> > reproduce this at will, so let me know of other experiments to do.

Btw., could you please describe (again) what your current best method 
for reproduction is? It's been a long discussion ...

> Somebody else who knows the apic needs to also take a look, but I'd 
> love to hear what the actual hardware interrupt is (from that 
> "vector_irq[vector]" thing above.
> 
> I'm not recognizing 0xe1 as any of the hardcoded SMP vectors (they 
> are 0xf0-0xff), so it sounds like an external one. But that then 
> requires the whole mapping table thing.
> 
> Ingo/Peter/Jiang - is there anything else useful we could print out? 
> I worry about the irq movement code. Can we add printk's to when an 
> irq is chasing from one CPU to another and doing that 
> "move_in_progress" thing? I've always been scared of that code.

1)

So the irq_cfg::move_in_progress field originates from:

  610142927b5b ("[PATCH] x86_64 irq: Safely cleanup an irq after moving it.")

and I agree that it looks fragile, so it would be nice to see how much 
(if at all?) it gets used, by sticking a few pr_info()s in it.

Debug patch for the vector movement state machine attached below. 
Untested.

2)

But ... having taken a quick look at the vector movement handling, I 
am scared more than ever,and I cannot convince myself that it's race 
free. It's possibly harmless, but still, famous last words ...

For example, most ->move_in_progress transitions happen with the 
vector_lock held - with the exception of send_cleanup_vector(): there 
we are only holding the desc->lock, but that's not enough! For 
example, this codepath:

static void __irq_complete_move(struct irq_cfg *cfg, unsigned vector)
{
unsigned me;

if (likely(!cfg->move_in_progress))
return;

me = smp_processor_id();

if (vector == cfg->vector && cpumask_test_cpu(me, cfg->domain))
send_cleanup_vector(cfg);

...

void send_cleanup_vector(struct irq_cfg *cfg)
{
...

cfg->move_in_progress = 0;
}

is blatantly racy, unless I missed something obvious?

2b)

Initially I thought this only affects slowpaths like driver unregister 
or CPU hotplug, but I think this would be relevant for the fastpath of 
edge triggered irqs as well:

void apic_ack_edge(struct irq_data *data)
{
irq_complete_move(irqd_cfg(data));
irq_move_irq(data);
ack_APIC_irq();
}

and irq_complete_move() checks and clears cfg->move_in_progress as 
listed above.

So in most scenarios this is probably harmless, because it can in the 
worst case result in the missing of a ->move_in_progress flag setting.

But it does not look harmless in the apic_set_affinity() code path: 
there we call into assign_irq_vector() without the desc->lock held, 
due to this gem in the IRQ core:

int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
{
unsigned long flags;
struct irq_desc *desc = irq_get_desc_lock(irq, , 
IRQ_GET_DESC_CHECK_GLOBAL);

if (!desc)
return -EINVAL;
desc->affinity_hint = m;
irq_put_desc_unlock(desc, flags);
/* set the initial affinity to prevent every interrupt being on CPU0 */
if (m)
__irq_set_affinity(irq, m, false);
return 0;
}

argh!

Now if this ever crosses path with an assign_irq_vector() call on 
another CPU, then I really cannot see what would save us from deep 
trouble: we use cfg->vector while that is possibly being modified, 
right?

So I'd suggest to put a printk into irq_set_affinity_hint() as well, 
to make sure it's not used during this test. In particular:

drivers/virtio/virtio_pci_common.c: 
irq_set_affinity_hint(irq, NULL);
drivers/virtio/virtio_pci_common.c: 
irq_set_affinity_hint(irq, mask);

might be triggering it in the virtualization code...

The second patch below adds the relevant pr_info(). (untested)

Now this too might be unrelated, because the affinity hint was added 
ages ago, in:

e7a297b0d7d6 ("genirq: Add CPU mask affinity hint")

and the potentially racy nature of calling into set_affinity without 
the desc lock held was probably not realized back then.

VirtIO's use of the affinity-hint was added a while ago as well, four 
years ago, in:

  75a0a52be3c2 ("virtio: introduce an API to set affinity for a virtqueue")

2c)

The other thing that worries me here is that we apparently send an 
IRQ-move IPI while having an un-acked local APIC (!). I have vague 
memories that this was problematic and fragile 

Re: [RFC/RFT, RESEND] powerpc: move cacheinfo sysfs to generic cacheinfo infrastructure

2015-03-31 Thread Michael Ellerman
On Mon, 2015-23-02 at 18:18:20 UTC, Sudeep Holla wrote:
> This patch removes the redundant sysfs cacheinfo code by reusing
> the newly introduced generic cacheinfo infrastructure through the
> commit 246246cbde5e ("drivers: base: support cpu cache information
> interface to userspace via sysfs")
> 
> Signed-off-by: Sudeep Holla 
> Cc: Benjamin Herrenschmidt 
> Cc: Paul Mackerras 
> Cc: Michael Ellerman 
> Cc: Anshuman Khandual 
> Cc: linuxppc-...@lists.ozlabs.org
> ---
>  arch/powerpc/kernel/cacheinfo.c | 811 
> +---
>  arch/powerpc/kernel/cacheinfo.h |   8 -
>  arch/powerpc/kernel/sysfs.c |  12 +-
>  3 files changed, 91 insertions(+), 740 deletions(-)
>  delete mode 100644 arch/powerpc/kernel/cacheinfo.h
> 
> Hi,
> 
> This patch is not tested. Last time Anshuman tested, he had seen issues.
> The core driver has changed a lot after that. Since PPC depends a lot
> on DT for cache information, there might be issues in the core later
> which I could not identify with ARM/ARM64. It would be much appreciable
> if someone help me in testing and fixing those so that PPC can migrate
> to new/common cacheinfo infrastructure. This resend is rebased on v4.0-rc1

Doesn't build for me.

  arch/powerpc/platforms/pseries/suspend.c:29:36: fatal error: 
../../kernel/cacheinfo.h: No such file or directory
  #include "../../kernel/cacheinfo.h"

Anshuman must have worked around that somehow to test it previously?

Removing the include doesn't fix it, it needs cacheinfo_cpu_on/offline().

cheers
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] perf tools: unify perf_event_attr printing

2015-03-31 Thread Peter Zijlstra
On Tue, Mar 31, 2015 at 10:19:55AM +0200, Peter Zijlstra wrote:
> Fwiw, having 3 incomplete ways to print perf_event_attr() is
> disgusting.

How about something like so? Its not identical, but at least its
complete and consistent.

---
 tools/perf/util/print_attr.h |   69 +++
 tools/perf/util/print_helper.c   |   52 +++
 tools/perf/util/print_helper.h   |7 +
 tools/perf/util/Build|1 
 tools/perf/util/evsel.c  |  178 +--
 tools/perf/util/header.c |   34 ++-
 6 files changed, 167 insertions(+), 174 deletions(-)

--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -74,6 +74,7 @@ libperf-y += data.o
 libperf-$(CONFIG_X86) += tsc.o
 libperf-y += cloexec.o
 libperf-y += thread-stack.o
+libperf-y += print_helper.o
 
 libperf-$(CONFIG_LIBELF) += symbol-elf.o
 libperf-$(CONFIG_LIBELF) += probe-event.o
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -26,6 +26,7 @@
 #include "perf_regs.h"
 #include "debug.h"
 #include "trace-event.h"
+#include "print_helper.h"
 
 static struct {
bool sample_id_all;
@@ -1011,21 +1012,6 @@ static int get_group_fd(struct perf_evse
return fd;
 }
 
-#define __PRINT_ATTR(fmt, cast, field)  \
-   fprintf(fp, "  %-19s "fmt"\n", #field, cast attr->field)
-
-#define PRINT_ATTR_U32(field)  __PRINT_ATTR("%u" , , field)
-#define PRINT_ATTR_X32(field)  __PRINT_ATTR("%#x", , field)
-#define PRINT_ATTR_U64(field)  __PRINT_ATTR("%" PRIu64, (uint64_t), field)
-#define PRINT_ATTR_X64(field)  __PRINT_ATTR("%#"PRIx64, (uint64_t), field)
-
-#define PRINT_ATTR2N(name1, field1, name2, field2) \
-   fprintf(fp, "  %-19s %u%-19s %u\n", \
-   name1, attr->field1, name2, attr->field2)
-
-#define PRINT_ATTR2(field1, field2) \
-   PRINT_ATTR2N(#field1, field1, #field2, field2)
-
 static size_t perf_event_attr__fprintf(struct perf_event_attr *attr, FILE *fp)
 {
size_t ret = 0;
@@ -1033,42 +1019,15 @@ static size_t perf_event_attr__fprintf(s
ret += fprintf(fp, "%.60s\n", graph_dotted_line);
ret += fprintf(fp, "perf_event_attr:\n");
 
-   ret += PRINT_ATTR_U32(type);
-   ret += PRINT_ATTR_U32(size);
-   ret += PRINT_ATTR_X64(config);
-   ret += PRINT_ATTR_U64(sample_period);
-   ret += PRINT_ATTR_U64(sample_freq);
-   ret += PRINT_ATTR_X64(sample_type);
-   ret += PRINT_ATTR_X64(read_format);
-
-   ret += PRINT_ATTR2(disabled, inherit);
-   ret += PRINT_ATTR2(pinned, exclusive);
-   ret += PRINT_ATTR2(exclude_user, exclude_kernel);
-   ret += PRINT_ATTR2(exclude_hv, exclude_idle);
-   ret += PRINT_ATTR2(mmap, comm);
-   ret += PRINT_ATTR2(freq, inherit_stat);
-   ret += PRINT_ATTR2(enable_on_exec, task);
-   ret += PRINT_ATTR2(watermark, precise_ip);
-   ret += PRINT_ATTR2(mmap_data, sample_id_all);
-   ret += PRINT_ATTR2(exclude_host, exclude_guest);
-   ret += PRINT_ATTR2N("excl.callchain_kern", exclude_callchain_kernel,
-   "excl.callchain_user", exclude_callchain_user);
-   ret += PRINT_ATTR2(mmap2, comm_exec);
-   ret += __PRINT_ATTR("%u",,use_clockid);
-
-
-   ret += PRINT_ATTR_U32(wakeup_events);
-   ret += PRINT_ATTR_U32(wakeup_watermark);
-   ret += PRINT_ATTR_X32(bp_type);
-   ret += PRINT_ATTR_X64(bp_addr);
-   ret += PRINT_ATTR_X64(config1);
-   ret += PRINT_ATTR_U64(bp_len);
-   ret += PRINT_ATTR_X64(config2);
-   ret += PRINT_ATTR_X64(branch_sample_type);
-   ret += PRINT_ATTR_X64(sample_regs_user);
-   ret += PRINT_ATTR_U32(sample_stack_user);
-   ret += PRINT_ATTR_U32(clockid);
-   ret += PRINT_ATTR_X64(sample_regs_intr);
+#define PRINT_ATTR(_n, _f, _p) \
+do {   \
+   ret += fprintf(fp, "  %-19s ", _n); \
+   ret += _p(fp, attr->_f);\
+} while (0)
+
+#include "util/print_attr.h"
+
+#undef PRINT_ATTR
 
ret += fprintf(fp, "%.60s\n", graph_dotted_line);
 
@@ -1996,64 +1955,6 @@ static int comma_fprintf(FILE *fp, bool
return ret;
 }
 
-static int __if_fprintf(FILE *fp, bool *first, const char *field, u64 value)
-{
-   if (value == 0)
-   return 0;
-
-   return comma_fprintf(fp, first, " %s: %" PRIu64, field, value);
-}
-
-#define if_print(field) printed += __if_fprintf(fp, , #field, 
evsel->attr.field)
-
-struct bit_names {
-   int bit;
-   const char *name;
-};
-
-static int bits__fprintf(FILE *fp, const char *field, u64 value,
-struct bit_names *bits, bool *first)
-{
-   int i = 0, printed = comma_fprintf(fp, first, " %s: ", field);
-   bool first_bit = true;
-
-   do {
-   if (value & bits[i].bit) {
-   printed += fprintf(fp, "%s%s", first_bit ? "" : "|", 
bits[i].name);
-   first_bit = false;
-   }
-   } while (bits[++i].name != 

Re: [PATCH 1/4] ARM: multi_v7_defconfig: Enable Tegra ACTMON support

2015-03-31 Thread Marcel Ziswiler
On Mon, 2015-03-30 at 16:40 +0200, Tomeu Vizoso wrote:
> This brings the DevFreq framework in and builds the ACTMON driver that
> on Tegra124 will scale the external memory clock based on current load.
> 
> Signed-off-by: Tomeu Vizoso 

The series,
Acked-by: Marcel Ziswiler 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 0/2] Add support for Lite On LTR559 sensor

2015-03-31 Thread Daniel Baluta
First patch does some cleanups in order to make alignment style
consistent with the rest of IIO drivers. Then second patch adds
support for Lite On LTR559 ambient light and proximity sensor.

This is a RFC because the code is compile tested only. The 
chip should arrive in a few days.

Daniel Baluta (2):
  iio: light: ltr501: Fix alignment to match open parenthesis
  iio: light: Add support for LTR559 chip

 drivers/iio/light/ltr501.c | 240 +++--
 1 file changed, 187 insertions(+), 53 deletions(-)

-- 
1.9.1

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


[RFC PATCH 2/2] iio: light: Add support for LTR559 chip

2015-03-31 Thread Daniel Baluta
This device is register compatible with LTR501, with a minor difference for
ALS control register as showed below:

ALS Control register for LTR501:

7  6  5  4  3  2  1  0
+--+--+--+--+--+--+--+--+
|   |  |  | |
|Reserved   | Gain |  SW  |ALS Mode |
|   |  | Reset| |
+--+--+--+--+--+--+--+--+

ALS Control register for LTR559:

7  6  5  4  3  2  1  0
+--+--+--+--+--+--+--+--+
|||  |  |
| Reserved   |Gain|  SW  | ALS  |
||| Reset| Mode |
+--+--+--+--+--+--+--+--+

We handle this difference by introducing ltr501_chip_info.

Datasheet for LTR559 is at:
http://optoelectronics.liteon.com/upload/download/DS86-2013-0003/S_110_LTR-559ALS-01_DS_V1.pdf

Signed-off-by: Daniel Baluta 
---
 drivers/iio/light/ltr501.c | 196 +
 1 file changed, 163 insertions(+), 33 deletions(-)

diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
index 883855a..5939cda 100644
--- a/drivers/iio/light/ltr501.c
+++ b/drivers/iio/light/ltr501.c
@@ -45,12 +45,89 @@
 
 #define LTR501_PS_DATA_MASK 0x7ff
 
+#define LTR501_RESERVED_GAIN -1
+
+enum {
+   ltr501 = 0,
+   ltr559,
+};
+
+struct ltr501_gain {
+   int scale;
+   int uscale;
+};
+
+static struct ltr501_gain ltr501_als_gain_tbl[] = {
+   {1, 0},
+   {0, 5000},
+};
+
+static struct ltr501_gain ltr559_als_gain_tbl[] = {
+   {1, 0},
+   {0, 50},
+   {0, 25},
+   {0, 125000},
+   {LTR501_RESERVED_GAIN, LTR501_RESERVED_GAIN},
+   {LTR501_RESERVED_GAIN, LTR501_RESERVED_GAIN},
+   {0, 2},
+   {0, 1},
+};
+
+static struct ltr501_gain ltr501_ps_gain_tbl[] = {
+   {1, 0},
+   {0, 25},
+   {0, 125000},
+   {0, 62500},
+};
+
+static struct ltr501_gain ltr559_ps_gain_tbl[] = {
+   {0, 62500}, /* x16 gain */
+   {0, 31250}, /* x32 gain */
+   {0, 15625}, /* bits X1 are for x64 gain */
+   {0, 15624},
+};
+
+struct ltr501_chip_info {
+   u8 chip_id;
+   struct ltr501_gain *als_gain;
+   int als_gain_tbl_size;
+   struct ltr501_gain *ps_gain;
+   int ps_gain_tbl_size;
+   u8 als_mode_active;
+   u8 als_gain_mask;
+   u8 als_gain_shift;
+};
+
 struct ltr501_data {
struct i2c_client *client;
struct mutex lock_als, lock_ps;
+   struct ltr501_chip_info *chip_info;
u8 als_contr, ps_contr;
 };
 
+static struct ltr501_chip_info ltr501_chip_info_tbl[] = {
+   [ltr501] = {
+   .chip_id = 0x08,
+   .als_gain = ltr501_als_gain_tbl,
+   .als_gain_tbl_size = ARRAY_SIZE(ltr501_als_gain_tbl),
+   .ps_gain = ltr501_ps_gain_tbl,
+   .ps_gain_tbl_size = ARRAY_SIZE(ltr501_ps_gain_tbl),
+   .als_mode_active = BIT(0) | BIT(1),
+   .als_gain_mask = BIT(3),
+   .als_gain_shift = 3,
+   },
+   [ltr559] = {
+   .chip_id = 0x09,
+   .als_gain = ltr559_als_gain_tbl,
+   .als_gain_tbl_size = ARRAY_SIZE(ltr559_als_gain_tbl),
+   .ps_gain = ltr559_ps_gain_tbl,
+   .ps_gain_tbl_size = ARRAY_SIZE(ltr559_ps_gain_tbl),
+   .als_mode_active = BIT(1),
+   .als_gain_mask = BIT(2) | BIT(3) | BIT(4),
+   .als_gain_shift = 2,
+   },
+};
+
 static int ltr501_drdy(struct ltr501_data *data, u8 drdy_mask)
 {
int tries = 100;
@@ -125,10 +202,6 @@ static const struct iio_chan_spec ltr501_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(3),
 };
 
-static const int ltr501_ps_gain[4][2] = {
-   {1, 0}, {0, 25}, {0, 125000}, {0, 62500}
-};
-
 static int ltr501_read_raw(struct iio_dev *indio_dev,
   struct iio_chan_spec const *chan,
   int *val, int *val2, long mask)
@@ -166,20 +239,16 @@ static int ltr501_read_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_SCALE:
switch (chan->type) {
case IIO_INTENSITY:
-   if (data->als_contr & LTR501_CONTR_ALS_GAIN_MASK) {
-   *val = 0;
-   *val2 = 5000;
-   return IIO_VAL_INT_PLUS_MICRO;
-   } else {
-   *val = 1;
-   *val2 = 0;
-   return IIO_VAL_INT;
-   }
+   i = (data->als_contr & data->chip_info->als_gain_mask) 
>>
+   data->chip_info->als_gain_shift;
+   *val = 

[RFC PATCH 1/2] iio: light: ltr501: Fix alignment to match open parenthesis

2015-03-31 Thread Daniel Baluta
This makes ltr501 code consistent with the coding style adopted
for the new drivers added to IIO.
We prepare the path for adding support for LTR559 chip.

Reported by checkpatch.pl

Signed-off-by: Daniel Baluta 
---
 drivers/iio/light/ltr501.c | 46 +-
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
index 62b7072..883855a 100644
--- a/drivers/iio/light/ltr501.c
+++ b/drivers/iio/light/ltr501.c
@@ -58,7 +58,7 @@ static int ltr501_drdy(struct ltr501_data *data, u8 drdy_mask)
 
while (tries--) {
ret = i2c_smbus_read_byte_data(data->client,
-   LTR501_ALS_PS_STATUS);
+  LTR501_ALS_PS_STATUS);
if (ret < 0)
return ret;
if ((ret & drdy_mask) == drdy_mask)
@@ -77,7 +77,8 @@ static int ltr501_read_als(struct ltr501_data *data, __le16 
buf[2])
return ret;
/* always read both ALS channels in given order */
return i2c_smbus_read_i2c_block_data(data->client,
-   LTR501_ALS_DATA1, 2 * sizeof(__le16), (u8 *) buf);
+LTR501_ALS_DATA1,
+2 * sizeof(__le16), (u8 *)buf);
 }
 
 static int ltr501_read_ps(struct ltr501_data *data)
@@ -107,7 +108,7 @@ static int ltr501_read_ps(struct ltr501_data *data)
 static const struct iio_chan_spec ltr501_channels[] = {
LTR501_INTENSITY_CHANNEL(0, LTR501_ALS_DATA0, IIO_MOD_LIGHT_BOTH, 0),
LTR501_INTENSITY_CHANNEL(1, LTR501_ALS_DATA1, IIO_MOD_LIGHT_IR,
-   BIT(IIO_CHAN_INFO_SCALE)),
+BIT(IIO_CHAN_INFO_SCALE)),
{
.type = IIO_PROXIMITY,
.address = LTR501_PS_DATA,
@@ -129,8 +130,8 @@ static const int ltr501_ps_gain[4][2] = {
 };
 
 static int ltr501_read_raw(struct iio_dev *indio_dev,
-   struct iio_chan_spec const *chan,
-   int *val, int *val2, long mask)
+  struct iio_chan_spec const *chan,
+  int *val, int *val2, long mask)
 {
struct ltr501_data *data = iio_priv(indio_dev);
__le16 buf[2];
@@ -149,7 +150,7 @@ static int ltr501_read_raw(struct iio_dev *indio_dev,
if (ret < 0)
return ret;
*val = le16_to_cpu(chan->address == LTR501_ALS_DATA1 ?
-   buf[0] : buf[1]);
+  buf[0] : buf[1]);
return IIO_VAL_INT;
case IIO_PROXIMITY:
mutex_lock(>lock_ps);
@@ -199,8 +200,8 @@ static int ltr501_get_ps_gain_index(int val, int val2)
 }
 
 static int ltr501_write_raw(struct iio_dev *indio_dev,
-  struct iio_chan_spec const *chan,
-  int val, int val2, long mask)
+   struct iio_chan_spec const *chan,
+   int val, int val2, long mask)
 {
struct ltr501_data *data = iio_priv(indio_dev);
int i;
@@ -219,7 +220,8 @@ static int ltr501_write_raw(struct iio_dev *indio_dev,
else
return -EINVAL;
return i2c_smbus_write_byte_data(data->client,
-   LTR501_ALS_CONTR, data->als_contr);
+LTR501_ALS_CONTR,
+data->als_contr);
case IIO_PROXIMITY:
i = ltr501_get_ps_gain_index(val, val2);
if (i < 0)
@@ -227,7 +229,8 @@ static int ltr501_write_raw(struct iio_dev *indio_dev,
data->ps_contr &= ~LTR501_CONTR_PS_GAIN_MASK;
data->ps_contr |= i << LTR501_CONTR_PS_GAIN_SHIFT;
return i2c_smbus_write_byte_data(data->client,
-   LTR501_PS_CONTR, data->ps_contr);
+LTR501_PS_CONTR,
+data->ps_contr);
default:
return -EINVAL;
}
@@ -279,7 +282,7 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p)
 
/* figure out which data needs to be ready */
if (test_bit(0, indio_dev->active_scan_mask) ||
-   test_bit(1, indio_dev->active_scan_mask))
+   test_bit(1, indio_dev->active_scan_mask))
mask |= LTR501_STATUS_ALS_RDY;
if (test_bit(2, indio_dev->active_scan_mask))
mask |= LTR501_STATUS_PS_RDY;
@@ -290,7 +293,9 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p)
 
if (mask & 

[RFC PATCH 1/2] iio: light: ltr501: Fix alignment to match open parenthesis

2015-03-31 Thread Daniel Baluta
This makes ltr501 code consistent with the coding style adopted
for the new drivers added to IIO.
We prepare the path for adding support for LTR559 chip.

Reported by checkpatch.pl

Signed-off-by: Daniel Baluta 
---
 drivers/iio/light/ltr501.c | 46 +-
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
index 62b7072..883855a 100644
--- a/drivers/iio/light/ltr501.c
+++ b/drivers/iio/light/ltr501.c
@@ -58,7 +58,7 @@ static int ltr501_drdy(struct ltr501_data *data, u8 drdy_mask)
 
while (tries--) {
ret = i2c_smbus_read_byte_data(data->client,
-   LTR501_ALS_PS_STATUS);
+  LTR501_ALS_PS_STATUS);
if (ret < 0)
return ret;
if ((ret & drdy_mask) == drdy_mask)
@@ -77,7 +77,8 @@ static int ltr501_read_als(struct ltr501_data *data, __le16 
buf[2])
return ret;
/* always read both ALS channels in given order */
return i2c_smbus_read_i2c_block_data(data->client,
-   LTR501_ALS_DATA1, 2 * sizeof(__le16), (u8 *) buf);
+LTR501_ALS_DATA1,
+2 * sizeof(__le16), (u8 *)buf);
 }
 
 static int ltr501_read_ps(struct ltr501_data *data)
@@ -107,7 +108,7 @@ static int ltr501_read_ps(struct ltr501_data *data)
 static const struct iio_chan_spec ltr501_channels[] = {
LTR501_INTENSITY_CHANNEL(0, LTR501_ALS_DATA0, IIO_MOD_LIGHT_BOTH, 0),
LTR501_INTENSITY_CHANNEL(1, LTR501_ALS_DATA1, IIO_MOD_LIGHT_IR,
-   BIT(IIO_CHAN_INFO_SCALE)),
+BIT(IIO_CHAN_INFO_SCALE)),
{
.type = IIO_PROXIMITY,
.address = LTR501_PS_DATA,
@@ -129,8 +130,8 @@ static const int ltr501_ps_gain[4][2] = {
 };
 
 static int ltr501_read_raw(struct iio_dev *indio_dev,
-   struct iio_chan_spec const *chan,
-   int *val, int *val2, long mask)
+  struct iio_chan_spec const *chan,
+  int *val, int *val2, long mask)
 {
struct ltr501_data *data = iio_priv(indio_dev);
__le16 buf[2];
@@ -149,7 +150,7 @@ static int ltr501_read_raw(struct iio_dev *indio_dev,
if (ret < 0)
return ret;
*val = le16_to_cpu(chan->address == LTR501_ALS_DATA1 ?
-   buf[0] : buf[1]);
+  buf[0] : buf[1]);
return IIO_VAL_INT;
case IIO_PROXIMITY:
mutex_lock(>lock_ps);
@@ -199,8 +200,8 @@ static int ltr501_get_ps_gain_index(int val, int val2)
 }
 
 static int ltr501_write_raw(struct iio_dev *indio_dev,
-  struct iio_chan_spec const *chan,
-  int val, int val2, long mask)
+   struct iio_chan_spec const *chan,
+   int val, int val2, long mask)
 {
struct ltr501_data *data = iio_priv(indio_dev);
int i;
@@ -219,7 +220,8 @@ static int ltr501_write_raw(struct iio_dev *indio_dev,
else
return -EINVAL;
return i2c_smbus_write_byte_data(data->client,
-   LTR501_ALS_CONTR, data->als_contr);
+LTR501_ALS_CONTR,
+data->als_contr);
case IIO_PROXIMITY:
i = ltr501_get_ps_gain_index(val, val2);
if (i < 0)
@@ -227,7 +229,8 @@ static int ltr501_write_raw(struct iio_dev *indio_dev,
data->ps_contr &= ~LTR501_CONTR_PS_GAIN_MASK;
data->ps_contr |= i << LTR501_CONTR_PS_GAIN_SHIFT;
return i2c_smbus_write_byte_data(data->client,
-   LTR501_PS_CONTR, data->ps_contr);
+LTR501_PS_CONTR,
+data->ps_contr);
default:
return -EINVAL;
}
@@ -279,7 +282,7 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p)
 
/* figure out which data needs to be ready */
if (test_bit(0, indio_dev->active_scan_mask) ||
-   test_bit(1, indio_dev->active_scan_mask))
+   test_bit(1, indio_dev->active_scan_mask))
mask |= LTR501_STATUS_ALS_RDY;
if (test_bit(2, indio_dev->active_scan_mask))
mask |= LTR501_STATUS_PS_RDY;
@@ -290,7 +293,9 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p)
 
if (mask & 

[PATCH 6/5] x86/asm/entry/64: tidy up some instructions

2015-03-31 Thread Denys Vlasenko
Tidy up TEST insns width to use shorter insn form,
Use logically correct JZ mnemonic instead of JE (this doesn't change code).
Replace several BT insns with equivalent, but shorter TEST insns.

Signed-off-by: Denys Vlasenko 
CC: Linus Torvalds 
CC: Steven Rostedt 
CC: Ingo Molnar 
CC: Borislav Petkov 
CC: "H. Peter Anvin" 
CC: Andy Lutomirski 
CC: Oleg Nesterov 
CC: Frederic Weisbecker 
CC: Alexei Starovoitov 
CC: Will Drewry 
CC: Kees Cook 
CC: x...@kernel.org
CC: linux-kernel@vger.kernel.org
---
 arch/x86/kernel/entry_64.S | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 356266c..cc166ab 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -67,8 +67,8 @@ ENDPROC(native_usergs_sysret64)
 
 .macro TRACE_IRQS_IRETQ
 #ifdef CONFIG_TRACE_IRQFLAGS
-   bt   $9,EFLAGS(%rsp)/* interrupts off? */
-   jnc  1f
+   testb   $2, EFLAGS+1(%rsp)  /* interrupts off? */
+   jz  1f
TRACE_IRQS_ON
 1:
 #endif
@@ -100,8 +100,8 @@ ENDPROC(native_usergs_sysret64)
 .endm
 
 .macro TRACE_IRQS_IRETQ_DEBUG
-   bt   $9,EFLAGS(%rsp)/* interrupts off? */
-   jnc  1f
+   testb   $2, EFLAGS+1(%rsp)  /* interrupts off? */
+   jz  1f
TRACE_IRQS_ON_DEBUG
 1:
 .endm
@@ -513,8 +513,8 @@ ENTRY(ret_from_fork)
 
RESTORE_EXTRA_REGS
 
-   testl $3,CS(%rsp)   # from kernel_thread?
-   jz   1f
+   testb   $3, CS(%rsp)# from kernel_thread?
+   jz  1f
 
/*
 * By the time we get here, we have no idea whether our pt_regs,
@@ -598,8 +598,8 @@ END(interrupt)
 
leaq -RBP(%rsp),%rdi/* arg1 for \func (pointer to pt_regs) */
 
-   testl $3, CS-RBP(%rsp)
-   je 1f
+   testb   $3, CS-RBP(%rsp)
+   jz  1f
SWAPGS
 1:
/*
@@ -653,8 +653,8 @@ ret_from_intr:
CFI_DEF_CFA_REGISTERrsp
CFI_ADJUST_CFA_OFFSET   RBP
 
-   testl $3,CS(%rsp)
-   je retint_kernel
+   testb   $3, CS(%rsp)
+   jz  retint_kernel
/* Interrupt came from user space */
 
GET_THREAD_INFO(%rcx)
@@ -739,8 +739,8 @@ retint_kernel:
 #ifdef CONFIG_PREEMPT
/* Interrupts are off */
/* Check if we need preemption */
-   bt  $9,EFLAGS(%rsp) /* interrupts were off? */
-   jnc 1f
+   testb   $2,EFLAGS+1(%rsp)   /* interrupts were off? */
+   jz  1f
 0: cmpl$0,PER_CPU_VAR(__preempt_count)
jnz 1f
callpreempt_schedule_irq
@@ -950,8 +950,8 @@ ENTRY(\sym)
.if \paranoid
.if \paranoid == 1
CFI_REMEMBER_STATE
-   testl $3, CS(%rsp)  /* If coming from userspace, switch */
-   jnz 1f  /* stacks. */
+   testb   $3, CS(%rsp)/* If coming from userspace, switch */
+   jnz 1f  /* stacks. */
.endif
call paranoid_entry
.else
@@ -1291,8 +1291,8 @@ ENTRY(error_entry)
SAVE_C_REGS 8
SAVE_EXTRA_REGS 8
xorl %ebx,%ebx
-   testl $3,CS+8(%rsp)
-   je error_kernelspace
+   testb $3,CS+8(%rsp)
+   jz error_kernelspace
 error_swapgs:
SWAPGS
 error_sti:
@@ -1343,7 +1343,7 @@ ENTRY(error_exit)
TRACE_IRQS_OFF
GET_THREAD_INFO(%rcx)
testl %eax,%eax
-   jne retint_kernel
+   jnz retint_kernel
LOCKDEP_SYS_EXIT_IRQ
movl TI_flags(%rcx),%edx
movl $_TIF_WORK_MASK,%edi
-- 
1.8.1.4

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


[RFC PATCH 0/2] Add support for Lite On LTR559 sensor

2015-03-31 Thread Daniel Baluta
First patch does some cleanups in order to make alignment style
consistent with the rest of IIO drivers. Then second patch adds
support for Lite On LTR559 ambient light and proximity sensor.

This is a RFC because the code is compile tested only. The 
chip should arrive in a few days.

Daniel Baluta (2):
  iio: light: ltr501: Fix alignment to match open parenthesis
  iio: light: Add support for LTR559 chip

 drivers/iio/light/ltr501.c | 240 +++--
 1 file changed, 187 insertions(+), 53 deletions(-)

-- 
1.9.1

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


[RFC PATCH 2/2] iio: light: Add support for LTR559 chip

2015-03-31 Thread Daniel Baluta
This device is register compatible with LTR501, with a minor difference for
ALS control register as showed below:

ALS Control register for LTR501:

7  6  5  4  3  2  1  0
+--+--+--+--+--+--+--+--+
|   |  |  | |
|Reserved   | Gain |  SW  |ALS Mode |
|   |  | Reset| |
+--+--+--+--+--+--+--+--+

ALS Control register for LTR559:

7  6  5  4  3  2  1  0
+--+--+--+--+--+--+--+--+
|||  |  |
| Reserved   |Gain|  SW  | ALS  |
||| Reset| Mode |
+--+--+--+--+--+--+--+--+

We handle this difference by introducing ltr501_chip_info.

Datasheet for LTR559 is at:
http://optoelectronics.liteon.com/upload/download/DS86-2013-0003/S_110_LTR-559ALS-01_DS_V1.pdf

Signed-off-by: Daniel Baluta 
---
 drivers/iio/light/ltr501.c | 196 +
 1 file changed, 163 insertions(+), 33 deletions(-)

diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
index 883855a..5939cda 100644
--- a/drivers/iio/light/ltr501.c
+++ b/drivers/iio/light/ltr501.c
@@ -45,12 +45,89 @@
 
 #define LTR501_PS_DATA_MASK 0x7ff
 
+#define LTR501_RESERVED_GAIN -1
+
+enum {
+   ltr501 = 0,
+   ltr559,
+};
+
+struct ltr501_gain {
+   int scale;
+   int uscale;
+};
+
+static struct ltr501_gain ltr501_als_gain_tbl[] = {
+   {1, 0},
+   {0, 5000},
+};
+
+static struct ltr501_gain ltr559_als_gain_tbl[] = {
+   {1, 0},
+   {0, 50},
+   {0, 25},
+   {0, 125000},
+   {LTR501_RESERVED_GAIN, LTR501_RESERVED_GAIN},
+   {LTR501_RESERVED_GAIN, LTR501_RESERVED_GAIN},
+   {0, 2},
+   {0, 1},
+};
+
+static struct ltr501_gain ltr501_ps_gain_tbl[] = {
+   {1, 0},
+   {0, 25},
+   {0, 125000},
+   {0, 62500},
+};
+
+static struct ltr501_gain ltr559_ps_gain_tbl[] = {
+   {0, 62500}, /* x16 gain */
+   {0, 31250}, /* x32 gain */
+   {0, 15625}, /* bits X1 are for x64 gain */
+   {0, 15624},
+};
+
+struct ltr501_chip_info {
+   u8 chip_id;
+   struct ltr501_gain *als_gain;
+   int als_gain_tbl_size;
+   struct ltr501_gain *ps_gain;
+   int ps_gain_tbl_size;
+   u8 als_mode_active;
+   u8 als_gain_mask;
+   u8 als_gain_shift;
+};
+
 struct ltr501_data {
struct i2c_client *client;
struct mutex lock_als, lock_ps;
+   struct ltr501_chip_info *chip_info;
u8 als_contr, ps_contr;
 };
 
+static struct ltr501_chip_info ltr501_chip_info_tbl[] = {
+   [ltr501] = {
+   .chip_id = 0x08,
+   .als_gain = ltr501_als_gain_tbl,
+   .als_gain_tbl_size = ARRAY_SIZE(ltr501_als_gain_tbl),
+   .ps_gain = ltr501_ps_gain_tbl,
+   .ps_gain_tbl_size = ARRAY_SIZE(ltr501_ps_gain_tbl),
+   .als_mode_active = BIT(0) | BIT(1),
+   .als_gain_mask = BIT(3),
+   .als_gain_shift = 3,
+   },
+   [ltr559] = {
+   .chip_id = 0x09,
+   .als_gain = ltr559_als_gain_tbl,
+   .als_gain_tbl_size = ARRAY_SIZE(ltr559_als_gain_tbl),
+   .ps_gain = ltr559_ps_gain_tbl,
+   .ps_gain_tbl_size = ARRAY_SIZE(ltr559_ps_gain_tbl),
+   .als_mode_active = BIT(1),
+   .als_gain_mask = BIT(2) | BIT(3) | BIT(4),
+   .als_gain_shift = 2,
+   },
+};
+
 static int ltr501_drdy(struct ltr501_data *data, u8 drdy_mask)
 {
int tries = 100;
@@ -125,10 +202,6 @@ static const struct iio_chan_spec ltr501_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(3),
 };
 
-static const int ltr501_ps_gain[4][2] = {
-   {1, 0}, {0, 25}, {0, 125000}, {0, 62500}
-};
-
 static int ltr501_read_raw(struct iio_dev *indio_dev,
   struct iio_chan_spec const *chan,
   int *val, int *val2, long mask)
@@ -166,20 +239,16 @@ static int ltr501_read_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_SCALE:
switch (chan->type) {
case IIO_INTENSITY:
-   if (data->als_contr & LTR501_CONTR_ALS_GAIN_MASK) {
-   *val = 0;
-   *val2 = 5000;
-   return IIO_VAL_INT_PLUS_MICRO;
-   } else {
-   *val = 1;
-   *val2 = 0;
-   return IIO_VAL_INT;
-   }
+   i = (data->als_contr & data->chip_info->als_gain_mask) 
>>
+   data->chip_info->als_gain_shift;
+   *val = 

[PATCH 5/5 v2] x86/asm/entry/64: simplify looping around preempt_schedule_irq

2015-03-31 Thread Denys Vlasenko
At this label, we test whether interrupt/exception was in kernel.
If it did, we jump to preemption check. If preemption does happen
(IOW if we call preempt_schedule_irq), we go back to exit_intr.

But it's pointless, we already know that test succeeded last time,
preemption doesn't change the fact that interrupt/exception
was in kernel. We can go back directly to checking
PER_CPU_VAR(__preempt_count) instead.

This makes exit_intr label unused. Dropping it.

Signed-off-by: Denys Vlasenko 
CC: Linus Torvalds 
CC: Steven Rostedt 
CC: Ingo Molnar 
CC: Borislav Petkov 
CC: "H. Peter Anvin" 
CC: Andy Lutomirski 
CC: Oleg Nesterov 
CC: Frederic Weisbecker 
CC: Alexei Starovoitov 
CC: Will Drewry 
CC: Kees Cook 
CC: x...@kernel.org
CC: linux-kernel@vger.kernel.org
---

Changes in v2:
* split insn cleanups into a separate patch
* improve commit log message

 arch/x86/kernel/entry_64.S | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 16bf357..356266c 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -653,7 +653,6 @@ ret_from_intr:
CFI_DEF_CFA_REGISTERrsp
CFI_ADJUST_CFA_OFFSET   RBP
 
-exit_intr:
testl $3,CS(%rsp)
je retint_kernel
/* Interrupt came from user space */
@@ -740,12 +739,12 @@ retint_kernel:
 #ifdef CONFIG_PREEMPT
/* Interrupts are off */
/* Check if we need preemption */
-   cmpl$0,PER_CPU_VAR(__preempt_count)
-   jnz 1f
bt  $9,EFLAGS(%rsp) /* interrupts were off? */
jnc 1f
+0: cmpl$0,PER_CPU_VAR(__preempt_count)
+   jnz 1f
callpreempt_schedule_irq
-   jmp exit_intr
+   jmp 0b
 1:
 #endif
/*
-- 
1.8.1.4

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


Re: another pmem variant V2

2015-03-31 Thread Boaz Harrosh
On 03/31/2015 01:25 PM, Boaz Harrosh wrote:
> On 03/31/2015 12:25 PM, Christoph Hellwig wrote:
<>
> The problem I see is that if I state a memmap=nn!aa that crosses a NUMA
> boundary then the machine will not boot.
> So BTW for sure I need that "don't merge E820_PMEM ranges" patch because
> otherwise I will not be able to boot if I have pmem on both NUMA nodes
> and they happen to be contiguous.
> 

BTW if you need NUMA emulated in your KVM add the below to your virsh edit

  


  
  

  


memory= is in KiB only
The sum of these must exactly match what you have for 
  8388608
  8388608

And you probably already have say:


Cheers
Boaz

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: [Qemu-devel] [PATCH v4 10/15] target-s390x: Prepare accelerator during cpu object realization

2015-03-31 Thread Michael Mueller
On Mon, 30 Mar 2015 16:33:51 -0300
Eduardo Habkost  wrote:

> On Mon, Mar 30, 2015 at 04:28:23PM +0200, Michael Mueller wrote:
> > This patch implements routine s390_cpu_model_init(). It is called by the
> > realize function during instantiation of an cpu object. Its task is to
> > initialize the current accelerator with the properties of the selected
> > processor model.
> > 
> > Signed-off-by: Michael Mueller 
> > ---
> >  target-s390x/cpu-models.c | 37 +
> >  target-s390x/cpu-models.h |  4 
> >  target-s390x/cpu.c|  1 +
> >  3 files changed, 42 insertions(+)
> > 
> > diff --git a/target-s390x/cpu-models.c b/target-s390x/cpu-models.c
> > index 8a877d3..ba873ea 100644
> > --- a/target-s390x/cpu-models.c
> > +++ b/target-s390x/cpu-models.c
> > @@ -111,6 +111,7 @@ typedef struct ParmAddrAddrModeMask {
> >  } ParmAddrAddrModeMask;
> >  
> >  static GSList *s390_cpu_aliases;
> > +static bool cpu_models_used;
> >  
> >  /* compare order of two cpu classes for ascending sort */
> >  gint s390_cpu_class_asc_order_compare(gconstpointer a, gconstpointer b)
> > @@ -670,3 +671,39 @@ uint64_t *s390_current_fac_list_mask(void)
> >  return s390_fac_list_mask_by_machine(mc->name);
> >  }
> >  #endif
> > +
> > +/**
> > + * s390_cpu_model_init:
> > + * @cc: S390 CPU class
> > + *
> > + * This function intitializes the current accelerator with processor
> > + * related properties.
> > + *
> > + * Since: 2.4
> > + */
> > +void s390_cpu_model_init(S390CPUClass *cc)
> > +{
> > +S390ProcessorProps proc;
> > +
> > +/* none cpu model case */
> > +if (!strcmp(object_class_get_name(OBJECT_CLASS(cc)), TYPE_S390_CPU)) {
> > +return;
> > +}
> 
> Instead of checking the class name, can't you just check a S390CPUClass
> field that may indicate that s390_cpu_model_init() doesn't need to do
> anything for the class? Maybe (cpuid(cc->proc) == 0)?

That will work as well but excludes cpuid 0 from being a valid cpu id.

> 
> 
> > +
> > +/* accelerator already prepared */
> > +if (cpu_models_used) {
> > +return;
> > +}
> 
> I'm still trying to understand the need for this global. But I will ask
> for more details in the following patches that actually use
> s390_cpu_models_used()?

I'm currently using the variable to avoid multiple calls to 
kvm_s390_set_processor_props() as it
sets the processor properties for all vcpus. I will not hurt to call it twice 
or more often, it
is just not required and just consumes cpu cycles.

> 
> > +
> > +proc.cpuid = cpuid(cc->proc);
> > +proc.ibc = cc->proc.ibc;
> > +bitmap_zero(proc.fac_list, FAC_LIST_ARCH_S390_SIZE_UINT1);
> > +bitmap_copy(proc.fac_list, cc->fac_list[ACCEL_CURRENT],
> > +FAC_LIST_CPU_S390_SIZE_UINT1);
> > +
> > +if (kvm_enabled()) {
> > +if (!kvm_s390_set_processor_props()) {
> > +cpu_models_used = true;
> > +}
> > +}
> > +}
> > diff --git a/target-s390x/cpu-models.h b/target-s390x/cpu-models.h
> > index 9562088..fe3997f 100644
> > --- a/target-s390x/cpu-models.h
> > +++ b/target-s390x/cpu-models.h
> > @@ -45,6 +45,9 @@
> >  #define type_cpuid(x) ((uint64_t)((x) & 0x) << 16)
> >  #define id_cpuid(x)   ((uint64_t)((x) & 0xff) << 32)
> >  #define ver_cpuid(x)  ((uint64_t)((x) & 0xff) << 56)
> > +#define cpuid(x)  (ver_cpuid(x.ver) |  \
> > +   id_cpuid(x.id) |\
> > +   type_cpuid(x.type))
> >  
> >  #define oldest_ibc(x) (((uint32_t)(x) >> 16) & 0xfff)
> >  #define newest_ibc(x) ((uint32_t)(x) & 0xfff)
> > @@ -108,6 +111,7 @@ void s390_cpu_list_entry(gpointer data, gpointer 
> > user_data);
> >  bool s390_cpu_classes_initialized(void);
> >  uint64_t *s390_fac_list_mask_by_machine(const char *name);
> >  uint64_t *s390_current_fac_list_mask(void);
> > +void s390_cpu_model_init(S390CPUClass *cc);
> >  
> >  extern uint64_t qemu_s390_fac_list_mask[];
> >  
> > diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
> > index c33f05e..829945d 100644
> > --- a/target-s390x/cpu.c
> > +++ b/target-s390x/cpu.c
> > @@ -180,6 +180,7 @@ static void s390_cpu_realizefn(DeviceState *dev, Error 
> > **errp)
> >  CPUState *cs = CPU(dev);
> >  S390CPUClass *scc = S390_CPU_GET_CLASS(dev);
> >  
> > +s390_cpu_model_init(scc);
> >  s390_cpu_gdb_init(cs);
> >  qemu_init_vcpu(cs);
> >  #if !defined(CONFIG_USER_ONLY)
> > -- 
> > 1.8.3.1
> > 
> 

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


Re: another pmem variant V2

2015-03-31 Thread Boaz Harrosh
On 03/31/2015 12:25 PM, Christoph Hellwig wrote:
> On Thu, Mar 26, 2015 at 06:57:47PM +0200, Boaz Harrosh wrote:
>> On 03/26/2015 10:32 AM, Christoph Hellwig wrote:
>>> Here is another version of the same trivial pmem driver, because two
>>> obviously aren't enough.  The first patch is the same pmem driver
>>> that Ross posted a short time ago, just modified to use platform_devices
>>> to find the persistant memory region instead of hardconding it in the
>>> Kconfig.  This allows to keep pmem.c separate from any discovery mechanism,
>>> but still allow auto-discovery.
>>>
>>
>> Hi Christoph
>>
>> So I've been trying to test your version, and play around with it.
>> I currently have some problems, but this is the end of the week for me
>> so I will debug and fix it after the weekend on Sunday.
> 
> Any news?  I'd really like to resend this ASAP to get it into 4.1..

Yes sorry I got stuck with the NUMA thing. I will finally finish today.

For some reason your patch with the memmap=nn!aa behaves differently than
with  memmap=nn\$aa

And also compared to my old e820.c fix + my old pmem. My fixes are effectively
the same as with your Kernel and the memmap=nn\$aa which sets the range 
"reserved"
like. And less "ram" like as in your patch.

The problem I see is that if I state a memmap=nn!aa that crosses a NUMA
boundary then the machine will not boot.
So BTW for sure I need that "don't merge E820_PMEM ranges" patch because
otherwise I will not be able to boot if I have pmem on both NUMA nodes
and they happen to be contiguous.

I do not understand why this happens, because a contiguous range of
RAM is fine with cross NUMA and pmem not. (Also the pmem defined as
memmap=nn!aa behaves the same)

Also we have another problem with NUMA that I'm researching for a solution
long term. Is that if the second NUMA node has only pmem and no RAM than
the Kernel will not define a second NUMA node. And we are NUMA screwed with
pmem. So one must put v-ram and nv-ram equally spread across his nodes.

Regarding the SQUASHMEs to PMEM. Originally I had them as 3-4 patches.
But I thought since you are squashing them into a single submitted patch
I can just send just the one patch. Tell me what you prefer and I'll
resend (The one vs the three)

And one last issue. I have some configuration "hardness" with the
memmap=nn!aa Kernel command line API, it was better for me with the
pmem map= module param. Will you be OK if I split pmem_probe() into
calling pmem_alloc(addr, length), so I can keep an out-of-tree patch
that adds the map= parameter to pmem?

Will send the patch in one hour. Just tell me if you need just the one
or three.

Thanks, Christoph
Boaz

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] drm: rockchip: Turn off VT switching on suspend

2015-03-31 Thread Caesar Wang
drm/rockchip already has support for disabling all displays on suspend
and enabling them on resume.

Disable automatic VT switching on suspend by the pm console tracking
layer.

Tested on veyron, used `echo mem > sys/power/state`
  => verified no VT switch

Reviewed-by: Daniel Kurtz 
Signed-off-by: Caesar Wang 
---

 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
index a5d889a..eb4e0db 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
@@ -119,6 +119,9 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper 
*helper,
DRM_DEBUG_KMS("FB [%dx%d]-%d kvaddr=%p offset=%ld size=%d\n",
  fb->width, fb->height, fb->depth, rk_obj->kvaddr,
  offset, size);
+
+   fbi->skip_vt_switch = true;
+
return 0;
 
 err_drm_framebuffer_unref:
-- 
1.9.1

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


[PATCH 0/1] drm: rockchip: Turn off VT switching on suspend

2015-03-31 Thread Caesar Wang
drm/rockchip already has support for disabling all displays on suspend
and enabling them on resume.

Disable automatic VT switching on suspend by the pm console tracking
layer.

Tested on veyron, used `echo mem > sys/power/state`
  => verified no VT switch.



Caesar Wang (1):
  drm: rockchip: Turn off VT switching on suspend

 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c | 3 +++
 1 file changed, 3 insertions(+)

-- 
1.9.1

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


Re: [PATCH 4/4] Documentation: extcon: usb-gpio: update usb-gpio binding description

2015-03-31 Thread Roger Quadros
On 31/03/15 10:46, Robert Baldyga wrote:
> Add information about VBUS pin detection support, 'debounce' property
> and some other details.
> 
> Signed-off-by: Robert Baldyga 
> ---
>  .../devicetree/bindings/extcon/extcon-usb-gpio.txt | 23 
> --
>  1 file changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt 
> b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
> index af0b903..d3fcf8b 100644
> --- a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
> +++ b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
> @@ -1,16 +1,35 @@
>  USB GPIO Extcon device
>  
> -This is a virtual device used to generate USB cable states from the USB ID 
> pin
> -connected to a GPIO pin.
> +This is a virtual device used to generate USB cable states from the USB
> +ID and VBUS signals connected to a GPIO pins.

s/to a GPIO/to GPIO/

> +
> +Some devices has only one of these GPIO pins, so we support cases when
s/has/have/

> +only one of them is present. Hence properties 'id-gpio' and 'vbus-gpio'
> +are described as optional, but at least one of them has to be present
> +in extcon-usb-gpio node.
> +
> +In general we have three cases:
> + 1. We have both VBUS and ID pin detection - we can detect USB, USB-HOST
> +and cable disconnection.

The interpretation of "cable disconnect" might not be always true.
ID may be 1 and VBUS 0 but cable might still not be disconnected.
e.g. if both are OTG devices.
That's why we have ADP to detect cable connect/disconnect status for OTG case.

So let's leave cable disconnection interpretation to the USB stack and
just deal with passing ID/VBUS status. I must admit that the extcon cable
state names are misleading. They should really have been named
USB-ID and USB-VBUS :).

The driver doesn't do connect/disconnect detection but only infers the other
pin state if only one of the ID/VBUS is available.

> + 2. We have only VBUS detection - we can detect USB and cable disconnection.
> + 3. We have ID pin only - we can distinguish between USB and USB-HOST
> +but without ability to detect cable disconnection.

how about rewording these 3 points like so with a short header about
clarification of extcon USB/USB_HOST states.

The extcon cable states USB and USB_HOST are actually VBUS and (inverted) ID
pin states and do not indicate what mode the USB needs to operate in.
That decision is done by the USB stack.

1. If VBUS and ID gpios are present we pass them as is
USB-HOST = !ID, USB = VBUS
2. If only VBUS gpio is present we assume that ID pin is always High.
USB-HOST = false, USB = VBUS.
3. If only ID pin is available we infer the VBUS pin states based on ID.
USB-HOST = !ID, USB = ID

>  
>  Required properties:
>  - compatible: Should be "linux,extcon-usb-gpio"
> +
> +Optional properties
>  - id-gpio: gpio for USB ID pin. See gpio binding.
> +- vbus-gpio: gpio for USB VBUS pin. See gpio binding.
> +- debounce: gpio debounce time in milliseconds (u32).
> +
>  
>  Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below:
>   extcon_usb1 {
>   compatible = "linux,extcon-usb-gpio";
>   id-gpio = < 1 GPIO_ACTIVE_HIGH>;
> + vbus-gpio = < 2 GPIO_ACTIVE_HIGH>;
> + debounce = <25>;
>   }
>  
>   _dwc3_1 {
>
 
cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] watchdog: nohz: don't run watchdog on nohz_full cores

2015-03-31 Thread Christoph Lameter
On Mon, 30 Mar 2015, cmetc...@ezchip.com wrote:

> Running watchdog can be a helpful debugging feature on regular
> cores, but it's incompatible with nohz_full, since it forces
> regular scheduling events.  Accordingly, just exit out immediately
> from any nohz_full core.

At this point we still have a timer tick every second. So just change the
way the checking occurs that it can be done during the once per second
tick for now? If the tick idle period is expanded later maybe only run the
watchdog activity during those inevitable ticks?

It may be best if the watchdog could be configured as to which processors
it should run on?

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


[PATCH 4/5] clocksource/drivers/sun5i: Refactor the current code

2015-03-31 Thread Daniel Lezcano
From: Maxime Ripard 

Refactor the code in order to remove the global variables and split the clock
source and clock events registration in order to ease the addition of the clock
notifiers needed to handle the parent clock rate changes.

Signed-off-by: Maxime Ripard 
Signed-off-by: Daniel Lezcano 

Conflicts:
drivers/clocksource/timer-sun5i.c
---
 drivers/clocksource/timer-sun5i.c | 231 +++---
 1 file changed, 166 insertions(+), 65 deletions(-)

diff --git a/drivers/clocksource/timer-sun5i.c 
b/drivers/clocksource/timer-sun5i.c
index 80459b9..5a4f820 100644
--- a/drivers/clocksource/timer-sun5i.c
+++ b/drivers/clocksource/timer-sun5i.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -36,8 +37,27 @@
 
 #define TIMER_SYNC_TICKS   3
 
-static void __iomem *timer_base;
-static u32 ticks_per_jiffy;
+struct sun5i_timer {
+   void __iomem*base;
+   struct clk  *clk;
+   u32 ticks_per_jiffy;
+};
+
+struct sun5i_timer_clksrc {
+   struct sun5i_timer  timer;
+   struct clocksource  clksrc;
+};
+
+#define to_sun5i_timer_clksrc(x) \
+   container_of(x, struct sun5i_timer_clksrc, clksrc)
+
+struct sun5i_timer_clkevt {
+   struct sun5i_timer  timer;
+   struct clock_event_device   clkevt;
+};
+
+#define to_sun5i_timer_clkevt(x) \
+   container_of(x, struct sun5i_timer_clkevt, clkevt)
 
 /*
  * When we disable a timer, we need to wait at least for 2 cycles of
@@ -45,30 +65,30 @@ static u32 ticks_per_jiffy;
  * that is already setup and runs at the same frequency than the other
  * timers, and we never will be disabled.
  */
-static void sun5i_clkevt_sync(void)
+static void sun5i_clkevt_sync(struct sun5i_timer_clkevt *ce)
 {
-   u32 old = readl(timer_base + TIMER_CNTVAL_LO_REG(1));
+   u32 old = readl(ce->timer.base + TIMER_CNTVAL_LO_REG(1));
 
-   while ((old - readl(timer_base + TIMER_CNTVAL_LO_REG(1))) < 
TIMER_SYNC_TICKS)
+   while ((old - readl(ce->timer.base + TIMER_CNTVAL_LO_REG(1))) < 
TIMER_SYNC_TICKS)
cpu_relax();
 }
 
-static void sun5i_clkevt_time_stop(u8 timer)
+static void sun5i_clkevt_time_stop(struct sun5i_timer_clkevt *ce, u8 timer)
 {
-   u32 val = readl(timer_base + TIMER_CTL_REG(timer));
-   writel(val & ~TIMER_CTL_ENABLE, timer_base + TIMER_CTL_REG(timer));
+   u32 val = readl(ce->timer.base + TIMER_CTL_REG(timer));
+   writel(val & ~TIMER_CTL_ENABLE, ce->timer.base + TIMER_CTL_REG(timer));
 
-   sun5i_clkevt_sync();
+   sun5i_clkevt_sync(ce);
 }
 
-static void sun5i_clkevt_time_setup(u8 timer, u32 delay)
+static void sun5i_clkevt_time_setup(struct sun5i_timer_clkevt *ce, u8 timer, 
u32 delay)
 {
-   writel(delay, timer_base + TIMER_INTVAL_LO_REG(timer));
+   writel(delay, ce->timer.base + TIMER_INTVAL_LO_REG(timer));
 }
 
-static void sun5i_clkevt_time_start(u8 timer, bool periodic)
+static void sun5i_clkevt_time_start(struct sun5i_timer_clkevt *ce, u8 timer, 
bool periodic)
 {
-   u32 val = readl(timer_base + TIMER_CTL_REG(timer));
+   u32 val = readl(ce->timer.base + TIMER_CTL_REG(timer));
 
if (periodic)
val &= ~TIMER_CTL_ONESHOT;
@@ -76,66 +96,170 @@ static void sun5i_clkevt_time_start(u8 timer, bool 
periodic)
val |= TIMER_CTL_ONESHOT;
 
writel(val | TIMER_CTL_ENABLE | TIMER_CTL_RELOAD,
-  timer_base + TIMER_CTL_REG(timer));
+  ce->timer.base + TIMER_CTL_REG(timer));
 }
 
 static void sun5i_clkevt_mode(enum clock_event_mode mode,
- struct clock_event_device *clk)
+ struct clock_event_device *clkevt)
 {
+   struct sun5i_timer_clkevt *ce = to_sun5i_timer_clkevt(clkevt);
+
switch (mode) {
case CLOCK_EVT_MODE_PERIODIC:
-   sun5i_clkevt_time_stop(0);
-   sun5i_clkevt_time_setup(0, ticks_per_jiffy);
-   sun5i_clkevt_time_start(0, true);
+   sun5i_clkevt_time_stop(ce, 0);
+   sun5i_clkevt_time_setup(ce, 0, ce->timer.ticks_per_jiffy);
+   sun5i_clkevt_time_start(ce, 0, true);
break;
case CLOCK_EVT_MODE_ONESHOT:
-   sun5i_clkevt_time_stop(0);
-   sun5i_clkevt_time_start(0, false);
+   sun5i_clkevt_time_stop(ce, 0);
+   sun5i_clkevt_time_start(ce, 0, false);
break;
case CLOCK_EVT_MODE_UNUSED:
case CLOCK_EVT_MODE_SHUTDOWN:
default:
-   sun5i_clkevt_time_stop(0);
+   sun5i_clkevt_time_stop(ce, 0);
break;
}
 }
 
 static int sun5i_clkevt_next_event(unsigned long evt,
-  struct clock_event_device *unused)
+  struct clock_event_device *clkevt)
 {
-   sun5i_clkevt_time_stop(0);
-   

[PATCH 2/5] clocksource/drivers/sun5i: Switch to request_irq

2015-03-31 Thread Daniel Lezcano
From: Maxime Ripard 

The current code uses setup_irq, while it could perfectly use the much simpler
request_irq. Switch to that.

Signed-off-by: Maxime Ripard 
Signed-off-by: Daniel Lezcano 

Conflicts:
drivers/clocksource/timer-sun5i.c
---
 drivers/clocksource/timer-sun5i.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/clocksource/timer-sun5i.c 
b/drivers/clocksource/timer-sun5i.c
index 58597fb..03f04d8 100644
--- a/drivers/clocksource/timer-sun5i.c
+++ b/drivers/clocksource/timer-sun5i.c
@@ -129,13 +129,6 @@ static irqreturn_t sun5i_timer_interrupt(int irq, void 
*dev_id)
return IRQ_HANDLED;
 }
 
-static struct irqaction sun5i_timer_irq = {
-   .name = "sun5i_timer0",
-   .flags = IRQF_TIMER | IRQF_IRQPOLL,
-   .handler = sun5i_timer_interrupt,
-   .dev_id = _clockevent,
-};
-
 static void __init sun5i_timer_init(struct device_node *node)
 {
struct reset_control *rstc;
@@ -181,7 +174,8 @@ static void __init sun5i_timer_init(struct device_node 
*node)
clockevents_config_and_register(_clockevent, rate,
TIMER_SYNC_TICKS, 0x);
 
-   ret = setup_irq(irq, _timer_irq);
+   ret = request_irq(irq, sun5i_timer_interrupt, IRQF_TIMER | IRQF_IRQPOLL,
+ "sun5i_timer0", _clockevent);
if (ret)
pr_warn("failed to setup irq %d\n", irq);
 }
-- 
1.9.1

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


[PATCH 5/5] clocksource/drivers/sun5i: Add clock notifiers

2015-03-31 Thread Daniel Lezcano
From: Maxime Ripard 

The parent clock of the sun5i timer is the AHB clock, which rate might change
because of other devices requirements.

This is for example the case on the Allwinner A31, where the DMA controller
needs a minimum rate higher than the default, that is enforced after the timer
driver has probed.

Add clock notifiers to make sure we reflect the clock rate changes in the timer
rates.

Signed-off-by: Maxime Ripard 
Signed-off-by: Daniel Lezcano 
---
 drivers/clocksource/timer-sun5i.c | 68 +--
 1 file changed, 66 insertions(+), 2 deletions(-)

diff --git a/drivers/clocksource/timer-sun5i.c 
b/drivers/clocksource/timer-sun5i.c
index 5a4f820..18616e6 100644
--- a/drivers/clocksource/timer-sun5i.c
+++ b/drivers/clocksource/timer-sun5i.c
@@ -40,9 +40,13 @@
 struct sun5i_timer {
void __iomem*base;
struct clk  *clk;
+   struct notifier_block   clk_rate_cb;
u32 ticks_per_jiffy;
 };
 
+#define to_sun5i_timer(x) \
+   container_of(x, struct sun5i_timer, clk_rate_cb)
+
 struct sun5i_timer_clksrc {
struct sun5i_timer  timer;
struct clocksource  clksrc;
@@ -151,6 +155,30 @@ static cycle_t sun5i_clksrc_read(struct clocksource 
*clksrc)
return ~readl(cs->timer.base + TIMER_CNTVAL_LO_REG(1));
 }
 
+static int sun5i_rate_cb_clksrc(struct notifier_block *nb,
+   unsigned long event, void *data)
+{
+   struct clk_notifier_data *ndata = data;
+   struct sun5i_timer *timer = to_sun5i_timer(nb);
+   struct sun5i_timer_clksrc *cs = container_of(timer,
+struct sun5i_timer_clksrc, 
timer);
+
+   switch (event) {
+   case PRE_RATE_CHANGE:
+   clocksource_unregister(>clksrc);
+   break;
+
+   case POST_RATE_CHANGE:
+   clocksource_register_hz(>clksrc, ndata->new_rate);
+   break;
+
+   default:
+   break;
+   }
+
+   return NOTIFY_DONE;
+}
+
 static int __init sun5i_setup_clocksource(struct device_node *node,
  void __iomem *base,
  struct clk *clk, int irq)
@@ -173,6 +201,14 @@ static int __init sun5i_setup_clocksource(struct 
device_node *node,
 
cs->timer.base = base;
cs->timer.clk = clk;
+   cs->timer.clk_rate_cb.notifier_call = sun5i_rate_cb_clksrc;
+   cs->timer.clk_rate_cb.next = NULL;
+
+   ret = clk_notifier_register(clk, >timer.clk_rate_cb);
+   if (ret) {
+   pr_err("Unable to register clock notifier.\n");
+   goto err_disable_clk;
+   }
 
writel(~0, base + TIMER_INTVAL_LO_REG(1));
writel(TIMER_CTL_ENABLE | TIMER_CTL_RELOAD,
@@ -187,11 +223,13 @@ static int __init sun5i_setup_clocksource(struct 
device_node *node,
ret = clocksource_register_hz(>clksrc, rate);
if (ret) {
pr_err("Couldn't register clock source.\n");
-   goto err_disable_clk;
+   goto err_remove_notifier;
}
 
return 0;
 
+err_remove_notifier:
+   clk_notifier_unregister(clk, >timer.clk_rate_cb);
 err_disable_clk:
clk_disable_unprepare(clk);
 err_free:
@@ -199,6 +237,22 @@ err_free:
return ret;
 }
 
+static int sun5i_rate_cb_clkevt(struct notifier_block *nb,
+   unsigned long event, void *data)
+{
+   struct clk_notifier_data *ndata = data;
+   struct sun5i_timer *timer = to_sun5i_timer(nb);
+   struct sun5i_timer_clkevt *ce = container_of(timer,
+struct sun5i_timer_clkevt, 
timer);
+
+   if (event == POST_RATE_CHANGE) {
+   clockevents_update_freq(>clkevt, ndata->new_rate);
+   ce->timer.ticks_per_jiffy = DIV_ROUND_UP(ndata->new_rate, HZ);
+   }
+
+   return NOTIFY_DONE;
+}
+
 static int __init sun5i_setup_clockevent(struct device_node *node, void 
__iomem *base,
 struct clk *clk, int irq)
 {
@@ -222,6 +276,14 @@ static int __init sun5i_setup_clockevent(struct 
device_node *node, void __iomem
ce->timer.base = base;
ce->timer.ticks_per_jiffy = DIV_ROUND_UP(rate, HZ);
ce->timer.clk = clk;
+   ce->timer.clk_rate_cb.notifier_call = sun5i_rate_cb_clkevt;
+   ce->timer.clk_rate_cb.next = NULL;
+
+   ret = clk_notifier_register(clk, >timer.clk_rate_cb);
+   if (ret) {
+   pr_err("Unable to register clock notifier.\n");
+   goto err_disable_clk;
+   }
 
ce->clkevt.name = node->name;
ce->clkevt.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
@@ -242,11 +304,13 @@ static int __init sun5i_setup_clockevent(struct 
device_node *node, void __iomem
  "sun5i_timer0", ce);
if (ret) {

[PATCH 3/5] clocksource/drivers/sun5i: Use of_io_request_and_map

2015-03-31 Thread Daniel Lezcano
From: Maxime Ripard 

of_iomap doesn't do a request_mem_region on the memory area defined in the DT
it maps. Switch to of_io_request_and_map to make sure we're the only users.

Signed-off-by: Maxime Ripard 
Signed-off-by: Daniel Lezcano 
---
 drivers/clocksource/timer-sun5i.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clocksource/timer-sun5i.c 
b/drivers/clocksource/timer-sun5i.c
index 03f04d8..80459b9 100644
--- a/drivers/clocksource/timer-sun5i.c
+++ b/drivers/clocksource/timer-sun5i.c
@@ -137,7 +137,8 @@ static void __init sun5i_timer_init(struct device_node 
*node)
int ret, irq;
u32 val;
 
-   timer_base = of_iomap(node, 0);
+   timer_base = of_io_request_and_map(node, 0,
+  of_node_full_name(node));
if (!timer_base)
panic("Can't map registers");
 
-- 
1.9.1

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


[PATCH 1/5] clocksource/drivers/arm_arch_timer: Rename arch_timer_probed to reflect behaviour

2015-03-31 Thread Daniel Lezcano
From: Laurent Pinchart 

The arch_timer_probed function returns whether the given time doesn't
need to be probed. This can be the case when the timer has been probed
already, but also when it has no corresponding enabled node in DT.

Rename the function to arch_timer_needs_probe and invert its return value
to better reflect the function's purpose and behaviour.

Acked-by: Sudeep Holla 
Signed-off-by: Laurent Pinchart 
Signed-off-by: Daniel Lezcano 
---
 drivers/clocksource/arm_arch_timer.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/clocksource/arm_arch_timer.c 
b/drivers/clocksource/arm_arch_timer.c
index a3025e7..26acfb5 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -661,17 +661,17 @@ static const struct of_device_id 
arch_timer_mem_of_match[] __initconst = {
 };
 
 static bool __init
-arch_timer_probed(int type, const struct of_device_id *matches)
+arch_timer_needs_probe(int type, const struct of_device_id *matches)
 {
struct device_node *dn;
-   bool probed = true;
+   bool needs_probe = false;
 
dn = of_find_matching_node(NULL, matches);
if (dn && of_device_is_available(dn) && !(arch_timers_present & type))
-   probed = false;
+   needs_probe = true;
of_node_put(dn);
 
-   return probed;
+   return needs_probe;
 }
 
 static void __init arch_timer_common_init(void)
@@ -680,9 +680,10 @@ static void __init arch_timer_common_init(void)
 
/* Wait until both nodes are probed if we have two timers */
if ((arch_timers_present & mask) != mask) {
-   if (!arch_timer_probed(ARCH_MEM_TIMER, arch_timer_mem_of_match))
+   if (arch_timer_needs_probe(ARCH_MEM_TIMER,
+ arch_timer_mem_of_match))
return;
-   if (!arch_timer_probed(ARCH_CP15_TIMER, arch_timer_of_match))
+   if (arch_timer_needs_probe(ARCH_CP15_TIMER, 
arch_timer_of_match))
return;
}
 
-- 
1.9.1

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


[GIT PULL] clockevents for 4.1 #2

2015-03-31 Thread Daniel Lezcano

Hi Ingo, Thomas,

this is the second pull request with the different fixes. The sun5i 
timer conflict is fixed and the function name for arch arm timer is also 
fixed. So this second pull request contains the following:


 - Changed the arch_timer_probed function name to 
arch_timer_needs_probe to reflect better the behavior (Laurent Pinchart)


 - Used the freq changes notifiers to fix the rate alteration with the 
cpufreq driver as this one impacts the sun5i's parent clock (Maxime Ripard)


Thanks !

  -- Daniel

The following changes since commit 4806c87f017d8a7003ad34886f58c3b9e023df6a:

  clocksource/drivers/at91: Fix IO endianness (2015-03-31 09:15:58 +0200)

are available in the git repository at:

  http://git.linaro.org/people/daniel.lezcano/linux.git clockevents/4.1

for you to fetch changes up to 639793eb6552f3f5ce7db93e75aff57c1bad7a6b:

  clocksource/drivers/sun5i: Add clock notifiers (2015-03-31 11:50:06 
+0200)



Laurent Pinchart (1):
  clocksource/drivers/arm_arch_timer: Rename arch_timer_probed to 
reflect behaviour


Maxime Ripard (4):
  clocksource/drivers/sun5i: Switch to request_irq
  clocksource/drivers/sun5i: Use of_io_request_and_map
  clocksource/drivers/sun5i: Refactor the current code
  clocksource/drivers/sun5i: Add clock notifiers

 drivers/clocksource/arm_arch_timer.c |  13 +-
 drivers/clocksource/timer-sun5i.c| 302 
+++--

 2 files changed, 238 insertions(+), 77 deletions(-)

--
  Linaro.org │ Open source software for ARM SoCs

Follow Linaro:   Facebook |
 Twitter |
 Blog

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


Re: [PATCH] of: Custom printk format specifier for device node

2015-03-31 Thread Pantelis Antoniou
Hi Grant,

> On Mar 30, 2015, at 22:04 , Grant Likely  wrote:
> 
> On Thu, 22 Jan 2015 22:31:46 +0200
> , Pantelis Antoniou 
> wrote:
>> Hi Joe,
>> 
>>> On Jan 21, 2015, at 19:37 , Joe Perches  wrote:
>>> 
>>> On Wed, 2015-01-21 at 19:06 +0200, Pantelis Antoniou wrote:
 90% of the usage of device node's full_name is printing it out
 in a kernel message. Preparing for the eventual delayed allocation
 introduce a custom printk format specifier that is both more
 compact and more pleasant to the eye.
 
 For instance typical use is:
pr_info("Frobbing node %s\n", node->full_name);
 
 Which can be written now as:
pr_info("Frobbing node %pO\n", node);
>> 
>>> Still disliking use of %p0.
>>> 
>> 
>> pO - Open Firmware
>> 
>> pT for tree is bad, cause we plan to use a tree type in the future in OF.
> 
> So, here's a radical thought. How about we reserve '%pO' for objects, as
> in kobjects.  We'll use extra flags to narrow down specifically to
> device tree nodes, but we could teach vsprintf() to treat a plain '%pO'
> as plain kobject pointer, and if it is able to recognize the kobj_type,
> then run a specific decoder to format it.
> 
> This also gives us a namespace for various kinds of firmware data
> output. %Od could be a struct device, %On for device tree node, %Oa for
> an ACPI node, etc.
> 

I’m fine with this. I also have a patch to turn an overlay to a kobj
so this fits naturally.

OTOH if we do this, I would expect to rework the custom printk infrastructure
to be more generic.

IMHO having the format specifier and the format print methods in lib/vsprintf.c
is not very nice.

How about having a way to register object printk handlers with something like 
that?
We could put that in a special linker section and have the printk method pass 
control
there.

PRINTK_OBJFMT(’n’, printk_objfmt_device_node);

We might have to make a few printk methods public however.

>> 
 More fine-grained control of formatting includes printing the name,
 flag, path-spec name, reference count and others, explained in the
 documentation entry.
 
 Signed-off-by: Pantelis Antoniou 
 
 dt-print
 ---
 Documentation/printk-formats.txt |  29 
 lib/vsprintf.c   | 151 
 +++
 2 files changed, 180 insertions(+)
 
 diff --git a/Documentation/printk-formats.txt 
 b/Documentation/printk-formats.txt
 index 5a615c1..2d42c04 100644
 --- a/Documentation/printk-formats.txt
 +++ b/Documentation/printk-formats.txt
 @@ -231,6 +231,35 @@ struct va_format:
Do not use this feature without some mechanism to verify the
correctness of the format string and va_list arguments.
 
 +Device tree nodes:
 +
 +  %pO[fnpPcCFr]
 +
 +  For printing device tree nodes. The optional arguments are:
 +f device node full_name
 +n device node name
 +p device node phandle
 +P device node path spec (name + @unit)
 +F device node flags
 +c major compatible string
 +C full compatible string
 +r node reference count
 +  Without any arguments prints full_name (same as %pOf)
 +  The separator when using multiple arguments is '|'
 +
 +  Examples:
 +
 +  %pO /foo/bar@0  - Node full name
 +  %pOf/foo/bar@0  - Same as above
 +  %pOfp   /foo/bar@0|10   - Node full name + phandle
 +  %pOfcF  /foo/bar@0|foo,device|--P-  - Node full name +
 +major compatible string +
 +node flags
 +  D - dynamic
 +  d - detached
 +  P - Populated
 +  B - Populated bus
 +
 u64 SHOULD be printed with %llu/%llx:
 
printk("%llu", u64_var);
 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
>>> []
>>> 
>>> Add #ifdef back ?
>>> 
>> 
>> The whole thing is optimized away when CONFIG_OF is not defined, leaving only
>> the return statement.
>> 
 +static noinline_for_stack
 +char *device_node_string(char *buf, char *end, struct device_node *dn,
 +   struct printf_spec spec, const char *fmt)
 +{
 +  char tbuf[sizeof("xx") + 1];
 +  const char *fmtp, *p;
 +  int len, ret, i, j, pass;
 +  char c;
 +
 +  if (!IS_ENABLED(CONFIG_OF))
 +  return string(buf, end, "(!OF)", spec);
>>> 
>>> Not very descriptive output, maybe the address would be better.
>>> 
>> 
>> OK
>> 
 +
 +  if ((unsigned long)dn < PAGE_SIZE)
 +  return string(buf, end, "(null)", spec);
 +
 

Re: [PATCH] mm/mmap.c: use while instead of if+goto

2015-03-31 Thread Rasmus Villemoes
On Mon, Mar 30 2015, Andrew Morton  wrote:

> On Mon, 30 Mar 2015 23:54:13 +0300 "Kirill A. Shutemov" 
>  wrote:
>
>> On Mon, Mar 30, 2015 at 09:40:35PM +0200, Rasmus Villemoes wrote:
>> > The creators of the C language gave us the while keyword. Let's use
>> > that instead of synthesizing it from if+goto.
>> > 
>> > Made possible by 6597d783397a ("mm/mmap.c: replace find_vma_prepare()
>> > with clearer find_vma_links()").
>> > 
>> > Signed-off-by: Rasmus Villemoes 
>> 
>> 
>> Looks good, except both your plus-lines are over 80-characters long for no
>> reason.
>
> --- a/mm/mmap.c~mm-mmapc-use-while-instead-of-ifgoto-fix
> +++ a/mm/mmap.c
> @@ -1551,7 +1551,8 @@ unsigned long mmap_region(struct file *f
>
> I'm not sure it improves things a lot, but mmap.c has been pretty
> careful about the 80-col thing...

Yeah, I did run checkpatch and chose to ignore the 80-col warning, since
I think both the patch and the resulting code was more readable that
way. I don't really care either way, though.

Rasmus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: [LKP] [x86/intel/quark] 8bbc2a135b6: WARNING: CPU: 0 PID: 1 at arch/x86/platform/intel-quark/imr.c:358 imr_add_range+0x2b4/0x370()

2015-03-31 Thread Bryan O'Donoghue

On 31/03/15 03:02, huang ying wrote:

The qemu command line we used is as follow:

qemu-system-i386 -enable-kvm -kernel
/kernel/i386-randconfig-ib0-03292200/bc465aa9d045feb0e13b4a8f32cc33c1943f62d6/vmlinuz-4.0.0-rc5
-append 'user=lkp
job=/lkp/scheduled/vm-kbuild-yocto-i386-4/rand_boot-1-yocto-minimal-i386.cgz-i386-randconfig-ib0-03292200-bc465aa9d045feb0e13b4a8f32cc33c1943f62d6-0-20150329-102587-1i8stfj.yaml
ARCH=i386
BOOT_IMAGE=/kernel/i386-randconfig-ib0-03292200/bc465aa9d045feb0e13b4a8f32cc33c1943f62d6/vmlinuz-4.0.0-rc5
kconfig=i386-randconfig-ib0-03292200
commit=bc465aa9d045feb0e13b4a8f32cc33c1943f62d6 branch=linus/master
root=/dev/ram0 max_uptime=3600
RESULT_ROOT=/result/vm-kbuild-yocto-i386/boot/1/yocto-minimal-i386.cgz/i386-randconfig-ib0-03292200/bc465aa9d045feb0e13b4a8f32cc33c1943f62d6/0
ip=vm-kbuild-yocto-i386-4::dhcp earlyprintk=ttyS0,115200
rd.udev.log-priority=err systemd.log_target=journal
systemd.log_level=warning debug apic=debug sysrq_always_enabled
rcupdate.rcu_cpu_stall_timeout=100 panic=-1 softlockup_panic=1
nmi_watchdog=panic oops=panic load_ramdisk=2 prompt_ramdisk=0
console=ttyS0,115200 console=tty0 vga=normal rw drbd.minor_count=8'
-initrd /fs/sda1/initrd-vm-kbuild-yocto-i386-4 -m 320 -smp 2 -net
nic,vlan=1,model=e1000 -net user,vlan=1 -boot order=nc -no-reboot
-watchdog i6300esb -rtc base=localtime -drive
file=/fs/sda1/disk0-vm-kbuild-yocto-i386-4,media=disk,if=virtio -pidfile
/dev/shm/kboot/pid-vm-kbuild-yocto-i386-4 -serial
file:/dev/shm/kboot/serial-vm-kbuild-yocto-i386-4 -daemonize -display
none -monitor null


Thanks.

Replicated - have a patch ready :)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 05/86] x86/gart: use uapi/linux/pci_ids.h directly

2015-03-31 Thread Ingo Molnar

* Michael S. Tsirkin  wrote:

> On Tue, Mar 31, 2015 at 10:34:45AM +0200, Ingo Molnar wrote:
> > 
> > * Michael S. Tsirkin  wrote:
> > 
> > > On Mon, Mar 30, 2015 at 07:29:36AM +0200, Ingo Molnar wrote:
> > > > 
> > > > * Michael S. Tsirkin  wrote:
> > > > 
> > > > > Header moved from linux/pci_ids.h to uapi/linux/pci_ids.h,
> > > > > use the new header directly so we can drop
> > > > > the wrapper in include/linux/pci_ids.h.
> > > > > 
> > > > > Signed-off-by: Michael S. Tsirkin 
> > > > > ---
> > > > >  arch/x86/kernel/aperture_64.c | 2 +-
> > > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > 
> > > > > diff --git a/arch/x86/kernel/aperture_64.c 
> > > > > b/arch/x86/kernel/aperture_64.c
> > > > > index 76164e1..3b52a56 100644
> > > > > --- a/arch/x86/kernel/aperture_64.c
> > > > > +++ b/arch/x86/kernel/aperture_64.c
> > > > > @@ -17,7 +17,7 @@
> > > > >  #include 
> > > > >  #include 
> > > > >  #include 
> > > > > -#include 
> > > > > +#include 
> > > > >  #include 
> > > > >  #include 
> > > > >  #include 
> > > > > -- 
> > > > > MST
> > > > > 
> > > > 
> > > > NAK, it's absolutely ridiculous to send a 86 patches series for a 
> > > > trivial change like this!
> > > > 
> > > > Just do the rename in a single patch and avoid the churn. Even if 
> > > > there are conflicts, they are utmost trivial to fix up.
> > > > 
> > > > In fact the usual way to do such renames is to wait until the end of 
> > > > -rc1, auto-generate it and send Linus the core patch with the trivial 
> > > > renames straight away.
> > > > 
> > > > Thanks,
> > > > 
> > > > Ingo
> > > 
> > > 
> > > Unfortunately, vger mailing lists reject any email with more than 2k of
> > > email headers.  This means if I do what you suggest I can't Cc all
> > > maintainers for all affected files. [...]
> > 
> > You can Cc: linux-arch and lkml for tree-wide changes.
> > 
> > Also, since it's mostly trivial, there shouldn't be much (if any) 
> > controversy about it, right?
> 
> I thought so, too. However, I was just proven wrong and the patchset 
> was nacked. [...]

Well, I only NAK-ed its high-churn presentation, not the essence of it 
which looks good to me.

> [...] Would relevant people notice it if it's just linux-arch? IIUC 
> most people don't read lkml.  I guess Linus would notice and reject 
> it.

Just keep it in a clean, separate topic branch and point it out in the 
pull request - there's no reason to reject good changes, plus with 
this structure:

> > > [...]  I could just Cc all mailing lists I guess, but I really 
> > > wasn't sure about some parts of the change, deferring it until end 
> > > of -rc1 wouldn't be appropriate in this case, would it?
> > 
> > So since 90% of the patches are just a trivial:
> > 
> >   -#include 
> >   +#include 
> > 
> > you can auto-generate that simple rename and file movement into a 
> > single commit, at the end of -rc1, without affecting anyone, via 
> > something like:
> > 
> >   sed -i 's/linux\/pci_ids.h/uapi\/linux\/pci_ids.h/g' $(git grep -l 
> > linux/pci_ids.h)
> >   git mv include/linux/pci_ids.h include/uapi/linux/pci_ids.h
> >   git commit -a
> > 
> > (totally untested)
> > 
> > This should just work.
> >
> > Any other changes, as the removal of inclusions from files that 
> > apparently don't need it, or cleanups like the changing of the guard 
> > defines in pci_id.h, can be done on top of that - on a one patch per 
> > change basis.
> > 
> > This should drastically remove the churn.

it's trivially correct.

I just tried the untested script above and it generates a commit and a 
kernel that builds just fine.

So with that structure my high-churn complaint gets addressed and my 
NAK turns into:

  Acked-by: Ingo Molnar 

Thanks,

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


Re: [PATCH v2] mm: vmscan: do not throttle based on pfmemalloc reserves if node has no reclaimable pages

2015-03-31 Thread Michal Hocko
On Fri 27-03-15 15:23:50, Nishanth Aravamudan wrote:
> On 27.03.2015 [13:17:59 -0700], Dave Hansen wrote:
> > On 03/27/2015 12:28 PM, Nishanth Aravamudan wrote:
> > > @@ -2585,7 +2585,7 @@ static bool pfmemalloc_watermark_ok(pg_data_t 
> > > *pgdat)
> > >  
> > > for (i = 0; i <= ZONE_NORMAL; i++) {
> > > zone = >node_zones[i];
> > > -   if (!populated_zone(zone))
> > > +   if (!populated_zone(zone) || !zone_reclaimable(zone))
> > > continue;
> > >  
> > > pfmemalloc_reserve += min_wmark_pages(zone);
> > 
> > Do you really want zone_reclaimable()?  Or do you want something more
> > direct like "zone_reclaimable_pages(zone) == 0"?
> 
> Yeah, I guess in my testing this worked out to be the same, since
> zone_reclaimable_pages(zone) is 0 and so zone_reclaimable(zone) will
> always be false. Thanks!
> 
> Based upon 675becce15 ("mm: vmscan: do not throttle based on pfmemalloc
> reserves if node has no ZONE_NORMAL") from Mel.
> 
> We have a system with the following topology:
> 
> # numactl -H
> available: 3 nodes (0,2-3)
> node 0 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
> 23 24 25 26 27 28 29 30 31
> node 0 size: 28273 MB
> node 0 free: 27323 MB
> node 2 cpus:
> node 2 size: 16384 MB
> node 2 free: 0 MB
> node 3 cpus: 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
> node 3 size: 30533 MB
> node 3 free: 13273 MB
> node distances:
> node   0   2   3
>   0:  10  20  20
>   2:  20  10  20
>   3:  20  20  10
> 
> Node 2 has no free memory, because:
> # cat 
> /sys/devices/system/node/node2/hugepages/hugepages-16777216kB/nr_hugepages
> 1
> 
> This leads to the following zoneinfo:
> 
> Node 2, zone  DMA
>   pages free 0
> min  1840
> low  2300
> high 2760
> scanned  0
> spanned  262144
> present  262144
> managed  262144
> ...
>   all_unreclaimable: 1

Blee, this is a weird configuration.

> If one then attempts to allocate some normal 16M hugepages via
> 
> echo 37 > /proc/sys/vm/nr_hugepages
> 
> The echo never returns and kswapd2 consumes CPU cycles.
> 
> This is because throttle_direct_reclaim ends up calling
> wait_event(pfmemalloc_wait, pfmemalloc_watermark_ok...).
> pfmemalloc_watermark_ok() in turn checks all zones on the node if there
> are any reserves, and if so, then indicates the watermarks are ok, by
> seeing if there are sufficient free pages.
> 
> 675becce15 added a condition already for memoryless nodes. In this case,
> though, the node has memory, it is just all consumed (and not
> reclaimable). Effectively, though, the result is the same on this call
> to pfmemalloc_watermark_ok() and thus seems like a reasonable additional
> condition.
> 
> With this change, the afore-mentioned 16M hugepage allocation attempt
> succeeds and correctly round-robins between Nodes 1 and 3.

I am just wondering whether this is the right/complete fix. Don't we
need a similar treatment at more places?
I would expect kswapd would be looping endlessly because the zone
wouldn't be balanced obviously. But I would be wrong... because
pgdat_balanced is doing this:
/*
 * A special case here:
 *
 * balance_pgdat() skips over all_unreclaimable after
 * DEF_PRIORITY. Effectively, it considers them balanced so
 * they must be considered balanced here as well!
 */
if (!zone_reclaimable(zone)) {
balanced_pages += zone->managed_pages;
continue;
}

and zone_reclaimable is false for you as you didn't have any
zone_reclaimable_pages(). But wakeup_kswapd doesn't do this check so it
would see !zone_balanced() AFAICS (build_zonelists doesn't ignore those
zones right?) and so the kswapd would be woken up easily. So it looks
like a mess.

There are possibly other places which rely on populated_zone or
for_each_populated_zone without checking reclaimability. Are those
working as expected?

That being said. I am not objecting to this patch. I am just trying to
wrap my head around possible issues from such a weird configuration and
all the consequences.

> Signed-off-by: Nishanth Aravamudan 

The patch as is doesn't seem to be harmful.

Reviewed-by: Michal Hocko 

> ---
> v1 -> v2:
>   Check against zone_reclaimable_pages, rather zone_reclaimable, based
>   upon feedback from Dave Hansen.

Dunno, but shouldn't we use the same thing here and in pgdat_balanced?
zone_reclaimable_pages seems to be used only from zone_reclaimable().

> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 5e8eadd71bac..c627fa4c991f 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -2646,7 +2646,8 @@ static bool pfmemalloc_watermark_ok(pg_data_t *pgdat)
>  
>   for (i = 0; i <= ZONE_NORMAL; i++) {
>   zone = >node_zones[i];
> - if (!populated_zone(zone))
> + 

Re: [PATCH 0/6] virtio_balloon: virtio 1 support

2015-03-31 Thread Michael S. Tsirkin
On Tue, Mar 31, 2015 at 10:46:18AM +0200, Cornelia Huck wrote:
> On Mon, 30 Mar 2015 19:37:08 +0200
> "Michael S. Tsirkin"  wrote:
> 
> > Virtio 1.0 doesn't include a modern balloon device.
> > At some point we'll likely define an incompatible interface with a different
> > ID.  But for now, it's not a big change to support a transitional balloon
> > device: this has the advantage of supporting existing drivers, 
> > transparently.
> 
> This is needed to support a ballooner on transports that don't support
> mixing legacy and 1.0, right?

That too. But it's also useful if you don't know whether your guest
supports virtio 1 or not - which is the point of using
a transitional device.

> > 
> > The only issue is with the stats buffer, which has misaligned fields.
> > Seems easy to fix by prepending a 6 byte reserved field.
> 
> I assume you also define the stats fields to be le for 1.0?

They were always le for the balloon.

> > 
> > I'll post spec patch and qemu patches shortly.
> 
> I'll defer review until then.
> 
> > 
> > Michael S. Tsirkin (6):
> >   virtio_balloon: transitional interface
> >   virtio: balloon might not be a legacy device
> >   virtio_ccw: support non-legacy balloon devices
> >   virtio_mmio: support non-legacy balloon devices
> >   virtio_pci: support non-legacy balloon devices
> >   virtio: drop virtio_device_is_legacy_only
> > 
> >  include/linux/virtio.h  |  2 --
> >  include/uapi/linux/virtio_balloon.h |  6 ++
> >  drivers/s390/kvm/virtio_ccw.c   | 10 +++---
> >  drivers/virtio/virtio.c |  6 --
> >  drivers/virtio/virtio_balloon.c |  8 ++--
> >  drivers/virtio/virtio_mmio.c|  8 
> >  drivers/virtio/virtio_pci_modern.c  |  3 ---
> >  7 files changed, 15 insertions(+), 28 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 05/86] x86/gart: use uapi/linux/pci_ids.h directly

2015-03-31 Thread Michael S. Tsirkin
On Tue, Mar 31, 2015 at 10:34:45AM +0200, Ingo Molnar wrote:
> 
> * Michael S. Tsirkin  wrote:
> 
> > On Mon, Mar 30, 2015 at 07:29:36AM +0200, Ingo Molnar wrote:
> > > 
> > > * Michael S. Tsirkin  wrote:
> > > 
> > > > Header moved from linux/pci_ids.h to uapi/linux/pci_ids.h,
> > > > use the new header directly so we can drop
> > > > the wrapper in include/linux/pci_ids.h.
> > > > 
> > > > Signed-off-by: Michael S. Tsirkin 
> > > > ---
> > > >  arch/x86/kernel/aperture_64.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/arch/x86/kernel/aperture_64.c 
> > > > b/arch/x86/kernel/aperture_64.c
> > > > index 76164e1..3b52a56 100644
> > > > --- a/arch/x86/kernel/aperture_64.c
> > > > +++ b/arch/x86/kernel/aperture_64.c
> > > > @@ -17,7 +17,7 @@
> > > >  #include 
> > > >  #include 
> > > >  #include 
> > > > -#include 
> > > > +#include 
> > > >  #include 
> > > >  #include 
> > > >  #include 
> > > > -- 
> > > > MST
> > > > 
> > > 
> > > NAK, it's absolutely ridiculous to send a 86 patches series for a 
> > > trivial change like this!
> > > 
> > > Just do the rename in a single patch and avoid the churn. Even if 
> > > there are conflicts, they are utmost trivial to fix up.
> > > 
> > > In fact the usual way to do such renames is to wait until the end of 
> > > -rc1, auto-generate it and send Linus the core patch with the trivial 
> > > renames straight away.
> > > 
> > > Thanks,
> > > 
> > >   Ingo
> > 
> > 
> > Unfortunately, vger mailing lists reject any email with more than 2k of
> > email headers.  This means if I do what you suggest I can't Cc all
> > maintainers for all affected files. [...]
> 
> You can Cc: linux-arch and lkml for tree-wide changes.
> 
> Also, since it's mostly trivial, there shouldn't be much (if any) 
> controversy about it, right?

I thought so, too. However, I was just proven wrong and the patchset
was nacked. Would relevant people notice it if it's just linux-arch?
IIUC most people don't read lkml.  I guess Linus would notice
and reject it.


> > [...]  I could just Cc all mailing lists I guess, but I really 
> > wasn't sure about some parts of the change, deferring it until end 
> > of -rc1 wouldn't be appropriate in this case, would it?
> 
> So since 90% of the patches are just a trivial:
> 
>   -#include 
>   +#include 
> 
> you can auto-generate that simple rename and file movement into a 
> single commit, at the end of -rc1, without affecting anyone, via 
> something like:
> 
>   sed -i 's/linux\/pci_ids.h/uapi\/linux\/pci_ids.h/g' $(git grep -l 
> linux/pci_ids.h)
>   git mv include/linux/pci_ids.h include/uapi/linux/pci_ids.h
>   git commit -a
> 
> (totally untested)
> 
> This should just work.
>
> Any other changes, as the removal of inclusions from files that 
> apparently don't need it, or cleanups like the changing of the guard 
> defines in pci_id.h, can be done on top of that - on a one patch per 
> change basis.
> 
> This should drastically remove the churn.
> 
> What do you think?
> 
> Thanks,
> 
>   Ingo


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


Re: [PATCH v2 2/3] rtc: mediatek: Add MT6397 RTC driver

2015-03-31 Thread Eddie Huang
Hi Tomasz,

On Mon, 2015-03-30 at 16:41 +0900, Tomasz Figa wrote:
> Hi Eddie,
> 
> Please see my comments inline.
> 
> On Wed, Mar 18, 2015 at 2:45 PM, Eddie Huang  wrote:
> > From: Tianping Fang 
> >
> > Add Mediatek MT6397 RTC driver
> 
> [snip]
> 
> > +#define RTC_BBPU   0x
> > +#define RTC_WRTGR  0x003c
> > +#define RTC_IRQ_EN 0x0004
> > +#define RTC_IRQ_STA0x0002
> > +
> > +#define RTC_BBPU_CBUSY (1 << 6)
> > +#define RTC_IRQ_STA_AL (1 << 0)
> > +#define RTC_IRQ_STA_LP (1 << 3)
> 
> nit: Could you use BIT() macro for definitions of single bits? (+
> further occurrences in the patch)
Will fix it.

> 
> [snip]
> 
> > +
> > +static int mtk_rtc_read(struct mt6397_rtc *rtc, u32 offset, u32 *data)
> > +{
> > +   u32 addr = rtc->addr_base + offset;
> > +
> > +   if (offset < rtc->addr_range)
> > +   return regmap_read(rtc->regmap, addr, data);
> > +
> > +   return -EINVAL;
> > +}
> > +
> > +static int mtk_rtc_write(struct mt6397_rtc *rtc, u32 offset, u32 data)
> > +{
> > +   u32 addr;
> > +
> > +   addr = rtc->addr_base + offset;
> > +
> > +   if (offset < rtc->addr_range)
> > +   return regmap_write(rtc->regmap, addr, data);
> > +
> > +   return -EINVAL;
> > +}
> 
> Do you actually need these wrappers? Could you use regmap_write() and
> _read() directly? This would also enable you to use
> regmap_update_bits() instead of implicit read, modify and write.
These wrappers used to check register range. But I think the check is
redundant, I will bypass the check and use regmap API directly.

> 
> > +
> > +static int mtk_rtc_write_trigger(struct mt6397_rtc *rtc)
> > +{
> > +   int ret;
> > +   u32 data;
> > +
> > +   ret = mtk_rtc_write(rtc, RTC_WRTGR, 1);
> > +   if (ret < 0)
> > +   goto exit;
> > +
> > +   ret = mtk_rtc_read(rtc, RTC_BBPU, );
> > +   if (ret < 0)
> > +   goto exit;
> > +
> > +   while (data & RTC_BBPU_CBUSY) {
> > +   cpu_relax();
> > +   ret = mtk_rtc_read(rtc, RTC_BBPU, );
> > +   if (ret < 0)
> > +   goto exit;
> > +   }
> 
> The initial read and the loop could be folded into a do {} while loop?
> Also it would be safer to have a timeout here.
Because I need to check return value, so not put initial read in do { }.
Indeed, it is safer to add timeout here.


> > +
> > +static int __mtk_rtc_read_time(struct mt6397_rtc *rtc,
> > +   struct rtc_time *tm, int *sec)
> > +{
> > +   int ret;
> > +
> > +   mutex_lock(>lock);
> > +   ret = mtk_rtc_read(rtc, RTC_TC_SEC, >tm_sec);
> > +   if (ret < 0)
> > +   goto exit;
> > +   ret = mtk_rtc_read(rtc, RTC_TC_MIN, >tm_min);
> > +   if (ret < 0)
> > +   goto exit;
> > +   ret = mtk_rtc_read(rtc, RTC_TC_HOU, >tm_hour);
> > +   if (ret < 0)
> > +   goto exit;
> > +   ret = mtk_rtc_read(rtc, RTC_TC_DOM, >tm_mday);
> > +   if (ret < 0)
> > +   goto exit;
> > +   ret = mtk_rtc_read(rtc, RTC_TC_MTH, >tm_mon);
> > +   if (ret < 0)
> > +   goto exit;
> > +   ret = mtk_rtc_read(rtc, RTC_TC_YEA, >tm_year);
> > +   if (ret < 0)
> > +   goto exit;
> > +   ret = mtk_rtc_read(rtc, RTC_TC_SEC, sec);
> 
> Would the hardware allow this to be merged into single burst transfer
> reading all the registers into a buffer, so then you could just copy
> the values from that buffer into target struct instead of issuing
> multiple reads one by one?
OK, Sascha already mentioned this before, I think I should change to use
single burst reading.

> 
> Also shouldn't the unused bits be masked out?
Hardware return zero in unused bits. So I think it not necessary to add
mask.

> 
> > +
> > +exit:
> > +   mutex_unlock(>lock);
> > +   return ret;
> > +}
> > +
> > +static int mtk_rtc_read_time(struct device *dev, struct rtc_time *tm)
> > +{
> > +   time64_t time;
> > +   struct mt6397_rtc *rtc = dev_get_drvdata(dev);
> > +   int sec, ret;
> > +
> > +   do {
> > +   ret = __mtk_rtc_read_time(rtc, tm, );
> > +   if (ret < 0)
> > +   goto exit;
> > +   } while (sec < tm->tm_sec);
> 
> Shouldn't this be while (sec > tm->tm_sec)?
No, it should keep it as is, this is used to check whether second
overflow (from 59 to 0). If yes, read time again.

> 
> > +
> > +   tm->tm_year += RTC_MIN_YEAR_OFFSET;
> > +   tm->tm_mon--;
> 
> Could you add a comment explaining why this is decremented?
Year register only have 7bits, use RTC_MIN_YEAR_OFFSET to reduce bit
usage. Minus the offset before write to register and add back the offset
after read register back. And month register start from 1, but tm_mon
start from zero. I will add comment.

> 
> > +   time = rtc_tm_to_time64(tm);
> > +
> > +   tm->tm_wday = (time / 86400 + 4) % 

Re: [PATCH 7/7] staging: comedi: comedi_fops: extend spin-lock scope in comedi_event()

2015-03-31 Thread Ian Abbott

On 30/03/15 17:47, Hartley Sweeten wrote:

On Friday, March 27, 2015 8:13 AM, Ian Abbott wrote:

`comedi_event()` is called from low-level drivers to handle comedi
asynchronous command event flags.  As a safety check, it checks the
subdevice's "run" flags to make sure an asynchronous command is running.
It can also change the run flags to mark the command as no longer
running (possibly also marking it as terminated with an error).
Checking the runflags and modifying them involves two uses of the
subdevice's spin-lock.  It seems better to do it with a single use of
the spin-lock.  This also avoids possible interactions with
`do_become_nonbusy()`.

Acquire the subdevice's spin-lock at the start of `comedi_event()` and
release it near the end, before a possible call to `kill_fasync()` (but
after it's parameter values have been determined).

Add and make use of few new inline helper functions:

* `__comedi_clear_subdevice_runflags()` -- clears some run flags without
   using the spin-lock
* `__comedi_set_subdevice_runflags()` -- sets some run flags without
   using the spin-lock
* `__comedi_get_subdevice_runflags()` -- a spin-lockless version of
   `comedi_get_subdevice_runflags()
* `__comedi_is_subdevice_running()` -- a spin-lockless version of
* `comedi_is_subdevice_running()`

Signed-off-by: Ian Abbott 


Ian,

For completeness, the comedi_alloc_spriv() helper should probably use
__comedi_set_subdevice_runflags() to set the COMEDI_SRF_FREE_SPRIV
bit.

Regards,
Hartley



Good point.  "drivers/staging/comedi/drivers.c" also reads the runflags 
directly, so perhaps __comedi_clear_subdevice_runflags(), 
__comedi_set_subdevice_runflags() and __comedi_get_subdevice_runflags() 
should be placed in "drivers/staging/comedi/comedi_internal.h".  Or we 
could ditch all three of those inline functions as they are just simple 
one-liners.


--
-=( Ian Abbott @ MEV Ltd.E-mail:  )=-
-=(  Web: http://www.mev.co.uk/  )=-
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: [GIT PULL] clockevents for 4.1

2015-03-31 Thread Ingo Molnar

* Daniel Lezcano  wrote:

> On 03/31/2015 09:17 AM, Ingo Molnar wrote:
> >
> >* Daniel Lezcano  wrote:
> >
> >>
> >>Hi Thomas, Ingo,
> >>
> >>this pull request contains the following changes for 4.1:
> >>
> >>  - Made IO endian agnostic for at91 and dw apb timers (Ben Dooks)
> >>
> >>  - Maintained tegra endianess (Dmitry Osipenko)
> >>
> >>  - Enabled the sun4i / sun5i timer for sched_clock, all others winner 
> >> boards
> >>have the arch arm timer which is more accurate (Hans de Goede)
> >>
> >>  - Renamed the arch arm timer function name to reflect better its purpose
> >>(Laurent Pinchart)
> >>
> >>  - Cleaned up the sun5i timer code, replaced the setup_irq by the
> >>request_irq function and handled the parent clock frequency change with the
> >>frequency notifiers (Maxime Ripard)
> >>
> >>  - Fixed features declaration for the efm32 timer (Viresh Kumar)
> >>
> >>Thanks !
> >
> >So I had some comments about one of the patches, and fixes to
> >changelogs, so I've applied all but the sun4/5i patches from email to
> >move things forward.
> 
> The subsystem prefix is now 'clocksource/drivers/' ?

At least now that we have a good number of clocksource drivers, for 
such pure driver changes that's the logical prefix and makes it easier 
to tell apart clocksource core changes from driver changes.

> > The sun4/5i patches conflicted - mind reposting those merged on 
> > top of the latest tip:timers:core tree?
> 
> Yes, sure. No problem.

Thanks!

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


[PATCH] pinctrl: Add support for PM8916 GPIO's and MPP's

2015-03-31 Thread Ivan T. Ivanov
Add compatible string definitions and supported pin functions.

Signed-off-by: Ivan T. Ivanov 
---
 .../devicetree/bindings/pinctrl/qcom,pmic-gpio.txt|  2 ++
 .../devicetree/bindings/pinctrl/qcom,pmic-mpp.txt |  2 ++
 drivers/pinctrl/qcom/pinctrl-spmi-gpio.c  |  1 +
 drivers/pinctrl/qcom/pinctrl-spmi-mpp.c   |  1 +
 include/dt-bindings/pinctrl/qcom,pmic-gpio.h  | 15 +++
 include/dt-bindings/pinctrl/qcom,pmic-mpp.h   |  4 
 6 files changed, 25 insertions(+)

diff --git a/Documentation/devicetree/bindings/pinctrl/qcom,pmic-gpio.txt 
b/Documentation/devicetree/bindings/pinctrl/qcom,pmic-gpio.txt
index 7ed0804..1ae63c0 100644
--- a/Documentation/devicetree/bindings/pinctrl/qcom,pmic-gpio.txt
+++ b/Documentation/devicetree/bindings/pinctrl/qcom,pmic-gpio.txt
@@ -10,6 +10,7 @@ PMIC's from Qualcomm.
"qcom,pm8018-gpio"
"qcom,pm8038-gpio"
"qcom,pm8058-gpio"
+   "qcom,pm8916-gpio"
"qcom,pm8917-gpio"
"qcom,pm8921-gpio"
"qcom,pm8941-gpio"
@@ -74,6 +75,7 @@ to specify in a pin configuration subnode:
gpio1-gpio6 for pm8018
gpio1-gpio12 for pm8038
gpio1-gpio40 for pm8058
+   gpio1-gpio4 for pm8916
gpio1-gpio38 for pm8917
gpio1-gpio44 for pm8921
gpio1-gpio36 for pm8941
diff --git a/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt 
b/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt
index 854774b..ed19991 100644
--- a/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt
+++ b/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt
@@ -8,6 +8,7 @@ of PMIC's from Qualcomm.
Value type: 
Definition: Should contain one of:
"qcom,pm8841-mpp",
+   "qcom,pm8916-mpp",
"qcom,pm8941-mpp",
"qcom,pma8084-mpp",

@@ -67,6 +68,7 @@ to specify in a pin configuration subnode:
Definition: List of MPP pins affected by the properties specified in
this subnode.  Valid pins are:
mpp1-mpp4 for pm8841
+   mpp1-mpp4 for pm8916
mpp1-mpp8 for pm8941
mpp1-mpp4 for pma8084

diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c 
b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
index 0f11a26..b2d2221 100644
--- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
+++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
@@ -810,6 +810,7 @@ static int pmic_gpio_remove(struct platform_device *pdev)
 }

 static const struct of_device_id pmic_gpio_of_match[] = {
+   { .compatible = "qcom,pm8916-gpio" },   /* 4 GPIO's */
{ .compatible = "qcom,pm8941-gpio" },   /* 36 GPIO's */
{ .compatible = "qcom,pma8084-gpio" },  /* 22 GPIO's */
{ },
diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c 
b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
index a8924db..8f36c5f 100644
--- a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
+++ b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
@@ -925,6 +925,7 @@ static int pmic_mpp_remove(struct platform_device *pdev)

 static const struct of_device_id pmic_mpp_of_match[] = {
{ .compatible = "qcom,pm8841-mpp" },/* 4 MPP's */
+   { .compatible = "qcom,pm8916-mpp" },/* 4 MPP's */
{ .compatible = "qcom,pm8941-mpp" },/* 8 MPP's */
{ .compatible = "qcom,pma8084-mpp" },   /* 8 MPP's */
{ },
diff --git a/include/dt-bindings/pinctrl/qcom,pmic-gpio.h 
b/include/dt-bindings/pinctrl/qcom,pmic-gpio.h
index fa74d7c..aafa76c 100644
--- a/include/dt-bindings/pinctrl/qcom,pmic-gpio.h
+++ b/include/dt-bindings/pinctrl/qcom,pmic-gpio.h
@@ -48,6 +48,14 @@
 #define PM8058_GPIO_L5 6
 #define PM8058_GPIO_L2 7

+/*
+ * Note: PM8916 GPIO1 and GPIO2 are supporting
+ * only L2(1.15V) and L5(1.8V) options
+ */
+#define PM8916_GPIO_VPH0
+#define PM8916_GPIO_L2 2
+#define PM8916_GPIO_L5 3
+
 #define PM8917_GPIO_VPH0
 #define PM8917_GPIO_S4 2
 #define PM8917_GPIO_L153
@@ -115,6 +123,13 @@
 #define PM8058_GPIO39_MP3_CLK  PMIC_GPIO_FUNC_FUNC1
 #define PM8058_GPIO40_EXT_BB_ENPMIC_GPIO_FUNC_FUNC1

+#define PM8916_GPIO1_BAT_ALRM_OUT  PMIC_GPIO_FUNC_FUNC1
+#define PM8916_GPIO1_KEYP_DRV  PMIC_GPIO_FUNC_FUNC2
+#define PM8916_GPIO2_DIV_CLK   PMIC_GPIO_FUNC_FUNC1
+#define PM8916_GPIO2_SLEEP_CLK PMIC_GPIO_FUNC_FUNC2
+#define PM8916_GPIO3_KEYP_DRV  PMIC_GPIO_FUNC_FUNC1
+#define PM8916_GPIO4_KEYP_DRV  PMIC_GPIO_FUNC_FUNC2
+
 #define PM8917_GPIO9_18_KEYP_DRV   PMIC_GPIO_FUNC_FUNC1
 #define PM8917_GPIO20_BAT_ALRM_OUT PMIC_GPIO_FUNC_FUNC1
 #define 

Re: [GIT PULL] clockevents for 4.1

2015-03-31 Thread Daniel Lezcano

On 03/31/2015 09:17 AM, Ingo Molnar wrote:


* Daniel Lezcano  wrote:



Hi Thomas, Ingo,

this pull request contains the following changes for 4.1:

  - Made IO endian agnostic for at91 and dw apb timers (Ben Dooks)

  - Maintained tegra endianess (Dmitry Osipenko)

  - Enabled the sun4i / sun5i timer for sched_clock, all others winner boards
have the arch arm timer which is more accurate (Hans de Goede)

  - Renamed the arch arm timer function name to reflect better its purpose
(Laurent Pinchart)

  - Cleaned up the sun5i timer code, replaced the setup_irq by the
request_irq function and handled the parent clock frequency change with the
frequency notifiers (Maxime Ripard)

  - Fixed features declaration for the efm32 timer (Viresh Kumar)

Thanks !


So I had some comments about one of the patches, and fixes to
changelogs, so I've applied all but the sun4/5i patches from email to
move things forward.


The subsystem prefix is now 'clocksource/drivers/' ?


The sun4/5i patches conflicted - mind reposting those merged on top of
the latest tip:timers:core tree?


Yes, sure. No problem.

Thanks !

  -- Daniel


--
  Linaro.org │ Open source software for ARM SoCs

Follow Linaro:   Facebook |
 Twitter |
 Blog

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


Re: [PATCH v2 1/2] clk: fractional-divider: switch to rational best approximation

2015-03-31 Thread Andy Shevchenko
On Tue, 2015-03-31 at 10:42 +0300, Andy Shevchenko wrote:
> On Tue, Mar 31, 2015 at 3:32 AM, Stephen Boyd  wrote:
> > On 03/30/15 11:57, Andy Shevchenko wrote:
> >> This patch converts the code to use rational best approximation algorithm 
> >> which
> >> is more precise.
> 
> >> --- a/drivers/clk/Kconfig
> >> +++ b/drivers/clk/Kconfig
> >> @@ -14,6 +14,7 @@ config COMMON_CLK
> >>   select HAVE_CLK_PREPARE
> >>   select CLKDEV_LOOKUP
> >>   select SRCU
> >> + select RATIONAL
> >>   ---help---
> >> The common clock framework is a single definition of struct
> >> clk, useful across many platforms, as well as an
> >> @@ -63,7 +64,6 @@ config COMMON_CLK_SI5351
> >>   tristate "Clock driver for SiLabs 5351A/B/C"
> >>   depends on I2C
> >>   select REGMAP_I2C
> >> - select RATIONAL
> >>   ---help---
> >> This driver supports Silicon Labs 5351A/B/C programmable clock
> >> generators.
> >> @@ -139,7 +139,6 @@ config COMMON_CLK_CDCE706
> >>   tristate "Clock driver for TI CDCE706 clock synthesizer"
> >>   depends on I2C
> >>   select REGMAP_I2C
> >> - select RATIONAL
> >>   ---help---
> >> This driver supports TI CDCE706 programmable 3-PLL clock 
> >> synthesizer.
> >
> > Will some kernel janitor find us if we leave the selects here? I know
> > you removed it because COMMON_CLK must be Y here and we'd always select
> > RATIONAL, but it feels better to leave it alone and actually split off
> > the basic clock types into individual configs so that the tiny kernel
> > users don't have unused code lying around. That could be future work
> > someday and then we might forget to select RATIONAL again.
> 
> I'm fine with that as well. So, do I need to resend or you apply
> modified version?

There are couple of issues with arithmetics, such as we can't use
mult_frac() because of potential overflow on 32 bit kernels, so I will
resend new version.

-- 
Andy Shevchenko 
Intel Finland Oy

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


Re: [PATCH 3/4] extcon: usb-gpio: make debounce value configurable in devicetree

2015-03-31 Thread Roger Quadros
On 31/03/15 10:46, Robert Baldyga wrote:
> This patch adds devicetree property for setting debounce value. It allows
> to set debounce time shorter or longer depending on the needs of given
> platform.
> 
> Signed-off-by: Robert Baldyga 
> ---
>  drivers/extcon/extcon-usb-gpio.c | 14 +-
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-usb-gpio.c 
> b/drivers/extcon/extcon-usb-gpio.c
> index 02ff40e..86e3ece 100644
> --- a/drivers/extcon/extcon-usb-gpio.c
> +++ b/drivers/extcon/extcon-usb-gpio.c
> @@ -130,6 +130,7 @@ static int usb_extcon_probe(struct platform_device *pdev)
>   struct device *dev = >dev;
>   struct device_node *np = dev->of_node;
>   struct usb_extcon_info *info;
> + u32 debounce;
>   int ret;
>  
>   if (!np)
> @@ -140,6 +141,11 @@ static int usb_extcon_probe(struct platform_device *pdev)
>   return -ENOMEM;
>  
>   info->dev = dev;
> +
> + ret = of_property_read_u32(np, "debounce", );
> + if (ret < 0)
> + debounce = USB_GPIO_DEBOUNCE_MS;
> +

Should we sanity check debounce value provided by device tree?
e.g. if it is greater than USB_GPIO_DEBOUNCE_MAX then we error out.
MAX could be 100 or 250ms.

>   info->id_gpiod = devm_gpiod_get_optional(>dev, "id");
>   info->vbus_gpiod = devm_gpiod_get_optional(>dev, "vbus");
>  
> @@ -161,16 +167,14 @@ static int usb_extcon_probe(struct platform_device 
> *pdev)
>   }
>  
>   if (info->id_gpiod)
> - ret = gpiod_set_debounce(info->id_gpiod,
> - USB_GPIO_DEBOUNCE_MS * 1000);
> + ret = gpiod_set_debounce(info->id_gpiod, debounce * 1000);
>   if (!ret && info->vbus_gpiod) {
> - ret = gpiod_set_debounce(info->vbus_gpiod,
> - USB_GPIO_DEBOUNCE_MS * 1000);
> + ret = gpiod_set_debounce(info->vbus_gpiod, debounce * 1000);
>   if (ret < 0 && info->id_gpiod)
>   gpiod_set_debounce(info->vbus_gpiod, 0);
>   }
>   if (ret < 0)
> - info->debounce_jiffies = msecs_to_jiffies(USB_GPIO_DEBOUNCE_MS);
> + info->debounce_jiffies = msecs_to_jiffies(debounce);
>  
>   INIT_DELAYED_WORK(>wq_detcable, usb_extcon_detect_cable);
>  
> 

cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: another pmem variant V2

2015-03-31 Thread Christoph Hellwig
On Thu, Mar 26, 2015 at 06:57:47PM +0200, Boaz Harrosh wrote:
> On 03/26/2015 10:32 AM, Christoph Hellwig wrote:
> > Here is another version of the same trivial pmem driver, because two
> > obviously aren't enough.  The first patch is the same pmem driver
> > that Ross posted a short time ago, just modified to use platform_devices
> > to find the persistant memory region instead of hardconding it in the
> > Kconfig.  This allows to keep pmem.c separate from any discovery mechanism,
> > but still allow auto-discovery.
> > 
> 
> Hi Christoph
> 
> So I've been trying to test your version, and play around with it.
> I currently have some problems, but this is the end of the week for me
> so I will debug and fix it after the weekend on Sunday.

Any news?  I'd really like to resend this ASAP to get it into 4.1..
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] kvm: avoid page allocation failure in kvm_set_memory_region()

2015-03-31 Thread Igor Mammedov
On Fri, 20 Mar 2015 12:21:37 +
Igor Mammedov  wrote:

> KVM guest can fail to startup with following trace on host:
> 
> qemu-system-x86: page allocation failure: order:4, mode:0x40d0
> Call Trace:
>   dump_stack+0x47/0x67
>   warn_alloc_failed+0xee/0x150
>   __alloc_pages_direct_compact+0x14a/0x150
>   __alloc_pages_nodemask+0x776/0xb80
>   alloc_kmem_pages+0x3a/0x110
>   kmalloc_order+0x13/0x50
>   kmemdup+0x1b/0x40
>   __kvm_set_memory_region+0x24a/0x9f0 [kvm]
>   kvm_set_ioapic+0x130/0x130 [kvm]
>   kvm_set_memory_region+0x21/0x40 [kvm]
>   kvm_vm_ioctl+0x43f/0x750 [kvm]
> 
> Failure happens when attempting to allocate pages for
> 'struct kvm_memslots', however it doesn't have to be
> present in physically contiguous (kmalloc-ed) address
> space, change allocation to kvm_kvzalloc() so that
> it will be vmalloc-ed when its size is more then a page.
> 
> Signed-off-by: Igor Mammedov 
ping


> ---
> v2:
>  - alloc initial memslots with vmalloc
>  - use kvfree in every place where memslots are freed
> 
> TODO:
>  - work on follow up patches to allocate space for
>actual amount of memory_slots instead of possible maximum.
> ---
>  virt/kvm/kvm_main.c | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index a2214d9..cc6a25d 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -471,7 +471,7 @@ static struct kvm *kvm_create_vm(unsigned long
> type) BUILD_BUG_ON(KVM_MEM_SLOTS_NUM > SHRT_MAX);
>  
>   r = -ENOMEM;
> - kvm->memslots = kzalloc(sizeof(struct kvm_memslots),
> GFP_KERNEL);
> + kvm->memslots = kvm_kvzalloc(sizeof(struct kvm_memslots));
>   if (!kvm->memslots)
>   goto out_err_no_srcu;
>  
> @@ -522,7 +522,7 @@ out_err_no_srcu:
>  out_err_no_disable:
>   for (i = 0; i < KVM_NR_BUSES; i++)
>   kfree(kvm->buses[i]);
> - kfree(kvm->memslots);
> + kvfree(kvm->memslots);
>   kvm_arch_free_vm(kvm);
>   return ERR_PTR(r);
>  }
> @@ -578,7 +578,7 @@ static void kvm_free_physmem(struct kvm *kvm)
>   kvm_for_each_memslot(memslot, slots)
>   kvm_free_physmem_slot(kvm, memslot, NULL);
>  
> - kfree(kvm->memslots);
> + kvfree(kvm->memslots);
>  }
>  
>  static void kvm_destroy_devices(struct kvm *kvm)
> @@ -871,10 +871,10 @@ int __kvm_set_memory_region(struct kvm *kvm,
>   goto out_free;
>   }
>  
> - slots = kmemdup(kvm->memslots, sizeof(struct kvm_memslots),
> - GFP_KERNEL);
> + slots = kvm_kvzalloc(sizeof(struct kvm_memslots));
>   if (!slots)
>   goto out_free;
> + memcpy(slots, kvm->memslots, sizeof(struct kvm_memslots));
>  
>   if ((change == KVM_MR_DELETE) || (change == KVM_MR_MOVE)) {
>   slot = id_to_memslot(slots, mem->slot);
> @@ -917,7 +917,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
>   kvm_arch_commit_memory_region(kvm, mem, , change);
>  
>   kvm_free_physmem_slot(kvm, , );
> - kfree(old_memslots);
> + kvfree(old_memslots);
>  
>   /*
>* IOMMU mapping:  New slots need to be mapped.  Old slots
> need to be @@ -936,7 +936,7 @@ int __kvm_set_memory_region(struct kvm
> *kvm, return 0;
>  
>  out_slots:
> - kfree(slots);
> + kvfree(slots);
>  out_free:
>   kvm_free_physmem_slot(kvm, , );
>  out:

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


<    5   6   7   8   9   10   11   12   13   14   >