Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4832914iob; Mon, 9 May 2022 02:42:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygWwIv6hEXYH5eYZhy9umHBwqumeo9xQyi+lYbJZwREwJyAYPXS7TA+p8ujHn3wDh8xM5o X-Received: by 2002:a17:90b:4c10:b0:1dc:8289:7266 with SMTP id na16-20020a17090b4c1000b001dc82897266mr25676056pjb.190.1652089378022; Mon, 09 May 2022 02:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652089378; cv=none; d=google.com; s=arc-20160816; b=oo9BpJmLjq0/CM+li5encsFKac3pSWEWDq53X3ZniTDEEBzYNBZX3c1dYPw0Zu7Kno SV6TDuWA/TmkOozFCXbXrcxE/ESBhvs9hQ7ouDZmXWruTuDWA7QytTRbT880saIrX/Oz g2OpCashhN9LjpkWX3IK9Evb7VOJdBcDr3bKuXm81ww0l8O0VqUoqgZJ19RXncr5XfEy sswE5Zr4Tix9Up0k7BFrLmfwqP8TpZRhne7drxkliOigkv7ELkZLTxf9r3jpDC45gFuH TB0+HdM02YXOcBII5ILQWiFrl5P5bj0mjmEMUGuVYu7p27ywZkBH9m4L13YmwTsvOLmn llIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=G2s+AM5Z/cEWfKtZbdmffBUO5M791JT3EdrRSPC+WgI=; b=jjM/+9400PP+Hxo3z6KiYn5dbzc7TVTc2LJjjBZ+xEXv0fKcbSLVu75Jhrmn2BDsJK MuSmXeALSaYgZxv+fTWJKc2k7AMBcLNzd776cDCnRdhX856+7Q1gihJic8lwlp3VJLwH FuqXbdTFcObOj4+xRfTDkTYco/NDmFQi8ct9uJaBA9n5QA8I6IBZpKAlJaw3BMOLlQX3 Vif2kFSGFOxCSWhRpzuKyTk2Su0sOZQeM2buLeP8+aiSsHbmslYll/RlgsetlBGRng71 W0J9BCtkDQADsQHEyG19JXbtE6RZCPuapbaFSDVUvcpzbjFy0sQ/4EI4agyD1iUaUsFB Ng1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c5-20020a170903234500b0015ec0e8d867si11899900plh.247.2022.05.09.02.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 02:42:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 014CA1D6772; Mon, 9 May 2022 02:27:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359571AbiEFNMw (ORCPT + 99 others); Fri, 6 May 2022 09:12:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237119AbiEFNMq (ORCPT ); Fri, 6 May 2022 09:12:46 -0400 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 396C820BED; Fri, 6 May 2022 06:09:02 -0700 (PDT) Received: by mail-qv1-f47.google.com with SMTP id kl21so5346495qvb.9; Fri, 06 May 2022 06:09:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=G2s+AM5Z/cEWfKtZbdmffBUO5M791JT3EdrRSPC+WgI=; b=KDdd7fWVz2Gc3n3evTji4Ff9SHDMtj2TXkoOPsceaxAiVKLV+xGG/zABuL+2yU/BEe AhwuSV0HEF9UAwNTd1a2GizHrHcIx8wPUC1fygO+P3uNk9mDKpEARIf57sRrMRZFptJ/ JnWjeJrZAZnuH4d4yyWqxzQ+pno0rHdaiDCNZHyuVo8Uzuaw5wz/OCmtD7n6odg5ENdx VG/vH11Xxx04yZV6fMLGBzFuhux9teiMZQYg7I6cIG5wFaerG+hEydGg9Wks1SSciTMd 0hnzwEvVc9QEWbitrYzTmwvX5JDNsec44fVG/Oktpr27UzCotE1jRg85SMZ/aGUvMYjG 1Jug== X-Gm-Message-State: AOAM5319qGOEzbYnPsXr/HiOa2BfYkHy7njGh2WiQ0ibzeA6lWE4KYwK 3bHlOofu0owjQHoMomzDEM+VIP1+hbJ+4g== X-Received: by 2002:a0c:c3c6:0:b0:42c:17e4:9a75 with SMTP id p6-20020a0cc3c6000000b0042c17e49a75mr2596825qvi.124.1651842541158; Fri, 06 May 2022 06:09:01 -0700 (PDT) Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com. [209.85.219.171]) by smtp.gmail.com with ESMTPSA id x13-20020ac86b4d000000b002f39b99f69asm2539395qts.52.2022.05.06.06.08.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 May 2022 06:08:59 -0700 (PDT) Received: by mail-yb1-f171.google.com with SMTP id i38so12717763ybj.13; Fri, 06 May 2022 06:08:58 -0700 (PDT) X-Received: by 2002:a25:4506:0:b0:648:cfc2:301d with SMTP id s6-20020a254506000000b00648cfc2301dmr2250498yba.380.1651842538339; Fri, 06 May 2022 06:08:58 -0700 (PDT) MIME-Version: 1.0 References: <20220505161028.GA492600@bhelgaas> <5239892986c94239a122ab2f7a18a7a5@AcuMS.aculab.com> In-Reply-To: <5239892986c94239a122ab2f7a18a7a5@AcuMS.aculab.com> From: Geert Uytterhoeven Date: Fri, 6 May 2022 15:08:46 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC v2 01/39] Kconfig: introduce HAS_IOPORT option and select it as necessary To: David Laight Cc: "Maciej W. Rozycki" , Arnd Bergmann , Rich Felker , "open list:IA64 (Itanium) PLATFORM" , "open list:SUPERH" , Catalin Marinas , Dave Hansen , "open list:MIPS" , "James E.J. Bottomley" , "open list:SPARC + UltraSPARC (sparc/sparc64)" , "open list:RISC-V ARCHITECTURE" , Will Deacon , linux-arch , Yoshinori Sato , Helge Deller , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Russell King , Ingo Molnar , linux-pci , Bjorn Helgaas , Matt Turner , Albert Ou , Arnd Bergmann , Niklas Schnelle , "open list:M68K ARCHITECTURE" , Ivan Kokshaysky , Paul Walmsley , Thomas Gleixner , "moderated list:ARM PORT" , Richard Henderson , Michal Simek , Thomas Bogendoerfer , "open list:PARISC ARCHITECTURE" , Greg Kroah-Hartman , Linux Kernel Mailing List , Palmer Dabbelt , "open list:ALPHA PORT" , Borislav Petkov , "open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)" , "David S. Miller" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Fri, May 6, 2022 at 2:56 PM David Laight wrote: > From: Maciej W. Rozycki > > Sent: 06 May 2022 13:27 > > On Fri, 6 May 2022, Arnd Bergmann wrote: > > > > If this is PCI/PCIe indeed, then an I/O access is just a different bit > > > > pattern put on the bus/in the TLP in the address phase. So what is there > > > > inherent to the s390 architecture that prevents that different bit pattern > > > > from being used? > > > > > > The hardware design for PCI on s390 is very different from any other > > > architecture, and more abstract. Rather than implementing MMIO register > > > access as pointer dereference, this is a separate CPU instruction that > > > takes a device/bar plus offset as arguments rather than a pointer, and > > > Linux encodes this back into a fake __iomem token. > > > > OK, that seems to me like a reasonable and quite a clean design (on the > > hardware side). > > > > So what happens if the instruction is given an I/O rather than memory BAR > > as the relevant argument? Is the address space indicator bit (bit #0) > > simply ignored or what? > > You don't understand something... > > For a memory BAR pci_ioremap() returns a token that can be used with readl(). > On most architectures readl() is just a memory access. > This all fails on an I/O BAR. > > For an I/O BAR you want a similar pair of functions. > On x86 the access function would need to use the 'in/out' instructions but > there is no requirement for the token to be the native io port number. > On many non-x86 architectures the access function would be a simple memory > access - but a specific system (eg many ppc) may never actually allow > such mappings to succeed. > > You might also want a third PCI mapping function that can map a memory > BAR or an I/O BAR - with a suitable access function. > On x86 this would need something like ioread8() for accesses. > Except that function uses small integers for io port numbers > (which is inherently dangerous). > > Nothing except the architecture specific implementation of the function > to access an io BAR would ever go near a function called inb(). > > The same is really true for other bus type - including ISA and EISA. > (Ignoring the horrid of probing ISI bus devices - hopefully they > are in the ACPI tables??_ > If a driver is probed on a ISA bus there ought to be functions > equivalent to pci_ioremap() (for both memory and IO addresses) > that return tokens appropriate for the specific bus. > > That is all a different load of churn. A loooong time ago, it was suggested to add register accessor functions to struct device, so e.g. readl(dev, offset) would call into these accessors, which would implement the bus-specific behavior. No more worries about readl(), __raw_readl(), ioread32b(), or whatever quirk is needed, at the (small on nowadays' machines) expense of some indirection... Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds