Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1115065pxv; Thu, 22 Jul 2021 23:20:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyj0JBpCO6mb7fH0hRi5hQ1cMjVG428s7cj2SKvY/8iT4JYwBtkulfaUgygbgFUgTzWf18r X-Received: by 2002:a05:6e02:12e1:: with SMTP id l1mr2446863iln.0.1627021244894; Thu, 22 Jul 2021 23:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627021244; cv=none; d=google.com; s=arc-20160816; b=kTgBX34sVrNwfU1NpVEttUp7XK94vd05ocauv5wLFEbnuCff7sVo+hhkgvrd6wxOpD hbQLr+w6MqN1SyCi/lpb8ySMsCOGVuTpNqzblOfy1DBcWyq6zJIXpGWJuSzcnEwgfwAl wz/XZKcM+mZrQidnk+ajumsbBQ+3BVRxcmIQTVghjjihbDgxliCq1trRW4MDkTKN0wnO bPRI/1VDWdjc6xlYRkXGonf8jY9SuTIZgjg15Gi8kIWBCFfxVG4NL1mLc+fuQZPD8g+j h8/RN5WeO8KSk9BVFNeSvaeRXNu3vLO0NvLNjyewO/fykBkSihJF4/UdCGXKkzjOrF1r PWKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=NNpJx2SW/QFPlOc56vEIJUR8SCI7iEb11nPeK4LJcik=; b=S+w45sPubl/Oj/mdyPDMQSWWMcmjmRcyDlIoPvMc17ZTgmAQCE0uzmhS4vYbkmDZ4h kuSpWxBvuPrB/pLY3jJDOiaXQFvu9Usi2s/8L3+CzvruOiEnBSBvjup8OgzNr/nANUwm 9yn4AoARG+c8vMqx0QJXolxkAn4ANxN0NFykIe6ojyrxhc/3p+A8roG+HRZFDQ9LU67Z oAoAzABrfnOmKdg7qKJ5GZ/0p4vqf7gy22S/+9/Acs+ObBGSIzPx2MJ7VwEH9E09oTj1 ODHf10bSuI8MdX9vxrCuj961L/7B+PoU1U9GeE8Z/PZHZ1Xx7vjjJN9so7eLAxECjlp3 7Drw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g5si20965322ilk.74.2021.07.22.23.20.32; Thu, 22 Jul 2021 23:20:44 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233922AbhGWFjM (ORCPT + 99 others); Fri, 23 Jul 2021 01:39:12 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:7417 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233733AbhGWFjL (ORCPT ); Fri, 23 Jul 2021 01:39:11 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GWJwd6Jh0z7wqY; Fri, 23 Jul 2021 14:16:01 +0800 (CST) Received: from dggemi759-chm.china.huawei.com (10.1.198.145) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Fri, 23 Jul 2021 14:19:42 +0800 Received: from localhost.localdomain (10.67.165.24) by dggemi759-chm.china.huawei.com (10.1.198.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Fri, 23 Jul 2021 14:19:42 +0800 From: Guangbin Huang To: , , , , , , , CC: , , , , Subject: [RFC PATCH net-next 2/4] io: add function to flush the write combine buffer to device immediately Date: Fri, 23 Jul 2021 14:16:07 +0800 Message-ID: <1627020969-32945-3-git-send-email-huangguangbin2@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1627020969-32945-1-git-send-email-huangguangbin2@huawei.com> References: <1627020969-32945-1-git-send-email-huangguangbin2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggemi759-chm.china.huawei.com (10.1.198.145) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiongfeng Wang Device registers can be mapped as write-combine type. In this case, data are not written into the device immediately. They are temporarily stored in the write combine buffer and written into the device when the buffer is full. But in some situation, we need to flush the write combine buffer to device immediately for better performance. So we add a general function called 'flush_wc_write()'. We use DGH instruction to implement this function for ARM64. Signed-off-by: Xiongfeng Wang --- arch/arm64/include/asm/io.h | 2 ++ include/linux/io.h | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h index 7fd836bea7eb..5315d023b2dd 100644 --- a/arch/arm64/include/asm/io.h +++ b/arch/arm64/include/asm/io.h @@ -112,6 +112,8 @@ static inline u64 __raw_readq(const volatile void __iomem *addr) #define __iowmb() dma_wmb() #define __iomb() dma_mb() +#define flush_wc_write() dgh() + /* * Relaxed I/O memory access primitives. These follow the Device memory * ordering rules but do not guarantee any ordering relative to Normal memory diff --git a/include/linux/io.h b/include/linux/io.h index 9595151d800d..469d53444218 100644 --- a/include/linux/io.h +++ b/include/linux/io.h @@ -166,4 +166,10 @@ static inline void arch_io_free_memtype_wc(resource_size_t base, } #endif +/* IO barriers */ + +#ifndef flush_wc_write +#define flush_wc_write() do { } while (0) +#endif + #endif /* _LINUX_IO_H */ -- 2.8.1