Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp2111065lkv; Thu, 20 May 2021 03:40:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyf+NTB/ZTdG/HXs3ei0G8QOGBqkhxHe9juvyJqmAyKqgOIgq/FMwimoC5kkSggN8daCp53 X-Received: by 2002:a92:d306:: with SMTP id x6mr5134382ila.88.1621507233998; Thu, 20 May 2021 03:40:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621507233; cv=none; d=google.com; s=arc-20160816; b=YK8ep79vBEDd+LqXVZgx2EUF6tslgekb8x7rESOM2t5Od2nd9ZNJP2ynb7aUaMi5yf 7EgkBGkFdCKMc6Xn6TbObb3pHqgvCqDalHKSWLcfY+QOmp2jfObYfYGQni5rYlxT5fFN O4bSFzRZH4i//9uWbkhIgg0UUl2K8dWFj2gKhcLddfF56/ehPKuiyZmOCP75X/aDt2Un Xm4l29+epJA7vthk92nwAV9HEkHn8AXJgjEcKdNFMFS4zsVY/Nft79Qod8T66/DeXuoU 2Vq27MeoJ8v/QYoyVDGnGJvsQUGWnSjK2TcY6r3rqWXn2uKWH8lE5QhZqYFk2i2+j2Sh AuOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DYm3MUF8o1p9smrbW+neZaZSMohDZNn1AWE7Ecs95ew=; b=or6/HlGAAMsMQ2EKGQhwkrrpXWP0R/Ilw7+m2qJbGrYrFSGeNQtUVID9XkBOgHLdk6 f5J4qYj1jA+NwbYj7QGaUQkmLClAjL1q0rJ2Dc8uKePFf6I88hOv171A62YTHk87pGYF /CASbx/Y4+O8iosZdp/8fNZ7bsIxtMUxwqI+dHuuCGeZiwzIp+WX5LgZicPQbKK/WDd5 NiAtfVVnIjnLhFQEc2n4IROtIZs6XXQDvTL1a0Sh0isXKji8jIZEqrdzfgVqN00sbJbF F4F1faQDlnJ1I5ysreg57n/ibbUsup1QAoeX0/Vy8OYx7BJNF07Oqrc7JahTPq4R2/rL KBlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qAVsZ0nm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s13si1806612iow.103.2021.05.20.03.40.14; Thu, 20 May 2021 03:40:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qAVsZ0nm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237857AbhETKjK (ORCPT + 99 others); Thu, 20 May 2021 06:39:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:55694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236616AbhETKYW (ORCPT ); Thu, 20 May 2021 06:24:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 091776145D; Thu, 20 May 2021 09:49:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504151; bh=XAy2pfgFYlYB+28faCmmV4EPXsFKQAhJypPcnYGlmpU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qAVsZ0nmUS/zwl2WwJ97Zh7G8AR2Bl+pzzjsTwinXyLboZQu5YGUq8fDiWI0xgCyP VtNEjfiOeMoAD9yZfkmthZ/hrzOE0+yXVC25AJq80eaFNiKcHhSWtVPRZv3DIx6SH5 TszYW3pyXkY+0rdX58koZr5I/AumvrlwkyQcii7Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilya Lipnitskiy , Lorenzo Pieralisi , Tobias Wolf , Thomas Bogendoerfer Subject: [PATCH 4.14 115/323] MIPS: pci-rt2880: fix slot 0 configuration Date: Thu, 20 May 2021 11:20:07 +0200 Message-Id: <20210520092124.038324455@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ilya Lipnitskiy commit 8e98b697006d749d745d3b174168a877bb96c500 upstream. pci_fixup_irqs() used to call pcibios_map_irq on every PCI device, which for RT2880 included bus 0 slot 0. After pci_fixup_irqs() got removed, only slots/funcs with devices attached would be called. While arguably the right thing, that left no chance for this driver to ever initialize slot 0, effectively bricking PCI and USB on RT2880 devices such as the Belkin F5D8235-4 v1. Slot 0 configuration needs to happen after PCI bus enumeration, but before any device at slot 0x11 (func 0 or 1) is talked to. That was determined empirically by testing on a Belkin F5D8235-4 v1 device. A minimal BAR 0 config write followed by read, then setting slot 0 PCI_COMMAND to MASTER | IO | MEMORY is all that seems to be required for proper functionality. Tested by ensuring that full- and high-speed USB devices get enumerated on the Belkin F5D8235-4 v1 (with an out of tree DTS file from OpenWrt). Fixes: 04c81c7293df ("MIPS: PCI: Replace pci_fixup_irqs() call with host bridge IRQ mapping hooks") Signed-off-by: Ilya Lipnitskiy Cc: Lorenzo Pieralisi Cc: Tobias Wolf Cc: # v4.14+ Signed-off-by: Thomas Bogendoerfer Signed-off-by: Greg Kroah-Hartman --- arch/mips/pci/pci-rt2880.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) --- a/arch/mips/pci/pci-rt2880.c +++ b/arch/mips/pci/pci-rt2880.c @@ -183,7 +183,6 @@ static inline void rt2880_pci_write_u32( int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) { - u16 cmd; int irq = -1; if (dev->bus->number != 0) @@ -191,8 +190,6 @@ int pcibios_map_irq(const struct pci_dev switch (PCI_SLOT(dev->devfn)) { case 0x00: - rt2880_pci_write_u32(PCI_BASE_ADDRESS_0, 0x08000000); - (void) rt2880_pci_read_u32(PCI_BASE_ADDRESS_0); break; case 0x11: irq = RT288X_CPU_IRQ_PCI; @@ -204,16 +201,6 @@ int pcibios_map_irq(const struct pci_dev break; } - pci_write_config_byte((struct pci_dev *) dev, - PCI_CACHE_LINE_SIZE, 0x14); - pci_write_config_byte((struct pci_dev *) dev, PCI_LATENCY_TIMER, 0xFF); - pci_read_config_word((struct pci_dev *) dev, PCI_COMMAND, &cmd); - cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_IO | PCI_COMMAND_MEMORY | - PCI_COMMAND_INVALIDATE | PCI_COMMAND_FAST_BACK | - PCI_COMMAND_SERR | PCI_COMMAND_WAIT | PCI_COMMAND_PARITY; - pci_write_config_word((struct pci_dev *) dev, PCI_COMMAND, cmd); - pci_write_config_byte((struct pci_dev *) dev, PCI_INTERRUPT_LINE, - dev->irq); return irq; } @@ -252,6 +239,30 @@ static int rt288x_pci_probe(struct platf int pcibios_plat_dev_init(struct pci_dev *dev) { + static bool slot0_init; + + /* + * Nobody seems to initialize slot 0, but this platform requires it, so + * do it once when some other slot is being enabled. The PCI subsystem + * should configure other slots properly, so no need to do anything + * special for those. + */ + if (!slot0_init && dev->bus->number == 0) { + u16 cmd; + u32 bar0; + + slot0_init = true; + + pci_bus_write_config_dword(dev->bus, 0, PCI_BASE_ADDRESS_0, + 0x08000000); + pci_bus_read_config_dword(dev->bus, 0, PCI_BASE_ADDRESS_0, + &bar0); + + pci_bus_read_config_word(dev->bus, 0, PCI_COMMAND, &cmd); + cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_IO | PCI_COMMAND_MEMORY; + pci_bus_write_config_word(dev->bus, 0, PCI_COMMAND, cmd); + } + return 0; }