Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp29141ybj; Wed, 6 May 2020 10:48:54 -0700 (PDT) X-Google-Smtp-Source: APiQypKnsj7qtKdtN2snyMVbIN2LT3ofz1def6qxq3OCV4qDlLa1+UgSW+SBmmyj8Up+/H0pTo2B X-Received: by 2002:a05:6402:1506:: with SMTP id f6mr8186592edw.217.1588787334154; Wed, 06 May 2020 10:48:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588787334; cv=none; d=google.com; s=arc-20160816; b=ix8KromsZIuMYBqW7lwdIC2tVI6dFL7us39V92WFQaMqQ/mCyccS0Tta93V9pz+c8w eh7m6UOnqR10R+tmkjct9XMSD9Wfyk8hBZokdatO+s9bMW9FOjay2k7HawtX4AgoH1Sx hhl4wY617T/w3xhCaqBQmpyb18srtn6gilD3/aEGeHrLyFmslffnVPrpCtLI5urebPdE Mk6Ili/jodCj9P9WyyySQhwV67c0rLZbXX46Xz7VnumrVvvboQP9oun3JmvXyvCItf1D eLpNYHjtsyqEz9rqmYBsikCEQXYiVIpkqYnDcHuGr/SSXrzKoTDlOoDcbopnARRSUVZb K4jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=QdjgYq1Gnfp0yhPQs1o5+WTyOA1kOdBYqYmlVFi+ujM=; b=UW09r5ar2fGNlqXLR+/xf3E5wVJBrMd6rIcbG0i4MxFS/AuPwSTlSCGEWBEYR7Tpv4 PNjJReVZO7ylpGgboPKtGHfv/eznEN9CvI52qRjDfaz8AzKr+858tmZyINKNnkRMoPl6 upVaJJL7nrHJESsA0+DMJuOggD9YE8Pfew0G+U/e8BTbaxOXoBq5Mcc5smDXkBzG5Iq9 X9e3cxWzAPlXZzXTwFNE8OEj/qo8JeeuYQoTKdfaoYf1DzZBIlDHgrhZrw6j7I2aPDYS TB3wE+ABBLd0Cqtt7P+EyrzRVBdDdQOd1DCZncLSjX/27MvQv3kEZmoNLxhQ+nK3CVFm vZlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd5si1575312edb.34.2020.05.06.10.48.31; Wed, 06 May 2020 10:48:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730396AbgEFRod (ORCPT + 99 others); Wed, 6 May 2020 13:44:33 -0400 Received: from mail.baikalelectronics.com ([87.245.175.226]:32790 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729460AbgEFRoV (ORCPT ); Wed, 6 May 2020 13:44:21 -0400 Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 42D008000B82; Wed, 6 May 2020 17:44:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3dSIDd2UUX5J; Wed, 6 May 2020 20:44:17 +0300 (MSK) From: To: Thomas Bogendoerfer CC: Serge Semin , Serge Semin , Alexey Malahov , Paul Burton , Ralf Baechle , Arnd Bergmann , Rob Herring , , , Kate Stewart , Thomas Gleixner , Steve Winslow , Greg Kroah-Hartman , , Subject: [PATCH v2 13/20] mips: early_printk_8250: Use offset-sized IO-mem accessors Date: Wed, 6 May 2020 20:42:31 +0300 Message-ID: <20200506174238.15385-14-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20200506174238.15385-1-Sergey.Semin@baikalelectronics.ru> References: <20200306124807.3596F80307C2@mail.baikalelectronics.ru> <20200506174238.15385-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Serge Semin Some platforms may prohibit to access the IO-memory with instructions of certain memory widths. For instance Bailal-T1 has devices placed behind memory OCP port (which also the reason of DMA accesses being incoherent) and can't be accessed through CCA uncacheable memory with other than 4-bytes aligned (LW/SW) instructions. Ignoring this rule will cause the APB EHB error with 0xFFs returned on read operations. In order to fix the issue for this platform and for others, which may have similar problems, lets recode serial_in()/serial_out() to call a certain memory accessors in accordance with the UART registers shift setting. Signed-off-by: Serge Semin Cc: Alexey Malahov Cc: Thomas Bogendoerfer Cc: Paul Burton Cc: Ralf Baechle Cc: Arnd Bergmann Cc: Rob Herring Cc: linux-pm@vger.kernel.org Cc: devicetree@vger.kernel.org --- arch/mips/kernel/early_printk_8250.c | 34 ++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/arch/mips/kernel/early_printk_8250.c b/arch/mips/kernel/early_printk_8250.c index 567c6ec0cfae..e2c2405cff62 100644 --- a/arch/mips/kernel/early_printk_8250.c +++ b/arch/mips/kernel/early_printk_8250.c @@ -23,12 +23,42 @@ void setup_8250_early_printk_port(unsigned long base, unsigned int reg_shift, static inline u8 serial_in(int offset) { - return readb(serial8250_base + (offset << serial8250_reg_shift)); + u8 ret = 0xFF; + + offset <<= serial8250_reg_shift; + switch (serial8250_reg_shift) { + case 0: + ret = readb(serial8250_base + offset); + break; + case 1: + ret = readw(serial8250_base + offset); + break; + case 2: + ret = readl(serial8250_base + offset); + break; + default: + break; + } + + return ret; } static inline void serial_out(int offset, char value) { - writeb(value, serial8250_base + (offset << serial8250_reg_shift)); + offset <<= serial8250_reg_shift; + switch (serial8250_reg_shift) { + case 0: + writeb(value, serial8250_base + offset); + break; + case 1: + writew(value, serial8250_base + offset); + break; + case 2: + writel(value, serial8250_base + offset); + break; + default: + break; + } } void prom_putchar(char c) -- 2.25.1