RE: [v3 04/26] iommu, x86: Implement irq_set_vcpu_affinity for intel_ir_chip

2015-01-28 Thread Wu, Feng


> -Original Message-
> From: David Woodhouse [mailto:dw...@infradead.org]
> Sent: Wednesday, January 28, 2015 11:27 PM
> To: Wu, Feng
> Cc: t...@linutronix.de; mi...@redhat.com; h...@zytor.com; x...@kernel.org;
> g...@kernel.org; pbonz...@redhat.com; j...@8bytes.org;
> alex.william...@redhat.com; jiang@linux.intel.com; eric.au...@linaro.org;
> linux-kernel@vger.kernel.org; io...@lists.linux-foundation.org;
> k...@vger.kernel.org
> Subject: Re: [v3 04/26] iommu, x86: Implement irq_set_vcpu_affinity for
> intel_ir_chip
> 
> On Fri, 2014-12-12 at 23:14 +0800, Feng Wu wrote:
> > Implement irq_set_vcpu_affinity for intel_ir_chip.
> >
> > Signed-off-by: Feng Wu 
> > Reviewed-by: Jiang Liu 
> 
> Acked-by: David.Woodhouse  assuming a
> suitable answer to...
> 
> > +   vcpu_pi_info = (struct vcpu_data *)vcpu_info;
> > +   memcpy(irte_pi, _data->irte_entry, sizeof(struct irte));
> > +
> > +   irte_pi->urg = 0;
> > +   irte_pi->vector = vcpu_pi_info->vector;
> > +   irte_pi->pda_l = (vcpu_pi_info->pi_desc_addr >>
> > +(32 - PDA_LOW_BIT)) & ~(-1UL << PDA_LOW_BIT);
> > +   irte_pi->pda_h = (vcpu_pi_info->pi_desc_addr >> 32) &
> > +~(-1UL << PDA_HIGH_BIT);
> > +
> > +   irte_pi->__reserved_1 = 0;
> > +   irte_pi->__reserved_2 = 0;
> > +   irte_pi->__reserved_3 = 0;
> > +   irte_pi->__reserved_4 = 0;
> 
>  do we need a barrier here before we set this bit?

Thanks a lot for your Ack, David!

I cannot find a reason why we need a barrier here, since 'irte_pi' is only a 
local
variant here, the real operation to program hardware occurs in modify_irte(), in
which spin lock is acquired, this means the there is an implicit barrier there.

Thanks,
Feng

> 
> > +   irte_pi->pst = 1;
> > +
> > +   modify_irte(_data->irq_2_iommu, (struct irte *)irte_pi);
> 
> 
> --
> dwmw2
N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�:+v���zZ+��+zf���h���~i���z��w���?�&�)ߢf��^jǫy�m��@A�a���
0��h���i

Re: [PATCH v4 1/2] dts: Documentation: Add documentation for Exynos7 SoC thermal bindings

2015-01-28 Thread Lukasz Majewski
Hi Abhilash,

> Add documentation for exynos7 thermal bindings including compatible
> name and special clock properties.
> 
> Signed-off-by: Abhilash Kesavan 
> ---
>  .../devicetree/bindings/thermal/exynos-thermal.txt |4 
>  1 file changed, 4 insertions(+)
> 
> diff --git
> a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
> b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt index
> 0f44932..695150a 100644 ---
> a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt +++
> b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt @@
> -12,6 +12,7 @@ "samsung,exynos5420-tmu-ext-triminfo" for TMU channels
> 2, 3 and 4 Exynos5420 (Must pass triminfo base and triminfo clock)
> "samsung,exynos5440-tmu"
> +"samsung,exynos7-tmu"
>  - interrupt-parent : The phandle for the interrupt controller
>  - reg : Address range of the thermal registers. For soc's which has
> multiple instances of TMU and some registers are shared across all
> TMU's like @@ -32,10 +33,13 @@
>  - clocks : The main clocks for TMU device
>   -- 1. operational clock for TMU channel
>   -- 2. optional clock to access the shared registers of TMU
> channel
> + -- 3. optional special clock for functional operation
>  - clock-names : Thermal system clock name
>   -- "tmu_apbif" operational clock for current TMU channel
>   -- "tmu_triminfo_apbif" clock to access the shared triminfo
> register for current TMU channel
> + -- "tmu_sclk" clock for functional operation of the current
> TMU
> + channel
>  - vtmu-supply: This entry is optional and provides the regulator
> node supplying voltage to TMU. If needed this entry can be placed
> inside board/platform specific dts file.

Acked-by: Lukasz Majewski 

-- 
Best regards,

Lukasz Majewski

Samsung R Institute Poland (SRPOL) | Linux Platform Group
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 2/3] perf: Add a bit of paranoia

2015-01-28 Thread Jiri Olsa
On Wed, Jan 28, 2015 at 09:16:49PM -0500, Vince Weaver wrote:
> On Tue, 27 Jan 2015, Vince Weaver wrote:
> 
> > On Mon, 26 Jan 2015, Peter Zijlstra wrote:
> > 
> > > I think the below should cure this; if we install a group leader it will
> > > iterate the (still intact) group list and find its siblings and try and
> > > install those too -- even though those still have the old event->ctx --
> > > in the new ctx.
> > 
> > I've been fuzzing 24 hours (despite the blizzard) with this patch
> > plus the original series on top of 3.19-rc6 on the Haswell machine and it 
> > is looking good.
> 
> OK it took about 48 hours but I managed to generate this:
> 
> [162118.235829] [ cut here ]
> [162118.241388] WARNING: CPU: 5 PID: 13571 at kernel/events/core.c:1644 
> perf_remove_from_context+0xf5/0x120()
> [162118.252183] Modules linked in: fuse x86_pkg_temp_thermal intel_powerclamp 
> intel_rapl iosf_mbi coretemp kvm crct10dif_pclmul snd_hda_codec_realtek 
> snd_hda_codec_hdmi snd_hda_codec_generic crc32_pclmul snd_hda_intel 
> ghash_clmulni_intel snd_hda_controller aesni_intel snd_hda_codec aes_x86_64 
> snd_hwdep lrw gf128mul snd_pcm ppdev glue_helper xhci_pci mei_me iTCO_wdt 
> iTCO_vendor_support i915 snd_timer drm_kms_helper snd drm ablk_helper lpc_ich 
> mfd_core evdev pcspkr parport_pc psmouse cryptd soundcore i2c_i801 serio_raw 
> parport xhci_hcd mei wmi tpm_tis tpm video battery button processor 
> i2c_algo_bit sg sr_mod sd_mod cdrom ahci libahci e1000e ehci_pci libata ptp 
> ehci_hcd crc32c_intel usbcore scsi_mod usb_common pps_core thermal fan 
> thermal_sys
> [162118.325574] CPU: 5 PID: 13571 Comm: perf_fuzzer Tainted: GW  
> 3.19.0-rc6+ #126
> [162118.334984] Hardware name: LENOVO 10AM000AUS/SHARKBAY, BIOS FBKT72AUS 
> 01/26/2014
> [162118.343581]  81a3f194 8800c8463b48 816b6761 
> 
> [162118.352277]   8800c8463b88 8106dcda 
> 8800c9286c40
> [162118.360962]  8800c8c01800 8800c8c3a090 8800c8c3a090 
> 8800c71b4800
> [162118.369669] Call Trace:
> [162118.372984]  [] dump_stack+0x45/0x57
> [162118.379170]  [] warn_slowpath_common+0x8a/0xc0
> [162118.386267]  [] warn_slowpath_null+0x1a/0x20
> [162118.393160]  [] perf_remove_from_context+0xf5/0x120
> [162118.400706]  [] put_event+0x115/0x170
> [162118.407004]  [] ? put_event+0x51/0x170
> [162118.413340]  [] ? mutex_unlock+0xe/0x10
> [162118.419792]  [] perf_release+0x15/0x20
> [162118.426144]  [] __fput+0xdf/0x1f0
> [162118.432009]  [] fput+0xe/0x10
> [162118.437895]  [] task_work_run+0xa7/0xe0
> [162118.444377]  [] do_exit+0x319/0xac0
> [162118.450443]  [] ? get_signal+0xe9/0x770
> [162118.456906]  [] ? get_signal+0x359/0x770
> [162118.463427]  [] do_group_exit+0x54/0xe0
> [162118.469887]  [] get_signal+0x296/0x770
> [162118.476237]  [] ? __do_page_fault+0x1f2/0x580
> [162118.483251]  [] do_signal+0x28/0xbb0
> [162118.489392]  [] ? do_page_fault+0x22/0x30
> [162118.496055]  [] do_notify_resume+0x70/0x90
> [162118.502811]  [] retint_signal+0x48/0x86
> [162118.509272] ---[ end trace 55752a03ec8ab978 ]---
> 


hum, I dont see a way how the event->ctx could be changed once the task is
already in exit, but should we access the event->ctx after the refcnt check?

jirka


---
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 66c1da1ddc2c..0507e3dd6955 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3572,7 +3572,7 @@ static void perf_remove_from_owner(struct perf_event 
*event)
  */
 static void put_event(struct perf_event *event)
 {
-   struct perf_event_context *ctx = event->ctx;
+   struct perf_event_context *ctx;
 
if (!atomic_long_dec_and_test(>refcount))
return;
@@ -3580,6 +3580,7 @@ static void put_event(struct perf_event *event)
if (!is_kernel_event(event))
perf_remove_from_owner(event);
 
+   ctx = event->ctx;
WARN_ON_ONCE(ctx->parent_ctx);
/*
 * There are two ways this annotation is useful:
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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/4] New Lenovos 2015 touchpads: party time!

2015-01-28 Thread Hans de Goede

Hi Benjamin & et al,

On 28-01-15 21:10, Benjamin Tissoires wrote:

Hi Dmitry,

Lenovo released their new models, and believe it or not, some kernel
work is required to support them!

We learned the lesson and we will try to maximize the effort in user space
through udev rules instead of polluting the kernel with exceptions.

Patches 1 & 2 are general fixes for synaptics that have been unnoticed
until this new models. They are marked as stable.

Patch 3 is a generic way to fix the PnpId list that was hardcoded in the
kernel. This one is also marked as stable so that distributions will not
have the top software buttons on devices that do not require it.

Patch 4 is a nice to have. It is not mandatory, so not CC-ed to stable,
it just reduced the PnpId list.

The good thing is that the reported min/max are correct, so the problems
with the first generation of the t440 touchpad have been fixed now (and
synaptics assured us that they will keep checking the quality of the PS/2
handling of their touchpads).

One last thing, I still did not manage to talk to the device over SMBus,
so we are still stuck with the PS/2 protocol and its limitations for this
series.


Series looks good to me and is:

Acked-by: Hans de Goede 

Regards,

Hans
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] Input: sun4i-ts: add thermal driver dependency

2015-01-28 Thread Hans de Goede

Hi,

On 28-01-15 16:17, Arnd Bergmann wrote:

The sun4i-ts driver has had a dependency on the thermal code
since it was first merged,


The "since it was first merged bit" is not true, this is caused
by recent changes by ChenYu.

Other then that no objections from me against the proposed fix.

Regards,

Hans


 but this is not currently enforced

in Kconfig, so in some randconfig builds we get

drivers/built-in.o: In function `sun4i_ts_remove':
:(.text+0x2376f4): undefined reference to `thermal_zone_of_sensor_unregister'
drivers/built-in.o: In function `sun4i_ts_probe':
:(.text+0x237a94): undefined reference to `thermal_zone_of_sensor_register'
:(.text+0x237c00): undefined reference to `thermal_zone_of_sensor_unregister'

We need the dependency on THERMAL in order to ensure that this
driver becomes a loadable module if the thermal support itself
is modular, while the dependency on THERMAL_OF is a runtime dependency
and the driver will still build but not work if it is missing.

Signed-off-by: Arnd Bergmann 
Fixes: 6decea7c5438e2 ("Input: add driver for Allwinner sunxi SoC's rtp 
controller")

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 58917525126e..e2447f0063b7 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -943,6 +943,8 @@ config TOUCHSCREEN_SUN4I
tristate "Allwinner sun4i resistive touchscreen controller support"
depends on ARCH_SUNXI || COMPILE_TEST
depends on HWMON
+   depends on THERMAL
+   depends on THERMAL_OF || COMPILE_TEST
help
  This selects support for the resistive touchscreen controller
  found on Allwinner sunxi SoCs.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 3/3] mm: cma: release trigger

2015-01-28 Thread Joonsoo Kim
On Tue, Jan 27, 2015 at 09:22:57PM -0500, Sasha Levin wrote:
> Provides a userspace interface to trigger a CMA release.
> 
> Usage:
> 
>   echo [pages] > free
> 
> This would provide testing/fuzzing access to the CMA release paths.
> 
> Signed-off-by: Sasha Levin 
> ---
>  mm/cma_debug.c |   56 
> 
>  1 file changed, 56 insertions(+)
> 
> diff --git a/mm/cma_debug.c b/mm/cma_debug.c
> index 5bd6863..c29f029 100644
> --- a/mm/cma_debug.c
> +++ b/mm/cma_debug.c
> @@ -39,6 +39,59 @@ static void cma_add_to_cma_mem_list(struct cma *cma, 
> struct cma_mem *mem)
>   spin_unlock(>mem_head_lock);
>  }
>  
> +static struct cma_mem *cma_get_entry_from_list(struct cma *cma)
> +{
> + struct cma_mem *mem = NULL;
> +
> + spin_lock(>mem_head_lock);
> + if (!hlist_empty(>mem_head)) {
> + mem = hlist_entry(cma->mem_head.first, struct cma_mem, node);
> + hlist_del_init(>node);
> + }
> + spin_unlock(>mem_head_lock);
> +
> + return mem;
> +}
> +
> +static int cma_free_mem(struct cma *cma, int count)
> +{
> + struct cma_mem *mem = NULL;
> +
> + while (count) {
> + mem = cma_get_entry_from_list(cma);
> + if (mem == NULL)
> + return 0;
> +
> + if (mem->n <= count) {
> + cma_release(cma, mem->p, mem->n);
> + count -= mem->n;
> + kfree(mem);
> + } else if (cma->order_per_bit == 0) {
> + cma_release(cma, mem->p, count);
> + mem->p += count;
> + mem->n -= count;
> + count = 0;
> + cma_add_to_cma_mem_list(cma, mem);
> + } else {
> + cma_add_to_cma_mem_list(cma, mem);
> + break;
> + }
> + }

Hmm... I'm not sure we need to deal with "mem->m < count" case.
It is not suitable for any cma_alloc/release usecase.
And, I'd like to insert some error log to last case rather than
silently ignoring the request.

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


Re: [PATCH v4 1/2] dts: Documentation: Add documentation for Exynos7 SoC thermal bindings

2015-01-28 Thread Lukasz Majewski
Hi Eduardo,

> On Wed, Jan 28, 2015 at 04:21:49PM +0530, Abhilash Kesavan wrote:
> > Hi Eduardo,
> > 
> > On Tue, Jan 27, 2015 at 11:18 AM, Abhilash Kesavan
> >  wrote:
> > > Add documentation for exynos7 thermal bindings including
> > > compatible name and special clock properties.
> > >
> > > Signed-off-by: Abhilash Kesavan 
> > > ---
> > >  .../devicetree/bindings/thermal/exynos-thermal.txt |4 
> > >  1 file changed, 4 insertions(+)
> > >
> > > diff --git
> > > a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
> > > b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
> > > index 0f44932..695150a 100644 ---
> > > a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
> > > +++
> > > b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt @@
> > > -12,6 +12,7 @@ "samsung,exynos5420-tmu-ext-triminfo" for TMU
> > > channels 2, 3 and 4 Exynos5420 (Must pass triminfo base and
> > > triminfo clock) "samsung,exynos5440-tmu"
> > > +  "samsung,exynos7-tmu"
> > >  - interrupt-parent : The phandle for the interrupt controller
> > >  - reg : Address range of the thermal registers. For soc's which
> > > has multiple instances of TMU and some registers are shared
> > > across all TMU's like @@ -32,10 +33,13 @@
> > >  - clocks : The main clocks for TMU device
> > > -- 1. operational clock for TMU channel
> > > -- 2. optional clock to access the shared registers of
> > > TMU channel
> > > +   -- 3. optional special clock for functional operation
> > >  - clock-names : Thermal system clock name
> > > -- "tmu_apbif" operational clock for current TMU channel
> > > -- "tmu_triminfo_apbif" clock to access the shared
> > > triminfo register for current TMU channel
> > > +   -- "tmu_sclk" clock for functional operation of the
> > > current TMU
> > > +   channel
> > >  - vtmu-supply: This entry is optional and provides the regulator
> > > node supplying voltage to TMU. If needed this entry can be placed
> > > inside board/platform specific dts file.
> > 
> > Can you kindly consider applying these two patches to your next tree
> > if they look OK ?
> 
> Abhilash, can you please get at least one Reviewed-by from one of the
> active developers of exynos thermal driver?

I will review your patches. :-)

> 
> 
> > 
> > Regards,
> > Abhilash
> > > --
> > > 1.7.9.5
> > >



-- 
Best regards,

Lukasz Majewski

Samsung R Institute Poland (SRPOL) | Linux Platform Group
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] x86: Add Isolated Memory Regions for Quark X1000

2015-01-28 Thread Ingo Molnar

* Bryan O'Donoghue  wrote:

> Intel's Quark X1000 SoC contains a set of registers called 
> Isolated Memory Regions. IMRs are accessed over the IOSF 
> mailbox interface. IMRs are areas carved out of memory that 
> define read/write access rights to the various system agents 
> within the Quark system. For a given agent in the system it is 
> possible to specify if that agent may read or write an area of 
> memory defined by an IMR with a granularity of 1 KiB.

A couple of minor details:

> + if (ret)
> + goto done;
> +
> + /* Lock bit must be set separately to addr_lo address bits. */
> + if (lock) {
> + imr->addr_lo |= IMR_LOCK;
> + ret = iosf_mbi_write(QRK_MBI_UNIT_MM, QRK_MBI_MM_WRITE,
> + reg - IMR_NUM_REGS, imr->addr_lo);
> + if (ret)
> + goto done;
> + }
> +
> + local_irq_restore(flags);
> + return 0;
> +done:
> + /*
> +  * If writing to the IOSF failed then we're in an unknown state,
> +  * likely a very bad state. An IMR in an invalid state will almost
> +  * certainly lead to a memory access violation.
> +  */
> + local_irq_restore(flags);
> + WARN(ret, "IOSF-MBI write fail range 0x%08x-0x%08x unreliable\n",
> +  imr_to_phys(imr->addr_lo), imr_to_phys(imr->addr_hi) + IMR_MASK);
> +
> + return ret;
> +}

looks like the 'done' label really wants to be 'error' or 
'failed'?

Also, if this message ever triggers in practice, if the IMR is in 
a likely bad state, we might as well attempt to turn it off, so 
that we have a chance to get the log out and all that?

