Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1384438rdh; Fri, 24 Nov 2023 11:08:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUj+6RoaSAeFrOW2jPPraT924NVEJZGRKdbFMr6Vn+sot9ZeqoQtG5bjT5NfTT7nH1nbF5 X-Received: by 2002:a9d:7506:0:b0:6bd:62c1:65c with SMTP id r6-20020a9d7506000000b006bd62c1065cmr3355016otk.18.1700852931874; Fri, 24 Nov 2023 11:08:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700852931; cv=none; d=google.com; s=arc-20160816; b=NIajM2+ghe3pZGpgTDWZEHRktLirR0eS0IC8r1VoeVe2mPGKmerZ/UyaW3hc6XwDiF 8mmLA0uK1s4P1xxN78z6LpmYMOQ6JEtWFg3Z9fPnX89pllTK533MhuLc92ZLkm+GqUBd n+vv5XKMYI2TuFn9xViGQHF9oiishjlu05i11RVgqFN/U/pIf+q3T+/3UordsMyDEBQj tXR1Kpgu6TJ2ZsCbintcJlStxPkWdsdvZQrV7ttIXF7chgZ/f7ttpGWpgPkcDEvMxQUQ LysQVQ9b1pPWw8UzJMEEvvQCREbobPmEYxECUe7Jxt5wMkqMpJPcxzAn+2W8SXHm2ZJV UVkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:content-language:references:cc:to:subject:from :user-agent:mime-version:date:message-id:dkim-signature; bh=2ktMN6fpPE1Jf/JsJv1eWYJ7kbl3PClV8V5bIG3J558=; fh=ZL6NpPzqwxB4XwM3y+dOBGphC+P1zpVQxpsW2uPGOB4=; b=vGM7q88+zSZbJUb/Z3Azqf79WelEoL2qom1oqTxymEtU0IvhidTvFrd6hdK5LnvpAQ JUIvSEXSt1CoKXJkrYqxID7N3nTWdhra3UqhdQ1+nvMsMuR1IplKHI23M0c5Mr+Iu6ax swTQNuGCppe4AOWWc0v687VYoq7o7alJA0bAPEpC4yxyI1+usB8XOrPyPzCJeuQQS5N9 k1NTH9H3HzUMJMlSSSVyohZrk7Cst6pKDwnrIbij4uZro6zTwGT29aR+cuEnHEGyKFA1 Fpk+Tj1Q0/U0iML5bNGbHFidlTn8vyvZFBPhFCr0jk2E4i5P7oyho4oLtoK5FkkWOEUc 9+nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R5AhIL42; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id dz11-20020a0568306d0b00b006d7f777df21si2049738otb.53.2023.11.24.11.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 11:08:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R5AhIL42; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 7E6D680B950D; Fri, 24 Nov 2023 11:08:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345911AbjKXTI3 (ORCPT + 99 others); Fri, 24 Nov 2023 14:08:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345799AbjKXTI2 (ORCPT ); Fri, 24 Nov 2023 14:08:28 -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 B7B4C19B1 for ; Fri, 24 Nov 2023 11:08:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700852913; 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=2ktMN6fpPE1Jf/JsJv1eWYJ7kbl3PClV8V5bIG3J558=; b=R5AhIL42byWML5c2aXzoYyeUNZ2ilRvQExbw6dxikcjmbr5wZHvbzA+OeiHCpb+b9fF2L1 lJUK7wstZKl9t8dN0NuHUHAHhBXC6roPQCBODHiq46t+rXLQpIQG6W3Iypux6+p6KcVn+e twLESudGdoa8Nkq327CUEYqR3L5R1XY= Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-696-P_0_uEoONRm4ynfhoWadcg-1; Fri, 24 Nov 2023 14:08:31 -0500 X-MC-Unique: P_0_uEoONRm4ynfhoWadcg-1 Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2c50ef18b04so26551541fa.1 for ; Fri, 24 Nov 2023 11:08:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700852910; x=1701457710; h=content-transfer-encoding:in-reply-to:organization:content-language :references:cc:to:subject:from:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2ktMN6fpPE1Jf/JsJv1eWYJ7kbl3PClV8V5bIG3J558=; b=SwphvGzlb40ECtswj83Nd6lguhcWCrydDmLXXCTyfYFuDqRTuJJ9V1Ik8CJaLuX3Am jUcDUPZ1a8P9KxepCn2RAy7J7j5aWF8ujKU+ikA1U3O9K3UhbnlrDe4fJk8Rbs9pXoFf z1bOILijLxqqY9MWmCsPp5UK8UGNuI+YanofFUUvtzapahi7jq6D8uweYX/UhEYBQf8i djwNlTLeKNkUvuhLZRbOlHWoZ8rlsyHqi/J+jjJvdy1cMEeDuHh3DtsbUQOpD33vmfls ZQSspVQHftVx+aAsAxxTW9TPkwyVskKRU9+32H9N6jxEOk055QTjtYlpxSHTFKYkpBoF 3MOg== X-Gm-Message-State: AOJu0Yw3x/otQJncD/mKH28ekT0cJ54bXCyW+NBhEv/3q7KhbdqhwLD+ d9saHNQbgCkEmoE26yn+GTo8NOcygfjGQjoAEdrtM+8TZgsMlRyDmB7pAYSs+KZ02Ho5YTtY8Vb hQj56EmzN4OMwzdVY4Ts/XIyB X-Received: by 2002:a2e:9d5a:0:b0:2c7:3b83:c4b7 with SMTP id y26-20020a2e9d5a000000b002c73b83c4b7mr2699922ljj.14.1700852910305; Fri, 24 Nov 2023 11:08:30 -0800 (PST) X-Received: by 2002:a2e:9d5a:0:b0:2c7:3b83:c4b7 with SMTP id y26-20020a2e9d5a000000b002c73b83c4b7mr2699899ljj.14.1700852909940; Fri, 24 Nov 2023 11:08:29 -0800 (PST) Received: from ?IPV6:2a02:810d:4b3f:de9c:abf:b8ff:feee:998b? ([2a02:810d:4b3f:de9c:abf:b8ff:feee:998b]) by smtp.gmail.com with ESMTPSA id hg25-20020a170906f35900b00a08a933baafsm1312957ejb.126.2023.11.24.11.08.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Nov 2023 11:08:29 -0800 (PST) Message-ID: Date: Fri, 24 Nov 2023 20:08:27 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Danilo Krummrich Subject: Re: [PATCH 4/4] lib/iomap.c: improve comment about pci anomaly To: Arnd Bergmann , 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 Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org References: <20231120215945.52027-2-pstanner@redhat.com> <20231120215945.52027-6-pstanner@redhat.com> Content-Language: en-US Organization: RedHat In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 howler.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 (howler.vger.email [0.0.0.0]); Fri, 24 Nov 2023 11:08:48 -0800 (PST) Hi Arnd, On 11/21/23 11:03, Arnd Bergmann wrote: > 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) Let's shed some light on the different config options related to this. To me it looks like GENERIC_IOMAP always implies GENERIC_PCI_IOMAP. lib/iomap.c contains a definition of pci_iounmap() since it uses the common IO_COND() macro. This definitions wins if GENERIC_IOMAP was selected. lib/pci_iomap.c contains another definition of pci_iounmap() which is guarded by ARCH_WANTS_GENERIC_PCI_IOUNMAP to prevent multiple definitions in case either GENERIC_IOMAP is set or the architecture already defined pci_iounmap(). What's the purpose of not having set ARCH_HAS_GENERIC_IOPORT_MAP producing an empty definition of pci_iounmap() though [1]? And more generally, is there any other (subtle) logic behind this? [1] https://elixir.bootlin.com/linux/latest/source/lib/pci_iomap.c#L167 > { > #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(). So, that would be similar to IO_COND(), right? What would we need inb() for in this context? - Danilo > > 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 >