Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp3346926rwb; Sat, 6 Aug 2022 19:27:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR55NtOA2W5Uu/Dho6FY+Xe0O/k4FqyqE+AscJr7SBpeLbFtCb9E7JnDS+h5a+b7mkBNY1gD X-Received: by 2002:a17:902:ef46:b0:168:bac3:2fd4 with SMTP id e6-20020a170902ef4600b00168bac32fd4mr12964081plx.132.1659839245005; Sat, 06 Aug 2022 19:27:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659839245; cv=none; d=google.com; s=arc-20160816; b=mTQJLbuonUoRN83NbJp/2JNHvfUtGAr0PZCzw6B+Vo4RGKuoCot7ZrWlCTi329sfdV 7/Rjc8Q+eCr4tAALIGZT5fQQD9goEWufwog11yA/rmtkpWumPnqmhjIxeKo/lMh03601 5fk4oUsx7eblinresLIF0sMG4+xHT1efkoOq3/VgnTZ48BBAu9CPmufPrKzQhrsgKyMX 6h7fEGl41V2cTdBwf4dFCZgpJGEy4iKqVbo9dFZ0yyKjcMDESS2QV/0dSnbYmHzFbpPs rpAkxthvK/eaJYbkedf8yNnGXpMfJUO1d/LiuRY4lLmzgGtVF8xK8Qcus8e4Jb5EcYPC r1qA== 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=v4CNgJJIcoMkC9vrZjaMgTGVZv0Sy/rv5ilzH4CCfrc=; b=wIlJqQKBb72apTUDHwby5cFcVT9AjTOKdxQowwKi7wAj+RNSxurpUD8RwWyRNom6o5 FZ/xY6Gab6HUaAz9JUXSk3c41064xJ+NCoUfyEyyRULTt375SPM6ACZ5ChTldDqBRgss 9sRerw9LPlfZAGkch1f7jegXwLX8zkuqb3HVMshbnFLViGsMlJ1z3IxXHt0Imd0a/rT+ 1KC2N4ChXz3BE0tEFwOFsUXTEk/jHkpygRW8c1jAdMD3MedBgxEpev2zeYKGcJhsxQCD sbA3LhNRETLl7Rtt+T2K4umJOrxzHSAJlLOLOczQTuBZD05aJOvrvVTPvTb3VaC0raoR gQzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XM4bTcoq; 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 n8-20020a170903110800b0016d5fcd3f51si9949184plh.442.2022.08.06.19.27.09; Sat, 06 Aug 2022 19:27:24 -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=XM4bTcoq; 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 S234263AbiHGCLU (ORCPT + 99 others); Sat, 6 Aug 2022 22:11:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231978AbiHGCLS (ORCPT ); Sat, 6 Aug 2022 22:11:18 -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 ESMTP id 1C933A446 for ; Sat, 6 Aug 2022 19:11:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659838275; 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=v4CNgJJIcoMkC9vrZjaMgTGVZv0Sy/rv5ilzH4CCfrc=; b=XM4bTcoq1A931Zxnh1F13bd0jxWUHyHnR6fiq+GbYZBO/Tx8Ka/nIrnjoRetQT+P9JfA5K cthyKB4EWllDsfHqtNW2r+jY8PvD4swV/88kYKo1ub6CHumgasm9lNF626UKb5OwvRBAxA 46ISh9q8vobFfZpgcgKDaP/6odHqquI= 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-452-oYMJ3l63PWGF6orAWnvEaQ-1; Sat, 06 Aug 2022 22:11:12 -0400 X-MC-Unique: oYMJ3l63PWGF6orAWnvEaQ-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 BAB3E3C025C2; Sun, 7 Aug 2022 02:11:11 +0000 (UTC) Received: from localhost (ovpn-12-55.pek2.redhat.com [10.72.12.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B0D212026D4C; Sun, 7 Aug 2022 02:11:10 +0000 (UTC) Date: Sun, 7 Aug 2022 10:11:05 +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 02/11] mm: ioremap: fixup the physical address Message-ID: <20220807021105.GD416711@MiWiFi-R3L-srv> References: <20220801144029.57829-1-bhe@redhat.com> <20220801144029.57829-3-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.78 on 10.11.54.4 X-Spam-Status: No, score=-2.7 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/04/22 at 06:02pm, Alexander Gordeev wrote: > On Mon, Aug 01, 2022 at 10:40:20PM +0800, Baoquan He wrote: > > This is a preparation patch, no functionality change. > > There is, please see below. > > > @@ -3,11 +3,17 @@ > > #include > > #include > > > > -void __iomem *ioremap_allowed(phys_addr_t phys_addr, size_t size, unsigned long prot) > > +void __iomem * > > +ioremap_allowed(phys_addr_t *paddr, size_t size, unsigned long *prot_val) > > { > > - unsigned long last_addr = phys_addr + size - 1; > > + unsigned long last_addr, offset, phys_addr = *paddr; > > int ret = -EINVAL; > > > > + offset = phys_addr & (~PAGE_MASK); > > + phys_addr -= offset; > > FWIW, phys_addr &= PAGE_MASK looks much more usual. Sure, will change. > > > @@ -11,13 +11,20 @@ > > #include > > #include > > > > -void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, > > +void __iomem *ioremap_prot(phys_addr_t paddr, size_t size, > > unsigned long prot) > > { > > unsigned long offset, vaddr; > > - phys_addr_t last_addr; > > + phys_addr_t last_addr, phys_addr = paddr; > > struct vm_struct *area; > > void __iomem *base; > > + unsigned long prot_val = prot; > > Why prot_val is needed? I will remove it and pass &prot to ioremap_allowed(). I could think too much when I made change here. Thanks. > > > + base = ioremap_allowed(&phys_addr, size, &prot_val); > > + if (IS_ERR(base)) > > + return NULL; > > + else if (base) > > + return base; > > By moving ioremap_allowed() here you allow it to be called > before the wrap-around check, including architectures that > do not do fixups. Yes, just as you say. > > And now ioremap_allowed() semantics, prototype and name turn > less than obvious. Why not introduce a separate fixup callback? I can do that, while a little worried if too many hooks introduced. I will introduce another fixup hook in v2 if no other suggestion or concern. Thanks. > > > /* Disallow wrap-around or zero size */ > > last_addr = phys_addr + size - 1; > > @@ -29,12 +36,6 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, > > phys_addr -= offset; > > size = PAGE_ALIGN(size + offset); > > > > - base = ioremap_allowed(phys_addr, size, prot); > > - if (IS_ERR(base)) > > - return NULL; > > - else if (base) > > - return base; > > - > > area = get_vm_area_caller(size, VM_IOREMAP, > > __builtin_return_address(0)); > > if (!area) >