Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp61633rwi; Sun, 9 Oct 2022 18:31:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4D+yq/Jv1n/tZ5Fyb0OsIeAMb54DiddBAnvrRiaZ0pnL3Vh3dMvV6M4SgDdVfm99CV75Ly X-Received: by 2002:a17:902:d2cf:b0:17f:7b65:862f with SMTP id n15-20020a170902d2cf00b0017f7b65862fmr16182128plc.168.1665365469467; Sun, 09 Oct 2022 18:31:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665365469; cv=none; d=google.com; s=arc-20160816; b=Xo78fpNai/dOnHqraVQi2VqKLKslOHKjFSogbrT6XdKVvnAvNIuLwDC4BHK4f/kunf F6KMrBURyxVl6yXrR8cShWsGpdnMQglO6+PB7izxtYE3G3jYVxicb+NBIoKSNwf4nHO2 69rQDC5DKAQtHYIanXtfkdkYdwAolm+RthOf1YHZ2UywFmLXz9kUEHwxiWzsp4gMljBa oAqbWycq7uZ2sZKIHh27Zxxar36cBcQDjSoU3+wixhjTJkdkDdS7TUf8tKZGSdbHqkkF pGtzpFWnVPel62UcyCieLMnEorGdCvemO8aXvEvMG+9IH8JXQFmTAlqaIiUv/qZFn8OI S1IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2Wlgr5678H60NOl4njbwYLitT+ttN6vPLcrFmUMxdHw=; b=LrfP0PtkVQv6rIv16x2LBIhcgm8uTgWM703ygI2VqaFCCu55buWYX3YifetbJULAV2 b60Wx7cJIM+BKXG4qMeGhqHNYAbx4MYYQXul3KM8/nAXIO43g/C3/SIAGJIkG7lE5zfs 19dp735tenj5MqHcXci5xzHrQBQf62QeLwJ4mjScek/lel2T5NFGlJhmYPqrRfC0zuMz ADaykBYJIwdR3OcODoxmXvD6H6atnWrXzHRXocx8MAJGBVQLnCQojtY76xf0rN/tbL5Y nPorXgJa9M2MWSh+yRLcNj/9Td/ME01D9jQUtXsPQGAl8GPghlJS3TBupyOmgT0a/mKf HeWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dZfP16ve; 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 a15-20020a631a4f000000b004347b49d045si11224482pgm.631.2022.10.09.18.30.57; Sun, 09 Oct 2022 18:31:09 -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=dZfP16ve; 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 S230217AbiJJA5P (ORCPT + 99 others); Sun, 9 Oct 2022 20:57:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230141AbiJJA46 (ORCPT ); Sun, 9 Oct 2022 20:56:58 -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 ACAE13F320 for ; Sun, 9 Oct 2022 17:41:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665362409; 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: in-reply-to:in-reply-to:references:references; bh=2Wlgr5678H60NOl4njbwYLitT+ttN6vPLcrFmUMxdHw=; b=dZfP16vexRb9t4V3sEa18x3+PFhg7NGFWmQEeoOTM+uFXRM5UAWA8q+Khf52wXwC+yb8pA x2sT3AreDs/8jTyhiyNycn25/iR6xm1sWzKopxLmJezWAN9NauXvRqv64duNG2K38LnZGH uFmu8Hm25kFq9Nvm+Ys99pzTRSAD0Bw= 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-508-yxRvlpj5P7axHHUHhconUQ-1; Sun, 09 Oct 2022 20:25:28 -0400 X-MC-Unique: yxRvlpj5P7axHHUHhconUQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B071B29AB406; Mon, 10 Oct 2022 00:25:27 +0000 (UTC) Received: from localhost (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 70EE5145D825; Mon, 10 Oct 2022 00:25:26 +0000 (UTC) Date: Mon, 10 Oct 2022 08:25:22 +0800 From: Baoquan He To: Kefeng Wang Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, hch@infradead.org, agordeev@linux.ibm.com, christophe.leroy@csgroup.eu, schnelle@linux.ibm.com, David.Laight@aculab.com, shorne@gmail.com, Arnd Bergmann , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 03/11] mm/ioremap: change the return value of io[re|un]map_allowed and rename Message-ID: References: <20221009103114.149036-1-bhe@redhat.com> <20221009103114.149036-4-bhe@redhat.com> <10ada8f0-0931-b6a6-e240-fc8b500e578d@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <10ada8f0-0931-b6a6-e240-fc8b500e578d@huawei.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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 autolearn=ham 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 On 10/09/22 at 07:13pm, Kefeng Wang wrote: > > On 2022/10/9 18:31, Baoquan He wrote: > > Currently, hooks ioremap_allowed() and iounmap_allowed() are used to > > check if it's qualified to do ioremap, and now this is done on ARM64. > > However, in oder to convert more architectures to take GENERIC_IOREMAP > > method, several more things need be done in those two hooks: > > 1) The io address mapping need be handled specifically on architectures, > > e.g arc, ia64, s390; > > 2) The original physical address passed into ioremap_prot() need be > > fixed up, e.g arc; > > 3) The 'prot' passed into ioremap_prot() need be adjusted, e.g on arc > > and xtensa. > > > > To handle these three issues, > > > > 1) Rename ioremap_allowed() and iounmap_allowed() to arch_ioremap() > > and arch_iounmap() since the old name can't reflect their > > functionality after change; > > 2) Change the return value of arch_ioremap() so that arch can add > > specifical io address mapping handling inside and return the maped > > address. Now their returned value means: > > === > > arch_ioremap() return a bool, > pointer? Right, I forgot fixing it again. Thanks. > > - IS_ERR means return an error > > - 0 means continue to remap > > - a non-zero, non-IS_ERR pointer is returned directly > > arch_iounmap() return a bool, > > - true means continue to vunmap > > - false means skip vunmap and return directly > ... > > /* > > diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h > > index a68f8fbf423b..2ae16906f3be 100644 > > --- a/include/asm-generic/io.h > > +++ b/include/asm-generic/io.h > > @@ -1049,25 +1049,26 @@ static inline void iounmap(volatile void __iomem *addr) > > /* > > * Arch code can implement the following two hooks when using GENERIC_IOREMAP > > - * ioremap_allowed() return a bool, > > - * - true means continue to remap > > - * - false means skip remap and return directly > > - * iounmap_allowed() return a bool, > > + * arch_ioremap() return a bool, > ditto... Will change. > > area = get_vm_area_caller(size, VM_IOREMAP, > > __builtin_return_address(0)); > > if (!area) > > @@ -52,7 +57,7 @@ void iounmap(volatile void __iomem *addr) > > { > > void *vaddr = (void *)((unsigned long)addr & PAGE_MASK); > > - if (!iounmap_allowed(vaddr)) > > + if (!arch_iounmap((void __iomem *)addr)) > vaddr? No, it's intentional. Alexander suggested this, both of you discussed this in v1, see below thread. https://lore.kernel.org/all/Yu4mYxpV0GWRTjQp@li-4a3a4a4c-28e5-11b2-a85c-a8d192c6f089.ibm.com/T/#u > > return; > > if (is_vmalloc_addr(vaddr)) >