Re: [PATCH] ieee802154: fix error handling in ieee802154fake_probe()
Hi Alex, >> In case of any failure ieee802154fake_probe() just calls unregister_netdev(). >> But it does not look safe to unregister netdevice before it was registered. >> >> The patch implements straightforward resource deallocation in case of >> failure in ieee802154fake_probe(). >> >> Found by Linux Driver Verification project (linuxtesting.org). >> > > Thanks for the patch! But I already delete the whole fakehard driver. > The patch to remove this driver is already in net-next. > > There was too many issues with the fake hardMAC drivers and we don't > really supported a "real" hardMAC transceiver. For my rework to grab the > good things from wireless implementation and put 802.15.4 functionality > on it I simple delete the whole driver and _maybe_ add a new one with > the new introduced interfaces for possible hardMAC functionality. > > This patch could go into bluetooth(net)/stable but I don't think that > there are many users for this driver. I am not sure that this is worth it then. Dave, do you want to just take it via net-stable tree? We currently have no urgent bluetooth-stable tree patches pending. 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 2/3] staging: vme: mmap() support for vme_user
On Sat, Nov 15, 2014 at 02:36:17AM +0300, Dmitry Kalinkin wrote: > +int vme_master_mmap(struct vme_resource *resource, struct vm_area_struct > *vma) > +{ > + struct vme_master_resource *image; > + phys_addr_t phys_addr; > + unsigned long vma_size; > + > + if (resource->type != VME_MASTER) { > + printk(KERN_ERR "Not a master resource\n"); Run your patch through scripts/checkpatch.pl Also warning messages let people flood /var/log/messages so they can be a DoS vector. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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] ieee802154: fix error handling in ieee802154fake_probe()
Hi, On Sat, Nov 15, 2014 at 02:11:59AM +0300, Alexey Khoroshilov wrote: > In case of any failure ieee802154fake_probe() just calls unregister_netdev(). > But it does not look safe to unregister netdevice before it was registered. > > The patch implements straightforward resource deallocation in case of > failure in ieee802154fake_probe(). > > Found by Linux Driver Verification project (linuxtesting.org). > Thanks for the patch! But I already delete the whole fakehard driver. The patch to remove this driver is already in net-next. There was too many issues with the fake hardMAC drivers and we don't really supported a "real" hardMAC transceiver. For my rework to grab the good things from wireless implementation and put 802.15.4 functionality on it I simple delete the whole driver and _maybe_ add a new one with the new introduced interfaces for possible hardMAC functionality. This patch could go into bluetooth(net)/stable but I don't think that there are many users for this driver. - Alex -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/2] ASoC: rt5677: add a platform config option for PDM clock divider
The PDM output clock can use a divider of 1/2/3/4 based on the system clock Signed-off-by: Ben Zhang --- Documentation/devicetree/bindings/sound/rt5677.txt | 5 + include/sound/rt5677.h | 8 sound/soc/codecs/rt5677.c | 7 +++ 3 files changed, 20 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/rt5677.txt b/Documentation/devicetree/bindings/sound/rt5677.txt index 740ff77..141f3e1 100644 --- a/Documentation/devicetree/bindings/sound/rt5677.txt +++ b/Documentation/devicetree/bindings/sound/rt5677.txt @@ -27,6 +27,10 @@ Optional properties: Boolean. Indicate MIC1/2 input and LOUT1/2/3 outputs are differential, rather than single-ended. +- realtek,pdm_clk_div + Select 0/1/2/3 as PDM clock divider 1/2/4/3 respectively. + PDM clock = system clock / PDM clock divider + - realtek,gpio-config Array of six 8bit elements that configures GPIO. 0 - floating (reset value) @@ -71,6 +75,7 @@ rt5677 { realtek,pow-ldo2-gpio = <&gpio TEGRA_GPIO(V, 3) GPIO_ACTIVE_HIGH>; realtek,in1-differential = "true"; + realtek,pdm_clk_div = <1> /* PDM clock = system clock / 2 */ realtek,gpio-config = /bits/ 8 <0 0 0 0 0 2>; /* pull up GPIO6 */ realtek,jd2-gpio = <3>; /* Enables Jack detection for GPIO6 */ }; diff --git a/include/sound/rt5677.h b/include/sound/rt5677.h index d9eb7d8..368aa33 100644 --- a/include/sound/rt5677.h +++ b/include/sound/rt5677.h @@ -17,6 +17,12 @@ enum rt5677_dmic2_clk { RT5677_DMIC_CLK2 = 1, }; +enum rt5677_pdm_clk_div { + RT5677_PDM_CLK_DIV1 = 0, + RT5677_PDM_CLK_DIV2 = 1, + RT5677_PDM_CLK_DIV4 = 2, + RT5677_PDM_CLK_DIV3 = 3, +}; struct rt5677_platform_data { /* IN1/IN2/LOUT1/LOUT2/LOUT3 can optionally be differential */ @@ -27,6 +33,8 @@ struct rt5677_platform_data { bool lout3_diff; /* DMIC2 clock source selection */ enum rt5677_dmic2_clk dmic2_clk_pin; + /* System clock to PDM filter divider */ + enum rt5677_pdm_clk_div pdm_clk_div; /* configures GPIO, 0 - floating, 1 - pulldown, 2 - pullup */ u8 gpio_config[6]; diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 384281d..383cb61 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -4502,6 +4502,8 @@ static int rt5677_parse_dt(struct rt5677_priv *rt5677, struct device_node *np) "realtek,lout2-differential"); rt5677->pdata.lout3_diff = of_property_read_bool(np, "realtek,lout3-differential"); + of_property_read_u32(np, "realtek,pdm_clk_div", + &rt5677->pdata.pdm_clk_div); rt5677->pow_ldo2 = of_get_named_gpio(np, "realtek,pow-ldo2-gpio", 0); @@ -4548,6 +4550,8 @@ static void rt5677_parse_acpi(struct rt5677_priv *rt5677, struct device *dev) { rt5677->pdata.dmic2_clk_pin = (enum rt5677_dmic2_clk) rt5677_parse_acpi_entry(dev, "DCLK"); + rt5677->pdata.pdm_clk_div = (enum rt5677_pdm_clk_div) + rt5677_parse_acpi_entry(dev, "PCLK"); rt5677->pdata.in1_diff = (bool)rt5677_parse_acpi_entry(dev, "IN1"); rt5677->pdata.in2_diff = (bool)rt5677_parse_acpi_entry(dev, "IN2"); rt5677->pdata.lout1_diff = (bool)rt5677_parse_acpi_entry(dev, "OUT1"); @@ -4730,6 +4734,9 @@ static int rt5677_i2c_probe(struct i2c_client *i2c, RT5677_GPIO5_DIR_OUT); } + regmap_update_bits(rt5677->regmap, RT5677_PDM_DATA_CTRL1, + RT5677_PDM_DIV_MASK, rt5677->pdata.pdm_clk_div); + rt5677_init_gpio(i2c); rt5677_irq_init(i2c); -- 2.1.0.rc2.206.gedb03e5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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] ASoC: rt5677: Add ACPI device probing
The rt5677 codec driver looks for ACPI device ID "RT5677CE", which is specified in coreboot. This patch allows platform data to be obtained via ACPI Signed-off-by: Ben Zhang --- sound/soc/codecs/rt5677.c | 52 +-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 5d317c68..384281d 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -4525,6 +4526,43 @@ static int rt5677_parse_dt(struct rt5677_priv *rt5677, struct device_node *np) return 0; } +#ifdef CONFIG_ACPI + +static unsigned long long rt5677_parse_acpi_entry(struct device *dev, + acpi_string name) +{ + acpi_handle handle = ACPI_HANDLE(dev); + unsigned long long val; + acpi_status status; + + status = acpi_evaluate_integer(handle, name, NULL, &val); + if (ACPI_FAILURE(status)) { + dev_err(dev, "Failed to parse ACPI entry %s, default to 0: %d\n", + name, status); + return 0; + } + return val; +} + +static void rt5677_parse_acpi(struct rt5677_priv *rt5677, struct device *dev) +{ + rt5677->pdata.dmic2_clk_pin = (enum rt5677_dmic2_clk) + rt5677_parse_acpi_entry(dev, "DCLK"); + rt5677->pdata.in1_diff = (bool)rt5677_parse_acpi_entry(dev, "IN1"); + rt5677->pdata.in2_diff = (bool)rt5677_parse_acpi_entry(dev, "IN2"); + rt5677->pdata.lout1_diff = (bool)rt5677_parse_acpi_entry(dev, "OUT1"); + rt5677->pdata.lout2_diff = (bool)rt5677_parse_acpi_entry(dev, "OUT2"); + rt5677->pdata.lout3_diff = (bool)rt5677_parse_acpi_entry(dev, "OUT3"); + rt5677->pdata.jd1_gpio = rt5677_parse_acpi_entry(dev, "JD1"); + rt5677->pdata.jd2_gpio = rt5677_parse_acpi_entry(dev, "JD2"); + rt5677->pdata.jd3_gpio = rt5677_parse_acpi_entry(dev, "JD3"); +} +#else +static void rt5677_parse_acpi(struct rt5677_priv *rt5677, struct device *dev) +{ +} +#endif + static struct regmap_irq rt5677_irqs[] = { [RT5677_IRQ_JD1] = { .reg_offset = 0, @@ -4604,6 +4642,7 @@ static int rt5677_i2c_probe(struct i2c_client *i2c, if (pdata) rt5677->pdata = *pdata; + rt5677->pow_ldo2 = -EINVAL; if (i2c->dev.of_node) { ret = rt5677_parse_dt(rt5677, i2c->dev.of_node); if (ret) { @@ -4611,8 +4650,8 @@ static int rt5677_i2c_probe(struct i2c_client *i2c, ret); return ret; } - } else { - rt5677->pow_ldo2 = -EINVAL; + } else if (ACPI_HANDLE(&i2c->dev)) { + rt5677_parse_acpi(rt5677, &i2c->dev); } if (gpio_is_valid(rt5677->pow_ldo2)) { @@ -4708,10 +4747,19 @@ static int rt5677_i2c_remove(struct i2c_client *i2c) return 0; } +#ifdef CONFIG_ACPI +static const struct acpi_device_id rt5677_acpi_id[] = { + { "RT5677CE", 0 }, + { } +}; +MODULE_DEVICE_TABLE(acpi, rt5677_acpi_id); +#endif + static struct i2c_driver rt5677_i2c_driver = { .driver = { .name = "rt5677", .owner = THIS_MODULE, + .acpi_match_table = ACPI_PTR(rt5677_acpi_id), }, .probe = rt5677_i2c_probe, .remove = rt5677_i2c_remove, -- 2.1.0.rc2.206.gedb03e5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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: [Cocci] spatch for trivial pointer comparison style?
On Fri, 14 Nov 2014, Joe Perches wrote: > On Fri, 2014-11-14 at 10:18 +0100, Julia Lawall wrote: > > On Thu, 13 Nov 2014, Joe Perches wrote: > [] > > > Yes, I agree with some of the things Al Viro said > > > there, but isn't 'type t; t *p;' a subset of > > > "expression *e"? > > > No. How would you expect it to be different. > > [] No. [] and * are treated completely differently. > > type t means that the type > > is known. expression *e means that there is a * in the type. > > I had thought "expression *" could be r-value and > "type t; t *p;" could be l-value. No, you made that one up :) As we considered that it would be common to want to specify the type of an expression, we thought it would be tiresome to have to put eg expression int x. So you can just say int x. The downside is that people write identifer x; and then don't understand the error message, because any misspelled metavariable kind is considered to be a type name. julia > But then I don't find (or maybe don't parse too well) > the coccinelle documentation that specifies these > type relationships. > > cheers, Joe > > > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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 v11 0/12] dw-hdmi: convert imx hdmi to bridge/dw_hdmi
On Fri, Nov 14, 2014 at 9:37 PM, Andy Yan wrote: > > We found Freescale imx6 and Rockchip rk3288 and Ingenic JZ4780 (Xburst/MIPS) > use the interface compatible Designware HDMI IP, but they also have some > lightly differences, such as phy pll configuration, register width(imx hdmi > register is one byte, but rk3288 is 4 bytes width and can only be accessed > by word), 4K support(imx6 doesn't support 4k, but rk3288 does), and HDMI2.0 > support. > > To reuse the imx-hdmi driver, we make this patch set: > (1): fix some CodingStyle warning to make checkpatch happy > (2): split out imx-soc code from imx-hdmi to dw_hdmi-imx.c > (3): move imx-hdmi to bridge/dw-hdmi, and convert it to a drm_bridge driver > (4): add rockchip rk3288 platform specific code dw_hdmi-rockchip.c > > Changes in v11: > - rearrange the patch order > - squash patch > - split some modification form patch > > Changes in v10: > - split generic dw_hdmi.c improvements from patch#11 (add rk3288 support) > - add more display mode support mpll configuration for rk3288 > > Changes in v9: > - move some phy configuration to platform driver > > Changes in v8: > - correct some spelling mistake > - modify ddc-i2c-bus and interrupt description > - Add documentation for rockchip dw hdmi > > Changes in v7: > - remove unused variables from structure dw_hdmi > - remove a wrong modification > - add copyrights for dw_hdmi-imx.c > > Changes in v6: > - rearrange the patch order > - move some modification from patch#5 > - move some modification to patch#6 > - refactor register access without reg_shift > > Changes in v5: > - refactor reg-io-width > > Changes in v4: > - fix checkpatch CHECK > - defer probe ddc i2c adapter > > Changes in v3: > - split multi-register access to one indepent patch > > Changes in v2: > - use git format -M to generate these patch > > Andy Yan (11): > staging: imx-drm: imx-hdmi: make checkpatch happy > staging: imx-drm: imx-hdmi: return defer if can't get ddc i2c adapter > staging: imx-drm: imx-hdmi: split imx soc specific code from imx-hdmi > staging: imx-drm: imx-hdmi: move imx-hdmi to bridge/dw_hdmi > dt-bindings: add document for dw_hdmi > drm: bridge/dw_hdmi: add support for multi-byte register width access > drm: bridge/dw_hdmi: add mode_valid support > drm: bridge/dw_hdmi: clear i2cmphy_stat0 reg in hdmi_phy_wait_i2c_done > drm: bridge/dw_hdmi: add function dw_hdmi_phy_enable_spare > dt-bindings: Add documentation for rockchip dw hdmi > drm: bridge/dw_hdmi: add rockchip rk3288 support > > Yakir Yang (1): > drm: bridge/dw_hdmi: convert dw-hdmi to drm_bridge mode Patch 1 & 2 are: Reviewed-by: Daniel Kurtz I think these first two are ready (or will be, after a small nit fix to #2). Since they are independent of the imx/dw_hdmi split, can we get them accepted first, to help shrink Andy's patch set? Thanks, -djk > > .../devicetree/bindings/drm/bridge/dw_hdmi.txt | 40 ++ > .../devicetree/bindings/video/dw_hdmi-rockchip.txt | 43 ++ > drivers/gpu/drm/bridge/Kconfig | 5 + > drivers/gpu/drm/bridge/Makefile| 1 + > .../imx-hdmi.c => gpu/drm/bridge/dw_hdmi.c}| 762 > + > .../imx-hdmi.h => gpu/drm/bridge/dw_hdmi.h}| 8 +- > drivers/gpu/drm/rockchip/Kconfig | 10 + > drivers/gpu/drm/rockchip/Makefile | 2 +- > drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c| 355 ++ > drivers/staging/imx-drm/Kconfig| 1 + > drivers/staging/imx-drm/Makefile | 2 +- > drivers/staging/imx-drm/dw_hdmi-imx.c | 274 > include/drm/bridge/dw_hdmi.h | 60 ++ > 13 files changed, 1138 insertions(+), 425 deletions(-) > create mode 100644 Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt > create mode 100644 > Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt > rename drivers/{staging/imx-drm/imx-hdmi.c => gpu/drm/bridge/dw_hdmi.c} (70%) > rename drivers/{staging/imx-drm/imx-hdmi.h => gpu/drm/bridge/dw_hdmi.h} (99%) > create mode 100644 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c > create mode 100644 drivers/staging/imx-drm/dw_hdmi-imx.c > create mode 100644 include/drm/bridge/dw_hdmi.h > > -- > 1.9.1 > -- Daniel Kurtz | Software Engineer | djku...@google.com | 650.204.0722 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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] ipc/mqueue.c: Drag unneeded code out of locks
> What's the benefit here? Seems very risky at very little gain. > > The juice ain't worth the squeeze. NAK Hello, It is fair to argue that these changes are too tiny to be very meaningful for performance but the other goal of this patch was also to make the code look cleaner and easier for me and other people to understand. I hope that is a reasonable desire. It is not fair to argue that these changes are risky. If it is risky for a person to add code then the code is too complicated to understand and should be rewritten or tests or formal methods should be used to verify correctness. Are you suggesting that the mqueue subsystem is too complicated for one to understand changes made to it and that it needs to be cleaned up a bit? I am trying to make the code easier to understand with this patch. Or that you'd want some more testing of the mqueue subsystem or the changes I made too it? Or that you'd want some more formal methods to make the code easier to verify? I suppose the area of code use a few extra sparse annotations. Thank you, Steven Stewart-Gallus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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] ipc/mqueue.c: Drag unneeded code out of locks
Hello, thank you for the criticism. > It's probably better to do this as three or four separate patches. Really? Alright if you insist I'll do the next version as multiple patches. > Well yes, that's what EMFILE means but "too_many_open_files" doesn't > make sense in this context! Fair enough, I'll rename it in the next version. > Thatsabug. It only requires CAP_SYS_RESOURCE if we're trying with > queues_count >= queues_max. Right, that was dumb of me. > This test isn't really needed. I don't follow. If the queue creation is not rejected then the resource user has to be accounted for right? And we can't add the resource to accounting if it is not created right? Thank you, Steven Stewart-Gallus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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 v11 02/12] staging: imx-drm: imx-hdmi: return defer if can't get ddc i2c adapter
On Fri, Nov 14, 2014 at 9:39 PM, Andy Yan wrote: > drm driver may probe before the i2c bus, so the driver should > defer probing until it is available > > Signed-off-by: Andy Yan > > --- > > Changes in v11: None > Changes in v10: None > Changes in v9: None > Changes in v8: None > Changes in v7: None > Changes in v6: None > Changes in v5: None > Changes in v4: > - defer probe ddc i2c adapter > > Changes in v3: None > Changes in v2: None > > drivers/staging/imx-drm/imx-hdmi.c | 5 - > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/imx-drm/imx-hdmi.c > b/drivers/staging/imx-drm/imx-hdmi.c > index 79daec4..c2b035a 100644 > --- a/drivers/staging/imx-drm/imx-hdmi.c > +++ b/drivers/staging/imx-drm/imx-hdmi.c > @@ -1611,8 +1611,11 @@ static int imx_hdmi_bind(struct device *dev, struct > device *master, void *data) > ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0); > if (ddc_node) { > hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node); > - if (!hdmi->ddc) > + if (!hdmi->ddc) { > dev_dbg(hdmi->dev, "failed to read ddc node\n"); > + of_node_put(ddc_node); > + return -EPROBE_DEFER; > + } Nit: You could move "of_node_put()" above "if (!hdmi->ddc)", and not need it in two places. Either way, this one is: Reviewed-by: Daniel Kurtz > > of_node_put(ddc_node); > } else { > -- > 1.9.1 > -- Daniel Kurtz | Software Engineer | djku...@google.com | 650.204.0722 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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 v11 01/12] staging: imx-drm: imx-hdmi: make checkpatch happy
On Fri, Nov 14, 2014 at 9:38 PM, Andy Yan wrote: > CHECK: Alignment should match open parenthesis > + if ((hdmi->vic == 10) || (hdmi->vic == 11) || > + (hdmi->vic == 12) || (hdmi->vic == 13) || > > CHECK: braces {} should be used on all arms of this statement > + if (hdmi->hdmi_data.video_mode.mdvi) > [...] > + else { > [...] > > Signed-off-by: Andy Yan Reviewed-by: Daniel Kurtz > > --- > > Changes in v11: None > Changes in v10: None > Changes in v9: None > Changes in v8: None > Changes in v7: None > Changes in v6: > - rearrange the patch order > > Changes in v5: None > Changes in v4: > - fix checkpatch CHECK > > Changes in v3: None > Changes in v2: None > > drivers/staging/imx-drm/imx-hdmi.c | 97 > +++--- > 1 file changed, 48 insertions(+), 49 deletions(-) > > diff --git a/drivers/staging/imx-drm/imx-hdmi.c > b/drivers/staging/imx-drm/imx-hdmi.c > index aaec6b2..79daec4 100644 > --- a/drivers/staging/imx-drm/imx-hdmi.c > +++ b/drivers/staging/imx-drm/imx-hdmi.c > @@ -163,7 +163,7 @@ static void hdmi_modb(struct imx_hdmi *hdmi, u8 data, u8 > mask, unsigned reg) > } > > static void hdmi_mask_writeb(struct imx_hdmi *hdmi, u8 data, unsigned int > reg, > - u8 shift, u8 mask) > +u8 shift, u8 mask) > { > hdmi_modb(hdmi, data << shift, mask, reg); > } > @@ -327,7 +327,7 @@ static unsigned int hdmi_compute_cts(unsigned int freq, > unsigned long pixel_clk, > } > > static void hdmi_set_clk_regenerator(struct imx_hdmi *hdmi, > - unsigned long pixel_clk) > +unsigned long pixel_clk) > { > unsigned int clk_n, clk_cts; > > @@ -338,7 +338,7 @@ static void hdmi_set_clk_regenerator(struct imx_hdmi > *hdmi, > > if (!clk_cts) { > dev_dbg(hdmi->dev, "%s: pixel clock not supported: %lu\n", > -__func__, pixel_clk); > + __func__, pixel_clk); > return; > } > > @@ -477,13 +477,11 @@ static void imx_hdmi_update_csc_coeffs(struct imx_hdmi > *hdmi) > u16 coeff_b = (*csc_coeff)[1][i]; > u16 coeff_c = (*csc_coeff)[2][i]; > > - hdmi_writeb(hdmi, coeff_a & 0xff, > - HDMI_CSC_COEF_A1_LSB + i * 2); > + hdmi_writeb(hdmi, coeff_a & 0xff, HDMI_CSC_COEF_A1_LSB + i * > 2); > hdmi_writeb(hdmi, coeff_a >> 8, HDMI_CSC_COEF_A1_MSB + i * 2); > hdmi_writeb(hdmi, coeff_b & 0xff, HDMI_CSC_COEF_B1_LSB + i * > 2); > hdmi_writeb(hdmi, coeff_b >> 8, HDMI_CSC_COEF_B1_MSB + i * 2); > - hdmi_writeb(hdmi, coeff_c & 0xff, > - HDMI_CSC_COEF_C1_LSB + i * 2); > + hdmi_writeb(hdmi, coeff_c & 0xff, HDMI_CSC_COEF_C1_LSB + i * > 2); > hdmi_writeb(hdmi, coeff_c >> 8, HDMI_CSC_COEF_C1_MSB + i * 2); > } > > @@ -535,21 +533,22 @@ static void hdmi_video_packetize(struct imx_hdmi *hdmi) > struct hdmi_data_info *hdmi_data = &hdmi->hdmi_data; > u8 val, vp_conf; > > - if (hdmi_data->enc_out_format == RGB > - || hdmi_data->enc_out_format == YCBCR444) { > - if (!hdmi_data->enc_color_depth) > + if (hdmi_data->enc_out_format == RGB || > + hdmi_data->enc_out_format == YCBCR444) { > + if (!hdmi_data->enc_color_depth) { > output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS; > - else if (hdmi_data->enc_color_depth == 8) { > + } else if (hdmi_data->enc_color_depth == 8) { > color_depth = 4; > output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS; > - } else if (hdmi_data->enc_color_depth == 10) > + } else if (hdmi_data->enc_color_depth == 10) { > color_depth = 5; > - else if (hdmi_data->enc_color_depth == 12) > + } else if (hdmi_data->enc_color_depth == 12) { > color_depth = 6; > - else if (hdmi_data->enc_color_depth == 16) > + } else if (hdmi_data->enc_color_depth == 16) { > color_depth = 7; > - else > + } else { > return; > + } > } else if (hdmi_data->enc_out_format == YCBCR422_8BITS) { > if (!hdmi_data->enc_color_depth || > hdmi_data->enc_color_depth == 8) > @@ -561,8 +560,9 @@ static void hdmi_video_packetize(struct imx_hdmi *hdmi) > else > return; > output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_YCC422; > - } else > + } else { > return; > + } > > /* set the packetizer registers */ > val = ((color_depth << HDMI_VP_PR_CD_COLOR_DEPTH_OFFSET) & > @@ -623,34 +623,34
[PATCH 07/26 v5] kprobes/tracing: Use trace_seq_has_overflowed() for overflow checks
From: "Steven Rostedt (Red Hat)" Instead of checking the return value of trace_seq_printf() and friends for overflowing of the buffer, use the trace_seq_has_overflowed() helper function. This cleans up the code quite a bit and also takes us a step closer to changing the return values of trace_seq_printf() and friends to void. Link: http://lkml.kernel.org/r/20141114011411.181812...@goodmis.org Reviewed-by: Srikar Dronamraju Acked-by: Masami Hiramatsu Signed-off-by: Steven Rostedt --- kernel/trace/trace_kprobe.c | 42 -- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index ef7e7f16ed1a..5edb518be345 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -1024,27 +1024,22 @@ print_kprobe_event(struct trace_iterator *iter, int flags, field = (struct kprobe_trace_entry_head *)iter->ent; tp = container_of(event, struct trace_probe, call.event); - if (!trace_seq_printf(s, "%s: (", ftrace_event_name(&tp->call))) - goto partial; + trace_seq_printf(s, "%s: (", ftrace_event_name(&tp->call)); if (!seq_print_ip_sym(s, field->ip, flags | TRACE_ITER_SYM_OFFSET)) - goto partial; + goto out; - if (!trace_seq_putc(s, ')')) - goto partial; + trace_seq_putc(s, ')'); data = (u8 *)&field[1]; for (i = 0; i < tp->nr_args; i++) if (!tp->args[i].type->print(s, tp->args[i].name, data + tp->args[i].offset, field)) - goto partial; - - if (!trace_seq_putc(s, '\n')) - goto partial; + goto out; - return TRACE_TYPE_HANDLED; -partial: - return TRACE_TYPE_PARTIAL_LINE; + trace_seq_putc(s, '\n'); + out: + return trace_handle_return(s); } static enum print_line_t @@ -1060,33 +1055,28 @@ print_kretprobe_event(struct trace_iterator *iter, int flags, field = (struct kretprobe_trace_entry_head *)iter->ent; tp = container_of(event, struct trace_probe, call.event); - if (!trace_seq_printf(s, "%s: (", ftrace_event_name(&tp->call))) - goto partial; + trace_seq_printf(s, "%s: (", ftrace_event_name(&tp->call)); if (!seq_print_ip_sym(s, field->ret_ip, flags | TRACE_ITER_SYM_OFFSET)) - goto partial; + goto out; - if (!trace_seq_puts(s, " <- ")) - goto partial; + trace_seq_puts(s, " <- "); if (!seq_print_ip_sym(s, field->func, flags & ~TRACE_ITER_SYM_OFFSET)) - goto partial; + goto out; - if (!trace_seq_putc(s, ')')) - goto partial; + trace_seq_putc(s, ')'); data = (u8 *)&field[1]; for (i = 0; i < tp->nr_args; i++) if (!tp->args[i].type->print(s, tp->args[i].name, data + tp->args[i].offset, field)) - goto partial; + goto out; - if (!trace_seq_putc(s, '\n')) - goto partial; + trace_seq_putc(s, '\n'); - return TRACE_TYPE_HANDLED; -partial: - return TRACE_TYPE_PARTIAL_LINE; + out: + return trace_handle_return(s); } -- 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/
[PATCH 02/26 v5] tracing: Add trace_seq_has_overflowed() and trace_handle_return()
From: "Steven Rostedt (Red Hat)" Adding a trace_seq_has_overflowed() which returns true if the trace_seq had too much written into it allows us to simplify the code. Instead of checking the return value of every call to trace_seq_printf() and friends, they can all be called normally, and at the end we can return !trace_seq_has_overflowed() instead. Several functions also return TRACE_TYPE_PARTIAL_LINE when the trace_seq overflowed and TRACE_TYPE_HANDLED otherwise. Another helper function was created called trace_handle_return() which takes a trace_seq and returns these enums. Using this helper function also simplifies the code. This change also makes it possible to remove the return values of trace_seq_printf() and friends. They should instead just be void functions. Link: http://lkml.kernel.org/r/20141114011410.365183...@goodmis.org Reviewed-by: Petr Mladek Signed-off-by: Steven Rostedt --- include/linux/ftrace_event.h | 11 ++ include/linux/trace_seq.h| 12 ++ include/trace/ftrace.h | 6 +- kernel/trace/trace.c | 69 +++ kernel/trace/trace.h | 1 + kernel/trace/trace_output.c | 416 +-- kernel/trace/trace_output.h | 16 +- 7 files changed, 231 insertions(+), 300 deletions(-) diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h index 28672e87e910..0bebb5c348b8 100644 --- a/include/linux/ftrace_event.h +++ b/include/linux/ftrace_event.h @@ -138,6 +138,17 @@ enum print_line_t { TRACE_TYPE_NO_CONSUME = 3 /* Handled but ask to not consume */ }; +/* + * Several functions return TRACE_TYPE_PARTIAL_LINE if the trace_seq + * overflowed, and TRACE_TYPE_HANDLED otherwise. This helper function + * simplifies those functions and keeps them in sync. + */ +static inline enum print_line_t trace_handle_return(struct trace_seq *s) +{ + return trace_seq_has_overflowed(s) ? + TRACE_TYPE_PARTIAL_LINE : TRACE_TYPE_HANDLED; +} + void tracing_generic_entry_update(struct trace_entry *entry, unsigned long flags, int pc); diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h index ea6c9dea79e3..07eda413dfcf 100644 --- a/include/linux/trace_seq.h +++ b/include/linux/trace_seq.h @@ -40,6 +40,18 @@ trace_seq_buffer_ptr(struct trace_seq *s) return s->buffer + s->len; } +/** + * trace_seq_has_overflowed - return true if the trace_seq took too much + * @s: trace sequence descriptor + * + * Returns true if too much data was added to the trace_seq and it is + * now full and will not take anymore. + */ +static inline bool trace_seq_has_overflowed(struct trace_seq *s) +{ + return s->full || s->len > PAGE_SIZE - 1; +} + /* * Currently only defined when tracing is enabled. */ diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h index 26b4f2e13275..f13471b5d27a 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.h @@ -280,11 +280,9 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \ if (ret)\ return ret; \ \ - ret = trace_seq_printf(s, print); \ - if (!ret) \ - return TRACE_TYPE_PARTIAL_LINE; \ + trace_seq_printf(s, print); \ \ - return TRACE_TYPE_HANDLED; \ + return trace_handle_return(s); \ } \ static struct trace_event_functions ftrace_event_type_funcs_##call = { \ .trace = ftrace_raw_output_##call, \ diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 44d561426700..3ce3c4ccfc94 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -2649,24 +2649,21 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter) event = ftrace_find_event(entry->type); if (trace_flags & TRACE_ITER_CONTEXT_INFO) { - if (iter->iter_flags & TRACE_FILE_LAT_FMT) { - if (!trace_print_lat_context(iter)) - goto partial; - } else { - if (!trace_print_context(iter)) - goto partial; - } + if (iter->iter_flags & TRACE_FILE_LAT_FMT) + trace_print_lat_context(iter); + else + trace_print_context(iter); } + if (trace_seq_has_overflowed(s)) + return TRACE_TYPE_PARTIAL_LINE; +
[PATCH 13/26 v5] tracing: Fix return value of ftrace_raw_output_prep()
From: "Steven Rostedt (Red Hat)" If the trace_seq of ftrace_raw_output_prep() is full this function returns TRACE_TYPE_PARTIAL_LINE, otherwise it returns zero. The problem is that TRACE_TYPE_PARTIAL_LINE happens to be zero! The thing is, the caller of ftrace_raw_output_prep() expects a success to be zero. Change that to expect it to be TRACE_TYPE_HANDLED. Link: http://lkml.kernel.org/r/20141114112522.ga2...@dhcp128.suse.cz Reminded-by: Petr Mladek Signed-off-by: Steven Rostedt --- include/trace/ftrace.h | 2 +- kernel/trace/trace_output.c | 5 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h index f13471b5d27a..139b5067345b 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.h @@ -277,7 +277,7 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags,\ field = (typeof(field))iter->ent; \ \ ret = ftrace_raw_output_prep(iter, trace_event);\ - if (ret)\ + if (ret != TRACE_TYPE_HANDLED) \ return ret; \ \ trace_seq_printf(s, print); \ diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c index 163c11b6b8ff..723818bc83b4 100644 --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c @@ -196,10 +196,7 @@ int ftrace_raw_output_prep(struct trace_iterator *iter, trace_seq_init(p); trace_seq_printf(s, "%s: ", ftrace_event_name(event)); - if (trace_seq_has_overflowed(s)) - return TRACE_TYPE_PARTIAL_LINE; - - return 0; + return trace_handle_return(s); } EXPORT_SYMBOL(ftrace_raw_output_prep); -- 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/
[PATCH 05/26 v5] tracing: Have branch tracer use trace_handle_return() helper function
From: "Steven Rostedt (Red Hat)" The branch tracer should not be checking the trace_seq_printf() return value as that will soon be void. There's a new trace_handle_return() helper function that will return TRACE_TYPE_PARTIAL_LINE if the trace_seq overflowed and TRACE_TYPE_HANDLED otherwise. Reviewed-by: Petr Mladek Signed-off-by: Steven Rostedt --- kernel/trace/trace_branch.c | 15 +++ 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c index a3916f68a1c7..7d6e2afde669 100644 --- a/kernel/trace/trace_branch.c +++ b/kernel/trace/trace_branch.c @@ -151,14 +151,13 @@ static enum print_line_t trace_branch_print(struct trace_iterator *iter, trace_assign_type(field, iter->ent); - if (trace_seq_printf(&iter->seq, "[%s] %s:%s:%d\n", -field->correct ? " ok " : " MISS ", -field->func, -field->file, -field->line)) - return TRACE_TYPE_PARTIAL_LINE; - - return TRACE_TYPE_HANDLED; + trace_seq_printf(&iter->seq, "[%s] %s:%s:%d\n", +field->correct ? " ok " : " MISS ", +field->func, +field->file, +field->line); + + return trace_handle_return(&iter->seq); } static void branch_print_header(struct seq_file *s) -- 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/
[PATCH 04/26 v5] ring-buffer: Remove check of trace_seq_{puts,printf}() return values
From: "Steven Rostedt (Red Hat)" Remove checking the return value of all trace_seq_puts(). It was wrong anyway as only the last return value mattered. But as the trace_seq_puts() is going to be a void function in the future, we should not be checking the return value of it anyway. Just return !trace_seq_has_overflowed() instead. Reviewed-by: Petr Mladek Signed-off-by: Steven Rostedt --- kernel/trace/ring_buffer.c | 75 ++ 1 file changed, 36 insertions(+), 39 deletions(-) diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 2d75c94ae87d..a28bdd17c853 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -34,21 +34,19 @@ static void update_pages_handler(struct work_struct *work); */ int ring_buffer_print_entry_header(struct trace_seq *s) { - int ret; - - ret = trace_seq_puts(s, "# compressed entry header\n"); - ret = trace_seq_puts(s, "\ttype_len:5 bits\n"); - ret = trace_seq_puts(s, "\ttime_delta : 27 bits\n"); - ret = trace_seq_puts(s, "\tarray : 32 bits\n"); - ret = trace_seq_putc(s, '\n'); - ret = trace_seq_printf(s, "\tpadding : type == %d\n", - RINGBUF_TYPE_PADDING); - ret = trace_seq_printf(s, "\ttime_extend : type == %d\n", - RINGBUF_TYPE_TIME_EXTEND); - ret = trace_seq_printf(s, "\tdata max type_len == %d\n", - RINGBUF_TYPE_DATA_TYPE_LEN_MAX); + trace_seq_puts(s, "# compressed entry header\n"); + trace_seq_puts(s, "\ttype_len:5 bits\n"); + trace_seq_puts(s, "\ttime_delta : 27 bits\n"); + trace_seq_puts(s, "\tarray : 32 bits\n"); + trace_seq_putc(s, '\n'); + trace_seq_printf(s, "\tpadding : type == %d\n", +RINGBUF_TYPE_PADDING); + trace_seq_printf(s, "\ttime_extend : type == %d\n", +RINGBUF_TYPE_TIME_EXTEND); + trace_seq_printf(s, "\tdata max type_len == %d\n", +RINGBUF_TYPE_DATA_TYPE_LEN_MAX); - return ret; + return !trace_seq_has_overflowed(s); } /* @@ -419,32 +417,31 @@ static inline int test_time_stamp(u64 delta) int ring_buffer_print_page_header(struct trace_seq *s) { struct buffer_data_page field; - int ret; - - ret = trace_seq_printf(s, "\tfield: u64 timestamp;\t" - "offset:0;\tsize:%u;\tsigned:%u;\n", - (unsigned int)sizeof(field.time_stamp), - (unsigned int)is_signed_type(u64)); - - ret = trace_seq_printf(s, "\tfield: local_t commit;\t" - "offset:%u;\tsize:%u;\tsigned:%u;\n", - (unsigned int)offsetof(typeof(field), commit), - (unsigned int)sizeof(field.commit), - (unsigned int)is_signed_type(long)); - - ret = trace_seq_printf(s, "\tfield: int overwrite;\t" - "offset:%u;\tsize:%u;\tsigned:%u;\n", - (unsigned int)offsetof(typeof(field), commit), - 1, - (unsigned int)is_signed_type(long)); - - ret = trace_seq_printf(s, "\tfield: char data;\t" - "offset:%u;\tsize:%u;\tsigned:%u;\n", - (unsigned int)offsetof(typeof(field), data), - (unsigned int)BUF_PAGE_SIZE, - (unsigned int)is_signed_type(char)); - return ret; + trace_seq_printf(s, "\tfield: u64 timestamp;\t" +"offset:0;\tsize:%u;\tsigned:%u;\n", +(unsigned int)sizeof(field.time_stamp), +(unsigned int)is_signed_type(u64)); + + trace_seq_printf(s, "\tfield: local_t commit;\t" +"offset:%u;\tsize:%u;\tsigned:%u;\n", +(unsigned int)offsetof(typeof(field), commit), +(unsigned int)sizeof(field.commit), +(unsigned int)is_signed_type(long)); + + trace_seq_printf(s, "\tfield: int overwrite;\t" +"offset:%u;\tsize:%u;\tsigned:%u;\n", +(unsigned int)offsetof(typeof(field), commit), +1, +(unsigned int)is_signed_type(long)); + + trace_seq_printf(s, "\tfield: char data;\t" +"offset:%u;\tsize:%u;\tsigned:%u;\n", +(unsigned int)offsetof(typeof(field), data), +(unsigned int)BUF_PAGE_SIZE, +(unsigned int)is_signed_type(char)); + + return !trace_seq_has_overflowed(s); } struct rb_irq_work { -- 2.1.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the bo
[PATCH 10/26 v5] tracing/uprobes: Do not use return values of trace_seq_printf()
From: "Steven Rostedt (Red Hat)" The functions trace_seq_printf() and friends will soon no longer have return values. Using trace_seq_has_overflowed() and trace_handle_return() should be used instead. Link: http://lkml.kernel.org/r/20141114011411.693008...@goodmis.org Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Srikar Dronamraju Signed-off-by: Steven Rostedt --- kernel/trace/trace_uprobe.c | 23 ++- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c index e35327c787f7..fd76f8e108ef 100644 --- a/kernel/trace/trace_uprobe.c +++ b/kernel/trace/trace_uprobe.c @@ -852,16 +852,14 @@ print_uprobe_event(struct trace_iterator *iter, int flags, struct trace_event *e tu = container_of(event, struct trace_uprobe, tp.call.event); if (is_ret_probe(tu)) { - if (!trace_seq_printf(s, "%s: (0x%lx <- 0x%lx)", - ftrace_event_name(&tu->tp.call), - entry->vaddr[1], entry->vaddr[0])) - goto partial; + trace_seq_printf(s, "%s: (0x%lx <- 0x%lx)", +ftrace_event_name(&tu->tp.call), +entry->vaddr[1], entry->vaddr[0]); data = DATAOF_TRACE_ENTRY(entry, true); } else { - if (!trace_seq_printf(s, "%s: (0x%lx)", - ftrace_event_name(&tu->tp.call), - entry->vaddr[0])) - goto partial; + trace_seq_printf(s, "%s: (0x%lx)", +ftrace_event_name(&tu->tp.call), +entry->vaddr[0]); data = DATAOF_TRACE_ENTRY(entry, false); } @@ -869,14 +867,13 @@ print_uprobe_event(struct trace_iterator *iter, int flags, struct trace_event *e struct probe_arg *parg = &tu->tp.args[i]; if (!parg->type->print(s, parg->name, data + parg->offset, entry)) - goto partial; + goto out; } - if (trace_seq_putc(s, '\n')) - return TRACE_TYPE_HANDLED; + trace_seq_putc(s, '\n'); -partial: - return TRACE_TYPE_PARTIAL_LINE; + out: + return trace_handle_return(s); } typedef bool (*filter_func_t)(struct uprobe_consumer *self, -- 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/
[PATCH 08/26 v5] tracing: Do not check return values of trace_seq_p*() for mmio tracer
From: "Steven Rostedt (Red Hat)" The return values for trace_seq_printf() and friends are going to be removed and they will become void functions. The mmio tracer checked their return and even did so incorrectly. Some of the funtions which returned the values were never checked themselves. Removing all the checks simplifies the code. Use trace_seq_has_overflowed() and trace_handle_return() where necessary instead. Signed-off-by: Steven Rostedt --- kernel/trace/trace_mmiotrace.c | 52 +- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c index 0abd9b863474..7a9ba62e9fef 100644 --- a/kernel/trace/trace_mmiotrace.c +++ b/kernel/trace/trace_mmiotrace.c @@ -59,17 +59,15 @@ static void mmio_trace_start(struct trace_array *tr) mmio_reset_data(tr); } -static int mmio_print_pcidev(struct trace_seq *s, const struct pci_dev *dev) +static void mmio_print_pcidev(struct trace_seq *s, const struct pci_dev *dev) { - int ret = 0; int i; resource_size_t start, end; const struct pci_driver *drv = pci_dev_driver(dev); - /* XXX: incomplete checks for trace_seq_printf() return value */ - ret += trace_seq_printf(s, "PCIDEV %02x%02x %04x%04x %x", - dev->bus->number, dev->devfn, - dev->vendor, dev->device, dev->irq); + trace_seq_printf(s, "PCIDEV %02x%02x %04x%04x %x", +dev->bus->number, dev->devfn, +dev->vendor, dev->device, dev->irq); /* * XXX: is pci_resource_to_user() appropriate, since we are * supposed to interpret the __ioremap() phys_addr argument based on @@ -77,21 +75,20 @@ static int mmio_print_pcidev(struct trace_seq *s, const struct pci_dev *dev) */ for (i = 0; i < 7; i++) { pci_resource_to_user(dev, i, &dev->resource[i], &start, &end); - ret += trace_seq_printf(s, " %llx", + trace_seq_printf(s, " %llx", (unsigned long long)(start | (dev->resource[i].flags & PCI_REGION_FLAG_MASK))); } for (i = 0; i < 7; i++) { pci_resource_to_user(dev, i, &dev->resource[i], &start, &end); - ret += trace_seq_printf(s, " %llx", + trace_seq_printf(s, " %llx", dev->resource[i].start < dev->resource[i].end ? (unsigned long long)(end - start) + 1 : 0); } if (drv) - ret += trace_seq_printf(s, " %s\n", drv->name); + trace_seq_printf(s, " %s\n", drv->name); else - ret += trace_seq_puts(s, " \n"); - return ret; + trace_seq_puts(s, " \n"); } static void destroy_header_iter(struct header_iter *hiter) @@ -179,28 +176,27 @@ static enum print_line_t mmio_print_rw(struct trace_iterator *iter) unsigned long long t= ns2usecs(iter->ts); unsigned long usec_rem = do_div(t, USEC_PER_SEC); unsigned secs = (unsigned long)t; - int ret = 1; trace_assign_type(field, entry); rw = &field->rw; switch (rw->opcode) { case MMIO_READ: - ret = trace_seq_printf(s, + trace_seq_printf(s, "R %d %u.%06lu %d 0x%llx 0x%lx 0x%lx %d\n", rw->width, secs, usec_rem, rw->map_id, (unsigned long long)rw->phys, rw->value, rw->pc, 0); break; case MMIO_WRITE: - ret = trace_seq_printf(s, + trace_seq_printf(s, "W %d %u.%06lu %d 0x%llx 0x%lx 0x%lx %d\n", rw->width, secs, usec_rem, rw->map_id, (unsigned long long)rw->phys, rw->value, rw->pc, 0); break; case MMIO_UNKNOWN_OP: - ret = trace_seq_printf(s, + trace_seq_printf(s, "UNKNOWN %u.%06lu %d 0x%llx %02lx,%02lx," "%02lx 0x%lx %d\n", secs, usec_rem, rw->map_id, @@ -209,12 +205,11 @@ static enum print_line_t mmio_print_rw(struct trace_iterator *iter) (rw->value >> 0) & 0xff, rw->pc, 0); break; default: - ret = trace_seq_puts(s, "rw what?\n"); + trace_seq_puts(s, "rw what?\n"); break; } - if (ret) - return TRACE_TYPE_HANDLED; - return TRACE_TYPE_PARTIAL_LINE; + + return trace_handle_return(s); } static enum print_line_t mmio_print_map(struct trace_iterator *iter) @@ -226,31 +221,29 @@ static enum print_line_t mmio_print_map(struct trace_iterator *iter) unsigned long long t= ns2usecs(iter->ts); unsigned
[PATCH 11/26 v5] tracing: Do not use return values of trace_seq_printf() in syscall tracing
From: "Steven Rostedt (Red Hat)" The functions trace_seq_printf() and friends will not be returning values soon and will be void functions. To know if they succeeded or not, the functions trace_seq_has_overflowed() and trace_handle_return() should be used instead. Reviewed-by: Petr Mladek Signed-off-by: Steven Rostedt --- kernel/trace/trace_syscalls.c | 43 +++ 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c index 4dc8b79c5f75..2193e8038681 100644 --- a/kernel/trace/trace_syscalls.c +++ b/kernel/trace/trace_syscalls.c @@ -114,7 +114,7 @@ print_syscall_enter(struct trace_iterator *iter, int flags, struct trace_entry *ent = iter->ent; struct syscall_trace_enter *trace; struct syscall_metadata *entry; - int i, ret, syscall; + int i, syscall; trace = (typeof(trace))ent; syscall = trace->nr; @@ -128,35 +128,24 @@ print_syscall_enter(struct trace_iterator *iter, int flags, goto end; } - ret = trace_seq_printf(s, "%s(", entry->name); - if (!ret) - return TRACE_TYPE_PARTIAL_LINE; + trace_seq_printf(s, "%s(", entry->name); for (i = 0; i < entry->nb_args; i++) { /* parameter types */ - if (trace_flags & TRACE_ITER_VERBOSE) { - ret = trace_seq_printf(s, "%s ", entry->types[i]); - if (!ret) - return TRACE_TYPE_PARTIAL_LINE; - } + if (trace_flags & TRACE_ITER_VERBOSE) + trace_seq_printf(s, "%s ", entry->types[i]); + /* parameter values */ - ret = trace_seq_printf(s, "%s: %lx%s", entry->args[i], - trace->args[i], - i == entry->nb_args - 1 ? "" : ", "); - if (!ret) - return TRACE_TYPE_PARTIAL_LINE; + trace_seq_printf(s, "%s: %lx%s", entry->args[i], +trace->args[i], +i == entry->nb_args - 1 ? "" : ", "); } - ret = trace_seq_putc(s, ')'); - if (!ret) - return TRACE_TYPE_PARTIAL_LINE; - + trace_seq_putc(s, ')'); end: - ret = trace_seq_putc(s, '\n'); - if (!ret) - return TRACE_TYPE_PARTIAL_LINE; + trace_seq_putc(s, '\n'); - return TRACE_TYPE_HANDLED; + return trace_handle_return(s); } static enum print_line_t @@ -168,7 +157,6 @@ print_syscall_exit(struct trace_iterator *iter, int flags, struct syscall_trace_exit *trace; int syscall; struct syscall_metadata *entry; - int ret; trace = (typeof(trace))ent; syscall = trace->nr; @@ -176,7 +164,7 @@ print_syscall_exit(struct trace_iterator *iter, int flags, if (!entry) { trace_seq_putc(s, '\n'); - return TRACE_TYPE_HANDLED; + goto out; } if (entry->exit_event->event.type != ent->type) { @@ -184,12 +172,11 @@ print_syscall_exit(struct trace_iterator *iter, int flags, return TRACE_TYPE_UNHANDLED; } - ret = trace_seq_printf(s, "%s -> 0x%lx\n", entry->name, + trace_seq_printf(s, "%s -> 0x%lx\n", entry->name, trace->ret); - if (!ret) - return TRACE_TYPE_PARTIAL_LINE; - return TRACE_TYPE_HANDLED; + out: + return trace_handle_return(s); } extern char *__bad_type_size(void); -- 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/
[PATCH 00/26 v5] trace-seq/seq-buf/x86/printk: Print all stacks from NMI safely
Version 5! Full diff between v4 and v5 will be replied to this email. Here's the summary of the differences since version 4: . Various clean ups . Added trace_seq_used() to be used instead of s->seq.len . Used seq_buf_used() instead of s->len . Fixed output of ftrace_raw_output_prep() as well as caller code . Fixed up tracing_fill_pipe_page() The logic was a bit whacky and this was needed when introducing trace_seq_used() . Rebased on latest ftrace/core code . Fixed uprobe to be like probe code in print_uprobe_event() . Introduced new seq_buf_can_fit() to remove the likelyhood of screwing up the s->len + * < s->size code. Now it's just seq_buf_can_fit(s, len) which will tell us if the len can still fit in the buffer. Enjoy, -- Steve Steven Rostedt (Red Hat) (26): tracing: Fix trace_seq_bitmask() to start at current position tracing: Add trace_seq_has_overflowed() and trace_handle_return() blktrace/tracing: Use trace_seq_has_overflowed() helper function ring-buffer: Remove check of trace_seq_{puts,printf}() return values tracing: Have branch tracer use trace_handle_return() helper function tracing: Have function_graph use trace_seq_has_overflowed() kprobes/tracing: Use trace_seq_has_overflowed() for overflow checks tracing: Do not check return values of trace_seq_p*() for mmio tracer tracing/probes: Do not use return value of trace_seq_printf() tracing/uprobes: Do not use return values of trace_seq_printf() tracing: Do not use return values of trace_seq_printf() in syscall tracing tracing: Remove return values of most trace_seq_*() functions tracing: Fix return value of ftrace_raw_output_prep() tracing: Create seq_buf layer in trace_seq tracing: Convert seq_buf_path() to be like seq_path() tracing: Convert seq_buf fields to be like seq_file fields tracing: Add a seq_buf_clear() helper and clear len and readpos in init seq_buf: Create seq_buf_used() to find out how much was written tracing: Use trace_seq_used() and seq_buf_used() instead of len seq_buf: Add seq_buf_can_fit() helper function tracing: Have seq_buf use full buffer tracing: Add seq_buf_get_buf() and seq_buf_commit() helper functions seq-buf: Make seq_buf_bprintf() conditional on CONFIG_BINARY_PRINTF seq_buf: Move the seq_buf code to lib/ printk: Add per_cpu printk func to allow printk to be diverted x86/nmi: Perform a safe NMI stack trace on all CPUs arch/x86/kernel/apic/hw_nmi.c| 91 +++- include/linux/ftrace_event.h | 11 + include/linux/percpu.h | 3 + include/linux/printk.h | 2 + include/linux/seq_buf.h | 136 include/linux/trace_seq.h| 77 --- include/trace/ftrace.h | 8 +- kernel/printk/printk.c | 38 +++- kernel/trace/blktrace.c | 148 ++--- kernel/trace/ring_buffer.c | 75 +++ kernel/trace/trace.c | 126 ++- kernel/trace/trace.h | 3 +- kernel/trace/trace_branch.c | 15 +- kernel/trace/trace_events.c | 9 +- kernel/trace/trace_functions_graph.c | 393 +++-- kernel/trace/trace_kprobe.c | 42 ++-- kernel/trace/trace_mmiotrace.c | 52 ++--- kernel/trace/trace_output.c | 417 ++- kernel/trace/trace_output.h | 16 +- kernel/trace/trace_probe.c | 10 +- kernel/trace/trace_seq.c | 253 + kernel/trace/trace_syscalls.c| 43 ++-- kernel/trace/trace_uprobe.c | 23 +- lib/Makefile | 2 +- lib/seq_buf.c| 351 + 25 files changed, 1323 insertions(+), 1021 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 09/26 v5] tracing/probes: Do not use return value of trace_seq_printf()
From: "Steven Rostedt (Red Hat)" The functions trace_seq_printf() and friends will soon not have a return value and will only be a void function. Use trace_seq_has_overflowed() instead to know if the trace_seq operations succeeded or not. Link: http://lkml.kernel.org/r/20141114011411.530216...@goodmis.org Cc: Namhyung Kim Acked-by: Masami Hiramatsu Signed-off-by: Steven Rostedt --- kernel/trace/trace_probe.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index d4b9fc22cd27..b983b2fd2ca1 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -40,7 +40,8 @@ const char *reserved_field_names[] = { int PRINT_TYPE_FUNC_NAME(type)(struct trace_seq *s, const char *name, \ void *data, void *ent) \ { \ - return trace_seq_printf(s, " %s=" fmt, name, *(type *)data);\ + trace_seq_printf(s, " %s=" fmt, name, *(type *)data); \ + return !trace_seq_has_overflowed(s);\ } \ const char PRINT_TYPE_FMT_NAME(type)[] = fmt; \ NOKPROBE_SYMBOL(PRINT_TYPE_FUNC_NAME(type)); @@ -61,10 +62,11 @@ int PRINT_TYPE_FUNC_NAME(string)(struct trace_seq *s, const char *name, int len = *(u32 *)data >> 16; if (!len) - return trace_seq_printf(s, " %s=(fault)", name); + trace_seq_printf(s, " %s=(fault)", name); else - return trace_seq_printf(s, " %s=\"%s\"", name, - (const char *)get_loc_data(data, ent)); + trace_seq_printf(s, " %s=\"%s\"", name, +(const char *)get_loc_data(data, ent)); + return !trace_seq_has_overflowed(s); } NOKPROBE_SYMBOL(PRINT_TYPE_FUNC_NAME(string)); -- 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/
[PATCH 18/26 v5] seq_buf: Create seq_buf_used() to find out how much was written
From: "Steven Rostedt (Red Hat)" Add a helper function seq_buf_used() that replaces the SEQ_BUF_USED() private macro to let callers have a method to know how much of the seq_buf was written to. Link: http://lkml.kernel.org/r/20141114011412.170377...@goodmis.org Link: http://lkml.kernel.org/r/20141114011413.321654...@goodmis.org Signed-off-by: Steven Rostedt --- include/linux/seq_buf.h | 6 ++ kernel/trace/seq_buf.c | 5 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h index 5d91262433e2..93718e570d4c 100644 --- a/include/linux/seq_buf.h +++ b/include/linux/seq_buf.h @@ -64,6 +64,12 @@ seq_buf_buffer_left(struct seq_buf *s) return (s->size - 1) - s->len; } +/* How much buffer was written? */ +static inline unsigned int seq_buf_used(struct seq_buf *s) +{ + return min(s->len, s->size); +} + extern __printf(2, 3) int seq_buf_printf(struct seq_buf *s, const char *fmt, ...); extern __printf(2, 0) diff --git a/kernel/trace/seq_buf.c b/kernel/trace/seq_buf.c index 7dac34d1235b..9ec5305d9da7 100644 --- a/kernel/trace/seq_buf.c +++ b/kernel/trace/seq_buf.c @@ -16,9 +16,6 @@ #include #include -/* How much buffer is written? */ -#define SEQ_BUF_USED(s) min((s)->len, (s)->size - 1) - /** * seq_buf_print_seq - move the contents of seq_buf into a seq_file * @m: the seq_file descriptor that is the destination @@ -28,7 +25,7 @@ */ int seq_buf_print_seq(struct seq_file *m, struct seq_buf *s) { - unsigned int len = SEQ_BUF_USED(s); + unsigned int len = seq_buf_used(s); return seq_write(m, s->buffer, len); } -- 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/
[PATCH 16/26 v5] tracing: Convert seq_buf fields to be like seq_file fields
From: "Steven Rostedt (Red Hat)" In facilitating the conversion of seq_file to use seq_buf, have the seq_buf fields match the types used by seq_file. Link: http://lkml.kernel.org/r/20141104160222.195301...@goodmis.org Tested-by: Jiri Kosina Acked-by: Jiri Kosina Reviewed-by: Petr Mladek Signed-off-by: Steven Rostedt --- include/linux/seq_buf.h | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h index 38770688a627..d14dc9023dde 100644 --- a/include/linux/seq_buf.h +++ b/include/linux/seq_buf.h @@ -16,10 +16,10 @@ * @readpos: The next position to read in the buffer. */ struct seq_buf { - unsigned char *buffer; - unsigned intsize; - unsigned intlen; - unsigned intreadpos; + char*buffer; + size_t size; + size_t len; + loff_t readpos; }; static inline void -- 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/
[PATCH 15/26 v5] tracing: Convert seq_buf_path() to be like seq_path()
From: "Steven Rostedt (Red Hat)" Rewrite seq_buf_path() like it is done in seq_path() and allow it to accept any escape character instead of just "\n". Making seq_buf_path() like seq_path() will help prevent problems when converting seq_file to use the seq_buf logic. Link: http://lkml.kernel.org/r/20141104160222.048795...@goodmis.org Link: http://lkml.kernel.org/r/20141114011412.338523...@goodmis.org Tested-by: Jiri Kosina Acked-by: Jiri Kosina Reviewed-by: Petr Mladek Signed-off-by: Steven Rostedt --- include/linux/seq_buf.h | 2 +- kernel/trace/seq_buf.c | 28 kernel/trace/trace_seq.c | 4 ++-- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h index 4f7a96a9d71a..38770688a627 100644 --- a/include/linux/seq_buf.h +++ b/include/linux/seq_buf.h @@ -73,7 +73,7 @@ extern int seq_buf_putc(struct seq_buf *s, unsigned char c); extern int seq_buf_putmem(struct seq_buf *s, const void *mem, unsigned int len); extern int seq_buf_putmem_hex(struct seq_buf *s, const void *mem, unsigned int len); -extern int seq_buf_path(struct seq_buf *s, const struct path *path); +extern int seq_buf_path(struct seq_buf *s, const struct path *path, const char *esc); extern int seq_buf_bitmask(struct seq_buf *s, const unsigned long *maskp, int nmaskbits); diff --git a/kernel/trace/seq_buf.c b/kernel/trace/seq_buf.c index e9a7861595d2..7dac34d1235b 100644 --- a/kernel/trace/seq_buf.c +++ b/kernel/trace/seq_buf.c @@ -272,28 +272,32 @@ int seq_buf_putmem_hex(struct seq_buf *s, const void *mem, * seq_buf_path - copy a path into the sequence buffer * @s: seq_buf descriptor * @path: path to write into the sequence buffer. + * @esc: set of characters to escape in the output * * Write a path name into the sequence buffer. * - * Returns zero on success, -1 on overflow + * Returns the number of written bytes on success, -1 on overflow */ -int seq_buf_path(struct seq_buf *s, const struct path *path) +int seq_buf_path(struct seq_buf *s, const struct path *path, const char *esc) { - unsigned int len = seq_buf_buffer_left(s); - unsigned char *p; + char *buf = s->buffer + s->len; + size_t size = seq_buf_buffer_left(s); + int res = -1; WARN_ON(s->size == 0); - p = d_path(path, s->buffer + s->len, len); - if (!IS_ERR(p)) { - p = mangle_path(s->buffer + s->len, p, "\n"); - if (p) { - s->len = p - s->buffer; - return 0; + if (size) { + char *p = d_path(path, buf, size); + if (!IS_ERR(p)) { + char *end = mangle_path(buf, p, esc); + if (end) + res = end - buf; } } - seq_buf_set_overflow(s); - return -1; + if (res > 0) + s->len += res; + + return res; } /** diff --git a/kernel/trace/trace_seq.c b/kernel/trace/trace_seq.c index b623b7295864..087fa514069d 100644 --- a/kernel/trace/trace_seq.c +++ b/kernel/trace/trace_seq.c @@ -339,7 +339,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path) return 0; } - ret = seq_buf_path(&s->seq, path); + ret = seq_buf_path(&s->seq, path, "\n"); if (unlikely(seq_buf_has_overflowed(&s->seq))) { s->seq.len = save_len; @@ -347,7 +347,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path) return 0; } - return ret; + return 1; } EXPORT_SYMBOL_GPL(trace_seq_path); -- 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/
[PATCH 14/26 v5] tracing: Create seq_buf layer in trace_seq
From: "Steven Rostedt (Red Hat)" Create a seq_buf layer that trace_seq sits on. The seq_buf will not be limited to page size. This will allow other usages of seq_buf instead of a hard set PAGE_SIZE one that trace_seq has. Link: http://lkml.kernel.org/r/20141104160221.864997...@goodmis.org Link: http://lkml.kernel.org/r/20141114011412.170377...@goodmis.org Tested-by: Jiri Kosina Acked-by: Jiri Kosina Reviewed-by: Petr Mladek Signed-off-by: Steven Rostedt --- include/linux/seq_buf.h | 81 + include/linux/trace_seq.h| 12 +- kernel/trace/Makefile| 1 + kernel/trace/seq_buf.c | 341 +++ kernel/trace/trace.c | 39 ++-- kernel/trace/trace_events.c | 6 +- kernel/trace/trace_functions_graph.c | 6 +- kernel/trace/trace_seq.c | 177 +- 8 files changed, 538 insertions(+), 125 deletions(-) create mode 100644 include/linux/seq_buf.h create mode 100644 kernel/trace/seq_buf.c diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h new file mode 100644 index ..4f7a96a9d71a --- /dev/null +++ b/include/linux/seq_buf.h @@ -0,0 +1,81 @@ +#ifndef _LINUX_SEQ_BUF_H +#define _LINUX_SEQ_BUF_H + +#include + +/* + * Trace sequences are used to allow a function to call several other functions + * to create a string of data to use. + */ + +/** + * seq_buf - seq buffer structure + * @buffer:pointer to the buffer + * @size: size of the buffer + * @len: the amount of data inside the buffer + * @readpos: The next position to read in the buffer. + */ +struct seq_buf { + unsigned char *buffer; + unsigned intsize; + unsigned intlen; + unsigned intreadpos; +}; + +static inline void +seq_buf_init(struct seq_buf *s, unsigned char *buf, unsigned int size) +{ + s->buffer = buf; + s->size = size; + s->len = 0; + s->readpos = 0; +} + +/* + * seq_buf have a buffer that might overflow. When this happens + * the len and size are set to be equal. + */ +static inline bool +seq_buf_has_overflowed(struct seq_buf *s) +{ + return s->len == s->size; +} + +static inline void +seq_buf_set_overflow(struct seq_buf *s) +{ + s->len = s->size; +} + +/* + * How much buffer is left on the seq_buf? + */ +static inline unsigned int +seq_buf_buffer_left(struct seq_buf *s) +{ + if (seq_buf_has_overflowed(s)) + return 0; + + return (s->size - 1) - s->len; +} + +extern __printf(2, 3) +int seq_buf_printf(struct seq_buf *s, const char *fmt, ...); +extern __printf(2, 0) +int seq_buf_vprintf(struct seq_buf *s, const char *fmt, va_list args); +extern int +seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary); +extern int seq_buf_print_seq(struct seq_file *m, struct seq_buf *s); +extern int seq_buf_to_user(struct seq_buf *s, char __user *ubuf, + int cnt); +extern int seq_buf_puts(struct seq_buf *s, const char *str); +extern int seq_buf_putc(struct seq_buf *s, unsigned char c); +extern int seq_buf_putmem(struct seq_buf *s, const void *mem, unsigned int len); +extern int seq_buf_putmem_hex(struct seq_buf *s, const void *mem, + unsigned int len); +extern int seq_buf_path(struct seq_buf *s, const struct path *path); + +extern int seq_buf_bitmask(struct seq_buf *s, const unsigned long *maskp, + int nmaskbits); + +#endif /* _LINUX_SEQ_BUF_H */ diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h index db8a73224f1a..85d37106be3d 100644 --- a/include/linux/trace_seq.h +++ b/include/linux/trace_seq.h @@ -1,7 +1,7 @@ #ifndef _LINUX_TRACE_SEQ_H #define _LINUX_TRACE_SEQ_H -#include +#include #include @@ -12,16 +12,14 @@ struct trace_seq { unsigned char buffer[PAGE_SIZE]; - unsigned intlen; - unsigned intreadpos; + struct seq_buf seq; int full; }; static inline void trace_seq_init(struct trace_seq *s) { - s->len = 0; - s->readpos = 0; + seq_buf_init(&s->seq, s->buffer, PAGE_SIZE); s->full = 0; } @@ -37,7 +35,7 @@ trace_seq_init(struct trace_seq *s) static inline unsigned char * trace_seq_buffer_ptr(struct trace_seq *s) { - return s->buffer + s->len; + return s->buffer + s->seq.len; } /** @@ -49,7 +47,7 @@ trace_seq_buffer_ptr(struct trace_seq *s) */ static inline bool trace_seq_has_overflowed(struct trace_seq *s) { - return s->full || s->len > PAGE_SIZE - 1; + return s->full || seq_buf_has_overflowed(&s->seq); } /* diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile index 67d6369ddf83..edc98c72a634 100644 --- a/kernel/trace/Makefile +++ b/kernel/trace/Makefile @@ -29,6 +29,7 @@ obj-$(CONFIG_RING_BUFFER_BENCHMARK) += ring_buffer_benchmark.o obj-$(CONFIG_TRACING
[PATCH 17/26 v5] tracing: Add a seq_buf_clear() helper and clear len and readpos in init
From: "Steven Rostedt (Red Hat)" Add a helper function seq_buf_clear() that resets the len and readpos fields of a seq_buf. Currently it is only used in the seq_buf_init() but will be used later when updating the seq_file code. Link: http://lkml.kernel.org/r/20141104160222.352309...@goodmis.org Tested-by: Jiri Kosina Acked-by: Jiri Kosina Reviewed-by: Petr Mladek Signed-off-by: Steven Rostedt --- include/linux/seq_buf.h | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h index d14dc9023dde..5d91262433e2 100644 --- a/include/linux/seq_buf.h +++ b/include/linux/seq_buf.h @@ -22,13 +22,18 @@ struct seq_buf { loff_t readpos; }; +static inline void seq_buf_clear(struct seq_buf *s) +{ + s->len = 0; + s->readpos = 0; +} + static inline void seq_buf_init(struct seq_buf *s, unsigned char *buf, unsigned int size) { s->buffer = buf; s->size = size; - s->len = 0; - s->readpos = 0; + seq_buf_clear(s); } /* -- 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/
Re: [PATCH 00/26 v5] trace-seq/seq-buf/x86/printk: Print all stacks from NMI safely
On Fri, 14 Nov 2014 23:58:47 -0500 Steven Rostedt wrote: > Version 5! > > Full diff between v4 and v5 will be replied to this email. > Here it is: -- Steve diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h index da211dfbcebe..9aafe0e24c68 100644 --- a/include/linux/seq_buf.h +++ b/include/linux/seq_buf.h @@ -67,7 +67,7 @@ seq_buf_buffer_left(struct seq_buf *s) /* How much buffer was written? */ static inline unsigned int seq_buf_used(struct seq_buf *s) { - return min((s)->len, (s)->size); + return min(s->len, s->size); } /** @@ -105,7 +105,8 @@ static inline void seq_buf_commit(struct seq_buf *s, int num) if (num < 0) { seq_buf_set_overflow(s); } else { - BUG_ON(s->len + num > s->size + 1); + /* num must be negative on overflow */ + BUG_ON(s->len + num > s->size); s->len += num; } } diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h index 85d37106be3d..cfaf5a1d4bad 100644 --- a/include/linux/trace_seq.h +++ b/include/linux/trace_seq.h @@ -24,6 +24,24 @@ trace_seq_init(struct trace_seq *s) } /** + * trace_seq_used - amount of actual data written to buffer + * @s: trace sequence descriptor + * + * Returns the amount of data written to the buffer. + * + * IMPORTANT! + * + * Use this instead of @s->seq.len if you need to pass the amount + * of data from the buffer to another buffer (userspace, or what not). + * The @s->seq.len on overflow is bigger than the buffer size and + * using it can cause access to undefined memory. + */ +static inline int trace_seq_used(struct trace_seq *s) +{ + return seq_buf_used(&s->seq); +} + +/** * trace_seq_buffer_ptr - return pointer to next location in buffer * @s: trace sequence descriptor * @@ -35,7 +53,7 @@ trace_seq_init(struct trace_seq *s) static inline unsigned char * trace_seq_buffer_ptr(struct trace_seq *s) { - return s->buffer + s->seq.len; + return s->buffer + seq_buf_used(&s->seq); } /** diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h index f13471b5d27a..139b5067345b 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.h @@ -277,7 +277,7 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags,\ field = (typeof(field))iter->ent; \ \ ret = ftrace_raw_output_prep(iter, trace_event);\ - if (ret)\ + if (ret != TRACE_TYPE_HANDLED) \ return ret; \ \ trace_seq_printf(s, print); \ diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 7d7a07e9b9e9..9f1ffc707f3b 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -944,10 +944,10 @@ static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt) { int len; - if (s->seq.len <= s->seq.readpos) + if (trace_seq_used(s) <= s->seq.readpos) return -EBUSY; - len = s->seq.len - s->seq.readpos; + len = trace_seq_used(s) - s->seq.readpos; if (cnt > len) cnt = len; memcpy(buf, s->buffer + s->seq.readpos, cnt); @@ -4514,18 +4514,18 @@ waitagain: trace_access_lock(iter->cpu_file); while (trace_find_next_entry_inc(iter) != NULL) { enum print_line_t ret; - int len = iter->seq.seq.len; + int save_len = iter->seq.seq.len; ret = print_trace_line(iter); if (ret == TRACE_TYPE_PARTIAL_LINE) { /* don't print partial lines */ - iter->seq.seq.len = len; + iter->seq.seq.len = save_len; break; } if (ret != TRACE_TYPE_NO_CONSUME) trace_consume(iter); - if (iter->seq.seq.len >= cnt) + if (trace_seq_used(&iter->seq) >= cnt) break; /* @@ -4541,7 +4541,7 @@ waitagain: /* Now copy what we have to the user */ sret = trace_seq_to_user(&iter->seq, ubuf, cnt); - if (iter->seq.seq.readpos >= iter->seq.seq.len) + if (iter->seq.seq.readpos >= trace_seq_used(&iter->seq)) trace_seq_init(&iter->seq); /* @@ -4575,20 +4575,33 @@ static size_t tracing_fill_pipe_page(size_t rem, struct trace_iterator *iter) { size_t count; + int save_len; int ret; /* Seq buffer is page-sized, exactly what we need. */ for (;;) { - count = iter->seq.seq.len; + save_len = iter->seq.seq.len; ret = pr
[PATCH 01/26 v5] tracing: Fix trace_seq_bitmask() to start at current position
From: "Steven Rostedt (Red Hat)" In trace_seq_bitmask() it calls bitmap_scnprintf() not from the current position of the trace_seq buffer (s->buffer + s->len), but instead from the beginning of the buffer (s->buffer). Luckily, the only user of this "ipi_raise tracepoint" uses it as the first parameter, and as such, the start of the temp buffer in include/trace/ftrace.h (see __get_bitmask()). Reported-by: Petr Mladek Reviewed-by: Petr Mladek Signed-off-by: Steven Rostedt --- kernel/trace/trace_seq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace_seq.c b/kernel/trace/trace_seq.c index 1f24ed99dca2..b100994a17fe 100644 --- a/kernel/trace/trace_seq.c +++ b/kernel/trace/trace_seq.c @@ -122,7 +122,7 @@ int trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, if (s->full || !len) return 0; - ret = bitmap_scnprintf(s->buffer, len, maskp, nmaskbits); + ret = bitmap_scnprintf(s->buffer + s->len, len, maskp, nmaskbits); s->len += ret; return 1; -- 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/
[PATCH 22/26 v5] tracing: Add seq_buf_get_buf() and seq_buf_commit() helper functions
From: "Steven Rostedt (Red Hat)" Add two helper functions; seq_buf_get_buf() and seq_buf_commit() that are used by seq_buf_path(). This makes the code similar to the seq_file: seq_path() function, and will help to be able to consolidate the functions between seq_file and trace_seq. Link: http://lkml.kernel.org/r/20141104160222.644881...@goodmis.org Link: http://lkml.kernel.org/r/20141114011412.977571...@goodmis.org Tested-by: Jiri Kosina Acked-by: Jiri Kosina Reviewed-by: Petr Mladek Signed-off-by: Steven Rostedt --- include/linux/seq_buf.h | 41 + kernel/trace/seq_buf.c | 7 +++ 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h index 0800a24b4348..12c64282aa98 100644 --- a/include/linux/seq_buf.h +++ b/include/linux/seq_buf.h @@ -70,6 +70,47 @@ static inline unsigned int seq_buf_used(struct seq_buf *s) return min(s->len, s->size); } +/** + * seq_buf_get_buf - get buffer to write arbitrary data to + * @s: the seq_buf handle + * @bufp: the beginning of the buffer is stored here + * + * Return the number of bytes available in the buffer, or zero if + * there's no space. + */ +static inline size_t seq_buf_get_buf(struct seq_buf *s, char **bufp) +{ + WARN_ON(s->len > s->size + 1); + + if (s->len < s->size) { + *bufp = s->buffer + s->len; + return s->size - s->len; + } + + *bufp = NULL; + return 0; +} + +/** + * seq_buf_commit - commit data to the buffer + * @s: the seq_buf handle + * @num: the number of bytes to commit + * + * Commit @num bytes of data written to a buffer previously acquired + * by seq_buf_get. To signal an error condition, or that the data + * didn't fit in the available space, pass a negative @num value. + */ +static inline void seq_buf_commit(struct seq_buf *s, int num) +{ + if (num < 0) { + seq_buf_set_overflow(s); + } else { + /* num must be negative on overflow */ + BUG_ON(s->len + num > s->size); + s->len += num; + } +} + extern __printf(2, 3) int seq_buf_printf(struct seq_buf *s, const char *fmt, ...); extern __printf(2, 0) diff --git a/kernel/trace/seq_buf.c b/kernel/trace/seq_buf.c index 27e48348ae67..3319dfbbb75b 100644 --- a/kernel/trace/seq_buf.c +++ b/kernel/trace/seq_buf.c @@ -285,8 +285,8 @@ int seq_buf_putmem_hex(struct seq_buf *s, const void *mem, */ int seq_buf_path(struct seq_buf *s, const struct path *path, const char *esc) { - char *buf = s->buffer + s->len; - size_t size = seq_buf_buffer_left(s); + char *buf; + size_t size = seq_buf_get_buf(s, &buf); int res = -1; WARN_ON(s->size == 0); @@ -299,8 +299,7 @@ int seq_buf_path(struct seq_buf *s, const struct path *path, const char *esc) res = end - buf; } } - if (res > 0) - s->len += res; + seq_buf_commit(s, res); return res; } -- 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/
[PATCH 21/26 v5] tracing: Have seq_buf use full buffer
From: "Steven Rostedt (Red Hat)" Currently seq_buf is full when all but one byte of the buffer is filled. Change it so that the seq_buf is full when all of the buffer is filled. Some of the functions would fill the buffer completely and report everything was fine. This was inconsistent with the max of size - 1. Changing this to be max of size makes all functions consistent. Link: http://lkml.kernel.org/r/20141104160222.502133...@goodmis.org Link: http://lkml.kernel.org/r/20141114011412.811957...@goodmis.org Tested-by: Jiri Kosina Acked-by: Jiri Kosina Reviewed-by: Petr Mladek Signed-off-by: Steven Rostedt --- include/linux/seq_buf.h | 6 +++--- kernel/trace/seq_buf.c | 9 ++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h index 93718e570d4c..0800a24b4348 100644 --- a/include/linux/seq_buf.h +++ b/include/linux/seq_buf.h @@ -43,13 +43,13 @@ seq_buf_init(struct seq_buf *s, unsigned char *buf, unsigned int size) static inline bool seq_buf_has_overflowed(struct seq_buf *s) { - return s->len == s->size; + return s->len > s->size; } static inline void seq_buf_set_overflow(struct seq_buf *s) { - s->len = s->size; + s->len = s->size + 1; } /* @@ -61,7 +61,7 @@ seq_buf_buffer_left(struct seq_buf *s) if (seq_buf_has_overflowed(s)) return 0; - return (s->size - 1) - s->len; + return s->size - s->len; } /* How much buffer was written? */ diff --git a/kernel/trace/seq_buf.c b/kernel/trace/seq_buf.c index 89d1bd5c27fe..27e48348ae67 100644 --- a/kernel/trace/seq_buf.c +++ b/kernel/trace/seq_buf.c @@ -18,7 +18,7 @@ static bool seq_buf_can_fit(struct seq_buf *s, size_t len) { - return s->len + len < s->size; + return s->len + len <= s->size; } /** @@ -102,8 +102,11 @@ int seq_buf_bitmask(struct seq_buf *s, const unsigned long *maskp, WARN_ON(s->size == 0); /* -* The last byte of the buffer is used to determine if we -* overflowed or not. +* Note, because bitmap_scnprintf() only returns the number of bytes +* written and not the number that would be written, we use the last +* byte of the buffer to let us know if we overflowed. There's a small +* chance that the bitmap could have fit exactly inside the buffer, but +* it's not that critical if that does happen. */ if (len > 1) { ret = bitmap_scnprintf(s->buffer + s->len, len, maskp, nmaskbits); -- 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/
[PATCH 24/26 v5] seq_buf: Move the seq_buf code to lib/
From: "Steven Rostedt (Red Hat)" The seq_buf functions are rather useful outside of tracing. Instead of having it be dependent on CONFIG_TRACING, move the code into lib/ and allow other users to have access to it even when tracing is not configured. The seq_buf utility is similar to the seq_file utility, but instead of writing sending data back up to userland, it writes it into a buffer defined at seq_buf_init(). This allows us to send a descriptor around that writes printf() formatted strings into it that can be retrieved later. It is currently used by the tracing facility for such things like trace events to convert its binary saved data in the ring buffer into an ASCII human readable context to be displayed in /sys/kernel/debug/trace. It can also be used for doing NMI prints safely from NMI context into the seq_buf and retrieved later and dumped to printk() safely. Doing printk() from an NMI context is dangerous because an NMI can preempt a current printk() and deadlock on it. Link: http://lkml.kernel.org/p/20140619213952.058255...@goodmis.org Tested-by: Jiri Kosina Acked-by: Jiri Kosina Reviewed-by: Petr Mladek Signed-off-by: Steven Rostedt --- kernel/trace/Makefile | 1 - kernel/trace/seq_buf.c | 351 - lib/Makefile | 2 +- lib/seq_buf.c | 351 + 4 files changed, 352 insertions(+), 353 deletions(-) delete mode 100644 kernel/trace/seq_buf.c create mode 100644 lib/seq_buf.c diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile index edc98c72a634..67d6369ddf83 100644 --- a/kernel/trace/Makefile +++ b/kernel/trace/Makefile @@ -29,7 +29,6 @@ obj-$(CONFIG_RING_BUFFER_BENCHMARK) += ring_buffer_benchmark.o obj-$(CONFIG_TRACING) += trace.o obj-$(CONFIG_TRACING) += trace_output.o obj-$(CONFIG_TRACING) += trace_seq.o -obj-$(CONFIG_TRACING) += seq_buf.o obj-$(CONFIG_TRACING) += trace_stat.o obj-$(CONFIG_TRACING) += trace_printk.o obj-$(CONFIG_CONTEXT_SWITCH_TRACER) += trace_sched_switch.o diff --git a/kernel/trace/seq_buf.c b/kernel/trace/seq_buf.c deleted file mode 100644 index a2288ca567a3.. --- a/kernel/trace/seq_buf.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - * seq_buf.c - * - * Copyright (C) 2014 Red Hat Inc, Steven Rostedt - * - * The seq_buf is a handy tool that allows you to pass a descriptor around - * to a buffer that other functions can write to. It is similar to the - * seq_file functionality but has some differences. - * - * To use it, the seq_buf must be initialized with seq_buf_init(). - * This will set up the counters within the descriptor. You can call - * seq_buf_init() more than once to reset the seq_buf to start - * from scratch. - */ -#include -#include -#include - -static bool seq_buf_can_fit(struct seq_buf *s, size_t len) -{ - return s->len + len <= s->size; -} - -/** - * seq_buf_print_seq - move the contents of seq_buf into a seq_file - * @m: the seq_file descriptor that is the destination - * @s: the seq_buf descriptor that is the source. - * - * Returns zero on success, non zero otherwise - */ -int seq_buf_print_seq(struct seq_file *m, struct seq_buf *s) -{ - unsigned int len = seq_buf_used(s); - - return seq_write(m, s->buffer, len); -} - -/** - * seq_buf_vprintf - sequence printing of information. - * @s: seq_buf descriptor - * @fmt: printf format string - * @args: va_list of arguments from a printf() type function - * - * Writes a vnprintf() format into the sequencce buffer. - * - * Returns zero on success, -1 on overflow. - */ -int seq_buf_vprintf(struct seq_buf *s, const char *fmt, va_list args) -{ - int len; - - WARN_ON(s->size == 0); - - if (s->len < s->size) { - len = vsnprintf(s->buffer + s->len, s->size - s->len, fmt, args); - if (seq_buf_can_fit(s, len)) { - s->len += len; - return 0; - } - } - seq_buf_set_overflow(s); - return -1; -} - -/** - * seq_buf_printf - sequence printing of information - * @s: seq_buf descriptor - * @fmt: printf format string - * - * Writes a printf() format into the sequence buffer. - * - * Returns zero on success, -1 on overflow. - */ -int seq_buf_printf(struct seq_buf *s, const char *fmt, ...) -{ - va_list ap; - int ret; - - va_start(ap, fmt); - ret = seq_buf_vprintf(s, fmt, ap); - va_end(ap); - - return ret; -} - -/** - * seq_buf_bitmask - write a bitmask array in its ASCII representation - * @s: seq_buf descriptor - * @maskp: points to an array of unsigned longs that represent a bitmask - * @nmaskbits: The number of bits that are valid in @maskp - * - * Writes a ASCII representation of a bitmask string into @s. - * - * Returns zero on success, -1 on overflow. - */ -int seq_buf_bitmask(struct seq_buf *s, const unsigned long *maskp, - int nmaskbits) -{ - unsigned int len = seq_buf_buf
[PATCH 26/26 v5] x86/nmi: Perform a safe NMI stack trace on all CPUs
From: "Steven Rostedt (Red Hat)" When trigger_all_cpu_backtrace() is called on x86, it will trigger an NMI on each CPU and call show_regs(). But this can lead to a hard lock up if the NMI comes in on another printk(). In order to avoid this, when the NMI triggers, it switches the printk routine for that CPU to call a NMI safe printk function that records the printk in a per_cpu seq_buf descriptor. After all NMIs have finished recording its data, the seq_bufs are printed in a safe context. Link: http://lkml.kernel.org/p/20140619213952.360076...@goodmis.org Tested-by: Jiri Kosina Acked-by: Jiri Kosina Acked-by: Paul E. McKenney Signed-off-by: Steven Rostedt --- arch/x86/kernel/apic/hw_nmi.c | 91 --- 1 file changed, 86 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/apic/hw_nmi.c b/arch/x86/kernel/apic/hw_nmi.c index 6a1e71bde323..c95c3e9ce196 100644 --- a/arch/x86/kernel/apic/hw_nmi.c +++ b/arch/x86/kernel/apic/hw_nmi.c @@ -18,6 +18,7 @@ #include #include #include +#include #ifdef CONFIG_HARDLOCKUP_DETECTOR u64 hw_nmi_get_sample_period(int watchdog_thresh) @@ -29,14 +30,35 @@ u64 hw_nmi_get_sample_period(int watchdog_thresh) #ifdef arch_trigger_all_cpu_backtrace /* For reliability, we're prepared to waste bits here. */ static DECLARE_BITMAP(backtrace_mask, NR_CPUS) __read_mostly; +static cpumask_var_t printtrace_mask; + +#define NMI_BUF_SIZE 4096 + +struct nmi_seq_buf { + unsigned char buffer[NMI_BUF_SIZE]; + struct seq_buf seq; +}; + +/* Safe printing in NMI context */ +static DEFINE_PER_CPU(struct nmi_seq_buf, nmi_print_seq); /* "in progress" flag of arch_trigger_all_cpu_backtrace */ static unsigned long backtrace_flag; +static void print_seq_line(struct nmi_seq_buf *s, int start, int end) +{ + const char *buf = s->buffer + start; + + printk("%.*s", (end - start) + 1, buf); +} + void arch_trigger_all_cpu_backtrace(bool include_self) { + struct nmi_seq_buf *s; + int len; + int cpu; int i; - int cpu = get_cpu(); + int this_cpu = get_cpu(); if (test_and_set_bit(0, &backtrace_flag)) { /* @@ -49,7 +71,17 @@ void arch_trigger_all_cpu_backtrace(bool include_self) cpumask_copy(to_cpumask(backtrace_mask), cpu_online_mask); if (!include_self) - cpumask_clear_cpu(cpu, to_cpumask(backtrace_mask)); + cpumask_clear_cpu(this_cpu, to_cpumask(backtrace_mask)); + + cpumask_copy(printtrace_mask, to_cpumask(backtrace_mask)); + /* +* Set up per_cpu seq_buf buffers that the NMIs running on the other +* CPUs will write to. +*/ + for_each_cpu(cpu, to_cpumask(backtrace_mask)) { + s = &per_cpu(nmi_print_seq, cpu); + seq_buf_init(&s->seq, s->buffer, NMI_BUF_SIZE); + } if (!cpumask_empty(to_cpumask(backtrace_mask))) { pr_info("sending NMI to %s CPUs:\n", @@ -65,11 +97,58 @@ void arch_trigger_all_cpu_backtrace(bool include_self) touch_softlockup_watchdog(); } + /* +* Now that all the NMIs have triggered, we can dump out their +* back traces safely to the console. +*/ + for_each_cpu(cpu, printtrace_mask) { + int last_i = 0; + + s = &per_cpu(nmi_print_seq, cpu); + len = seq_buf_used(&s->seq); + if (!len) + continue; + + /* Print line by line. */ + for (i = 0; i < len; i++) { + if (s->buffer[i] == '\n') { + print_seq_line(s, last_i, i); + last_i = i + 1; + } + } + /* Check if there was a partial line. */ + if (last_i < len) { + print_seq_line(s, last_i, len - 1); + pr_cont("\n"); + } + } + clear_bit(0, &backtrace_flag); smp_mb__after_atomic(); put_cpu(); } +/* + * It is not safe to call printk() directly from NMI handlers. + * It may be fine if the NMI detected a lock up and we have no choice + * but to do so, but doing a NMI on all other CPUs to get a back trace + * can be done with a sysrq-l. We don't want that to lock up, which + * can happen if the NMI interrupts a printk in progress. + * + * Instead, we redirect the vprintk() to this nmi_vprintk() that writes + * the content into a per cpu seq_buf buffer. Then when the NMIs are + * all done, we can safely dump the contents of the seq_buf to a printk() + * from a non NMI context. + */ +static int nmi_vprintk(const char *fmt, va_list args) +{ + struct nmi_seq_buf *s = this_cpu_ptr(&nmi_print_seq); + unsigned int len = seq_buf_used(&s->seq); + + seq_buf_vprintf(&s->seq, fmt, args); + return seq_buf_used(&s->seq) - len; +}
[PATCH 19/26 v5] tracing: Use trace_seq_used() and seq_buf_used() instead of len
From: "Steven Rostedt (Red Hat)" As the seq_buf->len will soon be +1 size when there's an overflow, we must use trace_seq_used() or seq_buf_used() methods to get the real length. This will prevent buffer overflow issues if just the len of the seq_buf descriptor is used to copy memory. Link: http://lkml.kernel.org/r/20141114121911.09ba3...@gandalf.local.home Reported-by: Petr Mladek Signed-off-by: Steven Rostedt --- include/linux/trace_seq.h| 20 +++- kernel/trace/seq_buf.c | 2 +- kernel/trace/trace.c | 44 kernel/trace/trace_events.c | 9 +--- kernel/trace/trace_functions_graph.c | 5 +++- kernel/trace/trace_seq.c | 2 +- 6 files changed, 60 insertions(+), 22 deletions(-) diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h index 85d37106be3d..cfaf5a1d4bad 100644 --- a/include/linux/trace_seq.h +++ b/include/linux/trace_seq.h @@ -24,6 +24,24 @@ trace_seq_init(struct trace_seq *s) } /** + * trace_seq_used - amount of actual data written to buffer + * @s: trace sequence descriptor + * + * Returns the amount of data written to the buffer. + * + * IMPORTANT! + * + * Use this instead of @s->seq.len if you need to pass the amount + * of data from the buffer to another buffer (userspace, or what not). + * The @s->seq.len on overflow is bigger than the buffer size and + * using it can cause access to undefined memory. + */ +static inline int trace_seq_used(struct trace_seq *s) +{ + return seq_buf_used(&s->seq); +} + +/** * trace_seq_buffer_ptr - return pointer to next location in buffer * @s: trace sequence descriptor * @@ -35,7 +53,7 @@ trace_seq_init(struct trace_seq *s) static inline unsigned char * trace_seq_buffer_ptr(struct trace_seq *s) { - return s->buffer + s->seq.len; + return s->buffer + seq_buf_used(&s->seq); } /** diff --git a/kernel/trace/seq_buf.c b/kernel/trace/seq_buf.c index 9ec5305d9da7..ce17f65268ed 100644 --- a/kernel/trace/seq_buf.c +++ b/kernel/trace/seq_buf.c @@ -328,7 +328,7 @@ int seq_buf_to_user(struct seq_buf *s, char __user *ubuf, int cnt) if (s->len <= s->readpos) return -EBUSY; - len = s->len - s->readpos; + len = seq_buf_used(s) - s->readpos; if (cnt > len) cnt = len; ret = copy_to_user(ubuf, s->buffer + s->readpos, cnt); diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 7d7a07e9b9e9..9f1ffc707f3b 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -944,10 +944,10 @@ static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt) { int len; - if (s->seq.len <= s->seq.readpos) + if (trace_seq_used(s) <= s->seq.readpos) return -EBUSY; - len = s->seq.len - s->seq.readpos; + len = trace_seq_used(s) - s->seq.readpos; if (cnt > len) cnt = len; memcpy(buf, s->buffer + s->seq.readpos, cnt); @@ -4514,18 +4514,18 @@ waitagain: trace_access_lock(iter->cpu_file); while (trace_find_next_entry_inc(iter) != NULL) { enum print_line_t ret; - int len = iter->seq.seq.len; + int save_len = iter->seq.seq.len; ret = print_trace_line(iter); if (ret == TRACE_TYPE_PARTIAL_LINE) { /* don't print partial lines */ - iter->seq.seq.len = len; + iter->seq.seq.len = save_len; break; } if (ret != TRACE_TYPE_NO_CONSUME) trace_consume(iter); - if (iter->seq.seq.len >= cnt) + if (trace_seq_used(&iter->seq) >= cnt) break; /* @@ -4541,7 +4541,7 @@ waitagain: /* Now copy what we have to the user */ sret = trace_seq_to_user(&iter->seq, ubuf, cnt); - if (iter->seq.seq.readpos >= iter->seq.seq.len) + if (iter->seq.seq.readpos >= trace_seq_used(&iter->seq)) trace_seq_init(&iter->seq); /* @@ -4575,20 +4575,33 @@ static size_t tracing_fill_pipe_page(size_t rem, struct trace_iterator *iter) { size_t count; + int save_len; int ret; /* Seq buffer is page-sized, exactly what we need. */ for (;;) { - count = iter->seq.seq.len; + save_len = iter->seq.seq.len; ret = print_trace_line(iter); - count = iter->seq.seq.len - count; - if (rem < count) { - rem = 0; - iter->seq.seq.len -= count; + + if (trace_seq_has_overflowed(&iter->seq)) { + iter->seq.seq.len = save_len; break; } + + /* +* This should not be hit, because it should only +
[PATCH 25/26 v5] printk: Add per_cpu printk func to allow printk to be diverted
From: "Steven Rostedt (Red Hat)" Being able to divert printk to call another function besides the normal logging is useful for such things like NMI handling. If some functions are to be called from NMI that does printk() it is possible to lock up the box if the nmi handler triggers when another printk is happening. One example of this use is to perform a stack trace on all CPUs via NMI. But if the NMI is to do the printk() it can cause the system to lock up. By allowing the printk to be diverted to another function that can safely record the printk output and then print it when it in a safe context then NMIs will be safe to call these functions like show_regs(). Link: http://lkml.kernel.org/p/20140619213952.209176...@goodmis.org Tested-by: Jiri Kosina Acked-by: Jiri Kosina Acked-by: Paul E. McKenney Reviewed-by: Petr Mladek Signed-off-by: Steven Rostedt --- include/linux/percpu.h | 3 +++ include/linux/printk.h | 2 ++ kernel/printk/printk.c | 38 +- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/include/linux/percpu.h b/include/linux/percpu.h index a3aa63e47637..ba2e85a0ff5b 100644 --- a/include/linux/percpu.h +++ b/include/linux/percpu.h @@ -134,4 +134,7 @@ extern phys_addr_t per_cpu_ptr_to_phys(void *addr); (typeof(type) __percpu *)__alloc_percpu(sizeof(type), \ __alignof__(type)) +/* To avoid include hell, as printk can not declare this, we declare it here */ +DECLARE_PER_CPU(printk_func_t, printk_func); + #endif /* __LINUX_PERCPU_H */ diff --git a/include/linux/printk.h b/include/linux/printk.h index d78125f73ac4..3bbd979d32fb 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -162,6 +162,8 @@ extern int kptr_restrict; extern void wake_up_klogd(void); +typedef int(*printk_func_t)(const char *fmt, va_list args); + void log_buf_kexec_setup(void); void __init setup_log_buf(int early); void dump_stack_set_arch_desc(const char *fmt, ...); diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index ced2b84b1cb7..f7b723f98cb9 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -1807,6 +1807,30 @@ asmlinkage int printk_emit(int facility, int level, } EXPORT_SYMBOL(printk_emit); +int vprintk_default(const char *fmt, va_list args) +{ + int r; + +#ifdef CONFIG_KGDB_KDB + if (unlikely(kdb_trap_printk)) { + r = vkdb_printf(fmt, args); + return r; + } +#endif + r = vprintk_emit(0, -1, NULL, 0, fmt, args); + + return r; +} +EXPORT_SYMBOL_GPL(vprintk_default); + +/* + * This allows printk to be diverted to another function per cpu. + * This is useful for calling printk functions from within NMI + * without worrying about race conditions that can lock up the + * box. + */ +DEFINE_PER_CPU(printk_func_t, printk_func) = vprintk_default; + /** * printk - print a kernel message * @fmt: format string @@ -1830,19 +1854,15 @@ EXPORT_SYMBOL(printk_emit); */ asmlinkage __visible int printk(const char *fmt, ...) { + printk_func_t vprintk_func; va_list args; int r; -#ifdef CONFIG_KGDB_KDB - if (unlikely(kdb_trap_printk)) { - va_start(args, fmt); - r = vkdb_printf(fmt, args); - va_end(args); - return r; - } -#endif va_start(args, fmt); - r = vprintk_emit(0, -1, NULL, 0, fmt, args); + preempt_disable(); + vprintk_func = this_cpu_read(printk_func); + r = vprintk_func(fmt, args); + preempt_enable(); va_end(args); return r; -- 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/
[PATCH 20/26 v5] seq_buf: Add seq_buf_can_fit() helper function
From: "Steven Rostedt (Red Hat)" Add a seq_buf_can_fit() helper function that removes the possible mistakes of comparing the seq_buf length plus added data compared to the size of the buffer. Signed-off-by: Steven Rostedt --- kernel/trace/seq_buf.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/kernel/trace/seq_buf.c b/kernel/trace/seq_buf.c index ce17f65268ed..89d1bd5c27fe 100644 --- a/kernel/trace/seq_buf.c +++ b/kernel/trace/seq_buf.c @@ -16,6 +16,11 @@ #include #include +static bool seq_buf_can_fit(struct seq_buf *s, size_t len) +{ + return s->len + len < s->size; +} + /** * seq_buf_print_seq - move the contents of seq_buf into a seq_file * @m: the seq_file descriptor that is the destination @@ -48,7 +53,7 @@ int seq_buf_vprintf(struct seq_buf *s, const char *fmt, va_list args) if (s->len < s->size) { len = vsnprintf(s->buffer + s->len, s->size - s->len, fmt, args); - if (s->len + len < s->size) { + if (seq_buf_can_fit(s, len)) { s->len += len; return 0; } @@ -137,7 +142,7 @@ int seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary) if (s->len < s->size) { ret = bstr_printf(s->buffer + s->len, len, fmt, binary); - if (s->len + ret < s->size) { + if (seq_buf_can_fit(s, ret)) { s->len += ret; return 0; } @@ -161,7 +166,7 @@ int seq_buf_puts(struct seq_buf *s, const char *str) WARN_ON(s->size == 0); - if (s->len + len < s->size) { + if (seq_buf_can_fit(s, len)) { memcpy(s->buffer + s->len, str, len); s->len += len; return 0; @@ -183,7 +188,7 @@ int seq_buf_putc(struct seq_buf *s, unsigned char c) { WARN_ON(s->size == 0); - if (s->len + 1 < s->size) { + if (seq_buf_can_fit(s, 1)) { s->buffer[s->len++] = c; return 0; } @@ -207,7 +212,7 @@ int seq_buf_putmem(struct seq_buf *s, const void *mem, unsigned int len) { WARN_ON(s->size == 0); - if (s->len + len < s->size) { + if (seq_buf_can_fit(s, len)) { memcpy(s->buffer + s->len, mem, len); s->len += len; return 0; -- 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/
[PATCH 23/26 v5] seq-buf: Make seq_buf_bprintf() conditional on CONFIG_BINARY_PRINTF
From: "Steven Rostedt (Red Hat)" The function bstr_printf() from lib/vsprnintf.c is only available if CONFIG_BINARY_PRINTF is defined. This is due to the only user currently being the tracing infrastructure, which needs to select this config when tracing is configured. Until there is another user of the binary printf formats, this will continue to be the case. Since seq_buf.c is now lives in lib/ and is compiled even without tracing, it must encompass its use of bstr_printf() which is used by seq_buf_printf(). This too is only used by the tracing infrastructure and is still encapsulated by the CONFIG_BINARY_PRINTF. Link: http://lkml.kernel.org/r/20141104160222.969013...@goodmis.org Tested-by: Jiri Kosina Acked-by: Jiri Kosina Reviewed-by: Petr Mladek Signed-off-by: Steven Rostedt --- include/linux/seq_buf.h | 7 +-- kernel/trace/seq_buf.c | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h index 12c64282aa98..9aafe0e24c68 100644 --- a/include/linux/seq_buf.h +++ b/include/linux/seq_buf.h @@ -115,8 +115,6 @@ extern __printf(2, 3) int seq_buf_printf(struct seq_buf *s, const char *fmt, ...); extern __printf(2, 0) int seq_buf_vprintf(struct seq_buf *s, const char *fmt, va_list args); -extern int -seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary); extern int seq_buf_print_seq(struct seq_file *m, struct seq_buf *s); extern int seq_buf_to_user(struct seq_buf *s, char __user *ubuf, int cnt); @@ -130,4 +128,9 @@ extern int seq_buf_path(struct seq_buf *s, const struct path *path, const char * extern int seq_buf_bitmask(struct seq_buf *s, const unsigned long *maskp, int nmaskbits); +#ifdef CONFIG_BINARY_PRINTF +extern int +seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary); +#endif + #endif /* _LINUX_SEQ_BUF_H */ diff --git a/kernel/trace/seq_buf.c b/kernel/trace/seq_buf.c index 3319dfbbb75b..a2288ca567a3 100644 --- a/kernel/trace/seq_buf.c +++ b/kernel/trace/seq_buf.c @@ -119,6 +119,7 @@ int seq_buf_bitmask(struct seq_buf *s, const unsigned long *maskp, return -1; } +#ifdef CONFIG_BINARY_PRINTF /** * seq_buf_bprintf - Write the printf string from binary arguments * @s: seq_buf descriptor @@ -153,6 +154,7 @@ int seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary) seq_buf_set_overflow(s); return -1; } +#endif /* CONFIG_BINARY_PRINTF */ /** * seq_buf_puts - sequence printing of simple string -- 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/
[PATCH 03/26 v5] blktrace/tracing: Use trace_seq_has_overflowed() helper function
From: "Steven Rostedt (Red Hat)" Checking the return code of every trace_seq_printf() operation and having to return early if it overflowed makes the code messy. Using the new trace_seq_has_overflowed() and trace_handle_return() functions allows us to clean up the code. In the future, trace_seq_printf() and friends will be turning into void functions and not returning a value. The trace_seq_has_overflowed() is to be used instead. This cleanup allows that change to take place. Cc: Jens Axboe Reviewed-by: Petr Mladek Signed-off-by: Steven Rostedt --- kernel/trace/blktrace.c | 148 +--- 1 file changed, 66 insertions(+), 82 deletions(-) diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index c1bd4ada2a04..11b9cb36092b 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c @@ -1142,9 +1142,9 @@ static void get_pdu_remap(const struct trace_entry *ent, r->sector_from = be64_to_cpu(sector_from); } -typedef int (blk_log_action_t) (struct trace_iterator *iter, const char *act); +typedef void (blk_log_action_t) (struct trace_iterator *iter, const char *act); -static int blk_log_action_classic(struct trace_iterator *iter, const char *act) +static void blk_log_action_classic(struct trace_iterator *iter, const char *act) { char rwbs[RWBS_LEN]; unsigned long long ts = iter->ts; @@ -1154,33 +1154,33 @@ static int blk_log_action_classic(struct trace_iterator *iter, const char *act) fill_rwbs(rwbs, t); - return trace_seq_printf(&iter->seq, - "%3d,%-3d %2d %5d.%09lu %5u %2s %3s ", - MAJOR(t->device), MINOR(t->device), iter->cpu, - secs, nsec_rem, iter->ent->pid, act, rwbs); + trace_seq_printf(&iter->seq, +"%3d,%-3d %2d %5d.%09lu %5u %2s %3s ", +MAJOR(t->device), MINOR(t->device), iter->cpu, +secs, nsec_rem, iter->ent->pid, act, rwbs); } -static int blk_log_action(struct trace_iterator *iter, const char *act) +static void blk_log_action(struct trace_iterator *iter, const char *act) { char rwbs[RWBS_LEN]; const struct blk_io_trace *t = te_blk_io_trace(iter->ent); fill_rwbs(rwbs, t); - return trace_seq_printf(&iter->seq, "%3d,%-3d %2s %3s ", - MAJOR(t->device), MINOR(t->device), act, rwbs); + trace_seq_printf(&iter->seq, "%3d,%-3d %2s %3s ", +MAJOR(t->device), MINOR(t->device), act, rwbs); } -static int blk_log_dump_pdu(struct trace_seq *s, const struct trace_entry *ent) +static void blk_log_dump_pdu(struct trace_seq *s, const struct trace_entry *ent) { const unsigned char *pdu_buf; int pdu_len; - int i, end, ret; + int i, end; pdu_buf = pdu_start(ent); pdu_len = te_blk_io_trace(ent)->pdu_len; if (!pdu_len) - return 1; + return; /* find the last zero that needs to be printed */ for (end = pdu_len - 1; end >= 0; end--) @@ -1188,119 +1188,107 @@ static int blk_log_dump_pdu(struct trace_seq *s, const struct trace_entry *ent) break; end++; - if (!trace_seq_putc(s, '(')) - return 0; + trace_seq_putc(s, '('); for (i = 0; i < pdu_len; i++) { - ret = trace_seq_printf(s, "%s%02x", - i == 0 ? "" : " ", pdu_buf[i]); - if (!ret) - return ret; + trace_seq_printf(s, "%s%02x", +i == 0 ? "" : " ", pdu_buf[i]); /* * stop when the rest is just zeroes and indicate so * with a ".." appended */ - if (i == end && end != pdu_len - 1) - return trace_seq_puts(s, " ..) "); + if (i == end && end != pdu_len - 1) { + trace_seq_puts(s, " ..) "); + return; + } } - return trace_seq_puts(s, ") "); + trace_seq_puts(s, ") "); } -static int blk_log_generic(struct trace_seq *s, const struct trace_entry *ent) +static void blk_log_generic(struct trace_seq *s, const struct trace_entry *ent) { char cmd[TASK_COMM_LEN]; trace_find_cmdline(ent->pid, cmd); if (t_action(ent) & BLK_TC_ACT(BLK_TC_PC)) { - int ret; - - ret = trace_seq_printf(s, "%u ", t_bytes(ent)); - if (!ret) - return 0; - ret = blk_log_dump_pdu(s, ent); - if (!ret) - return 0; - return trace_seq_printf(s, "[%s]\n", cmd); + trace_seq_printf(s, "%u ", t_bytes(ent)); + blk_log_dump_pdu(s, ent); + trace_seq_printf(s, "[%s]\
[PATCH 06/26 v5] tracing: Have function_graph use trace_seq_has_overflowed()
From: "Steven Rostedt (Red Hat)" Instead of doing individual checks all over the place that makes the code very messy. Just check trace_seq_has_overflowed() at the end or in strategic places. This makes the code much cleaner and also helps with getting closer to removing the return values of trace_seq_printf() and friends. Link: http://lkml.kernel.org/r/20141114011410.987913...@goodmis.org Reviewed-by: Petr Mladek Signed-off-by: Steven Rostedt --- kernel/trace/trace.h | 2 +- kernel/trace/trace_functions_graph.c | 382 +++ 2 files changed, 118 insertions(+), 266 deletions(-) diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 19418221b302..c3a37e55ec8b 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -726,7 +726,7 @@ extern unsigned long trace_flags; extern enum print_line_t print_graph_function_flags(struct trace_iterator *iter, u32 flags); extern void print_graph_headers_flags(struct seq_file *s, u32 flags); -extern enum print_line_t +extern void trace_print_graph_duration(unsigned long long duration, struct trace_seq *s); extern void graph_trace_open(struct trace_iterator *iter); extern void graph_trace_close(struct trace_iterator *iter); diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c index 55bdf9d7f714..100288d10e1f 100644 --- a/kernel/trace/trace_functions_graph.c +++ b/kernel/trace/trace_functions_graph.c @@ -107,7 +107,7 @@ enum { FLAGS_FILL_END = 3 << TRACE_GRAPH_PRINT_FILL_SHIFT, }; -static enum print_line_t +static void print_graph_duration(unsigned long long duration, struct trace_seq *s, u32 flags); @@ -483,33 +483,24 @@ static int graph_trace_update_thresh(struct trace_array *tr) static int max_bytes_for_cpu; -static enum print_line_t -print_graph_cpu(struct trace_seq *s, int cpu) +static void print_graph_cpu(struct trace_seq *s, int cpu) { - int ret; - /* * Start with a space character - to make it stand out * to the right a bit when trace output is pasted into * email: */ - ret = trace_seq_printf(s, " %*d) ", max_bytes_for_cpu, cpu); - if (!ret) - return TRACE_TYPE_PARTIAL_LINE; - - return TRACE_TYPE_HANDLED; + trace_seq_printf(s, " %*d) ", max_bytes_for_cpu, cpu); } #define TRACE_GRAPH_PROCINFO_LENGTH14 -static enum print_line_t -print_graph_proc(struct trace_seq *s, pid_t pid) +static void print_graph_proc(struct trace_seq *s, pid_t pid) { char comm[TASK_COMM_LEN]; /* sign + log10(MAX_INT) + '\0' */ char pid_str[11]; int spaces = 0; - int ret; int len; int i; @@ -524,56 +515,43 @@ print_graph_proc(struct trace_seq *s, pid_t pid) spaces = TRACE_GRAPH_PROCINFO_LENGTH - len; /* First spaces to align center */ - for (i = 0; i < spaces / 2; i++) { - ret = trace_seq_putc(s, ' '); - if (!ret) - return TRACE_TYPE_PARTIAL_LINE; - } + for (i = 0; i < spaces / 2; i++) + trace_seq_putc(s, ' '); - ret = trace_seq_printf(s, "%s-%s", comm, pid_str); - if (!ret) - return TRACE_TYPE_PARTIAL_LINE; + trace_seq_printf(s, "%s-%s", comm, pid_str); /* Last spaces to align center */ - for (i = 0; i < spaces - (spaces / 2); i++) { - ret = trace_seq_putc(s, ' '); - if (!ret) - return TRACE_TYPE_PARTIAL_LINE; - } - return TRACE_TYPE_HANDLED; + for (i = 0; i < spaces - (spaces / 2); i++) + trace_seq_putc(s, ' '); } -static enum print_line_t -print_graph_lat_fmt(struct trace_seq *s, struct trace_entry *entry) +static void print_graph_lat_fmt(struct trace_seq *s, struct trace_entry *entry) { - if (!trace_seq_putc(s, ' ')) - return 0; - - return trace_print_lat_fmt(s, entry); + trace_seq_putc(s, ' '); + trace_print_lat_fmt(s, entry); } /* If the pid changed since the last trace, output this event */ -static enum print_line_t +static void verif_pid(struct trace_seq *s, pid_t pid, int cpu, struct fgraph_data *data) { pid_t prev_pid; pid_t *last_pid; - int ret; if (!data) - return TRACE_TYPE_HANDLED; + return; last_pid = &(per_cpu_ptr(data->cpu_data, cpu)->last_pid); if (*last_pid == pid) - return TRACE_TYPE_HANDLED; + return; prev_pid = *last_pid; *last_pid = pid; if (prev_pid == -1) - return TRACE_TYPE_HANDLED; + return; /* * Context-switch trace line: @@ -582,33 +560,12 @@ verif_pid(struct trace_seq *s, pid_t pid, int cpu, struct fgraph_data *data) -- */ - ret = trace_seq_puts(s, -
[PATCH 12/26 v5] tracing: Remove return values of most trace_seq_*() functions
From: "Steven Rostedt (Red Hat)" The trace_seq_printf() and friends are used to store strings into a buffer that can be passed around from function to function. If the trace_seq buffer fills up, it will not print any more. The return values were somewhat inconsistant and using trace_seq_has_overflowed() was a better way to know if the write to the trace_seq buffer succeeded or not. Now that all users have removed reading the return value of the printf() type functions, they can safely return void and keep future users of them from reading the inconsistent values as well. Link: http://lkml.kernel.org/r/20141114011411.992510...@goodmis.org Signed-off-by: Steven Rostedt --- include/linux/trace_seq.h | 37 + kernel/trace/trace_seq.c | 84 +-- 2 files changed, 38 insertions(+), 83 deletions(-) diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h index 07eda413dfcf..db8a73224f1a 100644 --- a/include/linux/trace_seq.h +++ b/include/linux/trace_seq.h @@ -57,40 +57,37 @@ static inline bool trace_seq_has_overflowed(struct trace_seq *s) */ #ifdef CONFIG_TRACING extern __printf(2, 3) -int trace_seq_printf(struct trace_seq *s, const char *fmt, ...); +void trace_seq_printf(struct trace_seq *s, const char *fmt, ...); extern __printf(2, 0) -int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args); -extern int +void trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args); +extern void trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary); extern int trace_print_seq(struct seq_file *m, struct trace_seq *s); extern int trace_seq_to_user(struct trace_seq *s, char __user *ubuf, int cnt); -extern int trace_seq_puts(struct trace_seq *s, const char *str); -extern int trace_seq_putc(struct trace_seq *s, unsigned char c); -extern int trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len); -extern int trace_seq_putmem_hex(struct trace_seq *s, const void *mem, +extern void trace_seq_puts(struct trace_seq *s, const char *str); +extern void trace_seq_putc(struct trace_seq *s, unsigned char c); +extern void trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len); +extern void trace_seq_putmem_hex(struct trace_seq *s, const void *mem, unsigned int len); extern int trace_seq_path(struct trace_seq *s, const struct path *path); -extern int trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, +extern void trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, int nmaskbits); #else /* CONFIG_TRACING */ -static inline int trace_seq_printf(struct trace_seq *s, const char *fmt, ...) +static inline void trace_seq_printf(struct trace_seq *s, const char *fmt, ...) { - return 0; } -static inline int +static inline void trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary) { - return 0; } -static inline int +static inline void trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, int nmaskbits) { - return 0; } static inline int trace_print_seq(struct seq_file *m, struct trace_seq *s) @@ -102,23 +99,19 @@ static inline int trace_seq_to_user(struct trace_seq *s, char __user *ubuf, { return 0; } -static inline int trace_seq_puts(struct trace_seq *s, const char *str) +static inline void trace_seq_puts(struct trace_seq *s, const char *str) { - return 0; } -static inline int trace_seq_putc(struct trace_seq *s, unsigned char c) +static inline void trace_seq_putc(struct trace_seq *s, unsigned char c) { - return 0; } -static inline int +static inline void trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len) { - return 0; } -static inline int trace_seq_putmem_hex(struct trace_seq *s, const void *mem, +static inline void trace_seq_putmem_hex(struct trace_seq *s, const void *mem, unsigned int len) { - return 0; } static inline int trace_seq_path(struct trace_seq *s, const struct path *path) { diff --git a/kernel/trace/trace_seq.c b/kernel/trace/trace_seq.c index b100994a17fe..fabfa0f190a3 100644 --- a/kernel/trace/trace_seq.c +++ b/kernel/trace/trace_seq.c @@ -69,20 +69,15 @@ int trace_print_seq(struct seq_file *m, struct trace_seq *s) * trace_seq_printf() is used to store strings into a special * buffer (@s). Then the output may be either used by * the sequencer or pulled into another buffer. - * - * Returns 1 if we successfully written all the contents to - * the buffer. - * Returns 0 if we the length to write is bigger than the - * reserved buffer space. In this case, nothing gets written. */ -int trace_seq_printf(struct trace_seq *s, const char *fmt, ...) +void trace_seq_printf(struct trace_seq *s, const char *fmt, ...) { unsigned int len = TRACE_SEQ_
Re: [PATCH v2] x86, mm: set NX across entire PMD at boot
On Fri, Nov 14, 2014 at 6:46 PM, Kees Cook wrote: > On Fri, Nov 14, 2014 at 6:29 PM, Yinghai Lu wrote: >> should use attached one instead. >> >> 1. should use _brk_end instead of &end, as we only use partial of >>brk. >> 2. [_brk_end, pm_end) page range is already converted. aka >>is not wasted. > > Are you sure? For me, _brk_end isn't far enough: > > [1.475572] all_end: 0x82df5000 > [1.476736] _brk_end: 0x82dd6000 Yes. _brk_end should be small then &_end. > >> >> --- >> arch/x86/mm/init_64.c |6 -- >> 1 file changed, 4 insertions(+), 2 deletions(-) >> >> Index: linux-2.6/arch/x86/mm/init_64.c >> === >> --- linux-2.6.orig/arch/x86/mm/init_64.c >> +++ linux-2.6/arch/x86/mm/init_64.c >> @@ -1124,7 +1124,8 @@ void mark_rodata_ro(void) >> unsigned long end = (unsigned long) &__end_rodata_hpage_align; >> unsigned long text_end = PFN_ALIGN(&__stop___ex_table); >> unsigned long rodata_end = PFN_ALIGN(&__end_rodata); >> -unsigned long all_end = PFN_ALIGN(&_end); >> +unsigned long all_end = PFN_ALIGN(_brk_end); >> +unsigned long pmd_end = roundup(all_end, PMD_SIZE); >> >> printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n", >> (end - start) >> 10); >> @@ -1136,7 +1137,7 @@ void mark_rodata_ro(void) >> * The rodata/data/bss/brk section (but not the kernel text!) >> * should also be not-executable. >> */ >> -set_memory_nx(rodata_start, (all_end - rodata_start) >> PAGE_SHIFT); >> +set_memory_nx(rodata_start, (pmd_end - rodata_start) >> PAGE_SHIFT); >> >> rodata_test(); >> >> @@ -1148,6 +1149,7 @@ void mark_rodata_ro(void) >> set_memory_ro(start, (end-start) >> PAGE_SHIFT); >> #endif >> >> +/* all_end to pmd_end is handled via free_all_bootmem() */ >> free_init_pages("unused kernel", >> (unsigned long) __va(__pa_symbol(text_end)), >> (unsigned long) __va(__pa_symbol(rodata_start))); > > This patch produces the same results as my v1 patch: > > 0x8202d000-0x8220 1868K RW GLB NX pte > 0x8220-0x82e012M RW PSE GLB NX pmd > 0x82e0-0xc000 978M pmd > > Is this correct? It sounded like tglx wanted the pmd split, like this: > > 0x8220-0x82c010M RW PSE GLB NX pmd > 0x82c0-0x82df5000 2004K RW GLB NX pte > 0x82df5000-0x82e044K RW NX pte > 0x82e0-0xc000 978M pmd Need to remove GLB ? Yinghai -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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] x86, mm: set NX across entire PMD at boot
On Fri, Nov 14, 2014 at 7:06 PM, Kees Cook wrote: > On Fri, Nov 14, 2014 at 5:29 PM, Yinghai Lu wrote: >> >> [0.00] .text: [0x0100-0x0200d548] >> [0.00] .rodata: [0x0220-0x02a1cfff] >> [0.00] .data: [0x02c0-0x02e50e7f] >> [0.00] .init: [0x02e52000-0x03212fff] >> [0.00].bss: [0x03221000-0x0437bfff] >> [0.00].brk: [0x0437c000-0x043a1fff] > > And which CONFIG turns on this reporting? > My local patch. this brk does not shrink yet. Yinghai -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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] audit: convert status version to a feature bitmap
On 14/11/13, Steve Grubb wrote: > On Thursday, November 13, 2014 08:08:52 PM Richard Guy Briggs wrote: > > > So what terrible things happen to userspace if > > > AUDIT_VERSION_BACKLOG_WAIT_TIME becomes 0x03 instead of 0x02? > > > > But it won't. It gets the value of > > AUDIT_FEATURE_BITMAP_BACKLOG_WAIT_TIME, which is 0x0002. > > > > I think you meant to ask about AUDIT_VERSION_LATEST, which would become 3. > > > > You *did* already ask that question in a previous thread, and there > > didn't seem to be a concern. Steve Grubb could likely answer this > > question better than me. > > The audit 2.4.1 package has been pushed to everything from F20 -> rawhide. If > you don't see any problems, then its safe. But check carefully around the > things that you did change. Right now, we only are caring about only one > kernel feature, --loginuid-immutable. Check that it still works, auditctl -s. Here's my output, which I assume looks sane: [root@f20 ~]# rpm -q audit audit-2.4.1-1.fc20.x86_64 [root@f20 ~]# auditctl -s enabled 1 flag 1 pid 307 rate_limit 0 backlog_limit 320 lost 0 backlog 0 backlog_wait_time 6 loginuid_immutable 0 unlocked > -Steve - RGB -- Richard Guy Briggs Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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 0/7] Replace _PAGE_NUMA with PAGE_NONE protections
On 11/14/2014 08:32 AM, Mel Gorman wrote:> This is follow up from the "pipe/page fault oddness" thread. Hi Mel, Applying this patch series I've started seeing the following straight away: [ 367.547848] page:ea0003fb7db0 count:1007 mapcount:1005 mapping:8800691f2f58 index:0x37 [ 367.551481] flags: 0x5001aa8030202d(locked|referenced|uptodate|lru|writeback|unevictable|mlocked) [ 367.555382] page dumped because: VM_BUG_ON_PAGE(!v9inode->writeback_fid) [ 367.558262] page->mem_cgroup:88006d8a1bd8 [ 367.560403] [ cut here ] [ 367.562343] kernel BUG at fs/9p/vfs_addr.c:190! [ 367.564239] invalid opcode: [#1] PREEMPT SMP DEBUG_PAGEALLOC KASAN [ 367.566991] Dumping ftrace buffer: [ 367.568481](ftrace buffer empty) [ 367.569914] Modules linked in: [ 367.570254] CPU: 3 PID: 8234 Comm: kworker/u52:1 Not tainted 3.18.0-rc4-next-20141114-sasha-00054-ga9ff95e-dirty #1459 [ 367.570254] Workqueue: writeback bdi_writeback_workfn (flush-9p-1) [ 367.570254] task: 8801e21d8000 ti: 8801e1f34000 task.ti: 8801e1f34000 [ 367.570254] RIP: v9fs_vfs_writepage_locked (fs/9p/vfs_addr.c:190 (discriminator 1)) [ 367.570254] RSP: 0018:8801e1f376c8 EFLAGS: 00010286 [ 367.570254] RAX: 0021 RBX: ea0003fb7db0 RCX: [ 367.570254] RDX: 0021 RSI: 9208b2e6 RDI: 8801e21d8d0c [ 367.570254] RBP: 8801e1f37728 R08: 0001 R09: [ 367.570254] R10: 0001 R11: 0001 R12: 8800691f2d48 [ 367.570254] R13: 1000 R14: 8800691f2c30 R15: 8800691f2c98 [ 367.570254] FS: () GS:8801e5c0() knlGS: [ 367.570254] CS: 0010 DS: ES: CR0: 8005003b [ 367.570254] CR2: CR3: ca00c000 CR4: 06a0 [ 367.570254] DR0: 8100 DR1: DR2: [ 367.570254] DR3: DR6: 0ff0 DR7: 0600 [ 367.570254] Stack: [ 367.570254] da003c43b1a1 da003c43b1a1 0002 [ 367.570254] 0002 00037000 8801e1f37758 ea0003fb7db0 [ 367.570254] 8801e1f37a60 8801e1f37a60 ea0003fb7db0 [ 367.570254] Call Trace: [ 367.570254] v9fs_vfs_writepage (fs/9p/vfs_addr.c:212) [ 367.570254] __writepage (include/linux/pagemap.h:32 mm/page-writeback.c:2006) [ 367.570254] write_cache_pages (mm/page-writeback.c:1943) [ 367.570254] ? bdi_set_max_ratio (mm/page-writeback.c:2003) [ 367.570254] ? sched_clock_local (kernel/sched/clock.c:202) [ 367.570254] generic_writepages (mm/page-writeback.c:2030) [ 367.570254] do_writepages (mm/page-writeback.c:2047) [ 367.570254] __writeback_single_inode (fs/fs-writeback.c:461 (discriminator 3)) [ 367.570254] writeback_sb_inodes (fs/fs-writeback.c:706) [ 367.570254] __writeback_inodes_wb (fs/fs-writeback.c:749) [ 367.570254] wb_writeback (fs/fs-writeback.c:880) [ 367.570254] ? __lock_is_held (kernel/locking/lockdep.c:3518) [ 367.570254] bdi_writeback_workfn (fs/fs-writeback.c:1015 fs/fs-writeback.c:1060) [ 367.570254] process_one_work (kernel/workqueue.c:2023 include/linux/jump_label.h:114 include/trace/events/workqueue.h:111 kernel/workqueue.c:2028) [ 367.570254] ? process_one_work (kernel/workqueue.c:2020) [ 367.570254] ? get_lock_stats (kernel/locking/lockdep.c:249) [ 367.570254] worker_thread (include/linux/list.h:189 kernel/workqueue.c:2156) [ 367.570254] ? __schedule (./arch/x86/include/asm/bitops.h:311 include/linux/thread_info.h:91 include/linux/sched.h:2939 kernel/sched/core.c:2848) [ 367.570254] ? rescuer_thread (kernel/workqueue.c:2100) [ 367.570254] kthread (kernel/kthread.c:207) [ 367.570254] ? flush_kthread_work (kernel/kthread.c:176) [ 367.570254] ret_from_fork (arch/x86/kernel/entry_64.S:348) [ 367.570254] ? flush_kthread_work (kernel/kthread.c:176) [ 367.570254] Code: 48 83 c4 38 44 89 f0 5b 41 5c 41 5d 41 5e 41 5f 5d c3 66 2e 0f 1f 84 00 00 00 00 00 48 c7 c6 f8 18 37 93 48 89 df e8 e1 8b 93 fe <0f> 0b 48 89 de 48 c7 c7 30 bd 9f 95 48 89 4d b8 e8 10 5f 02 0f All code 0: 48 83 c4 38 add$0x38,%rsp 4: 44 89 f0mov%r14d,%eax 7: 5b pop%rbx 8: 41 5c pop%r12 a: 41 5d pop%r13 c: 41 5e pop%r14 e: 41 5f pop%r15 10: 5d pop%rbp 11: c3 retq 12: 66 2e 0f 1f 84 00 00nopw %cs:0x0(%rax,%rax,1) 19: 00 00 00 1c: 48 c7 c6 f8 18 37 93mov$0x933718f8,%rsi 23: 48 89 dfmov%rbx,%rdi 26: e8 e1 8b 93 fe callq 0xfe938c0c 2b:* 0f 0b ud2 <-- trapping instruction 2d: 48 89 de
Re: [PATCH v2] x86, mm: set NX across entire PMD at boot
On Fri, Nov 14, 2014 at 5:29 PM, Yinghai Lu wrote: > On Fri, Nov 14, 2014 at 12:45 PM, Kees Cook wrote: >> When setting up permissions on kernel memory at boot, the end of the >> PMD that was split from bss remained executable. It should be NX like >> the rest. This performs a PMD alignment instead of a PAGE alignment to >> get the correct span of memory, and should be freed. >> >> Before: >> ---[ High Kernel Mapping ]--- >> ... >> 0x8202d000-0x8220 1868K RW GLB NX pte >> 0x8220-0x82c010M RW PSE GLB NX pmd >> 0x82c0-0x82df5000 2004K RW GLB NX pte >> 0x82df5000-0x82e044K RW GLB x pte >> 0x82e0-0xc000 978M pmd >> >> After: >> ---[ High Kernel Mapping ]--- >> ... >> 0x8202d000-0x8220 1868K RW GLB NX pte >> 0x8220-0x82c010M RW PSE GLB NX pmd >> 0x82c0-0x82df5000 2004K RW GLB NX pte >> 0x82df5000-0x82e044K RW NX pte >> 0x82e0-0xc000 978M pmd >> >> Signed-off-by: Kees Cook >> --- >> v2: >> - added call to free_init_pages(), as suggested by tglx >> --- >> arch/x86/mm/init_64.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c >> index 4cb8763868fc..0d498c922668 100644 >> --- a/arch/x86/mm/init_64.c >> +++ b/arch/x86/mm/init_64.c >> @@ -1124,6 +1124,7 @@ void mark_rodata_ro(void) >> unsigned long text_end = PFN_ALIGN(&__stop___ex_table); >> unsigned long rodata_end = PFN_ALIGN(&__end_rodata); >> unsigned long all_end = PFN_ALIGN(&_end); >> + unsigned long pmd_end = roundup(all_end, PMD_SIZE); >> >> printk(KERN_INFO "Write protecting the kernel read-only data: >> %luk\n", >>(end - start) >> 10); >> @@ -1135,7 +1136,7 @@ void mark_rodata_ro(void) >> * The rodata/data/bss/brk section (but not the kernel text!) >> * should also be not-executable. >> */ >> - set_memory_nx(rodata_start, (all_end - rodata_start) >> PAGE_SHIFT); >> + set_memory_nx(rodata_start, (pmd_end - rodata_start) >> PAGE_SHIFT); >> >> rodata_test(); >> >> @@ -1147,6 +1148,7 @@ void mark_rodata_ro(void) >> set_memory_ro(start, (end-start) >> PAGE_SHIFT); >> #endif >> >> + free_init_pages("unused kernel", all_end, pmd_end); >> free_init_pages("unused kernel", >> (unsigned long) __va(__pa_symbol(text_end)), >> (unsigned long) __va(__pa_symbol(rodata_start))); > > something is wrong: > > [7.842479] Freeing unused kernel memory: 3844K (82e52000 - > 83213000) > [7.843305] Write protecting the kernel read-only data: 28672k > [7.844433] BUG: Bad page state in process swapper/0 pfn:043c0 > [7.845093] page:ea10f000 count:0 mapcount:-127 mapping: > (null) index:0x2 > [7.846388] flags: 0x10() > [7.846871] page dumped because: nonzero mapcount > [7.847343] Modules linked in: > [7.847719] CPU: 2 PID: 1 Comm: swapper/0 Not tainted > 3.18.0-rc4-yh-01896-g40204c8-dirty #23 > [7.848809] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), > BIOS rel-1.7.5-0-ge51488c-20140602_164612-nilsson.home.kraxel.org > 04/01/2014 > [7.850014] 828300ca 880078babd68 81ff47d0 > 0001 > [7.850857] ea10f000 880078babd98 8118c2bd > 001d4cc0 > [7.851791] ea10f000 ea10f000 > 880078babdf8 > [7.852700] Call Trace: > [7.852991] [] dump_stack+0x45/0x57 > [7.853494] [] bad_page+0xfd/0x130 > [7.854130] [] free_pages_prepare+0x13c/0x1c0 > [7.854808] [] ? adjust_managed_page_count+0x5d/0x70 > [7.855575] [] free_hot_cold_page+0x35/0x180 > [7.856326] [] __free_pages+0x13/0x40 > [7.856854] [] free_reserved_area+0xcd/0x140 > [7.857442] [] free_init_pages+0x98/0xb0 > [7.858001] [] mark_rodata_ro+0xb5/0x120 > [7.858622] [] ? rest_init+0xc0/0xc0 > [7.859174] [] kernel_init+0x1d/0x100 > [7.859724] [] ret_from_fork+0x7c/0xb0 > [7.860279] [] ? rest_init+0xc0/0xc0 > [7.860836] Disabling lock debugging due to kernel taint > [7.861432] Freeing unused kernel memory: 376K (843a2000 - > 8440) > [7.866118] Freeing unused kernel memory: 1980K (880002011000 - > 88000220) > [7.870525] Freeing unused kernel memory: 1932K (880002a1d000 - > 880002c0) Also, what tree is this? "Freeing %s" went away in c88442ec45f30d587b38b935a14acde4e217a926 (and should probably be re-added, which is what I assume has happened.) > > [0.00] .text: [0x0100-0x0200d548] > [0.00] .rodata: [0x0220-0x
Re: [PATCH v2] kernel: use the gnu89 standard explicitly
On 11/14/2014 08:43 AM, Andrey Ryabinin wrote: > 2014-10-20 5:40 GMT+03:00 Sasha Levin : >> gcc5 changes the default standard to c11, which makes kernel >> build unhappy. >> >> Explicitly define the kernel standard to be gnu89 which should >> keep everything working exactly like it was before gcc5. >> > > Ping. > fwiw, I'm happy with using Kirill's patch from this thread, it even has his SoB! :) Thanks, Sasha -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RESUBMIT] [PATCH] Replace mentions of "list_struct" to "list_head"
On Fri, Nov 14, 2014 at 05:09:55AM +0400, Andrey Utkin wrote: > There's no such thing as "list_struct". > > Signed-off-by: Andrey Utkin May as well get group rates on the acks... ;-) Acked-by: Paul E. McKenney > --- > drivers/gpu/drm/radeon/mkregtable.c | 24 > drivers/media/pci/cx18/cx18-driver.h | 2 +- > include/linux/list.h | 34 +- > include/linux/plist.h| 10 +- > include/linux/rculist.h | 8 > scripts/kconfig/list.h | 6 +++--- > tools/usb/usbip/libsrc/list.h| 2 +- > 7 files changed, 43 insertions(+), 43 deletions(-) > > diff --git a/drivers/gpu/drm/radeon/mkregtable.c > b/drivers/gpu/drm/radeon/mkregtable.c > index 4a85bb6..b928c17 100644 > --- a/drivers/gpu/drm/radeon/mkregtable.c > +++ b/drivers/gpu/drm/radeon/mkregtable.c > @@ -347,7 +347,7 @@ static inline void list_splice_tail_init(struct list_head > *list, > * list_entry - get the struct for this entry > * @ptr: the &struct list_head pointer. > * @type:the type of the struct this is embedded in. > - * @member: the name of the list_struct within the struct. > + * @member: the name of the list_head within the struct. > */ > #define list_entry(ptr, type, member) \ > container_of(ptr, type, member) > @@ -356,7 +356,7 @@ static inline void list_splice_tail_init(struct list_head > *list, > * list_first_entry - get the first element from a list > * @ptr: the list head to take the element from. > * @type:the type of the struct this is embedded in. > - * @member: the name of the list_struct within the struct. > + * @member: the name of the list_head within the struct. > * > * Note, that list is expected to be not empty. > */ > @@ -406,7 +406,7 @@ static inline void list_splice_tail_init(struct list_head > *list, > * list_for_each_entry - iterate over list of given type > * @pos: the type * to use as a loop cursor. > * @head:the head for your list. > - * @member: the name of the list_struct within the struct. > + * @member: the name of the list_head within the struct. > */ > #define list_for_each_entry(pos, head, member) > \ > for (pos = list_entry((head)->next, typeof(*pos), member); \ > @@ -417,7 +417,7 @@ static inline void list_splice_tail_init(struct list_head > *list, > * list_for_each_entry_reverse - iterate backwards over list of given type. > * @pos: the type * to use as a loop cursor. > * @head:the head for your list. > - * @member: the name of the list_struct within the struct. > + * @member: the name of the list_head within the struct. > */ > #define list_for_each_entry_reverse(pos, head, member) > \ > for (pos = list_entry((head)->prev, typeof(*pos), member); \ > @@ -428,7 +428,7 @@ static inline void list_splice_tail_init(struct list_head > *list, > * list_prepare_entry - prepare a pos entry for use in > list_for_each_entry_continue() > * @pos: the type * to use as a start point > * @head:the head of the list > - * @member: the name of the list_struct within the struct. > + * @member: the name of the list_head within the struct. > * > * Prepares a pos entry for use as a start point in > list_for_each_entry_continue(). > */ > @@ -439,7 +439,7 @@ static inline void list_splice_tail_init(struct list_head > *list, > * list_for_each_entry_continue - continue iteration over list of given type > * @pos: the type * to use as a loop cursor. > * @head:the head for your list. > - * @member: the name of the list_struct within the struct. > + * @member: the name of the list_head within the struct. > * > * Continue to iterate over list of given type, continuing after > * the current position. > @@ -453,7 +453,7 @@ static inline void list_splice_tail_init(struct list_head > *list, > * list_for_each_entry_continue_reverse - iterate backwards from the given > point > * @pos: the type * to use as a loop cursor. > * @head:the head for your list. > - * @member: the name of the list_struct within the struct. > + * @member: the name of the list_head within the struct. > * > * Start to iterate over list of given type backwards, continuing after > * the current position. > @@ -467,7 +467,7 @@ static inline void list_splice_tail_init(struct list_head > *list, > * list_for_each_entry_from - iterate over list of given type from the > current point > * @pos: the type * to use as a loop cursor. > * @head:the head for your list. > - * @member: the name of the list_struct within the struct. > + * @member: the name of the list_head within the struct. > * > * Iterate over list of given type, continuing from current position. > */ > @@ -480,7 +480,7 @@ static inline void list_splice_tail_init(struct list_head > *list, > * @pos: the type * to u
Re: [PATCH v2] x86, mm: set NX across entire PMD at boot
On Fri, Nov 14, 2014 at 6:29 PM, Yinghai Lu wrote: > On Fri, Nov 14, 2014 at 5:29 PM, Yinghai Lu wrote: >> On Fri, Nov 14, 2014 at 12:45 PM, Kees Cook wrote: >>> v2: >>> - added call to free_init_pages(), as suggested by tglx > >> something is wrong: >> >> [7.842479] Freeing unused kernel memory: 3844K (82e52000 - >> 83213000) >> [7.843305] Write protecting the kernel read-only data: 28672k > > > should use attached one instead. > > 1. should use _brk_end instead of &end, as we only use partial of >brk. > 2. [_brk_end, pm_end) page range is already converted. aka >is not wasted. Are you sure? For me, _brk_end isn't far enough: [1.475572] all_end: 0x82df5000 [1.476736] _brk_end: 0x82dd6000 > > --- > arch/x86/mm/init_64.c |6 -- > 1 file changed, 4 insertions(+), 2 deletions(-) > > Index: linux-2.6/arch/x86/mm/init_64.c > === > --- linux-2.6.orig/arch/x86/mm/init_64.c > +++ linux-2.6/arch/x86/mm/init_64.c > @@ -1124,7 +1124,8 @@ void mark_rodata_ro(void) > unsigned long end = (unsigned long) &__end_rodata_hpage_align; > unsigned long text_end = PFN_ALIGN(&__stop___ex_table); > unsigned long rodata_end = PFN_ALIGN(&__end_rodata); > -unsigned long all_end = PFN_ALIGN(&_end); > +unsigned long all_end = PFN_ALIGN(_brk_end); > +unsigned long pmd_end = roundup(all_end, PMD_SIZE); > > printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n", > (end - start) >> 10); > @@ -1136,7 +1137,7 @@ void mark_rodata_ro(void) > * The rodata/data/bss/brk section (but not the kernel text!) > * should also be not-executable. > */ > -set_memory_nx(rodata_start, (all_end - rodata_start) >> PAGE_SHIFT); > +set_memory_nx(rodata_start, (pmd_end - rodata_start) >> PAGE_SHIFT); > > rodata_test(); > > @@ -1148,6 +1149,7 @@ void mark_rodata_ro(void) > set_memory_ro(start, (end-start) >> PAGE_SHIFT); > #endif > > +/* all_end to pmd_end is handled via free_all_bootmem() */ > free_init_pages("unused kernel", > (unsigned long) __va(__pa_symbol(text_end)), > (unsigned long) __va(__pa_symbol(rodata_start))); This patch produces the same results as my v1 patch: 0x8202d000-0x8220 1868K RW GLB NX pte 0x8220-0x82e012M RW PSE GLB NX pmd 0x82e0-0xc000 978M pmd Is this correct? It sounded like tglx wanted the pmd split, like this: 0x8220-0x82c010M RW PSE GLB NX pmd 0x82c0-0x82df5000 2004K RW GLB NX pte 0x82df5000-0x82e044K RW NX pte 0x82e0-0xc000 978M pmd -Kees -- Kees Cook Chrome OS Security -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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 Sat, Nov 15, 2014 at 01:36:41AM +0100, Thomas Gleixner wrote: > On Fri, 14 Nov 2014, Dave Jones wrote: > > > On Fri, Nov 14, 2014 at 11:55:30PM +0100, Thomas Gleixner wrote: > > > > > So this looks more like a smp function call fuckup. > > > > > > I assume Dave is running that stuff on KVM. So it might be worth while > > > to look at the IPI magic there. > > > > no, bare metal. > > Ok, but that does not change the fact that we are stuck in > smp_function_call land. > > Enabling softlockup_all_cpu_backtrace will probably not help much as > we will end up waiting for csd_lock again :( > > Is the machine still accesible when this happens? If yes, we might > enable a few trace points and functions and read out the trace > buffer. If not, we could just panic the machine and dump the trace > buffer over serial. No, it wedges solid. Even though it says something like "CPU3 locked up", aparently all cores also get stuck. 9 times out of 10 it doesn't stay alive long enough to even get the full trace out over usb-serial. Dave -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v4] sched/numa: fix unsafe get_task_struct() in task_numa_assign()
On 11/10/2014 11:03 AM, Peter Zijlstra wrote: > On Fri, Nov 07, 2014 at 10:48:27PM -0500, Sasha Levin wrote: >> > [ 829.539183] BUG: spinlock recursion on CPU#10, trinity-c594/11067 >> > [ 829.539203] lock: 0x880631dd6b80, .magic: dead4ead, .owner: >> > trinity-c594/11067, .owner_cpu: 13 > Ooh, look at that. CPU#10 vs .owner_cpu: 13 on the _same_ task. > > One of those again :/ This actually reproduces pretty easily. The stack trace seems to be different but the end result is the same as above. Anything we can do to debug it? I'm really not sure how just the owner_cpu can be different here. Thanks, Sasha -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2] x86, mm: set NX across entire PMD at boot
On Fri, Nov 14, 2014 at 5:29 PM, Yinghai Lu wrote: > On Fri, Nov 14, 2014 at 12:45 PM, Kees Cook wrote: >> v2: >> - added call to free_init_pages(), as suggested by tglx > something is wrong: > > [7.842479] Freeing unused kernel memory: 3844K (82e52000 - > 83213000) > [7.843305] Write protecting the kernel read-only data: 28672k should use attached one instead. 1. should use _brk_end instead of &end, as we only use partial of brk. 2. [_brk_end, pm_end) page range is already converted. aka is not wasted. --- arch/x86/mm/init_64.c |6 -- 1 file changed, 4 insertions(+), 2 deletions(-) Index: linux-2.6/arch/x86/mm/init_64.c === --- linux-2.6.orig/arch/x86/mm/init_64.c +++ linux-2.6/arch/x86/mm/init_64.c @@ -1124,7 +1124,8 @@ void mark_rodata_ro(void) unsigned long end = (unsigned long) &__end_rodata_hpage_align; unsigned long text_end = PFN_ALIGN(&__stop___ex_table); unsigned long rodata_end = PFN_ALIGN(&__end_rodata); -unsigned long all_end = PFN_ALIGN(&_end); +unsigned long all_end = PFN_ALIGN(_brk_end); +unsigned long pmd_end = roundup(all_end, PMD_SIZE); printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n", (end - start) >> 10); @@ -1136,7 +1137,7 @@ void mark_rodata_ro(void) * The rodata/data/bss/brk section (but not the kernel text!) * should also be not-executable. */ -set_memory_nx(rodata_start, (all_end - rodata_start) >> PAGE_SHIFT); +set_memory_nx(rodata_start, (pmd_end - rodata_start) >> PAGE_SHIFT); rodata_test(); @@ -1148,6 +1149,7 @@ void mark_rodata_ro(void) set_memory_ro(start, (end-start) >> PAGE_SHIFT); #endif +/* all_end to pmd_end is handled via free_all_bootmem() */ free_init_pages("unused kernel", (unsigned long) __va(__pa_symbol(text_end)), (unsigned long) __va(__pa_symbol(rodata_start))); 1. should use _brk_end instead of &end, as we only use partial of brk. 2. [_brk_end, pm_end) page range is already converted. aka is not wasted. --- arch/x86/mm/init_64.c |6 -- 1 file changed, 4 insertions(+), 2 deletions(-) Index: linux-2.6/arch/x86/mm/init_64.c === --- linux-2.6.orig/arch/x86/mm/init_64.c +++ linux-2.6/arch/x86/mm/init_64.c @@ -1124,7 +1124,8 @@ void mark_rodata_ro(void) unsigned long end = (unsigned long) &__end_rodata_hpage_align; unsigned long text_end = PFN_ALIGN(&__stop___ex_table); unsigned long rodata_end = PFN_ALIGN(&__end_rodata); - unsigned long all_end = PFN_ALIGN(&_end); + unsigned long all_end = PFN_ALIGN(_brk_end); + unsigned long pmd_end = roundup(all_end, PMD_SIZE); printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n", (end - start) >> 10); @@ -1136,7 +1137,7 @@ void mark_rodata_ro(void) * The rodata/data/bss/brk section (but not the kernel text!) * should also be not-executable. */ - set_memory_nx(rodata_start, (all_end - rodata_start) >> PAGE_SHIFT); + set_memory_nx(rodata_start, (pmd_end - rodata_start) >> PAGE_SHIFT); rodata_test(); @@ -1148,6 +1149,7 @@ void mark_rodata_ro(void) set_memory_ro(start, (end-start) >> PAGE_SHIFT); #endif + /* all_end to pmd_end is handled via free_all_bootmem() */ free_init_pages("unused kernel", (unsigned long) __va(__pa_symbol(text_end)), (unsigned long) __va(__pa_symbol(rodata_start)));
Re: simd: Allow simd use in kernel threads with softirqs disabled
On Fri, Nov 14, 2014 at 05:17:05PM +0100, Ard Biesheuvel wrote: > On 14 November 2014 16:43, Herbert Xu wrote: > > While working on the cryptd request reordering problem, I noticed > > an anomaly where kernel threads are normally allowed to use simd > > per may_use_simd, but as soon as you disable softirqs, they suddenly > > lose that ability for no good reason. > > > > The problem is that in_interrupt does not distinguish between > > softirq processing and simply having softirqs disabled. This > > patch creates a new helper in_serving_interrupt which makes that > > distinction. It then uses this in all current implementations > > of may_use_simd. > > > > Isn't that a much more widespread problem if in_interrupt() yields > true while no interrupt is being served? Good point. Other users of in_interrupt() are just as likely to really want the in_serving version. However, the safe option is to leave them unchanged until we audit each single one. If it turns out that all users of in_interrupt() decay into in_serving_interrupt() then we could remove in_interrupt(). Cheers, -- Email: Herbert Xu 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/
[PATCH] DTS: ARM: OMAP3-N900: Add n900-battery support
This adds support for the N900's battery to the Nokia N900 DTS file. Signed-off-by: Sebastian Reichel --- arch/arm/boot/dts/omap3-n900.dts | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts index bc82a12..39778e5 100644 --- a/arch/arm/boot/dts/omap3-n900.dts +++ b/arch/arm/boot/dts/omap3-n900.dts @@ -115,6 +115,12 @@ eci-switch-gpios = <&gpio6 22 GPIO_ACTIVE_HIGH>; /* 182 */ speaker-amplifier-gpios = <&twl_gpio 7 GPIO_ACTIVE_HIGH>; }; + + battery: n900-battery { + compatible = "nokia,n900-battery"; + io-channels = <&twl_madc 0>, <&twl_madc 4>, <&twl_madc 12>; + io-channel-names = "temp", "bsi", "vbat"; + }; }; &omap3_pmx_core { -- 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/
Re: [PATCH 2/2] dma-debug: prevent early callers from crashing
On 11/13/2014 08:31 PM, Florian Fainelli wrote: > dma_debug_init() is called by architecture specific code at different > levels, but typically as a fs_initcall due to the debugfs > initialization. Some platforms may have early callers of the DMA-API, > running prior to the fs_initcall() level, which is not much of an issue > unless CONFIG_DMA_API_DEBUG is set. Whe the DMA-API debugging facilities > are turned on a caller will go through: > > debug_dma_map_{single,page} > -> dma_mapping_error (inline function usually) > -> debug_dma_mapping_error > -> get_hash_bucket > > Calling get_hash_bucket() returns a valid hash value since we hash on > high bits of the dma_addr cookie, but we will grab an unitialized > spinlock, which typically won't crash but produce a warning, the real > crash will however happen during the bucket list traversal because the > list has not been initialized yet. > > An obvious solution is of course to move some of the offenders to run > after the fs_initcall level, but since this might not always be an > option, we add a flag "dma_debug_initialized" which is set to false by > default, and set to true once dma_debug_init() has had a chance to run. > > The dma_debug_disabled() helper function previously introduced just > needs to check for dma_debug_initialized to allow the caller to proceed > or not. BTW, one approach I initially took was to add an "initialized" flag to the hash bucket structure that would be set to false by default, set to true once we have initialized the array in dma_debug_init(). The problem with that is that debug_dma_mapping_error() returns void, so we can't propagate an error back to the caller: debug_dma_map_page(). debug_dma_map_page() then proceeds with creating a new entry, but since we still have not initialized everything, in particular the free_entries list is empty, and this triggers a fatal error that leads to setting global_disable, not ideal, hence this approach. > > Signed-off-by: Florian Fainelli > --- > lib/dma-debug.c | 12 ++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/lib/dma-debug.c b/lib/dma-debug.c > index 1ac35dbaf8e0..9722bd2dbc9b 100644 > --- a/lib/dma-debug.c > +++ b/lib/dma-debug.c > @@ -102,9 +102,12 @@ static DEFINE_SPINLOCK(free_entries_lock); > /* Global disable flag - will be set in case of an error */ > static u32 global_disable __read_mostly; > > +/* Early initialization disable flag, set at the end of dma_debug_init */ > +static bool dma_debug_initialized __read_mostly; > + > static inline bool dma_debug_disabled(void) > { > - return global_disable; > + return global_disable || !dma_debug_initialized; > } > > /* Global error count */ > @@ -999,7 +1002,10 @@ void dma_debug_init(u32 num_entries) > { > int i; > > - if (dma_debug_disabled()) > + /* Do not use dma_debug_initialized here, since we really want to be > + * called to set dma_debug_initialized > + */ > + if (global_disable) > return; > > for (i = 0; i < HASH_SIZE; ++i) { > @@ -1026,6 +1032,8 @@ void dma_debug_init(u32 num_entries) > > nr_total_entries = num_free_entries; > > + dma_debug_initialized = true; > + > pr_info("DMA-API: debugging enabled by kernel config\n"); > } > > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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 Fri, Nov 14, 2014 at 2:55 PM, Thomas Gleixner wrote: > > This stale entry is not relevant here because the thing is stuck in > generic_exec_single(). That wasn't really my argument. The fact that "do_flush_tlb_all()" was left over on the stack frame implies that we're not doing the range-flush, and if it was some odd bug with a negative range or something like that (due to the fix in commit ce9ec37bddb6), I'd expect the lockup to be due to a hung do_kernel_range_flush() or something. But the range flushing never even happens. > So from smp_call_function_many() we end up via > smp_call_function_single() in generic_exec_single(). > > So the only ways to get stuck there are: > > csd_lock(csd); > and > csd_lock_wait(csd); Judging by the code disassembly, it's the "csd_lock_wait(csd)" at the end. The disassembly looks like 29: f3 90 pause 2b:* f6 43 18 01 testb $0x1,0x18(%rbx) <-- trapping instruction 2f: 75 f8 jne0x29 31: 31 c0 xor%eax,%eax and that "xor %eax,%eax" seems to be part of the "return 0" immediately afterwards. But that's not entirely conclusive, it's just a strong hint. It does sound like there might be some IPI issue. I just don't see *any* changes in this area since 3.17. Some unrelated APIC change? I don't see that either. As you noted, there are KVM changes, but apparently that isn't involved either. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] ARM: DTS: OMAP3-N900: add si4713 support
Add si4713 node to the N900 device tree file. Signed-off-by: Sebastian Reichel --- arch/arm/boot/dts/omap3-n900.dts | 10 ++ 1 file changed, 10 insertions(+) diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts index 9b0494a..81c99f3 100644 --- a/arch/arm/boot/dts/omap3-n900.dts +++ b/arch/arm/boot/dts/omap3-n900.dts @@ -540,6 +540,16 @@ power-gpio = <&gpio4 2 GPIO_ACTIVE_HIGH>; /* 98 */ }; + si4713: si4713@63 { + compatible = "silabs,si4713"; +reg = <0x63>; + +interrupts-extended = <&gpio2 21 IRQ_TYPE_EDGE_FALLING>; /* 53 */ +reset-gpios = <&gpio6 3 GPIO_ACTIVE_HIGH>; /* 163 */ +vio-supply = <&vio>; +vdd-supply = <&vaux1>; + }; + bq24150a: bq24150a@6b { compatible = "ti,bq24150a"; reg = <0x6b>; -- 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/
Re: [PATCH 2/2] ARM: dts: Add devicetree for NovaTech OrionLXm
Hi, On Fri, Nov 14, 2014 at 04:47:02PM -0600, George McCollister wrote: > Felipe, > > Thank you for your reply. no problem > >> + vbat: fixedregulator@0 { > >> + compatible = "regulator-fixed"; > >> + regulator-name = "vbat"; > >> + regulator-min-microvolt = <500>; > >> + regulator-max-microvolt = <500>; > >> + regulator-boot-on; > >> + }; > > > > I suppose this is the 5V on a power jack, or something like that ? > > It comes with one of three different power supplies (24 - 250VDC, 120 > - 240VAC, 12VDC input) all of which ultimately supply a fixed 5V and > 3.3V. Alright :-) Thanks. Do you mind adding a comment on this DTS stating that just so people don't get confused ? > > > >> + vmmcsd_fixed: fixedregulator@0 { > >> + compatible = "regulator-fixed"; > >> + regulator-name = "vmmcsd_fixed"; > >> + regulator-min-microvolt = <330>; > >> + regulator-max-microvolt = <330>; > > > > but this... I know every other board devices this as a fixed regulator, > > but is it really a fixed regulator or is supplied by one of the LDOs on > > the PMIC ? > > > > It's actually fixed (not from TP65910). Oh, so this 3.3V fixed rail is the same one derived from from the three possible power supplies you described above ? > >> +&am33xx_pinmux { > >> + mmc1_pins: pinmux_mmc1_pins { > >> + pinctrl-single,pins = < > >> + 0xf0 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat3 > >> */ > >> + 0xf4 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat2 > >> */ > >> + 0xf8 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat1 > >> */ > >> + 0xfc (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat0 > >> */ > >> + 0x100 (PIN_INPUT_PULLUP | MUX_MODE0)/* mmc0_clk > >> */ > >> + 0x104 (PIN_INPUT_PULLUP | MUX_MODE0)/* mmc0_cmd > >> */ > >> + >; > >> + }; > >> + > >> + i2c0_pins: pinmux_i2c0_pins { > >> + pinctrl-single,pins = < > >> + 0x188 (PIN_INPUT_PULLUP | MUX_MODE0)/* > >> i2c0_sda.i2c0_sda */ > >> + 0x18c (PIN_INPUT_PULLUP | MUX_MODE0)/* > >> i2c0_scl.i2c0_scl */ > >> + >; > >> + }; > >> + > >> + i2c2_pins: pinmux_i2c2_pins { > >> + pinctrl-single,pins = < > >> + 0x178 (PIN_INPUT_PULLUP | MUX_MODE3)/* > >> uart1_ctsn.i2c2_sda */ > >> + 0x17c (PIN_INPUT_PULLUP | MUX_MODE3)/* > >> uart1_rtsn.i2c2_scl */ > > > > on thing to keep in mind, if you already have external pullups, you > > might not want to add internal pullups as you'd end up with both > > resistors in parallel. For I2C the danger is minimal (unless you have a > > ton of bus capacitance, then it changes high/low time), but it's best to > > write a more "pristine" DTS. (and sure, I know pretty much every board > > makes this mistake, but it's best if we don't proliferate the error) > > I'll make sure this is correct and include any required changes in the > next version of the patch series. cool, thanks > >> +&i2c0 { > >> + pinctrl-names = "default"; > >> + pinctrl-0 = <&i2c0_pins>; > >> + > >> + status = "okay"; > >> + clock-frequency = <40>; > >> + > >> + serial_config1: serial_config1@20 { > >> + compatible = "nxp,pca9539"; > >> + reg = <0x20>; > >> + }; > >> + > >> + serial_config2: serial_config2@21 { > >> + compatible = "nxp,pca9539"; > >> + reg = <0x21>; > >> + }; > >> + > >> + tps: tps@2d { > >> + reg = <0x2d>; > > > > which TPS device ? no compatible ? > > > >> +/include/ "tps65910.dtsi" > > > > oh... okay. > > I'm assuming that means you're okay with this (if not please elaborate > on how to improve it). sure, i'm okay. But it's still nice to add a compatible to that tps node, then again, it's added to tps65910.dtsi so that would be a very minor nit. > >> +&tps { > >> + vcc1-supply = <&vbat>; > >> + vcc2-supply = <&vbat>; > >> + vcc3-supply = <&vbat>; > >> + vcc4-supply = <&vbat>; > >> + vcc5-supply = <&vbat>; > >> + vcc6-supply = <&vbat>; > >> + vcc7-supply = <&vbat>; > >> + vccio-supply = <&vbat>; > >> + > >> + regulators { > >> + vrtc_reg: regulator@0 { > >> + regulator-always-on; > > > > this should not be always on, you want to pass this as supply to the RTC > > module so it can manage it. It's also best to give names to all > > regulators, so people know what they're used for. > > I think we may actually be able to turn this one and possibly two > others off, I will investigate. > > I've come up with names for all of the regulators being used and will > include the changes in the next version of the patch series. Thanks, that helps reviewing the validity of
Re: [RFC PATCH 0/7] Replace _PAGE_NUMA with PAGE_NONE protections
On Fri, Nov 14, 2014 at 5:32 AM, Mel Gorman wrote: > > This series is very heavily based on patches from Linus and Aneesh to > replace the existing PTE/PMD NUMA helper functions with normal change > protections. I did alter and add parts of it but I consider them relatively > minor contributions. Note that the signed-offs here need addressing. I > couldn't use "From" or Signed-off-by from the original authors as the > patches had to be broken up and they were never signed off. I expect the > two people involved will just stick their signed-off-by on it. Feel free to just take authorship of my parts, and make my "Needs-sign-off's" be just "Acked-by:" Or alternatively keep them as "Signed-off-by:", even when it looks a bit odd if it doesn't have a "From:" me, when the actual patch won't then actually go through me - I'm assuming this will come in through the -mm tree. As to the ppc parts, obviously it would be good to have Aneesh re-test the series.. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] timekeeping: Move persistent clock registration code from ARM to kernel
On Sat, 15 Nov 2014, Thomas Gleixner wrote: > On Fri, 14 Nov 2014, Anatol Pomozov wrote: > > On Fri, Nov 14, 2014 at 4:18 PM, Thomas Gleixner wrote: > > >> So what I suppose to do with my patch? If it does not work could > > >> anyone provide patch that removes ARM arch dependency from > > >> tegra20_timer.c? > > > > > > Huch? You want other people to solve your problems? > > > > This is not the point. I provided patch that fixes the issue. Other > > people said that they have ideas how to do it different (and better) > > way. So I am asking to share these ideas represented as a patch. > > That's not the way it works. > > You sent a patch to solve an problem which you are facing. > > Now the people who review the patch think that there is a better > approach than moving code from arm/ to the timekeeping core code. > > So it's up to you to come up with a patch which solves the problem in > the right way. And just for the record this whole thing is just hilarious. ARM64 selects ARM_ARCH_TIMER which registers the architected timer as the primary clocksource. Now that timer has the following flag set: CLOCK_SOURCE_SUSPEND_NONSTOP And that flag causes the core timekeeping code to use the clocksource to figure out the time which the machine spent in suspend. So registering that tegra RTC as persistent clock does not have any value at all. Simply because it is completely irrelevant at boot time whether the RTC can be accessed right at timekeeping init or not. Nothing in early boot needs wall clock time. It's good enough to set wall clock time late in the boot process as the first use case is when the root file system gets mounted. And the RTC driver which obviously deals with the same hardware is initialized before that. So you are trying to move something which is outright pointless to the core code just because you carry that patch in your ChromeOS support hackery. Thanks, tglx -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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] mmu_gather: move minimal range calculations into generic code
On Fri, Nov 14, 2014 at 9:10 AM, Will Deacon wrote: > > Cc: Linus Torvalds Make that an Acked-by, it still looks fine to me. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2] x86, mm: set NX across entire PMD at boot
On Fri, Nov 14, 2014 at 12:45 PM, Kees Cook wrote: > When setting up permissions on kernel memory at boot, the end of the > PMD that was split from bss remained executable. It should be NX like > the rest. This performs a PMD alignment instead of a PAGE alignment to > get the correct span of memory, and should be freed. > > Before: > ---[ High Kernel Mapping ]--- > ... > 0x8202d000-0x8220 1868K RW GLB NX pte > 0x8220-0x82c010M RW PSE GLB NX pmd > 0x82c0-0x82df5000 2004K RW GLB NX pte > 0x82df5000-0x82e044K RW GLB x pte > 0x82e0-0xc000 978M pmd > > After: > ---[ High Kernel Mapping ]--- > ... > 0x8202d000-0x8220 1868K RW GLB NX pte > 0x8220-0x82c010M RW PSE GLB NX pmd > 0x82c0-0x82df5000 2004K RW GLB NX pte > 0x82df5000-0x82e044K RW NX pte > 0x82e0-0xc000 978M pmd > > Signed-off-by: Kees Cook > --- > v2: > - added call to free_init_pages(), as suggested by tglx > --- > arch/x86/mm/init_64.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c > index 4cb8763868fc..0d498c922668 100644 > --- a/arch/x86/mm/init_64.c > +++ b/arch/x86/mm/init_64.c > @@ -1124,6 +1124,7 @@ void mark_rodata_ro(void) > unsigned long text_end = PFN_ALIGN(&__stop___ex_table); > unsigned long rodata_end = PFN_ALIGN(&__end_rodata); > unsigned long all_end = PFN_ALIGN(&_end); > + unsigned long pmd_end = roundup(all_end, PMD_SIZE); > > printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n", >(end - start) >> 10); > @@ -1135,7 +1136,7 @@ void mark_rodata_ro(void) > * The rodata/data/bss/brk section (but not the kernel text!) > * should also be not-executable. > */ > - set_memory_nx(rodata_start, (all_end - rodata_start) >> PAGE_SHIFT); > + set_memory_nx(rodata_start, (pmd_end - rodata_start) >> PAGE_SHIFT); > > rodata_test(); > > @@ -1147,6 +1148,7 @@ void mark_rodata_ro(void) > set_memory_ro(start, (end-start) >> PAGE_SHIFT); > #endif > > + free_init_pages("unused kernel", all_end, pmd_end); > free_init_pages("unused kernel", > (unsigned long) __va(__pa_symbol(text_end)), > (unsigned long) __va(__pa_symbol(rodata_start))); something is wrong: [7.842479] Freeing unused kernel memory: 3844K (82e52000 - 83213000) [7.843305] Write protecting the kernel read-only data: 28672k [7.844433] BUG: Bad page state in process swapper/0 pfn:043c0 [7.845093] page:ea10f000 count:0 mapcount:-127 mapping: (null) index:0x2 [7.846388] flags: 0x10() [7.846871] page dumped because: nonzero mapcount [7.847343] Modules linked in: [7.847719] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 3.18.0-rc4-yh-01896-g40204c8-dirty #23 [7.848809] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.7.5-0-ge51488c-20140602_164612-nilsson.home.kraxel.org 04/01/2014 [7.850014] 828300ca 880078babd68 81ff47d0 0001 [7.850857] ea10f000 880078babd98 8118c2bd 001d4cc0 [7.851791] ea10f000 ea10f000 880078babdf8 [7.852700] Call Trace: [7.852991] [] dump_stack+0x45/0x57 [7.853494] [] bad_page+0xfd/0x130 [7.854130] [] free_pages_prepare+0x13c/0x1c0 [7.854808] [] ? adjust_managed_page_count+0x5d/0x70 [7.855575] [] free_hot_cold_page+0x35/0x180 [7.856326] [] __free_pages+0x13/0x40 [7.856854] [] free_reserved_area+0xcd/0x140 [7.857442] [] free_init_pages+0x98/0xb0 [7.858001] [] mark_rodata_ro+0xb5/0x120 [7.858622] [] ? rest_init+0xc0/0xc0 [7.859174] [] kernel_init+0x1d/0x100 [7.859724] [] ret_from_fork+0x7c/0xb0 [7.860279] [] ? rest_init+0xc0/0xc0 [7.860836] Disabling lock debugging due to kernel taint [7.861432] Freeing unused kernel memory: 376K (843a2000 - 8440) [7.866118] Freeing unused kernel memory: 1980K (880002011000 - 88000220) [7.870525] Freeing unused kernel memory: 1932K (880002a1d000 - 880002c0) [0.00] .text: [0x0100-0x0200d548] [0.00] .rodata: [0x0220-0x02a1cfff] [0.00] .data: [0x02c0-0x02e50e7f] [0.00] .init: [0x02e52000-0x03212fff] [0.00].bss: [0x03221000-0x0437bfff] [0.00].brk: [0x0437c000-0x043a1fff] -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.o
Re: [patch 07/16] genirq: Introduce helper irq_domain_set_info() to reduce duplicated code
On 2014/11/15 1:35, Marc Zyngier wrote: > On 14/11/14 15:41, Jiang Liu wrote: >> On 2014/11/14 23:31, Marc Zyngier wrote: >>> On 12/11/14 13:43, Thomas Gleixner wrote: From: Jiang Liu Signed-off-by: Jiang Liu Cc: Bjorn Helgaas Cc: Grant Likely Cc: Marc Zyngier Cc: Yingjoe Chen Cc: Yijing Wang Signed-off-by: Thomas Gleixner --- include/linux/irqdomain.h |5 + kernel/irq/irqdomain.c| 10 ++ 2 files changed, 15 insertions(+) Index: tip/include/linux/irqdomain.h === --- tip.orig/include/linux/irqdomain.h +++ tip/include/linux/irqdomain.h @@ -33,6 +33,7 @@ #define _LINUX_IRQDOMAIN_H #include +#include #include struct device_node; @@ -263,6 +264,10 @@ extern int irq_domain_set_hwirq_and_chip irq_hw_number_t hwirq, struct irq_chip *chip, void *chip_data); +extern void irq_domain_set_info(struct irq_domain *domain, unsigned int virq, + irq_hw_number_t hwirq, struct irq_chip *chip, + void *chip_data, irq_flow_handler_t handler, + void *handler_data, const char *handler_name); extern void irq_domain_reset_irq_data(struct irq_data *irq_data); extern void irq_domain_free_irqs_common(struct irq_domain *domain, int virq, int nr_irqs); Index: tip/kernel/irq/irqdomain.c === --- tip.orig/kernel/irq/irqdomain.c +++ tip/kernel/irq/irqdomain.c @@ -882,6 +882,16 @@ int irq_domain_set_hwirq_and_chip(struct return 0; } +void irq_domain_set_info(struct irq_domain *domain, unsigned int virq, + irq_hw_number_t hwirq, struct irq_chip *chip, + void *chip_data, irq_flow_handler_t handler, + void *handler_data, const char *handler_name) +{ + irq_domain_set_hwirq_and_chip(domain, virq, hwirq, chip, chip_data); + __irq_set_handler(virq, handler, 0, handler_name); + irq_set_handler_data(virq, handler_data); +} + >>> >>> We still have the issue that, depending on where in the stack this is >>> called, this will succeed or fail: If this is called from the inner >>> irqchip, __irq_set_handler() will fail, as it will look at the outer >>> domain as the (desc->irq_data.chip == &no_irq_chip) test fails (we >>> haven't set the top level yet). >>> >>> I have this very imperfect workaround in my tree: >>> >>> diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c >>> index d028b34..91e6515 100644 >>> --- a/kernel/irq/chip.c >>> +++ b/kernel/irq/chip.c >>> @@ -731,7 +731,16 @@ __irq_set_handler(unsigned int irq, irq_flow_handler_t >>> handle, int is_chained, >>> if (!handle) { >>> handle = handle_bad_irq; >>> } else { >>> - if (WARN_ON(desc->irq_data.chip == &no_irq_chip)) >>> +#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY >>> + struct irq_data *irq_data = &desc->irq_data; >>> + while (irq_data) { >>> + if (irq_data->chip != &no_irq_chip) >>> + break; >>> + irq_data = irq_data->parent_data; >>> + } >>> +#endif >>> + >>> + if (WARN_ON(!irq_data || irq_data->chip == &no_irq_chip)) >>> goto out; >>> } >>> >>> Which translate into: If there is at least one irqchip in the domain, >>> it will probably sort itself out. Not ideal. Any real solution to >>> this problem? >>> >>> GICv2 faces this exact problem, as some of its interrupts are used >>> directly, and some others are used through the MSI domain. In the >>> GIC driver, it is almost impossible to find out... >> Hi Marc, >> I prefer the above solution to relax the warning conditions. >> Changing the calling order in irq_domain_ops->alloc() looks a little >> strange, and other interrupt drivers may still run into the same issue. > > OK. Where do we from from there? Do you want a proper patch, or will you > fold this into the existing code? A patch will be great:) > > Thanks, > > M. > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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: Request for help: what did I do wrong with idtentry?
On Fri, Nov 14, 2014 at 4:52 PM, Luck, Tony wrote: >> causes Tony's MCE stress test to fail, presumably when some CPU either >> becomes permanently non-interruptable or otherwise wanders off into >> the weeds. > > It might be that recent "improvements" I made to my test harness have > messed things up. I trimmed one delay (between injection and consumption), > but it turns out the other delay in the code never get executed (because we > take a SIGBUS on consumption and then longjmp). So my test that used > to pause a bit between iterations were running almost back to back > consumption and injection of next error. Hmm. Am I right that the timeout code in mce.c is overly aggressive, too? > > This meant the serial console was a huge bottleneck (especially as my > development BIOS is also kicking its own debug junk onto the same port). > Some of the errors pointed obliquely at console. > > I've slowed things back down to where they used to be, and things are > ticking along nicely (with 0.6 second delay between iterations). Just > passed the 2800 mark and still going. I'm leaving it running over the > weekend - if it makes it into the 50k level I'm willing to call it good. > Phew :) FWIW, I've confirmed that my code survives int3 from userspace, int3 from normal kernel code, and int3 from kernel with user gs. I'm not completely thrilled with what it does to double_fault, though. If we somehow get a double fault caused by an interrupt hitting userspace with a bad kernel_stack, then we'll end up page faulting in the double_fault prologue. I'm not convinced that this is worth worrying about. It would be easy enough to fix, though, even if it would further uglify the code. --Andy -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v3 00/21] backports: add kernel integration support
On Fri, Nov 14, 2014 at 1:10 PM, Luis R. Rodriguez wrote: > On Fri, Nov 14, 2014 at 12:54 PM, Johannes Berg > wrote: >> On Fri, 2014-11-14 at 12:52 -0800, Luis R. Rodriguez wrote: >>> On Fri, Nov 14, 2014 at 12:50 PM, Johannes Berg >>> wrote: >>> > On Tue, 2014-11-11 at 00:14 -0800, Luis R. Rodriguez wrote: >>> >> From: "Luis R. Rodriguez" >>> >> >>> >> This third series should hopefully address all pending feedback. >>> >> I've split out patches even more, but more importantly have >>> >> made the parser simpler by both integrating the logic required >>> >> to understand a backport by identifying the backport by type >>> >> and strategy, sharing that, and then providing ignore lists on >>> >> the parsers. >>> > >>> > I think from a code change POV I should be OK with this, but I'll >>> > definitely want to run it and see the differences. I'll have to do that >>> > next week, it's getting late here. >>> >>> OK. So I shouldn't merge yet? >> >> I would prefer you didn't, but OTOH we can always fix up issues later as >> well. > > I'll wait. Pushed. Luis -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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] ACPI / sleep: Drain outstanding events after disabling multiple GPEs
On Saturday, November 15, 2014 02:30:51 AM Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > After multiple GPEs have been disabled at the low level in one go, > like when acpi_disable_all_gpes() is called, we should always drain > all of the outstanding events from them, or the ACPICA's GPE handling > code may re-enable one of them as a result of a race condition. Scratch the last part. We simply need to drain them to prevent the GPE handling code from being executed in parallel with whatever happens after the GPEs have been disabled. > For this reason, call acpi_os_wait_events_complete() after > acpi_enable_all_wakeup_gpes() and acpi_disable_all_gpes() in > acpi_freeze_prepare() and acpi_power_off_prepare(), respectively. > > Signed-off-by: Rafael J. Wysocki > --- > drivers/acpi/sleep.c |2 ++ > 1 file changed, 2 insertions(+) > > Index: linux-pm/drivers/acpi/sleep.c > === > --- linux-pm.orig/drivers/acpi/sleep.c > +++ linux-pm/drivers/acpi/sleep.c > @@ -630,6 +630,7 @@ static int acpi_freeze_begin(void) > static int acpi_freeze_prepare(void) > { > acpi_enable_all_wakeup_gpes(); > + acpi_os_wait_events_complete(); > enable_irq_wake(acpi_gbl_FADT.sci_interrupt); > return 0; > } > @@ -825,6 +826,7 @@ static void acpi_power_off_prepare(void) > /* Prepare to power off the system */ > acpi_sleep_prepare(ACPI_STATE_S5); > acpi_disable_all_gpes(); > + acpi_os_wait_events_complete(); > } > > static void acpi_power_off(void) > > -- > To unsubscribe from this list: send the line "unsubscribe linux-acpi" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] ACPI / sleep: Drain outstanding events after disabling multiple GPEs
From: Rafael J. Wysocki After multiple GPEs have been disabled at the low level in one go, like when acpi_disable_all_gpes() is called, we should always drain all of the outstanding events from them, or the ACPICA's GPE handling code may re-enable one of them as a result of a race condition. For this reason, call acpi_os_wait_events_complete() after acpi_enable_all_wakeup_gpes() and acpi_disable_all_gpes() in acpi_freeze_prepare() and acpi_power_off_prepare(), respectively. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/sleep.c |2 ++ 1 file changed, 2 insertions(+) Index: linux-pm/drivers/acpi/sleep.c === --- linux-pm.orig/drivers/acpi/sleep.c +++ linux-pm/drivers/acpi/sleep.c @@ -630,6 +630,7 @@ static int acpi_freeze_begin(void) static int acpi_freeze_prepare(void) { acpi_enable_all_wakeup_gpes(); + acpi_os_wait_events_complete(); enable_irq_wake(acpi_gbl_FADT.sci_interrupt); return 0; } @@ -825,6 +826,7 @@ static void acpi_power_off_prepare(void) /* Prepare to power off the system */ acpi_sleep_prepare(ACPI_STATE_S5); acpi_disable_all_gpes(); + acpi_os_wait_events_complete(); } static void acpi_power_off(void) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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] timekeeping: Move persistent clock registration code from ARM to kernel
On Fri, 14 Nov 2014, Anatol Pomozov wrote: > On Fri, Nov 14, 2014 at 4:18 PM, Thomas Gleixner wrote: > >> So what I suppose to do with my patch? If it does not work could > >> anyone provide patch that removes ARM arch dependency from > >> tegra20_timer.c? > > > > Huch? You want other people to solve your problems? > > This is not the point. I provided patch that fixes the issue. Other > people said that they have ideas how to do it different (and better) > way. So I am asking to share these ideas represented as a patch. That's not the way it works. You sent a patch to solve an problem which you are facing. Now the people who review the patch think that there is a better approach than moving code from arm/ to the timekeeping core code. So it's up to you to come up with a patch which solves the problem in the right way. Thanks, tglx -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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] timekeeping: Move persistent clock registration code from ARM to kernel
On 11/14/2014 03:03 PM, Anatol Pomozov wrote: Hi On Thu, Nov 13, 2014 at 2:46 PM, Thomas Gleixner wrote: On Mon, 10 Nov 2014, Anatol Pomozov wrote: On Mon, Nov 10, 2014 at 1:53 AM, Thierry Reding wrote: On Fri, Nov 07, 2014 at 11:34:15AM -0800, Anatol Pomozov wrote: ARM timekeeping functionality allows to register persistent/boot clock dynamically. This code is arch-independent and can be useful on other plaforms as well. As a byproduct of this change, tegra20_timer becomes ARM64 compatible. Tested: backported the change to chromeos-3.14 kernel ran on tegra 64bit board, made sure high-resolution clock works. Using this on an upstream kernel doesn't work, though, because 64-bit ARM doesn't implement struct delay_timer which the driver needs since v3.17. But I suppose the delay timer infrastructure could be moved into the core similar to the persistent and boot clock as this patch does. Thanks. It makes sense, I will send it in a separate patch, once this one will be reviewed. On our kernel I haven't seen this issue as we still use 3.14. That's why you should test/compile your stuff on latest greatest and not on a year old conglomorate of unknown provenance. :) Unfortunately it is not possible to test this patch with upstream. There is no ARM64 bit support for Tegra yet. I am trying to cleanup/upstream my ChromeOS patches and this clock patch in particular makes one small step towards this goal. Also Thierry mentioned that he works on full ARM64 Tegra support and it is really exciting! What we usually do is send patches in the order the kernel boot process needs them. First modify the kernel to know about 64-bit Tegra, add earlyprintk support, make sure the early boot process spits out something on the UART, then add whatever next item is missing (e.g. clock driver, timers, ...). That way, every patch we apply can actually be tested in the mainline kernel, since the code actually reaches that point in execution. If we were for example to send in a ton of driver patches for ARM64 right now, we couldn't test them. Quite possibly those patches wouldn't fully work, and we'd just have churn fixing them up later once the base CPU/SoC support was added. It's better to only upstream patches that can actually be exercised in order to avoid that churn. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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: [V2 PATCH 3/4] scsi:stex.c Add reboot support
On Wed, Nov 12, 2014 at 09:27:50AM -0800, Christoph Hellwig wrote: > > +static int stex_reboot_callback(struct notifier_block *self, > > + unsigned long val, > > + void *data) > > +{ > > + if (val == SYS_RESTART) > > + isRestart = 1; > > + return NOTIFY_OK; > > +} > > > > @@ -1832,7 +1859,14 @@ static void stex_shutdown(struct pci_dev *pdev) > > { > > struct st_hba *hba = pci_get_drvdata(pdev); > > > > - stex_hba_stop(hba); > > + if (hba->yellowstone == 1) > > + stex_hba_stop(hba, ST_IGNORED); > > + else { > > + if (isRestart) > > + stex_hba_stop(hba, ST_S6); > > + else > > + stex_hba_stop(hba, ST_S5); > > + } > > This sort of check for reboot vs restart isn't really something > we want in drivers. I don't really know how we could find this > out assuming we even want drivers to behave differently. > > Maybe Greg or someone on lkml has an idea how to best handle this case. What is "this case"? And yes, I agree, we shouldn't care, in drivers, about reboot vs. restart, as they should both be the same thing, along with "disconnect", right? thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[GIT PULL] Power Supply changes for 3.18-rc
Hi Linus, The following changes since commit 7881c64716f3a7d60b325ed0ad4d15f49b474a43: power: ab8500_fg: Fix build warning (2014-10-05 02:10:20 +0200) are available in the git repository at: git://git.infradead.org/battery-2.6.git tags/for-v3.18-rc for you to fetch changes up to cdaf3e15385d3232b52287e50692506f8fd01a09: power: charger-manager: Fix accessing invalidated power supply after charger unbind (2014-10-28 03:30:21 +0100) power supply and reset changes for the v3.18-rc - misc. charger-manager fixes - year 2038 fix in ab8500_fg - fix error handling of bq2415x_charger Ebru Akagunduz (1): power: ab8500_fg.c: use 64-bit time types Krzysztof Kozlowski (6): power: bq2415x_charger: Properly handle ENODEV from power_supply_get_by_phandle power: bq2415x_charger: Fix memory leak on DTS parsing error power_supply: Add no_thermal property to prevent recursive get_temp calls power: charger-manager: Avoid recursive thermal get_temp call power: charger-manager: Fix accessing invalidated power supply after fuel gauge unbind power: charger-manager: Fix accessing invalidated power supply after charger unbind drivers/power/ab8500_fg.c | 17 ++--- drivers/power/bq2415x_charger.c | 23 +++--- drivers/power/charger-manager.c | 164 drivers/power/power_supply_core.c | 3 +++ include/linux/power/charger-manager.h | 3 --- include/linux/power_supply.h | 6 + 6 files changed, 144 insertions(+), 72 deletions(-) -- Sebastian signature.asc Description: Digital signature
RE: Request for help: what did I do wrong with idtentry?
> causes Tony's MCE stress test to fail, presumably when some CPU either > becomes permanently non-interruptable or otherwise wanders off into > the weeds. It might be that recent "improvements" I made to my test harness have messed things up. I trimmed one delay (between injection and consumption), but it turns out the other delay in the code never get executed (because we take a SIGBUS on consumption and then longjmp). So my test that used to pause a bit between iterations were running almost back to back consumption and injection of next error. This meant the serial console was a huge bottleneck (especially as my development BIOS is also kicking its own debug junk onto the same port). Some of the errors pointed obliquely at console. I've slowed things back down to where they used to be, and things are ticking along nicely (with 0.6 second delay between iterations). Just passed the 2800 mark and still going. I'm leaving it running over the weekend - if it makes it into the 50k level I'm willing to call it good. -Tony
Re: [PATCH] timekeeping: Move persistent clock registration code from ARM to kernel
Hi On Fri, Nov 14, 2014 at 4:18 PM, Thomas Gleixner wrote: > On Fri, 14 Nov 2014, Anatol Pomozov wrote: >> On Thu, Nov 13, 2014 at 2:46 PM, Thomas Gleixner wrote: >> > On Mon, 10 Nov 2014, Anatol Pomozov wrote: >> >> On Mon, Nov 10, 2014 at 1:53 AM, Thierry Reding >> >> wrote: >> >> > On Fri, Nov 07, 2014 at 11:34:15AM -0800, Anatol Pomozov wrote: >> >> >> ARM timekeeping functionality allows to register persistent/boot clock >> >> >> dynamically. >> >> >> This code is arch-independent and can be useful on other plaforms as >> >> >> well. >> >> >> >> >> >> As a byproduct of this change, tegra20_timer becomes ARM64 compatible. >> >> >> >> >> >> Tested: backported the change to chromeos-3.14 kernel ran on tegra >> >> >> 64bit >> >> >> board, made sure high-resolution clock works. >> >> > >> >> > Using this on an upstream kernel doesn't work, though, because 64-bit >> >> > ARM doesn't implement struct delay_timer which the driver needs since >> >> > v3.17. >> >> > >> >> > But I suppose the delay timer infrastructure could be moved into the >> >> > core similar to the persistent and boot clock as this patch does. >> >> >> >> Thanks. It makes sense, I will send it in a separate patch, once this >> >> one will be reviewed. On our kernel I haven't seen this issue as we >> >> still use 3.14. >> > >> > That's why you should test/compile your stuff on latest greatest and >> > not on a year old conglomorate of unknown provenance. :) >> >> Unfortunately it is not possible to test this patch with upstream. >> There is no ARM64 bit support for Tegra yet. I am trying to >> cleanup/upstream my ChromeOS patches and this clock patch in >> particular makes one small step towards this goal. Also Thierry >> mentioned that he works on full ARM64 Tegra support and it is really >> exciting! > > Everything is exciting, but it does not change the fact, that this > patch cannot work on current upstream. Could you please be more specific what exactly does not work? Are you talking about delay timer? But my patch does not touch any delay timer code. I can compile tegra_timer for ARM. And this code is not usable on arm64 anyway because whole Tegra is not ported yet. Somebody should make additional changes to upstream tegra20_timer.c code. I might try to do it later when Tegra will be ported. >> So what I suppose to do with my patch? If it does not work could >> anyone provide patch that removes ARM arch dependency from >> tegra20_timer.c? > > Huch? You want other people to solve your problems? This is not the point. I provided patch that fixes the issue. Other people said that they have ideas how to do it different (and better) way. So I am asking to share these ideas represented as a patch. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] gpio-tz1090: fix error handling of irq_of_parse_and_map
On Friday, November 14, 2014 11:53:07 PM James Hogan wrote: > On Fri, Nov 14, 2014 at 01:32:56PM -0800, Dmitry Torokhov wrote: > > irq_of_parse_and_map() returns 0 on error, so testing for negative > > result never works. > > > > Signed-off-by: Dmitry Torokhov > > Good catch, thanks! > > Acked-by: James Hogan > > A quick coccinelle script shows up numerous other cases of this error > around the kernel tree too... Yeah, I sent out a few patches today. Thanks, Dmitry -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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] x86, PCI: support mmio more than 44 bit on 32bit/PAE mode
On Thu, Nov 13, 2014 at 07:59:27PM -0800, Yinghai Lu wrote: > Aaron reported 32bit/PAE mode, has problem with 64bit resource. > > [6.610012] pci :03:00.0: reg 0x10: [mem 0x383fffc0-0x383fffdf > 64bit pref] > [6.622195] pci :03:00.0: reg 0x20: [mem 0x383fffe04000-0x383fffe07fff > 64bit pref] > [6.656112] pci :03:00.1: reg 0x10: [mem 0x383fffa0-0x383fffbf > 64bit pref] > [6.668293] pci :03:00.1: reg 0x20: [mem 0x383fffe0-0x383fffe03fff > 64bit pref] > ... > [ 12.374143] calling ixgbe_init_module+0x0/0x51 @ 1 > [ 12.378130] ixgbe: Intel(R) 10 Gigabit PCI Express Network Driver - > version 3.19.1-k > [ 12.385318] ixgbe: Copyright (c) 1999-2014 Intel Corporation. > [ 12.390578] ixgbe :03:00.0: Adapter removed > [ 12.394247] ixgbe: probe of :03:00.0 failed with error -5 > [ 12.399369] ixgbe :03:00.1: Adapter removed > [ 12.403036] ixgbe: probe of :03:00.1 failed with error -5 > [ 12.408017] initcall ixgbe_init_module+0x0/0x51 returned 0 after 29200 > usecs > > root cause is ioremap can not handle mmio range that is more than 44bits on > 32bit PAE mode. > > We are using pfn with unsigned long like pfn_pte(), so those 0x383fffc0 > will > overflow in pfn format with unsigned long (that is 32bits in 32bit x86 kernel, > and pfn only can support 44bits). > > | static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot) > | { > |return __pte(((phys_addr_t)page_nr << PAGE_SHIFT) | > | massage_pgprot(pgprot)); > | } > > We could limit iomem to 44 bits so we can reject them early from root bus. > but xhci is not happy with resource allocation (hang ?) > > Change phys_addr_t for pfn_pte, and add overflow check to skip ram checking, > as the mmio is too big to be ram. > At last, can not use PHYSICAL_PAGE_MASK to get aligned phys_addr. If I understand correctly, the problem is that we have a 46-bit physical address (0x383fffc0) and with 4KB pages, we're trying to put a 36-bit PFN into a 32-bit unsigned long, which obviously doesn't fit. This patch fixes a few spots, but aren't there many more places with the same problem? I guess this is a VM issue anyway, not a PCI problem, so I'll defer to the VM folks and let them handle this. Bjorn > Link: https://bugzilla.kernel.org/show_bug.cgi?id=88131 > Reported-by: Aaron Ma > Tested-by: Aaron Ma > Signed-off-by: Yinghai Lu > > --- > arch/x86/include/asm/page.h|8 > arch/x86/include/asm/pgtable.h |4 ++-- > arch/x86/mm/ioremap.c |6 -- > arch/x86/mm/pat.c |3 +++ > 4 files changed, 17 insertions(+), 4 deletions(-) > > Index: linux-2.6/arch/x86/include/asm/page.h > === > --- linux-2.6.orig/arch/x86/include/asm/page.h > +++ linux-2.6/arch/x86/include/asm/page.h > @@ -15,6 +15,14 @@ > > #ifndef __ASSEMBLY__ > > +static inline int pfn_overflow(dma_addr_t phy_addr) > +{ > + dma_addr_t real_pfn = phy_addr >> PAGE_SHIFT; > + unsigned long pfn = (unsigned long)real_pfn; > + > + return pfn != real_pfn; > +} > + > struct page; > > #include > Index: linux-2.6/arch/x86/include/asm/pgtable.h > === > --- linux-2.6.orig/arch/x86/include/asm/pgtable.h > +++ linux-2.6/arch/x86/include/asm/pgtable.h > @@ -354,9 +354,9 @@ static inline pgprotval_t massage_pgprot > return protval; > } > > -static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot) > +static inline pte_t pfn_pte(phys_addr_t page_nr, pgprot_t pgprot) > { > - return __pte(((phys_addr_t)page_nr << PAGE_SHIFT) | > + return __pte((page_nr << PAGE_SHIFT) | >massage_pgprot(pgprot)); > } > > Index: linux-2.6/arch/x86/mm/ioremap.c > === > --- linux-2.6.orig/arch/x86/mm/ioremap.c > +++ linux-2.6/arch/x86/mm/ioremap.c > @@ -122,7 +122,9 @@ static void __iomem *__ioremap_caller(re > if (ram_region < 0) { > pfn = phys_addr >> PAGE_SHIFT; > last_pfn = last_addr >> PAGE_SHIFT; > - if (walk_system_ram_range(pfn, last_pfn - pfn + 1, NULL, > + /* pfn overflow, don't need to check */ > + if (!pfn_overflow(last_addr) && > + walk_system_ram_range(pfn, last_pfn - pfn + 1, NULL, > __ioremap_check_ram) == 1) > return NULL; > } > @@ -130,7 +132,7 @@ static void __iomem *__ioremap_caller(re >* Mappings have to be page-aligned >*/ > offset = phys_addr & ~PAGE_MASK; > - phys_addr &= PHYSICAL_PAGE_MASK; > + phys_addr -= offset; > size = PAGE_ALIGN(last_addr+1) - phys_addr; > > retval = reserve_memtype(phys_addr, (u64)phys_addr + size, > Index: linux-2.6/arch/x86/mm/pat.c > ===
Re: frequent lockups in 3.18rc4
On Fri, 14 Nov 2014, Dave Jones wrote: > On Fri, Nov 14, 2014 at 11:55:30PM +0100, Thomas Gleixner wrote: > > > So this looks more like a smp function call fuckup. > > > > I assume Dave is running that stuff on KVM. So it might be worth while > > to look at the IPI magic there. > > no, bare metal. Ok, but that does not change the fact that we are stuck in smp_function_call land. Enabling softlockup_all_cpu_backtrace will probably not help much as we will end up waiting for csd_lock again :( Is the machine still accesible when this happens? If yes, we might enable a few trace points and functions and read out the trace buffer. If not, we could just panic the machine and dump the trace buffer over serial. Sigh tglx -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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] serial: 8250_dw: Handle no_console_suspend when uart loses state
In certain suspend modes on certain boards the 8250 UART may lose state when the device goes to suspend. If we're using no_console_suspend this can cause lots of problems during resume. Let's cache the basic UART config registers at suspend time and if we notice that the UART loses state (by looking at a canary stored in the scratch register) we'll restore it. Signed-off-by: Doug Anderson --- Note that I don't have a board that properly suspends and resumes from the deepest sleep state that runs atop mainline, so this is tested on a local tree that is based on 3.14 with backports (specifically on rk3288-pinky). It is compile tested atop mainline. drivers/tty/serial/8250/8250_dw.c | 67 +++ 1 file changed, 67 insertions(+) diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index 0bfdccc..444ff540 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -38,6 +38,9 @@ #define DW_UART_CPR0xf4 /* Component Parameter Register */ #define DW_UART_UCV0xf8 /* UART Component Version */ +/* We'll place this canary in SCR while suspending; if gone we've lost state */ +#define DW_UART_SCR_STATE 0x22 + /* Component Parameter Register bits */ #define DW_UART_CPR_ABP_DATA_WIDTH (3 << 0) #define DW_UART_CPR_AFCE_MODE (1 << 4) @@ -63,6 +66,13 @@ struct dw8250_data { struct clk *pclk; struct reset_control*rst; struct uart_8250_dmadma; + + int suspending; + int saved_lcr; + int saved_dll; + int saved_dlm; + int saved_ier; + int saved_fcr; }; #define BYT_PRV_CLK0x800 @@ -92,10 +102,35 @@ static void dw8250_force_idle(struct uart_port *p) (void)p->serial_in(p, UART_RX); } +static void dw8250_serial_restore(struct uart_port *p) +{ + struct dw8250_data *data = p->private_data; + struct uart_8250_port *port8250 = serial8250_get_port(data->line); + + data->suspending = 0; + + serial_out(port8250, UART_LCR, data->saved_lcr | UART_LCR_DLAB); + serial_out(port8250, UART_DLL, data->saved_dll); + serial_out(port8250, UART_DLM, data->saved_dlm); + serial_out(port8250, UART_LCR, data->saved_lcr); + + serial_out(port8250, UART_IER, data->saved_ier); + serial_out(port8250, UART_FCR, data->saved_fcr); + serial_out(port8250, UART_MCR, data->last_mcr); +} + static void dw8250_serial_out(struct uart_port *p, int offset, int value) { struct dw8250_data *d = p->private_data; + /* +* If we started suspending and we see SCR went back to 0, assume we've +* suspended and resumed and lost state. Restore it now. +*/ + if (d->suspending && + readb(p->membase + (UART_SCR << p->regshift)) != DW_UART_SCR_STATE) + dw8250_serial_restore(p); + if (offset == UART_MCR) d->last_mcr = value; @@ -133,6 +168,14 @@ static void dw8250_serial_out32(struct uart_port *p, int offset, int value) { struct dw8250_data *d = p->private_data; + /* +* If we started suspending and we see SCR went back to 0, assume we've +* suspended and resumed and lost state. Restore it now. +*/ + if (d->suspending && + readb(p->membase + (UART_SCR << p->regshift)) != DW_UART_SCR_STATE) + dw8250_serial_restore(p); + if (offset == UART_MCR) d->last_mcr = value; @@ -487,9 +530,29 @@ static int dw8250_remove(struct platform_device *pdev) static int dw8250_suspend(struct device *dev) { struct dw8250_data *data = dev_get_drvdata(dev); + struct uart_8250_port *port8250 = serial8250_get_port(data->line); + struct uart_port *port = &port8250->port; serial8250_suspend_port(data->line); + /* We only deal with ports that were left on (no_console_suspend) */ + if (port->suspended) + return 0; + + /* We'll save our registers in case we lose state in suspend */ + data->saved_fcr = serial_in(port8250, UART_FCR); + data->saved_ier = serial_in(port8250, UART_IER); + data->saved_lcr = serial_in(port8250, UART_LCR); + + serial_out(port8250, UART_LCR, data->saved_lcr | UART_LCR_DLAB); + data->saved_dlm = serial_in(port8250, UART_DLM); + data->saved_dll = serial_in(port8250, UART_DLL); + serial_out(port8250, UART_LCR, data->saved_lcr); + + /* Put a special canary in the scratch so we tell when state is lost */ + serial_out(port8250, UART_SCR, DW_UART_SCR_STATE); + data->suspending = 1; + return 0; } @@ -497,6 +560,10 @@ static int dw8250_resume(struct device *dev) { struct dw8250_data *data = dev_get_drvdata(dev); + /* We never los
Re: [PATCH 1/1 net-next] Bluetooth: hidp: replace kzalloc/copy_from_user by memdup_user
Hi Fabian, > use memdup_user for rd_data import. > > Signed-off-by: Fabian Frederick > --- > net/bluetooth/hidp/core.c | 10 +++--- > 1 file changed, 3 insertions(+), 7 deletions(-) patch has been applied to bluetooth-next tree. 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] PCI: Don't reject 64bit mmio on 32bit/PAE mode
On Thu, Nov 13, 2014 at 07:59:10PM -0800, Yinghai Lu wrote: > Aaron reported 32bit/PAE mode, has problem with 64bit resource. > > [6.610012] pci :03:00.0: reg 0x10: [mem 0x383fffc0-0x383fffdf > 64bit pref] > [6.622195] pci :03:00.0: reg 0x20: [mem 0x383fffe04000-0x383fffe07fff > 64bit pref] > [6.656112] pci :03:00.1: reg 0x10: [mem 0x383fffa0-0x383fffbf > 64bit pref] > [6.668293] pci :03:00.1: reg 0x20: [mem 0x383fffe0-0x383fffe03fff > 64bit pref] > [6.702055] pci :00:02.2: PCI bridge to [bus 03-04] > [6.706434] pci :00:02.2: bridge window [io 0x1000-0x1fff] > [6.711783] pci :00:02.2: bridge window [mem 0x9190-0x91cf] > [6.717906] pci :00:02.2: can't handle 64-bit address space for bridge > > So the kernel reject 64bit mmio on pci pref bridge that is assigned by > firmware. > > When 32bit PAE is enabled, we could support 64bit mmio. > but BITS_PER_LONG==64 checking could reject firmware assigned mmio that > is above 4G. On x86 32bit always has BITS_PER_LONG equal to 32. > > We could use CONFIG_ARCH_DMA_ADDR_T_64BIT or dma_addr_t size checking instead. > Use dma_addr_t size checking to avoid using MARCO. > > Also need to change to use dma_addr_t instead of unsigned long > for base/limit to avoid overflow. > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=88131 > Reported-by: Aaron Ma > Tested-by: Aaron Ma > Signed-off-by: Yinghai Lu Applied to for-linus for v3.18, thanks! > --- > drivers/pci/probe.c | 22 +++--- > 1 file changed, 11 insertions(+), 11 deletions(-) > > Index: linux-2.6/drivers/pci/probe.c > === > --- linux-2.6.orig/drivers/pci/probe.c > +++ linux-2.6/drivers/pci/probe.c > @@ -406,15 +406,15 @@ static void pci_read_bridge_mmio_pref(st > { > struct pci_dev *dev = child->self; > u16 mem_base_lo, mem_limit_lo; > - unsigned long base, limit; > + dma_addr_t base, limit; > struct pci_bus_region region; > struct resource *res; > > res = child->resource[2]; > pci_read_config_word(dev, PCI_PREF_MEMORY_BASE, &mem_base_lo); > pci_read_config_word(dev, PCI_PREF_MEMORY_LIMIT, &mem_limit_lo); > - base = ((unsigned long) mem_base_lo & PCI_PREF_RANGE_MASK) << 16; > - limit = ((unsigned long) mem_limit_lo & PCI_PREF_RANGE_MASK) << 16; > + base = ((dma_addr_t) mem_base_lo & PCI_PREF_RANGE_MASK) << 16; > + limit = ((dma_addr_t) mem_limit_lo & PCI_PREF_RANGE_MASK) << 16; > > if ((mem_base_lo & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) > { > u32 mem_base_hi, mem_limit_hi; > @@ -428,15 +428,15 @@ static void pci_read_bridge_mmio_pref(st >* this, just assume they are not being used. >*/ > if (mem_base_hi <= mem_limit_hi) { > -#if BITS_PER_LONG == 64 > - base |= ((unsigned long) mem_base_hi) << 32; > - limit |= ((unsigned long) mem_limit_hi) << 32; > -#else > - if (mem_base_hi || mem_limit_hi) { > - dev_err(&dev->dev, "can't handle 64-bit address > space for bridge\n"); > - return; > + if (sizeof(dma_addr_t) < 8) { > + if (mem_base_hi || mem_limit_hi) { > + dev_err(&dev->dev, "can't handle 64-bit > address space for bridge\n"); > + return; > + } > + } else { > + base |= ((dma_addr_t) mem_base_hi) << 32; > + limit |= ((dma_addr_t) mem_limit_hi) << 32; > } > -#endif > } > } > if (base <= limit) { -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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] timekeeping: Move persistent clock registration code from ARM to kernel
On Fri, 14 Nov 2014, Anatol Pomozov wrote: > On Thu, Nov 13, 2014 at 2:46 PM, Thomas Gleixner wrote: > > On Mon, 10 Nov 2014, Anatol Pomozov wrote: > >> On Mon, Nov 10, 2014 at 1:53 AM, Thierry Reding > >> wrote: > >> > On Fri, Nov 07, 2014 at 11:34:15AM -0800, Anatol Pomozov wrote: > >> >> ARM timekeeping functionality allows to register persistent/boot clock > >> >> dynamically. > >> >> This code is arch-independent and can be useful on other plaforms as > >> >> well. > >> >> > >> >> As a byproduct of this change, tegra20_timer becomes ARM64 compatible. > >> >> > >> >> Tested: backported the change to chromeos-3.14 kernel ran on tegra 64bit > >> >> board, made sure high-resolution clock works. > >> > > >> > Using this on an upstream kernel doesn't work, though, because 64-bit > >> > ARM doesn't implement struct delay_timer which the driver needs since > >> > v3.17. > >> > > >> > But I suppose the delay timer infrastructure could be moved into the > >> > core similar to the persistent and boot clock as this patch does. > >> > >> Thanks. It makes sense, I will send it in a separate patch, once this > >> one will be reviewed. On our kernel I haven't seen this issue as we > >> still use 3.14. > > > > That's why you should test/compile your stuff on latest greatest and > > not on a year old conglomorate of unknown provenance. :) > > Unfortunately it is not possible to test this patch with upstream. > There is no ARM64 bit support for Tegra yet. I am trying to > cleanup/upstream my ChromeOS patches and this clock patch in > particular makes one small step towards this goal. Also Thierry > mentioned that he works on full ARM64 Tegra support and it is really > exciting! Everything is exciting, but it does not change the fact, that this patch cannot work on current upstream. > So what I suppose to do with my patch? If it does not work could > anyone provide patch that removes ARM arch dependency from > tegra20_timer.c? Huch? You want other people to solve your problems? Thanks, tglx -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 1/2] clk: rockchip: add bindings for the mmc clock phases
This will be used in a later patch for clock phase tuning. Suggested-by: Heiko Stuebner Signed-off-by: Alexandru M Stan --- Changes in v2: None include/dt-bindings/clock/rk3288-cru.h | 10 ++ 1 file changed, 10 insertions(+) diff --git a/include/dt-bindings/clock/rk3288-cru.h b/include/dt-bindings/clock/rk3288-cru.h index 100a08c..465d0f6 100644 --- a/include/dt-bindings/clock/rk3288-cru.h +++ b/include/dt-bindings/clock/rk3288-cru.h @@ -72,6 +72,16 @@ #define SCLK_HEVC_CABAC111 #define SCLK_HEVC_CORE 112 +#define SCLK_SDMMC_DRV_PHASE 113 +#define SCLK_SDIO0_DRV_PHASE 114 +#define SCLK_SDIO1_DRV_PHASE 115 +#define SCLK_EMMC_DRV_PHASE116 + +#define SCLK_SDMMC_SAMPLE_PHASE117 +#define SCLK_SDIO0_SAMPLE_PHASE118 +#define SCLK_SDIO1_SAMPLE_PHASE119 +#define SCLK_EMMC_SAMPLE_PHASE 120 + #define DCLK_VOP0 190 #define DCLK_VOP1 191 -- 2.1.0.rc2.206.gedb03e5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 2/2] clk: rockchip: Add support for the mmc clock phases using the framework
The drive and sample phases are generated by dividing an upstream parent clock by 2, this allows us to adjust the phase by 90 deg. There's also an option to have up to 255 delay elements (40-80 picoseconds long). This driver uses those elements (under the assumption that they're 60ps long) to generate a rough 45deg (which might be from 33deg to 66deg) setting. Suggested-by: Heiko Stuebner Signed-off-by: Alexandru M Stan --- Changes in v2: - fixed my cc/to list - removed dangling #DEFINE DEBUG drivers/clk/rockchip/Makefile| 1 + drivers/clk/rockchip/clk-mmc-phase.c | 149 +++ drivers/clk/rockchip/clk-rk3288.c| 12 +++ drivers/clk/rockchip/clk.c | 8 ++ drivers/clk/rockchip/clk.h | 23 ++ 5 files changed, 193 insertions(+) create mode 100644 drivers/clk/rockchip/clk-mmc-phase.c diff --git a/drivers/clk/rockchip/Makefile b/drivers/clk/rockchip/Makefile index bd8514d..2714097 100644 --- a/drivers/clk/rockchip/Makefile +++ b/drivers/clk/rockchip/Makefile @@ -6,6 +6,7 @@ obj-y += clk-rockchip.o obj-y += clk.o obj-y += clk-pll.o obj-y += clk-cpu.o +obj-y += clk-mmc-phase.o obj-$(CONFIG_RESET_CONTROLLER) += softrst.o obj-y += clk-rk3188.o diff --git a/drivers/clk/rockchip/clk-mmc-phase.c b/drivers/clk/rockchip/clk-mmc-phase.c new file mode 100644 index 000..763df4b --- /dev/null +++ b/drivers/clk/rockchip/clk-mmc-phase.c @@ -0,0 +1,149 @@ +/* + * Copyright 2014 Google, Inc + * Author: Alexandru M Stan + * + * 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. + */ + +#include +#include +#include "clk.h" + +struct rockchip_mmc_clock_phase { + struct clk_hw hw; + void __iomem*reg; + int id; + int shift; +}; + +#define to_phase(_hw) container_of(_hw, struct rockchip_mmc_clock_phase, hw) + +static unsigned long rockchip_mmc_recalc(struct clk_hw *hw, +unsigned long parent_rate) +{ + return parent_rate / 2; +} + +#define ROCKCHIP_MMC_DELAY_SEL BIT(10) +#define ROCKCHIP_MMC_DEGREE_MASK 0x3 +#define ROCKCHIP_MMC_DELAYNUM_OFFSET 2 +#define ROCKCHIP_MMC_DELAYNUM_MASK (0xff << ROCKCHIP_MMC_DELAYNUM_OFFSET) + +#define PSECS_PER_SEC 1LL + +/* + * Each fine delay is between 40ps-80ps. Assume each fine delay is 60ps to + * simplify calculations. So 45degs could be anywhere between 33deg and 66deg. + */ +#define DELAY_ELEMENT_PSEC 60 + +static int rockchip_mmc_get_phase(struct clk_hw *hw) +{ + struct rockchip_mmc_clock_phase *phase = to_phase(hw); + unsigned long rate = clk_get_rate(hw->clk); + u32 raw_value; + u16 degrees; + u8 delay_num = 0; + + raw_value = readl(phase->reg) >> (phase->shift); + + degrees = (raw_value & ROCKCHIP_MMC_DEGREE_MASK) * 90; + + if (raw_value & ROCKCHIP_MMC_DELAY_SEL) { + /* degrees/delaynum * 1 */ + unsigned long factor = (DELAY_ELEMENT_PSEC / 10) * 36 * + (rate / 100); + + delay_num = (raw_value & ROCKCHIP_MMC_DELAYNUM_MASK); + delay_num >>= ROCKCHIP_MMC_DELAYNUM_OFFSET; + degrees += delay_num * factor / 1; + } + + return degrees % 360; +} + +static int rockchip_mmc_set_phase(struct clk_hw *hw, int degrees) +{ + struct rockchip_mmc_clock_phase *phase = to_phase(hw); + unsigned long rate = clk_get_rate(hw->clk); + u8 nineties, is_fortyfive; + u8 delay_num = 0; + u32 raw_value; + + degrees -= degrees % 45; + + nineties = degrees / 90; + is_fortyfive = (degrees % 90) == 45; + + if (is_fortyfive) { + u64 delay; + + delay = PSECS_PER_SEC; + do_div(delay, rate); + do_div(delay, 360 / 45); + do_div(delay, DELAY_ELEMENT_PSEC); + + delay_num = (u8) min(delay, 255ULL); + } + + raw_value = ROCKCHIP_MMC_DELAY_SEL; + raw_value |= delay_num << ROCKCHIP_MMC_DELAYNUM_OFFSET; + raw_value |= nineties; + writel(HIWORD_UPDATE(raw_value, 0x, phase->shift), phase->reg); + + pr_debug("%s->set_phase(%d) delay_nums=%u reg[0x%p]=0x%x actual_degrees=%d\n", + __clk_get_name(hw->clk), degrees, delay_num, + phase->reg, raw_value>>phase->shift, + rockchip_mmc_get_phase(hw) + ); + + return 0; +} + +static const struct clk_ops rockchip_phase_clk_ops = { + .recal
[PATCH v2 0/2] Add support for the rockchip mmc clock phases using the framework
For now all I have is the getter and setter for the phase, nothing that uses it (that is ready). You can test the getter like this: localhost ~ # cat /sys/kernel/debug/clk/clk_summary|grep sample -C 1 sclk_sdio1002400 0 0 sdio1_sample 001200 0 0 sdio1_drv 001200 0 90 -- sclk_sdmmc 11 29700 0 0 sdmmc_sample 00 14850 0 134 sdmmc_drv00 14850 0 90 -- sclk_sdio0 11 1 0 0 sdio0_sample 005000 0 0 sdio0_drv005000 0 90 sclk_emmc 11 1 0 0 emmc_sample 005000 0 0 emmc_drv 005000 0 180 Next thing that will come is some dts changes that will make use of these new clocks, and eventually mmc code will be changed to tune with these clocks. Changes in v2: - fixed my cc/to list - removed dangling #DEFINE DEBUG Alexandru M Stan (2): clk: rockchip: add bindings for the mmc clock phases clk: rockchip: Add support for the mmc clock phases using the framework drivers/clk/rockchip/Makefile | 1 + drivers/clk/rockchip/clk-mmc-phase.c | 149 + drivers/clk/rockchip/clk-rk3288.c | 12 +++ drivers/clk/rockchip/clk.c | 8 ++ drivers/clk/rockchip/clk.h | 23 + include/dt-bindings/clock/rk3288-cru.h | 10 +++ 6 files changed, 203 insertions(+) create mode 100644 drivers/clk/rockchip/clk-mmc-phase.c -- 2.1.0.rc2.206.gedb03e5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@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] gpio-tz1090: fix error handling of irq_of_parse_and_map
On Fri, Nov 14, 2014 at 01:32:56PM -0800, Dmitry Torokhov wrote: > irq_of_parse_and_map() returns 0 on error, so testing for negative > result never works. > > Signed-off-by: Dmitry Torokhov Good catch, thanks! Acked-by: James Hogan A quick coccinelle script shows up numerous other cases of this error around the kernel tree too... Cheers James > --- > > Not tested, found by casual inspection of the code. > > drivers/gpio/gpio-tz1090.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpio-tz1090.c b/drivers/gpio/gpio-tz1090.c > index 9e90177..e3024bb 100644 > --- a/drivers/gpio/gpio-tz1090.c > +++ b/drivers/gpio/gpio-tz1090.c > @@ -446,7 +446,7 @@ static int tz1090_gpio_bank_probe(struct > tz1090_gpio_bank_info *info) > bank->irq = irq_of_parse_and_map(np, 0); > > /* The interrupt is optional (it may be used by another core on chip) */ > - if (bank->irq < 0) { > + if (!bank->irq) { > dev_info(dev, "IRQ not provided for bank %u, IRQs disabled\n", >info->index); > return 0; > -- > 2.1.0.rc2.206.gedb03e5 > > > -- > Dmitry signature.asc Description: Digital signature
Re: [PATCH 2/2] clk: rockchip: Add support for the mmc clock phases using the framework
Hi, Am Freitag, 14. November 2014, 14:52:54 schrieb Alexandru M Stan: > The drive and sample phases are generated by dividing an upstream parent > clock by 2, this allows us to adjust the phase by 90 deg. > > There's also an option to have up to 255 delay elements (40-80 picoseconds > long). This driver uses those elements (under the assumption that they're > 60ps long) to generate a rough 45deg (which might be from 33deg to 66deg) > setting. > > Suggested-by: Heiko Stuebner > Signed-off-by: Alexandru M Stan apart from the dangling #define DEBUG below, this looks good to me. But I'd like to get a go ahead from Mike for this bigger chunk of new code. > --- > drivers/clk/rockchip/Makefile| 1 + > drivers/clk/rockchip/clk-mmc-phase.c | 150 > +++ drivers/clk/rockchip/clk-rk3288.c| > 12 +++ > drivers/clk/rockchip/clk.c | 8 ++ > drivers/clk/rockchip/clk.h | 23 ++ > 5 files changed, 194 insertions(+) > create mode 100644 drivers/clk/rockchip/clk-mmc-phase.c > > diff --git a/drivers/clk/rockchip/Makefile b/drivers/clk/rockchip/Makefile > index bd8514d..2714097 100644 > --- a/drivers/clk/rockchip/Makefile > +++ b/drivers/clk/rockchip/Makefile > @@ -6,6 +6,7 @@ obj-y += clk-rockchip.o > obj-y+= clk.o > obj-y+= clk-pll.o > obj-y+= clk-cpu.o > +obj-y+= clk-mmc-phase.o > obj-$(CONFIG_RESET_CONTROLLER) += softrst.o > > obj-y+= clk-rk3188.o > diff --git a/drivers/clk/rockchip/clk-mmc-phase.c > b/drivers/clk/rockchip/clk-mmc-phase.c new file mode 100644 > index 000..5c1532a > --- /dev/null > +++ b/drivers/clk/rockchip/clk-mmc-phase.c > @@ -0,0 +1,150 @@ > +/* > + * Copyright 2014 Google, Inc > + * Author: Alexandru M Stan > + * > + * 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. > + */ > + > +#define DEBUG should not be here Heiko > +#include > +#include > +#include "clk.h" > + > +struct rockchip_mmc_clock_phase { > + struct clk_hw hw; > + void __iomem*reg; > + int id; > + int shift; > +}; > + > +#define to_phase(_hw) container_of(_hw, struct rockchip_mmc_clock_phase, > hw) + > +static unsigned long rockchip_mmc_recalc(struct clk_hw *hw, > + unsigned long parent_rate) > +{ > + return parent_rate / 2; > +} > + > +#define ROCKCHIP_MMC_DELAY_SEL BIT(10) > +#define ROCKCHIP_MMC_DEGREE_MASK 0x3 > +#define ROCKCHIP_MMC_DELAYNUM_OFFSET 2 > +#define ROCKCHIP_MMC_DELAYNUM_MASK (0xff << ROCKCHIP_MMC_DELAYNUM_OFFSET) > + > +#define PSECS_PER_SEC 1LL > + > +/* > + * Each fine delay is between 40ps-80ps. Assume each fine delay is 60ps to > + * simplify calculations. So 45degs could be anywhere between 33deg and > 66deg. + */ > +#define DELAY_ELEMENT_PSEC 60 > + > +static int rockchip_mmc_get_phase(struct clk_hw *hw) > +{ > + struct rockchip_mmc_clock_phase *phase = to_phase(hw); > + unsigned long rate = clk_get_rate(hw->clk); > + u32 raw_value; > + u16 degrees; > + u8 delay_num = 0; > + > + raw_value = readl(phase->reg) >> (phase->shift); > + > + degrees = (raw_value & ROCKCHIP_MMC_DEGREE_MASK) * 90; > + > + if (raw_value & ROCKCHIP_MMC_DELAY_SEL) { > + /* degrees/delaynum * 1 */ > + unsigned long factor = (DELAY_ELEMENT_PSEC / 10) * 36 * > + (rate / 100); > + > + delay_num = (raw_value & ROCKCHIP_MMC_DELAYNUM_MASK); > + delay_num >>= ROCKCHIP_MMC_DELAYNUM_OFFSET; > + degrees += delay_num * factor / 1; > + } > + > + return degrees % 360; > +} > + > +static int rockchip_mmc_set_phase(struct clk_hw *hw, int degrees) > +{ > + struct rockchip_mmc_clock_phase *phase = to_phase(hw); > + unsigned long rate = clk_get_rate(hw->clk); > + u8 nineties, is_fortyfive; > + u8 delay_num = 0; > + u32 raw_value; > + > + degrees -= degrees % 45; > + > + nineties = degrees / 90; > + is_fortyfive = (degrees % 90) == 45; > + > + if (is_fortyfive) { > + u64 delay; > + > + delay = PSECS_PER_SEC; > + do_div(delay, rate); > + do_div(delay, 360 / 45); > + do_div(delay, DELAY_ELEMENT_PSEC); > + > + delay_num = (u8) min(delay, 255ULL); > + } > + > + raw_value = ROCKCHIP_MMC_DELAY_SEL; > + raw_value |= delay_num << ROCKCHIP_MMC_DELAYNUM_OFFSET; > + raw_value |= nineties; > + writel
[PATCH 3/3] vme: tsi148: Master windows support USERx and CR/CSR accesses, not slaves
From: Martyn Welch The tsi148 driver is registering the slave images as supporting the "USER" access modes and CR/CSR access mode rather than the master images as it should. Remove the incorrect case entries for these modes from the tsi148_slave_set() function, stop registering slave_images as supporting these modes and instead register master windows as supporting these modes. Signed-off-by: Martyn Welch Acked-by: Dmitry Kalinkin --- drivers/vme/bridges/vme_tsi148.c | 11 +++ 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/vme/bridges/vme_tsi148.c b/drivers/vme/bridges/vme_tsi148.c index e07cfa8..895c2a3 100644 --- a/drivers/vme/bridges/vme_tsi148.c +++ b/drivers/vme/bridges/vme_tsi148.c @@ -587,11 +587,6 @@ static int tsi148_slave_set(struct vme_slave_resource *image, int enabled, granularity = 0x1; addr |= TSI148_LCSR_ITAT_AS_A64; break; - case VME_CRCSR: - case VME_USER1: - case VME_USER2: - case VME_USER3: - case VME_USER4: default: dev_err(tsi148_bridge->parent, "Invalid address space\n"); return -EINVAL; @@ -2471,7 +2466,8 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) master_image->locked = 0; master_image->number = i; master_image->address_attr = VME_A16 | VME_A24 | VME_A32 | - VME_A64; + VME_A64 | VME_CRCSR | VME_USER1 | VME_USER2 | + VME_USER3 | VME_USER4; master_image->cycle_attr = VME_SCT | VME_BLT | VME_MBLT | VME_2eVME | VME_2eSST | VME_2eSSTB | VME_2eSST160 | VME_2eSST267 | VME_2eSST320 | VME_SUPER | VME_USER | @@ -2500,8 +2496,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) slave_image->locked = 0; slave_image->number = i; slave_image->address_attr = VME_A16 | VME_A24 | VME_A32 | - VME_A64 | VME_CRCSR | VME_USER1 | VME_USER2 | - VME_USER3 | VME_USER4; + VME_A64; slave_image->cycle_attr = VME_SCT | VME_BLT | VME_MBLT | VME_2eVME | VME_2eSST | VME_2eSSTB | VME_2eSST160 | VME_2eSST267 | VME_2eSST320 | VME_SUPER | VME_USER | -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/3] mmap() for vme_user and CR/CSR fix for master
Dear all, mmap() on VME bridge devices is a feature present in many existing Linux and UNIX drivers. The proposed solution follows the approach so that mmap() offsets are coherent with read() and write() offsets, which seems to be the only manner compatible with the current vme_user API. It also ends up adding vme_master_mmap call to the VME subsystem API. On one hand this might come useful for a board driver that will be able to expose one of its windows to the user that way. On the other hand it introduces dependency on vma_area_struct into vme.h, which doesn't seem very right. Also I'm bringing up a bugfix by Martyn Welch that was published on the list, but for some reason didn't make it to the kernel. Cheers, Dmitry Dmitry Kalinkin (2): staging: vme: use image mutex for ioctl() staging: vme: mmap() support for vme_user Martyn Welch (1): vme: tsi148: Master windows support USERx and CR/CSR accesses, not slaves drivers/staging/vme/devices/vme_user.c | 94 -- drivers/vme/bridges/vme_tsi148.c | 11 ++-- drivers/vme/vme.c | 26 ++ include/linux/vme.h| 1 + 4 files changed, 120 insertions(+), 12 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/3] staging: vme: mmap() support for vme_user
We also make sure that user won't be able to reconfigure the window while it is mmap'ed. Signed-off-by: Dmitry Kalinkin Cc: Igor Alekseev --- drivers/staging/vme/devices/vme_user.c | 85 ++ drivers/vme/vme.c | 26 +++ include/linux/vme.h| 1 + 3 files changed, 112 insertions(+) diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index 8731838..b7fe1f0 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -17,6 +17,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -99,6 +100,7 @@ struct image_desc { struct device *device; /* Sysfs device */ struct vme_resource *resource; /* VME resource */ int users; /* Number of current users */ + int mmap_count; /* Number of current mmap's */ }; static struct image_desc image[VME_DEVS]; @@ -134,6 +136,10 @@ static ssize_t vme_user_write(struct file *, const char __user *, size_t, loff_t *); static loff_t vme_user_llseek(struct file *, loff_t, int); static long vme_user_unlocked_ioctl(struct file *, unsigned int, unsigned long); +static int vme_user_mmap(struct file *file, struct vm_area_struct *vma); + +static void vme_user_vm_open(struct vm_area_struct *vma); +static void vme_user_vm_close(struct vm_area_struct *vma); static int vme_user_match(struct vme_dev *); static int vme_user_probe(struct vme_dev *); @@ -147,6 +153,17 @@ static const struct file_operations vme_user_fops = { .llseek = vme_user_llseek, .unlocked_ioctl = vme_user_unlocked_ioctl, .compat_ioctl = vme_user_unlocked_ioctl, + .mmap = vme_user_mmap, +}; + +struct vme_user_vma_priv { + unsigned int minor; + atomic_t refcnt; +}; + +static const struct vm_operations_struct vme_user_vm_ops = { + .open = vme_user_vm_open, + .close = vme_user_vm_close, }; @@ -488,6 +505,11 @@ static int vme_user_ioctl(struct inode *inode, struct file *file, case VME_SET_MASTER: + if (image[minor].mmap_count != 0) { + pr_warn("Can't adjust mapped window\n"); + return -EPERM; + } + copied = copy_from_user(&master, argp, sizeof(master)); if (copied != 0) { pr_warn("Partial copy from userspace\n"); @@ -564,6 +586,69 @@ vme_user_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return ret; } +static void vme_user_vm_open(struct vm_area_struct *vma) +{ + struct vme_user_vma_priv *vma_priv = vma->vm_private_data; + + atomic_inc(&vma_priv->refcnt); +} + +static void vme_user_vm_close(struct vm_area_struct *vma) +{ + struct vme_user_vma_priv *vma_priv = vma->vm_private_data; + unsigned int minor = vma_priv->minor; + + if (!atomic_dec_and_test(&vma_priv->refcnt)) + return; + + mutex_lock(&image[minor].mutex); + image[minor].mmap_count--; + mutex_unlock(&image[minor].mutex); + + kfree(vma_priv); +} + +static int vme_user_master_mmap(unsigned int minor, struct vm_area_struct *vma) +{ + int err; + struct vme_user_vma_priv *vma_priv; + + mutex_lock(&image[minor].mutex); + + err = vme_master_mmap(image[minor].resource, vma); + if (err) { + mutex_unlock(&image[minor].mutex); + return err; + } + + vma_priv = kmalloc(sizeof(struct vme_user_vma_priv), GFP_KERNEL); + if (vma_priv == NULL) { + mutex_unlock(&image[minor].mutex); + return -ENOMEM; + } + + vma_priv->minor = minor; + atomic_set(&vma_priv->refcnt, 1); + vma->vm_ops = &vme_user_vm_ops; + vma->vm_private_data = vma_priv; + + image[minor].mmap_count++; + + mutex_unlock(&image[minor].mutex); + + return 0; +} + +static int vme_user_mmap(struct file *file, struct vm_area_struct *vma) +{ + unsigned int minor = MINOR(file->f_dentry->d_inode->i_rdev); + + if (type[minor] == MASTER_MINOR) + return vme_user_master_mmap(minor, vma); + + return -ENODEV; +} + /* * Unallocate a previously allocated buffer diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c index 7516030..3dc62b4 100644 --- a/drivers/vme/vme.c +++ b/drivers/vme/vme.c @@ -609,6 +609,32 @@ unsigned int vme_master_rmw(struct vme_resource *resource, unsigned int mask, } EXPORT_SYMBOL(vme_master_rmw); +int vme_master_mmap(struct vme_resource *resource, struct vm_area_struct *vma) +{ + struct vme_master_resource *image; + phys_addr_t phys_addr; + unsigned long vma_size; + + if (resource->type != VME_MASTER) { + printk(KERN_ERR "Not a master resource\n"); +
[PATCH 1/3] staging: vme: use image mutex for ioctl()
This implements more granular locking in vme_user_ioctl() by using separate locks for each devfs device. This also provides a synchronization between vme_user_read(), vme_user_write() and vme_user_ioctl(). Signed-off-by: Dmitry Kalinkin Cc: Igor Alekseev --- drivers/staging/vme/devices/vme_user.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index 8b1f533..8731838 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -41,7 +41,6 @@ #include "vme_user.h" -static DEFINE_MUTEX(vme_user_mutex); static const char driver_name[] = "vme_user"; static int bus[VME_USER_BUS_MAX]; @@ -555,10 +554,12 @@ static long vme_user_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int ret; + struct inode *inode = file_inode(file); + unsigned int minor = MINOR(inode->i_rdev); - mutex_lock(&vme_user_mutex); - ret = vme_user_ioctl(file_inode(file), file, cmd, arg); - mutex_unlock(&vme_user_mutex); + mutex_lock(&image[minor].mutex); + ret = vme_user_ioctl(inode, file, cmd, arg); + mutex_unlock(&image[minor].mutex); return ret; } -- 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] cpuidle: Invert CPUIDLE_FLAG_TIME_VALID logic
On Wednesday, November 12, 2014 04:03:50 PM Daniel Lezcano wrote: > The only place where the time is invalid is when the ACPI_CSTATE_FFH entry > method is not set. Otherwise for all the drivers, the time can be correctly > measured. > > Instead of duplicating the CPUIDLE_FLAG_TIME_VALID flag in all the drivers > for all the states, just invert the logic by replacing it by the flag > CPUIDLE_FLAG_TIME_INVALID, hence we can set this flag only for the acpi idle > driver, remove the former flag from all the drivers and invert the logic with > this flag in the different governor. > > Signed-off-by: Daniel Lezcano Queued up for 3.19, thanks! > --- > arch/arm/include/asm/cpuidle.h | 1 - > arch/arm/mach-davinci/cpuidle.c| 1 - > arch/arm/mach-imx/cpuidle-imx5.c | 1 - > arch/arm/mach-imx/cpuidle-imx6q.c | 3 +- > arch/arm/mach-imx/cpuidle-imx6sl.c | 3 +- > arch/arm/mach-omap2/cpuidle34xx.c | 7 --- > arch/arm/mach-omap2/cpuidle44xx.c | 5 +- > arch/arm/mach-s3c64xx/cpuidle.c| 1 - > arch/arm/mach-shmobile/pm-sh7372.c | 4 -- > arch/arm/mach-tegra/cpuidle-tegra114.c | 1 - > arch/arm/mach-tegra/cpuidle-tegra20.c | 3 +- > arch/arm/mach-tegra/cpuidle-tegra30.c | 1 - > arch/mips/include/asm/idle.h | 1 - > arch/sh/kernel/cpu/shmobile/cpuidle.c | 3 - > arch/x86/kernel/apm_32.c | 1 - > drivers/acpi/processor_idle.c | 6 +- > drivers/cpuidle/cpuidle-arm64.c| 1 - > drivers/cpuidle/cpuidle-at91.c | 1 - > drivers/cpuidle/cpuidle-big_little.c | 6 +- > drivers/cpuidle/cpuidle-calxeda.c | 1 - > drivers/cpuidle/cpuidle-cps.c | 7 +-- > drivers/cpuidle/cpuidle-exynos.c | 1 - > drivers/cpuidle/cpuidle-kirkwood.c | 1 - > drivers/cpuidle/cpuidle-mvebu-v7.c | 8 +-- > drivers/cpuidle/cpuidle-powernv.c | 6 +- > drivers/cpuidle/cpuidle-pseries.c | 3 - > drivers/cpuidle/cpuidle-ux500.c| 3 +- > drivers/cpuidle/cpuidle-zynq.c | 1 - > drivers/cpuidle/driver.c | 1 - > drivers/cpuidle/dt_idle_states.c | 2 +- > drivers/cpuidle/governors/ladder.c | 2 +- > drivers/cpuidle/governors/menu.c | 2 +- > drivers/idle/intel_idle.c | 108 > - > include/linux/cpuidle.h| 4 +- > 34 files changed, 75 insertions(+), 125 deletions(-) > > diff --git a/arch/arm/include/asm/cpuidle.h b/arch/arm/include/asm/cpuidle.h > index 2fca60a..af319ac 100644 > --- a/arch/arm/include/asm/cpuidle.h > +++ b/arch/arm/include/asm/cpuidle.h > @@ -15,7 +15,6 @@ static inline int arm_cpuidle_simple_enter(struct > cpuidle_device *dev, > .exit_latency = 1,\ > .target_residency = 1,\ > .power_usage= p,\ > - .flags = CPUIDLE_FLAG_TIME_VALID,\ > .name = "WFI",\ > .desc = "ARM WFI",\ > } > diff --git a/arch/arm/mach-davinci/cpuidle.c b/arch/arm/mach-davinci/cpuidle.c > index f1ac1c9..b4675fc 100644 > --- a/arch/arm/mach-davinci/cpuidle.c > +++ b/arch/arm/mach-davinci/cpuidle.c > @@ -66,7 +66,6 @@ static struct cpuidle_driver davinci_idle_driver = { > .enter = davinci_enter_idle, > .exit_latency = 10, > .target_residency = 1, > - .flags = CPUIDLE_FLAG_TIME_VALID, > .name = "DDR SR", > .desc = "WFI and DDR Self Refresh", > }, > diff --git a/arch/arm/mach-imx/cpuidle-imx5.c > b/arch/arm/mach-imx/cpuidle-imx5.c > index 5a47e3c..3feca52 100644 > --- a/arch/arm/mach-imx/cpuidle-imx5.c > +++ b/arch/arm/mach-imx/cpuidle-imx5.c > @@ -24,7 +24,6 @@ static struct cpuidle_driver imx5_cpuidle_driver = { > .enter= imx5_cpuidle_enter, > .exit_latency = 2, > .target_residency = 1, > - .flags= CPUIDLE_FLAG_TIME_VALID, > .name = "IMX5 SRPG", > .desc = "CPU state retained,powered off", > }, > diff --git a/arch/arm/mach-imx/cpuidle-imx6q.c > b/arch/arm/mach-imx/cpuidle-imx6q.c > index aa93578..d76d086 100644 > --- a/arch/arm/mach-imx/cpuidle-imx6q.c > +++ b/arch/arm/mach-imx/cpuidle-imx6q.c > @@ -53,8 +53,7 @@ static struct cpuidle_driver imx6q_cpuidle_driver = { > { > .exit_latency = 50, > .target_residency = 75, > - .flags = CPUIDLE_FLAG_TIME_VALID | > - CPUIDLE_FLAG_TIMER_STOP, > + .flags = CPUIDLE_FLAG_TIMER_STOP, > .enter = imx6q_enter_wait, > .name = "WAIT", > .desc = "Clock off", > diff --git a/arch/arm/mach-imx/cpuidle-imx6sl.c > b/arch/a
Re: [PATCH V2] cpufreq: respect the min/max settings from user space
On Monday, November 10, 2014 02:14:50 PM Vince Hsu wrote: > When the user space tries to set scaling_(max|min)_freq through > sysfs, the cpufreq_set_policy() asks other driver's opinions > for the max/min frequencies. Some device drivers, like Tegra > CPU EDP which is not upstreamed yet though, may constrain the > CPU maximum frequency dynamically because of board design. > So if the user space access happens and some driver is capping > the cpu frequency at the same time, the user_policy->(max|min) > is overridden by the capped value, and that's not expected by > the user space. And if the user space is not invoked again, > the CPU will always be capped by the user_policy->(max|min) > even no drivers limit the CPU frequency any more. > > This patch preserves the user specified min/max settings, so that > every time the cpufreq policy is updated, the new max/min can > be re-evaluated correctly based on the user's expection and > the present device drivers' status. > > Signed-off-by: Vince Hsu > Acked-by: Viresh Kumar Queued up for 3.19, thanks! > --- > v2: added Viresh's Acked-by > > drivers/cpufreq/cpufreq.c | 6 -- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 644b54e1e7d1..0721ab352e2a 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -535,7 +535,7 @@ static int cpufreq_set_policy(struct cpufreq_policy > *policy, > static ssize_t store_##file_name \ > (struct cpufreq_policy *policy, const char *buf, size_t count) > \ > {\ > - int ret;\ > + int ret, temp; \ > struct cpufreq_policy new_policy; \ > \ > ret = cpufreq_get_policy(&new_policy, policy->cpu); \ > @@ -546,8 +546,10 @@ static ssize_t store_##file_name > \ > if (ret != 1) \ > return -EINVAL; \ > \ > + temp = new_policy.object; \ > ret = cpufreq_set_policy(policy, &new_policy); \ > - policy->user_policy.object = policy->object;\ > + if (!ret) \ > + policy->user_policy.object = temp; \ > \ > return ret ? ret : count; \ > } > -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[ANNOUNCE] Git v2.2.0-rc2
A release candidate Git v2.2.0-rc2 is now available for testing at the usual places. We expect that the final will happen late next week, and it will be different from this tarball only with small documentation update changes. The tarballs are found at: https://www.kernel.org/pub/software/scm/git/testing/ The following public repositories all have a copy of the 'v2.2.0-rc2' tag and the 'master' branch that the tag points at: url = https://kernel.googlesource.com/pub/scm/git/git url = git://repo.or.cz/alt-git.git url = https://code.google.com/p/git-core/ url = git://git.sourceforge.jp/gitroot/git-core/git.git url = git://git-core.git.sourceforge.net/gitroot/git-core/git-core url = https://github.com/gitster/git Git v2.2 Release Notes (draft) == Updates since v2.1 -- Ports * Building on older MacOS X systems automatically sets the necessary NO_APPLE_COMMON_CRYPTO build-time option. * The support to build with NO_PTHREADS has been resurrected. * Compilation options has been updated a bit to support z/OS port better. UI, Workflows & Features * "git archive" learned to filter what gets archived with pathspec. * "git config --edit --global" starts from a skeletal per-user configuration file contents, instead of a total blank, when the user does not already have any. This immediately reduces the need for a later "Have you forgotten setting core.user?" and we can add more to the template as we gain more experience. * "git stash list -p" used to be almost always a no-op because each stash entry is represented as a merge commit. It learned to show the difference between the base commit version and the working tree version, which is in line with what "git show" gives. * Sometimes users want to report a bug they experience on their repository, but they are not at liberty to share the contents of the repository. "fast-export" was taught an "--anonymize" option to replace blob contents, names of people and paths and log messages with bland and simple strings to help them. * "git difftool" learned an option to stop feeding paths to the diff backend when it exits with a non-zero status. * "git grep" allows to paint (or not paint) partial matches on context lines when showing "grep -C" output in color. * "log --date=iso" uses a slight variant of ISO 8601 format that is made more human readable. A new "--date=iso-strict" option gives datetime output that is more strictly conformant. * The logic "git prune" uses is more resilient against various corner cases. * A broken reimplementation of Git could write an invalid index that records both stage #0 and higher stage entries for the same path. We now notice and reject such an index, as there is no sensible fallback (we do not know if the broken tool wanted to resolve and forgot to remove higher stage entries, or if it wanted to unresolve and forgot to remove the stage#0 entry). * The temporary files "git mergetool" uses are named to avoid too many dots in them (e.g. a temporary file for "hello.c" used to be named e.g. "hello.BASE.4321.c" but now uses underscore instead, e.g. "hello_BASE_4321.c"). * The temporary files "git mergetools" uses can be placed in a newly created temporary directory, instead of the current directory, by setting the mergetool.writeToTemp configuration variable. * "git mergetool" understands "--tool bc" now, as version 4 of BeyondCompare can be driven the same way as its version 3 and it feels awkward to say "--tool bc3". * The "pre-receive" and "post-receive" hooks are no longer required to consume their input fully (not following this requirement used to result in intermittent errors in "git push"). * The pretty-format specifier "%d", which expanded to " (tagname)" for a tagged commit, gained a cousin "%D" that just gives the "tagname" without frills. * "git push" learned "--signed" push, that allows a push (i.e. request to update the refs on the other side to point at a new history, together with the transmission of necessary objects) to be signed, so that it can be verified and audited, using the GPG signature of the person who pushed, that the tips of branches at a public repository really point the commits the pusher wanted to, without having to "trust" the server. * "git interpret-trailers" is a new filter to programmatically edit the tail end of the commit log messages. * "git help everyday" shows the "Everyday Git in 20 commands or so" document, whose contents have been updated to more modern Git practice. * On the "git svn" front, work to reduce memory consumption and to improve handling of mergeinfo progresses. Performance, Internal Implementation, etc. * The API to manipulate the "refs" has been restructured to make it more transactional, with the eventual goal to allow all-or-none atomi
Re: [PATCH v4 0/3] PM / clock_ops: add pm_clk_add_clk()
On Thursday, November 06, 2014 03:50:59 PM Grygorii Strashko wrote: > Hi Santosh, Kevin, > > I've separated these patches in standalone series as requested by > Santosh (https://lkml.org/lkml/2014/10/24/591). Also, I've kept > versioning of patches from original series and therefor this > is v4 of patches. > > The patch 1 was originally introduced in [1] (Apr 2014) and it allows > to fill per-device list of clock from DT. > > The patch 2 is small clean up needed for patch 3. > > The patch 3 was created as was discussed in v2 and first introduced in v3. > Here I marked it as RFC, because I've found some disadvantages of such > approach - see comments to the patch itself. > > Finally, this series is needed to enable to enable Runtime > PM for Keystone 2, but honestly I need only patch 1. > > RFC version of patches can be found at [2]. > > Changes in v4: > - pm_clk_add_clk() changed to get reference on clock as >requested by Dmitry Torokhov (see v3). Now the caller has to >use clk_put() on clock pointer when done. > > Changes in v3: > - handling of the case when !CONFIG_PM_RUNTIME has been >moved in PM clock framework. > > Changes in v2: > - minor comments applied and rebased on top of Linux 3.18-rc1. > > Links on previous versions: > v3: https://lkml.org/lkml/2014/10/23/342 > v2: https://lkml.org/lkml/2014/10/20/248 > v1: https://lkml.org/lkml/2014/9/29/382 > > [1] "[PATCH/RFC 0/4] of: Register clocks for Runtime PM with PM core" > https://lkml.org/lkml/2014/4/24/1118 > > [2] "[RFC PATCH 0/4] ARM: keystone: pm: switch to use generic pm domains" > https://lkml.org/lkml/2014/9/25/364 > > CC: Santosh Shilimkar > CC: Kevin Hilman > CC: Ulf Hansson > CC: Geert Uytterhoeven > CC: Dmitry Torokhov > > Geert Uytterhoeven (1): > PM / clock_ops: Add pm_clk_add_clk() > > Grygorii Strashko (2): > PM / clock_ops: make __pm_clk_enable more generic > PM / clock_ops: add and enable clocks always if !CONFIG_PM_RUNTIME > > drivers/base/power/clock_ops.c | 89 > +++--- > include/linux/pm_clock.h | 8 > 2 files changed, 65 insertions(+), 32 deletions(-) Patches [1-2/3] queued up for 3.19, thanks! -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 0/2] intel_pstate: Add support for hardware managed P states (HWP)
On Thursday, November 06, 2014 09:40:45 AM dirk.brande...@gmail.com wrote: > From: Dirk Brandewie > > This patch set adds support for HWP. When HWP is enabled the CPU will > do P state autonomously and intel_pstate simply provides an interface > to forward user preferences to the CPU while maintaining the > interfaces required by the cpufreq core. > > Dirk Brandewie (2): > x86: Add support for Intel HWP feature detection. > intel_pstate: Add support for HWP > > Documentation/cpu-freq/intel-pstate.txt | 37 > Documentation/kernel-parameters.txt | 3 + > arch/x86/include/asm/cpufeature.h | 5 ++ > arch/x86/include/uapi/asm/msr-index.h | 41 + > arch/x86/kernel/cpu/scattered.c | 5 ++ > drivers/cpufreq/intel_pstate.c | 102 > +++- > 6 files changed, 178 insertions(+), 15 deletions(-) Both patches queued up for 3.19 (with assorted fixups), thanks! -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: frequent lockups in 3.18rc4
On Fri, Nov 14, 2014 at 11:55:30PM +0100, Thomas Gleixner wrote: > So this looks more like a smp function call fuckup. > > I assume Dave is running that stuff on KVM. So it might be worth while > to look at the IPI magic there. no, bare metal. Dave -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 0/3] Intel RAPL updates for Atom CPUs
On Friday, November 07, 2014 09:29:24 AM Jacob Pan wrote: > Running Average Power Limit (RAPL) is supported in Atom processors > with a slightly different implementation. This patchset abstracts the > differences and add support for newer ATOM CPUs. > > Intel Software Developers Manual has also been updated with many changes > and clarifications on how RAPL units and power limits are calculated. > > Changes: > v2: fix 32 bit divide in time window calculation > > Jacob Pan (3): > powercap/rapl: abstract per cpu type functions > powercap/rapl: handle atom and core differences > powercap/rapl: add new model ids > > drivers/powercap/intel_rapl.c | 264 > -- > 1 file changed, 177 insertions(+), 87 deletions(-) Series queued up for 3.19 (along with the later build fix), thanks! -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] PM / Domains: Extract code to power off/on a PM domain
On Thursday, November 13, 2014 03:10:07 PM Pavel Machek wrote: > On Mon 2014-11-10 19:39:19, Geert Uytterhoeven wrote: > > PM domains are powered on/off from various places. Some callers do > > latency measurements, others don't. Consolidate using two helper > > functions, which always measure the latencies, and update the stored > > latencies when needed. > > > > Other minor changes: > > - Use pr_warn() instead of pr_warning(), > > - There's no need to check genpd->name, %s handles NULL pointers fine, > > - Make the warning format strings identical, to save memory. > > > > Signed-off-by: Geert Uytterhoeven > > Reviewed-by: Ulf Hansson > > Reviewed-by: Kevin Hilman > > Acked-by: Pavel Machek Patch queued up for 3.19, thanks! > > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c > > index a841bab441147b3d..2fccf2c2575e4fa3 100644 > > --- a/drivers/base/power/domain.c > > +++ b/drivers/base/power/domain.c > > @@ -151,6 +151,59 @@ static void genpd_recalc_cpu_exit_latency(struct > > generic_pm_domain *genpd) > > genpd->cpuidle_data->idle_state->exit_latency = usecs64; > > } > > > > +static int genpd_power_on(struct generic_pm_domain *genpd) > > +{ > > + ktime_t time_start; > > + s64 elapsed_ns; > > + int ret; > > + > > + if (!genpd->power_on) > > + return 0; > > + > > + time_start = ktime_get(); > > + ret = genpd->power_on(genpd); > > + if (ret) > > + return ret; > > + > > + elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start)); > > + if (elapsed_ns <= genpd->power_on_latency_ns) > > + return ret; > > + > > + genpd->power_on_latency_ns = elapsed_ns; > > + genpd->max_off_time_changed = true; > > + genpd_recalc_cpu_exit_latency(genpd); > > + pr_warn("%s: Power-%s latency exceeded, new value %lld ns\n", > > + genpd->name, "on", elapsed_ns); > > + > > + return ret; > > +} > > + > > +static int genpd_power_off(struct generic_pm_domain *genpd) > > +{ > > + ktime_t time_start; > > + s64 elapsed_ns; > > + int ret; > > + > > + if (!genpd->power_off) > > + return 0; > > + > > + time_start = ktime_get(); > > + ret = genpd->power_off(genpd); > > + if (ret == -EBUSY) > > + return ret; > > + > > + elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start)); > > + if (elapsed_ns <= genpd->power_off_latency_ns) > > + return ret; > > + > > + genpd->power_off_latency_ns = elapsed_ns; > > + genpd->max_off_time_changed = true; > > + pr_warn("%s: Power-%s latency exceeded, new value %lld ns\n", > > + genpd->name, "off", elapsed_ns); > > + > > + return ret; > > +} > > + > > /** > > * __pm_genpd_poweron - Restore power to a given PM domain and its masters. > > * @genpd: PM domain to power up. > > @@ -222,25 +275,9 @@ static int __pm_genpd_poweron(struct generic_pm_domain > > *genpd) > > } > > } > > > > - if (genpd->power_on) { > > - ktime_t time_start = ktime_get(); > > - s64 elapsed_ns; > > - > > - ret = genpd->power_on(genpd); > > - if (ret) > > - goto err; > > - > > - elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start)); > > - if (elapsed_ns > genpd->power_on_latency_ns) { > > - genpd->power_on_latency_ns = elapsed_ns; > > - genpd->max_off_time_changed = true; > > - genpd_recalc_cpu_exit_latency(genpd); > > - if (genpd->name) > > - pr_warning("%s: Power-on latency exceeded, " > > - "new value %lld ns\n", genpd->name, > > - elapsed_ns); > > - } > > - } > > + ret = genpd_power_on(genpd); > > + if (ret) > > + goto err; > > > > out: > > genpd_set_active(genpd); > > @@ -529,16 +566,11 @@ static int pm_genpd_poweroff(struct generic_pm_domain > > *genpd) > > } > > > > if (genpd->power_off) { > > - ktime_t time_start; > > - s64 elapsed_ns; > > - > > if (atomic_read(&genpd->sd_count) > 0) { > > ret = -EBUSY; > > goto out; > > } > > > > - time_start = ktime_get(); > > - > > /* > > * If sd_count > 0 at this point, one of the subdomains hasn't > > * managed to call pm_genpd_poweron() for the master yet after > > @@ -547,21 +579,11 @@ static int pm_genpd_poweroff(struct generic_pm_domain > > *genpd) > > * the pm_genpd_poweron() restore power for us (this shouldn't > > * happen very often). > > */ > > - ret = genpd->power_off(genpd); > > + ret = genpd_power_off(genpd); > > if (ret == -EBUSY) { > > genpd_set_active(genpd); > > goto out; > > } > > - > > - elapsed_ns = ktime_to_ns(kt
Re: [PATCH v2] PM / Domains: Make genpd parameter of pm_genpd_present() const
On Thursday, November 13, 2014 04:26:51 PM Pavel Machek wrote: > On Thu 2014-11-13 16:12:25, Geert Uytterhoeven wrote: > > Hi Pavel, > > > > On Thu, Nov 13, 2014 at 3:09 PM, Pavel Machek wrote: > > > Acked-by: Pavel Machek > > > > You've got a new email address? ;-) > > Yes, I decided to typo-squat myself :-). Just kidding. > > Acked-by: Pavel Machek Patch queued up for 3.19, thanks! -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[for-next][PATCH 6/9] tracing: Merge consecutive seq_puts calls
From: Rasmus Villemoes Consecutive seq_puts calls with literal strings can be merged to a single call. This reduces the size of the generated code, and can also lead to slight .rodata reduction (because of fewer nul and padding bytes). It should also shave a off a few clock cycles. Link: http://lkml.kernel.org/r/1415479332-25944-3-git-send-email-li...@rasmusvillemoes.dk Signed-off-by: Rasmus Villemoes Signed-off-by: Steven Rostedt --- kernel/trace/trace.c| 64 ++--- kernel/trace/trace_branch.c | 14 +- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index a419db75152c..44d561426700 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -2509,14 +2509,14 @@ get_total_entries(struct trace_buffer *buf, static void print_lat_help_header(struct seq_file *m) { - seq_puts(m, "# _--=> CPU#\n"); - seq_puts(m, "# / _-=> irqs-off\n"); - seq_puts(m, "#| / _=> need-resched\n"); - seq_puts(m, "#|| / _---=> hardirq/softirq \n"); - seq_puts(m, "#||| / _--=> preempt-depth \n"); - seq_puts(m, "# / delay \n"); - seq_puts(m, "# cmd pid | time | caller \n"); - seq_puts(m, "# \\ / | \\| / \n"); + seq_puts(m, "# _--=> CPU#\n" + "# / _-=> irqs-off\n" + "#| / _=> need-resched\n" + "#|| / _---=> hardirq/softirq \n" + "#||| / _--=> preempt-depth \n" + "# / delay\n" + "# cmd pid | time | caller \n" + "# \\ / | \\| / \n"); } static void print_event_info(struct trace_buffer *buf, struct seq_file *m) @@ -2533,20 +2533,20 @@ static void print_event_info(struct trace_buffer *buf, struct seq_file *m) static void print_func_help_header(struct trace_buffer *buf, struct seq_file *m) { print_event_info(buf, m); - seq_puts(m, "# TASK-PID CPU# TIMESTAMP FUNCTION\n"); - seq_puts(m, "# | | | | |\n"); + seq_puts(m, "# TASK-PID CPU# TIMESTAMP FUNCTION\n" + "# | | | | |\n"); } static void print_func_help_header_irq(struct trace_buffer *buf, struct seq_file *m) { print_event_info(buf, m); - seq_puts(m, "# _-=> irqs-off\n"); - seq_puts(m, "# / _=> need-resched\n"); - seq_puts(m, "#| / _---=> hardirq/softirq\n"); - seq_puts(m, "#|| / _--=> preempt-depth\n"); - seq_puts(m, "#||| / delay\n"); - seq_puts(m, "# TASK-PID CPU# TIMESTAMP FUNCTION\n"); - seq_puts(m, "# | | | | |\n"); + seq_puts(m, "# _-=> irqs-off\n" + "# / _=> need-resched\n" + "#| / _---=> hardirq/softirq\n" + "#|| / _--=> preempt-depth\n" + "#||| / delay\n" + "# TASK-PID CPU# TIMESTAMP FUNCTION\n" + "# | | | | |\n"); } void @@ -2860,34 +2860,34 @@ static void test_ftrace_alive(struct seq_file *m) { if (!ftrace_is_dead()) return; - seq_puts(m, "# WARNING: FUNCTION TRACING IS CORRUPTED\n"); - seq_puts(m, "# MAY BE MISSING FUNCTION EVENTS\n"); + seq_puts(m, "# WARNING: FUNCTION TRACING IS CORRUPTED\n" + "# MAY BE MISSING FUNCTION EVENTS\n"); } #ifdef CONFIG_TRACER_MAX_TRACE static void show_snapshot_main_help(struct seq_file *m) { - seq_puts(m, "# echo 0 > snapshot : Clears and frees snapshot buffer\n"); - seq_puts(m, "# echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.\n"); - seq_puts(m, "# Takes a snapshot of the main buffer.\n"); - seq_puts(m, "# echo 2 > snapshot : Clears snapshot buffer (but does not allocate or free)\n"); - seq_puts(m, "# (Doesn't have to be '2' works with any number that\n"); - seq_puts(m, "# is not a '0' or '1')\n"); + seq_puts(m, "# echo 0 > snapshot : Clears and frees snapshot buffer\n" +
[for-next][PATCH 5/9] tracing: Replace seq_printf by simpler equivalents
From: Rasmus Villemoes Using seq_printf to print a simple string or a single character is a lot more expensive than it needs to be, since seq_puts and seq_putc exist. These patches do seq_printf(m, s) -> seq_puts(m, s) seq_printf(m, "%s", s) -> seq_puts(m, s) seq_printf(m, "%c", c) -> seq_putc(m, c) Subsequent patches will simplify further. Link: http://lkml.kernel.org/r/1415479332-25944-2-git-send-email-li...@rasmusvillemoes.dk Signed-off-by: Rasmus Villemoes Signed-off-by: Steven Rostedt --- kernel/trace/ftrace.c| 30 kernel/trace/trace.c | 44 ++-- kernel/trace/trace_branch.c | 26 ++--- kernel/trace/trace_events.c | 4 ++-- kernel/trace/trace_events_trigger.c | 2 +- kernel/trace/trace_functions.c | 2 +- kernel/trace/trace_functions_graph.c | 28 +++ kernel/trace/trace_kprobe.c | 4 ++-- kernel/trace/trace_uprobe.c | 2 +- 9 files changed, 71 insertions(+), 71 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 1a13e615a068..6233f9102179 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -571,13 +571,13 @@ static int function_stat_cmp(void *p1, void *p2) static int function_stat_headers(struct seq_file *m) { #ifdef CONFIG_FUNCTION_GRAPH_TRACER - seq_printf(m, " Function " - "HitTimeAvg s^2\n" - " " - "------ ---\n"); + seq_puts(m, " Function " +"HitTimeAvg s^2\n" + " " +"------ ---\n"); #else - seq_printf(m, " Function Hit\n" - " ---\n"); + seq_puts(m, " Function Hit\n" + " ---\n"); #endif return 0; } @@ -604,7 +604,7 @@ static int function_stat_show(struct seq_file *m, void *v) seq_printf(m, " %-30.30s %10lu", str, rec->counter); #ifdef CONFIG_FUNCTION_GRAPH_TRACER - seq_printf(m, ""); + seq_puts(m, ""); avg = rec->time; do_div(avg, rec->counter); @@ -3006,9 +3006,9 @@ static int t_show(struct seq_file *m, void *v) if (iter->flags & FTRACE_ITER_PRINTALL) { if (iter->flags & FTRACE_ITER_NOTRACE) - seq_printf(m, " no functions disabled \n"); + seq_puts(m, " no functions disabled \n"); else - seq_printf(m, " all functions enabled \n"); + seq_puts(m, " all functions enabled \n"); return 0; } @@ -3030,13 +3030,13 @@ static int t_show(struct seq_file *m, void *v) seq_printf(m, "\ttramp: %pS", (void *)ops->trampoline); else - seq_printf(m, "\ttramp: ERROR!"); + seq_puts(m, "\ttramp: ERROR!"); } add_trampoline_func(m, ops, rec); } - seq_printf(m, "\n"); + seq_putc(m, '\n'); return 0; } @@ -4233,9 +4233,9 @@ static int g_show(struct seq_file *m, void *v) struct ftrace_graph_data *fgd = m->private; if (fgd->table == ftrace_graph_funcs) - seq_printf(m, " all functions enabled \n"); + seq_puts(m, " all functions enabled \n"); else - seq_printf(m, " no functions disabled \n"); + seq_puts(m, " no functions disabled \n"); return 0; } @@ -5155,12 +5155,12 @@ static int fpid_show(struct seq_file *m, void *v) const struct ftrace_pid *fpid = list_entry(v, struct ftrace_pid, list); if (v == (void *)1) { - seq_printf(m, "no pid\n"); + seq_puts(m, "no pid\n"); return 0; } if (fpid->pid == ftrace_swapper_pid) - seq_printf(m, "swapper tasks\n"); + seq_puts(m, "swapper tasks\n"); else seq_printf(m, "%u\n", pid_vnr(fpid->pid)); diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 75798ab8eb88..a419db75152c 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -2860,44 +2860,44 @@ static void test_ftrace_alive(struct seq_file *m) { if (!ftrace_is_dead()) return; - seq_printf(m, "# WARNING:
[for-next][PATCH 0/9] tracing: Some fixes and cleanups for 3.19
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git for-next Head SHA1: 4526d0676a150dce7a93ad93e03bef7f77e7c906 Byungchul Park (1): function_graph: Fix micro seconds notations Daniel Bristot de Oliveira (1): ftrace-graph: show latency-format on print_graph_irq() Daniel Thompson (2): tracing: kdb: Fix kernel panic during ftdump tracing: kdb: Fix kernel livelock with empty buffers Luis Claudio R. Goncalves (1): tracing: Fix traceoff_on_warning handling on boot command line Rasmus Villemoes (3): tracing: Replace seq_printf by simpler equivalents tracing: Merge consecutive seq_puts calls trace: Replace single-character seq_puts with seq_putc Steven Rostedt (Red Hat) (1): ftrace: Have the control_ops get a trampoline kernel/trace/ftrace.c| 32 +++--- kernel/trace/trace.c | 83 ++-- kernel/trace/trace_branch.c | 32 +++--- kernel/trace/trace_events.c | 4 +- kernel/trace/trace_events_trigger.c | 6 +-- kernel/trace/trace_functions.c | 2 +- kernel/trace/trace_functions_graph.c | 49 - kernel/trace/trace_kdb.c | 21 + kernel/trace/trace_kprobe.c | 12 +++--- kernel/trace/trace_printk.c | 2 +- kernel/trace/trace_uprobe.c | 4 +- 11 files changed, 132 insertions(+), 115 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[for-next][PATCH 1/9] ftrace: Have the control_ops get a trampoline
From: "Steven Rostedt (Red Hat)" With the new logic, if only a single user of ftrace function hooks is used, it will get its own trampoline assigned to it. The problem is that the control_ops is an indirect ops that perf ops uses. What that means is that when perf registers its ops with register_ftrace_function(), it has the CONTROL flag set and gets added to the control list instead of the global ftrace list. The control_ops gets added to that instead and the mcount trampoline calls the control_ops function. The control_ops function will iterate the control list and call the ops functions that are attached to it. But currently the trampoline is added to the perf ops and not the control ops, and when ftrace tries to find a trampoline hook for it, it fails to find one and gives the following splat: [ cut here ] WARNING: CPU: 0 PID: 10133 at kernel/trace/ftrace.c:2033 ftrace_get_addr_new+0x6f/0xc0() Modules linked in: [...] CPU: 0 PID: 10133 Comm: perf Tainted: P 3.18.0-rc1-test+ #388 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v02.05 05/07/2012 07f1 8800c2643bc8 814fca6e 88011ea0ed01 8800c2643c08 81041ffd 810c388c 81a5a350 880119b0 810001c8 Call Trace: [] dump_stack+0x46/0x58 [] warn_slowpath_common+0x81/0x9b [] ? ftrace_get_addr_new+0x6f/0xc0 [] ? 0x810001c8 [] warn_slowpath_null+0x1a/0x1c [] ftrace_get_addr_new+0x6f/0xc0 [] ftrace_replace_code+0xd6/0x334 [] ftrace_modify_all_code+0x41/0xc5 [] arch_ftrace_update_code+0x10/0x19 [] ftrace_run_update_code+0x21/0x42 [] ftrace_startup_enable+0x32/0x34 [] ftrace_startup+0x14e/0x15a [] register_ftrace_function+0x27/0x40 [] perf_ftrace_event_register+0x3e/0xee [] perf_trace_init+0x29d/0x2a9 [] perf_tp_event_init+0x27/0x3a [] perf_init_event+0x9e/0xed [] perf_event_alloc+0x299/0x330 [] SYSC_perf_event_open+0x3ee/0x816 [] ? mntput+0x2d/0x2f [] ? __fput+0xa7/0x1b2 [] ? do_gettimeofday+0x22/0x3a [] SyS_perf_event_open+0x9/0xb [] system_call_fastpath+0x12/0x17 ---[ end trace 81a53565150e4982 ]--- Bad trampoline accounting at: 810001c8 (run_init_process+0x0/0x2d) (1001) Update the control_ops trampoline instead of the perf ops one. Reported-by: l...@01.org Signed-off-by: Steven Rostedt --- kernel/trace/ftrace.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 4043332f6720..1a13e615a068 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -418,6 +418,8 @@ static int __register_ftrace_function(struct ftrace_ops *ops) if (control_ops_alloc(ops)) return -ENOMEM; add_ftrace_list_ops(&ftrace_control_list, &control_ops, ops); + /* The control_ops needs the trampoline update */ + ops = &control_ops; } else add_ftrace_ops(&ftrace_ops_list, ops); -- 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/