From patchwork Fri Jun 9 07:55:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 105358 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp785739vqr; Fri, 9 Jun 2023 01:07:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7P8gx+lpp+aoRqUM2DbYJ8rYHybpwysgOwibW6Umldr9NxSmS1SSXb6zsnwqOpyawNGr/b X-Received: by 2002:a05:6a20:d387:b0:10b:2f5a:83af with SMTP id iq7-20020a056a20d38700b0010b2f5a83afmr340650pzb.16.1686298052278; Fri, 09 Jun 2023 01:07:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686298052; cv=none; d=google.com; s=arc-20160816; b=KPEPqF7oRoyDrBA56DrENUAyV8w7d8jjkQmJaBXagXU+ghjXSFdg8p8lJF6asoz33v Pcn6Dn4hVl8YZgj/AHwWb08NTQDtfL3VlBY7i8MhbBiOoQBLvqcv9cN0rN5HquJWeRPV z6BJlj3Ge80D/P17N/sd/tMagvU2L+qSBAbtJPf8r0m43ry2aj6DDhIl6Vr6cVPUiwPA zRycbBm0l7IhNU0quq47YlcebTCbRueTVyrFvzZ/d9HeoRWAJmdMngyfKDrQ2vlZcd6A GMect8ynq1uDYGakdtLUXqDzn3umNutGdhBXtfFK7fbRiXantIPKONFizNGUQEjSQsRR plug== 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=pRjmDB/MhJX2uAhXZR6PcmrnbkF0aNZomeUUr4ZAM3o=; b=yWMUI0sv72DqOTeASeYC9ozIgLbwz46UOppRvU5t1pLOU3TU9WojKtUcjgMEjL5Tdt EKoBzVKtYjlSo3C0lD15ZPHUbNcP3BieFiuQsfLmk/rQdaCaPcer0RzaeFxXMMoWCVmj us8q1iueEW6XwW07MZNzWvWKZaDXazsxDY3qG92P37mp2sPEJ/gH6bK2blGbyfYLLaoR XWrtdoo3G2PEzH3McoiD3HyA8XLUSULw+VJlpF7l6UW82ZHd8p0mXqgjGeLDdMXnwged I6lYJgWkhE1vDpgew/ZOHA9Uq6cQy1PJ+kIgigFhpkP473TflnV/bl4poWdQudoXevA9 8uVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DoDkc7SB; 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 t21-20020aa79475000000b0064f400fcb99si2132380pfq.148.2023.06.09.01.07.17; Fri, 09 Jun 2023 01:07:32 -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=DoDkc7SB; 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 S239742AbjFIIAg (ORCPT + 99 others); Fri, 9 Jun 2023 04:00:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239841AbjFIH7t (ORCPT ); Fri, 9 Jun 2023 03:59:49 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B6FF3C2F for ; Fri, 9 Jun 2023 00:57:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297451; 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=pRjmDB/MhJX2uAhXZR6PcmrnbkF0aNZomeUUr4ZAM3o=; b=DoDkc7SBlIINeMaGw76OfpYjJfkTLUaAfFW8oe32iqC4v+EjPa3OmcGhYvYkmMD11PTiu7 E28ZuWccwKguhfumPk23avaM/tdAP1/Y8MGptzJ7Hd0mklMLsVh9ARqZ362vVQznymRXQ4 URpQSbPhq1OddjmLf+sPAUmqszLqp9c= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-437-Rqd3XGSRMJmpF0VEV5s9pg-1; Fri, 09 Jun 2023 03:57:24 -0400 X-MC-Unique: Rqd3XGSRMJmpF0VEV5s9pg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AEC4280120A; Fri, 9 Jun 2023 07:57:23 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 244B620268C6; Fri, 9 Jun 2023 07:57:17 +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@lst.de, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, Baoquan He Subject: [PATCH v6 15/19] mm/ioremap: Consider IOREMAP space in generic ioremap Date: Fri, 9 Jun 2023 15:55:24 +0800 Message-Id: <20230609075528.9390-16-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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, 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?1768211666313863280?= X-GMAIL-MSGID: =?utf-8?q?1768211666313863280?= From: Christophe Leroy Architectures like powerpc have a dedicated space for IOREMAP mappings. If so, use it in generic_ioremap_prot(). Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig --- v5->v6: Add definition of IOREMAP_START|END in mm/ioremap.c so that we can call __get_vm_area_caller() for all ARCH-es - Christoph mm/ioremap.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mm/ioremap.c b/mm/ioremap.c index 86b82ec27d2b..68d9895144ad 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -11,6 +11,15 @@ #include #include +/* + * Ioremap often, but not always uses the generic vmalloc area. E.g on + * Power ARCH, it could have different ioremap space. + */ +#ifndef IOREMAP_START +#define IOREMAP_START VMALLOC_START +#define IOREMAP_END VMALLOC_END +#endif + void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, pgprot_t prot) { @@ -35,8 +44,8 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) return NULL; - area = get_vm_area_caller(size, VM_IOREMAP, - __builtin_return_address(0)); + area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, + IOREMAP_END, __builtin_return_address(0)); if (!area) return NULL; vaddr = (unsigned long)area->addr; @@ -66,7 +75,7 @@ void generic_iounmap(volatile void __iomem *addr) if (!iounmap_allowed(vaddr)) return; - if (is_vmalloc_addr(vaddr)) + if (is_ioremap_addr(vaddr)) vunmap(vaddr); }