Linux-MIPS Archive on lore.kernel.org
 help / Atom feed
* Re: [PATCH] MIPS: Workaround bugged BCM4704 & BCM5354 that crash with kmap_coherent()
       [not found] <20190207155200.16880-1-zajec5@gmail.com>
@ 2019-02-07 19:42 ` Paul Burton
  0 siblings, 0 replies; 1+ messages in thread
From: Paul Burton @ 2019-02-07 19:42 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Ralf Baechle, James Hogan, Hauke Mehrtens, Matt Redfearn,
	Michal Hocko, Andrew Morton, Mike Rapoport, Alexandre Belloni,
	Pravin Shedge, linux-mips, Rafał Miłecki, linux-mips

Hi Rafał,

On Thu, Feb 07, 2019 at 04:52:00PM +0100, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> This workarounds what seems to be a hardware bug present in some early
> Broadcom MIPS CPUs. For some reason using kmap_coherent() for copying a
> memory causes a "Data bus error" or SoC reboot.
>
>%
>
> diff --git a/arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h b/arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h
> index b23ff47ea475..553505dea60b 100644
> --- a/arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h
> +++ b/arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h
> @@ -80,4 +80,12 @@
>  #define cpu_scache_line_size()		0
>  #define cpu_has_vz			0
>  
> +/*
> + * Workaround for the bugged BCM4704 & BCM5354:
> + * copy_from_user_page() + kmap_coherent() causes "Data bus error"
> + * copy_to_user_page() + kmap_coherent() causes immediate reboot
> + */
> +#define cpu_has_kmap_coherent		(cpu_data[0].processor_id != 0x29006 && \
> +					 cpu_data[0].processor_id != 0x29029)
> +
>  #endif /* __ASM_MACH_BCM47XX_CPU_FEATURE_OVERRIDES_H */
> diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
> index c3b45e248806..67007bf15543 100644
> --- a/arch/mips/mm/init.c
> +++ b/arch/mips/mm/init.c
> @@ -174,7 +174,7 @@ void copy_user_highpage(struct page *to, struct page *from,
>  	void *vfrom, *vto;
>  
>  	vto = kmap_atomic(to);
> -	if (cpu_has_dc_aliases &&
> +	if (cpu_has_kmap_coherent && cpu_has_dc_aliases &&
>  	    page_mapcount(from) && !Page_dcache_dirty(from)) {
>  		vfrom = kmap_coherent(from, vaddr);
>  		copy_page(vto, vfrom);

Won't this introduce cache aliasing problems?

The reason for using kmap_coherent at all is to ensure we use a mapping
with the same cache colouring as the user's mapping. If the CPU suffers
from dcache aliasing & we don't do that colouring then it seems like
this might lead to us reading/copying stale data?

Thanks,
    Paul

^ permalink raw reply	[flat|nested] 1+ messages in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20190207155200.16880-1-zajec5@gmail.com>
2019-02-07 19:42 ` [PATCH] MIPS: Workaround bugged BCM4704 & BCM5354 that crash with kmap_coherent() Paul Burton

Linux-MIPS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mips/0 linux-mips/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mips linux-mips/ https://lore.kernel.org/linux-mips \
		linux-mips@vger.kernel.org linux-mips@archiver.kernel.org
	public-inbox-index linux-mips


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-mips


AGPL code for this site: git clone https://public-inbox.org/ public-inbox