Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5602658imu; Tue, 29 Jan 2019 23:58:34 -0800 (PST) X-Google-Smtp-Source: ALg8bN5IMWRmLUFwzmiCyVI5tJfxNs5HEpKhEZXTeoY0hGKanMAIGBgfuBJtE3xud+XVmEh3pLLF X-Received: by 2002:a17:902:b282:: with SMTP id u2mr29791431plr.89.1548835114792; Tue, 29 Jan 2019 23:58:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548835114; cv=none; d=google.com; s=arc-20160816; b=o1fZ8ilI0EdDr4/S7+zSgZnkIoj2BbX4gjR37hhn+ekj4xkJ+2Uli4XQyFDcrErdaK 5lSnikARVjfVKUaOOMPFqV0EeXoZKrvUEwHna00IjY0NDlCRsSfEiej39y+wR7Otpmvn IV9Uvet7PS86TFyguoaL+ndPtGNjyWeY4ywomglq6GAEY3g+pd5/0qiLJvwr/GtzNXpc qskMCJfPTDOV+EUAkhAmHiXe0xzI3OWvczM6HXXG4LXLxnKuTr+3EqsblWgd70lg6fHs QV/mqaqZKguk3pgM/1iZLxUNa4tHUeFUPOIuN5OhWcr2l0GEpI3mcS44JnN31ZaRCiVI ZltA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=6XjnxnKR6D0VnNyZeM73vV7ocs1mlBfQcZNwvfKVvyY=; b=BnOMNjgTDn4IQbtKnvkfxrg5Jfb/Dpu05dOnTenCzDT02Hsltq7iz1cGTAzL713ba7 UsFuZG92tfg3gih0c8v70fV/5/m+/XKXh4+F/7LuKk2+Es45l/UklKrHqlg6Oqkg1p6e 03+6sSSp7T9amcCNoqothGKyh0wV87vJregeVXqy8vGqh3L7iTeaP6c8uOyQZdt3HQr2 yCmncbq3nnxeM3mZZpV4xIdbGIE6MXCaYWJpghvvcin3VebU76dB2hnY+0YwH0ogdApS OFNoYNAlqhqDgBPos6QWsAXXMN1UR43n9hjOiDG0gEin6J8U3mcmTFUGpI5A9BlfUN6H Oy4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j3si828185plk.199.2019.01.29.23.58.19; Tue, 29 Jan 2019 23:58:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729148AbfA3H4s (ORCPT + 99 others); Wed, 30 Jan 2019 02:56:48 -0500 Received: from mga12.intel.com ([192.55.52.136]:25882 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725830AbfA3H4s (ORCPT ); Wed, 30 Jan 2019 02:56:48 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jan 2019 23:56:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,540,1539673200"; d="scan'208";a="142623893" Received: from cvg-ubt08.iil.intel.com (HELO [143.185.152.136]) ([143.185.152.136]) by fmsmga001.fm.intel.com with ESMTP; 29 Jan 2019 23:56:43 -0800 Subject: Re: [PATCH] lib: 64bit IO To: Greg Kroah-Hartman Cc: Linus Torvalds , linux-kernel@vger.kernel.org References: <20190129154102.17655-1-vladimir.kondratiev@linux.intel.com> <20190129160130.GA19439@kroah.com> From: Vladimir Kondratiev Message-ID: Date: Wed, 30 Jan 2019 09:56:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190129160130.GA19439@kroah.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/29/19 6:01 PM, Greg Kroah-Hartman wrote: > On Tue, Jan 29, 2019 at 05:41:02PM +0200, Vladimir Kondratiev wrote: >> implement missing io{read|write}64 >> >> For 64-bit platforms, these 64-bit io functions are defined in >> include/asm-generic/iomap.h, >> but actual implementation missing. Provide it. > > What is in include/asm-generic/io.h? > > $ git grep iowrite64be | grep generic > include/asm-generic/io.h:#ifndef iowrite64be > include/asm-generic/io.h:#define iowrite64be iowrite64be > include/asm-generic/io.h:static inline void iowrite64be(u64 value, volatile void __iomem *addr) > include/asm-generic/iomap.h:extern void iowrite64be(u64, void __iomem *); > > so are you sure this is needed? > > What code is failing to build for you? The code you mentioned is under #ifndef CONFIG_GENERIC_IOMAP i.e. it works for platforms that does not define CONFIG_GENERIC_IOMAP This currently defined for quite a lot of platforms, all these should not use these inlines and use lib/iomap.c - it selected by the same symbol, from lib/Makefile: obj-$(CONFIG_GENERIC_IOMAP) += iomap.o linux$ git grep GENERIC_IOMAP | grep Kconfig arch/hexagon/Kconfig: select GENERIC_IOMAP arch/ia64/Kconfig: select GENERIC_IOMAP arch/m68k/Kconfig: select GENERIC_IOMAP arch/mips/Kconfig: select GENERIC_IOMAP arch/openrisc/Kconfig: select GENERIC_IOMAP arch/powerpc/platforms/Kconfig: select GENERIC_IOMAP arch/unicore32/Kconfig: select GENERIC_IOMAP arch/x86/Kconfig: select GENERIC_IOMAP lib/Kconfig:config GENERIC_IOMAP Actually, I am using 64-bit MIPS platform for now, and some pieces of code was not compiling without this patch; but this looks like code all platforms above need in order to use 64-bit transactions in "io{redd|write}xx" style Also, I figured out most platforms does not bother providing PIO in 64-bit quantities, so see below version 2 with MMIO-only implementation. > > thanks, > > greg k-h > From 7f0d31a7cdcc535e0248cb4c4cf8f1d16dc0133d Mon Sep 17 00:00:00 2001 From: Vladimir Kondratiev Date: Thu, 24 Jan 2019 16:59:20 +0200 Subject: [PATCH v2] lib: 64bit IO implement missing io{read|write}64 For 64-bit platforms, these 64-bit io functions are defined in include/asm-generic/iomap.h, but actual implementation missing. Provide it. Most platforms does not provide 64-bit PIO functions, thus implement 64-bit transactions as MMIO only Signed-off-by: Vladimir Kondratiev --- lib/iomap.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/lib/iomap.c b/lib/iomap.c index 541d926da95e..86501bccdf72 100644 --- a/lib/iomap.c +++ b/lib/iomap.c @@ -67,6 +67,9 @@ static void bad_io_access(unsigned long port, const char *access) #ifndef mmio_read16be #define mmio_read16be(addr) be16_to_cpu(__raw_readw(addr)) #define mmio_read32be(addr) be32_to_cpu(__raw_readl(addr)) +#ifdef CONFIG_64BIT +#define mmio_read64be(addr) be64_to_cpu(__raw_readq(addr)) +#endif #endif unsigned int ioread8(void __iomem *addr) @@ -100,6 +103,22 @@ EXPORT_SYMBOL(ioread16be); EXPORT_SYMBOL(ioread32); EXPORT_SYMBOL(ioread32be); +#ifdef CONFIG_64BIT + +u64 ioread64(void __iomem *addr) +{ + return readq(addr); +} +EXPORT_SYMBOL(ioread64); + +u64 ioread64be(void __iomem *addr) +{ + return mmio_read64be(addr); +} +EXPORT_SYMBOL(ioread64be); + +#endif /* CONFIG_64BIT */ + #ifndef pio_write16be #define pio_write16be(val,port) outw(swab16(val),port) #define pio_write32be(val,port) outl(swab32(val),port) @@ -108,6 +127,9 @@ EXPORT_SYMBOL(ioread32be); #ifndef mmio_write16be #define mmio_write16be(val,port) __raw_writew(be16_to_cpu(val),port) #define mmio_write32be(val,port) __raw_writel(be32_to_cpu(val),port) +#ifdef CONFIG_64BIT +#define mmio_write64be(val, port) __raw_writeq(be64_to_cpu(val), port) +#endif #endif void iowrite8(u8 val, void __iomem *addr) @@ -136,6 +158,22 @@ EXPORT_SYMBOL(iowrite16be); EXPORT_SYMBOL(iowrite32); EXPORT_SYMBOL(iowrite32be); +#ifdef CONFIG_64BIT + +void iowrite64(u64 val, void __iomem *addr) +{ + writeq(val, addr); +} +EXPORT_SYMBOL(iowrite64); + +void iowrite64be(u64 val, void __iomem *addr) +{ + mmio_write64be(val, addr); +} +EXPORT_SYMBOL(iowrite64be); + +#endif /* CONFIG_64BIT */ + /* * These are the "repeat MMIO read/write" functions. * Note the "__raw" accesses, since we don't want to -- 2.19.1