Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp268446rdf; Tue, 21 Nov 2023 02:03:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IEi/PAutZ4J6U3GoGZkZhW61sH2E1pwhtiQTitCMirvvBO3ul2dpkFBmc3O1qpSZgEzUm+s X-Received: by 2002:a05:6a00:230f:b0:6ad:535e:6ed9 with SMTP id h15-20020a056a00230f00b006ad535e6ed9mr9899534pfh.16.1700561034732; Tue, 21 Nov 2023 02:03:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700561034; cv=none; d=google.com; s=arc-20160816; b=yU/bIZzALBM3CB+0j14aCiZoAhD3X4usLrB2h/3nDhJd9tDXRoGk7FEEFj0Hx+5YC7 Vq4Hc3/VeVLuDIk6ThJgloL/MuJv4nYmoPfhp64EC1y1gPRElHC9pFU1MpIvAkx6EfbG QENrcAwJBMolo68lRF9YqUzd62UW3EcQEuO4qlNtK+Jc5S4AHFywK4oNd3o6wLu2HoER putwgfuYhEQLdbMmcQNIoZcvixTdYFt0K9ZKGhSTXSsR0s4EqBvsf3uf1p2Nalh/l8rT mLJzLk+FAT+0BU8J82Wh5667rvqvVWORleWYh/ZqBJQYXZBbh7qMBvLqDfJJ8/QMOO/d GD4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature; bh=YrpMeXdJ5ZCbPsg0bEt9UIxZl/qZw3mM38KtY2Yassg=; fh=84EnaAUACVtiQIBVEUv8V/+moi6opmgSt0fDKpyYDB4=; b=yFjY1YkHPXWGGXVyg+zt4SPnhlt+LbWvCmURPKNM1HWkQhSFYH4XCRI5v2stZXZGII mVr1vwI/5/VH3bZc8m5uCFJ2P/J/HNwSofIaiTM6XLebZhBbOjs4M9PercONzg2v9zMM G2NJvx2zhzSjexVqZx0Bm/w+rotpclp1Fd0yKcEvB2oRn31viGfreKVmFycWx6HsMDLe rUIJtj8dh2Mm2qSFTOaLncoi5kFs9GZ4byYu10neQ+u1KMz7wCQRem3kOr55hMUijHW6 EUQb1UCjhQhrApkSBX1cu94WZi7dNihR1UMwKEFaSewkNIcs0z002uqvBEgelmCLTRua u5pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fKP5KSwW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id n26-20020a6563da000000b005bd28c9bb23si10053535pgv.308.2023.11.21.02.03.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 02:03:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fKP5KSwW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id D9D048056C56; Tue, 21 Nov 2023 02:03:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232462AbjKUKDg (ORCPT + 99 others); Tue, 21 Nov 2023 05:03:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229598AbjKUKDe (ORCPT ); Tue, 21 Nov 2023 05:03:34 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F7A3F5 for ; Tue, 21 Nov 2023 02:03:31 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 095ABC433C9; Tue, 21 Nov 2023 10:03:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700561010; bh=koXHjXCkUn9fEpUuj0fKfGenlf1DnXywIbJ9kbvHrHE=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=fKP5KSwWc0vw/gLa5kt8qk6+lo2wOlm558Kp/3bTafIQKbJKJTWPqEJjKaeUAX7y8 lI/mLvyNmGQhlLZouOBMCl3g6aAOpSNyDrhoV71M3Z/662sGs+owMgvSOtTNFtDtB8 Rm+MlDpvL6WVL9hV9ZkUxOHwfJ5DfV7FGmLsYj5tZxOppcBLk5S9PrNzRLuHpIkwxI 3tl3JWu7fPo9PK9/X+xC7TqrMyl6pQ2+GS+Oq0dJUKOZb9zJ7jrw1pzzk7tHKEXrNm sIKaEScK6WaYrclQRJxXbap5Jsz+GLWY6IownzJ4N9OTQw8S+sUAY0s39UN1gj+p9L 28cgRXamBW+sQ== Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailauth.nyi.internal (Postfix) with ESMTP id D370727C005A; Tue, 21 Nov 2023 05:03:28 -0500 (EST) Received: from imap51 ([10.202.2.101]) by compute5.internal (MEProxy); Tue, 21 Nov 2023 05:03:28 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudegledgtdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedftehr nhguuceuvghrghhmrghnnhdfuceorghrnhgusehkvghrnhgvlhdrohhrgheqnecuggftrf grthhtvghrnhepvdeviefgtedugeevieelvdfgveeuvdfgteegfeeiieejjeffgeeghedu gedtveehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprghrnhguodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduvdekhedujedt vdegqddvkeejtddtvdeigedqrghrnhgupeepkhgvrhhnvghlrdhorhhgsegrrhhnuggsrd guvg X-ME-Proxy: Feedback-ID: i36794607:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id A9496B60089; Tue, 21 Nov 2023 05:03:26 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-1178-geeaf0069a7-fm-20231114.001-geeaf0069 MIME-Version: 1.0 Message-Id: In-Reply-To: <20231120215945.52027-6-pstanner@redhat.com> References: <20231120215945.52027-2-pstanner@redhat.com> <20231120215945.52027-6-pstanner@redhat.com> Date: Tue, 21 Nov 2023 11:03:06 +0100 From: "Arnd Bergmann" To: "Philipp Stanner" , "Bjorn Helgaas" , "Andrew Morton" , "Randy Dunlap" , "Jason Gunthorpe" , "Eric Auger" , "Kent Overstreet" , "Niklas Schnelle" , "Neil Brown" , "John Sanpe" , "Dave Jiang" , "Yury Norov" , "Kees Cook" , "Masami Hiramatsu" , "David Gow" , "Herbert Xu" , "Thomas Gleixner" , "wuqiang.matt" , "Jason Baron" , "Ben Dooks" , "Danilo Krummrich" Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH 4/4] lib/iomap.c: improve comment about pci anomaly Content-Type: text/plain X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 groat.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 (groat.vger.email [0.0.0.0]); Tue, 21 Nov 2023 02:03:44 -0800 (PST) On Mon, Nov 20, 2023, at 22:59, Philipp Stanner wrote: > lib/iomap.c contains one of the definitions of pci_iounmap(). The > current comment above this out-of-place function does not clarify WHY > the function is defined here. > > Linus's detailed comment above pci_iounmap() in drivers/pci/iomap.c > clarifies that in a far better way. > > Extend the existing comment with an excerpt from Linus's and hint at the > other implementation in drivers/pci/iomap.c > > Signed-off-by: Philipp Stanner I think instead of explaining why the code is so complicated here, I'd prefer to make it more logical and not have to explain it. We should be able to define a generic version like void pci_iounmap(struct pci_dev *dev, void __iomem * addr) { #ifdef CONFIG_HAS_IOPORT if (iomem_is_ioport(addr)) { ioport_unmap(addr); return; } #endif iounmap(addr) } and then define iomem_is_ioport() in lib/iomap.c for x86, while defining it in asm-generic/io.h for the rest, with an override in asm/io.h for those architectures that need a custom inb(). Note that with ia64 gone, GENERIC_IOMAP is not at all generic any more and could just move it to x86 or name it something else. This is what currently uses it: arch/hexagon/Kconfig: select GENERIC_IOMAP arch/um/Kconfig: select GENERIC_IOMAP These have no port I/O at all, so it doesn't do anything. arch/m68k/Kconfig: select GENERIC_IOMAP on m68knommu, the default implementation from asm-generic/io.h as the same effect as GENERIC_IOMAP but is more efficient. On classic m68k, GENERIC_IOMAP does not do what it is meant to because I/O ports on ISA devices have port numbers above PIO_OFFSET. Also they don't have PCI. arch/mips/Kconfig: select GENERIC_IOMAP This looks completely bogus because it sets PIO_RESERVED to 0 and always uses the mmio part of lib/iomap.c. arch/powerpc/platforms/Kconfig: select GENERIC_IOMAP This is only used for two platforms: cell and powernv, though on Cell it no longer does anything after the commit f4981a00636 ("powerpc: Remove the celleb support"); I think the entire io_workarounds code now be folded back into spider_pci.c if we wanted to. The PowerNV LPC support does seem to still rely on it. This tries to do the exact same thing as lib/logic_pio.c for Huawei arm64 servers. I suspect that neither of them does it entirely correctly since the powerpc side appears to just override any non-LPC PIO support while the arm64 side is missing the ioread/iowrite support. Arnd