Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1173190rwd; Tue, 16 May 2023 12:58:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6OjW4GJL2pynk2CLH4cXo0doR8x0YRb/6uD/buXkkyfziqUZZYK2qXDcztM8oyfxTMYXBb X-Received: by 2002:a05:6a20:734f:b0:107:35ed:28b5 with SMTP id v15-20020a056a20734f00b0010735ed28b5mr2121898pzc.2.1684267096593; Tue, 16 May 2023 12:58:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684267096; cv=none; d=google.com; s=arc-20160816; b=t7hQDdWW7wHv4Fq9dhNHGW5HLqBudGUypjxD7UKanle035PnV31tJWeUilM5f1+tbx iIH3EPPCGeY596SWsDe87yZNR7Clip733LSgt6Y1lv3GVC5sfTEG5JVLsdBA+UV5aP3q /Z+61/enba2AQL2pheCBtadf8Sp5bCeLbB6PjcJ49LUc0/ErGj1bbK3sNeHk/lK+UgpM rv7mHhH+eCv4Xx/vJFPWCVdUrGvy/sxTVOSZ5PCNWaobXj2xwuaygLRbrD2lsVX4r4Xy KQrGADbAHdN15KRoyHtoBibdJuYTCU3b0AG30cBW5f1j3o+EKUNItfStA4XvAs3Y9XW2 RQEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=jPWBcfgioMZ9ytAoeO6Vx3f5UpturzLamnxwgaAYv3E=; b=hvvvf/oMRSL993k637yWWjFzI2qoT6/luA/64Jp5CsE1+/dZh9pd7GHkcDZWbUfN93 SsqV0MWGYNRKXudB//BhFK8LFpj/FRzuFO26NgC/erkE0pmZOHW/dB1oHDiz+IEN64x8 EmjysayE3WA2XLbstNM/Ccd+yzkwxiYOKUv24herOw2SJRQvI8pplXfbPkaXWk2kvJ0w uV3yTCGcVXz9DSy0wvWpbupEyIsJMUO9SX364wKfzJ1vob+sHd+dHnigDfu0xcCgmedI dN2gGG8gCmYzBCnld9SJQp0HGBqMi2MrWoPNhBDdcvoUBjV2gX7GYWqyCBN1Yw4RxOA8 aH8g== 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s20-20020a63af54000000b005192d51325dsi18642066pgo.42.2023.05.16.12.58.02; Tue, 16 May 2023 12:58:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229555AbjEPTvk (ORCPT + 99 others); Tue, 16 May 2023 15:51:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbjEPTvi (ORCPT ); Tue, 16 May 2023 15:51:38 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 9C5BD76B1 for ; Tue, 16 May 2023 12:51:31 -0700 (PDT) Received: (qmail 845160 invoked by uid 1000); 16 May 2023 15:51:30 -0400 Date: Tue, 16 May 2023 15:51:30 -0400 From: Alan Stern To: Arnd Bergmann Cc: Greg Kroah-Hartman , Niklas Schnelle , Bjorn Helgaas , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Mauro Carvalho Chehab , "Rafael J . Wysocki" , Geert Uytterhoeven , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-kernel@vger.kernel.org, Linux-Arch , linux-pci@vger.kernel.org, Arnd Bergmann , linux-usb@vger.kernel.org Subject: Re: [PATCH v4 35/41] usb: uhci: handle HAS_IOPORT dependencies Message-ID: <23936929-80e4-4599-827a-d09b4960f3ab@rowland.harvard.edu> References: <20230516110038.2413224-1-schnelle@linux.ibm.com> <20230516110038.2413224-36-schnelle@linux.ibm.com> <2023051643-overtime-unbridle-7cdd@gregkh> <4e291030-99d9-4b8b-9389-9b8f2560b8e8@app.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4e291030-99d9-4b8b-9389-9b8f2560b8e8@app.fastmail.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS, 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 Tue, May 16, 2023 at 06:44:34PM +0200, Arnd Bergmann wrote: > On Tue, May 16, 2023, at 18:29, Greg Kroah-Hartman wrote: > > On Tue, May 16, 2023 at 01:00:31PM +0200, Niklas Schnelle wrote: > > >> #ifndef CONFIG_USB_UHCI_SUPPORT_NON_PCI_HC > >> /* Support PCI only */ > >> static inline u32 uhci_readl(const struct uhci_hcd *uhci, int reg) > >> { > >> - return inl(uhci->io_addr + reg); > >> + return UHCI_IN(inl(uhci->io_addr + reg)); > >> } > >> > >> static inline void uhci_writel(const struct uhci_hcd *uhci, u32 val, int reg) > >> { > >> - outl(val, uhci->io_addr + reg); > >> + UHCI_OUT(outl(val, uhci->io_addr + reg)); > > > > I'm confused now. > > > > So if CONFIG_HAS_IOPORT is enabled, wonderful, all is good. > > > > But if it isn't, then these are just no-ops that do nothing? So then > > the driver will fail to work? Why have these stubs at all? > > > > Why not just not build the driver at all if this option is not enabled? > > If I remember correctly, the problem here is the lack of > abstractions in the uhci driver, it instead supports all > combinations of on-chip non-PCI devices using readb()/writeb() > and PCI devices using inb()/outb() in a shared codebase. Isn't that an abstraction? A single set of operations (uhci_readl(), uhci_writel(), etc.) that always does the right sort of I/O even when talking to different buses? So I'm not sure what you mean by "the lack of abstractions". > A particularly tricky combination is a kernel that supports on-chip > UHCI as well as CONFIG_USB_PCI (for EHCI/XHCI) but does not support > I/O ports because of platform limitations. The trick is to come up > with a set of changes that doesn't have to rewrite the entire logic > but also doesn't add an obscene number of #ifdef checks. Indeed, in a kernel supporting that tricky combination the no-op code would be generated. But it would never execute at runtime because the uhci_has_pci_registers(uhci) test would always return 0, and so the driver wouldn't fail. > That said, there is a minor problem with the empty definition > > +#define UHCI_OUT(x) > > I think this should be "do { } while (0)" to avoid warnings > about empty if/else blocks. I'm sure Niklas wouldn't mind making such a change. But do we really get such warnings? Does the compiler really think that this kind of (macro-expanded) code: if (uhci_has_pci_registers(uhci)) ; else if (uhci_is_aspeed(uhci)) writel(val, uhci->regs + uhci_aspeed_reg(reg)); deserves a warning? I write stuff like that fairly often; it's a good way to showcase a high-probability do-nothing pathway at the start of a series of conditional cases. And I haven't noticed any complaints from the compiler. Alan Stern