From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A5A1C4332F for ; Tue, 7 Nov 2023 23:25:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235623AbjKGXZU (ORCPT ); Tue, 7 Nov 2023 18:25:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344267AbjKGXYg (ORCPT ); Tue, 7 Nov 2023 18:24:36 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42B3F213D; Tue, 7 Nov 2023 15:23:51 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18C6CC433CC; Tue, 7 Nov 2023 23:23:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699399430; bh=T+VF2SfYqdlsFE0o5OEbuT79GlyXUHL7Mt9mzqFNmuU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ouMHc/gA7UUN3A4JadzDHS1ppuGTEpPk1DYEO8JoA9hDOnobAqFPfxV82hJuir4hP 18WZA2Dxw3CyHIoZtiUPnf0sUvzwZoTbDOwt5bcbYG1zghbkIkSxGoeyHo88lDmy9x 8AbrXSmqNu9lEyy6BjrvIqiCkT7JtpGi0doHicATXEhuGH1neVNHtZn0zPKShIVRNp DOCilSg7HTLVpos3Ob8up7R8Zy3SlKR2xhh5sRyTqn/F8nlcZ3quaed/N7/W9dqXc4 5SPsx23Y/IYicpCwAIAs5l/R9j6HH1rbTVYm58gSrjXHZgWfjbNP4C6REf+fubgt/m +QD3wwaerT1sA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Niklas Schnelle , Arnd Bergmann , Greg Kroah-Hartman , Sasha Levin , mathias.nyman@intel.com, linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 6.5 10/18] usb: pci-quirks: handle HAS_IOPORT dependency for UHCI handoff Date: Tue, 7 Nov 2023 18:23:05 -0500 Message-ID: <20231107232330.3776001-10-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231107232330.3776001-1-sashal@kernel.org> References: <20231107232330.3776001-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.5.10 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Niklas Schnelle [ Upstream commit 358ad297e379ff548247e3e24c6619559942bfdd ] In a future patch HAS_IOPORT=n will result in inb()/outb() and friends not being declared. With the AMD quirk handled USB PCI quirks still use inw() in uhci_check_and_reset_hc() and thus indirectly in quirk_usb_handoff_uhci(). Handle this by conditionally compiling uhci_check_and_reset_hc() and stubbing out quirk_usb_handoff_uhci() when HAS_IOPORT is not available. Co-developed-by: Arnd Bergmann Signed-off-by: Arnd Bergmann Signed-off-by: Niklas Schnelle Link: https://lore.kernel.org/r/20230911125653.1393895-4-schnelle@linux.ibm.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/pci-quirks.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index 10813096d00c6..1f9c1b1435d86 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c @@ -634,6 +634,16 @@ void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev) } EXPORT_SYMBOL_GPL(usb_asmedia_modifyflowcontrol); +static inline int io_type_enabled(struct pci_dev *pdev, unsigned int mask) +{ + u16 cmd; + + return !pci_read_config_word(pdev, PCI_COMMAND, &cmd) && (cmd & mask); +} + +#define mmio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_MEMORY) + +#if defined(CONFIG_HAS_IOPORT) && IS_ENABLED(CONFIG_USB_UHCI_HCD) /* * Make sure the controller is completely inactive, unable to * generate interrupts or do DMA. @@ -715,14 +725,7 @@ int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base) } EXPORT_SYMBOL_GPL(uhci_check_and_reset_hc); -static inline int io_type_enabled(struct pci_dev *pdev, unsigned int mask) -{ - u16 cmd; - return !pci_read_config_word(pdev, PCI_COMMAND, &cmd) && (cmd & mask); -} - #define pio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_IO) -#define mmio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_MEMORY) static void quirk_usb_handoff_uhci(struct pci_dev *pdev) { @@ -742,6 +745,12 @@ static void quirk_usb_handoff_uhci(struct pci_dev *pdev) uhci_check_and_reset_hc(pdev, base); } +#else /* defined(CONFIG_HAS_IOPORT && IS_ENABLED(CONFIG_USB_UHCI_HCD) */ + +static void quirk_usb_handoff_uhci(struct pci_dev *pdev) {} + +#endif /* defined(CONFIG_HAS_IOPORT && IS_ENABLED(CONFIG_USB_UHCI_HCD) */ + static int mmio_resource_enabled(struct pci_dev *pdev, int idx) { return pci_resource_start(pdev, idx) && mmio_enabled(pdev); -- 2.42.0