Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp310607pxj; Thu, 20 May 2021 09:50:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHr6CqPRmA+bNSEc9Ueluz/pFiNSUi9cR5IeAEQCcLvtMpoqmua0mTZZTKyymIGDo9yWOP X-Received: by 2002:a17:906:1815:: with SMTP id v21mr5571473eje.376.1621529415868; Thu, 20 May 2021 09:50:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621529415; cv=none; d=google.com; s=arc-20160816; b=Yuqo+VwzmnWNqwLpzk4HR2XPR9IsXAuST5yIyNSQmE5li9jq3ruB/qD7B7ymoVQqPd J9kqLQE/do7vwpsyG5tDO4oAs34nKuPYNOXf0w+Wa6UkBF8xuJqutWe972t5Z9CyjyCn OI0lQiMVhpWlFmtl5J9MFmxIvsjHJUwMZFYs8/Itez0Wh0+4QISl67gqDCDVZYHbax// avuFjygDlCz9gc9GjHGOqFdgdDP8k3vQ2XMQRUnkgBpzf+Y4a5XC+yhXSLEoVtyRTnuk 1LAi0/QNLBoAFMmN1o85BtpibMQcgfMwvm3qbWhdhVMYgz5HBhAJxJAxLARZpIAE73dj YoLw== 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=scltzNbASTMnu27tPBvgDebjeuhmyyW69cbWXK4wrAt1BSLDNUXWsghIoGD9hYPX3v NdQFOFIIh9zPkQY/rDm1ZsXf+vMq2kjHjphgY58yZ5syp6O250DNoa6pEmvpKGuoITqJ Ta+/1TRMuGWN3aov4WEYllG2ElEwPofATt4LzajBCXLFg7MibChrpUCFlKRUoBaaF4pv waiXrlmJuRBJVxvbEHr6WkU3I65kRwMmq9mpy0i3lS/O2nYiCnfhmwHKUadBVUPRS7vS vS5mqJPr9d2xxxIAuwvtOsb8gpXGUe084nV+Hu9v3/WJ0KivC5LXs+rpcupcxX6UclgM nj2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="WW1EG/Xc"; 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 z26si3469266ejc.46.2021.05.20.09.49.52; Thu, 20 May 2021 09:50:15 -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="WW1EG/Xc"; 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 S234242AbhETJtJ (ORCPT + 99 others); Thu, 20 May 2021 05:49:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:46020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233840AbhETJqj (ORCPT ); Thu, 20 May 2021 05:46:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1BA786145F; Thu, 20 May 2021 09:34:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503243; bh=XAy2pfgFYlYB+28faCmmV4EPXsFKQAhJypPcnYGlmpU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WW1EG/Xc9fdBP7/Yn2qV3ZFstLBKjjgUEsyioRZPAhXTGzKLyhYHpU/79x77mtcwl 2nvHAsehyWIQBwvezqR8SLqqtraF8MdbMBVKI667HHa3tdqwvV5Zjc9p5nbk+rnQTf +NuSmiHVIr957lu4k53eHDFFRocOXiDXhYLwU6r4= 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.19 133/425] MIPS: pci-rt2880: fix slot 0 configuration Date: Thu, 20 May 2021 11:18:22 +0200 Message-Id: <20210520092135.803149244@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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; }