Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2729991rdb; Mon, 4 Dec 2023 06:10:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IEw2gT236EfHTIj9O3G6bscBCJmlSktQ5oUR1kJF3CRgngoVAt2AQlGZ9u5g8cGzJtIp0gO X-Received: by 2002:a05:6a20:8e0d:b0:186:ff2d:f964 with SMTP id y13-20020a056a208e0d00b00186ff2df964mr5800312pzj.36.1701699004217; Mon, 04 Dec 2023 06:10:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701699004; cv=none; d=google.com; s=arc-20160816; b=pGmsUSD7fpoFZr7nWXkCrz/eNG3prK8AMroZ3K3Bg0SyvaqW0qZGrePBrHnfifQPXJ qOifS/PWDI4QXtABdrFH2t6V6HSNVuXDQp6YJaXRCQFRdbkr9a5qIEQmJNNdXf9gZUEf TKXDhGewl6+xUbIaTZGSXSXc9wVp3aP3gn240aGOOcDy8ArxKPG13CrJVlE010+2/yZZ 5HINXe8gd1QS0WKTIi+j/thdWHLBFwQDsayW5f//YSSvNXSW9e3jKgmuZ/BJkl9/LtgZ mCpaaIgc0yPCIlrIxIttW/8OBJamorIQU7uYC6fFpoIdobI8pCmy+8BoIK8Ijos3+U9b 6lFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=Jre80fB5gxpOyf9zLOpdEKJWXB6ZQSAxU9A6LZTXLUU=; fh=M3uJjnC3gspSZP1E4XnOLPxj4BfIqU5bsHi6qX6892M=; b=pQ2FXt+Rn4nyduq6CCGraC02hdC8ZeGUxD/CuJXN6oa3R+WaBXYprEXJJcuzyU5HxA SCtbNRfqPtog2bX+fLegJL6ZuaqC5o8LCXoGqVeV/AnIt+Nfjab4Z/l/Nyvkm8TT7wh6 YbhoM5iM9EDidccNEkUiB/jbsuf5egMnKRtMqbx97ZxLBMICDgPZLrKtbOU84UWYRBvQ GyfoxQVAEYeCass67Bw8BObtYHznd+jlOzkP6JBoIZjaivjzhoKUMQeoHmjJzTSlVPYI 5QuFHpplqNkFhmTwot/A9eZO9CYqHuLmiYPxcjCtb4u/2p+UPCWp+JJlVjOs1Im9ofRt kWwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ROilq0nP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id e16-20020a656790000000b005c212bdc7d2si3920174pgr.611.2023.12.04.06.10.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 06:10:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ROilq0nP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 5BFC08096A43; Mon, 4 Dec 2023 06:10:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344962AbjLDOJp (ORCPT + 99 others); Mon, 4 Dec 2023 09:09:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344990AbjLDOJn (ORCPT ); Mon, 4 Dec 2023 09:09:43 -0500 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 33452106 for ; Mon, 4 Dec 2023 06:09:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701698989; 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=Jre80fB5gxpOyf9zLOpdEKJWXB6ZQSAxU9A6LZTXLUU=; b=ROilq0nPcGmOxlMcRV+FGtpy9a8ghpKO5nKkBLgTKygAvPg7i0YUy7U74V/LrrsduvD3h/ EwM2E6k3bMWsj3mVmRzqwgMZ9eMAiDMHP7KFJrX/KtatOrs+1dZPvk7X9AF5FZMAm8biNt TteB/kqcCKRc1slVU5K/Pydkab5dkV0= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-606-3C-IE55SMjGK79oQc6gdMg-1; Mon, 04 Dec 2023 09:09:47 -0500 X-MC-Unique: 3C-IE55SMjGK79oQc6gdMg-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-40b4302eac2so7857175e9.1 for ; Mon, 04 Dec 2023 06:09:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701698986; x=1702303786; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Jre80fB5gxpOyf9zLOpdEKJWXB6ZQSAxU9A6LZTXLUU=; b=ogC5uo8czLnMgzirjiRh2jAGEkiUQ26ucYRyEKgx//+ulagSEiDnnvdSUaLjt0tYgQ Ix3kGI5YJbkiuuYL9QUHJ6RQcwpUwbsHOA4fZPz8opLp8tbkzkDCM82xWUuUHIp82Tg8 8BDMY4RwYUug4ltGR4iDNQnujEI2Z9/lirxikpQMIJizuUTE7Kk1ecbqpAshXHwXJGdo 9/Sg4psT0HtyfnfI1gj8cy4nv0p2Xt4NADQa3mSBEBuWJSg1/X0QrxpViUXkQvhW0Ljg DLCWeUURdHI6UkXPUzs/Lkb+LzacKaluUhrzGvh5apTPn0ZegMyy1ZweGGkveoolOxTp ND6A== X-Gm-Message-State: AOJu0Yxj2jVtErwQdZ6Fy1OrwzMbhQ/JZjbuDX9pJdrQlygEvgrEzwLJ gVu5rjUBqMWrV3ZLoT5ksKtLHXHSemD/EEunUo+hkbAIUjT/tRX7aOpX/boAQ7p75vLVwa9LwW/ dPhX4q+Ls8idXEtRQu92xJqR4 X-Received: by 2002:a05:600c:54f0:b0:40b:4b69:b1a0 with SMTP id jb16-20020a05600c54f000b0040b4b69b1a0mr13770507wmb.3.1701698986425; Mon, 04 Dec 2023 06:09:46 -0800 (PST) X-Received: by 2002:a05:600c:54f0:b0:40b:4b69:b1a0 with SMTP id jb16-20020a05600c54f000b0040b4b69b1a0mr13770492wmb.3.1701698986081; Mon, 04 Dec 2023 06:09:46 -0800 (PST) Received: from pstanner-thinkpadt14sgen1.remote.csb ([2001:9e8:32c8:b00:227b:d2ff:fe26:2a7a]) by smtp.gmail.com with ESMTPSA id bi19-20020a05600c3d9300b0040b54d7ebb9sm15028705wmb.41.2023.12.04.06.09.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 06:09:45 -0800 (PST) Message-ID: Subject: Re: [PATCH v3 5/5] lib, pci: unify generic pci_iounmap() From: Philipp Stanner To: Arnd Bergmann , Bjorn Helgaas , Hanjun Guo , Neil Brown , Kent Overstreet , Jakub Kicinski , Niklas Schnelle , Uladzislau Koshchanka , John Sanpe , Dave Jiang , Masami Hiramatsu , Kees Cook , David Gow , Herbert Xu , Shuah Khan , "wuqiang.matt" , Yury Norov , Jason Baron , Andrew Morton , Ben Dooks , Danilo Krummrich Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Linux-Arch , stable@vger.kernel.org, Arnd Bergmann , pstanner@redhat.com Date: Mon, 04 Dec 2023 15:09:43 +0100 In-Reply-To: <05173886-444c-4bae-b1a5-d2b068e9c4a5@app.fastmail.com> References: <20231204123834.29247-1-pstanner@redhat.com> <20231204123834.29247-6-pstanner@redhat.com> <2648aef32cd5a2272cd3ce8cd7ed5b29b2d21cad.camel@redhat.com> <05173886-444c-4bae-b1a5-d2b068e9c4a5@app.fastmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 04 Dec 2023 06:10:01 -0800 (PST) On Mon, 2023-12-04 at 14:50 +0100, Arnd Bergmann wrote: > On Mon, Dec 4, 2023, at 14:39, Philipp Stanner wrote: > > On Mon, 2023-12-04 at 13:38 +0100, Philipp Stanner wrote: >=20 > > > + */ > > > +#if defined(ARCH_WANTS_GENERIC_IOMEM_IS_IOPORT) > > > +bool iomem_is_ioport(void __iomem *addr) > > > =C2=A0{ > > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0IO_COND(addr, /* nothing *= /, iounmap(addr)); > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0unsigned long port =3D (un= signed long __force)addr; > > > + > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (port > PIO_OFFSET && p= ort < PIO_RESERVED) > >=20 > > by the way: > > Reading that again my instinctive feeling would be that it should > > be > > port >=3D PIO_OFFSET. > >=20 > > This is, however, the exactly copied logic from the IO_COND macro > > in > > lib/iomap.c. Is it possible that this macro contains a bug here? >=20 > Right, I think that would make more sense, but there is no > practical difference as long as I/O port 0 is always unused, > which is at least true on x86 because of PCIBIOS_MIN_IO. > Commit bb356ddb78b2 ("RISC-V: PCI: Avoid handing out address > 0 to devices") describes how setting PCIBIOS_MIN_IO to 0 > caused other problems. Ok, makes sense. But should we then adjust iomem_is_ioport() in asm-generic/io.h, as well, so that it matches IO_COND()'s behavior? It currently does this: uintptr_t start =3D (uintptr_t)PCI_IOBASE; uintptr_t addr =3D (uintptr_t)addr_raw; if (addr >=3D start && addr < start + IO_SPACE_LIMIT) return true; and if the architecture does not set PCI_IOBASE, then it's set per default to 0, as well. So we have two inconsistent definitons >=20 > I would just leave the logic consistent with IO_COND here, > or maybe use IO_COND() directly, like >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 IO_COND(addr, return true, /* nothing */); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return false; I considered using it to increase consistency. However, I valued improved readability more. Considering that the mid-term goal is to move it to x86 anyways I'd like to leave it that way for now. P. >=20 > =C2=A0=C2=A0=C2=A0=C2=A0 Arnd >=20