linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vineet Gupta <vineet.gupta1@synopsys.com>
To: Eugeniy Paltsev <eugeniy.paltsev@synopsys.com>,
	<linux-snps-arc@lists.infradead.org>
Cc: Alexey Brodkin <alexey.brodkin@synopsys.com>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/5] ARCv2: introduce unaligned access under a Kconfig option
Date: Fri, 1 Feb 2019 15:27:45 -0800	[thread overview]
Message-ID: <f95135f7-20e3-1897-d3dc-e8dadf8a2ac5@synopsys.com> (raw)
In-Reply-To: <20190130163244.10870-3-Eugeniy.Paltsev@synopsys.com>

On 1/30/19 8:32 AM, Eugeniy Paltsev wrote:
> As of today we enable unaligned access unconditionally on ARCv2.
> Lets move it under Kconfig option so we can disable it in case of
> using HW configuration which lacks of it.
> 
> Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
> ---
>  arch/arc/Kconfig                      |  8 ++++++++
>  arch/arc/include/asm/irqflags-arcv2.h |  4 ++++
>  arch/arc/kernel/head.S                | 14 +++++++++-----
>  arch/arc/kernel/intc-arcv2.c          |  2 +-
>  4 files changed, 22 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
> index 376366a7db81..37c8aeefa3a5 100644
> --- a/arch/arc/Kconfig
> +++ b/arch/arc/Kconfig
> @@ -387,6 +387,14 @@ config ARC_HAS_SWAPE
>  
>  if ISA_ARCV2
>  
> +config ARC_USE_UNALIGNED_MEM_ACCESS
> +	bool "Handle unaligned access in HW and use it"
> +	default y
> +	help
> +	  The ARC HS architecture supports unaligned memory access
> +	  which is disabled by default. Enable unaligned access in
> +	  hardware and use it in software.
> +
>  config ARC_HAS_LL64
>  	bool "Insn: 64bit LDD/STD"
>  	help
> diff --git a/arch/arc/include/asm/irqflags-arcv2.h b/arch/arc/include/asm/irqflags-arcv2.h
> index 8a4f77ea3238..9b911e2c6b31 100644
> --- a/arch/arc/include/asm/irqflags-arcv2.h
> +++ b/arch/arc/include/asm/irqflags-arcv2.h
> @@ -44,8 +44,12 @@
>  #define ARCV2_IRQ_DEF_PRIO	1
>  
>  /* seed value for status register */
> +#ifdef CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS
>  #define ISA_INIT_STATUS_BITS	(STATUS_IE_MASK | STATUS_AD_MASK | \
>  					(ARCV2_IRQ_DEF_PRIO << 1))
> +#else
> +#define ISA_INIT_STATUS_BITS	(STATUS_IE_MASK | (ARCV2_IRQ_DEF_PRIO << 1))
> +#endif /* CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS */
>  
>  #ifndef __ASSEMBLY__
>  
> diff --git a/arch/arc/kernel/head.S b/arch/arc/kernel/head.S
> index 25b3a247e11c..bd24ba0e0264 100644
> --- a/arch/arc/kernel/head.S
> +++ b/arch/arc/kernel/head.S
> @@ -49,11 +49,15 @@
>  
>  1:
>  
> -#ifdef CONFIG_ISA_ARCV2
> -	; Enable unaligned access as disabled by default in hw while
> -	; gcc 8.1.0 onwards (ARC GNU 2018.03) unconditionally generates
> -	; code for unaligned accesses
> -	flag    1 << STATUS_AD_BIT
> +	; Enable / disable HW handling of unaligned access in the CPU.
> +#ifdef CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS
> +	kflag	STATUS_AD_MASK
> +#else
> +	; Handling of unaligned access is disabled by default but we disable it
> +	; manually in case of any bootloader enabled it earlier.
> +	lr	r5, [ARC_REG_STATUS32]
> +	bclr	r5, r5, STATUS_AD_BIT
> +	kflag	r5
>  #endif
>  .endm

I tested these patches and we have a little problem when
CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS is disabled. AD bit is cleared, but current
gcc (2018.09 release) generates unaligned accesses still.


Misaligned Access
Path: (null)
CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc4+ #484

[ECR   ]: 0x000d0000 => Check Programmer's Manual
[EFA   ]: 0x808293cf
[BLINK ]: device_node_gen_full_name+0x3e/0xd4
[ERET  ]: string.constprop.11+0x3e/0x6c
[STAT32]: 0x00000002 :   K
BTA: 0x807e8768	 SP: 0x808d9e94	 FP: 0x00000000
LPS: 0x807ede44	LPE: 0x807ede54	LPC: 0x00000000
r00: 0x00000001	r01: 0x00000001	r02: 0x00000000	
...
Stack Trace:
  string.constprop.11+0x3e/0x6c
  device_node_gen_full_name+0x3e/0xd4
  device_node_string+0x128/0x32c
  vsnprintf+0xfa/0x3c4
  kvasprintf+0x24/0x78
  kasprintf+0x16/0x1c
  __irq_domain_add+0x72/0x1b8
  init_onchip_IRQ+0x38/0x60


Guess there's no solution to this. We could force select the option in relevant
Kconfig, but this applies to pretty much every platform and defeats the purpose of
option in first place.

>  
> diff --git a/arch/arc/kernel/intc-arcv2.c b/arch/arc/kernel/intc-arcv2.c
> index 067ea362fb3e..6359896da1ea 100644
> --- a/arch/arc/kernel/intc-arcv2.c
> +++ b/arch/arc/kernel/intc-arcv2.c
> @@ -93,7 +93,7 @@ void arc_init_IRQ(void)
>  
>  	/* setup status32, don't enable intr yet as kernel doesn't want */
>  	tmp = read_aux_reg(ARC_REG_STATUS32);
> -	tmp |= STATUS_AD_MASK | (ARCV2_IRQ_DEF_PRIO << 1);
> +	tmp |= ARCV2_IRQ_DEF_PRIO << 1;
>  	tmp &= ~STATUS_IE_MASK;
>  	asm volatile("kflag %0	\n"::"r"(tmp));
>  }
> 


  reply	other threads:[~2019-02-01 23:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30 16:32 [PATCH v2 0/5] introduce unaligned access under a Kconfig option Eugeniy Paltsev
2019-01-30 16:32 ` [PATCH v2 1/5] ARCv2: lib: memcpy: fix doing prefetchw outside of buffer Eugeniy Paltsev
2019-01-30 16:32 ` [PATCH v2 2/5] ARCv2: introduce unaligned access under a Kconfig option Eugeniy Paltsev
2019-02-01 23:27   ` Vineet Gupta [this message]
2019-02-01 23:36     ` Vineet Gupta
2019-01-30 16:32 ` [PATCH v2 3/5] ARCv2: use unaligned access in SW Eugeniy Paltsev
2019-01-30 16:32 ` [PATCH v2 4/5] ARCv2: LIB: MEMCPY: fixed and optimised routine Eugeniy Paltsev
2019-01-30 16:32 ` [PATCH v2 5/5] ARC: boot log: print unaligned memory access details Eugeniy Paltsev
2019-02-02  0:47 ` [PATCH v2 0/5] introduce unaligned access under a Kconfig option Vineet Gupta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f95135f7-20e3-1897-d3dc-e8dadf8a2ac5@synopsys.com \
    --to=vineet.gupta1@synopsys.com \
    --cc=alexey.brodkin@synopsys.com \
    --cc=eugeniy.paltsev@synopsys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-snps-arc@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).