Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1746439rwd; Mon, 15 May 2023 02:23:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6bCwJunajm76/KQP67xMQPPerPI31UTT5WiMopyN3jRZuBtt8U7ciMSOAzAWJdyxEYSq4F X-Received: by 2002:a17:902:f682:b0:1a6:db0a:8005 with SMTP id l2-20020a170902f68200b001a6db0a8005mr40828863plg.68.1684142609095; Mon, 15 May 2023 02:23:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684142609; cv=none; d=google.com; s=arc-20160816; b=ifodO3OyWMuGyYTyTsn1dyJ/1XaCtlgIfW8c7tkL3Zcf2k64zdBg6NidqEeD5Dz03O mCoQHZB0BwzqmLseFBTCB2pBhcmP7SWdv4Ns42WcSfXv7jiaW9At6Al/pPoD5DLoquyw jPYj/w8Y3OnKVxKp5/w9nEm8dN+1FInFsmeoAl3rcdPPlPPLnJya9Tx5DsS7CJwb+dM3 +X/oN+5FIOdg9av+msmSENdKXY1PZocSdw8i5BnUF5033LZYLqgU7jM10PemsDbgK8wI cZoUtE3o3SeImKHKoyRW4I063VuMYA8d9WY8erUa1mkTFxn22tDikwGOclgODQ7lHt3j cCLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v0nZZRtgRBEjd1TuZoUTX3TC1k0a64a2n3jlsJishp4=; b=yBcBgJtDkB89N05miunWJcAVUyidX3Nar3Lp2K/VYyEk0RBjnhuh5T1UhFH0LVDU8l exjfhgY/4dBl/fAfP6JZWwemfL9QX+hLfuTHJVeARPMnNB/zsqThzXUYIax37t5ZLCOF hlNrXxQJ5S1L8SDN977NhOIKnCVLtiNlTuKqxILeMr+Gkryxq/xc2Lswg+btrdqqkZwf rPa6MVefZ9cYWHHiorv3Fq5b+qx6O2z4VZGHXAl396WF14aPUNCKZC9tec/euAsHGwhn Jn7xyKZfxfU69/AYlSgfiTKpOM84lFhxoE7bUKmnLAGJgMZE7OMVqBq8iJwQV0gwYJAJ S1SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YqgBHyRM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k5-20020a170902694500b001a986ca38easi14936328plt.15.2023.05.15.02.23.16; Mon, 15 May 2023 02:23:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YqgBHyRM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238974AbjEOJKY (ORCPT + 99 others); Mon, 15 May 2023 05:10:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238948AbjEOJKH (ORCPT ); Mon, 15 May 2023 05:10:07 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D930E79 for ; Mon, 15 May 2023 02:09:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v0nZZRtgRBEjd1TuZoUTX3TC1k0a64a2n3jlsJishp4=; b=YqgBHyRM1vXbBL2YJ7dQ+oqvLIXkteyybk1hzJ/LcoKpFlQmT7znybtMk0khdJn+1qzwZN khtCkpgodCEqyPBJsKdc5eMwRnhXlZGkS08ZT1cRuhTBlFZReDsGiBRbTyIszH7DTqbt1r 3IzsyByoHKGiUNPDNmlTAr5PePJ7AVc= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-672-74Ahrn84PGaX_v4p8ksNng-1; Mon, 15 May 2023 05:09:16 -0400 X-MC-Unique: 74Ahrn84PGaX_v4p8ksNng-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3FBD21C08788; Mon, 15 May 2023 09:09:15 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70BD340C2063; Mon, 15 May 2023 09:09:08 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He , Brian Cain , linux-hexagon@vger.kernel.org Subject: [PATCH v5 RESEND 02/17] hexagon: mm: Convert to GENERIC_IOREMAP Date: Mon, 15 May 2023 17:08:33 +0800 Message-Id: <20230515090848.833045-3-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org By taking GENERIC_IOREMAP method, the generic ioremap_prot() and iounmap() are visible and available to arch. This change will simplify implementation by removing duplicated codes with generic ioremap_prot() and iounmap(), and has the equivalent functioality. For hexagon, the current ioremap() and iounmap() are the same as generic version. After taking GENERIC_IOREMAP way, the old ioremap() and iounmap() can be completely removed. Signed-off-by: Baoquan He Cc: Brian Cain Cc: linux-hexagon@vger.kernel.org --- arch/hexagon/Kconfig | 1 + arch/hexagon/include/asm/io.h | 9 +++++-- arch/hexagon/mm/ioremap.c | 44 ----------------------------------- 3 files changed, 8 insertions(+), 46 deletions(-) delete mode 100644 arch/hexagon/mm/ioremap.c diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig index 54eadf265178..17afffde1a7f 100644 --- a/arch/hexagon/Kconfig +++ b/arch/hexagon/Kconfig @@ -25,6 +25,7 @@ config HEXAGON select NEED_SG_DMA_LENGTH select NO_IOPORT_MAP select GENERIC_IOMAP + select GENERIC_IOREMAP select GENERIC_SMP_IDLE_THREAD select STACKTRACE_SUPPORT select GENERIC_CLOCKEVENTS_BROADCAST diff --git a/arch/hexagon/include/asm/io.h b/arch/hexagon/include/asm/io.h index 46a099de85b7..dcd9cbbf5934 100644 --- a/arch/hexagon/include/asm/io.h +++ b/arch/hexagon/include/asm/io.h @@ -170,8 +170,13 @@ static inline void writel(u32 data, volatile void __iomem *addr) #define writew_relaxed __raw_writew #define writel_relaxed __raw_writel -void __iomem *ioremap(unsigned long phys_addr, unsigned long size); -#define ioremap_uc(X, Y) ioremap((X), (Y)) +/* + * I/O memory mapping functions. + */ +#define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \ + (__HEXAGON_C_DEV << 6)) + +#define ioremap_uc(addr, size) ioremap((addr), (size)) #define __raw_writel writel diff --git a/arch/hexagon/mm/ioremap.c b/arch/hexagon/mm/ioremap.c deleted file mode 100644 index 255c5b1ee1a7..000000000000 --- a/arch/hexagon/mm/ioremap.c +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * I/O remap functions for Hexagon - * - * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. - */ - -#include -#include -#include - -void __iomem *ioremap(unsigned long phys_addr, unsigned long size) -{ - unsigned long last_addr, addr; - unsigned long offset = phys_addr & ~PAGE_MASK; - struct vm_struct *area; - - pgprot_t prot = __pgprot(_PAGE_PRESENT|_PAGE_READ|_PAGE_WRITE - |(__HEXAGON_C_DEV << 6)); - - last_addr = phys_addr + size - 1; - - /* Wrapping not allowed */ - if (!size || (last_addr < phys_addr)) - return NULL; - - /* Rounds up to next page size, including whole-page offset */ - size = PAGE_ALIGN(offset + size); - - area = get_vm_area(size, VM_IOREMAP); - addr = (unsigned long)area->addr; - - if (ioremap_page_range(addr, addr+size, phys_addr, prot)) { - vunmap((void *)addr); - return NULL; - } - - return (void __iomem *) (offset + addr); -} - -void iounmap(const volatile void __iomem *addr) -{ - vunmap((void *) ((unsigned long) addr & PAGE_MASK)); -} -- 2.34.1