From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752888AbbCKMpJ (ORCPT ); Wed, 11 Mar 2015 08:45:09 -0400 Received: from down.free-electrons.com ([37.187.137.238]:51476 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751176AbbCKMpC (ORCPT ); Wed, 11 Mar 2015 08:45:02 -0400 Message-ID: <550038C9.7010807@free-electrons.com> Date: Wed, 11 Mar 2015 13:44:57 +0100 From: Gregory CLEMENT User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Stas Sergeev CC: Andrew Morton , Linux kernel , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] n_tty: use kmalloc() instead of vmalloc() to avoid crash on armada-xp References: <54FF21BE.2040506@list.ru> In-Reply-To: <54FF21BE.2040506@list.ru> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Stas, On 10/03/2015 17:54, Stas Sergeev wrote: > Hello, the patch below is needed for a successful boot on armada-xp. > I am really surprised by this patch because I used the Armada XP based board in a daily base and I never saw this issue. Could you provide your .config? Also could you confirm that you use the dts from arch/arm/boot/dts wihtout any change? Thanks, Gregory > -=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=- > This fixes the following crash at boot: > > Unhandled fault: external abort on non-linefetch (0x808) at 0xf00ca018 > Internal error: : 808 [#1] SMP ARM > > CPU: 2 PID: 1 Comm: swapper/0 Not tainted 4.0.0-rc1 #3 > Hardware name: Marvell Armada 370/XP (Device Tree) > task: ed41e800 ti: ed43e000 task.ti: ed43e000 > PC is at _set_bit+0x28/0x50 > LR is at n_tty_set_termios+0x328/0x358 > pc : [] lr : [] psr: 40000113 > sp : ed43fd00 ip : 00000000 fp : 00000000 > r10: 00000002 r9 : 00000000 r8 : ec930200 > r7 : 00000000 r6 : f00ca018 r5 : f00ca000 r4 : ed69cc00 > r3 : 00002000 r2 : 00002000 r1 : f00ca018 r0 : 00000000 > Flags: nZcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel > Control: 10c5387d Table: 0000406a DAC: 00000015 > Process swapper/0 (pid: 1, stack limit = 0xed43e220) > > The offending instruction in _set_bit() is "strex r0, r2, [r1]" > For some reason the exclusive access instructions do not like the > vmalloc() space... While there may be another fix to make them > fine about vmalloc() space, it still looks like a good idea to > use kmalloc() for allocating a small (sub-page) struct. > > Signed-off-by: Stas Sergeev > --- > drivers/tty/n_tty.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c > index cf6e0f2..e03622e 100644 > --- a/drivers/tty/n_tty.c > +++ b/drivers/tty/n_tty.c > @@ -50,7 +50,6 @@ > #include > #include > #include > -#include > > > /* number of characters left in xmit buffer before select has we have > room */ > @@ -1892,7 +1891,7 @@ static void n_tty_close(struct tty_struct *tty) > if (tty->link) > n_tty_packet_mode_flush(tty); > > - vfree(ldata); > + kfree(ldata); > tty->disc_data = NULL; > } > > @@ -1911,7 +1910,7 @@ static int n_tty_open(struct tty_struct *tty) > struct n_tty_data *ldata; > > /* Currently a malloc failure here can panic */ > - ldata = vmalloc(sizeof(*ldata)); > + ldata = kmalloc(sizeof(*ldata), GFP_KERNEL); > if (!ldata) > goto err; > > -- Gregory Clement, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com