> +
> +/**
> + * imr_dbgfs_state_show - print state of IMR registers.
> + *
> + * @s:   pointer to seq_file for output.
> + * @unused:  unused parameter.
> + * @return:  0 on success or error code passed from mbi_iosf on failure.
> + */
> +static int imr_dbgfs_state_show(struct seq_file *s, void *unused)
> +{
> + phys_addr_t base;
> + phys_addr_t end;
> + int i;
> + struct imr_device *idev = s->private;
> + struct imr_regs imr;
> + size_t size;
> + int ret = -ENODEV;
> +
> + mutex_lock(>lock);
> +
> + for (i = 0; i < idev->max_imr; i++) {
>
> +int imr_add_range(phys_addr_t base, size_t size,
> +   unsigned int rmask, unsigned int wmask, bool lock)
> +{
> + phys_addr_t end;
> + unsigned int i;
> + struct imr_device *idev = _dev;
> + struct imr_regs imr;
> + int reg;
> + int ret;
> +
> + if (idev->init == false)
> + return -ENODEV;

You might want to add a WARN_ONCE() here? Someone tried to add an 
IMR but has done it too early. Return values get ignored so 
often, kernel messages not so much.

(Just like imr_check_range() does emit warnings.)

> + ret = imr_check_range(base, size);
> + if (ret)
> + return ret;
> +
> + if (size == 0)
> + return -EINVAL;

Looks like the zero-size check could be added to 
imr_check_range(), and be renamed to imr_check_params() or so?

> + /* Tweak the size value. */
> + size = imr_fixup_size(size);

So why not add a 'raw_size' (or so) variable and use that, to not 
confuse user provided size with the offset-corrected size?

Then imr_fixup_size() could be renamed to imr_raw_size() as well, 
making it slightly easier on the eyes as well.

> + end = base + size;
> +
> + /*
> +  * Check for reserved IMR value common to firmware, kernel and grub
> +  * indicating a disabled IMR.
> +  */
> + imr.addr_lo = phys_to_imr(base);
> + imr.addr_hi = phys_to_imr(end);
> + imr.rmask = rmask;
> + imr.wmask = wmask;
> + if (!imr_is_enabled())
> + return -EINVAL;
> +
> + mutex_lock(>lock);
> +
> + /*
> +  * Find a free IMR while checking for an existing overlapping range.
> +  * Note there's no restriction in silicon to prevent IMR overlaps.
> +  * For the sake of simplicity and ease in defining/debugging an IMR
> +  * memory map we exclude IMR overlaps.
> +  */
> + reg = -1;
> + for (i = 0; i < idev->max_imr; i++) {
> + ret = imr_read(idev, i, );
> + if (ret)
> + goto done;
> +
> + /* Find overlap @ base or end of requested range. */
> + if (imr_is_enabled()) {
> + if (imr_address_overlap(base, )) {
> + ret = -EINVAL;
> + goto done;
> + }
> + if (imr_address_overlap(end, )) {
> + ret = -EINVAL;
> + goto done;
> + }
> + } else {
> + reg = i;
> + }
> + }
> +
> + /* Error out if we have no free IMR entries. */
> + if (reg == -1) {
> + ret = -ENODEV;
> + goto done;
> + }
> +
> + pr_debug("IMR %d phys 

Re: [RFC 1/3] Slab infrastructure for array operations

2015-01-28 Thread Joonsoo Kim
On Wed, Jan 28, 2015 at 09:30:56AM -0600, Christoph Lameter wrote:
> On Wed, 28 Jan 2015, Joonsoo Kim wrote:
> 
> > > GFP_SLAB_ARRAY new is best for large quantities in either allocator since
> > > SLAB also has to construct local metadata structures.
> >
> > In case of SLAB, there is just a little more work to construct local 
> > metadata so
> > GFP_SLAB_ARRAY_NEW would not show better performance
> > than GFP_SLAB_ARRAY_LOCAL, because it would cause more overhead due to
> > more page allocations. Because of this characteristic, I said that
> > which option is
> > the best is implementation specific and therefore we should not expose it.
> 
> For large amounts of objects (hundreds or higher) GFP_SLAB_ARRAY_LOCAL
> will never have enough objects. GFP_SLAB_ARRAY_NEW will go to the page
> allocator and bypass free table creation and all the queuing that objects
> go through normally in SLAB. AFAICT its going to be a significant win.
> 
> A similar situation is true for the freeing operation. If the freeing
> operation results in all objects in a page being freed then we can also
> bypass that and put the page directly back into the page allocator (to be
> implemented once we agree on an approach).
> 
> > Even if we narrow down the problem to the SLUB, choosing correct option is
> > difficult enough. User should know how many objects are cached in this
> > kmem_cache
> > in order to choose best option since relative quantity would make
> > performance difference.
> 
> Ok we can add a function call to calculate the number of objects cached
> per cpu and per node? But then that is rather fluid and could change any
> moment.
> 
> > And, how many objects are cached in this kmem_cache could be changed
> > whenever implementation changed.
> 
> The default when no options are specified is to first exhaust the node
> partial objects, then allocate new slabs as long as we have more than
> objects per page left and only then satisfy from cpu local object. I think
> that is satisfactory for the majority of the cases.
> 
> The detailed control options were requested at the meeting in Auckland at
> the LCA. I am fine with dropping those if they do not make sense. Makes
> the API and implementation simpler. Jesper, are you ok with this?

IMHO, it'd be better to choose a proper way of allocation by slab itself
and not to expose options to API user. We could decide the best option
according to current status of kmem_cache and requested object number
and internal implementation.

Is there any obvious example these option are needed for user?

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


Re: 3.19 on Nokia n900: audio quality awful

2015-01-28 Thread Jarkko Nikula
On Wed, Jan 28, 2015 at 11:41:44PM +0100, Pavel Machek wrote:
> On Wed 2015-01-28 20:15:46, Jarkko Nikula wrote:
> > On 01/26/2015 03:20 PM, Peter Ujfalusi wrote:
> > > On 01/18/2015 02:01 PM, Pavel Machek wrote:
> > No need to go that far. N900 has been supported in mainline since 2.6.39
> > or so. Part A of AIC34 (which is basically dual AIC33 in a same package)
> > drives 2 V for the digital microphone bias and part B 2.5 V for the headset.
> 
> Let me try... Umm, no change here :-(
> 
> root@n900:/tmp# arecord delme
> Recording WAVE 'delme' : Unsigned 8 bit, Rate 8000 Hz, Mono
> ^CAborted by signal Interrupt...
> root@n900:/tmp# hexdump delme
> 000 4952 4646 987c  4157 4556 6d66 2074
> 010 0010  0001 0001 1f40  1f40 
> 020 0001 0008 6164 6174 9858  8080 8080
> 030 8080 8080 8080 8080 8080 8080 8080 8080
> *
> 0009880
> root@n900:/tmp# aplay delme
> Playing WAVE 'delme' : Unsigned 8 bit, Rate 8000 Hz, Mono
> root@n900:/tmp#
> 
> I did this:
> 
> I'm not sure which one is "main" microphone and which is headset, but
> I guess 2V should be "close enough" to 2.5V to produce something
> different from zeros..?
> 
Main or integrated is digital microphone which does AD conversion itself
and headset is analogue. If DMIC is without bias codec will sample plain
zeros from DMIC input but analogue input should always produce some random
LSB bits from codec's AD converter.

If codec produces zeros also from analogue input then I suppose codec
ADC is not powered up or similar. One way to hunt regression if
bisecting is not possible due reason or another is to dump and diff codec
registers from /sys/kernel/debug/regmap/ using both working commit and head.

> diff --git a/arch/arm/boot/dts/omap3-n900.dts 
> b/arch/arm/boot/dts/omap3-n900.dts
> index 48b0987..f18a5b0 100644
> --- a/arch/arm/boot/dts/omap3-n900.dts
> +++ b/arch/arm/boot/dts/omap3-n900.dts
> @@ -491,6 +491,8 @@
>   DRVDD-supply = <>;
>   IOVDD-supply = <>;
>   DVDD-supply = <>;
> +
> + ai3x-micbias-vg = <1>;
>   };
Looks ok for digital mic.

>  
>   tlv320aic3x_aux: tlv320aic3x@19 {
> @@ -502,6 +504,8 @@
>   DRVDD-supply = <>;
>   IOVDD-supply = <>;
>   DVDD-supply = <>;
> +
> + ai3x-micbias-vg = <1>;
>   };
This should be 2, i.e. 2.5 V according to
Documentation/devicetree/bindings/sound/tlv320aic3x.txt. I think 2 V is
too low for some headset mics and that was the reason for 2.5 V.

-- 
Jarkko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] arm: tegra: implement NVEC driver using tegra i2c.

2015-01-28 Thread Andrey Danin
Hi,

NVEC driver contains code to manage tegra i2c controller in slave mode.
I2C slave support was implemented in linux kernel. The goal of this
patch serie is to implement I2C slave mode in tegra drived and rework
NVEC driver to use it.

Patches are based on i2c for-next.

Patch 1 imeplents slave mode for tegra I2C controller. This patch
was checked on tegra 2 device (Toshiba AC100) only. Please review
carefully.

Patch 2 reworks NVEC driver itself. I kept code close to original.

Patch 3 fixes device tree and documentation.


Thanks in advance

Andrey Danin (3):
  i2c: tegra: implement slave mode
  staging/nvec: reimplement on top of tegra i2c driver
  dt: paz00: define nvec as child of i2c bus

 .../devicetree/bindings/nvec/nvidia,nvec.txt   |  19 +-
 arch/arm/boot/dts/tegra20-paz00.dts|  22 +-
 drivers/i2c/busses/i2c-tegra.c | 131 +++
 drivers/staging/nvec/nvec.c| 379 +++--
 drivers/staging/nvec/nvec.h|  17 +-
 5 files changed, 264 insertions(+), 304 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/


linux-next: manual merge of the akpm-current tree with the xen-tip tree

2015-01-28 Thread Stephen Rothwell
Hi Andrew,

Today's linux-next merge of the akpm-current tree got a conflict in
include/linux/mm.h between commit 667a0a06c99d ("mm: provide a
find_special_page vma operation") from the xen-tip tree and commit
cfd00f5aa195 ("mm: drop vm_ops->remap_pages and
generic_file_remap_pages() stub") from the akpm-current tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

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

diff --cc include/linux/mm.h
index 9269af7349fe,b5e28731a293..
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@@ -287,17 -284,6 +284,14 @@@ struct vm_operations_struct 
struct mempolicy *(*get_policy)(struct vm_area_struct *vma,
unsigned long addr);
  #endif
-   /* called by sys_remap_file_pages() to populate non-linear mapping */
-   int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
-  unsigned long size, pgoff_t pgoff);
 +
 +  /*
 +   * Called by vm_normal_page() for special PTEs to find the
 +   * page for @addr.  This is useful if the default behavior
 +   * (using pte_page()) would not find the correct page.
 +   */
 +  struct page *(*find_special_page)(struct vm_area_struct *vma,
 +unsigned long addr);
  };
  
  struct mmu_gather;


pgpURNIg68FKw.pgp
Description: OpenPGP digital signature


[PATCH 1/3] i2c: tegra: implement slave mode

2015-01-28 Thread Andrey Danin
Initialization code is based on NVEC driver.

There is a HW bug in AP20 that was also mentioned in kernel sources
for Toshiba AC100.

Signed-off-by: Andrey Danin 
---
 drivers/i2c/busses/i2c-tegra.c | 131 +
 1 file changed, 131 insertions(+)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 28b87e6..cfc4e67 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -42,8 +42,15 @@
 #define I2C_SL_CNFG0x020
 #define I2C_SL_CNFG_NACK   (1<<1)
 #define I2C_SL_CNFG_NEWSL  (1<<2)
+#define I2C_SL_RCVD0x024
+#define I2C_SL_STATUS  0x028
+#define I2C_SL_ST_IRQ  (1<<3)
+#define I2C_SL_ST_END_TRANS(1<<4)
+#define I2C_SL_ST_RCVD (1<<2)
+#define I2C_SL_ST_RNW  (1<<1)
 #define I2C_SL_ADDR1   0x02c
 #define I2C_SL_ADDR2   0x030
+#define I2C_SL_DELAY_COUNT 0x03c
 #define I2C_TX_FIFO0x050
 #define I2C_RX_FIFO0x054
 #define I2C_PACKET_TRANSFER_STATUS 0x058
@@ -125,6 +132,8 @@ enum msg_end_type {
  * @clk_divisor_std_fast_mode: Clock divisor in standard/fast mode. It is
  * applicable if there is no fast clock source i.e. single clock
  * source.
+ * @slave_read_start_delay: Workaround for AP20 I2C Slave Controller bug. Delay
+ *  before writing data byte into register I2C_SL_RCVD.
  */
 
 struct tegra_i2c_hw_feature {
@@ -133,6 +142,7 @@ struct tegra_i2c_hw_feature {
bool has_single_clk_source;
int clk_divisor_hs_mode;
int clk_divisor_std_fast_mode;
+   int slave_read_start_delay;
 };
 
 /**
@@ -173,6 +183,7 @@ struct tegra_i2c_dev {
int msg_read;
u32 bus_clk_rate;
bool is_suspended;
+   struct i2c_client *slave;
 };
 
 static void dvc_writel(struct tegra_i2c_dev *i2c_dev, u32 val, unsigned long 
reg)
@@ -398,6 +409,12 @@ static inline int tegra_i2c_clock_enable(struct 
tegra_i2c_dev *i2c_dev)
 
 static inline void tegra_i2c_clock_disable(struct tegra_i2c_dev *i2c_dev)
 {
+   if (i2c_dev->slave) {
+   dev_warn(i2c_dev->dev,
+   "i2c slave is registered, don't disable a clock\n");
+   return;
+   }
+
clk_disable(i2c_dev->div_clk);
if (!i2c_dev->hw->has_single_clk_source)
clk_disable(i2c_dev->fast_clk);
@@ -459,12 +476,84 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
return err;
 }
 
+static inline int is_ready(unsigned long status)
+{
+   return status & I2C_SL_ST_IRQ;
+}
+
+static inline int is_write(unsigned long status)
+{
+   return (status & I2C_SL_ST_RNW) == 0;
+}
+
+static inline int is_read(unsigned long status)
+{
+   return !is_write(status);
+}
+
+static inline int is_trans_start(unsigned long status)
+{
+   return status & I2C_SL_ST_RCVD;
+}
+
+static inline int is_trans_end(unsigned long status)
+{
+   return status & I2C_SL_ST_END_TRANS;
+}
+
+static bool tegra_i2c_slave_isr(int irq, struct tegra_i2c_dev *i2c_dev)
+{
+   unsigned long status;
+   u8 value;
+
+   if (!i2c_dev->slave || !i2c_dev->slave->slave_cb)
+   return false;
+
+   status = i2c_readl(i2c_dev, I2C_SL_STATUS);
+   if (!is_ready(status))
+   return false;
+
+   /* master sent stop */
+   if (is_trans_end(status)) {
+   i2c_slave_event(i2c_dev->slave, I2C_SLAVE_STOP, NULL);
+   if (!is_trans_start(status))
+   return true;
+   }
+
+   /* i2c master sends data to us */
+   if (is_write(status)) {
+   i2c_slave_event(i2c_dev->slave, I2C_SLAVE_REQ_WRITE_START,
+   NULL);
+   value = i2c_readl(i2c_dev, I2C_SL_RCVD);
+   if (is_trans_start(status))
+   i2c_writel(i2c_dev, 0, I2C_SL_RCVD);
+   i2c_slave_event(i2c_dev->slave, I2C_SLAVE_REQ_WRITE_END,
+   );
+   }
+
+   /* i2c master reads data from us */
+   if (is_read(status)) {
+   i2c_slave_event(i2c_dev->slave, I2C_SLAVE_REQ_READ_START,
+   );
+   if (is_trans_start(status)
+   && i2c_dev->hw->slave_read_start_delay)
+   udelay(i2c_dev->hw->slave_read_start_delay);
+   i2c_writel(i2c_dev, value, I2C_SL_RCVD);
+   i2c_slave_event(i2c_dev->slave, I2C_SLAVE_REQ_READ_END, NULL);
+   }
+
+   return true;
+}
+
 static irqreturn_t tegra_i2c_isr(int irq, void *dev_id)
 {
u32 status;
const u32 status_err = I2C_INT_NO_ACK | I2C_INT_ARBITRATION_LOST;
struct 

[PATCH 3/3] dt: paz00: define nvec as child of i2c bus

2015-01-28 Thread Andrey Danin
NVEC driver was reimplemented to use tegra i2c. Use common i2c bindings
for NVEC node.

Signed-off-by: Andrey Danin 
---
 .../devicetree/bindings/nvec/nvidia,nvec.txt   | 19 ++-
 arch/arm/boot/dts/tegra20-paz00.dts| 22 +-
 2 files changed, 11 insertions(+), 30 deletions(-)

diff --git a/Documentation/devicetree/bindings/nvec/nvidia,nvec.txt 
b/Documentation/devicetree/bindings/nvec/nvidia,nvec.txt
index 5ae601e..d82c125 100644
--- a/Documentation/devicetree/bindings/nvec/nvidia,nvec.txt
+++ b/Documentation/devicetree/bindings/nvec/nvidia,nvec.txt
@@ -2,20 +2,5 @@ NVIDIA compliant embedded controller
 
 Required properties:
 - compatible : should be "nvidia,nvec".
-- reg : the iomem of the i2c slave controller
-- interrupts : the interrupt line of the i2c slave controller
-- clock-frequency : the frequency of the i2c bus
-- gpios : the gpio used for ec request
-- slave-addr: the i2c address of the slave controller
-- clocks : Must contain an entry for each entry in clock-names.
-  See ../clocks/clock-bindings.txt for details.
-- clock-names : Must include the following entries:
-  Tegra20/Tegra30:
-  - div-clk
-  - fast-clk
-  Tegra114:
-  - div-clk
-- resets : Must contain an entry for each entry in reset-names.
-  See ../reset/reset.txt for details.
-- reset-names : Must include the following entries:
-  - i2c
+- request-gpios : the gpio used for ec request
+- reg: the i2c address of the slave controller
diff --git a/arch/arm/boot/dts/tegra20-paz00.dts 
b/arch/arm/boot/dts/tegra20-paz00.dts
index ed7e100..65e247b 100644
--- a/arch/arm/boot/dts/tegra20-paz00.dts
+++ b/arch/arm/boot/dts/tegra20-paz00.dts
@@ -288,20 +288,16 @@
clock-frequency = <10>;
};
 
-   nvec@7000c500 {
-   compatible = "nvidia,nvec";
-   reg = <0x7000c500 0x100>;
-   interrupts = ;
-   #address-cells = <1>;
-   #size-cells = <0>;
+   i2c@7000c500 {
+   status = "okay";
clock-frequency = <8>;
-   request-gpios = < TEGRA_GPIO(V, 2) GPIO_ACTIVE_HIGH>;
-   slave-addr = <138>;
-   clocks = <_car TEGRA20_CLK_I2C3>,
-<_car TEGRA20_CLK_PLL_P_OUT3>;
-   clock-names = "div-clk", "fast-clk";
-   resets = <_car 67>;
-   reset-names = "i2c";
+
+   nvec: nvec@45 {
+   compatible = "nvidia,nvec";
+   request-gpios = < TEGRA_GPIO(V, 2)
+   GPIO_ACTIVE_HIGH>;
+   reg = <0x45>;
+   };
};
 
i2c@7000d000 {
-- 
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] checkpatch: Add ability to --fix unnecessary blank lines around braces

2015-01-28 Thread Joe Perches
There's a --strict test for these blank lines.

Add the ability to automatically remove them with --fix.

Signed-off-by: Joe Perches 
---
 scripts/checkpatch.pl | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 6705576..059c032 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4461,12 +4461,18 @@ sub process {
 
 # check for unnecessary blank lines around braces
if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) {
-   CHK("BRACES",
-   "Blank lines aren't necessary before a close brace 
'}'\n" . $hereprev);
+   if (CHK("BRACES",
+   "Blank lines aren't necessary before a close 
brace '}'\n" . $hereprev) &&
+   $fix && $prevrawline =~ /^\+/) {
+   fix_delete_line($fixlinenr - 1, $prevrawline);
+   }
}
if (($rawline =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) {
-   CHK("BRACES",
-   "Blank lines aren't necessary after an open brace 
'{'\n" . $hereprev);
+   if (CHK("BRACES",
+   "Blank lines aren't necessary after an open 
brace '{'\n" . $hereprev) &&
+   $fix) {
+   fix_delete_line($fixlinenr, $rawline);
+   }
}
 
 # no volatiles please



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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/nvec: reimplement on top of tegra i2c driver

2015-01-28 Thread Andrey Danin
Remove i2c controller related code and use tegra i2c driver in slave mode.

Signed-off-by: Andrey Danin 
---
 drivers/staging/nvec/nvec.c | 379 ++--
 drivers/staging/nvec/nvec.h |  17 +-
 2 files changed, 122 insertions(+), 274 deletions(-)

diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index 120b70d..d645c58 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -25,8 +25,8 @@
 #include 
 #include 
 #include 
+#include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -39,25 +39,12 @@
 
 #include "nvec.h"
 
-#define I2C_CNFG   0x00
-#define I2C_CNFG_PACKET_MODE_EN(1<<10)
-#define I2C_CNFG_NEW_MASTER_SFM(1<<11)
-#define I2C_CNFG_DEBOUNCE_CNT_SHIFT12
-
-#define I2C_SL_CNFG0x20
-#define I2C_SL_NEWSL   (1<<2)
-#define I2C_SL_NACK(1<<1)
-#define I2C_SL_RESP(1<<0)
-#define I2C_SL_IRQ (1<<3)
-#define END_TRANS  (1<<4)
-#define RCVD   (1<<2)
-#define RNW(1<<1)
-
-#define I2C_SL_RCVD0x24
-#define I2C_SL_STATUS  0x28
-#define I2C_SL_ADDR1   0x2c
-#define I2C_SL_ADDR2   0x30
-#define I2C_SL_DELAY_COUNT 0x3c
+
+#define I2C_SL_ST_END_TRANS(1<<4)
+#define I2C_SL_ST_IRQ  (1<<3)
+#define I2C_SL_ST_RCVD (1<<2)
+#define I2C_SL_ST_RNW  (1<<1)
+
 
 /**
  * enum nvec_msg_category - Message categories for nvec_msg_alloc()
@@ -327,6 +314,7 @@ struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec,
 
mutex_unlock(>sync_write_mutex);
 
+
return msg;
 }
 EXPORT_SYMBOL(nvec_write_sync);
@@ -475,11 +463,13 @@ static void nvec_tx_completed(struct nvec_chip *nvec)
 {
/* We got an END_TRANS, let's skip this, maybe there's an event */
if (nvec->tx->pos != nvec->tx->size) {
-   dev_err(nvec->dev, "premature END_TRANS, resending\n");
+   dev_err(nvec->dev, "premature END_TRANS, resending: pos:%u, 
size:%u\n",
+   nvec->tx->pos, nvec->tx->size);
nvec->tx->pos = 0;
nvec_gpio_set_value(nvec, 0);
} else {
-   nvec->state = 0;
+   nvec->state = ST_NONE;
+   nvec->tx->pos = 0;
}
 }
 
@@ -497,7 +487,7 @@ static void nvec_rx_completed(struct nvec_chip *nvec)
   (uint) nvec->rx->pos);
 
nvec_msg_free(nvec, nvec->rx);
-   nvec->state = 0;
+   nvec->state = ST_NONE;
 
/* Battery quirk - Often incomplete, and likes to crash */
if (nvec->rx->data[0] == NVEC_BAT)
@@ -514,7 +504,7 @@ static void nvec_rx_completed(struct nvec_chip *nvec)
 
spin_unlock(>rx_lock);
 
-   nvec->state = 0;
+   nvec->state = ST_NONE;
 
if (!nvec_msg_is_event(nvec->rx))
complete(>ec_transfer);
@@ -523,21 +513,6 @@ static void nvec_rx_completed(struct nvec_chip *nvec)
 }
 
 /**
- * nvec_invalid_flags - Send an error message about invalid flags and jump
- * @nvec: The nvec device
- * @status: The status flags
- * @reset: Whether we shall jump to state 0.
- */
-static void nvec_invalid_flags(struct nvec_chip *nvec, unsigned int status,
-  bool reset)
-{
-   dev_err(nvec->dev, "unexpected status flags 0x%02x during state %i\n",
-   status, nvec->state);
-   if (reset)
-   nvec->state = 0;
-}
-
-/**
  * nvec_tx_set - Set the message to transfer (nvec->tx)
  * @nvec: A  nvec_chip
  *
@@ -566,150 +541,85 @@ static void nvec_tx_set(struct nvec_chip *nvec)
(uint)nvec->tx->size, nvec->tx->data[1]);
 }
 
+
 /**
- * nvec_interrupt - Interrupt handler
- * @irq: The IRQ
- * @dev: The nvec device
+ * nvec_slave_cb - I2C slave callback
  *
- * Interrupt handler that fills our RX buffers and empties our TX
- * buffers. This uses a finite state machine with ridiculous amounts
- * of error checking, in order to be fairly reliable.
+ * This callback fills our RX buffers and empties our TX
+ * buffers. This uses a finite state machine.
  */
-static irqreturn_t nvec_interrupt(int irq, void *dev)
+static int nvec_slave_cb(struct i2c_client *client,
+   enum i2c_slave_event event, u8 *val)
 {
-   unsigned long status;
-   unsigned int received = 0;
-   unsigned char to_send = 0xff;
-   const unsigned long irq_mask = I2C_SL_IRQ | END_TRANS | RCVD | RNW;
-   struct nvec_chip *nvec = dev;
-   unsigned int state = nvec->state;
-
-   status = readl(nvec->base + I2C_SL_STATUS);
-
-   /* Filter out some errors */
-   if ((status & irq_mask) == 0 && (status & ~irq_mask) != 0) {
-   dev_err(nvec->dev, "unexpected irq mask %lx\n", status);
-   return IRQ_HANDLED;
-   }
-   if 

[PATCH v11 05/28] scripts/gdb: Add lx-symbols command

2015-01-28 Thread Jan Kiszka
This is probably the most useful helper when debugging kernel modules:
lx-symbols first reloads vmlinux. Then it searches recursively for *.ko
files in the specified paths and the current directory. Finally it walks
the kernel's module list, issuing the necessary add-symbol-file command
for each loaded module so that gdb knows which module symbol corresponds
to which address. It also looks up variable sections (bss, data, rodata)
and appends their address to the add-symbole-file command line. This
allows to access global module variables just like any other variable.

Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/symbols.py | 127 +++
 scripts/gdb/vmlinux-gdb.py   |   1 +
 2 files changed, 128 insertions(+)
 create mode 100644 scripts/gdb/linux/symbols.py

diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py
new file mode 100644
index 000..bd21a96
--- /dev/null
+++ b/scripts/gdb/linux/symbols.py
@@ -0,0 +1,127 @@
+#
+# gdb helper commands and functions for Linux kernel debugging
+#
+#  load kernel and module symbols
+#
+# Copyright (c) Siemens AG, 2011-2013
+#
+# Authors:
+#  Jan Kiszka 
+#
+# This work is licensed under the terms of the GNU GPL version 2.
+#
+
+import gdb
+import os
+import re
+import string
+
+from linux import modules, utils
+
+
+class LxSymbols(gdb.Command):
+"""(Re-)load symbols of Linux kernel and currently loaded modules.
+
+The kernel (vmlinux) is taken from the current working directly. Modules (.ko)
+are scanned recursively, starting in the same directory. Optionally, the module
+search path can be extended by a space separated list of paths passed to the
+lx-symbols command."""
+
+module_paths = []
+module_files = []
+module_files_updated = False
+
+def __init__(self):
+super(LxSymbols, self).__init__("lx-symbols", gdb.COMMAND_FILES,
+gdb.COMPLETE_FILENAME)
+
+def _update_module_files(self):
+self.module_files = []
+for path in self.module_paths:
+gdb.write("scanning for modules in {0}\n".format(path))
+for root, dirs, files in os.walk(path):
+for name in files:
+if name.endswith(".ko"):
+self.module_files.append(root + "/" + name)
+self.module_files_updated = True
+
+def _get_module_file(self, module_name):
+module_pattern = ".*/{0}\.ko$".format(
+string.replace(module_name, "_", r"[_\-]"))
+for name in self.module_files:
+if re.match(module_pattern, name) and os.path.exists(name):
+return name
+return None
+
+def _section_arguments(self, module):
+try:
+sect_attrs = module['sect_attrs'].dereference()
+except gdb.error:
+return ""
+attrs = sect_attrs['attrs']
+section_name_to_address = {
+attrs[n]['name'].string() : attrs[n]['address']
+for n in range(sect_attrs['nsections'])}
+args = []
+for section_name in [".data", ".data..read_mostly", ".rodata", ".bss"]:
+address = section_name_to_address.get(section_name)
+if address:
+args.append(" -s {name} {addr}".format(
+name=section_name, addr=str(address)))
+return "".join(args)
+
+def load_module_symbols(self, module):
+module_name = module['name'].string()
+module_addr = str(module['module_core']).split()[0]
+
+module_file = self._get_module_file(module_name)
+if not module_file and not self.module_files_updated:
+self._update_module_files()
+module_file = self._get_module_file(module_name)
+
+if module_file:
+gdb.write("loading @{addr}: {filename}\n".format(
+addr=module_addr, filename=module_file))
+cmdline = "add-symbol-file {filename} {addr}{sections}".format(
+filename=module_file,
+addr=module_addr,
+sections=self._section_arguments(module))
+gdb.execute(cmdline, to_string=True)
+else:
+gdb.write("no module object found for '{0}'\n".format(module_name))
+
+def load_all_symbols(self):
+gdb.write("loading vmlinux\n")
+
+# Dropping symbols will disable all breakpoints. So save their states
+# and restore them afterward.
+saved_states = []
+if hasattr(gdb, 'breakpoints') and not gdb.breakpoints() is None:
+for bp in gdb.breakpoints():
+saved_states.append({'breakpoint': bp, 'enabled': bp.enabled})
+
+# drop all current symbols and reload vmlinux
+gdb.execute("symbol-file", to_string=True)
+gdb.execute("symbol-file vmlinux")
+
+module_list = modules.ModuleList()
+if not module_list:
+gdb.write("no modules found\n")
+else:
+

[PATCH v11 10/28] scripts/gdb: Add read_u16/32/64 helpers

2015-01-28 Thread Jan Kiszka
Add helpers for reading integers from target memory buffers. Required
when caching the memory access is more efficient than reading individual
values via gdb.

Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/utils.py | 21 +
 1 file changed, 21 insertions(+)

diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py
index 10a227b..808a265 100644
--- a/scripts/gdb/linux/utils.py
+++ b/scripts/gdb/linux/utils.py
@@ -85,3 +85,24 @@ def get_target_endianness():
 else:
 raise gdb.GdgError("unknown endianness '{0}'".format(endian))
 return target_endianness
+
+
+def read_u16(buffer):
+if get_target_endianness() == LITTLE_ENDIAN:
+return ord(buffer[0]) + (ord(buffer[1]) << 8)
+else:
+return ord(buffer[1]) + (ord(buffer[0]) << 8)
+
+
+def read_u32(buffer):
+if get_target_endianness() == LITTLE_ENDIAN:
+return read_u16(buffer[0:2]) + (read_u16(buffer[2:4]) << 16)
+else:
+return read_u16(buffer[2:4]) + (read_u16(buffer[0:2]) << 16)
+
+
+def read_u64(buffer):
+if get_target_endianness() == LITTLE_ENDIAN:
+return read_u32(buffer[0:4]) + (read_u32(buffer[4:8]) << 32)
+else:
+return read_u32(buffer[4:8]) + (read_u32(buffer[0:4]) << 32)
-- 
2.1.4

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


[PATCH v11 16/28] scripts/gdb: Add get_gdbserver_type helper

2015-01-28 Thread Jan Kiszka
This helper probes the type of the gdb server. Supported are QEMU and
KGDB so far. Knowledge about the gdb server is required e.g. to retrieve
the current CPU or current task.

Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/utils.py | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py
index 71ee48c..a4a1640 100644
--- a/scripts/gdb/linux/utils.py
+++ b/scripts/gdb/linux/utils.py
@@ -119,3 +119,38 @@ def is_target_arch(arch):
 if target_arch is None:
 target_arch = gdb.execute("show architecture", to_string=True)
 return arch in target_arch
+
+
+GDBSERVER_QEMU = 0
+GDBSERVER_KGDB = 1
+gdbserver_type = None
+
+
+def get_gdbserver_type():
+def exit_handler(event):
+global gdbserver_type
+gdbserver_type = None
+gdb.events.exited.disconnect(exit_handler)
+
+def probe_qemu():
+try:
+return gdb.execute("monitor info version", to_string=True) != ""
+except:
+return False
+
+def probe_kgdb():
+try:
+thread_info = gdb.execute("info thread 2", to_string=True)
+return "shadowCPU0" in thread_info
+except:
+return False
+
+global gdbserver_type
+if gdbserver_type is None:
+if probe_qemu():
+gdbserver_type = GDBSERVER_QEMU
+elif probe_kgdb():
+gdbserver_type = GDBSERVER_KGDB
+if not gdbserver_type is None and hasattr(gdb, 'events'):
+gdb.events.exited.connect(exit_handler)
+return gdbserver_type
-- 
2.1.4

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


[PATCH v11 14/28] scripts/gdb: Add is_target_arch helper

2015-01-28 Thread Jan Kiszka
This helper caches to result of "show architecture" and matches the
provided arch (sub-)string against that output.

Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/utils.py | 13 +
 1 file changed, 13 insertions(+)

diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py
index 808a265..71ee48c 100644
--- a/scripts/gdb/linux/utils.py
+++ b/scripts/gdb/linux/utils.py
@@ -106,3 +106,16 @@ def read_u64(buffer):
 return read_u32(buffer[0:4]) + (read_u32(buffer[4:8]) << 32)
 else:
 return read_u32(buffer[4:8]) + (read_u32(buffer[0:4]) << 32)
+
+
+target_arch = None
+
+
+def is_target_arch(arch):
+if hasattr(gdb.Frame, 'architecture'):
+return arch in gdb.newest_frame().architecture().name()
+else:
+global target_arch
+if target_arch is None:
+target_arch = gdb.execute("show architecture", to_string=True)
+return arch in target_arch
-- 
2.1.4

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


[PATCH v11 12/28] scripts/gdb: Add task iteration class

2015-01-28 Thread Jan Kiszka
This class allows to iterate over all tasks of the target.

Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/tasks.py | 46 ++
 1 file changed, 46 insertions(+)
 create mode 100644 scripts/gdb/linux/tasks.py

diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py
new file mode 100644
index 000..cd25984
--- /dev/null
+++ b/scripts/gdb/linux/tasks.py
@@ -0,0 +1,46 @@
+#
+# gdb helper commands and functions for Linux kernel debugging
+#
+#  task & thread tools
+#
+# Copyright (c) Siemens AG, 2011-2013
+#
+# Authors:
+#  Jan Kiszka 
+#
+# This work is licensed under the terms of the GNU GPL version 2.
+#
+
+import gdb
+
+from linux import utils
+
+
+task_type = utils.CachedType("struct task_struct")
+
+
+class TaskList:
+def __init__(self):
+global task_type
+self.task_ptr_type = task_type.get_type().pointer()
+self.init_task = gdb.parse_and_eval("init_task")
+self.curr_group = self.init_task.address
+self.curr_task = None
+
+def __iter__(self):
+return self
+
+def next(self):
+t = self.curr_task
+if not t or t == self.curr_group:
+self.curr_group = \
+utils.container_of(self.curr_group['tasks']['next'],
+   self.task_ptr_type, "tasks")
+if self.curr_group == self.init_task.address:
+raise StopIteration
+t = self.curr_task = self.curr_group
+else:
+self.curr_task = \
+utils.container_of(t['thread_group']['next'],
+   self.task_ptr_type, "thread_group")
+return t
-- 
2.1.4

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


[PATCH v11 18/28] scripts/gdb: Add lx_current convenience function

2015-01-28 Thread Jan Kiszka
This is a shorthand for *$lx_per_cpu("current_task"), i.e. a convenience
function to retrieve the currently running task of the active context.

Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/cpus.py | 17 +
 1 file changed, 17 insertions(+)

diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py
index 18337e0..b683da9 100644
--- a/scripts/gdb/linux/cpus.py
+++ b/scripts/gdb/linux/cpus.py
@@ -66,3 +66,20 @@ Note that VAR has to be quoted as string."""
 
 
 PerCpu()
+
+
+class LxCurrentFunc(gdb.Function):
+"""Return current task.
+
+$lx_current([CPU]): Return the per-cpu task variable for the given CPU
+number. If CPU is omitted, the CPU of the current context is used."""
+
+def __init__(self):
+super(LxCurrentFunc, self).__init__("lx_current")
+
+def invoke(self, cpu=-1):
+var_ptr = gdb.parse_and_eval("_task")
+return per_cpu(var_ptr, cpu).dereference()
+
+
+LxCurrentFunc()
-- 
2.1.4

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


[PATCH v11 04/28] scripts/gdb: Add module iteration class

2015-01-28 Thread Jan Kiszka
Will soon be used for loading symbols, printing global variables or
listing modules.

Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/modules.py | 39 +++
 1 file changed, 39 insertions(+)
 create mode 100644 scripts/gdb/linux/modules.py

diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py
new file mode 100644
index 000..8a65c3d
--- /dev/null
+++ b/scripts/gdb/linux/modules.py
@@ -0,0 +1,39 @@
+#
+# gdb helper commands and functions for Linux kernel debugging
+#
+#  module tools
+#
+# Copyright (c) Siemens AG, 2013
+#
+# Authors:
+#  Jan Kiszka 
+#
+# This work is licensed under the terms of the GNU GPL version 2.
+#
+
+import gdb
+
+from linux import utils
+
+
+module_type = utils.CachedType("struct module")
+
+
+class ModuleList:
+def __init__(self):
+global module_type
+self.module_ptr_type = module_type.get_type().pointer()
+modules = gdb.parse_and_eval("modules")
+self.curr_entry = modules['next']
+self.end_of_list = modules.address
+
+def __iter__(self):
+return self
+
+def next(self):
+entry = self.curr_entry
+if entry != self.end_of_list:
+self.curr_entry = entry['next']
+return utils.container_of(entry, self.module_ptr_type, "list")
+else:
+raise StopIteration
-- 
2.1.4

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


[PATCH v11 13/28] scripts/gdb: Add helper and convenience function to look up tasks

2015-01-28 Thread Jan Kiszka
Add the helper task_by_pid that can look up a task by its PID. Also
export it as a convenience function.

Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/tasks.py | 27 +++
 scripts/gdb/vmlinux-gdb.py |  1 +
 2 files changed, 28 insertions(+)

diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py
index cd25984..13bb97c 100644
--- a/scripts/gdb/linux/tasks.py
+++ b/scripts/gdb/linux/tasks.py
@@ -44,3 +44,30 @@ class TaskList:
 utils.container_of(t['thread_group']['next'],
self.task_ptr_type, "thread_group")
 return t
+
+
+def get_task_by_pid(pid):
+for task in TaskList():
+if int(task['pid']) == pid:
+return task
+return None
+
+
+class LxTaskByPidFunc(gdb.Function):
+"""Find Linux task by PID and return the task_struct variable.
+
+$lx_task_by_pid(PID): Given PID, iterate over all tasks of the target and
+return that task_struct variable which PID matches."""
+
+def __init__(self):
+super(LxTaskByPidFunc, self).__init__("lx_task_by_pid")
+
+def invoke(self, pid):
+task = get_task_by_pid(pid)
+if task:
+return task.dereference()
+else:
+raise gdb.GdbError("No task of PID " + str(pid))
+
+
+LxTaskByPidFunc()
diff --git a/scripts/gdb/vmlinux-gdb.py b/scripts/gdb/vmlinux-gdb.py
index fa66d23..4d7eb2c 100644
--- a/scripts/gdb/vmlinux-gdb.py
+++ b/scripts/gdb/vmlinux-gdb.py
@@ -26,3 +26,4 @@ else:
 import linux.symbols
 import linux.modules
 import linux.dmesg
+import linux.tasks
-- 
2.1.4

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


[PATCH v11 26/28] scripts/gdb: Convert CpuList to generator function

2015-01-28 Thread Jan Kiszka
Yet another code simplification.

Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/cpus.py| 71 
 scripts/gdb/linux/modules.py |  2 +-
 2 files changed, 33 insertions(+), 40 deletions(-)

diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py
index 8045871..4297b83 100644
--- a/scripts/gdb/linux/cpus.py
+++ b/scripts/gdb/linux/cpus.py
@@ -61,50 +61,43 @@ def cpu_mask_invalidate(event):
 gdb.events.new_objfile.disconnect(cpu_mask_invalidate)
 
 
-class CpuList():
-def __init__(self, mask_name):
-global cpu_mask
-self.mask = None
-if mask_name in cpu_mask:
-self.mask = cpu_mask[mask_name]
-if self.mask is None:
-self.mask = gdb.parse_and_eval(mask_name + ".bits")
-if hasattr(gdb, 'events'):
-cpu_mask[mask_name] = self.mask
-gdb.events.stop.connect(cpu_mask_invalidate)
-if hasattr(gdb.events, 'new_objfile'):
-gdb.events.new_objfile.connect(cpu_mask_invalidate)
-self.bits_per_entry = self.mask[0].type.sizeof * 8
-self.num_entries = self.mask.type.sizeof * 8 / self.bits_per_entry
-self.entry = -1
-self.bits = 0
-
-def __iter__(self):
-return self
-
-def __next__(self):
-while self.bits == 0:
-self.entry += 1
-if self.entry == self.num_entries:
-raise StopIteration
-self.bits = self.mask[self.entry]
-if self.bits != 0:
-self.bit = 0
+def cpu_list(mask_name):
+global cpu_mask
+mask = None
+if mask_name in cpu_mask:
+mask = cpu_mask[mask_name]
+if mask is None:
+mask = gdb.parse_and_eval(mask_name + ".bits")
+if hasattr(gdb, 'events'):
+cpu_mask[mask_name] = mask
+gdb.events.stop.connect(cpu_mask_invalidate)
+if hasattr(gdb.events, 'new_objfile'):
+gdb.events.new_objfile.connect(cpu_mask_invalidate)
+bits_per_entry = mask[0].type.sizeof * 8
+num_entries = mask.type.sizeof * 8 / bits_per_entry
+entry = -1
+bits = 0
+
+while True:
+while bits == 0:
+entry += 1
+if entry == num_entries:
+return
+bits = mask[entry]
+if bits != 0:
+bit = 0
 break
 
-while self.bits & 1 == 0:
-self.bits >>= 1
-self.bit += 1
-
-cpu = self.entry * self.bits_per_entry + self.bit
+while bits & 1 == 0:
+bits >>= 1
+bit += 1
 
-self.bits >>= 1
-self.bit += 1
+cpu = entry * bits_per_entry + bit
 
-return cpu
+bits >>= 1
+bit += 1
 
-def next(self):
-return self.__next__()
+yield cpu
 
 
 class PerCpu(gdb.Function):
diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py
index 6d49722..a1504c4 100644
--- a/scripts/gdb/linux/modules.py
+++ b/scripts/gdb/linux/modules.py
@@ -75,7 +75,7 @@ class LxLsmod(gdb.Command):
 for module in module_list():
 ref = 0
 module_refptr = module['refptr']
-for cpu in cpus.CpuList("cpu_possible_mask"):
+for cpu in cpus.cpu_list("cpu_possible_mask"):
 refptr = cpus.per_cpu(module_refptr, cpu)
 ref += refptr['incs']
 ref -= refptr['decs']
-- 
2.1.4

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


[PATCH v11 25/28] scripts/gdb: Convert ModuleList to generator function

2015-01-28 Thread Jan Kiszka
Analogously to the task list, convert the module list to a generator
function. It noticeably simplifies the code.

Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/modules.py | 33 +++--
 scripts/gdb/linux/symbols.py |  2 +-
 2 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py
index 2dbf679..6d49722 100644
--- a/scripts/gdb/linux/modules.py
+++ b/scripts/gdb/linux/modules.py
@@ -19,31 +19,20 @@ from linux import cpus, utils
 module_type = utils.CachedType("struct module")
 
 
-class ModuleList:
-def __init__(self):
-global module_type
-self.module_ptr_type = module_type.get_type().pointer()
-modules = gdb.parse_and_eval("modules")
-self.curr_entry = modules['next']
-self.end_of_list = modules.address
-
-def __iter__(self):
-return self
-
-def __next__(self):
-entry = self.curr_entry
-if entry != self.end_of_list:
-self.curr_entry = entry['next']
-return utils.container_of(entry, self.module_ptr_type, "list")
-else:
-raise StopIteration
+def module_list():
+global module_type
+module_ptr_type = module_type.get_type().pointer()
+modules = gdb.parse_and_eval("modules")
+entry = modules['next']
+end_of_list = modules.address
 
-def next(self):
-return self.__next__()
+while entry != end_of_list:
+yield utils.container_of(entry, module_ptr_type, "list")
+entry = entry['next']
 
 
 def find_module_by_name(name):
-for module in ModuleList():
+for module in module_list():
 if module['name'].string() == name:
 return module
 return None
@@ -83,7 +72,7 @@ class LxLsmod(gdb.Command):
 "Address{0}Module  Size  Used by\n".format(
 "" if utils.get_long_type().sizeof == 8 else ""))
 
-for module in ModuleList():
+for module in module_list():
 ref = 0
 module_refptr = module['refptr']
 for cpu in cpus.CpuList("cpu_possible_mask"):
diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py
index ae757fd..bf05e45 100644
--- a/scripts/gdb/linux/symbols.py
+++ b/scripts/gdb/linux/symbols.py
@@ -133,7 +133,7 @@ lx-symbols command."""
 gdb.execute("symbol-file vmlinux")
 
 self.loaded_modules = []
-module_list = modules.ModuleList()
+module_list = modules.module_list()
 if not module_list:
 gdb.write("no modules found\n")
 else:
-- 
2.1.4

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


[PATCH v11 07/28] scripts/gdb: Add automatic symbol reloading on module insertion

2015-01-28 Thread Jan Kiszka
This installs a silent breakpoint on the do_init_module function. The
breakpoint handler will try to load symbols from the module files found
during lx-symbols execution. This way, breakpoints can be set to module
initialization functions, and there is no need to explicitly call
lx-symbols after (re-)loading a module.

Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/symbols.py | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py
index bd21a96..139841f 100644
--- a/scripts/gdb/linux/symbols.py
+++ b/scripts/gdb/linux/symbols.py
@@ -19,6 +19,30 @@ import string
 from linux import modules, utils
 
 
+if hasattr(gdb, 'Breakpoint'):
+class LoadModuleBreakpoint(gdb.Breakpoint):
+def __init__(self, spec, gdb_command):
+super(LoadModuleBreakpoint, self).__init__(spec, internal=True)
+self.silent = True
+self.gdb_command = gdb_command
+
+def stop(self):
+module = gdb.parse_and_eval("mod")
+module_name = module['name'].string()
+cmd = self.gdb_command
+
+# enforce update if object file is not found
+cmd.module_files_updated = False
+
+if module_name in cmd.loaded_modules:
+gdb.write("refreshing all symbols to reload module "
+  "'{0}'\n".format(module_name))
+cmd.load_all_symbols()
+else:
+cmd.load_module_symbols(module)
+return False
+
+
 class LxSymbols(gdb.Command):
 """(Re-)load symbols of Linux kernel and currently loaded modules.
 
@@ -30,6 +54,8 @@ lx-symbols command."""
 module_paths = []
 module_files = []
 module_files_updated = False
+loaded_modules = []
+breakpoint = None
 
 def __init__(self):
 super(LxSymbols, self).__init__("lx-symbols", gdb.COMMAND_FILES,
@@ -87,6 +113,8 @@ lx-symbols command."""
 addr=module_addr,
 sections=self._section_arguments(module))
 gdb.execute(cmdline, to_string=True)
+if not module_name in self.loaded_modules:
+self.loaded_modules.append(module_name)
 else:
 gdb.write("no module object found for '{0}'\n".format(module_name))
 
@@ -104,6 +132,7 @@ lx-symbols command."""
 gdb.execute("symbol-file", to_string=True)
 gdb.execute("symbol-file vmlinux")
 
+self.loaded_modules = []
 module_list = modules.ModuleList()
 if not module_list:
 gdb.write("no modules found\n")
@@ -123,5 +152,15 @@ lx-symbols command."""
 
 self.load_all_symbols()
 
+if hasattr(gdb, 'Breakpoint'):
+if not self.breakpoint is None:
+self.breakpoint.delete()
+self.breakpoint = None
+self.breakpoint = LoadModuleBreakpoint(
+"kernel/module.c:do_init_module", self)
+else:
+gdb.write("Note: symbol update on module loading not supported "
+  "with this gdb version\n")
+
 
 LxSymbols()
-- 
2.1.4

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


[PATCH v11 08/28] scripts/gdb: Add internal helper and convenience function to look up a module

2015-01-28 Thread Jan Kiszka
Add the internal helper get_module_by_name to obtain the module
structure corresponding to the given name. Also export this service as a
convenience function.

Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/modules.py | 28 
 scripts/gdb/vmlinux-gdb.py   |  1 +
 2 files changed, 29 insertions(+)

diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py
index 8a65c3d..531f763 100644
--- a/scripts/gdb/linux/modules.py
+++ b/scripts/gdb/linux/modules.py
@@ -37,3 +37,31 @@ class ModuleList:
 return utils.container_of(entry, self.module_ptr_type, "list")
 else:
 raise StopIteration
+
+
+def find_module_by_name(name):
+for module in ModuleList():
+if module['name'].string() == name:
+return module
+return None
+
+
+class LxModule(gdb.Function):
+"""Find module by name and return the module variable.
+
+$lx_module("MODULE"): Given the name MODULE, iterate over all loaded modules
+of the target and return that module variable which MODULE matches."""
+
+def __init__(self):
+super(LxModule, self).__init__("lx_module")
+
+def invoke(self, mod_name):
+mod_name = mod_name.string()
+module = find_module_by_name(mod_name)
+if module:
+return module.dereference()
+else:
+raise gdb.GdbError("Unable to find MODULE " + mod_name)
+
+
+LxModule()
diff --git a/scripts/gdb/vmlinux-gdb.py b/scripts/gdb/vmlinux-gdb.py
index 0b0faa4..cf2e716 100644
--- a/scripts/gdb/vmlinux-gdb.py
+++ b/scripts/gdb/vmlinux-gdb.py
@@ -24,3 +24,4 @@ except:
 else:
 import linux.utils
 import linux.symbols
+import linux.modules
-- 
2.1.4

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


[PATCH v11 28/28] scripts/gdb: Disable pagination while printing from breakpoint handler

2015-01-28 Thread Jan Kiszka
While reporting the (refreshed) list of modules on automatic updates we
may hit the page boundary of the output console and cause a stop if
pagination is enabled. However, gdb does not accept user input while
running over the breakpoint handler. So we get stuck, and the user is
forced to interrupt gdb.

Resolve this by disabling pagination during automatic symbol updates. We
restore the user's configuration once done.

Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/symbols.py | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py
index bf05e45..cd5bea9 100644
--- a/scripts/gdb/linux/symbols.py
+++ b/scripts/gdb/linux/symbols.py
@@ -34,12 +34,23 @@ if hasattr(gdb, 'Breakpoint'):
 # enforce update if object file is not found
 cmd.module_files_updated = False
 
+# Disable pagination while reporting symbol (re-)loading.
+# The console input is blocked in this context so that we would
+# get stuck waiting for the user to acknowledge paged output.
+show_pagination = gdb.execute("show pagination", to_string=True)
+pagination = show_pagination.endswith("on.\n")
+gdb.execute("set pagination off")
+
 if module_name in cmd.loaded_modules:
 gdb.write("refreshing all symbols to reload module "
   "'{0}'\n".format(module_name))
 cmd.load_all_symbols()
 else:
 cmd.load_module_symbols(module)
+
+# restore pagination state
+gdb.execute("set pagination %s" % ("on" if pagination else "off"))
+
 return False
 
 
-- 
2.1.4

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


Re: [PATCH v1 2/2] zram: remove init_lock in zram_make_request

2015-01-28 Thread Sergey Senozhatsky
On (01/29/15 15:35), Minchan Kim wrote:
>
> As you told, the data was not stable.
>
yes. fread test was always slower, and the rest was mostly slower.


> Anyway, when I read down_read implementation, it's one atomic instruction.
> Hmm, it seems te be better for srcu_read_lock which does more things.
>
srcu looks havier, agree.

> But I guessed most of overhead are from [de]compression, memcpy, clear_page
> That's why I guessed we don't have measurable difference from that.
> What's the data pattern if you use iozone?

by "data pattern" you mean usage scenario? well, I usually use zram for
`make -jX', where X=[4..N]. so N concurrent read-write ops scenario.

-ss

> I guess it's really simple pattern compressor can do fast. I used /dev/sda
> for dd write so more realistic data. Anyway, if we has 10% regression even if
> the data is simple, I never want to merge it.
> I will test it carefully and if it turns out lots regression,
> surely, I will not go with this and send the original patch again.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: [lm-sensors] [PATCH] hwmon: (ads7828) Make sample interval configurable

2015-01-28 Thread Guenter Roeck

On 01/28/2015 11:00 PM, Robert Rosengren wrote:

On 01/28/2015 03:50 PM, Guenter Roeck wrote:

Can you possibly send me the output from i2cdump ? That might help figuring out 
what is going on.

I don't have i2cdump (I suppose that you mean the lm-sensors tool) available 
for my hardware. I'll give it a go to compile it...



Ah, don't bother then. I should hopefully get the samples in a couple of days.

Is your hardware big endian or little endian ?

Thanks,
Guenter

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


Re: [PATCH v2 linux-trace 1/8] tracing: attach eBPF programs to tracepoints and syscalls

2015-01-28 Thread Alexei Starovoitov
On Wed, Jan 28, 2015 at 10:41 PM, Namhyung Kim  wrote:
>
> I think it's not a problem of bpf.  An user process can be killed
> anytime while it enabed events without bpf.  The only thing it should
> care is the auto-unload IMHO.

ok. I think it does indeed make sense to decouple the logic.
We can add 'auto_enable' file to achieve desired Ctrl-C behavior.
While the 'auto_enable' file is open the event will be enabled
and writes to 'enable' file will be ignored.
As soon as file closes, the event is auto-disabled.
Then user space will use 'bpf' file to attach/auto-unload
and 'auto_enable' file together.
Seem there would be a use for such 'auto_enable'
without bpf as well.

> I'm okay for not calling bpf program in NMI but not for disabling events.
>
> Suppose an user was collecting an event (including in NMI) and then
> [s]he also wanted to run a bpf program.  So [s]he wrote a program
> always return 1.  But after attaching the program, it didn't record
> the event in NMI..  Isn't that a problem?

ok, I think 'if (in_nmi()) return 1;' will work then, right?
Or you're thinking something else ?

> Right.  I think bpf programs belong to a user process but events are
> global resource.  Maybe you also need to consider attaching bpf
> program via perf (ioctl?) interface..

yes. I did. Please see my reply to Masami.
ioctl only works for tracepoints.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: [lm-sensors] [PATCH] hwmon: (ads7828) Make sample interval configurable

2015-01-28 Thread Robert Rosengren

On 01/28/2015 03:50 PM, Guenter Roeck wrote:

Can you possibly send me the output from i2cdump ? That might help figuring out 
what is going on.
I don't have i2cdump (I suppose that you mean the lm-sensors tool) 
available for my hardware. I'll give it a go to compile it...


BR,
Robert
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 2/2] perf: update userspace page info for software event

2015-01-28 Thread Shaohua Li
Ping!

On Fri, Jan 23, 2015 at 07:57:24AM -0800, Shaohua Li wrote:
> On Fri, Jan 23, 2015 at 09:44:51AM +0100, Peter Zijlstra wrote:
> > On Thu, Jan 22, 2015 at 01:09:02PM -0800, Shaohua Li wrote:
> > > ---
> > >  kernel/events/core.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/kernel/events/core.c b/kernel/events/core.c
> > > index 4edde3e..4221240 100644
> > > --- a/kernel/events/core.c
> > > +++ b/kernel/events/core.c
> > > @@ -5950,6 +5950,7 @@ static int perf_swevent_add(struct perf_event 
> > > *event, int flags)
> > >   }
> > >  
> > >   hlist_add_head_rcu(>hlist_entry, head);
> > > + perf_event_update_userpage(event);
> > >  
> > >   return 0;
> > >  }
> > > @@ -6419,6 +6420,7 @@ static int cpu_clock_event_add(struct perf_event 
> > > *event, int flags)
> > >  {
> > >   if (flags & PERF_EF_START)
> > >   cpu_clock_event_start(event, flags);
> > > + perf_event_update_userpage(event);
> > >  
> > >   return 0;
> > >  }
> > > @@ -6493,6 +6495,7 @@ static int task_clock_event_add(struct perf_event 
> > > *event, int flags)
> > >  {
> > >   if (flags & PERF_EF_START)
> > >   task_clock_event_start(event, flags);
> > > + perf_event_update_userpage(event);
> > >  
> > >   return 0;
> > >  }
> > 
> > How about the one I sent; which adds it to {start,stop} instead of add?
> > {start,stop} is the right place to add them, although this add might be
> > sufficient for your use case.
> Hi Peter,
> I tried {start, stop}, it doesn't work (doesn't get called in context
> switch) and I still get a CLOCK_MONOTONIC. So I added it to .add, which
> is called in context switch and I got correct thread time. Am I missing
> anything?
> 
> Thanks,
> Shaohua
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 v11 27/28] scripts/gdb: Define maintainer

2015-01-28 Thread Jan Kiszka
I'm proposing myself for keeping an eye on these scripts and integrating
contributions.

Signed-off-by: Jan Kiszka 
---
 MAINTAINERS | 5 +
 1 file changed, 5 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 2ebb056..3570313 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4164,6 +4164,11 @@ W:   http://www.icp-vortex.com/
 S: Supported
 F: drivers/scsi/gdt*
 
+GDB KERNEL DEBUGGING HELPER SCRIPTS
+M: Jan Kiszka 
+S: Supported
+F: scripts/gdb/
+
 GEMTEK FM RADIO RECEIVER DRIVER
 M: Hans Verkuil 
 L: linux-me...@vger.kernel.org
-- 
2.1.4

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


[PATCH v11 23/28] scripts/gdb: Ignore byte-compiled python files

2015-01-28 Thread Jan Kiszka
From: Daniel Thompson 

Using the gdb scripts leaves byte-compiled python files in the scripts/
directory. These should be ignored by git and cleaned up by mrproper.

Signed-off-by: Daniel Thompson 
Cc: Michal Marek 
Cc: linux-kbu...@vger.kernel.org
Signed-off-by: Jan Kiszka 
---
 .gitignore   | 1 +
 Makefile | 3 ++-
 scripts/gdb/linux/.gitignore | 2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)
 create mode 100644 scripts/gdb/linux/.gitignore

diff --git a/.gitignore b/.gitignore
index ce57b79..ecb89e3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,6 +43,7 @@ Module.symvers
 /TAGS
 /linux
 /vmlinux
+/vmlinux-gdb.py
 /vmlinuz
 /System.map
 /Module.markers
diff --git a/Makefile b/Makefile
index 6881ddf..ee7394e 100644
--- a/Makefile
+++ b/Makefile
@@ -1179,7 +1179,8 @@ MRPROPER_FILES += .config .config.old .version 
.old_version $(version_h) \
  Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
  signing_key.priv signing_key.x509 x509.genkey \
  extra_certificates signing_key.x509.keyid \
- signing_key.x509.signer vmlinux-gdb.py
+ signing_key.x509.signer vmlinux-gdb.py\
+ scripts/gdb/linux/*.py[co]
 
 # clean - Delete most, but leave enough to build external modules
 #
diff --git a/scripts/gdb/linux/.gitignore b/scripts/gdb/linux/.gitignore
new file mode 100644
index 000..52e4e61
--- /dev/null
+++ b/scripts/gdb/linux/.gitignore
@@ -0,0 +1,2 @@
+*.pyc
+*.pyo
-- 
2.1.4

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


Re: [PATCH V3 2/2] perf symbols: debuglink should take symfs option into account

2015-01-28 Thread Namhyung Kim
On Wed, Jan 28, 2015 at 08:08:30PM -0800, Victor Kamensky wrote:
> Hi  Namhyung,
> 
> On 28 January 2015 at 17:38, Namhyung Kim  wrote:
> > Hi Victor,
> >
> > On Mon, Jan 26, 2015 at 10:34:02PM -0800, Victor Kamensky wrote:
> >> Currently code that tries to read corresponding debug symbol
> >> file from .gnu_debuglink section (DSO_BINARY_TYPE__DEBUGLINK)
> >> does not take in account symfs option, so filename__read_debuglink
> >> function cannot open ELF file, if symfs option is used.
> >>
> >> Fix is to add proper handling of symfs as it is done in other
> >> places: use __symbol__join_symfs function to get real file name
> >> of target ELF file.
> >>
> >> Signed-off-by: Victor Kamensky 
> >> Cc: Peter Zijlstra 
> >> Cc: Paul Mackerras 
> >> Cc: Ingo Molnar 
> >> Cc: Arnaldo Carvalho de Melo 
> >> Cc: Jiri Olsa 
> >> Cc: Adrian Hunter 
> >> Cc: Waiman Long 
> >> Cc: David Ahern 
> >> Acked-and-tested-by: David Ahern 
> >
> > Acked-by: Namhyung Kim 
> 
> Thank you for the Acks! Is there any action items on my side?
> Should I repost patches with your Acks? Or you or Arnaldo
> will add them once they got merged in proper tree for
> upstreaming?

I think Arnaldo will merge them with Acks. ;-)

Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] g_NCR5380: Kill compiler warning if builtin

2015-01-28 Thread Finn Thain

Acked-by: Finn Thain 

On Sat, 3 Jan 2015, Geert Uytterhoeven wrote:

> If CONFIG_SCSI_GENERIC_NCR5380=y:
> 
> drivers/scsi/g_NCR5380.c:727: warning: ?id_table? defined but not used
> 
> In the non-modular case, MODULE_DEVICE_TABLE() expands to nothing, and
> id_table is not referenced.
> 
> Correct the existing #ifdef to fix this.
> 
> Signed-off-by: Geert Uytterhoeven 
> ---
>  drivers/scsi/g_NCR5380.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c
> index f35792f7051c0884..74ec2f5669aba5f5 100644
> --- a/drivers/scsi/g_NCR5380.c
> +++ b/drivers/scsi/g_NCR5380.c
> @@ -723,7 +723,7 @@ module_param(ncr_53c400a, int, 0);
>  module_param(dtc_3181e, int, 0);
>  MODULE_LICENSE("GPL");
>  
> -#ifndef SCSI_G_NCR5380_MEM
> +#if !defined(SCSI_G_NCR5380_MEM) && defined(MODULE)
>  static struct isapnp_device_id id_table[] = {
>   {
>ISAPNP_ANY_ID, ISAPNP_ANY_ID,
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 v11 01/28] scripts/gdb: Add infrastructure

2015-01-28 Thread Jan Kiszka
This provides the basic infrastructure to load kernel-specific python
helper scripts when debugging the kernel in gdb.

The loading mechanism is based on gdb loading for -gdb.py when
opening . Therefore, this places a corresponding link to the
main helper script into the output directory that contains vmlinux.

The main scripts will pull in submodules containing Linux specific gdb
commands and functions. To avoid polluting the source directory with
compiled python modules, we link to them from the object directory.

Due to gdb.parse_and_eval and string redirection for gdb.execute, we
depend on gdb >= 7.2.

This feature is enabled via CONFIG_GDB_SCRIPTS.

CC: Michal Marek 
CC: linux-kbu...@vger.kernel.org
Signed-off-by: Jan Kiszka 
---
 Makefile  |  5 -
 lib/Kconfig.debug | 11 +++
 scripts/Makefile  |  3 ++-
 scripts/gdb/Makefile  |  1 +
 scripts/gdb/linux/Makefile| 11 +++
 scripts/gdb/linux/__init__.py |  0
 scripts/gdb/vmlinux-gdb.py| 23 +++
 7 files changed, 52 insertions(+), 2 deletions(-)
 create mode 100644 scripts/gdb/Makefile
 create mode 100644 scripts/gdb/linux/Makefile
 create mode 100644 scripts/gdb/linux/__init__.py
 create mode 100644 scripts/gdb/vmlinux-gdb.py

diff --git a/Makefile b/Makefile
index 95a0e82..6881ddf 100644
--- a/Makefile
+++ b/Makefile
@@ -922,6 +922,9 @@ endif
 ifdef CONFIG_BUILD_DOCSRC
$(Q)$(MAKE) $(build)=Documentation
 endif
+ifdef CONFIG_GDB_SCRIPTS
+   $(Q)ln -fsn `cd $(srctree) && /bin/pwd`/scripts/gdb/vmlinux-gdb.py
+endif
+$(call if_changed,link-vmlinux)
 
 # The actual objects are generated when descending,
@@ -1176,7 +1179,7 @@ MRPROPER_FILES += .config .config.old .version 
.old_version $(version_h) \
  Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
  signing_key.priv signing_key.x509 x509.genkey \
  extra_certificates signing_key.x509.keyid \
- signing_key.x509.signer
+ signing_key.x509.signer vmlinux-gdb.py
 
 # clean - Delete most, but leave enough to build external modules
 #
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 5f2ce61..74984af 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -167,6 +167,17 @@ config DEBUG_INFO_DWARF4
  But it significantly improves the success of resolving
  variables in gdb on optimized code.
 
+config GDB_SCRIPTS
+   bool "Provide GDB scripts for kernel debugging"
+   select DEBUG_INFO
+   help
+ This creates the required links to GDB helper scripts in the
+ build directory. If you load vmlinux into gdb, the helper
+ scripts will be automatically imported by gdb as well, and
+ additional functions are available to analyze a Linux kernel
+ instance. See Documentation/gdb-kernel-debugging.txt for further
+ details.
+
 config ENABLE_WARN_DEPRECATED
bool "Enable __deprecated logic"
default y
diff --git a/scripts/Makefile b/scripts/Makefile
index 72902b5..7413b1b 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -36,6 +36,7 @@ subdir-$(CONFIG_MODVERSIONS) += genksyms
 subdir-y += mod
 subdir-$(CONFIG_SECURITY_SELINUX) += selinux
 subdir-$(CONFIG_DTC) += dtc
+subdir-$(CONFIG_GDB_SCRIPTS) += gdb
 
 # Let clean descend into subdirs
-subdir-+= basic kconfig package
+subdir-+= basic kconfig package gdb
diff --git a/scripts/gdb/Makefile b/scripts/gdb/Makefile
new file mode 100644
index 000..62f5f65
--- /dev/null
+++ b/scripts/gdb/Makefile
@@ -0,0 +1 @@
+subdir-y := linux
diff --git a/scripts/gdb/linux/Makefile b/scripts/gdb/linux/Makefile
new file mode 100644
index 000..dcb63ab
--- /dev/null
+++ b/scripts/gdb/linux/Makefile
@@ -0,0 +1,11 @@
+always := gdb-scripts
+
+SRCTREE := $(shell cd $(srctree) && /bin/pwd)
+
+$(obj)/gdb-scripts:
+ifneq ($(KBUILD_SRC),)
+   $(Q)ln -fsn $(SRCTREE)/$(obj)/*.py $(objtree)/$(obj)
+endif
+   @:
+
+clean-files := *.pyc $(if $(KBUILD_SRC),*.py)
diff --git a/scripts/gdb/linux/__init__.py b/scripts/gdb/linux/__init__.py
new file mode 100644
index 000..e69de29
diff --git a/scripts/gdb/vmlinux-gdb.py b/scripts/gdb/vmlinux-gdb.py
new file mode 100644
index 000..c1d90ce
--- /dev/null
+++ b/scripts/gdb/vmlinux-gdb.py
@@ -0,0 +1,23 @@
+#
+# gdb helper commands and functions for Linux kernel debugging
+#
+#  loader module
+#
+# Copyright (c) Siemens AG, 2012, 2013
+#
+# Authors:
+#  Jan Kiszka 
+#
+# This work is licensed under the terms of the GNU GPL version 2.
+#
+
+import os
+
+sys.path.insert(0, os.path.dirname(__file__) + "/scripts/gdb")
+
+try:
+gdb.parse_and_eval("0")
+gdb.execute("", to_string=True)
+except:
+gdb.write("NOTE: gdb 7.2 or later required for Linux helper scripts to "
+  "work.\n")
-- 
2.1.4

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

[PATCH v11 02/28] scripts/gdb: Add cache for type objects

2015-01-28 Thread Jan Kiszka
Type lookups are very slow in gdb-python which is often noticeable when
iterating over a number of objects. Introduce the helper class
CachedType that keeps a reference to a gdb.Type object but also
refreshes it after an object file has been loaded.

Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/utils.py | 34 ++
 1 file changed, 34 insertions(+)
 create mode 100644 scripts/gdb/linux/utils.py

diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py
new file mode 100644
index 000..f883611
--- /dev/null
+++ b/scripts/gdb/linux/utils.py
@@ -0,0 +1,34 @@
+#
+# gdb helper commands and functions for Linux kernel debugging
+#
+#  common utilities
+#
+# Copyright (c) Siemens AG, 2011-2013
+#
+# Authors:
+#  Jan Kiszka 
+#
+# This work is licensed under the terms of the GNU GPL version 2.
+#
+
+import gdb
+
+
+class CachedType:
+def __init__(self, name):
+self._type = None
+self._name = name
+
+def _new_objfile_handler(self, event):
+self._type = None
+gdb.events.new_objfile.disconnect(self._new_objfile_handler)
+
+def get_type(self):
+if self._type is None:
+self._type = gdb.lookup_type(self._name)
+if self._type is None:
+raise gdb.GdbError(
+"cannot resolve type '{0}'".format(self._name))
+if hasattr(gdb, 'events') and hasattr(gdb.events, 'new_objfile'):
+gdb.events.new_objfile.connect(self._new_objfile_handler)
+return self._type
-- 
2.1.4

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


[PATCH v11 15/28] scripts/gdb: Add internal helper and convenience function to retrieve thread_info

2015-01-28 Thread Jan Kiszka
Add the internal helper get_thread_info that calculates the thread_info
from a given task variable. Also export this service as a convenience
function.

Note: ia64 version is untested.

CC: Tony Luck 
CC: Fenghua Yu 
CC: linux-i...@vger.kernel.org
Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/tasks.py | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py
index 13bb97c..63cd6c5 100644
--- a/scripts/gdb/linux/tasks.py
+++ b/scripts/gdb/linux/tasks.py
@@ -71,3 +71,38 @@ return that task_struct variable which PID matches."""
 
 
 LxTaskByPidFunc()
+
+
+thread_info_type = utils.CachedType("struct thread_info")
+
+ia64_task_size = None
+
+
+def get_thread_info(task):
+global thread_info_type
+thread_info_ptr_type = thread_info_type.get_type().pointer()
+if utils.is_target_arch("ia64"):
+global ia64_task_size
+if ia64_task_size is None:
+ia64_task_size = gdb.parse_and_eval("sizeof(struct task_struct)")
+thread_info_addr = task.address + ia64_task_size
+thread_info = thread_info_addr.cast(thread_info_ptr_type)
+else:
+thread_info = task['stack'].cast(thread_info_ptr_type)
+return thread_info.dereference()
+
+
+class LxThreadInfoFunc (gdb.Function):
+"""Calculate Linux thread_info from task variable.
+
+$lx_thread_info(TASK): Given TASK, return the corresponding thread_info
+variable."""
+
+def __init__(self):
+super(LxThreadInfoFunc, self).__init__("lx_thread_info")
+
+def invoke(self, task):
+return get_thread_info(task)
+
+
+LxThreadInfoFunc()
-- 
2.1.4

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


Re: [PATCH v2 0/6] scsi: Some seq_file cleanups/optimizations

2015-01-28 Thread Finn Thain

I have one reservation about this patch series.

For example, the changes,

-   seq_printf(m, "%s", p);
+   seq_puts(m, p);

These calls are not equivalent because the bounds check is not the same. 
seq_puts will fail when m->count + strlen(p) == m->size.

seq_write() does the same check as seq_puts() but the other routines vary.

There's a similar situation with the changes,

-   seq_puts(m, "x");
+   seq_putc(m, 'x');

Have you considered what the implications might be? Are there any?

-- 

On Wed, 3 Dec 2014, Rasmus Villemoes wrote:

> These patches mostly replace seq_printf with simpler and faster
> equivalents, e.g. seq_printf(m, "something") => seq_puts(m,
> "something") and seq_printf(m, "\n") => seq_putc(m, '\n). But before
> my Coccinelle scripts could be unleashed I had to clean up an
> unnecessary macro.
> 
> The patches don't change the semantics of the code (well, that's the
> idea anyway), but should make it slightly smaller and faster.
> 
> v2: Redone on top of git://git.infradead.org/users/hch/scsi-queue.git 
> drivers-for-3.19
> 
> Rasmus Villemoes (6):
>   scsi: Remove SPRINTF macro
>   scsi/advansys: Replace seq_printf with seq_puts
>   scsi/aha152x: Replace seq_printf with seq_puts
>   scsi: misc:  Replace seq_printf with seq_puts
>   scsi: misc: Merge consecutive seq_puts calls
>   scsi: misc: Print single-character strings with seq_putc
> 
>  drivers/scsi/BusLogic.c |  10 +-
>  drivers/scsi/NCR5380.c  |  20 ++-
>  drivers/scsi/advansys.c | 142 -
>  drivers/scsi/aha152x.c  | 295 
> ++--
>  drivers/scsi/aic7xxx/aic79xx_proc.c |  38 +++--
>  drivers/scsi/aic7xxx/aic7xxx_proc.c |  24 +--
>  drivers/scsi/arm/fas216.c   |   6 +-
>  drivers/scsi/atari_NCR5380.c|   4 +-
>  drivers/scsi/atp870u.c  |   5 +-
>  drivers/scsi/dc395x.c   |  79 +-
>  drivers/scsi/dpt_i2o.c  |   2 +-
>  drivers/scsi/eata_pio.c |   2 +-
>  drivers/scsi/esas2r/esas2r_main.c   |   2 +-
>  drivers/scsi/gdth_proc.c|  24 +--
>  drivers/scsi/in2000.c   |  18 +--
>  drivers/scsi/ips.c  |   7 +-
>  drivers/scsi/megaraid.c |   2 +-
>  drivers/scsi/nsp32.c|  41 +++--
>  drivers/scsi/pcmcia/nsp_cs.c|  50 +++---
>  drivers/scsi/qla2xxx/qla_dfs.c  |   8 +-
>  drivers/scsi/scsi_proc.c|  22 +--
>  drivers/scsi/scsi_trace.c   |   6 +-
>  drivers/scsi/wd33c93.c  |  18 +--
>  drivers/scsi/wd7000.c   |  41 +++--
>  24 files changed, 412 insertions(+), 454 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 v11 24/28] scripts/gdb: Use a generator instead of iterator for task list

2015-01-28 Thread Jan Kiszka
From: Daniel Wagner 

The iterator does not return any task_struct from the thread_group list
because the first condition in the 'if not t or ...' will only be the
first time None.

Instead of keeping track of the state ourself in the next() function,
we fall back using Python's generator.

Signed-off-by: Daniel Wagner 
Cc: Jan Kiszka 
Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/tasks.py | 50 +++---
 1 file changed, 20 insertions(+), 30 deletions(-)

diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py
index 0008e75..e2037d9 100644
--- a/scripts/gdb/linux/tasks.py
+++ b/scripts/gdb/linux/tasks.py
@@ -18,38 +18,28 @@ from linux import utils
 
 task_type = utils.CachedType("struct task_struct")
 
-
-class TaskList:
-def __init__(self):
-global task_type
-self.task_ptr_type = task_type.get_type().pointer()
-self.init_task = gdb.parse_and_eval("init_task")
-self.curr_group = self.init_task.address
-self.curr_task = None
-
-def __iter__(self):
-return self
-
-def __next__(self):
-t = self.curr_task
-if not t or t == self.curr_group:
-self.curr_group = \
-utils.container_of(self.curr_group['tasks']['next'],
-   self.task_ptr_type, "tasks")
-if self.curr_group == self.init_task.address:
-raise StopIteration
-t = self.curr_task = self.curr_group
-else:
-self.curr_task = \
-utils.container_of(t['thread_group']['next'],
-   self.task_ptr_type, "thread_group")
-return t
-
-def next(self):
-return self.__next__()
+def task_lists():
+global task_type
+task_ptr_type = task_type.get_type().pointer()
+init_task = gdb.parse_and_eval("init_task").address
+t = g = init_task
+
+while True:
+while True:
+yield t
+
+t = utils.container_of(t['thread_group']['next'],
+   task_ptr_type, "thread_group")
+if t == g:
+break
+
+t = g = utils.container_of(g['tasks']['next'],
+   task_ptr_type, "tasks")
+if t == init_task:
+return
 
 def get_task_by_pid(pid):
-for task in TaskList():
+for task in task_lists():
 if int(task['pid']) == pid:
 return task
 return None
-- 
2.1.4

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


[PATCH v11 22/28] scripts/gdb: Port to python3 / gdb7.7

2015-01-28 Thread Jan Kiszka
From: Pantelis Koukousoulas 

I tried to use these scripts in an ubuntu 14.04 host (gdb 7.7 compiled
against python 3.3) but there were several errors.

I believe this patch fixes these issues so that the commands
now work (I tested lx-symbols, lx-dmesg, lx-lsmod).

Main issues that needed to be resolved:

  * In python 2 iterators have a "next()" method. In python 3 it is
__next__() instead (so let's just add both).

  * In older python versions there was an implicit conversion
in object.__format__() (used when an object is in string.format())
where it was converting the object to str first and then
calling str's __format__(). This has now been removed so
we must explicitly convert to str the objects for which
we need to keep this behavior.

  * In dmesg.py: in python 3 log_buf is now a "memoryview" object
which needs to be converted to a string in order to use string
methods like "splitlines()". Luckily memoryview exists in
python 2.7.6 as well, so we can convert log_buf to memoryview
and use the same code in both python 2 and python 3.

This version of the patch has now been tested with gdb 7.7 and
both python 3.4 and python 2.7.6 (I think asking for at least
python 2.7.6 is a reasonable requirement instead of complicating
the code with version checks etc).

Signed-off-by: Pantelis Koukousoulas 
Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/cpus.py| 5 -
 scripts/gdb/linux/dmesg.py   | 3 ++-
 scripts/gdb/linux/modules.py | 9 ++---
 scripts/gdb/linux/symbols.py | 4 ++--
 scripts/gdb/linux/tasks.py   | 4 +++-
 scripts/gdb/linux/utils.py   | 2 +-
 6 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py
index c1441f2..8045871 100644
--- a/scripts/gdb/linux/cpus.py
+++ b/scripts/gdb/linux/cpus.py
@@ -82,7 +82,7 @@ class CpuList():
 def __iter__(self):
 return self
 
-def next(self):
+def __next__(self):
 while self.bits == 0:
 self.entry += 1
 if self.entry == self.num_entries:
@@ -103,6 +103,9 @@ class CpuList():
 
 return cpu
 
+def next(self):
+return self.__next__()
+
 
 class PerCpu(gdb.Function):
 """Return per-cpu variable.
diff --git a/scripts/gdb/linux/dmesg.py b/scripts/gdb/linux/dmesg.py
index 7650f24..3c947f0 100644
--- a/scripts/gdb/linux/dmesg.py
+++ b/scripts/gdb/linux/dmesg.py
@@ -51,9 +51,10 @@ class LxDmesg(gdb.Command):
 continue
 
 text_len = utils.read_u16(log_buf[pos + 10:pos + 12])
+text = log_buf[pos + 16:pos + 16 + text_len]
 time_stamp = utils.read_u64(log_buf[pos:pos + 8])
 
-for line in log_buf[pos + 16:pos + 16 + text_len].splitlines():
+for line in memoryview(text).tobytes().splitlines():
 gdb.write("[{time:12.6f}] {line}\n".format(
 time=time_stamp / 10.0,
 line=line))
diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py
index e7c99e9..2dbf679 100644
--- a/scripts/gdb/linux/modules.py
+++ b/scripts/gdb/linux/modules.py
@@ -30,7 +30,7 @@ class ModuleList:
 def __iter__(self):
 return self
 
-def next(self):
+def __next__(self):
 entry = self.curr_entry
 if entry != self.end_of_list:
 self.curr_entry = entry['next']
@@ -38,6 +38,9 @@ class ModuleList:
 else:
 raise StopIteration
 
+def next(self):
+return self.__next__()
+
 
 def find_module_by_name(name):
 for module in ModuleList():
@@ -91,8 +94,8 @@ class LxLsmod(gdb.Command):
 gdb.write("{address} {name:<19} {size:>8}  {ref}".format(
 address=str(module['module_core']).split()[0],
 name=module['name'].string(),
-size=module['core_size'],
-ref=ref))
+size=str(module['core_size']),
+ref=str(ref)))
 
 source_list = module['source_list']
 t = self._module_use_type.get_type().pointer()
diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py
index 139841f..ae757fd 100644
--- a/scripts/gdb/linux/symbols.py
+++ b/scripts/gdb/linux/symbols.py
@@ -73,7 +73,7 @@ lx-symbols command."""
 
 def _get_module_file(self, module_name):
 module_pattern = ".*/{0}\.ko$".format(
-string.replace(module_name, "_", r"[_\-]"))
+module_name.replace("_", r"[_\-]"))
 for name in self.module_files:
 if re.match(module_pattern, name) and os.path.exists(name):
 return name
@@ -87,7 +87,7 @@ lx-symbols command."""
 attrs = sect_attrs['attrs']
 section_name_to_address = {
 attrs[n]['name'].string() : attrs[n]['address']
-for n in range(sect_attrs['nsections'])}
+for n in range(int(sect_attrs['nsections']))}
 args = []
 for section_name in 

[PATCH v11 06/28] module: Do not inline do_init_module

2015-01-28 Thread Jan Kiszka
This provides a reliable breakpoint target, required for automatic
symbol loading via the gdb helper command 'lx-symbols'.

CC: Rusty Russell 
Signed-off-by: Jan Kiszka 
---
 kernel/module.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index d856e96..2df6cec 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -3011,8 +3011,13 @@ static void do_free_init(struct rcu_head *head)
kfree(m);
 }
 
-/* This is where the real work happens */
-static int do_init_module(struct module *mod)
+/*
+ * This is where the real work happens.
+ *
+ * Keep it uninlined to provide a reliable breakpoint target, e.g. for the gdb
+ * helper command 'lx-symbols'.
+ */
+static noinline int do_init_module(struct module *mod)
 {
int ret = 0;
struct mod_initfree *freeinit;
-- 
2.1.4

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


[tip:x86/urgent] x86, microcode: Return error from driver init code when loader is disabled

2015-01-28 Thread tip-bot for Boris Ostrovsky
Commit-ID:  da63865a01c6384d459464e5165d95d4f04878d8
Gitweb: http://git.kernel.org/tip/da63865a01c6384d459464e5165d95d4f04878d8
Author: Boris Ostrovsky 
AuthorDate: Tue, 27 Jan 2015 21:21:09 -0500
Committer:  Borislav Petkov 
CommitDate: Wed, 28 Jan 2015 09:23:40 +0100

x86, microcode: Return error from driver init code when loader is disabled

Commits 65cef1311d5d ("x86, microcode: Add a disable chicken bit") and
a18a0f6850d4 ("x86, microcode: Don't initialize microcode code on
paravirt") allow microcode driver skip initialization when microcode
loading is not permitted.

However, they don't prevent the driver from being loaded since the
init code returns 0. If at some point later the driver gets unloaded
this will result in an oops while trying to deregister the (never
registered) device.

To avoid this, make init code return an error on paravirt or when
microcode loading is disabled. The driver will then never be loaded.

Signed-off-by: Boris Ostrovsky 
Link: 
http://lkml.kernel.org/r/1422411669-25147-1-git-send-email-boris.ostrov...@oracle.com
Reported-by: James Digwall 
Cc: sta...@vger.kernel.org # 3.18
Signed-off-by: Borislav Petkov 
---
 arch/x86/kernel/cpu/microcode/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c 
b/arch/x86/kernel/cpu/microcode/core.c
index 15c2909..36a8361 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -552,7 +552,7 @@ static int __init microcode_init(void)
int error;
 
if (paravirt_enabled() || dis_ucode_ldr)
-   return 0;
+   return -EINVAL;
 
if (c->x86_vendor == X86_VENDOR_INTEL)
microcode_ops = init_intel_microcode();
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 v11 21/28] scripts/gdb: Add basic documentation

2015-01-28 Thread Jan Kiszka
CC: Rob Landley 
CC: linux-...@vger.kernel.org
Signed-off-by: Jan Kiszka 
---
 Documentation/gdb-kernel-debugging.txt | 160 +
 1 file changed, 160 insertions(+)
 create mode 100644 Documentation/gdb-kernel-debugging.txt

diff --git a/Documentation/gdb-kernel-debugging.txt 
b/Documentation/gdb-kernel-debugging.txt
new file mode 100644
index 000..7050ce8
--- /dev/null
+++ b/Documentation/gdb-kernel-debugging.txt
@@ -0,0 +1,160 @@
+Debugging kernel and modules via gdb
+
+
+The kernel debugger kgdb, hypervisors like QEMU or JTAG-based hardware
+interfaces allow to debug the Linux kernel and its modules during runtime
+using gdb. Gdb comes with a powerful scripting interface for python. The
+kernel provides a collection of helper scripts that can simplify typical
+kernel debugging steps. This is a short tutorial about how to enable and use
+them. It focuses on QEMU/KVM virtual machines as target, but the examples can
+be transferred to the other gdb stubs as well.
+
+
+Requirements
+
+
+ o gdb 7.2+ (recommended: 7.4+) with python support enabled (typically true
+   for distributions)
+
+
+Setup
+-
+
+ o Create a virtual Linux machine for QEMU/KVM (see www.linux-kvm.org and
+   www.qemu.org for more details). For cross-development,
+   http://landley.net/aboriginal/bin keeps a pool of machine images and
+   toolchains that can be helpful to start from.
+
+ o Build the kernel with CONFIG_GDB_SCRIPTS enabled, but leave
+   CONFIG_DEBUG_INFO_REDUCED off. If your architecture supports
+   CONFIG_FRAME_POINTER, keep it enabled.
+
+ o Install that kernel on the guest.
+
+   Alternatively, QEMU allows to boot the kernel directly using -kernel,
+   -append, -initrd command line switches. This is generally only useful if
+   you do not depend on modules. See QEMU documentation for more details on
+   this mode.
+
+ o Enable the gdb stub of QEMU/KVM, either
+- at VM startup time by appending "-s" to the QEMU command line
+   or
+- during runtime by issuing "gdbserver" from the QEMU monitor
+  console
+
+ o cd /path/to/linux-build
+
+ o Start gdb: gdb vmlinux
+
+   Note: Some distros may restrict auto-loading of gdb scripts to known safe
+   directories. In case gdb reports to refuse loading vmlinux-gdb.py, add
+
+add-auto-load-safe-path /path/to/linux-build
+
+   to ~/.gdbinit. See gdb help for more details.
+
+ o Attach to the booted guest:
+(gdb) target remote :1234
+
+
+Examples of using the Linux-provided gdb helpers
+
+
+ o Load module (and main kernel) symbols:
+(gdb) lx-symbols
+loading vmlinux
+scanning for modules in /home/user/linux/build
+loading @0xa002: 
/home/user/linux/build/net/netfilter/xt_tcpudp.ko
+loading @0xa0016000: 
/home/user/linux/build/net/netfilter/xt_pkttype.ko
+loading @0xa0002000: 
/home/user/linux/build/net/netfilter/xt_limit.ko
+loading @0xa00ca000: /home/user/linux/build/net/packet/af_packet.ko
+loading @0xa003c000: /home/user/linux/build/fs/fuse/fuse.ko
+...
+loading @0xa000: 
/home/user/linux/build/drivers/ata/ata_generic.ko
+
+ o Set a breakpoint on some not yet loaded module function, e.g.:
+(gdb) b btrfs_init_sysfs
+Function "btrfs_init_sysfs" not defined.
+Make breakpoint pending on future shared library load? (y or [n]) y
+Breakpoint 1 (btrfs_init_sysfs) pending.
+
+ o Continue the target
+(gdb) c
+
+ o Load the module on the target and watch the symbols being loaded as well as
+   the breakpoint hit:
+loading @0xa0034000: /home/user/linux/build/lib/libcrc32c.ko
+loading @0xa005: /home/user/linux/build/lib/lzo/lzo_compress.ko
+loading @0xa006e000: 
/home/user/linux/build/lib/zlib_deflate/zlib_deflate.ko
+loading @0xa01b1000: /home/user/linux/build/fs/btrfs/btrfs.ko
+
+Breakpoint 1, btrfs_init_sysfs () at /home/user/linux/fs/btrfs/sysfs.c:36
+36  btrfs_kset = kset_create_and_add("btrfs", NULL, fs_kobj);
+
+ o Dump the log buffer of the target kernel:
+(gdb) lx-dmesg
+[ 0.00] Initializing cgroup subsys cpuset
+[ 0.00] Initializing cgroup subsys cpu
+[ 0.00] Linux version 3.8.0-rc4-dbg+ (...
+[ 0.00] Command line: root=/dev/sda2 resume=/dev/sda1 vga=0x314
+[ 0.00] e820: BIOS-provided physical RAM map:
+[ 0.00] BIOS-e820: [mem 0x-0x0009fbff] 
usable
+[ 0.00] BIOS-e820: [mem 0x0009fc00-0x0009] 
reserved
+
+
+ o Examine fields of the current task struct:
+(gdb) p $lx_current().pid
+$1 = 4998
+(gdb) p $lx_current().comm
+$2 = "modprobe\000\000\000\000\000\000\000"
+
+ o Make use of the per-cpu function for the current or a specified CPU:
+(gdb) p $lx_per_cpu("runqueues").nr_running
+$3 = 1

Re: [PATCH 17/28] scsi: drop owner assignment from platform_drivers

2015-01-28 Thread Finn Thain

Acked-by: Finn Thain 

On Sun, 21 Dec 2014, Wolfram Sang wrote:

> This platform_driver does not need to set an owner, it will be populated by 
> the
> driver core.
> 
> Signed-off-by: Wolfram Sang 
> ---
> Generated with coccinelle. SmPL file is in the introductory msg. The big
> cleanup was pulled in this merge window. This series catches the bits fallen
> through. The patches shall go in via the subsystem trees.
> 
>  drivers/scsi/atari_scsi.c | 1 -
>  drivers/scsi/mac_scsi.c   | 1 -
>  drivers/scsi/sun3_scsi.c  | 1 -
>  3 files changed, 3 deletions(-)
> 
> diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c
> index d1c37a386947..5ede3daa93dc 100644
> --- a/drivers/scsi/atari_scsi.c
> +++ b/drivers/scsi/atari_scsi.c
> @@ -1014,7 +1014,6 @@ static struct platform_driver atari_scsi_driver = {
>   .remove = __exit_p(atari_scsi_remove),
>   .driver = {
>   .name   = DRV_MODULE_NAME,
> - .owner  = THIS_MODULE,
>   },
>  };
>  
> diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c
> index 1e85c07e3b62..d64a769b8155 100644
> --- a/drivers/scsi/mac_scsi.c
> +++ b/drivers/scsi/mac_scsi.c
> @@ -483,7 +483,6 @@ static struct platform_driver mac_scsi_driver = {
>   .remove = __exit_p(mac_scsi_remove),
>   .driver = {
>   .name   = DRV_MODULE_NAME,
> - .owner  = THIS_MODULE,
>   },
>  };
>  
> diff --git a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c
> index 2a906d1d34ba..22a42836d193 100644
> --- a/drivers/scsi/sun3_scsi.c
> +++ b/drivers/scsi/sun3_scsi.c
> @@ -676,7 +676,6 @@ static struct platform_driver sun3_scsi_driver = {
>   .remove = __exit_p(sun3_scsi_remove),
>   .driver = {
>   .name   = DRV_MODULE_NAME,
> - .owner  = THIS_MODULE,
>   },
>  };
>  
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 v11 11/28] scripts/gdb: Add lx-dmesg command

2015-01-28 Thread Jan Kiszka
This pokes into the log buffer of the debugged kernel, dumping it to the
gdb console. Helping in case the target should or can no longer execute
dmesg itself.

CC: Kay Sievers 
Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/dmesg.py | 64 ++
 scripts/gdb/vmlinux-gdb.py |  1 +
 2 files changed, 65 insertions(+)
 create mode 100644 scripts/gdb/linux/dmesg.py

diff --git a/scripts/gdb/linux/dmesg.py b/scripts/gdb/linux/dmesg.py
new file mode 100644
index 000..7650f24
--- /dev/null
+++ b/scripts/gdb/linux/dmesg.py
@@ -0,0 +1,64 @@
+#
+# gdb helper commands and functions for Linux kernel debugging
+#
+#  kernel log buffer dump
+#
+# Copyright (c) Siemens AG, 2011, 2012
+#
+# Authors:
+#  Jan Kiszka 
+#
+# This work is licensed under the terms of the GNU GPL version 2.
+#
+
+import gdb
+import string
+
+from linux import utils
+
+
+class LxDmesg(gdb.Command):
+"""Print Linux kernel log buffer."""
+
+def __init__(self):
+super(LxDmesg, self).__init__("lx-dmesg", gdb.COMMAND_DATA)
+
+def invoke(self, arg, from_tty):
+log_buf_addr = int(str(gdb.parse_and_eval("log_buf")).split()[0], 16)
+log_first_idx = int(gdb.parse_and_eval("log_first_idx"))
+log_next_idx = int(gdb.parse_and_eval("log_next_idx"))
+log_buf_len = int(gdb.parse_and_eval("log_buf_len"))
+
+inf = gdb.inferiors()[0]
+start = log_buf_addr + log_first_idx
+if log_first_idx < log_next_idx:
+log_buf_2nd_half = -1
+length = log_next_idx - log_first_idx
+log_buf = inf.read_memory(start, length)
+else:
+log_buf_2nd_half = log_buf_len - log_first_idx
+log_buf = inf.read_memory(start, log_buf_2nd_half) + \
+inf.read_memory(log_buf_addr, log_next_idx)
+
+pos = 0
+while pos < log_buf.__len__():
+length = utils.read_u16(log_buf[pos + 8:pos + 10])
+if length == 0:
+if log_buf_2nd_half == -1:
+gdb.write("Corrupted log buffer!\n")
+break
+pos = log_buf_2nd_half
+continue
+
+text_len = utils.read_u16(log_buf[pos + 10:pos + 12])
+time_stamp = utils.read_u64(log_buf[pos:pos + 8])
+
+for line in log_buf[pos + 16:pos + 16 + text_len].splitlines():
+gdb.write("[{time:12.6f}] {line}\n".format(
+time=time_stamp / 10.0,
+line=line))
+
+pos += length
+
+
+LxDmesg()
diff --git a/scripts/gdb/vmlinux-gdb.py b/scripts/gdb/vmlinux-gdb.py
index cf2e716..fa66d23 100644
--- a/scripts/gdb/vmlinux-gdb.py
+++ b/scripts/gdb/vmlinux-gdb.py
@@ -25,3 +25,4 @@ else:
 import linux.utils
 import linux.symbols
 import linux.modules
+import linux.dmesg
-- 
2.1.4

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


[PATCH v11 03/28] scripts/gdb: Add container_of helper and convenience function

2015-01-28 Thread Jan Kiszka
Provide an internal helper with container_of semantics. As type lookups
are very slow in gdb-python and we need a type "long" for this, cache
the reference to this type object. Then export the helper also as a
convenience function form use at the gdb command line.

Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/utils.py | 35 +++
 scripts/gdb/vmlinux-gdb.py |  2 ++
 2 files changed, 37 insertions(+)

diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py
index f883611..c9d705b 100644
--- a/scripts/gdb/linux/utils.py
+++ b/scripts/gdb/linux/utils.py
@@ -32,3 +32,38 @@ class CachedType:
 if hasattr(gdb, 'events') and hasattr(gdb.events, 'new_objfile'):
 gdb.events.new_objfile.connect(self._new_objfile_handler)
 return self._type
+
+
+long_type = CachedType("long")
+
+
+def get_long_type():
+global long_type
+return long_type.get_type()
+
+
+def offset_of(typeobj, field):
+element = gdb.Value(0).cast(typeobj)
+return int(str(element[field].address).split()[0], 16)
+
+
+def container_of(ptr, typeobj, member):
+return (ptr.cast(get_long_type()) -
+offset_of(typeobj, member)).cast(typeobj)
+
+
+class ContainerOf(gdb.Function):
+"""Return pointer to containing data structure.
+
+$container_of(PTR, "TYPE", "ELEMENT"): Given PTR, return a pointer to the
+data structure of the type TYPE in which PTR is the address of ELEMENT.
+Note that TYPE and ELEMENT have to be quoted as strings."""
+
+def __init__(self):
+super(ContainerOf, self).__init__("container_of")
+
+def invoke(self, ptr, typename, elementname):
+return container_of(ptr, gdb.lookup_type(typename.string()).pointer(),
+elementname.string())
+
+ContainerOf()
diff --git a/scripts/gdb/vmlinux-gdb.py b/scripts/gdb/vmlinux-gdb.py
index c1d90ce..6495841 100644
--- a/scripts/gdb/vmlinux-gdb.py
+++ b/scripts/gdb/vmlinux-gdb.py
@@ -21,3 +21,5 @@ try:
 except:
 gdb.write("NOTE: gdb 7.2 or later required for Linux helper scripts to "
   "work.\n")
+else:
+import linux.utils
-- 
2.1.4

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


[PATCH v11 17/28] scripts/gdb: Add internal helper and convenience function for per-cpu lookup

2015-01-28 Thread Jan Kiszka
This function allows to obtain a per-cpu variable, either of the current
or an explicitly specified CPU.

Note: sparc64 version is untested.

CC: "David S. Miller" 
CC: sparcli...@vger.kernel.org
Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/cpus.py  | 68 ++
 scripts/gdb/vmlinux-gdb.py |  1 +
 2 files changed, 69 insertions(+)
 create mode 100644 scripts/gdb/linux/cpus.py

diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py
new file mode 100644
index 000..18337e0
--- /dev/null
+++ b/scripts/gdb/linux/cpus.py
@@ -0,0 +1,68 @@
+#
+# gdb helper commands and functions for Linux kernel debugging
+#
+#  per-cpu tools
+#
+# Copyright (c) Siemens AG, 2011-2013
+#
+# Authors:
+#  Jan Kiszka 
+#
+# This work is licensed under the terms of the GNU GPL version 2.
+#
+
+import gdb
+
+from linux import tasks, utils
+
+
+MAX_CPUS = 4096
+
+
+def get_current_cpu():
+if utils.get_gdbserver_type() == utils.GDBSERVER_QEMU:
+return gdb.selected_thread().num - 1
+elif utils.get_gdbserver_type() == utils.GDBSERVER_KGDB:
+tid = gdb.selected_thread().ptid[2]
+if tid > (0x1 - MAX_CPUS - 2):
+return 0x1 - tid - 2
+else:
+return tasks.get_thread_info(tasks.get_task_by_pid(tid))['cpu']
+else:
+raise gdb.GdbError("Sorry, obtaining the current CPU is not yet "
+   "supported with this gdb server.")
+
+
+def per_cpu(var_ptr, cpu):
+if cpu == -1:
+cpu = get_current_cpu()
+if utils.is_target_arch("sparc:v9"):
+offset = gdb.parse_and_eval(
+"trap_block[{0}].__per_cpu_base".format(str(cpu)))
+else:
+try:
+offset = gdb.parse_and_eval(
+"__per_cpu_offset[{0}]".format(str(cpu)))
+except gdb.error:
+# !CONFIG_SMP case
+offset = 0
+pointer = var_ptr.cast(utils.get_long_type()) + offset
+return pointer.cast(var_ptr.type).dereference()
+
+
+class PerCpu(gdb.Function):
+"""Return per-cpu variable.
+
+$lx_per_cpu("VAR"[, CPU]): Return the per-cpu variable called VAR for the
+given CPU number. If CPU is omitted, the CPU of the current context is used.
+Note that VAR has to be quoted as string."""
+
+def __init__(self):
+super(PerCpu, self).__init__("lx_per_cpu")
+
+def invoke(self, var_name, cpu=-1):
+var_ptr = gdb.parse_and_eval("&" + var_name.string())
+return per_cpu(var_ptr, cpu)
+
+
+PerCpu()
diff --git a/scripts/gdb/vmlinux-gdb.py b/scripts/gdb/vmlinux-gdb.py
index 4d7eb2c..4848928 100644
--- a/scripts/gdb/vmlinux-gdb.py
+++ b/scripts/gdb/vmlinux-gdb.py
@@ -27,3 +27,4 @@ else:
 import linux.modules
 import linux.dmesg
 import linux.tasks
+import linux.cpus
-- 
2.1.4

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


[PATCH v11 20/28] scripts/gdb: Add lx-lsmod command

2015-01-28 Thread Jan Kiszka
This adds a lsmod-like command to list all currently loaded modules of
the target.

Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/modules.py | 46 +++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py
index 531f763..e7c99e9 100644
--- a/scripts/gdb/linux/modules.py
+++ b/scripts/gdb/linux/modules.py
@@ -13,7 +13,7 @@
 
 import gdb
 
-from linux import utils
+from linux import cpus, utils
 
 
 module_type = utils.CachedType("struct module")
@@ -65,3 +65,47 @@ of the target and return that module variable which MODULE 
matches."""
 
 
 LxModule()
+
+
+class LxLsmod(gdb.Command):
+"""List currently loaded modules."""
+
+_module_use_type = utils.CachedType("struct module_use")
+
+def __init__(self):
+super(LxLsmod, self).__init__("lx-lsmod", gdb.COMMAND_DATA)
+
+def invoke(self, arg, from_tty):
+gdb.write(
+"Address{0}Module  Size  Used by\n".format(
+"" if utils.get_long_type().sizeof == 8 else ""))
+
+for module in ModuleList():
+ref = 0
+module_refptr = module['refptr']
+for cpu in cpus.CpuList("cpu_possible_mask"):
+refptr = cpus.per_cpu(module_refptr, cpu)
+ref += refptr['incs']
+ref -= refptr['decs']
+
+gdb.write("{address} {name:<19} {size:>8}  {ref}".format(
+address=str(module['module_core']).split()[0],
+name=module['name'].string(),
+size=module['core_size'],
+ref=ref))
+
+source_list = module['source_list']
+t = self._module_use_type.get_type().pointer()
+entry = source_list['next']
+first = True
+while entry != source_list.address:
+use = utils.container_of(entry, t, "source_list")
+gdb.write("{separator}{name}".format(
+separator=" " if first else ",",
+name=use['source']['name'].string()))
+first = False
+entry = entry['next']
+gdb.write("\n")
+
+
+LxLsmod()
-- 
2.1.4

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


[PATCH v11 19/28] scripts/gdb: Add class to iterate over CPU masks

2015-01-28 Thread Jan Kiszka
Will be used first to count module references. It is optimized to read
the mask only once per stop.

Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/cpus.py | 54 +++
 1 file changed, 54 insertions(+)

diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py
index b683da9..c1441f2 100644
--- a/scripts/gdb/linux/cpus.py
+++ b/scripts/gdb/linux/cpus.py
@@ -50,6 +50,60 @@ def per_cpu(var_ptr, cpu):
 return pointer.cast(var_ptr.type).dereference()
 
 
+cpu_mask = {}
+
+
+def cpu_mask_invalidate(event):
+global cpu_mask
+cpu_mask = {}
+gdb.events.stop.disconnect(cpu_mask_invalidate)
+if hasattr(gdb.events, 'new_objfile'):
+gdb.events.new_objfile.disconnect(cpu_mask_invalidate)
+
+
+class CpuList():
+def __init__(self, mask_name):
+global cpu_mask
+self.mask = None
+if mask_name in cpu_mask:
+self.mask = cpu_mask[mask_name]
+if self.mask is None:
+self.mask = gdb.parse_and_eval(mask_name + ".bits")
+if hasattr(gdb, 'events'):
+cpu_mask[mask_name] = self.mask
+gdb.events.stop.connect(cpu_mask_invalidate)
+if hasattr(gdb.events, 'new_objfile'):
+gdb.events.new_objfile.connect(cpu_mask_invalidate)
+self.bits_per_entry = self.mask[0].type.sizeof * 8
+self.num_entries = self.mask.type.sizeof * 8 / self.bits_per_entry
+self.entry = -1
+self.bits = 0
+
+def __iter__(self):
+return self
+
+def next(self):
+while self.bits == 0:
+self.entry += 1
+if self.entry == self.num_entries:
+raise StopIteration
+self.bits = self.mask[self.entry]
+if self.bits != 0:
+self.bit = 0
+break
+
+while self.bits & 1 == 0:
+self.bits >>= 1
+self.bit += 1
+
+cpu = self.entry * self.bits_per_entry + self.bit
+
+self.bits >>= 1
+self.bit += 1
+
+return cpu
+
+
 class PerCpu(gdb.Function):
 """Return per-cpu variable.
 
-- 
2.1.4

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


[PATCH v11 09/28] scripts/gdb: Add get_target_endianness helper

2015-01-28 Thread Jan Kiszka
Parse the target endianness from the output of "show endian" and cache
the result to return it via the new helper get_target_endiannes. We will
need it for reading integers from buffers that contain target memory.

Signed-off-by: Jan Kiszka 
---
 scripts/gdb/linux/utils.py | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py
index c9d705b..10a227b 100644
--- a/scripts/gdb/linux/utils.py
+++ b/scripts/gdb/linux/utils.py
@@ -67,3 +67,21 @@ Note that TYPE and ELEMENT have to be quoted as strings."""
 elementname.string())
 
 ContainerOf()
+
+
+BIG_ENDIAN = 0
+LITTLE_ENDIAN = 1
+target_endianness = None
+
+
+def get_target_endianness():
+global target_endianness
+if target_endianness is None:
+endian = gdb.execute("show endian", to_string=True)
+if "little endian" in endian:
+target_endianness = LITTLE_ENDIAN
+elif "big endian" in endian:
+target_endianness = BIG_ENDIAN
+else:
+raise gdb.GdgError("unknown endianness '{0}'".format(endian))
+return target_endianness
-- 
2.1.4

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


[PATCH v11 00/28] Add gdb python scripts as kernel debugging helpers

2015-01-28 Thread Jan Kiszka
Hi Andrew,

here comes the requested update of the series.

Changes since v10:
 - rebase over recent Linus master (rc6+)
 - fix stuck gdb pagination during modprobe related symbol reloading

See http://lkml.indiana.edu/hypermail/linux/kernel/1210.0/01598.html for
the original description and

git://git.kiszka.org/linux.git queues/gdb-scripts

for the latest version.

On the gdb upstream front there is good and bad news again. The good
news is that the regression reported in the last round was fixed now
[1]. The bad news is that upcoming 7.9 has a new regression that is even
causing a crash of the target kernel [2]. So the recommendation is still
to stick with gdb 7.7.

Jan

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=17642
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=17837

CC: Daniel Thompson 
CC: Daniel Wagner 
CC: "David S. Miller" 
CC: Fenghua Yu 
Cc: Jan Kiszka 
CC: Kay Sievers 
CC: linux-...@vger.kernel.org
CC: linux-i...@vger.kernel.org
Cc: linux-kbu...@vger.kernel.org
CC: linux-kbu...@vger.kernel.org
Cc: Michal Marek 
CC: Michal Marek 
CC: Pantelis Koukousoulas 
CC: Rob Landley 
CC: Rusty Russell 
CC: sparcli...@vger.kernel.org
CC: Tony Luck 

Daniel Thompson (1):
  scripts/gdb: Ignore byte-compiled python files

Daniel Wagner (1):
  scripts/gdb: Use a generator instead of iterator for task list

Jan Kiszka (25):
  scripts/gdb: Add infrastructure
  scripts/gdb: Add cache for type objects
  scripts/gdb: Add container_of helper and convenience function
  scripts/gdb: Add module iteration class
  scripts/gdb: Add lx-symbols command
  module: Do not inline do_init_module
  scripts/gdb: Add automatic symbol reloading on module insertion
  scripts/gdb: Add internal helper and convenience function to look up a
module
  scripts/gdb: Add get_target_endianness helper
  scripts/gdb: Add read_u16/32/64 helpers
  scripts/gdb: Add lx-dmesg command
  scripts/gdb: Add task iteration class
  scripts/gdb: Add helper and convenience function to look up tasks
  scripts/gdb: Add is_target_arch helper
  scripts/gdb: Add internal helper and convenience function to retrieve
thread_info
  scripts/gdb: Add get_gdbserver_type helper
  scripts/gdb: Add internal helper and convenience function for per-cpu
lookup
  scripts/gdb: Add lx_current convenience function
  scripts/gdb: Add class to iterate over CPU masks
  scripts/gdb: Add lx-lsmod command
  scripts/gdb: Add basic documentation
  scripts/gdb: Convert ModuleList to generator function
  scripts/gdb: Convert CpuList to generator function
  scripts/gdb: Define maintainer
  scripts/gdb: Disable pagination while printing from breakpoint handler

Pantelis Koukousoulas (1):
  scripts/gdb: Port to python3 / gdb7.7

 .gitignore |   1 +
 Documentation/gdb-kernel-debugging.txt | 160 +
 MAINTAINERS|   5 +
 Makefile   |   6 +-
 kernel/module.c|   9 +-
 lib/Kconfig.debug  |  11 ++
 scripts/Makefile   |   3 +-
 scripts/gdb/Makefile   |   1 +
 scripts/gdb/linux/.gitignore   |   2 +
 scripts/gdb/linux/Makefile |  11 ++
 scripts/gdb/linux/__init__.py  |   0
 scripts/gdb/linux/cpus.py  | 135 +
 scripts/gdb/linux/dmesg.py |  65 
 scripts/gdb/linux/modules.py   | 103 +++
 scripts/gdb/linux/symbols.py   | 177 +
 scripts/gdb/linux/tasks.py | 100 +++
 scripts/gdb/linux/utils.py | 156 +
 scripts/gdb/vmlinux-gdb.py |  30 ++
 18 files changed, 971 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/gdb-kernel-debugging.txt
 create mode 100644 scripts/gdb/Makefile
 create mode 100644 scripts/gdb/linux/.gitignore
 create mode 100644 scripts/gdb/linux/Makefile
 create mode 100644 scripts/gdb/linux/__init__.py
 create mode 100644 scripts/gdb/linux/cpus.py
 create mode 100644 scripts/gdb/linux/dmesg.py
 create mode 100644 scripts/gdb/linux/modules.py
 create mode 100644 scripts/gdb/linux/symbols.py
 create mode 100644 scripts/gdb/linux/tasks.py
 create mode 100644 scripts/gdb/linux/utils.py
 create mode 100644 scripts/gdb/vmlinux-gdb.py

-- 
2.1.4

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


Re: [GIT PULL] A microcode loader fix for 3.19

2015-01-28 Thread Ingo Molnar

* Borislav Petkov  wrote:

> Hi guys,
> 
> please pull this last small fix for the microcode loader not erroring
> out of its init routine properly.
> 
> Optimally, it should go with the last batch of tip/urgent stuff for
> 3.19, if possible.
> 
> Thanks.
> 
> ---
> The following changes since commit 26bc420b59a38e4e6685a73345a0def461136dce:
> 
>   Linux 3.19-rc6 (2015-01-25 20:04:41 -0800)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git 
> tags/microcode_fix_for_3.19
> 
> for you to fetch changes up to da63865a01c6384d459464e5165d95d4f04878d8:
> 
>   x86, microcode: Return error from driver init code when loader is disabled 
> (2015-01-28 09:23:40 +0100)
> 
> 
> One final fix for 3.19 to address a wrongful deregistering of the
> microcode loader module.
> 
> 
> Boris Ostrovsky (1):
>   x86, microcode: Return error from driver init code when loader is 
> disabled
> 
>  arch/x86/kernel/cpu/microcode/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/cpu/microcode/core.c 
> b/arch/x86/kernel/cpu/microcode/core.c
> index 15c29096136b..36a83617eb21 100644
> --- a/arch/x86/kernel/cpu/microcode/core.c
> +++ b/arch/x86/kernel/cpu/microcode/core.c
> @@ -552,7 +552,7 @@ static int __init microcode_init(void)
>   int error;
>  
>   if (paravirt_enabled() || dis_ucode_ldr)
> - return 0;
> + return -EINVAL;
>  
>   if (c->x86_vendor == X86_VENDOR_INTEL)
>   microcode_ops = init_intel_microcode();

Pulled into tip:x86/urgent, thanks Boris!

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


[PATCH v5 13/13] pm: at91: amend the pm_suspend entry for at91_cpuidle_device

2015-01-28 Thread Wenyou Yang
Because the at91_xxx_standby() function is substitued by the at91_pm_suspend(),
the pm_suspend entry for at91_cpuidle_device changes as well.

Signed-off-by: Wenyou Yang 
Acked-by: Alexandre Belloni 
---
 arch/arm/mach-at91/pm.c |   16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index f915f4b..657b9ba 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -41,7 +41,6 @@ static struct {
int memctrl;
 } at91_pm_data;
 
-static void (*at91_pm_standby)(void);
 void __iomem *at91_ramc_base[2];
 
 static int at91_pm_valid_state(suspend_state_t state)
@@ -216,12 +215,15 @@ static struct platform_device at91_cpuidle_device = {
.name = "cpuidle-at91",
 };
 
-void at91_pm_set_standby(void (*at91_standby)(void))
+static void at91_cpuidle_set_suspend(void (*at91_suspend)(void))
 {
-   if (at91_standby) {
-   at91_cpuidle_device.dev.platform_data = at91_standby;
-   at91_pm_standby = at91_standby;
-   }
+   if (at91_suspend)
+   at91_cpuidle_device.dev.platform_data = at91_suspend;
+}
+
+static void at91_cpuidle_suspend(void)
+{
+   at91_pm_suspend(PM_SUSPEND_STANDBY);
 }
 
 static struct of_device_id ramc_ids[] = {
@@ -298,6 +300,8 @@ static void __init at91_pm_init(void)
 {
at91_pm_sram_init();
 
+   at91_cpuidle_set_suspend(at91_cpuidle_suspend);
+
if (at91_cpuidle_device.dev.platform_data)
platform_device_register(_cpuidle_device);
 
-- 
1.7.9.5

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


[PATCH v5 12/13] pm: at91: remove the data member at91_xxx_standby() of struct ramc_ids

2015-01-28 Thread Wenyou Yang
Because the at91_xxx_standby() function is removed,
remove the data member of struct ramc_ids.

Signed-off-by: Wenyou Yang 
Acked-by: Alexandre Belloni 
---
 arch/arm/mach-at91/pm.c |   19 ---
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index ce15013..f915f4b 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -225,10 +225,10 @@ void at91_pm_set_standby(void (*at91_standby)(void))
 }
 
 static struct of_device_id ramc_ids[] = {
-   { .compatible = "atmel,at91rm9200-sdramc", .data = at91rm9200_standby },
-   { .compatible = "atmel,at91sam9260-sdramc", .data = 
at91sam9_sdram_standby },
-   { .compatible = "atmel,at91sam9g45-ddramc", .data = at91_ddr_standby },
-   { .compatible = "atmel,sama5d3-ddramc", .data = at91_ddr_standby },
+   { .compatible = "atmel,at91rm9200-sdramc" },
+   { .compatible = "atmel,at91sam9260-sdramc" },
+   { .compatible = "atmel,at91sam9g45-ddramc" },
+   { .compatible = "atmel,sama5d3-ddramc" },
{ /*sentinel*/ }
 };
 
@@ -237,28 +237,17 @@ static void at91_dt_ramc(void)
struct device_node *np;
const struct of_device_id *of_id;
int idx = 0;
-   const void *standby = NULL;
 
for_each_matching_node_and_match(np, ramc_ids, _id) {
at91_ramc_base[idx] = of_iomap(np, 0);
if (!at91_ramc_base[idx])
panic(pr_fmt("unable to map ramc[%d] cpu registers\n"), 
idx);
 
-   if (!standby)
-   standby = of_id->data;
-
idx++;
}
 
if (!idx)
panic(pr_fmt("unable to find compatible ram controller node in 
dtb\n"));
-
-   if (!standby) {
-   pr_warn("ramc no standby function available\n");
-   return;
-   }
-
-   at91_pm_set_standby(standby);
 }
 
 static void __init at91_pm_sram_init(void)
-- 
1.7.9.5

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


[PATCH v5 11/13] pm: at91: remove the at91_xxx_standby() function definitions in the pm.h

2015-01-28 Thread Wenyou Yang
Because the the suspend to standby mode uses the sram function,
these functions will not used, remove the redundant code.

Signed-off-by: Wenyou Yang 
Acked-by: Alexandre Belloni 
---
 arch/arm/mach-at91/pm.h |   97 ---
 1 file changed, 97 deletions(-)

diff --git a/arch/arm/mach-at91/pm.h b/arch/arm/mach-at91/pm.h
index 5bc9c33..158575e 100644
--- a/arch/arm/mach-at91/pm.h
+++ b/arch/arm/mach-at91/pm.h
@@ -12,7 +12,6 @@
 #define __ARCH_ARM_MACH_AT91_PM
 
 #include 
-
 #include 
 
 #defineAT91_PM_MEMCTRL_MASK0x0f
@@ -22,100 +21,4 @@
 
 #defineAT91_PM_SLOW_CLOCK  0x01
 
-#ifdef CONFIG_PM
-extern void at91_pm_set_standby(void (*at91_standby)(void));
-#else
-static inline void at91_pm_set_standby(void (*at91_standby)(void)) { }
-#endif
-
-/*
- * The AT91RM9200 goes into self-refresh mode with this command, and will
- * terminate self-refresh automatically on the next SDRAM access.
- *
- * Self-refresh mode is exited as soon as a memory access is made, but we don't
- * know for sure when that happens. However, we need to restore the low-power
- * mode if it was enabled before going idle. Restoring low-power mode while
- * still in self-refresh is "not recommended", but seems to work.
- */
-
-static inline void at91rm9200_standby(void)
-{
-   u32 lpr = at91_ramc_read(0, AT91RM9200_SDRAMC_LPR);
-
-   asm volatile(
-   "b1f\n\t"
-   ".align5\n\t"
-   "1:  mcrp15, 0, %0, c7, c10, 4\n\t"
-   "str%0, [%1, %2]\n\t"
-   "str%3, [%1, %4]\n\t"
-   "mcrp15, 0, %0, c7, c0, 4\n\t"
-   "str%5, [%1, %2]"
-   :
-   : "r" (0), "r" (AT91_BASE_SYS), "r" (AT91RM9200_SDRAMC_LPR),
- "r" (1), "r" (AT91RM9200_SDRAMC_SRR),
- "r" (lpr));
-}
-
-/* We manage both DDRAM/SDRAM controllers, we need more than one value to
- * remember.
- */
-static inline void at91_ddr_standby(void)
-{
-   /* Those two values allow us to delay self-refresh activation
-* to the maximum. */
-   u32 lpr0, lpr1 = 0;
-   u32 saved_lpr0, saved_lpr1 = 0;
-
-   if (at91_ramc_base[1]) {
-   saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR);
-   lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB;
-   lpr1 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
-   }
-
-   saved_lpr0 = at91_ramc_read(0, AT91_DDRSDRC_LPR);
-   lpr0 = saved_lpr0 & ~AT91_DDRSDRC_LPCB;
-   lpr0 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
-
-   /* self-refresh mode now */
-   at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0);
-   if (at91_ramc_base[1])
-   at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1);
-
-   cpu_do_idle();
-
-   at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0);
-   if (at91_ramc_base[1])
-   at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1);
-}
-
-/* We manage both DDRAM/SDRAM controllers, we need more than one value to
- * remember.
- */
-static inline void at91sam9_sdram_standby(void)
-{
-   u32 lpr0, lpr1 = 0;
-   u32 saved_lpr0, saved_lpr1 = 0;
-
-   if (at91_ramc_base[1]) {
-   saved_lpr1 = at91_ramc_read(1, AT91_SDRAMC_LPR);
-   lpr1 = saved_lpr1 & ~AT91_SDRAMC_LPCB;
-   lpr1 |= AT91_SDRAMC_LPCB_SELF_REFRESH;
-   }
-
-   saved_lpr0 = at91_ramc_read(0, AT91_SDRAMC_LPR);
-   lpr0 = saved_lpr0 & ~AT91_SDRAMC_LPCB;
-   lpr0 |= AT91_SDRAMC_LPCB_SELF_REFRESH;
-
-   /* self-refresh mode now */
-   at91_ramc_write(0, AT91_SDRAMC_LPR, lpr0);
-   if (at91_ramc_base[1])
-   at91_ramc_write(1, AT91_SDRAMC_LPR, lpr1);
-
-   cpu_do_idle();
-
-   at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr0);
-   if (at91_ramc_base[1])
-   at91_ramc_write(1, AT91_SDRAMC_LPR, saved_lpr1);
-}
-
 #endif
-- 
1.7.9.5

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


[PATCH v5 10/13] pm: at91: rename function name: at91_slow_clock()-->at91_pm_suspend_sram_fn

2015-01-28 Thread Wenyou Yang
As the file name's renaming, rename the file name at91_slow_clock()-->
at91_pm_suspend_sram_fn, rename the function handler's name at the same time.

Signed-off-by: Wenyou Yang 
Acked-by: Alexandre Belloni 
---
 arch/arm/mach-at91/pm.c |   25 +
 arch/arm/mach-at91/pm_suspend.S |   24 ++--
 2 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index c3a697f..ce15013 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -131,13 +131,12 @@ int at91_suspend_entering_slow_clock(void)
 }
 EXPORT_SYMBOL(at91_suspend_entering_slow_clock);
 
-
-static void (*slow_clock)(void __iomem *pmc, void __iomem *ramc0,
+static void (*at91_suspend_sram_fn)(void __iomem *pmc, void __iomem *ramc0,
  void __iomem *ramc1, int memctrl);
 
-extern void at91_slow_clock(void __iomem *pmc, void __iomem *ramc0,
+extern void at91_pm_suspend_in_sram(void __iomem *pmc, void __iomem *ramc0,
void __iomem *ramc1, int memctrl);
-extern u32 at91_slow_clock_sz;
+extern u32 at91_pm_suspend_in_sram_sz;
 
 static void at91_pm_suspend(suspend_state_t state)
 {
@@ -146,8 +145,8 @@ static void at91_pm_suspend(suspend_state_t state)
pm_data |= (state == PM_SUSPEND_MEM) ?
AT91_PM_MODE(AT91_PM_SLOW_CLOCK) : 0;
 
-   slow_clock(at91_pmc_base, at91_ramc_base[0],
-   at91_ramc_base[1], pm_data);
+   at91_suspend_sram_fn(at91_pmc_base, at91_ramc_base[0],
+   at91_ramc_base[1], pm_data);
 }
 
 static int at91_pm_enter(suspend_state_t state)
@@ -288,17 +287,19 @@ static void __init at91_pm_sram_init(void)
goto put_node;
}
 
-   sram_base = gen_pool_alloc(sram_pool, at91_slow_clock_sz);
+   sram_base = gen_pool_alloc(sram_pool, at91_pm_suspend_in_sram_sz);
if (!sram_base) {
-   pr_warn("%s: unable to alloc ocram!\n", __func__);
+   pr_warn("%s: unable to alloc sram!\n", __func__);
goto put_node;
}
 
sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
-   slow_clock = __arm_ioremap_exec(sram_pbase, at91_slow_clock_sz, false);
+   at91_suspend_sram_fn = __arm_ioremap_exec(sram_pbase,
+   at91_pm_suspend_in_sram_sz, false);
 
-   /* Copy the slow_clock handler to SRAM */
-   memcpy(slow_clock, at91_slow_clock, at91_slow_clock_sz);
+   /* Copy the pm suspend handler to SRAM */
+   memcpy(at91_suspend_sram_fn,
+   at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
 
 put_node:
of_node_put(node);
@@ -311,7 +312,7 @@ static void __init at91_pm_init(void)
if (at91_cpuidle_device.dev.platform_data)
platform_device_register(_cpuidle_device);
 
-   if (slow_clock)
+   if (at91_suspend_sram_fn)
suspend_set_ops(_pm_ops);
else
pr_info("AT91: PM : Not supported, due to no sram allocated\n");
diff --git a/arch/arm/mach-at91/pm_suspend.S b/arch/arm/mach-at91/pm_suspend.S
index 8edbad0..122a3f1 100644
--- a/arch/arm/mach-at91/pm_suspend.S
+++ b/arch/arm/mach-at91/pm_suspend.S
@@ -55,23 +55,19 @@ mode.reqr6
 
.text
 
-/* void at91_slow_clock(void __iomem *pmc, void __iomem *sdramc,
+/*
+ * void at91_pm_suspend_in_sram(void __iomem *pmc, void __iomem *sdramc,
  * void __iomem *ramc1, int memctrl)
+ * @input param:
+ * @r0: the base address of AT91_PMC
+ * @r1: the base address of SDRAM Controller (SDRAM, DDRSDR, or AT91_SYS)
+ * @r2: the base address of second SDRAM Controller or 0 if not present
+ * @r3: the pm information
  */
-ENTRY(at91_slow_clock)
+ENTRY(at91_pm_suspend_in_sram)
/* Save registers on stack */
stmfd   sp!, {r4 - r12, lr}
 
-   /*
-* Register usage:
-*  R0 = Base address of AT91_PMC
-*  R1 = Base address of RAM Controller (SDRAM, DDRSDR, or AT91_SYS)
-*  R2 = Base address of second RAM Controller or 0 if not present
-*  R3 = Memory controller
-*  R4 = temporary register
-*  R5 = temporary register
-*/
-
/* Drain write buffer */
mov tmp1, #0
mcr p15, 0, tmp1, c7, c10, 4
@@ -277,5 +273,5 @@ ram_restored:
 .saved_sam9_mdr1:
.word 0
 
-ENTRY(at91_slow_clock_sz)
-   .word .-at91_slow_clock
+ENTRY(at91_pm_suspend_in_sram_sz)
+   .word .-at91_pm_suspend_in_sram
-- 
1.7.9.5

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


[PATCH v5 09/13] pm: at91: rename file name: pm_slowclock.S -->pm_suspend.S

2015-01-28 Thread Wenyou Yang
Because the sram function is used for the suspend to standby mode as well,
more than suspend to memory, so renaming is more elegant.

Signed-off-by: Wenyou Yang 
Acked-by: Alexandre Belloni 
---
 arch/arm/mach-at91/Makefile   |2 +-
 arch/arm/mach-at91/pm_slowclock.S |  281 -
 arch/arm/mach-at91/pm_suspend.S   |  281 +
 3 files changed, 282 insertions(+), 282 deletions(-)
 delete mode 100644 arch/arm/mach-at91/pm_slowclock.S
 create mode 100644 arch/arm/mach-at91/pm_suspend.S

diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 103c256..7df8c854 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -13,7 +13,7 @@ obj-$(CONFIG_SOC_SAMA5)   += sama5.o
 
 # Power Management
 obj-$(CONFIG_PM)   += pm.o
-obj-$(CONFIG_PM)   += pm_slowclock.o
+obj-$(CONFIG_PM)   += pm_suspend.o
 
 ifeq ($(CONFIG_PM_DEBUG),y)
 CFLAGS_pm.o += -DDEBUG
diff --git a/arch/arm/mach-at91/pm_slowclock.S 
b/arch/arm/mach-at91/pm_slowclock.S
deleted file mode 100644
index f56d114..000
--- a/arch/arm/mach-at91/pm_slowclock.S
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * arch/arm/mach-at91/pm_slow_clock.S
- *
- *  Copyright (C) 2006 Savin Zlobec
- *
- * AT91SAM9 support:
- *  Copyright (C) 2007 Anti Sullin 
-#include 
-#include 
-#include 
-
-#include "pm.h"
-
-pmc.reqr0
-sdramc .reqr1
-ramc1  .reqr2
-memctrl.reqr3
-tmp1   .reqr4
-tmp2   .reqr5
-mode   .reqr6
-
-/*
- * Wait until master clock is ready (after switching master clock source)
- */
-   .macro wait_mckrdy
-1: ldr tmp1, [pmc, #AT91_PMC_SR]
-   tst tmp1, #AT91_PMC_MCKRDY
-   beq 1b
-   .endm
-
-/*
- * Wait until master oscillator has stabilized.
- */
-   .macro wait_moscrdy
-1: ldr tmp1, [pmc, #AT91_PMC_SR]
-   tst tmp1, #AT91_PMC_MOSCS
-   beq 1b
-   .endm
-
-/*
- * Wait until PLLA has locked.
- */
-   .macro wait_pllalock
-1: ldr tmp1, [pmc, #AT91_PMC_SR]
-   tst tmp1, #AT91_PMC_LOCKA
-   beq 1b
-   .endm
-
-   .text
-
-/* void at91_slow_clock(void __iomem *pmc, void __iomem *sdramc,
- * void __iomem *ramc1, int memctrl)
- */
-ENTRY(at91_slow_clock)
-   /* Save registers on stack */
-   stmfd   sp!, {r4 - r12, lr}
-
-   /*
-* Register usage:
-*  R0 = Base address of AT91_PMC
-*  R1 = Base address of RAM Controller (SDRAM, DDRSDR, or AT91_SYS)
-*  R2 = Base address of second RAM Controller or 0 if not present
-*  R3 = Memory controller
-*  R4 = temporary register
-*  R5 = temporary register
-*/
-
-   /* Drain write buffer */
-   mov tmp1, #0
-   mcr p15, 0, tmp1, c7, c10, 4
-
-   mov tmp1, memctrl
-   mov tmp2, tmp1, lsr#AT91_PM_MODE_OFFSET
-   and mode, tmp2, #AT91_PM_MODE_MASK
-
-   mov tmp1, memctrl
-   and memctrl, tmp1, #AT91_PM_MEMCTRL_MASK
-
-   cmp memctrl, #AT91_MEMCTRL_MC
-   bne ddr_sr_enable
-
-   /*
-* at91rm9200 Memory controller
-*/
-   /* Put SDRAM in self-refresh mode */
-   mov tmp1, #1
-   str tmp1, [sdramc, #AT91RM9200_SDRAMC_SRR]
-   b   sdr_sr_done
-
-   /*
-* DDRSDR Memory controller
-*/
-ddr_sr_enable:
-   cmp memctrl, #AT91_MEMCTRL_DDRSDR
-   bne sdr_sr_enable
-
-   /* LPDDR1 --> force DDR2 mode during self-refresh */
-   ldr tmp1, [sdramc, #AT91_DDRSDRC_MDR]
-   str tmp1, .saved_sam9_mdr
-   bic tmp1, tmp1, #~AT91_DDRSDRC_MD
-   cmp tmp1, #AT91_DDRSDRC_MD_LOW_POWER_DDR
-   ldreq   tmp1, [sdramc, #AT91_DDRSDRC_MDR]
-   biceq   tmp1, tmp1, #AT91_DDRSDRC_MD
-   orreq   tmp1, tmp1, #AT91_DDRSDRC_MD_DDR2
-   streq   tmp1, [sdramc, #AT91_DDRSDRC_MDR]
-
-   /* prepare for DDRAM self-refresh mode */
-   ldr tmp1, [sdramc, #AT91_DDRSDRC_LPR]
-   str tmp1, .saved_sam9_lpr
-   bic tmp1, #AT91_DDRSDRC_LPCB
-   orr tmp1, #AT91_DDRSDRC_LPCB_SELF_REFRESH
-
-   /* figure out if we use the second ram controller */
-   cmp ramc1, #0
-   beq ddr_no_2nd_ctrl
-
-   ldr tmp2, [ramc1, #AT91_DDRSDRC_MDR]
-   str tmp2, .saved_sam9_mdr1
-   bic tmp2, tmp2, #~AT91_DDRSDRC_MD
-   cmp tmp2, #AT91_DDRSDRC_MD_LOW_POWER_DDR
-   ldreq   tmp2, [ramc1, #AT91_DDRSDRC_MDR]
-   biceq   tmp2, tmp2, #AT91_DDRSDRC_MD
-   orreq   tmp2, tmp2, #AT91_DDRSDRC_MD_DDR2
-   streq   tmp2, [ramc1, #AT91_DDRSDRC_MDR]
-
-   ldr tmp2, [ramc1, #AT91_DDRSDRC_LPR]
-   str tmp2, .saved_sam9_lpr1
-   bic tmp2, #AT91_DDRSDRC_LPCB
-   orr tmp2, #AT91_DDRSDRC_LPCB_SELF_REFRESH
-
-   /* Enable DDRAM self-refresh mode */
-   str tmp2, [ramc1, #AT91_DDRSDRC_LPR]

Re: [PATCH 1/6] soc: qcom: gsbi: Add support for ADM CRCI muxing

2015-01-28 Thread Stephen Boyd
On 01/28, Andy Gross wrote:
> On Wed, Jan 28, 2015 at 06:11:50PM -0800, Stephen Boyd wrote:
> 
> > 
> > > +- syscon-tcsr: indicates phandle of TCSR syscon node
> > 
> > Make this optional but required if any child nodes use dma?
> 
> To enforce that I'd have to determine that a child has a dmas.  I guess that
> isn't so bad.

I don't think we need to write any code in the driver to enforce
this right now. As long as nobody gets it wrong bad things won't
happen and we can just assume that the DT is correct. Once we get
some bad DT we can go ahead and implement some DT parsing stuff.

> 
> 
> > > +
> > > + if (!gsbi_num || gsbi_num > MAX_GSBI) {
> > > + dev_err(>dev, "invalid gsbi number\n");
> > > + return -EINVAL;
> > > + }
> > > +
> > >   if (of_property_read_u32(node, "qcom,mode", >mode)) {
> > >   dev_err(>dev, "missing mode configuration\n");
> > >   return -EINVAL;
> > > @@ -64,6 +185,26 @@ static int gsbi_probe(struct platform_device *pdev)
> > >   writel_relaxed((gsbi->mode << GSBI_PROTOCOL_SHIFT) | gsbi->crci,
> > >   base + GSBI_CTRL_REG);
> > >  
> > > + /*
> > > +  * modify tcsr to reflect mode and ADM CRCI mux
> > > +  * Each gsbi contains a pair of bits, one for RX and one for TX
> > > +  * SPI mode requires both bits cleared, otherwise they are set
> > > +  */
> > > + match = of_match_node(gsbi_dt_match, node);
> > 
> > Why not match the config to the TCSR compatible string? Wouldn't
> > that more accurately reflect that we need to set different bits
> > depending on which type of TCSR we're using? The version of GSBI
> > hardware is not actually changing in every different SoC so I
> > don't see why we want to change the compatible there just because
> > the TCSR register layout changed.
> 
> That is true.  However, with the gsbi compat, I avoid doing a match multiple
> times and get the table I need immediately.  The alternative is N checks or
> pulling the compat strings and comparing them to get the right table.

Sorry I'm not following. We always have to call of_match_node()
here and I'm just suggesting we replace gsbi_dt_match with
tcsr_dt_match and leave gsbi_dt_match like it was before. I don't
see how anything is avoided.

> 
> 
> > > +
> > > + if (config)
> > > + for (i = 0; i < config->num_rows; i++) {
> > > + if (gsbi->mode == GSBI_PROT_SPI)
> > 
> > Doesn't I2C need the same treatment (anything in QUP really)?
> > Maybe the logic could be changed to check for gsbi->crci ==
> > GSBI_CRCI_QUP?
> 
> Nope.  I2C doesn't support DMA when ADM is the controller.  It's only SPI or
> UART.

Ok, I don't get it but I guess it doesn't matter if I2C doesn't
use it.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 v5 08/13] pm: at91: the standby mode uses the same sram function as the suspend to memory mode

2015-01-28 Thread Wenyou Yang
To simply the PM code, the suspend to standby mode uses the same sram function
as the suspend to memory mode, running in the internal SRAM,
instead of the respective code for each mode.

But for the suspend to standby mode, the master clock doesn't
switch to the slow clock,  and the main oscillator doesn't
turn off as well.

Signed-off-by: Wenyou Yang 
---
 arch/arm/mach-at91/pm.c   |   85 +
 arch/arm/mach-at91/pm.h   |7 +++
 arch/arm/mach-at91/pm_slowclock.S |   18 
 3 files changed, 64 insertions(+), 46 deletions(-)

diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index d2a64cc..c3a697f 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -139,62 +139,55 @@ extern void at91_slow_clock(void __iomem *pmc, void 
__iomem *ramc0,
void __iomem *ramc1, int memctrl);
 extern u32 at91_slow_clock_sz;
 
+static void at91_pm_suspend(suspend_state_t state)
+{
+   unsigned int pm_data = at91_pm_data.memctrl;
+
+   pm_data |= (state == PM_SUSPEND_MEM) ?
+   AT91_PM_MODE(AT91_PM_SLOW_CLOCK) : 0;
+
+   slow_clock(at91_pmc_base, at91_ramc_base[0],
+   at91_ramc_base[1], pm_data);
+}
+
 static int at91_pm_enter(suspend_state_t state)
 {
at91_pinctrl_gpio_suspend();
 
switch (state) {
+   /*
+* Suspend-to-RAM is like STANDBY plus slow clock mode, so
+* drivers must suspend more deeply, the master clock switches
+* to the clk32k and turns off the main oscillator
+*/
+   case PM_SUSPEND_MEM:
/*
-* Suspend-to-RAM is like STANDBY plus slow clock mode, so
-* drivers must suspend more deeply:  only the master clock
-* controller may be using the main oscillator.
+* Ensure that clocks are in a valid state.
 */
-   case PM_SUSPEND_MEM:
-   /*
-* Ensure that clocks are in a valid state.
-*/
-   if (!at91_pm_verify_clocks())
-   goto error;
-
-   /*
-* Enter slow clock mode by switching over to clk32k and
-* turning off the main oscillator; reverse on wakeup.
-*/
-   if (slow_clock) {
-   slow_clock(at91_pmc_base, at91_ramc_base[0],
-  at91_ramc_base[1],
-  at91_pm_data.memctrl);
-   break;
-   } else {
-   pr_info("AT91: PM - no slow clock mode enabled 
...\n");
-   /* FALLTHROUGH leaving master clock alone */
-   }
+   if (!at91_pm_verify_clocks())
+   goto error;
 
-   /*
-* STANDBY mode has *all* drivers suspended; ignores irqs not
-* marked as 'wakeup' event sources; and reduces DRAM power.
-* But otherwise it's identical to PM_SUSPEND_ON:  cpu idle, and
-* nothing fancy done with main or cpu clocks.
-*/
-   case PM_SUSPEND_STANDBY:
-   /*
-* NOTE: the Wait-for-Interrupt instruction needs to be
-* in icache so no SDRAM accesses are needed until the
-* wakeup IRQ occurs and self-refresh is terminated.
-* For ARM 926 based chips, this requirement is weaker
-* as at91sam9 can access a RAM in self-refresh mode.
-*/
-   if (at91_pm_standby)
-   at91_pm_standby();
-   break;
+   at91_pm_suspend(state);
 
-   case PM_SUSPEND_ON:
-   cpu_do_idle();
-   break;
+   break;
 
-   default:
-   pr_debug("AT91: PM - bogus suspend state %d\n", state);
-   goto error;
+   /*
+* STANDBY mode has *all* drivers suspended; ignores irqs not
+* marked as 'wakeup' event sources; and reduces DRAM power.
+* But otherwise it's identical to PM_SUSPEND_ON:  cpu idle, and
+* nothing fancy done with main or cpu clocks.
+*/
+   case PM_SUSPEND_STANDBY:
+   at91_pm_suspend(state);
+   break;
+
+   case PM_SUSPEND_ON:
+   cpu_do_idle();
+   break;
+
+   default:
+   pr_debug("AT91: PM - bogus suspend state %d\n", state);
+   goto error;
}
 
 error:
diff --git a/arch/arm/mach-at91/pm.h b/arch/arm/mach-at91/pm.h
index d2c8996..5bc9c33 100644
--- 

[PATCH v5 07/13] pm: at91: remove the config item CONFIG_AT91_SLOW_CLOCK

2015-01-28 Thread Wenyou Yang
The slow clock always exists, for the suspend to memory mode,
the master clock always switch to the slow clock.

To simplify the PM config, remove this config item, remove
the definition code as well.

Signed-off-by: Wenyou Yang 
Acked-by: Alexandre Belloni 
---
 arch/arm/mach-at91/Kconfig  |   13 -
 arch/arm/mach-at91/Makefile |2 +-
 arch/arm/mach-at91/pm.c |9 -
 3 files changed, 1 insertion(+), 23 deletions(-)

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 6b9e685..3a5e46a 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -120,19 +120,6 @@ endif # SOC_SAM_V4_V5
 
 comment "AT91 Feature Selections"
 
-config AT91_SLOW_CLOCK
-   bool "Suspend-to-RAM disables main oscillator"
-   depends on SUSPEND
-   help
- Select this if you want Suspend-to-RAM to save the most power
- possible (without powering off the CPU) by disabling the PLLs
- and main oscillator so that only the 32 KiHz clock is available.
-
- When only that slow-clock is available, some peripherals lose
- functionality.  Many can't issue wakeup events unless faster
- clocks are available.  Some lose their operating state and
- need to be completely re-initialized.
-
 config AT91_TIMER_HZ
int "Kernel HZ (jiffies per second)"
range 32 1024
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 827fdbc..103c256 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -13,7 +13,7 @@ obj-$(CONFIG_SOC_SAMA5)   += sama5.o
 
 # Power Management
 obj-$(CONFIG_PM)   += pm.o
-obj-$(CONFIG_AT91_SLOW_CLOCK)  += pm_slowclock.o
+obj-$(CONFIG_PM)   += pm_slowclock.o
 
 ifeq ($(CONFIG_PM_DEBUG),y)
 CFLAGS_pm.o += -DDEBUG
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 6df0152..d2a64cc 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -135,11 +135,9 @@ EXPORT_SYMBOL(at91_suspend_entering_slow_clock);
 static void (*slow_clock)(void __iomem *pmc, void __iomem *ramc0,
  void __iomem *ramc1, int memctrl);
 
-#ifdef CONFIG_AT91_SLOW_CLOCK
 extern void at91_slow_clock(void __iomem *pmc, void __iomem *ramc0,
void __iomem *ramc1, int memctrl);
 extern u32 at91_slow_clock_sz;
-#endif
 
 static int at91_pm_enter(suspend_state_t state)
 {
@@ -271,7 +269,6 @@ static void at91_dt_ramc(void)
at91_pm_set_standby(standby);
 }
 
-#ifdef CONFIG_AT91_SLOW_CLOCK
 static void __init at91_pm_sram_init(void)
 {
struct gen_pool *sram_pool;
@@ -313,16 +310,10 @@ static void __init at91_pm_sram_init(void)
 put_node:
of_node_put(node);
 }
-#endif
-
 
 static void __init at91_pm_init(void)
 {
-#ifdef CONFIG_AT91_SLOW_CLOCK
at91_pm_sram_init();
-#endif
-
-   pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock 
mode)" : ""));
 
if (at91_cpuidle_device.dev.platform_data)
platform_device_register(_cpuidle_device);
-- 
1.7.9.5

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


Re: [PATCH] net, ethernet, LLVMLinux: Add missing MODULE_DEVICE_TABLE()

2015-01-28 Thread David Miller
From: Behan Webster 
Date: Wed, 28 Jan 2015 17:36:14 -0800

> Missing MODULE_DEVICE_TABLE for pci ids from benet driver found by clang.
> 
> Signed-off-by: Behan Webster 
> Suggested-by: Arnd Bergmann 

Why are you removing the device table?

Second of all, your Subject needs to be adjusted, using "net" and
"LLVMLinux" in your subsystem prefix is not appropriate.  Simply
"be2net: ", the name of this driver, is sufficient.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 v5 06/13] ARM: at91: move select SRAM to ARCH_AT91

2015-01-28 Thread Wenyou Yang
Because the CONFIG_AT91_SLOW_CLOCK will be removed
to simply the PM config, so move select SRAM.

Signed-off-by: Wenyou Yang 
Acked-by: Alexandre Belloni 
---
 arch/arm/mach-at91/Kconfig |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index c6740e3..6b9e685 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -25,6 +25,7 @@ config SOC_SAMA5
select MEMORY
select ATMEL_SDRAMC
select PHYLIB if NETDEVICES
+   select SRAM if PM
 
 menu "Atmel AT91 System-on-Chip"
 
@@ -82,6 +83,7 @@ config SOC_AT91RM9200
select CPU_ARM920T
select GENERIC_CLOCKEVENTS
select HAVE_AT91_USB_CLK
+   select SRAM if PM
 
 config SOC_AT91SAM9
bool "AT91SAM9"
@@ -95,6 +97,7 @@ config SOC_AT91SAM9
select HAVE_AT91_UTMI
select HAVE_FB_ATMEL
select MEMORY
+   select SRAM if PM
help
  Select this if you are using one of those Atmel SoC:
AT91SAM9260
@@ -119,7 +122,6 @@ comment "AT91 Feature Selections"
 
 config AT91_SLOW_CLOCK
bool "Suspend-to-RAM disables main oscillator"
-   select SRAM
depends on SUSPEND
help
  Select this if you want Suspend-to-RAM to save the most power
-- 
1.7.9.5

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


Re: [PATCH v13 0/6] Per-user clock constraints

2015-01-28 Thread Tomeu Vizoso
On 01/29/2015 03:26 AM, Mike Turquette wrote:
> Quoting Tomeu Vizoso (2015-01-27 22:59:59)
>> On 01/27/2015 01:55 AM, Stephen Boyd wrote:
>>> On 01/23/15 03:03, Tomeu Vizoso wrote:
 Hi,

 in this v13 I have:

 * added the latest R-b tags from Stephen,

 * split some lines that went over the 80-char limit,

 * made explicit in the docs that the range limits are inclusive, and

 * removed an ifdef in clkdev.c by adding a dev_id param to 
 __of_clk_get_by_name.

>>>
>>> I think this patch series is ready to go except for the last one? Do you
>>> plan on polishing that one some more?
>>
>> Hi Mike,
>>
>> do you plan to merge this for 3.20?
> 
> Tomeu,
> 
> Yes. I have taken patches 1-5.
> 
> I edited patch #3 to adapt clk_has_parent for struct clk_core.
> 
> https://git.kernel.org/cgit/linux/kernel/git/clk/linux.git/commit/?h=clk-next=59cf3fcf9bafe8fdb6183f13dafb81fc8213a8f9
> 
> Patch #4 need an update to convert sun6i_ahb1_clk_determine_rate to have
> min/max rates.
> 
> https://git.kernel.org/cgit/linux/kernel/git/clk/linux.git/commit/?h=clk-next=cb75a8fcd14e71c115decc416dd8d223e7c8b2e0
> 
> Can you look it over and make sure I didn't screw anything up?

Yup, they look good to me. I have also done some testing here.

Thanks,

Tomeu

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 linux-trace 1/8] tracing: attach eBPF programs to tracepoints and syscalls

2015-01-28 Thread Namhyung Kim
On Thu, Jan 29, 2015 at 1:40 PM, Alexei Starovoitov  wrote:
> On Wed, Jan 28, 2015 at 4:46 PM, Namhyung Kim  wrote:
>>>
>>> +static int event_filter_release(struct inode *inode, struct file *filp)
>>> +{
>>> + struct ftrace_event_file *file;
>>> + char buf[2] = "0";
>>> +
>>> + mutex_lock(_mutex);
>>> + file = event_file_data(filp);
>>> + if (file) {
>>> + if (file->flags & TRACE_EVENT_FL_BPF) {
>>> + /* auto-disable the filter */
>>> + ftrace_event_enable_disable(file, 0);
>>
>> Hmm.. what if user already enabled an event, attached a bpf filter and
>> then detached the filter - I'm not sure we can always auto-disable
>> it..
>
> why not?
> I think it makes sense auto enable/disable, since that
> is cleaner user experience.
> Otherwise Ctrl-C of the user process will have bpf program dangling.
> not good. If we auto-unload bpf program only, it's equally bad.
> Since Ctrl-C of the process will auto-onload only
> and will keep tracepoint enabled which will be spamming
> the trace buffer.

I think it's not a problem of bpf.  An user process can be killed
anytime while it enabed events without bpf.  The only thing it should
care is the auto-unload IMHO.


>
>>> +unsigned int trace_filter_call_bpf(struct event_filter *filter, void *ctx)
>>> +{
>>> + unsigned int ret;
>>> +
>>> + if (in_nmi()) /* not supported yet */
>>> + return 0;
>>
>> But doesn't this mean to auto-disable all attached events during NMI
>> as returning 0 will prevent the event going to ring buffer?
>
> well, it means that if tracepoint fired during nmi the program
> won't be called and event won't be sent to trace buffer.
> The program might be broken (like divide by zero) and
> it will self-terminate with 'return 0'
> so zero should be the safest return value that
> causes minimum disturbance to the whole system overall.

I'm okay for not calling bpf program in NMI but not for disabling events.

Suppose an user was collecting an event (including in NMI) and then
[s]he also wanted to run a bpf program.  So [s]he wrote a program
always return 1.  But after attaching the program, it didn't record
the event in NMI..  Isn't that a problem?


>
>> I think it'd be better to keep an attached event in a soft-disabled
>> state like event trigger and give control of enabling to users..
>
> I think it suffers from the same Ctrl-C issue.
> Say, attaching bpf program activates tracepoint and keeps
> it in soft-disabled. Then user space clears soft-disabled.
> Then user Ctrl-C it. Now bpf program must auto-detach
> and unload, since prog_fd is closing.
> If we don't completely deactivate tracepoint, then
> Ctrl-C will leave the state of the system in the state
> different from it was before user process started running.
> I think we must avoid such situation.
> 'kill pid' should be completely cleaning all resources
> that user process was using.
> Yes. It's different from typical usage of /sys/.../tracing
> that has all global knobs, but, imo, it's cleaner this way.

Right.  I think bpf programs belong to a user process but events are
global resource.  Maybe you also need to consider attaching bpf
program via perf (ioctl?) interface..

Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] cpufreq: fix another race between PPC notification and vcpu_hotplug()

2015-01-28 Thread Ethan Zhao
There is race observed between PPC changed notification handler worker thread
and vcpu_hotplug() called within xenbus_thread() context.
It is shown as following WARNING:

 [ cut here ]
 WARNING: CPU: 0 PID: 4 at include/linux/kref.h:47
 kobject_get+0x41/0x50()
 Modules linked in: acpi_cpufreq(+) nfsd auth_rpcgss nfs_acl
 lockd grace sunrpc xfs libcrc32c sd_mod ixgbe igb mdio ahci hwmon
 ...
 [   14.003548] CPU: 0 PID: 4 Comm: kworker/0:0 Not tainted
 ...
 [   14.003553] Workqueue: kacpi_notify acpi_os_execute_deferred
 [   14.003554]   8c76682c 88094c793af8
 81661b14
 [   14.003556]    88094c793b38
 81072b61
 [   14.003558]  88094c793bd8 8812491f8800 0292
 
 [   14.003560] Call Trace:
 [   14.003567]  [] dump_stack+0x46/0x58
 [   14.003571]  [] warn_slowpath_common+0x81/0xa0
 [   14.003572]  [] warn_slowpath_null+0x1a/0x20
 [   14.003574]  [] kobject_get+0x41/0x50
 [   14.003579]  [] cpufreq_cpu_get+0x75/0xc0
 [   14.003581]  [] cpufreq_update_policy+0x2e/0x1f0
 [   14.003586]  [] ? up+0x32/0x50
 [   14.003589]  [] ? acpi_ns_get_node+0xcb/0xf2
 [   14.003591]  [] ? acpi_evaluate_object+0x22c/0x252
 [   14.003593]  [] ? acpi_get_handle+0x95/0xc0
 [   14.003596]  [] ? acpi_has_method+0x25/0x40
 [   14.003601]  [] acpi_processor_ppc_has_changed+0x77/0x82
 [   14.003604]  [] ? move_linked_works+0x66/0x90
 [   14.003606]  [] acpi_processor_notify+0x58/0xe7
 [   14.003609]  [] acpi_ev_notify_dispatch+0x44/0x5c
 [   14.003611]  [] acpi_os_execute_deferred+0x15/0x22
 [   14.003614]  [] process_one_work+0x160/0x410
 [   14.003616]  [] worker_thread+0x11b/0x520
 [   14.003617]  [] ? rescuer_thread+0x380/0x380
 [   14.003621]  [] kthread+0xe1/0x100
 [   14.003623]  [] ? kthread_create_on_node+0x1b0/0x1b0
 [   14.003628]  [] ret_from_fork+0x7c/0xb0
 [   14.003630]  [] ? kthread_create_on_node+0x1b0/0x1b0
 [   14.003631] ---[ end trace 89e66eb9795efdf7 ]---

 Thread A: Workqueue: kacpi_notify

 acpi_processor_notify()
   acpi_processor_ppc_has_changed()
 cpufreq_update_policy()
   cpufreq_cpu_get()
 kobject_get()

 Thread B: xenbus_thread()

 xenbus_thread()
   msg->u.watch.handle->callback()
 handle_vcpu_hotplug_event()
   vcpu_hotplug()
 cpu_down()
   __cpu_notify(CPU_DOWN_PREPARE..)
 cpufreq_cpu_callback()
   __cpufreq_remove_dev_prepare()
 update_policy_cpu()
   kobject_move()

To avoid this race, cpufreq_cpu_get() should check the cpu is offline or not
and move the kobject_move() after up_write(>rwsem) in function
update_policy_cpu() to be sure the updating to the policy was done in another
thread. 

But seems it is not complete fix because of some functions would schedule out
we could couldn't move them into sections proteced by rwsem directly, such as
the move_object().

Only passed buidling with v3.19-rc6.

Signed-off-by: Ethan Zhao 
---
 drivers/cpufreq/cpufreq.c | 28 ++--
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 46bed4f..b5e2bb8 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -202,7 +202,7 @@ struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
struct cpufreq_policy *policy = NULL;
unsigned long flags;
 
-   if (cpufreq_disabled() || (cpu >= nr_cpu_ids))
+   if (cpufreq_disabled() || cpu_is_offline(cpu))
return NULL;
 
if (!down_read_trylock(_rwsem))
@@ -214,10 +214,18 @@ struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
if (cpufreq_driver) {
/* get the CPU */
policy = per_cpu(cpufreq_cpu_data, cpu);
-   if (policy)
-   kobject_get(>kobj);
+   if (!policy)
+   goto out;
+
+   if (policy->cpu != cpu) {
+   policy = NULL;
+   goto out;
+   }
+
+   kobject_get(>kobj);
}
 
+out:
read_unlock_irqrestore(_driver_lock, flags);
 
if (!policy)
@@ -1083,13 +1091,6 @@ static int update_policy_cpu(struct cpufreq_policy 
*policy, unsigned int cpu,
if (WARN_ON(cpu == policy->cpu))
return 0;
 
-   /* Move kobject to the new policy->cpu */
-   ret = kobject_move(>kobj, _dev->kobj);
-   if (ret) {
-   pr_err("%s: Failed to move kobj: %d\n", __func__, ret);
-   return ret;
-   }
-
down_write(>rwsem);
 
policy->last_cpu = policy->cpu;
@@ -1097,6 +1098,13 @@ static int update_policy_cpu(struct cpufreq_policy 
*policy, unsigned int cpu,
 
up_write(>rwsem);
 
+   /* Move kobject to the new policy->cpu */
+   ret = kobject_move(>kobj, _dev->kobj);
+   if (ret) {
+   pr_err("%s: Failed to 

[PATCH v5 05/13] pm: at91: move the copying the sram function to the sram initializationi phase

2015-01-28 Thread Wenyou Yang
To decrease the suspend time, move the copying the sram function
to the sram initialization phase, instead of every time go to suspend.

In the meanwhile, if there is no sram allocated for PM, the PM is not supported.

Signed-off-by: Wenyou Yang 
Acked-by: Alexandre Belloni 
---
 arch/arm/mach-at91/pm.c |   12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index daa998d..6df0152 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -163,10 +163,6 @@ static int at91_pm_enter(suspend_state_t state)
 * turning off the main oscillator; reverse on wakeup.
 */
if (slow_clock) {
-#ifdef CONFIG_AT91_SLOW_CLOCK
-   /* copy slow_clock handler to SRAM, and call it 
*/
-   memcpy(slow_clock, at91_slow_clock, 
at91_slow_clock_sz);
-#endif
slow_clock(at91_pmc_base, at91_ramc_base[0],
   at91_ramc_base[1],
   at91_pm_data.memctrl);
@@ -311,6 +307,9 @@ static void __init at91_pm_sram_init(void)
sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
slow_clock = __arm_ioremap_exec(sram_pbase, at91_slow_clock_sz, false);
 
+   /* Copy the slow_clock handler to SRAM */
+   memcpy(slow_clock, at91_slow_clock, at91_slow_clock_sz);
+
 put_node:
of_node_put(node);
 }
@@ -328,7 +327,10 @@ static void __init at91_pm_init(void)
if (at91_cpuidle_device.dev.platform_data)
platform_device_register(_cpuidle_device);
 
-   suspend_set_ops(_pm_ops);
+   if (slow_clock)
+   suspend_set_ops(_pm_ops);
+   else
+   pr_info("AT91: PM : Not supported, due to no sram allocated\n");
 }
 
 void __init at91rm9200_pm_init(void)
-- 
1.7.9.5

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


[PATCH v5 04/13] pm: at91: pm_slowclock: remove the unused code related with SLOWDOWN_MASTER_CLOCK

2015-01-28 Thread Wenyou Yang
The SLOWDOWN_MASTER_CLOCK definition is not used, remove the redundant code.

Signed-off-by: Wenyou Yang 
Acked-by: Alexandre Belloni 
---
 arch/arm/mach-at91/pm_slowclock.S |   37 -
 1 file changed, 37 deletions(-)

diff --git a/arch/arm/mach-at91/pm_slowclock.S 
b/arch/arm/mach-at91/pm_slowclock.S
index 1155217..4e55665 100644
--- a/arch/arm/mach-at91/pm_slowclock.S
+++ b/arch/arm/mach-at91/pm_slowclock.S
@@ -11,20 +11,11 @@
  * published by the Free Software Foundation.
  *
  */
-
 #include 
 #include 
 #include 
 #include 
 
-/*
- * When SLOWDOWN_MASTER_CLOCK is defined we will also slow down the Master
- * clock during suspend by adjusting its prescalar and divisor.
- * NOTE: This hasn't been shown to be stable on SAM9s; and on the RM9200 there
- *   are errata regarding adjusting the prescalar and divisor.
- */
-#undef SLOWDOWN_MASTER_CLOCK
-
 pmc.reqr0
 sdramc .reqr1
 ramc1  .reqr2
@@ -166,18 +157,6 @@ sdr_sr_done:
 
wait_mckrdy
 
-#ifdef SLOWDOWN_MASTER_CLOCK
-   /*
-* Set the Master Clock PRES and MDIV fields.
-*
-* See AT91RM9200 errata #27 and #28 for details.
-*/
-   mov tmp1, #0
-   str tmp1, [pmc, #AT91_PMC_MCKR]
-
-   wait_mckrdy
-#endif
-
/* Save PLLA setting and disable it */
ldr tmp1, [pmc, #AT91_CKGR_PLLAR]
str tmp1, .saved_pllar
@@ -213,22 +192,6 @@ sdr_sr_done:
wait_pllalock
 4:
 
-#ifdef SLOWDOWN_MASTER_CLOCK
-   /*
-* First set PRES if it was not 0,
-* than set CSS and MDIV fields.
-*
-* See AT91RM9200 errata #27 and #28 for details.
-*/
-   ldr tmp1, .saved_mckr
-   tst tmp1, #AT91_PMC_PRES
-   beq 2f
-   and tmp1, tmp1, #AT91_PMC_PRES
-   str tmp1, [pmc, #AT91_PMC_MCKR]
-
-   wait_mckrdy
-#endif
-
/*
 * Restore master clock setting
 */
-- 
1.7.9.5

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


[PATCH v5 03/13] pm: at91: Workaround DDRSDRC self-refresh bug with LPDDR1 memories.

2015-01-28 Thread Wenyou Yang
From: Peter Rosin 

The DDRSDR controller fails miserably to put LPDDR1 memories in
self-refresh. Force the controller to think it has DDR2 memories
during the self-refresh period, as the DDR2 self-refresh spec is
equivalent to LPDDR1, and is correctly implemented in the
controller.

Assume that the second controller has the same fault, but that is
untested.

Signed-off-by: Peter Rosin 
Acked-by: Nicolas Ferre 
---
 arch/arm/mach-at91/pm_slowclock.S  |   43 +++-
 include/soc/at91/at91sam9_ddrsdr.h |2 +-
 2 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-at91/pm_slowclock.S 
b/arch/arm/mach-at91/pm_slowclock.S
index e2bfaf5..1155217 100644
--- a/arch/arm/mach-at91/pm_slowclock.S
+++ b/arch/arm/mach-at91/pm_slowclock.S
@@ -100,6 +100,16 @@ ddr_sr_enable:
cmp memctrl, #AT91_MEMCTRL_DDRSDR
bne sdr_sr_enable
 
+   /* LPDDR1 --> force DDR2 mode during self-refresh */
+   ldr tmp1, [sdramc, #AT91_DDRSDRC_MDR]
+   str tmp1, .saved_sam9_mdr
+   bic tmp1, tmp1, #~AT91_DDRSDRC_MD
+   cmp tmp1, #AT91_DDRSDRC_MD_LOW_POWER_DDR
+   ldreq   tmp1, [sdramc, #AT91_DDRSDRC_MDR]
+   biceq   tmp1, tmp1, #AT91_DDRSDRC_MD
+   orreq   tmp1, tmp1, #AT91_DDRSDRC_MD_DDR2
+   streq   tmp1, [sdramc, #AT91_DDRSDRC_MDR]
+
/* prepare for DDRAM self-refresh mode */
ldr tmp1, [sdramc, #AT91_DDRSDRC_LPR]
str tmp1, .saved_sam9_lpr
@@ -108,14 +118,26 @@ ddr_sr_enable:
 
/* figure out if we use the second ram controller */
cmp ramc1, #0
-   ldrne   tmp2, [ramc1, #AT91_DDRSDRC_LPR]
-   strne   tmp2, .saved_sam9_lpr1
-   bicne   tmp2, #AT91_DDRSDRC_LPCB
-   orrne   tmp2, #AT91_DDRSDRC_LPCB_SELF_REFRESH
+   beq ddr_no_2nd_ctrl
+
+   ldr tmp2, [ramc1, #AT91_DDRSDRC_MDR]
+   str tmp2, .saved_sam9_mdr1
+   bic tmp2, tmp2, #~AT91_DDRSDRC_MD
+   cmp tmp2, #AT91_DDRSDRC_MD_LOW_POWER_DDR
+   ldreq   tmp2, [ramc1, #AT91_DDRSDRC_MDR]
+   biceq   tmp2, tmp2, #AT91_DDRSDRC_MD
+   orreq   tmp2, tmp2, #AT91_DDRSDRC_MD_DDR2
+   streq   tmp2, [ramc1, #AT91_DDRSDRC_MDR]
+
+   ldr tmp2, [ramc1, #AT91_DDRSDRC_LPR]
+   str tmp2, .saved_sam9_lpr1
+   bic tmp2, #AT91_DDRSDRC_LPCB
+   orr tmp2, #AT91_DDRSDRC_LPCB_SELF_REFRESH
 
/* Enable DDRAM self-refresh mode */
+   str tmp2, [ramc1, #AT91_DDRSDRC_LPR]
+ddr_no_2nd_ctrl:
str tmp1, [sdramc, #AT91_DDRSDRC_LPR]
-   strne   tmp2, [ramc1, #AT91_DDRSDRC_LPR]
 
b   sdr_sr_done
 
@@ -227,12 +249,17 @@ sdr_sr_done:
 */
cmp memctrl, #AT91_MEMCTRL_DDRSDR
bne sdr_en_restore
+   /* Restore MDR in case of LPDDR1 */
+   ldr tmp1, .saved_sam9_mdr
+   str tmp1, [sdramc, #AT91_DDRSDRC_MDR]
/* Restore LPR on AT91 with DDRAM */
ldr tmp1, .saved_sam9_lpr
str tmp1, [sdramc, #AT91_DDRSDRC_LPR]
 
/* if we use the second ram controller */
cmp ramc1, #0
+   ldrne   tmp2, .saved_sam9_mdr1
+   strne   tmp2, [ramc1, #AT91_DDRSDRC_MDR]
ldrne   tmp2, .saved_sam9_lpr1
strne   tmp2, [ramc1, #AT91_DDRSDRC_LPR]
 
@@ -263,5 +290,11 @@ ram_restored:
 .saved_sam9_lpr1:
.word 0
 
+.saved_sam9_mdr:
+   .word 0
+
+.saved_sam9_mdr1:
+   .word 0
+
 ENTRY(at91_slow_clock_sz)
.word .-at91_slow_clock
diff --git a/include/soc/at91/at91sam9_ddrsdr.h 
b/include/soc/at91/at91sam9_ddrsdr.h
index 0210797..dc10c52 100644
--- a/include/soc/at91/at91sam9_ddrsdr.h
+++ b/include/soc/at91/at91sam9_ddrsdr.h
@@ -92,7 +92,7 @@
 #defineAT91_DDRSDRC_UPD_MR (3 << 20)/* Update load 
mode register and extended mode register */
 
 #define AT91_DDRSDRC_MDR   0x20/* Memory Device Register */
-#defineAT91_DDRSDRC_MD (3 << 0)/* 
Memory Device Type */
+#defineAT91_DDRSDRC_MD (7 << 0)/* Memory 
Device Type */
 #defineAT91_DDRSDRC_MD_SDR 0
 #defineAT91_DDRSDRC_MD_LOW_POWER_SDR   1
 #defineAT91_DDRSDRC_MD_LOW_POWER_DDR   3
-- 
1.7.9.5

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


Re: [PATCH v2 linux-trace 1/8] tracing: attach eBPF programs to tracepoints and syscalls

2015-01-28 Thread Alexei Starovoitov
On Wed, Jan 28, 2015 at 9:39 PM, Masami Hiramatsu
 wrote:
>
> Maybe, would we need a reference counter for each event? :)

when we would want multiple users to attach different programs
to the same event, then yes.
Right now I'd rather have things simple.

> Actually, ftrace event is not similar to perf-event which ktap
> is based on, ftrace event interface is always exported via
> debugfs, this means users can share the event for different
> usage.

yes.I've been thinking to extend perf_event ioctl to attach programs,
but right now it's only supporting tracepoints and kprobe
seems not trivial to add.
So I went for tracefs style of attaching for now.

> One possible other solution is to add a instance-lock interface
> for each ftrace instance and lock it by bpf. Then, other users
> can not enable/disable the events in the instance.

the user space can synchronize itself via flock. kernel doesn't
need to arbitrate. If one user process attached a program
that auto-enabled an event and another process did
'echo 0 > enable', it's fine. I think it's a feature instead of a bug.
Both users are root anyway.

The more we talk about it, the more I like a new 'bpf' file
approach within tracefs (that I've mentioned in cover letter)
with auto-enable/disable logic to make it clear that
it's different from traditional global 'filter' file.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 v5 02/13] pm: at91: pm_slowclock: remove clocks which are already stopped when entering slow clock mode

2015-01-28 Thread Wenyou Yang
From: Sylvain Rochet 

Assume USB PLL and PLL B are already stopped before entering sleep mode,
print a warning if this isn't the case.

Removed PLL B from slow clock code, all drivers are supposed to properly
unprepare clocks.

Signed-off-by: Sylvain Rochet 
---
 arch/arm/mach-at91/pm.c   |   12 
 arch/arm/mach-at91/pm_slowclock.S |   31 ---
 2 files changed, 12 insertions(+), 31 deletions(-)

diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index af8d8af..daa998d 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -100,6 +100,18 @@ static int at91_pm_verify_clocks(void)
}
}
 
+   /* Drivers should have previously suspended USB PLL */
+   if (at91_pmc_read(AT91_CKGR_UCKR) & AT91_PMC_UPLLEN) {
+   pr_err("AT91: PM - Suspend-to-RAM with USB PLL running\n");
+   return 0;
+   }
+
+   /* Drivers should have previously suspended PLL B */
+   if (at91_pmc_read(AT91_PMC_SR) & AT91_PMC_LOCKB) {
+   pr_err("AT91: PM - Suspend-to-RAM with PLL B running\n");
+   return 0;
+   }
+
return 1;
 }
 
diff --git a/arch/arm/mach-at91/pm_slowclock.S 
b/arch/arm/mach-at91/pm_slowclock.S
index 50744e7..e2bfaf5 100644
--- a/arch/arm/mach-at91/pm_slowclock.S
+++ b/arch/arm/mach-at91/pm_slowclock.S
@@ -59,15 +59,6 @@ tmp2 .reqr5
beq 1b
.endm
 
-/*
- * Wait until PLLB has locked.
- */
-   .macro wait_pllblock
-1: ldr tmp1, [pmc, #AT91_PMC_SR]
-   tst tmp1, #AT91_PMC_LOCKB
-   beq 1b
-   .endm
-
.text
 
 /* void at91_slow_clock(void __iomem *pmc, void __iomem *sdramc,
@@ -173,13 +164,6 @@ sdr_sr_done:
orr tmp1, tmp1, #(1 << 29)  /* bit 29 always set */
str tmp1, [pmc, #AT91_CKGR_PLLAR]
 
-   /* Save PLLB setting and disable it */
-   ldr tmp1, [pmc, #AT91_CKGR_PLLBR]
-   str tmp1, .saved_pllbr
-
-   mov tmp1, #AT91_PMC_PLLCOUNT
-   str tmp1, [pmc, #AT91_CKGR_PLLBR]
-
/* Turn off the main oscillator */
ldr tmp1, [pmc, #AT91_CKGR_MOR]
bic tmp1, tmp1, #AT91_PMC_MOSCEN
@@ -195,18 +179,6 @@ sdr_sr_done:
 
wait_moscrdy
 
-   /* Restore PLLB setting */
-   ldr tmp1, .saved_pllbr
-   str tmp1, [pmc, #AT91_CKGR_PLLBR]
-
-   tst tmp1, #(AT91_PMC_MUL &  0xff)
-   bne 1f
-   tst tmp1, #(AT91_PMC_MUL & ~0xff)
-   beq 2f
-1:
-   wait_pllblock
-2:
-
/* Restore PLLA setting */
ldr tmp1, .saved_pllar
str tmp1, [pmc, #AT91_CKGR_PLLAR]
@@ -285,9 +257,6 @@ ram_restored:
 .saved_pllar:
.word 0
 
-.saved_pllbr:
-   .word 0
-
 .saved_sam9_lpr:
.word 0
 
-- 
1.7.9.5

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


[PATCH v5 01/13] pm: at91: pm_slowclock: fix suspend/resume hang up in timeouts

2015-01-28 Thread Wenyou Yang
From: Sylvain Rochet 

Removed timeout on XTAL, PLL lock and Master Clock Ready, hang if
something went wrong instead of continuing in unknown condition. There
is not much we can do if a PLL lock never ends, we are running in SRAM
and we will not be able to connect back the sdram or ddram in order to
be able to fire up a message or just panic.

As a bonus, not decounting the timeout register in slow clock mode
reduce cumulated suspend time and resume time from ~17ms to ~15ms.

Signed-off-by: Sylvain Rochet 
---
 arch/arm/mach-at91/pm_slowclock.S |   33 -
 1 file changed, 4 insertions(+), 29 deletions(-)

diff --git a/arch/arm/mach-at91/pm_slowclock.S 
b/arch/arm/mach-at91/pm_slowclock.S
index 556151e..50744e7 100644
--- a/arch/arm/mach-at91/pm_slowclock.S
+++ b/arch/arm/mach-at91/pm_slowclock.S
@@ -25,11 +25,6 @@
  */
 #undef SLOWDOWN_MASTER_CLOCK
 
-#define MCKRDY_TIMEOUT 1000
-#define MOSCRDY_TIMEOUT1000
-#define PLLALOCK_TIMEOUT   1000
-#define PLLBLOCK_TIMEOUT   1000
-
 pmc.reqr0
 sdramc .reqr1
 ramc1  .reqr2
@@ -41,56 +36,36 @@ tmp2.reqr5
  * Wait until master clock is ready (after switching master clock source)
  */
.macro wait_mckrdy
-   mov tmp2, #MCKRDY_TIMEOUT
-1: sub tmp2, tmp2, #1
-   cmp tmp2, #0
-   beq 2f
-   ldr tmp1, [pmc, #AT91_PMC_SR]
+1: ldr tmp1, [pmc, #AT91_PMC_SR]
tst tmp1, #AT91_PMC_MCKRDY
beq 1b
-2:
.endm
 
 /*
  * Wait until master oscillator has stabilized.
  */
.macro wait_moscrdy
-   mov tmp2, #MOSCRDY_TIMEOUT
-1: sub tmp2, tmp2, #1
-   cmp tmp2, #0
-   beq 2f
-   ldr tmp1, [pmc, #AT91_PMC_SR]
+1: ldr tmp1, [pmc, #AT91_PMC_SR]
tst tmp1, #AT91_PMC_MOSCS
beq 1b
-2:
.endm
 
 /*
  * Wait until PLLA has locked.
  */
.macro wait_pllalock
-   mov tmp2, #PLLALOCK_TIMEOUT
-1: sub tmp2, tmp2, #1
-   cmp tmp2, #0
-   beq 2f
-   ldr tmp1, [pmc, #AT91_PMC_SR]
+1: ldr tmp1, [pmc, #AT91_PMC_SR]
tst tmp1, #AT91_PMC_LOCKA
beq 1b
-2:
.endm
 
 /*
  * Wait until PLLB has locked.
  */
.macro wait_pllblock
-   mov tmp2, #PLLBLOCK_TIMEOUT
-1: sub tmp2, tmp2, #1
-   cmp tmp2, #0
-   beq 2f
-   ldr tmp1, [pmc, #AT91_PMC_SR]
+1: ldr tmp1, [pmc, #AT91_PMC_SR]
tst tmp1, #AT91_PMC_LOCKB
beq 1b
-2:
.endm
 
.text
-- 
1.7.9.5

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


[PATCH v5 00/13] AT91 pm cleanup for 3.20

2015-01-28 Thread Wenyou Yang
Hi Nicolas,

This version is rebased on the branch: at91-3.20-cleanup of the repository
git://git.kernel.org/pub/scm/linux/kernel/git/nferre/linux-at91.git

It is purpose to clean up the PM code, includes the patches from Peter Rosin 
and Sylvain Rochet.

Since verifying the USB clock and USB PLL disabling before suspending to memory,
it aslo depends on the following patch serials from Sylvain:
[PATCHv6 0/5] USB: gadget: atmel_usba_udc: Driver improvements
[PATCHv7 0/6] USB: host: Atmel OHCI and EHCI drivers improvements

Removes CONFIG_AT91_SLOW_CLOCK config item to simply the PM config,
The suspend to standby mode uses the same sram function as the suspend to 
memory mode.
Remove some unused code.

Alexandr & Sylvain, Thank you very much for so many feedbacks.

Changes in v5:
 - Rebase the branch: at91-3.20-cleanup HEAD:fa9df37

Changes in v4:
 - Clear unused state argument in at91_pm_verify_clocks()
 - Remove pr_info("AT91:... slow_clock ? ..") in patch 07/13.

Changes in v3
 - Sylvain splits the patch in two
 - Add handling if no sram allocated for PM
 - Retain the STANDBY and SUSPEND_MEM select in at91_pm_enter.

Changes in v2:
 - Rebase on the at91-3.20-cleanup branch
 - Recover the verify clock condition, only for suspend to memory.
 - Collect ACK from Alexandre
 - Add the macro for PM mode

Peter Rosin (1):
  pm: at91: Workaround DDRSDRC self-refresh bug with LPDDR1 memories.

Sylvain Rochet (2):
  pm: at91: pm_slowclock: fix suspend/resume hang up in timeouts
  pm: at91: pm_slowclock: remove clocks which are already stopped when
entering slow clock mode

Wenyou Yang (10):
  pm: at91: pm_slowclock: remove the unused code related with
SLOWDOWN_MASTER_CLOCK
  pm: at91: move the copying the sram function to the sram
initializationi phase
  ARM: at91: move select SRAM to ARCH_AT91
  pm: at91: remove the config item CONFIG_AT91_SLOW_CLOCK
  pm: at91: the standby mode uses the same sram function as the suspend
to memory mode
  pm: at91: rename file name: pm_slowclock.S -->pm_suspend.S
  pm: at91: rename function name:
at91_slow_clock()-->at91_pm_suspend_sram_fn
  pm: at91: remove the at91_xxx_standby() function definitions in the
pm.h
  pm: at91: remove the data member at91_xxx_standby() of struct
ramc_ids
  pm: at91: amend the pm_suspend entry for at91_cpuidle_device

 arch/arm/mach-at91/Kconfig |   17 +-
 arch/arm/mach-at91/Makefile|2 +-
 arch/arm/mach-at91/pm.c|  166 +-
 arch/arm/mach-at91/pm.h|  100 +--
 arch/arm/mach-at91/pm_slowclock.S  |  323 
 arch/arm/mach-at91/pm_suspend.S|  277 +++
 include/soc/at91/at91sam9_ddrsdr.h |2 +-
 7 files changed, 366 insertions(+), 521 deletions(-)
 delete mode 100644 arch/arm/mach-at91/pm_slowclock.S
 create mode 100644 arch/arm/mach-at91/pm_suspend.S

-- 
1.7.9.5

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


Re: [PATCH v1 2/2] zram: remove init_lock in zram_make_request

2015-01-28 Thread Minchan Kim
On Thu, Jan 29, 2015 at 03:06:04PM +0900, Sergey Senozhatsky wrote:
> On (01/29/15 14:28), Minchan Kim wrote:
> > > I'm still concerned about performance numbers that I see on my x86_64.
> > > it's not always, but mostly slower. I'll give it another try (disable
> > > lockdep, etc.), but if we lose 10% on average then, sorry, I'm not so
> > > positive about srcu change and will tend to vote for your initial commit
> > > that simply moved meta free() out of init_lock and left locking as is
> > > (lockdep warning would have been helpful there, because otherwise it
> > > just looked like we change code w/o any reason).
> > > 
> > > what do you thunk?
> > 
> > Surely I agreee with you. If it suffers from 10% performance regression,
> > it's absolutely no go.
> > 
> > However, I believe it should be no loss because that's one of the reason
> > from RCU birth which should be really win in read-side lock path compared
> > to other locking.
> > 
> > Please test it with dd or something for block-based test for removing
> > noise from FS. I also will test it to confirm that with real machine.
> > 
> 
> do you test with a single dd thread/process?  just dd if=foo of=bar -c... or
> you start N `dd &' processes?

I tested it with multiple dd processes.

> 
> for a single writer there should be no difference, no doubt. I'm more
> interested in multi-writer/multi-reader/mixed use cases.
> 
> the options that I use are: iozone -t 3 -R -r 16K -s 60M -I +Z
> and -I is:
>   -I  Use VxFS VX_DIRECT, O_DIRECT,or O_DIRECTIO for all file operations
> 
> with O_DIRECT I don't think there is a lot of noise, but I'll try to use
> different benchmarks a bit later.
> 

As you told, the data was not stable.
Anyway, when I read down_read implementation, it's one atomic instruction.
Hmm, it seems te be better for srcu_read_lock which does more things.
But I guessed most of overhead are from [de]compression, memcpy, clear_page
That's why I guessed we don't have measurable difference from that.
What's the data pattern if you use iozone? I guess it's really simple
pattern compressor can do fast. I used /dev/sda for dd write so
more realistic data. Anyway, if we has 10% regression even if the data
is simple, I never want to merge it.
I will test it carefully and if it turns out lots regression,
surely, I will not go with this and send the original patch again.

Thanks.

> 
>   -ss

-- 
Kind regards,
Minchan Kim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] net:wan:Change location of debug printk statement in the function,hss_hdlc_poll

2015-01-28 Thread Krzysztof Hałasa
Nicholas Krause  writes:

> This changes the location of the printk for montioring if the stucture pointer
> desc of type structure desc has a error count due to failing in the switch
> statement for checking it's status from the default switch case in this switch
> to the area of the function for checking if there is a error count. Due to 
> this
> this part of the function can now be uncommented as it's now needed for 
> printing
> out important information if the structure pointer,desc has a error count for
> debugging purposes.

This error count seems to be secondary to the desc->status. It's isn't
normally logged (RX errors on serial links are quite normal) and only
the "default" case, normally not seen, would be logged (to indicate
unhandled condition). In the "normal" error path, the driver ignores
error count, because there could be several errors counted for a single
erroneous frame (or non-frame).

Also the patch seems to remove the beginning of a preprocessor directive
(#if) without removing its end (#endif). I'd be surprised if it compiles.

> --- a/drivers/net/wan/ixp4xx_hss.c
> +++ b/drivers/net/wan/ixp4xx_hss.c
> @@ -697,7 +697,6 @@ static int hss_hdlc_poll(struct napi_struct *napi, int 
> budget)
>   }
>  
>   desc = rx_desc_ptr(port, n);
> -#if 0 /* FIXME - error_count counts modulo 256, perhaps we should use it */
>   if (desc->error_count)
>   printk(KERN_DEBUG "%s: hss_hdlc_poll status 0x%02X"
>  " errors %u\n", dev->name, desc->status,
> @@ -735,9 +734,7 @@ static int hss_hdlc_poll(struct napi_struct *napi, int 
> budget)
>   dev->stats.rx_length_errors++;
>   dev->stats.rx_errors++;
>   break;
> - default:/* FIXME - remove printk */
> - netdev_err(dev, "hss_hdlc_poll: status 0x%02X errors 
> %u\n",
> -desc->status, desc->error_count);
> + default:
>   dev->stats.rx_errors++;
>   }

-- 
Krzysztof Halasa

Research Institute for Automation and Measurements PIAP
Al. Jerozolimskie 202, 02-486 Warsaw, Poland
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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.7.3 no longer applies relative symbolic link patches

2015-01-28 Thread Junio C Hamano
Junio C Hamano  writes:

> Subject: [PATCH] apply: refuse touching a file beyond symlink
>
> Because Git tracks symbolic links as symbolic links, a path that has
> a symbolic link in its leading part (e.g. path/to/dir being a
> symbolic link to somewhere else, be it inside or outside the working
> tree) can never appear in a patch that validly apply, unless the
> same patch first removes the symbolic link.

I should rephrase the above to make it more readable.

... its leading part (e.g. path/to/dir/file, where path/to/dir is a
symbolic link to somewhere else, ...

is what I meant to say.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: randconfig build error with next-20150127, in drivers/i2c/busses/i2c-designware-baytrail.c

2015-01-28 Thread Wolfram Sang
On Tue, Jan 27, 2015 at 04:41:44PM -0700, Jim Davis wrote:
> Building with the attached random configuration file,

A proper Kconfig dependency fix has already been added and is in
linux-next as of today.



signature.asc
Description: Digital signature


Re: [PATCH v2] lib/checksum.c: fix carry in csum_tcpudp_nofold

2015-01-28 Thread David Miller
From: Karl Beldan 
Date: Wed, 28 Jan 2015 10:58:11 +0100

> The carry from the 64->32bits folding was dropped, e.g with:
> saddr=0x daddr=0xFFFF len=0x proto=0 sum=1,
> csum_tcpudp_nofold returned 0 instead of 1.
> 
> Signed-off-by: Karl Beldan 

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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 06/16] ARM: cns3xxx: convert PCI to use generic config accesses

2015-01-28 Thread Krzysztof Hałasa
Rob Herring  writes:

> Convert the cns3xxx PCI driver to use the generic config access functions.
>
> This changes accesses from __raw_readl/__raw_writel to readl/writel.
>
>  arch/arm/mach-cns3xxx/pcie.c | 52 
> +---

This looks fine:
Acked-by: Krzysztof Hałasa 

-- 
Krzysztof Halasa

Research Institute for Automation and Measurements PIAP
Al. Jerozolimskie 202, 02-486 Warsaw, Poland
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] cpuidle/powernv: Read target_residency value of idle states from DT if available

2015-01-28 Thread Stewart Smith
Preeti U Murthy  writes:
> The device tree now exposes the residency values for different idle states. 
> Read
> these values instead of calculating residency from the latency values. The 
> values
> exposed in the DT are validated for optimal power efficiency. However to 
> maintain
> compatibility with the older firmware code which does not expose residency
> values, use default values as a fallback mechanism. While at it, handle some
> cleanups.

>From a "I just merged the patch that exports these values from firmware"
point of view, using them and falling back looks good.

(I find the hardcoding of snooze in the driver a bit odd, as is the
hardcoding of max power states to 8 - which could bite us in the future
if a future processor has more states... but these aren't problems with
this patch)

Acked-by: Stewart Smith 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] toshiba_acpi: Add a check for TOS_NOT_SUPPORTED in the sci_open function

2015-01-28 Thread Darren Hart
On Sun, Jan 18, 2015 at 07:17:12PM -0700, Azael Avalos wrote:
> This was "toshiba_acpi: Change sci_open function return value"
> 
> Some Toshiba laptops have "poorly implemented" SCI calls on their
> BIOSes and are not checking for sci_{open, close} calls, therefore,
> the sci_open function is failing and making some of the supported
> features unavailable (kbd backlight, touchpad, illumination, etc.).
> 
> This patch checks wheter we receive TOS_NOT_SUPPORTED and returns

   ^ whether

(checkpatch.pl would catch this)

Since I'm late in review, this one's on me ;-)

> 1, making the supported features work on such laptops.
> 
> In the case that some laptops really do not support the SCI, all the
> SCI dependent functions check for TOS_NOT_SUPPORTED, and thus, not
> registering support for the queried feature.
> 
> Signed-off-by: Azael Avalos 

Queued for 3.20.

> ---
> Darren,
> 
> Hopefully this new patch eases some of the concerns of the previous
> patch, and this time I added a comment block explaining a bit, but of
> course, let me know if there is something else that needs change.
> 
> Cheers
> Azael
> 
>  drivers/platform/x86/toshiba_acpi.c | 13 +
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/platform/x86/toshiba_acpi.c 
> b/drivers/platform/x86/toshiba_acpi.c
> index fc34a71..899ead6b 100644
> --- a/drivers/platform/x86/toshiba_acpi.c
> +++ b/drivers/platform/x86/toshiba_acpi.c
> @@ -389,6 +389,19 @@ static int sci_open(struct toshiba_acpi_dev *dev)
>   } else if (out[0] == TOS_ALREADY_OPEN) {
>   pr_info("Toshiba SCI already opened\n");
>   return 1;
> + } else if (out[0] == TOS_NOT_SUPPORTED) {
> + /* Some BIOSes do not have the SCI open/close functions
> +  * implemented and return 0x8000 (Not Supported), failing to
> +  * register some supported features.
> +  *
> +  * Simply return 1 if we hit those affected laptops to make the
> +  * supported features work.
> +  *
> +  * In the case that some laptops really do not support the SCI,
> +  * all the SCI dependent functions check for TOS_NOT_SUPPORTED,
> +  * and thus, not registering support for the queried feature.
> +  */

This is great by the way, when things are just weird/broken, this is when we
need really clear comments.

> + return 1;
>   } else if (out[0] == TOS_NOT_PRESENT) {
>   pr_info("Toshiba SCI is not present\n");
>   }

Thanks,

-- 
Darren Hart
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 2/2] afs: Prevent callback expiry timer overflow

2015-01-28 Thread Tina Ruchandani
get_seconds() returns real wall-clock seconds. On 32-bit systems
this value will overflow in year 2038 and beyond. This patch changes
afs_vnode record to use ktime_get_real_seconds() instead, for the
fields cb_expires and cb_expires_at.

Signed-off-by: Tina Ruchandani 
---
 fs/afs/fsclient.c | 2 +-
 fs/afs/inode.c| 7 ---
 fs/afs/internal.h | 4 ++--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c
index c2e930e..c775fef 100644
--- a/fs/afs/fsclient.c
+++ b/fs/afs/fsclient.c
@@ -139,7 +139,7 @@ static void xdr_decode_AFSCallBack(const __be32 **_bp, 
struct afs_vnode *vnode)
vnode->cb_version   = ntohl(*bp++);
vnode->cb_expiry= ntohl(*bp++);
vnode->cb_type  = ntohl(*bp++);
-   vnode->cb_expires   = vnode->cb_expiry + get_seconds();
+   vnode->cb_expires   = vnode->cb_expiry + ktime_get_real_seconds();
*_bp = bp;
 }
 
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 8a1d38e..6f04ede 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -244,12 +244,13 @@ struct inode *afs_iget(struct super_block *sb, struct key 
*key,
vnode->cb_version = 0;
vnode->cb_expiry = 0;
vnode->cb_type = 0;
-   vnode->cb_expires = get_seconds();
+   vnode->cb_expires = ktime_get_real_seconds();
} else {
vnode->cb_version = cb->version;
vnode->cb_expiry = cb->expiry;
vnode->cb_type = cb->type;
-   vnode->cb_expires = vnode->cb_expiry + get_seconds();
+   vnode->cb_expires = vnode->cb_expiry +
+   ktime_get_real_seconds();
}
}
 
@@ -322,7 +323,7 @@ int afs_validate(struct afs_vnode *vnode, struct key *key)
!test_bit(AFS_VNODE_CB_BROKEN, >flags) &&
!test_bit(AFS_VNODE_MODIFIED, >flags) &&
!test_bit(AFS_VNODE_ZAP_DATA, >flags)) {
-   if (vnode->cb_expires < get_seconds() + 10) {
+   if (vnode->cb_expires < ktime_get_real_seconds() + 10) {
_debug("callback expired");
set_bit(AFS_VNODE_CB_BROKEN, >flags);
} else {
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 63c97e2..36e5f05 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -375,8 +375,8 @@ struct afs_vnode {
struct rb_node  server_rb;  /* link in server->fs_vnodes */
struct rb_node  cb_promise; /* link in server->cb_promises 
*/
struct work_struct  cb_broken_work; /* work to be done on callback 
break */
-   time_t  cb_expires; /* time at which callback 
expires */
-   time_t  cb_expires_at;  /* time used to order 
cb_promise */
+   time64_tcb_expires; /* time at which callback 
expires */
+   time64_tcb_expires_at;  /* time used to order 
cb_promise */
unsignedcb_version; /* callback version */
unsignedcb_expiry;  /* callback expiry time */
afs_callback_type_t cb_type;/* type of callback */
-- 
2.2.0.rc0.207.ga3a616c

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] afs: Migrate vlocation fields to 64-bit

2015-01-28 Thread Tina Ruchandani
get_seconds() returns real wall-clock seconds. On 32-bit systems
this value will overflow in year 2038 and beyond. This patch changes
afs's vlocation record to use ktime_get_real_seconds() instead, for the
fields time_of_death and update_at.

Signed-off-by: Tina Ruchandani 
---
 fs/afs/callback.c  |  7 ---
 fs/afs/internal.h  |  7 ---
 fs/afs/server.c|  6 +++---
 fs/afs/vlocation.c | 16 +---
 4 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/fs/afs/callback.c b/fs/afs/callback.c
index 7ef637d..7d54efd 100644
--- a/fs/afs/callback.c
+++ b/fs/afs/callback.c
@@ -362,7 +362,7 @@ static void afs_callback_updater(struct work_struct *work)
 {
struct afs_server *server;
struct afs_vnode *vnode, *xvnode;
-   time_t now;
+   time64_t now;
long timeout;
int ret;
 
@@ -370,7 +370,7 @@ static void afs_callback_updater(struct work_struct *work)
 
_enter("");
 
-   now = get_seconds();
+   now = ktime_get_real_seconds();
 
/* find the first vnode to update */
spin_lock(>cb_lock);
@@ -424,7 +424,8 @@ static void afs_callback_updater(struct work_struct *work)
 
/* and then reschedule */
_debug("reschedule");
-   vnode->update_at = get_seconds() + afs_vnode_update_timeout;
+   vnode->update_at = ktime_get_real_seconds() +
+   afs_vnode_update_timeout;
 
spin_lock(>cb_lock);
 
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 71d5982..63c97e2 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -11,6 +11,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -247,7 +248,7 @@ struct afs_cache_vhash {
  */
 struct afs_vlocation {
atomic_tusage;
-   time_t  time_of_death;  /* time at which put reduced 
usage to 0 */
+   time64_ttime_of_death;  /* time at which put reduced 
usage to 0 */
struct list_headlink;   /* link in cell volume location 
list */
struct list_headgrave;  /* link in master graveyard 
list */
struct list_headupdate; /* link in master update list */
@@ -258,7 +259,7 @@ struct afs_vlocation {
struct afs_cache_vlocation vldb;/* volume information DB record 
*/
struct afs_volume   *vols[3];   /* volume access record pointer 
(index by type) */
wait_queue_head_t   waitq;  /* status change waitqueue */
-   time_t  update_at;  /* time at which record should 
be updated */
+   time64_tupdate_at;  /* time at which record should 
be updated */
spinlock_t  lock;   /* access lock */
afs_vlocation_state_t   state;  /* volume location state */
unsigned short  upd_rej_cnt;/* ENOMEDIUM count during 
update */
@@ -271,7 +272,7 @@ struct afs_vlocation {
  */
 struct afs_server {
atomic_tusage;
-   time_t  time_of_death;  /* time at which put reduced 
usage to 0 */
+   time64_ttime_of_death;  /* time at which put reduced 
usage to 0 */
struct in_addr  addr;   /* server address */
struct afs_cell *cell;  /* cell in which server resides 
*/
struct list_headlink;   /* link in cell's server list */
diff --git a/fs/afs/server.c b/fs/afs/server.c
index f342acf..3bc1a46 100644
--- a/fs/afs/server.c
+++ b/fs/afs/server.c
@@ -237,7 +237,7 @@ void afs_put_server(struct afs_server *server)
spin_lock(_server_graveyard_lock);
if (atomic_read(>usage) == 0) {
list_move_tail(>grave, _server_graveyard);
-   server->time_of_death = get_seconds();
+   server->time_of_death = ktime_get_real_seconds();
queue_delayed_work(afs_wq, _server_reaper,
   afs_server_timeout * HZ);
}
@@ -272,9 +272,9 @@ static void afs_reap_server(struct work_struct *work)
LIST_HEAD(corpses);
struct afs_server *server;
unsigned long delay, expiry;
-   time_t now;
+   time64_t now;
 
-   now = get_seconds();
+   now = ktime_get_real_seconds();
spin_lock(_server_graveyard_lock);
 
while (!list_empty(_server_graveyard)) {
diff --git a/fs/afs/vlocation.c b/fs/afs/vlocation.c
index 5297678..ee9015c 100644
--- a/fs/afs/vlocation.c
+++ b/fs/afs/vlocation.c
@@ -340,7 +340,8 @@ static void afs_vlocation_queue_for_updates(struct 
afs_vlocation *vl)
struct afs_vlocation *xvl;
 
/* wait at least 10 minutes before updating... */
-   vl->update_at = get_seconds() + afs_vlocation_update_timeout;
+   vl->update_at = ktime_get_real_seconds() +
+   afs_vlocation_update_timeout;
 
spin_lock(_vlocation_updates_lock);
 
@@ -506,7 +507,7 @@ void 

Re: [PATCH v1 2/2] zram: remove init_lock in zram_make_request

2015-01-28 Thread Sergey Senozhatsky
On (01/29/15 14:28), Minchan Kim wrote:
> > I'm still concerned about performance numbers that I see on my x86_64.
> > it's not always, but mostly slower. I'll give it another try (disable
> > lockdep, etc.), but if we lose 10% on average then, sorry, I'm not so
> > positive about srcu change and will tend to vote for your initial commit
> > that simply moved meta free() out of init_lock and left locking as is
> > (lockdep warning would have been helpful there, because otherwise it
> > just looked like we change code w/o any reason).
> > 
> > what do you thunk?
> 
> Surely I agreee with you. If it suffers from 10% performance regression,
> it's absolutely no go.
> 
> However, I believe it should be no loss because that's one of the reason
> from RCU birth which should be really win in read-side lock path compared
> to other locking.
> 
> Please test it with dd or something for block-based test for removing
> noise from FS. I also will test it to confirm that with real machine.
> 

do you test with a single dd thread/process?  just dd if=foo of=bar -c... or
you start N `dd &' processes?

for a single writer there should be no difference, no doubt. I'm more
interested in multi-writer/multi-reader/mixed use cases.

the options that I use are: iozone -t 3 -R -r 16K -s 60M -I +Z
and -I is:
-I  Use VxFS VX_DIRECT, O_DIRECT,or O_DIRECTIO for all file operations

with O_DIRECT I don't think there is a lot of noise, but I'll try to use
different benchmarks a bit later.


-ss
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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.7.3 no longer applies relative symbolic link patches

2015-01-28 Thread Junio C Hamano
Junio C Hamano  writes:

> Junio C Hamano  writes:
>
>> If the user wants to apply a patch that touches ../etc/shadow, is
>> the tool in the place to complain?"
>
> Let me take this part back.
>
> I think "git apply" should behave closely to "git apply --index"
> (which is used by "git am" unless there is a very good reason not to
> (and "'git apply --index' behaves differently from GNU patch, and we
> should match what the latter does" is not a very good reason).  When
> the index guards the working tree, we do not follow any symlink,
> whether the destination is inside the current directory or not.
>
> I however do not think the current "git apply" notices that it will
> overwrite a path beyond a symlink---we may need to fix that if that
> is the case.  I'll see what I can find (but I'll be doing 2.3-rc2
> today so it may be later this week).

Yikes.  It turns out that the index is what protects us from going
outside the working tree.  "apply --index" (hence "am") is immune
against the CVE-2015-1196, but that is not because we do not follow
symbolic links.

Also the solution is not just a simple has_symlink_leading_path().
Here is tonight's snapshot of what I've found out (not tested beyond
passing the test suite including the new test added by the patch).

-- >8 --
Subject: [PATCH] apply: refuse touching a file beyond symlink

Because Git tracks symbolic links as symbolic links, a path that has
a symbolic link in its leading part (e.g. path/to/dir being a
symbolic link to somewhere else, be it inside or outside the working
tree) can never appear in a patch that validly apply, unless the
same patch first removes the symbolic link.

Detect and reject such a patch.  Things to note:

 - Unfortunately, we cannot reuse the has_symlink_leading_path()
   from dir.c, as that is only about the working tree, but "git
   apply" can be told to apply the patch only to the index.

 - We cannot directly use has_symlink_leading_path() even when we
   are applying to the working tree, as an early patch of a valid
   input may remove a symbolic link path/to/dir and then a later
   patch of the input may create a path path/to/dir/file.  The
   leading symbolic link check must be done on the interim result we
   compute in core (i.e. after the first patch, there is no
   path/to/dir symbolic link and it is perfectly valid to create
   path/to/dir/file).  Similarly, when an input creates a symbolic
   link path/to/dir and then creates a file path/to/dir/file, we
   need to flag it as an error without actually creating path/to/dir
   symbolic link in the filesystem.

 - Instead, for any patch in the input that leaves a path (i.e. a
   non deletion) in the result, we check all leading paths against
   interim result and then either the index or the working tree.
   The interim result of applying patch is already kept track of
   by fn_table logic for us.

Signed-off-by: Junio C Hamano 
---
 builtin/apply.c | 44 +
 t/t4122-apply-symlink-inside.sh | 37 ++
 2 files changed, 81 insertions(+)

diff --git a/builtin/apply.c b/builtin/apply.c
index ef32e4f..da088c5 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -3483,6 +3483,46 @@ static int check_to_create(const char *new_name, int 
ok_if_exists)
return 0;
 }
 
+static int path_is_beyond_symlink(const char *name_)
+{
+   struct strbuf name = STRBUF_INIT;
+
+   strbuf_addstr(, name_);
+   do {
+   struct patch *previous;
+
+   while (--name.len && name.buf[name.len] != '/')
+   ; /* scan backwards */
+   if (!name.len)
+   break;
+   name.buf[name.len] = '\0';
+   previous = in_fn_table(name.buf);
+   if (previous) {
+   if (!was_deleted(previous) &&
+   !to_be_deleted(previous) &&
+   previous->new_mode &&
+   S_ISLNK(previous->new_mode))
+   goto symlink_found;
+   } else if (check_index) {
+   int pos = cache_name_pos(name.buf, name.len);
+   if (0 <= pos &&
+   S_ISLNK(active_cache[pos]->ce_mode))
+   goto symlink_found;
+   } else {
+   struct stat st;
+   if (!lstat(name.buf, ) && S_ISLNK(st.st_mode))
+   goto symlink_found;
+   }
+   } while (1);
+
+   strbuf_release();
+   return 0;
+symlink_found:
+   strbuf_release();
+   return -1;
+
+}
+
 /*
  * Check and apply the patch in-core; leave the result in patch->result
  * for the caller to write it out to the final destination.
@@ -3570,6 +3610,10 @@ static int check_patch(struct patch *patch)
}
}
 
+   if (!patch->is_delete && 

[PATCH 0/2] afs: Migrate to 64-bit timekeeping

2015-01-28 Thread Tina Ruchandani
This patchset is an attempt to port afs's timekeeping
variables from time_t type to time64_t. AFS uses
get_seconds to store real (wall clock) time in seconds.
The time returned by get_seconds() will overflow on 32-bit systems
in year 2106 and beyond.
This patchset replaces the usage with ktime_get_real_seconds.
Fields that propagate to the inode (mtime_client, mtime_server,
creation) remain untouched, as the inode timestamps are only 32bit.

Tina Ruchandani (2):
  afs: Migrate vlocation fields to 64-bit
  afs: Prevent callback expiry timer overflow

 fs/afs/callback.c  |  7 ---
 fs/afs/fsclient.c  |  2 +-
 fs/afs/inode.c |  7 ---
 fs/afs/internal.h  | 11 ++-
 fs/afs/server.c|  6 +++---
 fs/afs/vlocation.c | 16 +---
 6 files changed, 27 insertions(+), 22 deletions(-)

-- 
2.2.0.rc0.207.ga3a616c

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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/3] kprobes/ftrace/x86: Function graph trace jprobes

2015-01-28 Thread Masami Hiramatsu
(2015/01/28 13:30), Steven Rostedt wrote:
> I had these patches sitting in my repo for a while, thinking I already
> posted them. I never did, so here I go  (a little late :-/)

Oops, I might miss that.

> Basically, what I had before was fixes for jprobes and function graph
> tracing that were stepping on each other. When enabling both jprobes
> and graph tracer, it could crash the system. The fix was just to ignore
> function graph tracing while handling a jprobe. This was fine for stable
> and fixing a bug that would usually crash, but it still messes with
> function graph trace. It is still required if fentry is not used, but
> when fentry is (which is now the majority of cases - gcc > 4.6 and x86_64),
> we can trace jprobes with a little trickery.
> 
> The way this solves the issue is that on the return from the jprobe,
> we can detect if function graph tracing happened because the stack
> frame would have changed. When this is detected
>  (saved_sp == return_to_handler), the ip is changed once again to
> go preform a "fixup". The real ip is saved in r10 (callee clobber)
> and will be put back by the fixup trampoline.

Hmm, could you make this more generic? Maybe we can directly call
ftrace_return_to_handler() from longjmp_break_handler().
Actually, current implementation seems just skipping one return
address, however, there may be possible to call jprobe_return() in
the nested functions, like below;

void test_exit(int flag)
{
if (!flag)
jprobe_return();
}
int jdo_fork(...)
{
...
test_exit(something_to_test);
...
jprobe_return();
return 0;
}

I've tested similar code on this series and it crashed kernel.
(I also checked that the above example can work safely without graph tracer)

[58149.913578] Planted jprobe at 8109a2a0, handler addr a007e030
[58152.642572] jprobe: clone_flags = 0x1200011, stack_start = 0x0 stack_size = 
0x0
[58152.642923]  never_ret: 18874385,   (null)
[58152.664210] jprobe at 8109a2a0 unregistered
[58152.667840] kernel tried to execute NX-protected page - exploit attempt? 
(uid: 1000)
[58152.668796] BUG: unable to handle kernel paging request at 7fffae3c30a0
[58152.668796] IP: [<7fffae3c30a0>] 0x7fffae3c30a0
[58152.668796] PGD 42cb66067 PUD 42b708067 PMD 42a464067 PTE 800413146065
[58152.668796] Oops: 0011 [#1] SMP
[58152.668796] Modules linked in: jprobe_example(E) nls_utf8 isofs cirrus 
drm_kms_helper ttm drm ppdev crct10dif_pclmul crc32_pclmul parport_pc 
virtio_net i2c_piix4 parport crc32c_intel virtio_balloon
serio_raw ghash_clmulni_intel virtio_blk virtio_pci virtio_ring ata_generic 
virtio pata_acpi [last unloaded: jprobe_example]
[58152.668796] CPU: 0 PID: 12992 Comm: bash Tainted: GE  
3.19.0-rc3+ #1
[58152.668796] Hardware name: Fedora Project OpenStack Nova, BIOS 
1.7.5-20140709_153950- 04/01/2014
[58152.668796] task: 88042c4fb8a0 ti: 88042b638000 task.ti: 
88042b638000
[58152.668796] RIP: 0010:[<7fffae3c30a0>]  [<7fffae3c30a0>] 
0x7fffae3c30a0
[58152.668796] RSP: 0018:88042b63bf48  EFLAGS: 00010282
[58152.668796] RAX: 0027 RBX:  RCX: 8800bbae0100
[58152.668796] RDX:  RSI:  RDI: a007e089
[58152.668796] RBP: 88042b63bf40 R08: 0cc8 R09: 88042bfffcd8
[58152.668796] R10: 000c R11: 0cc8 R12: 7fffae3c3060
[58152.668796] R13:  R14:  R15: 01d63470
[58152.668796] FS:  7fdfbb57a700() GS:88043fc0() 
knlGS:
[58152.668796] CS:  0010 DS:  ES:  CR0: 80050033
[58152.668796] CR2: 7fffae3c30a0 CR3: 00042b58b000 CR4: 000406f0
[58152.668796] Stack:
[58152.668796]  8176a9c8 817682e9 01d63470 

[58152.668796]   7fffae3c3060 7fffae3c30a0 

[58152.668796]  0246 7fdfbb57a9d0  

[58152.668796] Call Trace:
[58152.668796]  [] ftrace_graph_caller+0xa8/0xa8
[58152.668796]  [] __bad_area_nosemaphore+0x8d/0x220
[58152.668796]  [] ? system_call_fastpath+0x12/0x17
[58152.668796] Code:  Bad RIP value.
[58152.668796] RIP  [<7fffae3c30a0>] 0x7fffae3c30a0
[58152.668796]  RSP 
[58152.668796] CR2: 7fffae3c30a0
[58152.668796] [ cut here ]

Thank you,

-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu...@hitachi.com


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


[PATCH v3] ocfs2: Use 64bit variables to track heartbeat time

2015-01-28 Thread Tina Ruchandani
o2hb_elapsed_msecs computes the time taken for a disk heartbeat.
'struct timeval' variables are used to store start and end  times.
On 32-bit systems, the 'tv_sec' component of 'struct timeval' will
overflow in year 2038 and beyond.
This patch solves the overflow with the following:
1.  Replace o2hb_elapsed_msecs using 'ktime_t' values to measure start
and end time, and built-in function 'ktime_ms_delta' to compute the
elapsed time.
ktime_get_real() is used since the code prints out the wallclock time.
2.  Changes format string to print time as a single 64-bit nanoseconds
value ("%lld") instead of seconds and microseconds. This simplifies
the code since converting ktime_t to that format would need expensive
computation. However, the debug log string is less readable than the
previous format.

Suggested by: Arnd Bergmann 
Signed-off-by: Tina Ruchandani 
---
Changes in v3:
- Remove usage of timespec64 as its inefficient, change the prints
  format string instead.
Changes in v2:
- Use ktime_t instead of timespec64 to simplify computation of
  elapsed time.
- Use ktime_ms_delta instead of timespec64_sub and
  dividing, since 32-bit kernel cannot divide a 64-bit number.
---
 fs/ocfs2/cluster/heartbeat.c | 49 
 1 file changed, 9 insertions(+), 40 deletions(-)

diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 16eff45..3a60c832 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -36,7 +36,7 @@
 #include 
 #include 
 #include 
-
+#include 
 #include "heartbeat.h"
 #include "tcp.h"
 #include "nodemanager.h"
@@ -1061,37 +1061,6 @@ bail:
return ret;
 }

-/* Subtract b from a, storing the result in a. a *must* have a larger
- * value than b. */
-static void o2hb_tv_subtract(struct timeval *a,
-struct timeval *b)
-{
-   /* just return 0 when a is after b */
-   if (a->tv_sec < b->tv_sec ||
-   (a->tv_sec == b->tv_sec && a->tv_usec < b->tv_usec)) {
-   a->tv_sec = 0;
-   a->tv_usec = 0;
-   return;
-   }
-
-   a->tv_sec -= b->tv_sec;
-   a->tv_usec -= b->tv_usec;
-   while ( a->tv_usec < 0 ) {
-   a->tv_sec--;
-   a->tv_usec += 100;
-   }
-}
-
-static unsigned int o2hb_elapsed_msecs(struct timeval *start,
-  struct timeval *end)
-{
-   struct timeval res = *end;
-
-   o2hb_tv_subtract(, start);
-
-   return res.tv_sec * 1000 + res.tv_usec / 1000;
-}
-
 /*
  * we ride the region ref that the region dir holds.  before the region
  * dir is removed and drops it ref it will wait to tear down this
@@ -1102,7 +1071,7 @@ static int o2hb_thread(void *data)
int i, ret;
struct o2hb_region *reg = data;
struct o2hb_bio_wait_ctxt write_wc;
-   struct timeval before_hb, after_hb;
+   ktime_t before_hb, after_hb;
unsigned int elapsed_msec;

mlog(ML_HEARTBEAT|ML_KTHREAD, "hb thread running\n");
@@ -1119,18 +1088,18 @@ static int o2hb_thread(void *data)
 * hr_timeout_ms between disk writes. On busy systems
 * this should result in a heartbeat which is less
 * likely to time itself out. */
-   do_gettimeofday(_hb);
+   before_hb = ktime_get_real();

ret = o2hb_do_disk_heartbeat(reg);

-   do_gettimeofday(_hb);
-   elapsed_msec = o2hb_elapsed_msecs(_hb, _hb);
+   after_hb = ktime_get_real();
+
+   elapsed_msec = (unsigned int)
+   ktime_ms_delta(after_hb, before_hb);

mlog(ML_HEARTBEAT,
-"start = %lu.%lu, end = %lu.%lu, msec = %u, ret = %d\n",
-before_hb.tv_sec, (unsigned long) before_hb.tv_usec,
-after_hb.tv_sec, (unsigned long) after_hb.tv_usec,
-elapsed_msec, ret);
+"start = %lld, end = %lld, msec = %u, ret = %d\n",
+before_hb.tv64, after_hb.tv64, elapsed_msec, ret);
 
if (!kthread_should_stop() &&
elapsed_msec < reg->hr_timeout_ms) {
-- 
2.2.0.rc0.207.ga3a616c

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] AFS: Correctly use 64-bit time for UUID

2015-01-28 Thread Tina Ruchandani
UUID calculation uses 'struct timespec' whose seconds will overflow
in year 2038 and beyond for 32-bit systems. This patch removes the
dependency on 'struct timespec' by using ktime_get_real_ns().
While the patch does not fix a 'bug' as such, it is part of a larger
effort to remove instances of 'struct timespec' and other data-structures
suffering from y2038 problem from the kernel.

Suggested-by: Arnd Bergmann 
Signed-off-by: Tina Ruchandani 
---
 fs/afs/main.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/afs/main.c b/fs/afs/main.c
index 35de0c0..7a9c2e6 100644
--- a/fs/afs/main.c
+++ b/fs/afs/main.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "internal.h"
 
 MODULE_DESCRIPTION("AFS Client File System");
@@ -37,7 +38,6 @@ struct workqueue_struct *afs_wq;
  */
 static int __init afs_get_client_UUID(void)
 {
-   struct timespec ts;
u64 uuidtime;
u16 clockseq;
int ret;
@@ -48,9 +48,7 @@ static int __init afs_get_client_UUID(void)
if (ret < 0)
return ret;
 
-   getnstimeofday();
-   uuidtime = (u64) ts.tv_sec * 1000 * 1000 * 10;
-   uuidtime += ts.tv_nsec / 100;
+   uuidtime = ktime_get_real_ns() / 100;
uuidtime += AFS_UUID_TO_UNIX_TIME;
afs_uuid.time_low = uuidtime;
afs_uuid.time_mid = uuidtime >> 32;
-- 
2.2.0.rc0.207.ga3a616c

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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] tpm: fix suspend/resume paths for TPM 2.0

2015-01-28 Thread Jarkko Sakkinen
Fixed suspend/resume paths for TPM 2.0 and consolidated all the
associated code to the tpm_pm_suspend() and tpm_pm_resume()
functions. Resume path should be handled by the firmware, i.e.
Startup(CLEAR) for hibernate and Startup(STATE) for suspend.

There might be some non-PC embedded devices in the future where
Startup() is not the handled by the FW but fixing the code for
those IMHO should be postponed until there is hardware available
to test the fixes although extra Startup in the driver code is
essentially a NOP.

Added Shutdown(CLEAR) to the remove paths of TIS and CRB drivers.
Changed tpm2_shutdown() to a void function because there isn't
much you can do except print an error message if this fails with
a system error.

Reported-by: Peter Hüwe 
Signed-off-by: Jarkko Sakkinen 
---
 drivers/char/tpm/tpm-interface.c |  6 --
 drivers/char/tpm/tpm.h   |  2 +-
 drivers/char/tpm/tpm2-cmd.c  | 19 +++
 drivers/char/tpm/tpm_crb.c   | 20 +---
 drivers/char/tpm/tpm_tis.c   | 26 +-
 5 files changed, 34 insertions(+), 39 deletions(-)

diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index bf53a37..e85d341 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -901,8 +901,10 @@ int tpm_pm_suspend(struct device *dev)
if (chip == NULL)
return -ENODEV;
 
-   if (chip->flags & TPM_CHIP_FLAG_TPM2)
-   return tpm2_shutdown(chip, TPM2_SU_CLEAR);
+   if (chip->flags & TPM_CHIP_FLAG_TPM2) {
+   tpm2_shutdown(chip, TPM2_SU_STATE);
+   return 0;
+   }
 
/* for buggy tpm, flush pcrs with extend to selected dummy */
if (tpm_suspend_pcr) {
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 7b0727c..a2ce379 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -432,7 +432,7 @@ ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 
property_id,
u32 *value, const char *desc);
 
 extern int tpm2_startup(struct tpm_chip *chip, u16 startup_type);
-extern int tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type);
+extern void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type);
 extern unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *, u32);
 extern int tpm2_do_selftest(struct tpm_chip *chip);
 extern int tpm2_gen_interrupt(struct tpm_chip *chip, bool quiet);
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index 1abe650..f2f38a5 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -456,20 +456,23 @@ static const struct tpm_input_header tpm2_shutdown_header 
= {
  * @chip:  TPM chip to use.
  * @shutdown_type  shutdown type. The value is either
  * TPM_SU_CLEAR or TPM_SU_STATE.
- *
- * 0 is returned when the operation is successful. If a negative number is
- * returned it remarks a POSIX error code. If a positive number is returned
- * it remarks a TPM error.
  */
-int tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type)
+void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type)
 {
struct tpm2_cmd cmd;
+   int rc;
 
cmd.header.in = tpm2_shutdown_header;
-
cmd.params.startup_in.startup_type = cpu_to_be16(shutdown_type);
-   return tpm_transmit_cmd(chip, , sizeof(cmd),
-   "stopping the TPM");
+
+   rc = tpm_transmit_cmd(chip, , sizeof(cmd), "stopping the TPM");
+
+   /* In places where shutdown command is sent there's no much we can do
+* except print the error code on a system failure.
+*/
+   if (rc < 0)
+   dev_warn(chip->pdev, "transmit returned %d while stopping the 
TPM",
+rc);
 }
 EXPORT_SYMBOL_GPL(tpm2_shutdown);
 
diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
index 3dd23cf..b26ceee 100644
--- a/drivers/char/tpm/tpm_crb.c
+++ b/drivers/char/tpm/tpm_crb.c
@@ -95,21 +95,7 @@ struct crb_priv {
u8 __iomem *rsp;
 };
 
-#ifdef CONFIG_PM_SLEEP
-static int crb_resume(struct device *dev)
-{
-   int rc;
-   struct tpm_chip *chip = dev_get_drvdata(dev);
-
-   rc = tpm2_shutdown(chip, TPM2_SU_STATE);
-   if (!rc)
-   rc = tpm2_do_selftest(chip);
-
-   return rc;
-}
-#endif
-
-static SIMPLE_DEV_PM_OPS(crb_pm, tpm_pm_suspend, crb_resume);
+static SIMPLE_DEV_PM_OPS(crb_pm, tpm_pm_suspend, tpm_pm_resume);
 
 static u8 crb_status(struct tpm_chip *chip)
 {
@@ -326,6 +312,10 @@ static int crb_acpi_remove(struct acpi_device *device)
struct tpm_chip *chip = dev_get_drvdata(dev);
 
tpm_chip_unregister(chip);
+
+   if (chip->flags & TPM_CHIP_FLAG_TPM2)
+   tpm2_shutdown(chip, TPM2_SU_CLEAR);
+
return 0;
 }
 
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 6725bef..e12b3ab 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ 

Re: [PATCH 1/6] soc: qcom: gsbi: Add support for ADM CRCI muxing

2015-01-28 Thread Andy Gross
On Wed, Jan 28, 2015 at 06:11:50PM -0800, Stephen Boyd wrote:



> >  Required properties:
> > -- compatible: must contain "qcom,gsbi-v1.0.0" for APQ8064/IPQ8064
> > +- compatible:  Should contain:
> > +   "qcom,gsbi-ipq8064" for IPQ8064
> > +   "qcom,gsbi-apq8064" for APQ8064
> > +   "qcom,gsbi-msm8960" for MSM8960
> > +   "qcom,gsbi-msm8660" for MSM8660
> 
> Hopefully this is not necessary, but if it is we should leave the
> old compatible here and say it's deprecated or something.

Right.  I went back and forth with the tcsr vs gsbi.  If change the compats I'll
put in a deprecated.

> >  - reg: Address range for GSBI registers
> >  - clocks: required clock
> >  - clock-names: must contain "iface" entry
> >  - qcom,mode : indicates MUX value for configuration of the serial 
> > interface.
> >Please reference dt-bindings/soc/qcom,gsbi.h for valid mux values.
> > +- qcom,gsbi-num: indicates GSBI instance number
> 
> Why not use DT aliases for this? Then other drivers or more
> generic code can search for a gsbiN alias for the particular gsbi
> node. No qcom specific property.

Yeah thats cleaner.  I'll do that.

> 
> > +- syscon-tcsr: indicates phandle of TCSR syscon node
> 
> Make this optional but required if any child nodes use dma?

To enforce that I'd have to determine that a child has a dmas.  I guess that
isn't so bad.



> >  static int gsbi_probe(struct platform_device *pdev)
> >  {
> > struct device_node *node = pdev->dev.of_node;
> > +   const struct of_device_id *match;
> > struct resource *res;
> > void __iomem *base;
> > struct gsbi_info *gsbi;
> > +   u32 gsbi_num, i, val;
> 
> i should be int
> 
> > +   struct crci_config *config;
> 
> const?

will fix both.

> >  
> > gsbi = devm_kzalloc(>dev, sizeof(*gsbi), GFP_KERNEL);
> >  
> > @@ -45,6 +152,20 @@ static int gsbi_probe(struct platform_device *pdev)
> > if (IS_ERR(base))
> > return PTR_ERR(base);
> >  
> > +   gsbi->tcsr = syscon_regmap_lookup_by_phandle(node, "syscon-tcsr");
> > +   if (IS_ERR(gsbi->tcsr))
> > +   return -EINVAL;
> > +
> > +   if (of_property_read_u32(node, "qcom,gsbi-num", _num)) {
> > +   dev_err(>dev, "missing gsbi instance number\n");
> > +   return -EINVAL;
> > +   }
> 
> As said before, aliases would do the job the same and not require
> some qcom specific property.

Yup. will fix.

> > +
> > +   if (!gsbi_num || gsbi_num > MAX_GSBI) {
> > +   dev_err(>dev, "invalid gsbi number\n");
> > +   return -EINVAL;
> > +   }
> > +
> > if (of_property_read_u32(node, "qcom,mode", >mode)) {
> > dev_err(>dev, "missing mode configuration\n");
> > return -EINVAL;
> > @@ -64,6 +185,26 @@ static int gsbi_probe(struct platform_device *pdev)
> > writel_relaxed((gsbi->mode << GSBI_PROTOCOL_SHIFT) | gsbi->crci,
> > base + GSBI_CTRL_REG);
> >  
> > +   /*
> > +* modify tcsr to reflect mode and ADM CRCI mux
> > +* Each gsbi contains a pair of bits, one for RX and one for TX
> > +* SPI mode requires both bits cleared, otherwise they are set
> > +*/
> > +   match = of_match_node(gsbi_dt_match, node);
> 
> Why not match the config to the TCSR compatible string? Wouldn't
> that more accurately reflect that we need to set different bits
> depending on which type of TCSR we're using? The version of GSBI
> hardware is not actually changing in every different SoC so I
> don't see why we want to change the compatible there just because
> the TCSR register layout changed.

That is true.  However, with the gsbi compat, I avoid doing a match multiple
times and get the table I need immediately.  The alternative is N checks or
pulling the compat strings and comparing them to get the right table.

> > +   config = (struct crci_config *)match->data;
> 
> Cast shouldn't be necessary if config is const?

will check if that works

> > +
> > +   if (config)
> > +   for (i = 0; i < config->num_rows; i++) {
> > +   if (gsbi->mode == GSBI_PROT_SPI)
> 
> Doesn't I2C need the same treatment (anything in QUP really)?
> Maybe the logic could be changed to check for gsbi->crci ==
> GSBI_CRCI_QUP?

Nope.  I2C doesn't support DMA when ADM is the controller.  It's only SPI or
UART.

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@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: Edited kexec_load(2) [kexec_file_load()] man page for review

2015-01-28 Thread Michael Kerrisk (man-pages)
On 29 January 2015 at 02:27, Scot Doyle  wrote:
> On Wed, 28 Jan 2015, Vivek Goyal wrote:
>> On Wed, Jan 28, 2015 at 10:10:59PM +, Scot Doyle wrote:
>> > On Wed, 28 Jan 2015, Vivek Goyal wrote:
>> > > On Wed, Jan 28, 2015 at 09:14:03PM +, Scot Doyle wrote:
>> > > > When I tested, kexec_file_load required CONFIG_RELOCATABLE. Is the same
>> > > > true for kexec_load? Would it make sense to note this in the man pages
>> > > > along with the need for CONFIG_KEXEC_FILE, etc? Or as an error message?
>> > >
>> > > Hmm.., I can't see an explicity dependency between RELOCATABLE and
>> > > KEXEC. Both KEXEC and KEXEC_FILE should be able to load a kernel
>> > > even if it had RELOCATABLE=n.
>> > >
>> > > Just that kernel will run from the address it has been built for.
>> > >
>> > > Thanks
>> > > Vivek
>> >
>> > Confusing, right? kexec_file_load returns -ENOEXEC and dmesg says
>> > "kexec-bzImage64: XLF_CAN_BE_LOADED_ABOVE_4G is not set." which leads to
>> > arch/x86/boot/header.S line 396:
>> >
>> > #if defined(CONFIG_RELOCATABLE) && defined(CONFIG_X86_64)
>> >/* kernel/boot_param/ramdisk could be loaded above 4g */
>> > # define XLF1 XLF_CAN_BE_LOADED_ABOVE_4G
>> > #else
>> > # define XLF1 0
>> > #endif
>>
>> Ah, this one. Actually generic kexec file loading implementation does not
>> impose this restriction. It is the image specific loader part which
>> decides what kind of bzImage it can load.
>>
>> Current implementation (kexec-bzimage64.c), is only supporting loading
>> bzImages which are 64bit and can be loaded above 4G. This simplifies
>> the implementation of loader.
>>
>> But there is nothing which prevents one from implementing other image
>> loaders.
>>
>> So instead of saying that kexec_file_load() depends on CONFIG_RELOCATABLE,
>> it might be better to say in man page that currently this system call
>> supports only loading a bzImage which is 64bit and which can be loaded
>> above 4G too.
>>
>> Thanks
>> Vivek
>
> Thanks, I agree, and think it would make sense to list them as part of the
> page's ENOEXEC error.

Scott, could you then phras a couple of sentences that capture thge
details, so I can add it to the ENOEXEC error?

Thanks,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] x86: Add Isolated Memory Regions for Quark X1000

2015-01-28 Thread Darren Hart
On Wed, Jan 28, 2015 at 06:36:25PM +, Bryan O'Donoghue wrote:
> Intel's Quark X1000 SoC contains a set of registers called Isolated Memory
> Regions. IMRs are accessed over the IOSF mailbox interface. IMRs are areas
> carved out of memory that define read/write access rights to the various
> system agents within the Quark system. For a given agent in the system it is
> possible to specify if that agent may read or write an area of memory
> defined by an IMR with a granularity of 1 KiB.
> 
> Quark_SecureBootPRM_330234_001.pdf section 4.5 details the concept of IMRs
> quark-x1000-datasheet.pdf section 12.7.4 details the implementation of IMRs
> in silicon.
> 
> eSRAM flush, CPU Snoop write-only, CPU SMM Mode, CPU non-SMM mode, RMU and
> PCIe Virtual Channels (VC0 and VC1) can have individual read/write access
> masks applied to them for a given memory region in Quark X1000. This
> enables IMRs to treat each memory transaction type listed above on an
> individual basis and to filter appropriately based on the IMR access mask
> for the memory region. Quark supports eight IMRs.
> 
> Since all of the DMA capable SoC components in the X1000 are mapped to VC0
> it is possible to define sections of memory as invalid for DMA write
> operations originating from Ethernet, USB, SD and any other DMA capable
> south-cluster component on VC0. Similarly it is possible to mark kernel
> memory as non-SMM mode read/write only or to mark BIOS runtime memory as SMM
> mode accessible only depending on the particular memory footprint on a given
> system.
> 
> On an IMR violation Quark SoC X1000 systems are configured to reset the
> system, so ensuring that the IMR memory map is consistent with the EFI
> provided memory map is critical to ensure no IMR violations reset the
> system.
> 
> The API for accessing IMRs is based on MTRR code but doesn't provide a /proc
> or /sys interface to manipulate IMRs. Defining the size and extent of IMRs
> is exclusively the domain of in-kernel code.
> 
> Quark firmware sets up a series of locked IMRs around pieces of memory that
> firmware owns such as ACPI runtime data. During boot a series of unlocked
> IMRs are placed around items in memory to guarantee no DMA modification of
> those items can take place. Grub also places an unlocked IMR around the
> kernel boot params data structure and compressed kernel image. It is
> necessary for the kernel to tear down all unlocked IMRs in order to ensure
> that the kernel's view of memory passed via the EFI memory map is consistent
> with the IMR memory map. Without tearing down all unlocked IMRs on boot
> transitory IMRs such as those used to protect the compressed kernel image
> will cause IMR violations and system reboots.
> 
> The IMR init code tears down all unlocked IMRs and sets a protective IMR
> around the kernel .text and .rodata as one contiguous block. This sanitizes
> the IMR memory map with respect to the EFI memory map and protects the
> read-only portions of the kernel from unwarranted DMA access.
> 
> Signed-off-by: Bryan O'Donoghue 

Most of my concerns were addressed by V3 or so, but I've followed along and
concur with the subsequent improvements.

Reviewed-by: Darren Hart 

-- 
Darren Hart
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 v2 linux-trace 1/8] tracing: attach eBPF programs to tracepoints and syscalls

2015-01-28 Thread Masami Hiramatsu
(2015/01/29 13:40), Alexei Starovoitov wrote:
> On Wed, Jan 28, 2015 at 4:46 PM, Namhyung Kim  wrote:
>>>
>>> +static int event_filter_release(struct inode *inode, struct file *filp)
>>> +{
>>> + struct ftrace_event_file *file;
>>> + char buf[2] = "0";
>>> +
>>> + mutex_lock(_mutex);
>>> + file = event_file_data(filp);
>>> + if (file) {
>>> + if (file->flags & TRACE_EVENT_FL_BPF) {
>>> + /* auto-disable the filter */
>>> + ftrace_event_enable_disable(file, 0);
>>
>> Hmm.. what if user already enabled an event, attached a bpf filter and
>> then detached the filter - I'm not sure we can always auto-disable
>> it..
> 
> why not?
> I think it makes sense auto enable/disable, since that
> is cleaner user experience.

Maybe, would we need a reference counter for each event? :)

Actually, ftrace event is not similar to perf-event which ktap
is based on, ftrace event interface is always exported via
debugfs, this means users can share the event for different
usage.

One possible other solution is to add a instance-lock interface
for each ftrace instance and lock it by bpf. Then, other users
can not enable/disable the events in the instance.

Thank you,


-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu...@hitachi.com


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


Re: [PATCH] ARM: /proc/atags: Export also for DT

2015-01-28 Thread Jean-Christophe PLAGNIOL-VILLARD

> On Jan 28, 2015, at 3:19 PM, Pavel Machek  wrote:
> 
> Hi!
> 
>>> In other words, what prevents someone from creating, say, a custom 
>>> minimal Barebox version that sits on top of the existing N900 
>>> bootloader?  Wouldn't that provide a much better user experience?
>> 
>> I do agree with Nicolas
>> 
>> If I can get my hand on a phone I’ll put barebox on it
> 
> Grab it in the nearest "second hand cellphones" shop, and have fun! It
> should be less than $70.

will see if I can found one in Shanghai at the second hand market

Does it exist a qemu emulation?

Best Regards,
J.
>   Pavel
> -- 
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) 
> http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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


Re: mmotm 2015-01-22-15-04: qemu failure due to 'mm: memcontrol: remove unnecessary soft limit tree node test'

2015-01-28 Thread Christoph Lameter
On Tue, 27 Jan 2015, Michal Hocko wrote:

> Admittedly, I was checking only SLAB allocator when reviewing and
> assuming SLUB would behave in the same way :/
> But maybe I have misinterpreted the slab code as well and
> get_node(struct kmem_cache *, int node) returns non-NULL for !online
> nodes.

Oh. Just allocate from node 12345 in SLAB and you will also have a strange
failure.

> I have briefly checked the code and it seems that many users are aware
> of this and use the same construct Johannes used in the end or they use
> cpu_to_node. But then there are other users doing:
> net/openvswitch/flow_table.c:
> /* Initialize the default stat node. */
> stats = kmem_cache_alloc_node(flow_stats_cache,
>   GFP_KERNEL | __GFP_ZERO, 0);
>
> and this can blow up if Node0 is not online. I haven't checked other

Node 0 is special in many architectures and is guaranteed to exist.
PowerPC is a notable exception which causes frequent issues with NUMA
changes.

> That being said I have no problem with checking node_online in the memcg
> code which was reported to blow up here. I am just thinking whether it
> is safe to simply blow up like that.

Node numbers must be legitimate in order to be used. Same thing with
processor numbers. We cannot always check if they are online. The numbers
in use must be sane. We have notifier subsystems that do callbacks to
allow subsystems to add and remove new nodes and processors. Those should
be used to ensure that only legitimate node and processor numbers are
used.


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


[PATCH v2 02/02] STAGING: Fix pcl818.c coding style issue: line over 80 characters

2015-01-28 Thread Simon Guo
Correct one coding style problem(detected by checkpatch.pl) in pcl818.c.
- line over 80 characters

Signed-off-by: Simon Guo 
---
 drivers/staging/comedi/drivers/pcl818.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/pcl818.c 
b/drivers/staging/comedi/drivers/pcl818.c
index 5d9050c..2b8a05e 100644
--- a/drivers/staging/comedi/drivers/pcl818.c
+++ b/drivers/staging/comedi/drivers/pcl818.c
@@ -297,9 +297,11 @@ static const struct pcl818_board boardtypes[] = {
 
 struct pcl818_private {
struct comedi_isadma *dma;
-   unsigned int ns_min;/*  manimal allowed delay between samples (in 
us) for actual card */
+   /*  manimal allowed delay between samples (in us) for actual card */
+   unsigned int ns_min;
int i8253_osc_base; /*  1/frequency of on board oscilator in ns */
-   unsigned int act_chanlist[16];  /*  MUX setting for actual AI 
operations */
+   /*  MUX setting for actual AI operations */
+   unsigned int act_chanlist[16];
unsigned int act_chanlist_len;  /*  how long is actual MUX list */
unsigned int act_chanlist_pos;  /*  actual position in MUX list */
unsigned int divisor1;
@@ -641,7 +643,8 @@ static int check_channel_list(struct comedi_device *dev,
break;
nowmustbechan =
(CR_CHAN(chansegment[i - 1]) + 1) % s->n_chan;
-   if (nowmustbechan != CR_CHAN(chanlist[i])) {/*  
channel list isn't continuous :-( */
+   if (nowmustbechan != CR_CHAN(chanlist[i])) {
+   /*  channel list isn't continuous :-( */
dev_dbg(dev->class_dev,
"channel list must be continuous! 
chanlist[%i]=%d but must be %d or %d!\n",
i, CR_CHAN(chanlist[i]), nowmustbechan,
@@ -1147,8 +1150,10 @@ static int pcl818_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
devpriv->ns_min = board->ns_min;
 
if (!board->is_818) {
-   if ((it->options[6] == 1) || (it->options[6] == 100))
-   devpriv->ns_min = 1;/* extended PCL718 to 
100kHz DAC */
+   if ((it->options[6] == 1) || (it->options[6] == 100)) {
+   /* extended PCL718 to 100kHz DAC */
+   devpriv->ns_min = 1;
+   }
}
 
pcl818_reset(dev);
-- 
1.8.1.2

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


  1   2   3   4   5   6   7   8   9   10   >