From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F41EC19F2D for ; Sun, 7 Aug 2022 02:11:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA1788E0002; Sat, 6 Aug 2022 22:11:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A50C58E0001; Sat, 6 Aug 2022 22:11:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 919788E0002; Sat, 6 Aug 2022 22:11:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 831EA8E0001 for ; Sat, 6 Aug 2022 22:11:15 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5E4861205F1 for ; Sun, 7 Aug 2022 02:11:15 +0000 (UTC) X-FDA: 79771169310.07.0A272A9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 9A118100152 for ; Sun, 7 Aug 2022 02:11:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659838274; 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=VE9eEdc9zJc7iXDpEyLkF4+3zeNH9CKaFQmdzlEmLUMPRHFJqdYyZbtvcV9PzyixvV1vD2 WXAb699a4agvS5i5aYrq+VvLPTZAlaJ3Uc4+VQRfz97VoZIVNFRvEA03xgengHCF3UA7NM byN9xY8g4Znm4okdh2svglWNRA6r+uI= 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659838275; a=rsa-sha256; cv=none; b=oJvdVO0qi12+7AyFli94Nre9Ol/MctizoTJxUNcwdeYYeoWN6CyPMBImsSoqX3e6vGzz5r QgbARlJxWsBB+pJvEQ8o2JF24qFz+PtXIZLKNcEMDeFqJdYMVUpkpd5tUf9NJbrVlohObt Z+0YSqzRC2XnPMVdhHgqkb/e8KEPKmk= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VE9eEdc9; spf=pass (imf14.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659838275; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=v4CNgJJIcoMkC9vrZjaMgTGVZv0Sy/rv5ilzH4CCfrc=; b=z0eS0AJKhUaOG7Opkv9e6jmw7LdoFuf/rroAlg9/T84jeHr8D/Qg4vx0ztEvbv0i8HB0b8 v6710yXh3BkSNXgYlR4XcCad3gR0NvgtyhX+5PLmvwF5d60yOC8tnYl0IJ9YKuwRwofbqX l/8w42w7MtaDdCg5aboE+JEcHr4rHjs= X-Rspamd-Queue-Id: 9A118100152 Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VE9eEdc9; spf=pass (imf14.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: piwpkupb6yrg6xrega9dscpm9mrkzekc X-HE-Tag: 1659838274-192970 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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) >