From patchwork Mon May 15 09:08:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 93985 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6780782vqo; Mon, 15 May 2023 02:22:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4urMxf72Klyz9x5AhuPqfey8MgSBiQ7vcKpI8kMoD6oogVnW9fdY3tZ854hQwphSM+B16b X-Received: by 2002:a17:902:c2c4:b0:1ae:4:da97 with SMTP id c4-20020a170902c2c400b001ae0004da97mr5166203pla.4.1684142572836; Mon, 15 May 2023 02:22:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684142572; cv=none; d=google.com; s=arc-20160816; b=wKABqIH6h520KKngk+ui+5L9dNjhvIA1jeGOuY+sm0SWTBbgijqZakGuuFPET7hoIa n7Fh7KUI+HdYjmHJkCEs2LHsxgZUEFLRR/buNlG/P6nlHHRiZ0NAW9zrG0eSH2Dy+87a JNwQna8m2Bv58eCFE+zgADcX1U3LctXDIAOQqeZydoSH7CO8asfYEr3BJhtpfgs+GrOc LLosF9MAoO8+TBCFspuTyw5A8kT1wI7qyAXrKQFlPu+E0fQDs1mHPFZz1GUhYZSRpBXW 8ibAL9kz7Yw/KdsPPbKOJMVDv5Up/pMz4Q50XHF0u80/q+SGYTkp1nMEIPzltKZQtxyL s8TQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e12-20020a170902d38c00b001a6ff6a83e2si11380835pld.522.2023.05.15.02.22.40; Mon, 15 May 2023 02:22:52 -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 S239022AbjEOJKZ (ORCPT + 99 others); Mon, 15 May 2023 05:10:25 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765951482520411770?= X-GMAIL-MSGID: =?utf-8?q?1765951482520411770?= 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 Reviewed-by: Mike Rapoport (IBM) Reviewed-by: Christoph Hellwig --- 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)); -}