Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2061668rwe; Sun, 28 Aug 2022 03:00:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR5ZdYXuti9Bpg/jqEToO303MCCk9zGq32O0GxomxEqvwUSSgShDqUM4LYDH56vsuhMPXM/A X-Received: by 2002:a17:903:244c:b0:16e:fa53:a54c with SMTP id l12-20020a170903244c00b0016efa53a54cmr11365560pls.46.1661680801488; Sun, 28 Aug 2022 03:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661680801; cv=none; d=google.com; s=arc-20160816; b=L3uL68Rjvus+V4PF5iw4FDLB7wj63xD4UKx4lkG+u0i+/RBKvMY35zwj017gbj0b5F oqlZSOiUfmEiBwqai+7NQBAbBjPPN5IIePm7K7Kcl2LSbNJ0/c+w0GR74GhOibuGTWI8 1Ove1fd/TIpu7IlvRFt6H0fnKAFMSwpSgkx911zlkvEZn9GokR2Ou9RoeTDVTZycYg8G 7xA/4lsUp8aFRKiSiqaS5md+v0xUrm/legk4H5z0PEa2OXvb1bKUDcsXnSTS0A0fPPdj LNxUBso5LANqG7BTnD9mF9riR33ddYsBMeurqcr69nnWZhte/j4F7ZfJqkRGV9FiG68a zk3w== 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=KmoVkJKn7sDlJ8XCXp6Z2DlsC39Vq8jBiod6jjguAyk=; b=zVGxegmzoMEZvTLllBMPA405uGEsOlO84ct8odHUFshsyDYIYHbhTLtJS8hr14VN/J CFwc0xvLNjzUQydR7E+QVUmnPMgC4k7ij0KlwTWzEILmZX74tkChg2mCKeSrcY1LW1YT d/QZus7Wv19rnI0nmbxD92BjdJ1pZZ6Qm57YmIXOLsR+JhMh2NGvxyQvDtzg5QtQix7M 5xTTgKffr5kcuYqfgaesqpnkK2sZBq5pmywtnThKvorsMZxbyox7prgGzu6GaALu9ek8 PIvJqsSFcnv47u5GSfQeNyGYW10knjN9mA7uABhHix3hRf0ViVtQCE9iNF+qnP6/KWvX GFHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="B7/KTyOr"; 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 q98-20020a17090a17eb00b001fb57daa5b5si2642517pja.138.2022.08.28.02.59.50; Sun, 28 Aug 2022 03:00:01 -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="B7/KTyOr"; 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 S229563AbiH1J57 (ORCPT + 99 others); Sun, 28 Aug 2022 05:57:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229684AbiH1J4G (ORCPT ); Sun, 28 Aug 2022 05:56:06 -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 F263D4CA16 for ; Sun, 28 Aug 2022 02:56:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661680561; 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=KmoVkJKn7sDlJ8XCXp6Z2DlsC39Vq8jBiod6jjguAyk=; b=B7/KTyOrewLL6TOj0YQCKPfVy4cy38hotDl0AEEE8AWhLqgSua5ai5/TC832YakEBTznbq 3ULPsEOyq7o/hFCwRZCkNtLIz8MokFyL5WrnhNuakJVWWgnLAjXyr/T7i3/b0aOnJ7C3+r sdevlVyQdlEaVquI7WMyZjNCqDarfGU= 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-378--Y5_IFOCNa6f2P_lc1v6tA-1; Sun, 28 Aug 2022 05:55:57 -0400 X-MC-Unique: -Y5_IFOCNa6f2P_lc1v6tA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6EB3780029D; Sun, 28 Aug 2022 09:55:57 +0000 (UTC) Received: from localhost (ovpn-12-25.pek2.redhat.com [10.72.12.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4F5794010D43; Sun, 28 Aug 2022 09:55:55 +0000 (UTC) Date: Sun, 28 Aug 2022 17:55:52 +0800 From: Baoquan He To: Alexander Gordeev Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, hch@infradead.org, wangkefeng.wang@huawei.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 01/11] mm/ioremap: change the return value of io[re|un]map_allowed and rename Message-ID: References: <20220820003125.353570-1-bhe@redhat.com> <20220820003125.353570-2-bhe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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=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 08/28/22 at 10:36am, Alexander Gordeev wrote: > On Sat, Aug 20, 2022 at 08:31:15AM +0800, Baoquan He wrote: > > Hi Baoquan, > > > arch_ioremap() return a bool, > > - IS_ERR means return an error > > - NULL means continue to remap > > - a non-NULL, non-IS_ERR pointer is returned directly > > arch_iounmap() return a bool, > > - 0 means continue to vunmap > > - error code means skip vunmap and return directly > > It would make more sense if the return values were described > from the prospective of an architecture, not the caller. > I.e true - unmapped, false - not supported, etc. Yes, sounds reasonable to me, thanks. While ChristopheL suggested to take another way. Please see below link. I will reply to Christophe to discuss that. https://lore.kernel.org/all/8df89136-a7f2-9b66-d522-a4fb9860bf22@csgroup.eu/T/#u If the current arch_ioremap() way is taken, I will change the description as you said. > > > diff --git a/mm/ioremap.c b/mm/ioremap.c > > index 8652426282cc..99fde69becc7 100644 > > --- a/mm/ioremap.c > > +++ b/mm/ioremap.c > > @@ -17,6 +17,13 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, > > unsigned long offset, vaddr; > > phys_addr_t last_addr; > > struct vm_struct *area; > > + void __iomem *ioaddr; > > + > > + ioaddr = arch_ioremap(phys_addr, size, prot); > > + if (IS_ERR(ioaddr)) > > + return NULL; > > + else if (ioaddr) > > + return ioaddr; > > It seems to me arch_ioremap() could simply return an address > or an error. Then IOMEM_ERR_PTR(-ENOSYS) if the architecture > does not support it reads much better than the cryptic NULL. I may not follow. Returning NULL means arch_ioremap() doesn't give out a mapped address and doesn't encounter wrong thing. NULL is a little twisting, maybe '0' is better? > > Probably arch_iounmap() returning error would look better too, > though not sure about that. Don't follow either. arch_iounmap() is returning error now.