Re: [PATCH v3 3/3] sched: BUG when stack end location is over written
On Thu, 2014-09-11 at 16:41 +0100, Aaron Tomlin wrote: Currently in the event of a stack overrun a call to schedule() does not check for this type of corruption. This corruption is often silent and can go unnoticed. However once the corrupted region is examined at a later stage, the outcome is undefined and often results in a sporadic page fault which cannot be handled. This patch checks for a stack overrun and takes appropriate action since the damage is already done, there is no point in continuing. Signed-off-by: Aaron Tomlin atom...@redhat.com --- kernel/sched/core.c | 3 +++ lib/Kconfig.debug | 12 2 files changed, 15 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ec1a286..0b70b73 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2660,6 +2660,9 @@ static noinline void __schedule_bug(struct task_struct *prev) */ static inline void schedule_debug(struct task_struct *prev) { +#ifdef CONFIG_SCHED_STACK_END_CHECK + BUG_ON(unlikely(task_stack_end_corrupted(prev))) +#endif Spot the bug? Please compile your code in future. ../kernel/sched/core.c: In function ‘schedule_debug’: ../kernel/sched/core.c:2671:2: error: expected ‘;’ before ‘if’ if (unlikely(in_atomic_preempt_off() prev-state != TASK_DEAD)) ^ ../kernel/sched/core.c: At top level: ../kernel/sched/core.c:2635:22: warning: ‘__schedule_bug’ defined but not used [-Wunused-function] static noinline void __schedule_bug(struct task_struct *prev) ^ make[3]: *** [kernel/sched/core.o] Error 1 make[2]: *** [kernel/sched] Error 2 make[1]: *** [kernel] Error 2 make: *** [sub-make] Error 2 cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V2] ASoC: fsl_ssi: refine ipg clock usage in this module
Hi, On Fri, Sep 12, 2014 at 10:01:12AM +0800, Shengjiu Wang wrote: On Thu, Sep 11, 2014 at 03:57:37PM -0700, Nicolin Chen wrote: On Thu, Sep 11, 2014 at 01:38:29PM +0800, Shengjiu Wang wrote: Move the ipg clock enable and disable operation to startup and shutdown, that is only enable ipg clock when ssi is working. Keep clock is disabled when ssi is in idle. otherwise, _fsl_ssi_set_dai_fmt function need to be called in probe, so add ipg clock control for it. It seems to be no objection so far against my last suggestion to use regmap's mmio_clk() for named ipg clk only. So you may still consider about that. I think mmio_clk() can be put to another patch. and this patch only for clk_enable() and clk_disable() operation. I would also prefer Nicolin's suggestion using regmap's mmio clk. I think it may be better to not add this particular patch at all and just go with the mmio_clk patch. It should be easy enough to just add the clock names to the devicetrees. That way we can avoid all those clock enable/disable function calls. Anyway, I'd like to do thing in parallel. So I just simply tested it on my side and its works fine, it may still need to be tested by others though. Nicolina Hi Markus could you please review it, and share your comments? I think the clock enabling for AC97 is missing in your patch. Best regards, Markus -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | signature.asc Description: Digital signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V2] ASoC: fsl_ssi: refine ipg clock usage in this module
On Fri, Sep 12, 2014 at 08:17:06AM +0200, Markus Pargmann wrote: Hi, On Fri, Sep 12, 2014 at 10:01:12AM +0800, Shengjiu Wang wrote: On Thu, Sep 11, 2014 at 03:57:37PM -0700, Nicolin Chen wrote: On Thu, Sep 11, 2014 at 01:38:29PM +0800, Shengjiu Wang wrote: Move the ipg clock enable and disable operation to startup and shutdown, that is only enable ipg clock when ssi is working. Keep clock is disabled when ssi is in idle. otherwise, _fsl_ssi_set_dai_fmt function need to be called in probe, so add ipg clock control for it. It seems to be no objection so far against my last suggestion to use regmap's mmio_clk() for named ipg clk only. So you may still consider about that. I think mmio_clk() can be put to another patch. and this patch only for clk_enable() and clk_disable() operation. I would also prefer Nicolin's suggestion using regmap's mmio clk. I think it may be better to not add this particular patch at all and just go with the mmio_clk patch. It should be easy enough to just add the clock names to the devicetrees. That way we can avoid all those clock enable/disable function calls. I considered if use Nicolin's suggestion, I still need ot add those enable/disable function calls, because I want to remove the enable/disable function call in fsl_ssi_imx_probe, then I need to add enable/disable function call in _fsl_ssi_set_dai_fmt(), which is called in fsl_ssi_probe(). _fsl_ssi_set_dai_fmt() need to access the registers. Anyway, I'd like to do thing in parallel. So I just simply tested it on my side and its works fine, it may still need to be tested by others though. Nicolina Hi Markus could you please review it, and share your comments? I think the clock enabling for AC97 is missing in your patch. I add clock enable in fsl_ssi_startup(), I think it is enough for AC97, does it? wang shengjiu Best regards, Markus -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v3 1/3] init/main.c: Give init_task a canary
On Thu, 2014-09-11 at 16:41 +0100, Aaron Tomlin wrote: Tasks get their end of stack set to STACK_END_MAGIC with the aim to catch stack overruns. Currently this feature does not apply to init_task. This patch removes this restriction. diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c index 51ab9e7..35d0760c 100644 --- a/arch/powerpc/mm/fault.c +++ b/arch/powerpc/mm/fault.c @@ -30,7 +30,6 @@ #include linux/kprobes.h #include linux/kdebug.h #include linux/perf_event.h -#include linux/magic.h #include linux/ratelimit.h #include linux/context_tracking.h @@ -538,7 +537,7 @@ void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig) regs-nip); stackend = end_of_stack(current); - if (current != init_task *stackend != STACK_END_MAGIC) + if (*stackend != STACK_END_MAGIC) printk(KERN_ALERT Thread overran stack, or stack corrupted\n); This part looks fine. Acked-by: Michael Ellerman m...@ellerman.id.au cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] Avoid bashisms
On Mon, 2014-08-04 at 23:36 +0400, av1...@comtv.ru wrote: From 300a98f895dc7e2167cf379408322a9607907761 Mon Sep 17 00:00:00 2001 From: malc av1...@comtv.ru Date: Mon, 4 Aug 2014 23:28:05 +0400 Subject: [PATCH] Avoid bashisms Hi malc, If you want us to take your patch, please resend with: - a better subject, eg: powerpc: Avoid bashisms in prom_init_check.sh - a Signed-off-by line. cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] powerpc: make of_device_ids const
On Wed, 2014-09-10 at 21:56 +0200, Uwe Kleine-König wrote: of_device_ids (i.e. compatible strings and the respective data) are not supposed to change at runtime. All functions working with of_device_ids provided by linux/of.h work with const of_device_ids. This allows to mark all struct of_device_id const, too. While touching these line also put the __init annotation at the right position where necessary. Signed-off-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de --- Hello, I don't know how arch/powerpc is maintained. So please tell me if I should split this patch further. I manually checked that all const annotations are OK, and the 0day build bot didn't find a regression. Thanks. We'll take it as-is, it seems to merge cleanly. We track patches via patchwork, this one is at: http://patchwork.ozlabs.org/patch/387959/ cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [PATCH v3 0/3] sched: Always check the integrity of the canary
From: Chuck Ebbert David Laight david.lai...@aculab.com wrote: From: Aaron Tomlin Currently in the event of a stack overrun a call to schedule() does not check for this type of corruption. This corruption is often silent and can go unnoticed. However once the corrupted region is examined at a later stage, the outcome is undefined and often results in a sporadic page fault which cannot be handled. The first patch adds a canary to init_task's end of stack. While the second patch provides a helper to determine the integrity of the canary. The third checks for a stack overrun and takes appropriate action since the damage is already done, there is no point in continuing. Clearly you've just been 'bitten' by a kernel stack overflow. But a simple 'canary' isn't going to find most of the overflows and will give an incorrect 'sense of security'. The canary will only work if the stack is densely written. In practise the stack alignment rules create gaps, and the most likely reason for overflow is a large on-stack buffer that isn't actually written to. The only real way to detect kernel stack overflow is to arrange for an unmapped page beyond the stack. That costs KVA, but not much else. That doesn't work either, because the threadinfo sits between the end of the stack and the beginning of the next page, making it possible to corrupt critical data without running off the page. Then flip the order of the allocations so that the threadinfo is at the other end. I'm not sure how many per-lwp structures the linux kernel has, but I know that on netbsd the main thing the kernel stack hits is the fpu save area - the end of that is the avx area which won't be needed when the stack usage is large. Everything else could be moved from the stack pages to the lwp struct itself. David ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/2] pseries: Fix endian issues in cpu hot-removal
On Wed, 2014-09-10 at 17:41 -0500, Thomas Falcon wrote: When removing a cpu, this patch makes sure that values gotten from or passed to firmware are in the correct endian format. Signed-off-by: Thomas Falcon tlfal...@linux.vnet.ibm.com --- arch/powerpc/platforms/pseries/dlpar.c | 14 +++--- arch/powerpc/platforms/pseries/hotplug-cpu.c | 8 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c index cd425dc..c5ecfdb 100644 --- a/arch/powerpc/platforms/pseries/dlpar.c +++ b/arch/powerpc/platforms/pseries/dlpar.c @@ -442,7 +442,7 @@ static int dlpar_offline_cpu(struct device_node *dn) int rc = 0; unsigned int cpu; int len, nthreads, i; - const u32 *intserv; + const __be32 *intserv; intserv = of_get_property(dn, ibm,ppc-interrupt-server#s, len); if (!intserv) @@ -453,7 +453,7 @@ static int dlpar_offline_cpu(struct device_node *dn) cpu_maps_update_begin(); for (i = 0; i nthreads; i++) { Can you please do the conversion once here for each value of i. You can call the converted value thread ? for_each_present_cpu(cpu) { - if (get_hard_smp_processor_id(cpu) != intserv[i]) + if (get_hard_smp_processor_id(cpu) != be32_to_cpu(intserv[i])) continue; Rather than doing it for every cpu in the system for every value of i. Not that performance is really an issue, but it's just ugly. And obviously the other places that use it in the loop should use the converted value. @@ -494,7 +494,7 @@ out: static ssize_t dlpar_cpu_release(const char *buf, size_t count) { struct device_node *dn; - const u32 *drc_index; + const __be32 *drc_index; int rc; dn = of_find_node_by_path(buf); @@ -513,7 +513,7 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count) return -EINVAL; } Here again you should do the conversion once. Better still use of_property_read_u32(). - rc = dlpar_release_drc(*drc_index); + rc = dlpar_release_drc(be32_to_cpup(drc_index)); if (rc) { of_node_put(dn); return rc; @@ -521,7 +521,7 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count) rc = dlpar_detach_node(dn); if (rc) { - dlpar_acquire_drc(*drc_index); + dlpar_acquire_drc(be32_to_cpup(drc_index)); return rc; } cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V2] ASoC: fsl_ssi: refine ipg clock usage in this module
On Fri, Sep 12, 2014 at 03:14:28PM +0800, Shengjiu Wang wrote: On Fri, Sep 12, 2014 at 08:17:06AM +0200, Markus Pargmann wrote: Hi, On Fri, Sep 12, 2014 at 10:01:12AM +0800, Shengjiu Wang wrote: On Thu, Sep 11, 2014 at 03:57:37PM -0700, Nicolin Chen wrote: On Thu, Sep 11, 2014 at 01:38:29PM +0800, Shengjiu Wang wrote: Move the ipg clock enable and disable operation to startup and shutdown, that is only enable ipg clock when ssi is working. Keep clock is disabled when ssi is in idle. otherwise, _fsl_ssi_set_dai_fmt function need to be called in probe, so add ipg clock control for it. It seems to be no objection so far against my last suggestion to use regmap's mmio_clk() for named ipg clk only. So you may still consider about that. I think mmio_clk() can be put to another patch. and this patch only for clk_enable() and clk_disable() operation. I would also prefer Nicolin's suggestion using regmap's mmio clk. I think it may be better to not add this particular patch at all and just go with the mmio_clk patch. It should be easy enough to just add the clock names to the devicetrees. That way we can avoid all those clock enable/disable function calls. I considered if use Nicolin's suggestion, I still need ot add those enable/disable function calls, because I want to remove the enable/disable function call in fsl_ssi_imx_probe, then I need to add enable/disable function call in _fsl_ssi_set_dai_fmt(), which is called in fsl_ssi_probe(). _fsl_ssi_set_dai_fmt() need to access the registers. I think Nicolin's suggestion was to check for a clock named ipg. If it exists, you can simply use devm_regmap_init_mmio_clk(). Otherwise you could fallback to the old behaviour and get the first clock and enable it without disabling it after the probe function. After that, you could add the clock-names property to the devicetrees and have the same result. Anyway, I'd like to do thing in parallel. So I just simply tested it on my side and its works fine, it may still need to be tested by others though. Nicolina Hi Markus could you please review it, and share your comments? I think the clock enabling for AC97 is missing in your patch. I add clock enable in fsl_ssi_startup(), I think it is enough for AC97, does it? No. We export ac97 read/write ops for the whole AC97 stuff. These may be used outside of the usual startup/shutdown which is done for substreams. It may work to have the ipg clock enabled in fsl_ssi_ac97_read/fsl_ssi_ac97_write. Best regards, Markus -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | signature.asc Description: Digital signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V2] powerpc/eeh: Fix kernel crash when passing through VF
On Fri, Sep 12, 2014 at 03:05:18PM +1000, Gavin Shan wrote: On Fri, Sep 12, 2014 at 01:55:23PM +1000, Michael Ellerman wrote: On Thu, 2014-09-11 at 11:42 +0800, Wei Yang wrote: diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c index 4a45ba8..403445e 100644 --- a/arch/powerpc/kernel/eeh.c +++ b/arch/powerpc/kernel/eeh.c @@ -625,7 +625,7 @@ int eeh_pci_enable(struct eeh_pe *pe, int function) int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state) { struct eeh_dev *edev = pci_dev_to_eeh_dev(dev); - struct eeh_pe *pe = edev-pe; + struct eeh_pe *pe = edev ? edev-pe : NULL; if (!pe) { pr_err(%s: No PE found on PCI device %s\n, We seem to do this or something similar in a few places. Is it worth having a pci_dev_to_eeh_pe() inline? Yes, maybe we just need a eeh_dev_to_pe() because converting pci_dev to eeh_dev is already coverred by pci_dev_to_eeh_dev(). With eeh_dev_to_pe(), it looks like this: struct pci_dev *pdev; struct eeh_dev *edev = pci_dev_to_eeh_dev(pdev); struct eeh_pe *pe = eeh_dev_to_pe(edev); Or another case: struct device_node *dn; struct eeh_dev *edev = of_node_to_eeh_dev(dn); struct eeh_pe *pe = eeh_dev_to_pe(edev); With these helper, it would be more consolidate to jump between those data. Gavin, You would add these helpers? Or would like me to add them? Thanks, Gavin cheers -- Richard Yang Help you, Help me ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v3 3/3] sched: BUG when stack end location is over written
On Fri, Sep 12, 2014 at 02:06:57PM +1000, Michael Ellerman wrote: On Thu, 2014-09-11 at 16:41 +0100, Aaron Tomlin wrote: diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index a285900..2a8280a 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -824,6 +824,18 @@ config SCHEDSTATS application, you can say N to avoid the very slight overhead this adds. +config SCHED_STACK_END_CHECK + bool Detect stack corruption on calls to schedule() + depends on DEBUG_KERNEL + default y Did you really mean default y? Doing so means it will be turned on more or less everywhere, which defeats the purpose of having a config option in the first place. Only if Kconfig CONFIG_DEBUG_KERNEL is enabled in the first place. -- Aaron Tomlin ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v3 3/3] sched: BUG when stack end location is over written
On Fri, Sep 12, 2014 at 04:04:51PM +1000, Michael Ellerman wrote: On Thu, 2014-09-11 at 16:41 +0100, Aaron Tomlin wrote: Currently in the event of a stack overrun a call to schedule() does not check for this type of corruption. This corruption is often silent and can go unnoticed. However once the corrupted region is examined at a later stage, the outcome is undefined and often results in a sporadic page fault which cannot be handled. This patch checks for a stack overrun and takes appropriate action since the damage is already done, there is no point in continuing. Signed-off-by: Aaron Tomlin atom...@redhat.com --- kernel/sched/core.c | 3 +++ lib/Kconfig.debug | 12 2 files changed, 15 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ec1a286..0b70b73 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2660,6 +2660,9 @@ static noinline void __schedule_bug(struct task_struct *prev) */ static inline void schedule_debug(struct task_struct *prev) { +#ifdef CONFIG_SCHED_STACK_END_CHECK + BUG_ON(unlikely(task_stack_end_corrupted(prev))) +#endif Spot the bug? Please compile your code in future. Oops! Sorry about that. -- Aaron Tomlin ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH V3] ASoC: fsl_ssi: refine ipg clock usage in this module
Check if ipg clock is in clock-names property, then we can move the ipg clock enable and disable operation to startup and shutdown, that is only enable ipg clock when ssi is working and keep clock is disabled when ssi is in idle. But when the checking is failed, remain the clock control as before. Signed-off-by: Shengjiu Wang shengjiu.w...@freescale.com --- V3 change log: update patch according Nicolin and markus's comments sound/soc/fsl/fsl_ssi.c | 53 --- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 2fc3e66..6d1dfd5 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -169,6 +169,7 @@ struct fsl_ssi_private { u8 i2s_mode; bool use_dma; bool use_dual_fifo; + bool has_ipg_clk_name; unsigned int fifo_depth; struct fsl_ssi_rxtx_reg_val rxtx_reg_val; @@ -530,6 +531,11 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream-private_data; struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(rtd-cpu_dai); + int ret; + + ret = clk_prepare_enable(ssi_private-clk); + if (ret) + return ret; /* When using dual fifo mode, it is safer to ensure an even period * size. If appearing to an odd number while DMA always starts its @@ -544,6 +550,21 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, } /** + * fsl_ssi_shutdown: shutdown the SSI + * + */ +static void fsl_ssi_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_pcm_runtime *rtd = substream-private_data; + struct fsl_ssi_private *ssi_private = + snd_soc_dai_get_drvdata(rtd-cpu_dai); + + clk_disable_unprepare(ssi_private-clk); + +} + +/** * fsl_ssi_set_bclk - configure Digital Audio Interface bit clock * * Note: This function can be only called when using SSI as DAI master @@ -1043,6 +1064,7 @@ static int fsl_ssi_dai_probe(struct snd_soc_dai *dai) static const struct snd_soc_dai_ops fsl_ssi_dai_ops = { .startup= fsl_ssi_startup, + .shutdown = fsl_ssi_shutdown, .hw_params = fsl_ssi_hw_params, .hw_free= fsl_ssi_hw_free, .set_fmt= fsl_ssi_set_dai_fmt, @@ -1168,17 +1190,22 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev, u32 dmas[4]; int ret; - ssi_private-clk = devm_clk_get(pdev-dev, NULL); + if (ssi_private-has_ipg_clk_name) + ssi_private-clk = devm_clk_get(pdev-dev, ipg); + else + ssi_private-clk = devm_clk_get(pdev-dev, NULL); if (IS_ERR(ssi_private-clk)) { ret = PTR_ERR(ssi_private-clk); dev_err(pdev-dev, could not get clock: %d\n, ret); return ret; } - ret = clk_prepare_enable(ssi_private-clk); - if (ret) { - dev_err(pdev-dev, clk_prepare_enable failed: %d\n, ret); - return ret; + if (!ssi_private-has_ipg_clk_name) { + ret = clk_prepare_enable(ssi_private-clk); + if (ret) { + dev_err(pdev-dev, clk_prepare_enable failed: %d\n, ret); + return ret; + } } /* For those SLAVE implementations, we ingore non-baudclk cases @@ -1236,8 +1263,9 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev, return 0; error_pcm: - clk_disable_unprepare(ssi_private-clk); + if (!ssi_private-has_ipg_clk_name) + clk_disable_unprepare(ssi_private-clk); return ret; } @@ -1246,7 +1274,8 @@ static void fsl_ssi_imx_clean(struct platform_device *pdev, { if (!ssi_private-use_dma) imx_pcm_fiq_exit(pdev); - clk_disable_unprepare(ssi_private-clk); + if (!ssi_private-has_ipg_clk_name) + clk_disable_unprepare(ssi_private-clk); } static int fsl_ssi_probe(struct platform_device *pdev) @@ -1321,8 +1350,16 @@ static int fsl_ssi_probe(struct platform_device *pdev) return -ENOMEM; } - ssi_private-regs = devm_regmap_init_mmio(pdev-dev, iomem, + ret = of_property_match_string(np, clock-names, ipg); + if (ret 0) { + ssi_private-has_ipg_clk_name = false; + ssi_private-regs = devm_regmap_init_mmio(pdev-dev, iomem, fsl_ssi_regconfig); + } else { + ssi_private-has_ipg_clk_name = true; + ssi_private-regs = devm_regmap_init_mmio_clk(pdev-dev, + ipg, iomem, fsl_ssi_regconfig); + } if (IS_ERR(ssi_private-regs)) { dev_err(pdev-dev, Failed to init register map\n); return
Re: [PATCH V2] ASoC: fsl_ssi: refine ipg clock usage in this module
On Fri, Sep 12, 2014 at 10:54:46AM +0200, Markus Pargmann wrote: On Fri, Sep 12, 2014 at 03:14:28PM +0800, Shengjiu Wang wrote: On Fri, Sep 12, 2014 at 08:17:06AM +0200, Markus Pargmann wrote: Hi, On Fri, Sep 12, 2014 at 10:01:12AM +0800, Shengjiu Wang wrote: On Thu, Sep 11, 2014 at 03:57:37PM -0700, Nicolin Chen wrote: On Thu, Sep 11, 2014 at 01:38:29PM +0800, Shengjiu Wang wrote: Move the ipg clock enable and disable operation to startup and shutdown, that is only enable ipg clock when ssi is working. Keep clock is disabled when ssi is in idle. otherwise, _fsl_ssi_set_dai_fmt function need to be called in probe, so add ipg clock control for it. It seems to be no objection so far against my last suggestion to use regmap's mmio_clk() for named ipg clk only. So you may still consider about that. I think mmio_clk() can be put to another patch. and this patch only for clk_enable() and clk_disable() operation. I would also prefer Nicolin's suggestion using regmap's mmio clk. I think it may be better to not add this particular patch at all and just go with the mmio_clk patch. It should be easy enough to just add the clock names to the devicetrees. That way we can avoid all those clock enable/disable function calls. I considered if use Nicolin's suggestion, I still need ot add those enable/disable function calls, because I want to remove the enable/disable function call in fsl_ssi_imx_probe, then I need to add enable/disable function call in _fsl_ssi_set_dai_fmt(), which is called in fsl_ssi_probe(). _fsl_ssi_set_dai_fmt() need to access the registers. I think Nicolin's suggestion was to check for a clock named ipg. If it exists, you can simply use devm_regmap_init_mmio_clk(). Otherwise you could fallback to the old behaviour and get the first clock and enable it without disabling it after the probe function. After that, you could add the clock-names property to the devicetrees and have the same result. Ok, I have sent V3 for review. please check. wang shengjiu Anyway, I'd like to do thing in parallel. So I just simply tested it on my side and its works fine, it may still need to be tested by others though. Nicolina Hi Markus could you please review it, and share your comments? I think the clock enabling for AC97 is missing in your patch. I add clock enable in fsl_ssi_startup(), I think it is enough for AC97, does it? No. We export ac97 read/write ops for the whole AC97 stuff. These may be used outside of the usual startup/shutdown which is done for substreams. It may work to have the ipg clock enabled in fsl_ssi_ac97_read/fsl_ssi_ac97_write. Best regards, Markus -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] cpuidle/powernv: Enter fastsleep on checking if deep idle states are allowed
Today the procfs interface /proc/sys/kernel/powersave-nap is used to control entry into deep idle states beyond snooze. Check for the value of this parameter before entering fastsleep. We already do this check for nap in power7_idle(). Signed-off-by: Preeti U Murthy pre...@linux.vnet.ibm.com --- drivers/cpuidle/cpuidle-powernv.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c index a64be57..b8ba52e 100644 --- a/drivers/cpuidle/cpuidle-powernv.c +++ b/drivers/cpuidle/cpuidle-powernv.c @@ -69,6 +69,12 @@ static int fastsleep_loop(struct cpuidle_device *dev, unsigned long old_lpcr = mfspr(SPRN_LPCR); unsigned long new_lpcr; + /* +* Verify if snooze is the only valid cpuidle state +*/ + if (!(powersave_nap 0)) + return index; + if (unlikely(system_state SYSTEM_RUNNING)) return index; ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v3 3/3] sched: BUG when stack end location is over written
On Fri, 2014-09-12 at 10:44 +0100, Aaron Tomlin wrote: On Fri, Sep 12, 2014 at 02:06:57PM +1000, Michael Ellerman wrote: On Thu, 2014-09-11 at 16:41 +0100, Aaron Tomlin wrote: diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index a285900..2a8280a 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -824,6 +824,18 @@ config SCHEDSTATS application, you can say N to avoid the very slight overhead this adds. +config SCHED_STACK_END_CHECK + bool Detect stack corruption on calls to schedule() + depends on DEBUG_KERNEL + default y Did you really mean default y? Doing so means it will be turned on more or less everywhere, which defeats the purpose of having a config option in the first place. Only if Kconfig CONFIG_DEBUG_KERNEL is enabled in the first place. Which is likely enabled just about everywhere on the planet. -Mike ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v4 3/3] sched: BUG when stack end location is over written
Currently in the event of a stack overrun a call to schedule() does not check for this type of corruption. This corruption is often silent and can go unnoticed. However once the corrupted region is examined at a later stage, the outcome is undefined and often results in a sporadic page fault which cannot be handled. This patch checks for a stack overrun and takes appropriate action since the damage is already done, there is no point in continuing. Signed-off-by: Aaron Tomlin atom...@redhat.com --- kernel/sched/core.c | 3 +++ lib/Kconfig.debug | 12 2 files changed, 15 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ec1a286..6ed1a24 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2660,6 +2660,9 @@ static noinline void __schedule_bug(struct task_struct *prev) */ static inline void schedule_debug(struct task_struct *prev) { +#ifdef CONFIG_SCHED_STACK_END_CHECK + BUG_ON(unlikely(task_stack_end_corrupted(prev))); +#endif /* * Test if we are atomic. Since do_exit() needs to call into * schedule() atomically, we ignore that path. Otherwise whine diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index a285900..e58163d 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -824,6 +824,18 @@ config SCHEDSTATS application, you can say N to avoid the very slight overhead this adds. +config SCHED_STACK_END_CHECK + bool Detect stack corruption on calls to schedule() + depends on DEBUG_KERNEL + default n + help + This option checks for a stack overrun on calls to schedule(). + If the stack end location is found to be over written always panic as + the content of the corrupted region can no longer be trusted. + This is to ensure no erroneous behaviour occurs which could result in + data corruption or a sporadic crash at a later stage once the region + is examined. The runtime overhead introduced is minimal. + config TIMER_STATS bool Collect kernel timers statistics depends on DEBUG_KERNEL PROC_FS -- 1.9.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v4 2/3] sched: Add helper for task stack page overrun checking
This facility is used in a few places so let's introduce a helper function to improve code readability. Signed-off-by: Aaron Tomlin atom...@redhat.com --- arch/powerpc/mm/fault.c| 4 +--- arch/x86/mm/fault.c| 4 +--- include/linux/sched.h | 2 ++ kernel/trace/trace_stack.c | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c index 35d0760c..99b2f27 100644 --- a/arch/powerpc/mm/fault.c +++ b/arch/powerpc/mm/fault.c @@ -507,7 +507,6 @@ bail: void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig) { const struct exception_table_entry *entry; - unsigned long *stackend; /* Are we prepared to handle this fault? */ if ((entry = search_exception_tables(regs-nip)) != NULL) { @@ -536,8 +535,7 @@ void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig) printk(KERN_ALERT Faulting instruction address: 0x%08lx\n, regs-nip); - stackend = end_of_stack(current); - if (*stackend != STACK_END_MAGIC) + if (task_stack_end_corrupted(current)) printk(KERN_ALERT Thread overran stack, or stack corrupted\n); die(Kernel access of bad area, regs, sig); diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index bc23a70..6240bc7 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -648,7 +648,6 @@ no_context(struct pt_regs *regs, unsigned long error_code, unsigned long address, int signal, int si_code) { struct task_struct *tsk = current; - unsigned long *stackend; unsigned long flags; int sig; @@ -708,8 +707,7 @@ no_context(struct pt_regs *regs, unsigned long error_code, show_fault_oops(regs, error_code, address); - stackend = end_of_stack(tsk); - if (*stackend != STACK_END_MAGIC) + if (task_stack_end_corrupted(tsk)) printk(KERN_EMERG Thread overran stack, or stack corrupted\n); tsk-thread.cr2 = address; diff --git a/include/linux/sched.h b/include/linux/sched.h index 7ef34b7..a80e35d 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2615,6 +2615,8 @@ static inline unsigned long *end_of_stack(struct task_struct *p) } #endif +#define task_stack_end_corrupted(task) \ + (*(end_of_stack(task)) != STACK_END_MAGIC) static inline int object_is_on_stack(void *obj) { diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c index 1636e41..16eddb3 100644 --- a/kernel/trace/trace_stack.c +++ b/kernel/trace/trace_stack.c @@ -170,7 +170,7 @@ check_stack(unsigned long ip, unsigned long *stack) i++; } - if (*end_of_stack(current) != STACK_END_MAGIC) { + if (task_stack_end_corrupted(current)) { print_max_stack(); BUG(); } -- 1.9.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v4 1/3] init/main.c: Give init_task a canary
Tasks get their end of stack set to STACK_END_MAGIC with the aim to catch stack overruns. Currently this feature does not apply to init_task. This patch removes this restriction. Note that a similar patch was posted by Prarit Bhargava [1] some time ago but was never merged. [1]: http://marc.info/?l=linux-kernelm=127144305403241w=2 Signed-off-by: Aaron Tomlin atom...@redhat.com Acked-by: Michael Ellerman m...@ellerman.id.au --- arch/powerpc/mm/fault.c| 3 +-- arch/x86/mm/fault.c| 3 +-- include/linux/sched.h | 2 ++ init/main.c| 1 + kernel/fork.c | 12 +--- kernel/trace/trace_stack.c | 4 +--- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c index 51ab9e7..35d0760c 100644 --- a/arch/powerpc/mm/fault.c +++ b/arch/powerpc/mm/fault.c @@ -30,7 +30,6 @@ #include linux/kprobes.h #include linux/kdebug.h #include linux/perf_event.h -#include linux/magic.h #include linux/ratelimit.h #include linux/context_tracking.h @@ -538,7 +537,7 @@ void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig) regs-nip); stackend = end_of_stack(current); - if (current != init_task *stackend != STACK_END_MAGIC) + if (*stackend != STACK_END_MAGIC) printk(KERN_ALERT Thread overran stack, or stack corrupted\n); die(Kernel access of bad area, regs, sig); diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index a241946..bc23a70 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -3,7 +3,6 @@ * Copyright (C) 2001, 2002 Andi Kleen, SuSE Labs. * Copyright (C) 2008-2009, Red Hat Inc., Ingo Molnar */ -#include linux/magic.h /* STACK_END_MAGIC */ #include linux/sched.h /* test_thread_flag(), ... */ #include linux/kdebug.h /* oops_begin/end, ... */ #include linux/module.h /* search_exception_table */ @@ -710,7 +709,7 @@ no_context(struct pt_regs *regs, unsigned long error_code, show_fault_oops(regs, error_code, address); stackend = end_of_stack(tsk); - if (tsk != init_task *stackend != STACK_END_MAGIC) + if (*stackend != STACK_END_MAGIC) printk(KERN_EMERG Thread overran stack, or stack corrupted\n); tsk-thread.cr2 = address; diff --git a/include/linux/sched.h b/include/linux/sched.h index 5c2c885..7ef34b7 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -57,6 +57,7 @@ struct sched_param { #include linux/llist.h #include linux/uidgid.h #include linux/gfp.h +#include linux/magic.h #include asm/processor.h @@ -2636,6 +2637,7 @@ static inline unsigned long stack_not_used(struct task_struct *p) return (unsigned long)n - (unsigned long)end_of_stack(p); } #endif +extern void set_task_stack_end_magic(struct task_struct *tsk); /* set thread flags in other task's structures * - see asm/thread_info.h for TIF_ flags available diff --git a/init/main.c b/init/main.c index bb1aed9..5fc3fc7 100644 --- a/init/main.c +++ b/init/main.c @@ -508,6 +508,7 @@ asmlinkage __visible void __init start_kernel(void) * lockdep hash: */ lockdep_init(); + set_task_stack_end_magic(init_task); smp_setup_processor_id(); debug_objects_early_init(); diff --git a/kernel/fork.c b/kernel/fork.c index 0cf9cdb..adf9583 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -294,11 +294,18 @@ int __weak arch_dup_task_struct(struct task_struct *dst, return 0; } +void set_task_stack_end_magic(struct task_struct *tsk) +{ + unsigned long *stackend; + + stackend = end_of_stack(tsk); + *stackend = STACK_END_MAGIC;/* for overflow detection */ +} + static struct task_struct *dup_task_struct(struct task_struct *orig) { struct task_struct *tsk; struct thread_info *ti; - unsigned long *stackend; int node = tsk_fork_get_node(orig); int err; @@ -328,8 +335,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) setup_thread_stack(tsk, orig); clear_user_return_notifier(tsk); clear_tsk_need_resched(tsk); - stackend = end_of_stack(tsk); - *stackend = STACK_END_MAGIC;/* for overflow detection */ + set_task_stack_end_magic(tsk); #ifdef CONFIG_CC_STACKPROTECTOR tsk-stack_canary = get_random_int(); diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c index 8a4e5cb..1636e41 100644 --- a/kernel/trace/trace_stack.c +++ b/kernel/trace/trace_stack.c @@ -13,7 +13,6 @@ #include linux/sysctl.h #include linux/init.h #include linux/fs.h -#include linux/magic.h #include asm/setup.h @@ -171,8 +170,7 @@ check_stack(unsigned long ip, unsigned long *stack) i++; } - if ((current != init_task - *(end_of_stack(current)) !=
[PATCH v4 0/3] sched: Always check the integrity of the canary
Hi Peter, Please let me know if this iteration is satisfactory. Thanks. Currently in the event of a stack overrun a call to schedule() does not check for this type of corruption. This corruption is often silent and can go unnoticed. However once the corrupted region is examined at a later stage, the outcome is undefined and often results in a sporadic page fault which cannot be handled. The first patch adds a canary to init_task's end of stack. While the second patch provides a helper to determine the integrity of the canary. The third checks for a stack overrun and takes appropriate action since the damage is already done, there is no point in continuing. Changes since v3: * Add Michael Ellerman's Acked-by to first patch (for powerpc) * Fix compiler error - Michael Ellerman * Set default Kconfig option to n - Michael Ellerman Changes since v2: * Use BUG_ON in schedule_debug() - Peter Zijlstra * Use a more explicit function name for setting the canary - Chuck Ebbert Changes since v1: * Rebased against v3.17-rc4 * Add a canary to init_task - Oleg Nesterov * Fix various code formatting issues - Peter Zijlstra * Introduce Kconfig option - Peter Zijlstra Aaron Tomlin (3): init/main.c: Give init_task a canary sched: Add helper for task stack page overrun checking sched: BUG when stack end location is over written arch/powerpc/mm/fault.c| 5 + arch/x86/mm/fault.c| 5 + include/linux/sched.h | 4 init/main.c| 1 + kernel/fork.c | 12 +--- kernel/sched/core.c| 3 +++ kernel/trace/trace_stack.c | 4 +--- lib/Kconfig.debug | 12 8 files changed, 32 insertions(+), 14 deletions(-) -- 1.9.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v2] deb-pkg: Add support for powerpc little endian
On 2014-09-07 04:42, Ben Hutchings wrote: On Fri, 2014-09-05 at 09:09 -0300, Thadeu Lima de Souza Cascardo wrote: On Fri, Sep 05, 2014 at 05:55:18PM +1000, Michael Neuling wrote: On Fri, 2014-09-05 at 09:13 +0200, Gabriel Paubert wrote: On Fri, Sep 05, 2014 at 03:28:47PM +1000, Michael Neuling wrote: The Debian powerpc little endian architecture is called ppc64le. This Huh? ppc64le or ppc64el? ppc64el. Commit message is wrong. Fixed below. Mikey What about ppc64? Also, I sent that already a month ago. Both linuxppc-dev and Michal Marek were on cc. http://marc.info/?l=linux-kernelm=140744360328562w=2 Anyone using powerpc (32-bit) will then need to add ppc64 as a foreign architecture before they can install a 64-bit custom kernel. This is fine in principle, except that ppc64 is not an official Debian port and its packages are not mirrored on the same servers. [...] So I think Michael's version, leaving big-endian kernels as powerpc by default, is preferable for now. I applied v2 of Michael's patch to kbuild.git#misc. Michal ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V3] ASoC: fsl_ssi: refine ipg clock usage in this module
On Fri, Sep 12, 2014 at 06:35:15PM +0800, Shengjiu Wang wrote: Check if ipg clock is in clock-names property, then we can move the ipg clock enable and disable operation to startup and shutdown, that is only enable ipg clock when ssi is working and keep clock is disabled when ssi is in idle. But when the checking is failed, remain the clock control as before. Signed-off-by: Shengjiu Wang shengjiu.w...@freescale.com The patch looks fine to me. I tested the has_ipg_clk_name == true case, and it works fine. As long as there's no further objection, I can give an Acked-by. (I think Timur and Markus may like to have a test as well.) Thank you Nicolin ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/2] pseries: Fix endian issues in cpu hot-removal
On 09/12/2014 03:53 AM, Michael Ellerman wrote: On Wed, 2014-09-10 at 17:41 -0500, Thomas Falcon wrote: When removing a cpu, this patch makes sure that values gotten from or passed to firmware are in the correct endian format. Signed-off-by: Thomas Falcon tlfal...@linux.vnet.ibm.com --- arch/powerpc/platforms/pseries/dlpar.c | 14 +++--- arch/powerpc/platforms/pseries/hotplug-cpu.c | 8 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c index cd425dc..c5ecfdb 100644 --- a/arch/powerpc/platforms/pseries/dlpar.c +++ b/arch/powerpc/platforms/pseries/dlpar.c @@ -442,7 +442,7 @@ static int dlpar_offline_cpu(struct device_node *dn) int rc = 0; unsigned int cpu; int len, nthreads, i; - const u32 *intserv; + const __be32 *intserv; intserv = of_get_property(dn, ibm,ppc-interrupt-server#s, len); if (!intserv) @@ -453,7 +453,7 @@ static int dlpar_offline_cpu(struct device_node *dn) cpu_maps_update_begin(); for (i = 0; i nthreads; i++) { Can you please do the conversion once here for each value of i. You can call the converted value thread ? for_each_present_cpu(cpu) { - if (get_hard_smp_processor_id(cpu) != intserv[i]) + if (get_hard_smp_processor_id(cpu) != be32_to_cpu(intserv[i])) continue; Rather than doing it for every cpu in the system for every value of i. Not that performance is really an issue, but it's just ugly. And obviously the other places that use it in the loop should use the converted value. @@ -494,7 +494,7 @@ out: static ssize_t dlpar_cpu_release(const char *buf, size_t count) { struct device_node *dn; - const u32 *drc_index; + const __be32 *drc_index; int rc; dn = of_find_node_by_path(buf); @@ -513,7 +513,7 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count) return -EINVAL; } Here again you should do the conversion once. Better still use of_property_read_u32(). - rc = dlpar_release_drc(*drc_index); + rc = dlpar_release_drc(be32_to_cpup(drc_index)); if (rc) { of_node_put(dn); return rc; @@ -521,7 +521,7 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count) rc = dlpar_detach_node(dn); if (rc) { - dlpar_acquire_drc(*drc_index); + dlpar_acquire_drc(be32_to_cpup(drc_index)); return rc; } cheers Thanks for the feedback. Sending patches with your suggested changes. tom ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 1/2] pseries: Fix endian issues in onlining cpu threads
The ibm,ppc-interrupt-server#s property is in big endian format. These values need to be converted when used by little endian architectures. Signed-off-by: Thomas Falcon tlfal...@linux.vnet.ibm.com --- Changes in v2: Followed suggestions from Michael Ellerman conversion of intserv values occur once --- arch/powerpc/platforms/pseries/dlpar.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c index c2806c8..9e9f30b2 100644 --- a/arch/powerpc/platforms/pseries/dlpar.c +++ b/arch/powerpc/platforms/pseries/dlpar.c @@ -363,7 +363,8 @@ static int dlpar_online_cpu(struct device_node *dn) int rc = 0; unsigned int cpu; int len, nthreads, i; - const u32 *intserv; + const __be32 *intserv; + u32 thread; intserv = of_get_property(dn, ibm,ppc-interrupt-server#s, len); if (!intserv) @@ -373,8 +374,9 @@ static int dlpar_online_cpu(struct device_node *dn) cpu_maps_update_begin(); for (i = 0; i nthreads; i++) { + thread = be32_to_cpu(intserv[i]); for_each_present_cpu(cpu) { - if (get_hard_smp_processor_id(cpu) != intserv[i]) + if (get_hard_smp_processor_id(cpu) != thread) continue; BUG_ON(get_cpu_current_state(cpu) != CPU_STATE_OFFLINE); @@ -388,7 +390,7 @@ static int dlpar_online_cpu(struct device_node *dn) } if (cpu == num_possible_cpus()) printk(KERN_WARNING Could not find cpu to online - with physical id 0x%x\n, intserv[i]); + with physical id 0x%x\n, thread); } cpu_maps_update_done(); -- 1.8.5.2 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 2/2] pseries: Fix endian issues in cpu hot-removal
When removing a cpu, this patch makes sure that values gotten from or passed to firmware are in the correct endian format. Signed-off-by: Thomas Falcon tlfal...@linux.vnet.ibm.com --- Changes in v2: Followed suggestions from Michael Ellerman: Conversion of intserv to cpu endian occurs once. Conversion of drc_index to cpu endian occurs once using of_property_read_u32. --- arch/powerpc/platforms/pseries/dlpar.c | 20 +++- arch/powerpc/platforms/pseries/hotplug-cpu.c | 10 ++ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c index 9e9f30b2..343dfdf 100644 --- a/arch/powerpc/platforms/pseries/dlpar.c +++ b/arch/powerpc/platforms/pseries/dlpar.c @@ -444,7 +444,8 @@ static int dlpar_offline_cpu(struct device_node *dn) int rc = 0; unsigned int cpu; int len, nthreads, i; - const u32 *intserv; + const __be32 *intserv; + u32 thread; intserv = of_get_property(dn, ibm,ppc-interrupt-server#s, len); if (!intserv) @@ -454,8 +455,9 @@ static int dlpar_offline_cpu(struct device_node *dn) cpu_maps_update_begin(); for (i = 0; i nthreads; i++) { + thread = be32_to_cpu(intserv[i]); for_each_present_cpu(cpu) { - if (get_hard_smp_processor_id(cpu) != intserv[i]) + if (get_hard_smp_processor_id(cpu) != thread) continue; if (get_cpu_current_state(cpu) == CPU_STATE_OFFLINE) @@ -477,14 +479,14 @@ static int dlpar_offline_cpu(struct device_node *dn) * Upgrade it's state to CPU_STATE_OFFLINE. */ set_preferred_offline_state(cpu, CPU_STATE_OFFLINE); - BUG_ON(plpar_hcall_norets(H_PROD, intserv[i]) + BUG_ON(plpar_hcall_norets(H_PROD, thread) != H_SUCCESS); __cpu_die(cpu); break; } if (cpu == num_possible_cpus()) printk(KERN_WARNING Could not find cpu to offline - with physical id 0x%x\n, intserv[i]); + with physical id 0x%x\n, thread); } cpu_maps_update_done(); @@ -496,15 +498,15 @@ out: static ssize_t dlpar_cpu_release(const char *buf, size_t count) { struct device_node *dn; - const u32 *drc_index; + const u32 drc_index; int rc; dn = of_find_node_by_path(buf); if (!dn) return -EINVAL; - drc_index = of_get_property(dn, ibm,my-drc-index, NULL); - if (!drc_index) { + rc = of_property_read_u32(dn, ibm,my-drc-index, drc_index); + if (rc) { of_node_put(dn); return -EINVAL; } @@ -515,7 +517,7 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count) return -EINVAL; } - rc = dlpar_release_drc(*drc_index); + rc = dlpar_release_drc(drc_index); if (rc) { of_node_put(dn); return rc; @@ -523,7 +525,7 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count) rc = dlpar_detach_node(dn); if (rc) { - dlpar_acquire_drc(*drc_index); + dlpar_acquire_drc(drc_index); return rc; } diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c index 447f8c6..5c375f9 100644 --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c @@ -90,7 +90,7 @@ static void rtas_stop_self(void) { static struct rtas_args args = { .nargs = 0, - .nret = 1, + .nret = cpu_to_be32(1), .rets = args.args[0], }; @@ -312,7 +312,8 @@ static void pseries_remove_processor(struct device_node *np) { unsigned int cpu; int len, nthreads, i; - const u32 *intserv; + const __be32 *intserv; + u32 thread; intserv = of_get_property(np, ibm,ppc-interrupt-server#s, len); if (!intserv) @@ -322,8 +323,9 @@ static void pseries_remove_processor(struct device_node *np) cpu_maps_update_begin(); for (i = 0; i nthreads; i++) { + thread = be32_to_cpu(intserv[i]); for_each_present_cpu(cpu) { - if (get_hard_smp_processor_id(cpu) != intserv[i]) + if (get_hard_smp_processor_id(cpu) != thread) continue; BUG_ON(cpu_online(cpu)); set_cpu_present(cpu, false); @@ -332,7 +334,7 @@ static void pseries_remove_processor(struct device_node *np)
powerpc: Avoid bashisms in prom_init_check.sh
From 300a98f895dc7e2167cf379408322a9607907761 Mon Sep 17 00:00:00 2001 From: malc av1474 at comtv.ru Date: Mon, 4 Aug 2014 23:28:05 +0400 Subject: [PATCH] powerpc: Avoid bashisms in prom_init_check.sh Signed-off-by: Vassili Karpov av1...@comtv.ru --- arch/powerpc/kernel/prom_init_check.sh | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/kernel/prom_init_check.sh b/arch/powerpc/kernel/prom_init_check.sh index fe8e54b..413f792 100644 --- a/arch/powerpc/kernel/prom_init_check.sh +++ b/arch/powerpc/kernel/prom_init_check.sh @@ -50,22 +50,22 @@ do done # ignore register save/restore funcitons - if [ ${UNDEF:0:9} = _restgpr_ ]; then + if [ $(printf %.9s $UNDEF) = _restgpr_ ]; then OK=1 fi - if [ ${UNDEF:0:10} = _restgpr0_ ]; then + if [ $(printf %.10s $UNDEF) = _restgpr0_ ]; then OK=1 fi - if [ ${UNDEF:0:11} = _rest32gpr_ ]; then + if [ $(printf %.11s $UNDEF) = _rest32gpr_ ]; then OK=1 fi - if [ ${UNDEF:0:9} = _savegpr_ ]; then + if [ $(printf %.9s $UNDEF) = _savegpr_ ]; then OK=1 fi - if [ ${UNDEF:0:10} = _savegpr0_ ]; then + if [ $(printf %.10s $UNDEF) = _savegpr0_ ]; then OK=1 fi - if [ ${UNDEF:0:11} = _save32gpr_ ]; then + if [ $(printf %.11s $UNDEF) = _save32gpr_ ]; then OK=1 fi -- 2.0.0.GIT On Mon, 2014-08-04 at 23:36 +0400, av1...@comtv.ru wrote: From 300a98f895dc7e2167cf379408322a9607907761 Mon Sep 17 00:00:00 2001 From: malc av1...@comtv.ru Date: Mon, 4 Aug 2014 23:28:05 +0400 Subject: [PATCH] Avoid bashisms Hi malc, If you want us to take your patch, please resend with: - a better subject, eg: powerpc: Avoid bashisms in prom_init_check.sh - a Signed-off-by line. cheers Thanks for suggestions, -- mailto:av1...@comtv.ru ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [alsa-devel] [PATCH V3] ASoC: fsl_ssi: refine ipg clock usage in this module
Hi Il 12/set/2014 14:18 Shengjiu Wang shengjiu.w...@freescale.com ha scritto: Check if ipg clock is in clock-names property, then we can move the ipg clock enable and disable operation to startup and shutdown, that is only enable ipg clock when ssi is working and keep clock is disabled when ssi is in idle. But when the checking is failed, remain the clock control as before. Signed-off-by: Shengjiu Wang shengjiu.w...@freescale.com --- V3 change log: update patch according Nicolin and markus's comments sound/soc/fsl/fsl_ssi.c | 53 --- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 2fc3e66..6d1dfd5 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -169,6 +169,7 @@ struct fsl_ssi_private { u8 i2s_mode; bool use_dma; bool use_dual_fifo; + bool has_ipg_clk_name; unsigned int fifo_depth; struct fsl_ssi_rxtx_reg_val rxtx_reg_val; @@ -530,6 +531,11 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream-private_data; struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(rtd-cpu_dai); + int ret; + + ret = clk_prepare_enable(ssi_private-clk); + if (ret) + return ret; /* When using dual fifo mode, it is safer to ensure an even period * size. If appearing to an odd number while DMA always starts its @@ -544,6 +550,21 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, } /** + * fsl_ssi_shutdown: shutdown the SSI + * + */ +static void fsl_ssi_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_pcm_runtime *rtd = substream-private_data; + struct fsl_ssi_private *ssi_private = + snd_soc_dai_get_drvdata(rtd-cpu_dai); + + clk_disable_unprepare(ssi_private-clk); + +} + +/** * fsl_ssi_set_bclk - configure Digital Audio Interface bit clock * * Note: This function can be only called when using SSI as DAI master @@ -1043,6 +1064,7 @@ static int fsl_ssi_dai_probe(struct snd_soc_dai *dai) static const struct snd_soc_dai_ops fsl_ssi_dai_ops = { .startup= fsl_ssi_startup, + .shutdown = fsl_ssi_shutdown, .hw_params = fsl_ssi_hw_params, .hw_free= fsl_ssi_hw_free, .set_fmt= fsl_ssi_set_dai_fmt, @@ -1168,17 +1190,22 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev, u32 dmas[4]; int ret; - ssi_private-clk = devm_clk_get(pdev-dev, NULL); + if (ssi_private-has_ipg_clk_name) + ssi_private-clk = devm_clk_get(pdev-dev, ipg); + else + ssi_private-clk = devm_clk_get(pdev-dev, NULL); if (IS_ERR(ssi_private-clk)) { ret = PTR_ERR(ssi_private-clk); dev_err(pdev-dev, could not get clock: %d\n, ret); return ret; } - ret = clk_prepare_enable(ssi_private-clk); - if (ret) { - dev_err(pdev-dev, clk_prepare_enable failed: %d\n, ret); - return ret; + if (!ssi_private-has_ipg_clk_name) { + ret = clk_prepare_enable(ssi_private-clk); + if (ret) { + dev_err(pdev-dev, clk_prepare_enable failed: %d\n, ret); + return ret; + } } /* For those SLAVE implementations, we ingore non-baudclk cases @@ -1236,8 +1263,9 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev, return 0; error_pcm: - clk_disable_unprepare(ssi_private-clk); + if (!ssi_private-has_ipg_clk_name) + clk_disable_unprepare(ssi_private-clk); return ret; } @@ -1246,7 +1274,8 @@ static void fsl_ssi_imx_clean(struct platform_device *pdev, { if (!ssi_private-use_dma) imx_pcm_fiq_exit(pdev); - clk_disable_unprepare(ssi_private-clk); + if (!ssi_private-has_ipg_clk_name) + clk_disable_unprepare(ssi_private-clk); } static int fsl_ssi_probe(struct platform_device *pdev) @@ -1321,8 +1350,16 @@ static int fsl_ssi_probe(struct platform_device *pdev) return -ENOMEM; } - ssi_private-regs = devm_regmap_init_mmio(pdev-dev, iomem, + ret = of_property_match_string(np, clock-names, ipg); + if (ret 0) { + ssi_private-has_ipg_clk_name = false; It's false already. Michael + ssi_private-regs = devm_regmap_init_mmio(pdev-dev, iomem, fsl_ssi_regconfig); + } else { + ssi_private-has_ipg_clk_name = true; + ssi_private-regs = devm_regmap_init_mmio_clk(pdev-dev, +