Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5012585ybv; Mon, 17 Feb 2020 10:22:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwrHxCpjW9d5k03UDHn92t6vKm2iHK2EHoKP0BBnSZFWQCpeN8Nbfn2XS7RsQYAqYmeyENE X-Received: by 2002:aca:f584:: with SMTP id t126mr222266oih.132.1581963749003; Mon, 17 Feb 2020 10:22:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581963748; cv=none; d=google.com; s=arc-20160816; b=AYVyJHKDkLgs+hr8/6fUJT4ICh8uJYPpM9cWNTyFmc66huctqgsltdFd3uAuidF0Ex +G2ZpzrwVNiByu5553Z1IKbxngEMof5yBatQzfsiY8yq/0PRJfIlhk0p4nyTwocWBJwU my5feFdZQ49py+EX8een4t4IxYvvBxLJOasIoYjIpHZPkWT7Hs+jtmLQW6yJJdfC/554 48SpmY4xF7kcqwpPRJmLwNQVssdgi9LZ+fAKNv3ZBfnKzo9SoDkzT5qnd/UF+UHcIfFK I7eVp0+rHJwPZIjkj/+WPDeCb1cHwTPAEXUghFTXynFdZh8hNnfO0FKBbVVy6hGCAKme ezkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=Nhbrp+Pp7DfecWgaugSZ6e+4cuwdEWfiLacpNtZF654=; b=LVG10+QI8EqOeMeuDA4Ghu8+d3NkIh6fUpmUQpkt6D85ggfi1gmBFVn6ej3ntQdemW xziUTWhw9NcZWGAgDe2I82OhMXHJ/xLohNcTWZVn4qU9uxlqBWy7cOZ/8fcMDBefuyfG TUTzUH4lgLZmtvyTEzdNo2+9NAeMnjcVL9+aYdUex/k296wTOSRDDhDL248Y0Kl+/wAY httGm25uK7jTQRAfZMmKb3AVMJvcIslHEtcneTF2S805dqihjT+0W42/NlAJ75rSQBIK iOL9Q1Hb3Ov/wAZQDrAJrHlNcx8vOoK0N5hsUxWdQ3YMhITF7Wb6ZKR16XW7r/96n3aY PgZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1si513486ota.259.2020.02.17.10.22.17; Mon, 17 Feb 2020 10:22:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729753AbgBQRsO convert rfc822-to-8bit (ORCPT + 99 others); Mon, 17 Feb 2020 12:48:14 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:60719 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728889AbgBQRsO (ORCPT ); Mon, 17 Feb 2020 12:48:14 -0500 Received: from [192.168.1.183] ([37.4.249.150]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MpUQk-1jowEF3hTY-00pw6F; Mon, 17 Feb 2020 18:47:51 +0100 Subject: Re: [PATCH] usb: xhci-pci: Raspberry Pi FW loader for VIA VL805 To: Nicolas Saenz Julienne , Mathias Nyman , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com Cc: linux-usb@vger.kernel.org, Greg Kroah-Hartman , oneukum@suse.com, linux-kernel@vger.kernel.org, tim.gover@raspberrypi.org, linux-rpi-kernel@lists.infradead.org, phil@raspberrypi.com, linux-arm-kernel@lists.infradead.org References: <20200217100701.19949-1-nsaenzjulienne@suse.de> From: Stefan Wahren Openpgp: preference=signencrypt Autocrypt: addr=stefan.wahren@i2se.com; keydata= xsFNBFt6gBMBEACub/pBevHxbvJefyZG32JINmn2bsEPX25V6fejmyYwmCGKjFtL/DoUMEVH DxCJ47BMXo344fHV1C3AnudgN1BehLoBtLHxmneCzgH3KcPtWW7ptj4GtJv9CQDZy27SKoEP xyaI8CF0ygRxJc72M9I9wmsPZ5bUHsLuYWMqQ7JcRmPs6D8gBkk+8/yngEyNExwxJpR1ylj5 bjxWDHyYQvuJ5LzZKuO9LB3lXVsc4bqXEjc6VFuZFCCk/syio/Yhse8N+Qsx7MQagz4wKUkQ QbfXg1VqkTnAivXs42VnIkmu5gzIw/0tRJv50FRhHhxpyKAI8B8nhN8Qvx7MVkPc5vDfd3uG YW47JPhVQBcUwJwNk/49F9eAvg2mtMPFnFORkWURvP+G6FJfm6+CvOv7YfP1uewAi4ln+JO1 g+gjVIWl/WJpy0nTipdfeH9dHkgSifQunYcucisMyoRbF955tCgkEY9EMEdY1t8iGDiCgX6s 50LHbi3k453uacpxfQXSaAwPksl8MkCOsv2eEr4INCHYQDyZiclBuuCg8ENbR6AGVtZSPcQb enzSzKRZoO9CaqID+favLiB/dhzmHA+9bgIhmXfvXRLDZze8po1dyt3E1shXiddZPA8NuJVz EIt2lmI6V8pZDpn221rfKjivRQiaos54TgZjjMYI7nnJ7e6xzwARAQABzSlTdGVmYW4gV2Fo cmVuIDxzdGVmYW4ud2FocmVuQGluLXRlY2guY29tPsLBdwQTAQgAIQUCXIdehwIbAwULCQgH AgYVCAkKCwIEFgIDAQIeAQIXgAAKCRCUgewPEZDy2yHTD/9UF7QlDkGxzQ7AaCI6N95iQf8/ 1oSUaDNu2Y6IK+DzQpb1TbTOr3VJwwY8a3OWz5NLSOLMWeVxt+osMmlQIGubD3ODZJ8izPlG /JrNt5zSdmN5IA5f3esWWQVKvghZAgTDqdpv+ZHW2EmxnAJ1uLFXXeQd3UZ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zHyYcc8qDLFvG9FPhmQuT2s9Blx6gI 323GnEq1lwWPJVzP4jQkJKIAXwFpv+W8CWLqzDWOvdlrDaTaVMscFTeH5W6Uprl65jqFQGMp cRGCs8GCUW13H0IyOtQtwWXA4ny+SL81pviAmaSXU8laKaRu91VOVaF9f4sAEQEAAcLBXwQY AQIACQUCW3qAEwIbDAAKCRCUgewPEZDy2+oXD/9cHHRkBZOfkmSq14Svx062PtU0KV470TSn p/jWoYJnKIw3G0mXIRgrtH2dPwpIgVjsYyRSVMKmSpt5ZrDf9NtTbNWgk8VoLeZzYEo+J3oP qFrTMs3aYYv7e4+JK695YnmQ+mOD9nia915tr5AZj95UfSTlyUmyic1d8ovsf1fP7XCUVRFc RjfNfDF1oL/pDgMP5GZ2OwaTejmyCuHjM8IR1CiavBpYDmBnTYk7Pthy6atWvYl0fy/CqajT Ksx7+p9xziu8ZfVX+iKBCc+He+EDEdGIDhvNZ/IQHfOB2PUXWGS+s9FNTxr/A6nLGXnA9Y6w 93iPdYIwxS7KXLoKJee10DjlzsYsRflFOW0ZOiSihICXiQV1uqM6tzFG9gtRcius5UAthWaO 1OwUSCQmfCOm4fvMIJIA9rxtoS6OqRQciF3crmo0rJCtN2awZfgi8XEif7d6hjv0EKM9XZoi AZYZD+/iLm5TaKWN6oGIti0VjJv8ZZOZOfCb6vqFIkJW+aOu4orTLFMz28aoU3QyWpNC8FFm dYsVua8s6gN1NIa6y3qa/ZB8bA/iky59AEz4iDIRrgUzMEg8Ak7Tfm1KiYeiTtBDCo25BvXj bqsyxkQD1nkRm6FAVzEuOPIe8JuqW2xD9ixGYvjU5hkRgJp3gP5b+cnG3LPqquQ2E6goKUML AQ== Message-ID: Date: Mon, 17 Feb 2020 18:47:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20200217100701.19949-1-nsaenzjulienne@suse.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Content-Language: en-US X-Provags-ID: V03:K1:MEb+cWca3hrW4nDZ1ggAgFk9coBvX+/65EOeZDFWM3YU2lCE+4z CCfBEJUUKkrd8L/4PY7EkBKjZXrhu32tNcDRrjg56fDdcT2HzI+AwBEoBgZVhniQNzy6LC3 vGIOE+c++1IckNzQa5YhE43tZRPZeoAE2ORAgaVMGIKjj/CbYtDdW6OUaHVoseC0DyHLYe0 ejGE14WZ9wqBihuviT8RA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:CtL1K4btfg8=:b0MJWvqdGLbwBJHopp8Gjc qsJ0ntfLMykISUkWPD0JlJVXJ2/yHpHMSCm7tYteY65wDgapLBWxAiSfVZeIohXvSTazvkkfz 4udwZDxnW2sUSGsehbUy6sPWW1fyePxQcWinLlsXS2xV3WTTDrRM0bmBFbhUzFINc4GFWQ8Tj t372TSdmNb6TZYJFzpnrvix1110aCgcYdaEKTrMt+YIYnxoLXdtM72agogIzw0SAmvl7mSWsk +ecYM/86NfwtMMvzYMRBST1VKbbBJKQ0bm6Qtt2at4cKkDTdKYuYMdrj26IZ5UUFMnsjDQOcs elc9vUJWtWZkVJwi8/IUHznIUsFGB+UQWHTvhId4dcs6i725+UDHD6wpy98v0ex+DLByL+mFR nQTeLZSbpRs9AUQqqhAOykM6H3VXmoCXP0aDTMEnbXRPmMSj7R3DSe11u0Jz1xBVeB/N2/WBF cf7zpKKCfF9A8CLkJ7lFeV4fmXPi0eY1X1wG/h1YMuY8NY0p6DQXbvLQlKLHXBCmQjagD07J9 0Jy5SOaRKb0lMz0KXzXBiveE+amPWGAhAI+AE3FCAgePEmLaFKyF5VqdLhO5Zv+m10tdFdOEb bga7zeSu/xtXenvOg1QoQoP7xapQo0NEt6eIW6JVtELZKA64QsRlOR0u2J669wktqWcNEwMHm ovUP/lrKZ9dt8BfAqIx5oG7CZlKUtlAOs5Y15aIvypLcYQLUJ/5VtGjz1V/XLbY5a2jlkU6iE RYSbN4NDG28IX35ztFa4Y2RXYhvERkEfjaV6zeeD6+AGHoNaUlYaTWq8hsWS5SIiYTPowi+TP u3fKJ1HlgahtFGLqpLGF2z/lZQI+ArTyL+wLWbfn2vvTSkp+SXQ85+76vgdh6mkSp3U6bVx Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Nicolas, Am 17.02.20 um 11:07 schrieb Nicolas Saenz Julienne: > On the Raspberry Pi 4, after a PCI reset, VL805's firmware may either be > loaded directly from an EEPROM or, if not present, by the SoC's > VideCore. Inform VideCore that VL805 was just reset, or defer xhci's > probe if not yet joinable trough the mailbox interface. > > Based on Tim Gover's downstream implementation. > > Signed-off-by: Nicolas Saenz Julienne > --- > drivers/usb/host/xhci-pci.c | 50 ++++++++++++++++++++++ > include/soc/bcm2835/raspberrypi-firmware.h | 2 +- > 2 files changed, 51 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c > index 4917c5b033fa..eadace4a9339 100644 > --- a/drivers/usb/host/xhci-pci.c > +++ b/drivers/usb/host/xhci-pci.c > @@ -13,6 +13,8 @@ > #include > #include > > +#include > + > #include "xhci.h" > #include "xhci-trace.h" > > @@ -308,6 +310,44 @@ static int xhci_pci_setup(struct usb_hcd *hcd) > return xhci_pci_reinit(xhci, pdev); > } > > +/* > + * On the Raspberry Pi 4, after a PCI reset, VL805's firmware may either be > + * loaded directly from an EEPROM or, if not present, by the SoC's VideCore. > + * Inform VideCore that VL805 was just reset, or defer xhci's probe if not yet > + * joinable trough the mailbox interface. > + */ > +static int raspberrypi_load_vl805_fw(struct pci_dev *pdev) > +{ > +#ifdef CONFIG_RASPBERRYPI_FIRMWARE > + struct device_node *fw_np; > + struct rpi_firmware *fw; > + u32 dev_addr; > + int ret; > + > + fw_np = of_find_compatible_node(NULL, NULL, > + "raspberrypi,bcm2835-firmware"); > + if (!fw_np) > + return 0; > + > + fw = rpi_firmware_get(fw_np); > + of_node_put(fw_np); > + if (!fw) > + return -EPROBE_DEFER; > + > + dev_addr = pdev->bus->number << 20 | PCI_SLOT(pdev->devfn) << 15 | > + PCI_FUNC(pdev->devfn) << 12; > + > + ret = rpi_firmware_property(fw, RPI_FIRMWARE_NOTIFY_XHCI_RESET, > + &dev_addr, sizeof(dev_addr)); > + if (ret) > + return ret; not sure, but there could be a corner case which should be handled differently. In case the Raspberry Pi 4 has an EEPROM for the VL805 firmware but the firmware is too old to handle RPI_FIRMWARE_NOTIFY_XHCI_RESET, we should return with 0. I don't know there is a change to detect this reliable. I just want to mention this. > + > + dev_dbg(&pdev->dev, "loaded Raspberry Pi's VL805 firmware\n"); > + > +#endif > + return 0; > +} > + > /* > * We need to register our own PCI probe function (instead of the USB core's > * function) in order to create a second roothub under xHCI. > @@ -321,6 +361,16 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) > > driver = (struct hc_driver *)id->driver_data; > > + if (dev->vendor == PCI_VENDOR_ID_VIA && dev->device == 0x3483) { > + retval = raspberrypi_load_vl805_fw(dev); > + if (retval) { > + if (retval != -EPROBE_DEFER) > + dev_err(&dev->dev, > + "Failed to load VL805's firmware"); > + return retval; > + } > + } > + > /* Prevent runtime suspending between USB-2 and USB-3 initialization */ > pm_runtime_get_noresume(&dev->dev); > > diff --git a/include/soc/bcm2835/raspberrypi-firmware.h b/include/soc/bcm2835/raspberrypi-firmware.h > index 7800e12ee042..cc9cdbc66403 100644 > --- a/include/soc/bcm2835/raspberrypi-firmware.h > +++ b/include/soc/bcm2835/raspberrypi-firmware.h > @@ -90,7 +90,7 @@ enum rpi_firmware_property_tag { > RPI_FIRMWARE_SET_PERIPH_REG = 0x00038045, > RPI_FIRMWARE_GET_POE_HAT_VAL = 0x00030049, > RPI_FIRMWARE_SET_POE_HAT_VAL = 0x00030050, > - > + RPI_FIRMWARE_NOTIFY_XHCI_RESET = 0x00030058, In past we updated the firmware mailbox property interface in a bunch as a separate patch. So we can avoid those gaps. Best regards Stefan > > /* Dispmanx TAGS */ > RPI_FIRMWARE_FRAMEBUFFER_ALLOCATE = 0x00040001,