Re: [Cluster-devel] gfs2: gfs2_dir_get_hash_table(): avoiding deferred vfree() is easy here...
- Original Message - vfree() is allowed under spinlock these days, but it's cheaper when it doesn't step into deferred case and here it's very easy to avoid. Signed-off-by: Al Viro v...@zeniv.linux.org.uk --- fs/gfs2/dir.c |7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index c247fed..c5a34f0 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c @@ -370,11 +370,12 @@ static __be64 *gfs2_dir_get_hash_table(struct gfs2_inode *ip) } spin_lock(inode-i_lock); - if (ip-i_hash_cache) - kvfree(hc); - else + if (likely(!ip-i_hash_cache)) { ip-i_hash_cache = hc; + hc = NULL; + } spin_unlock(inode-i_lock); + kvfree(hc); return ip-i_hash_cache; } -- 1.7.10.4 ACK Bob Peterson Red Hat File Systems -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@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: [Cluster-devel] gfs2: use kvfree() instead of open-coding it
- Original Message - Signed-off-by: Al Viro v...@zeniv.linux.org.uk --- fs/gfs2/dir.c | 40 fs/gfs2/quota.c |9 ++--- 2 files changed, 10 insertions(+), 39 deletions(-) diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index 5d4261f..c247fed 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c @@ -365,22 +365,15 @@ static __be64 *gfs2_dir_get_hash_table(struct gfs2_inode *ip) ret = gfs2_dir_read_data(ip, hc, hsize); if (ret 0) { - if (is_vmalloc_addr(hc)) - vfree(hc); - else - kfree(hc); + kvfree(hc); return ERR_PTR(ret); } spin_lock(inode-i_lock); - if (ip-i_hash_cache) { - if (is_vmalloc_addr(hc)) - vfree(hc); - else - kfree(hc); - } else { + if (ip-i_hash_cache) + kvfree(hc); + else ip-i_hash_cache = hc; - } spin_unlock(inode-i_lock); return ip-i_hash_cache; @@ -396,10 +389,7 @@ void gfs2_dir_hash_inval(struct gfs2_inode *ip) { __be64 *hc = ip-i_hash_cache; ip-i_hash_cache = NULL; - if (is_vmalloc_addr(hc)) - vfree(hc); - else - kfree(hc); + kvfree(hc); } static inline int gfs2_dirent_sentinel(const struct gfs2_dirent *dent) @@ -1168,10 +1158,7 @@ fail: gfs2_dinode_out(dip, dibh-b_data); brelse(dibh); out_kfree: - if (is_vmalloc_addr(hc2)) - vfree(hc2); - else - kfree(hc2); + kvfree(hc2); return error; } @@ -1302,14 +1289,6 @@ static void *gfs2_alloc_sort_buffer(unsigned size) return ptr; } -static void gfs2_free_sort_buffer(void *ptr) -{ - if (is_vmalloc_addr(ptr)) - vfree(ptr); - else - kfree(ptr); -} - static int gfs2_dir_read_leaf(struct inode *inode, struct dir_context *ctx, int *copied, unsigned *depth, u64 leaf_no) @@ -1393,7 +1372,7 @@ static int gfs2_dir_read_leaf(struct inode *inode, struct dir_context *ctx, out_free: for(i = 0; i leaf; i++) brelse(larr[i]); - gfs2_free_sort_buffer(larr); + kvfree(larr); out: return error; } @@ -2004,10 +1983,7 @@ out_rlist: gfs2_rlist_free(rlist); gfs2_quota_unhold(dip); out: - if (is_vmalloc_addr(ht)) - vfree(ht); - else - kfree(ht); + kvfree(ht); return error; } diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 64b29f7..c8b148b 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -1360,13 +1360,8 @@ void gfs2_quota_cleanup(struct gfs2_sbd *sdp) gfs2_assert_warn(sdp, !atomic_read(sdp-sd_quota_count)); - if (sdp-sd_quota_bitmap) { - if (is_vmalloc_addr(sdp-sd_quota_bitmap)) - vfree(sdp-sd_quota_bitmap); - else - kfree(sdp-sd_quota_bitmap); - sdp-sd_quota_bitmap = NULL; - } + kvfree(sdp-sd_quota_bitmap); + sdp-sd_quota_bitmap = NULL; } static void quotad_error(struct gfs2_sbd *sdp, const char *msg, int error) -- 1.7.10.4 ACK Bob Peterson Red Hat File Systems -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@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 00/16] Refine PCI host bridge scan interfaces
On Thursday 20 November 2014 13:01:08 Tomasz Nowicki wrote: On 18.11.2014 13:27, Arnd Bergmann wrote: On Tuesday 18 November 2014 20:17:57 Yijing Wang wrote: I hope platforms with ACPI or DT could both use pci_create_host_bridge(). Why we need to use two different ways to process it ? These are completely different use cases: a) For DT, we want loadable device drivers that start by probing a host bridge device which was added through the DT platform code. The driver is self-contained, and eventually we want to be able to unload it. We have lots of different per-soc drivers that require different quirks b) For ACPI, the interface is defined in the ACPI spec across architectures and SoCs, we don't have host bridge drivers and the code that initializes the PCI is required early during boot and called from architecture code. There is no parent device, as ACPI sees PCI as a fundamental building block by itself, and there are no drivers because the firmware does the initial hardware setup, so we only have to access the config space. Hmmm, I'm a little confused, so why you think ACPI host driver should not use pci_create_host_bridge(), because ACPI PCI driver has no parent device ? It's one of the difference. Having a parent device can certainly make your life simpler, since you have devm_kzalloc(), dev_info(), etc. Coming from the other end, I think ACPI needs PCI to be available during early boot, at a time where we might not want pci_create_host_bridge() to do the right thing. Device pointer is not required for ACPI, struct acpi_device is all we need to get all that info. If pci_create_host_bridge() would be DT specific, it would be nice to have sth similar for ACPI but that is out of this patch set scope. My point was more that we don't need to have something like it for ACPI, since we don't get random drivers that need to be probed that way, just one common implementation that calls into the PCI core. We should of course share the common bits with pci_create_host_bridge() in some form, but that can be done by moving the x86 pci_acpi_scan_root function and/or acpi_pci_root_add() to a common place in drivers/pci and then refactoring the internals. Arnd -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] gpio_wdt: Add always_running feature to GPIO watchdog
On some chips, like the TPS386000, the trigger cannot be disabled and the CPU must keep toggling the line at all times. Add a switch always_running to keep toggling the GPIO line regardless of the state of the soft part of the watchdog. The armed member keeps track of whether a timeout must also cause a reset. Signed-off-by: Mike Looijmans mike.looijm...@topic.nl --- drivers/watchdog/gpio_wdt.c | 20 +--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c index 220a9e0..921ee67 100644 --- a/drivers/watchdog/gpio_wdt.c +++ b/drivers/watchdog/gpio_wdt.c @@ -31,6 +31,8 @@ struct gpio_wdt_priv { int gpio; boolactive_low; boolstate; + boolalways_running; + boolarmed; unsigned inthw_algo; unsigned inthw_margin; unsigned long last_jiffies; @@ -56,6 +58,7 @@ static int gpio_wdt_start(struct watchdog_device *wdd) gpio_direction_output(priv-gpio, priv-state); priv-last_jiffies = jiffies; mod_timer(priv-timer, priv-last_jiffies + priv-hw_margin); + priv-armed = true; return 0; } @@ -64,8 +67,11 @@ static int gpio_wdt_stop(struct watchdog_device *wdd) { struct gpio_wdt_priv *priv = watchdog_get_drvdata(wdd); - mod_timer(priv-timer, 0); - gpio_wdt_disable(priv); + priv-armed = false; + if (!priv-always_running) { + mod_timer(priv-timer, 0); + gpio_wdt_disable(priv); + } return 0; } @@ -91,7 +97,7 @@ static void gpio_wdt_hwping(unsigned long data) struct watchdog_device *wdd = (struct watchdog_device *)data; struct gpio_wdt_priv *priv = watchdog_get_drvdata(wdd); - if (time_after(jiffies, priv-last_jiffies + + if (priv-armed time_after(jiffies, priv-last_jiffies + msecs_to_jiffies(wdd-timeout * 1000))) { dev_crit(wdd-dev, Timer expired. System will reboot soon!\n); return; @@ -197,6 +203,9 @@ static int gpio_wdt_probe(struct platform_device *pdev) /* Use safe value (1/2 of real timeout) */ priv-hw_margin = msecs_to_jiffies(hw_margin / 2); + priv-always_running = of_property_read_bool(pdev-dev.of_node, + always_running); + watchdog_set_drvdata(priv-wdd, priv); priv-wdd.info = gpio_wdt_ident; @@ -218,6 +227,11 @@ static int gpio_wdt_probe(struct platform_device *pdev) if (ret) watchdog_unregister_device(priv-wdd); + if (priv-always_running) { + gpio_wdt_start(priv-wdd); + priv-armed = false; + } + return ret; } -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v6 1/4] mfd: rt5033: Add Richtek RT5033 driver core.
This patch adds a new driver for Richtek RT5033 driver. RT5033 is a Multifunction device which includes battery charger, fuel gauge, flash LED current source, LDO and synchronous Buck converter. It is interfaced to host controller using I2C interface. Cc: Samuel Ortiz sa...@linux.intel.com Cc: Lee Jones lee.j...@linaro.org Signed-off-by: Beomho Seo beomho@samsung.com Acked-by: Chanwoo Choi cw00.c...@samsung.com --- Changes in v6 - Fix white space issue in mfd cell struct. Changes in v5 - Change possible built as a module. - Revise rt5033_dev mfd cell entry. - Fix incorrect typo. - Add module alias. Changes in v4 - none. Changes in v3 - Correct sentence errors. - Add author information the top of each drivers. - Remove unnecessary pre-initialise, struct member(rt5033-i2c) and blink. - Change some return check. - Use bool and of_match_ptr(). Changes in v2 - Remove volatile_reg callback. Because this driver not in use regmap cache. - Revmoe unnecessary subnode of_compatible. - Add define for set_high impedance mode of charger. drivers/mfd/Kconfig| 12 ++ drivers/mfd/Makefile |1 + drivers/mfd/rt5033.c | 141 +++ include/linux/mfd/rt5033-private.h | 260 include/linux/mfd/rt5033.h | 62 + 5 files changed, 476 insertions(+) create mode 100644 drivers/mfd/rt5033.c create mode 100644 include/linux/mfd/rt5033-private.h create mode 100644 include/linux/mfd/rt5033.h diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 72d3808..9c13170 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -618,6 +618,18 @@ config MFD_RTSX_PCI types of memory cards, such as Memory Stick, Memory Stick Pro, Secure Digital and MultiMediaCard. +config MFD_RT5033 + tristate Richtek RT5033 Power Management IC + depends on I2C=y + select MFD_CORE + select REGMAP_I2C + help + This driver provides for the Richtek RT5033 Power Management IC, + which includes the I2C driver and the Core APIs. This driver provides + common support for accessing the device. The device supports multiple + sub-devices like charger, fuel gauge, flash LED, current source, + LDO and Buck. + config MFD_RTSX_USB tristate Realtek USB card reader depends on USB diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 53467e2..4059c24 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -176,6 +176,7 @@ obj-$(CONFIG_MFD_IPAQ_MICRO)+= ipaq-micro.o obj-$(CONFIG_MFD_MENF21BMC)+= menf21bmc.o obj-$(CONFIG_MFD_HI6421_PMIC) += hi6421-pmic-core.o obj-$(CONFIG_MFD_DLN2) += dln2.o +obj-$(CONFIG_MFD_RT5033) += rt5033.o intel-soc-pmic-objs:= intel_soc_pmic_core.o intel_soc_pmic_crc.o obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c new file mode 100644 index 000..e2877c0 --- /dev/null +++ b/drivers/mfd/rt5033.c @@ -0,0 +1,141 @@ +/* + * MFD core driver for the Richtek RT5033. + * + * Copyright (C) 2014 Samsung Electronics, Co., Ltd. + * Author: Beomho Seo beomho@samsung.com + * + * 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 bythe Free Software Foundation. + */ + +#include linux/err.h +#include linux/module.h +#include linux/interrupt.h +#include linux/of_device.h +#include linux/mfd/core.h +#include linux/mfd/rt5033.h +#include linux/mfd/rt5033-private.h + +static const struct regmap_irq rt5033_irqs[] = { + { .mask = RT5033_PMIC_IRQ_BUCKOCP, }, + { .mask = RT5033_PMIC_IRQ_BUCKLV, }, + { .mask = RT5033_PMIC_IRQ_SAFELDOLV, }, + { .mask = RT5033_PMIC_IRQ_LDOLV, }, + { .mask = RT5033_PMIC_IRQ_OT, }, + { .mask = RT5033_PMIC_IRQ_VDDA_UV, }, +}; + +static const struct regmap_irq_chip rt5033_irq_chip = { + .name = rt5033, + .status_base= RT5033_REG_PMIC_IRQ_STAT, + .mask_base = RT5033_REG_PMIC_IRQ_CTRL, + .mask_invert= true, + .num_regs = 1, + .irqs = rt5033_irqs, + .num_irqs = ARRAY_SIZE(rt5033_irqs), +}; + +static const struct mfd_cell rt5033_devs[] = { + { .name = rt5033-regulator, }, + { + .name = rt5033-charger, + .of_compatible = richtek,rt5033-charger, + }, { + .name = rt5033-battery, + .of_compatible = richtek,rt5033-battery, + }, +}; + +static const struct of_device_id rt5033_dt_match[] = { + { .compatible = richtek,rt5033, }, + { } +}; + +static const struct regmap_config rt5033_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = RT5033_REG_END, +}; + +static int rt5033_i2c_probe(struct i2c_client *i2c, +
[PATCH v6 4/4] Documentation: Add documentation for rt5033 multifunction device
This patch device tree binding documentation for rt5033 multifunction device. Cc: Rob Herring robh...@kernel.org Cc: Pawel Moll pawel.m...@arm.com Cc: Mark Rutland mark.rutl...@arm.com Cc: Ian campbell ijc+devicet...@hellion.org.uk Cc: Kumar Gala ga...@codeaurora.org Signed-off-by: Beomho Seo beomho@samsung.com Acked-by: Chanwoo Choi cw00.c...@samsung.com --- Changes in v6: Changes in v5: Changes in v4: Changes in v3: - none. Changes in v2: - Revise binding documentation. Documentation/devicetree/bindings/mfd/rt5033.txt | 108 .../devicetree/bindings/vendor-prefixes.txt|1 + 2 files changed, 109 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt diff --git a/Documentation/devicetree/bindings/mfd/rt5033.txt b/Documentation/devicetree/bindings/mfd/rt5033.txt new file mode 100644 index 000..52a6d33 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/rt5033.txt @@ -0,0 +1,108 @@ +Richtek RT5033 Power management Integrated Circuit + +RT5033 is a Multifunction device which includes battery charger, fuel gauge, +flash LED current source, LDO and synchronous Buck converter for portable +applications. It is interfaced to host controller using i2c interface. + +Required properties: +- compatible : Must be richtek,rt5033 +- reg : Specifies the i2c slave address of general part. +- interrupts : This i2c devices has an IRQ line connected to the main SoC. +- interrupt-parent : The parent interrupt controller. + +Optional node: +Regulators: The regulators of RT5033 have to be instantiated under sub-node +named regulators usinge the following format. + + regulators { + regulator-name { + regulator-name = LDO/BUCK + regulator subnodes called X, Y and Z + }; + }; + refer Documentation/devicetree/bindings/regulator/regulator.txt + + +Battery charger: There battery charger of RT5033 have to be instantiated under +sub-node named charger using the following format. + +Required properties: +- compatible : Must be richtek,rt5033-charger. +- richtek,pre-uamp : Current of pre-charge mode. The pre-charge current levels + are 350 mA to 650 mA programmed by I2C per 100 mA. +- richtek,pre-threshold-uvolt : Voltage of threshold pre-charge mode. Battery + voltage is below pre-charge threshold voltage, the charger is in pre-charge + mode with pre-charge current. Its levels are 2.3 V to 3.8 V programmed + by I2C per 0.1 V. +- richtek,fast-uamp : Current of fast-charge mode. The fast-charge current + levels are 700 mA to 2000 mA programmed by I2C per 100 mA. +- richtek,const-uvolt : Battery regulation voltage of constant voltage mode. + This voltage level 3.65 V to 4.4 V bye I2C per 0.025 V. +- richtek,eoc-uamp : This property is end of charge current. Its level 150 mA + to 200 mA. + + charger { + compatible = richtek,rt5033-charger; + richtek,pre-uamp = 35; + richtek,pre-threshold-uvolt = 340; + richtek,fast-uamp = 200; + richtek,const-uvolt = 435; + richtek,eoc-uamp = 25; + }; + + +Fuelgauge: There fuelgauge of RT5033 to be instantiated node named fuelgauge +using the following format. + +Required properties: +- compatible = Must be richtek,rt5033-battery. + + i2c_fuel: i2c@1 { + compatible = i2c-gpio; + standard i2c-gpio constraints... + fuelgauge { + compatible = richtek,rt5033-battery. + }; + }; + + +Example: + + rt5033@34 { + compatible = richtek,rt5033; + reg = 0x34; + interrupt-parent = gpx1; + interrupts = 5 0; + + regulators { + buck_reg: BUCK { + regulator-name = BUCK; + regulator-min-microvolt = 120; + regulator-max-microvolt = 120; + regulator-always-on; + }; + }; + + charger { + compatible = richtek,rt5033-charger; + richtek,pre-uamp = 35; + richtek,pre-threshold-uvolt = 340; + richtek,fast-uamp = 200; + richtek,const-uvolt = 435; + richtek,eoc-uamp = 25; + }; + + }; + + i2c_fuel: i2c@10 { + compatible = i2c-gpio; + gpios = gpm3 1 0 + gpm3 0 0; + + fuel: rt5033-battery@35 { + compatible =
[PATCH v6 2/4] power: rt5033_battery: Add RT5033 Fuel gauge device driver
This patch adds device driver of Richtek PMIC. The driver support battery fuel gange. Fuel gauge calculates and determines the battery state of charge(SOC) according to battery open circuit voltage(OCV). Also, this driver provides battery average voltage, voltage and bettery present property. Cc: Sebastian Reichel s...@kernel.org Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com Cc: David Woodhouse dw...@infradead.org Signed-off-by: Beomho Seo beomho@samsung.com Acked-by: Chanwoo Choi cw00.c...@samsung.com --- Changes in v6: Changes in v5: Changes in v4: - none. Changes in v3: - Add author information the top of driver. Changes in v2: - Remove volatile_reg callback. Because this driver not in use regmap cache. - Fix wrong register name. drivers/power/Kconfig |8 ++ drivers/power/Makefile |1 + drivers/power/rt5033_battery.c | 177 3 files changed, 186 insertions(+) create mode 100644 drivers/power/rt5033_battery.c diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig index 0108c2a..da6981f 100644 --- a/drivers/power/Kconfig +++ b/drivers/power/Kconfig @@ -397,6 +397,14 @@ config BATTERY_GOLDFISH Say Y to enable support for the battery and AC power in the Goldfish emulator. +config BATTERY_RT5033 + tristate RT5033 fuel gauge support + depends on MFD_RT5033 + help + This adds support for battery fuel gauge in Richtek RT5033 PMIC. + The fuelgauge calculates and determines the battery state of charge + according to battery open circuit voltage. + source drivers/power/reset/Kconfig endif # POWER_SUPPLY diff --git a/drivers/power/Makefile b/drivers/power/Makefile index dfa8942..b83a0c7 100644 --- a/drivers/power/Makefile +++ b/drivers/power/Makefile @@ -34,6 +34,7 @@ obj-$(CONFIG_BATTERY_DA9052) += da9052-battery.o obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o obj-$(CONFIG_BATTERY_MAX17042) += max17042_battery.o obj-$(CONFIG_BATTERY_Z2) += z2_battery.o +obj-$(CONFIG_BATTERY_RT5033) += rt5033_battery.o obj-$(CONFIG_BATTERY_S3C_ADC) += s3c_adc_battery.o obj-$(CONFIG_BATTERY_TWL4030_MADC) += twl4030_madc_battery.o obj-$(CONFIG_CHARGER_88PM860X) += 88pm860x_charger.o diff --git a/drivers/power/rt5033_battery.c b/drivers/power/rt5033_battery.c new file mode 100644 index 000..7b898f4 --- /dev/null +++ b/drivers/power/rt5033_battery.c @@ -0,0 +1,177 @@ +/* + * Fuel gauge driver for Richtek RT5033 + * + * Copyright (C) 2014 Samsung Electronics, Co., Ltd. + * Author: Beomho Seo beomho@samsung.com + * + * 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 bythe Free Software Foundation. + */ + +#include linux/module.h +#include linux/platform_device.h +#include linux/power_supply.h +#include linux/mfd/rt5033-private.h +#include linux/mfd/rt5033.h + +static int rt5033_battery_get_capacity(struct i2c_client *client) +{ + struct rt5033_battery *battery = i2c_get_clientdata(client); + u32 msb; + + regmap_read(battery-regmap, RT5033_FUEL_REG_SOC_H, msb); + + return msb; +} + +static int rt5033_battery_get_present(struct i2c_client *client) +{ + struct rt5033_battery *battery = i2c_get_clientdata(client); + u32 val; + + regmap_read(battery-regmap, RT5033_FUEL_REG_CONFIG_L, val); + + return (val RT5033_FUEL_BAT_PRESENT) ? true : false; +} + +static int rt5033_battery_get_watt_prop(struct i2c_client *client, + enum power_supply_property psp) +{ + struct rt5033_battery *battery = i2c_get_clientdata(client); + unsigned int regh, regl; + int ret; + u32 msb, lsb; + + switch (psp) { + case POWER_SUPPLY_PROP_VOLTAGE_NOW: + regh = RT5033_FUEL_REG_VBAT_H; + regl = RT5033_FUEL_REG_VBAT_L; + break; + case POWER_SUPPLY_PROP_VOLTAGE_AVG: + regh = RT5033_FUEL_REG_AVG_VOLT_H; + regl = RT5033_FUEL_REG_AVG_VOLT_L; + break; + case POWER_SUPPLY_PROP_VOLTAGE_OCV: + regh = RT5033_FUEL_REG_OCV_H; + regl = RT5033_FUEL_REG_OCV_L; + break; + default: + return -EINVAL; + } + + regmap_read(battery-regmap, regh, msb); + regmap_read(battery-regmap, regl, lsb); + + ret = ((msb 4) + (lsb 4)) * 1250 / 1000; + + return ret; +} + +static int rt5033_battery_get_property(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + struct rt5033_battery *battery = container_of(psy, + struct rt5033_battery, psy); + + switch (psp) { + case POWER_SUPPLY_PROP_VOLTAGE_NOW: + case POWER_SUPPLY_PROP_VOLTAGE_AVG: + case POWER_SUPPLY_PROP_VOLTAGE_OCV: + val-intval =
[PATCH v6 3/4] power: rt5033_charger: Add RT5033 charger device driver
This patch add device driver of Richtek RT5033 PMIC. The driver support switching charger. rt5033 charger provide three charging mode. Three charging mode are pre charge mode, fast cahrge mode and constant voltage mode. They are have vary charge rate, charge parameters. The charge parameters can be controlled by i2c interface. Cc: Sebastian Reichel s...@kernel.org Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com Cc: David Woodhouse dw...@infradead.org Signed-off-by: Beomho Seo beomho@samsung.com Acked-by: Chanwoo Choi cw00.c...@samsung.com --- Changes in v6: Changes in v5: Changes in v4: - none. Changes in v3: - Add author information the top of driver. Changes in v2: - Fix wrong error message. - Fix return value at error case. Because charger-data null, probe function return zero. - Use define for set control register. drivers/power/Kconfig |8 + drivers/power/Makefile |1 + drivers/power/rt5033_charger.c | 485 3 files changed, 494 insertions(+) create mode 100644 drivers/power/rt5033_charger.c diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig index da6981f..629b101 100644 --- a/drivers/power/Kconfig +++ b/drivers/power/Kconfig @@ -405,6 +405,14 @@ config BATTERY_RT5033 The fuelgauge calculates and determines the battery state of charge according to battery open circuit voltage. +config CHARGER_RT5033 + tristate RT5033 battery charger support + depends on MFD_RT5033 + help + This adds support for battery charger in Richtek RT5033 PMIC. + The device supports pre-charge mode, fast charge mode and + constant voltage mode. + source drivers/power/reset/Kconfig endif # POWER_SUPPLY diff --git a/drivers/power/Makefile b/drivers/power/Makefile index b83a0c7..bb8cce3 100644 --- a/drivers/power/Makefile +++ b/drivers/power/Makefile @@ -57,6 +57,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o obj-$(CONFIG_POWER_AVS)+= avs/ +obj-$(CONFIG_POWER_RT5033) += rt5033_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o obj-$(CONFIG_POWER_RESET) += reset/ diff --git a/drivers/power/rt5033_charger.c b/drivers/power/rt5033_charger.c new file mode 100644 index 000..634f2f1 --- /dev/null +++ b/drivers/power/rt5033_charger.c @@ -0,0 +1,485 @@ +/* + * Battery charger driver for RT5033 + * + * Copyright (C) 2014 Samsung Electronics, Co., Ltd. + * Author: Beomho Seo beomho@samsung.com + * + * 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 bythe Free Software Foundation. + */ + +#include linux/module.h +#include linux/platform_device.h +#include linux/power_supply.h +#include linux/mfd/rt5033-private.h +#include linux/mfd/rt5033.h + +static int rt5033_get_charger_state(struct rt5033_charger *charger) +{ + struct regmap *regmap = charger-rt5033-regmap; + int state = POWER_SUPPLY_STATUS_UNKNOWN; + u32 reg_data; + + if (!regmap) + return state; + + regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data); + + switch (reg_data RT5033_CHG_STAT_MASK) { + case RT5033_CHG_STAT_DISCHARGING: + state = POWER_SUPPLY_STATUS_DISCHARGING; + break; + case RT5033_CHG_STAT_CHARGING: + state = POWER_SUPPLY_STATUS_CHARGING; + break; + case RT5033_CHG_STAT_FULL: + state = POWER_SUPPLY_STATUS_FULL; + break; + case RT5033_CHG_STAT_NOT_CHARGING: + state = POWER_SUPPLY_STATUS_NOT_CHARGING; + break; + } + + return state; +} + +static int rt5033_get_charger_type(struct rt5033_charger *charger) +{ + struct regmap *regmap = charger-rt5033-regmap; + int state = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN; + u32 reg_data; + + regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data); + + switch (reg_data RT5033_CHG_STAT_TYPE_MASK) { + case RT5033_CHG_STAT_TYPE_FAST: + state = POWER_SUPPLY_CHARGE_TYPE_FAST; + break; + case RT5033_CHG_STAT_TYPE_PRE: + state = POWER_SUPPLY_CHARGE_TYPE_TRICKLE; + break; + } + + return state; +} + +static int rt5033_get_charger_current(struct rt5033_charger *charger, + enum power_supply_property psp) +{ + struct regmap *regmap = charger-rt5033-regmap; + unsigned int state, reg_data, data; + + if (psp == POWER_SUPPLY_PROP_CURRENT_MAX) + return RT5033_CHG_MAX_CURRENT; + + regmap_read(regmap, RT5033_REG_CHG_CTRL5, reg_data); + + state = (reg_data RT5033_CHGCTRL5_ICHG_SHIFT) 0xf; + + if (state RT5033_CHG_MAX_CURRENT) +
[PATCH v6 0/4] mfd: rt5033: Add Richtek RT5033 drivers
This patchset adds driver for Richtek rt5033 chip The chip contains switching charge mode Li-Ion/Li-Polymer battery charger, fuelgauge, regulators. This patchset provides common support for accessing the device. This patchset have been tested base on exynos board. Changes in v6 - Fix white space issue in mfd cell struct. Changes in v5 - Change possible built as a module. - Revise rt5033_dev mfd cell entry. - Fix incorrect typo. - Add module alias. Changes in v4 - rt5033 regulator patch is applied by Mark Brown. Changes in v3 - Correct sentence errors. - Add author information the top of each drivers. - Remove unnecessary pre-initialise, struct member(rt5033-i2c) and blink. - Change some return check. - Use bool and of_match_ptr(). Changes in v2: - Remove volatile_reg callback. Because this driver not in use regmap cache. - Remove unnecessary subnode of_compatible. - Add definde for set high impedance mode of charger. - Remove unnecessary device specific code. - Fix wrong register name. - Fix wrong error message. - Fix return vallue at error case. - Revise binding documentation. Beomho Seo (4): mfd: rt5033: Add Richtek RT5033 driver core. power: rt5033_battery: Add RT5033 Fuel gauge device driver power: rt5033_charger: Add RT5033 charger device driver Documentation: Add documentation for rt5033 multifunction device Documentation/devicetree/bindings/mfd/rt5033.txt | 108 + .../devicetree/bindings/vendor-prefixes.txt|1 + drivers/mfd/Kconfig| 12 + drivers/mfd/Makefile |1 + drivers/mfd/rt5033.c | 141 ++ drivers/power/Kconfig | 16 + drivers/power/Makefile |2 + drivers/power/rt5033_battery.c | 177 +++ drivers/power/rt5033_charger.c | 485 include/linux/mfd/rt5033-private.h | 260 +++ include/linux/mfd/rt5033.h | 62 +++ 11 files changed, 1265 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt create mode 100644 drivers/mfd/rt5033.c create mode 100644 drivers/power/rt5033_battery.c create mode 100644 drivers/power/rt5033_charger.c create mode 100644 include/linux/mfd/rt5033-private.h create mode 100644 include/linux/mfd/rt5033.h -- 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] hid-multitouch: Add quirk for VTL touch panels
On Wed, 19 Nov 2014, Benjamin Tissoires wrote: though this patch works for this particular device, I just thought at something which may solve the problem in a different way. I asked Mathieu to test the different solution, so I'd rather you to wait for final confirmation before merging this patch. Thanks for the heads up, I am putting this patch on hold until further notice from you or Mathieu. -- Jiri Kosina SUSE Labs -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH] mm/zsmalloc: remove unnecessary check
ZS_SIZE_CLASSES is calc by: ((ZS_MAX_ALLOC_SIZE - ZS_MIN_ALLOC_SIZE) / ZS_SIZE_CLASS_DELTA + 1) So when i is in [0, ZS_SIZE_CLASSES - 1), the size: size = ZS_MIN_ALLOC_SIZE + i * ZS_SIZE_CLASS_DELTA will not be greater than ZS_MAX_ALLOC_SIZE This patch removes the unnecessary check. Signed-off-by: Mahendran Ganesh opensource.gan...@gmail.com --- mm/zsmalloc.c |2 -- 1 file changed, 2 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index b3b57ef..f2279e2 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -973,8 +973,6 @@ struct zs_pool *zs_create_pool(gfp_t flags) struct size_class *prev_class; size = ZS_MIN_ALLOC_SIZE + i * ZS_SIZE_CLASS_DELTA; - if (size ZS_MAX_ALLOC_SIZE) - size = ZS_MAX_ALLOC_SIZE; pages_per_zspage = get_pages_per_zspage(size); /* -- 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: [PATCHv2 2/3] kernel: add support for live patching
On Wed, 19 Nov 2014, Seth Jennings wrote: On Tue, Nov 18, 2014 at 03:45:22PM +0100, Miroslav Benes wrote: On Sun, 16 Nov 2014, Seth Jennings wrote: [...] diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h new file mode 100644 index 000..8b68fef --- /dev/null +++ b/include/linux/livepatch.h @@ -0,0 +1,68 @@ +/* + * livepatch.h - Live Kernel Patching Core + * + * Copyright (C) 2014 Seth Jennings sjenn...@redhat.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. + */ + +#ifndef _LINUX_LIVEPATCH_H_ +#define _LINUX_LIVEPATCH_H_ + +#include linux/module.h + I think we need something like #if IS_ENABLED(CONFIG_LIVE_PATCHING) here. Otherwise kernel module with live patch itself would be built even with live patching support disabled (as the structures and needed functions are declared). What do you think of this (already includes s/lp/klp/ change)? diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h index 0143b73..a9821f3 100644 --- a/include/linux/livepatch.h +++ b/include/linux/livepatch.h @@ -21,6 +21,7 @@ #define _LINUX_LIVEPATCH_H_ #include linux/module.h +#include asm/livepatch.h /* TODO: add kernel-doc for structures once agreed upon */ @@ -58,11 +59,20 @@ struct klp_patch { struct klp_object *objs; }; -int klp_register_patch(struct klp_patch *); -int klp_unregister_patch(struct klp_patch *); -int klp_enable_patch(struct klp_patch *); -int klp_disable_patch(struct klp_patch *); +#ifdef CONFIG_LIVE_PATCHING -#include asm/livepatch.h +extern int klp_register_patch(struct klp_patch *); +extern int klp_unregister_patch(struct klp_patch *); +extern int klp_enable_patch(struct klp_patch *); +extern int klp_disable_patch(struct klp_patch *); + +#else /* !CONFIG_LIVE_PATCHING */ + +static int klp_register_patch(struct klp_patch *k) { return -ENOSYS; } +static int klp_unregister_patch(struct klp_patch *k) { return -ENOSYS; } +static int klp_enable_patch(struct klp_patch *k) { return -ENOSYS; } +static int klp_disable_patch(struct klp_patch *k) { return -ENOSYS; } + +#endif This seems to be the way many headers handle this. Patch modules built against a kernel that doesn't support live patching will build cleanly, but will always fail to load. Seth Hm, I would still vote for build failure. I think it doesn't make sense to build patch module against a kernel that doesn't support live patching and it is better to let the user know (and not potentially someone else who would load it and fail). Afaik the other headers handle it your way because otherwise the code would be spoiled by #ifdefs in .c files. However I think that our case is a bit different. Anyway it is better to use #if (IS_ENABLED(CONFIG_LIVE_PATCHING)) than simple #ifdef (see Documentation/CodingStyle) and make the functions static inlined for !CONFIG_LIVE_PATCHING case. Mira +/* TODO: add kernel-doc for structures once agreed upon */ + +struct lp_func { + const char *old_name; /* function to be patched */ + void *new_func; /* replacement function in patch module */ + /* + * The old_addr field is optional and can be used to resolve + * duplicate symbol names in the vmlinux object. If this + * information is not present, the symbol is located by name + * with kallsyms. If the name is not unique and old_addr is + * not provided, the patch application fails as there is no + * way to resolve the ambiguity. + */ + unsigned long old_addr; +}; + +struct lp_reloc { + unsigned long dest; + unsigned long src; + unsigned long type; + const char *name; + int addend; + int external; +}; + +struct lp_object { + const char *name; /* vmlinux or module name */ + struct lp_func *funcs; + struct lp_reloc *relocs; +}; + +struct lp_patch { + struct module *mod; /* module containing the patch */ + struct lp_object *objs; +}; + +int lp_register_patch(struct lp_patch *); +int lp_unregister_patch(struct lp_patch *); +int lp_enable_patch(struct lp_patch *); +int lp_disable_patch(struct lp_patch *); + +#include asm/livepatch.h and #endif for CONFIG_LIVE_PATCHING here. + +#endif /*
[PATCH V2 00/22] perf tools: Introduce an abstraction for Instruction Tracing
Hi Here is V2 of some more preparatory patches for Intel PT that introduce an abstraction for Instruction tracing. 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 Instruction Trace data 2. processing Instruction Trace 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_ITRACE. 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 similar fashion to the existing PERF_RECORD_HEADER_TRACING_DATA event. The main recording patches are: perf evlist: Add initial support for mmapping an Instruction Trace buffer perf tools: Add user events for Instruction Tracing perf tools: Add support for Instruction Trace recording perf record: Add basic Instruction Tracing support Processing consists of providing hooks in session processing to enable an Instruction Trace decoder to see all the events and deliver synthesized events transparently into the event stream. The main processing patch is: perf session: Add hooks to allow transparent decoding of Instruction Tracing data Adrian Hunter (22): perf header: Add Instruction Tracing feature perf evlist: Add initial support for mmapping an Instruction Trace buffer perf tools: Add user events for Instruction Tracing perf tools: Add support for Instruction Trace recording perf record: Add basic Instruction Tracing support perf record: Extend -m option for Instruction Tracing mmap pages perf tools: Add a user event for Instruction Tracing errors perf session: Add hooks to allow transparent decoding of Instruction Tracing data perf session: Add Instruction Tracing options perf itrace: Add helpers for Instruction Tracing errors perf itrace: Add helpers for queuing Instruction Tracing data perf itrace: Add a heap for sorting Instruction Tracing queues perf itrace: Add processing for Instruction Tracing events perf itrace: Add a hashtable for caching decoded instructions perf tools: Add member to struct dso for an instruction cache perf script: Add Instruction Tracing support perf script: Always allow fields 'addr' and 'cpu' for itrace perf report: Add Instruction Tracing support perf inject: Re-pipe Instruction Tracing events perf inject: Add Instruction Tracing support perf tools: Add Instruction Tracing index perf tools: Hit all build ids when Instruction Tracing tools/perf/Documentation/perf-inject.txt | 27 + tools/perf/Documentation/perf-record.txt |2 + tools/perf/Documentation/perf-report.txt | 28 + tools/perf/Documentation/perf-script.txt | 28 + tools/perf/Makefile.perf |2 + tools/perf/builtin-buildid-list.c|9 + tools/perf/builtin-inject.c | 157 +++- tools/perf/builtin-record.c | 173 +++- tools/perf/builtin-report.c | 12 + tools/perf/builtin-script.c | 39 +- tools/perf/perf.h|2 + tools/perf/util/dso.c|2 + tools/perf/util/dso.h|3 + tools/perf/util/event.c |3 + tools/perf/util/event.h | 38 + tools/perf/util/evlist.c | 70 +- tools/perf/util/evlist.h |6 + tools/perf/util/header.c | 36 + tools/perf/util/header.h |1 + tools/perf/util/itrace.c | 1255 ++ tools/perf/util/itrace.h | 447 +++ tools/perf/util/record.c | 11 +- tools/perf/util/session.c| 148 +++- tools/perf/util/session.h|6 + tools/perf/util/tool.h | 10 +- 25 files changed, 2468 insertions(+), 47 deletions(-) create mode 100644 tools/perf/util/itrace.c create mode 100644 tools/perf/util/itrace.h Regards Adrian -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V2 01/22] perf header: Add Instruction Tracing feature
Add a feature to indicate that a perf.data file contains Instruction Tracing data. Signed-off-by: Adrian Hunter adrian.hun...@intel.com --- 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 b20e40c..0fe5301 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_itrace(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_itrace(struct perf_header *ph __maybe_unused, +int fd __maybe_unused, FILE *fp) +{ + fprintf(fp, # contains Instruction Traces\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_ITRACE, itrace), }; struct header_print_data { diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index 3bb90ac..990edcf 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_ITRACE, 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 V2 07/22] perf tools: Add a user event for Instruction Tracing errors
Errors encountered when decoding an Instruction 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 adrian.hun...@intel.com --- 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 efe6475..573fed2 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_ITRACE_INFO] = ITRACE_INFO, [PERF_RECORD_ITRACE]= ITRACE, + [PERF_RECORD_ITRACE_ERROR] = ITRACE_ERROR, }; const char *perf_event__name(unsigned int id) diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index a093d56..7c1daae 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_ITRACE_INFO = 70, PERF_RECORD_ITRACE = 71, + PERF_RECORD_ITRACE_ERROR= 72, PERF_RECORD_HEADER_MAX }; @@ -300,6 +301,20 @@ struct itrace_event { u32 reserved__; /* For alignment */ }; +#define MAX_ITRACE_ERROR_MSG 64 + +struct itrace_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_ITRACE_ERROR_MSG]; +}; + union perf_event { struct perf_event_headerheader; struct mmap_event mmap; @@ -317,6 +332,7 @@ union perf_event { struct id_index_event id_index; struct itrace_info_eventitrace_info; struct itrace_event itrace; + struct itrace_error_event itrace_error; }; void perf_event__print_totals(void); diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 6f56afb..7fb5e90 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -271,6 +271,15 @@ static s64 process_event_itrace_stub(struct perf_tool *tool __maybe_unused, return event-itrace.size; } +static +int process_event_itrace_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) @@ -311,6 +320,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool) tool-itrace_info = process_event_itrace_info_stub; if (tool-itrace == NULL) tool-itrace = process_event_itrace_stub; + if (tool-itrace_error == NULL) + tool-itrace_error = process_event_itrace_error_stub; } static void swap_sample_id_all(union perf_event *event, void *data) @@ -514,6 +525,17 @@ static void perf_event__itrace_swap(union perf_event *event, event-itrace.cpu = bswap_32(event-itrace.cpu); } +static void perf_event__itrace_error_swap(union perf_event *event, + bool sample_id_all __maybe_unused) +{ + event-itrace_error.type = bswap_32(event-itrace_error.type); + event-itrace_error.code = bswap_32(event-itrace_error.code); + event-itrace_error.cpu = bswap_32(event-itrace_error.cpu); + event-itrace_error.pid = bswap_32(event-itrace_error.pid); + event-itrace_error.tid = bswap_32(event-itrace_error.tid); + event-itrace_error.ip = bswap_64(event-itrace_error.ip); +} + typedef void (*perf_event__swap_op)(union perf_event *event, bool sample_id_all); @@ -535,6 +557,7 @@ static perf_event__swap_op perf_event__swap_ops[] = { [PERF_RECORD_ID_INDEX]= perf_event__all64_swap, [PERF_RECORD_ITRACE_INFO] = perf_event__itrace_info_swap, [PERF_RECORD_ITRACE] = perf_event__itrace_swap, + [PERF_RECORD_ITRACE_ERROR]= perf_event__itrace_error_swap, [PERF_RECORD_HEADER_MAX] = NULL, }; @@ -1005,6 +1028,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-itrace(tool, event, session); + case PERF_RECORD_ITRACE_ERROR: + return tool-itrace_error(tool,
[PATCH V2 16/22] perf script: Add Instruction Tracing support
Add support for decoding an Instruction Trace. Signed-off-by: Adrian Hunter adrian.hun...@intel.com --- 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 2149480..f89f3be 100644 --- a/tools/perf/Documentation/perf-script.txt +++ b/tools/perf/Documentation/perf-script.txt @@ -215,6 +215,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 1000) for instructions events can be + specified in units of: + + i instructions (default) + t ticks + ms milliseconds + us microseconds + ns nanoseconds + + 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 ce304df..dbffd00 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/itrace.h #include linux/bitmap.h 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, + .itrace_info = perf_event__process_itrace_info, + .itrace = perf_event__process_itrace, + .itrace_error= perf_event__process_itrace_error, .ordered_events = true, .ordering_requires_timestamps = true, }, @@ -1570,6 +1576,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, script.show_mmap_events, Show the mmap events), + OPT_CALLBACK_OPTARG('Z', itrace, itrace_synth_opts, NULL, opts, + Instruction Tracing options, + itrace_parse_synth_opts), OPT_END() }; const char * const script_usage[] = { @@ -1767,6 +1776,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) script.session = session; + session-itrace_synth_opts = itrace_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 V2 06/22] perf record: Extend -m option for Instruction Tracing mmap pages
Extend the -m option so that the number of mmap pages for Instruction Tracing can be specified. Signed-off-by: Adrian Hunter adrian.hun...@intel.com --- 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 af9a54e..a5f2096 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt @@ -91,6 +91,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 Instruction + Tracing can be specified. -g:: Enables call-graph (stack chain/backtrace) recording. diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 73c3d9b..f5dc415 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -751,6 +751,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(mmap_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(mmap_pages, p + 1); + if (ret) + goto out_free; + + opts-itrace_mmap_pages = mmap_pages; + +out_free: + free(s); + return ret; +} + static const char * const __record_usage[] = { perf record [options] [command], perf record [options] -- command [options], @@ -824,9 +867,9 @@ struct option __record_options[] = { record.opts.no_inherit_set, child tasks do not inherit counters), OPT_UINTEGER('F', freq, record.opts.user_freq, profile at this frequency), - OPT_CALLBACK('m', mmap-pages, record.opts.mmap_pages, pages, -number of mmap data pages, -perf_evlist__parse_mmap_pages), + OPT_CALLBACK('m', mmap-pages, record.opts, pages[,pages], +number of mmap data pages and instruction tracing mmap pages, +record__parse_mmap_pages), OPT_BOOLEAN(0, group, record.opts.group, put the counters into a counter group), OPT_CALLBACK_NOOPT('g', NULL, record.opts, diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 2ee7f46..27d4de3 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -984,10 +984,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; @@ -1004,6 +1002,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 f19d89c..fcf2975c 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -121,6 +121,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
[PATCH V2 05/22] perf record: Add basic Instruction Tracing support
Amend the perf record tool to read the Instruction Tracing mmap and synthesize Instruction Tracing events. Signed-off-by: Adrian Hunter adrian.hun...@intel.com --- tools/perf/builtin-record.c | 99 ++--- 1 file changed, 85 insertions(+), 14 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 8648c6d..73c3d9b 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/itrace.h #include unistd.h #include sched.h @@ -38,6 +39,7 @@ struct record { struct record_opts opts; u64 bytes_written; struct perf_data_file file; + struct itrace_record*itr; struct perf_evlist *evlist; struct perf_session *session; const char *progname; @@ -110,6 +112,43 @@ out: return rc; } +static int record__process_itrace(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.itrace.size includes padding, see __itrace_mmap__read() */ + padding = (len1 + len2) 7; + if (padding) + padding = 8 - padding; + + record__write(rec, event, event-header.size); + record__write(rec, data1, len1); + record__write(rec, data2, len2); + record__write(rec, pad, padding); + + return 0; +} + +static int record__itrace_mmap_read(struct record *rec, + struct itrace_mmap *mm) +{ + int ret; + + ret = itrace_mmap__read(mm, rec-itr, rec-tool, + record__process_itrace); + 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; @@ -168,13 +207,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-itrace_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-itrace_mmap_pages); rc = -errno; } else { pr_err(failed to mmap with %d (%s)\n, errno, @@ -257,12 +298,20 @@ static int record__mmap_read_all(struct record *rec) int rc = 0; for (i = 0; i rec-evlist-nr_mmaps; i++) { + struct itrace_mmap *mm = rec-evlist-mmap[i].itrace_mmap; + if (rec-evlist-mmap[i].base) { if (record__mmap_read(rec, i) != 0) { rc = -1; goto out; } } + + if (mm-base + record__itrace_mmap_read(rec, mm) != 0) { + rc = -1; + goto out; + } } /* @@ -292,6 +341,9 @@ static void record__init_features(struct record *rec) if (!rec-opts.branch_stack) perf_header__clear_feat(session-header, HEADER_BRANCH_STACK); + + if (!rec-opts.full_itrace) + perf_header__clear_feat(session-header, HEADER_ITRACE); } static volatile int workload_exec_errno; @@ -407,6 +459,13 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) } } + if (rec-opts.full_itrace) { + err = perf_event__synthesize_itrace_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) @@ -505,16 +564,17 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) } if (!quiet) { - fprintf(stderr, [ perf record: Woken up %ld times to write data ]\n, waking); - - /* -* Approximate RIP event size: 24 bytes. -*/ -
[PATCH V2 08/22] perf session: Add hooks to allow transparent decoding of Instruction Tracing data
Hook into session processing so that Instruction Trace 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 Instruction 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 itrace events to the decoder using perf_tool-itrace() (support for that still to come). 2. The decoder can process side-band events as needed due to the itrace-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 adrian.hun...@intel.com --- tools/perf/util/itrace.h | 57 +++ tools/perf/util/session.c | 52 +- tools/perf/util/session.h | 3 +++ 3 files changed, 106 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/itrace.h b/tools/perf/util/itrace.h index 44b6a01..1cf5d16 100644 --- a/tools/perf/util/itrace.h +++ b/tools/perf/util/itrace.h @@ -23,6 +23,7 @@ #include linux/types.h #include ../perf.h +#include session.h union perf_event; struct perf_session; @@ -32,6 +33,26 @@ struct record_opts; struct itrace_info_event; /** + * struct itrace - session callbacks to allow Instruction Trace 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 + * @error_count: number of errors + */ +struct itrace { + 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); + unsigned long long error_count; +}; + +/** * struct itrace_mmap - records an mmap of the itrace buffer. * @base: address of mapped area * @userpg: pointer to buffer's perf_event_mmap_page @@ -150,4 +171,40 @@ int perf_event__synthesize_itrace(struct perf_tool *tool, size_t size, u64 offset, u64 ref, int idx, u32 tid, u32 cpu); +static inline int itrace__process_event(struct perf_session *session, + union perf_event *event, + struct perf_sample *sample, + struct perf_tool *tool) +{ + if (!session-itrace) + return 0; + + return session-itrace-process_event(session, event, sample, tool); +} + +static inline int itrace__flush_events(struct perf_session *session, + struct perf_tool *tool) +{ + if (!session-itrace) + return 0; + + return session-itrace-flush_events(session, tool); +} + +static inline void itrace__free_events(struct perf_session *session) +{ + if (!session-itrace) + return; + + return session-itrace-free_events(session); +} + +static inline void itrace__free(struct perf_session *session) +{ + if (!session-itrace) + return; + + return session-itrace-free(session); +} + #endif diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 7fb5e90..6eb40d7 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -15,6 +15,7 @@ #include cpumap.h #include perf_regs.h #include asm/bug.h +#include itrace.h static int perf_session__open(struct perf_session *session) { @@ -166,6 +167,7 @@ static void perf_session_env__delete(struct perf_session_env *env) void perf_session__delete(struct perf_session *session) { + itrace__free(session); perf_session__destroy_kernel_maps(session); perf_session__delete_dead_threads(session); perf_session__delete_threads(session); @@ -933,10 +935,11 @@ perf_session__deliver_sample(struct perf_session *session, sample-read.one, machine); } -int perf_session__deliver_event(struct perf_session *session, - union perf_event *event, - struct perf_sample *sample, - struct perf_tool *tool, u64 file_offset) +static int __perf_session__deliver_event(struct perf_session *session, +union perf_event *event, +struct perf_sample
[PATCH V2 03/22] perf tools: Add user events for Instruction Tracing
Add two user events for Instruction Tracing. PERF_RECORD_ITRACE_INFO contains metadata, consisting primarily the type of the Instruction Tracing data plus some amount of architecture-specific information. There should be only one PERF_RECORD_ITRACE_INFO event. PERF_RECORD_ITRACE identifies Instruction Tracing data copied from the mmapped Instruction Tracing region. The actual data is not part of the event but immediately follows it. Signed-off-by: Adrian Hunter adrian.hun...@intel.com --- 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 6c6d044..efe6475 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_ITRACE_INFO] = ITRACE_INFO, + [PERF_RECORD_ITRACE]= ITRACE, }; const char *perf_event__name(unsigned int id) diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 09b9e8d..a093d56 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_ITRACE_INFO = 70, + PERF_RECORD_ITRACE = 71, PERF_RECORD_HEADER_MAX }; @@ -280,6 +282,24 @@ struct id_index_event { struct id_index_entry entries[0]; }; +struct itrace_info_event { + struct perf_event_header header; + u32 type; + u32 reserved__; /* For alignment */ + u64 priv[]; +}; + +struct itrace_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; @@ -295,6 +315,8 @@ union perf_event { struct tracing_data_event tracing_data; struct build_id_event build_id; struct id_index_event id_index; + struct itrace_info_eventitrace_info; + struct itrace_event itrace; }; void perf_event__print_totals(void); diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 6ac62ae..6f56afb 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -237,6 +237,40 @@ static int process_id_index_stub(struct perf_tool *tool __maybe_unused, return 0; } +static int process_event_itrace_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_itrace_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-itrace.size); + return event-itrace.size; +} + void perf_tool__fill_defaults(struct perf_tool *tool) { if (tool-sample == NULL) @@ -273,6 +307,10 @@ void perf_tool__fill_defaults(struct perf_tool *tool) } if (tool-id_index == NULL) tool-id_index = process_id_index_stub; + if (tool-itrace_info == NULL) + tool-itrace_info = process_event_itrace_info_stub; + if (tool-itrace == NULL) + tool-itrace = process_event_itrace_stub; } static void swap_sample_id_all(union perf_event *event, void *data) @@ -453,6 +491,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__itrace_info_swap(union perf_event *event, +bool sample_id_all __maybe_unused) +{ + size_t
[PATCH V2 17/22] perf script: Always allow fields 'addr' and 'cpu' for itrace
If a file contains Instruction Tracing data then always allow fields 'addr' and 'cpu' to be selected as options for perf script. This is necessary because Instruction Trace decoding may synthesize events with that information. Signed-off-by: Adrian Hunter adrian.hun...@intel.com --- tools/perf/builtin-script.c | 28 +--- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index dbffd00..8976d9b 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 = evsel-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,21 @@ 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 = evsel-attr; + bool allow_user_set; + + allow_user_set = perf_header__has_feat(session-header, HEADER_ITRACE); if (PRINT_FIELD(TRACE) !perf_session__has_traces(session, record -R)) @@ -192,8 +206,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 +244,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/
[PATCH V2 22/22] perf tools: Hit all build ids when Instruction Tracing
We need to include all buildids when a perf.data file contains Instruction Tracing data because we do not decode the trace for that purpose because it would take too long. Signed-off-by: Adrian Hunter adrian.hun...@intel.com --- 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 ed3873b..d694309 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(file, false, build_id__mark_dso_hit_ops); if (session == NULL) return -1; + + /* +* We take all buildids when the file contains Instruction Tracing data +* because we do not decode the trace because it would take too long. +*/ + if (!perf_data_file__is_pipe(file) + perf_header__has_feat(session-header, HEADER_ITRACE)) + 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 4d0fe53..285f159 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_itrace; const char *input_name; struct perf_data_file output; u64 bytes_written; @@ -115,6 +116,8 @@ static s64 perf_event__repipe_itrace(struct perf_tool *tool, tool); int ret; + inject-have_itrace = true; + if (!inject-output.is_pipe) { off_t offset; @@ -502,9 +505,12 @@ static int __cmd_inject(struct perf_inject *inject) ret = perf_session__process_events(session, inject-tool); if (!file_out-is_pipe) { - if (inject-build_ids) + if (inject-build_ids) { perf_header__set_feat(session-header, HEADER_BUILD_ID); + if (inject-have_itrace) + dsos__hit_all(session); + } /* * The instruction traces 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 6b95d99..f4347c7 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -613,8 +613,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 +* Instruction Tracing data because we do not decode the +* trace because it would take too long. +*/ + if (rec-opts.full_itrace) + dsos__hit_all(rec-session); + } perf_session__write_header(rec-session, rec-evlist, file-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/
Re: [PATCH 1/3] mfd: cros_ec: Add Chrome OS EC userspace device interface
I know how the device driver model works. I'm asking where the 'device' is registered from, not the 'driver' i.e. platform data, DT, ACPI? Right, sorry for misunderstanding your question and the silly comment then. $Subject adds a cros-ec-dev mfd cell to the cros ec mfd driver. So the device is registered from DT when the cros ec device node is matched (e.g: google,cros-ec-spi or google,cros-ec-i2c) and the cros ec mfd driver probe function calls mfd_add_devices(). Ah, so it's registered from another MFD device. That's okay then. That answers my question. FWIW I was going to ask about the missing match table, but that's not required in this case. -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V2 20/22] perf inject: Add Instruction Tracing support
Add support for decoding an Instruction Trace. The Instruction Tracing events are stripped and replaced by synthesized events. Signed-off-by: Adrian Hunter adrian.hun...@intel.com --- 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..9f49c43 100644 --- a/tools/perf/Documentation/perf-inject.txt +++ b/tools/perf/Documentation/perf-inject.txt @@ -44,6 +44,33 @@ OPTIONS --kallsyms=file:: 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 1000) for instructions events can be + specified in units of: + + i instructions (default) + t ticks + ms milliseconds + us microseconds + ns nanoseconds + + 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 29e0840..c3323ea 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/itrace.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 { @@ -198,6 +200,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) @@ -210,6 +238,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) @@ -393,16 +433,20 @@ static int __cmd_inject(struct perf_inject *inject) int ret = -EINVAL; struct perf_session *session = inject-session; struct perf_data_file *file_out = inject-output; + 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 (inject-sched_stat) { @@ -423,10 +467,22 @@ static int
[PATCH V2 21/22] perf tools: Add Instruction Tracing index
Add an index of Instruction 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. Instruction 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, Instruction Tracing events can be found in advance and the PERF_RECORD_FINISHED_ROUND approach works as usual. The index is recorded with the itrace feature in the perf.data file. A session reads the index but does not process it. An Instruction Trace decoder can queue all the Instruction Trace data in advance using itrace_queues__process_index() or otherwise process the index in some custom manner. Signed-off-by: Adrian Hunter adrian.hun...@intel.com --- tools/perf/builtin-inject.c | 15 tools/perf/builtin-record.c | 15 tools/perf/util/header.c| 30 ++- tools/perf/util/itrace.c| 214 tools/perf/util/itrace.h| 35 tools/perf/util/session.c | 2 + tools/perf/util/session.h | 1 + 7 files changed, 308 insertions(+), 4 deletions(-) diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index c3323ea..4d0fe53 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -115,6 +115,18 @@ static s64 perf_event__repipe_itrace(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 = itrace_index__itrace_event(session-itrace_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) @@ -481,6 +493,9 @@ static int __cmd_inject(struct perf_inject *inject) output_data_offset = 4096; } + if (!inject-itrace_synth_opts.set) + itrace_index__free(session-itrace_index); + if (!file_out-is_pipe) lseek(file_out-fd, output_data_offset, SEEK_SET); diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index f5dc415..6b95d99 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -117,9 +117,24 @@ static int record__process_itrace(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 = rec-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 = itrace_index__itrace_event(rec-session-itrace_index, +event, file_offset); + if (err) + return err; + } + /* event.itrace.size includes padding, see __itrace_mmap__read() */ padding = (len1 + len2) 7; if (padding) diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 0fe5301..3f75cf6 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -869,11 +869,18 @@ static int write_branch_stack(int fd __maybe_unused, return 0; } -static int write_itrace(int fd __maybe_unused, - struct perf_header *h __maybe_unused, +static int write_itrace(int fd, struct perf_header *h, struct perf_evlist *evlist __maybe_unused) { - return 0; + struct perf_session *session; + int err; + + session = container_of(h, struct perf_session, header); + + err = itrace_index__write(fd, session-itrace_index); + if (err 0) + pr_err(Failed to write itrace index\n); + return err; } static void print_hostname(struct perf_header *ph, int fd __maybe_unused, @@ -1846,6 +1853,21 @@ out_free: return ret; } +static int process_itrace(struct perf_file_section *section, + struct perf_header *ph, int fd, + void *data __maybe_unused) +{ + struct perf_session *session; + int err; + + session = container_of(ph, struct perf_session, header); + + err = itrace_index__process(fd, section-size, session, ph-needs_swap); + if (err 0) + pr_err(Failed to process
[PATCH V2 18/22] perf report: Add Instruction Tracing support
Add support for decoding an Instruction Trace. Signed-off-by: Adrian Hunter adrian.hun...@intel.com --- tools/perf/Documentation/perf-report.txt | 28 tools/perf/builtin-report.c | 12 2 files changed, 40 insertions(+) diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index 0927bf4..34530db 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt @@ -308,6 +308,34 @@ OPTIONS --header-only:: Show only perf.data header (forces --stdio). +-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 1000) for instructions events can be + specified in units of: + + i instructions (default) + t ticks + ms milliseconds + us microseconds + ns nanoseconds + + 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 140a6cd..1b92c3d 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/itrace.h + #include dlfcn.h #include linux/bitmap.h @@ -572,6 +574,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; @@ -593,6 +596,10 @@ 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, + .itrace_info = perf_event__process_itrace_info, + .itrace = perf_event__process_itrace, + .itrace_error= perf_event__count_itrace_error, .ordered_events = true, .ordering_requires_timestamps = true, }, @@ -696,6 +703,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, itrace_synth_opts, NULL, opts, + Instruction Tracing options, + itrace_parse_synth_opts), OPT_END() }; struct perf_data_file file = { @@ -740,6 +750,8 @@ repeat: report.queue_size); } + session-itrace_synth_opts = itrace_synth_opts; + report.session = session; has_br_stack = perf_header__has_feat(session-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 V2 19/22] perf inject: Re-pipe Instruction Tracing events
New Instruction Tracing events must be re-piped by default. Signed-off-by: Adrian Hunter adrian.hun...@intel.com --- 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 84df2de..29e0840 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(inject-output, event, -event-header.size); + size = perf_data_file__write(inject-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_op2_synth(struct perf_tool *tool, union perf_event *event, struct perf_session *session @@ -79,6 +104,31 @@ static int perf_event__repipe_attr(struct perf_tool *tool, return perf_event__repipe_synth(tool, event); } +static s64 perf_event__repipe_itrace(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-itrace.size); + } else { + ret = output_bytes(inject, event, + event-header.size + event-itrace.size); + } + if (ret 0) + return ret; + + return event-itrace.size; +} + static int perf_event__repipe(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, @@ -407,6 +457,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, + .itrace_info= perf_event__repipe_op2_synth, + .itrace = perf_event__repipe_itrace, + .itrace_error = perf_event__repipe_op2_synth, .finished_round = perf_event__repipe_op2_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/
Re: [PATCH 3/3] mfd: cros_ec: Expose Chrome OS Lightbar to users
On Thu, 20 Nov 2014, Javier Martinez Canillas wrote: Hello Lee, On 11/18/2014 03:22 PM, Lee Jones wrote: --- drivers/mfd/Makefile | 2 +- drivers/mfd/cros_ec_dev.c | 2 + drivers/mfd/cros_ec_dev.h | 3 + drivers/mfd/cros_ec_lightbar.c | 347 + By the sounds of the description, it doesn't seem as though this driver lives in MFD. I suggest another home, such as drivers/led. You are right. As I said in the other email, I'll move it to drivers/platform/chrome/ which seems like a more suitable place. Does it? I would have thought 'lightbar' lives in LEDs, but I guess that's between you and the drivers/platform/chrome maintainer now. -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/1] IBM-EMAC: Deletion of unnecessary checks before the function call of_dev_put
From: Markus Elfring elfr...@users.sourceforge.net Date: Thu, 20 Nov 2014 14:22:47 +0100 The of_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring elfr...@users.sourceforge.net --- drivers/net/ethernet/ibm/emac/core.c | 24 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index 87bd953..3f3fba9 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -2323,16 +2323,11 @@ static int emac_check_deps(struct emac_instance *dev, static void emac_put_deps(struct emac_instance *dev) { - if (dev-mal_dev) - of_dev_put(dev-mal_dev); - if (dev-zmii_dev) - of_dev_put(dev-zmii_dev); - if (dev-rgmii_dev) - of_dev_put(dev-rgmii_dev); - if (dev-mdio_dev) - of_dev_put(dev-mdio_dev); - if (dev-tah_dev) - of_dev_put(dev-tah_dev); + of_dev_put(dev-mal_dev); + of_dev_put(dev-zmii_dev); + of_dev_put(dev-rgmii_dev); + of_dev_put(dev-mdio_dev); + of_dev_put(dev-tah_dev); } static int emac_of_bus_notify(struct notifier_block *nb, unsigned long action, @@ -2371,8 +2366,7 @@ static int emac_wait_deps(struct emac_instance *dev) bus_unregister_notifier(platform_bus_type, emac_of_bus_notifier); err = emac_check_deps(dev, deps) ? 0 : -ENODEV; for (i = 0; i EMAC_DEP_COUNT; i++) { - if (deps[i].node) - of_node_put(deps[i].node); + of_node_put(deps[i].node); if (err deps[i].ofdev) of_dev_put(deps[i].ofdev); } @@ -2383,8 +2377,7 @@ static int emac_wait_deps(struct emac_instance *dev) dev-tah_dev = deps[EMAC_DEP_TAH_IDX].ofdev; dev-mdio_dev = deps[EMAC_DEP_MDIO_IDX].ofdev; } - if (deps[EMAC_DEP_PREV_IDX].ofdev) - of_dev_put(deps[EMAC_DEP_PREV_IDX].ofdev); + of_dev_put(deps[EMAC_DEP_PREV_IDX].ofdev); return err; } @@ -3113,8 +3106,7 @@ static void __exit emac_exit(void) /* Destroy EMAC boot list */ for (i = 0; i EMAC_BOOT_LIST_SIZE; i++) - if (emac_boot_list[i]) - of_node_put(emac_boot_list[i]); + of_node_put(emac_boot_list[i]); } module_init(emac_init); -- 2.1.3 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V2 12/22] perf itrace: Add a heap for sorting Instruction Tracing queues
In order to process Instruction 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 adrian.hun...@intel.com --- tools/perf/util/itrace.c | 85 tools/perf/util/itrace.h | 29 + 2 files changed, 114 insertions(+) diff --git a/tools/perf/util/itrace.c b/tools/perf/util/itrace.c index c67bf10..b50d959 100644 --- a/tools/perf/util/itrace.c +++ b/tools/perf/util/itrace.c @@ -347,6 +347,91 @@ void itrace_queues__free(struct itrace_queues *queues) queues-nr_queues = 0; } +static void itrace_heapify(struct itrace_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 itrace_heap__add(struct itrace_heap *heap, unsigned int queue_nr, +u64 ordinal) +{ + struct itrace_heap_item *heap_array; + + if (queue_nr = heap-heap_sz) { + unsigned int heap_sz = ITRACE_INIT_NR_QUEUES; + + while (heap_sz = queue_nr) + heap_sz = 1; + heap_array = realloc(heap-heap_array, +heap_sz * sizeof(struct itrace_heap_item)); + if (!heap_array) + return -ENOMEM; + heap-heap_array = heap_array; + heap-heap_sz = heap_sz; + } + + itrace_heapify(heap-heap_array, heap-heap_cnt++, queue_nr, ordinal); + + return 0; +} + +void itrace_heap__free(struct itrace_heap *heap) +{ + zfree(heap-heap_array); + heap-heap_cnt = 0; + heap-heap_sz = 0; +} + +void itrace_heap__pop(struct itrace_heap *heap) +{ + unsigned int pos, last, heap_cnt = heap-heap_cnt; + struct itrace_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; + itrace_heapify(heap_array, pos, heap_array[last].queue_nr, + heap_array[last].ordinal); +} + size_t itrace_record__info_priv_size(struct itrace_record *itr) { if (itr) diff --git a/tools/perf/util/itrace.h b/tools/perf/util/itrace.h index c357893..a7d4ad2 100644 --- a/tools/perf/util/itrace.h +++ b/tools/perf/util/itrace.h @@ -172,6 +172,29 @@ struct itrace_queues { }; /** + * struct itrace_heap_item - element of struct itrace_heap. + * @queue_nr: queue number + * @ordinal: value used for sorting (lowest ordinal is top of the heap) expected + * to be a timestamp + */ +struct itrace_heap_item { + unsigned intqueue_nr; + u64 ordinal; +}; + +/** + * struct itrace_heap - a heap suitable for sorting Instruction 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 itrace_heap { + struct itrace_heap_item *heap_array; + unsigned intheap_cnt; + unsigned intheap_sz; +}; + +/** * struct itrace_mmap - records an mmap of the itrace buffer. * @base: address of mapped area * @userpg: pointer to buffer's perf_event_mmap_page @@ -280,6 +303,12 @@ void *itrace_buffer__get_data(struct itrace_buffer *buffer, int fd); void itrace_buffer__put_data(struct itrace_buffer *buffer); void itrace_buffer__drop_data(struct itrace_buffer *buffer); void itrace_buffer__free(struct itrace_buffer *buffer); + +int itrace_heap__add(struct itrace_heap *heap, unsigned int queue_nr, +u64 ordinal); +void itrace_heap__pop(struct itrace_heap *heap); +void itrace_heap__free(struct itrace_heap *heap); + struct itrace_record
[PATCH V2 15/22] perf tools: Add member to struct dso for an instruction cache
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 adrian.hun...@intel.com --- 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 45be944..73e28ca 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 itrace.h #include util.h #include debug.h @@ -914,6 +915,7 @@ void dso__delete(struct dso *dso) } dso__data_close(dso); + itrace_cache__free(dso-itrace_cache); dso_cache__free(dso-data.cache); dso__free_a2l(dso); zfree(dso-symsrc_filename); diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 3782c82..c27c8fc 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -101,6 +101,8 @@ struct dsos { struct rb_root root; /* rbtree root sorted by long name */ }; +struct itrace_cache; + struct dso { struct list_head node; struct rb_node rb_node; /* rbtree node sorted by long name */ @@ -130,6 +132,7 @@ struct dso { u16 long_name_len; u16 short_name_len; void*dwfl; /* DWARF debug info */ + struct itrace_cache *itrace_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/
Re: ext4: kill ext4_kvfree()
On Thu 20-11-14 08:10:05, Al Viro wrote: Signed-off-by: Al Viro v...@zeniv.linux.org.uk Looks good. Added Ted (ext4 maintainer) to CC. Reviewed-by: Jan Kara j...@suse.cz Honza --- fs/ext4/ext4.h|1 - fs/ext4/mballoc.c |6 +++--- fs/ext4/resize.c |6 +++--- fs/ext4/super.c | 19 +-- 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index c55a1fa..21a3b38 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2192,7 +2192,6 @@ extern int ext4_calculate_overhead(struct super_block *sb); extern void ext4_superblock_csum_set(struct super_block *sb); extern void *ext4_kvmalloc(size_t size, gfp_t flags); extern void *ext4_kvzalloc(size_t size, gfp_t flags); -extern void ext4_kvfree(void *ptr); extern int ext4_alloc_flex_bg_array(struct super_block *sb, ext4_group_t ngroup); extern const char *ext4_decode_error(struct super_block *sb, int errno, diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index dbfe15c..004d0ff 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -2358,7 +2358,7 @@ int ext4_mb_alloc_groupinfo(struct super_block *sb, ext4_group_t ngroups) if (sbi-s_group_info) { memcpy(new_groupinfo, sbi-s_group_info, sbi-s_group_info_size * sizeof(*sbi-s_group_info)); - ext4_kvfree(sbi-s_group_info); + kvfree(sbi-s_group_info); } sbi-s_group_info = new_groupinfo; sbi-s_group_info_size = size / sizeof(*sbi-s_group_info); @@ -2495,7 +2495,7 @@ err_freebuddy: kfree(sbi-s_group_info[i]); iput(sbi-s_buddy_cache); err_freesgi: - ext4_kvfree(sbi-s_group_info); + kvfree(sbi-s_group_info); return -ENOMEM; } @@ -2708,7 +2708,7 @@ int ext4_mb_release(struct super_block *sb) EXT4_DESC_PER_BLOCK_BITS(sb); for (i = 0; i num_meta_group_infos; i++) kfree(sbi-s_group_info[i]); - ext4_kvfree(sbi-s_group_info); + kvfree(sbi-s_group_info); } kfree(sbi-s_mb_offsets); kfree(sbi-s_mb_maxs); diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index ca45883..bf76f40 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -856,7 +856,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, n_group_desc[gdb_num] = gdb_bh; EXT4_SB(sb)-s_group_desc = n_group_desc; EXT4_SB(sb)-s_gdb_count++; - ext4_kvfree(o_group_desc); + kvfree(o_group_desc); le16_add_cpu(es-s_reserved_gdt_blocks, -1); err = ext4_handle_dirty_super(handle, sb); @@ -866,7 +866,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, return err; exit_inode: - ext4_kvfree(n_group_desc); + kvfree(n_group_desc); brelse(iloc.bh); exit_dind: brelse(dind); @@ -909,7 +909,7 @@ static int add_new_gdb_meta_bg(struct super_block *sb, n_group_desc[gdb_num] = gdb_bh; EXT4_SB(sb)-s_group_desc = n_group_desc; EXT4_SB(sb)-s_gdb_count++; - ext4_kvfree(o_group_desc); + kvfree(o_group_desc); BUFFER_TRACE(gdb_bh, get_write_access); err = ext4_journal_get_write_access(handle, gdb_bh); if (unlikely(err)) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 2c9e686..4b79f39 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -176,15 +176,6 @@ void *ext4_kvzalloc(size_t size, gfp_t flags) return ret; } -void ext4_kvfree(void *ptr) -{ - if (is_vmalloc_addr(ptr)) - vfree(ptr); - else - kfree(ptr); - -} - ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, struct ext4_group_desc *bg) { @@ -811,8 +802,8 @@ static void ext4_put_super(struct super_block *sb) for (i = 0; i sbi-s_gdb_count; i++) brelse(sbi-s_group_desc[i]); - ext4_kvfree(sbi-s_group_desc); - ext4_kvfree(sbi-s_flex_groups); + kvfree(sbi-s_group_desc); + kvfree(sbi-s_flex_groups); percpu_counter_destroy(sbi-s_freeclusters_counter); percpu_counter_destroy(sbi-s_freeinodes_counter); percpu_counter_destroy(sbi-s_dirs_counter); @@ -1939,7 +1930,7 @@ int ext4_alloc_flex_bg_array(struct super_block *sb, ext4_group_t ngroup) memcpy(new_groups, sbi-s_flex_groups, (sbi-s_flex_groups_allocated * sizeof(struct flex_groups))); - ext4_kvfree(sbi-s_flex_groups); + kvfree(sbi-s_flex_groups); } sbi-s_flex_groups = new_groups; sbi-s_flex_groups_allocated = size / sizeof(struct flex_groups); @@ -4224,7 +4215,7 @@ failed_mount7: failed_mount6: ext4_mb_release(sb); if (sbi-s_flex_groups) - ext4_kvfree(sbi-s_flex_groups); +
[PATCH V2 13/22] perf itrace: Add processing for Instruction Tracing events
Provide hooks so that an Instruction Trace decoder can process Instruction Tracing events. Signed-off-by: Adrian Hunter adrian.hun...@intel.com --- tools/perf/util/itrace.c | 49 tools/perf/util/itrace.h | 13 + 2 files changed, 62 insertions(+) diff --git a/tools/perf/util/itrace.c b/tools/perf/util/itrace.c index b50d959..eb43a7f 100644 --- a/tools/perf/util/itrace.c +++ b/tools/perf/util/itrace.c @@ -599,6 +599,28 @@ out_free: return err; } +static bool itrace__dont_decode(struct perf_session *session) +{ + return !session-itrace_synth_opts || + session-itrace_synth_opts-dont_decode; +} + +int perf_event__process_itrace_info(struct perf_tool *tool __maybe_unused, + union perf_event *event, + struct perf_session *session __maybe_unused) +{ + enum itrace_type type = event-itrace_info.type; + + if (dump_trace) + fprintf(stdout, type: %u\n, type); + + switch (type) { + case PERF_ITRACE_UNKNOWN: + default: + return -EINVAL; + } +} + int perf_event__synthesize_itrace(struct perf_tool *tool, perf_event__handler_t process, size_t size, u64 offset, u64 ref, int idx, @@ -619,6 +641,30 @@ int perf_event__synthesize_itrace(struct perf_tool *tool, return process(tool, ev, NULL, NULL); } +s64 perf_event__process_itrace(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-itrace.size, event-itrace.offset, + event-itrace.reference, event-itrace.idx, + event-itrace.tid, event-itrace.cpu); + + if (itrace__dont_decode(session)) + return event-itrace.size; + + if (!session-itrace || event-header.type != PERF_RECORD_ITRACE) + return -EINVAL; + + err = session-itrace-process_itrace_event(session, event, tool); + if (err 0) + return err; + + return event-itrace.size; +} + #define PERF_ITRACE_DEFAULT_PERIOD_TYPE PERF_ITRACE_PERIOD_NANOSECS #define PERF_ITRACE_DEFAULT_PERIOD 10 #define PERF_ITRACE_DEFAULT_CALLCHAIN_SZ 16 @@ -764,6 +810,9 @@ int perf_event__process_itrace_error(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_session *session) { + if (itrace__dont_decode(session)) + return 0; + if (session-itrace) session-itrace-error_count += 1; diff --git a/tools/perf/util/itrace.h b/tools/perf/util/itrace.h index a7d4ad2..575037c 100644 --- a/tools/perf/util/itrace.h +++ b/tools/perf/util/itrace.h @@ -34,6 +34,10 @@ struct option; struct record_opts; struct itrace_info_event; +enum itrace_type { + PERF_ITRACE_UNKNOWN, +}; + enum itrace_error_type { PERF_ITRACE_DECODER_ERROR = 1, }; @@ -90,6 +94,9 @@ struct itrace { union perf_event *event, struct perf_sample *sample, struct perf_tool *tool); + int (*process_itrace_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); @@ -330,10 +337,16 @@ int perf_event__synthesize_itrace_info(struct itrace_record *itr, struct perf_tool *tool, struct perf_session *session, perf_event__handler_t process); +int perf_event__process_itrace_info(struct perf_tool *tool, + union perf_event *event, + struct perf_session *session); int perf_event__synthesize_itrace(struct perf_tool *tool, perf_event__handler_t process, size_t size, u64 offset, u64 ref, int idx, u32 tid, u32 cpu); +s64 perf_event__process_itrace(struct perf_tool *tool, + union perf_event *event, + struct perf_session *session); int perf_event__process_itrace_error(struct perf_tool *tool, union perf_event *event, struct perf_session *session); -- 1.9.1 -- To unsubscribe from this list: send the
[PATCH V2 14/22] perf itrace: Add a hashtable for caching decoded instructions
Decoding Instruction Trace data may involve walking object code. Rather than repetitively decoding the same instructions, a cache can be used to cache the results. Signed-off-by: Adrian Hunter adrian.hun...@intel.com --- tools/perf/util/itrace.c | 123 +++ tools/perf/util/itrace.h | 14 ++ 2 files changed, 137 insertions(+) diff --git a/tools/perf/util/itrace.c b/tools/perf/util/itrace.c index eb43a7f..fd67a9a 100644 --- a/tools/perf/util/itrace.c +++ b/tools/perf/util/itrace.c @@ -37,6 +37,8 @@ #include thread_map.h #include itrace.h +#include linux/hash.h + #include event.h #include session.h #include debug.h @@ -916,3 +918,124 @@ int itrace_mmap__read(struct itrace_mmap *mm, struct itrace_record *itr, return 1; } + +/** + * struct itrace_cache - hash table to cache decoded instruction blocks + * @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 itrace_cache { + struct hlist_head *hashtable; + size_t sz; + size_t entry_size; + size_t limit; + size_t cnt; + unsigned int bits; +}; + +struct itrace_cache *itrace_cache__new(unsigned int bits, size_t entry_size, + unsigned int limit_percent) +{ + struct itrace_cache *c; + struct hlist_head *ht; + size_t sz, i; + + c = zalloc(sizeof(struct itrace_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(ht[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 itrace_cache__drop(struct itrace_cache *c) +{ + struct itrace_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, c-hashtable[i], hash) { + hlist_del(entry-hash); + itrace_cache__free_entry(c, entry); + } + } + + c-cnt = 0; +} + +void itrace_cache__free(struct itrace_cache *c) +{ + if (!c) + return; + + itrace_cache__drop(c); + free(c-hashtable); + free(c); +} + +void *itrace_cache__alloc_entry(struct itrace_cache *c) +{ + return malloc(c-entry_size); +} + +void itrace_cache__free_entry(struct itrace_cache *c __maybe_unused, + void *entry) +{ + free(entry); +} + +int itrace_cache__add(struct itrace_cache *c, u32 key, + struct itrace_cache_entry *entry) +{ + if (c-limit ++c-cnt c-limit) + itrace_cache__drop(c); + + entry-key = key; + hlist_add_head(entry-hash, c-hashtable[hash_32(key, c-bits)]); + + return 0; +} + +void *itrace_cache__lookup(struct itrace_cache *c, u32 key) +{ + struct itrace_cache_entry *entry; + struct hlist_head *hlist; + + if (!c) + return NULL; + + hlist = c-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/itrace.h b/tools/perf/util/itrace.h index 575037c..e67fa34 100644 --- a/tools/perf/util/itrace.h +++ b/tools/perf/util/itrace.h @@ -316,6 +316,20 @@ int itrace_heap__add(struct itrace_heap *heap, unsigned int queue_nr, void itrace_heap__pop(struct itrace_heap *heap); void itrace_heap__free(struct itrace_heap *heap); +struct itrace_cache_entry { + struct hlist_node hash; + u32 key; +}; + +struct itrace_cache *itrace_cache__new(unsigned int bits, size_t entry_size, + unsigned int limit_percent); +void itrace_cache__free(struct itrace_cache *itrace_cache); +void *itrace_cache__alloc_entry(struct itrace_cache *c); +void itrace_cache__free_entry(struct itrace_cache *c, void *entry); +int itrace_cache__add(struct itrace_cache *c, u32 key, + struct itrace_cache_entry *entry); +void *itrace_cache__lookup(struct itrace_cache *c, u32 key); + struct itrace_record *itrace_record__init(int *err); int itrace_record__options(struct itrace_record *itr, -- 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
[PATCH V2 10/22] perf itrace: Add helpers for Instruction Tracing errors
Add functions to synthesize, count and print Instruction Tracing error events. Signed-off-by: Adrian Hunter adrian.hun...@intel.com --- tools/perf/util/itrace.c | 55 tools/perf/util/itrace.h | 16 ++ 2 files changed, 71 insertions(+) diff --git a/tools/perf/util/itrace.c b/tools/perf/util/itrace.c index 2a3a7ce..b063c26 100644 --- a/tools/perf/util/itrace.c +++ b/tools/perf/util/itrace.c @@ -22,6 +22,7 @@ #include linux/types.h #include stdlib.h +#include stdio.h #include string.h #include errno.h @@ -33,6 +34,7 @@ #include itrace.h #include event.h +#include session.h #include debug.h #include parse-options.h @@ -157,6 +159,28 @@ struct itrace_record * __weak itrace_record__init(int *err) return NULL; } +void itrace_synth_error(struct itrace_error_event *itrace_error, int type, + int code, int cpu, pid_t pid, pid_t tid, u64 ip, + const char *msg) +{ + size_t size; + + memset(itrace_error, 0, sizeof(struct itrace_error_event)); + + itrace_error-header.type = PERF_RECORD_ITRACE_ERROR; + itrace_error-type = type; + itrace_error-code = code; + itrace_error-cpu = cpu; + itrace_error-pid = pid; + itrace_error-tid = tid; + itrace_error-ip = ip; + strlcpy(itrace_error-msg, msg, MAX_ITRACE_ERROR_MSG); + + size = (void *)itrace_error-msg - (void *)itrace_error + + strlen(itrace_error-msg) + 1; + itrace_error-header.size = PERF_ALIGN(size, sizeof(u64)); +} + int perf_event__synthesize_itrace_info(struct itrace_record *itr, struct perf_tool *tool, struct perf_session *session, @@ -336,6 +360,37 @@ out_err: return -EINVAL; } +size_t perf_event__fprintf_itrace_error(union perf_event *event, FILE *fp) +{ + struct itrace_error_event *e = event-itrace_error; + int ret; + + ret = fprintf(fp, Instruction trace error type %u, 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; +} + +int perf_event__process_itrace_error(struct perf_tool *tool __maybe_unused, +union perf_event *event, +struct perf_session *session) +{ + if (session-itrace) + session-itrace-error_count += 1; + + perf_event__fprintf_itrace_error(event, stdout); + return 0; +} + +int perf_event__count_itrace_error(struct perf_tool *tool __maybe_unused, + union perf_event *event __maybe_unused, + struct perf_session *session) +{ + if (session-itrace) + session-itrace-error_count += 1; + return 0; +} + int itrace_mmap__read(struct itrace_mmap *mm, struct itrace_record *itr, struct perf_tool *tool, process_itrace_t fn) { diff --git a/tools/perf/util/itrace.h b/tools/perf/util/itrace.h index 76e70ea..8275afd 100644 --- a/tools/perf/util/itrace.h +++ b/tools/perf/util/itrace.h @@ -33,6 +33,10 @@ struct option; struct record_opts; struct itrace_info_event; +enum itrace_error_type { + PERF_ITRACE_DECODER_ERROR = 1, +}; + enum itrace_period_type { PERF_ITRACE_PERIOD_INSTRUCTIONS, PERF_ITRACE_PERIOD_TICKS, @@ -202,6 +206,10 @@ int itrace_record__info_fill(struct itrace_record *itr, void itrace_record__free(struct itrace_record *itr); u64 itrace_record__reference(struct itrace_record *itr); +void itrace_synth_error(struct itrace_error_event *itrace_error, int type, + int code, int cpu, pid_t pid, pid_t tid, u64 ip, + const char *msg); + int perf_event__synthesize_itrace_info(struct itrace_record *itr, struct perf_tool *tool, struct perf_session *session, @@ -210,10 +218,18 @@ int perf_event__synthesize_itrace(struct perf_tool *tool, perf_event__handler_t process, size_t size, u64 offset, u64 ref, int idx, u32 tid, u32 cpu); +int perf_event__process_itrace_error(struct perf_tool *tool, +union perf_event *event, +struct perf_session *session); +int perf_event__count_itrace_error(struct perf_tool *tool __maybe_unused, + union perf_event *event __maybe_unused, + struct perf_session *session); int itrace_parse_synth_opts(const struct option *opt, const char *str, int unset); void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts); +size_t perf_event__fprintf_itrace_error(union
[PATCH V2 11/22] perf itrace: Add helpers for queuing Instruction Tracing data
Provide functions to queue Instruction Tracing data buffers for processing. A Instruction Trace 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 adrian.hun...@intel.com --- tools/perf/util/itrace.c | 304 +++ tools/perf/util/itrace.h | 87 ++ 2 files changed, 391 insertions(+) diff --git a/tools/perf/util/itrace.c b/tools/perf/util/itrace.c index b063c26..c67bf10 100644 --- a/tools/perf/util/itrace.c +++ b/tools/perf/util/itrace.c @@ -20,11 +20,15 @@ #include linux/kernel.h #include linux/perf_event.h #include linux/types.h +#include linux/string.h +#include sys/param.h #include stdlib.h #include stdio.h #include string.h +#include limits.h #include errno.h +#include linux/list.h #include ../perf.h #include util.h @@ -108,6 +112,241 @@ void itrace_mmap_params__set_idx(struct itrace_mmap_params *mp, } } +#define ITRACE_INIT_NR_QUEUES 32 + +static struct itrace_queue *itrace_alloc_queue_array(unsigned int nr_queues) +{ + struct itrace_queue *queue_array; + unsigned int max_nr_queues, i; + + max_nr_queues = MIN(UINT_MAX, SIZE_MAX) / sizeof(struct itrace_queue); + if (nr_queues max_nr_queues) + return NULL; + + queue_array = calloc(nr_queues, sizeof(struct itrace_queue)); + if (!queue_array) + return NULL; + + for (i = 0; i nr_queues; i++) { + INIT_LIST_HEAD(queue_array[i].head); + queue_array[i].priv = NULL; + } + + return queue_array; +} + +int itrace_queues__init(struct itrace_queues *queues) +{ + queues-nr_queues = ITRACE_INIT_NR_QUEUES; + queues-queue_array = itrace_alloc_queue_array(queues-nr_queues); + if (!queues-queue_array) + return -ENOMEM; + return 0; +} + +static int itrace_queues__grow(struct itrace_queues *queues, + unsigned int new_nr_queues) +{ + unsigned int nr_queues = queues-nr_queues; + struct itrace_queue *queue_array; + unsigned int i; + + if (!nr_queues) + nr_queues = ITRACE_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 = itrace_alloc_queue_array(nr_queues); + if (!queue_array) + return -ENOMEM; + + for (i = 0; i queues-nr_queues; i++) { + list_splice_tail(queues-queue_array[i].head, +queue_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 *itrace_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 itrace_queues__add_buffer(struct itrace_queues *queues, +unsigned int idx, +struct itrace_buffer *buffer) +{ + struct itrace_queue *queue; + int err; + + if (idx = queues-nr_queues) { + err = itrace_queues__grow(queues, idx + 1); + if (err) + return err; + } + + queue = queues-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(itrace 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(buffer-list, queue-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 itrace_queues__split_buffer(struct itrace_queues *queues, + unsigned int idx, + struct itrace_buffer *buffer) +{ + u64 sz = buffer-size; + bool consecutive = false; + struct itrace_buffer *b; + int
[PATCH V2 09/22] perf session: Add Instruction Tracing options
It is assumed that Instruction Trace decoding will synthesize events for consumption by other tools. 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 adrian.hun...@intel.com --- tools/perf/util/itrace.c | 131 ++ tools/perf/util/itrace.h | 43 +++ tools/perf/util/session.h | 2 + 3 files changed, 176 insertions(+) diff --git a/tools/perf/util/itrace.c b/tools/perf/util/itrace.c index 08372a9..2a3a7ce 100644 --- a/tools/perf/util/itrace.c +++ b/tools/perf/util/itrace.c @@ -34,6 +34,7 @@ #include event.h #include debug.h +#include parse-options.h int itrace_mmap__mmap(struct itrace_mmap *mm, struct itrace_mmap_params *mp, void *userpg, int fd) @@ -205,6 +206,136 @@ int perf_event__synthesize_itrace(struct perf_tool *tool, return process(tool, ev, NULL, NULL); } +#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, endptr, 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 = + PERF_ITRACE_DEFAULT_CALLCHAIN_SZ; +
[PATCH V2 04/22] perf tools: Add support for Instruction Trace recording
Add support for reading from the Instruction Tracing mmap and synthesizing Instruction Tracing events. This patch introduces an abstraction for recording Instruction Trace data. Recording is initialized by itrace_record__init() which is a weak function to be implemented by the architecture to provide recording callbacks. Recording is mainly handled by itrace_mmap__read() and perf_event__synthesize_itrace() but there are callbacks for miscellaneous needs including validating and processing user options, populating private data in itrace_info_event, and freeing the structure when finished. Signed-off-by: Adrian Hunter adrian.hun...@intel.com --- tools/perf/perf.h| 2 + tools/perf/util/itrace.c | 195 +++ tools/perf/util/itrace.h | 59 +- tools/perf/util/record.c | 11 ++- 4 files changed, 265 insertions(+), 2 deletions(-) diff --git a/tools/perf/perf.h b/tools/perf/perf.h index 1dabb85..ca4c09d 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h @@ -53,8 +53,10 @@ struct record_opts { bool sample_time; bool period; bool sample_intr_regs; + bool full_itrace; unsigned int freq; unsigned int mmap_pages; + unsigned int itrace_mmap_pages; unsigned int user_freq; u64 branch_stack; u64 default_interval; diff --git a/tools/perf/util/itrace.c b/tools/perf/util/itrace.c index c950b4f..08372a9 100644 --- a/tools/perf/util/itrace.c +++ b/tools/perf/util/itrace.c @@ -21,6 +21,10 @@ #include linux/perf_event.h #include linux/types.h +#include stdlib.h +#include string.h +#include errno.h + #include ../perf.h #include util.h #include evlist.h @@ -28,6 +32,9 @@ #include thread_map.h #include itrace.h +#include event.h +#include debug.h + int itrace_mmap__mmap(struct itrace_mmap *mm, struct itrace_mmap_params *mp, void *userpg, int fd) { @@ -97,3 +104,191 @@ void itrace_mmap_params__set_idx(struct itrace_mmap_params *mp, mp-tid = evlist-threads-map[idx]; } } + +size_t itrace_record__info_priv_size(struct itrace_record *itr) +{ + if (itr) + return itr-info_priv_size(itr); + return 0; +} + +static int itrace_not_supported(void) +{ + pr_err(Instruction tracing is not supported on this architecture\n); + return -EINVAL; +} + +int itrace_record__info_fill(struct itrace_record *itr, +struct perf_session *session, +struct itrace_info_event *itrace_info, +size_t priv_size) +{ + if (itr) + return itr-info_fill(itr, session, itrace_info, priv_size); + return itrace_not_supported(); +} + +void itrace_record__free(struct itrace_record *itr) +{ + if (itr) + itr-free(itr); +} + +int itrace_record__options(struct itrace_record *itr, + struct perf_evlist *evlist, + struct record_opts *opts) +{ + if (itr) + return itr-recording_options(itr, evlist, opts); + return 0; +} + +u64 itrace_record__reference(struct itrace_record *itr) +{ + if (itr) + return itr-reference(itr); + return 0; +} + +struct itrace_record * __weak itrace_record__init(int *err) +{ + *err = 0; + return NULL; +} + +int perf_event__synthesize_itrace_info(struct itrace_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 itrace information\n); + priv_size = itrace_record__info_priv_size(itr); + ev = zalloc(sizeof(struct itrace_info_event) + priv_size); + if (!ev) + return -ENOMEM; + + ev-itrace_info.header.type = PERF_RECORD_ITRACE_INFO; + ev-itrace_info.header.size = sizeof(struct itrace_info_event) + + priv_size; + err = itrace_record__info_fill(itr, session, ev-itrace_info, + priv_size); + if (err) + goto out_free; + + err = process(tool, ev, NULL, NULL); +out_free: + free(ev); + return err; +} + +int perf_event__synthesize_itrace(struct perf_tool *tool, + perf_event__handler_t process, + size_t size, u64 offset, u64 ref, int idx, + u32 tid, u32 cpu) +{ + union perf_event ev; + + memset(ev, 0, sizeof(ev)); + ev.itrace.header.type = PERF_RECORD_ITRACE; + ev.itrace.header.size = sizeof(ev.itrace); + ev.itrace.size = size; + ev.itrace.offset = offset; + ev.itrace.reference = ref; +
[PATCH 0/2] Add regulator-haptic driver
This patch series adds regulator-haptic driver. The regulator-haptic has haptic motor and it is controlled by voltage of regulator via force feedback framework. Jaewon Kim (2): Input: add regulator haptic driver ARM: dts: Add regulator-haptic device node for exynos3250-rinato .../devicetree/bindings/input/regulator-haptic.txt | 24 ++ arch/arm/boot/dts/exynos3250-rinato.dts|7 + drivers/input/misc/Kconfig | 11 + drivers/input/misc/Makefile|1 + drivers/input/misc/regulator-haptic.c | 241 5 files changed, 284 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/regulator-haptic.txt create mode 100644 drivers/input/misc/regulator-haptic.c -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V2 02/22] perf evlist: Add initial support for mmapping an Instruction Trace buffer
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 for Instruction Tracing, hence the name itrace. The first implementation will support Intel BTS and Intel PT. One itrace buffer is mmapped per perf-events buffer. If the requested itrace buffer size is zero, which it will be until further support is added, then no itrace mmapping is attempted. Signed-off-by: Adrian Hunter adrian.hun...@intel.com --- tools/perf/Makefile.perf | 2 + tools/perf/util/evlist.c | 60 +++-- tools/perf/util/evlist.h | 5 +++ tools/perf/util/itrace.c | 99 tools/perf/util/itrace.h | 96 ++ 5 files changed, 259 insertions(+), 3 deletions(-) create mode 100644 tools/perf/util/itrace.c create mode 100644 tools/perf/util/itrace.h diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 478efa9..f321e2f 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -314,6 +314,7 @@ LIB_H += util/perf_regs.h LIB_H += util/unwind.h LIB_H += util/vdso.h LIB_H += util/tsc.h +LIB_H += util/itrace.h LIB_H += ui/helpline.h LIB_H += ui/progress.h LIB_H += ui/util.h @@ -399,6 +400,7 @@ LIB_OBJS += $(OUTPUT)util/data.o LIB_OBJS += $(OUTPUT)util/tsc.o LIB_OBJS += $(OUTPUT)util/cloexec.o LIB_OBJS += $(OUTPUT)util/thread-stack.o +LIB_OBJS += $(OUTPUT)util/itrace.o LIB_OBJS += $(OUTPUT)ui/setup.o LIB_OBJS += $(OUTPUT)ui/helpline.o diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index cfbe2b9..2ee7f46 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -724,6 +724,34 @@ void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx) perf_evlist__mmap_put(evlist, idx); } +int __weak itrace_mmap__mmap(struct itrace_mmap *mm __maybe_unused, +struct itrace_mmap_params *mp __maybe_unused, +void *userpg __maybe_unused, +int fd __maybe_unused) +{ + return 0; +} + +void __weak itrace_mmap__munmap(struct itrace_mmap *mm __maybe_unused) +{ +} + +void __weak itrace_mmap_params__init( + struct itrace_mmap_params *mp __maybe_unused, + off_t itrace_offset __maybe_unused, + unsigned int itrace_pages __maybe_unused, + bool itrace_overwrite __maybe_unused) +{ +} + +void __weak itrace_mmap_params__set_idx( + struct itrace_mmap_params *mp __maybe_unused, + struct perf_evlist *evlist __maybe_unused, + int idx __maybe_unused, + bool per_cpu __maybe_unused) +{ +} + static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx) { if (evlist-mmap[idx].base != NULL) { @@ -731,6 +759,7 @@ static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx) evlist-mmap[idx].base = NULL; evlist-mmap[idx].refcnt = 0; } + itrace_mmap__munmap(evlist-mmap[idx].itrace_mmap); } void perf_evlist__munmap(struct perf_evlist *evlist) @@ -758,6 +787,7 @@ static int perf_evlist__alloc_mmap(struct perf_evlist *evlist) struct mmap_params { int prot; int mask; + struct itrace_mmap_params itrace_mp; }; static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx, @@ -788,6 +818,10 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx, return -1; } + if (itrace_mmap__mmap(evlist-mmap[idx].itrace_mmap, + mp-itrace_mp, evlist-mmap[idx].base, fd)) + return -1; + return 0; } @@ -852,6 +886,8 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, for (cpu = 0; cpu nr_cpus; cpu++) { int output = -1; + itrace_mmap_params__set_idx(mp-itrace_mp, evlist, cpu, true); + for (thread = 0; thread nr_threads; thread++) { if (perf_evlist__mmap_per_evsel(evlist, cpu, mp, cpu, thread, output)) @@ -877,6 +913,9 @@ static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, for (thread = 0; thread nr_threads; thread++) { int output = -1; + itrace_mmap_params__set_idx(mp-itrace_mp, evlist, thread, + false); + if (perf_evlist__mmap_per_evsel(evlist, thread, mp, 0, thread, output)) goto out_unmap; @@ -966,19 +1005,25 @@ int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str, } /** - * perf_evlist__mmap - Create
[PATCH 2/2] ARM: dts: Add regulator-haptic device node for exynos3250-rinato
This patch adds regulator-haptic device node controlled by regulator. Signed-off-by: Jaewon Kim jaewon02@samsung.com --- arch/arm/boot/dts/exynos3250-rinato.dts |7 +++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/boot/dts/exynos3250-rinato.dts b/arch/arm/boot/dts/exynos3250-rinato.dts index 84380fa..8172815 100644 --- a/arch/arm/boot/dts/exynos3250-rinato.dts +++ b/arch/arm/boot/dts/exynos3250-rinato.dts @@ -104,6 +104,13 @@ }; }; }; + + regulator-haptic { + compatible = regulator-haptic; + haptic-supply = motor_reg; + min-microvolt = 110; + max-microvolt = 270; + }; }; adc { -- 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 v4 1/2] ARM: keystone: pm: switch to use generic pm domains
On Thu, Nov 20, 2014 at 2:12 PM, Ulf Hansson ulf.hans...@linaro.org wrote: According to earlier comments in this thread, device's clocks are split into functional and PM clocks. If I understand correctly, a typical platform driver will enable it's functional clocks during -probe() and you want the PM domain to take care of the PM clocks, when the device changes runtime PM status. How will you describe these different set of device clocks in DT? True :( You can dig deeper in the history of this series if you wish. - first Geert Uytterhoeven proposed to use CLK_RUNTIME_PM there https://lkml.org/lkml/2014/11/6/319 - second I proposed to introduce smth. like clkops-clocks, pm-clocks there https://lkml.org/lkml/2014/6/12/436 or fck-clocks/opt-clocks later. ^failed. So, this implementation picks up all clocks for each device, which is ok for Keystone 2 and, because it's platform specific. Yes, it would definitely solve the problem that I see with the infrastructure code that the current version adds into the platform directory. The exact binding of course should be reviewed by the pmdomain and DT maintainers, to ensure that it is done the best possible way, because I assume we will end up using it a lot, and it would be a shame to get it slightly wrong. One possible variation I can think of would be to just use simple-pmdomain as the compatible string, and use properties in the node itself to decide what the domain should control, e.g. clk_pmdomain: pmdomain { compatible = simple-pmdomain; pmdomain-enable-clocks; #power-domain-cells = 0; }; clk_regulator_pmdomain: pmdomain { compatible = simple-pmdomain; pmdomain-enable-clocks; pmdomain-enable-regulators; #power-domain-cells = 0; }; and then have each device link to one of the nodes as the pmdomain. That's seems like a good approach to me. Yes, but your previous comment is still actual :( Agree! So I really think we need to decide on how to address the split of the device clocks. Before that's done, I don't think it make sense to add a simple-pmdomain compatible, since it will likely not be that many SoC that can use it. So, does anyone have a suggestion on how to deal with the split of the device clocks into functional clocks and into PM clocks? That's indeed the tricky part. On shmobile, we just use the NULL clock, i.e. the first clock, for historical reasons. Using clock-names (e.g. fck and pm) will conflict with existing bindings for devices that already mandate specific clock names. As the clock being a PM clock is a property of the clock provider (at last on shmobile), I originally came up with not handling it in DT, but advertising it in the clock provider driver: - first Geert Uytterhoeven proposed to use CLK_RUNTIME_PM there https://lkml.org/lkml/2014/11/6/319 Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say programmer or something like that. -- Linus Torvalds -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/2] Input: add regulator haptic driver
This patch adds support for haptic driver controlled by voltage of regulator. And this driver support for Force Feedback interface from input framework Signed-off-by: Jaewon Kim jaewon02@samsung.com Signed-off-by: Hyunhee Kim hyunhee@samsung.com Acked-by: Kyungmin Park kyungmin.p...@samsung.com --- .../devicetree/bindings/input/regulator-haptic.txt | 24 ++ drivers/input/misc/Kconfig | 11 + drivers/input/misc/Makefile|1 + drivers/input/misc/regulator-haptic.c | 241 4 files changed, 277 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/regulator-haptic.txt create mode 100644 drivers/input/misc/regulator-haptic.c diff --git a/Documentation/devicetree/bindings/input/regulator-haptic.txt b/Documentation/devicetree/bindings/input/regulator-haptic.txt new file mode 100644 index 000..9f60e17 --- /dev/null +++ b/Documentation/devicetree/bindings/input/regulator-haptic.txt @@ -0,0 +1,24 @@ +* Requlator Haptic Device Tree Bindings + +The regulator haptic driver controlled by voltage of regulator. +This driver implemented via Force Feedback interface. + +Required Properties: + - compatible : Should be regulator-haptic + - haptic-supply : Power supply for the haptic motor. + [*] refer Documentation/devicetree/bindings/regulator/regulator.txt + + - max-microvolt : The maximum voltage value supplied to haptic motor. + [The unit of the voltage is a micro] + + - min-microvolt : The minimum voltage value in which haptic motor reacts. + [The unit of the voltage is a micro] + +Example: + + regulator-haptic { + compatible = regulator-haptic; + haptic-supply = motor_regulator; + max-microvolt = 270; + min-microvolt = 110; + }; diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 23297ab..e5e556d 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -394,6 +394,17 @@ config INPUT_CM109 To compile this driver as a module, choose M here: the module will be called cm109. +config INPUT_REGULATOR_HAPTIC + tristate regulator haptics support + select INPUT_FF_MEMLESS + help + This option enables device driver support for the haptic controlled + by regulator. This driver supports ff-memless interface + from input framework. + + To compile this driver as a module, choose M here: the + module will be called regulator-haptic. + config INPUT_RETU_PWRBUTTON tristate Retu Power button Driver depends on MFD_RETU diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 19c7603..1f135af 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -53,6 +53,7 @@ obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY) += pmic8xxx-pwrkey.o obj-$(CONFIG_INPUT_POWERMATE) += powermate.o obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o +obj-$(CONFIG_INPUT_REGULATOR_HAPTIC) += regulator-haptic.o obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)+= rotary_encoder.o obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o diff --git a/drivers/input/misc/regulator-haptic.c b/drivers/input/misc/regulator-haptic.c new file mode 100644 index 000..1a83ecb --- /dev/null +++ b/drivers/input/misc/regulator-haptic.c @@ -0,0 +1,241 @@ +/* + * Regulator haptic driver + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Author: Jaewon Kim jaewon02@samsung.com + * Author: Hyunhee Kim hyunhee@samsung.com + * + * 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 linux/module.h +#include linux/platform_device.h +#include linux/input.h +#include linux/slab.h +#include linux/regulator/consumer.h +#include linux/of.h + +#define MAX_MAGNITUDE_SHIFT16 + +struct regulator_haptic { + struct device *dev; + struct input_dev *input_dev; + struct regulator *regulator; + struct work_struct work; + + bool enabled; + bool suspend_state; + unsigned int max_volt; + unsigned int min_volt; + unsigned int intensity; + unsigned int magnitude; +}; + +static void regulator_haptic_enable(struct regulator_haptic *haptic) +{ + int error; + + if (haptic-enabled) + return; + + error = regulator_enable(haptic-regulator); + if (error) { + dev_err(haptic-dev, cannot enable regulator\n); + return; + } + + haptic-enabled = true; +} + +static void regulator_haptic_disable(struct regulator_haptic *haptic) +{ + int error; + + if (!haptic-enabled) +
Re: [PATCH 3/3] mfd: cros_ec: Expose Chrome OS Lightbar to users
Hello Lee, On 11/20/2014 02:27 PM, Lee Jones wrote: By the sounds of the description, it doesn't seem as though this driver lives in MFD. I suggest another home, such as drivers/led. You are right. As I said in the other email, I'll move it to drivers/platform/chrome/ which seems like a more suitable place. Does it? I would have thought 'lightbar' lives in LEDs, but I guess that's between you and the drivers/platform/chrome maintainer now. Ok, I'll move cros_ec_lightbar to drivers/led then and cros_ec_dev to drivers/platform/chrome. Thanks a lot for all your suggestions! Best regards, Javier -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@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] KVM: ia64: remove
2014-11-19 22:05+0100, Paolo Bonzini: KVM for ia64 has been marked as broken not just once, but twice even, and the last patch from the maintainer is now roughly 5 years old. Time for it to rest in piece. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- Nice, if only every diffstat was like that! I propose another removal. (The reasoning below wasn't confirmed with ia64 compiler. I'd remove the ioctls even if they worked.) ---8--- KVM: remove buggy ia64 specific ioctls IA64 is no longer present so new applications shouldn't use them. The main problem is that they most likely didn't work even before, because we have misused ioctl #define KVM_SET_GUEST_DEBUG _IOW(KVMIO, 0x9b, struct kvm_guest_debug) #define KVM_IA64_VCPU_SET_STACK _IOW(KVMIO, 0x9b, void *) as struct kvm_guest_debug { __u32 control; __u32 pad; struct kvm_guest_debug_arch arch; }; and struct kvm_guest_debug_arch { }; mean that sizeof(struct kvm_guest_debug) == sizeof(void *) == 8 thus KVM_SET_GUEST_DEBUG == KVM_IA64_VCPU_SET_STACK and KVM_SET_GUEST_DEBUG is handled before KVM_IA64_VCPU_SET_STACK. Signed-off-by: Radim Krčmář rkrc...@redhat.com --- include/uapi/linux/kvm.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 6d59e5b..a37fd12 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -1099,9 +1099,6 @@ struct kvm_s390_ucas_mapping { #define KVM_X86_SETUP_MCE _IOW(KVMIO, 0x9c, __u64) #define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO, 0x9d, __u64) #define KVM_X86_SET_MCE _IOW(KVMIO, 0x9e, struct kvm_x86_mce) -/* IA64 stack access */ -#define KVM_IA64_VCPU_GET_STACK _IOR(KVMIO, 0x9a, void *) -#define KVM_IA64_VCPU_SET_STACK _IOW(KVMIO, 0x9b, void *) /* Available with KVM_CAP_VCPU_EVENTS */ #define KVM_GET_VCPU_EVENTS _IOR(KVMIO, 0x9f, struct kvm_vcpu_events) #define KVM_SET_VCPU_EVENTS _IOW(KVMIO, 0xa0, struct kvm_vcpu_events) -- 2.1.0 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH V4 1/3] perf tools: enable LBR call stack support
On Thu, Nov 20, 2014 at 7:32 AM, Namhyung Kim namhy...@kernel.org wrote: On Wed, 19 Nov 2014 14:32:08 +, Kan Liang wrote: On Tue, 18 Nov 2014 16:36:55 -0500, kan liang wrote: + if (attr-exclude_user) { + attr-exclude_user = 0; + + pr_warning(LBR callstack option is only available + to get user callchain information. + Force exclude_user to 0.\n); + } I'm not sure what's in a higher priority - maybe I missed earlier discussion. IOW what about this? if (attr-exclude_user) { pr_warning(LBR callstack option is only available to get user callchain information.\n); I think either is fine. I'd like to add more info Falling back to framepointers. based on your changes. So the user know what they will get then. What do you think? Looks good to me. But I still slightly prefer not to override user settings. But it's not a strong opinion though - I'd like to here from others. I don't like when the tool changes the use settings under the hood. I think perf did that with cycles - TASK_CLOCK if PMU was not supported and that was very confusing to me especially with no warning. So if LBR Call stack mode is not avail, then inform the user with a warning or error, don't swap silently. OK. So the new patch will warn the user if LBR call stack is no available. It will also tell the user that the FP mode will replace the LBR mode. Thanks, Kan
Re: [PATCH vfs 2/2] {block|char}_dev: remove inode-i_devices
On Thu, Nov 20, 2014 at 08:11:18AM -0500, Tejun Heo wrote: ... creating another one-off behavior. If we demote this to something which is shared only between block and char devs, we can go simpler and less versatile. Where should it go tho? So, one option is implementing something minimal in fs/devptrs.h or somesuch and include it from block/char_dev.c. If it isn't exposed as a generic lib function, this can be a lot simpler. I'll give it a shot later today. Thanks. -- tejun -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@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: crypto: user - Allow get request with empty driver name
On Thu, Nov 20, 2014 at 02:10:00PM +0100, Stephan Mueller wrote: What about the following if (p-cru_driver_name[0] alg = crypto_alg_match(p, 1); else alg = crypto_alg_match(p, 0); If cru_driver_name is not empty then exact will never be used, no? Cheers, -- Email: Herbert Xu herb...@gondor.apana.org.au Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] mm: page_alloc: store updated page migratetype to avoid misusing stale value
On Thu, Nov 20, 2014 at 5:28 AM, Vlastimil Babka vba...@suse.cz wrote: On 11/17/2014 11:40 AM, Weijie Yang wrote: The commit ad53f92e(fix incorrect isolation behavior by rechecking migratetype) patch series describe the race between page isolation and free path, and try to fix the freepage account issues. However, there is still a little issue: freed page could have stale migratetype in the free_list. This would cause some bad behavior if we misuse this stale value later. Such as: in __test_page_isolated_in_pageblock() we check the buddy page, if the page's stale migratetype is not MIGRATE_ISOLATE, which will cause unnecessary page move action. Hello, Hi Vlastimil, Thanks for your reply, that makes me think from a bigger view. After a careful check according to your said, this patch is not proper, it should be dropped and I will resend a v2 patch. are there other places than __test_page_isolated_in_pageblock(), where freepage_migratetype matters? You make it sound like it's just an example, but I doubt there is any other. All other callers of get_freepage_migratetype() are querying pages on the pcplists, not the buddy lists. There it serves as a cached value for migratetype so it doesn't have to be read again when freeing from pcplists to budy list. Agree. Now only __test_page_isolated_in_pageblock() matters freepage_migratetype. pages from pcplists have a cached but not 100% accurate migratetype and we will recheck them when drain them to buddy if there is a need(race with isolation); pages in buddy should have an update and 100% accurate migratetype, or it would cause some bad issue, and that is the aim of this patch. Or, if we make nobody rely on the freepage_migratetype in buddy, we can take no care of the 100% accuracy of the freepage_migratetype in buddy. This is your suggestion, do I understand it correctly? Seems to me that __test_page_isolated_in_pageblock() was an exception that tried to rely on freepage_migratetype being valid even after the page has moved from pcplist to buddy list, but this assumption was always broken. I am not very clear, could you please explain why it always broken? Sure, if all the pages in isolated pageblock are catched by move_freepages() during isolation, then the freetype is correct, but that doesn't always happen due to parallel activity (and that's the core problem that Joonsoo's series dealt with). Agree. Joonsoo's series fix the race between page freeing and isolation due to not-update freepage_migratetype check, and introduce nr_isolate_pageblock to avoid too much heavy check. So, in this patch you try to make sure that freepage_migratetype will be correct after page got to buddy list via __free_one_page(). But I don't think that covers all situations. Look at expand(), which puts potentially numerous splitted free pages on free_list, and doesn't set freepage_migratetype. Sure, this ommision doesn't affect __test_page_isolated_in_pageblock(), as expand() is called during allocation, which won't touch ISOLATE pageblocks, and free pages created by expand() *before* setting ISOLATE are processed by move_freepages(). I have to admit I did not think about the page_alloc path(such as expand), I will review the code before I resend the patch. What I thought is setting freepage_migratetype via __free_one_page() is enough because we can ensure them correct from the begining __free_pages_bootmem(). So my point is, you are maybe fixing just the case of __test_page_isolated_in_pageblock() (but not completely I think, see below) by adding extra operation to __free_one_page() which is hot path. And all for a WARN_ON_ONCE. That doesn't seem like a good tradeoff. And to do it consistently, you would need to add the operation also to expand(), another hotpath. So that's a NAK from me. I agree we should handle hot patch carefully, in my next patch I will consider how to avoid affecting the hot path meanwhile fix the __test_page_isolated_in_pageblock(). I would uggest you throw the __test_page_isolated_in_pageblock() function away completely. I'm not sure we can throw it completely. There is another check on page_count besides PageBuddy() and hwpoison stuff. Or just rework it to check for PageBuddy() and hwpoison stuff - the migratetype checks make no sense to me. Or if you insist that this is needed for debugging further possible races in page isolation, then please hide the necessary bits in hot paths being a debugging config option. Agree. If you agree, we can even throw away the set_freepage_migratetype() calls from move_freepages() - there's no point to them anymore. Agree. This patch store the page's updated migratetype after free the page to the free_list to avoid subsequent misusing stale value, and use a WARN_ON_ONCE to catch a potential undetected race between isolatation and free path. Signed-off-by: Weijie Yang weijie.y...@samsung.com --- mm/page_alloc.c |1 +
[PATCH] kvm: x86: move ioapic.c and irq_comm.c back to arch/x86/
ia64 does not need them anymore. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- arch/x86/include/asm/kvm_host.h | 16 arch/x86/kvm/Makefile | 5 ++--- {virt = arch/x86}/kvm/ioapic.c | 0 {virt = arch/x86}/kvm/ioapic.h | 1 - {virt = arch/x86}/kvm/irq_comm.c | 4 ++-- arch/x86/kvm/x86.c| 1 + include/linux/kvm_host.h | 22 -- virt/kvm/eventfd.c| 7 --- virt/kvm/kvm_main.c | 3 --- 9 files changed, 29 insertions(+), 30 deletions(-) rename {virt = arch/x86}/kvm/ioapic.c (100%) rename {virt = arch/x86}/kvm/ioapic.h (98%) rename {virt = arch/x86}/kvm/irq_comm.c (98%) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 769db36a3001..76ff3e2d8fd2 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -603,6 +603,9 @@ struct kvm_arch { struct kvm_xen_hvm_config xen_hvm_config; + /* reads protected by irq_srcu, writes by irq_lock */ + struct hlist_head mask_notifier_list; + /* fields used by HYPER-V emulation */ u64 hv_guest_os_id; u64 hv_hypercall; @@ -819,6 +822,19 @@ int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa, const void *val, int bytes); u8 kvm_get_guest_memory_type(struct kvm_vcpu *vcpu, gfn_t gfn); +struct kvm_irq_mask_notifier { + void (*func)(struct kvm_irq_mask_notifier *kimn, bool masked); + int irq; + struct hlist_node link; +}; + +void kvm_register_irq_mask_notifier(struct kvm *kvm, int irq, + struct kvm_irq_mask_notifier *kimn); +void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int irq, + struct kvm_irq_mask_notifier *kimn); +void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned pin, +bool mask); + extern bool tdp_enabled; u64 vcpu_tsc_khz(struct kvm_vcpu *vcpu); diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile index 25d22b2d6509..ee1cd92b03be 100644 --- a/arch/x86/kvm/Makefile +++ b/arch/x86/kvm/Makefile @@ -7,14 +7,13 @@ CFLAGS_vmx.o := -I. KVM := ../../../virt/kvm -kvm-y += $(KVM)/kvm_main.o $(KVM)/ioapic.o \ - $(KVM)/coalesced_mmio.o $(KVM)/irq_comm.o \ +kvm-y += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o \ $(KVM)/eventfd.o $(KVM)/irqchip.o $(KVM)/vfio.o kvm-$(CONFIG_KVM_DEVICE_ASSIGNMENT)+= $(KVM)/assigned-dev.o $(KVM)/iommu.o kvm-$(CONFIG_KVM_ASYNC_PF) += $(KVM)/async_pf.o kvm-y += x86.o mmu.o emulate.o i8259.o irq.o lapic.o \ - i8254.o cpuid.o pmu.o + i8254.o ioapic.o irq_comm.o cpuid.o pmu.o kvm-intel-y+= vmx.o kvm-amd-y += svm.o diff --git a/virt/kvm/ioapic.c b/arch/x86/kvm/ioapic.c similarity index 100% rename from virt/kvm/ioapic.c rename to arch/x86/kvm/ioapic.c diff --git a/virt/kvm/ioapic.h b/arch/x86/kvm/ioapic.h similarity index 98% rename from virt/kvm/ioapic.h rename to arch/x86/kvm/ioapic.h index dc3baa3a538f..deac8d509f2a 100644 --- a/virt/kvm/ioapic.h +++ b/arch/x86/kvm/ioapic.h @@ -96,7 +96,6 @@ int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, struct kvm_lapic_irq *irq, unsigned long *dest_map); int kvm_get_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state); int kvm_set_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state); -void kvm_vcpu_request_scan_ioapic(struct kvm *kvm); void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap, u32 *tmr); diff --git a/virt/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c similarity index 98% rename from virt/kvm/irq_comm.c rename to arch/x86/kvm/irq_comm.c index 1345bde064f5..e9c135b639aa 100644 --- a/virt/kvm/irq_comm.c +++ b/arch/x86/kvm/irq_comm.c @@ -234,7 +234,7 @@ void kvm_register_irq_mask_notifier(struct kvm *kvm, int irq, { mutex_lock(kvm-irq_lock); kimn-irq = irq; - hlist_add_head_rcu(kimn-link, kvm-mask_notifier_list); + hlist_add_head_rcu(kimn-link, kvm-arch.mask_notifier_list); mutex_unlock(kvm-irq_lock); } @@ -256,7 +256,7 @@ void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned pin, idx = srcu_read_lock(kvm-irq_srcu); gsi = kvm_irq_map_chip_pin(kvm, irqchip, pin); if (gsi != -1) - hlist_for_each_entry_rcu(kimn, kvm-mask_notifier_list, link) + hlist_for_each_entry_rcu(kimn, kvm-arch.mask_notifier_list, link) if (kimn-irq == gsi) kimn-func(kimn, mask); srcu_read_unlock(kvm-irq_srcu, idx); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a8f53a6960fd..5337039427c8 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@
Re: [PATCH v5 2/2] tracing: add additional marks to signal very large time
On Thu, 20 Nov 2014 15:05:43 +0900 Namhyung Kim namhy...@kernel.org wrote: Hi Steve and Byungchul, On Wed, 19 Nov 2014 20:06:04 -0500, Steven Rostedt wrote: On Thu, 20 Nov 2014 09:15:35 +0900 byungchul.p...@lge.com wrote: -static unsigned long preempt_mark_thresh_us = 100; +#undef MARK +#define MARK(v, s) {.val = v, .sym = s} +/* trace overhead mark */ +static const struct trace_mark { + unsigned long long val; /* unit: nsec */ + charsym; +} mark[] = { + MARK(10ULL , '$'), /* 1 sec */ + MARK(100ULL , '#'), /* 1000 usecs */ + MARK(10ULL , '!'), /* 100 usecs */ + MARK(1ULL , '+'), /* 10 usecs */ + MARK(0ULL , ' '), /* 0 usecs */ +}; +#undef MARK + +char trace_find_mark(unsigned long long d) +{ + int i; + int size = ARRAY_SIZE(mark); + + for (i = 0; i size; i++) { + if (d = mark[i].val) + break; + } + + return (i == size)? ' ' : mark[i].sym; Change this to: /* The break from loop must have been hit */ if (WARN_ON_ONCE(i == size)) return ' '; I think it's impossible since it's always true that 'd = 0'. It is impossible if this code never changes. But we all know that wont be the case :-) -- Steve -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@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/2] tracing: add additional marks to signal very large time
On Thu, 20 Nov 2014 15:38:46 +0900 Byungchul Park byungchul.p...@lge.com wrote: I think it's impossible since it's always true that 'd = 0'. If someone won't define MARK(0ULL, ' '), then i think it can happen. :) Actually, remove the MARK(0ULL, ' ') and keep the return value as is. But clean it up a little like this: return (i == size) ? ' ' : mark[i].sym; Notice the space between size) and ? -- Steve -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@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] KVM: ia64: remove
On 20/11/2014 14:38, Radim Krčmář wrote: I propose another removal. (The reasoning below wasn't confirmed with ia64 compiler. I'd remove the ioctls even if they worked.) Checked and applied, thanks. Paolo ---8--- KVM: remove buggy ia64 specific ioctls IA64 is no longer present so new applications shouldn't use them. The main problem is that they most likely didn't work even before, because we have misused ioctl #define KVM_SET_GUEST_DEBUG _IOW(KVMIO, 0x9b, struct kvm_guest_debug) #define KVM_IA64_VCPU_SET_STACK _IOW(KVMIO, 0x9b, void *) as struct kvm_guest_debug { __u32 control; __u32 pad; struct kvm_guest_debug_arch arch; }; and struct kvm_guest_debug_arch { }; mean that sizeof(struct kvm_guest_debug) == sizeof(void *) == 8 thus KVM_SET_GUEST_DEBUG == KVM_IA64_VCPU_SET_STACK and KVM_SET_GUEST_DEBUG is handled before KVM_IA64_VCPU_SET_STACK. Signed-off-by: Radim Krčmář rkrc...@redhat.com --- include/uapi/linux/kvm.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 6d59e5b..a37fd12 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -1099,9 +1099,6 @@ struct kvm_s390_ucas_mapping { #define KVM_X86_SETUP_MCE _IOW(KVMIO, 0x9c, __u64) #define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO, 0x9d, __u64) #define KVM_X86_SET_MCE _IOW(KVMIO, 0x9e, struct kvm_x86_mce) -/* IA64 stack access */ -#define KVM_IA64_VCPU_GET_STACK _IOR(KVMIO, 0x9a, void *) -#define KVM_IA64_VCPU_SET_STACK _IOW(KVMIO, 0x9b, void *) /* Available with KVM_CAP_VCPU_EVENTS */ #define KVM_GET_VCPU_EVENTS _IOR(KVMIO, 0x9f, struct kvm_vcpu_events) #define KVM_SET_VCPU_EVENTS _IOW(KVMIO, 0xa0, struct kvm_vcpu_events) -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls
From: Markus Elfring elfr...@users.sourceforge.net Date: Thu, 20 Nov 2014 14:47:12 +0100 The functions kfree() and of_node_put() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring elfr...@users.sourceforge.net --- drivers/net/ethernet/xilinx/ll_temac_main.c | 3 +-- drivers/net/ethernet/xilinx/xilinx_emaclite.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c index fda5891..af60867 100644 --- a/drivers/net/ethernet/xilinx/ll_temac_main.c +++ b/drivers/net/ethernet/xilinx/ll_temac_main.c @@ -224,8 +224,7 @@ static void temac_dma_bd_release(struct net_device *ndev) dma_free_coherent(ndev-dev.parent, sizeof(*lp-tx_bd_v) * TX_BD_NUM, lp-tx_bd_v, lp-tx_bd_p); - if (lp-rx_skb) - kfree(lp-rx_skb); + kfree(lp-rx_skb); } /** diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c index 28dbbdc..2485879 100644 --- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c +++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c @@ -1200,8 +1200,7 @@ static int xemaclite_of_remove(struct platform_device *of_dev) unregister_netdev(ndev); - if (lp-phy_node) - of_node_put(lp-phy_node); + of_node_put(lp-phy_node); lp-phy_node = NULL; xemaclite_remove_ndev(ndev); -- 2.1.3 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
Mikko, On Wed, Nov 19, 2014 at 05:43:20PM +0200, Mikko Perttunen wrote: On 11/19/2014 05:41 PM, Mikko Perttunen wrote: On 11/18/2014 04:39 PM, Eduardo Valentin wrote: Different drivers request API extensions in of-thermal. For this reason, additional callbacks are required to fit the new drivers needs. The current API implementation expects the registering sensor driver to provide a get_temp and get_trend callbacks as function parameters. As the amount of callbacks is growing, this patch changes the existing implementation to use a .ops field to hold all the of thermal callbacks to sensor drivers. This patch also changes the existing of-thermal users to fit the new API design. No functional change is introduced in this patch. Cc: Alexandre Courbot gnu...@gmail.com Cc: devicet...@vger.kernel.org Cc: Grant Likely grant.lik...@linaro.org Cc: Guenter Roeck li...@roeck-us.net Cc: Jean Delvare jdelv...@suse.de Cc: linux-kernel@vger.kernel.org Cc: linux...@vger.kernel.org Cc: linux-te...@vger.kernel.org Cc: lm-sens...@lm-sensors.org Cc: Rob Herring robh...@kernel.org Cc: Stephen Warren swar...@wwwdotorg.org Cc: Thierry Reding thierry.red...@gmail.com Cc: Zhang Rui rui.zh...@intel.com Reviewed-by: Lukasz Majewski l.majew...@samsung.com Signed-off-by: Eduardo Valentin edubez...@gmail.com --- drivers/hwmon/lm75.c | 9 +++-- drivers/hwmon/ntc_thermistor.c | 6 +++- drivers/hwmon/tmp102.c | 6 +++- drivers/thermal/of-thermal.c | 40 ++ drivers/thermal/tegra_soctherm.c | 7 ++-- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 8 +++-- include/linux/thermal.h| 24 + 7 files changed, 63 insertions(+), 37 deletions(-) --- Difference from V3: - Keep the same behavior regarding callback checks. Change in behavior may be sent in a separate patch. Difference from V2: - Fix wrong assignment in tegra driver. Difference from V1: - Fix error handling when .get_trend is not provided. @@ -356,8 +356,8 @@ thermal_zone_of_add_sensor(struct device_node *zone, * than one sensors * @data: a private pointer (owned by the caller) that will be passed *back, when a temperature reading is needed. - * @get_temp: a pointer to a function that reads the sensor temperature. - * @get_trend: a pointer to a function that reads the sensor temperature trend. + * @ops: struct thermal_zone_of_device *. Must contain at least .get_trend and + * .get_temp. This comment seems to be incorrect, as .get_trend is optional. Also, the parameter is of type struct thermal_zone_of_device_ops *, not just thermal_zone_of_device. * * This function will search the list of thermal zones described in device * tree and look for the zone that refer to the sensor device pointed by With that minor one fixed, Tested-by: Mikko Perttunen mikko.perttu...@kapsi.fi Reviewed-by: Mikko Perttunen mikko.perttu...@kapsi.fi All the comments fixed now. Thanks for reviewing and testing. Cheers, Mikko -- To unsubscribe from this list: send the line unsubscribe linux-tegra in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Cheers, Eduardo Valentin signature.asc Description: Digital signature
Re: [PATCH v3] Bluetooth: automatically flushable packets aren't allowed on LE links
Hi Johan, The bluetooth spec states that automatically flushable packets may not be sent over a LE-U link. Signed-off-by: Steven Walter stevenrwal...@gmail.com --- net/bluetooth/l2cap_core.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 4af3821..7c4350f 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -764,7 +764,7 @@ static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, if (!skb) return; -if (lmp_no_flush_capable(conn-hcon-hdev)) +if (lmp_no_flush_capable(conn-hcon-hdev) || conn-hcon-type == LE_LINK) flags = ACL_START_NO_FLUSH; else flags = ACL_START; @@ -784,7 +784,7 @@ static bool __chan_is_moving(struct l2cap_chan *chan) static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) { struct hci_conn *hcon = chan-conn-hcon; -u16 flags; +u16 flags = ACL_START; BT_DBG(chan %p, skb %p len %d priority %u, chan, skb, skb-len, skb-priority); @@ -798,11 +798,13 @@ static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) return; } -if (!test_bit(FLAG_FLUSHABLE, chan-flags) -lmp_no_flush_capable(hcon-hdev)) +if (hcon-type == LE_LINK) { +/* LE-U does not support auto-flushing packets */ flags = ACL_START_NO_FLUSH; -else -flags = ACL_START; +} else if (!test_bit(FLAG_FLUSHABLE, chan-flags) +lmp_no_flush_capable(hcon-hdev)) { +flags = ACL_START_NO_FLUSH; +} I think Marcel was after just providing a clarifying code comment in both places - having two branches of an if-statement doing exactly the same thing looks a bit weird to me. To make thins completely clear I'd suggest adding a simple helper function that you can call from both places to get the needed flags, something like the following: I am actually fine with just adding a comment explaining the complex if statement on why it is correct. It is just a helper for everybody to understand what and why it is done that way. static u16 get_acl_flags(struct hci_conn *hcon, struct l2cap_chan *chan) { If we do it with a helper functions, then it should only provide the l2cap_chan since we can get the hci_conn from there. /* LE-U does not support auto-flushing packets */ if (hcon-type == LE_LINK) return ACL_START_NO_FLUSH; /* If non-flushable packets are not supported don't request them */ if (!lmp_no_flush_capable(hcon-hdev)) return ACL_START; /* If the chan has requested auto-flushing go with that */ if (chan test_bit(FLAG_FLUSHABLE, chan-flags)) return ACL_START; This seems to be a bit too much. The FLAG_FLUSABLE is only settable if the controller supports it. I wonder why we need the LMP features check here in the first place. Can we not just trust the flag on the channel is set correctly and enforce it before setting the flag. /* Otherwise go with a non-flushable packet */ return ACL_START_NO_FLUSH; } This way we'd avoid complex if-statements and can clearly document each condition independently. Regards Marcel -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v4 3/3] tracing: add additional marks to signal very large delay
On Thu, 20 Nov 2014 15:11:19 +0900 Namhyung Kim namhy...@kernel.org wrote: +'#' - greater than 1000 microsecond +'!' - greater than 100 microsecond +'+' - greater than 10 microsecond I've noticed that it's now changed from 1 msec to 10 msec. Is it okay? Yeah, I didn't like the inconsistency between the two tracers, and not only that, I found the 1 microsecond mark rather useless. 10 is a much better value. I don't think people will complain about this API change. -- Steve -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@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 RESEND] ARM: dts: bcm63138: change interupts to interrupts
On Mon, 17 Nov 2014, Radek Dostal wrote: all other nodes in bcm63138.dtsi use interrupts, this had to be just a typo which never got noticed, even it may have quite some consequences. Signed-off-by: Radek Dostal radek.dos...@streamunlimited.com Acked-by: Florian Fainelli f.faine...@gmail.com --- Dear all, resending the previous patch with added Acked-by from Florian Fainelli. I did not hear anything back for almost a week. Additionally CC to triv...@kernel.org as it may qualify for it. As this got acked by Florian and I don't see it in linux-next as of today, I am taking it. -- Jiri Kosina SUSE Labs -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
Alexander, On Wed, Nov 19, 2014 at 05:06:24PM +0900, Alexandre Courbot wrote: On Tue, Nov 18, 2014 at 11:39 PM, Eduardo Valentin edubez...@gmail.com wrote: Different drivers request API extensions in of-thermal. For this reason, additional callbacks are required to fit the new drivers needs. The current API implementation expects the registering sensor driver to provide a get_temp and get_trend callbacks as function parameters. As the amount of callbacks is growing, this patch changes the existing implementation to use a .ops field to hold all the of thermal callbacks to sensor drivers. This patch also changes the existing of-thermal users to fit the new API design. No functional change is introduced in this patch. A good idea even if no ops were to be added! Reviewed-by: Alexandre Courbot acour...@nvidia.com Thanks for reviewing. Eduardo Valentin signature.asc Description: Digital signature
Re: [PATCH] tracing: Fix race of function probes counting
On Thu, 20 Nov 2014 20:45:09 +0900 Masami Hiramatsu masami.hiramatsu...@hitachi.com wrote: Signed-off-by: Steven Rostedt rost...@goodmis.org I have found a couple of typos, but basically, it looks OK. Reviewed-by: Masami Hiramatsu masami.hiramatsu...@hitachi.com Grumble. I already pushed this to next so it's in my no rebase state. But I can add another patch to do these updates. --- kernel/trace/trace_functions.c | 117 + 1 file changed, 96 insertions(+), 21 deletions(-) diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c index a8e0c7666164..973db52eb070 100644 --- a/kernel/trace/trace_functions.c +++ b/kernel/trace/trace_functions.c @@ -261,37 +261,74 @@ static struct tracer function_trace __tracer_data = }; #ifdef CONFIG_DYNAMIC_FTRACE -static int update_count(void **data) +static void update_traceon_count(void **data, int on) btw, why don't you use bool instead of int? Because I didn't think of it ;-) Yeah, bool would be better. { - unsigned long *count = (long *)data; + long *count = (long *)data; + long old_count = *count; - if (!*count) - return 0; + /* +* Tracing gets disabled (or enabled) once per count. +* This function can be called at the same time on mulitple CPUs. multiple You know, that is probably the biggest typo I make. My fingers do not like to hit 't' before 'i' when I type multiple. In fact, it did it just then (I had to go back and correct it)! +* It is fine if both disable (or enable) tracing, as disabling +* (or enabling) the second time doesn't do anything as the +* state of the tracer is already disabled (or enabled). +* What needs to be synchronized in this case is that the count +* only gets decremented once, even if the tracer is disabled +* (or enabled) twice, as the second one is really a nop. +* +* The memory barriers guarantee that we only decrement the +* counter once. First the count is read to a local variable +* and a read barrier is used to make sure that it is loaded +* before checking if the tracer is in the state we want. +* If the tracer is not in the state we want, then the count +* is guaranteed to be the old count. +* +* Next the tracer is set to the state we want (disabled or enabled) +* then a write memory barrier is used to make sure that +* the new state is visible before changing the counter by +* one minus the old counter. This guarantees that another CPU +* executing this code will see the new state before seeing +* the new counter value, and would not do anthing if the new ^^^anything? OK, will fix. Thanks, -- Steve +* counter is seen. +* +* Note, there is no synchronization between this and a user +* setting the tracing_on file. But we currently don't care +* about that. +*/ + if (!old_count) + return; - if (*count != -1) - (*count)--; + /* Make sure we see count before checking tracing state */ + smp_rmb(); - return 1; + if (on == !!tracing_is_on()) + return; + + if (on) + tracing_on(); + else + tracing_off(); + + /* unlimited? */ + if (old_count == -1) + return; + + /* Make sure tracing state is visible before updating count */ + smp_wmb(); + + *count = old_count - 1; } static void ftrace_traceon_count(unsigned long ip, unsigned long parent_ip, void **data) { - if (tracing_is_on()) - return; - - if (update_count(data)) - tracing_on(); + update_traceon_count(data, 1); } static void ftrace_traceoff_count(unsigned long ip, unsigned long parent_ip, void **data) { - if (!tracing_is_on()) - return; - - if (update_count(data)) - tracing_off(); + update_traceon_count(data, 0); } static void @@ -330,11 +367,49 @@ ftrace_stacktrace(unsigned long ip, unsigned long parent_ip, void **data) static void ftrace_stacktrace_count(unsigned long ip, unsigned long parent_ip, void **data) { - if (!tracing_is_on()) - return; + long *count = (long *)data; + long old_count; + long new_count; - if (update_count(data)) - trace_dump_stack(STACK_SKIP); + /* +* Stack traces should only execute the number of times the +* user specified in the counter. +*/ + do { + + if (!tracing_is_on()) + return; + + old_count = *count; + + if (!old_count) + return; + + /* unlimited? */ +
[PATCH] random: wait for system_wq before pushing entropy into output pools
First prototype of tool which injects random delays in random places (implemented on top of kernel address sanitizer by Andrey Ryabinin) have caught race right at the first try. credit_entropy_bits() schedules work for pushing entropy from one pool into another too early, when system_wq isn't yet created. It's called from add_interrupt_randomness, so this path starts working right after enabling interrupts in start_kernel, but system workqueues are initialized much later in early_initcall(init_workqueues). It's impossible to create them earlier because threads have to be forked from kthreadd. This patch skips pushing if system_wq isn't here yet. Delaying this till SYSTEM_RUNNING state might lead to significant lost of precious entropy. Signed-off-by: Konstantin Khlebnikov k.khlebni...@samsung.com Reported-and-tested-by: Andrey Ryabinin a.ryabi...@samsung.com --- drivers/char/random.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 04645c0..d4a684f 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -683,7 +683,7 @@ retry: * full. */ if (entropy_bits random_write_wakeup_bits - r-initialized + system_wq r-initialized r-entropy_total = 2*random_read_wakeup_bits) { static struct entropy_store *last = blocking_pool; struct entropy_store *other = blocking_pool; @@ -695,7 +695,7 @@ retry: last = other; if (last-entropy_count = 3 * last-poolinfo-poolfracbits / 4) { - schedule_work(last-push_work); + queue_work(system_wq, last-push_work); r-entropy_total = 0; } } -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] kselftest: Move the docs to the Documentation dir
On 11/19/2014 05:16 PM, Tim Bird wrote: Also, adjust the formatting a bit, and expand the section about using TARGETS= on the make command line. Signed-off-by: Tim Bird tim.b...@sonymobile.com --- Documentation/kselftest.txt| 69 ++ tools/testing/selftests/README.txt | 61 - 2 files changed, 69 insertions(+), 61 deletions(-) create mode 100644 Documentation/kselftest.txt delete mode 100644 tools/testing/selftests/README.txt diff --git a/Documentation/kselftest.txt b/Documentation/kselftest.txt new file mode 100644 index 000..a87d840 --- /dev/null +++ b/Documentation/kselftest.txt Tim, Thanks for doing this. Looks good to me. I think you missed Documentation maintainer. Adding linux-doc and Jon Corbet to the thread with my ack to take this through Documentation tree. Acked-by: shua...@osg.samsung.com thanks, -- Shuah -- Shuah Khan Sr. Linux Kernel Developer Samsung Research America (Silicon Valley) shua...@osg.samsung.com | (970) 217-8978 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v4 3/6] mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save
On Tuesday 18 November 2014 10:42 PM, Dmitry Torokhov wrote: On Tue, Nov 18, 2014 at 02:30:05PM +, Lee Jones wrote: On Fri, 14 Nov 2014, Vignesh R wrote: In one shot mode, sequencer automatically disables all enabled steps at the end of each cycle. (both ADC steps and TSC steps) Hence these steps need not be saved in reg_se_cache for clearing these steps at a later stage. Also, when ADC wakes up Sequencer should not be busy executing any of the config steps except for the charge step. Previously charge step was 1 ADC clock cycle and hence it was ignored. Signed-off-by: Vignesh R vigne...@ti.com --- drivers/mfd/ti_am335x_tscadc.c | 7 +-- include/linux/mfd/ti_am335x_tscadc.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) Code looks better now. Acked-by: Lee Jones lee.jo...@linaro.org What's the plan for this series? I am waiting for the interested parties to provide more feedback. So far I have seen a few reports saying that they see issues with the series applied. I tested this using lcd7 cape connected to beaglebone black. The latest kernel I could find on this board was a TI BSP based v3.14 kernel. So I had to port these patches to that kernel. Cc Robert Nelson to see if he knows about a more recent kernel supporting that cape. I did not see any breakage with these patches applied although I did not see any noticeable performance improvement as well. I also tested along with continuous loop reading from /sys/bus/iio/devices/iio:device0/in_voltage5_raw I have pushed the kernel I used here in case anyone wants to take a look at my porting. http://git.ti.com/cgit/cgit.cgi/~nsekhar/ti-linux-kernel/nsekhar-ti-linux-kernel.git/log/?h=am335x-tsc-test I also tested this series on AM335x EVM using the v3.18-rc5 kernel. Again, no breakage but no improvement as well. All testing was done using ts_test FWIW, you can add: Tested-by: Sekhar Nori nsek...@ti.com Thanks, Sekhar -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@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] MIPS: mips-cm: CM regions are disabled at boot
On 11/20/2014 01:34 PM, Paul Burton wrote: On Thu, Nov 20, 2014 at 01:29:00PM +0100, Niklas Svensson wrote: Each CM_REGION_TARGET is set to disabled at boot, That part is true... so there is no need to disable the matching CM_GCR_REG explicitly. ...however there is no guarantee that the bootloader, or another kernel, or some other piece of code didn't program the registers differently before Linux starts. So I believe this patch to be incorrect. That is the reason for this patch. This will overwrite settings written by the bootloader. Say if the bootloader sets up an iocu, then these writes will clear those settings. Thanks, Paul Signed-off-by: Niklas Svensson nikl...@axis.com --- arch/mips/kernel/mips-cm.c | 10 -- 1 file changed, 10 deletions(-) diff --git a/arch/mips/kernel/mips-cm.c b/arch/mips/kernel/mips-cm.c index f76f7a0..a4bbfd9 100644 --- a/arch/mips/kernel/mips-cm.c +++ b/arch/mips/kernel/mips-cm.c @@ -104,16 +104,6 @@ int mips_cm_probe(void) base_reg |= CM_GCR_BASE_CMDEFTGT_MEM; write_gcr_base(base_reg); -/* disable CM regions */ -write_gcr_reg0_base(CM_GCR_REGn_BASE_BASEADDR_MSK); -write_gcr_reg0_mask(CM_GCR_REGn_MASK_ADDRMASK_MSK); -write_gcr_reg1_base(CM_GCR_REGn_BASE_BASEADDR_MSK); -write_gcr_reg1_mask(CM_GCR_REGn_MASK_ADDRMASK_MSK); -write_gcr_reg2_base(CM_GCR_REGn_BASE_BASEADDR_MSK); -write_gcr_reg2_mask(CM_GCR_REGn_MASK_ADDRMASK_MSK); -write_gcr_reg3_base(CM_GCR_REGn_BASE_BASEADDR_MSK); -write_gcr_reg3_mask(CM_GCR_REGn_MASK_ADDRMASK_MSK); - /* probe for an L2-only sync region */ mips_cm_probe_l2sync(); -- 2.1.3 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] random: wait for system_wq before pushing entropy into output pools
kasan splash and kernel oops, just for the record. [ 105.538000] == [ 105.538000] BUG: AddressSanitizer: user-memory-access on address 100 [ 105.538000] Read of size 4 by thread T1: [ 105.538000] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.18.0-rc4-mm1+ #146 [ 105.538000] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.7.5-0-ge51488c-20140602_164612-nilsson.home.kraxel.org 04/01/2014 [ 105.538000] 0013 3193e813 0013 [ 105.538000] 880003a03b50 81cffcb6 880003a03b80 [ 105.538000] 880003a03b70 81219794 0100 82282a20 [ 105.538000] Call Trace: [ 105.538000] IRQ dump_stack (lib/dump_stack.c:52) [ 105.538000] kasan_report_user_access (mm/kasan/report.c:198) [ 105.538000] __asan_load4 (mm/kasan/kasan.c:248 mm/kasan/kasan.c:403) [ 105.538000] ? __queue_work (kernel/workqueue.c:1301 (discriminator 8)) [ 105.538000] __queue_work (kernel/workqueue.c:1301 (discriminator 8)) [ 105.538000] ? add_interrupt_randomness (drivers/char/random.c:926) [ 105.538000] queue_work_on (kernel/workqueue.c:1403) [ 105.538000] credit_entropy_bits (drivers/char/random.c:699) [ 105.538000] add_interrupt_randomness (drivers/char/random.c:926) [ 105.538000] handle_irq_event_percpu (kernel/irq/handle.c:178) [ 105.538000] handle_irq_event (kernel/irq/handle.c:194) [ 105.538000] handle_level_irq (kernel/irq/chip.c:454) [ 105.538000] handle_irq (arch/x86/kernel/irq_64.c:89) [ 105.538000] do_IRQ (arch/x86/kernel/irq.c:200) [ 105.538000] common_interrupt (arch/x86/kernel/entry_64.S:798) [ 105.538000] ? rcu_gp_kthread (kernel/rcu/tree.c:2557) [ 105.538000] ? __do_softirq (arch/x86/include/asm/atomic.h:27 include/linux/jump_label.h:88 include/linux/jump_label.h:153 include/trace/events/irq.h:126 kernel/softirq.c:270) [ 105.538000] irq_exit (kernel/softirq.c:346 kernel/softirq.c:387) [ 105.538000] do_IRQ (arch/x86/kernel/irq.c:216) [ 105.538000] common_interrupt (arch/x86/kernel/entry_64.S:798) [ 105.538000] EOI ? delay_tsc (arch/x86/include/asm/paravirt.h:179 arch/x86/lib/delay.c:61) [ 105.538000] __const_udelay (arch/x86/lib/delay.c:126) [ 105.538000] __asan_load8 (mm/kasan/kasan.c:243 mm/kasan/kasan.c:409) [ 105.538000] setup_local_APIC (arch/x86/include/asm/apic.h:400 arch/x86/kernel/apic/apic.c:1372) [ 105.538000] native_smp_prepare_cpus (arch/x86/kernel/smpboot.c:1129) [ 105.538000] kernel_init_freeable (init/main.c:884 init/main.c:991) [ 105.538000] ? rest_init (init/main.c:924) [ 105.538000] kernel_init (init/main.c:929) [ 105.538000] ? rest_init (init/main.c:924) [ 105.538000] ret_from_fork (arch/x86/kernel/entry_64.S:348) [ 105.538000] ? rest_init (init/main.c:924) [ 105.538000] == [ 105.538000] BUG: unable to handle kernel NULL pointer dereference at 0100 [ 105.538000] IP: __queue_work (kernel/workqueue.c:1301 (discriminator 8)) [ 105.538000] PGD 0 [ 105.538000] Oops: [#1] SMP KASAN [ 105.538000] Modules linked in: [ 105.538000] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.18.0-rc4-mm1+ #146 [ 105.538000] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.7.5-0-ge51488c-20140602_164612-nilsson.home.kraxel.org 04/01/2014 [ 105.538000] task: 88001f88 ti: 8800035f8000 task.ti: 8800035f8000 [ 105.538000] RIP: __queue_work (kernel/workqueue.c:1301 (discriminator 8)) [ 105.538000] RSP: :880003a03bd0 EFLAGS: 00010086 [ 105.538000] RAX: RBX: 0082 RCX: 0042 [ 105.538000] RDX: RSI: 0013 RDI: 0013 [ 105.538000] RBP: 880003a03c30 R08: 000a R09: 0006 [ 105.538000] R10: dfffe901 R11: 104a4530 R12: 82282a20 [ 105.538000] R13: 0040 R14: R15: 815c844e [ 105.538000] FS: () GS:880003a0() knlGS: [ 105.538000] CS: 0010 DS: ES: CR0: 80050033 [ 105.538000] CR2: 0100 CR3: 02211000 CR4: 001406f0 [ 105.538000] Stack: [ 105.538000] 0100 0001 3193e813 [ 105.538000] 0082 00408257fc40 880003a03c50 0082 [ 105.538000] 82282a00 82282c28 815c844e [ 105.538000] Call Trace: [ 105.538000] IRQ [ 105.538000] ? add_interrupt_randomness (drivers/char/random.c:926) [ 105.538000] queue_work_on (kernel/workqueue.c:1403) [ 105.538000] credit_entropy_bits (drivers/char/random.c:699) [ 105.538000] add_interrupt_randomness (drivers/char/random.c:926) [ 105.538000] handle_irq_event_percpu (kernel/irq/handle.c:178) [ 105.538000] handle_irq_event (kernel/irq/handle.c:194) [ 105.538000]
Re: [PATCH v9 03/19] vfio: platform: add the VFIO PLATFORM module to Kconfig
On Thu, Nov 13, 2014 at 9:05 AM, Hongbo Zhang hongbo.zh...@linaro.org wrote: On 12 November 2014 17:57, Antonios Motakis a.mota...@virtualopensystems.com wrote: Hello Hongbo, On Wed, Nov 12, 2014 at 10:52 AM, Hongbo Zhang hongbo.zh...@linaro.org wrote: On 28 October 2014 02:07, Antonios Motakis a.mota...@virtualopensystems.com wrote: Enable building the VFIO PLATFORM driver that allows to use Linux platform devices with VFIO. Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com --- drivers/vfio/Kconfig | 1 + drivers/vfio/Makefile | 1 + drivers/vfio/platform/Kconfig | 9 + drivers/vfio/platform/Makefile | 4 4 files changed, 15 insertions(+) create mode 100644 drivers/vfio/platform/Kconfig create mode 100644 drivers/vfio/platform/Makefile diff --git a/drivers/vfio/Kconfig b/drivers/vfio/Kconfig index a0abe04..962fb80 100644 --- a/drivers/vfio/Kconfig +++ b/drivers/vfio/Kconfig @@ -27,3 +27,4 @@ menuconfig VFIO If you don't know what to do here, say N. source drivers/vfio/pci/Kconfig +source drivers/vfio/platform/Kconfig diff --git a/drivers/vfio/Makefile b/drivers/vfio/Makefile index 0b035b1..dadf0ca 100644 --- a/drivers/vfio/Makefile +++ b/drivers/vfio/Makefile @@ -3,3 +3,4 @@ obj-$(CONFIG_VFIO_IOMMU_TYPE1) += vfio_iommu_type1.o obj-$(CONFIG_VFIO_IOMMU_SPAPR_TCE) += vfio_iommu_spapr_tce.o obj-$(CONFIG_VFIO_SPAPR_EEH) += vfio_spapr_eeh.o obj-$(CONFIG_VFIO_PCI) += pci/ +obj-$(CONFIG_VFIO_PLATFORM) += platform/ diff --git a/drivers/vfio/platform/Kconfig b/drivers/vfio/platform/Kconfig new file mode 100644 index 000..c51af17 --- /dev/null +++ b/drivers/vfio/platform/Kconfig @@ -0,0 +1,9 @@ +config VFIO_PLATFORM + tristate VFIO support for platform devices + depends on VFIO EVENTFD ARM Hi Antonios, Is this only for ARM? how about X86 and PowerPC? On Freescale's PowerPC platform, the IOMMU is called PAMU (Peripheral Access Management Unit), and I am trying to use this VFIO framework on it. In principle it should be working on any platform with such devices; as long as you have a VFIO IOMMU driver for the PAMU (on ARM we use VFIO PLATFORM for the device, with VFIO IOMMU TYPE1 for the IOMMU). Antonios, As far as you know, on which ARM platform can I apply your patches directly? My purpose is to apply you patches[1], and then implement a user space driver to evaluate the performance. In principle, if your target has a working IOMMU in front of a platform or AMBA device, then you should be able to use this. In practice, I have tested this on various fast models, and less extensively on Arndale in the past. Linaro as far as I know has tested this series on Calxeda devices with an xgmac NIC. [1] It is better without manually merging conflicts/dependencies etc, I am vfio-platform user, not a iommu expert. So if you have a suitable IOMMU driver for your target, feel free to test it, and let us know of the results. + help + Support for platform devices with VFIO. This is required to make + use of platform devices present on the system using the VFIO + framework. + + If you don't know what to do here, say N. diff --git a/drivers/vfio/platform/Makefile b/drivers/vfio/platform/Makefile new file mode 100644 index 000..279862b --- /dev/null +++ b/drivers/vfio/platform/Makefile @@ -0,0 +1,4 @@ + +vfio-platform-y := vfio_platform.o vfio_platform_common.o + +obj-$(CONFIG_VFIO_PLATFORM) += vfio-platform.o -- 2.1.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v9 01/19] vfio/platform: initial skeleton of VFIO support for platform devices
On Wed, Nov 12, 2014 at 5:49 PM, Alex Williamson alex.william...@redhat.com wrote: On Wed, 2014-11-12 at 11:05 +0100, Eric Auger wrote: Hi Antonios, On 10/27/2014 07:07 PM, Antonios Motakis wrote: This patch forms the common skeleton code for platform devices support with VFIO. This will include the core functionality of VFIO_PLATFORM, however binding to the device and discovering the device resources will be done with the help of a separate file where any Linux platform bus specific code will reside. This will allow us to implement support for also discovering AMBA devices and their resources, but still reuse a large part of the VFIO_PLATFORM implementation. Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com --- drivers/vfio/platform/vfio_platform_common.c | 126 ++ drivers/vfio/platform/vfio_platform_private.h | 36 2 files changed, 162 insertions(+) create mode 100644 drivers/vfio/platform/vfio_platform_common.c create mode 100644 drivers/vfio/platform/vfio_platform_private.h diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c new file mode 100644 index 000..e0fdbc8 --- /dev/null +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2013 - Virtual Open Systems + * Author: Antonios Motakis a.mota...@virtualopensystems.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include linux/device.h +#include linux/interrupt.h +#include linux/iommu.h +#include linux/module.h +#include linux/mutex.h +#include linux/notifier.h +#include linux/pm_runtime.h +#include linux/slab.h +#include linux/types.h +#include linux/uaccess.h +#include linux/vfio.h +#include linux/io.h not sure at that state all the above includes are needed. + +#include vfio_platform_private.h + +static void vfio_platform_release(void *device_data) +{ + module_put(THIS_MODULE); +} + +static int vfio_platform_open(void *device_data) +{ + if (!try_module_get(THIS_MODULE)) + return -ENODEV; + + return 0; +} + +static long vfio_platform_ioctl(void *device_data, + unsigned int cmd, unsigned long arg) a minor style comment/question that applies on all the series. Shouldn't subsequent argument lines rather be aligned with the first char after (, as done in PCI code? It's also my preferred style to indent to just after the open paren on wrapped lines where possible, but I don't think there are hard rules in CodingStyle or checkpatch that enforce this, so I often let it slide. Thanks, You're right that there are no hard coding style rules for this, but I also like this style so I'll apply it more consistently. Alex +{ + if (cmd == VFIO_DEVICE_GET_INFO) + return -EINVAL; + + else if (cmd == VFIO_DEVICE_GET_REGION_INFO) + return -EINVAL; + + else if (cmd == VFIO_DEVICE_GET_IRQ_INFO) + return -EINVAL; + + else if (cmd == VFIO_DEVICE_SET_IRQS) + return -EINVAL; + + else if (cmd == VFIO_DEVICE_RESET) + return -EINVAL; + + return -ENOTTY; +} + +static ssize_t vfio_platform_read(void *device_data, char __user *buf, + size_t count, loff_t *ppos) +{ + return -EINVAL; +} + +static ssize_t vfio_platform_write(void *device_data, const char __user *buf, + size_t count, loff_t *ppos) +{ + return -EINVAL; +} + +static int vfio_platform_mmap(void *device_data, struct vm_area_struct *vma) +{ + return -EINVAL; +} + +static const struct vfio_device_ops vfio_platform_ops = { + .name = vfio-platform, + .open = vfio_platform_open, + .release= vfio_platform_release, + .ioctl = vfio_platform_ioctl, + .read = vfio_platform_read, + .write = vfio_platform_write, + .mmap = vfio_platform_mmap, +}; + +int vfio_platform_probe_common(struct vfio_platform_device *vdev, + struct device *dev) +{ + struct iommu_group *group; + int ret; + + if (!vdev) + return -EINVAL; + + group = iommu_group_get(dev); + if (!group) { + pr_err(VFIO: No
Re: [PATCH v9 06/19] vfio/platform: return info for bound device
On Wed, Nov 12, 2014 at 5:36 PM, Alex Williamson alex.william...@redhat.com wrote: On Wed, 2014-11-12 at 11:32 +0100, Eric Auger wrote: On 10/27/2014 07:07 PM, Antonios Motakis wrote: A VFIO userspace driver will start by opening the VFIO device that corresponds to an IOMMU group, and will use the ioctl interface to get the basic device info, such as number of memory regions and interrupts, and their properties. This patch enables the VFIO_DEVICE_GET_INFO ioctl call. Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com --- drivers/vfio/platform/vfio_platform_common.c | 23 --- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c index e0fdbc8..cb20526 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -43,10 +43,27 @@ static int vfio_platform_open(void *device_data) static long vfio_platform_ioctl(void *device_data, unsigned int cmd, unsigned long arg) { - if (cmd == VFIO_DEVICE_GET_INFO) - return -EINVAL; + struct vfio_platform_device *vdev = device_data; + unsigned long minsz; + + if (cmd == VFIO_DEVICE_GET_INFO) { + struct vfio_device_info info; + + minsz = offsetofend(struct vfio_device_info, num_irqs); + + if (copy_from_user(info, (void __user *)arg, minsz)) + return -EFAULT; + + if (info.argsz minsz) + return -EINVAL; + + info.flags = vdev-flags; + info.num_regions = 0; + info.num_irqs = 0; Seems a bit weird to me to enable the modality but returning zeroed values. Shouldn't we put that patch after VFIO_DEVICE_GET_REGION_INFO and VFIO_DEVICE_GET_IRQ_INFO ones? I actually like how Antonios has started from a base framework, exposing a device but none of the resources and then incrementally adds each component. It's also a good showcase of the VFIO ABI that we can do things like this. Thanks, I also agree with Alex with this. But of course I'm not married with any particular splitting style, in case we decide to change this. Alex -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v9 08/19] vfio/platform: read and write support for the device fd
On Wed, Nov 12, 2014 at 4:46 PM, Eric Auger eric.au...@linaro.org wrote: On 10/27/2014 07:07 PM, Antonios Motakis wrote: VFIO returns a file descriptor which we can use to manipulate the memory regions of the device. Usually, the user will mmap memory regions that are addressable on page boundaries, however for memory regions where this is not the case we cannot provide mmap functionality due to security concerns. For this reason we also need allow to read and write to the memory regions some rewording needed here via the file descriptor. Implement this funcionality typo Ack! Regards Eric only for MMIO regions of platform devices; PIO regions are not being handled at this point. Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com --- drivers/vfio/platform/vfio_platform_common.c | 150 ++ drivers/vfio/platform/vfio_platform_private.h | 1 + 2 files changed, 151 insertions(+) diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c index 82de752..e10a8d0 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -55,6 +55,10 @@ static int vfio_platform_regions_init(struct vfio_platform_device *vdev) switch (resource_type(res)) { case IORESOURCE_MEM: vdev-regions[i].type = VFIO_PLATFORM_REGION_TYPE_MMIO; + vdev-regions[i].flags |= VFIO_REGION_INFO_FLAG_READ; + if (!(res-flags IORESOURCE_READONLY)) + vdev-regions[i].flags |= + VFIO_REGION_INFO_FLAG_WRITE; break; case IORESOURCE_IO: vdev-regions[i].type = VFIO_PLATFORM_REGION_TYPE_PIO; @@ -74,6 +78,11 @@ err: static void vfio_platform_regions_cleanup(struct vfio_platform_device *vdev) { + int i; + + for (i = 0; i vdev-num_regions; i++) + iounmap(vdev-regions[i].ioaddr); + vdev-num_regions = 0; kfree(vdev-regions); } @@ -176,15 +185,156 @@ static long vfio_platform_ioctl(void *device_data, return -ENOTTY; } +static ssize_t vfio_platform_read_mmio(struct vfio_platform_region reg, +char __user *buf, size_t count, +loff_t off) +{ + unsigned int done = 0; + + if (!reg.ioaddr) { + reg.ioaddr = + ioremap_nocache(reg.addr, reg.size); + + if (!reg.ioaddr) + return -ENOMEM; + } + + while (count) { + size_t filled; + + if (count = 4 !(off % 4)) { + u32 val; + + val = ioread32(reg.ioaddr + off); + if (copy_to_user(buf, val, 4)) + goto err; + + filled = 4; + } else if (count = 2 !(off % 2)) { + u16 val; + + val = ioread16(reg.ioaddr + off); + if (copy_to_user(buf, val, 2)) + goto err; + + filled = 2; + } else { + u8 val; + + val = ioread8(reg.ioaddr + off); + if (copy_to_user(buf, val, 1)) + goto err; + + filled = 1; + } + + + count -= filled; + done += filled; + off += filled; + buf += filled; + } + + return done; +err: + return -EFAULT; +} + static ssize_t vfio_platform_read(void *device_data, char __user *buf, size_t count, loff_t *ppos) { + struct vfio_platform_device *vdev = device_data; + unsigned int index = VFIO_PLATFORM_OFFSET_TO_INDEX(*ppos); + loff_t off = *ppos VFIO_PLATFORM_OFFSET_MASK; + + if (index = vdev-num_regions) + return -EINVAL; + + if (!(vdev-regions[index].flags VFIO_REGION_INFO_FLAG_READ)) + return -EINVAL; + + if (vdev-regions[index].type VFIO_PLATFORM_REGION_TYPE_MMIO) + return vfio_platform_read_mmio(vdev-regions[index], + buf, count, off); + else if (vdev-regions[index].type VFIO_PLATFORM_REGION_TYPE_PIO) + return -EINVAL; /* not implemented */ + return -EINVAL; } +static ssize_t vfio_platform_write_mmio(struct vfio_platform_region reg, + const char __user *buf, size_t count, + loff_t off) +{ + unsigned int done = 0; + + if (!reg.ioaddr) { + reg.ioaddr = + ioremap_nocache(reg.addr, reg.size); + + if (!reg.ioaddr) +
Re: [PATCH v9 12/19] vfio/platform: trigger an interrupt via eventfd
On Wed, Nov 12, 2014 at 3:22 PM, Eric Auger eric.au...@linaro.org wrote: On 10/31/2014 08:36 PM, Alex Williamson wrote: On Mon, 2014-10-27 at 19:07 +0100, Antonios Motakis wrote: This patch allows to set an eventfd for a patform device's interrupt, platform device (typo) Ack. and also to trigger the interrupt eventfd from userspace for testing. Level sensitive interrupts are marked as maskable and are handled in a later patch. Edge triggered interrupts are not advertised as maskable and are implemented here using a simple and efficient IRQ handler. Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com --- drivers/vfio/platform/vfio_platform_irq.c | 93 ++- drivers/vfio/platform/vfio_platform_private.h | 2 + 2 files changed, 93 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/platform/vfio_platform_irq.c b/drivers/vfio/platform/vfio_platform_irq.c index 007b386..2ac8ed7 100644 --- a/drivers/vfio/platform/vfio_platform_irq.c +++ b/drivers/vfio/platform/vfio_platform_irq.c @@ -45,11 +45,91 @@ static int vfio_platform_set_irq_unmask(struct vfio_platform_device *vdev, return -EINVAL; } +static irqreturn_t vfio_irq_handler(int irq, void *dev_id) +{ +struct vfio_platform_irq *irq_ctx = dev_id; + +eventfd_signal(irq_ctx-trigger, 1); + +return IRQ_HANDLED; +} + +static int vfio_set_trigger(struct vfio_platform_device *vdev, int index, +int fd, irq_handler_t handler) +{ +struct vfio_platform_irq *irq = vdev-irqs[index]; +struct eventfd_ctx *trigger; +int ret; + +if (irq-trigger) { +free_irq(irq-hwirq, irq); +kfree(irq-name); +eventfd_ctx_put(irq-trigger); +irq-trigger = NULL; +} + +if (fd 0) /* Disable only */ +return 0; + +irq-name = kasprintf(GFP_KERNEL, vfio-irq[%d](%s), +irq-hwirq, vdev-name); +if (!irq-name) +return -ENOMEM; + +trigger = eventfd_ctx_fdget(fd); +if (IS_ERR(trigger)) { +kfree(irq-name); +return PTR_ERR(trigger); +} + +irq-trigger = trigger; + +ret = request_irq(irq-hwirq, handler, 0, irq-name, irq); +if (ret) { +kfree(irq-name); +eventfd_ctx_put(trigger); +irq-trigger = NULL; +return ret; +} + +return 0; you may simply return ret here? Indeed, ack. +} + static int vfio_platform_set_irq_trigger(struct vfio_platform_device *vdev, unsigned index, unsigned start, unsigned count, uint32_t flags, void *data) { -return -EINVAL; +struct vfio_platform_irq *irq = vdev-irqs[index]; +irq_handler_t handler; + +if (vdev-irqs[index].flags VFIO_IRQ_INFO_MASKABLE) +return -EINVAL; /* not implemented */ +else +handler = vfio_irq_handler; + +if (!count (flags VFIO_IRQ_SET_DATA_NONE)) +return vfio_set_trigger(vdev, index, -1, handler); + +if (start != 0 || count != 1) +return -EINVAL; + +if (flags VFIO_IRQ_SET_DATA_EVENTFD) { +int32_t fd = *(int32_t *)data; + +return vfio_set_trigger(vdev, index, fd, handler); +} + +if (flags VFIO_IRQ_SET_DATA_NONE) { +handler(irq-hwirq, irq); + +} else if (flags VFIO_IRQ_SET_DATA_BOOL) { +uint8_t trigger = *(uint8_t *)data; + +if (trigger) +handler(irq-hwirq, irq); +} + +return 0; } int vfio_platform_set_irqs_ioctl(struct vfio_platform_device *vdev, @@ -95,7 +175,11 @@ int vfio_platform_irq_init(struct vfio_platform_device *vdev) if (hwirq 0) goto err; -vdev-irqs[i].flags = 0; +vdev-irqs[i].flags = VFIO_IRQ_INFO_EVENTFD; + +if (irq_get_trigger_type(hwirq) IRQ_TYPE_LEVEL_MASK) +vdev-irqs[i].flags |= VFIO_IRQ_INFO_MASKABLE; This is a bit confusing because edge interrupts can support masking, but they don't require it. Level interrupts really must support masking because we need to mask them on the host and therefore the user needs to be able to unmask them (ignoring the irq prioritization thing you guys can do on arm). So this works, but I would really have expected VFIO_IRQ_INFO_AUTOMASKED here and in the above function. Shouldn't we have AUTOMASKED for level sensitive and MASKABLE for both level edge? I believe it was Alex's argument to expose edge triggered irqs as non-MASKABLE so they can benefit from a more efficient interrupt handler. Would it be acceptable to make them both maskable, but check for masked status without a lock? For forwarded IRQ, may I enrich the external API with a new function enabling to turn the automasked flag off? Would
Re: [PATCH v9 07/19] vfio/platform: return info for device memory mapped IO regions
On Wed, Nov 12, 2014 at 11:58 AM, Eric Auger eric.au...@linaro.org wrote: On 10/27/2014 07:07 PM, Antonios Motakis wrote: This patch enables the IOCTLs VFIO_DEVICE_GET_REGION_INFO ioctl call, which allows the user to learn about the available MMIO resources of a device. Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com --- drivers/vfio/platform/vfio_platform_common.c | 110 +- drivers/vfio/platform/vfio_platform_private.h | 22 ++ 2 files changed, 128 insertions(+), 4 deletions(-) diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c index cb20526..82de752 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -27,17 +27,97 @@ #include vfio_platform_private.h +static DEFINE_MUTEX(driver_lock); + +static int vfio_platform_regions_init(struct vfio_platform_device *vdev) +{ + int cnt = 0, i; + + while (vdev-get_resource(vdev, cnt)) + cnt++; + + vdev-regions = kcalloc(cnt, sizeof(struct vfio_platform_region), + GFP_KERNEL); + if (!vdev-regions) + return -ENOMEM; + + for (i = 0; i cnt; i++) { + struct resource *res = + vdev-get_resource(vdev, i); + + if (!res) + goto err; + + vdev-regions[i].addr = res-start; + vdev-regions[i].size = resource_size(res); + vdev-regions[i].flags = 0; + + switch (resource_type(res)) { + case IORESOURCE_MEM: + vdev-regions[i].type = VFIO_PLATFORM_REGION_TYPE_MMIO; + break; + case IORESOURCE_IO: + vdev-regions[i].type = VFIO_PLATFORM_REGION_TYPE_PIO; + break; + default: + goto err; + } + } + + vdev-num_regions = cnt; + + return 0; +err: Isn't it safer to reset vdev-num_regions here? I think in a next patch you will iounmap the num_regions in vfio_platform_regions_cleanup. Agreed! -- Eric + kfree(vdev-regions); + return -EINVAL; +} + +static void vfio_platform_regions_cleanup(struct vfio_platform_device *vdev) +{ + vdev-num_regions = 0; + kfree(vdev-regions); +} + static void vfio_platform_release(void *device_data) { + struct vfio_platform_device *vdev = device_data; + + mutex_lock(driver_lock); + + if (!(--vdev-refcnt)) { + vfio_platform_regions_cleanup(vdev); + } + + mutex_unlock(driver_lock); + module_put(THIS_MODULE); } static int vfio_platform_open(void *device_data) { + struct vfio_platform_device *vdev = device_data; + int ret; + if (!try_module_get(THIS_MODULE)) return -ENODEV; + mutex_lock(driver_lock); + + if (!vdev-refcnt) { + ret = vfio_platform_regions_init(vdev); + if (ret) + goto err_reg; + } + + vdev-refcnt++; + + mutex_unlock(driver_lock); return 0; + +err_reg: + mutex_unlock(driver_lock); + module_put(THIS_MODULE); + return ret; } static long vfio_platform_ioctl(void *device_data, @@ -58,15 +138,33 @@ static long vfio_platform_ioctl(void *device_data, return -EINVAL; info.flags = vdev-flags; - info.num_regions = 0; + info.num_regions = vdev-num_regions; info.num_irqs = 0; return copy_to_user((void __user *)arg, info, minsz); - } else if (cmd == VFIO_DEVICE_GET_REGION_INFO) - return -EINVAL; + } else if (cmd == VFIO_DEVICE_GET_REGION_INFO) { + struct vfio_region_info info; + + minsz = offsetofend(struct vfio_region_info, offset); + + if (copy_from_user(info, (void __user *)arg, minsz)) + return -EFAULT; - else if (cmd == VFIO_DEVICE_GET_IRQ_INFO) + if (info.argsz minsz) + return -EINVAL; + + if (info.index = vdev-num_regions) + return -EINVAL; + + /* map offset to the physical address */ + info.offset = VFIO_PLATFORM_INDEX_TO_OFFSET(info.index); + info.size = vdev-regions[info.index].size; + info.flags = vdev-regions[info.index].flags; + + return copy_to_user((void __user *)arg, info, minsz); + + } else if (cmd == VFIO_DEVICE_GET_IRQ_INFO) return -EINVAL; else if (cmd == VFIO_DEVICE_SET_IRQS) @@ -134,10 +232,14 @@ struct vfio_platform_device *vfio_platform_remove_common(struct device *dev) { struct vfio_platform_device *vdev; + mutex_lock(driver_lock); + vdev = vfio_del_group_dev(dev); if (vdev)
[PATCHv5 1/1] thermal: of: improve of-thermal sensor registration API
Different drivers request API extensions in of-thermal. For this reason, additional callbacks are required to fit the new drivers needs. The current API implementation expects the registering sensor driver to provide a get_temp and get_trend callbacks as function parameters. As the amount of callbacks is growing, this patch changes the existing implementation to use a .ops field to hold all the of thermal callbacks to sensor drivers. This patch also changes the existing of-thermal users to fit the new API design. No functional change is introduced in this patch. Cc: Alexandre Courbot gnu...@gmail.com Cc: devicet...@vger.kernel.org Cc: Grant Likely grant.lik...@linaro.org Cc: Guenter Roeck li...@roeck-us.net Cc: Jean Delvare jdelv...@suse.de Cc: linux-kernel@vger.kernel.org Cc: linux...@vger.kernel.org Cc: linux-te...@vger.kernel.org Cc: lm-sens...@lm-sensors.org Cc: Rob Herring robh...@kernel.org Cc: Stephen Warren swar...@wwwdotorg.org Cc: Thierry Reding thierry.red...@gmail.com Cc: Zhang Rui rui.zh...@intel.com Tested-by: Mikko Perttunen mikko.perttu...@kapsi.fi Reviewed-by: Mikko Perttunen mikko.perttu...@kapsi.fi Reviewed-by: Alexandre Courbot acour...@nvidia.com Reviewed-by: Lukasz Majewski l.majew...@samsung.com Signed-off-by: Eduardo Valentin edubez...@gmail.com --- drivers/hwmon/lm75.c | 9 +++-- drivers/hwmon/ntc_thermistor.c | 6 +++- drivers/hwmon/tmp102.c | 6 +++- drivers/thermal/of-thermal.c | 39 ++ drivers/thermal/tegra_soctherm.c | 7 ++-- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 8 +++-- include/linux/thermal.h| 24 + 7 files changed, 62 insertions(+), 37 deletions(-) --- Difference from V4: - Corrected comment about which callbacks are currently mandatory. - Fixed compilation error when !CONFIG_OF_THERMAL. Difference from V3: - Keep the same behavior regarding callback checks. Change in behavior may be sent in a separate patch. Difference from V2: - Fix wrong assignment in tegra driver. Difference from V1: - Fix error handling when .get_trend is not provided. diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index d16dbb3..e7c8bf9 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -176,6 +176,10 @@ static struct attribute *lm75_attrs[] = { }; ATTRIBUTE_GROUPS(lm75); +static const struct thermal_zone_of_device_ops lm75_of_thermal_ops = { + .get_temp = lm75_read_temp, +}; + /*---*/ /* device probe and removal */ @@ -291,10 +295,9 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id) if (IS_ERR(data-hwmon_dev)) return PTR_ERR(data-hwmon_dev); - data-tz = thermal_zone_of_sensor_register(data-hwmon_dev, - 0, + data-tz = thermal_zone_of_sensor_register(data-hwmon_dev, 0, data-hwmon_dev, - lm75_read_temp, NULL); + lm75_of_thermal_ops); if (IS_ERR(data-tz)) data-tz = NULL; diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c index 4ff89b2..bca8521c8 100644 --- a/drivers/hwmon/ntc_thermistor.c +++ b/drivers/hwmon/ntc_thermistor.c @@ -486,6 +486,10 @@ static const struct attribute_group ntc_attr_group = { .attrs = ntc_attributes, }; +static const struct thermal_zone_of_device_ops ntc_of_thermal_ops = { + .get_temp = ntc_read_temp, +}; + static int ntc_thermistor_probe(struct platform_device *pdev) { const struct of_device_id *of_id = @@ -579,7 +583,7 @@ static int ntc_thermistor_probe(struct platform_device *pdev) pdev_id-name); data-tz = thermal_zone_of_sensor_register(data-dev, 0, data-dev, - ntc_read_temp, NULL); + ntc_of_thermal_ops); if (IS_ERR(data-tz)) { dev_dbg(pdev-dev, Failed to register to thermal fw.\n); data-tz = NULL; diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c index 5171995..ba9f478 100644 --- a/drivers/hwmon/tmp102.c +++ b/drivers/hwmon/tmp102.c @@ -158,6 +158,10 @@ ATTRIBUTE_GROUPS(tmp102); #define TMP102_CONFIG (TMP102_CONF_TM | TMP102_CONF_EM | TMP102_CONF_CR1) #define TMP102_CONFIG_RD_ONLY (TMP102_CONF_R0 | TMP102_CONF_R1 | TMP102_CONF_AL) +static const struct thermal_zone_of_device_ops tmp102_of_thermal_ops = { + .get_temp = tmp102_read_temp, +}; + static int tmp102_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -215,7 +219,7 @@ static int
Re: [PATCH vfs 2/2] {block|char}_dev: remove inode-i_devices
On 11/20/2014 03:11 PM, Tejun Heo wrote: Hello, Boaz. W/ preloading, one way to do it is, if (preload()) handle -ENOMEM; lock; error = insert(); if (error) handle error which can't be -ENOMEM; unlock; preload_end(); I like this one, cause of the place I come from. Where in a cluster you want the local fails as early as possible before you start to commit remotely, and need to undo on errors. And I can see the real flow of things Another way is preload(); // can't fail lock; error = insert(); if (error) handle error;' unlock; preload_end(); Both ways have pros and cons. The latter seems to lead to simpler code in general. Not always, but the overall. I still like the over all simplicity of the above pattern to this behind the seen complexity hidden away under the carpet. But I guess that is just me. That is your call sir. I do see your point though. And that's why the pattern usually leads to simpler code - it doesn't create a new failure point. Again a matter of taste. I like the extra ENOMEM failure point before I started to commit to any state changes, lock grabbing and unrolling in case of errors. But I see your points as well. For what it is worth I have reviewed your code and did not find any faults in it. It looks like sound code. Thanks 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 V2] ACPI: Add _DEP(Operation Region Dependencies) support to fix battery issue on the Asus T100TA
ACPI 5.0 introduces _DEP to designate device objects that OSPM should assign a higher priority in start ordering due to future operation region accesses. On Asus T100TA, ACPI battery info are read from a I2C slave device via I2C operation region. Before I2C operation region handler is installed, battery _STA always returns 0. There is a _DEP method of designating start order under battery device node. This patch is to implement _DEP feature to fix battery issue on the Asus T100TA. Introducing acpi_dep_list and adding dep_unmet count in the struct acpi_device. During ACPI namespace scan, create struct acpi_dep_data for a valid pair of master (device pointed to by _DEP)/slave(device with _DEP), record master's and slave's ACPI handle in it and put it into acpi_dep_list. The dep_unmet count will increase by one if there is a device under its _DEP. Driver's probe() should return EPROBE_DEFER when find dep_unmet is larger than 0. When I2C operation region handler is installed, remove all struct acpi_dep_data on the acpi_dep_list whose master is pointed to I2C host controller and decrease slave's dep_unmet. When dep_unmet decreases to 0, all _DEP conditions are met and then do acpi_bus_attach() for the device in order to resolve battery _STA issue on the Asus T100TA. Reference: https://bugzilla.kernel.org/show_bug.cgi?id=69011 Tested-by: Jan-Michael Brummer jan.brum...@tabos.org Tested-by: Adam Williamson ad...@happyassassin.net Tested-by: Michael Shigorin shigo...@gmail.com Acked-by: Wolfram Sang w...@the-dreams.de Signed-off-by: Lan Tianyu tianyu@intel.com --- Change since V1: Remove redundant blank line and some coding style fixs. drivers/acpi/battery.c | 4 +++ drivers/acpi/scan.c | 86 + drivers/i2c/i2c-core.c | 1 + include/acpi/acpi_bus.h | 1 + include/linux/acpi.h| 1 + 5 files changed, 93 insertions(+) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 8ec8a89..d98ba43 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -1180,6 +1180,10 @@ static int acpi_battery_add(struct acpi_device *device) if (!device) return -EINVAL; + + if (device-dep_unmet) + return -EPROBE_DEFER; + battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); if (!battery) return -ENOMEM; diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 9cb5cca..54a4102 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -36,6 +36,8 @@ bool acpi_force_hot_remove; static const char *dummy_hid = device; +static LIST_HEAD(acpi_dep_list); +static DEFINE_MUTEX(acpi_dep_list_lock); static LIST_HEAD(acpi_bus_id_list); static DEFINE_MUTEX(acpi_scan_lock); static LIST_HEAD(acpi_scan_handlers_list); @@ -43,6 +45,12 @@ DEFINE_MUTEX(acpi_device_lock); LIST_HEAD(acpi_wakeup_device_list); static DEFINE_MUTEX(acpi_hp_context_lock); +struct acpi_dep_data { + struct list_head node; + acpi_handle master; + acpi_handle slave; +}; + struct acpi_device_bus_id{ char bus_id[15]; unsigned int instance_no; @@ -2193,6 +2201,60 @@ static void acpi_scan_init_hotplug(struct acpi_device *adev) } } +static void acpi_device_dep_initialize(struct acpi_device *adev) +{ + struct acpi_dep_data *dep; + struct acpi_handle_list dep_devices; + struct acpi_device_info *info; + acpi_status status; + int i, skip; + + if (!acpi_has_method(adev-handle, _DEP)) + return; + + status = acpi_evaluate_reference(adev-handle, _DEP, NULL, + dep_devices); + if (ACPI_FAILURE(status)) { + dev_err(adev-dev, Failed to evaluate _DEP.\n); + return; + } + + for (i = 0; i dep_devices.count; i++) { + status = acpi_get_object_info(dep_devices.handles[i], info); + if (ACPI_FAILURE(status)) { + dev_err(adev-dev, Error reading device info\n); + continue; + } + + /* +* Skip the dependency of Windows System Power +* Management Controller +*/ + if (info-valid ACPI_VALID_HID +!strcmp(info-hardware_id.string, INT3396)) + skip = 1; + else + skip = 0; + + kfree(info); + + if (skip) + continue; + + dep = kzalloc(sizeof(struct acpi_dep_data), GFP_KERNEL); + if (!dep) + return; + + dep-master = dep_devices.handles[i]; + dep-slave = adev-handle; + adev-dep_unmet++; + + mutex_lock(acpi_dep_list_lock); + list_add_tail(dep-node , acpi_dep_list); + mutex_unlock(acpi_dep_list_lock); + }
Re: [PATCHv5 1/1] thermal: of: improve of-thermal sensor registration API
Hi Guenter, On Thu, Nov 20, 2014 at 10:12:13AM -0400, Eduardo Valentin wrote: Different drivers request API extensions in of-thermal. For this reason, additional callbacks are required to fit the new drivers needs. The current API implementation expects the registering sensor driver to provide a get_temp and get_trend callbacks as function parameters. As the amount of callbacks is growing, this patch changes the existing implementation to use a .ops field to hold all the of thermal callbacks to sensor drivers. This patch also changes the existing of-thermal users to fit the new API design. No functional change is introduced in this patch. Cc: Alexandre Courbot gnu...@gmail.com Cc: devicet...@vger.kernel.org Cc: Grant Likely grant.lik...@linaro.org Cc: Guenter Roeck li...@roeck-us.net Cc: Jean Delvare jdelv...@suse.de Cc: linux-kernel@vger.kernel.org Cc: linux...@vger.kernel.org Cc: linux-te...@vger.kernel.org Cc: lm-sens...@lm-sensors.org Cc: Rob Herring robh...@kernel.org Cc: Stephen Warren swar...@wwwdotorg.org Cc: Thierry Reding thierry.red...@gmail.com Cc: Zhang Rui rui.zh...@intel.com Tested-by: Mikko Perttunen mikko.perttu...@kapsi.fi Reviewed-by: Mikko Perttunen mikko.perttu...@kapsi.fi Reviewed-by: Alexandre Courbot acour...@nvidia.com Reviewed-by: Lukasz Majewski l.majew...@samsung.com Signed-off-by: Eduardo Valentin edubez...@gmail.com --- drivers/hwmon/lm75.c | 9 +++-- drivers/hwmon/ntc_thermistor.c | 6 +++- drivers/hwmon/tmp102.c | 6 +++- Do you have objections if I queue this one for 3.19? Cheers, Eduardo Valentin drivers/thermal/of-thermal.c | 39 ++ drivers/thermal/tegra_soctherm.c | 7 ++-- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 8 +++-- include/linux/thermal.h| 24 + 7 files changed, 62 insertions(+), 37 deletions(-) --- Difference from V4: - Corrected comment about which callbacks are currently mandatory. - Fixed compilation error when !CONFIG_OF_THERMAL. Difference from V3: - Keep the same behavior regarding callback checks. Change in behavior may be sent in a separate patch. Difference from V2: - Fix wrong assignment in tegra driver. Difference from V1: - Fix error handling when .get_trend is not provided. diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index d16dbb3..e7c8bf9 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -176,6 +176,10 @@ static struct attribute *lm75_attrs[] = { }; ATTRIBUTE_GROUPS(lm75); +static const struct thermal_zone_of_device_ops lm75_of_thermal_ops = { + .get_temp = lm75_read_temp, +}; + /*---*/ /* device probe and removal */ @@ -291,10 +295,9 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id) if (IS_ERR(data-hwmon_dev)) return PTR_ERR(data-hwmon_dev); - data-tz = thermal_zone_of_sensor_register(data-hwmon_dev, -0, + data-tz = thermal_zone_of_sensor_register(data-hwmon_dev, 0, data-hwmon_dev, -lm75_read_temp, NULL); +lm75_of_thermal_ops); if (IS_ERR(data-tz)) data-tz = NULL; diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c index 4ff89b2..bca8521c8 100644 --- a/drivers/hwmon/ntc_thermistor.c +++ b/drivers/hwmon/ntc_thermistor.c @@ -486,6 +486,10 @@ static const struct attribute_group ntc_attr_group = { .attrs = ntc_attributes, }; +static const struct thermal_zone_of_device_ops ntc_of_thermal_ops = { + .get_temp = ntc_read_temp, +}; + static int ntc_thermistor_probe(struct platform_device *pdev) { const struct of_device_id *of_id = @@ -579,7 +583,7 @@ static int ntc_thermistor_probe(struct platform_device *pdev) pdev_id-name); data-tz = thermal_zone_of_sensor_register(data-dev, 0, data-dev, - ntc_read_temp, NULL); +ntc_of_thermal_ops); if (IS_ERR(data-tz)) { dev_dbg(pdev-dev, Failed to register to thermal fw.\n); data-tz = NULL; diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c index 5171995..ba9f478 100644 --- a/drivers/hwmon/tmp102.c +++ b/drivers/hwmon/tmp102.c @@ -158,6 +158,10 @@ ATTRIBUTE_GROUPS(tmp102); #define TMP102_CONFIG (TMP102_CONF_TM | TMP102_CONF_EM | TMP102_CONF_CR1) #define TMP102_CONFIG_RD_ONLY (TMP102_CONF_R0 | TMP102_CONF_R1 | TMP102_CONF_AL) +static const struct
Re: [PATCH] arm64: crypto: Add ARM64 CRC32 hw accelerated module
+linux-arm-ker...@lists.infradead.org On Wed, Nov 19, 2014 at 11:19 AM, Yazen Ghannam yazen.ghan...@linaro.org wrote: This module registers a crc32 algorithm and a crc32c algorithm that use the optional CRC32 and CRC32C instructions in ARMv8. Tested on AMD Seattle. Improvement compared to crc32c-generic algorithm: TCRYPT CRC32C speed test shows ~450% speedup. Simple dd write tests to btrfs filesystem show ~30% speedup. Signed-off-by: Yazen Ghannam yazen.ghan...@linaro.org Acked-by: Steve Capper steve.cap...@linaro.org Acked-by: Ard Biesheuvel ard.biesheu...@linaro.org --- arch/arm64/crypto/Kconfig | 4 + arch/arm64/crypto/Makefile | 4 + arch/arm64/crypto/crc32-arm64.c | 274 3 files changed, 282 insertions(+) create mode 100644 arch/arm64/crypto/crc32-arm64.c diff --git a/arch/arm64/crypto/Kconfig b/arch/arm64/crypto/Kconfig index 5562652..c1a0468 100644 --- a/arch/arm64/crypto/Kconfig +++ b/arch/arm64/crypto/Kconfig @@ -50,4 +50,8 @@ config CRYPTO_AES_ARM64_NEON_BLK select CRYPTO_AES select CRYPTO_ABLK_HELPER +config CRYPTO_CRC32_ARM64 + tristate CRC32 and CRC32C using optional ARMv8 instructions + depends on ARM64 + select CRYPTO_HASH endif diff --git a/arch/arm64/crypto/Makefile b/arch/arm64/crypto/Makefile index a3f935f..5720608 100644 --- a/arch/arm64/crypto/Makefile +++ b/arch/arm64/crypto/Makefile @@ -34,5 +34,9 @@ AFLAGS_aes-neon.o := -DINTERLEAVE=4 CFLAGS_aes-glue-ce.o := -DUSE_V8_CRYPTO_EXTENSIONS +obj-$(CONFIG_CRYPTO_CRC32_ARM64) += crc32-arm64.o + +CFLAGS_crc32-arm64.o := -mcpu=generic+crc + $(obj)/aes-glue-%.o: $(src)/aes-glue.c FORCE $(call if_changed_rule,cc_o_c) diff --git a/arch/arm64/crypto/crc32-arm64.c b/arch/arm64/crypto/crc32-arm64.c new file mode 100644 index 000..9499199 --- /dev/null +++ b/arch/arm64/crypto/crc32-arm64.c @@ -0,0 +1,274 @@ +/* + * crc32-arm64.c - CRC32 and CRC32C using optional ARMv8 instructions + * + * Module based on crypto/crc32c_generic.c + * + * CRC32 loop taken from Ed Nevill's Hadoop CRC patch + * http://mail-archives.apache.org/mod_mbox/hadoop-common-dev/201406.mbox/%3C1403687030.3355.19.camel%40localhost.localdomain%3E + * + * Using inline assembly instead of intrinsics in order to be backwards + * compatible with older compilers. + * + * Copyright (C) 2014 Linaro Ltd yazen.ghan...@linaro.org + * + * 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 linux/unaligned/access_ok.h +#include linux/cpufeature.h +#include linux/init.h +#include linux/kernel.h +#include linux/module.h +#include linux/string.h + +#include crypto/internal/hash.h + +MODULE_AUTHOR(Yazen Ghannam yazen.ghan...@linaro.org); +MODULE_DESCRIPTION(CRC32 and CRC32C using optional ARMv8 instructions); +MODULE_LICENSE(GPL v2); + +#define CRC32X(crc, value) __asm__(crc32x %w[c], %w[c], %x[v]:[c]+r(crc):[v]r(value)) +#define CRC32W(crc, value) __asm__(crc32w %w[c], %w[c], %w[v]:[c]+r(crc):[v]r(value)) +#define CRC32H(crc, value) __asm__(crc32h %w[c], %w[c], %w[v]:[c]+r(crc):[v]r(value)) +#define CRC32B(crc, value) __asm__(crc32b %w[c], %w[c], %w[v]:[c]+r(crc):[v]r(value)) +#define CRC32CX(crc, value) __asm__(crc32cx %w[c], %w[c], %x[v]:[c]+r(crc):[v]r(value)) +#define CRC32CW(crc, value) __asm__(crc32cw %w[c], %w[c], %w[v]:[c]+r(crc):[v]r(value)) +#define CRC32CH(crc, value) __asm__(crc32ch %w[c], %w[c], %w[v]:[c]+r(crc):[v]r(value)) +#define CRC32CB(crc, value) __asm__(crc32cb %w[c], %w[c], %w[v]:[c]+r(crc):[v]r(value)) + +static u32 crc32_arm64_le_hw(u32 crc, const u8 *p, unsigned int len) +{ + s64 length = len; + + while ((length -= sizeof(u64)) = 0) { + CRC32X(crc, get_unaligned_le64(p)); + p += sizeof(u64); + } + + /* The following is more efficient than the straight loop */ + if (length sizeof(u32)) { + CRC32W(crc, get_unaligned_le32(p)); + p += sizeof(u32); + } + if (length sizeof(u16)) { + CRC32H(crc, get_unaligned_le16(p)); + p += sizeof(u16); + } + if (length sizeof(u8)) + CRC32B(crc, *p); + + return crc; +} + +static u32 crc32c_arm64_le_hw(u32 crc, const u8 *p, unsigned int len) +{ + s64 length = len; + + while ((length -= sizeof(u64)) = 0) { + CRC32CX(crc, get_unaligned_le64(p)); + p += sizeof(u64); + } + + /* The following is more efficient than the straight loop */ + if (length sizeof(u32)) { + CRC32CW(crc, get_unaligned_le32(p)); + p += sizeof(u32); + } + if (length sizeof(u16)) { + CRC32CH(crc,
Re: [PATCHv5 1/1] thermal: of: improve of-thermal sensor registration API
On 11/20/2014 06:12 AM, Eduardo Valentin wrote: Different drivers request API extensions in of-thermal. For this reason, additional callbacks are required to fit the new drivers needs. The current API implementation expects the registering sensor driver to provide a get_temp and get_trend callbacks as function parameters. As the amount of callbacks is growing, this patch changes the existing implementation to use a .ops field to hold all the of thermal callbacks to sensor drivers. This patch also changes the existing of-thermal users to fit the new API design. No functional change is introduced in this patch. Cc: Alexandre Courbot gnu...@gmail.com Cc: devicet...@vger.kernel.org Cc: Grant Likely grant.lik...@linaro.org Cc: Guenter Roeck li...@roeck-us.net Cc: Jean Delvare jdelv...@suse.de Cc: linux-kernel@vger.kernel.org Cc: linux...@vger.kernel.org Cc: linux-te...@vger.kernel.org Cc: lm-sens...@lm-sensors.org Cc: Rob Herring robh...@kernel.org Cc: Stephen Warren swar...@wwwdotorg.org Cc: Thierry Reding thierry.red...@gmail.com Cc: Zhang Rui rui.zh...@intel.com Tested-by: Mikko Perttunen mikko.perttu...@kapsi.fi Reviewed-by: Mikko Perttunen mikko.perttu...@kapsi.fi Reviewed-by: Alexandre Courbot acour...@nvidia.com Reviewed-by: Lukasz Majewski l.majew...@samsung.com Signed-off-by: Eduardo Valentin edubez...@gmail.com --- drivers/hwmon/lm75.c | 9 +++-- drivers/hwmon/ntc_thermistor.c | 6 +++- drivers/hwmon/tmp102.c | 6 +++- For the above: Acked-by: Guenter Roeck li...@roeck-us.net drivers/thermal/of-thermal.c | 39 ++ drivers/thermal/tegra_soctherm.c | 7 ++-- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 8 +++-- include/linux/thermal.h| 24 + 7 files changed, 62 insertions(+), 37 deletions(-) --- Difference from V4: - Corrected comment about which callbacks are currently mandatory. - Fixed compilation error when !CONFIG_OF_THERMAL. Difference from V3: - Keep the same behavior regarding callback checks. Change in behavior may be sent in a separate patch. Difference from V2: - Fix wrong assignment in tegra driver. Difference from V1: - Fix error handling when .get_trend is not provided. diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index d16dbb3..e7c8bf9 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -176,6 +176,10 @@ static struct attribute *lm75_attrs[] = { }; ATTRIBUTE_GROUPS(lm75); +static const struct thermal_zone_of_device_ops lm75_of_thermal_ops = { + .get_temp = lm75_read_temp, +}; + /*---*/ /* device probe and removal */ @@ -291,10 +295,9 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id) if (IS_ERR(data-hwmon_dev)) return PTR_ERR(data-hwmon_dev); - data-tz = thermal_zone_of_sensor_register(data-hwmon_dev, - 0, + data-tz = thermal_zone_of_sensor_register(data-hwmon_dev, 0, data-hwmon_dev, - lm75_read_temp, NULL); + lm75_of_thermal_ops); if (IS_ERR(data-tz)) data-tz = NULL; diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c index 4ff89b2..bca8521c8 100644 --- a/drivers/hwmon/ntc_thermistor.c +++ b/drivers/hwmon/ntc_thermistor.c @@ -486,6 +486,10 @@ static const struct attribute_group ntc_attr_group = { .attrs = ntc_attributes, }; +static const struct thermal_zone_of_device_ops ntc_of_thermal_ops = { + .get_temp = ntc_read_temp, +}; + static int ntc_thermistor_probe(struct platform_device *pdev) { const struct of_device_id *of_id = @@ -579,7 +583,7 @@ static int ntc_thermistor_probe(struct platform_device *pdev) pdev_id-name); data-tz = thermal_zone_of_sensor_register(data-dev, 0, data-dev, - ntc_read_temp, NULL); + ntc_of_thermal_ops); if (IS_ERR(data-tz)) { dev_dbg(pdev-dev, Failed to register to thermal fw.\n); data-tz = NULL; diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c index 5171995..ba9f478 100644 --- a/drivers/hwmon/tmp102.c +++ b/drivers/hwmon/tmp102.c @@ -158,6 +158,10 @@ ATTRIBUTE_GROUPS(tmp102); #define TMP102_CONFIG (TMP102_CONF_TM | TMP102_CONF_EM | TMP102_CONF_CR1) #define TMP102_CONFIG_RD_ONLY (TMP102_CONF_R0 | TMP102_CONF_R1 | TMP102_CONF_AL) +static const struct thermal_zone_of_device_ops tmp102_of_thermal_ops = { + .get_temp = tmp102_read_temp, +}; + static int tmp102_probe(struct
Re: [RFC PATCH] arm: imx: Workaround i.MX6 PMU interrupts muxed to one SPI
On 20/11/14 11:52, Lucas Stach wrote: Am Donnerstag, den 20.11.2014, 11:42 + schrieb Daniel Thompson: All PMU interrupts on multi-core i.MX6 devices are muxed onto a single SPI. Should the PMU of any core except 0 (the default affinity for the interrupt) trigger the interrupt then it cannot be serviced and, eventually, the spurious irq detection will forcefully disable the interrupt. This can be worked around by getting the interrupt handler to change its own affinity if it cannot figure out why it has been triggered. This patch adds logic to rotate the affinity to i.MX6. Signed-off-by: Daniel Thompson daniel.thomp...@linaro.org I've sent almost the same patch a while ago. At this time it was shot down due to fears of the measurements being too flaky to be useful with all that IRQ dance. While I don't think this is true (I did some measurements on a SOLO and a QUAD variants of the i.MX6 with the same workload, that were only minimally apart), I believe the IRQ affinity dance isn't the best way to handle this. Cumulative statistics and time based sampling profilers should be fine either way since a delay before the interrupt the asserted on the affected core should have a low impact here. A use case where the measurement would be flaky might be a profile trying to highlight which functions (or opcodes) of a process are most likely to miss the cache. In such a case delay before the interrupt is asserted would result in the cache miss being attributed to the wrong opcode. Note also that for a single threaded processes, or any other workload where one core's PMU raises interrupts much more frequently than any other, then the dance remains a good approach since it leaves the affinity set correctly for next time. I had planned to look into smp_call_function() to distribute the IRQ to all CPUs at the same time, but have not got around to it yet. Maybe you could investigate whether this is a viable solution to the problem at hand? I'm a little sceptical, not least because smp_call_function() and its friends can't be called from interrupt. This means the steps to propagate the interrupt become rather complex and therefore on systems with a small(ish) numbers of cores it is not obvious that the delay before the interrupt is asserted on the affected core will improve very much. Hopefully systems with a large number of cores won't exhibit this problem (because whatever the workaround we adopt there would be significant problems). Regards, Lucas --- Notes: This patch adopts the approach used on the u8500 (db8500_pmu_handler) but the logic has been generalized for any number of CPUs, mostly because the i.MX6 has a both dual and quad core variants. However it might be better to include the generalized logic in the main armpmu code. I think the logic could be deployed automatically on SMP systems with only a single not-percpu IRQ, replacing the plat-handle_irq dance we currently do to hook up this code. Thoughts? (or is there already shared logic to do this that I overlooked) arch/arm/mach-imx/mach-imx6q.c | 39 ++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c index d51c6e99a2e9..c056b7b97eaa 100644 --- a/arch/arm/mach-imx/mach-imx6q.c +++ b/arch/arm/mach-imx/mach-imx6q.c @@ -16,6 +16,7 @@ #include linux/delay.h #include linux/export.h #include linux/init.h +#include linux/interrupt.h #include linux/io.h #include linux/irq.h #include linux/irqchip.h @@ -33,6 +34,7 @@ #include linux/mfd/syscon/imx6q-iomuxc-gpr.h #include asm/mach/arch.h #include asm/mach/map.h +#include asm/pmu.h #include asm/system_misc.h #include common.h @@ -261,6 +263,40 @@ static void __init imx6q_axi_init(void) } } +/* + * The PMU IRQ lines of all cores are muxed onto a single interrupt. + * Rotate the interrupt around the cores if the current CPU cannot + * figure out why the interrupt has been triggered. + */ +static irqreturn_t imx6q_pmu_handler(int irq, void *dev, irq_handler_t handler) +{ +irqreturn_t ret = handler(irq, dev); +int next; + +if (ret == IRQ_NONE num_online_cpus() 1) { +next = cpumask_next(smp_processor_id(), cpu_online_mask); +if (next nr_cpu_ids) +next = cpumask_next(-1, cpu_online_mask); +irq_set_affinity(irq, cpumask_of(next)); +} + +/* + * We should be able to get away with the amount of IRQ_NONEs we give, + * while still having the spurious IRQ detection code kick in if the + * interrupt really starts hitting spuriously. + */ +return ret; +} + +static struct arm_pmu_platdata imx6q_pmu_platdata = { +.handle_irq = imx6q_pmu_handler, +}; + +static struct of_dev_auxdata imx6q_auxdata_lookup[] __initdata = { +
RE: [PATCH v4 3/6] mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save
-Original Message- From: Nori, Sekhar Sent: Thursday, November 20, 2014 7:56 AM I also tested this series on AM335x EVM using the v3.18-rc5 kernel. Again, no breakage but no improvement as well. The primary goal was not necessarily to improve performance of the touchscreen itself. It was to reduce unnecessary CPU overhead introduced by the 275us udelay in the ISR. On a related note, that 275us udelay is not something that worked for all boards. For example, see the following forum thread: http://e2e.ti.com/support/arm/sitara_arm/f/791/p/217587/775152.aspx#775152 In that thread the user was registering multiple press events for a single press. By increasing the udelay to 1.5ms they were able to solve the problem. Of course, having a 1.5ms delay in your ISR is a really bad thing to do... I have another customer that was experiencing the same issue of registering multiple press events, and sure enough the 1.5ms delay fixed their problem too. The patches allowed them to remove that gigantic delay from the ISR because that software delay has now become a hardware delay via CHARGECONFIG. That customer is the one that needed 0xB000 which is MUCH larger than the value of 0x400 that was working fine for me on the EVM. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@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 vfs 2/2] {block|char}_dev: remove inode-i_devices
On Thu, Nov 20, 2014 at 04:14:29PM +0200, Boaz Harrosh wrote: On 11/20/2014 03:11 PM, Tejun Heo wrote: Hello, Boaz. W/ preloading, one way to do it is, if (preload()) handle -ENOMEM; lock; error = insert(); if (error) handle error which can't be -ENOMEM; unlock; preload_end(); I like this one, cause of the place I come from. Where in a cluster you want the local fails as early as possible before you start to commit remotely, and need to undo on errors. And I can see the real flow of things Another way is preload(); // can't fail lock; error = insert(); if (error) handle error;' unlock; preload_end(); Both ways have pros and cons. The latter seems to lead to simpler code in general. Not always, but the overall. I still like the over all simplicity of the above pattern to this behind the seen complexity hidden away under the carpet. Maybe the right thing to do is allowing both. It really depends on the use cases. For a lot of cases, the error handling and unrolling are necessary anyway so the deferred preload failure doesn't add any complexity but there are cases where the insertion can be guaranteed to succeed. The only change necessary is making preload return -ENOMEM which can be ignored by the caller anyway. The caller can either ignore and handle the deferred failure later or handle it and know that later insertion won't fail with -ENOMEM. Anyways, let's see how minimal linked list implementation works out. Thanks. -- tejun -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@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: [PATCHv5 1/1] thermal: of: improve of-thermal sensor registration API
On 11/20/2014 06:18 AM, Eduardo Valentin wrote: Hi Guenter, On Thu, Nov 20, 2014 at 10:12:13AM -0400, Eduardo Valentin wrote: Different drivers request API extensions in of-thermal. For this reason, additional callbacks are required to fit the new drivers needs. The current API implementation expects the registering sensor driver to provide a get_temp and get_trend callbacks as function parameters. As the amount of callbacks is growing, this patch changes the existing implementation to use a .ops field to hold all the of thermal callbacks to sensor drivers. This patch also changes the existing of-thermal users to fit the new API design. No functional change is introduced in this patch. Cc: Alexandre Courbot gnu...@gmail.com Cc: devicet...@vger.kernel.org Cc: Grant Likely grant.lik...@linaro.org Cc: Guenter Roeck li...@roeck-us.net Cc: Jean Delvare jdelv...@suse.de Cc: linux-kernel@vger.kernel.org Cc: linux...@vger.kernel.org Cc: linux-te...@vger.kernel.org Cc: lm-sens...@lm-sensors.org Cc: Rob Herring robh...@kernel.org Cc: Stephen Warren swar...@wwwdotorg.org Cc: Thierry Reding thierry.red...@gmail.com Cc: Zhang Rui rui.zh...@intel.com Tested-by: Mikko Perttunen mikko.perttu...@kapsi.fi Reviewed-by: Mikko Perttunen mikko.perttu...@kapsi.fi Reviewed-by: Alexandre Courbot acour...@nvidia.com Reviewed-by: Lukasz Majewski l.majew...@samsung.com Signed-off-by: Eduardo Valentin edubez...@gmail.com --- drivers/hwmon/lm75.c | 9 +++-- drivers/hwmon/ntc_thermistor.c | 6 +++- drivers/hwmon/tmp102.c | 6 +++- Do you have objections if I queue this one for 3.19? No. Guenter -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@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] ARM: dts: Add max77693-haptic node for exynos4412-trats2
This patch adds max77693-haptic node to support for haptic motor driver. Signed-off-by: Jaewon Kim jaewon02@samsung.com --- arch/arm/boot/dts/exynos4412-trats2.dts |6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/boot/dts/exynos4412-trats2.dts b/arch/arm/boot/dts/exynos4412-trats2.dts index 72462e8..8ddebbc 100644 --- a/arch/arm/boot/dts/exynos4412-trats2.dts +++ b/arch/arm/boot/dts/exynos4412-trats2.dts @@ -543,6 +543,12 @@ regulator-max-microamp = 258; }; }; + + max77693_haptic { + compatible = maxim,max77693-haptic; + haptic-supply = ldo26_reg; + pwms = pwm 0 38022 0; + }; }; }; -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/2] ARM: dts: add pwm node for exynos4412-trats2
This patch add PWM(Pulse Width Modulation) node and handle to use pwm property. Signed-off-by: Jaewon Kim jaewon02@samsung.com --- arch/arm/boot/dts/exynos4412-trats2.dts |7 +++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/boot/dts/exynos4412-trats2.dts b/arch/arm/boot/dts/exynos4412-trats2.dts index 8ee20bd..72462e8 100644 --- a/arch/arm/boot/dts/exynos4412-trats2.dts +++ b/arch/arm/boot/dts/exynos4412-trats2.dts @@ -636,6 +636,13 @@ }; }; + pwm: pwm@139D { + pinctrl-0 = pwm0_out; + pinctrl-names = default; + samsung,pwm-outputs = 0; + status = okay; + }; + dsi_0: dsi@11C8 { vddcore-supply = ldo8_reg; vddio-supply = ldo10_reg; -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call vfree
From: Markus Elfring elfr...@users.sourceforge.net Date: Thu, 20 Nov 2014 15:15:21 +0100 The vfree() function performs also input parameter validation. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring elfr...@users.sourceforge.net --- drivers/net/hyperv/netvsc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index da2d346..ffe7481 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -548,8 +548,7 @@ int netvsc_device_remove(struct hv_device *device) vmbus_close(device-channel); /* Release all resources */ - if (net_device-sub_cb_buf) - vfree(net_device-sub_cb_buf); + vfree(net_device-sub_cb_buf); kfree(net_device); return 0; -- 2.1.3 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v9 06/19] vfio/platform: return info for bound device
On 11/20/2014 03:10 PM, Antonios Motakis wrote: On Wed, Nov 12, 2014 at 5:36 PM, Alex Williamson alex.william...@redhat.com wrote: On Wed, 2014-11-12 at 11:32 +0100, Eric Auger wrote: On 10/27/2014 07:07 PM, Antonios Motakis wrote: A VFIO userspace driver will start by opening the VFIO device that corresponds to an IOMMU group, and will use the ioctl interface to get the basic device info, such as number of memory regions and interrupts, and their properties. This patch enables the VFIO_DEVICE_GET_INFO ioctl call. Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com --- drivers/vfio/platform/vfio_platform_common.c | 23 --- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c index e0fdbc8..cb20526 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -43,10 +43,27 @@ static int vfio_platform_open(void *device_data) static long vfio_platform_ioctl(void *device_data, unsigned int cmd, unsigned long arg) { - if (cmd == VFIO_DEVICE_GET_INFO) - return -EINVAL; + struct vfio_platform_device *vdev = device_data; + unsigned long minsz; + + if (cmd == VFIO_DEVICE_GET_INFO) { + struct vfio_device_info info; + + minsz = offsetofend(struct vfio_device_info, num_irqs); + + if (copy_from_user(info, (void __user *)arg, minsz)) + return -EFAULT; + + if (info.argsz minsz) + return -EINVAL; + + info.flags = vdev-flags; + info.num_regions = 0; + info.num_irqs = 0; Seems a bit weird to me to enable the modality but returning zeroed values. Shouldn't we put that patch after VFIO_DEVICE_GET_REGION_INFO and VFIO_DEVICE_GET_IRQ_INFO ones? I actually like how Antonios has started from a base framework, exposing a device but none of the resources and then incrementally adds each component. It's also a good showcase of the VFIO ABI that we can do things like this. Thanks, I also agree with Alex with this. But of course I'm not married with any particular splitting style, in case we decide to change this. Hi Antonios, please keep as is. I also learn each day about splitting style ;-) Best Regards Eric Alex -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH V2] ACPI: Add _DEP(Operation Region Dependencies) support to fix battery issue on the Asus T100TA
On Thu, Nov 20, 2014 at 10:12:12PM +0800, Lan Tianyu wrote: ACPI 5.0 introduces _DEP to designate device objects that OSPM should assign a higher priority in start ordering due to future operation region accesses. On Asus T100TA, ACPI battery info are read from a I2C slave device via I2C operation region. Before I2C operation region handler is installed, battery _STA always returns 0. There is a _DEP method of designating start order under battery device node. This patch is to implement _DEP feature to fix battery issue on the Asus T100TA. Introducing acpi_dep_list and adding dep_unmet count in the struct acpi_device. During ACPI namespace scan, create struct acpi_dep_data for a valid pair of master (device pointed to by _DEP)/slave(device with _DEP), record master's and slave's ACPI handle in it and put it into acpi_dep_list. The dep_unmet count will increase by one if there is a device under its _DEP. Driver's probe() should return EPROBE_DEFER when find dep_unmet is larger than 0. When I2C operation region handler is installed, remove all struct acpi_dep_data on the acpi_dep_list whose master is pointed to I2C host controller and decrease slave's dep_unmet. When dep_unmet decreases to 0, all _DEP conditions are met and then do acpi_bus_attach() for the device in order to resolve battery _STA issue on the Asus T100TA. Reference: https://bugzilla.kernel.org/show_bug.cgi?id=69011 Tested-by: Jan-Michael Brummer jan.brum...@tabos.org Tested-by: Adam Williamson ad...@happyassassin.net Tested-by: Michael Shigorin shigo...@gmail.com Acked-by: Wolfram Sang w...@the-dreams.de Signed-off-by: Lan Tianyu tianyu@intel.com Looks good to me now, Acked-by: Mika Westerberg mika.westerb...@linux.intel.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 1/2] Input: add regulator haptic driver
Hi Jaewon, On 20 November 2014 19:01, Jaewon Kim jaewon02@samsung.com wrote: This patch adds support for haptic driver controlled by voltage of regulator. And this driver support for Force Feedback interface from input framework Signed-off-by: Jaewon Kim jaewon02@samsung.com Signed-off-by: Hyunhee Kim hyunhee@samsung.com Acked-by: Kyungmin Park kyungmin.p...@samsung.com --- .../devicetree/bindings/input/regulator-haptic.txt | 24 ++ drivers/input/misc/Kconfig | 11 + drivers/input/misc/Makefile|1 + drivers/input/misc/regulator-haptic.c | 241 4 files changed, 277 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/regulator-haptic.txt create mode 100644 drivers/input/misc/regulator-haptic.c diff --git a/Documentation/devicetree/bindings/input/regulator-haptic.txt b/Documentation/devicetree/bindings/input/regulator-haptic.txt new file mode 100644 index 000..9f60e17 --- /dev/null +++ b/Documentation/devicetree/bindings/input/regulator-haptic.txt @@ -0,0 +1,24 @@ +* Requlator Haptic Device Tree Bindings + +The regulator haptic driver controlled by voltage of regulator. +This driver implemented via Force Feedback interface. + +Required Properties: + - compatible : Should be regulator-haptic + - haptic-supply : Power supply for the haptic motor. + [*] refer Documentation/devicetree/bindings/regulator/regulator.txt + + - max-microvolt : The maximum voltage value supplied to haptic motor. + [The unit of the voltage is a micro] + + - min-microvolt : The minimum voltage value in which haptic motor reacts. + [The unit of the voltage is a micro] + +Example: + + regulator-haptic { + compatible = regulator-haptic; + haptic-supply = motor_regulator; + max-microvolt = 270; + min-microvolt = 110; + }; diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 23297ab..e5e556d 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -394,6 +394,17 @@ config INPUT_CM109 To compile this driver as a module, choose M here: the module will be called cm109. +config INPUT_REGULATOR_HAPTIC + tristate regulator haptics support + select INPUT_FF_MEMLESS + help + This option enables device driver support for the haptic controlled + by regulator. This driver supports ff-memless interface + from input framework. + + To compile this driver as a module, choose M here: the + module will be called regulator-haptic. + config INPUT_RETU_PWRBUTTON tristate Retu Power button Driver depends on MFD_RETU diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 19c7603..1f135af 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -53,6 +53,7 @@ obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY) += pmic8xxx-pwrkey.o obj-$(CONFIG_INPUT_POWERMATE) += powermate.o obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o +obj-$(CONFIG_INPUT_REGULATOR_HAPTIC) += regulator-haptic.o obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)+= rotary_encoder.o obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o diff --git a/drivers/input/misc/regulator-haptic.c b/drivers/input/misc/regulator-haptic.c new file mode 100644 index 000..1a83ecb --- /dev/null +++ b/drivers/input/misc/regulator-haptic.c @@ -0,0 +1,241 @@ +/* + * Regulator haptic driver + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Author: Jaewon Kim jaewon02@samsung.com + * Author: Hyunhee Kim hyunhee@samsung.com + * + * 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 linux/module.h +#include linux/platform_device.h +#include linux/input.h +#include linux/slab.h +#include linux/regulator/consumer.h +#include linux/of.h + +#define MAX_MAGNITUDE_SHIFT16 + +struct regulator_haptic { + struct device *dev; + struct input_dev *input_dev; + struct regulator *regulator; + struct work_struct work; + + bool enabled; + bool suspend_state; + unsigned int max_volt; + unsigned int min_volt; + unsigned int intensity; + unsigned int magnitude; +}; + +static void regulator_haptic_enable(struct regulator_haptic *haptic) +{ + int error; + + if (haptic-enabled) + return; + + error = regulator_enable(haptic-regulator); + if (error) { + dev_err(haptic-dev, cannot enable
Re: [PATCH v4 3/6] mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save
Brad, What you wrote is just the kind of thing one would like to see in the cover letter or change log... On Thu, Nov 20, 2014 at 02:23:30PM +, Griffis, Brad wrote: In that thread the user was registering multiple press events for a single press. By increasing the udelay to 1.5ms they were able to solve the problem. Of course, having a 1.5ms delay in your ISR is a really bad thing to do... I fully support removing the aweful ISR delay, as long as the result works! I have another customer that was experiencing the same issue of registering multiple press events, and sure enough the 1.5ms delay fixed their problem too. The patches allowed them to remove that gigantic delay from the ISR because that software delay has now become a hardware delay via CHARGECONFIG. That customer is the one that needed 0xB000 which is MUCH larger than the value of 0x400 that was working fine for me on the EVM. It would be really nice for TI to explain to board designers how to calculate the proper value. Thanks, Richard -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH RFC] audit: move the tree pruning to a dedicated thread
From: Palik, Imre im...@amazon.de When file auditing is enabled, during a low memory situation, a memory allocation with __GFP_FS can lead to pruning the inode cache. Which can, in turn lead to audit_tree_freeing_mark() being called. This can call audit_schedule_prune(), that tries to fork a pruning thread, and waits until the thread is created. But forking needs memory, and the memory allocations there are done with __GFP_FS. So we are waiting merrily for some __GFP_FS memory allocations to complete, while holding some filesystem locks. This can take a while ... This patch creates a single thread for pruning the tree from audit_tree_init(), and thus avoids the deadlock that the on-demand thread creation can cause. An alternative approach would be to move the thread creation outside of the lock. This would assume that other layers of the filesystem code don't hold any locks, and it would need some rewrite of the code to limit the amount of threads possibly spawned. Reported-by: Matt Wilson m...@amazon.com Cc: Matt Wilson m...@amazon.com Signed-off-by: Imre Palik im...@amazon.de --- kernel/audit_tree.c | 53 ++- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c index 0caf1f8..cf6db88 100644 --- a/kernel/audit_tree.c +++ b/kernel/audit_tree.c @@ -37,6 +37,7 @@ struct audit_chunk { static LIST_HEAD(tree_list); static LIST_HEAD(prune_list); +static struct task_struct *prune_thread; /* * One struct chunk is attached to each inode of interest. @@ -806,30 +807,39 @@ int audit_tag_tree(char *old, char *new) */ static int prune_tree_thread(void *unused) { - mutex_lock(audit_cmd_mutex); - mutex_lock(audit_filter_mutex); + for (;;) { + set_current_state(TASK_INTERRUPTIBLE); + if (list_empty(prune_list)) + schedule(); + __set_current_state(TASK_RUNNING); - while (!list_empty(prune_list)) { - struct audit_tree *victim; + mutex_lock(audit_cmd_mutex); + mutex_lock(audit_filter_mutex); - victim = list_entry(prune_list.next, struct audit_tree, list); - list_del_init(victim-list); + while (!list_empty(prune_list)) { + struct audit_tree *victim; - mutex_unlock(audit_filter_mutex); + victim = list_entry(prune_list.next, + struct audit_tree, list); + list_del_init(victim-list); - prune_one(victim); + mutex_unlock(audit_filter_mutex); - mutex_lock(audit_filter_mutex); - } + prune_one(victim); - mutex_unlock(audit_filter_mutex); - mutex_unlock(audit_cmd_mutex); + mutex_lock(audit_filter_mutex); + } + + mutex_unlock(audit_filter_mutex); + mutex_unlock(audit_cmd_mutex); + } return 0; } static void audit_schedule_prune(void) { - kthread_run(prune_tree_thread, NULL, audit_prune_tree); + BUG_ON(!prune_thread); + wake_up_process(prune_thread); } /* @@ -896,9 +906,10 @@ static void evict_chunk(struct audit_chunk *chunk) for (n = 0; n chunk-count; n++) list_del_init(chunk-owners[n].list); spin_unlock(hash_lock); + mutex_unlock(audit_filter_mutex); if (need_prune) audit_schedule_prune(); - mutex_unlock(audit_filter_mutex); + } static int audit_tree_handle_event(struct fsnotify_group *group, @@ -938,10 +949,16 @@ static int __init audit_tree_init(void) { int i; - audit_tree_group = fsnotify_alloc_group(audit_tree_ops); - if (IS_ERR(audit_tree_group)) - audit_panic(cannot initialize fsnotify group for rectree watches); - + prune_thread = kthread_create(prune_tree_thread, NULL, + audit_prune_tree); + if (IS_ERR(prune_thread)) { + audit_panic(cannot start thread audit_prune_tree); + } else { + wake_up_process(prune_thread); + audit_tree_group = fsnotify_alloc_group(audit_tree_ops); + if (IS_ERR(audit_tree_group)) + audit_panic(cannot initialize fsnotify group for rectree watches); + } for (i = 0; i HASH_SIZE; i++) INIT_LIST_HEAD(chunk_hash_heads[i]); -- 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: frequent lockups in 3.18rc4
On Wed, Nov 19, 2014 at 12:15:24AM -0500, Dave Jones wrote: On Tue, Nov 18, 2014 at 08:40:55PM -0800, Linus Torvalds wrote: Hmm, if we are getting soft-lockups here, maybe it suggest too much exit-work. Some TIF_NOHZ loop, perhaps? You have nohz on, don't you? That makes me wonder: does the problem go away if you disable NOHZ? Does nohz=off do enough ? I couldn't convince myself after looking at dmesg, and still seeing dynticks stuff in there. I'll do a rebuild with all the CONFIG_NO_HZ stuff off, though it also changes some other config stuff wrt timers. You also need to disable context tracking. So you need to deactive also CONFIG_RCU_USER_QS and CONFIG_CONTEXT_TRACKING_FORCE and eventually make sure nothing else is turning on CONFIG_CONTEXT_TRACKING. You can keep CONFIG_NO_HZ_IDLE though, just not CONFIG_NO_HZ_FULL. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@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: Looking for good references for ARM driver development
On Wed, 19 Nov 2014 17:05:00 +0100 Mason mpeg.b...@free.fr wrote: Hello Andreas, On 19/11/2014 16:02, Andreas Färber wrote: Am 19.11.2014 um 13:50 schrieb Mason: ... Since this appears to be about an ARM SoC according to your To list, in general, you create a device tree binding, that binding is registered within your platform/... driver code and referenced in the device tree for SoC or board, and then your driver will automatically be probed. I know nothing about DT (aside from the Wikipedia entry). I'll take a closer look at Documentation/devicetree. Will that explain what platform/... is? I see a drivers/platform folder, but nothing ARM-specific there? There are very good presentations from Free Electrons: * http://free-electrons.com/pub/conferences/2013/elce/petazzoni-device-tree-dummies/petazzoni-device-tree-dummies.pdf ** see also http://www.youtube.com/watch?v=m_NyYEBxfn8 * https://archive.fosdem.org/2013/schedule/event/arm_in_the_linux_kernel/attachments/slides/273/export/events/attachments/arm_in_the_linux_kernel/slides/273/arm_support_kernel.pdf -- Best regards, Antony Pavlov -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@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/1] crypto-drbg: Deletion of unnecessary checks before the function call kzfree
On Wed, Nov 19, 2014 at 10:20:32AM +0100, SF Markus Elfring wrote: From: Markus Elfring elfr...@users.sourceforge.net Date: Wed, 19 Nov 2014 10:11:04 +0100 The kzfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring elfr...@users.sourceforge.net Sorry but you're too late as someone else has already fixed this :) Thanks, -- Email: Herbert Xu herb...@gondor.apana.org.au Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v4 3/6] mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save
On Thu, Nov 20, 2014 at 07:26:00PM +0530, Sekhar Nori wrote: I tested this using lcd7 cape connected to beaglebone black. The latest kernel I could find on this board was a TI BSP based v3.14 kernel. So I had to port these patches to that kernel. Cc Robert Nelson to see if he knows about a more recent kernel supporting that cape. What is missing from mainline for the black? (I thought it was fully supported by now.) I did not see any breakage with these patches applied although I did not see any noticeable performance improvement as well. So, the jumping on pen-up persists, right? That means the patch series does not provide a general fix for that issue. I also tested this series on AM335x EVM using the v3.18-rc5 kernel. Again, no breakage but no improvement as well. You still have jumps on a pen up event? Thanks, Richard -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@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] arm64: crypto: Add ARM64 CRC32 hw accelerated module
On Thu, Nov 20, 2014 at 07:42:23AM -0600, Yazen Ghannam wrote: +linux-arm-ker...@lists.infradead.org On Wed, Nov 19, 2014 at 11:19 AM, Yazen Ghannam yazen.ghan...@linaro.org wrote: This module registers a crc32 algorithm and a crc32c algorithm that use the optional CRC32 and CRC32C instructions in ARMv8. Tested on AMD Seattle. Improvement compared to crc32c-generic algorithm: TCRYPT CRC32C speed test shows ~450% speedup. Simple dd write tests to btrfs filesystem show ~30% speedup. Signed-off-by: Yazen Ghannam yazen.ghan...@linaro.org Acked-by: Steve Capper steve.cap...@linaro.org Acked-by: Ard Biesheuvel ard.biesheu...@linaro.org Patch applied. Thanks! -- Email: Herbert Xu herb...@gondor.apana.org.au Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call dvb_unregister_device
On Nov 20 SF Markus Elfring wrote: From: Markus Elfring elfr...@users.sourceforge.net Date: Thu, 20 Nov 2014 10:49:07 +0100 The dvb_unregister_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring elfr...@users.sourceforge.net Reviewed-by: Stefan Richter stef...@s5r6.in-berlin.de --- drivers/media/firewire/firedtv-ci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/firewire/firedtv-ci.c b/drivers/media/firewire/firedtv-ci.c index e5ebdbf..e63f582 100644 --- a/drivers/media/firewire/firedtv-ci.c +++ b/drivers/media/firewire/firedtv-ci.c @@ -253,6 +253,5 @@ int fdtv_ca_register(struct firedtv *fdtv) void fdtv_ca_release(struct firedtv *fdtv) { - if (fdtv-cadev) - dvb_unregister_device(fdtv-cadev); + dvb_unregister_device(fdtv-cadev); } -- Stefan Richter -=-- =-== =-=-- http://arcgraph.de/sr/ -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@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] Input updates for 3.18-rc4
On Wed, Nov 19, 2014 at 4:05 PM, ulrik.debie...@e2big.org wrote: Hi, Thanks Dmitry, the fix you provided will mitigate the regression. But there might be more that is going on for v4 hardware. The detection of PACKET_TRACKPOINT can be made more strict. Thank you Marcus and Benjamin for the reports. Sorry for the regression, it was not expected that lowest nibble of packet[3] is 0x6 for non-trackpoint packets. So we have two laptops where 1) according to the msb of the capabilities has no trackpoint Benjamin, can you give feedback if the laptop has actually a trackpoint/stick/ how else one calls that strange but convenient thing in the middle of the keyboard ? Ulrik, the reporter said that there is no trackstick on his device. The exact reference is Samsung Notebook NP900X3E-A01SE. Cheers, Benjamin -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@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 RESEND v2 0/4] hwrng: atmel: add DT support
On Thu, Nov 20, 2014 at 10:43:21AM +0100, Nicolas Ferre wrote: This is the patch series that Boris sent yesterday. I've just collected Acked-by tags and resend it with updated cover letter. This series adds DT support for the TRNG (True Random Generator) block and adds missing trng nodes to at91sam9g45 dtsi files. Herbert, As you said that you can take this series, here is the latest vertion ready for you to pick it up. Thanks for your help. Bye, Boris Brezillon (4): hwrng: atmel: use clk_prepapre_enable/_disable_unprepare hwrng: atmel: add DT support hwrng: atmel: Add TRNG DT binding doc ARM: at91/dt: add trng node to at91sam9g45 All applied. Thanks! -- Email: Herbert Xu herb...@gondor.apana.org.au Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: linux-next: manual merge of the devicetree tree with the devicetree-current tree
Thanks Stephen, Yes, that looks right, but I'm going to drop the patch from my tree. It isn't a critical fix. The failure it solves is not a serious or dangerous. Thanks, g. On Thu, Nov 20, 2014 at 3:50 AM, Stephen Rothwell s...@canb.auug.org.au wrote: Hi Grant, Today's linux-next merge of the devicetree tree got a conflict in drivers/of/unittest.c between commit 817d2001c709 (of/selftest: Fix testing when /aliases is missing) from the devicetree-current tree and commit 5063e25a302e (of: Eliminate of_allnodes list) from the devicetree tree. I fixed it up (see below) and can carry the fix as necessary (no action is required). -- Cheers, Stephen Rothwells...@canb.auug.org.au diff --cc drivers/of/unittest.c index ae8b75904104,082bb2b6a5ad.. --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@@ -853,19 -858,20 +858,23 @@@ static int __init selftest_data_add(voi for_each_of_allnodes(np) __of_attach_node_sysfs(np); - of_aliases = of_find_node_by_path(/aliases); - of_chosen = of_find_node_by_path(/chosen); - return 0; + } else { + /* attach the sub-tree to live tree */ - rc = attach_node_and_children(selftest_data_node); - if (WARN_ON(rc)) - return rc; ++ np = selftest_data_node-child; ++ while (np) { ++ struct device_node *next = np-sibling; ++ np-parent = of_root; ++ attach_node_and_children(np); ++ np = next; ++ } } - /* attach the sub-tree to live tree */ - np = selftest_data_node-child; - while (np) { - struct device_node *next = np-sibling; - np-parent = of_root; - attach_node_and_children(np); - np = next; - } + /* Make sure of_aliases and of_chosen are up-to-date */ + if (!of_aliases) + of_aliases = of_find_node_by_path(/aliases); + if (!of_chosen) + of_chosen = of_find_node_by_path(/chosen); - return rc; + return 0; } /** -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] mmc: wmt-sdmmc: fix unmatched release_mem_region
From b0509e27e33326e6dccd67d8ebe67e2bdb0cfdde Mon Sep 17 00:00:00 2001 From: Helmut Stengele laut...@coldplug.net Date: Thu, 20 Nov 2014 15:27:40 +0100 Subject: [PATCH] mmc: wmt-sdmmc: fix unmatched release_mem_region Current code calls release_mem_region upon module unload without requesting the region first. This patch fixes it by moving to a devres-based ioremap implementation, which handles requesting and releasing memory region internally. This also makes the error/unload paths a bit simpler. Signed-off-by: Helmut Stengele laut...@coldplug.net --- This is a corrected patch based on the one Alexey sent for me. I sent it already but since i'm not used to send something upstream it was an attached file and obviously rejected. Patch is tested on bare-metal ( wm8850 ) and works like suspected. drivers/mmc/host/wmt-sdmmc.c | 14 +- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/wmt-sdmmc.c b/drivers/mmc/host/wmt-sdmmc.c index 54181b4..bcaa0cc 100644 --- a/drivers/mmc/host/wmt-sdmmc.c +++ b/drivers/mmc/host/wmt-sdmmc.c @@ -759,6 +759,7 @@ static int wmt_mci_probe(struct platform_device *pdev) const struct wmt_mci_caps *wmt_caps; int ret; int regular_irq, dma_irq; +struct resource *res; if (!of_id || !of_id-data) { dev_err(pdev-dev, Controller capabilities data missing\n); @@ -813,10 +814,11 @@ static int wmt_mci_probe(struct platform_device *pdev) if (of_get_property(np, cd-inverted, NULL)) priv-cd_inverted = 1; -priv-sdmmc_base = of_iomap(np, 0); +res = platform_get_resource(pdev, IORESOURCE_MEM, 0); +priv-sdmmc_base = devm_ioremap_resource(pdev-dev, res); if (!priv-sdmmc_base) { dev_err(pdev-dev, Failed to map IO space\n); -ret = -ENOMEM; +ret = PTR_ERR(priv-sdmmc_base); goto fail2; } @@ -826,7 +828,7 @@ static int wmt_mci_probe(struct platform_device *pdev) ret = request_irq(regular_irq, wmt_mci_regular_isr, 0, sdmmc, priv); if (ret) { dev_err(pdev-dev, Register regular IRQ fail\n); -goto fail3; +goto fail2; } ret = request_irq(dma_irq, wmt_mci_dma_isr, 0, sdmmc, priv); @@ -869,8 +871,6 @@ fail5: free_irq(dma_irq, priv); fail4: free_irq(regular_irq, priv); -fail3: -iounmap(priv-sdmmc_base); fail2: mmc_free_host(mmc); fail1: @@ -881,7 +881,6 @@ static int wmt_mci_remove(struct platform_device *pdev) { struct mmc_host *mmc; struct wmt_mci_priv *priv; -struct resource *res; u32 reg_tmp; mmc = platform_get_drvdata(pdev); @@ -909,9 +908,6 @@ static int wmt_mci_remove(struct platform_device *pdev) clk_disable_unprepare(priv-clk_sdmmc); clk_put(priv-clk_sdmmc); -res = platform_get_resource(pdev, IORESOURCE_MEM, 0); -release_mem_region(res-start, resource_size(res)); - mmc_free_host(mmc); dev_info(pdev-dev, WMT MCI device removed\n); -- 2.1.3 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: linux-next: Tree for Nov 20
On Thu, Nov 20, 2014 at 06:46:53PM +1100, Stephen Rothwell wrote: Hi all, Changes since 20141119: The asm-generic tree lost its build failure. The omap_dss2 tree still had its build failure for which I applied a patch. The devicetree tree gained a conflict against the devicetree-current tree. Non-merge commits (relative to Linus' tree): 7146 7140 files changed, 242712 insertions(+), 180038 deletions(-) Build results: total: 133 pass: 130 fail: 3 Failed builds: arm:davinci_all_defconfig arm:orion5x_defconfig hexagon:defconfig Qemu test results: total: 30 pass: 30 fail: 0 I assume the arm architecture folks will take care of the arm build failures, so I did not have a look into those. The hexagon build failure is due to a subtle change in files includes by other include files, resulting in a nested dependency which is no longer met. That may be tricky to fix. The qemu x86:nonsmp test only passes because I disabled PCI_MSI for this test. Claim there is that qemu would not implement some IO_APIC related functionality which is now mandatory. Guenter -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/